Ruby 3.1.3p185 (2022-11-24 revision 1a6b16756e0ba6b95ab71a441357ed5484e33498)
win32.h
1#ifndef RUBY_WIN32_H
2#define RUBY_WIN32_H 1
3
4#if defined(__cplusplus)
5extern "C" {
6#if 0
7} /* satisfy cc-mode */
8#endif
9#endif
10
11RUBY_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)
33extern "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
67extern "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
88typedef __int64 intptr_t;
89# else
90typedef 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
104typedef unsigned __int64 uintptr_t;
105# else
106typedef 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
132typedef 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 */
176struct 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
211struct timezone;
212
213#ifdef __MINGW32__
214#undef isascii
215#define isascii __isascii
216#endif
217
218struct iovec {
219 void *iov_base;
220 size_t iov_len;
221};
222struct 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 */
233struct 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
252extern void rb_w32_sysinit(int *, char ***);
253extern DWORD rb_w32_osid(void);
254extern int flock(int fd, int oper);
255extern int rb_w32_io_cancelable_p(int);
256extern int rb_w32_is_socket(int);
257extern int WSAAPI rb_w32_accept(int, struct sockaddr *, int *);
258extern int WSAAPI rb_w32_bind(int, const struct sockaddr *, int);
259extern int WSAAPI rb_w32_connect(int, const struct sockaddr *, int);
260extern void rb_w32_fdset(int, fd_set*);
261extern void rb_w32_fdclr(int, fd_set*);
262extern int rb_w32_fdisset(int, fd_set*);
263extern int WSAAPI rb_w32_select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
264extern int WSAAPI rb_w32_getpeername(int, struct sockaddr *, int *);
265extern int WSAAPI rb_w32_getsockname(int, struct sockaddr *, int *);
266extern int WSAAPI rb_w32_getsockopt(int, int, int, char *, int *);
267extern int WSAAPI rb_w32_ioctlsocket(int, long, u_long *);
268extern int WSAAPI rb_w32_listen(int, int);
269extern int WSAAPI rb_w32_recv(int, char *, int, int);
270extern int WSAAPI rb_w32_recvfrom(int, char *, int, int, struct sockaddr *, int *);
271extern int WSAAPI rb_w32_send(int, const char *, int, int);
272extern int WSAAPI rb_w32_sendto(int, const char *, int, int, const struct sockaddr *, int);
273extern int recvmsg(int, struct msghdr *, int);
274extern int sendmsg(int, const struct msghdr *, int);
275extern int WSAAPI rb_w32_setsockopt(int, int, int, const char *, int);
276extern int WSAAPI rb_w32_shutdown(int, int);
277extern int WSAAPI rb_w32_socket(int, int, int);
278extern SOCKET rb_w32_get_osfhandle(int);
279extern struct hostent *WSAAPI rb_w32_gethostbyaddr(const char *, int, int);
280extern struct hostent *WSAAPI rb_w32_gethostbyname(const char *);
281extern int WSAAPI rb_w32_gethostname(char *, int);
282extern struct protoent *WSAAPI rb_w32_getprotobyname(const char *);
283extern struct protoent *WSAAPI rb_w32_getprotobynumber(int);
284extern struct servent *WSAAPI rb_w32_getservbyname(const char *, const char *);
285extern struct servent *WSAAPI rb_w32_getservbyport(int, const char *);
286extern int socketpair(int, int, int, int *);
287extern int getifaddrs(struct ifaddrs **);
288extern void freeifaddrs(struct ifaddrs *);
289extern char * rb_w32_ugetcwd(char *, int);
290extern char * rb_w32_ugetenv(const char *);
291extern int rb_w32_urename(const char *, const char *);
292extern char **rb_w32_get_environ(void);
293extern void rb_w32_free_environ(char **);
294extern int rb_w32_map_errno(DWORD);
295extern const char *WSAAPI rb_w32_inet_ntop(int,const void *,char *,size_t);
296extern int WSAAPI rb_w32_inet_pton(int,const char *,void *);
297extern DWORD rb_w32_osver(void);
298
299extern int rb_w32_uchown(const char *, int, int);
300extern int rb_w32_ulink(const char *, const char *);
301extern ssize_t rb_w32_ureadlink(const char *, char *, size_t);
302extern ssize_t rb_w32_wreadlink(const WCHAR *, WCHAR *, size_t);
303extern int rb_w32_usymlink(const char *src, const char *link);
304extern int gettimeofday(struct timeval *, struct timezone *);
305extern int clock_gettime(clockid_t, struct timespec *);
306extern int clock_getres(clockid_t, struct timespec *);
307extern rb_pid_t waitpid(rb_pid_t, int *, int);
308extern rb_pid_t wait(int *);
309extern rb_pid_t rb_w32_uspawn(int, const char *, const char*);
310extern rb_pid_t rb_w32_uaspawn(int, const char *, char *const *);
311extern rb_pid_t rb_w32_uaspawn_flags(int, const char *, char *const *, DWORD);
312extern int kill(int, int);
313extern int fcntl(int, int, ...);
314extern int rb_w32_set_nonblock(int);
315extern rb_pid_t rb_w32_getpid(void);
316extern rb_pid_t rb_w32_getppid(void);
317extern int rb_w32_isatty(int);
318extern int rb_w32_uchdir(const char *);
319extern int rb_w32_umkdir(const char *, int);
320extern int rb_w32_urmdir(const char *);
321extern int rb_w32_uunlink(const char *);
322extern int rb_w32_uchmod(const char *, int);
323extern int rb_w32_ustati128(const char *, struct stati128 *);
324extern int rb_w32_ulstati128(const char *, struct stati128 *);
325extern int rb_w32_uaccess(const char *, int);
326extern char rb_w32_fd_is_text(int);
327extern int rb_w32_fstati128(int, struct stati128 *);
328extern 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)
335static inline float
336rb_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
349static inline double
350scalb(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
398extern int rb_w32_ftruncate(int fd, off_t length);
399extern int rb_w32_truncate(const char *path, off_t length);
400extern 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 */
422extern int ioctl (int, int, ...);
423extern rb_uid_t getuid (void);
424extern rb_uid_t geteuid (void);
425extern rb_gid_t getgid (void);
426extern rb_gid_t getegid (void);
427extern int setuid (rb_uid_t);
428extern int setgid (rb_gid_t);
429
430extern 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
696struct tms {
697 long tms_utime;
698 long tms_stime;
699 long tms_cutime;
700 long tms_cstime;
701};
702
703int rb_w32_times(struct tms *);
704
705struct tm *gmtime_r(const time_t *, struct tm *);
706struct tm *localtime_r(const time_t *, struct tm *);
707
708/* thread stuff */
709int rb_w32_sleep(unsigned long msec);
710int rb_w32_uopen(const char *, int, ...);
711int rb_w32_wopen(const WCHAR *, int, ...);
712int rb_w32_close(int);
713int rb_w32_fclose(FILE*);
714int rb_w32_pipe(int[2]);
715ssize_t rb_w32_read(int, void *, size_t);
716ssize_t rb_w32_write(int, const void *, size_t);
717off_t rb_w32_lseek(int, off_t, int);
718int rb_w32_uutime(const char *, const struct utimbuf *);
719int rb_w32_uutimes(const char *, const struct timeval *);
720int rb_w32_uutimensat(int /* must be AT_FDCWD */, const char *, const struct timespec *, int /* must be 0 */);
721long rb_w32_write_console(uintptr_t, int); /* use uintptr_t instead of VALUE because it's not defined yet here */
722int WINAPI rb_w32_Sleep(unsigned long msec);
723int rb_w32_wait_events_blocking(HANDLE *events, int num, DWORD timeout);
724int rb_w32_time_subtract(struct timeval *rest, const struct timeval *wait);
725int rb_w32_wrap_io_handle(HANDLE, int);
726int rb_w32_unwrap_io_handle(int);
727WCHAR *rb_w32_mbstr_to_wstr(UINT, const char *, int, long *);
728char *rb_w32_wstr_to_mbstr(UINT, const WCHAR *, int, long *);
729
730DEPRECATED_BY(rb_w32_ugetcwd, char *rb_w32_getcwd(char *, int));
731DEPRECATED_BY(rb_w32_ugetenv, char *rb_w32_getenv(const char *));
732DEPRECATED_BY(rb_w32_urename, int rb_w32_rename(const char *, const char *));
733DEPRECATED_BY(rb_w32_uopen, int rb_w32_open(const char *, int, ...));
734DEPRECATED_BY(rb_w32_uchown, int chown(const char *, int, int));
735DEPRECATED_BY(rb_w32_ulink, int link(const char *, const char *));
736DEPRECATED_BY(rb_w32_ureadlink, ssize_t readlink(const char *, char *, size_t));
737DEPRECATED_BY(rb_w32_usymlink, int symlink(const char *src, const char *link));
738DEPRECATED_BY(rb_w32_umkdir, int rb_w32_mkdir(const char *, int));
739DEPRECATED_BY(rb_w32_urmdir, int rb_w32_rmdir(const char *));
740DEPRECATED_BY(rb_w32_uunlink, int rb_w32_unlink(const char *));
741DEPRECATED_BY(rb_w32_uutime, int rb_w32_utime(const char *, const struct utimbuf *));
742DEPRECATED_BY(rb_w32_uutimes, int rb_w32_utimes(const char *, const struct timeval *));
743DEPRECATED_BY(rb_w32_uutimensat, int rb_w32_utimensat(int, const char *, const struct timespec *, int));
744DEPRECATED_BY(rb_w32_ustati128, int rb_w32_stati128(const char *, struct stati128 *));
745DEPRECATED_BY(rb_w32_ulstati128, int rb_w32_lstati128(const char *, struct stati128 *));
746DEPRECATED_BY(rb_w32_uaccess, int rb_w32_access(const char *, int));
747DEPRECATED_BY(rb_w32_uspawn, rb_pid_t rb_w32_spawn(int, const char *, const char*));
748DEPRECATED_BY(rb_w32_uaspawn, rb_pid_t rb_w32_aspawn(int, const char *, char *const *));
749DEPRECATED_BY(rb_w32_uaspawn_flags, rb_pid_t rb_w32_aspawn_flags(int, const char *, char *const *, DWORD));
750
751/*
752== ***CAUTION***
753Since 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,
756in asynchronous_func_t.
757*/
758typedef uintptr_t (*asynchronous_func_t)(uintptr_t self, int argc, uintptr_t* argv);
759uintptr_t rb_w32_asynchronize(asynchronous_func_t func, uintptr_t self, int argc, uintptr_t* argv, uintptr_t intrval);
760
761RUBY_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 */
788static inline double
789rb_w32_pow(double x, double y)
790{
791 return (double)powl(x, y);
792}
793#elif defined(__MINGW64_VERSION_MAJOR)
794double 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