about summary refs log tree commit diff
path: root/nptl/sysdeps/pthread/timer_gettime.c
diff options
context:
space:
mode:
Diffstat (limited to 'nptl/sysdeps/pthread/timer_gettime.c')
-rw-r--r--nptl/sysdeps/pthread/timer_gettime.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/nptl/sysdeps/pthread/timer_gettime.c b/nptl/sysdeps/pthread/timer_gettime.c
index 99a080311c..723a61632f 100644
--- a/nptl/sysdeps/pthread/timer_gettime.c
+++ b/nptl/sysdeps/pthread/timer_gettime.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000 Free Software Foundation, Inc.
+/* Copyright (C) 2000, 2004 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Kaz Kylheku <kaz@ashi.footprints.net>.
 
@@ -54,7 +54,13 @@ timer_gettime (timerid, value)
       if (armed)
 	{
 	  clock_gettime (clock, &now);
-	  timespec_sub (&value->it_value, &expiry, &now);
+	  if (timespec_compare (&now, &expiry) < 0)
+	    timespec_sub (&value->it_value, &expiry, &now);
+	  else
+	    {
+	      value->it_value.tv_sec = 0;
+	      value->it_value.tv_nsec = 0;
+	    }
 	}
       else
 	{