Move the getdomainname() declaration to <unistd.h>.
[pspp] / lib / unistd.in.h
1 /* Substitute for and wrapper around <unistd.h>.
2    Copyright (C) 2003-2008 Free Software Foundation, Inc.
3
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
6    the Free Software Foundation; either version 2, or (at your option)
7    any later version.
8
9    This program is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    GNU General Public License for more details.
13
14    You should have received a copy of the GNU General Public License
15    along with this program; if not, write to the Free Software Foundation,
16    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
17
18 #ifndef _GL_UNISTD_H
19
20 #if __GNUC__ >= 3
21 @PRAGMA_SYSTEM_HEADER@
22 #endif
23
24 /* The include_next requires a split double-inclusion guard.  */
25 #if @HAVE_UNISTD_H@
26 # @INCLUDE_NEXT@ @NEXT_UNISTD_H@
27 #endif
28
29 #ifndef _GL_UNISTD_H
30 #define _GL_UNISTD_H
31
32 /* mingw doesn't define the SEEK_* macros in <unistd.h>.  */
33 #if !(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET)
34 # include <stdio.h>
35 #endif
36
37 /* mingw fails to declare _exit in <unistd.h>.  */
38 #include <stdlib.h>
39
40 #if @GNULIB_WRITE@ && @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@
41 /* Get ssize_t.  */
42 # include <sys/types.h>
43 #endif
44
45 /* The definition of GL_LINK_WARNING is copied here.  */
46
47
48 /* Declare overridden functions.  */
49
50 #ifdef __cplusplus
51 extern "C" {
52 #endif
53
54
55 #if @GNULIB_CHOWN@
56 # if @REPLACE_CHOWN@
57 #  ifndef REPLACE_CHOWN
58 #   define REPLACE_CHOWN 1
59 #  endif
60 #  if REPLACE_CHOWN
61 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
62    to GID (if GID is not -1).  Follow symbolic links.
63    Return 0 if successful, otherwise -1 and errno set.
64    See the POSIX:2001 specification
65    <http://www.opengroup.org/susv3xsh/chown.html>.  */
66 #   define chown rpl_chown
67 extern int chown (const char *file, uid_t uid, gid_t gid);
68 #  endif
69 # endif
70 #elif defined GNULIB_POSIXCHECK
71 # undef chown
72 # define chown(f,u,g) \
73     (GL_LINK_WARNING ("chown fails to follow symlinks on some systems and " \
74                       "doesn't treat a uid or gid of -1 on some systems - " \
75                       "use gnulib module chown for portability"), \
76      chown (f, u, g))
77 #endif
78
79
80 #if @GNULIB_CLOSE@
81 # if @REPLACE_CLOSE@
82 /* Automatically included by modules that need a replacement for close.  */
83 #  undef close
84 #  define close rpl_close
85 extern int close (int);
86 # endif
87 #elif @UNISTD_H_HAVE_WINSOCK2_H@
88 # undef close
89 # define close close_used_without_requesting_gnulib_module_close
90 #elif defined GNULIB_POSIXCHECK
91 # undef close
92 # define close(f) \
93     (GL_LINK_WARNING ("close does not portably work on sockets - " \
94                       "use gnulib module close for portability"), \
95      close (f))
96 #endif
97
98
99 #if @GNULIB_DUP2@
100 # if !@HAVE_DUP2@
101 /* Copy the file descriptor OLDFD into file descriptor NEWFD.  Do nothing if
102    NEWFD = OLDFD, otherwise close NEWFD first if it is open.
103    Return 0 if successful, otherwise -1 and errno set.
104    See the POSIX:2001 specification
105    <http://www.opengroup.org/susv3xsh/dup2.html>.  */
106 extern int dup2 (int oldfd, int newfd);
107 # endif
108 #elif defined GNULIB_POSIXCHECK
109 # undef dup2
110 # define dup2(o,n) \
111     (GL_LINK_WARNING ("dup2 is unportable - " \
112                       "use gnulib module dup2 for portability"), \
113      dup2 (o, n))
114 #endif
115
116
117 #if @GNULIB_ENVIRON@
118 # if !@HAVE_DECL_ENVIRON@
119 /* Set of environment variables and values.  An array of strings of the form
120    "VARIABLE=VALUE", terminated with a NULL.  */
121 #  if defined __APPLE__ && defined __MACH__
122 #   include <crt_externs.h>
123 #   define environ (*_NSGetEnviron ())
124 #  else
125 extern char **environ;
126 #  endif
127 # endif
128 #elif defined GNULIB_POSIXCHECK
129 # undef environ
130 # define environ \
131     (GL_LINK_WARNING ("environ is unportable - " \
132                       "use gnulib module environ for portability"), \
133      environ)
134 #endif
135
136
137 #if @GNULIB_FCHDIR@
138 # if @REPLACE_FCHDIR@
139
140 /* Change the process' current working directory to the directory on which
141    the given file descriptor is open.
142    Return 0 if successful, otherwise -1 and errno set.
143    See the POSIX:2001 specification
144    <http://www.opengroup.org/susv3xsh/fchdir.html>.  */
145 extern int fchdir (int /*fd*/);
146
147 #  define dup rpl_dup
148 extern int dup (int);
149 #  define dup2 rpl_dup2
150 extern int dup2 (int, int);
151
152 # endif
153 #elif defined GNULIB_POSIXCHECK
154 # undef fchdir
155 # define fchdir(f) \
156     (GL_LINK_WARNING ("fchdir is unportable - " \
157                       "use gnulib module fchdir for portability"), \
158      fchdir (f))
159 #endif
160
161
162 #if @GNULIB_FSYNC@
163 /* Synchronize changes to a file.
164    Return 0 if successful, otherwise -1 and errno set.
165    See POSIX:2001 specification
166    <http://www.opengroup.org/susv3xsh/fsync.html>.  */
167 # if !@HAVE_FSYNC@
168 extern int fsync (int fd);
169 # endif
170 #elif defined GNULIB_POSIXCHECK
171 # undef fsync
172 # define fsync(fd) \
173     (GL_LINK_WARNING ("fsync is unportable - " \
174                       "use gnulib module fsync for portability"), \
175      fsync (fd))
176 #endif
177
178
179 #if @GNULIB_FTRUNCATE@
180 # if !@HAVE_FTRUNCATE@
181 /* Change the size of the file to which FD is opened to become equal to LENGTH.
182    Return 0 if successful, otherwise -1 and errno set.
183    See the POSIX:2001 specification
184    <http://www.opengroup.org/susv3xsh/ftruncate.html>.  */
185 extern int ftruncate (int fd, off_t length);
186 # endif
187 #elif defined GNULIB_POSIXCHECK
188 # undef ftruncate
189 # define ftruncate(f,l) \
190     (GL_LINK_WARNING ("ftruncate is unportable - " \
191                       "use gnulib module ftruncate for portability"), \
192      ftruncate (f, l))
193 #endif
194
195
196 #if @GNULIB_GETCWD@
197 /* Include the headers that might declare getcwd so that they will not
198    cause confusion if included after this file.  */
199 # include <stdlib.h>
200 # if @REPLACE_GETCWD@
201 /* Get the name of the current working directory, and put it in SIZE bytes
202    of BUF.
203    Return BUF if successful, or NULL if the directory couldn't be determined
204    or SIZE was too small.
205    See the POSIX:2001 specification
206    <http://www.opengroup.org/susv3xsh/getcwd.html>.
207    Additionally, the gnulib module 'getcwd' guarantees the following GNU
208    extension: If BUF is NULL, an array is allocated with 'malloc'; the array
209    is SIZE bytes long, unless SIZE == 0, in which case it is as big as
210    necessary.  */
211 #  define getcwd rpl_getcwd
212 extern char * getcwd (char *buf, size_t size);
213 # endif
214 #elif defined GNULIB_POSIXCHECK
215 # undef getcwd
216 # define getcwd(b,s) \
217     (GL_LINK_WARNING ("getcwd is unportable - " \
218                       "use gnulib module getcwd for portability"), \
219      getcwd (b, s))
220 #endif
221
222
223 #if @GNULIB_GETDOMAINNAME@
224 /* Return the NIS domain name of the machine.
225    WARNING! The NIS domain name is unrelated to the fully qualified host name
226             of the machine.  It is also unrelated to email addresses.
227    WARNING! The NIS domain name is usually the empty string or "(none)" when
228             not using NIS.
229
230    Put up to LEN bytes of the NIS domain name into NAME.
231    Null terminate it if the name is shorter than LEN.
232    If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
233    Return 0 if successful, otherwise set errno and return -1.  */
234 # if !@HAVE_GETDOMAINNAME@
235 extern int getdomainname(char *name, size_t len);
236 # endif
237 #elif defined GNULIB_POSIXCHECK
238 # undef getdomainname
239 # define getdomainname(n,l) \
240     (GL_LINK_WARNING ("getdomainname is unportable - " \
241                       "use gnulib module getdomainname for portability"), \
242      getdomainname (n, l))
243 #endif
244
245
246 #if @GNULIB_GETDTABLESIZE@
247 # if !@HAVE_GETDTABLESIZE@
248 /* Return the maximum number of file descriptors in the current process.  */
249 extern int getdtablesize (void);
250 # endif
251 #elif defined GNULIB_POSIXCHECK
252 # undef getdtablesize
253 # define getdtablesize() \
254     (GL_LINK_WARNING ("getdtablesize is unportable - " \
255                       "use gnulib module getdtablesize for portability"), \
256      getdtablesize ())
257 #endif
258
259
260 #if @GNULIB_GETLOGIN_R@
261 /* Copies the user's login name to NAME.
262    The array pointed to by NAME has room for SIZE bytes.
263
264    Returns 0 if successful.  Upon error, an error number is returned, or -1 in
265    the case that the login name cannot be found but no specific error is
266    provided (this case is hopefully rare but is left open by the POSIX spec).
267
268    See <http://www.opengroup.org/susv3xsh/getlogin.html>.
269  */
270 # if !@HAVE_DECL_GETLOGIN_R@
271 #  include <stddef.h>
272 extern int getlogin_r (char *name, size_t size);
273 # endif
274 #elif defined GNULIB_POSIXCHECK
275 # undef getlogin_r
276 # define getlogin_r(n,s) \
277     (GL_LINK_WARNING ("getlogin_r is unportable - " \
278                       "use gnulib module getlogin_r for portability"), \
279      getlogin_r (n, s))
280 #endif
281
282
283 #if @GNULIB_GETPAGESIZE@
284 # if @REPLACE_GETPAGESIZE@
285 #  define getpagesize rpl_getpagesize
286 extern int getpagesize (void);
287 # elif !@HAVE_GETPAGESIZE@
288 /* This is for POSIX systems.  */
289 #  if !defined getpagesize && defined _SC_PAGESIZE
290 #   if ! (defined __VMS && __VMS_VER < 70000000)
291 #    define getpagesize() sysconf (_SC_PAGESIZE)
292 #   endif
293 #  endif
294 /* This is for older VMS.  */
295 #  if !defined getpagesize && defined __VMS
296 #   ifdef __ALPHA
297 #    define getpagesize() 8192
298 #   else
299 #    define getpagesize() 512
300 #   endif
301 #  endif
302 /* This is for BeOS.  */
303 #  if !defined getpagesize && @HAVE_OS_H@
304 #   include <OS.h>
305 #   if defined B_PAGE_SIZE
306 #    define getpagesize() B_PAGE_SIZE
307 #   endif
308 #  endif
309 /* This is for AmigaOS4.0.  */
310 #  if !defined getpagesize && defined __amigaos4__
311 #   define getpagesize() 2048
312 #  endif
313 /* This is for older Unix systems.  */
314 #  if !defined getpagesize && @HAVE_SYS_PARAM_H@
315 #   include <sys/param.h>
316 #   ifdef EXEC_PAGESIZE
317 #    define getpagesize() EXEC_PAGESIZE
318 #   else
319 #    ifdef NBPG
320 #     ifndef CLSIZE
321 #      define CLSIZE 1
322 #     endif
323 #     define getpagesize() (NBPG * CLSIZE)
324 #    else
325 #     ifdef NBPC
326 #      define getpagesize() NBPC
327 #     endif
328 #    endif
329 #   endif
330 #  endif
331 # endif
332 #elif defined GNULIB_POSIXCHECK
333 # undef getpagesize
334 # define getpagesize() \
335     (GL_LINK_WARNING ("getpagesize is unportable - " \
336                       "use gnulib module getpagesize for portability"), \
337      getpagesize ())
338 #endif
339
340
341 #if @GNULIB_LCHOWN@
342 # if @REPLACE_LCHOWN@
343 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
344    to GID (if GID is not -1).  Do not follow symbolic links.
345    Return 0 if successful, otherwise -1 and errno set.
346    See the POSIX:2001 specification
347    <http://www.opengroup.org/susv3xsh/lchown.html>.  */
348 #  define lchown rpl_lchown
349 extern int lchown (char const *file, uid_t owner, gid_t group);
350 # endif
351 #elif defined GNULIB_POSIXCHECK
352 # undef lchown
353 # define lchown(f,u,g) \
354     (GL_LINK_WARNING ("lchown is unportable to pre-POSIX.1-2001 " \
355                       "systems - use gnulib module lchown for portability"), \
356      lchown (f, u, g))
357 #endif
358
359
360 #if @GNULIB_LSEEK@
361 # if @REPLACE_LSEEK@
362 /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
363    Return the new offset if successful, otherwise -1 and errno set.
364    See the POSIX:2001 specification
365    <http://www.opengroup.org/susv3xsh/lseek.html>.  */
366 #  define lseek rpl_lseek
367    extern off_t lseek (int fd, off_t offset, int whence);
368 # endif
369 #elif defined GNULIB_POSIXCHECK
370 # undef lseek
371 # define lseek(f,o,w) \
372     (GL_LINK_WARNING ("lseek does not fail with ESPIPE on pipes on some " \
373                       "systems - use gnulib module lseek for portability"), \
374      lseek (f, o, w))
375 #endif
376
377
378 #if @GNULIB_READLINK@
379 /* Read the contents of the symbolic link FILE and place the first BUFSIZE
380    bytes of it into BUF.  Return the number of bytes placed into BUF if
381    successful, otherwise -1 and errno set.
382    See the POSIX:2001 specification
383    <http://www.opengroup.org/susv3xsh/readlink.html>.  */
384 # if !@HAVE_READLINK@
385 #  include <stddef.h>
386 extern int readlink (const char *file, char *buf, size_t bufsize);
387 # endif
388 #elif defined GNULIB_POSIXCHECK
389 # undef readlink
390 # define readlink(f,b,s) \
391     (GL_LINK_WARNING ("readlink is unportable - " \
392                       "use gnulib module readlink for portability"), \
393      readlink (f, b, s))
394 #endif
395
396
397 #if @GNULIB_SLEEP@
398 /* Pause the execution of the current thread for N seconds.
399    Returns the number of seconds left to sleep.
400    See the POSIX:2001 specification
401    <http://www.opengroup.org/susv3xsh/sleep.html>.  */
402 # if !@HAVE_SLEEP@
403 extern unsigned int sleep (unsigned int n);
404 # endif
405 #elif defined GNULIB_POSIXCHECK
406 # undef sleep
407 # define sleep(n) \
408     (GL_LINK_WARNING ("sleep is unportable - " \
409                       "use gnulib module sleep for portability"), \
410      sleep (n))
411 #endif
412
413
414 #if @GNULIB_WRITE@ && @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@
415 /* Write up to COUNT bytes starting at BUF to file descriptor FD.
416    See the POSIX:2001 specification
417    <http://www.opengroup.org/susv3xsh/write.html>.  */
418 # undef write
419 # define write rpl_write
420 extern ssize_t write (int fd, const void *buf, size_t count);
421 #endif
422
423
424 #ifdef FCHDIR_REPLACEMENT
425 /* gnulib internal function.  */
426 extern void _gl_unregister_fd (int fd);
427 #endif
428
429
430 #ifdef __cplusplus
431 }
432 #endif
433
434
435 #endif /* _GL_UNISTD_H */
436 #endif /* _GL_UNISTD_H */