struct timespec normalization
Thomas Schwinge
thomas@codesourcery.com
Mon Feb 6 14:36:00 GMT 2012
Hi!
Fix struct timespec normalization (as used in many other places).
2012-01-24 Thomas Schwinge <thomas@codesourcery.com>
* resolv/gai_misc.c (handle_requests): Fix struct timespec
normalization.
* rt/tst-cpuclock2.c (test_nanosleep): Likewise.
* sysdeps/pthread/aio_misc.c (handle_fildes_io): Likewise.
diff --git a/resolv/gai_misc.c b/resolv/gai_misc.c
index 2eec0f5..8bbe3d1 100644
--- a/resolv/gai_misc.c
+++ b/resolv/gai_misc.c
@@ -1,5 +1,5 @@
-/* Copyright (C) 2001, 2006 Free Software Foundation, Inc.
+/* Copyright (C) 2001, 2006, 2012 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2001.
The GNU C Library is free software; you can redistribute it and/or
@@ -364,9 +364,9 @@ handle_requests (void *arg)
++idle_thread_count;
gettimeofday (&now, NULL);
wakeup_time.tv_sec = now.tv_sec + optim.gai_idle_time;
wakeup_time.tv_nsec = now.tv_usec * 1000;
- if (wakeup_time.tv_nsec > 1000000000)
+ if (wakeup_time.tv_nsec >= 1000000000)
{
wakeup_time.tv_nsec -= 1000000000;
++wakeup_time.tv_sec;
}
diff --git a/rt/tst-cpuclock2.c b/rt/tst-cpuclock2.c
index d1621f3..19c35ce 100644
--- a/rt/tst-cpuclock2.c
+++ b/rt/tst-cpuclock2.c
@@ -1,6 +1,6 @@
/* Test program for process and thread CPU clocks.
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2012 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -110,9 +110,9 @@ test_nanosleep (clockid_t clock, const char *which,
struct timespec sleeptimeabs = sleeptime;
sleeptimeabs.tv_sec += after.tv_sec;
sleeptimeabs.tv_nsec += after.tv_nsec;
- while (sleeptimeabs.tv_nsec > 1000000000)
+ while (sleeptimeabs.tv_nsec >= 1000000000)
{
++sleeptimeabs.tv_sec;
sleeptimeabs.tv_nsec -= 1000000000;
}
diff --git a/sysdeps/pthread/aio_misc.c b/sysdeps/pthread/aio_misc.c
index ca3d111..15e3167 100644
--- a/sysdeps/pthread/aio_misc.c
+++ b/sysdeps/pthread/aio_misc.c
@@ -1,6 +1,6 @@
/* Handle general operations.
- Copyright (C) 1997-2001, 2003, 2004, 2006, 2007, 2009, 2011
+ Copyright (C) 1997-2001, 2003, 2004, 2006, 2007, 2009, 2011, 2012
Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -635,9 +635,9 @@ handle_fildes_io (void *arg)
++idle_thread_count;
gettimeofday (&now, NULL);
wakeup_time.tv_sec = now.tv_sec + optim.aio_idle_time;
wakeup_time.tv_nsec = now.tv_usec * 1000;
- if (wakeup_time.tv_nsec > 1000000000)
+ if (wakeup_time.tv_nsec >= 1000000000)
{
wakeup_time.tv_nsec -= 1000000000;
++wakeup_time.tv_sec;
}
Grüße,
Thomas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 489 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20120206/2aa8fbc7/attachment.sig>
More information about the Libc-alpha
mailing list