Ruby 2.0.0p353(2013-11-22revision43784)

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

win32.h
Go to the documentation of this file.
1 #ifndef RUBY_WIN32_H
2 #define RUBY_WIN32_H 1
3
4 #if defined(__cplusplus)
5 extern "C" {
6 #if 0
7 } /* satisfy cc-mode */
8 #endif
9 #endif
10
11 #if defined __GNUC__ && __GNUC__ >= 4
12 #pragma GCC visibility push(default)
13 #endif
14
15 /*
16 * Copyright (c) 1993, Intergraph Corporation
17 *
18 * You may distribute under the terms of either the GNU General Public
19 * License or the Artistic License, as specified in the perl README file.
20 *
21 */
22
23 /*
24 * Definitions for NT port of Perl
25 */
26
27
28 /*
29 * Ok now we can include the normal include files.
30 */
31
32 /* #include <stdarg.h> conflict with varargs.h? */
33 #if !defined(WSAAPI)
34 #if defined(__cplusplus) && defined(_MSC_VER)
35 extern "C++" { /* template without extern "C++" */
36 #endif
37 #if !defined(_WIN64) && !defined(WIN32)
38 #define WIN32
39 #endif
40 #include <winsock2.h>
41 #include <ws2tcpip.h>
42 #if defined(__cplusplus) && defined(_MSC_VER)
43 }
44 #endif
45 #endif
46
47 /*
48 * We're not using Microsoft's "extensions" to C for
49 * Structured Exception Handling (SEH) so we can nuke these
50 */
51 #undef try
52 #undef except
53 #undef finally
54 #undef leave
55
56 #include <stdio.h>
57 #include <stdlib.h>
58 #include <string.h>
59 #include <direct.h>
60 #include <process.h>
61 #include <time.h>
62 #if defined(__cplusplus) && defined(_MSC_VER) && _MSC_VER == 1200
63 extern "C++" { /* template without extern "C++" */
64 #endif
65 #include <math.h>
66 #if defined(__cplusplus) && defined(_MSC_VER) && _MSC_VER == 1200
67 }
68 #endif
69 #include <signal.h>
70 #include <sys/stat.h>
71 #include <sys/types.h>
72 #ifdef HAVE_SYS_UTIME_H
73 # include <sys/utime.h>
74 #else
75 # include <utime.h>
76 #endif
77 #include <io.h>
78 #include <malloc.h>
79 #if defined __MINGW32__ || __BORLANDC__ >= 0x0580
80 # include <stdint.h>
81 #else
82 # if !defined(_INTPTR_T_DEFINED)
83 # ifdef _WIN64
84 typedef __int64 intptr_t;
85 # else
86 typedef int intptr_t;
87 # endif
88 # define _INTPTR_T_DEFINED
89 # endif
90 # if !defined(_UINTPTR_T_DEFINED)
91 # ifdef _WIN64
92 typedef unsigned __int64 uintptr_t;
93 # else
94 typedef unsigned int uintptr_t;
95 # endif
96 # define _UINTPTR_T_DEFINED
97 # endif
98 #endif
99 #ifndef __MINGW32__
100 # define mode_t int
101 #endif
102 #ifdef HAVE_UNISTD_H
103 # include <unistd.h>
104 #endif
105
106 #define rb_w32_iswinnt() TRUE
107 #define rb_w32_iswin95() FALSE
108
109 #define WNOHANG -1
110
111 #undef getc
112 #undef putc
113 #undef fgetc
114 #undef fputc
115 #undef getchar
116 #undef putchar
117 #undef fgetchar
118 #undef fputchar
119 #undef utime
120 #undef lseek
121 #undef stat
122 #undef fstat
123 #define getc(_stream) rb_w32_getc(_stream)
124 #define getchar() rb_w32_getc(stdin)
125 #define putc(_c, _stream) rb_w32_putc(_c, _stream)
126 #define putchar(_c) rb_w32_putc(_c, stdout)
127 #ifdef RUBY_EXPORT
128 #define fgetc(_stream) getc(_stream)
129 #define fputc(_c, _stream) putc(_c, _stream)
130 #define fgetchar() getchar()
131 #define fputchar(_c) putchar(_c)
132 #define utime(_p, _t) rb_w32_utime(_p, _t)
133 #define lseek(_f, _o, _w) _lseeki64(_f, _o, _w)
134
135 #define pipe(p) rb_w32_pipe(p)
136 #define open rb_w32_open
137 #define close(h) rb_w32_close(h)
138 #define fclose(f) rb_w32_fclose(f)
139 #define read(f, b, s) rb_w32_read(f, b, s)
140 #define write(f, b, s) rb_w32_write(f, b, s)
141 #define getpid() rb_w32_getpid()
142 #define getppid() rb_w32_getppid()
143 #define sleep(x) rb_w32_Sleep((x)*1000)
144 #define Sleep(msec) (void)rb_w32_Sleep(msec)
145 #define fstati64(fd,st) rb_w32_fstati64(fd,st)
146 #ifdef __BORLANDC__
147 #define creat(p, m) _creat(p, m)
148 #define eof() _eof()
149 #define filelength(h) _filelength(h)
150 #define mktemp(t) _mktemp(t)
151 #define tell(h) _tell(h)
152 #define _open _sopen
153 #define sopen _sopen
154 #undef fopen
155 #define fopen(p, m) rb_w32_fopen(p, m)
156 #undef fdopen
157 #define fdopen(h, m) rb_w32_fdopen(h, m)
158 #undef fsopen
159 #define fsopen(p, m, sh) rb_w32_fsopen(p, m, sh)
160 #endif /* __BORLANDC__ */
161
162 #undef execv
163 #define execv(path,argv) rb_w32_aspawn(P_OVERLAY,path,argv)
164 #if !defined(__BORLANDC__)
165 #undef isatty
166 #define isatty(h) rb_w32_isatty(h)
167 #endif /* __BORLANDC__ */
168
169 #undef mkdir
170 #define mkdir(p, m) rb_w32_mkdir(p, m)
171 #undef rmdir
172 #define rmdir(p) rb_w32_rmdir(p)
173 #undef unlink
174 #define unlink(p) rb_w32_unlink(p)
175 #endif /* RUBY_EXPORT */
176
177 #if SIZEOF_OFF_T == 8
178 #define off_t __int64
179 #define stat stati64
180 #define fstat(fd,st) fstati64(fd,st)
181 #if defined(__BORLANDC__)
182 #define stati64(path, st) rb_w32_stati64(path, st)
183 #elif !defined(_MSC_VER) || RT_VER < 80
184 #define stati64 _stati64
185 #ifndef _stati64
186 #define _stati64(path, st) rb_w32_stati64(path, st)
187 #endif
188 #else
189 #define stati64 _stat64
190 #define _stat64(path, st) rb_w32_stati64(path, st)
191 #endif
192 #else
193 #define stat(path,st) rb_w32_stat(path,st)
194 #define fstat(fd,st) rb_w32_fstat(fd,st)
195 extern int rb_w32_stat(const char *, struct stat *);
196 extern int rb_w32_fstat(int, struct stat *);
197 #endif
198 #define access(path,mode) rb_w32_access(path,mode)
199
200 #define strcasecmp _stricmp
201 #define strncasecmp _strnicmp
202 #define fsync _commit
203
204 struct timezone;
205
206 #ifdef __MINGW32__
207 #undef isascii
208 #define isascii __isascii
209 #endif
210
211 struct iovec {
212 void *iov_base;
213 size_t iov_len;
214 };
215 struct msghdr {
216 void *msg_name;
217 int msg_namelen;
218 struct iovec *msg_iov;
219 int msg_iovlen;
220 void *msg_control;
221 int msg_controllen;
222 int msg_flags;
223 };
224
225 extern DWORD rb_w32_osid(void);
226 extern int rb_w32_cmdvector(const char *, char ***);
227 extern rb_pid_t rb_w32_pipe_exec(const char *, const char *, int, int *, int *);
228 extern int flock(int fd, int oper);
229 extern int rb_w32_io_cancelable_p(int);
230 extern int rb_w32_is_socket(int);
231 extern int WSAAPI rb_w32_accept(int, struct sockaddr *, int *);
232 extern int WSAAPI rb_w32_bind(int, const struct sockaddr *, int);
233 extern int WSAAPI rb_w32_connect(int, const struct sockaddr *, int);
234 extern void rb_w32_fdset(int, fd_set*);
235 extern void rb_w32_fdclr(int, fd_set*);
236 extern int rb_w32_fdisset(int, fd_set*);
237 extern int WSAAPI rb_w32_select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
238 extern int WSAAPI rb_w32_getpeername(int, struct sockaddr *, int *);
239 extern int WSAAPI rb_w32_getsockname(int, struct sockaddr *, int *);
240 extern int WSAAPI rb_w32_getsockopt(int, int, int, char *, int *);
241 extern int WSAAPI rb_w32_ioctlsocket(int, long, u_long *);
242 extern int WSAAPI rb_w32_listen(int, int);
243 extern int WSAAPI rb_w32_recv(int, char *, int, int);
244 extern int WSAAPI rb_w32_recvfrom(int, char *, int, int, struct sockaddr *, int *);
245 extern int WSAAPI rb_w32_send(int, const char *, int, int);
246 extern int WSAAPI rb_w32_sendto(int, const char *, int, int, const struct sockaddr *, int);
247 extern int recvmsg(int, struct msghdr *, int);
248 extern int sendmsg(int, const struct msghdr *, int);
249 extern int WSAAPI rb_w32_setsockopt(int, int, int, const char *, int);
250 extern int WSAAPI rb_w32_shutdown(int, int);
251 extern int WSAAPI rb_w32_socket(int, int, int);
252 extern SOCKET rb_w32_get_osfhandle(int);
253 extern struct hostent *WSAAPI rb_w32_gethostbyaddr(const char *, int, int);
254 extern struct hostent *WSAAPI rb_w32_gethostbyname(const char *);
255 extern int WSAAPI rb_w32_gethostname(char *, int);
256 extern struct protoent *WSAAPI rb_w32_getprotobyname(const char *);
257 extern struct protoent *WSAAPI rb_w32_getprotobynumber(int);
258 extern struct servent *WSAAPI rb_w32_getservbyname(const char *, const char *);
259 extern struct servent *WSAAPI rb_w32_getservbyport(int, const char *);
260 extern int rb_w32_socketpair(int, int, int, int *);
261 extern char * rb_w32_getcwd(char *, int);
262 extern char * rb_w32_ugetenv(const char *);
263 extern char * rb_w32_getenv(const char *);
264 extern int rb_w32_rename(const char *, const char *);
265 extern int rb_w32_urename(const char *, const char *);
266 extern char **rb_w32_get_environ(void);
267 extern void rb_w32_free_environ(char **);
268 extern int rb_w32_map_errno(DWORD);
269 extern const char *WSAAPI rb_w32_inet_ntop(int,const void *,char *,size_t);
270 extern DWORD rb_w32_osver(void);
271
272 extern int chown(const char *, int, int);
273 extern int rb_w32_uchown(const char *, int, int);
274 extern int link(const char *, const char *);
275 extern int rb_w32_ulink(const char *, const char *);
276 extern int gettimeofday(struct timeval *, struct timezone *);
277 extern rb_pid_t waitpid (rb_pid_t, int *, int);
278 extern rb_pid_t rb_w32_spawn(int, const char *, const char*);
279 extern rb_pid_t rb_w32_aspawn(int, const char *, char *const *);
280 extern rb_pid_t rb_w32_aspawn_flags(int, const char *, char *const *, DWORD);
281 extern int kill(int, int);
282 extern int fcntl(int, int, ...);
283 extern rb_pid_t rb_w32_getpid(void);
284 extern rb_pid_t rb_w32_getppid(void);
285 #if !defined(__BORLANDC__)
286 extern int rb_w32_isatty(int);
287 #endif
288 extern int rb_w32_uchdir(const char *);
289 extern int rb_w32_mkdir(const char *, int);
290 extern int rb_w32_umkdir(const char *, int);
291 extern int rb_w32_rmdir(const char *);
292 extern int rb_w32_urmdir(const char *);
293 extern int rb_w32_unlink(const char *);
294 extern int rb_w32_uunlink(const char *);
295 extern int rb_w32_uchmod(const char *, int);
296 extern int rb_w32_stati64(const char *, struct stati64 *);
297 extern int rb_w32_ustati64(const char *, struct stati64 *);
298 extern int rb_w32_access(const char *, int);
299 extern int rb_w32_uaccess(const char *, int);
300 extern char rb_w32_fd_is_text(int);
301 extern int rb_w32_fstati64(int, struct stati64 *);
302
303 #ifdef __BORLANDC__
304 extern off_t _lseeki64(int, off_t, int);
305 extern FILE *rb_w32_fopen(const char *, const char *);
306 extern FILE *rb_w32_fdopen(int, const char *);
307 extern FILE *rb_w32_fsopen(const char *, const char *, int);
308 #endif
309
310 #include <float.h>
311
312 #if defined _MSC_VER && _MSC_VER >= 1800 && defined INFINITY
313 #pragma warning(push)
314 #pragma warning(disable:4756)
315 static inline float
316 rb_infinity_float(void)
317 {
318 return INFINITY;
319 }
320 #pragma warning(pop)
321 #undef INFINITY
322 #define INFINITY rb_infinity_float()
323 #endif
324
325 #if !defined __MINGW32__ || defined __NO_ISOCEXT
326 #ifndef isnan
327 #define isnan(x) _isnan(x)
328 #endif
329 static inline int
330 finite(double x)
331 {
332 return _finite(x);
333 }
334 #ifndef copysign
335 #define copysign(a, b) _copysign(a, b)
336 #endif
337 static inline double
338 scalb(double a, long b)
339 {
340 return _scalb(a, b);
341 }
342 #endif
343
344 #if !defined S_IFIFO && defined _S_IFIFO
345 #define S_IFIFO _S_IFIFO
346 #endif
347
348 #if 0 && defined __BORLANDC__
349 #undef S_ISDIR
350 #undef S_ISFIFO
351 #undef S_ISBLK
352 #undef S_ISCHR
353 #undef S_ISREG
354 #define S_ISDIR(m) (((unsigned short)(m) & S_IFMT) == S_IFDIR)
355 #define S_ISFIFO(m) (((unsigned short)(m) & S_IFMT) == S_IFIFO)
356 #define S_ISBLK(m) (((unsigned short)(m) & S_IFMT) == S_IFBLK)
357 #define S_ISCHR(m) (((unsigned short)(m) & S_IFMT) == S_IFCHR)
358 #define S_ISREG(m) (((unsigned short)(m) & S_IFMT) == S_IFREG)
359 #endif
360
361 #if !defined S_IRUSR && !defined __MINGW32__
362 #define S_IRUSR 0400
363 #endif
364 #ifndef S_IRGRP
365 #define S_IRGRP 0040
366 #endif
367 #ifndef S_IROTH
368 #define S_IROTH 0004
369 #endif
370
371 #if !defined S_IWUSR && !defined __MINGW32__
372 #define S_IWUSR 0200
373 #endif
374 #ifndef S_IWGRP
375 #define S_IWGRP 0020
376 #endif
377 #ifndef S_IWOTH
378 #define S_IWOTH 0002
379 #endif
380
381 #if !defined S_IXUSR && !defined __MINGW32__
382 #define S_IXUSR 0100
383 #endif
384 #ifndef S_IXGRP
385 #define S_IXGRP 0010
386 #endif
387 #ifndef S_IXOTH
388 #define S_IXOTH 0001
389 #endif
390
391 /*
392 * define this so we can do inplace editing
393 */
394
395 #define SUFFIX
396
397 extern int rb_w32_ftruncate(int fd, off_t length);
398 extern int rb_w32_truncate(const char *path, off_t length);
399 extern off_t rb_w32_ftello(FILE *stream);
400 extern int rb_w32_fseeko(FILE *stream, off_t offset, int whence);
401
402 #undef HAVE_FTRUNCATE
403 #define HAVE_FTRUNCATE 1
404 #if defined HAVE_FTRUNCATE64
405 #define ftruncate ftruncate64
406 #else
407 #define ftruncate rb_w32_ftruncate
408 #endif
409
410 #undef HAVE_TRUNCATE
411 #define HAVE_TRUNCATE 1
412 #if defined HAVE_TRUNCATE64
413 #define truncate truncate64
414 #else
415 #define truncate rb_w32_truncate
416 #endif
417
418 #undef HAVE_FSEEKO
419 #define HAVE_FSEEKO 1
420 #if defined HAVE_FSEEKO64
421 #define fseeko fseeko64
422 #else
423 #define fseeko rb_w32_fseeko
424 #endif
425
426 #undef HAVE_FTELLO
427 #define HAVE_FTELLO 1
428 #if defined HAVE_FTELLO64
429 #define ftello ftello64
430 #else
431 #define ftello rb_w32_ftello
432 #endif
433
434 /*
435 * stubs
436 */
437 extern int ioctl (int, int, ...);
438 extern rb_uid_t getuid (void);
439 extern rb_uid_t geteuid (void);
440 extern rb_gid_t getgid (void);
441 extern rb_gid_t getegid (void);
442 extern int setuid (rb_uid_t);
443 extern int setgid (rb_gid_t);
444
445 extern char *rb_w32_strerror(int);
446
447 #ifdef RUBY_EXPORT
448 #define strerror(e) rb_w32_strerror(e)
449 #endif
450
451 #define PIPE_BUF 1024
452
453 #define LOCK_SH 1
454 #define LOCK_EX 2
455 #define LOCK_NB 4
456 #define LOCK_UN 8
457
458
459 #ifndef SIGINT
460 #define SIGINT 2
461 #endif
462 #ifndef SIGKILL
463 #define SIGKILL 9
464 #endif
465
466
467 /* #undef va_start */
468 /* #undef va_end */
469
470 /* winsock error map */
471 #include <errno.h>
472
473 #ifndef EWOULDBLOCK
474 # define EWOULDBLOCK WSAEWOULDBLOCK
475 #endif
476 #ifndef EINPROGRESS
477 # define EINPROGRESS WSAEINPROGRESS
478 #endif
479 #ifndef EALREADY
480 # define EALREADY WSAEALREADY
481 #endif
482 #ifndef ENOTSOCK
483 # define ENOTSOCK WSAENOTSOCK
484 #endif
485 #ifndef EDESTADDRREQ
486 # define EDESTADDRREQ WSAEDESTADDRREQ
487 #endif
488 #ifndef EMSGSIZE
489 # define EMSGSIZE WSAEMSGSIZE
490 #endif
491 #ifndef EPROTOTYPE
492 # define EPROTOTYPE WSAEPROTOTYPE
493 #endif
494 #ifndef ENOPROTOOPT
495 # define ENOPROTOOPT WSAENOPROTOOPT
496 #endif
497 #ifndef EPROTONOSUPPORT
498 # define EPROTONOSUPPORT WSAEPROTONOSUPPORT
499 #endif
500 #ifndef ESOCKTNOSUPPORT
501 # define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT
502 #endif
503 #ifndef EOPNOTSUPP
504 # define EOPNOTSUPP WSAEOPNOTSUPP
505 #endif
506 #ifndef EPFNOSUPPORT
507 # define EPFNOSUPPORT WSAEPFNOSUPPORT
508 #endif
509 #ifndef EAFNOSUPPORT
510 # define EAFNOSUPPORT WSAEAFNOSUPPORT
511 #endif
512 #ifndef EADDRINUSE
513 # define EADDRINUSE WSAEADDRINUSE
514 #endif
515 #ifndef EADDRNOTAVAIL
516 # define EADDRNOTAVAIL WSAEADDRNOTAVAIL
517 #endif
518 #ifndef ENETDOWN
519 # define ENETDOWN WSAENETDOWN
520 #endif
521 #ifndef ENETUNREACH
522 # define ENETUNREACH WSAENETUNREACH
523 #endif
524 #ifndef ENETRESET
525 # define ENETRESET WSAENETRESET
526 #endif
527 #ifndef ECONNABORTED
528 # define ECONNABORTED WSAECONNABORTED
529 #endif
530 #ifndef ECONNRESET
531 # define ECONNRESET WSAECONNRESET
532 #endif
533 #ifndef ENOBUFS
534 # define ENOBUFS WSAENOBUFS
535 #endif
536 #ifndef EISCONN
537 # define EISCONN WSAEISCONN
538 #endif
539 #ifndef ENOTCONN
540 # define ENOTCONN WSAENOTCONN
541 #endif
542 #ifndef ESHUTDOWN
543 # define ESHUTDOWN WSAESHUTDOWN
544 #endif
545 #ifndef ETOOMANYREFS
546 # define ETOOMANYREFS WSAETOOMANYREFS
547 #endif
548 #ifndef ETIMEDOUT
549 # define ETIMEDOUT WSAETIMEDOUT
550 #endif
551 #ifndef ECONNREFUSED
552 # define ECONNREFUSED WSAECONNREFUSED
553 #endif
554 #ifndef ELOOP
555 # define ELOOP WSAELOOP
556 #endif
557 /*#define ENAMETOOLONG WSAENAMETOOLONG*/
558 #ifndef EHOSTDOWN
559 # define EHOSTDOWN WSAEHOSTDOWN
560 #endif
561 #ifndef EHOSTUNREACH
562 # define EHOSTUNREACH WSAEHOSTUNREACH
563 #endif
564 /*#define ENOTEMPTY WSAENOTEMPTY*/
565 #ifndef EPROCLIM
566 # define EPROCLIM WSAEPROCLIM
567 #endif
568 #ifndef EUSERS
569 # define EUSERS WSAEUSERS
570 #endif
571 #ifndef EDQUOT
572 # define EDQUOT WSAEDQUOT
573 #endif
574 #ifndef ESTALE
575 # define ESTALE WSAESTALE
576 #endif
577 #ifndef EREMOTE
578 # define EREMOTE WSAEREMOTE
579 #endif
580
581 #define F_DUPFD 0
582 #if 0
583 #define F_GETFD 1
584 #define F_SETFD 2
585 #define F_GETFL 3
586 #endif
587 #define F_SETFL 4
588 #if 0
589 #define FD_CLOEXEC 1 /* F_GETFD, F_SETFD */
590 #endif
591 #define O_NONBLOCK 1
592
593 #undef FD_SET
594 #define FD_SET(fd, set) do {\
595 unsigned int i;\
596 SOCKET s = _get_osfhandle(fd);\
597 \
598 for (i = 0; i < (set)->fd_count; i++) {\
599 if ((set)->fd_array[i] == s) {\
600 break;\
601 }\
602 }\
603 if (i == (set)->fd_count) {\
604 if ((set)->fd_count < FD_SETSIZE) {\
605 (set)->fd_array[i] = s;\
606 (set)->fd_count++;\
607 }\
608 }\
609 } while(0)
610
611 #undef FD_CLR
612 #define FD_CLR(f, s) rb_w32_fdclr(f, s)
613
614 #undef FD_ISSET
615 #define FD_ISSET(f, s) rb_w32_fdisset(f, s)
616
617 #ifdef RUBY_EXPORT
618 #undef inet_ntop
619 #define inet_ntop(f,a,n,l) rb_w32_inet_ntop(f,a,n,l)
620
621 #undef accept
622 #define accept(s, a, l) rb_w32_accept(s, a, l)
623
624 #undef bind
625 #define bind(s, a, l) rb_w32_bind(s, a, l)
626
627 #undef connect
628 #define connect(s, a, l) rb_w32_connect(s, a, l)
629
630 #undef select
631 #define select(n, r, w, e, t) rb_w32_select(n, r, w, e, t)
632
633 #undef getpeername
634 #define getpeername(s, a, l) rb_w32_getpeername(s, a, l)
635
636 #undef getsockname
637 #define getsockname(s, a, l) rb_w32_getsockname(s, a, l)
638
639 #undef getsockopt
640 #define getsockopt(s, v, n, o, l) rb_w32_getsockopt(s, v, n, o, l)
641
642 #undef ioctlsocket
643 #define ioctlsocket(s, c, a) rb_w32_ioctlsocket(s, c, a)
644
645 #undef listen
646 #define listen(s, b) rb_w32_listen(s, b)
647
648 #undef recv
649 #define recv(s, b, l, f) rb_w32_recv(s, b, l, f)
650
651 #undef recvfrom
652 #define recvfrom(s, b, l, f, fr, frl) rb_w32_recvfrom(s, b, l, f, fr, frl)
653
654 #undef send
655 #define send(s, b, l, f) rb_w32_send(s, b, l, f)
656
657 #undef sendto
658 #define sendto(s, b, l, f, t, tl) rb_w32_sendto(s, b, l, f, t, tl)
659
660 #undef setsockopt
661 #define setsockopt(s, v, n, o, l) rb_w32_setsockopt(s, v, n, o, l)
662
663 #undef shutdown
664 #define shutdown(s, h) rb_w32_shutdown(s, h)
665
666 #undef socket
667 #define socket(s, t, p) rb_w32_socket(s, t, p)
668
669 #undef gethostbyaddr
670 #define gethostbyaddr(a, l, t) rb_w32_gethostbyaddr(a, l, t)
671
672 #undef gethostbyname
673 #define gethostbyname(n) rb_w32_gethostbyname(n)
674
675 #undef gethostname
676 #define gethostname(n, l) rb_w32_gethostname(n, l)
677
678 #undef getprotobyname
679 #define getprotobyname(n) rb_w32_getprotobyname(n)
680
681 #undef getprotobynumber
682 #define getprotobynumber(n) rb_w32_getprotobynumber(n)
683
684 #undef getservbyname
685 #define getservbyname(n, p) rb_w32_getservbyname(n, p)
686
687 #undef getservbyport
688 #define getservbyport(p, pr) rb_w32_getservbyport(p, pr)
689
690 #undef socketpair
691 #define socketpair(a, t, p, s) rb_w32_socketpair(a, t, p, s)
692
693 #undef get_osfhandle
694 #define get_osfhandle(h) rb_w32_get_osfhandle(h)
695
696 #undef getcwd
697 #define getcwd(b, s) rb_w32_getcwd(b, s)
698
699 #undef getenv
700 #define getenv(n) rb_w32_getenv(n)
701
702 #undef rename
703 #define rename(o, n) rb_w32_rename(o, n)
704
705 #undef times
706 #define times(t) rb_w32_times(t)
707 #endif
708
709 struct tms {
710 long tms_utime;
711 long tms_stime;
712 long tms_cutime;
713 long tms_cstime;
714 };
715
716 int rb_w32_times(struct tms *);
717
718 struct tm *gmtime_r(const time_t *, struct tm *);
719 struct tm *localtime_r(const time_t *, struct tm *);
720
721 /* thread stuff */
722 int rb_w32_sleep(unsigned long msec);
723 int rb_w32_putc(int, FILE*);
724 int rb_w32_getc(FILE*);
725 int rb_w32_open(const char *, int, ...);
726 int rb_w32_uopen(const char *, int, ...);
727 int rb_w32_wopen(const WCHAR *, int, ...);
728 int rb_w32_close(int);
729 int rb_w32_fclose(FILE*);
730 int rb_w32_pipe(int[2]);
731 ssize_t rb_w32_read(int, void *, size_t);
732 ssize_t rb_w32_write(int, const void *, size_t);
733 int rb_w32_utime(const char *, const struct utimbuf *);
734 int rb_w32_uutime(const char *, const struct utimbuf *);
735 long rb_w32_write_console(uintptr_t, int); /* use uintptr_t instead of VALUE because it's not defined yet here */
736 int WINAPI rb_w32_Sleep(unsigned long msec);
737 int rb_w32_wait_events_blocking(HANDLE *events, int num, DWORD timeout);
738 int rb_w32_time_subtract(struct timeval *rest, const struct timeval *wait);
739 int rb_w32_wrap_io_handle(HANDLE, int);
740 int rb_w32_unwrap_io_handle(int);
741
742 /*
743 == ***CAUTION***
744 Since this function is very dangerous, ((*NEVER*))
745 * lock any HANDLEs(i.e. Mutex, Semaphore, CriticalSection and so on) or,
746 * use anything like TRAP_BEG...TRAP_END block structure,
747 in asynchronous_func_t.
748 */
749 typedef uintptr_t (*asynchronous_func_t)(uintptr_t self, int argc, uintptr_t* argv);
750 uintptr_t rb_w32_asynchronize(asynchronous_func_t func, uintptr_t self, int argc, uintptr_t* argv, uintptr_t intrval);
751
752 #if defined __GNUC__ && __GNUC__ >= 4
753 #pragma GCC visibility pop
754 #endif
755
756 #ifdef __MINGW_ATTRIB_PURE
757 /* License: Ruby's */
758 /* get rid of bugs in math.h of mingw */
759 #define frexp(_X, _Y) __extension__ ({\
760 int intpart_frexp_bug = intpart_frexp_bug;\
761 double result_frexp_bug = frexp((_X), &intpart_frexp_bug);\
762 *(_Y) = intpart_frexp_bug;\
763 result_frexp_bug;\
764 })
765 /* License: Ruby's */
766 #define modf(_X, _Y) __extension__ ({\
767 double intpart_modf_bug = intpart_modf_bug;\
768 double result_modf_bug = modf((_X), &intpart_modf_bug);\
769 *(_Y) = intpart_modf_bug;\
770 result_modf_bug;\
771 })
772 #endif
773
774 #if defined(__cplusplus)
775 #if 0
776 { /* satisfy cc-mode */
777 #endif
778 } /* extern "C" { */
779 #endif
780
781 #if defined(__MINGW64__)
782 /*
783 * Use powl() instead of broken pow() of x86_64-w64-mingw32.
784 * This workaround will fix test failures in test_bignum.rb,
785 * test_fixnum.rb and test_float.rb etc.
786 */
787 static inline double
788 rb_w32_pow(double x, double y)
789 {
790 return powl(x, y);
791 }
792 #elif defined(__MINGW64_VERSION_MAJOR)
793 /*
794 * Set floating point precision for pow() of mingw-w64 x86.
795 * With default precision the result is not proper on WinXP.
796 */
797 static inline double
798 rb_w32_pow(double x, double y)
799 {
800 double r;
801 unsigned int default_control = _controlfp(0, 0);
802 _controlfp(_PC_64, _MCW_PC);
803 r = pow(x, y);
804 /* Restore setting */
805 _controlfp(default_control, _MCW_PC);
806 return r;
807 }
808 #endif
809 #if defined(__MINGW64_VERSION_MAJOR) || defined(__MINGW64__)
810 #define pow rb_w32_pow
811 #endif
812
813 #endif /* RUBY_WIN32_H */
iovec::iov_len
size_t iov_len
Definition: win32.h:213
flock
RUBY_EXTERN int flock(int, int)
Definition: flock.c:125
rb_w32_ugetenv
char * rb_w32_ugetenv(const char *)
Definition: win32.c:4262
gettimeofday
int gettimeofday(struct timeval *, struct timezone *)
Definition: win32.c:4013
rb_w32_wait_events_blocking
int rb_w32_wait_events_blocking(HANDLE *events, int num, DWORD timeout)
ioctl
int ioctl(int, int,...)
Definition: win32.c:2438
rb_w32_getc
int rb_w32_getc(FILE *)
Definition: win32.c:4953
msghdr::msg_iovlen
int msg_iovlen
Definition: win32.h:219
iovec::iov_base
void * iov_base
Definition: win32.h:212
msghdr::msg_control
void * msg_control
Definition: win32.h:220
rb_w32_getppid
rb_pid_t rb_w32_getppid(void)
Definition: win32.c:5131
getuid
rb_uid_t getuid(void)
Definition: win32.c:2392
rb_w32_write
ssize_t rb_w32_write(int, const void *, size_t)
Definition: win32.c:6044
rb_w32_fstat
int rb_w32_fstat(int, struct stat *)
Definition: win32.c:4441
sendmsg
int sendmsg(int, const struct msghdr *, int)
Definition: win32.c:3337
rb_w32_connect
int WSAAPI rb_w32_connect(int, const struct sockaddr *, int)
Definition: win32.c:2961
rb_w32_bind
int WSAAPI rb_w32_bind(int, const struct sockaddr *, int)
Definition: win32.c:2942
rb_w32_sendto
int WSAAPI rb_w32_sendto(int, const char *, int, int, const struct sockaddr *, int)
Definition: win32.c:3235
tms::tms_stime
long tms_stime
Definition: win32.h:711
finite
RUBY_EXTERN int finite(double)
Definition: finite.c:6
msghdr::msg_namelen
int msg_namelen
Definition: win32.h:217
func
SSL_METHOD *(* func)(void)
Definition: ossl_ssl.c:108
rb_w32_fseeko
int rb_w32_fseeko(FILE *stream, off_t offset, int whence)
msghdr
Definition: win32.h:215
rb_w32_ustati64
int rb_w32_ustati64(const char *, struct stati64 *)
Definition: win32.c:4705
rb_w32_wrap_io_handle
int rb_w32_wrap_io_handle(HANDLE, int)
Definition: win32.c:6694
rb_w32_get_osfhandle
SOCKET rb_w32_get_osfhandle(int)
Definition: win32.c:958
a
Real * a
Definition: bigdecimal.c:1182
msghdr::msg_name
void * msg_name
Definition: win32.h:216
rb_w32_umkdir
int rb_w32_umkdir(const char *, int)
Definition: win32.c:6308
rb_w32_pipe_exec
rb_pid_t rb_w32_pipe_exec(const char *, const char *, int, int *, int *)
fcntl
int fcntl(int, int,...)
Definition: win32.c:3835
path
gz path
Definition: zlib.c:2279
rb_w32_read
ssize_t rb_w32_read(int, void *, size_t)
Definition: win32.c:5907
rb_w32_aspawn_flags
rb_pid_t rb_w32_aspawn_flags(int, const char *, char *const *, DWORD)
Definition: win32.c:1287
kill
int kill(int, int)
Definition: win32.c:4079
localtime_r
static struct tm * localtime_r(const time_t *t, struct tm *tm)
Definition: date_core.c:3616
rb_w32_getsockopt
int WSAAPI rb_w32_getsockopt(int, int, int, char *, int *)
Definition: win32.c:3036
rb_w32_urename
int rb_w32_urename(const char *, const char *)
Definition: win32.c:4360
rb_w32_fdisset
int rb_w32_fdisset(int, fd_set *)
Definition: win32.c:2472
rb_w32_getservbyname
struct servent *WSAAPI rb_w32_getservbyname(const char *, const char *)
Definition: win32.c:3592
msghdr::msg_iov
struct iovec * msg_iov
Definition: win32.h:218
rb_w32_pipe
int rb_w32_pipe(int[2])
Definition: win32.c:5430
rb_w32_open
int rb_w32_open(const char *, int,...)
Definition: win32.c:5210
rb_w32_select
int WSAAPI rb_w32_select(int, fd_set *, fd_set *, fd_set *, struct timeval *)
Definition: win32.c:2882
rb_w32_free_environ
void rb_w32_free_environ(char **)
Definition: win32.c:5113
r
r
Definition: bigdecimal.c:1196
rb_w32_accept
int WSAAPI rb_w32_accept(int, struct sockaddr *, int *)
Definition: win32.c:2906
rb_w32_getprotobynumber
struct protoent *WSAAPI rb_w32_getprotobynumber(int)
Definition: win32.c:3574
rb_w32_getpid
rb_pid_t rb_w32_getpid(void)
Definition: win32.c:5123
rb_w32_uaccess
int rb_w32_uaccess(const char *, int)
Definition: win32.c:4748
rb_w32_map_errno
int rb_w32_map_errno(DWORD)
Definition: win32.c:223
recvmsg
int recvmsg(int, struct msghdr *, int)
Definition: win32.c:3279
msghdr::msg_flags
int msg_flags
Definition: win32.h:222
gmtime_r
static struct tm * gmtime_r(const time_t *t, struct tm *tm)
Definition: date_core.c:3607
io.h
utime.h
rb_w32_fdclr
void rb_w32_fdclr(int, fd_set *)
Definition: win32.c:2454
rb_w32_times
int rb_w32_times(struct tms *)
Definition: win32.c:4900
rb_w32_socket
int WSAAPI rb_w32_socket(int, int, int)
Definition: win32.c:3473
rb_w32_is_socket
int rb_w32_is_socket(int)
Definition: win32.c:2309
__sFILE
Definition: vsnprintf.c:175
rb_w32_cmdvector
int rb_w32_cmdvector(const char *, char ***)
Definition: win32.c:1491
rb_w32_getsockname
int WSAAPI rb_w32_getsockname(int, struct sockaddr *, int *)
Definition: win32.c:3003
rb_w32_inet_ntop
const char *WSAAPI rb_w32_inet_ntop(int, const void *, char *, size_t)
Definition: win32.c:6550
rb_w32_gethostbyaddr
struct hostent *WSAAPI rb_w32_gethostbyaddr(const char *, int, int)
Definition: win32.c:3502
getegid
rb_gid_t getegid(void)
Definition: win32.c:2413
utimbuf
Definition: file.c:2361
rb_w32_gethostbyname
struct hostent *WSAAPI rb_w32_gethostbyname(const char *)
Definition: win32.c:3520
rb_w32_wopen
int rb_w32_wopen(const WCHAR *, int,...)
Definition: win32.c:5235
asynchronous_func_t
uintptr_t(* asynchronous_func_t)(uintptr_t self, int argc, uintptr_t *argv)
Definition: win32.h:749
DWORD
IUnknown DWORD
Definition: win32ole.c:149
rb_w32_send
int WSAAPI rb_w32_send(int, const char *, int, int)
Definition: win32.c:3228
rb_w32_spawn
rb_pid_t rb_w32_spawn(int, const char *, const char *)
Definition: win32.c:1180
rb_w32_ftello
off_t rb_w32_ftello(FILE *stream)
Definition: win32.c:4880
rb_w32_Sleep
int WINAPI rb_w32_Sleep(unsigned long msec)
rb_w32_recvfrom
int WSAAPI rb_w32_recvfrom(int, char *, int, int, struct sockaddr *, int *)
Definition: win32.c:3220
wait
VALUE wait
Definition: tcltklib.c:1759
chown
int chown(const char *, int, int)
Definition: win32.c:4065
unistd.h
signal.h
rb_w32_listen
int WSAAPI rb_w32_listen(int, int)
Definition: win32.c:3072
rb_w32_sleep
int rb_w32_sleep(unsigned long msec)
rb_w32_mkdir
int rb_w32_mkdir(const char *, int)
Definition: win32.c:6322
rb_w32_uutime
int rb_w32_uutime(const char *, const struct utimbuf *)
Definition: win32.c:6246
rb_w32_rmdir
int rb_w32_rmdir(const char *)
Definition: win32.c:6357
link
int link(const char *, const char *)
Definition: win32.c:4235
rb_w32_unwrap_io_handle
int rb_w32_unwrap_io_handle(int)
Definition: win32.c:6716
argv
VALUE * argv
Definition: tcltklib.c:1971
rb_w32_putc
int rb_w32_putc(int, FILE *)
Definition: win32.c:4974
rb_w32_fstati64
int rb_w32_fstati64(int, struct stati64 *)
Definition: win32.c:4465
rb_w32_time_subtract
int rb_w32_time_subtract(struct timeval *rest, const struct timeval *wait)
Definition: win32.c:2704
timeval
Definition: ossl_asn1.c:16
rb_w32_unlink
int rb_w32_unlink(const char *)
Definition: win32.c:6420
off_t
#define off_t
Definition: io.c:65
rb_w32_truncate
int rb_w32_truncate(const char *path, off_t length)
Definition: win32.c:4792
rb_w32_urmdir
int rb_w32_urmdir(const char *)
Definition: win32.c:6371
rb_w32_get_environ
char ** rb_w32_get_environ(void)
Definition: win32.c:5076
length
size_t length
Definition: tcltklib.c:4559
setgid
int setgid(rb_gid_t)
Definition: win32.c:2427
uintptr_t
unsigned int uintptr_t
Definition: win32.h:94
rb_w32_uopen
int rb_w32_uopen(const char *, int,...)
Definition: win32.c:5162
rb_w32_stati64
int rb_w32_stati64(const char *, struct stati64 *)
Definition: win32.c:4719
argc
int argc
Definition: tcltklib.c:1970
geteuid
rb_uid_t geteuid(void)
Definition: win32.c:2399
rb_w32_uchmod
int rb_w32_uchmod(const char *, int)
Definition: win32.c:6434
rb_w32_getenv
char * rb_w32_getenv(const char *)
Definition: win32.c:4300
intptr_t
int intptr_t
Definition: win32.h:86
iovec
Definition: win32.h:211
rb_w32_getprotobyname
struct protoent *WSAAPI rb_w32_getprotobyname(const char *)
Definition: win32.c:3556
INFINITY
#define INFINITY
Definition: missing.h:138
tms::tms_utime
long tms_utime
Definition: win32.h:710
rb_w32_setsockopt
int WSAAPI rb_w32_setsockopt(int, int, int, const char *, int)
Definition: win32.c:3389
b
Real * b
Definition: bigdecimal.c:1182
rb_w32_access
int rb_w32_access(const char *, int)
Definition: win32.c:4733
rb_w32_aspawn
rb_pid_t rb_w32_aspawn(int, const char *, char *const *)
Definition: win32.c:1357
tms::tms_cstime
long tms_cstime
Definition: win32.h:713
tms
Definition: win32.h:709
rb_w32_isatty
int rb_w32_isatty(int)
Definition: win32.c:6449
rb_w32_uchdir
int rb_w32_uchdir(const char *)
Definition: win32.c:6274
rb_w32_ulink
int rb_w32_ulink(const char *, const char *)
Definition: win32.c:4215
rb_w32_write_console
long rb_w32_write_console(uintptr_t, int)
Definition: win32.c:6145
rb_w32_strerror
char * rb_w32_strerror(int)
Definition: win32.c:2324
rb_w32_osid
DWORD rb_w32_osid(void)
rb_w32_ioctlsocket
int WSAAPI rb_w32_ioctlsocket(int, long, u_long *)
Definition: win32.c:3054
rb_w32_osver
DWORD rb_w32_osver(void)
Definition: win32.c:269
rb_w32_getservbyport
struct servent *WSAAPI rb_w32_getservbyport(int, const char *)
Definition: win32.c:3610
rb_w32_gethostname
int WSAAPI rb_w32_gethostname(char *, int)
Definition: win32.c:3538
rb_w32_ftruncate
int rb_w32_ftruncate(int fd, off_t length)
Definition: win32.c:4808
rb_w32_fdset
void rb_w32_fdset(int, fd_set *)
Definition: win32.c:2445
rb_w32_shutdown
int WSAAPI rb_w32_shutdown(int, int)
Definition: win32.c:3407
rb_w32_close
int rb_w32_close(int)
Definition: win32.c:5840
rb_w32_getpeername
int WSAAPI rb_w32_getpeername(int, struct sockaddr *, int *)
Definition: win32.c:2985
rb_w32_getcwd
char * rb_w32_getcwd(char *, int)
Definition: win32.c:4025
u_long
#define u_long
Definition: vsnprintf.c:64
scalb
static double scalb(double a, long b)
Definition: win32.h:338
msghdr::msg_controllen
int msg_controllen
Definition: win32.h:221
getgid
rb_gid_t getgid(void)
Definition: win32.c:2406
rb_w32_fclose
int rb_w32_fclose(FILE *)
Definition: win32.c:5407
rb_w32_fd_is_text
char rb_w32_fd_is_text(int)
Definition: win32.c:6568
tms::tms_cutime
long tms_cutime
Definition: win32.h:712
timezone
Definition: ripper.y:53
stat
#define stat(path, st)
Definition: win32.h:193
rb_w32_socketpair
int rb_w32_socketpair(int, int, int, int *)
Definition: win32.c:3717
rb_w32_recv
int WSAAPI rb_w32_recv(int, char *, int, int)
Definition: win32.c:3213
rb_w32_io_cancelable_p
int rb_w32_io_cancelable_p(int)
Definition: win32.c:2195
setuid
int setuid(rb_uid_t)
Definition: win32.c:2420
rb_w32_asynchronize
uintptr_t rb_w32_asynchronize(asynchronous_func_t func, uintptr_t self, int argc, uintptr_t *argv, uintptr_t intrval)
Definition: win32.c:5013
rb_w32_uunlink
int rb_w32_uunlink(const char *)
Definition: win32.c:6406
rb_w32_stat
int rb_w32_stat(const char *, struct stat *)
Definition: win32.c:4645
rb_w32_utime
int rb_w32_utime(const char *, const struct utimbuf *)
Definition: win32.c:6260
waitpid
rb_pid_t waitpid(rb_pid_t, int *, int)
Definition: win32.c:3919
rb_w32_uchown
int rb_w32_uchown(const char *, int, int)
Definition: win32.c:4072
rb_w32_rename
int rb_w32_rename(const char *, const char *)
Definition: win32.c:4379