summaryrefslogtreecommitdiff
path: root/lib/libc/gen
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1997-11-06 01:25:50 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1997-11-06 01:25:50 +0000
commit8599f9e108b853b72544216cf749e7fd896e9fa5 (patch)
tree4861c463993de7ec638af0671383605381207fb4 /lib/libc/gen
parentf65c780eca74851556a757da215891467035e225 (diff)
XPG4.2 compat:
1) usleep() and ualarm() use useconds_t not u_int 2) usleep() returns an int
Diffstat (limited to 'lib/libc/gen')
-rw-r--r--lib/libc/gen/ualarm.313
-rw-r--r--lib/libc/gen/ualarm.c13
-rw-r--r--lib/libc/gen/usleep.339
-rw-r--r--lib/libc/gen/usleep.c11
4 files changed, 57 insertions, 19 deletions
diff --git a/lib/libc/gen/ualarm.3 b/lib/libc/gen/ualarm.3
index e8d1378df7f..b96e888ad8d 100644
--- a/lib/libc/gen/ualarm.3
+++ b/lib/libc/gen/ualarm.3
@@ -1,4 +1,4 @@
-.\" $OpenBSD: ualarm.3,v 1.3 1997/09/26 01:25:26 millert Exp $
+.\" $OpenBSD: ualarm.3,v 1.4 1997/11/06 01:25:49 millert Exp $
.\"
.\" Copyright (c) 1986, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -31,7 +31,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd April 19, 1994
+.Dd November 4, 1997
.Dt UALARM 3
.Os BSD 4.3
.Sh NAME
@@ -39,8 +39,8 @@
.Nd schedule signal after specified time
.Sh SYNOPSIS
.Fd #include <unistd.h>
-.Ft u_int
-.Fn ualarm "u_int microseconds" "u_int interval"
+.Ft useconds_t
+.Fn ualarm "useconds_t microseconds" "useconds_t interval"
.Sh DESCRIPTION
.Bf -symbolic
This is a simplified interface to setitimer(2).
@@ -84,6 +84,11 @@ is 2147483647.
.Xr sleep 3 ,
.Xr alarm 3 ,
.Xr usleep 3
+.Sh STANDARDS
+The
+.Fn
+function conforms to
+.St -xpg4.2 .
.Sh HISTORY
The
.Fn ualarm
diff --git a/lib/libc/gen/ualarm.c b/lib/libc/gen/ualarm.c
index 02f760d4db9..19574b74c02 100644
--- a/lib/libc/gen/ualarm.c
+++ b/lib/libc/gen/ualarm.c
@@ -32,9 +32,10 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: ualarm.c,v 1.3 1996/09/15 09:31:08 tholo Exp $";
+static char rcsid[] = "$OpenBSD: ualarm.c,v 1.4 1997/11/06 01:25:48 millert Exp $";
#endif /* LIBC_SCCS and not lint */
+#include <sys/types.h>
#include <sys/time.h>
#include <unistd.h>
@@ -45,10 +46,10 @@ static char rcsid[] = "$OpenBSD: ualarm.c,v 1.3 1996/09/15 09:31:08 tholo Exp $"
* If ``reload'' is non-zero, keep generating SIGALRM
* every ``reload'' microseconds after the first signal.
*/
-u_int
+useconds_t
ualarm(usecs, reload)
- register unsigned usecs;
- register unsigned reload;
+ register useconds_t usecs;
+ register useconds_t reload;
{
struct itimerval new, old;
@@ -59,7 +60,7 @@ ualarm(usecs, reload)
new.it_value.tv_sec = usecs / USPS;
if (setitimer(ITIMER_REAL, &new, &old) == 0)
- return (old.it_value.tv_sec * USPS + old.it_value.tv_usec);
+ return ((useconds_t)(old.it_value.tv_sec * USPS + old.it_value.tv_usec));
/* else */
- return ((u_int)-1);
+ return ((useconds_t)-1);
}
diff --git a/lib/libc/gen/usleep.3 b/lib/libc/gen/usleep.3
index b8ff9be759f..6326eefc5ad 100644
--- a/lib/libc/gen/usleep.3
+++ b/lib/libc/gen/usleep.3
@@ -1,4 +1,4 @@
-.\" $OpenBSD: usleep.3,v 1.3 1997/04/25 14:47:59 kstailey Exp $
+.\" $OpenBSD: usleep.3,v 1.4 1997/11/06 01:25:48 millert Exp $
.\"
.\" Copyright (c) 1986, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -31,7 +31,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd June 4, 1993
+.Dd November 4, 1997
.Dt USLEEP 3
.Os BSD 4.3
.Sh NAME
@@ -39,8 +39,8 @@
.Nd suspend execution for interval of microseconds
.Sh SYNOPSIS
.Fd #include <unistd.h>
-.Ft void
-.Fn usleep "u_int microseconds"
+.Ft int
+.Fn usleep "useconds_t microseconds"
.Sh DESCRIPTION
The
.Fn usleep
@@ -63,6 +63,32 @@ with other uses of
(not that
.Fn usleep
interferes with interval timers anymore.)
+.Sh RETURN VALUE
+If the
+.Fn usleep
+function returns because the requested time has elapsed, the value
+returned will be zero.
+.Pp
+If the
+.Fn usleep
+function returns due to the delivery of a signal, the value returned
+will be the -1, and the global variable
+.Va errno
+will be set to indicate the interruption.
+.Sh ERRORS
+If any of the following conditions occur, the
+.Nm
+function shall return -1 and set
+.Va errno
+to the corresponding value.
+.Bl -tag -width Er
+.It Bq Er EINTR
+.Nm
+was interrupted by the delivery of a signal.
+.It Bq Er EINVAL
+.Fa useconds
+specified a value of 1,000,000 or more microseconds.
+.El
.Sh SEE ALSO
.Xr getitimer 2 ,
.Xr nanosleep 2 ,
@@ -71,6 +97,11 @@ interferes with interval timers anymore.)
.Xr alarm 3
.Xr sleep 3 ,
.Xr ualarm 3 ,
+.Sh STANDARDS
+The
+.Fn
+function conforms to
+.St -xpg4.2 .
.Sh HISTORY
The
.Fn usleep
diff --git a/lib/libc/gen/usleep.c b/lib/libc/gen/usleep.c
index eae3659a6fe..8a18ed160a3 100644
--- a/lib/libc/gen/usleep.c
+++ b/lib/libc/gen/usleep.c
@@ -32,22 +32,23 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: usleep.c,v 1.5 1997/04/25 04:20:42 tholo Exp $";
+static char rcsid[] = "$OpenBSD: usleep.c,v 1.6 1997/11/06 01:25:48 millert Exp $";
#endif /* LIBC_SCCS and not lint */
+#include <sys/types.h>
#include <sys/time.h>
-void
+int
usleep(useconds)
- unsigned int useconds;
+ useconds_t useconds;
{
struct timespec rqt;
if (useconds == 0)
- return;
+ return(0);
rqt.tv_sec = useconds / 1000000;
rqt.tv_nsec = (useconds % 1000000) * 1000;
- nanosleep(&rqt, NULL);
+ return(nanosleep(&rqt, NULL));
}