Sha256: 03824151a2c9621ce56a23f6f0273253ac83bb6703641c5b9c8f9606cf605fdb

Contents?: true

Size: 848 Bytes

Versions: 22

Compression:

Stored size: 848 Bytes

Contents

/*
 * this header includes functions to support broken systems
 * without clock_gettime() or CLOCK_MONOTONIC
 */

#ifndef HAVE_TYPE_CLOCKID_T
typedef int clockid_t;
#endif

#ifndef HAVE_CLOCK_GETTIME
#  ifndef CLOCK_REALTIME
#    define CLOCK_REALTIME 0 /* whatever */
#  endif
static int fake_clock_gettime(clockid_t clk_id, struct timespec *res)
{
	struct timeval tv;
	int r = gettimeofday(&tv, NULL);

	assert(0 == r && "gettimeofday() broke!?");
	res->tv_sec = tv.tv_sec;
	res->tv_nsec = tv.tv_usec * 1000;

	return r;
}
#  define clock_gettime fake_clock_gettime
#endif /* broken systems w/o clock_gettime() */

/*
 * UGH
 * CLOCK_MONOTONIC is not guaranteed to be a macro, either
 */
#ifndef CLOCK_MONOTONIC
#  if (!defined(_POSIX_MONOTONIC_CLOCK) || !defined(HAVE_CLOCK_MONOTONIC))
#    define CLOCK_MONOTONIC CLOCK_REALTIME
#  endif
#endif

Version data entries

22 entries across 22 versions & 2 rubygems

Version Path
clogger-2.4.0 ext/clogger_ext/broken_system_compat.h
clogger-2.3.1 ext/clogger_ext/broken_system_compat.h
clogger-2.3.0 ext/clogger_ext/broken_system_compat.h
sleepy_penguin-3.5.2 ext/sleepy_penguin/missing_clock_gettime.h
clogger-2.2.1 ext/clogger_ext/broken_system_compat.h
sleepy_penguin-3.5.1 ext/sleepy_penguin/missing_clock_gettime.h
clogger-2.2.0 ext/clogger_ext/broken_system_compat.h
sleepy_penguin-3.5.0 ext/sleepy_penguin/missing_clock_gettime.h
clogger-2.1.0 ext/clogger_ext/broken_system_compat.h
clogger-2.0.2 ext/clogger_ext/broken_system_compat.h
clogger-2.0.1 ext/clogger_ext/broken_system_compat.h
sleepy_penguin-3.4.1 ext/sleepy_penguin/missing_clock_gettime.h
clogger-2.0.0 ext/clogger_ext/broken_system_compat.h
sleepy_penguin-3.3.0 ext/sleepy_penguin/missing_clock_gettime.h
clogger-1.3.0 ext/clogger_ext/broken_system_compat.h
clogger-1.2.0 ext/clogger_ext/broken_system_compat.h
clogger-1.1.0 ext/clogger_ext/broken_system_compat.h
clogger-1.0.1 ext/clogger_ext/broken_system_compat.h
clogger-1.0.0 ext/clogger_ext/broken_system_compat.h
clogger-0.9.0 ext/clogger_ext/broken_system_compat.h