]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
hurd: fix usleep(ULONG_MAX)
authorSamuel Thibault <samuel.thibault@ens-lyon.org>
Sun, 28 Jun 2020 22:39:03 +0000 (22:39 +0000)
committerSamuel Thibault <samuel.thibault@ens-lyon.org>
Sun, 28 Jun 2020 22:39:03 +0000 (22:39 +0000)
* sysdeps/mach/usleep.c (usleep): Clamp timeout when rouding up.

sysdeps/mach/usleep.c

index 530336ba0b8a9fdf2d8b8d03181d49b986c6b4c4..d53eb04a517448d1f2e122e6f6f23d10ba3d560f 100644 (file)
@@ -25,11 +25,15 @@ int
 usleep (useconds_t useconds)
 {
   mach_port_t recv;
+  useconds_t useconds_up = useconds + 999;
+
+  if (useconds_up < useconds)
+    useconds_up = UINT32_MAX;
 
   recv = __mach_reply_port ();
 
   (void) __mach_msg (NULL, MACH_RCV_MSG|MACH_RCV_TIMEOUT|MACH_RCV_INTERRUPT,
-                    0, 0, recv, (useconds + 999) / 1000, MACH_PORT_NULL);
+                    0, 0, recv, useconds_up / 1000, MACH_PORT_NULL);
   __mach_port_destroy (mach_task_self (), recv);
 
   return 0;