3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
24 */
25
26 /* Copyright (c) 1988 AT&T */
27 /* All Rights Reserved */
28
29 #ifndef _UNISTD_H
30 #define _UNISTD_H
31
32 #include <sys/feature_tests.h>
33
34 #include <sys/types.h>
35 #include <sys/unistd.h>
36
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40
41 /* Symbolic constants for the "access" routine: */
42 #define R_OK 4 /* Test for Read permission */
330 defined(__EXTENSIONS__)
331 extern int ftruncate(int, off_t);
332 #endif /* !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE > 2)... */
333 extern char *getcwd(char *, size_t);
334 #if !defined(__XOPEN_OR_POSIX) || (defined(_XPG4_2) && !defined(_XPG6)) || \
335 defined(__EXTENSIONS__)
336 extern int getdtablesize(void);
337 #endif
338 extern gid_t getegid(void);
339 extern uid_t geteuid(void);
340 extern gid_t getgid(void);
341 extern int getgroups(int, gid_t *);
342 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
343 extern long gethostid(void);
344 #endif
345 #if defined(_XPG4_2)
346 extern int gethostname(char *, size_t);
347 #elif !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
348 extern int gethostname(char *, int);
349 #endif
350 extern char *getlogin(void);
351 #if defined(_XPG4) || defined(__EXTENSIONS__)
352 extern int getopt(int, char *const *, const char *);
353 extern char *optarg;
354 extern int opterr, optind, optopt;
355 /* Marked as LEGACY in SUSv2 and removed in SUSv3 */
356 #if !defined(_XPG6) || defined(__EXTENSIONS__)
357 extern char *getpass(const char *);
358 #endif
359 #endif /* defined(_XPG4) || defined(__EXTENSIONS__) */
360 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
361 /* Marked as LEGACY in SUSv2 and removed in SUSv3 */
362 #if !defined(_XPG6) || defined(__EXTENSIONS__)
363 extern int getpagesize(void);
364 #endif
365 extern pid_t getpgid(pid_t);
366 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */
367 extern pid_t getpid(void);
368 extern pid_t getppid(void);
369 extern pid_t getpgrp(void);
370
651 #if !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE > 2) || defined(_XPG4_2) || \
652 (defined(_LARGEFILE_SOURCE) && _FILE_OFFSET_BITS == 64) || \
653 defined(__EXTENSIONS__)
654 extern int ftruncate();
655 #endif /* !defined(__XOPEN_OR_POSIX) (_POSIX_C_SOURCE > 2)... */
656 extern char *getcwd();
657 #if !defined(__XOPEN_OR_POSIX) || (defined(_XPG4_2) && !defined(_XPG6)) || \
658 defined(__EXTENSIONS__)
659 extern int getdtablesize();
660 #endif
661 extern gid_t getegid();
662 extern uid_t geteuid();
663 extern gid_t getgid();
664 extern int getgroups();
665 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
666 extern long gethostid();
667 #endif
668 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
669 extern int gethostname();
670 #endif
671 extern char *getlogin();
672 #if defined(_XPG4) || defined(__EXTENSIONS__)
673 extern int getopt();
674 extern char *optarg;
675 extern int opterr, optind, optopt;
676 #if !defined(_XPG6) || defined(__EXTENSIONS__)
677 extern char *getpass();
678 #endif
679 #endif /* defined(_XPG4) || defined(__EXTENSIONS__) */
680 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
681 #if !defined(_XPG6) || defined(__EXTENSIONS__)
682 extern int getpagesize();
683 #endif
684 extern pid_t getpgid();
685 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */
686 extern pid_t getpid();
687 extern pid_t getppid();
688 extern pid_t getpgrp();
689 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
690 char *gettxt();
691 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
909 * _posix_func(). The preferred mechanism for the remapping is a compiler
910 * #pragma. If the compiler does not provide such a #pragma, the header file
911 * defines a static function func() which calls the _posix_func() version;
912 * this has to be done instead of #define since POSIX specifies that an
913 * application can #undef the symbol and still be bound to the correct
914 * implementation. Unfortunately, the statics confuse lint so we fallback to
915 * #define in that case.
916 *
917 * NOTE: Support for the Draft 6 definitions is provided for compatibility
918 * only. New applications/libraries should use the standard definitions.
919 */
920
921 #if defined(__EXTENSIONS__) || defined(_REENTRANT) || \
922 !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE - 0 >= 199506L) || \
923 defined(_POSIX_PTHREAD_SEMANTICS)
924
925 #if defined(__STDC__)
926
927 #if (_POSIX_C_SOURCE - 0 >= 199506L) || defined(_POSIX_PTHREAD_SEMANTICS)
928
929 #ifdef __PRAGMA_REDEFINE_EXTNAME
930 #pragma redefine_extname getlogin_r __posix_getlogin_r
931 #pragma redefine_extname ttyname_r __posix_ttyname_r
932 extern int getlogin_r(char *, int);
933 extern int ttyname_r(int, char *, size_t);
934 #else /* __PRAGMA_REDEFINE_EXTNAME */
935
936 extern int __posix_getlogin_r(char *, int);
937 extern int __posix_ttyname_r(int, char *, size_t);
938
939 #ifdef __lint
940
941 #define getlogin_r __posix_getlogin_r
942 #define ttyname_r __posix_ttyname_r
943
944 #else /* !__lint */
945
946 static int
947 getlogin_r(char *__name, int __len)
948 {
949 return (__posix_getlogin_r(__name, __len));
950 }
951 static int
952 ttyname_r(int __fildes, char *__buf, size_t __size)
953 {
954 return (__posix_ttyname_r(__fildes, __buf, __size));
955 }
956
957 #endif /* !__lint */
958 #endif /* __PRAGMA_REDEFINE_EXTNAME */
959
960 #else /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */
961
962 extern char *getlogin_r(char *, int);
963 extern char *ttyname_r(int, char *, int);
964
965 #endif /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */
966
967 #else /* __STDC__ */
968
969 #if (_POSIX_C_SOURCE - 0 >= 199506L) || defined(_POSIX_PTHREAD_SEMANTICS)
970
971 #ifdef __PRAGMA_REDEFINE_EXTNAME
972 #pragma redefine_extname getlogin_r __posix_getlogin_r
973 #pragma redefine_extname ttyname_r __posix_ttyname_r
974 extern int getlogin_r();
975 extern int ttyname_r();
976 #else /* __PRAGMA_REDEFINE_EXTNAME */
977
978 extern int __posix_getlogin_r();
979 extern int __posix_ttyname_r();
980
981 #ifdef __lint
982
983 #define getlogin_r __posix_getlogin_r
984 #define ttyname_r __posix_ttyname_r
985
986 #else /* !__lint */
987
988 static int
989 getlogin_r(__name, __len)
990 char *__name;
991 int __len;
992 {
993 return (__posix_getlogin_r(__name, __len));
994 }
995 static int
996 ttyname_r(__fildes, __buf, __size)
997 int __fildes;
998 char *__buf;
999 size_t __size;
1000 {
1001 return (__posix_ttyname_r(__fildes, __buf, __size));
1002 }
1003 #endif /* !__lint */
1004 #endif /* __PRAGMA_REDEFINE_EXTNAME */
1005
1006 #else /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */
1007
1008 extern char *getlogin_r();
1009 extern char *ttyname_r();
1010
1011 #endif /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */
1012
1013 #endif /* __STDC__ */
1014
1015 #endif /* defined(__EXTENSIONS__) || defined(_REENTRANT)... */
1016
1017 #ifdef __cplusplus
1018 }
1019 #endif
1020
1021 #endif /* _UNISTD_H */
|
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright (c) 2013 Gary Mills
24 *
25 * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
26 */
27
28 /* Copyright (c) 1988 AT&T */
29 /* All Rights Reserved */
30
31 #ifndef _UNISTD_H
32 #define _UNISTD_H
33
34 #include <sys/feature_tests.h>
35
36 #include <sys/types.h>
37 #include <sys/unistd.h>
38
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42
43 /* Symbolic constants for the "access" routine: */
44 #define R_OK 4 /* Test for Read permission */
332 defined(__EXTENSIONS__)
333 extern int ftruncate(int, off_t);
334 #endif /* !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE > 2)... */
335 extern char *getcwd(char *, size_t);
336 #if !defined(__XOPEN_OR_POSIX) || (defined(_XPG4_2) && !defined(_XPG6)) || \
337 defined(__EXTENSIONS__)
338 extern int getdtablesize(void);
339 #endif
340 extern gid_t getegid(void);
341 extern uid_t geteuid(void);
342 extern gid_t getgid(void);
343 extern int getgroups(int, gid_t *);
344 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
345 extern long gethostid(void);
346 #endif
347 #if defined(_XPG4_2)
348 extern int gethostname(char *, size_t);
349 #elif !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
350 extern int gethostname(char *, int);
351 #endif
352
353 #ifndef __GETLOGIN_DEFINED /* Avoid duplicate in stdlib.h */
354 #define __GETLOGIN_DEFINED
355 #ifndef __USE_LEGACY_LOGNAME__
356 #ifdef __PRAGMA_REDEFINE_EXTNAME
357 #pragma redefine_extname getlogin getloginx
358 #else /* __PRAGMA_REDEFINE_EXTNAME */
359 extern char *getloginx(void);
360 #define getlogin getloginx
361 #endif /* __PRAGMA_REDEFINE_EXTNAME */
362 #endif /* __USE_LEGACY_LOGNAME__ */
363 extern char *getlogin(void);
364 #endif /* __GETLOGIN_DEFINED */
365
366 #if defined(_XPG4) || defined(__EXTENSIONS__)
367 extern int getopt(int, char *const *, const char *);
368 extern char *optarg;
369 extern int opterr, optind, optopt;
370 /* Marked as LEGACY in SUSv2 and removed in SUSv3 */
371 #if !defined(_XPG6) || defined(__EXTENSIONS__)
372 extern char *getpass(const char *);
373 #endif
374 #endif /* defined(_XPG4) || defined(__EXTENSIONS__) */
375 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
376 /* Marked as LEGACY in SUSv2 and removed in SUSv3 */
377 #if !defined(_XPG6) || defined(__EXTENSIONS__)
378 extern int getpagesize(void);
379 #endif
380 extern pid_t getpgid(pid_t);
381 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */
382 extern pid_t getpid(void);
383 extern pid_t getppid(void);
384 extern pid_t getpgrp(void);
385
666 #if !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE > 2) || defined(_XPG4_2) || \
667 (defined(_LARGEFILE_SOURCE) && _FILE_OFFSET_BITS == 64) || \
668 defined(__EXTENSIONS__)
669 extern int ftruncate();
670 #endif /* !defined(__XOPEN_OR_POSIX) (_POSIX_C_SOURCE > 2)... */
671 extern char *getcwd();
672 #if !defined(__XOPEN_OR_POSIX) || (defined(_XPG4_2) && !defined(_XPG6)) || \
673 defined(__EXTENSIONS__)
674 extern int getdtablesize();
675 #endif
676 extern gid_t getegid();
677 extern uid_t geteuid();
678 extern gid_t getgid();
679 extern int getgroups();
680 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
681 extern long gethostid();
682 #endif
683 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
684 extern int gethostname();
685 #endif
686
687 #ifndef __GETLOGIN_DEFINED /* Avoid duplicate in stdlib.h */
688 #define __GETLOGIN_DEFINED
689 #ifndef __USE_LEGACY_LOGNAME__
690 #ifdef __PRAGMA_REDEFINE_EXTNAME
691 #pragma redefine_extname getlogin getloginx
692 #else /* __PRAGMA_REDEFINE_EXTNAME */
693 extern char *getloginx();
694 #define getlogin getloginx
695 #endif /* __PRAGMA_REDEFINE_EXTNAME */
696 #endif /* __USE_LEGACY_LOGNAME__ */
697 extern char *getlogin();
698 #endif /* __GETLOGIN_DEFINED */
699
700 #if defined(_XPG4) || defined(__EXTENSIONS__)
701 extern int getopt();
702 extern char *optarg;
703 extern int opterr, optind, optopt;
704 #if !defined(_XPG6) || defined(__EXTENSIONS__)
705 extern char *getpass();
706 #endif
707 #endif /* defined(_XPG4) || defined(__EXTENSIONS__) */
708 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
709 #if !defined(_XPG6) || defined(__EXTENSIONS__)
710 extern int getpagesize();
711 #endif
712 extern pid_t getpgid();
713 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */
714 extern pid_t getpid();
715 extern pid_t getppid();
716 extern pid_t getpgrp();
717 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
718 char *gettxt();
719 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
937 * _posix_func(). The preferred mechanism for the remapping is a compiler
938 * #pragma. If the compiler does not provide such a #pragma, the header file
939 * defines a static function func() which calls the _posix_func() version;
940 * this has to be done instead of #define since POSIX specifies that an
941 * application can #undef the symbol and still be bound to the correct
942 * implementation. Unfortunately, the statics confuse lint so we fallback to
943 * #define in that case.
944 *
945 * NOTE: Support for the Draft 6 definitions is provided for compatibility
946 * only. New applications/libraries should use the standard definitions.
947 */
948
949 #if defined(__EXTENSIONS__) || defined(_REENTRANT) || \
950 !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE - 0 >= 199506L) || \
951 defined(_POSIX_PTHREAD_SEMANTICS)
952
953 #if defined(__STDC__)
954
955 #if (_POSIX_C_SOURCE - 0 >= 199506L) || defined(_POSIX_PTHREAD_SEMANTICS)
956
957 #ifndef __USE_LEGACY_LOGNAME__
958 #ifdef __PRAGMA_REDEFINE_EXTNAME
959 #pragma redefine_extname getlogin_r __posix_getloginx_r
960 extern int getlogin_r(char *, int);
961 #else /* __PRAGMA_REDEFINE_EXTNAME */
962 extern int __posix_getloginx_r(char *, int);
963 #define getlogin_r __posix_getloginx_r
964 #endif /* __PRAGMA_REDEFINE_EXTNAME */
965 #else /* __USE_LEGACY_LOGNAME__ */
966 #ifdef __PRAGMA_REDEFINE_EXTNAME
967 #pragma redefine_extname getlogin_r __posix_getlogin_r
968 extern int getlogin_r(char *, int);
969 #else /* __PRAGMA_REDEFINE_EXTNAME */
970 extern int __posix_getlogin_r(char *, int);
971
972 #ifdef __lint
973
974 #define getlogin_r __posix_getlogin_r
975
976 #else /* !__lint */
977
978 static int
979 getlogin_r(char *__name, int __len)
980 {
981 return (__posix_getlogin_r(__name, __len));
982 }
983 static int
984
985 #endif /* !__lint */
986 #endif /* __PRAGMA_REDEFINE_EXTNAME */
987 #endif /* __USE_LEGACY_LOGNAME__ */
988
989 #ifdef __PRAGMA_REDEFINE_EXTNAME
990 #pragma redefine_extname ttyname_r __posix_ttyname_r
991 extern int ttyname_r(int, char *, size_t);
992 #else /* __PRAGMA_REDEFINE_EXTNAME */
993 extern int __posix_ttyname_r(int, char *, size_t);
994
995 #ifdef __lint
996
997 #define ttyname_r __posix_ttyname_r
998
999 #else /* !__lint */
1000
1001 static int
1002 ttyname_r(int __fildes, char *__buf, size_t __size)
1003 {
1004 return (__posix_ttyname_r(__fildes, __buf, __size));
1005 }
1006
1007 #endif /* !__lint */
1008 #endif /* __PRAGMA_REDEFINE_EXTNAME */
1009
1010 #else /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */
1011
1012 #ifndef __USE_LEGACY_LOGNAME__
1013 #ifdef __PRAGMA_REDEFINE_EXTNAME
1014 #pragma redefine_extname getlogin_r getloginx_r
1015 #else /* __PRAGMA_REDEFINE_EXTNAME */
1016 extern char *getloginx_r(char *, int);
1017 #define getlogin_r getloginx_r
1018 #endif /* __PRAGMA_REDEFINE_EXTNAME */
1019 #endif /* __USE_LEGACY_LOGNAME__ */
1020 extern char *getlogin_r(char *, int);
1021
1022 extern char *ttyname_r(int, char *, int);
1023
1024 #endif /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */
1025
1026 #else /* __STDC__ */
1027
1028 #if (_POSIX_C_SOURCE - 0 >= 199506L) || defined(_POSIX_PTHREAD_SEMANTICS)
1029
1030 #ifndef __USE_LEGACY_LOGNAME__
1031 #ifdef __PRAGMA_REDEFINE_EXTNAME
1032 #pragma redefine_extname getlogin_r __posix_getloginx_r
1033 extern int getlogin_r();
1034 #else /* __PRAGMA_REDEFINE_EXTNAME */
1035 extern int __posix_getloginx_r();
1036 #define getlogin_r __posix_getloginx_r
1037 #endif /* __PRAGMA_REDEFINE_EXTNAME */
1038 #else /* __USE_LEGACY_LOGNAME__ */
1039 #ifdef __PRAGMA_REDEFINE_EXTNAME
1040 #pragma redefine_extname getlogin_r __posix_getlogin_r
1041 extern int getlogin_r();
1042 #else /* __PRAGMA_REDEFINE_EXTNAME */
1043 extern int __posix_getlogin_r();
1044
1045 #ifdef __lint
1046
1047 #define getlogin_r __posix_getlogin_r
1048
1049 #else /* !__lint */
1050
1051 static int
1052 getlogin_r(__name, __len)
1053 char *__name;
1054 int __len;
1055 {
1056 return (__posix_getlogin_r(__name, __len));
1057 }
1058 #endif /* !__lint */
1059 #endif /* __PRAGMA_REDEFINE_EXTNAME */
1060 #endif /* __USE_LEGACY_LOGNAME__ */
1061
1062 #ifdef __PRAGMA_REDEFINE_EXTNAME
1063 #pragma redefine_extname ttyname_r __posix_ttyname_r
1064 extern int ttyname_r();
1065 #else /* __PRAGMA_REDEFINE_EXTNAME */
1066
1067 extern int __posix_ttyname_r();
1068
1069 #ifdef __lint
1070
1071 #define ttyname_r __posix_ttyname_r
1072
1073 #else /* !__lint */
1074
1075 ttyname_r(__fildes, __buf, __size)
1076 int __fildes;
1077 char *__buf;
1078 size_t __size;
1079 {
1080 return (__posix_ttyname_r(__fildes, __buf, __size));
1081 }
1082 #endif /* !__lint */
1083 #endif /* __PRAGMA_REDEFINE_EXTNAME */
1084
1085 #else /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */
1086
1087 #ifndef __USE_LEGACY_LOGNAME__
1088 #ifdef __PRAGMA_REDEFINE_EXTNAME
1089 #pragma redefine_extname getlogin_r getloginx_r
1090 #else /* __PRAGMA_REDEFINE_EXTNAME */
1091 extern char *getloginx_r();
1092 #define getlogin_r getloginx_r
1093 #endif /* __PRAGMA_REDEFINE_EXTNAME */
1094 #endif /* __USE_LEGACY_LOGNAME__ */
1095 extern char *getlogin_r();
1096
1097 extern char *ttyname_r();
1098
1099 #endif /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */
1100
1101 #endif /* __STDC__ */
1102
1103 #endif /* defined(__EXTENSIONS__) || defined(_REENTRANT)... */
1104
1105 #ifdef __cplusplus
1106 }
1107 #endif
1108
1109 #endif /* _UNISTD_H */
|