1 /* Copyright (C) 1991, 92, 93, 94, 95, 96, 97 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 not,
16 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. */
20 * POSIX Standard: 2.10 Symbolic Constants <unistd.h>
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 ISO/IEC 9945-1 as of August, 1988 and
34 extended by POSIX-1b (aka POSIX-4) and POSIX-1c (aka POSIX threads). */
35 #define _POSIX_VERSION 199506L
37 /* These are not #ifdef __USE_POSIX2 because they are
38 in the theoretically application-owned namespace. */
40 /* POSIX Standard approved as ISO/IEC 9945-2 as of December, 1993. */
41 #define _POSIX2_C_VERSION 199209L
43 /* If defined, the implementation supports the
44 C Language Bindings Option. */
45 #define _POSIX2_C_BIND 1
47 /* If defined, the implementation supports the
48 C Language Development Utilities Option. */
49 #define _POSIX2_C_DEV 1
51 /* If defined, the implementation supports the
52 Software Development Utilities Option. */
53 #define _POSIX2_SW_DEV 1
55 /* If defined, the implementation supports the
56 creation of locales with the localedef utility. */
57 #define _POSIX2_LOCALEDEF 1
59 /* Library conforms to X/Open version 4. */
60 #define _XOPEN_VERSION 4
62 /* Commands and utilities from XPG4 are available. */
63 #define _XOPEN_XCU_VERSION 4
65 /* We are compatible with the old published standards as well. */
70 /* The X/Open Unix extensions are available. */
73 /* Encryption is present. */
74 #define _XOPEN_CRYPT 1
76 /* The enhanced internationalization capabilities according to XPG4.2
78 #define _XOPEN_ENH_I18N 1
80 /* The legacy interfaces are also available. */
81 #define _XOPEN_LEGACY 1
84 /* Get values of POSIX options:
86 If these symbols are defined, the corresponding features are
87 always available. If not, they may be available sometimes.
88 The current values can be obtained with `sysconf'.
90 _POSIX_JOB_CONTROL Job control is supported.
91 _POSIX_SAVED_IDS Processes have a saved set-user-ID
92 and a saved set-group-ID.
93 _POSIX_REALTIME_SIGNALS Real-time, queued signals are supported.
94 _POSIX_PRIORITY_SCHEDULING Priority scheduling is supported.
95 _POSIX_TIMERS POSIX.4 clocks and timers are supported.
96 _POSIX_ASYNCHRONOUS_IO Asynchronous I/O is supported.
97 _POSIX_PRIORITIZED_IO Prioritized asynchronous I/O is supported.
98 _POSIX_SYNCHRONIZED_IO Synchronizing file data is supported.
99 _POSIX_FSYNC The fsync function is present.
100 _POSIX_MAPPED_FILES Mapping of files to memory is supported.
101 _POSIX_MEMLOCK Locking of all memory is supported.
102 _POSIX_MEMLOCK_RANGE Locking of ranges of memory is supported.
103 _POSIX_MEMORY_PROTECTION Setting of memory protections is supported.
104 _POSIX_MESSAGE_PASSING POSIX.4 message queues are supported.
105 _POSIX_SEMAPHORES POSIX.4 counting semaphores are supported.
106 _POSIX_SHARED_MEMORY_OBJECTS POSIX.4 shared memory objects are supported.
107 _POSIX_THREADS POSIX.1c pthreads are supported.
108 _POSIX_THREAD_ATTR_STACKADDR Thread stack address attribute option supported.
109 _POSIX_THREAD_ATTR_STACKSIZE Thread stack size attribute option supported.
110 _POSIX_THREAD_SAFE_FUNCTIONS Thread-safe functions are supported.
111 _POSIX_THREAD_PRIORITY_SCHEDULING
112 POSIX.1c thread execution scheduling supported.
113 _POSIX_THREAD_PRIO_INHERIT Thread priority inheritance option supported.
114 _POSIX_THREAD_PRIO_PROTECT Thread priority protection option supported.
115 _POSIX_THREAD_PROCESS_SHARED Process-shared synchronization supported.
116 _POSIX_PII Protocol-independent interfaces are supported.
117 _POSIX_PII_XTI XTI protocol-indep. interfaces are supported.
118 _POSIX_PII_SOCKET Socket protocol-indep. interfaces are supported.
119 _POSIX_PII_INTERNET Internet family of protocols supported.
120 _POSIX_PII_INTERNET_STREAM Connection-mode Internet protocol supported.
121 _POSIX_PII_INTERNET_DGRAM Connectionless Internet protocol supported.
122 _POSIX_PII_OSI ISO/OSI family of protocols supported.
123 _POSIX_PII_OSI_COTS Connection-mode ISO/OSI service supported.
124 _POSIX_PII_OSI_CLTS Connectionless ISO/OSI service supported.
125 _POSIX_POLL Implementation supports `poll' function.
126 _POSIX_SELECT Implementation supports `select' and `pselect'.
128 _XOPEN_REALTIME X/Open realtime support is available.
129 _XOPEN_REALTIME_THREADS X/Open realtime thread support is available.
130 _XOPEN_SHM Shared memory interface according to XPG4.2.
132 _XBS5_ILP32_OFF32 Implementation provides environment with 32-bit
133 int, long, pointer, and off_t types.
134 _XBS5_ILP32_OFFBIG Implementation provides environment with 32-bit
135 int, long, and pointer and off_t with at least
137 _XBS5_LP64_OFF64 Implementation provides environment with 32-bit
138 int, and 64-bit long, pointer, and off_t types.
139 _XBS5_LPBIG_OFFBIG Implementation provides environment with at
140 least 32 bits int and long, pointer, and off_t
141 with at least 64 bits.
143 If any of these symbols is defined as -1, the corresponding option is not
144 true for any file. If any is defined as other than -1, the corresponding
145 option is true for all files. If a symbol is not defined at all, the value
146 for a specific file can be obtained from `pathconf' and `fpathconf'.
148 _POSIX_CHOWN_RESTRICTED Only the super user can use `chown' to change
149 the owner of a file. `chown' can only be used
150 to change the group ID of a file to a group of
151 which the calling process is a member.
152 _POSIX_NO_TRUNC Pathname components longer than
153 NAME_MAX generate an error.
154 _POSIX_VDISABLE If defined, if the value of an element of the
155 `c_cc' member of `struct termios' is
156 _POSIX_VDISABLE, no character will have the
157 effect associated with that element.
158 _POSIX_SYNC_IO Synchronous I/O may be performed.
159 _POSIX_ASYNC_IO Asynchronous I/O may be performed.
160 _POSIX_PRIO_IO Prioritized Asynchronous I/O may be performed.
162 Support for the Large File Support interface is not generally available.
163 If it is available the following constants are defined to one.
164 _LFS64_LARGEFILE Low-level I/O supports large files.
165 _LFS64_STDIO Standard I/O supports large files.
168 #include <bits/posix_opt.h>
170 /* Get the environment definitions from Unix98. */
172 # include <bits/environments.h>
175 /* Standard file descriptors. */
176 #define STDIN_FILENO 0 /* Standard input. */
177 #define STDOUT_FILENO 1 /* Standard output. */
178 #define STDERR_FILENO 2 /* Standard error output. */
181 /* All functions that are not declared anywhere else. */
183 #include <bits/types.h>
186 typedef __ssize_t ssize_t;
187 # define ssize_t ssize_t
190 #define __need_size_t
195 /* The Single Unix specification says that some more types are
198 typedef __gid_t gid_t;
203 typedef __uid_t uid_t;
208 # ifndef __USE_FILE_OFFSET64
209 typedef __off_t off_t;
211 typedef __off64_t off_t;
215 # if defined __USE_LARGEFILE64 && !defined off64_t
216 typedef __off64_t off64_t;
217 # define off64_t off64_t
221 typedef __pid_t pid_t;
226 /* Values for the second argument to access.
227 These may be OR'd together. */
228 #define R_OK 4 /* Test for read permission. */
229 #define W_OK 2 /* Test for write permission. */
230 #define X_OK 1 /* Test for execute permission. */
231 #define F_OK 0 /* Test for existence. */
233 /* Test for access to NAME using the real UID and real GID. */
234 extern int __access __P ((__const char *__name, int __type));
235 extern int access __P ((__const char *__name, int __type));
238 /* Test for access to NAME using the effective UID and GID
239 (as normal file operations use). */
240 extern int __euidaccess __P ((__const char *__name, int __type));
241 extern int euidaccess __P ((__const char *__name, int __type));
245 /* Values for the WHENCE argument to lseek. */
246 #ifndef _STDIO_H /* <stdio.h> has the same definitions. */
247 # define SEEK_SET 0 /* Seek from beginning of file. */
248 # define SEEK_CUR 1 /* Seek from current position. */
249 # define SEEK_END 2 /* Seek from end of file. */
252 #if defined __USE_BSD && !defined L_SET
253 /* Old BSD names for the same constants; just for compatibility. */
254 # define L_SET SEEK_SET
255 # define L_INCR SEEK_CUR
256 # define L_XTND SEEK_END
260 /* Move FD's file position to OFFSET bytes from the
261 beginning of the file (if WHENCE is SEEK_SET),
262 the current position (if WHENCE is SEEK_CUR),
263 or the end of the file (if WHENCE is SEEK_END).
264 Return the new file position. */
265 extern __off_t __lseek __P ((int __fd, __off_t __offset, int __whence));
266 #ifndef __USE_FILE_OFFSET64
267 extern __off_t lseek __P ((int __fd, __off_t __offset, int __whence));
269 extern __off_t lseek __P ((int __fd, __off_t __offset, int __whence))
272 #ifdef __USE_LARGEFILE64
273 extern __off64_t lseek64 __P ((int __fd, __off64_t __offset, int __whence));
276 /* Close the file descriptor FD. */
277 extern int __close __P ((int __fd));
278 extern int close __P ((int __fd));
280 /* Read NBYTES into BUF from FD. Return the
281 number read, -1 for errors or 0 for EOF. */
282 extern ssize_t __read __P ((int __fd, __ptr_t __buf, size_t __nbytes));
283 extern ssize_t read __P ((int __fd, __ptr_t __buf, size_t __nbytes));
285 /* Write N bytes of BUF to FD. Return the number written, or -1. */
286 extern ssize_t __write __P ((int __fd, __const __ptr_t __buf, size_t __n));
287 extern ssize_t write __P ((int __fd, __const __ptr_t __buf, size_t __n));
290 /* Read NBYTES into BUF from FD at the given position OFFSET without
291 changing the file pointer. Return the number read, -1 for errors
293 extern ssize_t __pread __P ((int __fd, __ptr_t __buf, size_t __nbytes,
295 # ifndef __USE_FILE_OFFSET64
296 extern ssize_t pread __P ((int __fd, __ptr_t __buf, size_t __nbytes,
299 extern ssize_t pread __P ((int __fd, __ptr_t __buf, size_t __nbytes,
300 __off_t __offset)) __asm__ ("pread64");
302 extern ssize_t __pread64 __P ((int __fd, __ptr_t __buf, size_t __nbytes,
303 __off64_t __offset));
304 # ifdef __USE_LARGEFILE64
305 extern ssize_t pread64 __P ((int __fd, __ptr_t __buf, size_t __nbytes,
306 __off64_t __offset));
309 /* Write N bytes of BUF to FD at the given position OFFSET without
310 changing the file pointer. Return the number written, or -1. */
311 extern ssize_t __pwrite __P ((int __fd, __const __ptr_t __buf, size_t __n,
313 # ifndef __USE_FILE_OFFSET64
314 extern ssize_t pwrite __P ((int __fd, __const __ptr_t __buf, size_t __n,
317 extern ssize_t pwrite __P ((int __fd, __const __ptr_t __buf, size_t __n,
318 __off_t __offset)) __asm__ ("pwrite64");
320 extern ssize_t __pwrite64 __P ((int __fd, __const __ptr_t __buf, size_t __n,
321 __off64_t __offset));
322 # ifdef __USE_LARGEFILE64
323 extern ssize_t pwrite64 __P ((int __fd, __const __ptr_t __buf, size_t __n,
324 __off64_t __offset));
329 /* Create a one-way communication channel (pipe).
330 If successful, two file descriptors are stored in PIPEDES;
331 bytes written on PIPEDES[1] can be read from PIPEDES[0].
332 Returns 0 if successful, -1 if not. */
333 extern int __pipe __P ((int __pipedes[2]));
334 extern int pipe __P ((int __pipedes[2]));
336 /* Schedule an alarm. In SECONDS seconds, the process will get a SIGALRM.
337 If SECONDS is zero, any currently scheduled alarm will be cancelled.
338 The function returns the number of seconds remaining until the last
339 alarm scheduled would have signaled, or zero if there wasn't one.
340 There is no return value to indicate an error, but you can set `errno'
341 to 0 and check its value after calling `alarm', and this might tell you.
342 The signal may come late due to processor scheduling. */
343 extern unsigned int alarm __P ((unsigned int __seconds));
345 /* Make the process sleep for SECONDS seconds, or until a signal arrives
346 and is not ignored. The function returns the number of seconds less
347 than SECONDS which it actually slept (thus zero if it slept the full time).
348 If a signal handler does a `longjmp' or modifies the handling of the
349 SIGALRM signal while inside `sleep' call, the handling of the SIGALRM
350 signal afterwards is undefined. There is no return value to indicate
351 error, but if `sleep' returns SECONDS, it probably didn't work. */
352 extern unsigned int __sleep __P ((unsigned int __seconds));
353 extern unsigned int sleep __P ((unsigned int __seconds));
355 #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
356 /* Set an alarm to go off (generating a SIGALRM signal) in VALUE
357 microseconds. If INTERVAL is nonzero, when the alarm goes off, the
358 timer is reset to go off every INTERVAL microseconds thereafter.
359 Returns the number of microseconds remaining before the alarm. */
360 extern unsigned int ualarm __P ((unsigned int __value,
361 unsigned int __interval));
363 /* Sleep USECONDS microseconds, or until a signal arrives that is not blocked
365 extern void usleep __P ((unsigned int __useconds));
369 /* Suspend the process until a signal arrives.
370 This always returns -1 and sets `errno' to EINTR. */
371 extern int pause __P ((void));
374 /* Change the owner and group of FILE. */
375 extern int __chown __P ((__const char *__file,
376 __uid_t __owner, __gid_t __group));
377 extern int chown __P ((__const char *__file,
378 __uid_t __owner, __gid_t __group));
380 #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
381 /* Change the owner and group of the file that FD is open on. */
382 extern int __fchown __P ((int __fd,
383 __uid_t __owner, __gid_t __group));
384 extern int fchown __P ((int __fd,
385 __uid_t __owner, __gid_t __group));
388 /* Change owner and group of FILE, if it is a symbolic
389 link the ownership of the symbolic link is changed. */
390 extern int __lchown __P ((__const char *__file, __uid_t __owner,
392 extern int lchown __P ((__const char *__file, __uid_t __owner,
395 #endif /* Use BSD || X/Open Unix. */
397 /* Change the process's working directory to PATH. */
398 extern int __chdir __P ((__const char *__path));
399 extern int chdir __P ((__const char *__path));
401 #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
402 /* Change the process's working directory to the one FD is open on. */
403 extern int __fchdir __P ((int __fd));
404 extern int fchdir __P ((int __fd));
407 /* Get the pathname of the current working directory,
408 and put it in SIZE bytes of BUF. Returns NULL if the
409 directory couldn't be determined or SIZE was too small.
410 If successful, returns BUF. In GNU, if BUF is NULL,
411 an array is allocated with `malloc'; the array is SIZE
412 bytes long, unless SIZE == 0, in which case it is as
414 extern char *__getcwd __P ((char *__buf, size_t __size));
415 extern char *getcwd __P ((char *__buf, size_t __size));
418 /* Return a malloc'd string containing the current directory name.
419 If the environment variable `PWD' is set, and its value is correct,
420 that value is used. */
421 extern char *get_current_dir_name __P ((void));
423 /* Get the canonical absolute name of the named directory, and put it in SIZE
424 bytes of BUF. Returns NULL if the directory couldn't be determined or
425 SIZE was too small. If successful, returns BUF. In GNU, if BUF is
426 NULL, an array is allocated with `malloc'; the array is SIZE bytes long,
427 unless SIZE <= 0, in which case it is as big as necessary. */
429 char *__canonicalize_directory_name_internal __P ((__const char *__thisdir,
434 #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
435 /* Put the absolute pathname of the current working directory in BUF.
436 If successful, return BUF. If not, put an error message in
437 BUF and return NULL. BUF should be at least PATH_MAX bytes long. */
438 extern char *getwd __P ((char *__buf));
442 /* Duplicate FD, returning a new file descriptor on the same file. */
443 extern int __dup __P ((int __fd));
444 extern int dup __P ((int __fd));
446 /* Duplicate FD to FD2, closing FD2 and making it open on the same file. */
447 extern int __dup2 __P ((int __fd, int __fd2));
448 extern int dup2 __P ((int __fd, int __fd2));
450 /* NULL-terminated array of "NAME=VALUE" environment variables. */
451 extern char **__environ;
453 extern char **environ;
457 /* Replace the current process, executing PATH with arguments ARGV and
458 environment ENVP. ARGV and ENVP are terminated by NULL pointers. */
459 extern int __execve __P ((__const char *__path, char *__const __argv[],
460 char *__const __envp[]));
461 extern int execve __P ((__const char *__path, char *__const __argv[],
462 char *__const __envp[]));
465 /* Execute the file FD refers to, overlaying the running program image.
466 ARGV and ENVP are passed to the new program, as for `execve'. */
467 extern int fexecve __P ((int __fd,
468 char *__const __argv[], char *__const __envp[]));
473 /* Execute PATH with arguments ARGV and environment from `environ'. */
474 extern int execv __P ((__const char *__path, char *__const __argv[]));
476 /* Execute PATH with all arguments after PATH until a NULL pointer,
477 and the argument after that for environment. */
478 extern int execle __P ((__const char *__path, __const char *__arg, ...));
480 /* Execute PATH with all arguments after PATH until
481 a NULL pointer and environment from `environ'. */
482 extern int execl __P ((__const char *__path, __const char *__arg, ...));
484 /* Execute FILE, searching in the `PATH' environment variable if it contains
485 no slashes, with arguments ARGV and environment from `environ'. */
486 extern int execvp __P ((__const char *__file, char *__const __argv[]));
488 /* Execute FILE, searching in the `PATH' environment variable if
489 it contains no slashes, with all arguments after FILE until a
490 NULL pointer and environment from `environ'. */
491 extern int execlp __P ((__const char *__file, __const char *__arg, ...));
494 #if defined __USE_MISC || defined __USE_XOPEN
495 /* Add INC to priority of the current process. */
496 extern int nice __P ((int __inc));
500 /* Terminate program execution with the low-order 8 bits of STATUS. */
501 extern void _exit __P ((int __status)) __attribute__ ((__noreturn__));
504 /* Get the `_PC_*' symbols for the NAME argument to `pathconf' and `fpathconf';
505 the `_SC_*' symbols for the NAME argument to `sysconf';
506 and the `_CS_*' symbols for the NAME argument to `confstr'. */
507 #include <bits/confname.h>
509 /* Get file-specific configuration information about PATH. */
510 extern long int __pathconf __P ((__const char *__path, int __name));
511 extern long int pathconf __P ((__const char *__path, int __name));
513 /* Get file-specific configuration about descriptor FD. */
514 extern long int __fpathconf __P ((int __fd, int __name));
515 extern long int fpathconf __P ((int __fd, int __name));
517 /* Get the value of the system variable NAME. */
518 extern long int __sysconf __P ((int __name));
519 extern long int sysconf __P ((int __name));
522 /* Get the value of the string-valued system variable NAME. */
523 extern size_t confstr __P ((int __name, char *__buf, size_t __len));
527 /* Get the process ID of the calling process. */
528 extern __pid_t __getpid __P ((void));
529 extern __pid_t getpid __P ((void));
531 /* Get the process ID of the calling process's parent. */
532 extern __pid_t __getppid __P ((void));
533 extern __pid_t getppid __P ((void));
535 /* Get the process group ID of the calling process. */
536 extern __pid_t getpgrp __P ((void));
537 /* The old BSD definition is a bit different. */
538 extern __pid_t __bsd_getpgrp __P ((__pid_t __pid));
540 /* When we explicitely compile BSD sources use the BSD definition of this
541 function. Please note that we cannot use parameters for the macro. */
542 # define getpgrp __bsd_getpgrp
545 /* Set the process group ID of the process matching PID to PGID.
546 If PID is zero, the current process's process group ID is set.
547 If PGID is zero, the process ID of the process is used. */
548 extern int __setpgid __P ((__pid_t __pid, __pid_t __pgid));
549 extern int setpgid __P ((__pid_t __pid, __pid_t __pgid));
551 /* Get the process group ID of process PID. */
552 extern __pid_t __getpgid __P ((__pid_t __pid));
553 #ifdef __USE_XOPEN_EXTENDED
554 extern __pid_t getpgid __P ((__pid_t __pid));
557 #if defined __USE_SVID || defined __USE_BSD || defined __USE_XOPEN_EXTENDED
558 /* Both System V and BSD have `setpgrp' functions, but with different
559 calling conventions. The BSD function is the same as POSIX.1 `setpgid'
560 (above). The System V function takes no arguments and puts the calling
561 process in its on group like `setpgid (0, 0)'.
563 New programs should always use `setpgid' instead.
565 The default in GNU is to provide the System V function. The BSD
566 function is available under -D_BSD_SOURCE with -lbsd-compat. */
570 /* Set the process group ID of the calling process to its own PID.
571 This is exactly the same as `setpgid (0, 0)'. */
572 extern int setpgrp __P ((void));
576 /* Another name for `setpgid' (above). */
577 extern int setpgrp __P ((__pid_t __pid, __pid_t __pgrp));
579 # endif /* Favor BSD. */
580 #endif /* Use SVID or BSD. */
582 /* Create a new session with the calling process as its leader.
583 The process group IDs of the session and the calling process
584 are set to the process ID of the calling process, which is returned. */
585 extern __pid_t __setsid __P ((void));
586 extern __pid_t setsid __P ((void));
588 #ifdef __USE_XOPEN_EXTENDED
589 /* Return the session ID of the given process. */
590 extern __pid_t getsid __P ((__pid_t __pid));
593 /* Get the real user ID of the calling process. */
594 extern __uid_t __getuid __P ((void));
595 extern __uid_t getuid __P ((void));
597 /* Get the effective user ID of the calling process. */
598 extern __uid_t __geteuid __P ((void));
599 extern __uid_t geteuid __P ((void));
601 /* Get the real group ID of the calling process. */
602 extern __gid_t __getgid __P ((void));
603 extern __gid_t getgid __P ((void));
605 /* Get the effective group ID of the calling process. */
606 extern __gid_t __getegid __P ((void));
607 extern __gid_t getegid __P ((void));
609 /* If SIZE is zero, return the number of supplementary groups
610 the calling process is in. Otherwise, fill in the group IDs
611 of its supplementary groups in LIST and return the number written. */
612 extern int __getgroups __P ((int __size, __gid_t __list[]));
613 extern int getgroups __P ((int __size, __gid_t __list[]));
616 /* Return nonzero iff the calling process is in group GID. */
617 extern int __group_member __P ((__gid_t __gid));
618 extern int group_member __P ((__gid_t __gid));
621 /* Set the user ID of the calling process to UID.
622 If the calling process is the super-user, set the real
623 and effective user IDs, and the saved set-user-ID to UID;
624 if not, the effective user ID is set to UID. */
625 extern int __setuid __P ((__uid_t __uid));
626 extern int setuid __P ((__uid_t __uid));
628 #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
629 /* Set the real user ID of the calling process to RUID,
630 and the effective user ID of the calling process to EUID. */
631 extern int __setreuid __P ((__uid_t __ruid, __uid_t __euid));
632 extern int setreuid __P ((__uid_t __ruid, __uid_t __euid));
636 /* Set the effective user ID of the calling process to UID. */
637 extern int seteuid __P ((__uid_t __uid));
638 #endif /* Use BSD. */
640 /* Set the group ID of the calling process to GID.
641 If the calling process is the super-user, set the real
642 and effective group IDs, and the saved set-group-ID to GID;
643 if not, the effective group ID is set to GID. */
644 extern int __setgid __P ((__gid_t __gid));
645 extern int setgid __P ((__gid_t __gid));
647 #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
648 /* Set the real group ID of the calling process to RGID,
649 and the effective group ID of the calling process to EGID. */
650 extern int __setregid __P ((__gid_t __rgid, __gid_t __egid));
651 extern int setregid __P ((__gid_t __rgid, __gid_t __egid));
655 /* Set the effective group ID of the calling process to GID. */
656 extern int setegid __P ((__gid_t __gid));
657 #endif /* Use BSD. */
660 /* Clone the calling process, creating an exact copy.
661 Return -1 for errors, 0 to the new process,
662 and the process ID of the new process to the old process. */
663 extern __pid_t __fork __P ((void));
664 extern __pid_t fork __P ((void));
666 #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
667 /* Clone the calling process, but without copying the whole address space.
668 The the calling process is suspended until the the new process exits or is
669 replaced by a call to `execve'. Return -1 for errors, 0 to the new process,
670 and the process ID of the new process to the old process. */
671 extern __pid_t __vfork __P ((void));
672 extern __pid_t vfork __P ((void));
673 #endif /* Use BSD. */
676 /* Return the pathname of the terminal FD is open on, or NULL on errors.
677 The returned storage is good only until the next call to this function. */
678 extern char *ttyname __P ((int __fd));
680 /* Store at most BUFLEN characters of the pathname of the terminal FD is
681 open on in BUF. Return 0 on success, otherwise an error number. */
682 extern int __ttyname_r __P ((int __fd, char *__buf, size_t __buflen));
683 extern int ttyname_r __P ((int __fd, char *__buf, size_t __buflen));
685 /* Return 1 if FD is a valid descriptor associated
686 with a terminal, zero if not. */
687 extern int __isatty __P ((int __fd));
688 extern int isatty __P ((int __fd));
690 #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
691 /* Return the index into the active-logins file (utmp) for
692 the controlling terminal. */
693 extern int ttyslot __P ((void));
697 /* Make a link to FROM named TO. */
698 extern int __link __P ((__const char *__from, __const char *__to));
699 extern int link __P ((__const char *__from, __const char *__to));
701 #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
702 /* Make a symbolic link to FROM named TO. */
703 extern int __symlink __P ((__const char *__from, __const char *__to));
704 extern int symlink __P ((__const char *__from, __const char *__to));
706 /* Read the contents of the symbolic link PATH into no more than
707 LEN bytes of BUF. The contents are not null-terminated.
708 Returns the number of characters read, or -1 for errors. */
709 extern int __readlink __P ((__const char *__path, char *__buf, size_t __len));
710 extern int readlink __P ((__const char *__path, char *__buf, size_t __len));
711 #endif /* Use BSD. */
713 /* Remove the link NAME. */
714 extern int __unlink __P ((__const char *__name));
715 extern int unlink __P ((__const char *__name));
717 /* Remove the directory PATH. */
718 extern int __rmdir __P ((__const char *__path));
719 extern int rmdir __P ((__const char *__path));
722 /* Return the foreground process group ID of FD. */
723 extern __pid_t tcgetpgrp __P ((int __fd));
725 /* Set the foreground process group ID of FD set PGRP_ID. */
726 extern int tcsetpgrp __P ((int __fd, __pid_t __pgrp_id));
729 /* Return the login name of the user. */
730 extern char *getlogin __P ((void));
731 #ifdef __USE_REENTRANT
732 /* Return at most NAME_LEN characters of the login name of the user in NAME.
733 If it cannot be determined or some other error occurred, return the error
734 code. Otherwise return 0. */
735 extern int getlogin_r __P ((char *__name, size_t __name_len));
739 /* Set the login name returned by `getlogin'. */
740 extern int setlogin __P ((__const char *__name));
745 /* Process the arguments in ARGV (ARGC of them, minus
746 the program name) for options given in OPTS.
748 If `opterr' is zero, no messages are generated
749 for invalid options; it defaults to 1.
750 `optind' is the current index into ARGV.
751 `optarg' is the argument corresponding to the current option.
752 Return the option character from OPTS just read.
753 Return -1 when there are no more options.
754 For unrecognized options, or options missing arguments,
755 `optopt' is set to the option letter, and '?' is returned.
757 The OPTS string is a list of characters which are recognized option
758 letters, optionally followed by colons, specifying that that letter
759 takes an argument, to be placed in `optarg'.
761 If a letter in OPTS is followed by two colons, its argument is optional.
762 This behavior is specific to the GNU `getopt'.
764 The argument `--' causes premature termination of argument scanning,
765 explicitly telling `getopt' that there are no more options.
767 If OPTS begins with `--', then non-option arguments
768 are treated as arguments to the option '\0'.
769 This behavior is specific to the GNU `getopt'. */
770 extern int getopt __P ((int __argc, char *__const * __argv,
771 __const char *__opts));
779 #if defined __USE_BSD || defined __USE_XOPEN
781 /* Put the name of the current host in no more than LEN bytes of NAME.
782 The result is null-terminated if LEN is large enough for the full
783 name and the terminator. */
784 extern int __gethostname __P ((char *__name, size_t __len));
785 extern int gethostname __P ((char *__name, size_t __len));
787 /* Set the name of the current host to NAME, which is LEN bytes long.
788 This call is restricted to the super-user. */
789 extern int sethostname __P ((__const char *__name, size_t __len));
791 /* Set the current machine's Internet number to ID.
792 This call is restricted to the super-user. */
793 extern int sethostid __P ((long int __id));
796 /* Get and set the NIS (aka YP) domain name, if any.
797 Called just like `gethostname' and `sethostname'.
798 The NIS domain name is usually the empty string when not using NIS. */
799 extern int getdomainname __P ((char *__name, size_t __len));
800 extern int setdomainname __P ((__const char *__name, size_t __len));
803 /* Make all changes done to FD actually appear on disk. */
804 extern int fsync __P ((int __fd));
807 /* Revoke access permissions to all processes currently communicating
808 with the control terminal, and then send a SIGHUP signal to the process
809 group of the control terminal. */
810 extern int vhangup __P ((void));
812 /* Revoke the access of all descriptors currently open on FILE. */
813 extern int revoke __P ((__const char *__file));
816 /* Enable statistical profiling, writing samples of the PC into at most
817 SIZE bytes of SAMPLE_BUFFER; every processor clock tick while profiling
818 is enabled, the system examines the user PC and increments
819 SAMPLE_BUFFER[((PC - OFFSET) / 2) * SCALE / 65536]. If SCALE is zero,
820 disable profiling. Returns zero on success, -1 on error. */
821 extern int __profil __P ((unsigned short int *__sample_buffer, size_t __size,
822 size_t __offset, unsigned int __scale));
823 extern int profil __P ((unsigned short int *__sample_buffer, size_t __size,
824 size_t __offset, unsigned int __scale));
827 /* Turn accounting on if NAME is an existing file. The system will then write
828 a record for each process as it terminates, to this file. If NAME is NULL,
829 turn accounting off. This call is restricted to the super-user. */
830 extern int acct __P ((__const char *__name));
832 /* Make PATH be the root directory (the starting point for absolute paths).
833 This call is restricted to the super-user. */
834 extern int chroot __P ((__const char *__path));
837 /* Successive calls return the shells listed in `/etc/shells'. */
838 extern char *getusershell __P ((void));
839 extern void endusershell __P ((void)); /* Discard cached info. */
840 extern void setusershell __P ((void)); /* Rewind and re-read the file. */
843 /* Prompt with PROMPT and read a string from the terminal without echoing.
844 Uses /dev/tty if possible; otherwise stderr and stdin. */
845 extern char *getpass __P ((__const char *__prompt));
847 /* Put the program in the background, and dissociate from the controlling
848 terminal. If NOCHDIR is zero, do `chdir ("/")'. If NOCLOSE is zero,
849 redirects stdin, stdout, and stderr to /dev/null. */
850 extern int daemon __P ((int __nochdir, int __noclose));
852 #endif /* Use BSD || X/Open. */
855 #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
857 /* Return the current machine's Internet number. */
858 extern long int gethostid __P ((void));
860 /* Make all changes done to all files actually appear on disk. */
861 extern int sync __P ((void));
864 /* Return the number of bytes in a page. This is the system's page size,
865 which is not necessarily the same as the hardware page size. */
866 extern int __getpagesize __P ((void));
867 extern int getpagesize __P ((void));
870 /* Truncate FILE to LENGTH bytes. */
871 #ifndef __USE_FILE_OFFSET64
872 extern int truncate __P ((__const char *__file, __off_t __length));
874 extern int truncate __P ((__const char *__file, __off_t __length))
875 __asm__ ("truncate64");
877 #ifdef __USE_LARGEFILE64
878 extern int truncate64 __P ((__const char *__file, __off64_t __length));
881 /* Truncate the file FD is open on to LENGTH bytes. */
882 #ifndef __USE_FILE_OFFSET64
883 extern int ftruncate __P ((int __fd, __off_t __length));
885 extern int ftruncate __P ((int __fd, __off_t __length))
886 __asm__ ("ftruncate64");
888 #ifdef __USE_LARGEFILE64
889 extern int ftruncate64 __P ((int __fd, __off64_t __length));
893 /* Return the maximum number of file descriptors
894 the current process could possibly have. */
895 extern int __getdtablesize __P ((void));
896 extern int getdtablesize __P ((void));
898 #endif /* Use BSD || X/Open Unix. */
901 #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
903 /* Set the end of accessible data space (aka "the break") to ADDR.
904 Returns zero on success and -1 for errors (with errno set). */
905 extern int __brk __P ((__ptr_t __addr));
906 extern int brk __P ((__ptr_t __addr));
908 # define __need_ptrdiff_t
911 /* Increase or decrease the end of accessible data space by DELTA bytes.
912 If successful, returns the address the previous end of data space
913 (i.e. the beginning of the new space, if DELTA > 0);
914 returns (void *) -1 for errors (with errno set). */
915 extern __ptr_t __sbrk __P ((ptrdiff_t __delta));
916 extern __ptr_t sbrk __P ((ptrdiff_t __delta));
921 /* Invoke `system call' number SYSNO, passing it the remaining arguments.
922 This is completely system-dependent, and not often useful.
924 In Unix, `syscall' sets `errno' for all errors and most calls return -1
925 for errors; in many systems you cannot pass arguments or get return
926 values for all system calls (`pipe', `fork', and `getppid' typically
929 In Mach, all system calls take normal arguments and always return an
930 error code (zero for success). */
931 extern long int syscall __P ((long int __sysno, ...));
933 #endif /* Use misc. */
936 #if (defined __USE_MISC || defined __USE_XOPEN_EXTENDED) && !defined F_LOCK
937 /* NOTE: These declarations also appear in <fcntl.h>; be sure to keep both
938 files consistent. Some systems have them there and some here, and some
939 software depends on the macros being defined without including both. */
941 /* `lockf' is a simpler interface to the locking facilities of `fcntl'.
942 LEN is always relative to the current file position.
943 The CMD argument is one of the following. */
945 # define F_ULOCK 0 /* Unlock a previously locked region. */
946 # define F_LOCK 1 /* Lock a region for exclusive use. */
947 # define F_TLOCK 2 /* Test and lock a region for exclusive use. */
948 # define F_TEST 3 /* Test a region for other processes locks. */
950 # ifndef __USE_FILE_OFFSET64
951 extern int lockf __P ((int __fd, int __cmd, __off_t __len));
953 extern int lockf __P ((int __fd, int __cmd, __off_t __len))
956 # ifdef __USE_LARGEFILE64
957 extern int lockf64 __P ((int __fd, int __cmd, __off64_t __len));
959 #endif /* Use misc and F_LOCK not already defined. */
964 /* Evaluate EXPRESSION, and repeat as long as it returns -1 with `errno'
967 # define TEMP_FAILURE_RETRY(expression) \
969 ({ long int __result; \
970 do __result = (long int) (expression); \
971 while (__result == -1L && errno == EINTR); \
975 /* This variable is set nonzero at startup if the process's effective
976 IDs differ from its real IDs, or it is otherwise indicated that
977 extra security should be used. When this is set the dynamic linker
978 and some functions contained in the C library ignore various
979 environment variables that normally affect them. */
980 extern int __libc_enable_secure;
984 #if defined __USE_POSIX199309 || defined __USE_UNIX98
985 /* Synchronize at least the data part of a file with the underlying
987 extern int fdatasync __P ((int __fildes));
988 #endif /* Use POSIX199309 */
991 /* XPG4.2 specifies that prototypes for the encryption functions must
994 /* Encrypt at most 8 characters from KEY using salt to perturb DES. */
995 extern char *crypt __P ((__const char *__key, __const char *__salt));
997 /* Setup DES tables according KEY. */
998 extern void setkey __P ((__const char *__key));
1000 /* Encrypt data in BLOCK in place if EDFLAG is zero; otherwise decrypt
1002 extern void encrypt __P ((char *__block, int __edflag));
1005 /* Swab pairs bytes in the first N bytes of the area pointed to by
1006 FROM and copy the result to TO. The value of TO must not be in the
1007 range [FROM - N + 1, FROM - 1]. If N is odd the first byte in FROM
1008 is without partner. */
1009 extern void swab __P ((__const __ptr_t __from, __ptr_t __to, ssize_t __n));
1013 /* The Single Unix specification, version 2, demands these prototypes
1014 to be here. They are also found in <stdio.h>. */
1016 /* Return the name of the controlling terminal. */
1017 extern char *ctermid __P ((char *__s));
1019 /* Return the name of the current user. */
1020 extern char *cuserid __P ((char *__s));
1025 #endif /* unistd.h */