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