Ruby  3.1.4p223 (2023-03-30 revision HEAD)
win32.h
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 RUBY_SYMBOL_EXPORT_BEGIN
12 
13 /*
14  * Copyright (c) 1993, Intergraph Corporation
15  *
16  * You may distribute under the terms of either the GNU General Public
17  * License or the Artistic License, as specified in the perl README file.
18  *
19  */
20 
21 /*
22  * Definitions for NT port of Perl
23  */
24 
25 
26 /*
27  * Ok now we can include the normal include files.
28  */
29 
30 /* #include <stdarg.h> conflict with varargs.h? */
31 #if !defined(WSAAPI)
32 #if defined(__cplusplus) && defined(_MSC_VER)
33 extern "C++" { /* template without extern "C++" */
34 #endif
35 #if !defined(_WIN64) && !defined(WIN32)
36 #define WIN32
37 #endif
38 #if defined(_MSC_VER) && _MSC_VER <= 1200
39 #include <windows.h>
40 #endif
41 #include <winsock2.h>
42 #include <ws2tcpip.h>
43 #if !defined(_MSC_VER) || _MSC_VER >= 1400
44 #include <iphlpapi.h>
45 #endif
46 #if defined(__cplusplus) && defined(_MSC_VER)
47 }
48 #endif
49 #endif
50 
51 /*
52  * We're not using Microsoft's "extensions" to C for
53  * Structured Exception Handling (SEH) so we can nuke these
54  */
55 #undef try
56 #undef except
57 #undef finally
58 #undef leave
59 
60 #include <stdio.h>
61 #include <stdlib.h>
62 #include <string.h>
63 #include <direct.h>
64 #include <process.h>
65 #include <time.h>
66 #if defined(__cplusplus) && defined(_MSC_VER) && _MSC_VER == 1200
67 extern "C++" { /* template without extern "C++" */
68 #endif
69 #include <math.h>
70 #if defined(__cplusplus) && defined(_MSC_VER) && _MSC_VER == 1200
71 }
72 #endif
73 #include <signal.h>
74 #include <sys/stat.h>
75 #include <sys/types.h>
76 #ifdef HAVE_SYS_UTIME_H
77 # include <sys/utime.h>
78 #else
79 # include <utime.h>
80 #endif
81 #include <io.h>
82 #include <malloc.h>
83 #if defined __MINGW32__
84 # include <stdint.h>
85 #else
86 # if !defined(_INTPTR_T_DEFINED)
87 # ifdef _WIN64
88 typedef __int64 intptr_t;
89 # else
90 typedef int intptr_t;
91 # endif
92 # define _INTPTR_T_DEFINED
93 # endif
94 # if !defined(INTPTR_MAX)
95 # ifdef _WIN64
96 # define INTPTR_MAX 9223372036854775807I64
97 # else
98 # define INTPTR_MAX 2147483647
99 # endif
100 # define INTPTR_MIN (-INTPTR_MAX-1)
101 # endif
102 # if !defined(_UINTPTR_T_DEFINED)
103 # ifdef _WIN64
104 typedef unsigned __int64 uintptr_t;
105 # else
106 typedef unsigned int uintptr_t;
107 # endif
108 # define _UINTPTR_T_DEFINED
109 # endif
110 # if !defined(UINTPTR_MAX)
111 # ifdef _WIN64
112 # define UINTPTR_MAX 18446744073709551615UI64
113 # else
114 # define UINTPTR_MAX 4294967295U
115 # endif
116 # endif
117 #endif
118 #ifndef __MINGW32__
119 # define mode_t int
120 #endif
121 #ifdef HAVE_UNISTD_H
122 # include <unistd.h>
123 #endif
124 
125 #define rb_w32_iswinnt() TRUE
126 #define rb_w32_iswin95() FALSE
127 
128 #define WNOHANG -1
129 
130 #define O_SHARE_DELETE 0x20000000 /* for rb_w32_open(), rb_w32_wopen() */
131 
132 typedef int clockid_t;
133 #define CLOCK_REALTIME 0
134 #define CLOCK_MONOTONIC 1
135 
136 #undef utime
137 #undef lseek
138 #undef stat
139 #undef fstat
140 #ifdef RUBY_EXPORT
141 #define utime(_p, _t) rb_w32_uutime(_p, _t)
142 #undef HAVE_UTIMES
143 #define HAVE_UTIMES 1
144 #define utimes(_p, _t) rb_w32_uutimes(_p, _t)
145 #undef HAVE_UTIMENSAT
146 #define HAVE_UTIMENSAT 1
147 #define AT_FDCWD -100
148 #define utimensat(_d, _p, _t, _f) rb_w32_uutimensat(_d, _p, _t, _f)
149 #define lseek(_f, _o, _w) rb_w32_lseek(_f, _o, _w)
150 
151 #define pipe(p) rb_w32_pipe(p)
152 #define open rb_w32_uopen
153 #define close(h) rb_w32_close(h)
154 #define fclose(f) rb_w32_fclose(f)
155 #define read(f, b, s) rb_w32_read(f, b, s)
156 #define write(f, b, s) rb_w32_write(f, b, s)
157 #define getpid() rb_w32_getpid()
158 #define getppid() rb_w32_getppid()
159 #define sleep(x) rb_w32_Sleep((x)*1000)
160 #define Sleep(msec) (void)rb_w32_Sleep(msec)
161 
162 #undef execv
163 #define execv(path,argv) rb_w32_uaspawn(P_OVERLAY,path,argv)
164 #undef isatty
165 #define isatty(h) rb_w32_isatty(h)
166 
167 #undef mkdir
168 #define mkdir(p, m) rb_w32_umkdir(p, m)
169 #undef rmdir
170 #define rmdir(p) rb_w32_urmdir(p)
171 #undef unlink
172 #define unlink(p) rb_w32_uunlink(p)
173 #endif /* RUBY_EXPORT */
174 
175 /* same with stati64 except the size of st_ino and nanosecond timestamps */
176 struct stati128 {
177  _dev_t st_dev;
178  unsigned __int64 st_ino;
179  __int64 st_inohigh;
180  unsigned short st_mode;
181  short st_nlink;
182  short st_uid;
183  short st_gid;
184  _dev_t st_rdev;
185  __int64 st_size;
186  __time64_t st_atime;
187  long st_atimensec;
188  __time64_t st_mtime;
189  long st_mtimensec;
190  __time64_t st_ctime;
191  long st_ctimensec;
192 };
193 
194 #define off_t __int64
195 #define stat stati128
196 #undef SIZEOF_STRUCT_STAT_ST_INO
197 #define SIZEOF_STRUCT_STAT_ST_INO sizeof(unsigned __int64)
198 #define HAVE_STRUCT_STAT_ST_INOHIGH
199 #define HAVE_STRUCT_STAT_ST_ATIMENSEC
200 #define HAVE_STRUCT_STAT_ST_MTIMENSEC
201 #define HAVE_STRUCT_STAT_ST_CTIMENSEC
202 #define fstat(fd,st) rb_w32_fstati128(fd,st)
203 #define stati128(path, st) rb_w32_ustati128(path,st)
204 #define lstat(path,st) rb_w32_ulstati128(path,st)
205 #define access(path,mode) rb_w32_uaccess(path,mode)
206 
207 #define strcasecmp _stricmp
208 #define strncasecmp _strnicmp
209 #define fsync _commit
210 
211 struct timezone;
212 
213 #ifdef __MINGW32__
214 #undef isascii
215 #define isascii __isascii
216 #endif
217 
218 struct iovec {
219  void *iov_base;
220  size_t iov_len;
221 };
222 struct msghdr {
223  void *msg_name;
224  int msg_namelen;
225  struct iovec *msg_iov;
226  int msg_iovlen;
227  void *msg_control;
228  int msg_controllen;
229  int msg_flags;
230 };
231 
232 /* for getifaddrs() and others */
233 struct ifaddrs {
234  struct ifaddrs *ifa_next;
235  char *ifa_name;
236  u_int ifa_flags;
237  struct sockaddr *ifa_addr;
238  struct sockaddr *ifa_netmask;
239  struct sockaddr *ifa_broadaddr;
240  struct sockaddr *ifa_dstaddr;
241  void *ifa_data;
242 };
243 #ifdef IF_NAMESIZE
244 #define IFNAMSIZ IF_NAMESIZE
245 #else
246 #define IFNAMSIZ 256
247 #endif
248 #ifdef IFF_POINTTOPOINT
249 #define IFF_POINTOPOINT IFF_POINTTOPOINT
250 #endif
251 
252 extern void rb_w32_sysinit(int *, char ***);
253 extern DWORD rb_w32_osid(void);
254 extern int flock(int fd, int oper);
255 extern int rb_w32_io_cancelable_p(int);
256 extern int rb_w32_is_socket(int);
257 extern int WSAAPI rb_w32_accept(int, struct sockaddr *, int *);
258 extern int WSAAPI rb_w32_bind(int, const struct sockaddr *, int);
259 extern int WSAAPI rb_w32_connect(int, const struct sockaddr *, int);
260 extern void rb_w32_fdset(int, fd_set*);
261 extern void rb_w32_fdclr(int, fd_set*);
262 extern int rb_w32_fdisset(int, fd_set*);
263 extern int WSAAPI rb_w32_select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
264 extern int WSAAPI rb_w32_getpeername(int, struct sockaddr *, int *);
265 extern int WSAAPI rb_w32_getsockname(int, struct sockaddr *, int *);
266 extern int WSAAPI rb_w32_getsockopt(int, int, int, char *, int *);
267 extern int WSAAPI rb_w32_ioctlsocket(int, long, u_long *);
268 extern int WSAAPI rb_w32_listen(int, int);
269 extern int WSAAPI rb_w32_recv(int, char *, int, int);
270 extern int WSAAPI rb_w32_recvfrom(int, char *, int, int, struct sockaddr *, int *);
271 extern int WSAAPI rb_w32_send(int, const char *, int, int);
272 extern int WSAAPI rb_w32_sendto(int, const char *, int, int, const struct sockaddr *, int);
273 extern int recvmsg(int, struct msghdr *, int);
274 extern int sendmsg(int, const struct msghdr *, int);
275 extern int WSAAPI rb_w32_setsockopt(int, int, int, const char *, int);
276 extern int WSAAPI rb_w32_shutdown(int, int);
277 extern int WSAAPI rb_w32_socket(int, int, int);
278 extern SOCKET rb_w32_get_osfhandle(int);
279 extern struct hostent *WSAAPI rb_w32_gethostbyaddr(const char *, int, int);
280 extern struct hostent *WSAAPI rb_w32_gethostbyname(const char *);
281 extern int WSAAPI rb_w32_gethostname(char *, int);
282 extern struct protoent *WSAAPI rb_w32_getprotobyname(const char *);
283 extern struct protoent *WSAAPI rb_w32_getprotobynumber(int);
284 extern struct servent *WSAAPI rb_w32_getservbyname(const char *, const char *);
285 extern struct servent *WSAAPI rb_w32_getservbyport(int, const char *);
286 extern int socketpair(int, int, int, int *);
287 extern int getifaddrs(struct ifaddrs **);
288 extern void freeifaddrs(struct ifaddrs *);
289 extern char * rb_w32_ugetcwd(char *, int);
290 extern char * rb_w32_ugetenv(const char *);
291 extern int rb_w32_urename(const char *, const char *);
292 extern char **rb_w32_get_environ(void);
293 extern void rb_w32_free_environ(char **);
294 extern int rb_w32_map_errno(DWORD);
295 extern const char *WSAAPI rb_w32_inet_ntop(int,const void *,char *,size_t);
296 extern int WSAAPI rb_w32_inet_pton(int,const char *,void *);
297 extern DWORD rb_w32_osver(void);
298 
299 extern int rb_w32_uchown(const char *, int, int);
300 extern int rb_w32_ulink(const char *, const char *);
301 extern ssize_t rb_w32_ureadlink(const char *, char *, size_t);
302 extern ssize_t rb_w32_wreadlink(const WCHAR *, WCHAR *, size_t);
303 extern int rb_w32_usymlink(const char *src, const char *link);
304 extern int gettimeofday(struct timeval *, struct timezone *);
305 extern int clock_gettime(clockid_t, struct timespec *);
306 extern int clock_getres(clockid_t, struct timespec *);
307 extern rb_pid_t waitpid(rb_pid_t, int *, int);
308 extern rb_pid_t wait(int *);
309 extern rb_pid_t rb_w32_uspawn(int, const char *, const char*);
310 extern rb_pid_t rb_w32_uaspawn(int, const char *, char *const *);
311 extern rb_pid_t rb_w32_uaspawn_flags(int, const char *, char *const *, DWORD);
312 extern int kill(int, int);
313 extern int fcntl(int, int, ...);
314 extern int rb_w32_set_nonblock(int);
315 extern rb_pid_t rb_w32_getpid(void);
316 extern rb_pid_t rb_w32_getppid(void);
317 extern int rb_w32_isatty(int);
318 extern int rb_w32_uchdir(const char *);
319 extern int rb_w32_umkdir(const char *, int);
320 extern int rb_w32_urmdir(const char *);
321 extern int rb_w32_uunlink(const char *);
322 extern int rb_w32_uchmod(const char *, int);
323 extern int rb_w32_ustati128(const char *, struct stati128 *);
324 extern int rb_w32_ulstati128(const char *, struct stati128 *);
325 extern int rb_w32_uaccess(const char *, int);
326 extern char rb_w32_fd_is_text(int);
327 extern int rb_w32_fstati128(int, struct stati128 *);
328 extern int rb_w32_dup2(int, int);
329 
330 #include <float.h>
331 
332 #if defined _MSC_VER && _MSC_VER >= 1800 && defined INFINITY
333 #pragma warning(push)
334 #pragma warning(disable:4756)
335 static inline float
336 rb_infinity_float(void)
337 {
338  return INFINITY;
339 }
340 #pragma warning(pop)
341 #undef INFINITY
342 #define INFINITY rb_infinity_float()
343 #endif
344 
345 #if !defined __MINGW32__ || defined __NO_ISOCEXT
346 #ifndef copysign
347 #define copysign(a, b) _copysign(a, b)
348 #endif
349 static inline double
350 scalb(double a, long b)
351 {
352  return _scalb(a, b);
353 }
354 #endif
355 
356 #if !defined S_IFIFO && defined _S_IFIFO
357 #define S_IFIFO _S_IFIFO
358 #endif
359 
360 #if !defined S_IRUSR && !defined __MINGW32__
361 #define S_IRUSR 0400
362 #endif
363 #ifndef S_IRGRP
364 #define S_IRGRP 0040
365 #endif
366 #ifndef S_IROTH
367 #define S_IROTH 0004
368 #endif
369 
370 #if !defined S_IWUSR && !defined __MINGW32__
371 #define S_IWUSR 0200
372 #endif
373 #ifndef S_IWGRP
374 #define S_IWGRP 0020
375 #endif
376 #ifndef S_IWOTH
377 #define S_IWOTH 0002
378 #endif
379 
380 #if !defined S_IXUSR && !defined __MINGW32__
381 #define S_IXUSR 0100
382 #endif
383 #ifndef S_IXGRP
384 #define S_IXGRP 0010
385 #endif
386 #ifndef S_IXOTH
387 #define S_IXOTH 0001
388 #endif
389 
390 #define S_IFLNK 0xa000
391 
392 /*
393  * define this so we can do inplace editing
394  */
395 
396 #define SUFFIX
397 
398 extern int rb_w32_ftruncate(int fd, off_t length);
399 extern int rb_w32_truncate(const char *path, off_t length);
400 extern int rb_w32_utruncate(const char *path, off_t length);
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 #define truncate rb_w32_utruncate
413 
414 #if defined(_MSC_VER) && _MSC_VER >= 1400 && _MSC_VER < 1800
415 #define strtoll _strtoi64
416 #define strtoull _strtoui64
417 #endif
418 
419 /*
420  * stubs
421  */
422 extern int ioctl (int, int, ...);
423 extern rb_uid_t getuid (void);
424 extern rb_uid_t geteuid (void);
425 extern rb_gid_t getgid (void);
426 extern rb_gid_t getegid (void);
427 extern int setuid (rb_uid_t);
428 extern int setgid (rb_gid_t);
429 
430 extern char *rb_w32_strerror(int);
431 
432 #ifdef RUBY_EXPORT
433 #define strerror(e) rb_w32_strerror(e)
434 #endif
435 
436 #define PIPE_BUF 1024
437 
438 #define LOCK_SH 1
439 #define LOCK_EX 2
440 #define LOCK_NB 4
441 #define LOCK_UN 8
442 
443 
444 #ifndef SIGINT
445 #define SIGINT 2
446 #endif
447 #ifndef SIGKILL
448 #define SIGKILL 9
449 #endif
450 
451 
452 /* #undef va_start */
453 /* #undef va_end */
454 
455 /* winsock error map */
456 #include <errno.h>
457 
458 #ifndef EWOULDBLOCK
459 # define EWOULDBLOCK WSAEWOULDBLOCK
460 #endif
461 #ifndef EINPROGRESS
462 # define EINPROGRESS WSAEINPROGRESS
463 #endif
464 #ifndef EALREADY
465 # define EALREADY WSAEALREADY
466 #endif
467 #ifndef ENOTSOCK
468 # define ENOTSOCK WSAENOTSOCK
469 #endif
470 #ifndef EDESTADDRREQ
471 # define EDESTADDRREQ WSAEDESTADDRREQ
472 #endif
473 #ifndef EMSGSIZE
474 # define EMSGSIZE WSAEMSGSIZE
475 #endif
476 #ifndef EPROTOTYPE
477 # define EPROTOTYPE WSAEPROTOTYPE
478 #endif
479 #ifndef ENOPROTOOPT
480 # define ENOPROTOOPT WSAENOPROTOOPT
481 #endif
482 #ifndef EPROTONOSUPPORT
483 # define EPROTONOSUPPORT WSAEPROTONOSUPPORT
484 #endif
485 #ifndef ESOCKTNOSUPPORT
486 # define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT
487 #endif
488 #ifndef EOPNOTSUPP
489 # define EOPNOTSUPP WSAEOPNOTSUPP
490 #endif
491 #ifndef EPFNOSUPPORT
492 # define EPFNOSUPPORT WSAEPFNOSUPPORT
493 #endif
494 #ifndef EAFNOSUPPORT
495 # define EAFNOSUPPORT WSAEAFNOSUPPORT
496 #endif
497 #ifndef EADDRINUSE
498 # define EADDRINUSE WSAEADDRINUSE
499 #endif
500 #ifndef EADDRNOTAVAIL
501 # define EADDRNOTAVAIL WSAEADDRNOTAVAIL
502 #endif
503 #ifndef ENETDOWN
504 # define ENETDOWN WSAENETDOWN
505 #endif
506 #ifndef ENETUNREACH
507 # define ENETUNREACH WSAENETUNREACH
508 #endif
509 #ifndef ENETRESET
510 # define ENETRESET WSAENETRESET
511 #endif
512 #ifndef ECONNABORTED
513 # define ECONNABORTED WSAECONNABORTED
514 #endif
515 #ifndef ECONNRESET
516 # define ECONNRESET WSAECONNRESET
517 #endif
518 #ifndef ENOBUFS
519 # define ENOBUFS WSAENOBUFS
520 #endif
521 #ifndef EISCONN
522 # define EISCONN WSAEISCONN
523 #endif
524 #ifndef ENOTCONN
525 # define ENOTCONN WSAENOTCONN
526 #endif
527 #ifndef ESHUTDOWN
528 # define ESHUTDOWN WSAESHUTDOWN
529 #endif
530 #ifndef ETOOMANYREFS
531 # define ETOOMANYREFS WSAETOOMANYREFS
532 #endif
533 #ifndef ETIMEDOUT
534 # define ETIMEDOUT WSAETIMEDOUT
535 #endif
536 #ifndef ECONNREFUSED
537 # define ECONNREFUSED WSAECONNREFUSED
538 #endif
539 #ifndef ELOOP
540 # define ELOOP WSAELOOP
541 #endif
542 /*#define ENAMETOOLONG WSAENAMETOOLONG*/
543 #ifndef EHOSTDOWN
544 # define EHOSTDOWN WSAEHOSTDOWN
545 #endif
546 #ifndef EHOSTUNREACH
547 # define EHOSTUNREACH WSAEHOSTUNREACH
548 #endif
549 /*#define ENOTEMPTY WSAENOTEMPTY*/
550 #ifndef EPROCLIM
551 # define EPROCLIM WSAEPROCLIM
552 #endif
553 #ifndef EUSERS
554 # define EUSERS WSAEUSERS
555 #endif
556 #ifndef EDQUOT
557 # define EDQUOT WSAEDQUOT
558 #endif
559 #ifndef ESTALE
560 # define ESTALE WSAESTALE
561 #endif
562 #ifndef EREMOTE
563 # define EREMOTE WSAEREMOTE
564 #endif
565 
566 #define F_DUPFD 0
567 #define F_GETFD 1
568 #define F_SETFD 2
569 #if 0
570 #define F_GETFL 3
571 #endif
572 #define F_SETFL 4
573 #define F_DUPFD_CLOEXEC 67
574 #define FD_CLOEXEC 1 /* F_GETFD, F_SETFD */
575 #define O_NONBLOCK 1
576 
577 #undef FD_SET
578 #define FD_SET(fd, set) do {\
579  unsigned int i;\
580  SOCKET s = _get_osfhandle(fd);\
581 \
582  for (i = 0; i < (set)->fd_count; i++) {\
583  if ((set)->fd_array[i] == s) {\
584  break;\
585  }\
586  }\
587  if (i == (set)->fd_count) {\
588  if ((set)->fd_count < FD_SETSIZE) {\
589  (set)->fd_array[i] = s;\
590  (set)->fd_count++;\
591  }\
592  }\
593 } while(0)
594 
595 #undef FD_CLR
596 #define FD_CLR(f, s) rb_w32_fdclr(f, s)
597 
598 #undef FD_ISSET
599 #define FD_ISSET(f, s) rb_w32_fdisset(f, s)
600 
601 #ifdef RUBY_EXPORT
602 #undef inet_ntop
603 #define inet_ntop(f,a,n,l) rb_w32_inet_ntop(f,a,n,l)
604 
605 #undef inet_pton
606 #define inet_pton(f,s,d) rb_w32_inet_pton(f,s,d)
607 
608 #undef accept
609 #define accept(s, a, l) rb_w32_accept(s, a, l)
610 
611 #undef bind
612 #define bind(s, a, l) rb_w32_bind(s, a, l)
613 
614 #undef connect
615 #define connect(s, a, l) rb_w32_connect(s, a, l)
616 
617 #undef select
618 #define select(n, r, w, e, t) rb_w32_select(n, r, w, e, t)
619 
620 #undef getpeername
621 #define getpeername(s, a, l) rb_w32_getpeername(s, a, l)
622 
623 #undef getsockname
624 #define getsockname(s, a, l) rb_w32_getsockname(s, a, l)
625 
626 #undef getsockopt
627 #define getsockopt(s, v, n, o, l) rb_w32_getsockopt(s, v, n, o, l)
628 
629 #undef ioctlsocket
630 #define ioctlsocket(s, c, a) rb_w32_ioctlsocket(s, c, a)
631 
632 #undef listen
633 #define listen(s, b) rb_w32_listen(s, b)
634 
635 #undef recv
636 #define recv(s, b, l, f) rb_w32_recv(s, b, l, f)
637 
638 #undef recvfrom
639 #define recvfrom(s, b, l, f, fr, frl) rb_w32_recvfrom(s, b, l, f, fr, frl)
640 
641 #undef send
642 #define send(s, b, l, f) rb_w32_send(s, b, l, f)
643 
644 #undef sendto
645 #define sendto(s, b, l, f, t, tl) rb_w32_sendto(s, b, l, f, t, tl)
646 
647 #undef setsockopt
648 #define setsockopt(s, v, n, o, l) rb_w32_setsockopt(s, v, n, o, l)
649 
650 #undef shutdown
651 #define shutdown(s, h) rb_w32_shutdown(s, h)
652 
653 #undef socket
654 #define socket(s, t, p) rb_w32_socket(s, t, p)
655 
656 #undef gethostbyaddr
657 #define gethostbyaddr(a, l, t) rb_w32_gethostbyaddr(a, l, t)
658 
659 #undef gethostbyname
660 #define gethostbyname(n) rb_w32_gethostbyname(n)
661 
662 #undef gethostname
663 #define gethostname(n, l) rb_w32_gethostname(n, l)
664 
665 #undef getprotobyname
666 #define getprotobyname(n) rb_w32_getprotobyname(n)
667 
668 #undef getprotobynumber
669 #define getprotobynumber(n) rb_w32_getprotobynumber(n)
670 
671 #undef getservbyname
672 #define getservbyname(n, p) rb_w32_getservbyname(n, p)
673 
674 #undef getservbyport
675 #define getservbyport(p, pr) rb_w32_getservbyport(p, pr)
676 
677 #undef get_osfhandle
678 #define get_osfhandle(h) rb_w32_get_osfhandle(h)
679 
680 #undef getcwd
681 #define getcwd(b, s) rb_w32_ugetcwd(b, s)
682 
683 #undef getenv
684 #define getenv(n) rb_w32_ugetenv(n)
685 
686 #undef rename
687 #define rename(o, n) rb_w32_urename(o, n)
688 
689 #undef times
690 #define times(t) rb_w32_times(t)
691 
692 #undef dup2
693 #define dup2(o, n) rb_w32_dup2(o, n)
694 #endif
695 
696 struct tms {
697  long tms_utime;
698  long tms_stime;
699  long tms_cutime;
700  long tms_cstime;
701 };
702 
703 int rb_w32_times(struct tms *);
704 
705 struct tm *gmtime_r(const time_t *, struct tm *);
706 struct tm *localtime_r(const time_t *, struct tm *);
707 
708 /* thread stuff */
709 int rb_w32_sleep(unsigned long msec);
710 int rb_w32_uopen(const char *, int, ...);
711 int rb_w32_wopen(const WCHAR *, int, ...);
712 int rb_w32_close(int);
713 int rb_w32_fclose(FILE*);
714 int rb_w32_pipe(int[2]);
715 ssize_t rb_w32_read(int, void *, size_t);
716 ssize_t rb_w32_write(int, const void *, size_t);
717 off_t rb_w32_lseek(int, off_t, int);
718 int rb_w32_uutime(const char *, const struct utimbuf *);
719 int rb_w32_uutimes(const char *, const struct timeval *);
720 int rb_w32_uutimensat(int /* must be AT_FDCWD */, const char *, const struct timespec *, int /* must be 0 */);
721 long rb_w32_write_console(uintptr_t, int); /* use uintptr_t instead of VALUE because it's not defined yet here */
722 int WINAPI rb_w32_Sleep(unsigned long msec);
723 int rb_w32_wait_events_blocking(HANDLE *events, int num, DWORD timeout);
724 int rb_w32_time_subtract(struct timeval *rest, const struct timeval *wait);
725 int rb_w32_wrap_io_handle(HANDLE, int);
726 int rb_w32_unwrap_io_handle(int);
727 WCHAR *rb_w32_mbstr_to_wstr(UINT, const char *, int, long *);
728 char *rb_w32_wstr_to_mbstr(UINT, const WCHAR *, int, long *);
729 
730 DEPRECATED_BY(rb_w32_ugetcwd, char *rb_w32_getcwd(char *, int));
731 DEPRECATED_BY(rb_w32_ugetenv, char *rb_w32_getenv(const char *));
732 DEPRECATED_BY(rb_w32_urename, int rb_w32_rename(const char *, const char *));
733 DEPRECATED_BY(rb_w32_uopen, int rb_w32_open(const char *, int, ...));
734 DEPRECATED_BY(rb_w32_uchown, int chown(const char *, int, int));
735 DEPRECATED_BY(rb_w32_ulink, int link(const char *, const char *));
736 DEPRECATED_BY(rb_w32_ureadlink, ssize_t readlink(const char *, char *, size_t));
737 DEPRECATED_BY(rb_w32_usymlink, int symlink(const char *src, const char *link));
738 DEPRECATED_BY(rb_w32_umkdir, int rb_w32_mkdir(const char *, int));
739 DEPRECATED_BY(rb_w32_urmdir, int rb_w32_rmdir(const char *));
740 DEPRECATED_BY(rb_w32_uunlink, int rb_w32_unlink(const char *));
741 DEPRECATED_BY(rb_w32_uutime, int rb_w32_utime(const char *, const struct utimbuf *));
742 DEPRECATED_BY(rb_w32_uutimes, int rb_w32_utimes(const char *, const struct timeval *));
743 DEPRECATED_BY(rb_w32_uutimensat, int rb_w32_utimensat(int, const char *, const struct timespec *, int));
744 DEPRECATED_BY(rb_w32_ustati128, int rb_w32_stati128(const char *, struct stati128 *));
745 DEPRECATED_BY(rb_w32_ulstati128, int rb_w32_lstati128(const char *, struct stati128 *));
746 DEPRECATED_BY(rb_w32_uaccess, int rb_w32_access(const char *, int));
747 DEPRECATED_BY(rb_w32_uspawn, rb_pid_t rb_w32_spawn(int, const char *, const char*));
748 DEPRECATED_BY(rb_w32_uaspawn, rb_pid_t rb_w32_aspawn(int, const char *, char *const *));
749 DEPRECATED_BY(rb_w32_uaspawn_flags, rb_pid_t rb_w32_aspawn_flags(int, const char *, char *const *, DWORD));
750 
751 /*
752 == ***CAUTION***
753 Since this function is very dangerous, ((*NEVER*))
754 * lock any HANDLEs(i.e. Mutex, Semaphore, CriticalSection and so on) or,
755 * use anything like rb_thread_call_without_gvl,
756 in asynchronous_func_t.
757 */
758 typedef uintptr_t (*asynchronous_func_t)(uintptr_t self, int argc, uintptr_t* argv);
759 uintptr_t rb_w32_asynchronize(asynchronous_func_t func, uintptr_t self, int argc, uintptr_t* argv, uintptr_t intrval);
760 
761 RUBY_SYMBOL_EXPORT_END
762 
763 #if (defined(__MINGW64_VERSION_MAJOR) || defined(__MINGW64__)) && !defined(__cplusplus)
764 #ifdef RUBY_MINGW64_BROKEN_FREXP_MODF
765 /* License: Ruby's */
766 /* get rid of bugs in math.h of mingw */
767 #define frexp(_X, _Y) __extension__ ({\
768  int intpart_frexp_bug = intpart_frexp_bug;\
769  double result_frexp_bug = frexp((_X), &intpart_frexp_bug);\
770  *(_Y) = intpart_frexp_bug;\
771  result_frexp_bug;\
772 })
773 /* License: Ruby's */
774 #define modf(_X, _Y) __extension__ ({\
775  double intpart_modf_bug = intpart_modf_bug;\
776  double result_modf_bug = modf((_X), &intpart_modf_bug);\
777  *(_Y) = intpart_modf_bug;\
778  result_modf_bug;\
779 })
780 #endif
781 
782 #if defined(__MINGW64__)
783 /*
784  * Use powl() instead of broken pow() of x86_64-w64-mingw32.
785  * This workaround will fix test failures in test_bignum.rb,
786  * test_fixnum.rb and test_float.rb etc.
787  */
788 static inline double
789 rb_w32_pow(double x, double y)
790 {
791  return (double)powl(x, y);
792 }
793 #elif defined(__MINGW64_VERSION_MAJOR)
794 double rb_w32_pow(double x, double y);
795 #endif
796 #define pow rb_w32_pow
797 #endif
798 
799 #if defined(__cplusplus)
800 #if 0
801 { /* satisfy cc-mode */
802 #endif
803 } /* extern "C" { */
804 #endif
805 
806 #endif /* RUBY_WIN32_H */
Definition: win32.h:233
Definition: win32.h:218
Definition: win32.h:222
Definition: win32.h:696
Definition: file.c:2929