include/ruby/win32.h

Go to the documentation of this file.
00001 #ifndef RUBY_WIN32_H
00002 #define RUBY_WIN32_H 1
00003 
00004 #if defined(__cplusplus)
00005 extern "C" {
00006 #if 0
00007 } /* satisfy cc-mode */
00008 #endif
00009 #endif
00010 
00011 RUBY_SYMBOL_EXPORT_BEGIN
00012 
00013 /*
00014  *  Copyright (c) 1993, Intergraph Corporation
00015  *
00016  *  You may distribute under the terms of either the GNU General Public
00017  *  License or the Artistic License, as specified in the perl README file.
00018  *
00019  */
00020 
00021 /*
00022  * Definitions for NT port of Perl
00023  */
00024 
00025 
00026 /*
00027  * Ok now we can include the normal include files.
00028  */
00029 
00030 /* #include <stdarg.h> conflict with varargs.h? */
00031 #if !defined(WSAAPI)
00032 #if defined(__cplusplus) && defined(_MSC_VER)
00033 extern "C++" {                  /* template without extern "C++" */
00034 #endif
00035 #if !defined(_WIN64) && !defined(WIN32)
00036 #define WIN32
00037 #endif
00038 #include <winsock2.h>
00039 #include <ws2tcpip.h>
00040 #if !defined(_MSC_VER) || _MSC_VER >= 1400
00041 #include <iphlpapi.h>
00042 #endif
00043 #if defined(__cplusplus) && defined(_MSC_VER)
00044 }
00045 #endif
00046 #endif
00047 
00048 /*
00049  * We're not using Microsoft's "extensions" to C for
00050  * Structured Exception Handling (SEH) so we can nuke these
00051  */
00052 #undef try
00053 #undef except
00054 #undef finally
00055 #undef leave
00056 
00057 #include <stdio.h>
00058 #include <stdlib.h>
00059 #include <string.h>
00060 #include <direct.h>
00061 #include <process.h>
00062 #include <time.h>
00063 #if defined(__cplusplus) && defined(_MSC_VER) && _MSC_VER == 1200
00064 extern "C++" {                  /* template without extern "C++" */
00065 #endif
00066 #include <math.h>
00067 #if defined(__cplusplus) && defined(_MSC_VER) && _MSC_VER == 1200
00068 }
00069 #endif
00070 #include <signal.h>
00071 #include <sys/stat.h>
00072 #include <sys/types.h>
00073 #ifdef HAVE_SYS_UTIME_H
00074 # include <sys/utime.h>
00075 #else
00076 # include <utime.h>
00077 #endif
00078 #include <io.h>
00079 #include <malloc.h>
00080 #if defined __MINGW32__ || __BORLANDC__ >= 0x0580
00081 # include <stdint.h>
00082 #else
00083 # if !defined(_INTPTR_T_DEFINED)
00084 #  ifdef _WIN64
00085 typedef __int64 intptr_t;
00086 #  else
00087 typedef int intptr_t;
00088 #  endif
00089 #  define _INTPTR_T_DEFINED
00090 # endif
00091 # if !defined(INTPTR_MAX)
00092 #  ifdef _WIN64
00093 #    define INTPTR_MAX 9223372036854775807I64
00094 #  else
00095 #    define INTPTR_MAX 2147483647
00096 #  endif
00097 #  define INTPTR_MIN (-INTPTR_MAX-1)
00098 # endif
00099 # if !defined(_UINTPTR_T_DEFINED)
00100 #  ifdef _WIN64
00101 typedef unsigned __int64 uintptr_t;
00102 #  else
00103 typedef unsigned int uintptr_t;
00104 #  endif
00105 #  define _UINTPTR_T_DEFINED
00106 # endif
00107 # if !defined(UINTPTR_MAX)
00108 #  ifdef _WIN64
00109 #    define UINTPTR_MAX 18446744073709551615UI64
00110 #  else
00111 #    define UINTPTR_MAX 4294967295U
00112 #  endif
00113 # endif
00114 #endif
00115 #ifndef __MINGW32__
00116 # define mode_t int
00117 #endif
00118 #ifdef HAVE_UNISTD_H
00119 # include <unistd.h>
00120 #endif
00121 
00122 #define rb_w32_iswinnt()  TRUE
00123 #define rb_w32_iswin95()  FALSE
00124 
00125 #define WNOHANG -1
00126 
00127 typedef int clockid_t;
00128 #define CLOCK_REALTIME  0
00129 #define CLOCK_MONOTONIC 1
00130 
00131 #undef getc
00132 #undef putc
00133 #undef fgetc
00134 #undef fputc
00135 #undef getchar
00136 #undef putchar
00137 #undef fgetchar
00138 #undef fputchar
00139 #undef utime
00140 #undef lseek
00141 #undef stat
00142 #undef fstat
00143 #define getc(_stream)           rb_w32_getc(_stream)
00144 #define getchar()               rb_w32_getc(stdin)
00145 #define putc(_c, _stream)       rb_w32_putc(_c, _stream)
00146 #define putchar(_c)             rb_w32_putc(_c, stdout)
00147 #ifdef RUBY_EXPORT
00148 #define fgetc(_stream)          getc(_stream)
00149 #define fputc(_c, _stream)      putc(_c, _stream)
00150 #define fgetchar()              getchar()
00151 #define fputchar(_c)            putchar(_c)
00152 #define utime(_p, _t)           rb_w32_utime(_p, _t)
00153 #define lseek(_f, _o, _w)       _lseeki64(_f, _o, _w)
00154 
00155 #define pipe(p)                 rb_w32_pipe(p)
00156 #define open                    rb_w32_open
00157 #define close(h)                rb_w32_close(h)
00158 #define fclose(f)               rb_w32_fclose(f)
00159 #define read(f, b, s)           rb_w32_read(f, b, s)
00160 #define write(f, b, s)          rb_w32_write(f, b, s)
00161 #define getpid()                rb_w32_getpid()
00162 #define getppid()               rb_w32_getppid()
00163 #define sleep(x)                rb_w32_Sleep((x)*1000)
00164 #define Sleep(msec)             (void)rb_w32_Sleep(msec)
00165 #define fstati64(fd,st)         rb_w32_fstati64(fd,st)
00166 #ifdef __BORLANDC__
00167 #define creat(p, m)             _creat(p, m)
00168 #define eof()                   _eof()
00169 #define filelength(h)           _filelength(h)
00170 #define mktemp(t)               _mktemp(t)
00171 #define tell(h)                 _tell(h)
00172 #define _open                   _sopen
00173 #define sopen                   _sopen
00174 #undef fopen
00175 #define fopen(p, m)             rb_w32_fopen(p, m)
00176 #undef fdopen
00177 #define fdopen(h, m)            rb_w32_fdopen(h, m)
00178 #undef fsopen
00179 #define fsopen(p, m, sh)        rb_w32_fsopen(p, m, sh)
00180 #endif /* __BORLANDC__ */
00181 
00182 #undef execv
00183 #define execv(path,argv)        rb_w32_aspawn(P_OVERLAY,path,argv)
00184 #if !defined(__BORLANDC__)
00185 #undef isatty
00186 #define isatty(h)               rb_w32_isatty(h)
00187 #endif /* __BORLANDC__ */
00188 
00189 #undef mkdir
00190 #define mkdir(p, m)             rb_w32_mkdir(p, m)
00191 #undef rmdir
00192 #define rmdir(p)                rb_w32_rmdir(p)
00193 #undef unlink
00194 #define unlink(p)               rb_w32_unlink(p)
00195 #endif /* RUBY_EXPORT */
00196 
00197 #if SIZEOF_OFF_T == 8
00198 #define off_t __int64
00199 #define stat stati64
00200 #define fstat(fd,st)            fstati64(fd,st)
00201 #if defined(__BORLANDC__)
00202 #define stati64(path, st) rb_w32_stati64(path, st)
00203 #elif !defined(_MSC_VER) || RT_VER < 80
00204 #define stati64 _stati64
00205 #ifndef _stati64
00206 #define _stati64(path, st) rb_w32_stati64(path, st)
00207 #endif
00208 #else
00209 #define stati64 _stat64
00210 #define _stat64(path, st) rb_w32_stati64(path, st)
00211 #endif
00212 #else
00213 #define stat(path,st)           rb_w32_stat(path,st)
00214 #define fstat(fd,st)            rb_w32_fstat(fd,st)
00215 extern int rb_w32_stat(const char *, struct stat *);
00216 extern int rb_w32_fstat(int, struct stat *);
00217 #endif
00218 #define access(path,mode)       rb_w32_access(path,mode)
00219 
00220 #define strcasecmp              _stricmp
00221 #define strncasecmp             _strnicmp
00222 #define fsync                   _commit
00223 
00224 struct timezone;
00225 
00226 #ifdef __MINGW32__
00227 #undef isascii
00228 #define isascii __isascii
00229 #endif
00230 
00231 struct iovec {
00232     void *iov_base;
00233     size_t iov_len;
00234 };
00235 struct msghdr {
00236     void *msg_name;
00237     int msg_namelen;
00238     struct iovec *msg_iov;
00239     int msg_iovlen;
00240     void *msg_control;
00241     int msg_controllen;
00242     int msg_flags;
00243 };
00244 
00245 /* for getifaddrs() and others */
00246 struct ifaddrs {
00247     struct ifaddrs *ifa_next;
00248     char *ifa_name;
00249     u_int ifa_flags;
00250     struct sockaddr *ifa_addr;
00251     struct sockaddr *ifa_netmask;
00252     struct sockaddr *ifa_broadaddr;
00253     struct sockaddr *ifa_dstaddr;
00254     void *ifa_data;
00255 };
00256 #ifdef IF_NAMESIZE
00257 #define IFNAMSIZ IF_NAMESIZE
00258 #else
00259 #define IFNAMSIZ 256
00260 #endif
00261 #ifdef IFF_POINTTOPOINT
00262 #define IFF_POINTOPOINT IFF_POINTTOPOINT
00263 #endif
00264 
00265 extern DWORD  rb_w32_osid(void);
00266 extern int    rb_w32_cmdvector(const char *, char ***);
00267 extern rb_pid_t  rb_w32_pipe_exec(const char *, const char *, int, int *, int *);
00268 extern int    flock(int fd, int oper);
00269 extern int    rb_w32_io_cancelable_p(int);
00270 extern int    rb_w32_is_socket(int);
00271 extern int    WSAAPI rb_w32_accept(int, struct sockaddr *, int *);
00272 extern int    WSAAPI rb_w32_bind(int, const struct sockaddr *, int);
00273 extern int    WSAAPI rb_w32_connect(int, const struct sockaddr *, int);
00274 extern void   rb_w32_fdset(int, fd_set*);
00275 extern void   rb_w32_fdclr(int, fd_set*);
00276 extern int    rb_w32_fdisset(int, fd_set*);
00277 extern int    WSAAPI rb_w32_select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
00278 extern int    WSAAPI rb_w32_getpeername(int, struct sockaddr *, int *);
00279 extern int    WSAAPI rb_w32_getsockname(int, struct sockaddr *, int *);
00280 extern int    WSAAPI rb_w32_getsockopt(int, int, int, char *, int *);
00281 extern int    WSAAPI rb_w32_ioctlsocket(int, long, u_long *);
00282 extern int    WSAAPI rb_w32_listen(int, int);
00283 extern int    WSAAPI rb_w32_recv(int, char *, int, int);
00284 extern int    WSAAPI rb_w32_recvfrom(int, char *, int, int, struct sockaddr *, int *);
00285 extern int    WSAAPI rb_w32_send(int, const char *, int, int);
00286 extern int    WSAAPI rb_w32_sendto(int, const char *, int, int, const struct sockaddr *, int);
00287 extern int    recvmsg(int, struct msghdr *, int);
00288 extern int    sendmsg(int, const struct msghdr *, int);
00289 extern int    WSAAPI rb_w32_setsockopt(int, int, int, const char *, int);
00290 extern int    WSAAPI rb_w32_shutdown(int, int);
00291 extern int    WSAAPI rb_w32_socket(int, int, int);
00292 extern SOCKET rb_w32_get_osfhandle(int);
00293 extern struct hostent *WSAAPI rb_w32_gethostbyaddr(const char *, int, int);
00294 extern struct hostent *WSAAPI rb_w32_gethostbyname(const char *);
00295 extern int    WSAAPI rb_w32_gethostname(char *, int);
00296 extern struct protoent *WSAAPI rb_w32_getprotobyname(const char *);
00297 extern struct protoent *WSAAPI rb_w32_getprotobynumber(int);
00298 extern struct servent  *WSAAPI rb_w32_getservbyname(const char *, const char *);
00299 extern struct servent  *WSAAPI rb_w32_getservbyport(int, const char *);
00300 extern int    socketpair(int, int, int, int *);
00301 extern int    getifaddrs(struct ifaddrs **);
00302 extern void   freeifaddrs(struct ifaddrs *);
00303 extern char * rb_w32_getcwd(char *, int);
00304 extern char * rb_w32_ugetenv(const char *);
00305 extern char * rb_w32_getenv(const char *);
00306 extern int    rb_w32_rename(const char *, const char *);
00307 extern int    rb_w32_urename(const char *, const char *);
00308 extern char **rb_w32_get_environ(void);
00309 extern void   rb_w32_free_environ(char **);
00310 extern int    rb_w32_map_errno(DWORD);
00311 extern const char *WSAAPI rb_w32_inet_ntop(int,const void *,char *,size_t);
00312 extern int WSAAPI rb_w32_inet_pton(int,const char *,void *);
00313 extern DWORD  rb_w32_osver(void);
00314 
00315 extern int chown(const char *, int, int);
00316 extern int rb_w32_uchown(const char *, int, int);
00317 extern int link(const char *, const char *);
00318 extern int rb_w32_ulink(const char *, const char *);
00319 extern int gettimeofday(struct timeval *, struct timezone *);
00320 extern int clock_gettime(clockid_t, struct timespec *);
00321 extern int clock_getres(clockid_t, struct timespec *);
00322 extern rb_pid_t waitpid (rb_pid_t, int *, int);
00323 extern rb_pid_t rb_w32_spawn(int, const char *, const char*);
00324 extern rb_pid_t rb_w32_aspawn(int, const char *, char *const *);
00325 extern rb_pid_t rb_w32_aspawn_flags(int, const char *, char *const *, DWORD);
00326 extern rb_pid_t rb_w32_uspawn(int, const char *, const char*);
00327 extern rb_pid_t rb_w32_uaspawn(int, const char *, char *const *);
00328 extern rb_pid_t rb_w32_uaspawn_flags(int, const char *, char *const *, DWORD);
00329 extern int kill(int, int);
00330 extern int fcntl(int, int, ...);
00331 extern rb_pid_t rb_w32_getpid(void);
00332 extern rb_pid_t rb_w32_getppid(void);
00333 #if !defined(__BORLANDC__)
00334 extern int rb_w32_isatty(int);
00335 #endif
00336 extern int rb_w32_uchdir(const char *);
00337 extern int rb_w32_mkdir(const char *, int);
00338 extern int rb_w32_umkdir(const char *, int);
00339 extern int rb_w32_rmdir(const char *);
00340 extern int rb_w32_urmdir(const char *);
00341 extern int rb_w32_unlink(const char *);
00342 extern int rb_w32_uunlink(const char *);
00343 extern int rb_w32_uchmod(const char *, int);
00344 extern int rb_w32_stati64(const char *, struct stati64 *);
00345 extern int rb_w32_ustati64(const char *, struct stati64 *);
00346 extern int rb_w32_access(const char *, int);
00347 extern int rb_w32_uaccess(const char *, int);
00348 extern char rb_w32_fd_is_text(int);
00349 extern int rb_w32_fstati64(int, struct stati64 *);
00350 extern int rb_w32_dup2(int, int);
00351 
00352 #ifdef __BORLANDC__
00353 extern off_t _lseeki64(int, off_t, int);
00354 extern FILE *rb_w32_fopen(const char *, const char *);
00355 extern FILE *rb_w32_fdopen(int, const char *);
00356 extern FILE *rb_w32_fsopen(const char *, const char *, int);
00357 #endif
00358 
00359 #include <float.h>
00360 
00361 #if defined _MSC_VER && _MSC_VER >= 1800 && defined INFINITY
00362 #pragma warning(push)
00363 #pragma warning(disable:4756)
00364 static inline float
00365 rb_infinity_float(void)
00366 {
00367     return INFINITY;
00368 }
00369 #pragma warning(pop)
00370 #undef INFINITY
00371 #define INFINITY rb_infinity_float()
00372 #endif
00373 
00374 #if !defined __MINGW32__ || defined __NO_ISOCEXT
00375 #ifndef isnan
00376 #define isnan(x) _isnan(x)
00377 #endif
00378 static inline int
00379 finite(double x)
00380 {
00381     return _finite(x);
00382 }
00383 #ifndef copysign
00384 #define copysign(a, b) _copysign(a, b)
00385 #endif
00386 static inline double
00387 scalb(double a, long b)
00388 {
00389     return _scalb(a, b);
00390 }
00391 #else
00392 __declspec(dllimport) extern int finite(double);
00393 #endif
00394 
00395 #if !defined S_IFIFO && defined _S_IFIFO
00396 #define S_IFIFO _S_IFIFO
00397 #endif
00398 
00399 #if 0 && defined __BORLANDC__
00400 #undef S_ISDIR
00401 #undef S_ISFIFO
00402 #undef S_ISBLK
00403 #undef S_ISCHR
00404 #undef S_ISREG
00405 #define S_ISDIR(m)  (((unsigned short)(m) & S_IFMT) == S_IFDIR)
00406 #define S_ISFIFO(m) (((unsigned short)(m) & S_IFMT) == S_IFIFO)
00407 #define S_ISBLK(m)  (((unsigned short)(m) & S_IFMT) == S_IFBLK)
00408 #define S_ISCHR(m)  (((unsigned short)(m) & S_IFMT) == S_IFCHR)
00409 #define S_ISREG(m)  (((unsigned short)(m) & S_IFMT) == S_IFREG)
00410 #endif
00411 
00412 #if !defined S_IRUSR && !defined __MINGW32__
00413 #define S_IRUSR 0400
00414 #endif
00415 #ifndef S_IRGRP
00416 #define S_IRGRP 0040
00417 #endif
00418 #ifndef S_IROTH
00419 #define S_IROTH 0004
00420 #endif
00421 
00422 #if !defined S_IWUSR && !defined __MINGW32__
00423 #define S_IWUSR 0200
00424 #endif
00425 #ifndef S_IWGRP
00426 #define S_IWGRP 0020
00427 #endif
00428 #ifndef S_IWOTH
00429 #define S_IWOTH 0002
00430 #endif
00431 
00432 #if !defined S_IXUSR && !defined __MINGW32__
00433 #define S_IXUSR 0100
00434 #endif
00435 #ifndef S_IXGRP
00436 #define S_IXGRP 0010
00437 #endif
00438 #ifndef S_IXOTH
00439 #define S_IXOTH 0001
00440 #endif
00441 
00442 /*
00443  * define this so we can do inplace editing
00444  */
00445 
00446 #define SUFFIX
00447 
00448 extern int       rb_w32_ftruncate(int fd, off_t length);
00449 extern int       rb_w32_truncate(const char *path, off_t length);
00450 
00451 #undef HAVE_FTRUNCATE
00452 #define HAVE_FTRUNCATE 1
00453 #if defined HAVE_FTRUNCATE64
00454 #define ftruncate ftruncate64
00455 #else
00456 #define ftruncate rb_w32_ftruncate
00457 #endif
00458 
00459 #undef HAVE_TRUNCATE
00460 #define HAVE_TRUNCATE 1
00461 #if defined HAVE_TRUNCATE64
00462 #define truncate truncate64
00463 #else
00464 #define truncate rb_w32_truncate
00465 #endif
00466 
00467 /*
00468  * stubs
00469  */
00470 extern int       ioctl (int, int, ...);
00471 extern rb_uid_t  getuid (void);
00472 extern rb_uid_t  geteuid (void);
00473 extern rb_gid_t  getgid (void);
00474 extern rb_gid_t  getegid (void);
00475 extern int       setuid (rb_uid_t);
00476 extern int       setgid (rb_gid_t);
00477 
00478 extern int fstati64(int, struct stati64 *);
00479 
00480 extern char *rb_w32_strerror(int);
00481 
00482 #ifdef RUBY_EXPORT
00483 #define strerror(e) rb_w32_strerror(e)
00484 #endif
00485 
00486 #define PIPE_BUF 1024
00487 
00488 #define LOCK_SH 1
00489 #define LOCK_EX 2
00490 #define LOCK_NB 4
00491 #define LOCK_UN 8
00492 
00493 
00494 #ifndef SIGINT
00495 #define SIGINT 2
00496 #endif
00497 #ifndef SIGKILL
00498 #define SIGKILL 9
00499 #endif
00500 
00501 
00502 /* #undef va_start */
00503 /* #undef va_end */
00504 
00505 /* winsock error map */
00506 #include <errno.h>
00507 
00508 #ifndef EWOULDBLOCK
00509 # define EWOULDBLOCK            WSAEWOULDBLOCK
00510 #endif
00511 #ifndef EINPROGRESS
00512 # define EINPROGRESS            WSAEINPROGRESS
00513 #endif
00514 #ifndef EALREADY
00515 # define EALREADY               WSAEALREADY
00516 #endif
00517 #ifndef ENOTSOCK
00518 # define ENOTSOCK               WSAENOTSOCK
00519 #endif
00520 #ifndef EDESTADDRREQ
00521 # define EDESTADDRREQ           WSAEDESTADDRREQ
00522 #endif
00523 #ifndef EMSGSIZE
00524 # define EMSGSIZE               WSAEMSGSIZE
00525 #endif
00526 #ifndef EPROTOTYPE
00527 # define EPROTOTYPE             WSAEPROTOTYPE
00528 #endif
00529 #ifndef ENOPROTOOPT
00530 # define ENOPROTOOPT            WSAENOPROTOOPT
00531 #endif
00532 #ifndef EPROTONOSUPPORT
00533 # define EPROTONOSUPPORT        WSAEPROTONOSUPPORT
00534 #endif
00535 #ifndef ESOCKTNOSUPPORT
00536 # define ESOCKTNOSUPPORT        WSAESOCKTNOSUPPORT
00537 #endif
00538 #ifndef EOPNOTSUPP
00539 # define EOPNOTSUPP             WSAEOPNOTSUPP
00540 #endif
00541 #ifndef EPFNOSUPPORT
00542 # define EPFNOSUPPORT           WSAEPFNOSUPPORT
00543 #endif
00544 #ifndef EAFNOSUPPORT
00545 # define EAFNOSUPPORT           WSAEAFNOSUPPORT
00546 #endif
00547 #ifndef EADDRINUSE
00548 # define EADDRINUSE             WSAEADDRINUSE
00549 #endif
00550 #ifndef EADDRNOTAVAIL
00551 # define EADDRNOTAVAIL          WSAEADDRNOTAVAIL
00552 #endif
00553 #ifndef ENETDOWN
00554 # define ENETDOWN               WSAENETDOWN
00555 #endif
00556 #ifndef ENETUNREACH
00557 # define ENETUNREACH            WSAENETUNREACH
00558 #endif
00559 #ifndef ENETRESET
00560 # define ENETRESET              WSAENETRESET
00561 #endif
00562 #ifndef ECONNABORTED
00563 # define ECONNABORTED           WSAECONNABORTED
00564 #endif
00565 #ifndef ECONNRESET
00566 # define ECONNRESET             WSAECONNRESET
00567 #endif
00568 #ifndef ENOBUFS
00569 # define ENOBUFS                WSAENOBUFS
00570 #endif
00571 #ifndef EISCONN
00572 # define EISCONN                WSAEISCONN
00573 #endif
00574 #ifndef ENOTCONN
00575 # define ENOTCONN               WSAENOTCONN
00576 #endif
00577 #ifndef ESHUTDOWN
00578 # define ESHUTDOWN              WSAESHUTDOWN
00579 #endif
00580 #ifndef ETOOMANYREFS
00581 # define ETOOMANYREFS           WSAETOOMANYREFS
00582 #endif
00583 #ifndef ETIMEDOUT
00584 # define ETIMEDOUT              WSAETIMEDOUT
00585 #endif
00586 #ifndef ECONNREFUSED
00587 # define ECONNREFUSED           WSAECONNREFUSED
00588 #endif
00589 #ifndef ELOOP
00590 # define ELOOP                  WSAELOOP
00591 #endif
00592 /*#define ENAMETOOLONG  WSAENAMETOOLONG*/
00593 #ifndef EHOSTDOWN
00594 # define EHOSTDOWN              WSAEHOSTDOWN
00595 #endif
00596 #ifndef EHOSTUNREACH
00597 # define EHOSTUNREACH           WSAEHOSTUNREACH
00598 #endif
00599 /*#define ENOTEMPTY     WSAENOTEMPTY*/
00600 #ifndef EPROCLIM
00601 # define EPROCLIM               WSAEPROCLIM
00602 #endif
00603 #ifndef EUSERS
00604 # define EUSERS                 WSAEUSERS
00605 #endif
00606 #ifndef EDQUOT
00607 # define EDQUOT                 WSAEDQUOT
00608 #endif
00609 #ifndef ESTALE
00610 # define ESTALE                 WSAESTALE
00611 #endif
00612 #ifndef EREMOTE
00613 # define EREMOTE                WSAEREMOTE
00614 #endif
00615 
00616 #define F_DUPFD 0
00617 #if 0
00618 #define F_GETFD 1
00619 #define F_SETFD 2
00620 #define F_GETFL 3
00621 #endif
00622 #define F_SETFL 4
00623 #if 0
00624 #define FD_CLOEXEC 1 /* F_GETFD, F_SETFD */
00625 #endif
00626 #define O_NONBLOCK 1
00627 
00628 #undef FD_SET
00629 #define FD_SET(fd, set) do {\
00630     unsigned int i;\
00631     SOCKET s = _get_osfhandle(fd);\
00632 \
00633     for (i = 0; i < (set)->fd_count; i++) {\
00634         if ((set)->fd_array[i] == s) {\
00635             break;\
00636         }\
00637     }\
00638     if (i == (set)->fd_count) {\
00639         if ((set)->fd_count < FD_SETSIZE) {\
00640             (set)->fd_array[i] = s;\
00641             (set)->fd_count++;\
00642         }\
00643     }\
00644 } while(0)
00645 
00646 #undef FD_CLR
00647 #define FD_CLR(f, s)            rb_w32_fdclr(f, s)
00648 
00649 #undef FD_ISSET
00650 #define FD_ISSET(f, s)          rb_w32_fdisset(f, s)
00651 
00652 #ifdef RUBY_EXPORT
00653 #undef inet_ntop
00654 #define inet_ntop(f,a,n,l)      rb_w32_inet_ntop(f,a,n,l)
00655 
00656 #undef inet_pton
00657 #define inet_pton(f,s,d)        rb_w32_inet_pton(f,s,d)
00658 
00659 #undef accept
00660 #define accept(s, a, l)         rb_w32_accept(s, a, l)
00661 
00662 #undef bind
00663 #define bind(s, a, l)           rb_w32_bind(s, a, l)
00664 
00665 #undef connect
00666 #define connect(s, a, l)        rb_w32_connect(s, a, l)
00667 
00668 #undef select
00669 #define select(n, r, w, e, t)   rb_w32_select(n, r, w, e, t)
00670 
00671 #undef getpeername
00672 #define getpeername(s, a, l)    rb_w32_getpeername(s, a, l)
00673 
00674 #undef getsockname
00675 #define getsockname(s, a, l)    rb_w32_getsockname(s, a, l)
00676 
00677 #undef getsockopt
00678 #define getsockopt(s, v, n, o, l) rb_w32_getsockopt(s, v, n, o, l)
00679 
00680 #undef ioctlsocket
00681 #define ioctlsocket(s, c, a)    rb_w32_ioctlsocket(s, c, a)
00682 
00683 #undef listen
00684 #define listen(s, b)            rb_w32_listen(s, b)
00685 
00686 #undef recv
00687 #define recv(s, b, l, f)        rb_w32_recv(s, b, l, f)
00688 
00689 #undef recvfrom
00690 #define recvfrom(s, b, l, f, fr, frl) rb_w32_recvfrom(s, b, l, f, fr, frl)
00691 
00692 #undef send
00693 #define send(s, b, l, f)        rb_w32_send(s, b, l, f)
00694 
00695 #undef sendto
00696 #define sendto(s, b, l, f, t, tl) rb_w32_sendto(s, b, l, f, t, tl)
00697 
00698 #undef setsockopt
00699 #define setsockopt(s, v, n, o, l) rb_w32_setsockopt(s, v, n, o, l)
00700 
00701 #undef shutdown
00702 #define shutdown(s, h)          rb_w32_shutdown(s, h)
00703 
00704 #undef socket
00705 #define socket(s, t, p)         rb_w32_socket(s, t, p)
00706 
00707 #undef gethostbyaddr
00708 #define gethostbyaddr(a, l, t)  rb_w32_gethostbyaddr(a, l, t)
00709 
00710 #undef gethostbyname
00711 #define gethostbyname(n)        rb_w32_gethostbyname(n)
00712 
00713 #undef gethostname
00714 #define gethostname(n, l)       rb_w32_gethostname(n, l)
00715 
00716 #undef getprotobyname
00717 #define getprotobyname(n)       rb_w32_getprotobyname(n)
00718 
00719 #undef getprotobynumber
00720 #define getprotobynumber(n)     rb_w32_getprotobynumber(n)
00721 
00722 #undef getservbyname
00723 #define getservbyname(n, p)     rb_w32_getservbyname(n, p)
00724 
00725 #undef getservbyport
00726 #define getservbyport(p, pr)    rb_w32_getservbyport(p, pr)
00727 
00728 #undef get_osfhandle
00729 #define get_osfhandle(h)        rb_w32_get_osfhandle(h)
00730 
00731 #undef getcwd
00732 #define getcwd(b, s)            rb_w32_getcwd(b, s)
00733 
00734 #undef getenv
00735 #define getenv(n)               rb_w32_getenv(n)
00736 
00737 #undef rename
00738 #define rename(o, n)            rb_w32_rename(o, n)
00739 
00740 #undef times
00741 #define times(t)                rb_w32_times(t)
00742 
00743 #undef dup2
00744 #define dup2(o, n)              rb_w32_dup2(o, n)
00745 #endif
00746 
00747 struct tms {
00748         long    tms_utime;
00749         long    tms_stime;
00750         long    tms_cutime;
00751         long    tms_cstime;
00752 };
00753 
00754 int rb_w32_times(struct tms *);
00755 
00756 struct tm *gmtime_r(const time_t *, struct tm *);
00757 struct tm *localtime_r(const time_t *, struct tm *);
00758 
00759 /* thread stuff */
00760 int  rb_w32_sleep(unsigned long msec);
00761 int  rb_w32_putc(int, FILE*);
00762 int  rb_w32_getc(FILE*);
00763 int  rb_w32_open(const char *, int, ...);
00764 int  rb_w32_uopen(const char *, int, ...);
00765 int  rb_w32_wopen(const WCHAR *, int, ...);
00766 int  rb_w32_close(int);
00767 int  rb_w32_fclose(FILE*);
00768 int  rb_w32_pipe(int[2]);
00769 ssize_t rb_w32_read(int, void *, size_t);
00770 ssize_t rb_w32_write(int, const void *, size_t);
00771 int  rb_w32_utime(const char *, const struct utimbuf *);
00772 int  rb_w32_uutime(const char *, const struct utimbuf *);
00773 long rb_w32_write_console(uintptr_t, int);      /* use uintptr_t instead of VALUE because it's not defined yet here */
00774 int  WINAPI rb_w32_Sleep(unsigned long msec);
00775 int  rb_w32_wait_events_blocking(HANDLE *events, int num, DWORD timeout);
00776 int  rb_w32_time_subtract(struct timeval *rest, const struct timeval *wait);
00777 int  rb_w32_wrap_io_handle(HANDLE, int);
00778 int  rb_w32_unwrap_io_handle(int);
00779 WCHAR *rb_w32_mbstr_to_wstr(UINT, const char *, int, long *);
00780 char *rb_w32_wstr_to_mbstr(UINT, const WCHAR *, int, long *);
00781 
00782 /*
00783 == ***CAUTION***
00784 Since this function is very dangerous, ((*NEVER*))
00785 * lock any HANDLEs(i.e. Mutex, Semaphore, CriticalSection and so on) or,
00786 * use anything like TRAP_BEG...TRAP_END block structure,
00787 in asynchronous_func_t.
00788 */
00789 typedef uintptr_t (*asynchronous_func_t)(uintptr_t self, int argc, uintptr_t* argv);
00790 uintptr_t rb_w32_asynchronize(asynchronous_func_t func, uintptr_t self, int argc, uintptr_t* argv, uintptr_t intrval);
00791 
00792 RUBY_SYMBOL_EXPORT_END
00793 
00794 #ifdef __MINGW_ATTRIB_PURE
00795 /* License: Ruby's */
00796 /* get rid of bugs in math.h of mingw */
00797 #define frexp(_X, _Y) __extension__ ({\
00798     int intpart_frexp_bug = intpart_frexp_bug;\
00799     double result_frexp_bug = frexp((_X), &intpart_frexp_bug);\
00800     *(_Y) = intpart_frexp_bug;\
00801     result_frexp_bug;\
00802 })
00803 /* License: Ruby's */
00804 #define modf(_X, _Y) __extension__ ({\
00805     double intpart_modf_bug = intpart_modf_bug;\
00806     double result_modf_bug = modf((_X), &intpart_modf_bug);\
00807     *(_Y) = intpart_modf_bug;\
00808     result_modf_bug;\
00809 })
00810 #endif
00811 
00812 #if defined(__cplusplus)
00813 #if 0
00814 { /* satisfy cc-mode */
00815 #endif
00816 }  /* extern "C" { */
00817 #endif
00818 
00819 #if defined(__MINGW64__)
00820 /*
00821  * Use powl() instead of broken pow() of x86_64-w64-mingw32.
00822  * This workaround will fix test failures in test_bignum.rb,
00823  * test_fixnum.rb and test_float.rb etc.
00824  */
00825 static inline double
00826 rb_w32_pow(double x, double y)
00827 {
00828     return powl(x, y);
00829 }
00830 #elif defined(__MINGW64_VERSION_MAJOR)
00831 double rb_w32_pow(double x, double y);
00832 #endif
00833 #if defined(__MINGW64_VERSION_MAJOR) || defined(__MINGW64__)
00834 #define pow rb_w32_pow
00835 #endif
00836 
00837 #endif /* RUBY_WIN32_H */
00838 

Generated on 19 Jul 2016 for Ruby by  doxygen 1.4.7