diff options
Diffstat (limited to 'gl/unistd.in.h')
-rw-r--r-- | gl/unistd.in.h | 240 |
1 files changed, 237 insertions, 3 deletions
diff --git a/gl/unistd.in.h b/gl/unistd.in.h index a5dc04c9..1b2f80ee 100644 --- a/gl/unistd.in.h +++ b/gl/unistd.in.h | |||
@@ -1,5 +1,5 @@ | |||
1 | /* Substitute for and wrapper around <unistd.h>. | 1 | /* Substitute for and wrapper around <unistd.h>. |
2 | Copyright (C) 2004-2007 Free Software Foundation, Inc. | 2 | Copyright (C) 2003-2008 Free Software Foundation, Inc. |
3 | 3 | ||
4 | This program is free software; you can redistribute it and/or modify | 4 | This program is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published by | 5 | it under the terms of the GNU General Public License as published by |
@@ -17,6 +17,10 @@ | |||
17 | 17 | ||
18 | #ifndef _GL_UNISTD_H | 18 | #ifndef _GL_UNISTD_H |
19 | 19 | ||
20 | #if __GNUC__ >= 3 | ||
21 | @PRAGMA_SYSTEM_HEADER@ | ||
22 | #endif | ||
23 | |||
20 | /* The include_next requires a split double-inclusion guard. */ | 24 | /* The include_next requires a split double-inclusion guard. */ |
21 | #if @HAVE_UNISTD_H@ | 25 | #if @HAVE_UNISTD_H@ |
22 | # @INCLUDE_NEXT@ @NEXT_UNISTD_H@ | 26 | # @INCLUDE_NEXT@ @NEXT_UNISTD_H@ |
@@ -31,8 +35,55 @@ | |||
31 | #endif | 35 | #endif |
32 | 36 | ||
33 | /* mingw fails to declare _exit in <unistd.h>. */ | 37 | /* mingw fails to declare _exit in <unistd.h>. */ |
38 | /* mingw, BeOS, Haiku declare environ in <stdlib.h>, not in <unistd.h>. */ | ||
34 | #include <stdlib.h> | 39 | #include <stdlib.h> |
35 | 40 | ||
41 | #if @GNULIB_WRITE@ && @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@ | ||
42 | /* Get ssize_t. */ | ||
43 | # include <sys/types.h> | ||
44 | #endif | ||
45 | |||
46 | #if @GNULIB_GETHOSTNAME@ | ||
47 | /* Get all possible declarations of gethostname(). */ | ||
48 | # if @UNISTD_H_HAVE_WINSOCK2_H@ | ||
49 | # include <winsock2.h> | ||
50 | # if !defined _GL_SYS_SOCKET_H | ||
51 | # undef socket | ||
52 | # define socket socket_used_without_including_sys_socket_h | ||
53 | # undef connect | ||
54 | # define connect connect_used_without_including_sys_socket_h | ||
55 | # undef accept | ||
56 | # define accept accept_used_without_including_sys_socket_h | ||
57 | # undef bind | ||
58 | # define bind bind_used_without_including_sys_socket_h | ||
59 | # undef getpeername | ||
60 | # define getpeername getpeername_used_without_including_sys_socket_h | ||
61 | # undef getsockname | ||
62 | # define getsockname getsockname_used_without_including_sys_socket_h | ||
63 | # undef getsockopt | ||
64 | # define getsockopt getsockopt_used_without_including_sys_socket_h | ||
65 | # undef listen | ||
66 | # define listen listen_used_without_including_sys_socket_h | ||
67 | # undef recv | ||
68 | # define recv recv_used_without_including_sys_socket_h | ||
69 | # undef send | ||
70 | # define send send_used_without_including_sys_socket_h | ||
71 | # undef recvfrom | ||
72 | # define recvfrom recvfrom_used_without_including_sys_socket_h | ||
73 | # undef sendto | ||
74 | # define sendto sendto_used_without_including_sys_socket_h | ||
75 | # undef setsockopt | ||
76 | # define setsockopt setsockopt_used_without_including_sys_socket_h | ||
77 | # undef shutdown | ||
78 | # define shutdown shutdown_used_without_including_sys_socket_h | ||
79 | # endif | ||
80 | # if !defined _GL_SYS_SELECT_H | ||
81 | # undef select | ||
82 | # define select select_used_without_including_sys_select_h | ||
83 | # endif | ||
84 | # endif | ||
85 | #endif | ||
86 | |||
36 | /* The definition of GL_LINK_WARNING is copied here. */ | 87 | /* The definition of GL_LINK_WARNING is copied here. */ |
37 | 88 | ||
38 | 89 | ||
@@ -68,6 +119,29 @@ extern int chown (const char *file, uid_t uid, gid_t gid); | |||
68 | #endif | 119 | #endif |
69 | 120 | ||
70 | 121 | ||
122 | #if @GNULIB_CLOSE@ | ||
123 | # if @UNISTD_H_HAVE_WINSOCK2_H@ | ||
124 | /* Need a gnulib internal function. */ | ||
125 | # define HAVE__GL_CLOSE_FD_MAYBE_SOCKET 1 | ||
126 | # endif | ||
127 | # if @REPLACE_CLOSE@ | ||
128 | /* Automatically included by modules that need a replacement for close. */ | ||
129 | # undef close | ||
130 | # define close rpl_close | ||
131 | extern int close (int); | ||
132 | # endif | ||
133 | #elif @UNISTD_H_HAVE_WINSOCK2_H@ | ||
134 | # undef close | ||
135 | # define close close_used_without_requesting_gnulib_module_close | ||
136 | #elif defined GNULIB_POSIXCHECK | ||
137 | # undef close | ||
138 | # define close(f) \ | ||
139 | (GL_LINK_WARNING ("close does not portably work on sockets - " \ | ||
140 | "use gnulib module close for portability"), \ | ||
141 | close (f)) | ||
142 | #endif | ||
143 | |||
144 | |||
71 | #if @GNULIB_DUP2@ | 145 | #if @GNULIB_DUP2@ |
72 | # if !@HAVE_DUP2@ | 146 | # if !@HAVE_DUP2@ |
73 | /* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if | 147 | /* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if |
@@ -86,6 +160,41 @@ extern int dup2 (int oldfd, int newfd); | |||
86 | #endif | 160 | #endif |
87 | 161 | ||
88 | 162 | ||
163 | #if @GNULIB_ENVIRON@ | ||
164 | # if !@HAVE_DECL_ENVIRON@ | ||
165 | /* Set of environment variables and values. An array of strings of the form | ||
166 | "VARIABLE=VALUE", terminated with a NULL. */ | ||
167 | # if defined __APPLE__ && defined __MACH__ | ||
168 | # include <crt_externs.h> | ||
169 | # define environ (*_NSGetEnviron ()) | ||
170 | # else | ||
171 | extern char **environ; | ||
172 | # endif | ||
173 | # endif | ||
174 | #elif defined GNULIB_POSIXCHECK | ||
175 | # undef environ | ||
176 | # define environ \ | ||
177 | (GL_LINK_WARNING ("environ is unportable - " \ | ||
178 | "use gnulib module environ for portability"), \ | ||
179 | environ) | ||
180 | #endif | ||
181 | |||
182 | |||
183 | #if @GNULIB_EUIDACCESS@ | ||
184 | # if !@HAVE_EUIDACCESS@ | ||
185 | /* Like access(), except that is uses the effective user id and group id of | ||
186 | the current process. */ | ||
187 | extern int euidaccess (const char *filename, int mode); | ||
188 | # endif | ||
189 | #elif defined GNULIB_POSIXCHECK | ||
190 | # undef euidaccess | ||
191 | # define euidaccess(f,m) \ | ||
192 | (GL_LINK_WARNING ("euidaccess is unportable - " \ | ||
193 | "use gnulib module euidaccess for portability"), \ | ||
194 | euidaccess (f, m)) | ||
195 | #endif | ||
196 | |||
197 | |||
89 | #if @GNULIB_FCHDIR@ | 198 | #if @GNULIB_FCHDIR@ |
90 | # if @REPLACE_FCHDIR@ | 199 | # if @REPLACE_FCHDIR@ |
91 | 200 | ||
@@ -96,8 +205,6 @@ extern int dup2 (int oldfd, int newfd); | |||
96 | <http://www.opengroup.org/susv3xsh/fchdir.html>. */ | 205 | <http://www.opengroup.org/susv3xsh/fchdir.html>. */ |
97 | extern int fchdir (int /*fd*/); | 206 | extern int fchdir (int /*fd*/); |
98 | 207 | ||
99 | # define close rpl_close | ||
100 | extern int close (int); | ||
101 | # define dup rpl_dup | 208 | # define dup rpl_dup |
102 | extern int dup (int); | 209 | extern int dup (int); |
103 | # define dup2 rpl_dup2 | 210 | # define dup2 rpl_dup2 |
@@ -113,6 +220,23 @@ extern int dup2 (int, int); | |||
113 | #endif | 220 | #endif |
114 | 221 | ||
115 | 222 | ||
223 | #if @GNULIB_FSYNC@ | ||
224 | /* Synchronize changes to a file. | ||
225 | Return 0 if successful, otherwise -1 and errno set. | ||
226 | See POSIX:2001 specification | ||
227 | <http://www.opengroup.org/susv3xsh/fsync.html>. */ | ||
228 | # if !@HAVE_FSYNC@ | ||
229 | extern int fsync (int fd); | ||
230 | # endif | ||
231 | #elif defined GNULIB_POSIXCHECK | ||
232 | # undef fsync | ||
233 | # define fsync(fd) \ | ||
234 | (GL_LINK_WARNING ("fsync is unportable - " \ | ||
235 | "use gnulib module fsync for portability"), \ | ||
236 | fsync (fd)) | ||
237 | #endif | ||
238 | |||
239 | |||
116 | #if @GNULIB_FTRUNCATE@ | 240 | #if @GNULIB_FTRUNCATE@ |
117 | # if !@HAVE_FTRUNCATE@ | 241 | # if !@HAVE_FTRUNCATE@ |
118 | /* Change the size of the file to which FD is opened to become equal to LENGTH. | 242 | /* Change the size of the file to which FD is opened to become equal to LENGTH. |
@@ -157,6 +281,70 @@ extern char * getcwd (char *buf, size_t size); | |||
157 | #endif | 281 | #endif |
158 | 282 | ||
159 | 283 | ||
284 | #if @GNULIB_GETDOMAINNAME@ | ||
285 | /* Return the NIS domain name of the machine. | ||
286 | WARNING! The NIS domain name is unrelated to the fully qualified host name | ||
287 | of the machine. It is also unrelated to email addresses. | ||
288 | WARNING! The NIS domain name is usually the empty string or "(none)" when | ||
289 | not using NIS. | ||
290 | |||
291 | Put up to LEN bytes of the NIS domain name into NAME. | ||
292 | Null terminate it if the name is shorter than LEN. | ||
293 | If the NIS domain name is longer than LEN, set errno = EINVAL and return -1. | ||
294 | Return 0 if successful, otherwise set errno and return -1. */ | ||
295 | # if !@HAVE_GETDOMAINNAME@ | ||
296 | extern int getdomainname(char *name, size_t len); | ||
297 | # endif | ||
298 | #elif defined GNULIB_POSIXCHECK | ||
299 | # undef getdomainname | ||
300 | # define getdomainname(n,l) \ | ||
301 | (GL_LINK_WARNING ("getdomainname is unportable - " \ | ||
302 | "use gnulib module getdomainname for portability"), \ | ||
303 | getdomainname (n, l)) | ||
304 | #endif | ||
305 | |||
306 | |||
307 | #if @GNULIB_GETDTABLESIZE@ | ||
308 | # if !@HAVE_GETDTABLESIZE@ | ||
309 | /* Return the maximum number of file descriptors in the current process. */ | ||
310 | extern int getdtablesize (void); | ||
311 | # endif | ||
312 | #elif defined GNULIB_POSIXCHECK | ||
313 | # undef getdtablesize | ||
314 | # define getdtablesize() \ | ||
315 | (GL_LINK_WARNING ("getdtablesize is unportable - " \ | ||
316 | "use gnulib module getdtablesize for portability"), \ | ||
317 | getdtablesize ()) | ||
318 | #endif | ||
319 | |||
320 | |||
321 | #if @GNULIB_GETHOSTNAME@ | ||
322 | /* Return the standard host name of the machine. | ||
323 | WARNING! The host name may or may not be fully qualified. | ||
324 | |||
325 | Put up to LEN bytes of the host name into NAME. | ||
326 | Null terminate it if the name is shorter than LEN. | ||
327 | If the host name is longer than LEN, set errno = EINVAL and return -1. | ||
328 | Return 0 if successful, otherwise set errno and return -1. */ | ||
329 | # if @UNISTD_H_HAVE_WINSOCK2_H@ | ||
330 | # undef gethostname | ||
331 | # define gethostname rpl_gethostname | ||
332 | # endif | ||
333 | # if @UNISTD_H_HAVE_WINSOCK2_H@ || !@HAVE_GETHOSTNAME@ | ||
334 | extern int gethostname(char *name, size_t len); | ||
335 | # endif | ||
336 | #elif @UNISTD_H_HAVE_WINSOCK2_H@ | ||
337 | # undef gethostname | ||
338 | # define gethostname gethostname_used_without_requesting_gnulib_module_gethostname | ||
339 | #elif defined GNULIB_POSIXCHECK | ||
340 | # undef gethostname | ||
341 | # define gethostname(n,l) \ | ||
342 | (GL_LINK_WARNING ("gethostname is unportable - " \ | ||
343 | "use gnulib module gethostname for portability"), \ | ||
344 | gethostname (n, l)) | ||
345 | #endif | ||
346 | |||
347 | |||
160 | #if @GNULIB_GETLOGIN_R@ | 348 | #if @GNULIB_GETLOGIN_R@ |
161 | /* Copies the user's login name to NAME. | 349 | /* Copies the user's login name to NAME. |
162 | The array pointed to by NAME has room for SIZE bytes. | 350 | The array pointed to by NAME has room for SIZE bytes. |
@@ -238,6 +426,36 @@ extern int getpagesize (void); | |||
238 | #endif | 426 | #endif |
239 | 427 | ||
240 | 428 | ||
429 | #if @GNULIB_GETUSERSHELL@ | ||
430 | # if !@HAVE_GETUSERSHELL@ | ||
431 | /* Return the next valid login shell on the system, or NULL when the end of | ||
432 | the list has been reached. */ | ||
433 | extern char *getusershell (void); | ||
434 | /* Rewind to pointer that is advanced at each getusershell() call. */ | ||
435 | extern void setusershell (void); | ||
436 | /* Free the pointer that is advanced at each getusershell() call and | ||
437 | associated resources. */ | ||
438 | extern void endusershell (void); | ||
439 | # endif | ||
440 | #elif defined GNULIB_POSIXCHECK | ||
441 | # undef getusershell | ||
442 | # define getusershell() \ | ||
443 | (GL_LINK_WARNING ("getusershell is unportable - " \ | ||
444 | "use gnulib module getusershell for portability"), \ | ||
445 | getusershell ()) | ||
446 | # undef setusershell | ||
447 | # define setusershell() \ | ||
448 | (GL_LINK_WARNING ("setusershell is unportable - " \ | ||
449 | "use gnulib module getusershell for portability"), \ | ||
450 | setusershell ()) | ||
451 | # undef endusershell | ||
452 | # define endusershell() \ | ||
453 | (GL_LINK_WARNING ("endusershell is unportable - " \ | ||
454 | "use gnulib module getusershell for portability"), \ | ||
455 | endusershell ()) | ||
456 | #endif | ||
457 | |||
458 | |||
241 | #if @GNULIB_LCHOWN@ | 459 | #if @GNULIB_LCHOWN@ |
242 | # if @REPLACE_LCHOWN@ | 460 | # if @REPLACE_LCHOWN@ |
243 | /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE | 461 | /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE |
@@ -311,6 +529,22 @@ extern unsigned int sleep (unsigned int n); | |||
311 | #endif | 529 | #endif |
312 | 530 | ||
313 | 531 | ||
532 | #if @GNULIB_WRITE@ && @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@ | ||
533 | /* Write up to COUNT bytes starting at BUF to file descriptor FD. | ||
534 | See the POSIX:2001 specification | ||
535 | <http://www.opengroup.org/susv3xsh/write.html>. */ | ||
536 | # undef write | ||
537 | # define write rpl_write | ||
538 | extern ssize_t write (int fd, const void *buf, size_t count); | ||
539 | #endif | ||
540 | |||
541 | |||
542 | #ifdef FCHDIR_REPLACEMENT | ||
543 | /* gnulib internal function. */ | ||
544 | extern void _gl_unregister_fd (int fd); | ||
545 | #endif | ||
546 | |||
547 | |||
314 | #ifdef __cplusplus | 548 | #ifdef __cplusplus |
315 | } | 549 | } |
316 | #endif | 550 | #endif |