/* This source code was taken from the FAQ for the comp.unix.questions Usenet news group. It works under SCO, so I have used it as the basis for the sleep() and nap() functions as well. The document in question has Archive-Name "unix-faq/faq/part4" and bears the following disclaimers: --------------------------------------------------------------------- This collection of documents is Copyright (c) 1994, Ted Timar, except Part 6, which is Copyright (c) 1994, Pierre Lewis and Ted Timar. All rights reserved. Permission to distribute the collection is hereby granted providing that distribution is electronic, no money is involved, reasonable attempts are made to use the latest version and all credits and this copyright notice are maintained. Other requests for distribution will be considered. All reasonable requests will be granted. All information here has been contributed with good intentions, but none of it is guaranteed either by the contributors or myself to be accurate. The users of this information take all responsibility for any damage that may occur. Many FAQs, including this one, are available on the arcihve site rtfm.mit.edu in the directory pub/usenet/news.answers. The name under which a FAQ is archived appears in the "Archive-Name:" line at the top of the article. --------------------------------------------------------------------- Please note that this license is more restrictive than the GNU Library General Public License under which the rest of this software is distributed. This restriction applies to any programs you write which use the usleep(), sleep() or nap() functions from this library. There are no other functions with libc.a which use this code, but if you link with other libraries, or use source code which calls one of these three functions, then your program may be linked with this code. If you wish to use libc.a for purposes which conflict with the restrictions listed above, then you may wish to ensure your compliance by removing the usleep.o object from libc.a. You can do this with the "ar" and "ranlib" programs, but I do not support this procedure. Greg Wooledge gwooledge@onenet-ici.com wooledge@kellnet.com aa1254@lcfn.org */ /* usleep -- support routine for 4.2BSD system call emulations last edit: 29-Oct-1984 D A Gwyn */ extern int select(); int usleep( usec ) /* returns 0 if ok, else -1 */ long usec; /* delay in microseconds */ { static struct /* `timeval' */ { long tv_sec; /* seconds */ long tv_usec; /* microsecs */ } delay; /* _select() timeout */ delay.tv_sec = usec / 1000000L; delay.tv_usec = usec % 1000000L; return select( 0, (long *)0, (long *)0, (long *)0, &delay ); }