Mercurial > dwindows
diff 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 |
line wrap: on
line diff
--- a/compat.c Mon Sep 17 09:15:40 2001 +0000 +++ b/compat.c Sun Oct 14 23:27:37 2001 +0000 @@ -16,6 +16,23 @@ #endif #endif +#ifdef __UNIX__ +void msleep(long period) +{ +#ifdef __sun__ + /* usleep() isn't threadsafe on Solaris */ + struct timespec req; + + req.tv_sec = 0; + req.tv_nsec = period * 1000000; + + nanosleep(&req, NULL); +#else + usleep(period * 1000); +#endif +} +#endif + int sockread (int a, void *b, int c, int d) { #if defined(__IBMC__) || (defined(__WIN32__) && !defined(__CYGWIN32__)) @@ -69,6 +86,21 @@ #endif } +void block(int fd) +{ +#ifdef __IBMC__ + static int _nonblock = 0; + + ioctl(fd, FIONBIO, (char *)&_nonblock, sizeof(_nonblock)); +#elif defined(__WIN32__) && !defined(__CYGWIN32__) + static unsigned long _nonblock = 0; + + ioctlsocket(fd, FIONBIO, &_nonblock); +#else + fcntl(fd, F_SETFL, 0); +#endif +} + int socksprintf(int fd, char *format, ...) { va_list args; @@ -435,7 +467,7 @@ /* No snprintf() on OS/2 ??? */ sprintf(buf, "Drive %c", (char)drive + 'A' - 1); #else - snprintf(buf, len, "Drive %c", (char)drive + 'A' - 1); + _snprintf(buf, len, "Drive %c", (char)drive + 'A' - 1); #endif }