added replacement qsort for solaris
[btb/d2x.git] / misc / d_delay.c
1 /* $Id: d_delay.c,v 1.5 2003-02-18 20:35:35 btb Exp $ */
2 /*
3  * added on 9/2/98 by Matt Mueller
4  */
5
6 #ifdef HAVE_CONFIG_H
7 #include <conf.h>
8 #endif
9
10 #include "d_delay.h"
11
12 #ifndef d_delay
13
14 #if defined(__WINDOWS__) || defined(__MINGW32__)
15
16 #include <windows.h>
17
18 void d_delay (int ms) {
19  Sleep(ms);
20 }
21
22 #else
23
24 #include <sys/time.h>
25 #include <sys/types.h>
26 #include <unistd.h>
27 #include <time.h>
28
29 void d_delay (int ms) {
30 #if 0
31         struct timeval tv;
32         tv.tv_sec=ms/1000;
33 //edited 02/06/99 Matt Mueller - microseconds, not milliseconds
34         tv.tv_usec=(ms%1000)*1000;
35 //end edit -MM
36         select(0,NULL,NULL,NULL,&tv);
37 #elif 0
38         struct timespec tv;
39         tv.tv_sec=ms/1000;
40         tv.tv_nsec=(ms%1000)*1000000;//nanoseconds
41         nanosleep(&tv,NULL);
42 #else
43         usleep(ms*1000);
44 #endif
45 }
46
47 #endif
48 #endif