Mercurial > dwindows
comparison compat.c @ 37:360bc6a5f1c9
Sync with latest Dynamic Windows code.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sun, 14 Oct 2001 23:27:37 +0000 |
parents | cddb02f847e1 |
children | eb003f77538c |
comparison
equal
deleted
inserted
replaced
36:cddb02f847e1 | 37:360bc6a5f1c9 |
---|---|
14 #include <mntent.h> | 14 #include <mntent.h> |
15 #include <sys/vfs.h> | 15 #include <sys/vfs.h> |
16 #endif | 16 #endif |
17 #endif | 17 #endif |
18 | 18 |
19 #ifdef __UNIX__ | |
20 void msleep(long period) | |
21 { | |
22 #ifdef __sun__ | |
23 /* usleep() isn't threadsafe on Solaris */ | |
24 struct timespec req; | |
25 | |
26 req.tv_sec = 0; | |
27 req.tv_nsec = period * 1000000; | |
28 | |
29 nanosleep(&req, NULL); | |
30 #else | |
31 usleep(period * 1000); | |
32 #endif | |
33 } | |
34 #endif | |
35 | |
19 int sockread (int a, void *b, int c, int d) | 36 int sockread (int a, void *b, int c, int d) |
20 { | 37 { |
21 #if defined(__IBMC__) || (defined(__WIN32__) && !defined(__CYGWIN32__)) | 38 #if defined(__IBMC__) || (defined(__WIN32__) && !defined(__CYGWIN32__)) |
22 return recv(a,b,c,d); | 39 return recv(a,b,c,d); |
23 #else | 40 #else |
64 static unsigned long _nonblock = 1; | 81 static unsigned long _nonblock = 1; |
65 | 82 |
66 ioctlsocket(fd, FIONBIO, &_nonblock); | 83 ioctlsocket(fd, FIONBIO, &_nonblock); |
67 #else | 84 #else |
68 fcntl(fd, F_SETFL, O_NONBLOCK); | 85 fcntl(fd, F_SETFL, O_NONBLOCK); |
86 #endif | |
87 } | |
88 | |
89 void block(int fd) | |
90 { | |
91 #ifdef __IBMC__ | |
92 static int _nonblock = 0; | |
93 | |
94 ioctl(fd, FIONBIO, (char *)&_nonblock, sizeof(_nonblock)); | |
95 #elif defined(__WIN32__) && !defined(__CYGWIN32__) | |
96 static unsigned long _nonblock = 0; | |
97 | |
98 ioctlsocket(fd, FIONBIO, &_nonblock); | |
99 #else | |
100 fcntl(fd, F_SETFL, 0); | |
69 #endif | 101 #endif |
70 } | 102 } |
71 | 103 |
72 int socksprintf(int fd, char *format, ...) | 104 int socksprintf(int fd, char *format, ...) |
73 { | 105 { |
433 #endif | 465 #endif |
434 #elif defined(__OS2__) | 466 #elif defined(__OS2__) |
435 /* No snprintf() on OS/2 ??? */ | 467 /* No snprintf() on OS/2 ??? */ |
436 sprintf(buf, "Drive %c", (char)drive + 'A' - 1); | 468 sprintf(buf, "Drive %c", (char)drive + 'A' - 1); |
437 #else | 469 #else |
438 snprintf(buf, len, "Drive %c", (char)drive + 'A' - 1); | 470 _snprintf(buf, len, "Drive %c", (char)drive + 'A' - 1); |
439 #endif | 471 #endif |
440 } | 472 } |
441 | 473 |
442 void setfileinfo(char *filename, char *url) | 474 void setfileinfo(char *filename, char *url) |
443 { | 475 { |