Index: ossp-pkg/uuid/ChangeLog RCS File: /v/ossp/cvs/ossp-pkg/uuid/Attic/ChangeLog,v rcsdiff -q -kk '-r1.155' '-r1.156' -u '/v/ossp/cvs/ossp-pkg/uuid/Attic/ChangeLog,v' 2>/dev/null --- ChangeLog 2008/03/06 10:04:48 1.155 +++ ChangeLog 2008/03/06 12:14:49 1.156 @@ -13,6 +13,14 @@ Changes between 1.6.1 and 1.6.2 (21-Feb-2008 to 06-Mar-2008) + o Remove unused "struct timezone" from time_gettimeofday() in + order to simplify portability. + [Ralf S. Engelschall] + + o Add support for POSIX clock_gettime(3) in case the Unix/POSIX + gettimeofday(3) is not available. + [Ralf S. Engelschall] + o Upgrade build environment to GNU libtool 2.2. [Ralf S. Engelschall] Index: ossp-pkg/uuid/uuid.ac RCS File: /v/ossp/cvs/ossp-pkg/uuid/Attic/uuid.ac,v rcsdiff -q -kk '-r1.25' '-r1.26' -u '/v/ossp/cvs/ossp-pkg/uuid/Attic/uuid.ac,v' 2>/dev/null --- uuid.ac 2008/02/21 15:34:51 1.25 +++ uuid.ac 2008/03/06 12:14:49 1.26 @@ -76,27 +76,9 @@ AC_DEFINE(HAVE_STRUCT_TIMEVAL, 1, [define if exists "struct timeval"]) fi AC_MSG_RESULT([$msg]) - AC_MSG_CHECKING(for struct timezone) - AC_TRY_COMPILE([ -#ifdef HAVE_UNISTD_H -#include -#endif -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_SYS_TIME_H -#include -#endif -#include - ],[ struct timezone tz; ], - [ msg="yes" ], [ msg="no" ]) - if test ".$msg" = .yes; then - AC_DEFINE(HAVE_STRUCT_TIMEZONE, 1, [define if exists "struct timezone"]) - fi - AC_MSG_RESULT([$msg]) dnl # check for functions - AC_CHECK_FUNCS(getifaddrs nanosleep Sleep) + AC_CHECK_FUNCS(getifaddrs nanosleep Sleep gettimeofday clock_gettime) dnl # check size of built-in types AC_CHECK_TYPES([long long, long double]) Index: ossp-pkg/uuid/uuid.c RCS File: /v/ossp/cvs/ossp-pkg/uuid/Attic/uuid.c,v rcsdiff -q -kk '-r1.66' '-r1.67' -u '/v/ossp/cvs/ossp-pkg/uuid/Attic/uuid.c,v' 2>/dev/null --- uuid.c 2008/02/21 08:58:45 1.66 +++ uuid.c 2008/03/06 12:14:49 1.67 @@ -886,7 +886,7 @@ /* determine current system time and sequence counter */ for (;;) { /* determine current system time */ - if (time_gettimeofday(&time_now, NULL) == -1) + if (time_gettimeofday(&time_now) == -1) return UUID_RC_SYS; /* check whether system time changed since last retrieve */ Index: ossp-pkg/uuid/uuid_prng.c RCS File: /v/ossp/cvs/ossp-pkg/uuid/Attic/uuid_prng.c,v rcsdiff -q -kk '-r1.18' '-r1.19' -u '/v/ossp/cvs/ossp-pkg/uuid/Attic/uuid_prng.c,v' 2>/dev/null --- uuid_prng.c 2008/02/21 15:34:51 1.18 +++ uuid_prng.c 2008/03/06 12:14:49 1.19 @@ -87,7 +87,7 @@ (*prng)->cnt = 0; /* seed the C library PRNG once */ - (void)time_gettimeofday(&tv, NULL); + (void)time_gettimeofday(&tv); pid = getpid(); srand((unsigned int)( ((unsigned int)pid << 16) @@ -142,9 +142,9 @@ /* approach 2: try to gather data via weaker libc PRNG API. */ while (n > 0) { /* gather new entropy */ - (void)time_gettimeofday(&(entropy.tv), NULL); /* source: libc time */ - entropy.rnd = rand(); /* source: libc PRNG */ - entropy.cnt = prng->cnt++; /* source: local counter */ + (void)time_gettimeofday(&(entropy.tv)); /* source: libc time */ + entropy.rnd = rand(); /* source: libc PRNG */ + entropy.cnt = prng->cnt++; /* source: local counter */ /* pass entropy into MD5 engine */ if (md5_update(prng->md5, (void *)&entropy, sizeof(entropy)) != MD5_RC_OK) Index: ossp-pkg/uuid/uuid_time.c RCS File: /v/ossp/cvs/ossp-pkg/uuid/Attic/uuid_time.c,v rcsdiff -q -kk '-r1.1' '-r1.2' -u '/v/ossp/cvs/ossp-pkg/uuid/Attic/uuid_time.c,v' 2>/dev/null --- uuid_time.c 2008/02/21 08:58:45 1.1 +++ uuid_time.c 2008/03/06 12:14:49 1.2 @@ -47,16 +47,28 @@ /* own headers (part (1/2) */ #include "uuid_time.h" -/* POSIX gettimeofday(2) abstraction */ -int time_gettimeofday(struct timeval *tv, struct timezone *tz) +/* POSIX gettimeofday(2) abstraction (without timezone) */ +int time_gettimeofday(struct timeval *tv) { -#if defined(WIN32) +#if defined(HAVE_GETTIMEOFDAY) + /* Unix/POSIX pass-through */ + return gettimeofday(tv, NULL); +#elif defined(HAVE_CLOCK_GETTIME) + /* POSIX emulation */ + struct timespec ts; + if (clock_gettime(CLOCK_MONOTONIC, &ts) == -1) + return -1; + if (tv != NULL) { + tv->tv_sec = (long)ts.tv_sec; + tv->tv_usec = (long)ts.tv_nsec / 1000; + } + return 0; +#elif defined(WIN32) /* Windows emulation */ FILETIME ft; LARGE_INTEGER li; __int64 t; static int tzflag; - #if !defined(__GNUC__) #define EPOCHFILETIME 116444736000000000i64 #else @@ -72,18 +84,9 @@ tv->tv_sec = (long)(t / 1000000); tv->tv_usec = (long)(t % 1000000); } - if (tz != NULL) { - if (!tzflag) { - _tzset(); - tzflag++; - } - tz->tz_minuteswest = _timezone / 60; - tz->tz_dsttime = _daylight; - } return 0; #else - /* POSIX pass-through */ - return gettimeofday(tv, tz); +#error neither Win32 GetSystemTimeAsFileTime() nor Unix gettimeofday() nor POSIX clock_gettime() available! #endif } Index: ossp-pkg/uuid/uuid_time.h RCS File: /v/ossp/cvs/ossp-pkg/uuid/Attic/uuid_time.h,v rcsdiff -q -kk '-r1.2' '-r1.3' -u '/v/ossp/cvs/ossp-pkg/uuid/Attic/uuid_time.h,v' 2>/dev/null --- uuid_time.h 2008/02/21 15:34:51 1.2 +++ uuid_time.h 2008/03/06 12:14:49 1.3 @@ -47,11 +47,8 @@ #ifndef HAVE_STRUCT_TIMEVAL struct timeval { long tv_sec; long tv_usec; }; #endif -#ifndef HAVE_STRUCT_TIMEZONE -struct timezone { int tz_minuteswest; int tz_dsttime; }; -#endif -extern int time_gettimeofday(struct timeval *, struct timezone *); +extern int time_gettimeofday(struct timeval *); extern int time_usleep(long usec); #endif /* __UUID_TIME_H__ */