4 /* Support routines for the NT version of Emacs.
5 Copyright (C) 1994, 2001, 2002, 2003, 2004, 2005,
6 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
8 This file is part of GNU Emacs.
10 GNU Emacs is free software: you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation, either version 3 of the License, or
13 (at your option) any later version.
15 GNU Emacs is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
24 /* File descriptor set emulation. */
26 /* MSVC runtime library has limit of 64 descriptors by default */
29 unsigned int bits
[FD_SETSIZE
/ 32];
32 /* standard access macros */
33 #define FD_SET(n, p) \
35 if ((n) < FD_SETSIZE) { \
36 (p)->bits[(n)/32] |= (1 << (n)%32); \
39 #define FD_CLR(n, p) \
41 if ((n) < FD_SETSIZE) { \
42 (p)->bits[(n)/32] &= ~(1 << (n)%32); \
45 #define FD_ISSET(n, p) ((n) < FD_SETSIZE ? ((p)->bits[(n)/32] & (1 << (n)%32)) : 0)
46 #define FD_ZERO(p) memset((p), 0, sizeof(fd_set))
48 #define SELECT_TYPE fd_set
50 /* ------------------------------------------------------------------------- */
52 /* child_process.status values */
54 STATUS_READ_ERROR
= -1,
56 STATUS_READ_IN_PROGRESS
,
58 STATUS_READ_SUCCEEDED
,
59 STATUS_READ_ACKNOWLEDGED
62 /* This structure is used for both pipes and sockets; for
63 a socket, the process handle in pi is NULL. */
64 typedef struct _child_process
72 PROCESS_INFORMATION procinfo
;
79 #define MAXDESC FD_SETSIZE
80 #define MAX_CHILDREN MAXDESC/2
81 #define CHILD_ACTIVE(cp) ((cp)->char_avail != NULL)
83 /* parallel array of private info on file handles */
91 extern filedesc fd_info
[ MAXDESC
];
93 /* fd_info flag definitions */
94 #define FILE_READ 0x0001
95 #define FILE_WRITE 0x0002
96 #define FILE_LISTEN 0x0004
97 #define FILE_BINARY 0x0010
98 #define FILE_LAST_CR 0x0020
99 #define FILE_AT_EOF 0x0040
100 #define FILE_SEND_SIGCHLD 0x0080
101 #define FILE_PIPE 0x0100
102 #define FILE_SOCKET 0x0200
103 #define FILE_NDELAY 0x0400
104 #define FILE_SERIAL 0x0800
106 extern child_process
* new_child (void);
107 extern void delete_child (child_process
*cp
);
109 /* ------------------------------------------------------------------------- */
111 /* Equivalent of strerror for W32 error codes. */
112 extern char * w32_strerror (int error_no
);
114 /* Validate a pointer. */
115 extern int w32_valid_pointer_p (void *, int);
117 /* Get long (aka "true") form of file name, if it exists. */
118 extern BOOL
w32_get_long_filename (char * name
, char * buf
, int size
);
120 /* Prepare our standard handles for proper inheritance by child processes. */
121 extern void prepare_standard_handles (int in
, int out
,
122 int err
, HANDLE handles
[4]);
124 /* Reset our standard handles to their original state. */
125 extern void reset_standard_handles (int in
, int out
,
126 int err
, HANDLE handles
[4]);
128 /* Return the string resource associated with KEY of type TYPE. */
129 extern LPBYTE
w32_get_resource (char * key
, LPDWORD type
);
131 extern void init_ntproc (void);
132 extern void term_ntproc (void);
133 extern void globals_of_w32 (void);
134 extern void syms_of_w32term (void);
135 extern void syms_of_w32fns (void);
136 extern void globals_of_w32fns (void);
137 extern void syms_of_w32select (void);
138 extern void globals_of_w32select (void);
139 extern void term_w32select (void);
140 extern void syms_of_w32menu (void);
141 extern void globals_of_w32menu (void);
142 extern void syms_of_fontset (void);
144 extern int _sys_read_ahead (int fd
);
145 extern int _sys_wait_accept (int fd
);
147 #endif /* EMACS_W32_H */