Hurd select fixes.
[glibc.git] / posix / unistd.h
blob55d66a6d27f862df8f870cbcfd0c482d6c143c95
1 /* Copyright (C) 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
9 The GNU C Library 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 GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public
15 License along with the GNU C Library; see the file COPYING.LIB. If
16 not, write to the Free Software Foundation, Inc., 675 Mass Ave,
17 Cambridge, MA 02139, USA. */
20 * POSIX Standard: 2.10 Symbolic Constants <unistd.h>
23 #ifndef _UNISTD_H
25 #define _UNISTD_H 1
26 #include <features.h>
28 __BEGIN_DECLS
30 /* These may be used to determine what facilities are present at compile time.
31 Their values can be obtained at run time from sysconf. */
33 /* POSIX Standard approved as IEEE Std 1003.1 as of August, 1988. */
34 #define _POSIX_VERSION 199009L
36 /* These are not #ifdef __USE_POSIX2 because they are
37 in the theoretically application-owned namespace. */
39 #define _POSIX2_C_VERSION 199912L /* Invalid until 1003.2 is done. */
41 /* If defined, the implementation supports the
42 C Language Bindings Option. */
43 #define _POSIX2_C_BIND 1
45 /* If defined, the implementation supports the
46 C Language Development Utilities Option. */
47 #define _POSIX2_C_DEV 1
49 /* If defined, the implementation supports the
50 Software Development Utilities Option. */
51 #define _POSIX2_SW_DEV 1
54 /* Get values of POSIX options:
56 If these symbols are defined, the corresponding features are
57 always available. If not, they may be available sometimes.
58 The current values can be obtained with `sysconf'.
60 _POSIX_JOB_CONTROL Job control is supported.
61 _POSIX_SAVED_IDS Processes have a saved set-user-ID
62 and a saved set-group-ID.
64 If any of these symbols is defined as -1, the corresponding option is not
65 true for any file. If any is defined as other than -1, the corresponding
66 option is true for all files. If a symbol is not defined at all, the value
67 for a specific file can be obtained from `pathconf' and `fpathconf'.
69 _POSIX_CHOWN_RESTRICTED Only the super user can use `chown' to change
70 the owner of a file. `chown' can only be used
71 to change the group ID of a file to a group of
72 which the calling process is a member.
73 _POSIX_NO_TRUNC Pathname components longer than
74 NAME_MAX generate an error.
75 _POSIX_VDISABLE If defined, if the value of an element of the
76 `c_cc' member of `struct termios' is
77 _POSIX_VDISABLE, no character will have the
78 effect associated with that element.
81 #include <posix_opt.h>
84 /* Standard file descriptors. */
85 #define STDIN_FILENO 0 /* Standard input. */
86 #define STDOUT_FILENO 1 /* Standard output. */
87 #define STDERR_FILENO 2 /* Standard error output. */
90 /* All functions that are not declared anywhere else. */
92 #include <gnu/types.h>
94 #ifndef ssize_t
95 #define ssize_t __ssize_t
96 #endif
98 #define __need_size_t
99 #define __need_NULL
100 #include <stddef.h>
103 /* Values for the second argument to access.
104 These may be OR'd together. */
105 #define R_OK 4 /* Test for read permission. */
106 #define W_OK 2 /* Test for write permission. */
107 #define X_OK 1 /* Test for execute permission. */
108 #define F_OK 0 /* Test for existence. */
110 /* Test for access to NAME using the real UID and real GID. */
111 extern int __access __P ((__const char *__name, int __type));
112 extern int access __P ((__const char *__name, int __type));
114 #ifdef __USE_GNU
115 /* Test for access to NAME using the effective UID and GID
116 (as normal file operations use). */
117 extern int euidaccess __P ((__const char *__name, int __type));
118 #endif
121 /* Values for the WHENCE argument to lseek. */
122 #ifndef _STDIO_H /* <stdio.h> has the same definitions. */
123 #define SEEK_SET 0 /* Seek from beginning of file. */
124 #define SEEK_CUR 1 /* Seek from current position. */
125 #define SEEK_END 2 /* Seek from end of file. */
126 #endif
128 #if defined (__USE_BSD) && !defined (L_SET)
129 /* Old BSD names for the same constants; just for compatibility. */
130 #define L_SET SEEK_SET
131 #define L_INCR SEEK_CUR
132 #define L_XTND SEEK_END
133 #endif
136 /* Move FD's file position to OFFSET bytes from the
137 beginning of the file (if WHENCE is SEEK_SET),
138 the current position (if WHENCE is SEEK_CUR),
139 or the end of the file (if WHENCE is SEEK_END).
140 Return the new file position. */
141 extern __off_t __lseek __P ((int __fd, __off_t __offset, int __whence));
142 extern __off_t lseek __P ((int __fd, __off_t __offset, int __whence));
144 /* Close the file descriptor FD. */
145 extern int __close __P ((int __fd));
146 extern int close __P ((int __fd));
148 /* Read NBYTES into BUF from FD. Return the
149 number read, -1 for errors or 0 for EOF. */
150 extern ssize_t __read __P ((int __fd, __ptr_t __buf, size_t __nbytes));
151 extern ssize_t read __P ((int __fd, __ptr_t __buf, size_t __nbytes));
153 /* Write N bytes of BUF to FD. Return the number written, or -1. */
154 extern ssize_t __write __P ((int __fd, __const __ptr_t __buf, size_t __n));
155 extern ssize_t write __P ((int __fd, __const __ptr_t __buf, size_t __n));
158 /* Create a one-way communication channel (pipe).
159 If successul, two file descriptors are stored in PIPEDES;
160 bytes written on PIPEDES[1] can be read from PIPEDES[0].
161 Returns 0 if successful, -1 if not. */
162 extern int __pipe __P ((int __pipedes[2]));
163 extern int pipe __P ((int __pipedes[2]));
165 /* Schedule an alarm. In SECONDS seconds, the process will get a SIGALRM.
166 If SECONDS is zero, any currently scheduled alarm will be cancelled.
167 The function returns the number of seconds remaining until the last
168 alarm scheduled would have signaled, or zero if there wasn't one.
169 There is no return value to indicate an error, but you can set `errno'
170 to 0 and check its value after calling `alarm', and this might tell you.
171 The signal may come late due to processor scheduling. */
172 extern unsigned int alarm __P ((unsigned int __seconds));
174 /* Make the process sleep for SECONDS seconds, or until a signal arrives
175 and is not ignored. The function returns the number of seconds less
176 than SECONDS which it actually slept (thus zero if it slept the full time).
177 If a signal handler does a `longjmp' or modifies the handling of the
178 SIGALRM signal while inside `sleep' call, the handling of the SIGALRM
179 signal afterwards is undefined. There is no return value to indicate
180 error, but if `sleep' returns SECONDS, it probably didn't work. */
181 extern unsigned int sleep __P ((unsigned int __seconds));
184 /* Suspend the process until a signal arrives.
185 This always returns -1 and sets `errno' to EINTR. */
186 extern int pause __P ((void));
189 /* Change the owner and group of FILE. */
190 extern int __chown __P ((__const char *__file,
191 __uid_t __owner, __gid_t __group));
192 extern int chown __P ((__const char *__file,
193 __uid_t __owner, __gid_t __group));
195 #ifdef __USE_BSD
196 /* Change the owner and group of the file that FD is open on. */
197 extern int __fchown __P ((int __fd,
198 __uid_t __owner, __gid_t __group));
199 extern int fchown __P ((int __fd,
200 __uid_t __owner, __gid_t __group));
201 #endif /* Use BSD. */
203 /* Change the process's working directory to PATH. */
204 extern int __chdir __P ((__const char *__path));
205 extern int chdir __P ((__const char *__path));
207 #ifdef __USE_BSD
208 /* Change the process's working directory to the one FD is open on. */
209 extern int fchdir __P ((int __fd));
210 #endif
212 /* Get the pathname of the current working directory,
213 and put it in SIZE bytes of BUF. Returns NULL if the
214 directory couldn't be determined or SIZE was too small.
215 If successful, returns BUF. In GNU, if BUF is NULL,
216 an array is allocated with `malloc'; the array is SIZE
217 bytes long, unless SIZE <= 0, in which case it is as
218 big as necessary. */
219 extern char *__getcwd __P ((char *__buf, size_t __size));
220 extern char *getcwd __P ((char *__buf, size_t __size));
222 #ifdef __USE_GNU
223 /* Return a malloc'd string containing the current directory name.
224 If the environment variable `PWD' is set, and its value is correct,
225 that value is used. */
226 extern char *get_current_dir_name __P ((void));
227 #endif
229 #ifdef __USE_BSD
230 /* Put the absolute pathname of the current working directory in BUF.
231 If successful, return BUF. If not, put an error message in
232 BUF and return NULL. BUF should be at least PATH_MAX bytes long. */
233 extern char *getwd __P ((char *__buf));
234 #endif
237 /* Duplicate FD, returning a new file descriptor on the same file. */
238 extern int __dup __P ((int __fd));
239 extern int dup __P ((int __fd));
241 /* Duplicate FD to FD2, closing FD2 and making it open on the same file. */
242 extern int __dup2 __P ((int __fd, int __fd2));
243 extern int dup2 __P ((int __fd, int __fd2));
245 /* NULL-terminated array of "NAME=VALUE" environment variables. */
246 extern char **__environ;
247 extern char **environ;
250 /* Replace the current process, executing PATH with arguments ARGV and
251 environment ENVP. ARGV and ENVP are terminated by NULL pointers. */
252 extern int __execve __P ((__const char *__path, char *__const __argv[],
253 char *__const __envp[]));
254 extern int execve __P ((__const char *__path, char *__const __argv[],
255 char *__const __envp[]));
257 #ifdef __USE_GNU
258 /* Execute the file FD refers to, overlaying the running program image.
259 ARGV and ENVP are passed to the new program, as for `execve'. */
260 extern int fexecve __P ((int __fd,
261 char *const __argv[], char *const __envp[]));
263 #endif
266 /* Execute PATH with arguments ARGV and environment from `environ'. */
267 extern int execv __P ((__const char *__path, char *__const __argv[]));
269 /* Execute PATH with all arguments after PATH until a NULL pointer,
270 and the argument after that for environment. */
271 extern int execle __P ((__const char *__path, __const char *__arg,...));
273 /* Execute PATH with all arguments after PATH until
274 a NULL pointer and environment from `environ'. */
275 extern int execl __P ((__const char *__path, __const char *__arg,...));
277 /* Execute FILE, searching in the `PATH' environment variable if it contains
278 no slashes, with arguments ARGV and environment from `environ'. */
279 extern int execvp __P ((__const char *__file, char *__const __argv[]));
281 /* Execute FILE, searching in the `PATH' environment variable if
282 it contains no slashes, with all arguments after FILE until a
283 NULL pointer and environment from `environ'. */
284 extern int execlp __P ((__const char *__file, ...));
287 /* Terminate program execution with the low-order 8 bits of STATUS. */
288 extern void _exit __P ((int __status)) __attribute__ ((__noreturn__));
291 /* Get the `_PC_*' symbols for the NAME argument to `pathconf' and `fpathconf';
292 the `_SC_*' symbols for the NAME argument to `sysconf';
293 and the `_CS_*' symbols for the NAME argument to `confstr'. */
294 #include <confname.h>
296 /* Get file-specific configuration information about PATH. */
297 extern long int __pathconf __P ((__const char *__path, int __name));
298 extern long int pathconf __P ((__const char *__path, int __name));
300 /* Get file-specific configuration about descriptor FD. */
301 extern long int __fpathconf __P ((int __fd, int __name));
302 extern long int fpathconf __P ((int __fd, int __name));
304 /* Get the value of the system variable NAME. */
305 extern long int __sysconf __P ((int __name));
306 extern long int sysconf __P ((int __name));
308 #ifdef __USE_POSIX2
309 /* Get the value of the string-valued system variable NAME. */
310 extern size_t confstr __P ((int __name, char *__buf, size_t __len));
311 #endif
314 /* Get the process ID of the calling process. */
315 extern __pid_t __getpid __P ((void));
316 extern __pid_t getpid __P ((void));
318 /* Get the process ID of the calling process's parent. */
319 extern __pid_t __getppid __P ((void));
320 extern __pid_t getppid __P ((void));
322 /* Get the process group ID of the calling process. */
323 extern __pid_t getpgrp __P ((void));
325 /* Set the process group ID of the process matching PID to PGID.
326 If PID is zero, the current process's process group ID is set.
327 If PGID is zero, the process ID of the process is used. */
328 extern int setpgid __P ((__pid_t __pid, __pid_t __pgid));
330 /* Get the process group ID of process PID. */
331 extern __pid_t __getpgid __P ((__pid_t __pid));
332 #ifdef __USE_GNU
333 extern __pid_t getpgid __P ((__pid_t __pid));
334 #endif
336 #ifdef __USE_BSD
337 /* Another name for `setpgid'. */
338 extern int setpgrp __P ((__pid_t __pid, __pid_t __pgrp));
339 #endif /* Use BSD. */
341 /* Create a new session with the calling process as its leader.
342 The process group IDs of the session and the calling process
343 are set to the process ID of the calling process, which is returned. */
344 extern __pid_t __setsid __P ((void));
345 extern __pid_t setsid __P ((void));
347 #ifdef __USE_GNU
348 /* Return the session ID of the given process. */
349 extern __pid_t getsid __P ((__pid_t));
350 #endif
352 /* Get the real user ID of the calling process. */
353 extern __uid_t __getuid __P ((void));
354 extern __uid_t getuid __P ((void));
356 /* Get the effective user ID of the calling process. */
357 extern __uid_t __geteuid __P ((void));
358 extern __uid_t geteuid __P ((void));
360 /* Get the real group ID of the calling process. */
361 extern __gid_t __getgid __P ((void));
362 extern __gid_t getgid __P ((void));
364 /* Get the effective group ID of the calling process. */
365 extern __gid_t __getegid __P ((void));
366 extern __gid_t getegid __P ((void));
368 /* If SIZE is zero, return the number of supplementary groups
369 the calling process is in. Otherwise, fill in the group IDs
370 of its supplementary groups in LIST and return the number written. */
371 extern int __getgroups __P ((int __size, __gid_t __list[]));
372 extern int getgroups __P ((int __size, __gid_t __list[]));
374 #ifdef __USE_GNU
375 /* Return nonzero iff the calling process is in group GID. */
376 extern int __group_member __P ((__gid_t __gid));
377 extern int group_member __P ((__gid_t __gid));
378 #endif
380 /* Set the user ID of the calling process to UID.
381 If the calling process is the super-user, set the real
382 and effective user IDs, and the saved set-user-ID to UID;
383 if not, the effective user ID is set to UID. */
384 extern int __setuid __P ((__uid_t __uid));
385 extern int setuid __P ((__uid_t __uid));
387 #ifdef __USE_BSD
388 /* Set the real user ID of the calling process to RUID,
389 and the effective user ID of the calling process to EUID. */
390 extern int __setreuid __P ((__uid_t __ruid, __uid_t __euid));
391 extern int setreuid __P ((__uid_t __ruid, __uid_t __euid));
393 /* Set the effective user ID of the calling process to UID. */
394 extern int seteuid __P ((__uid_t __uid));
395 #endif /* Use BSD. */
397 /* Set the group ID of the calling process to GID.
398 If the calling process is the super-user, set the real
399 and effective group IDs, and the saved set-group-ID to GID;
400 if not, the effective group ID is set to GID. */
401 extern int __setgid __P ((__gid_t __gid));
402 extern int setgid __P ((__gid_t __gid));
404 #ifdef __USE_BSD
405 /* Set the real group ID of the calling process to RGID,
406 and the effective group ID of the calling process to EGID. */
407 extern int __setregid __P ((__gid_t __rgid, __gid_t __egid));
408 extern int setregid __P ((__gid_t __rgid, __gid_t __egid));
410 /* Set the effective group ID of the calling process to GID. */
411 extern int setegid __P ((__gid_t __gid));
412 #endif /* Use BSD. */
415 /* Clone the calling process, creating an exact copy.
416 Return -1 for errors, 0 to the new process,
417 and the process ID of the new process to the old process. */
418 extern __pid_t __fork __P ((void));
419 extern __pid_t fork __P ((void));
421 #ifdef __USE_BSD
422 /* Clone the calling process, but without copying the whole address space.
423 The the calling process is suspended until the the new process exits or is
424 replaced by a call to `execve'. Return -1 for errors, 0 to the new process,
425 and the process ID of the new process to the old process. */
426 extern __pid_t __vfork __P ((void));
427 extern __pid_t vfork __P ((void));
428 #endif /* Use BSD. */
431 /* Return the pathname of the terminal FD is open on, or NULL on errors.
432 The returned storage is good only until the next call to this function. */
433 extern char *ttyname __P ((int __fd));
434 #ifdef __USE_REENTRANT
435 /* Store at most BUFLEN characters of the pathname of the terminal FD is
436 open on in BUF. Return 0 on success, -1 otherwise. */
437 extern int ttyname_r __P ((int __fd, char *__buf, int __buflen));
438 #endif
440 /* Return 1 if FD is a valid descriptor associated
441 with a terminal, zero if not. */
442 extern int __isatty __P ((int __fd));
443 extern int isatty __P ((int __fd));
445 #ifdef __USE_BSD
446 /* Return the index into the active-logins file (utmp) for
447 the controlling terminal. */
448 extern int ttyslot __P ((void));
449 #endif
452 /* Make a link to FROM named TO. */
453 extern int __link __P ((__const char *__from, __const char *__to));
454 extern int link __P ((__const char *__from, __const char *__to));
456 #ifdef __USE_BSD
457 /* Make a symbolic link to FROM named TO. */
458 extern int __symlink __P ((__const char *__from, __const char *__to));
459 extern int symlink __P ((__const char *__from, __const char *__to));
461 /* Read the contents of the symbolic link PATH into no more than
462 LEN bytes of BUF. The contents are not null-terminated.
463 Returns the number of characters read, or -1 for errors. */
464 extern int __readlink __P ((__const char *__path, char *__buf, size_t __len));
465 extern int readlink __P ((__const char *__path, char *__buf, size_t __len));
466 #endif /* Use BSD. */
468 /* Remove the link NAME. */
469 extern int __unlink __P ((__const char *__name));
470 extern int unlink __P ((__const char *__name));
472 /* Remove the directory PATH. */
473 extern int __rmdir __P ((__const char *__path));
474 extern int rmdir __P ((__const char *__path));
477 /* Return the foreground process group ID of FD. */
478 extern __pid_t tcgetpgrp __P ((int __fd));
480 /* Set the foreground process group ID of FD set PGRP_ID. */
481 extern int tcsetpgrp __P ((int __fd, __pid_t __pgrp_id));
484 /* Return the login name of the user. */
485 extern char *getlogin __P ((void));
487 #ifdef __USE_BSD
488 /* Set the login name returned by `getlogin'. */
489 extern int setlogin __P ((__const char *__name));
490 #endif
493 #ifdef __USE_POSIX2
494 /* Process the arguments in ARGV (ARGC of them, minus
495 the program name) for options given in OPTS.
497 If `opterr' is zero, no messages are generated
498 for invalid options; it defaults to 1.
499 `optind' is the current index into ARGV.
500 `optarg' is the argument corresponding to the current option.
501 Return the option character from OPTS just read.
502 Return -1 when there are no more options.
503 For unrecognized options, or options missing arguments,
504 `optopt' is set to the option letter, and '?' is returned.
506 The OPTS string is a list of characters which are recognized option
507 letters, optionally followed by colons, specifying that that letter
508 takes an argument, to be placed in `optarg'.
510 If a letter in OPTS is followed by two colons, its argument is optional.
511 This behavior is specific to the GNU `getopt'.
513 The argument `--' causes premature termination of argument scanning,
514 explicitly telling `getopt' that there are no more options.
516 If OPTS begins with `--', then non-option arguments
517 are treated as arguments to the option '\0'.
518 This behavior is specific to the GNU `getopt'. */
519 extern int getopt __P ((int __argc, char *__const * __argv,
520 __const char *__opts));
521 extern int opterr;
522 extern int optind;
523 extern int optopt;
524 extern char *optarg;
525 #endif
528 #ifdef __USE_BSD
530 /* Put the name of the current host in no more than LEN bytes of NAME.
531 The result is null-terminated if LEN is large enough for the full
532 name and the terminator. */
533 extern int __gethostname __P ((char *__name, size_t __len));
534 extern int gethostname __P ((char *__name, size_t __len));
536 /* Set the name of the current host to NAME, which is LEN bytes long.
537 This call is restricted to the super-user. */
538 extern int sethostname __P ((__const char *__name, size_t __len));
540 /* Return the current machine's Internet number. */
541 extern long int gethostid __P ((void));
543 /* Set the current machine's Internet number to ID.
544 This call is restricted to the super-user. */
545 extern int sethostid __P ((long int __id));
548 /* Return the number of bytes in a page. This is the system's page size,
549 which is not necessarily the same as the hardware page size. */
550 extern size_t __getpagesize __P ((void));
551 extern size_t getpagesize __P ((void));
554 /* Return the maximum number of file descriptors
555 the current process could possibly have. */
556 extern int __getdtablesize __P ((void));
557 extern int getdtablesize __P ((void));
560 /* Truncate FILE to LENGTH bytes. */
561 extern int truncate __P ((__const char *__file, __off_t __length));
563 /* Truncate the file FD is open on to LENGTH bytes. */
564 extern int ftruncate __P ((int __fd, __off_t __length));
567 /* Make all changes done to FD actually appear on disk. */
568 extern int fsync __P ((int __fd));
570 /* Make all changes done to all files actually appear on disk. */
571 extern int sync __P ((void));
574 /* Revoke access permissions to all processes currently communicating
575 with the control terminal, and then send a SIGHUP signal to the process
576 group of the control terminal. */
577 extern int vhangup __P ((void));
579 /* Revoke the access of all descriptors currently open on FILE. */
580 extern int revoke __P ((const char *__file));
583 /* Enable statistical profiling, writing samples of the PC into at most
584 SIZE bytes of SAMPLE_BUFFER; every processor clock tick while profiling
585 is enabled, the system examines the user PC and increments
586 SAMPLE_BUFFER[((PC - OFFSET) / 2) * SCALE / 65536]. If SCALE is zero,
587 disable profiling. Returns zero on success, -1 on error. */
588 extern int profil __P ((unsigned short int *__sample_buffer, size_t __size,
589 size_t __offset, unsigned int __scale));
592 /* Turn accounting on if NAME is an existing file. The system will then write
593 a record for each process as it terminates, to this file. If NAME is NULL,
594 turn accounting off. This call is restricted to the super-user. */
595 extern int acct __P ((__const char *__name));
597 /* Make PATH be the root directory (the starting point for absolute paths).
598 This call is restricted to the super-user. */
599 extern int chroot __P ((__const char *__path));
601 /* Make the block special device PATH available to the system for swapping.
602 This call is restricted to the super-user. */
603 extern int swapon __P ((__const char *__path));
605 /* Reboot or halt the system. */
606 extern int reboot __P ((int __howto));
609 /* Successive calls return the shells listed in `/etc/shells'. */
610 extern char *getusershell __P ((void));
611 extern void endusershell __P ((void)); /* Discard cached info. */
612 extern void setusershell __P ((void)); /* Rewind and re-read the file. */
615 /* Prompt with PROMPT and read a string from the terminal without echoing.
616 Uses /dev/tty if possible; otherwise stderr and stdin. */
617 extern char *getpass __P ((const char *__prompt));
619 /* Put the program in the background, and dissociate from the controlling
620 terminal. If NOCHDIR is zero, do `chdir ("/")'. If NOCLOSE is zero,
621 redirects stdin, stdout, and stderr to /dev/null. */
622 extern int daemon __P ((int __nochdir, int __noclose));
624 #endif /* Use BSD. */
627 #ifdef __USE_MISC
629 /* Generate a unique temporary file name from TEMPLATE.
630 The last six characters of TEMPLATE must be "XXXXXX";
631 they are replaced with a string that makes the file name unique.
632 Returns TEMPLATE, or a null pointer if it cannot get a unique file name. */
633 extern char *mktemp __P ((char *__template));
635 /* Generate a unique temporary file name from TEMPLATE.
636 The last six characters of TEMPLATE must be "XXXXXX";
637 they are replaced with a string that makes the filename unique.
638 Returns a file descriptor open on the file for reading and writing,
639 or -1 if it cannot create a uniquely-named file. */
640 extern int mkstemp __P ((char *__template));
643 /* Set the end of accessible data space (aka "the break") to ADDR.
644 Returns zero on success and -1 for errors (with errno set). */
645 extern int __brk __P ((__ptr_t __addr));
646 extern int brk __P ((__ptr_t __addr));
648 #define __need_ptrdiff_t
649 #include <stddef.h>
651 /* Increase or decrease the end of accessible data space by DELTA bytes.
652 If successful, returns the address the previous end of data space
653 (i.e. the beginning of the new space, if DELTA > 0);
654 returns (void *) -1 for errors (with errno set). */
655 extern __ptr_t __sbrk __P ((ptrdiff_t __delta));
656 extern __ptr_t sbrk __P ((ptrdiff_t __delta));
659 /* Invoke `system call' number SYSNO, passing it the remaining arguments.
660 This is completely system-dependent, and not often useful.
662 In Unix, `syscall' sets `errno' for all errors and most calls return -1
663 for errors; in many systems you cannot pass arguments or get return
664 values for all system calls (`pipe', `fork', and `getppid' typically
665 among them).
667 In Mach, all system calls take normal arguments and always return an
668 error code (zero for success). */
669 extern int syscall __P ((int __sysno, ...));
671 #endif /* Use misc. */
674 #if defined (__USE_MISC) && !defined (F_LOCK)
675 /* NOTE: These declarations also appear in <fcntl.h>; be sure to keep both
676 files consistent. Some systems have them there and some here, and some
677 software depends on the macros being defined without including both. */
679 /* `lockf' is a simpler interface to the locking facilities of `fcntl'.
680 LEN is always relative to the current file position.
681 The CMD argument is one of the following. */
683 #define F_ULOCK 0 /* Unlock a previously locked region. */
684 #define F_LOCK 1 /* Lock a region for exclusive use. */
685 #define F_TLOCK 2 /* Test and lock a region for exclusive use. */
686 #define F_TEST 3 /* Test a region for other processes locks. */
688 extern int lockf __P ((int __fd, int __cmd, __off_t __len));
689 #endif /* Use misc and F_LOCK not already defined. */
692 #ifdef __USE_GNU
694 /* Evaluate EXPRESSION, and repeat as long as it returns -1 with `errno'
695 set to EINTR. */
697 #define TEMP_FAILURE_RETRY(expression) \
698 ({ long int __result; \
699 do __result = (long int) (expression); \
700 while (__result == -1L && errno == EINTR); \
701 __result; })
703 #endif
705 __END_DECLS
707 #endif /* unistd.h */