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