Module Name: src Committed By: martin Date: Sun Apr 28 13:23:20 UTC 2024
Modified Files: src/lib/libc/gen [netbsd-10]: usleep.3 usleep.c Log Message: Pull up following revision(s) (requested by jdolecek in ticket #678): lib/libc/gen/usleep.c: revision 1.21 lib/libc/gen/usleep.3: revision 1.20 lib/libc/gen/usleep.3: revision 1.21 allow usleep(3) with useconds >= 1000000 update manpage to mention this interface is obsolete, remove EINVAL from the ERRORS and mention EINTR instead. PR lib/58184 by Taylor R Campbell it's nanosleep(2), not nanosleep(3) To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.19.56.1 src/lib/libc/gen/usleep.3 cvs rdiff -u -r1.20 -r1.20.42.1 src/lib/libc/gen/usleep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/lib/libc/gen/usleep.3 diff -u src/lib/libc/gen/usleep.3:1.19 src/lib/libc/gen/usleep.3:1.19.56.1 --- src/lib/libc/gen/usleep.3:1.19 Thu Apr 29 17:29:56 2010 +++ src/lib/libc/gen/usleep.3 Sun Apr 28 13:23:20 2024 @@ -1,4 +1,4 @@ -.\" $NetBSD: usleep.3,v 1.19 2010/04/29 17:29:56 jruoho Exp $ +.\" $NetBSD: usleep.3,v 1.19.56.1 2024/04/28 13:23:20 martin Exp $ .\" .\" Copyright (c) 1986, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" @(#)usleep.3 8.1 (Berkeley) 6/4/93 .\" -.Dd April 29, 2010 +.Dd April 22, 2024 .Dt USLEEP 3 .Os .Sh NAME @@ -42,6 +42,11 @@ .Ft int .Fn usleep "useconds_t microseconds" .Sh DESCRIPTION +.Bf -symbolic +This interface is obsoleted by +.Xr nanosleep 2 . +.Ef +.Pp The .Fn usleep function @@ -53,13 +58,6 @@ action is to invoke a signal catching fu process. The suspension time may be longer than requested due to the scheduling of other activity by the system. -.Pp -The -.Fa microseconds -argument must be less than 1,000,000. -If the value of -.Fa microseconds -is 0, then the call has no effect. .Sh RETURN VALUES On successful completion, .Fn usleep @@ -72,10 +70,9 @@ The .Fn usleep function may fail if: .Bl -tag -width Er -.It Bq Er EINVAL -The -.Fa microseconds -interval specified 1,000,000 or more microseconds. +.It Bq Er EINTR +.Nm +was interrupted by the delivery of a signal. .El .Sh SEE ALSO .Xr nanosleep 2 , Index: src/lib/libc/gen/usleep.c diff -u src/lib/libc/gen/usleep.c:1.20 src/lib/libc/gen/usleep.c:1.20.42.1 --- src/lib/libc/gen/usleep.c:1.20 Mon Jun 25 22:32:44 2012 +++ src/lib/libc/gen/usleep.c Sun Apr 28 13:23:20 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: usleep.c,v 1.20 2012/06/25 22:32:44 abs Exp $ */ +/* $NetBSD: usleep.c,v 1.20.42.1 2024/04/28 13:23:20 martin Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include <sys/cdefs.h> #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: usleep.c,v 1.20 2012/06/25 22:32:44 abs Exp $"); +__RCSID("$NetBSD: usleep.c,v 1.20.42.1 2024/04/28 13:23:20 martin Exp $"); #endif /* LIBC_SCCS and not lint */ #include "namespace.h" @@ -51,13 +51,8 @@ usleep(useconds_t useconds) if (useconds == 0) return (0); - if (useconds >= 1000000) { - errno = EINVAL; - return (-1); - } - - ts.tv_sec = 0; - ts.tv_nsec = useconds * 1000; + ts.tv_sec = (useconds / 1000000); + ts.tv_nsec = (useconds % 1000000) * 1000; nanosleep(&ts, NULL);