aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--inet/deadline.c8
-rw-r--r--login/logout.c9
-rw-r--r--login/logwtmp.c7
-rw-r--r--nis/nis_call.c4
-rw-r--r--nptl/pthread_join_common.c7
-rw-r--r--nptl/pthread_mutex_timedlock.c7
-rw-r--r--nscd/nscd_helper.c24
-rw-r--r--resolv/gai_misc.c6
-rw-r--r--resolv/gai_suspend.c6
-rw-r--r--resolv/res_send.c7
-rw-r--r--sunrpc/auth_des.c19
-rw-r--r--sunrpc/auth_unix.c9
-rw-r--r--sunrpc/create_xid.c6
-rw-r--r--sunrpc/svcauth_des.c7
-rw-r--r--support/support_test_main.c23
-rw-r--r--sysdeps/generic/memusage.h16
-rw-r--r--sysdeps/mach/hurd/getitimer.c11
-rw-r--r--sysdeps/mach/hurd/setitimer.c13
-rw-r--r--sysdeps/mach/hurd/times.c7
-rw-r--r--sysdeps/mach/nanosleep.c36
-rw-r--r--sysdeps/mach/usleep.c5
-rw-r--r--sysdeps/posix/tempname.c9
-rw-r--r--sysdeps/posix/timespec_get.c14
-rw-r--r--sysdeps/pthread/aio_misc.c6
-rw-r--r--sysdeps/pthread/aio_suspend.c6
-rw-r--r--sysdeps/unix/make-syscalls.sh2
26 files changed, 137 insertions, 137 deletions
diff --git a/inet/deadline.c b/inet/deadline.c
index 6051f1fe0c..541c16bd9a 100644
--- a/inet/deadline.c
+++ b/inet/deadline.c
@@ -29,13 +29,7 @@ __deadline_current_time (void)
{
struct deadline_current_time result;
if (__clock_gettime (CLOCK_MONOTONIC, &result.current) != 0)
- {
- struct timeval current_tv;
- if (__gettimeofday (&current_tv, NULL) == 0)
- __libc_fatal ("Fatal error: gettimeofday system call failed\n");
- result.current.tv_sec = current_tv.tv_sec;
- result.current.tv_nsec = current_tv.tv_usec * 1000;
- }
+ __clock_gettime (CLOCK_REALTIME, &result.current);
assert (result.current.tv_sec >= 0);
return result;
}
diff --git a/login/logout.c b/login/logout.c
index d0d421cbf7..b8b38df19d 100644
--- a/login/logout.c
+++ b/login/logout.c
@@ -19,6 +19,7 @@
#include <errno.h>
#include <string.h>
#include <utmp.h>
+#include <time.h>
#include <sys/time.h>
int
@@ -45,10 +46,10 @@ logout (const char *line)
/* Clear information about who & from where. */
memset (ut->ut_name, '\0', sizeof ut->ut_name);
memset (ut->ut_host, '\0', sizeof ut->ut_host);
- struct timeval tv;
- __gettimeofday (&tv, NULL);
- ut->ut_tv.tv_sec = tv.tv_sec;
- ut->ut_tv.tv_usec = tv.tv_usec;
+
+ struct timespec ts;
+ __clock_gettime (CLOCK_REALTIME, &ts);
+ TIMESPEC_TO_TIMEVAL (&ut->ut_tv, &ts);
ut->ut_type = DEAD_PROCESS;
if (pututline (ut) != NULL)
diff --git a/login/logwtmp.c b/login/logwtmp.c
index 654f412ecb..eddba96f35 100644
--- a/login/logwtmp.c
+++ b/login/logwtmp.c
@@ -36,10 +36,9 @@ logwtmp (const char *line, const char *name, const char *host)
strncpy (ut.ut_name, name, sizeof ut.ut_name);
strncpy (ut.ut_host, host, sizeof ut.ut_host);
- struct timeval tv;
- __gettimeofday (&tv, NULL);
- ut.ut_tv.tv_sec = tv.tv_sec;
- ut.ut_tv.tv_usec = tv.tv_usec;
+ struct timespec ts;
+ __clock_gettime (CLOCK_REALTIME, &ts);
+ TIMESPEC_TO_TIMEVAL (&ut.ut_tv, &ts);
updwtmp (_PATH_WTMP, &ut);
}
diff --git a/nis/nis_call.c b/nis/nis_call.c
index 1684de1c6d..5097e614ea 100644
--- a/nis/nis_call.c
+++ b/nis/nis_call.c
@@ -709,6 +709,7 @@ __nisfind_server (const_nis_name name, int search_parent,
nis_error status;
directory_obj *obj;
struct timeval now;
+ struct timespec ts;
unsigned int server_used = ~0;
unsigned int current_ep = ~0;
@@ -718,7 +719,8 @@ __nisfind_server (const_nis_name name, int search_parent,
if (*dir != NULL)
return NIS_SUCCESS;
- (void) gettimeofday (&now, NULL);
+ __clock_gettime (CLOCK_REALTIME, &ts);
+ TIMESPEC_TO_TIMEVAL (&now, &ts);
if ((flags & NO_CACHE) == 0)
*dir = nis_server_cache_search (name, search_parent, &server_used,
diff --git a/nptl/pthread_join_common.c b/nptl/pthread_join_common.c
index 8b55c380e9..4d91c6fbf2 100644
--- a/nptl/pthread_join_common.c
+++ b/nptl/pthread_join_common.c
@@ -47,15 +47,14 @@ timedwait_tid (pid_t *tidp, const struct timespec *abstime)
/* Repeat until thread terminated. */
while ((tid = *tidp) != 0)
{
- struct timeval tv;
struct timespec rt;
/* Get the current time. */
- __gettimeofday (&tv, NULL);
+ __clock_gettime (CLOCK_REALTIME, &rt);
/* Compute relative timeout. */
- rt.tv_sec = abstime->tv_sec - tv.tv_sec;
- rt.tv_nsec = abstime->tv_nsec - tv.tv_usec * 1000;
+ rt.tv_sec = abstime->tv_sec - rt.tv_sec;
+ rt.tv_nsec = abstime->tv_nsec - rt.tv_nsec;
if (rt.tv_nsec < 0)
{
rt.tv_nsec += 1000000000;
diff --git a/nptl/pthread_mutex_timedlock.c b/nptl/pthread_mutex_timedlock.c
index c9bb3b9176..d6f0d9e31a 100644
--- a/nptl/pthread_mutex_timedlock.c
+++ b/nptl/pthread_mutex_timedlock.c
@@ -567,15 +567,14 @@ __pthread_mutex_clocklock_common (pthread_mutex_t *mutex,
goto failpp;
}
- struct timeval tv;
struct timespec rt;
/* Get the current time. */
- (void) __gettimeofday (&tv, NULL);
+ __clock_gettime (CLOCK_REALTIME, &rt);
/* Compute relative timeout. */
- rt.tv_sec = abstime->tv_sec - tv.tv_sec;
- rt.tv_nsec = abstime->tv_nsec - tv.tv_usec * 1000;
+ rt.tv_sec = abstime->tv_sec - rt.tv_sec;
+ rt.tv_nsec = abstime->tv_nsec - rt.tv_nsec;
if (rt.tv_nsec < 0)
{
rt.tv_nsec += 1000000000;
diff --git a/nscd/nscd_helper.c b/nscd/nscd_helper.c
index d326a380ee..7361fe2e0a 100644
--- a/nscd/nscd_helper.c
+++ b/nscd/nscd_helper.c
@@ -59,9 +59,10 @@ wait_on_socket (int sock, long int usectmo)
/* Handle the case where the poll() call is interrupted by a
signal. We cannot just use TEMP_FAILURE_RETRY since it might
lead to infinite loops. */
- struct timeval now;
- (void) __gettimeofday (&now, NULL);
- long int end = now.tv_sec * 1000 + usectmo + (now.tv_usec + 500) / 1000;
+ struct timespec now;
+ __clock_gettime (CLOCK_REALTIME, &now);
+ long int end = (now.tv_sec * 1000 + usectmo
+ + (now.tv_nsec + 500000) / 1000000);
long int timeout = usectmo;
while (1)
{
@@ -70,8 +71,9 @@ wait_on_socket (int sock, long int usectmo)
break;
/* Recompute the timeout time. */
- (void) __gettimeofday (&now, NULL);
- timeout = end - (now.tv_sec * 1000 + (now.tv_usec + 500) / 1000);
+ __clock_gettime (CLOCK_REALTIME, &now);
+ timeout = end - ((now.tv_sec * 1000
+ + (now.tv_nsec + 500000) / 1000000));
}
}
@@ -191,9 +193,7 @@ open_socket (request_type type, const char *key, size_t keylen)
memcpy (reqdata->key, key, keylen);
bool first_try = true;
- struct timeval tvend;
- /* Fake initializing tvend. */
- asm ("" : "=m" (tvend));
+ struct timespec tvend = { 0, 0 };
while (1)
{
#ifndef MSG_NOSIGNAL
@@ -212,18 +212,18 @@ open_socket (request_type type, const char *key, size_t keylen)
/* The daemon is busy wait for it. */
int to;
- struct timeval now;
- (void) __gettimeofday (&now, NULL);
+ struct timespec now;
+ __clock_gettime (CLOCK_REALTIME, &now);
if (first_try)
{
- tvend.tv_usec = now.tv_usec;
+ tvend.tv_nsec = now.tv_nsec;
tvend.tv_sec = now.tv_sec + 5;
to = 5 * 1000;
first_try = false;
}
else
to = ((tvend.tv_sec - now.tv_sec) * 1000
- + (tvend.tv_usec - now.tv_usec) / 1000);
+ + (tvend.tv_nsec - now.tv_nsec) / 1000000);
struct pollfd fds[1];
fds[0].fd = sock;
diff --git a/resolv/gai_misc.c b/resolv/gai_misc.c
index 8738359d81..760c33ac29 100644
--- a/resolv/gai_misc.c
+++ b/resolv/gai_misc.c
@@ -357,13 +357,13 @@ handle_requests (void *arg)
something to arrive in it. */
if (runp == NULL && optim.gai_idle_time >= 0)
{
- struct timeval now;
+ struct timespec now;
struct timespec wakeup_time;
++idle_thread_count;
- gettimeofday (&now, NULL);
+ __clock_gettime (CLOCK_REALTIME, &now);
wakeup_time.tv_sec = now.tv_sec + optim.gai_idle_time;
- wakeup_time.tv_nsec = now.tv_usec * 1000;
+ wakeup_time.tv_nsec = now.tv_nsec;
if (wakeup_time.tv_nsec >= 1000000000)
{
wakeup_time.tv_nsec -= 1000000000;
diff --git a/resolv/gai_suspend.c b/resolv/gai_suspend.c
index 16d6998980..b8c642bddc 100644
--- a/resolv/gai_suspend.c
+++ b/resolv/gai_suspend.c
@@ -91,11 +91,11 @@ gai_suspend (const struct gaicb *const list[], int ent,
{
/* We have to convert the relative timeout value into an
absolute time value with pthread_cond_timedwait expects. */
- struct timeval now;
+ struct timespec now;
struct timespec abstime;
- __gettimeofday (&now, NULL);
- abstime.tv_nsec = timeout->tv_nsec + now.tv_usec * 1000;
+ __clock_gettime (CLOCK_REALTIME, &now);
+ abstime.tv_nsec = timeout->tv_nsec + now.tv_nsec;
abstime.tv_sec = timeout->tv_sec + now.tv_sec;
if (abstime.tv_nsec >= 1000000000)
{
diff --git a/resolv/res_send.c b/resolv/res_send.c
index 6b9c73f820..47bfba6747 100644
--- a/resolv/res_send.c
+++ b/resolv/res_send.c
@@ -172,12 +172,7 @@ evCmpTime(struct timespec a, struct timespec b) {
static void
evNowTime(struct timespec *res) {
- struct timeval now;
-
- if (gettimeofday(&now, NULL) < 0)
- evConsTime(res, 0, 0);
- else
- TIMEVAL_TO_TIMESPEC (&now, res);
+ __clock_gettime(CLOCK_REALTIME, res);
}
diff --git a/sunrpc/auth_des.c b/sunrpc/auth_des.c
index 5b6f985bc2..d26820a701 100644
--- a/sunrpc/auth_des.c
+++ b/sunrpc/auth_des.c
@@ -41,6 +41,7 @@
#include <rpc/xdr.h>
#include <netinet/in.h> /* XXX: just to get htonl() and ntohl() */
#include <sys/socket.h>
+#include <time.h>
#include <shlib-compat.h>
#define MILLION 1000000L
@@ -246,15 +247,15 @@ authdes_marshal (AUTH *auth, XDR *xdrs)
int status;
int len;
register int32_t *ixdr;
- struct timeval tval;
+ struct timespec now;
/*
* Figure out the "time", accounting for any time difference
* with the server if necessary.
*/
- __gettimeofday (&tval, (struct timezone *) NULL);
- ad->ad_timestamp.tv_sec = tval.tv_sec + ad->ad_timediff.tv_sec;
- ad->ad_timestamp.tv_usec = tval.tv_usec + ad->ad_timediff.tv_usec;
+ __clock_gettime (CLOCK_REALTIME, &now);
+ ad->ad_timestamp.tv_sec = now.tv_sec + ad->ad_timediff.tv_sec;
+ ad->ad_timestamp.tv_usec = (now.tv_nsec / 1000) + ad->ad_timediff.tv_usec;
if (ad->ad_timestamp.tv_usec >= MILLION)
{
ad->ad_timestamp.tv_usec -= MILLION;
@@ -445,21 +446,23 @@ authdes_destroy (AUTH *auth)
static bool_t
synchronize (struct sockaddr *syncaddr, struct rpc_timeval *timep)
{
- struct timeval mytime;
+ struct timespec mytime;
struct rpc_timeval timeout;
+ long int myusec;
timeout.tv_sec = RTIME_TIMEOUT;
timeout.tv_usec = 0;
if (rtime ((struct sockaddr_in *) syncaddr, timep, &timeout) < 0)
return FALSE;
- __gettimeofday (&mytime, (struct timezone *) NULL);
+ __clock_gettime (CLOCK_REALTIME, &mytime);
timep->tv_sec -= mytime.tv_sec;
- if (mytime.tv_usec > timep->tv_usec)
+ myusec = mytime.tv_nsec / 1000;
+ if (myusec > timep->tv_usec)
{
timep->tv_sec -= 1;
timep->tv_usec += MILLION;
}
- timep->tv_usec -= mytime.tv_usec;
+ timep->tv_usec -= myusec;
return TRUE;
}
diff --git a/sunrpc/auth_unix.c b/sunrpc/auth_unix.c
index b035fdd870..ff0d2eb933 100644
--- a/sunrpc/auth_unix.c
+++ b/sunrpc/auth_unix.c
@@ -43,6 +43,7 @@
#include <stdio.h>
#include <string.h>
#include <unistd.h>
+#include <time.h>
#include <libintl.h>
#include <sys/param.h>
#include <wchar.h>
@@ -96,7 +97,7 @@ authunix_create (char *machname, uid_t uid, gid_t gid, int len,
{
struct authunix_parms aup;
char mymem[MAX_AUTH_BYTES];
- struct timeval now;
+ struct timespec now;
XDR xdrs;
AUTH *auth;
struct audata *au;
@@ -122,7 +123,7 @@ no_memory:
/*
* fill in param struct from the given params
*/
- (void) __gettimeofday (&now, (struct timezone *) 0);
+ __clock_gettime (CLOCK_REALTIME, &now);
aup.aup_time = now.tv_sec;
aup.aup_machname = machname;
aup.aup_uid = uid;
@@ -276,7 +277,7 @@ authunix_refresh (AUTH *auth)
{
struct audata *au = AUTH_PRIVATE (auth);
struct authunix_parms aup;
- struct timeval now;
+ struct timespec now;
XDR xdrs;
int stat;
@@ -297,7 +298,7 @@ authunix_refresh (AUTH *auth)
goto done;
/* update the time and serialize in place */
- (void) __gettimeofday (&now, (struct timezone *) 0);
+ __clock_gettime (CLOCK_REALTIME, &now);
aup.aup_time = now.tv_sec;
xdrs.x_op = XDR_ENCODE;
XDR_SETPOS (&xdrs, 0);
diff --git a/sunrpc/create_xid.c b/sunrpc/create_xid.c
index 1339615a1b..c692c1eb92 100644
--- a/sunrpc/create_xid.c
+++ b/sunrpc/create_xid.c
@@ -39,10 +39,10 @@ _create_xid (void)
pid_t pid = getpid ();
if (is_initialized != pid)
{
- struct timeval now;
+ struct timespec now;
- __gettimeofday (&now, (struct timezone *) 0);
- __srand48_r (now.tv_sec ^ now.tv_usec ^ pid,
+ __clock_gettime (CLOCK_REALTIME, &now);
+ __srand48_r (now.tv_sec ^ now.tv_nsec ^ pid,
&__rpc_lrand48_data);
is_initialized = pid;
}
diff --git a/sunrpc/svcauth_des.c b/sunrpc/svcauth_des.c
index c5a512d6f8..7607abc818 100644
--- a/sunrpc/svcauth_des.c
+++ b/sunrpc/svcauth_des.c
@@ -44,6 +44,7 @@
#include <limits.h>
#include <string.h>
#include <stdint.h>
+#include <time.h>
#include <sys/param.h>
#include <netinet/in.h>
#include <rpc/rpc.h>
@@ -295,7 +296,11 @@ _svcauth_des (register struct svc_req *rqst, register struct rpc_msg *msg)
debug ("timestamp before last seen");
return AUTH_REJECTEDVERF; /* replay */
}
- __gettimeofday (&current, (struct timezone *) NULL);
+ {
+ struct timespec now;
+ __clock_gettime (CLOCK_REALTIME, &now);
+ TIMESPEC_TO_TIMEVAL (&current, &now);
+ }
current.tv_sec -= window; /* allow for expiration */
if (!BEFORE (&current, &timestamp))
{
diff --git a/support/support_test_main.c b/support/support_test_main.c
index 0be1bd3d78..1df6e4f976 100644
--- a/support/support_test_main.c
+++ b/support/support_test_main.c
@@ -91,16 +91,18 @@ static pid_t test_pid;
static void (*cleanup_function) (void);
static void
-print_timestamp (const char *what, struct timeval tv)
+print_timestamp (const char *what, struct timespec tv)
{
struct tm tm;
+ /* Casts of tv.tv_nsec below are necessary because the type of
+ tv_nsec is not literally long int on all supported platforms. */
if (gmtime_r (&tv.tv_sec, &tm) == NULL)
- printf ("%s: %lld.%06d\n",
- what, (long long int) tv.tv_sec, (int) tv.tv_usec);
+ printf ("%s: %lld.%09ld\n",
+ what, (long long int) tv.tv_sec, (long int) tv.tv_nsec);
else
- printf ("%s: %04d-%02d-%02dT%02d:%02d:%02d.%06d\n",
+ printf ("%s: %04d-%02d-%02dT%02d:%02d:%02d.%09ld\n",
what, 1900 + tm.tm_year, tm.tm_mon + 1, tm.tm_mday,
- tm.tm_hour, tm.tm_min, tm.tm_sec, (int) tv.tv_usec);
+ tm.tm_hour, tm.tm_min, tm.tm_sec, (long int) tv.tv_nsec);
}
/* Timeout handler. We kill the child and exit with an error. */
@@ -113,8 +115,8 @@ signal_handler (int sig)
/* Do this first to avoid further interference from the
subprocess. */
- struct timeval now;
- bool now_available = gettimeofday (&now, NULL) == 0;
+ struct timespec now;
+ clock_gettime (CLOCK_REALTIME, &now);
struct stat64 st;
bool st_available = fstat64 (STDOUT_FILENO, &st) == 0 && st.st_mtime != 0;
@@ -168,12 +170,9 @@ signal_handler (int sig)
printf ("Timed out: killed the child process but it exited %d\n",
WEXITSTATUS (status));
- if (now_available)
- print_timestamp ("Termination time", now);
+ print_timestamp ("Termination time", now);
if (st_available)
- print_timestamp ("Last write to standard output",
- (struct timeval) { st.st_mtim.tv_sec,
- st.st_mtim.tv_nsec / 1000 });
+ print_timestamp ("Last write to standard output", st.st_mtim);
/* Exit with an error. */
exit (1);
diff --git a/sysdeps/generic/memusage.h b/sysdeps/generic/memusage.h
index 400fe23f29..88b291e3fa 100644
--- a/sysdeps/generic/memusage.h
+++ b/sysdeps/generic/memusage.h
@@ -26,14 +26,14 @@
#endif
#ifndef GETTIME
-# define GETTIME(low,high) \
- { \
- struct timeval tval; \
- uint64_t usecs; \
- gettimeofday (&tval, NULL); \
- usecs = (uint64_t) tval.tv_usec + (uint64_t) tval.tv_usec * 1000000; \
- low = usecs & 0xffffffff; \
- high = usecs >> 32; \
+# define GETTIME(low,high) \
+ { \
+ struct timespec now; \
+ uint64_t usecs; \
+ clock_gettime (CLOCK_REALTIME, &now); \
+ usecs = (uint64_t)now.tv_nsec / 1000 + (uint64_t)now.tv_sec * 1000000; \
+ low = usecs & 0xffffffff; \
+ high = usecs >> 32; \
}
#endif
diff --git a/sysdeps/mach/hurd/getitimer.c b/sysdeps/mach/hurd/getitimer.c
index f332f0e681..0982357815 100644
--- a/