1 /* -*- buffer-read-only: t -*- vi: set ro: */
2 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
3 /* Substitute for and wrapper around <unistd.h>.
4 Copyright (C) 2004-2008 Free Software Foundation, Inc.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software Foundation,
18 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
22 /* The include_next requires a split double-inclusion guard. */
24 # @INCLUDE_NEXT@ @NEXT_UNISTD_H@
30 /* mingw doesn't define the SEEK_* macros in <unistd.h>. */
31 #if !(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET)
35 /* mingw fails to declare _exit in <unistd.h>. */
38 /* The definition of GL_LINK_WARNING is copied here. */
41 /* Declare overridden functions. */
50 # ifndef REPLACE_CHOWN
51 # define REPLACE_CHOWN 1
54 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
55 to GID (if GID is not -1). Follow symbolic links.
56 Return 0 if successful, otherwise -1 and errno set.
57 See the POSIX:2001 specification
58 <http://www.opengroup.org/susv3xsh/chown.html>. */
59 # define chown rpl_chown
60 extern int chown (const char *file, uid_t uid, gid_t gid);
63 #elif defined GNULIB_POSIXCHECK
65 # define chown(f,u,g) \
66 (GL_LINK_WARNING ("chown fails to follow symlinks on some systems and " \
67 "doesn't treat a uid or gid of -1 on some systems - " \
68 "use gnulib module chown for portability"), \
75 /* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if
76 NEWFD = OLDFD, otherwise close NEWFD first if it is open.
77 Return 0 if successful, otherwise -1 and errno set.
78 See the POSIX:2001 specification
79 <http://www.opengroup.org/susv3xsh/dup2.html>. */
80 extern int dup2 (int oldfd, int newfd);
82 #elif defined GNULIB_POSIXCHECK
85 (GL_LINK_WARNING ("dup2 is unportable - " \
86 "use gnulib module dup2 for portability"), \
92 # if !@HAVE_DECL_ENVIRON@
93 /* Set of environment variables and values. An array of strings of the form
94 "VARIABLE=VALUE", terminated with a NULL. */
95 # if defined __APPLE__ && defined __MACH__
96 # include <crt_externs.h>
97 # define environ (*_NSGetEnviron ())
99 extern char **environ;
102 #elif defined GNULIB_POSIXCHECK
105 (GL_LINK_WARNING ("environ is unportable - " \
106 "use gnulib module environ for portability"), \
112 # if @REPLACE_FCHDIR@
114 /* Change the process' current working directory to the directory on which
115 the given file descriptor is open.
116 Return 0 if successful, otherwise -1 and errno set.
117 See the POSIX:2001 specification
118 <http://www.opengroup.org/susv3xsh/fchdir.html>. */
119 extern int fchdir (int /*fd*/);
121 # define close rpl_close
122 extern int close (int);
124 extern int dup (int);
125 # define dup2 rpl_dup2
126 extern int dup2 (int, int);
129 #elif defined GNULIB_POSIXCHECK
132 (GL_LINK_WARNING ("fchdir is unportable - " \
133 "use gnulib module fchdir for portability"), \
138 #if @GNULIB_FTRUNCATE@
139 # if !@HAVE_FTRUNCATE@
140 /* Change the size of the file to which FD is opened to become equal to LENGTH.
141 Return 0 if successful, otherwise -1 and errno set.
142 See the POSIX:2001 specification
143 <http://www.opengroup.org/susv3xsh/ftruncate.html>. */
144 extern int ftruncate (int fd, off_t length);
146 #elif defined GNULIB_POSIXCHECK
148 # define ftruncate(f,l) \
149 (GL_LINK_WARNING ("ftruncate is unportable - " \
150 "use gnulib module ftruncate for portability"), \
156 /* Include the headers that might declare getcwd so that they will not
157 cause confusion if included after this file. */
159 # if @REPLACE_GETCWD@
160 /* Get the name of the current working directory, and put it in SIZE bytes
162 Return BUF if successful, or NULL if the directory couldn't be determined
163 or SIZE was too small.
164 See the POSIX:2001 specification
165 <http://www.opengroup.org/susv3xsh/getcwd.html>.
166 Additionally, the gnulib module 'getcwd' guarantees the following GNU
167 extension: If BUF is NULL, an array is allocated with 'malloc'; the array
168 is SIZE bytes long, unless SIZE == 0, in which case it is as big as
170 # define getcwd rpl_getcwd
171 extern char * getcwd (char *buf, size_t size);
173 #elif defined GNULIB_POSIXCHECK
175 # define getcwd(b,s) \
176 (GL_LINK_WARNING ("getcwd is unportable - " \
177 "use gnulib module getcwd for portability"), \
182 #if @GNULIB_GETLOGIN_R@
183 /* Copies the user's login name to NAME.
184 The array pointed to by NAME has room for SIZE bytes.
186 Returns 0 if successful. Upon error, an error number is returned, or -1 in
187 the case that the login name cannot be found but no specific error is
188 provided (this case is hopefully rare but is left open by the POSIX spec).
190 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
192 # if !@HAVE_DECL_GETLOGIN_R@
194 extern int getlogin_r (char *name, size_t size);
196 #elif defined GNULIB_POSIXCHECK
198 # define getlogin_r(n,s) \
199 (GL_LINK_WARNING ("getlogin_r is unportable - " \
200 "use gnulib module getlogin_r for portability"), \
205 #if @GNULIB_GETPAGESIZE@
206 # if @REPLACE_GETPAGESIZE@
207 # define getpagesize rpl_getpagesize
208 extern int getpagesize (void);
209 # elif !@HAVE_GETPAGESIZE@
210 /* This is for POSIX systems. */
211 # if !defined getpagesize && defined _SC_PAGESIZE
212 # if ! (defined __VMS && __VMS_VER < 70000000)
213 # define getpagesize() sysconf (_SC_PAGESIZE)
216 /* This is for older VMS. */
217 # if !defined getpagesize && defined __VMS
219 # define getpagesize() 8192
221 # define getpagesize() 512
224 /* This is for BeOS. */
225 # if !defined getpagesize && @HAVE_OS_H@
227 # if defined B_PAGE_SIZE
228 # define getpagesize() B_PAGE_SIZE
231 /* This is for AmigaOS4.0. */
232 # if !defined getpagesize && defined __amigaos4__
233 # define getpagesize() 2048
235 /* This is for older Unix systems. */
236 # if !defined getpagesize && @HAVE_SYS_PARAM_H@
237 # include <sys/param.h>
238 # ifdef EXEC_PAGESIZE
239 # define getpagesize() EXEC_PAGESIZE
245 # define getpagesize() (NBPG * CLSIZE)
248 # define getpagesize() NBPC
254 #elif defined GNULIB_POSIXCHECK
256 # define getpagesize() \
257 (GL_LINK_WARNING ("getpagesize is unportable - " \
258 "use gnulib module getpagesize for portability"), \
264 # if @REPLACE_LCHOWN@
265 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
266 to GID (if GID is not -1). Do not follow symbolic links.
267 Return 0 if successful, otherwise -1 and errno set.
268 See the POSIX:2001 specification
269 <http://www.opengroup.org/susv3xsh/lchown.html>. */
270 # define lchown rpl_lchown
271 extern int lchown (char const *file, uid_t owner, gid_t group);
273 #elif defined GNULIB_POSIXCHECK
275 # define lchown(f,u,g) \
276 (GL_LINK_WARNING ("lchown is unportable to pre-POSIX.1-2001 " \
277 "systems - use gnulib module lchown for portability"), \
284 /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
285 Return the new offset if successful, otherwise -1 and errno set.
286 See the POSIX:2001 specification
287 <http://www.opengroup.org/susv3xsh/lseek.html>. */
288 # define lseek rpl_lseek
289 extern off_t lseek (int fd, off_t offset, int whence);
291 #elif defined GNULIB_POSIXCHECK
293 # define lseek(f,o,w) \
294 (GL_LINK_WARNING ("lseek does not fail with ESPIPE on pipes on some " \
295 "systems - use gnulib module lseek for portability"), \
300 #if @GNULIB_READLINK@
301 /* Read the contents of the symbolic link FILE and place the first BUFSIZE
302 bytes of it into BUF. Return the number of bytes placed into BUF if
303 successful, otherwise -1 and errno set.
304 See the POSIX:2001 specification
305 <http://www.opengroup.org/susv3xsh/readlink.html>. */
306 # if !@HAVE_READLINK@
308 extern int readlink (const char *file, char *buf, size_t bufsize);
310 #elif defined GNULIB_POSIXCHECK
312 # define readlink(f,b,s) \
313 (GL_LINK_WARNING ("readlink is unportable - " \
314 "use gnulib module readlink for portability"), \
320 /* Pause the execution of the current thread for N seconds.
321 Returns the number of seconds left to sleep.
322 See the POSIX:2001 specification
323 <http://www.opengroup.org/susv3xsh/sleep.html>. */
325 extern unsigned int sleep (unsigned int n);
327 #elif defined GNULIB_POSIXCHECK
330 (GL_LINK_WARNING ("sleep is unportable - " \
331 "use gnulib module sleep for portability"), \
341 #endif /* _GL_UNISTD_H */
342 #endif /* _GL_UNISTD_H */