Check-in Number:
|
5993 | |
Date: |
2008-Mar-06 13:14:49 (local)
2008-Mar-06 12:14:49 (UTC) |
User: | rse |
Branch: | |
Comment: |
1. Remove unused "struct timezone" from time_gettimeofday() in
order to simplify portability.
2. Add support for POSIX clock_gettime(3) in case the Unix/POSIX
gettimeofday(3) is not available. |
Tickets: |
|
Inspections: |
|
Files: |
|
ossp-pkg/uuid/ChangeLog 1.155 -> 1.156
--- 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]
|
|
ossp-pkg/uuid/uuid.ac 1.25 -> 1.26
--- 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 <unistd.h>
-#endif
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-#ifdef HAVE_SYS_TIME_H
-#include <sys/time.h>
-#endif
-#include <time.h>
- ],[ 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])
|
|
ossp-pkg/uuid/uuid.c 1.66 -> 1.67
--- 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 */
|
|
ossp-pkg/uuid/uuid_prng.c 1.18 -> 1.19
--- 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)
|
|
ossp-pkg/uuid/uuid_time.c 1.1 -> 1.2
--- 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
}
|
|
ossp-pkg/uuid/uuid_time.h 1.2 -> 1.3
--- 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__ */
|
|