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 /* Copyright (c) 2013, OmniTI Computer Consulting, Inc. 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
333 defined(__EXTENSIONS__)
334 extern int ftruncate(int, off_t);
335 #endif /* !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE > 2)... */
336 extern char *getcwd(char *, size_t);
337 #if !defined(__XOPEN_OR_POSIX) || (defined(_XPG4_2) && !defined(_XPG6)) || \
338 defined(__EXTENSIONS__)
339 extern int getdtablesize(void);
340 #endif
341 extern gid_t getegid(void);
342 extern uid_t geteuid(void);
343 extern gid_t getgid(void);
344 extern int getgroups(int, gid_t *);
345 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
346 extern long gethostid(void);
347 #endif
348 #if defined(_XPG4_2)
349 extern int gethostname(char *, size_t);
350 #elif !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
351 extern int gethostname(char *, int);
352 #endif
353 extern char *getlogin(void);
354 #if defined(_XPG4) || defined(__EXTENSIONS__)
355 extern int getopt(int, char *const *, const char *);
356 extern char *optarg;
357 extern int opterr, optind, optopt;
358 /* Marked as LEGACY in SUSv2 and removed in SUSv3 */
359 #if !defined(_XPG6) || defined(__EXTENSIONS__)
360 extern char *getpass(const char *);
361 #endif
362 #endif /* defined(_XPG4) || defined(__EXTENSIONS__) */
363 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
364 /* Marked as LEGACY in SUSv2 and removed in SUSv3 */
365 #if !defined(_XPG6) || defined(__EXTENSIONS__)
366 extern int getpagesize(void);
367 #endif
368 extern pid_t getpgid(pid_t);
369 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */
370 extern pid_t getpid(void);
371 extern pid_t getppid(void);
372 extern pid_t getpgrp(void);
373
664 #if !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE > 2) || defined(_XPG4_2) || \
665 (defined(_LARGEFILE_SOURCE) && _FILE_OFFSET_BITS == 64) || \
666 defined(__EXTENSIONS__)
667 extern int ftruncate();
668 #endif /* !defined(__XOPEN_OR_POSIX) (_POSIX_C_SOURCE > 2)... */
669 extern char *getcwd();
670 #if !defined(__XOPEN_OR_POSIX) || (defined(_XPG4_2) && !defined(_XPG6)) || \
671 defined(__EXTENSIONS__)
672 extern int getdtablesize();
673 #endif
674 extern gid_t getegid();
675 extern uid_t geteuid();
676 extern gid_t getgid();
677 extern int getgroups();
678 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
679 extern long gethostid();
680 #endif
681 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
682 extern int gethostname();
683 #endif
684 extern char *getlogin();
685 #if defined(_XPG4) || defined(__EXTENSIONS__)
686 extern int getopt();
687 extern char *optarg;
688 extern int opterr, optind, optopt;
689 #if !defined(_XPG6) || defined(__EXTENSIONS__)
690 extern char *getpass();
691 #endif
692 #endif /* defined(_XPG4) || defined(__EXTENSIONS__) */
693 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
694 #if !defined(_XPG6) || defined(__EXTENSIONS__)
695 extern int getpagesize();
696 #endif
697 extern pid_t getpgid();
698 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */
699 extern pid_t getpid();
700 extern pid_t getppid();
701 extern pid_t getpgrp();
702 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
703 char *gettxt();
704 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
922 * _posix_func(). The preferred mechanism for the remapping is a compiler
923 * #pragma. If the compiler does not provide such a #pragma, the header file
924 * defines a static function func() which calls the _posix_func() version;
925 * this has to be done instead of #define since POSIX specifies that an
926 * application can #undef the symbol and still be bound to the correct
927 * implementation. Unfortunately, the statics confuse lint so we fallback to
928 * #define in that case.
929 *
930 * NOTE: Support for the Draft 6 definitions is provided for compatibility
931 * only. New applications/libraries should use the standard definitions.
932 */
933
934 #if defined(__EXTENSIONS__) || defined(_REENTRANT) || \
935 !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE - 0 >= 199506L) || \
936 defined(_POSIX_PTHREAD_SEMANTICS)
937
938 #if defined(__STDC__)
939
940 #if (_POSIX_C_SOURCE - 0 >= 199506L) || defined(_POSIX_PTHREAD_SEMANTICS)
941
942 #ifdef __PRAGMA_REDEFINE_EXTNAME
943 #pragma redefine_extname getlogin_r __posix_getlogin_r
944 #pragma redefine_extname ttyname_r __posix_ttyname_r
945 extern int getlogin_r(char *, int);
946 extern int ttyname_r(int, char *, size_t);
947 #else /* __PRAGMA_REDEFINE_EXTNAME */
948
949 extern int __posix_getlogin_r(char *, int);
950 extern int __posix_ttyname_r(int, char *, size_t);
951
952 #ifdef __lint
953
954 #define getlogin_r __posix_getlogin_r
955 #define ttyname_r __posix_ttyname_r
956
957 #else /* !__lint */
958
959 static int
960 getlogin_r(char *__name, int __len)
961 {
962 return (__posix_getlogin_r(__name, __len));
963 }
964 static int
965 ttyname_r(int __fildes, char *__buf, size_t __size)
966 {
967 return (__posix_ttyname_r(__fildes, __buf, __size));
968 }
969
970 #endif /* !__lint */
971 #endif /* __PRAGMA_REDEFINE_EXTNAME */
972
973 #else /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */
974
975 extern char *getlogin_r(char *, int);
976 extern char *ttyname_r(int, char *, int);
977
978 #endif /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */
979
980 #else /* __STDC__ */
981
982 #if (_POSIX_C_SOURCE - 0 >= 199506L) || defined(_POSIX_PTHREAD_SEMANTICS)
983
984 #ifdef __PRAGMA_REDEFINE_EXTNAME
985 #pragma redefine_extname getlogin_r __posix_getlogin_r
986 #pragma redefine_extname ttyname_r __posix_ttyname_r
987 extern int getlogin_r();
988 extern int ttyname_r();
989 #else /* __PRAGMA_REDEFINE_EXTNAME */
990
991 extern int __posix_getlogin_r();
992 extern int __posix_ttyname_r();
993
994 #ifdef __lint
995
996 #define getlogin_r __posix_getlogin_r
997 #define ttyname_r __posix_ttyname_r
998
999 #else /* !__lint */
1000
1001 static int
1002 getlogin_r(__name, __len)
1003 char *__name;
1004 int __len;
1005 {
1006 return (__posix_getlogin_r(__name, __len));
1007 }
1008 static int
1009 ttyname_r(__fildes, __buf, __size)
1010 int __fildes;
1011 char *__buf;
1012 size_t __size;
1013 {
1014 return (__posix_ttyname_r(__fildes, __buf, __size));
1015 }
1016 #endif /* !__lint */
1017 #endif /* __PRAGMA_REDEFINE_EXTNAME */
1018
1019 #else /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */
1020
1021 extern char *getlogin_r();
1022 extern char *ttyname_r();
1023
1024 #endif /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */
1025
1026 #endif /* __STDC__ */
1027
1028 #endif /* defined(__EXTENSIONS__) || defined(_REENTRANT)... */
1029
1030 #ifdef __cplusplus
1031 }
1032 #endif
1033
1034 #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 /* Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved. */
32
33 #ifndef _UNISTD_H
34 #define _UNISTD_H
35
36 #include <sys/feature_tests.h>
37
38 #include <sys/types.h>
39 #include <sys/unistd.h>
40
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44
335 defined(__EXTENSIONS__)
336 extern int ftruncate(int, off_t);
337 #endif /* !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE > 2)... */
338 extern char *getcwd(char *, size_t);
339 #if !defined(__XOPEN_OR_POSIX) || (defined(_XPG4_2) && !defined(_XPG6)) || \
340 defined(__EXTENSIONS__)
341 extern int getdtablesize(void);
342 #endif
343 extern gid_t getegid(void);
344 extern uid_t geteuid(void);
345 extern gid_t getgid(void);
346 extern int getgroups(int, gid_t *);
347 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
348 extern long gethostid(void);
349 #endif
350 #if defined(_XPG4_2)
351 extern int gethostname(char *, size_t);
352 #elif !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
353 extern int gethostname(char *, int);
354 #endif
355
356 #ifndef __GETLOGIN_DEFINED /* Avoid duplicate in stdlib.h */
357 #define __GETLOGIN_DEFINED
358 #ifndef __USE_LEGACY_LOGNAME__
359 #ifdef __PRAGMA_REDEFINE_EXTNAME
360 #pragma redefine_extname getlogin getloginx
361 #else /* __PRAGMA_REDEFINE_EXTNAME */
362 extern char *getloginx(void);
363 #define getlogin getloginx
364 #endif /* __PRAGMA_REDEFINE_EXTNAME */
365 #endif /* __USE_LEGACY_LOGNAME__ */
366 extern char *getlogin(void);
367 #endif /* __GETLOGIN_DEFINED */
368
369 #if defined(_XPG4) || defined(__EXTENSIONS__)
370 extern int getopt(int, char *const *, const char *);
371 extern char *optarg;
372 extern int opterr, optind, optopt;
373 /* Marked as LEGACY in SUSv2 and removed in SUSv3 */
374 #if !defined(_XPG6) || defined(__EXTENSIONS__)
375 extern char *getpass(const char *);
376 #endif
377 #endif /* defined(_XPG4) || defined(__EXTENSIONS__) */
378 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
379 /* Marked as LEGACY in SUSv2 and removed in SUSv3 */
380 #if !defined(_XPG6) || defined(__EXTENSIONS__)
381 extern int getpagesize(void);
382 #endif
383 extern pid_t getpgid(pid_t);
384 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */
385 extern pid_t getpid(void);
386 extern pid_t getppid(void);
387 extern pid_t getpgrp(void);
388
679 #if !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE > 2) || defined(_XPG4_2) || \
680 (defined(_LARGEFILE_SOURCE) && _FILE_OFFSET_BITS == 64) || \
681 defined(__EXTENSIONS__)
682 extern int ftruncate();
683 #endif /* !defined(__XOPEN_OR_POSIX) (_POSIX_C_SOURCE > 2)... */
684 extern char *getcwd();
685 #if !defined(__XOPEN_OR_POSIX) || (defined(_XPG4_2) && !defined(_XPG6)) || \
686 defined(__EXTENSIONS__)
687 extern int getdtablesize();
688 #endif
689 extern gid_t getegid();
690 extern uid_t geteuid();
691 extern gid_t getgid();
692 extern int getgroups();
693 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
694 extern long gethostid();
695 #endif
696 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
697 extern int gethostname();
698 #endif
699
700 #ifndef __GETLOGIN_DEFINED /* Avoid duplicate in stdlib.h */
701 #define __GETLOGIN_DEFINED
702 #ifndef __USE_LEGACY_LOGNAME__
703 #ifdef __PRAGMA_REDEFINE_EXTNAME
704 #pragma redefine_extname getlogin getloginx
705 #else /* __PRAGMA_REDEFINE_EXTNAME */
706 extern char *getloginx();
707 #define getlogin getloginx
708 #endif /* __PRAGMA_REDEFINE_EXTNAME */
709 #endif /* __USE_LEGACY_LOGNAME__ */
710 extern char *getlogin();
711 #endif /* __GETLOGIN_DEFINED */
712
713 #if defined(_XPG4) || defined(__EXTENSIONS__)
714 extern int getopt();
715 extern char *optarg;
716 extern int opterr, optind, optopt;
717 #if !defined(_XPG6) || defined(__EXTENSIONS__)
718 extern char *getpass();
719 #endif
720 #endif /* defined(_XPG4) || defined(__EXTENSIONS__) */
721 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
722 #if !defined(_XPG6) || defined(__EXTENSIONS__)
723 extern int getpagesize();
724 #endif
725 extern pid_t getpgid();
726 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */
727 extern pid_t getpid();
728 extern pid_t getppid();
729 extern pid_t getpgrp();
730 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
731 char *gettxt();
732 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
950 * _posix_func(). The preferred mechanism for the remapping is a compiler
951 * #pragma. If the compiler does not provide such a #pragma, the header file
952 * defines a static function func() which calls the _posix_func() version;
953 * this has to be done instead of #define since POSIX specifies that an
954 * application can #undef the symbol and still be bound to the correct
955 * implementation. Unfortunately, the statics confuse lint so we fallback to
956 * #define in that case.
957 *
958 * NOTE: Support for the Draft 6 definitions is provided for compatibility
959 * only. New applications/libraries should use the standard definitions.
960 */
961
962 #if defined(__EXTENSIONS__) || defined(_REENTRANT) || \
963 !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE - 0 >= 199506L) || \
964 defined(_POSIX_PTHREAD_SEMANTICS)
965
966 #if defined(__STDC__)
967
968 #if (_POSIX_C_SOURCE - 0 >= 199506L) || defined(_POSIX_PTHREAD_SEMANTICS)
969
970 #ifndef __USE_LEGACY_LOGNAME__
971 #ifdef __PRAGMA_REDEFINE_EXTNAME
972 #pragma redefine_extname getlogin_r __posix_getloginx_r
973 extern int getlogin_r(char *, int);
974 #else /* __PRAGMA_REDEFINE_EXTNAME */
975 extern int __posix_getloginx_r(char *, int);
976 #define getlogin_r __posix_getloginx_r
977 #endif /* __PRAGMA_REDEFINE_EXTNAME */
978 #else /* __USE_LEGACY_LOGNAME__ */
979 #ifdef __PRAGMA_REDEFINE_EXTNAME
980 #pragma redefine_extname getlogin_r __posix_getlogin_r
981 extern int getlogin_r(char *, int);
982 #else /* __PRAGMA_REDEFINE_EXTNAME */
983 extern int __posix_getlogin_r(char *, int);
984
985 #ifdef __lint
986
987 #define getlogin_r __posix_getlogin_r
988
989 #else /* !__lint */
990
991 static int
992 getlogin_r(char *__name, int __len)
993 {
994 return (__posix_getlogin_r(__name, __len));
995 }
996
997 #endif /* !__lint */
998 #endif /* __PRAGMA_REDEFINE_EXTNAME */
999 #endif /* __USE_LEGACY_LOGNAME__ */
1000
1001 #ifdef __PRAGMA_REDEFINE_EXTNAME
1002 #pragma redefine_extname ttyname_r __posix_ttyname_r
1003 extern int ttyname_r(int, char *, size_t);
1004 #else /* __PRAGMA_REDEFINE_EXTNAME */
1005 extern int __posix_ttyname_r(int, char *, size_t);
1006
1007 #ifdef __lint
1008
1009 #define ttyname_r __posix_ttyname_r
1010
1011 #else /* !__lint */
1012
1013 static int
1014 ttyname_r(int __fildes, char *__buf, size_t __size)
1015 {
1016 return (__posix_ttyname_r(__fildes, __buf, __size));
1017 }
1018
1019 #endif /* !__lint */
1020 #endif /* __PRAGMA_REDEFINE_EXTNAME */
1021
1022 #else /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */
1023
1024 #ifndef __USE_LEGACY_LOGNAME__
1025 #ifdef __PRAGMA_REDEFINE_EXTNAME
1026 #pragma redefine_extname getlogin_r getloginx_r
1027 #else /* __PRAGMA_REDEFINE_EXTNAME */
1028 extern char *getloginx_r(char *, int);
1029 #define getlogin_r getloginx_r
1030 #endif /* __PRAGMA_REDEFINE_EXTNAME */
1031 #endif /* __USE_LEGACY_LOGNAME__ */
1032 extern char *getlogin_r(char *, int);
1033
1034 extern char *ttyname_r(int, char *, int);
1035
1036 #endif /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */
1037
1038 #else /* __STDC__ */
1039
1040 #if (_POSIX_C_SOURCE - 0 >= 199506L) || defined(_POSIX_PTHREAD_SEMANTICS)
1041
1042 #ifndef __USE_LEGACY_LOGNAME__
1043 #ifdef __PRAGMA_REDEFINE_EXTNAME
1044 #pragma redefine_extname getlogin_r __posix_getloginx_r
1045 extern int getlogin_r();
1046 #else /* __PRAGMA_REDEFINE_EXTNAME */
1047 extern int __posix_getloginx_r();
1048 #define getlogin_r __posix_getloginx_r
1049 #endif /* __PRAGMA_REDEFINE_EXTNAME */
1050 #else /* __USE_LEGACY_LOGNAME__ */
1051 #ifdef __PRAGMA_REDEFINE_EXTNAME
1052 #pragma redefine_extname getlogin_r __posix_getlogin_r
1053 extern int getlogin_r();
1054 #else /* __PRAGMA_REDEFINE_EXTNAME */
1055 extern int __posix_getlogin_r();
1056
1057 #ifdef __lint
1058
1059 #define getlogin_r __posix_getlogin_r
1060
1061 #else /* !__lint */
1062
1063 static int
1064 getlogin_r(__name, __len)
1065 char *__name;
1066 int __len;
1067 {
1068 return (__posix_getlogin_r(__name, __len));
1069 }
1070 #endif /* !__lint */
1071 #endif /* __PRAGMA_REDEFINE_EXTNAME */
1072 #endif /* __USE_LEGACY_LOGNAME__ */
1073
1074 #ifdef __PRAGMA_REDEFINE_EXTNAME
1075 #pragma redefine_extname ttyname_r __posix_ttyname_r
1076 extern int ttyname_r();
1077 #else /* __PRAGMA_REDEFINE_EXTNAME */
1078
1079 extern int __posix_ttyname_r();
1080
1081 #ifdef __lint
1082
1083 #define ttyname_r __posix_ttyname_r
1084
1085 #else /* !__lint */
1086
1087 ttyname_r(__fildes, __buf, __size)
1088 int __fildes;
1089 char *__buf;
1090 size_t __size;
1091 {
1092 return (__posix_ttyname_r(__fildes, __buf, __size));
1093 }
1094 #endif /* !__lint */
1095 #endif /* __PRAGMA_REDEFINE_EXTNAME */
1096
1097 #else /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */
1098
1099 #ifndef __USE_LEGACY_LOGNAME__
1100 #ifdef __PRAGMA_REDEFINE_EXTNAME
1101 #pragma redefine_extname getlogin_r getloginx_r
1102 #else /* __PRAGMA_REDEFINE_EXTNAME */
1103 extern char *getloginx_r();
1104 #define getlogin_r getloginx_r
1105 #endif /* __PRAGMA_REDEFINE_EXTNAME */
1106 #endif /* __USE_LEGACY_LOGNAME__ */
1107 extern char *getlogin_r();
1108
1109 extern char *ttyname_r();
1110
1111 #endif /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */
1112
1113 #endif /* __STDC__ */
1114
1115 #endif /* defined(__EXTENSIONS__) || defined(_REENTRANT)... */
1116
1117 #ifdef __cplusplus
1118 }
1119 #endif
1120
1121 #endif /* _UNISTD_H */
|