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