home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
GEMini Atari
/
GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso
/
zip
/
mint
/
mntlib16.lzh
/
MNTLIB16
/
SLEEP.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-08-03
|
1KB
|
54 lines
/* sleep -- sleep for a specified number of seconds */
/* usleep -- sleep for a specified number of microSecond */
/* written by Eric R. Smith and placed in the public domain */
#include <time.h>
#include <mintbind.h>
/* clock() has a rez of CLOCKS_PER_SEC ticks/sec */
#define USEC_PER_TICK (1000000U / ((unsigned long)CLOCKS_PER_SEC))
#define USEC_TO_CLOCK_TICKS(us) ((us) / USEC_PER_TICK )
void
sleep(n)
unsigned int n;
{
unsigned long stop;
extern int __mint;
if (__mint) {
while (n > 32) {
(void)Fselect(32000, 0L, 0L, 0L);
n -= 32;
}
(void)Fselect(1000*n, 0L, 0L, 0L);
}
else {
stop = clock() + n * CLOCKS_PER_SEC;
while (clock() < stop)
;
}
}
/*
* Sleep for usec microSeconds
* the actual suspension time can be arbitrarily longer
*
*/
void
usleep(unsigned long usec)
{
unsigned long stop;
extern int __mint;
if (__mint) {
(void)Fselect((unsigned)(usec/1000), 0L, 0L, 0L);
}
else {
stop = clock() + USEC_TO_CLOCK_TICKS(usec);
while (clock() < stop)
;
}
}