Ruby 1.9.3p194(2012-04-20revision35410)

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