authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-03-04 22:15:53-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-03-04 22:15:53-05:00
logaeb16010f37df3c702481c9bd98b8cc838418ee1
tree92194b8c0d4576efede7f29b2fee8b1bed1b2654
parent9c5852aa8674320d2912627708f32fea37d7cd08
signature Commit is signed but in an unrecognized format.

initial glibc support


606 files changed, 82120 insertions(+), 253 deletions(-)

CMakeLists.txt+605
...@@ -804,6 +804,604 @@ set(ZIG_C_HEADER_FILES...@@ -804,6 +804,604 @@ set(ZIG_C_HEADER_FILES
804 "xtestintrin.h"804 "xtestintrin.h"
805)805)
806806
807set(ZIG_LIBC_FILES
808 "glibc-include/a.out.h"
809 "glibc-include/aio.h"
810 "glibc-include/aliases.h"
811 "glibc-include/alloca.h"
812 "glibc-include/ar.h"
813 "glibc-include/argp.h"
814 "glibc-include/argz.h"
815 "glibc-include/arpa/ftp.h"
816 "glibc-include/arpa/inet.h"
817 "glibc-include/arpa/nameser.h"
818 "glibc-include/arpa/nameser_compat.h"
819 "glibc-include/arpa/telnet.h"
820 "glibc-include/arpa/tftp.h"
821 "glibc-include/assert.h"
822 "glibc-include/bits/a.out.h"
823 "glibc-include/bits/byteswap.h"
824 "glibc-include/bits/cmathcalls.h"
825 "glibc-include/bits/confname.h"
826 "glibc-include/bits/cpu-set.h"
827 "glibc-include/bits/dirent.h"
828 "glibc-include/bits/dlfcn.h"
829 "glibc-include/bits/elfclass.h"
830 "glibc-include/bits/endian.h"
831 "glibc-include/bits/environments.h"
832 "glibc-include/bits/epoll.h"
833 "glibc-include/bits/errno.h"
834 "glibc-include/bits/error.h"
835 "glibc-include/bits/eventfd.h"
836 "glibc-include/bits/fcntl-linux.h"
837 "glibc-include/bits/fcntl.h"
838 "glibc-include/bits/fcntl2.h"
839 "glibc-include/bits/fenv.h"
840 "glibc-include/bits/fenvinline.h"
841 "glibc-include/bits/floatn-common.h"
842 "glibc-include/bits/floatn.h"
843 "glibc-include/bits/flt-eval-method.h"
844 "glibc-include/bits/fp-fast.h"
845 "glibc-include/bits/fp-logb.h"
846 "glibc-include/bits/getopt_core.h"
847 "glibc-include/bits/getopt_ext.h"
848 "glibc-include/bits/getopt_posix.h"
849 "glibc-include/bits/hwcap.h"
850 "glibc-include/bits/in.h"
851 "glibc-include/bits/indirect-return.h"
852 "glibc-include/bits/initspin.h"
853 "glibc-include/bits/inotify.h"
854 "glibc-include/bits/ioctl-types.h"
855 "glibc-include/bits/ioctls.h"
856 "glibc-include/bits/ipc.h"
857 "glibc-include/bits/ipctypes.h"
858 "glibc-include/bits/iscanonical.h"
859 "glibc-include/bits/libc-header-start.h"
860 "glibc-include/bits/libm-simd-decl-stubs.h"
861 "glibc-include/bits/link.h"
862 "glibc-include/bits/local_lim.h"
863 "glibc-include/bits/locale.h"
864 "glibc-include/bits/long-double.h"
865 "glibc-include/bits/math-finite.h"
866 "glibc-include/bits/math-vector.h"
867 "glibc-include/bits/mathcalls-helper-functions.h"
868 "glibc-include/bits/mathcalls-narrow.h"
869 "glibc-include/bits/mathcalls.h"
870 "glibc-include/bits/mathdef.h"
871 "glibc-include/bits/mathinline.h"
872 "glibc-include/bits/mman-linux.h"
873 "glibc-include/bits/mman-map-flags-generic.h"
874 "glibc-include/bits/mman-shared.h"
875 "glibc-include/bits/mman.h"
876 "glibc-include/bits/monetary-ldbl.h"
877 "glibc-include/bits/mqueue.h"
878 "glibc-include/bits/mqueue2.h"
879 "glibc-include/bits/msq-pad.h"
880 "glibc-include/bits/msq.h"
881 "glibc-include/bits/netdb.h"
882 "glibc-include/bits/param.h"
883 "glibc-include/bits/poll.h"
884 "glibc-include/bits/poll2.h"
885 "glibc-include/bits/posix1_lim.h"
886 "glibc-include/bits/posix2_lim.h"
887 "glibc-include/bits/posix_opt.h"
888 "glibc-include/bits/printf-ldbl.h"
889 "glibc-include/bits/procfs-extra.h"
890 "glibc-include/bits/procfs-id.h"
891 "glibc-include/bits/procfs-prregset.h"
892 "glibc-include/bits/procfs.h"
893 "glibc-include/bits/pthreadtypes-arch.h"
894 "glibc-include/bits/pthreadtypes.h"
895 "glibc-include/bits/ptrace-shared.h"
896 "glibc-include/bits/resource.h"
897 "glibc-include/bits/sched.h"
898 "glibc-include/bits/select.h"
899 "glibc-include/bits/select2.h"
900 "glibc-include/bits/sem-pad.h"
901 "glibc-include/bits/sem.h"
902 "glibc-include/bits/semaphore.h"
903 "glibc-include/bits/setjmp.h"
904 "glibc-include/bits/setjmp2.h"
905 "glibc-include/bits/shm-pad.h"
906 "glibc-include/bits/shm.h"
907 "glibc-include/bits/shmlba.h"
908 "glibc-include/bits/sigaction.h"
909 "glibc-include/bits/sigcontext.h"
910 "glibc-include/bits/sigevent-consts.h"
911 "glibc-include/bits/siginfo-arch.h"
912 "glibc-include/bits/siginfo-consts-arch.h"
913 "glibc-include/bits/siginfo-consts.h"
914 "glibc-include/bits/signalfd.h"
915 "glibc-include/bits/signum-generic.h"
916 "glibc-include/bits/signum.h"
917 "glibc-include/bits/sigstack.h"
918 "glibc-include/bits/sigthread.h"
919 "glibc-include/bits/sockaddr.h"
920 "glibc-include/bits/socket.h"
921 "glibc-include/bits/socket2.h"
922 "glibc-include/bits/socket_type.h"
923 "glibc-include/bits/ss_flags.h"
924 "glibc-include/bits/stab.def"
925 "glibc-include/bits/stat.h"
926 "glibc-include/bits/statfs.h"
927 "glibc-include/bits/statvfs.h"
928 "glibc-include/bits/statx.h"
929 "glibc-include/bits/stdint-intn.h"
930 "glibc-include/bits/stdint-uintn.h"
931 "glibc-include/bits/stdio-ldbl.h"
932 "glibc-include/bits/stdio.h"
933 "glibc-include/bits/stdio2.h"
934 "glibc-include/bits/stdio_lim.h"
935 "glibc-include/bits/stdlib-bsearch.h"
936 "glibc-include/bits/stdlib-float.h"
937 "glibc-include/bits/stdlib-ldbl.h"
938 "glibc-include/bits/stdlib.h"
939 "glibc-include/bits/string_fortified.h"
940 "glibc-include/bits/strings_fortified.h"
941 "glibc-include/bits/stropts.h"
942 "glibc-include/bits/sys_errlist.h"
943 "glibc-include/bits/syscall.h"
944 "glibc-include/bits/sysctl.h"
945 "glibc-include/bits/syslog-ldbl.h"
946 "glibc-include/bits/syslog-path.h"
947 "glibc-include/bits/syslog.h"
948 "glibc-include/bits/sysmacros.h"
949 "glibc-include/bits/termios-baud.h"
950 "glibc-include/bits/termios-c_cc.h"
951 "glibc-include/bits/termios-c_cflag.h"
952 "glibc-include/bits/termios-c_iflag.h"
953 "glibc-include/bits/termios-c_lflag.h"
954 "glibc-include/bits/termios-c_oflag.h"
955 "glibc-include/bits/termios-misc.h"
956 "glibc-include/bits/termios-struct.h"
957 "glibc-include/bits/termios-tcflow.h"
958 "glibc-include/bits/termios.h"
959 "glibc-include/bits/thread-shared-types.h"
960 "glibc-include/bits/time.h"
961 "glibc-include/bits/time64.h"
962 "glibc-include/bits/timerfd.h"
963 "glibc-include/bits/timesize.h"
964 "glibc-include/bits/timex.h"
965 "glibc-include/bits/types.h"
966 "glibc-include/bits/types/FILE.h"
967 "glibc-include/bits/types/__FILE.h"
968 "glibc-include/bits/types/__fpos64_t.h"
969 "glibc-include/bits/types/__fpos_t.h"
970 "glibc-include/bits/types/__locale_t.h"
971 "glibc-include/bits/types/__mbstate_t.h"
972 "glibc-include/bits/types/__sigset_t.h"
973 "glibc-include/bits/types/__sigval_t.h"
974 "glibc-include/bits/types/clock_t.h"
975 "glibc-include/bits/types/clockid_t.h"
976 "glibc-include/bits/types/cookie_io_functions_t.h"
977 "glibc-include/bits/types/error_t.h"
978 "glibc-include/bits/types/locale_t.h"
979 "glibc-include/bits/types/mbstate_t.h"
980 "glibc-include/bits/types/res_state.h"
981 "glibc-include/bits/types/sig_atomic_t.h"
982 "glibc-include/bits/types/sigevent_t.h"
983 "glibc-include/bits/types/siginfo_t.h"
984 "glibc-include/bits/types/sigset_t.h"
985 "glibc-include/bits/types/sigval_t.h"
986 "glibc-include/bits/types/stack_t.h"
987 "glibc-include/bits/types/struct_FILE.h"
988 "glibc-include/bits/types/struct_iovec.h"
989 "glibc-include/bits/types/struct_itimerspec.h"
990 "glibc-include/bits/types/struct_osockaddr.h"
991 "glibc-include/bits/types/struct_rusage.h"
992 "glibc-include/bits/types/struct_sched_param.h"
993 "glibc-include/bits/types/struct_sigstack.h"
994 "glibc-include/bits/types/struct_timespec.h"
995 "glibc-include/bits/types/struct_timeval.h"
996 "glibc-include/bits/types/struct_tm.h"
997 "glibc-include/bits/types/time_t.h"
998 "glibc-include/bits/types/timer_t.h"
999 "glibc-include/bits/types/wint_t.h"
1000 "glibc-include/bits/typesizes.h"
1001 "glibc-include/bits/uintn-identity.h"
1002 "glibc-include/bits/uio-ext.h"
1003 "glibc-include/bits/uio_lim.h"
1004 "glibc-include/bits/unistd.h"
1005 "glibc-include/bits/utmp.h"
1006 "glibc-include/bits/utmpx.h"
1007 "glibc-include/bits/utsname.h"
1008 "glibc-include/bits/waitflags.h"
1009 "glibc-include/bits/waitstatus.h"
1010 "glibc-include/bits/wchar-ldbl.h"
1011 "glibc-include/bits/wchar.h"
1012 "glibc-include/bits/wchar2.h"
1013 "glibc-include/bits/wctype-wchar.h"
1014 "glibc-include/bits/wordsize.h"
1015 "glibc-include/bits/xopen_lim.h"
1016 "glibc-include/bits/xtitypes.h"
1017 "glibc-include/byteswap.h"
1018 "glibc-include/complex.h"
1019 "glibc-include/cpio.h"
1020 "glibc-include/crypt.h"
1021 "glibc-include/ctype.h"
1022 "glibc-include/dirent.h"
1023 "glibc-include/dlfcn.h"
1024 "glibc-include/elf.h"
1025 "glibc-include/endian.h"
1026 "glibc-include/envz.h"
1027 "glibc-include/err.h"
1028 "glibc-include/errno.h"
1029 "glibc-include/error.h"
1030 "glibc-include/execinfo.h"
1031 "glibc-include/fcntl.h"
1032 "glibc-include/features.h"
1033 "glibc-include/fenv.h"
1034 "glibc-include/fmtmsg.h"
1035 "glibc-include/fnmatch.h"
1036 "glibc-include/fpu_control.h"
1037 "glibc-include/fstab.h"
1038 "glibc-include/fts.h"
1039 "glibc-include/ftw.h"
1040 "glibc-include/gconv.h"
1041 "glibc-include/getopt.h"
1042 "glibc-include/glob.h"
1043 "glibc-include/gnu-versions.h"
1044 "glibc-include/gnu/lib-names-64.h"
1045 "glibc-include/gnu/lib-names.h"
1046 "glibc-include/gnu/libc-version.h"
1047 "glibc-include/gnu/stubs-64.h"
1048 "glibc-include/gnu/stubs.h"
1049 "glibc-include/grp.h"
1050 "glibc-include/gshadow.h"
1051 "glibc-include/iconv.h"
1052 "glibc-include/ieee754.h"
1053 "glibc-include/ifaddrs.h"
1054 "glibc-include/inttypes.h"
1055 "glibc-include/langinfo.h"
1056 "glibc-include/lastlog.h"
1057 "glibc-include/libgen.h"
1058 "glibc-include/libintl.h"
1059 "glibc-include/limits.h"
1060 "glibc-include/link.h"
1061 "glibc-include/locale.h"
1062 "glibc-include/malloc.h"
1063 "glibc-include/math.h"
1064 "glibc-include/mcheck.h"
1065 "glibc-include/memory.h"
1066 "glibc-include/mntent.h"
1067 "glibc-include/monetary.h"
1068 "glibc-include/mqueue.h"
1069 "glibc-include/net/ethernet.h"
1070 "glibc-include/net/if.h"
1071 "glibc-include/net/if_arp.h"
1072 "glibc-include/net/if_packet.h"
1073 "glibc-include/net/if_ppp.h"
1074 "glibc-include/net/if_shaper.h"
1075 "glibc-include/net/if_slip.h"
1076 "glibc-include/net/ppp-comp.h"
1077 "glibc-include/net/ppp_defs.h"
1078 "glibc-include/net/route.h"
1079 "glibc-include/netash/ash.h"
1080 "glibc-include/netatalk/at.h"
1081 "glibc-include/netax25/ax25.h"
1082 "glibc-include/netdb.h"
1083 "glibc-include/neteconet/ec.h"
1084 "glibc-include/netinet/ether.h"
1085 "glibc-include/netinet/icmp6.h"
1086 "glibc-include/netinet/if_ether.h"
1087 "glibc-include/netinet/if_fddi.h"
1088 "glibc-include/netinet/if_tr.h"
1089 "glibc-include/netinet/igmp.h"
1090 "glibc-include/netinet/in.h"
1091 "glibc-include/netinet/in_systm.h"
1092 "glibc-include/netinet/ip.h"
1093 "glibc-include/netinet/ip6.h"
1094 "glibc-include/netinet/ip_icmp.h"
1095 "glibc-include/netinet/tcp.h"
1096 "glibc-include/netinet/udp.h"
1097 "glibc-include/netipx/ipx.h"
1098 "glibc-include/netiucv/iucv.h"
1099 "glibc-include/netpacket/packet.h"
1100 "glibc-include/netrom/netrom.h"
1101 "glibc-include/netrose/rose.h"
1102 "glibc-include/nfs/nfs.h"
1103 "glibc-include/nl_types.h"
1104 "glibc-include/nss.h"
1105 "glibc-include/obstack.h"
1106 "glibc-include/paths.h"
1107 "glibc-include/poll.h"
1108 "glibc-include/printf.h"
1109 "glibc-include/proc_service.h"
1110 "glibc-include/protocols/routed.h"
1111 "glibc-include/protocols/rwhod.h"
1112 "glibc-include/protocols/talkd.h"
1113 "glibc-include/protocols/timed.h"
1114 "glibc-include/pthread.h"
1115 "glibc-include/pty.h"
1116 "glibc-include/pwd.h"
1117 "glibc-include/re_comp.h"
1118 "glibc-include/regex.h"
1119 "glibc-include/regexp.h"
1120 "glibc-include/resolv.h"
1121 "glibc-include/rpc/netdb.h"
1122 "glibc-include/sched.h"
1123 "glibc-include/scsi/scsi.h"
1124 "glibc-include/scsi/scsi_ioctl.h"
1125 "glibc-include/scsi/sg.h"
1126 "glibc-include/search.h"
1127 "glibc-include/semaphore.h"
1128 "glibc-include/setjmp.h"
1129 "glibc-include/sgtty.h"
1130 "glibc-include/shadow.h"
1131 "glibc-include/signal.h"
1132 "glibc-include/spawn.h"
1133 "glibc-include/stab.h"
1134 "glibc-include/stdc-predef.h"
1135 "glibc-include/stdint.h"
1136 "glibc-include/stdio.h"
1137 "glibc-include/stdio_ext.h"
1138 "glibc-include/stdlib.h"
1139 "glibc-include/string.h"
1140 "glibc-include/strings.h"
1141 "glibc-include/stropts.h"
1142 "glibc-include/sys/acct.h"
1143 "glibc-include/sys/auxv.h"
1144 "glibc-include/sys/bitypes.h"
1145 "glibc-include/sys/cdefs.h"
1146 "glibc-include/sys/debugreg.h"
1147 "glibc-include/sys/dir.h"
1148 "glibc-include/sys/elf.h"
1149 "glibc-include/sys/epoll.h"
1150 "glibc-include/sys/errno.h"
1151 "glibc-include/sys/eventfd.h"
1152 "glibc-include/sys/fanotify.h"
1153 "glibc-include/sys/fcntl.h"
1154 "glibc-include/sys/file.h"
1155 "glibc-include/sys/fsuid.h"
1156 "glibc-include/sys/gmon.h"
1157 "glibc-include/sys/gmon_out.h"
1158 "glibc-include/sys/inotify.h"
1159 "glibc-include/sys/io.h"
1160 "glibc-include/sys/ioctl.h"
1161 "glibc-include/sys/ipc.h"
1162 "glibc-include/sys/kd.h"
1163 "glibc-include/sys/klog.h"
1164 "glibc-include/sys/mman.h"
1165 "glibc-include/sys/mount.h"
1166 "glibc-include/sys/msg.h"
1167 "glibc-include/sys/mtio.h"
1168 "glibc-include/sys/param.h"
1169 "glibc-include/sys/pci.h"
1170 "glibc-include/sys/perm.h"
1171 "glibc-include/sys/personality.h"
1172 "glibc-include/sys/poll.h"
1173 "glibc-include/sys/prctl.h"
1174 "glibc-include/sys/procfs.h"
1175 "glibc-include/sys/profil.h"
1176 "glibc-include/sys/ptrace.h"
1177 "glibc-include/sys/queue.h"
1178 "glibc-include/sys/quota.h"
1179 "glibc-include/sys/random.h"
1180 "glibc-include/sys/raw.h"
1181 "glibc-include/sys/reboot.h"
1182 "glibc-include/sys/reg.h"
1183 "glibc-include/sys/resource.h"
1184 "glibc-include/sys/select.h"
1185 "glibc-include/sys/sem.h"
1186 "glibc-include/sys/sendfile.h"
1187 "glibc-include/sys/shm.h"
1188 "glibc-include/sys/signal.h"
1189 "glibc-include/sys/signalfd.h"
1190 "glibc-include/sys/socket.h"
1191 "glibc-include/sys/socketvar.h"
1192 "glibc-include/sys/soundcard.h"
1193 "glibc-include/sys/stat.h"
1194 "glibc-include/sys/statfs.h"
1195 "glibc-include/sys/statvfs.h"
1196 "glibc-include/sys/stropts.h"
1197 "glibc-include/sys/swap.h"
1198 "glibc-include/sys/syscall.h"
1199 "glibc-include/sys/sysctl.h"
1200 "glibc-include/sys/sysinfo.h"
1201 "glibc-include/sys/syslog.h"
1202 "glibc-include/sys/sysmacros.h"
1203 "glibc-include/sys/termios.h"
1204 "glibc-include/sys/time.h"
1205 "glibc-include/sys/timeb.h"
1206 "glibc-include/sys/timerfd.h"
1207 "glibc-include/sys/times.h"
1208 "glibc-include/sys/timex.h"
1209 "glibc-include/sys/ttychars.h"
1210 "glibc-include/sys/ttydefaults.h"
1211 "glibc-include/sys/types.h"
1212 "glibc-include/sys/ucontext.h"
1213 "glibc-include/sys/uio.h"
1214 "glibc-include/sys/un.h"
1215 "glibc-include/sys/unistd.h"
1216 "glibc-include/sys/user.h"
1217 "glibc-include/sys/utsname.h"
1218 "glibc-include/sys/vfs.h"
1219 "glibc-include/sys/vlimit.h"
1220 "glibc-include/sys/vm86.h"
1221 "glibc-include/sys/vt.h"
1222 "glibc-include/sys/vtimes.h"
1223 "glibc-include/sys/wait.h"
1224 "glibc-include/sys/xattr.h"
1225 "glibc-include/syscall.h"
1226 "glibc-include/sysexits.h"
1227 "glibc-include/syslog.h"
1228 "glibc-include/tar.h"
1229 "glibc-include/termio.h"
1230 "glibc-include/termios.h"
1231 "glibc-include/tgmath.h"
1232 "glibc-include/thread_db.h"
1233 "glibc-include/threads.h"
1234 "glibc-include/time.h"
1235 "glibc-include/ttyent.h"
1236 "glibc-include/uchar.h"
1237 "glibc-include/ucontext.h"
1238 "glibc-include/ulimit.h"
1239 "glibc-include/unistd.h"
1240 "glibc-include/utime.h"
1241 "glibc-include/utmp.h"
1242 "glibc-include/utmpx.h"
1243 "glibc-include/values.h"
1244 "glibc-include/wait.h"
1245 "glibc-include/wchar.h"
1246 "glibc-include/wctype.h"
1247 "glibc-include/wordexp.h"
1248 "glibc/bits/byteswap.h"
1249 "glibc/bits/endian.h"
1250 "glibc/bits/floatn-common.h"
1251 "glibc/bits/libc-header-start.h"
1252 "glibc/bits/long-double.h"
1253 "glibc/bits/stdint-intn.h"
1254 "glibc/bits/timesize.h"
1255 "glibc/bits/typesizes.h"
1256 "glibc/bits/time64.h"
1257 "glibc/bits/uintn-identity.h"
1258 "glibc/bits/waitflags.h"
1259 "glibc/bits/waitstatus.h"
1260 "glibc/bits/select.h"
1261 "glibc/bits/pthreadtypes.h"
1262 "glibc/bits/types/__sigset_t.h"
1263 "glibc/bits/types/struct_sched_param.h"
1264 "glibc/bits/stdlib-bsearch.h"
1265 "glibc/bits/stat.h"
1266 "glibc/bits/sched.h"
1267 "glibc/bits/time.h"
1268 "glibc/csu/abi-note.S"
1269 "glibc/csu/abi-tag.h"
1270 "glibc/csu/elf-init.c"
1271 "glibc/csu/init.c"
1272 "glibc/debug/stack_chk_fail_local.c"
1273 "glibc/debug/warning-nop.c"
1274 "glibc/include/alloca.h"
1275 "glibc/include/bits/types.h"
1276 "glibc/include/bits/types/__locale_t.h"
1277 "glibc/include/bits/types/clock_t.h"
1278 "glibc/include/bits/types/time_t.h"
1279 "glibc/include/bits/types/timer_t.h"
1280 "glibc/include/bits/types/clockid_t.h"
1281 "glibc/include/bits/types/locale_t.h"
1282 "glibc/include/bits/types/sigset_t.h"
1283 "glibc/include/bits/types/struct_timeval.h"
1284 "glibc/include/bits/types/struct_timespec.h"
1285 "glibc/include/bits/stdlib-float.h"
1286 "glibc/include/bits/statx.h"
1287 "glibc/include/bits/cpu-set.h"
1288 "glibc/include/config.h"
1289 "glibc/include/elf.h"
1290 "glibc/include/endian.h"
1291 "glibc/include/features.h"
1292 "glibc/include/gnu/stubs.h"
1293 "glibc/include/libc-modules.h"
1294 "glibc/include/libc-symbols.h"
1295 "glibc/include/stdc-predef.h"
1296 "glibc/include/stdlib.h"
1297 "glibc/include/sys/cdefs.h"
1298 "glibc/include/sys/types.h"
1299 "glibc/include/sys/select.h"
1300 "glibc/include/sys/stat.h"
1301 "glibc/include/stackinfo.h"
1302 "glibc/include/libc-pointer-arith.h"
1303 "glibc/include/dso_handle.h"
1304 "glibc/include/pthread.h"
1305 "glibc/include/sched.h"
1306 "glibc/include/time.h"
1307 "glibc/include/sys/time.h"
1308 "glibc/io/fstat.c"
1309 "glibc/io/fstat64.c"
1310 "glibc/io/fstatat.c"
1311 "glibc/io/fstatat64.c"
1312 "glibc/io/lstat.c"
1313 "glibc/io/lstat64.c"
1314 "glibc/io/mknod.c"
1315 "glibc/io/mknodat.c"
1316 "glibc/io/stat.c"
1317 "glibc/io/stat64.c"
1318 "glibc/io/sys/stat.h"
1319 "glibc/io/bits/statx.h"
1320 "glibc/locale/bits/types/__locale_t.h"
1321 "glibc/locale/bits/types/locale_t.h"
1322 "glibc/misc/sys/cdefs.h"
1323 "glibc/misc/sys/select.h"
1324 "glibc/nptl/pthread_atfork.c"
1325 "glibc/posix/bits/types.h"
1326 "glibc/posix/sys/types.h"
1327 "glibc/posix/sched.h"
1328 "glibc/posix/bits/cpu-set.h"
1329 "glibc/stdlib/at_quick_exit.c"
1330 "glibc/stdlib/atexit.c"
1331 "glibc/stdlib/exit.h"
1332 "glibc/stdlib/stdlib.h"
1333 "glibc/stdlib/bits/stdlib-float.h"
1334 "glibc/sysdeps/generic/dwarf2.h"
1335 "glibc/sysdeps/generic/symbol-hacks.h"
1336 "glibc/sysdeps/generic/sysdep.h"
1337 "glibc/sysdeps/generic/stackinfo.h"
1338 "glibc/sysdeps/generic/dl-dtprocnum.h"
1339 "glibc/sysdeps/generic/allocalim.h"
1340 "glibc/sysdeps/generic/libc-lock.h"
1341 "glibc/sysdeps/pthread/allocalim.h"
1342 "glibc/sysdeps/nptl/bits/pthreadtypes.h"
1343 "glibc/sysdeps/nptl/bits/thread-shared-types.h"
1344 "glibc/sysdeps/nptl/libc-lock.h"
1345 "glibc/sysdeps/nptl/pthread.h"
1346 "glibc/sysdeps/unix/sysv/linux/x86/bits/typesizes.h"
1347 "glibc/sysdeps/unix/sysv/linux/x86/sys/elf.h"
1348 "glibc/sysdeps/unix/sysv/linux/bits/sched.h"
1349 "glibc/sysdeps/unix/sysv/linux/bits/time.h"
1350 "glibc/sysdeps/unix/sysv/linux/include/sys/timex.h"
1351 "glibc/sysdeps/unix/sysv/linux/sys/timex.h"
1352 "glibc/sysdeps/unix/sysv/linux/bits/timex.h"
1353 "glibc/sysdeps/x86/bits/floatn.h"
1354 "glibc/sysdeps/x86/bits/wordsize.h"
1355 "glibc/sysdeps/x86/bits/endian.h"
1356 "glibc/sysdeps/x86/bits/select.h"
1357 "glibc/sysdeps/x86/sysdep.h"
1358 "glibc/sysdeps/x86/nptl/bits/pthreadtypes-arch.h"
1359 "glibc/sysdeps/x86_64/crti.S"
1360 "glibc/sysdeps/x86_64/crtn.S"
1361 "glibc/sysdeps/x86_64/start.S"
1362 "glibc/sysdeps/x86_64/sysdep.h"
1363 "glibc/sysdeps/x86_64/stackinfo.h"
1364 "glibc/time/bits/types/clock_t.h"
1365 "glibc/time/bits/types/clockid_t.h"
1366 "glibc/time/bits/types/time_t.h"
1367 "glibc/time/bits/types/timer_t.h"
1368 "glibc/time/bits/types/struct_timeval.h"
1369 "glibc/time/bits/types/struct_timespec.h"
1370 "glibc/time/time.h"
1371 "glibc/time/sys/time.h"
1372 "glibc/string/endian.h"
1373 "glibc/signal/bits/types/sigset_t.h"
1374 "glibc/stdlib/alloca.h"
1375 "glibc/elf/elf.h"
1376 "glibc/include/bits/types/struct_tm.h"
1377 "glibc/time/bits/types/struct_tm.h"
1378 "glibc/include/bits/types/struct_itimerspec.h"
1379 "glibc/time/bits/types/struct_itimerspec.h"
1380 "glibc/sysdeps/x86/bits/setjmp.h"
1381 "glibc/include/setjmp.h"
1382 "glibc/setjmp/setjmp.h"
1383 "glibc/setjmp/setjmp.h"
1384 "glibc/bits/setjmp.h"
1385 "glibc/sysdeps/nptl/libc-lockP.h"
1386 "glibc/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h"
1387 "glibc/sysdeps/nptl/lowlevellock.h"
1388 "glibc/include/stap-probe.h"
1389 "glibc/sysdeps/unix/sysv/linux/bits/param.h"
1390 "glibc/include/sys/param.h"
1391 "glibc/misc/sys/param.h"
1392 "glibc/bits/param.h"
1393 "glibc/include/signal.h"
1394 "glibc/include/sys/signal.h"
1395 "glibc/signal/signal.h"
1396 "glibc/signal/sys/signal.h"
1397 "glibc/sysdeps/unix/sysv/linux/bits/signum.h"
1398 "glibc/bits/signum.h"
1399 "glibc/bits/signum-generic.h"
1400 "glibc/include/bits/types/sig_atomic_t.h"
1401 "glibc/signal/bits/types/sig_atomic_t.h"
1402 "symbols.zig"
1403)
1404
807if(MSVC)1405if(MSVC)
808 set(MSVC_DIA_SDK_DIR "$ENV{VSINSTALLDIR}DIA SDK")1406 set(MSVC_DIA_SDK_DIR "$ENV{VSINSTALLDIR}DIA SDK")
809 if (IS_DIRECTORY ${MSVC_DIA_SDK_DIR})1407 if (IS_DIRECTORY ${MSVC_DIA_SDK_DIR})
...@@ -814,6 +1412,7 @@ endif()...@@ -814,6 +1412,7 @@ endif()
8141412
815set(ZIG_LIB_DIR "lib/zig")1413set(ZIG_LIB_DIR "lib/zig")
816set(C_HEADERS_DEST "${ZIG_LIB_DIR}/include")1414set(C_HEADERS_DEST "${ZIG_LIB_DIR}/include")
1415set(LIBC_FILES_DEST "${ZIG_LIB_DIR}/libc")
817set(ZIG_STD_DEST "${ZIG_LIB_DIR}/std")1416set(ZIG_STD_DEST "${ZIG_LIB_DIR}/std")
818set(CONFIGURE_OUT_FILE "${CMAKE_BINARY_DIR}/config.h")1417set(CONFIGURE_OUT_FILE "${CMAKE_BINARY_DIR}/config.h")
819configure_file (1418configure_file (
...@@ -917,6 +1516,12 @@ foreach(file ${ZIG_STD_FILES})...@@ -917,6 +1516,12 @@ foreach(file ${ZIG_STD_FILES})
917 install(FILES "${CMAKE_SOURCE_DIR}/std/${file}" DESTINATION "${file_dir}")1516 install(FILES "${CMAKE_SOURCE_DIR}/std/${file}" DESTINATION "${file_dir}")
918endforeach()1517endforeach()
9191518
1519foreach(file ${ZIG_LIBC_FILES})
1520 get_filename_component(file_dir "${LIBC_FILES_DEST}/${file}" DIRECTORY)
1521 install(FILES "${CMAKE_SOURCE_DIR}/libc/${file}" DESTINATION "${file_dir}")
1522endforeach()
1523
1524
920install(FILES "${CMAKE_SOURCE_DIR}/src-self-hosted/arg.zig" DESTINATION "${ZIG_STD_DEST}/special/fmt/")1525install(FILES "${CMAKE_SOURCE_DIR}/src-self-hosted/arg.zig" DESTINATION "${ZIG_STD_DEST}/special/fmt/")
921install(FILES "${CMAKE_SOURCE_DIR}/src-self-hosted/main.zig" DESTINATION "${ZIG_STD_DEST}/special/fmt/")1526install(FILES "${CMAKE_SOURCE_DIR}/src-self-hosted/main.zig" DESTINATION "${ZIG_STD_DEST}/special/fmt/")
922install(FILES "${CMAKE_SOURCE_DIR}/src-self-hosted/errmsg.zig" DESTINATION "${ZIG_STD_DEST}/special/fmt/")1527install(FILES "${CMAKE_SOURCE_DIR}/src-self-hosted/errmsg.zig" DESTINATION "${ZIG_STD_DEST}/special/fmt/")
libc/glibc-include/a.out.h created+138
...@@ -0,0 +1,138 @@
1#ifndef __A_OUT_GNU_H__
2#define __A_OUT_GNU_H__
3
4#include <bits/a.out.h>
5
6#define __GNU_EXEC_MACROS__
7
8struct exec
9{
10 unsigned long a_info; /* Use macros N_MAGIC, etc for access. */
11 unsigned int a_text; /* Length of text, in bytes. */
12 unsigned int a_data; /* Length of data, in bytes. */
13 unsigned int a_bss; /* Length of uninitialized data area for file, in bytes. */
14 unsigned int a_syms; /* Length of symbol table data in file, in bytes. */
15 unsigned int a_entry; /* Start address. */
16 unsigned int a_trsize;/* Length of relocation info for text, in bytes. */
17 unsigned int a_drsize;/* Length of relocation info for data, in bytes. */
18};
19
20enum machine_type
21{
22 M_OLDSUN2 = 0,
23 M_68010 = 1,
24 M_68020 = 2,
25 M_SPARC = 3,
26 M_386 = 100,
27 M_MIPS1 = 151,
28 M_MIPS2 = 152
29};
30
31#define N_MAGIC(exec) ((exec).a_info & 0xffff)
32#define N_MACHTYPE(exec) ((enum machine_type)(((exec).a_info >> 16) & 0xff))
33#define N_FLAGS(exec) (((exec).a_info >> 24) & 0xff)
34#define N_SET_INFO(exec, magic, type, flags) \
35 ((exec).a_info = ((magic) & 0xffff) \
36 | (((int)(type) & 0xff) << 16) \
37 | (((flags) & 0xff) << 24))
38#define N_SET_MAGIC(exec, magic) \
39 ((exec).a_info = ((exec).a_info & 0xffff0000) | ((magic) & 0xffff))
40#define N_SET_MACHTYPE(exec, machtype) \
41 ((exec).a_info = \
42 ((exec).a_info&0xff00ffff) | ((((int)(machtype))&0xff) << 16))
43#define N_SET_FLAGS(exec, flags) \
44 ((exec).a_info = \
45 ((exec).a_info&0x00ffffff) | (((flags) & 0xff) << 24))
46
47/* Code indicating object file or impure executable. */
48#define OMAGIC 0407
49/* Code indicating pure executable. */
50#define NMAGIC 0410
51/* Code indicating demand-paged executable. */
52#define ZMAGIC 0413
53/* This indicates a demand-paged executable with the header in the text.
54 The first page is unmapped to help trap NULL pointer references. */
55#define QMAGIC 0314
56/* Code indicating core file. */
57#define CMAGIC 0421
58
59#define N_TRSIZE(a) ((a).a_trsize)
60#define N_DRSIZE(a) ((a).a_drsize)
61#define N_SYMSIZE(a) ((a).a_syms)
62#define N_BADMAG(x) \
63 (N_MAGIC(x) != OMAGIC && N_MAGIC(x) != NMAGIC \
64 && N_MAGIC(x) != ZMAGIC && N_MAGIC(x) != QMAGIC)
65#define _N_HDROFF(x) (1024 - sizeof (struct exec))
66#define N_TXTOFF(x) \
67 (N_MAGIC(x) == ZMAGIC ? _N_HDROFF((x)) + sizeof (struct exec) : \
68 (N_MAGIC(x) == QMAGIC ? 0 : sizeof (struct exec)))
69#define N_DATOFF(x) (N_TXTOFF(x) + (x).a_text)
70#define N_TRELOFF(x) (N_DATOFF(x) + (x).a_data)
71#define N_DRELOFF(x) (N_TRELOFF(x) + N_TRSIZE(x))
72#define N_SYMOFF(x) (N_DRELOFF(x) + N_DRSIZE(x))
73#define N_STROFF(x) (N_SYMOFF(x) + N_SYMSIZE(x))
74
75/* Address of text segment in memory after it is loaded. */
76#define N_TXTADDR(x) (N_MAGIC(x) == QMAGIC ? 4096 : 0)
77
78/* Address of data segment in memory after it is loaded. */
79#define SEGMENT_SIZE 1024
80
81#define _N_SEGMENT_ROUND(x) (((x) + SEGMENT_SIZE - 1) & ~(SEGMENT_SIZE - 1))
82#define _N_TXTENDADDR(x) (N_TXTADDR(x)+(x).a_text)
83
84#define N_DATADDR(x) \
85 (N_MAGIC(x)==OMAGIC? (_N_TXTENDADDR(x)) \
86 : (_N_SEGMENT_ROUND (_N_TXTENDADDR(x))))
87#define N_BSSADDR(x) (N_DATADDR(x) + (x).a_data)
88
89#if !defined (N_NLIST_DECLARED)
90struct nlist
91{
92 union
93 {
94 char *n_name;
95 struct nlist *n_next;
96 long n_strx;
97 } n_un;
98 unsigned char n_type;
99 char n_other;
100 short n_desc;
101 unsigned long n_value;
102};
103#endif /* no N_NLIST_DECLARED. */
104
105#define N_UNDF 0
106#define N_ABS 2
107#define N_TEXT 4
108#define N_DATA 6
109#define N_BSS 8
110#define N_FN 15
111#define N_EXT 1
112#define N_TYPE 036
113#define N_STAB 0340
114#define N_INDR 0xa
115#define N_SETA 0x14 /* Absolute set element symbol. */
116#define N_SETT 0x16 /* Text set element symbol. */
117#define N_SETD 0x18 /* Data set element symbol. */
118#define N_SETB 0x1A /* Bss set element symbol. */
119#define N_SETV 0x1C /* Pointer to set vector in data area. */
120
121#if !defined (N_RELOCATION_INFO_DECLARED)
122/* This structure describes a single relocation to be performed.
123 The text-relocation section of the file is a vector of these structures,
124 all of which apply to the text section.
125 Likewise, the data-relocation section applies to the data section. */
126
127struct relocation_info
128{
129 int r_address;
130 unsigned int r_symbolnum:24;
131 unsigned int r_pcrel:1;
132 unsigned int r_length:2;
133 unsigned int r_extern:1;
134 unsigned int r_pad:4;
135};
136#endif /* no N_RELOCATION_INFO_DECLARED. */
137
138#endif /* __A_OUT_GNU_H__ */
libc/glibc-include/aio.h created+245
...@@ -0,0 +1,245 @@
1/* Copyright (C) 1996-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/*
19 * ISO/IEC 9945-1:1996 6.7: Asynchronous Input and Output
20 */
21
22#ifndef _AIO_H
23#define _AIO_H 1
24
25#include <features.h>
26#include <sys/types.h>
27#include <bits/types/sigevent_t.h>
28#include <bits/sigevent-consts.h>
29#include <bits/types/struct_timespec.h>
30
31__BEGIN_DECLS
32
33/* Asynchronous I/O control block. */
34struct aiocb
35{
36 int aio_fildes; /* File desriptor. */
37 int aio_lio_opcode; /* Operation to be performed. */
38 int aio_reqprio; /* Request priority offset. */
39 volatile void *aio_buf; /* Location of buffer. */
40 size_t aio_nbytes; /* Length of transfer. */
41 struct sigevent aio_sigevent; /* Signal number and value. */
42
43 /* Internal members. */
44 struct aiocb *__next_prio;
45 int __abs_prio;
46 int __policy;
47 int __error_code;
48 __ssize_t __return_value;
49
50#ifndef __USE_FILE_OFFSET64
51 __off_t aio_offset; /* File offset. */
52 char __pad[sizeof (__off64_t) - sizeof (__off_t)];
53#else
54 __off64_t aio_offset; /* File offset. */
55#endif
56 char __glibc_reserved[32];
57};
58
59/* The same for the 64bit offsets. Please note that the members aio_fildes
60 to __return_value have to be the same in aiocb and aiocb64. */
61#ifdef __USE_LARGEFILE64
62struct aiocb64
63{
64 int aio_fildes; /* File desriptor. */
65 int aio_lio_opcode; /* Operation to be performed. */
66 int aio_reqprio; /* Request priority offset. */
67 volatile void *aio_buf; /* Location of buffer. */
68 size_t aio_nbytes; /* Length of transfer. */
69 struct sigevent aio_sigevent; /* Signal number and value. */
70
71 /* Internal members. */
72 struct aiocb *__next_prio;
73 int __abs_prio;
74 int __policy;
75 int __error_code;
76 __ssize_t __return_value;
77
78 __off64_t aio_offset; /* File offset. */
79 char __glibc_reserved[32];
80};
81#endif
82
83
84#ifdef __USE_GNU
85/* To customize the implementation one can use the following struct.
86 This implementation follows the one in Irix. */
87struct aioinit
88 {
89 int aio_threads; /* Maximal number of threads. */
90 int aio_num; /* Number of expected simultanious requests. */
91 int aio_locks; /* Not used. */
92 int aio_usedba; /* Not used. */
93 int aio_debug; /* Not used. */
94 int aio_numusers; /* Not used. */
95 int aio_idle_time; /* Number of seconds before idle thread
96 terminates. */
97 int aio_reserved;
98 };
99#endif
100
101
102/* Return values of cancelation function. */
103enum
104{
105 AIO_CANCELED,
106#define AIO_CANCELED AIO_CANCELED
107 AIO_NOTCANCELED,
108#define AIO_NOTCANCELED AIO_NOTCANCELED
109 AIO_ALLDONE
110#define AIO_ALLDONE AIO_ALLDONE
111};
112
113
114/* Operation codes for `aio_lio_opcode'. */
115enum
116{
117 LIO_READ,
118#define LIO_READ LIO_READ
119 LIO_WRITE,
120#define LIO_WRITE LIO_WRITE
121 LIO_NOP
122#define LIO_NOP LIO_NOP
123};
124
125
126/* Synchronization options for `lio_listio' function. */
127enum
128{
129 LIO_WAIT,
130#define LIO_WAIT LIO_WAIT
131 LIO_NOWAIT
132#define LIO_NOWAIT LIO_NOWAIT
133};
134
135
136/* Allow user to specify optimization. */
137#ifdef __USE_GNU
138extern void aio_init (const struct aioinit *__init) __THROW __nonnull ((1));
139#endif
140
141
142#ifndef __USE_FILE_OFFSET64
143/* Enqueue read request for given number of bytes and the given priority. */
144extern int aio_read (struct aiocb *__aiocbp) __THROW __nonnull ((1));
145/* Enqueue write request for given number of bytes and the given priority. */
146extern int aio_write (struct aiocb *__aiocbp) __THROW __nonnull ((1));
147
148/* Initiate list of I/O requests. */
149extern int lio_listio (int __mode,
150 struct aiocb *const __list[__restrict_arr],
151 int __nent, struct sigevent *__restrict __sig)
152 __THROW __nonnull ((2));
153
154/* Retrieve error status associated with AIOCBP. */
155extern int aio_error (const struct aiocb *__aiocbp) __THROW __nonnull ((1));
156/* Return status associated with AIOCBP. */
157extern __ssize_t aio_return (struct aiocb *__aiocbp) __THROW __nonnull ((1));
158
159/* Try to cancel asynchronous I/O requests outstanding against file
160 descriptor FILDES. */
161extern int aio_cancel (int __fildes, struct aiocb *__aiocbp) __THROW;
162
163/* Suspend calling thread until at least one of the asynchronous I/O
164 operations referenced by LIST has completed.
165
166 This function is a cancellation point and therefore not marked with
167 __THROW. */
168extern int aio_suspend (const struct aiocb *const __list[], int __nent,
169 const struct timespec *__restrict __timeout)
170 __nonnull ((1));
171
172/* Force all operations associated with file desriptor described by
173 `aio_fildes' member of AIOCBP. */
174extern int aio_fsync (int __operation, struct aiocb *__aiocbp)
175 __THROW __nonnull ((2));
176#else
177# ifdef __REDIRECT_NTH
178extern int __REDIRECT_NTH (aio_read, (struct aiocb *__aiocbp), aio_read64)
179 __nonnull ((1));
180extern int __REDIRECT_NTH (aio_write, (struct aiocb *__aiocbp), aio_write64)
181 __nonnull ((1));
182
183extern int __REDIRECT_NTH (lio_listio,
184 (int __mode,
185 struct aiocb *const __list[__restrict_arr],
186 int __nent, struct sigevent *__restrict __sig),
187 lio_listio64) __nonnull ((2));
188
189extern int __REDIRECT_NTH (aio_error, (const struct aiocb *__aiocbp),
190 aio_error64) __nonnull ((1));
191extern __ssize_t __REDIRECT_NTH (aio_return, (struct aiocb *__aiocbp),
192 aio_return64) __nonnull ((1));
193
194extern int __REDIRECT_NTH (aio_cancel,
195 (int __fildes, struct aiocb *__aiocbp),
196 aio_cancel64);
197
198extern int __REDIRECT_NTH (aio_suspend,
199 (const struct aiocb *const __list[], int __nent,
200 const struct timespec *__restrict __timeout),
201 aio_suspend64) __nonnull ((1));
202
203extern int __REDIRECT_NTH (aio_fsync,
204 (int __operation, struct aiocb *__aiocbp),
205 aio_fsync64) __nonnull ((2));
206
207# else
208# define aio_read aio_read64
209# define aio_write aio_write64
210# define lio_listio lio_listio64
211# define aio_error aio_error64
212# define aio_return aio_return64
213# define aio_cancel aio_cancel64
214# define aio_suspend aio_suspend64
215# define aio_fsync aio_fsync64
216# endif
217#endif
218
219#ifdef __USE_LARGEFILE64
220extern int aio_read64 (struct aiocb64 *__aiocbp) __THROW __nonnull ((1));
221extern int aio_write64 (struct aiocb64 *__aiocbp) __THROW __nonnull ((1));
222
223extern int lio_listio64 (int __mode,
224 struct aiocb64 *const __list[__restrict_arr],
225 int __nent, struct sigevent *__restrict __sig)
226 __THROW __nonnull ((2));
227
228extern int aio_error64 (const struct aiocb64 *__aiocbp)
229 __THROW __nonnull ((1));
230extern __ssize_t aio_return64 (struct aiocb64 *__aiocbp)
231 __THROW __nonnull ((1));
232
233extern int aio_cancel64 (int __fildes, struct aiocb64 *__aiocbp) __THROW;
234
235extern int aio_suspend64 (const struct aiocb64 *const __list[], int __nent,
236 const struct timespec *__restrict __timeout)
237 __THROW __nonnull ((1));
238
239extern int aio_fsync64 (int __operation, struct aiocb64 *__aiocbp)
240 __THROW __nonnull ((2));
241#endif
242
243__END_DECLS
244
245#endif /* aio.h */
libc/glibc-include/aliases.h created+63
...@@ -0,0 +1,63 @@
1/* Copyright (C) 1996-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _ALIASES_H
19#define _ALIASES_H 1
20
21#include <features.h>
22
23#include <sys/types.h>
24
25
26__BEGIN_DECLS
27
28/* Structure to represent one entry of the alias data base. */
29struct aliasent
30 {
31 char *alias_name;
32 size_t alias_members_len;
33 char **alias_members;
34 int alias_local;
35 };
36
37
38/* Open alias data base files. */
39extern void setaliasent (void) __THROW;
40
41/* Close alias data base files. */
42extern void endaliasent (void) __THROW;
43
44/* Get the next entry from the alias data base. */
45extern struct aliasent *getaliasent (void) __THROW;
46
47/* Get the next entry from the alias data base and put it in RESULT_BUF. */
48extern int getaliasent_r (struct aliasent *__restrict __result_buf,
49 char *__restrict __buffer, size_t __buflen,
50 struct aliasent **__restrict __result) __THROW;
51
52/* Get alias entry corresponding to NAME. */
53extern struct aliasent *getaliasbyname (const char *__name) __THROW;
54
55/* Get alias entry corresponding to NAME and put it in RESULT_BUF. */
56extern int getaliasbyname_r (const char *__restrict __name,
57 struct aliasent *__restrict __result_buf,
58 char *__restrict __buffer, size_t __buflen,
59 struct aliasent **__restrict __result) __THROW;
60
61__END_DECLS
62
63#endif /* aliases.h */
libc/glibc-include/alloca.h created+40
...@@ -0,0 +1,40 @@
1/* Copyright (C) 1992-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _ALLOCA_H
19#define _ALLOCA_H 1
20
21#include <features.h>
22
23#define __need_size_t
24#include <stddef.h>
25
26__BEGIN_DECLS
27
28/* Remove any previous definitions. */
29#undef alloca
30
31/* Allocate a block that will be freed when the calling function exits. */
32extern void *alloca (size_t __size) __THROW;
33
34#ifdef __GNUC__
35# define alloca(size) __builtin_alloca (size)
36#endif /* GCC. */
37
38__END_DECLS
39
40#endif /* alloca.h */
libc/glibc-include/ar.h created+47
...@@ -0,0 +1,47 @@
1/* Header describing `ar' archive file format.
2 Copyright (C) 1996-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _AR_H
20#define _AR_H 1
21
22#include <sys/cdefs.h>
23
24/* Archive files start with the ARMAG identifying string. Then follows a
25 `struct ar_hdr', and as many bytes of member file data as its `ar_size'
26 member indicates, for each member file. */
27
28#define ARMAG "!<arch>\n" /* String that begins an archive file. */
29#define SARMAG 8 /* Size of that string. */
30
31#define ARFMAG "`\n" /* String in ar_fmag at end of each header. */
32
33__BEGIN_DECLS
34
35struct ar_hdr
36 {
37 char ar_name[16]; /* Member file name, sometimes / terminated. */
38 char ar_date[12]; /* File date, decimal seconds since Epoch. */
39 char ar_uid[6], ar_gid[6]; /* User and group IDs, in ASCII decimal. */
40 char ar_mode[8]; /* File mode, in ASCII octal. */
41 char ar_size[10]; /* File size, in ASCII decimal. */
42 char ar_fmag[2]; /* Always contains ARFMAG. */
43 };
44
45__END_DECLS
46
47#endif /* ar.h */
libc/glibc-include/argp.h created+559
...@@ -0,0 +1,559 @@
1/* Hierarchial argument parsing, layered over getopt.
2 Copyright (C) 1995-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Written by Miles Bader <miles@gnu.ai.mit.edu>.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
19
20#ifndef _ARGP_H
21#define _ARGP_H
22
23#include <stdio.h>
24#include <ctype.h>
25#include <getopt.h>
26#include <limits.h>
27#include <errno.h>
28
29__BEGIN_DECLS
30
31/* error_t may or may not be available from errno.h, depending on the
32 operating system. */
33#ifndef __error_t_defined
34# define __error_t_defined 1
35typedef int error_t;
36#endif
37
38/* A description of a particular option. A pointer to an array of
39 these is passed in the OPTIONS field of an argp structure. Each option
40 entry can correspond to one long option and/or one short option; more
41 names for the same option can be added by following an entry in an option
42 array with options having the OPTION_ALIAS flag set. */
43struct argp_option
44{
45 /* The long option name. For more than one name for the same option, you
46 can use following options with the OPTION_ALIAS flag set. */
47 const char *name;
48
49 /* What key is returned for this option. If > 0 and printable, then it's
50 also accepted as a short option. */
51 int key;
52
53 /* If non-NULL, this is the name of the argument associated with this
54 option, which is required unless the OPTION_ARG_OPTIONAL flag is set. */
55 const char *arg;
56
57 /* OPTION_ flags. */
58 int flags;
59
60 /* The doc string for this option. If both NAME and KEY are 0, This string
61 will be printed outdented from the normal option column, making it
62 useful as a group header (it will be the first thing printed in its
63 group); in this usage, it's conventional to end the string with a `:'. */
64 const char *doc;
65
66 /* The group this option is in. In a long help message, options are sorted
67 alphabetically within each group, and the groups presented in the order
68 0, 1, 2, ..., n, -m, ..., -2, -1. Every entry in an options array with
69 if this field 0 will inherit the group number of the previous entry, or
70 zero if it's the first one, unless its a group header (NAME and KEY both
71 0), in which case, the previous entry + 1 is the default. Automagic
72 options such as --help are put into group -1. */
73 int group;
74};
75
76/* The argument associated with this option is optional. */
77#define OPTION_ARG_OPTIONAL 0x1
78
79/* This option isn't displayed in any help messages. */
80#define OPTION_HIDDEN 0x2
81
82/* This option is an alias for the closest previous non-alias option. This
83 means that it will be displayed in the same help entry, and will inherit
84 fields other than NAME and KEY from the aliased option. */
85#define OPTION_ALIAS 0x4
86
87/* This option isn't actually an option (and so should be ignored by the
88 actual option parser), but rather an arbitrary piece of documentation that
89 should be displayed in much the same manner as the options. If this flag
90 is set, then the option NAME field is displayed unmodified (e.g., no `--'
91 prefix is added) at the left-margin (where a *short* option would normally
92 be displayed), and the documentation string in the normal place. For
93 purposes of sorting, any leading whitespace and punctuation is ignored,
94 except that if the first non-whitespace character is not `-', this entry
95 is displayed after all options (and OPTION_DOC entries with a leading `-')
96 in the same group. */
97#define OPTION_DOC 0x8
98
99/* This option shouldn't be included in `long' usage messages (but is still
100 included in help messages). This is mainly intended for options that are
101 completely documented in an argp's ARGS_DOC field, in which case including
102 the option in the generic usage list would be redundant. For instance,
103 if ARGS_DOC is "FOO BAR\n-x BLAH", and the `-x' option's purpose is to
104 distinguish these two cases, -x should probably be marked
105 OPTION_NO_USAGE. */
106#define OPTION_NO_USAGE 0x10
107
108struct argp; /* fwd declare this type */
109struct argp_state; /* " */
110struct argp_child; /* " */
111
112/* The type of a pointer to an argp parsing function. */
113typedef error_t (*argp_parser_t) (int __key, char *__arg,
114 struct argp_state *__state);
115
116/* What to return for unrecognized keys. For special ARGP_KEY_ keys, such
117 returns will simply be ignored. For user keys, this error will be turned
118 into EINVAL (if the call to argp_parse is such that errors are propagated
119 back to the user instead of exiting); returning EINVAL itself would result
120 in an immediate stop to parsing in *all* cases. */
121#define ARGP_ERR_UNKNOWN E2BIG /* Hurd should never need E2BIG. XXX */
122
123/* Special values for the KEY argument to an argument parsing function.
124 ARGP_ERR_UNKNOWN should be returned if they aren't understood.
125
126 The sequence of keys to a parsing function is either (where each
127 uppercased word should be prefixed by `ARGP_KEY_' and opt is a user key):
128
129 INIT opt... NO_ARGS END SUCCESS -- No non-option arguments at all
130 or INIT (opt | ARG)... END SUCCESS -- All non-option args parsed
131 or INIT (opt | ARG)... SUCCESS -- Some non-option arg unrecognized
132
133 The third case is where every parser returned ARGP_KEY_UNKNOWN for an
134 argument, in which case parsing stops at that argument (returning the
135 unparsed arguments to the caller of argp_parse if requested, or stopping
136 with an error message if not).
137
138 If an error occurs (either detected by argp, or because the parsing
139 function returned an error value), then the parser is called with
140 ARGP_KEY_ERROR, and no further calls are made. */
141
142/* This is not an option at all, but rather a command line argument. If a
143 parser receiving this key returns success, the fact is recorded, and the
144 ARGP_KEY_NO_ARGS case won't be used. HOWEVER, if while processing the
145 argument, a parser function decrements the NEXT field of the state it's
146 passed, the option won't be considered processed; this is to allow you to
147 actually modify the argument (perhaps into an option), and have it
148 processed again. */
149#define ARGP_KEY_ARG 0
150/* There are remaining arguments not parsed by any parser, which may be found
151 starting at (STATE->argv + STATE->next). If success is returned, but
152 STATE->next left untouched, it's assumed that all arguments were consume,
153 otherwise, the parser should adjust STATE->next to reflect any arguments
154 consumed. */
155#define ARGP_KEY_ARGS 0x1000006
156/* There are no more command line arguments at all. */
157#define ARGP_KEY_END 0x1000001
158/* Because it's common to want to do some special processing if there aren't
159 any non-option args, user parsers are called with this key if they didn't
160 successfully process any non-option arguments. Called just before
161 ARGP_KEY_END (where more general validity checks on previously parsed
162 arguments can take place). */
163#define ARGP_KEY_NO_ARGS 0x1000002
164/* Passed in before any parsing is done. Afterwards, the values of each
165 element of the CHILD_INPUT field, if any, in the state structure is
166 copied to each child's state to be the initial value of the INPUT field. */
167#define ARGP_KEY_INIT 0x1000003
168/* Use after all other keys, including SUCCESS & END. */
169#define ARGP_KEY_FINI 0x1000007
170/* Passed in when parsing has successfully been completed (even if there are
171 still arguments remaining). */
172#define ARGP_KEY_SUCCESS 0x1000004
173/* Passed in if an error occurs. */
174#define ARGP_KEY_ERROR 0x1000005
175
176/* An argp structure contains a set of options declarations, a function to
177 deal with parsing one, documentation string, a possible vector of child
178 argp's, and perhaps a function to filter help output. When actually
179 parsing options, getopt is called with the union of all the argp
180 structures chained together through their CHILD pointers, with conflicts
181 being resolved in favor of the first occurrence in the chain. */
182struct argp
183{
184 /* An array of argp_option structures, terminated by an entry with both
185 NAME and KEY having a value of 0. */
186 const struct argp_option *options;
187
188 /* What to do with an option from this structure. KEY is the key
189 associated with the option, and ARG is any associated argument (NULL if
190 none was supplied). If KEY isn't understood, ARGP_ERR_UNKNOWN should be
191 returned. If a non-zero, non-ARGP_ERR_UNKNOWN value is returned, then
192 parsing is stopped immediately, and that value is returned from
193 argp_parse(). For special (non-user-supplied) values of KEY, see the
194 ARGP_KEY_ definitions below. */
195 argp_parser_t parser;
196
197 /* A string describing what other arguments are wanted by this program. It
198 is only used by argp_usage to print the `Usage:' message. If it
199 contains newlines, the strings separated by them are considered
200 alternative usage patterns, and printed on separate lines (lines after
201 the first are prefix by ` or: ' instead of `Usage:'). */
202 const char *args_doc;
203
204 /* If non-NULL, a string containing extra text to be printed before and
205 after the options in a long help message (separated by a vertical tab
206 `\v' character). */
207 const char *doc;
208
209 /* A vector of argp_children structures, terminated by a member with a 0
210 argp field, pointing to child argps should be parsed with this one. Any
211 conflicts are resolved in favor of this argp, or early argps in the
212 CHILDREN list. This field is useful if you use libraries that supply
213 their own argp structure, which you want to use in conjunction with your
214 own. */
215 const struct argp_child *children;
216
217 /* If non-zero, this should be a function to filter the output of help
218 messages. KEY is either a key from an option, in which case TEXT is
219 that option's help text, or a special key from the ARGP_KEY_HELP_
220 defines, below, describing which other help text TEXT is. The function
221 should return either TEXT, if it should be used as-is, a replacement
222 string, which should be malloced, and will be freed by argp, or NULL,
223 meaning `print nothing'. The value for TEXT is *after* any translation
224 has been done, so if any of the replacement text also needs translation,
225 that should be done by the filter function. INPUT is either the input
226 supplied to argp_parse, or NULL, if argp_help was called directly. */
227 char *(*help_filter) (int __key, const char *__text, void *__input);
228
229 /* If non-zero the strings used in the argp library are translated using
230 the domain described by this string. Otherwise the currently installed
231 default domain is used. */
232 const char *argp_domain;
233};
234
235/* Possible KEY arguments to a help filter function. */
236#define ARGP_KEY_HELP_PRE_DOC 0x2000001 /* Help text preceeding options. */
237#define ARGP_KEY_HELP_POST_DOC 0x2000002 /* Help text following options. */
238#define ARGP_KEY_HELP_HEADER 0x2000003 /* Option header string. */
239#define ARGP_KEY_HELP_EXTRA 0x2000004 /* After all other documentation;
240 TEXT is NULL for this key. */
241/* Explanatory note emitted when duplicate option arguments have been
242 suppressed. */
243#define ARGP_KEY_HELP_DUP_ARGS_NOTE 0x2000005
244#define ARGP_KEY_HELP_ARGS_DOC 0x2000006 /* Argument doc string. */
245
246/* When an argp has a non-zero CHILDREN field, it should point to a vector of
247 argp_child structures, each of which describes a subsidiary argp. */
248struct argp_child
249{
250 /* The child parser. */
251 const struct argp *argp;
252
253 /* Flags for this child. */
254 int flags;
255
256 /* If non-zero, an optional header to be printed in help output before the
257 child options. As a side-effect, a non-zero value forces the child
258 options to be grouped together; to achieve this effect without actually
259 printing a header string, use a value of "". */
260 const char *header;
261
262 /* Where to group the child options relative to the other (`consolidated')
263 options in the parent argp; the values are the same as the GROUP field
264 in argp_option structs, but all child-groupings follow parent options at
265 a particular group level. If both this field and HEADER are zero, then
266 they aren't grouped at all, but rather merged with the parent options
267 (merging the child's grouping levels with the parents). */
268 int group;
269};
270
271/* Parsing state. This is provided to parsing functions called by argp,
272 which may examine and, as noted, modify fields. */
273struct argp_state
274{
275 /* The top level ARGP being parsed. */
276 const struct argp *root_argp;
277
278 /* The argument vector being parsed. May be modified. */
279 int argc;
280 char **argv;
281
282 /* The index in ARGV of the next arg that to be parsed. May be modified. */
283 int next;
284
285 /* The flags supplied to argp_parse. May be modified. */
286 unsigned flags;
287
288 /* While calling a parsing function with a key of ARGP_KEY_ARG, this is the
289 number of the current arg, starting at zero, and incremented after each
290 such call returns. At all other times, this is the number of such
291 arguments that have been processed. */
292 unsigned arg_num;
293
294 /* If non-zero, the index in ARGV of the first argument following a special
295 `--' argument (which prevents anything following being interpreted as an
296 option). Only set once argument parsing has proceeded past this point. */
297 int quoted;
298
299 /* An arbitrary pointer passed in from the user. */
300 void *input;
301 /* Values to pass to child parsers. This vector will be the same length as
302 the number of children for the current parser. */
303 void **child_inputs;
304
305 /* For the parser's use. Initialized to 0. */
306 void *hook;
307
308 /* The name used when printing messages. This is initialized to ARGV[0],
309 or PROGRAM_INVOCATION_NAME if that is unavailable. */
310 char *name;
311
312 /* Streams used when argp prints something. */
313 FILE *err_stream; /* For errors; initialized to stderr. */
314 FILE *out_stream; /* For information; initialized to stdout. */
315
316 void *pstate; /* Private, for use by argp. */
317};
318
319/* Flags for argp_parse (note that the defaults are those that are
320 convenient for program command line parsing): */
321
322/* Don't ignore the first element of ARGV. Normally (and always unless
323 ARGP_NO_ERRS is set) the first element of the argument vector is
324 skipped for option parsing purposes, as it corresponds to the program name
325 in a command line. */
326#define ARGP_PARSE_ARGV0 0x01
327
328/* Don't print error messages for unknown options to stderr; unless this flag
329 is set, ARGP_PARSE_ARGV0 is ignored, as ARGV[0] is used as the program
330 name in the error messages. This flag implies ARGP_NO_EXIT (on the
331 assumption that silent exiting upon errors is bad behaviour). */
332#define ARGP_NO_ERRS 0x02
333
334/* Don't parse any non-option args. Normally non-option args are parsed by
335 calling the parse functions with a key of ARGP_KEY_ARG, and the actual arg
336 as the value. Since it's impossible to know which parse function wants to
337 handle it, each one is called in turn, until one returns 0 or an error
338 other than ARGP_ERR_UNKNOWN; if an argument is handled by no one, the
339 argp_parse returns prematurely (but with a return value of 0). If all
340 args have been parsed without error, all parsing functions are called one
341 last time with a key of ARGP_KEY_END. This flag needn't normally be set,
342 as the normal behavior is to stop parsing as soon as some argument can't
343 be handled. */
344#define ARGP_NO_ARGS 0x04
345
346/* Parse options and arguments in the same order they occur on the command
347 line -- normally they're rearranged so that all options come first. */
348#define ARGP_IN_ORDER 0x08
349
350/* Don't provide the standard long option --help, which causes usage and
351 option help information to be output to stdout, and exit (0) called. */
352#define ARGP_NO_HELP 0x10
353
354/* Don't exit on errors (they may still result in error messages). */
355#define ARGP_NO_EXIT 0x20
356
357/* Use the gnu getopt `long-only' rules for parsing arguments. */
358#define ARGP_LONG_ONLY 0x40
359
360/* Turns off any message-printing/exiting options. */
361#define ARGP_SILENT (ARGP_NO_EXIT | ARGP_NO_ERRS | ARGP_NO_HELP)
362
363/* Parse the options strings in ARGC & ARGV according to the options in ARGP.
364 FLAGS is one of the ARGP_ flags above. If ARG_INDEX is non-NULL, the
365 index in ARGV of the first unparsed option is returned in it. If an
366 unknown option is present, ARGP_ERR_UNKNOWN is returned; if some parser
367 routine returned a non-zero value, it is returned; otherwise 0 is
368 returned. This function may also call exit unless the ARGP_NO_HELP flag
369 is set. INPUT is a pointer to a value to be passed in to the parser. */
370extern error_t argp_parse (const struct argp *__restrict __argp,
371 int __argc, char **__restrict __argv,
372 unsigned __flags, int *__restrict __arg_index,
373 void *__restrict __input);
374extern error_t __argp_parse (const struct argp *__restrict __argp,
375 int __argc, char **__restrict __argv,
376 unsigned __flags, int *__restrict __arg_index,
377 void *__restrict __input);
378
379/* Global variables. */
380
381/* If defined or set by the user program to a non-zero value, then a default
382 option --version is added (unless the ARGP_NO_HELP flag is used), which
383 will print this string followed by a newline and exit (unless the
384 ARGP_NO_EXIT flag is used). Overridden by ARGP_PROGRAM_VERSION_HOOK. */
385extern const char *argp_program_version;
386
387/* If defined or set by the user program to a non-zero value, then a default
388 option --version is added (unless the ARGP_NO_HELP flag is used), which
389 calls this function with a stream to print the version to and a pointer to
390 the current parsing state, and then exits (unless the ARGP_NO_EXIT flag is
391 used). This variable takes precedent over ARGP_PROGRAM_VERSION. */
392extern void (*argp_program_version_hook) (FILE *__restrict __stream,
393 struct argp_state *__restrict
394 __state);
395
396/* If defined or set by the user program, it should point to string that is
397 the bug-reporting address for the program. It will be printed by
398 argp_help if the ARGP_HELP_BUG_ADDR flag is set (as it is by various
399 standard help messages), embedded in a sentence that says something like
400 `Report bugs to ADDR.'. */
401extern const char *argp_program_bug_address;
402
403/* The exit status that argp will use when exiting due to a parsing error.
404 If not defined or set by the user program, this defaults to EX_USAGE from
405 <sysexits.h>. */
406extern error_t argp_err_exit_status;
407
408/* Flags for argp_help. */
409#define ARGP_HELP_USAGE 0x01 /* a Usage: message. */
410#define ARGP_HELP_SHORT_USAGE 0x02 /* " but don't actually print options. */
411#define ARGP_HELP_SEE 0x04 /* a `Try ... for more help' message. */
412#define ARGP_HELP_LONG 0x08 /* a long help message. */
413#define ARGP_HELP_PRE_DOC 0x10 /* doc string preceding long help. */
414#define ARGP_HELP_POST_DOC 0x20 /* doc string following long help. */
415#define ARGP_HELP_DOC (ARGP_HELP_PRE_DOC | ARGP_HELP_POST_DOC)
416#define ARGP_HELP_BUG_ADDR 0x40 /* bug report address */
417#define ARGP_HELP_LONG_ONLY 0x80 /* modify output appropriately to
418 reflect ARGP_LONG_ONLY mode. */
419
420/* These ARGP_HELP flags are only understood by argp_state_help. */
421#define ARGP_HELP_EXIT_ERR 0x100 /* Call exit(1) instead of returning. */
422#define ARGP_HELP_EXIT_OK 0x200 /* Call exit(0) instead of returning. */
423
424/* The standard thing to do after a program command line parsing error, if an
425 error message has already been printed. */
426#define ARGP_HELP_STD_ERR \
427 (ARGP_HELP_SEE | ARGP_HELP_EXIT_ERR)
428/* The standard thing to do after a program command line parsing error, if no
429 more specific error message has been printed. */
430#define ARGP_HELP_STD_USAGE \
431 (ARGP_HELP_SHORT_USAGE | ARGP_HELP_SEE | ARGP_HELP_EXIT_ERR)
432/* The standard thing to do in response to a --help option. */
433#define ARGP_HELP_STD_HELP \
434 (ARGP_HELP_SHORT_USAGE | ARGP_HELP_LONG | ARGP_HELP_EXIT_OK \
435 | ARGP_HELP_DOC | ARGP_HELP_BUG_ADDR)
436
437/* Output a usage message for ARGP to STREAM. FLAGS are from the set
438 ARGP_HELP_*. */
439extern void argp_help (const struct argp *__restrict __argp,
440 FILE *__restrict __stream,
441 unsigned __flags, char *__restrict __name);
442extern void __argp_help (const struct argp *__restrict __argp,
443 FILE *__restrict __stream, unsigned __flags,
444 char *__name);
445
446/* The following routines are intended to be called from within an argp
447 parsing routine (thus taking an argp_state structure as the first
448 argument). They may or may not print an error message and exit, depending
449 on the flags in STATE -- in any case, the caller should be prepared for
450 them *not* to exit, and should return an appropiate error after calling
451 them. [argp_usage & argp_error should probably be called argp_state_...,
452 but they're used often enough that they should be short] */
453
454/* Output, if appropriate, a usage message for STATE to STREAM. FLAGS are
455 from the set ARGP_HELP_*. */
456extern void argp_state_help (const struct argp_state *__restrict __state,
457 FILE *__restrict __stream,
458 unsigned int __flags);
459extern void __argp_state_help (const struct argp_state *__restrict __state,
460 FILE *__restrict __stream,
461 unsigned int __flags);
462
463/* Possibly output the standard usage message for ARGP to stderr and exit. */
464extern void argp_usage (const struct argp_state *__state);
465extern void __argp_usage (const struct argp_state *__state);
466
467/* If appropriate, print the printf string FMT and following args, preceded
468 by the program name and `:', to stderr, and followed by a `Try ... --help'
469 message, then exit (1). */
470extern void argp_error (const struct argp_state *__restrict __state,
471 const char *__restrict __fmt, ...)
472 __attribute__ ((__format__ (__printf__, 2, 3)));
473extern void __argp_error (const struct argp_state *__restrict __state,
474 const char *__restrict __fmt, ...)
475 __attribute__ ((__format__ (__printf__, 2, 3)));
476
477/* Similar to the standard gnu error-reporting function error(), but will
478 respect the ARGP_NO_EXIT and ARGP_NO_ERRS flags in STATE, and will print
479 to STATE->err_stream. This is useful for argument parsing code that is
480 shared between program startup (when exiting is desired) and runtime
481 option parsing (when typically an error code is returned instead). The
482 difference between this function and argp_error is that the latter is for
483 *parsing errors*, and the former is for other problems that occur during
484 parsing but don't reflect a (syntactic) problem with the input. */
485extern void argp_failure (const struct argp_state *__restrict __state,
486 int __status, int __errnum,
487 const char *__restrict __fmt, ...)
488 __attribute__ ((__format__ (__printf__, 4, 5)));
489extern void __argp_failure (const struct argp_state *__restrict __state,
490 int __status, int __errnum,
491 const char *__restrict __fmt, ...)
492 __attribute__ ((__format__ (__printf__, 4, 5)));
493
494/* Returns true if the option OPT is a valid short option. */
495extern int _option_is_short (const struct argp_option *__opt) __THROW;
496extern int __option_is_short (const struct argp_option *__opt) __THROW;
497
498/* Returns true if the option OPT is in fact the last (unused) entry in an
499 options array. */
500extern int _option_is_end (const struct argp_option *__opt) __THROW;
501extern int __option_is_end (const struct argp_option *__opt) __THROW;
502
503/* Return the input field for ARGP in the parser corresponding to STATE; used
504 by the help routines. */
505extern void *_argp_input (const struct argp *__restrict __argp,
506 const struct argp_state *__restrict __state)
507 __THROW;
508extern void *__argp_input (const struct argp *__restrict __argp,
509 const struct argp_state *__restrict __state)
510 __THROW;
511
512#ifdef __USE_EXTERN_INLINES
513
514# if !(defined _LIBC && _LIBC)
515# define __argp_usage argp_usage
516# define __argp_state_help argp_state_help
517# define __option_is_short _option_is_short
518# define __option_is_end _option_is_end
519# endif
520
521# ifndef ARGP_EI
522# define ARGP_EI __extern_inline
523# endif
524
525ARGP_EI void
526__argp_usage (const struct argp_state *__state)
527{
528 __argp_state_help (__state, stderr, ARGP_HELP_STD_USAGE);
529}
530
531ARGP_EI int
532__NTH (__option_is_short (const struct argp_option *__opt))
533{
534 if (__opt->flags & OPTION_DOC)
535 return 0;
536 else
537 {
538 int __key = __opt->key;
539 return __key > 0 && __key <= UCHAR_MAX && isprint (__key);
540 }
541}
542
543ARGP_EI int
544__NTH (__option_is_end (const struct argp_option *__opt))
545{
546 return !__opt->key && !__opt->name && !__opt->doc && !__opt->group;
547}
548
549# if !(defined _LIBC && _LIBC)
550# undef __argp_usage
551# undef __argp_state_help
552# undef __option_is_short
553# undef __option_is_end
554# endif
555#endif /* Use extern inlines. */
556
557__END_DECLS
558
559#endif /* argp.h */
libc/glibc-include/argz.h created+156
...@@ -0,0 +1,156 @@
1/* Routines for dealing with '\0' separated arg vectors.
2 Copyright (C) 1995-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _ARGZ_H
20#define _ARGZ_H 1
21
22#include <features.h>
23#include <errno.h>
24#include <string.h> /* Need size_t, and strchr is called below. */
25
26__BEGIN_DECLS
27
28/* error_t may or may not be available from errno.h, depending on the
29 operating system. */
30#ifndef __error_t_defined
31# define __error_t_defined 1
32typedef int error_t;
33#endif
34
35/* Make a '\0' separated arg vector from a unix argv vector, returning it in
36 ARGZ, and the total length in LEN. If a memory allocation error occurs,
37 ENOMEM is returned, otherwise 0. The result can be destroyed using free. */
38extern error_t __argz_create (char *const __argv[], char **__restrict __argz,
39 size_t *__restrict __len) __THROW;
40extern error_t argz_create (char *const __argv[], char **__restrict __argz,
41 size_t *__restrict __len) __THROW;
42
43/* Make a '\0' separated arg vector from a SEP separated list in
44 STRING, returning it in ARGZ, and the total length in LEN. If a
45 memory allocation error occurs, ENOMEM is returned, otherwise 0.
46 The result can be destroyed using free. */
47extern error_t argz_create_sep (const char *__restrict __string,
48 int __sep, char **__restrict __argz,
49 size_t *__restrict __len) __THROW;
50
51/* Returns the number of strings in ARGZ. */
52extern size_t __argz_count (const char *__argz, size_t __len)
53 __THROW __attribute_pure__;
54extern size_t argz_count (const char *__argz, size_t __len)
55 __THROW __attribute_pure__;
56
57/* Puts pointers to each string in ARGZ into ARGV, which must be large enough
58 to hold them all. */
59extern void __argz_extract (const char *__restrict __argz, size_t __len,
60 char **__restrict __argv) __THROW;
61extern void argz_extract (const char *__restrict __argz, size_t __len,
62 char **__restrict __argv) __THROW;
63
64/* Make '\0' separated arg vector ARGZ printable by converting all the '\0's
65 except the last into the character SEP. */
66extern void __argz_stringify (char *__argz, size_t __len, int __sep) __THROW;
67extern void argz_stringify (char *__argz, size_t __len, int __sep) __THROW;
68
69/* Append BUF, of length BUF_LEN to the argz vector in ARGZ & ARGZ_LEN. */
70extern error_t argz_append (char **__restrict __argz,
71 size_t *__restrict __argz_len,
72 const char *__restrict __buf, size_t __buf_len)
73 __THROW;
74
75/* Append STR to the argz vector in ARGZ & ARGZ_LEN. */
76extern error_t argz_add (char **__restrict __argz,
77 size_t *__restrict __argz_len,
78 const char *__restrict __str) __THROW;
79
80/* Append SEP separated list in STRING to the argz vector in ARGZ &
81 ARGZ_LEN. */
82extern error_t argz_add_sep (char **__restrict __argz,
83 size_t *__restrict __argz_len,
84 const char *__restrict __string, int __delim)
85 __THROW;
86
87/* Delete ENTRY from ARGZ & ARGZ_LEN, if it appears there. */
88extern void argz_delete (char **__restrict __argz,
89 size_t *__restrict __argz_len,
90 char *__restrict __entry) __THROW;
91
92/* Insert ENTRY into ARGZ & ARGZ_LEN before BEFORE, which should be an
93 existing entry in ARGZ; if BEFORE is NULL, ENTRY is appended to the end.
94 Since ARGZ's first entry is the same as ARGZ, argz_insert (ARGZ, ARGZ_LEN,
95 ARGZ, ENTRY) will insert ENTRY at the beginning of ARGZ. If BEFORE is not
96 in ARGZ, EINVAL is returned, else if memory can't be allocated for the new
97 ARGZ, ENOMEM is returned, else 0. */
98extern error_t argz_insert (char **__restrict __argz,
99 size_t *__restrict __argz_len,
100 char *__restrict __before,
101 const char *__restrict __entry) __THROW;
102
103/* Replace any occurrences of the string STR in ARGZ with WITH, reallocating
104 ARGZ as necessary. If REPLACE_COUNT is non-zero, *REPLACE_COUNT will be
105 incremented by number of replacements performed. */
106extern error_t argz_replace (char **__restrict __argz,
107 size_t *__restrict __argz_len,
108 const char *__restrict __str,
109 const char *__restrict __with,
110 unsigned int *__restrict __replace_count);
111
112/* Returns the next entry in ARGZ & ARGZ_LEN after ENTRY, or NULL if there
113 are no more. If entry is NULL, then the first entry is returned. This
114 behavior allows two convenient iteration styles:
115
116 char *entry = 0;
117 while ((entry = argz_next (argz, argz_len, entry)))
118 ...;
119
120 or
121
122 char *entry;
123 for (entry = argz; entry; entry = argz_next (argz, argz_len, entry))
124 ...;
125*/
126extern char *__argz_next (const char *__restrict __argz, size_t __argz_len,
127 const char *__restrict __entry) __THROW;
128extern char *argz_next (const char *__restrict __argz, size_t __argz_len,
129 const char *__restrict __entry) __THROW;
130
131#ifdef __USE_EXTERN_INLINES
132__extern_inline char *
133__NTH (__argz_next (const char *__argz, size_t __argz_len,
134 const char *__entry))
135{
136 if (__entry)
137 {
138 if (__entry < __argz + __argz_len)
139 __entry = strchr (__entry, '\0') + 1;
140
141 return __entry >= __argz + __argz_len ? (char *) NULL : (char *) __entry;
142 }
143 else
144 return __argz_len > 0 ? (char *) __argz : 0;
145}
146__extern_inline char *
147__NTH (argz_next (const char *__argz, size_t __argz_len,
148 const char *__entry))
149{
150 return __argz_next (__argz, __argz_len, __entry);
151}
152#endif /* Use extern inlines. */
153
154__END_DECLS
155
156#endif /* argz.h */
libc/glibc-include/arpa/ftp.h created+105
...@@ -0,0 +1,105 @@
1/*
2 * Copyright (c) 1983, 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 4. Neither the name of the University nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * @(#)ftp.h 8.1 (Berkeley) 6/2/93
30 */
31
32#ifndef _ARPA_FTP_H
33#define _ARPA_FTP_H 1
34
35/* Definitions for FTP; see RFC-765. */
36
37/*
38 * Reply codes.
39 */
40#define PRELIM 1 /* positive preliminary */
41#define COMPLETE 2 /* positive completion */
42#define CONTINUE 3 /* positive intermediate */
43#define TRANSIENT 4 /* transient negative completion */
44#define ERROR 5 /* permanent negative completion */
45
46/*
47 * Type codes
48 */
49#define TYPE_A 1 /* ASCII */
50#define TYPE_E 2 /* EBCDIC */
51#define TYPE_I 3 /* image */
52#define TYPE_L 4 /* local byte size */
53
54#ifdef FTP_NAMES
55char *typenames[] = {"0", "ASCII", "EBCDIC", "Image", "Local" };
56#endif
57
58/*
59 * Form codes
60 */
61#define FORM_N 1 /* non-print */
62#define FORM_T 2 /* telnet format effectors */
63#define FORM_C 3 /* carriage control (ASA) */
64#ifdef FTP_NAMES
65char *formnames[] = {"0", "Nonprint", "Telnet", "Carriage-control" };
66#endif
67
68/*
69 * Structure codes
70 */
71#define STRU_F 1 /* file (no record structure) */
72#define STRU_R 2 /* record structure */
73#define STRU_P 3 /* page structure */
74#ifdef FTP_NAMES
75char *strunames[] = {"0", "File", "Record", "Page" };
76#endif
77
78/*
79 * Mode types
80 */
81#define MODE_S 1 /* stream */
82#define MODE_B 2 /* block */
83#define MODE_C 3 /* compressed */
84#ifdef FTP_NAMES
85char *modenames[] = {"0", "Stream", "Block", "Compressed" };
86#endif
87
88/*
89 * Record Tokens
90 */
91#define REC_ESC '\377' /* Record-mode Escape */
92#define REC_EOR '\001' /* Record-mode End-of-Record */
93#define REC_EOF '\002' /* Record-mode End-of-File */
94
95/*
96 * Block Header
97 */
98#define BLK_EOR 0x80 /* Block is End-of-Record */
99#define BLK_EOF 0x40 /* Block is End-of-File */
100#define BLK_ERRORS 0x20 /* Block is suspected of containing errors */
101#define BLK_RESTART 0x10 /* Block is Restart Marker */
102
103#define BLK_BYTECOUNT 2 /* Bytes in this block */
104
105#endif /* arpa/ftp.h */
libc/glibc-include/arpa/inet.h created+105
...@@ -0,0 +1,105 @@
1/* Copyright (C) 1997-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _ARPA_INET_H
19#define _ARPA_INET_H 1
20
21#include <features.h>
22#include <netinet/in.h> /* To define `struct in_addr'. */
23
24/* Type for length arguments in socket calls. */
25#ifndef __socklen_t_defined
26typedef __socklen_t socklen_t;
27# define __socklen_t_defined
28#endif
29
30__BEGIN_DECLS
31
32/* Convert Internet host address from numbers-and-dots notation in CP
33 into binary data in network byte order. */
34extern in_addr_t inet_addr (const char *__cp) __THROW;
35
36/* Return the local host address part of the Internet address in IN. */
37extern in_addr_t inet_lnaof (struct in_addr __in) __THROW;
38
39/* Make Internet host address in network byte order by combining the
40 network number NET with the local address HOST. */
41extern struct in_addr inet_makeaddr (in_addr_t __net, in_addr_t __host)
42 __THROW;
43
44/* Return network number part of the Internet address IN. */
45extern in_addr_t inet_netof (struct in_addr __in) __THROW;
46
47/* Extract the network number in network byte order from the address
48 in numbers-and-dots natation starting at CP. */
49extern in_addr_t inet_network (const char *__cp) __THROW;
50
51/* Convert Internet number in IN to ASCII representation. The return value
52 is a pointer to an internal array containing the string. */
53extern char *inet_ntoa (struct in_addr __in) __THROW;
54
55/* Convert from presentation format of an Internet number in buffer
56 starting at CP to the binary network format and store result for
57 interface type AF in buffer starting at BUF. */
58extern int inet_pton (int __af, const char *__restrict __cp,
59 void *__restrict __buf) __THROW;
60
61/* Convert a Internet address in binary network format for interface
62 type AF in buffer starting at CP to presentation form and place
63 result in buffer of length LEN astarting at BUF. */
64extern const char *inet_ntop (int __af, const void *__restrict __cp,
65 char *__restrict __buf, socklen_t __len)
66 __THROW;
67
68
69/* The following functions are not part of XNS 5.2. */
70#ifdef __USE_MISC
71/* Convert Internet host address from numbers-and-dots notation in CP
72 into binary data and store the result in the structure INP. */
73extern int inet_aton (const char *__cp, struct in_addr *__inp) __THROW;
74
75/* Format a network number NET into presentation format and place result
76 in buffer starting at BUF with length of LEN bytes. */
77extern char *inet_neta (in_addr_t __net, char *__buf, size_t __len) __THROW;
78
79/* Convert network number for interface type AF in buffer starting at
80 CP to presentation format. The result will specifiy BITS bits of
81 the number. */
82extern char *inet_net_ntop (int __af, const void *__cp, int __bits,
83 char *__buf, size_t __len) __THROW;
84
85/* Convert network number for interface type AF from presentation in
86 buffer starting at CP to network format and store result int
87 buffer starting at BUF of size LEN. */
88extern int inet_net_pton (int __af, const char *__cp,
89 void *__buf, size_t __len) __THROW;
90
91/* Convert ASCII representation in hexadecimal form of the Internet
92 address to binary form and place result in buffer of length LEN
93 starting at BUF. */
94extern unsigned int inet_nsap_addr (const char *__cp,
95 unsigned char *__buf, int __len) __THROW;
96
97/* Convert internet address in binary form in LEN bytes starting at CP
98 a presentation form and place result in BUF. */
99extern char *inet_nsap_ntoa (int __len, const unsigned char *__cp,
100 char *__buf) __THROW;
101#endif
102
103__END_DECLS
104
105#endif /* arpa/inet.h */
libc/glibc-include/arpa/nameser.h created+443
...@@ -0,0 +1,443 @@
1/*
2 * Copyright (c) 1983, 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 4. Neither the name of the University nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30/*
31 * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
32 * Copyright (c) 1996-1999 by Internet Software Consortium.
33 *
34 * Permission to use, copy, modify, and distribute this software for any
35 * purpose with or without fee is hereby granted, provided that the above
36 * copyright notice and this permission notice appear in all copies.
37 *
38 * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
39 * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
40 * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
41 * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
42 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
43 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
44 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
45 * SOFTWARE.
46 */
47
48#ifndef _ARPA_NAMESER_H_
49#define _ARPA_NAMESER_H_
50
51#include <sys/param.h>
52#include <sys/types.h>
53#include <stdint.h>
54
55/*
56 * Define constants based on RFC 883, RFC 1034, RFC 1035
57 */
58#define NS_PACKETSZ 512 /*%< default UDP packet size */
59#define NS_MAXDNAME 1025 /*%< maximum domain name */
60#define NS_MAXMSG 65535 /*%< maximum message size */
61#define NS_MAXCDNAME 255 /*%< maximum compressed domain name */
62#define NS_MAXLABEL 63 /*%< maximum length of domain label */
63#define NS_HFIXEDSZ 12 /*%< #/bytes of fixed data in header */
64#define NS_QFIXEDSZ 4 /*%< #/bytes of fixed data in query */
65#define NS_RRFIXEDSZ 10 /*%< #/bytes of fixed data in r record */
66#define NS_INT32SZ 4 /*%< #/bytes of data in a uint32_t */
67#define NS_INT16SZ 2 /*%< #/bytes of data in a uint16_t */
68#define NS_INT8SZ 1 /*%< #/bytes of data in a uint8_t */
69#define NS_INADDRSZ 4 /*%< IPv4 T_A */
70#define NS_IN6ADDRSZ 16 /*%< IPv6 T_AAAA */
71#define NS_CMPRSFLGS 0xc0 /*%< Flag bits indicating name compression. */
72#define NS_DEFAULTPORT 53 /*%< For both TCP and UDP. */
73/*
74 * These can be expanded with synonyms, just keep ns_parse.c:ns_parserecord()
75 * in synch with it.
76 */
77typedef enum __ns_sect {
78 ns_s_qd = 0, /*%< Query: Question. */
79 ns_s_zn = 0, /*%< Update: Zone. */
80 ns_s_an = 1, /*%< Query: Answer. */
81 ns_s_pr = 1, /*%< Update: Prerequisites. */
82 ns_s_ns = 2, /*%< Query: Name servers. */
83 ns_s_ud = 2, /*%< Update: Update. */
84 ns_s_ar = 3, /*%< Query|Update: Additional records. */
85 ns_s_max = 4
86} ns_sect;
87
88/*%
89 * This is a message handle. It is caller allocated and has no dynamic data.
90 * This structure is intended to be opaque to all but ns_parse.c, thus the
91 * leading _'s on the member names. Use the accessor functions, not the _'s.
92 */
93typedef struct __ns_msg {
94 const unsigned char *_msg, *_eom;
95 uint16_t _id, _flags, _counts[ns_s_max];
96 const unsigned char *_sections[ns_s_max];
97 ns_sect _sect;
98 int _rrnum;
99 const unsigned char *_msg_ptr;
100} ns_msg;
101
102/* Private data structure - do not use from outside library. */
103struct _ns_flagdata { int mask, shift; };
104extern const struct _ns_flagdata _ns_flagdata[];
105
106/* Accessor macros - this is part of the public interface. */
107
108#define ns_msg_id(handle) ((handle)._id + 0)
109#define ns_msg_base(handle) ((handle)._msg + 0)
110#define ns_msg_end(handle) ((handle)._eom + 0)
111#define ns_msg_size(handle) ((handle)._eom - (handle)._msg)
112#define ns_msg_count(handle, section) ((handle)._counts[section] + 0)
113
114/*%
115 * This is a parsed record. It is caller allocated and has no dynamic data.
116 */
117typedef struct __ns_rr {
118 char name[NS_MAXDNAME];
119 uint16_t type;
120 uint16_t rr_class;
121 uint32_t ttl;
122 uint16_t rdlength;
123 const unsigned char * rdata;
124} ns_rr;
125
126/* Accessor macros - this is part of the public interface. */
127#define ns_rr_name(rr) (((rr).name[0] != '\0') ? (rr).name : ".")
128#define ns_rr_type(rr) ((ns_type)((rr).type + 0))
129#define ns_rr_class(rr) ((ns_class)((rr).rr_class + 0))
130#define ns_rr_ttl(rr) ((rr).ttl + 0)
131#define ns_rr_rdlen(rr) ((rr).rdlength + 0)
132#define ns_rr_rdata(rr) ((rr).rdata + 0)
133
134/*%
135 * These don't have to be in the same order as in the packet flags word,
136 * and they can even overlap in some cases, but they will need to be kept
137 * in synch with ns_parse.c:ns_flagdata[].
138 */
139typedef enum __ns_flag {
140 ns_f_qr, /*%< Question/Response. */
141 ns_f_opcode, /*%< Operation code. */
142 ns_f_aa, /*%< Authoritative Answer. */
143 ns_f_tc, /*%< Truncation occurred. */
144 ns_f_rd, /*%< Recursion Desired. */
145 ns_f_ra, /*%< Recursion Available. */
146 ns_f_z, /*%< MBZ. */
147 ns_f_ad, /*%< Authentic Data (DNSSEC). */
148 ns_f_cd, /*%< Checking Disabled (DNSSEC). */
149 ns_f_rcode, /*%< Response code. */
150 ns_f_max
151} ns_flag;
152
153/*%
154 * Currently defined opcodes.
155 */
156typedef enum __ns_opcode {
157 ns_o_query = 0, /*%< Standard query. */
158 ns_o_iquery = 1, /*%< Inverse query (deprecated/unsupported). */
159 ns_o_status = 2, /*%< Name server status query (unsupported). */
160 /* Opcode 3 is undefined/reserved. */
161 ns_o_notify = 4, /*%< Zone change notification. */
162 ns_o_update = 5, /*%< Zone update message. */
163 ns_o_max = 6
164} ns_opcode;
165
166/*%
167 * Currently defined response codes.
168 */
169typedef enum __ns_rcode {
170 ns_r_noerror = 0, /*%< No error occurred. */
171 ns_r_formerr = 1, /*%< Format error. */
172 ns_r_servfail = 2, /*%< Server failure. */
173 ns_r_nxdomain = 3, /*%< Name error. */
174 ns_r_notimpl = 4, /*%< Unimplemented. */
175 ns_r_refused = 5, /*%< Operation refused. */
176 /* these are for BIND_UPDATE */
177 ns_r_yxdomain = 6, /*%< Name exists */
178 ns_r_yxrrset = 7, /*%< RRset exists */
179 ns_r_nxrrset = 8, /*%< RRset does not exist */
180 ns_r_notauth = 9, /*%< Not authoritative for zone */
181 ns_r_notzone = 10, /*%< Zone of record different from zone section */
182 ns_r_max = 11,
183 /* The following are EDNS extended rcodes */
184 ns_r_badvers = 16,
185 /* The following are TSIG errors */
186 ns_r_badsig = 16,
187 ns_r_badkey = 17,
188 ns_r_badtime = 18
189} ns_rcode;
190
191/* BIND_UPDATE */
192typedef enum __ns_update_operation {
193 ns_uop_delete = 0,
194 ns_uop_add = 1,
195 ns_uop_max = 2
196} ns_update_operation;
197
198/*%
199 * This structure is used for TSIG authenticated messages
200 */
201struct ns_tsig_key {
202 char name[NS_MAXDNAME], alg[NS_MAXDNAME];
203 unsigned char *data;
204 int len;
205};
206typedef struct ns_tsig_key ns_tsig_key;
207
208/*%
209 * This structure is used for TSIG authenticated TCP messages
210 */
211struct ns_tcp_tsig_state {
212 int counter;
213 struct dst_key *key;
214 void *ctx;
215 unsigned char sig[NS_PACKETSZ];
216 int siglen;
217};
218typedef struct ns_tcp_tsig_state ns_tcp_tsig_state;
219
220#define NS_TSIG_FUDGE 300
221#define NS_TSIG_TCP_COUNT 100
222#define NS_TSIG_ALG_HMAC_MD5 "HMAC-MD5.SIG-ALG.REG.INT"
223
224#define NS_TSIG_ERROR_NO_TSIG -10
225#define NS_TSIG_ERROR_NO_SPACE -11
226#define NS_TSIG_ERROR_FORMERR -12
227
228/*%
229 * Currently defined type values for resources and queries.
230 */
231typedef enum __ns_type
232 {
233 ns_t_invalid = 0,
234
235 ns_t_a = 1,
236 ns_t_ns = 2,
237 ns_t_md = 3,
238 ns_t_mf = 4,
239 ns_t_cname = 5,
240 ns_t_soa = 6,
241 ns_t_mb = 7,
242 ns_t_mg = 8,
243 ns_t_mr = 9,
244 ns_t_null = 10,
245 ns_t_wks = 11,
246 ns_t_ptr = 12,
247 ns_t_hinfo = 13,
248 ns_t_minfo = 14,
249 ns_t_mx = 15,
250 ns_t_txt = 16,
251 ns_t_rp = 17,
252 ns_t_afsdb = 18,
253 ns_t_x25 = 19,
254 ns_t_isdn = 20,
255 ns_t_rt = 21,
256 ns_t_nsap = 22,
257 ns_t_nsap_ptr = 23,
258 ns_t_sig = 24,
259 ns_t_key = 25,
260 ns_t_px = 26,
261 ns_t_gpos = 27,
262 ns_t_aaaa = 28,
263 ns_t_loc = 29,
264 ns_t_nxt = 30,
265 ns_t_eid = 31,
266 ns_t_nimloc = 32,
267 ns_t_srv = 33,
268 ns_t_atma = 34,
269 ns_t_naptr = 35,
270 ns_t_kx = 36,
271 ns_t_cert = 37,
272 ns_t_a6 = 38,
273 ns_t_dname = 39,
274 ns_t_sink = 40,
275 ns_t_opt = 41,
276 ns_t_apl = 42,
277 ns_t_ds = 43,
278 ns_t_sshfp = 44,
279 ns_t_ipseckey = 45,
280 ns_t_rrsig = 46,
281 ns_t_nsec = 47,
282 ns_t_dnskey = 48,
283 ns_t_dhcid = 49,
284 ns_t_nsec3 = 50,
285 ns_t_nsec3param = 51,
286 ns_t_tlsa = 52,
287 ns_t_smimea = 53,
288 ns_t_hip = 55,
289 ns_t_ninfo = 56,
290 ns_t_rkey = 57,
291 ns_t_talink = 58,
292 ns_t_cds = 59,
293 ns_t_cdnskey = 60,
294 ns_t_openpgpkey = 61,
295 ns_t_csync = 62,
296 ns_t_spf = 99,
297 ns_t_uinfo = 100,
298 ns_t_uid = 101,
299 ns_t_gid = 102,
300 ns_t_unspec = 103,
301 ns_t_nid = 104,
302 ns_t_l32 = 105,
303 ns_t_l64 = 106,
304 ns_t_lp = 107,
305 ns_t_eui48 = 108,
306 ns_t_eui64 = 109,
307 ns_t_tkey = 249,
308 ns_t_tsig = 250,
309 ns_t_ixfr = 251,
310 ns_t_axfr = 252,
311 ns_t_mailb = 253,
312 ns_t_maila = 254,
313 ns_t_any = 255,
314 ns_t_uri = 256,
315 ns_t_caa = 257,
316 ns_t_avc = 258,
317 ns_t_ta = 32768,
318 ns_t_dlv = 32769,
319
320 ns_t_max = 65536
321 } ns_type;
322
323/*%
324 * Values for class field
325 */
326typedef enum __ns_class {
327 ns_c_invalid = 0, /*%< Cookie. */
328 ns_c_in = 1, /*%< Internet. */
329 ns_c_2 = 2, /*%< unallocated/unsupported. */
330 ns_c_chaos = 3, /*%< MIT Chaos-net. */
331 ns_c_hs = 4, /*%< MIT Hesiod. */
332 /* Query class values which do not appear in resource records */
333 ns_c_none = 254, /*%< for prereq. sections in update requests */
334 ns_c_any = 255, /*%< Wildcard match. */
335 ns_c_max = 65536
336} ns_class;
337
338/* Certificate type values in CERT resource records. */
339typedef enum __ns_cert_types {
340 cert_t_pkix = 1, /*%< PKIX (X.509v3) */
341 cert_t_spki = 2, /*%< SPKI */
342 cert_t_pgp = 3, /*%< PGP */
343 cert_t_url = 253, /*%< URL private type */
344 cert_t_oid = 254 /*%< OID private type */
345} ns_cert_types;
346
347/*%
348 * EDNS0 extended flags and option codes, host order.
349 */
350#define NS_OPT_DNSSEC_OK 0x8000U
351#define NS_OPT_NSID 3
352
353/*%
354 * Inline versions of get/put short/long. Pointer is advanced.
355 */
356#define NS_GET16(s, cp) do { \
357 const unsigned char *t_cp = (const unsigned char *)(cp); \
358 (s) = ((uint16_t)t_cp[0] << 8) \
359 | ((uint16_t)t_cp[1]) \
360 ; \
361 (cp) += NS_INT16SZ; \
362} while (0)
363
364#define NS_GET32(l, cp) do { \
365 const unsigned char *t_cp = (const unsigned char *)(cp); \
366 (l) = ((uint32_t)t_cp[0] << 24) \
367 | ((uint32_t)t_cp[1] << 16) \
368 | ((uint32_t)t_cp[2] << 8) \
369 | ((uint32_t)t_cp[3]) \
370 ; \
371 (cp) += NS_INT32SZ; \
372} while (0)
373
374#define NS_PUT16(s, cp) do { \
375 uint16_t t_s = (uint16_t)(s); \
376 unsigned char *t_cp = (unsigned char *)(cp); \
377 *t_cp++ = t_s >> 8; \
378 *t_cp = t_s; \
379 (cp) += NS_INT16SZ; \
380} while (0)
381
382#define NS_PUT32(l, cp) do { \
383 uint32_t t_l = (uint32_t)(l); \
384 unsigned char *t_cp = (unsigned char *)(cp); \
385 *t_cp++ = t_l >> 24; \
386 *t_cp++ = t_l >> 16; \
387 *t_cp++ = t_l >> 8; \
388 *t_cp = t_l; \
389 (cp) += NS_INT32SZ; \
390} while (0)
391
392__BEGIN_DECLS
393int ns_msg_getflag (ns_msg, int) __THROW;
394unsigned int ns_get16 (const unsigned char *) __THROW;
395unsigned long ns_get32 (const unsigned char *) __THROW;
396void ns_put16 (unsigned int, unsigned char *) __THROW;
397void ns_put32 (unsigned long, unsigned char *) __THROW;
398int ns_initparse (const unsigned char *, int, ns_msg *) __THROW;
399int ns_skiprr (const unsigned char *, const unsigned char *,
400 ns_sect, int) __THROW;
401int ns_parserr (ns_msg *, ns_sect, int, ns_rr *) __THROW;
402int ns_sprintrr (const ns_msg *, const ns_rr *,
403 const char *, const char *, char *, size_t)
404 __THROW;
405int ns_sprintrrf (const unsigned char *, size_t, const char *,
406 ns_class, ns_type, unsigned long,
407 const unsigned char *, size_t, const char *,
408 const char *, char *, size_t) __THROW;
409int ns_format_ttl (unsigned long, char *, size_t) __THROW;
410int ns_parse_ttl (const char *, unsigned long *) __THROW;
411uint32_t ns_datetosecs (const char *, int *) __THROW;
412int ns_name_ntol (const unsigned char *, unsigned char *, size_t)
413 __THROW;
414int ns_name_ntop (const unsigned char *, char *, size_t) __THROW;
415int ns_name_pton (const char *, unsigned char *, size_t) __THROW;
416int ns_name_unpack (const unsigned char *, const unsigned char *,
417 const unsigned char *, unsigned char *, size_t)
418 __THROW;
419int ns_name_pack (const unsigned char *, unsigned char *, int,
420 const unsigned char **, const unsigned char **)
421 __THROW;
422int ns_name_uncompress (const unsigned char *,
423 const unsigned char *,
424 const unsigned char *,
425 char *, size_t) __THROW;
426int ns_name_compress (const char *, unsigned char *, size_t,
427 const unsigned char **,
428 const unsigned char **) __THROW;
429int ns_name_skip (const unsigned char **, const unsigned char *)
430 __THROW;
431void ns_name_rollback (const unsigned char *,
432 const unsigned char **,
433 const unsigned char **) __THROW;
434int ns_samedomain (const char *, const char *) __THROW;
435int ns_subdomain (const char *, const char *) __THROW;
436int ns_makecanon (const char *, char *, size_t) __THROW;
437int ns_samename (const char *, const char *) __THROW;
438__END_DECLS
439
440#include <arpa/nameser_compat.h>
441
442#endif /* !_ARPA_NAMESER_H_ */
443/*! \file */
libc/glibc-include/arpa/nameser_compat.h created+221
...@@ -0,0 +1,221 @@
1/* Copyright (c) 1983, 1989
2 * The Regents of the University of California. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * 4. Neither the name of the University nor the names of its contributors
13 * may be used to endorse or promote products derived from this software
14 * without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#ifndef _ARPA_NAMESER_COMPAT_
30#define _ARPA_NAMESER_COMPAT_
31
32#include <endian.h>
33
34/*%
35 * Structure for query header. The order of the fields is machine- and
36 * compiler-dependent, depending on the byte/bit order and the layout
37 * of bit fields. We use bit fields only in int variables, as this
38 * is all ANSI requires. This requires a somewhat confusing rearrangement.
39 */
40
41typedef struct {
42 unsigned id :16; /*%< query identification number */
43#if __BYTE_ORDER == __BIG_ENDIAN
44 /* fields in third byte */
45 unsigned qr: 1; /*%< response flag */
46 unsigned opcode: 4; /*%< purpose of message */
47 unsigned aa: 1; /*%< authoritive answer */
48 unsigned tc: 1; /*%< truncated message */
49 unsigned rd: 1; /*%< recursion desired */
50 /* fields in fourth byte */
51 unsigned ra: 1; /*%< recursion available */
52 unsigned unused :1; /*%< unused bits (MBZ as of 4.9.3a3) */
53 unsigned ad: 1; /*%< authentic data from named */
54 unsigned cd: 1; /*%< checking disabled by resolver */
55 unsigned rcode :4; /*%< response code */
56#endif
57#if __BYTE_ORDER == __LITTLE_ENDIAN || __BYTE_ORDER == __PDP_ENDIAN
58 /* fields in third byte */
59 unsigned rd :1; /*%< recursion desired */
60 unsigned tc :1; /*%< truncated message */
61 unsigned aa :1; /*%< authoritive answer */
62 unsigned opcode :4; /*%< purpose of message */
63 unsigned qr :1; /*%< response flag */
64 /* fields in fourth byte */
65 unsigned rcode :4; /*%< response code */
66 unsigned cd: 1; /*%< checking disabled by resolver */
67 unsigned ad: 1; /*%< authentic data from named */
68 unsigned unused :1; /*%< unused bits (MBZ as of 4.9.3a3) */
69 unsigned ra :1; /*%< recursion available */
70#endif
71 /* remaining bytes */
72 unsigned qdcount :16; /*%< number of question entries */
73 unsigned ancount :16; /*%< number of answer entries */
74 unsigned nscount :16; /*%< number of authority entries */
75 unsigned arcount :16; /*%< number of resource entries */
76} HEADER;
77
78#define PACKETSZ NS_PACKETSZ
79#define MAXDNAME NS_MAXDNAME
80#define MAXCDNAME NS_MAXCDNAME
81#define MAXLABEL NS_MAXLABEL
82#define HFIXEDSZ NS_HFIXEDSZ
83#define QFIXEDSZ NS_QFIXEDSZ
84#define RRFIXEDSZ NS_RRFIXEDSZ
85#define INT32SZ NS_INT32SZ
86#define INT16SZ NS_INT16SZ
87#define INT8SZ NS_INT8SZ
88#define INADDRSZ NS_INADDRSZ
89#define IN6ADDRSZ NS_IN6ADDRSZ
90#define INDIR_MASK NS_CMPRSFLGS
91#define NAMESERVER_PORT NS_DEFAULTPORT
92
93#define S_ZONE ns_s_zn
94#define S_PREREQ ns_s_pr
95#define S_UPDATE ns_s_ud
96#define S_ADDT ns_s_ar
97
98#define QUERY ns_o_query
99#define IQUERY ns_o_iquery
100#define STATUS ns_o_status
101#define NS_NOTIFY_OP ns_o_notify
102#define NS_UPDATE_OP ns_o_update
103
104#define NOERROR ns_r_noerror
105#define FORMERR ns_r_formerr
106#define SERVFAIL ns_r_servfail
107#define NXDOMAIN ns_r_nxdomain
108#define NOTIMP ns_r_notimpl
109#define REFUSED ns_r_refused
110#define YXDOMAIN ns_r_yxdomain
111#define YXRRSET ns_r_yxrrset
112#define NXRRSET ns_r_nxrrset
113#define NOTAUTH ns_r_notauth
114#define NOTZONE ns_r_notzone
115/*#define BADSIG ns_r_badsig*/
116/*#define BADKEY ns_r_badkey*/
117/*#define BADTIME ns_r_badtime*/
118
119
120#define DELETE ns_uop_delete
121#define ADD ns_uop_add
122
123#define T_A ns_t_a
124#define T_NS ns_t_ns
125#define T_MD ns_t_md
126#define T_MF ns_t_mf
127#define T_CNAME ns_t_cname
128#define T_SOA ns_t_soa
129#define T_MB ns_t_mb
130#define T_MG ns_t_mg
131#define T_MR ns_t_mr
132#define T_NULL ns_t_null
133#define T_WKS ns_t_wks
134#define T_PTR ns_t_ptr
135#define T_HINFO ns_t_hinfo
136#define T_MINFO ns_t_minfo
137#define T_MX ns_t_mx
138#define T_TXT ns_t_txt
139#define T_RP ns_t_rp
140#define T_AFSDB ns_t_afsdb
141#define T_X25 ns_t_x25
142#define T_ISDN ns_t_isdn
143#define T_RT ns_t_rt
144#define T_NSAP ns_t_nsap
145#define T_NSAP_PTR ns_t_nsap_ptr
146#define T_SIG ns_t_sig
147#define T_KEY ns_t_key
148#define T_PX ns_t_px
149#define T_GPOS ns_t_gpos
150#define T_AAAA ns_t_aaaa
151#define T_LOC ns_t_loc
152#define T_NXT ns_t_nxt
153#define T_EID ns_t_eid
154#define T_NIMLOC ns_t_nimloc
155#define T_SRV ns_t_srv
156#define T_ATMA ns_t_atma
157#define T_NAPTR ns_t_naptr
158#define T_KX ns_t_kx
159#define T_CERT ns_t_cert
160#define T_A6 ns_t_a6
161#define T_DNAME ns_t_dname
162#define T_SINK ns_t_sink
163#define T_OPT ns_t_opt
164#define T_APL ns_t_apl
165#define T_DS ns_t_ds
166#define T_SSHFP ns_t_sshfp
167#define T_IPSECKEY ns_t_ipseckey
168#define T_RRSIG ns_t_rrsig
169#define T_NSEC ns_t_nsec
170#define T_DNSKEY ns_t_dnskey
171#define T_DHCID ns_t_dhcid
172#define T_NSEC3 ns_t_nsec3
173#define T_NSEC3PARAM ns_t_nsec3param
174#define T_TLSA ns_t_tlsa
175#define T_SMIMEA ns_t_smimea
176#define T_HIP ns_t_hip
177#define T_NINFO ns_t_ninfo
178#define T_RKEY ns_t_rkey
179#define T_TALINK ns_t_talink
180#define T_CDS ns_t_cds
181#define T_CDNSKEY ns_t_cdnskey
182#define T_OPENPGPKEY ns_t_openpgpkey
183#define T_CSYNC ns_t_csync
184#define T_SPF ns_t_spf
185#define T_UINFO ns_t_uinfo
186#define T_UID ns_t_uid
187#define T_GID ns_t_gid
188#define T_UNSPEC ns_t_unspec
189#define T_NID ns_t_nid
190#define T_L32 ns_t_l32
191#define T_L64 ns_t_l64
192#define T_LP ns_t_lp
193#define T_EUI48 ns_t_eui48
194#define T_EUI64 ns_t_eui64
195#define T_TKEY ns_t_tkey
196#define T_TSIG ns_t_tsig
197#define T_IXFR ns_t_ixfr
198#define T_AXFR ns_t_axfr
199#define T_MAILB ns_t_mailb
200#define T_MAILA ns_t_maila
201#define T_ANY ns_t_any
202#define T_URI ns_t_uri
203#define T_CAA ns_t_caa
204#define T_AVC ns_t_avc
205#define T_TA ns_t_ta
206#define T_DLV ns_t_dlv
207
208#define C_IN ns_c_in
209#define C_CHAOS ns_c_chaos
210#define C_HS ns_c_hs
211/* BIND_UPDATE */
212#define C_NONE ns_c_none
213#define C_ANY ns_c_any
214
215#define GETSHORT NS_GET16
216#define GETLONG NS_GET32
217#define PUTSHORT NS_PUT16
218#define PUTLONG NS_PUT32
219
220#endif /* _ARPA_NAMESER_COMPAT_ */
221/*! \file */
libc/glibc-include/arpa/telnet.h created+316
...@@ -0,0 +1,316 @@
1/*
2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 4. Neither the name of the University nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * @(#)telnet.h 8.2 (Berkeley) 12/15/93
30 */
31
32#ifndef _ARPA_TELNET_H
33#define _ARPA_TELNET_H 1
34
35/*
36 * Definitions for the TELNET protocol.
37 */
38#define IAC 255 /* interpret as command: */
39#define DONT 254 /* you are not to use option */
40#define DO 253 /* please, you use option */
41#define WONT 252 /* I won't use option */
42#define WILL 251 /* I will use option */
43#define SB 250 /* interpret as subnegotiation */
44#define GA 249 /* you may reverse the line */
45#define EL 248 /* erase the current line */
46#define EC 247 /* erase the current character */
47#define AYT 246 /* are you there */
48#define AO 245 /* abort output--but let prog finish */
49#define IP 244 /* interrupt process--permanently */
50#define BREAK 243 /* break */
51#define DM 242 /* data mark--for connect. cleaning */
52#define NOP 241 /* nop */
53#define SE 240 /* end sub negotiation */
54#define EOR 239 /* end of record (transparent mode) */
55#define ABORT 238 /* Abort process */
56#define SUSP 237 /* Suspend process */
57#define xEOF 236 /* End of file: EOF is already used... */
58
59#define SYNCH 242 /* for telfunc calls */
60
61#ifdef TELCMDS
62char *telcmds[] = {
63 "EOF", "SUSP", "ABORT", "EOR",
64 "SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC",
65 "EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC", 0,
66};
67#else
68extern char *telcmds[];
69#endif
70
71#define TELCMD_FIRST xEOF
72#define TELCMD_LAST IAC
73#define TELCMD_OK(x) ((unsigned int)(x) <= TELCMD_LAST && \
74 (unsigned int)(x) >= TELCMD_FIRST)
75#define TELCMD(x) telcmds[(x)-TELCMD_FIRST]
76
77/* telnet options */
78#define TELOPT_BINARY 0 /* 8-bit data path */
79#define TELOPT_ECHO 1 /* echo */
80#define TELOPT_RCP 2 /* prepare to reconnect */
81#define TELOPT_SGA 3 /* suppress go ahead */
82#define TELOPT_NAMS 4 /* approximate message size */
83#define TELOPT_STATUS 5 /* give status */
84#define TELOPT_TM 6 /* timing mark */
85#define TELOPT_RCTE 7 /* remote controlled transmission and echo */
86#define TELOPT_NAOL 8 /* negotiate about output line width */
87#define TELOPT_NAOP 9 /* negotiate about output page size */
88#define TELOPT_NAOCRD 10 /* negotiate about CR disposition */
89#define TELOPT_NAOHTS 11 /* negotiate about horizontal tabstops */
90#define TELOPT_NAOHTD 12 /* negotiate about horizontal tab disposition */
91#define TELOPT_NAOFFD 13 /* negotiate about formfeed disposition */
92#define TELOPT_NAOVTS 14 /* negotiate about vertical tab stops */
93#define TELOPT_NAOVTD 15 /* negotiate about vertical tab disposition */
94#define TELOPT_NAOLFD 16 /* negotiate about output LF disposition */
95#define TELOPT_XASCII 17 /* extended ascii character set */
96#define TELOPT_LOGOUT 18 /* force logout */
97#define TELOPT_BM 19 /* byte macro */
98#define TELOPT_DET 20 /* data entry terminal */
99#define TELOPT_SUPDUP 21 /* supdup protocol */
100#define TELOPT_SUPDUPOUTPUT 22 /* supdup output */
101#define TELOPT_SNDLOC 23 /* send location */
102#define TELOPT_TTYPE 24 /* terminal type */
103#define TELOPT_EOR 25 /* end or record */
104#define TELOPT_TUID 26 /* TACACS user identification */
105#define TELOPT_OUTMRK 27 /* output marking */
106#define TELOPT_TTYLOC 28 /* terminal location number */
107#define TELOPT_3270REGIME 29 /* 3270 regime */
108#define TELOPT_X3PAD 30 /* X.3 PAD */
109#define TELOPT_NAWS 31 /* window size */
110#define TELOPT_TSPEED 32 /* terminal speed */
111#define TELOPT_LFLOW 33 /* remote flow control */
112#define TELOPT_LINEMODE 34 /* Linemode option */
113#define TELOPT_XDISPLOC 35 /* X Display Location */
114#define TELOPT_OLD_ENVIRON 36 /* Old - Environment variables */
115#define TELOPT_AUTHENTICATION 37/* Authenticate */
116#define TELOPT_ENCRYPT 38 /* Encryption option */
117#define TELOPT_NEW_ENVIRON 39 /* New - Environment variables */
118#define TELOPT_EXOPL 255 /* extended-options-list */
119
120
121#define NTELOPTS (1+TELOPT_NEW_ENVIRON)
122#ifdef TELOPTS
123char *telopts[NTELOPTS+1] = {
124 "BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME",
125 "STATUS", "TIMING MARK", "RCTE", "NAOL", "NAOP",
126 "NAOCRD", "NAOHTS", "NAOHTD", "NAOFFD", "NAOVTS",
127 "NAOVTD", "NAOLFD", "EXTEND ASCII", "LOGOUT", "BYTE MACRO",
128 "DATA ENTRY TERMINAL", "SUPDUP", "SUPDUP OUTPUT",
129 "SEND LOCATION", "TERMINAL TYPE", "END OF RECORD",
130 "TACACS UID", "OUTPUT MARKING", "TTYLOC",
131 "3270 REGIME", "X.3 PAD", "NAWS", "TSPEED", "LFLOW",
132 "LINEMODE", "XDISPLOC", "OLD-ENVIRON", "AUTHENTICATION",
133 "ENCRYPT", "NEW-ENVIRON",
134 0,
135};
136#define TELOPT_FIRST TELOPT_BINARY
137#define TELOPT_LAST TELOPT_NEW_ENVIRON
138#define TELOPT_OK(x) ((unsigned int)(x) <= TELOPT_LAST)
139#define TELOPT(x) telopts[(x)-TELOPT_FIRST]
140#endif
141
142/* sub-option qualifiers */
143#define TELQUAL_IS 0 /* option is... */
144#define TELQUAL_SEND 1 /* send option */
145#define TELQUAL_INFO 2 /* ENVIRON: informational version of IS */
146#define TELQUAL_REPLY 2 /* AUTHENTICATION: client version of IS */
147#define TELQUAL_NAME 3 /* AUTHENTICATION: client version of IS */
148
149#define LFLOW_OFF 0 /* Disable remote flow control */
150#define LFLOW_ON 1 /* Enable remote flow control */
151#define LFLOW_RESTART_ANY 2 /* Restart output on any char */
152#define LFLOW_RESTART_XON 3 /* Restart output only on XON */
153
154/*
155 * LINEMODE suboptions
156 */
157
158#define LM_MODE 1
159#define LM_FORWARDMASK 2
160#define LM_SLC 3
161
162#define MODE_EDIT 0x01
163#define MODE_TRAPSIG 0x02
164#define MODE_ACK 0x04
165#define MODE_SOFT_TAB 0x08
166#define MODE_LIT_ECHO 0x10
167
168#define MODE_MASK 0x1f
169
170/* Not part of protocol, but needed to simplify things... */
171#define MODE_FLOW 0x0100
172#define MODE_ECHO 0x0200
173#define MODE_INBIN 0x0400
174#define MODE_OUTBIN 0x0800
175#define MODE_FORCE 0x1000
176
177#define SLC_SYNCH 1
178#define SLC_BRK 2
179#define SLC_IP 3
180#define SLC_AO 4
181#define SLC_AYT 5
182#define SLC_EOR 6
183#define SLC_ABORT 7
184#define SLC_EOF 8
185#define SLC_SUSP 9
186#define SLC_EC 10
187#define SLC_EL 11
188#define SLC_EW 12
189#define SLC_RP 13
190#define SLC_LNEXT 14
191#define SLC_XON 15
192#define SLC_XOFF 16
193#define SLC_FORW1 17
194#define SLC_FORW2 18
195
196#define NSLC 18
197
198/*
199 * For backwards compatibility, we define SLC_NAMES to be the
200 * list of names if SLC_NAMES is not defined.
201 */
202#define SLC_NAMELIST "0", "SYNCH", "BRK", "IP", "AO", "AYT", "EOR", \
203 "ABORT", "EOF", "SUSP", "EC", "EL", "EW", "RP", \
204 "LNEXT", "XON", "XOFF", "FORW1", "FORW2", 0,
205#ifdef SLC_NAMES
206char *slc_names[] = {
207 SLC_NAMELIST
208};
209#else
210extern char *slc_names[];
211#define SLC_NAMES SLC_NAMELIST
212#endif
213
214#define SLC_NAME_OK(x) ((unsigned int)(x) <= NSLC)
215#define SLC_NAME(x) slc_names[x]
216
217#define SLC_NOSUPPORT 0
218#define SLC_CANTCHANGE 1
219#define SLC_VARIABLE 2
220#define SLC_DEFAULT 3
221#define SLC_LEVELBITS 0x03
222
223#define SLC_FUNC 0
224#define SLC_FLAGS 1
225#define SLC_VALUE 2
226
227#define SLC_ACK 0x80
228#define SLC_FLUSHIN 0x40
229#define SLC_FLUSHOUT 0x20
230
231#define OLD_ENV_VAR 1
232#define OLD_ENV_VALUE 0
233#define NEW_ENV_VAR 0
234#define NEW_ENV_VALUE 1
235#define ENV_ESC 2
236#define ENV_USERVAR 3
237
238/*
239 * AUTHENTICATION suboptions
240 */
241
242/*
243 * Who is authenticating who ...
244 */
245#define AUTH_WHO_CLIENT 0 /* Client authenticating server */
246#define AUTH_WHO_SERVER 1 /* Server authenticating client */
247#define AUTH_WHO_MASK 1
248
249/*
250 * amount of authentication done
251 */
252#define AUTH_HOW_ONE_WAY 0
253#define AUTH_HOW_MUTUAL 2
254#define AUTH_HOW_MASK 2
255
256#define AUTHTYPE_NULL 0
257#define AUTHTYPE_KERBEROS_V4 1
258#define AUTHTYPE_KERBEROS_V5 2
259#define AUTHTYPE_SPX 3
260#define AUTHTYPE_MINK 4
261#define AUTHTYPE_CNT 5
262
263#define AUTHTYPE_TEST 99
264
265#ifdef AUTH_NAMES
266char *authtype_names[] = {
267 "NULL", "KERBEROS_V4", "KERBEROS_V5", "SPX", "MINK", 0,
268};
269#else
270extern char *authtype_names[];
271#endif
272
273#define AUTHTYPE_NAME_OK(x) ((unsigned int)(x) < AUTHTYPE_CNT)
274#define AUTHTYPE_NAME(x) authtype_names[x]
275
276/*
277 * ENCRYPTion suboptions
278 */
279#define ENCRYPT_IS 0 /* I pick encryption type ... */
280#define ENCRYPT_SUPPORT 1 /* I support encryption types ... */
281#define ENCRYPT_REPLY 2 /* Initial setup response */
282#define ENCRYPT_START 3 /* Am starting to send encrypted */
283#define ENCRYPT_END 4 /* Am ending encrypted */
284#define ENCRYPT_REQSTART 5 /* Request you start encrypting */
285#define ENCRYPT_REQEND 6 /* Request you send encrypting */
286#define ENCRYPT_ENC_KEYID 7
287#define ENCRYPT_DEC_KEYID 8
288#define ENCRYPT_CNT 9
289
290#define ENCTYPE_ANY 0
291#define ENCTYPE_DES_CFB64 1
292#define ENCTYPE_DES_OFB64 2
293#define ENCTYPE_CNT 3
294
295#ifdef ENCRYPT_NAMES
296char *encrypt_names[] = {
297 "IS", "SUPPORT", "REPLY", "START", "END",
298 "REQUEST-START", "REQUEST-END", "ENC-KEYID", "DEC-KEYID",
299 0,
300};
301char *enctype_names[] = {
302 "ANY", "DES_CFB64", "DES_OFB64", 0,
303};
304#else
305extern char *encrypt_names[];
306extern char *enctype_names[];
307#endif
308
309
310#define ENCRYPT_NAME_OK(x) ((unsigned int)(x) < ENCRYPT_CNT)
311#define ENCRYPT_NAME(x) encrypt_names[x]
312
313#define ENCTYPE_NAME_OK(x) ((unsigned int)(x) < ENCTYPE_CNT)
314#define ENCTYPE_NAME(x) enctype_names[x]
315
316#endif /* arpa/telnet.h */
libc/glibc-include/arpa/tftp.h created+82
...@@ -0,0 +1,82 @@
1/*
2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 4. Neither the name of the University nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * @(#)tftp.h 8.1 (Berkeley) 6/2/93
30 */
31
32#ifndef _ARPA_TFTP_H
33#define _ARPA_TFTP_H 1
34
35/*
36 * Trivial File Transfer Protocol (IEN-133)
37 */
38#define SEGSIZE 512 /* data segment size */
39
40/*
41 * Packet types.
42 */
43#define RRQ 01 /* read request */
44#define WRQ 02 /* write request */
45#define DATA 03 /* data packet */
46#define ACK 04 /* acknowledgement */
47#define ERROR 05 /* error code */
48
49struct tftphdr {
50 short th_opcode; /* packet type */
51 union {
52 char tu_padding[3]; /* sizeof() compat */
53 struct {
54 union {
55 unsigned short tu_block; /* block # */
56 short tu_code; /* error code */
57 } __attribute__ ((__packed__)) th_u3;
58 char tu_data[0]; /* data or error string */
59 } __attribute__ ((__packed__)) th_u2;
60 char tu_stuff[0]; /* request packet stuff */
61 } __attribute__ ((__packed__)) th_u1;
62} __attribute__ ((__packed__));
63
64#define th_block th_u1.th_u2.th_u3.tu_block
65#define th_code th_u1.th_u2.th_u3.tu_code
66#define th_stuff th_u1.tu_stuff
67#define th_data th_u1.th_u2.tu_data
68#define th_msg th_u1.th_u2.tu_data
69
70/*
71 * Error codes.
72 */
73#define EUNDEF 0 /* not defined */
74#define ENOTFOUND 1 /* file not found */
75#define EACCESS 2 /* access violation */
76#define ENOSPACE 3 /* disk full or allocation exceeded */
77#define EBADOP 4 /* illegal TFTP operation */
78#define EBADID 5 /* unknown transfer ID */
79#define EEXISTS 6 /* file already exists */
80#define ENOUSER 7 /* no such user */
81
82#endif /* arpa/tftp.h */
libc/glibc-include/assert.h created+141
...@@ -0,0 +1,141 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/*
19 * ISO C99 Standard: 7.2 Diagnostics <assert.h>
20 */
21
22#ifdef _ASSERT_H
23
24# undef _ASSERT_H
25# undef assert
26# undef __ASSERT_VOID_CAST
27
28# ifdef __USE_GNU
29# undef assert_perror
30# endif
31
32#endif /* assert.h */
33
34#define _ASSERT_H 1
35#include <features.h>
36
37#if defined __cplusplus && __GNUC_PREREQ (2,95)
38# define __ASSERT_VOID_CAST static_cast<void>
39#else
40# define __ASSERT_VOID_CAST (void)
41#endif
42
43/* void assert (int expression);
44
45 If NDEBUG is defined, do nothing.
46 If not, and EXPRESSION is zero, print an error message and abort. */
47
48#ifdef NDEBUG
49
50# define assert(expr) (__ASSERT_VOID_CAST (0))
51
52/* void assert_perror (int errnum);
53
54 If NDEBUG is defined, do nothing. If not, and ERRNUM is not zero, print an
55 error message with the error text for ERRNUM and abort.
56 (This is a GNU extension.) */
57
58# ifdef __USE_GNU
59# define assert_perror(errnum) (__ASSERT_VOID_CAST (0))
60# endif
61
62#else /* Not NDEBUG. */
63
64__BEGIN_DECLS
65
66/* This prints an "Assertion failed" message and aborts. */
67extern void __assert_fail (const char *__assertion, const char *__file,
68 unsigned int __line, const char *__function)
69 __THROW __attribute__ ((__noreturn__));
70
71/* Likewise, but prints the error text for ERRNUM. */
72extern void __assert_perror_fail (int __errnum, const char *__file,
73 unsigned int __line, const char *__function)
74 __THROW __attribute__ ((__noreturn__));
75
76
77/* The following is not at all used here but needed for standard
78 compliance. */
79extern void __assert (const char *__assertion, const char *__file, int __line)
80 __THROW __attribute__ ((__noreturn__));
81
82
83__END_DECLS
84
85/* When possible, define assert so that it does not add extra
86 parentheses around EXPR. Otherwise, those added parentheses would
87 suppress warnings we'd expect to be detected by gcc's -Wparentheses. */
88# if defined __cplusplus
89# define assert(expr) \
90 (static_cast <bool> (expr) \
91 ? void (0) \
92 : __assert_fail (#expr, __FILE__, __LINE__, __ASSERT_FUNCTION))
93# elif !defined __GNUC__ || defined __STRICT_ANSI__
94# define assert(expr) \
95 ((expr) \
96 ? __ASSERT_VOID_CAST (0) \
97 : __assert_fail (#expr, __FILE__, __LINE__, __ASSERT_FUNCTION))
98# else
99/* The first occurrence of EXPR is not evaluated due to the sizeof,
100 but will trigger any pedantic warnings masked by the __extension__
101 for the second occurrence. The ternary operator is required to
102 support function pointers and bit fields in this context, and to
103 suppress the evaluation of variable length arrays. */
104# define assert(expr) \
105 ((void) sizeof ((expr) ? 1 : 0), __extension__ ({ \
106 if (expr) \
107 ; /* empty */ \
108 else \
109 __assert_fail (#expr, __FILE__, __LINE__, __ASSERT_FUNCTION); \
110 }))
111# endif
112
113# ifdef __USE_GNU
114# define assert_perror(errnum) \
115 (!(errnum) \
116 ? __ASSERT_VOID_CAST (0) \
117 : __assert_perror_fail ((errnum), __FILE__, __LINE__, __ASSERT_FUNCTION))
118# endif
119
120/* Version 2.4 and later of GCC define a magical variable `__PRETTY_FUNCTION__'
121 which contains the name of the function currently being defined.
122 This is broken in G++ before version 2.6.
123 C9x has a similar variable called __func__, but prefer the GCC one since
124 it demangles C++ function names. */
125# if defined __cplusplus ? __GNUC_PREREQ (2, 6) : __GNUC_PREREQ (2, 4)
126# define __ASSERT_FUNCTION __extension__ __PRETTY_FUNCTION__
127# else
128# if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
129# define __ASSERT_FUNCTION __func__
130# else
131# define __ASSERT_FUNCTION ((const char *) 0)
132# endif
133# endif
134
135#endif /* NDEBUG. */
136
137
138#if defined __USE_ISOC11 && !defined __cplusplus
139# undef static_assert
140# define static_assert _Static_assert
141#endif
libc/glibc-include/bits/a.out.h created+11
...@@ -0,0 +1,11 @@
1#ifndef __A_OUT_GNU_H__
2# error "Never use <bits/a.out.h> directly; include <a.out.h> instead."
3#endif
4
5#ifdef __x86_64__
6
7/* Signal to users of this header that this architecture really doesn't
8 support a.out binary format. */
9#define __NO_A_OUT_SUPPORT 1
10
11#endif
libc/glibc-include/bits/byteswap.h created+79
...@@ -0,0 +1,79 @@
1/* Macros and inline functions to swap the order of bytes in integer values.
2 Copyright (C) 1997-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#if !defined _BYTESWAP_H && !defined _NETINET_IN_H && !defined _ENDIAN_H
20# error "Never use <bits/byteswap.h> directly; include <byteswap.h> instead."
21#endif
22
23#ifndef _BITS_BYTESWAP_H
24#define _BITS_BYTESWAP_H 1
25
26#include <features.h>
27#include <bits/types.h>
28
29/* Swap bytes in 16-bit value. */
30#define __bswap_constant_16(x) \
31 ((__uint16_t) ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8)))
32
33static __inline __uint16_t
34__bswap_16 (__uint16_t __bsx)
35{
36#if __GNUC_PREREQ (4, 8)
37 return __builtin_bswap16 (__bsx);
38#else
39 return __bswap_constant_16 (__bsx);
40#endif
41}
42
43/* Swap bytes in 32-bit value. */
44#define __bswap_constant_32(x) \
45 ((((x) & 0xff000000u) >> 24) | (((x) & 0x00ff0000u) >> 8) \
46 | (((x) & 0x0000ff00u) << 8) | (((x) & 0x000000ffu) << 24))
47
48static __inline __uint32_t
49__bswap_32 (__uint32_t __bsx)
50{
51#if __GNUC_PREREQ (4, 3)
52 return __builtin_bswap32 (__bsx);
53#else
54 return __bswap_constant_32 (__bsx);
55#endif
56}
57
58/* Swap bytes in 64-bit value. */
59#define __bswap_constant_64(x) \
60 ((((x) & 0xff00000000000000ull) >> 56) \
61 | (((x) & 0x00ff000000000000ull) >> 40) \
62 | (((x) & 0x0000ff0000000000ull) >> 24) \
63 | (((x) & 0x000000ff00000000ull) >> 8) \
64 | (((x) & 0x00000000ff000000ull) << 8) \
65 | (((x) & 0x0000000000ff0000ull) << 24) \
66 | (((x) & 0x000000000000ff00ull) << 40) \
67 | (((x) & 0x00000000000000ffull) << 56))
68
69__extension__ static __inline __uint64_t
70__bswap_64 (__uint64_t __bsx)
71{
72#if __GNUC_PREREQ (4, 3)
73 return __builtin_bswap64 (__bsx);
74#else
75 return __bswap_constant_64 (__bsx);
76#endif
77}
78
79#endif /* _BITS_BYTESWAP_H */
libc/glibc-include/bits/cmathcalls.h created+130
...@@ -0,0 +1,130 @@
1/* Prototype declarations for complex math functions;
2 helper file for <complex.h>.
3 Copyright (C) 1997-2019 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
19
20/* NOTE: Because of the special way this file is used by <complex.h>, this
21 file must NOT be protected from multiple inclusion as header files
22 usually are.
23
24 This file provides prototype declarations for the math functions.
25 Most functions are declared using the macro:
26
27 __MATHCALL (NAME, (ARGS...));
28
29 This means there is a function `NAME' returning `double' and a function
30 `NAMEf' returning `float'. Each place `_Mdouble_' appears in the
31 prototype, that is actually `double' in the prototype for `NAME' and
32 `float' in the prototype for `NAMEf'. Reentrant variant functions are
33 called `NAME_r' and `NAMEf_r'.
34
35 Functions returning other types like `int' are declared using the macro:
36
37 __MATHDECL (TYPE, NAME, (ARGS...));
38
39 This is just like __MATHCALL but for a function returning `TYPE'
40 instead of `_Mdouble_'. In all of these cases, there is still
41 both a `NAME' and a `NAMEf' that takes `float' arguments. */
42
43#ifndef _COMPLEX_H
44#error "Never use <bits/cmathcalls.h> directly; include <complex.h> instead."
45#endif
46
47#ifndef _Mdouble_complex_
48# define _Mdouble_complex_ _Mdouble_ _Complex
49#endif
50
51
52/* Trigonometric functions. */
53
54/* Arc cosine of Z. */
55__MATHCALL (cacos, (_Mdouble_complex_ __z));
56/* Arc sine of Z. */
57__MATHCALL (casin, (_Mdouble_complex_ __z));
58/* Arc tangent of Z. */
59__MATHCALL (catan, (_Mdouble_complex_ __z));
60
61/* Cosine of Z. */
62__MATHCALL (ccos, (_Mdouble_complex_ __z));
63/* Sine of Z. */
64__MATHCALL (csin, (_Mdouble_complex_ __z));
65/* Tangent of Z. */
66__MATHCALL (ctan, (_Mdouble_complex_ __z));
67
68
69/* Hyperbolic functions. */
70
71/* Hyperbolic arc cosine of Z. */
72__MATHCALL (cacosh, (_Mdouble_complex_ __z));
73/* Hyperbolic arc sine of Z. */
74__MATHCALL (casinh, (_Mdouble_complex_ __z));
75/* Hyperbolic arc tangent of Z. */
76__MATHCALL (catanh, (_Mdouble_complex_ __z));
77
78/* Hyperbolic cosine of Z. */
79__MATHCALL (ccosh, (_Mdouble_complex_ __z));
80/* Hyperbolic sine of Z. */
81__MATHCALL (csinh, (_Mdouble_complex_ __z));
82/* Hyperbolic tangent of Z. */
83__MATHCALL (ctanh, (_Mdouble_complex_ __z));
84
85
86/* Exponential and logarithmic functions. */
87
88/* Exponential function of Z. */
89__MATHCALL (cexp, (_Mdouble_complex_ __z));
90
91/* Natural logarithm of Z. */
92__MATHCALL (clog, (_Mdouble_complex_ __z));
93
94#ifdef __USE_GNU
95/* The base 10 logarithm is not defined by the standard but to implement
96 the standard C++ library it is handy. */
97__MATHCALL (clog10, (_Mdouble_complex_ __z));
98#endif
99
100/* Power functions. */
101
102/* Return X to the Y power. */
103__MATHCALL (cpow, (_Mdouble_complex_ __x, _Mdouble_complex_ __y));
104
105/* Return the square root of Z. */
106__MATHCALL (csqrt, (_Mdouble_complex_ __z));
107
108
109/* Absolute value, conjugates, and projection. */
110
111/* Absolute value of Z. */
112__MATHDECL (_Mdouble_,cabs, (_Mdouble_complex_ __z));
113
114/* Argument value of Z. */
115__MATHDECL (_Mdouble_,carg, (_Mdouble_complex_ __z));
116
117/* Complex conjugate of Z. */
118__MATHCALL (conj, (_Mdouble_complex_ __z));
119
120/* Projection of Z onto the Riemann sphere. */
121__MATHCALL (cproj, (_Mdouble_complex_ __z));
122
123
124/* Decomposing complex values. */
125
126/* Imaginary part of Z. */
127__MATHDECL (_Mdouble_,cimag, (_Mdouble_complex_ __z));
128
129/* Real part of Z. */
130__MATHDECL (_Mdouble_,creal, (_Mdouble_complex_ __z));
libc/glibc-include/bits/confname.h created+675
...@@ -0,0 +1,675 @@
1/* `sysconf', `pathconf', and `confstr' NAME values. Generic version.
2 Copyright (C) 1993-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _UNISTD_H
20# error "Never use <bits/confname.h> directly; include <unistd.h> instead."
21#endif
22
23/* Values for the NAME argument to `pathconf' and `fpathconf'. */
24enum
25 {
26 _PC_LINK_MAX,
27#define _PC_LINK_MAX _PC_LINK_MAX
28 _PC_MAX_CANON,
29#define _PC_MAX_CANON _PC_MAX_CANON
30 _PC_MAX_INPUT,
31#define _PC_MAX_INPUT _PC_MAX_INPUT
32 _PC_NAME_MAX,
33#define _PC_NAME_MAX _PC_NAME_MAX
34 _PC_PATH_MAX,
35#define _PC_PATH_MAX _PC_PATH_MAX
36 _PC_PIPE_BUF,
37#define _PC_PIPE_BUF _PC_PIPE_BUF
38 _PC_CHOWN_RESTRICTED,
39#define _PC_CHOWN_RESTRICTED _PC_CHOWN_RESTRICTED
40 _PC_NO_TRUNC,
41#define _PC_NO_TRUNC _PC_NO_TRUNC
42 _PC_VDISABLE,
43#define _PC_VDISABLE _PC_VDISABLE
44 _PC_SYNC_IO,
45#define _PC_SYNC_IO _PC_SYNC_IO
46 _PC_ASYNC_IO,
47#define _PC_ASYNC_IO _PC_ASYNC_IO
48 _PC_PRIO_IO,
49#define _PC_PRIO_IO _PC_PRIO_IO
50 _PC_SOCK_MAXBUF,
51#define _PC_SOCK_MAXBUF _PC_SOCK_MAXBUF
52 _PC_FILESIZEBITS,
53#define _PC_FILESIZEBITS _PC_FILESIZEBITS
54 _PC_REC_INCR_XFER_SIZE,
55#define _PC_REC_INCR_XFER_SIZE _PC_REC_INCR_XFER_SIZE
56 _PC_REC_MAX_XFER_SIZE,
57#define _PC_REC_MAX_XFER_SIZE _PC_REC_MAX_XFER_SIZE
58 _PC_REC_MIN_XFER_SIZE,
59#define _PC_REC_MIN_XFER_SIZE _PC_REC_MIN_XFER_SIZE
60 _PC_REC_XFER_ALIGN,
61#define _PC_REC_XFER_ALIGN _PC_REC_XFER_ALIGN
62 _PC_ALLOC_SIZE_MIN,
63#define _PC_ALLOC_SIZE_MIN _PC_ALLOC_SIZE_MIN
64 _PC_SYMLINK_MAX,
65#define _PC_SYMLINK_MAX _PC_SYMLINK_MAX
66 _PC_2_SYMLINKS
67#define _PC_2_SYMLINKS _PC_2_SYMLINKS
68 };
69
70/* Values for the argument to `sysconf'. */
71enum
72 {
73 _SC_ARG_MAX,
74#define _SC_ARG_MAX _SC_ARG_MAX
75 _SC_CHILD_MAX,
76#define _SC_CHILD_MAX _SC_CHILD_MAX
77 _SC_CLK_TCK,
78#define _SC_CLK_TCK _SC_CLK_TCK
79 _SC_NGROUPS_MAX,
80#define _SC_NGROUPS_MAX _SC_NGROUPS_MAX
81 _SC_OPEN_MAX,
82#define _SC_OPEN_MAX _SC_OPEN_MAX
83 _SC_STREAM_MAX,
84#define _SC_STREAM_MAX _SC_STREAM_MAX
85 _SC_TZNAME_MAX,
86#define _SC_TZNAME_MAX _SC_TZNAME_MAX
87 _SC_JOB_CONTROL,
88#define _SC_JOB_CONTROL _SC_JOB_CONTROL
89 _SC_SAVED_IDS,
90#define _SC_SAVED_IDS _SC_SAVED_IDS
91 _SC_REALTIME_SIGNALS,
92#define _SC_REALTIME_SIGNALS _SC_REALTIME_SIGNALS
93 _SC_PRIORITY_SCHEDULING,
94#define _SC_PRIORITY_SCHEDULING _SC_PRIORITY_SCHEDULING
95 _SC_TIMERS,
96#define _SC_TIMERS _SC_TIMERS
97 _SC_ASYNCHRONOUS_IO,
98#define _SC_ASYNCHRONOUS_IO _SC_ASYNCHRONOUS_IO
99 _SC_PRIORITIZED_IO,
100#define _SC_PRIORITIZED_IO _SC_PRIORITIZED_IO
101 _SC_SYNCHRONIZED_IO,
102#define _SC_SYNCHRONIZED_IO _SC_SYNCHRONIZED_IO
103 _SC_FSYNC,
104#define _SC_FSYNC _SC_FSYNC
105 _SC_MAPPED_FILES,
106#define _SC_MAPPED_FILES _SC_MAPPED_FILES
107 _SC_MEMLOCK,
108#define _SC_MEMLOCK _SC_MEMLOCK
109 _SC_MEMLOCK_RANGE,
110#define _SC_MEMLOCK_RANGE _SC_MEMLOCK_RANGE
111 _SC_MEMORY_PROTECTION,
112#define _SC_MEMORY_PROTECTION _SC_MEMORY_PROTECTION
113 _SC_MESSAGE_PASSING,
114#define _SC_MESSAGE_PASSING _SC_MESSAGE_PASSING
115 _SC_SEMAPHORES,
116#define _SC_SEMAPHORES _SC_SEMAPHORES
117 _SC_SHARED_MEMORY_OBJECTS,
118#define _SC_SHARED_MEMORY_OBJECTS _SC_SHARED_MEMORY_OBJECTS
119 _SC_AIO_LISTIO_MAX,
120#define _SC_AIO_LISTIO_MAX _SC_AIO_LISTIO_MAX
121 _SC_AIO_MAX,
122#define _SC_AIO_MAX _SC_AIO_MAX
123 _SC_AIO_PRIO_DELTA_MAX,
124#define _SC_AIO_PRIO_DELTA_MAX _SC_AIO_PRIO_DELTA_MAX
125 _SC_DELAYTIMER_MAX,
126#define _SC_DELAYTIMER_MAX _SC_DELAYTIMER_MAX
127 _SC_MQ_OPEN_MAX,
128#define _SC_MQ_OPEN_MAX _SC_MQ_OPEN_MAX
129 _SC_MQ_PRIO_MAX,
130#define _SC_MQ_PRIO_MAX _SC_MQ_PRIO_MAX
131 _SC_VERSION,
132#define _SC_VERSION _SC_VERSION
133 _SC_PAGESIZE,
134#define _SC_PAGESIZE _SC_PAGESIZE
135#define _SC_PAGE_SIZE _SC_PAGESIZE
136 _SC_RTSIG_MAX,
137#define _SC_RTSIG_MAX _SC_RTSIG_MAX
138 _SC_SEM_NSEMS_MAX,
139#define _SC_SEM_NSEMS_MAX _SC_SEM_NSEMS_MAX
140 _SC_SEM_VALUE_MAX,
141#define _SC_SEM_VALUE_MAX _SC_SEM_VALUE_MAX
142 _SC_SIGQUEUE_MAX,
143#define _SC_SIGQUEUE_MAX _SC_SIGQUEUE_MAX
144 _SC_TIMER_MAX,
145#define _SC_TIMER_MAX _SC_TIMER_MAX
146
147 /* Values for the argument to `sysconf'
148 corresponding to _POSIX2_* symbols. */
149 _SC_BC_BASE_MAX,
150#define _SC_BC_BASE_MAX _SC_BC_BASE_MAX
151 _SC_BC_DIM_MAX,
152#define _SC_BC_DIM_MAX _SC_BC_DIM_MAX
153 _SC_BC_SCALE_MAX,
154#define _SC_BC_SCALE_MAX _SC_BC_SCALE_MAX
155 _SC_BC_STRING_MAX,
156#define _SC_BC_STRING_MAX _SC_BC_STRING_MAX
157 _SC_COLL_WEIGHTS_MAX,
158#define _SC_COLL_WEIGHTS_MAX _SC_COLL_WEIGHTS_MAX
159 _SC_EQUIV_CLASS_MAX,
160#define _SC_EQUIV_CLASS_MAX _SC_EQUIV_CLASS_MAX
161 _SC_EXPR_NEST_MAX,
162#define _SC_EXPR_NEST_MAX _SC_EXPR_NEST_MAX
163 _SC_LINE_MAX,
164#define _SC_LINE_MAX _SC_LINE_MAX
165 _SC_RE_DUP_MAX,
166#define _SC_RE_DUP_MAX _SC_RE_DUP_MAX
167 _SC_CHARCLASS_NAME_MAX,
168#define _SC_CHARCLASS_NAME_MAX _SC_CHARCLASS_NAME_MAX
169
170 _SC_2_VERSION,
171#define _SC_2_VERSION _SC_2_VERSION
172 _SC_2_C_BIND,
173#define _SC_2_C_BIND _SC_2_C_BIND
174 _SC_2_C_DEV,
175#define _SC_2_C_DEV _SC_2_C_DEV
176 _SC_2_FORT_DEV,
177#define _SC_2_FORT_DEV _SC_2_FORT_DEV
178 _SC_2_FORT_RUN,
179#define _SC_2_FORT_RUN _SC_2_FORT_RUN
180 _SC_2_SW_DEV,
181#define _SC_2_SW_DEV _SC_2_SW_DEV
182 _SC_2_LOCALEDEF,
183#define _SC_2_LOCALEDEF _SC_2_LOCALEDEF
184
185 _SC_PII,
186#define _SC_PII _SC_PII
187 _SC_PII_XTI,
188#define _SC_PII_XTI _SC_PII_XTI
189 _SC_PII_SOCKET,
190#define _SC_PII_SOCKET _SC_PII_SOCKET
191 _SC_PII_INTERNET,
192#define _SC_PII_INTERNET _SC_PII_INTERNET
193 _SC_PII_OSI,
194#define _SC_PII_OSI _SC_PII_OSI
195 _SC_POLL,
196#define _SC_POLL _SC_POLL
197 _SC_SELECT,
198#define _SC_SELECT _SC_SELECT
199 _SC_UIO_MAXIOV,
200#define _SC_UIO_MAXIOV _SC_UIO_MAXIOV
201 _SC_IOV_MAX = _SC_UIO_MAXIOV,
202#define _SC_IOV_MAX _SC_IOV_MAX
203 _SC_PII_INTERNET_STREAM,
204#define _SC_PII_INTERNET_STREAM _SC_PII_INTERNET_STREAM
205 _SC_PII_INTERNET_DGRAM,
206#define _SC_PII_INTERNET_DGRAM _SC_PII_INTERNET_DGRAM
207 _SC_PII_OSI_COTS,
208#define _SC_PII_OSI_COTS _SC_PII_OSI_COTS
209 _SC_PII_OSI_CLTS,
210#define _SC_PII_OSI_CLTS _SC_PII_OSI_CLTS
211 _SC_PII_OSI_M,
212#define _SC_PII_OSI_M _SC_PII_OSI_M
213 _SC_T_IOV_MAX,
214#define _SC_T_IOV_MAX _SC_T_IOV_MAX
215
216 /* Values according to POSIX 1003.1c (POSIX threads). */
217 _SC_THREADS,
218#define _SC_THREADS _SC_THREADS
219 _SC_THREAD_SAFE_FUNCTIONS,
220#define _SC_THREAD_SAFE_FUNCTIONS _SC_THREAD_SAFE_FUNCTIONS
221 _SC_GETGR_R_SIZE_MAX,
222#define _SC_GETGR_R_SIZE_MAX _SC_GETGR_R_SIZE_MAX
223 _SC_GETPW_R_SIZE_MAX,
224#define _SC_GETPW_R_SIZE_MAX _SC_GETPW_R_SIZE_MAX
225 _SC_LOGIN_NAME_MAX,
226#define _SC_LOGIN_NAME_MAX _SC_LOGIN_NAME_MAX
227 _SC_TTY_NAME_MAX,
228#define _SC_TTY_NAME_MAX _SC_TTY_NAME_MAX
229 _SC_THREAD_DESTRUCTOR_ITERATIONS,
230#define _SC_THREAD_DESTRUCTOR_ITERATIONS _SC_THREAD_DESTRUCTOR_ITERATIONS
231 _SC_THREAD_KEYS_MAX,
232#define _SC_THREAD_KEYS_MAX _SC_THREAD_KEYS_MAX
233 _SC_THREAD_STACK_MIN,
234#define _SC_THREAD_STACK_MIN _SC_THREAD_STACK_MIN
235 _SC_THREAD_THREADS_MAX,
236#define _SC_THREAD_THREADS_MAX _SC_THREAD_THREADS_MAX
237 _SC_THREAD_ATTR_STACKADDR,
238#define _SC_THREAD_ATTR_STACKADDR _SC_THREAD_ATTR_STACKADDR
239 _SC_THREAD_ATTR_STACKSIZE,
240#define _SC_THREAD_ATTR_STACKSIZE _SC_THREAD_ATTR_STACKSIZE
241 _SC_THREAD_PRIORITY_SCHEDULING,
242#define _SC_THREAD_PRIORITY_SCHEDULING _SC_THREAD_PRIORITY_SCHEDULING
243 _SC_THREAD_PRIO_INHERIT,
244#define _SC_THREAD_PRIO_INHERIT _SC_THREAD_PRIO_INHERIT
245 _SC_THREAD_PRIO_PROTECT,
246#define _SC_THREAD_PRIO_PROTECT _SC_THREAD_PRIO_PROTECT
247 _SC_THREAD_PROCESS_SHARED,
248#define _SC_THREAD_PROCESS_SHARED _SC_THREAD_PROCESS_SHARED
249
250 _SC_NPROCESSORS_CONF,
251#define _SC_NPROCESSORS_CONF _SC_NPROCESSORS_CONF
252 _SC_NPROCESSORS_ONLN,
253#define _SC_NPROCESSORS_ONLN _SC_NPROCESSORS_ONLN
254 _SC_PHYS_PAGES,
255#define _SC_PHYS_PAGES _SC_PHYS_PAGES
256 _SC_AVPHYS_PAGES,
257#define _SC_AVPHYS_PAGES _SC_AVPHYS_PAGES
258 _SC_ATEXIT_MAX,
259#define _SC_ATEXIT_MAX _SC_ATEXIT_MAX
260 _SC_PASS_MAX,
261#define _SC_PASS_MAX _SC_PASS_MAX
262
263 _SC_XOPEN_VERSION,
264#define _SC_XOPEN_VERSION _SC_XOPEN_VERSION
265 _SC_XOPEN_XCU_VERSION,
266#define _SC_XOPEN_XCU_VERSION _SC_XOPEN_XCU_VERSION
267 _SC_XOPEN_UNIX,
268#define _SC_XOPEN_UNIX _SC_XOPEN_UNIX
269 _SC_XOPEN_CRYPT,
270#define _SC_XOPEN_CRYPT _SC_XOPEN_CRYPT
271 _SC_XOPEN_ENH_I18N,
272#define _SC_XOPEN_ENH_I18N _SC_XOPEN_ENH_I18N
273 _SC_XOPEN_SHM,
274#define _SC_XOPEN_SHM _SC_XOPEN_SHM
275
276 _SC_2_CHAR_TERM,
277#define _SC_2_CHAR_TERM _SC_2_CHAR_TERM
278 _SC_2_C_VERSION,
279#define _SC_2_C_VERSION _SC_2_C_VERSION
280 _SC_2_UPE,
281#define _SC_2_UPE _SC_2_UPE
282
283 _SC_XOPEN_XPG2,
284#define _SC_XOPEN_XPG2 _SC_XOPEN_XPG2
285 _SC_XOPEN_XPG3,
286#define _SC_XOPEN_XPG3 _SC_XOPEN_XPG3
287 _SC_XOPEN_XPG4,
288#define _SC_XOPEN_XPG4 _SC_XOPEN_XPG4
289
290 _SC_CHAR_BIT,
291#define _SC_CHAR_BIT _SC_CHAR_BIT
292 _SC_CHAR_MAX,
293#define _SC_CHAR_MAX _SC_CHAR_MAX
294 _SC_CHAR_MIN,
295#define _SC_CHAR_MIN _SC_CHAR_MIN
296 _SC_INT_MAX,
297#define _SC_INT_MAX _SC_INT_MAX
298 _SC_INT_MIN,
299#define _SC_INT_MIN _SC_INT_MIN
300 _SC_LONG_BIT,
301#define _SC_LONG_BIT _SC_LONG_BIT
302 _SC_WORD_BIT,
303#define _SC_WORD_BIT _SC_WORD_BIT
304 _SC_MB_LEN_MAX,
305#define _SC_MB_LEN_MAX _SC_MB_LEN_MAX
306 _SC_NZERO,
307#define _SC_NZERO _SC_NZERO
308 _SC_SSIZE_MAX,
309#define _SC_SSIZE_MAX _SC_SSIZE_MAX
310 _SC_SCHAR_MAX,
311#define _SC_SCHAR_MAX _SC_SCHAR_MAX
312 _SC_SCHAR_MIN,
313#define _SC_SCHAR_MIN _SC_SCHAR_MIN
314 _SC_SHRT_MAX,
315#define _SC_SHRT_MAX _SC_SHRT_MAX
316 _SC_SHRT_MIN,
317#define _SC_SHRT_MIN _SC_SHRT_MIN
318 _SC_UCHAR_MAX,
319#define _SC_UCHAR_MAX _SC_UCHAR_MAX
320 _SC_UINT_MAX,
321#define _SC_UINT_MAX _SC_UINT_MAX
322 _SC_ULONG_MAX,
323#define _SC_ULONG_MAX _SC_ULONG_MAX
324 _SC_USHRT_MAX,
325#define _SC_USHRT_MAX _SC_USHRT_MAX
326
327 _SC_NL_ARGMAX,
328#define _SC_NL_ARGMAX _SC_NL_ARGMAX
329 _SC_NL_LANGMAX,
330#define _SC_NL_LANGMAX _SC_NL_LANGMAX
331 _SC_NL_MSGMAX,
332#define _SC_NL_MSGMAX _SC_NL_MSGMAX
333 _SC_NL_NMAX,
334#define _SC_NL_NMAX _SC_NL_NMAX
335 _SC_NL_SETMAX,
336#define _SC_NL_SETMAX _SC_NL_SETMAX
337 _SC_NL_TEXTMAX,
338#define _SC_NL_TEXTMAX _SC_NL_TEXTMAX
339
340 _SC_XBS5_ILP32_OFF32,
341#define _SC_XBS5_ILP32_OFF32 _SC_XBS5_ILP32_OFF32
342 _SC_XBS5_ILP32_OFFBIG,
343#define _SC_XBS5_ILP32_OFFBIG _SC_XBS5_ILP32_OFFBIG
344 _SC_XBS5_LP64_OFF64,
345#define _SC_XBS5_LP64_OFF64 _SC_XBS5_LP64_OFF64
346 _SC_XBS5_LPBIG_OFFBIG,
347#define _SC_XBS5_LPBIG_OFFBIG _SC_XBS5_LPBIG_OFFBIG
348
349 _SC_XOPEN_LEGACY,
350#define _SC_XOPEN_LEGACY _SC_XOPEN_LEGACY
351 _SC_XOPEN_REALTIME,
352#define _SC_XOPEN_REALTIME _SC_XOPEN_REALTIME
353 _SC_XOPEN_REALTIME_THREADS,
354#define _SC_XOPEN_REALTIME_THREADS _SC_XOPEN_REALTIME_THREADS
355
356 _SC_ADVISORY_INFO,
357#define _SC_ADVISORY_INFO _SC_ADVISORY_INFO
358 _SC_BARRIERS,
359#define _SC_BARRIERS _SC_BARRIERS
360 _SC_BASE,
361#define _SC_BASE _SC_BASE
362 _SC_C_LANG_SUPPORT,
363#define _SC_C_LANG_SUPPORT _SC_C_LANG_SUPPORT
364 _SC_C_LANG_SUPPORT_R,
365#define _SC_C_LANG_SUPPORT_R _SC_C_LANG_SUPPORT_R
366 _SC_CLOCK_SELECTION,
367#define _SC_CLOCK_SELECTION _SC_CLOCK_SELECTION
368 _SC_CPUTIME,
369#define _SC_CPUTIME _SC_CPUTIME
370 _SC_THREAD_CPUTIME,
371#define _SC_THREAD_CPUTIME _SC_THREAD_CPUTIME
372 _SC_DEVICE_IO,
373#define _SC_DEVICE_IO _SC_DEVICE_IO
374 _SC_DEVICE_SPECIFIC,
375#define _SC_DEVICE_SPECIFIC _SC_DEVICE_SPECIFIC
376 _SC_DEVICE_SPECIFIC_R,
377#define _SC_DEVICE_SPECIFIC_R _SC_DEVICE_SPECIFIC_R
378 _SC_FD_MGMT,
379#define _SC_FD_MGMT _SC_FD_MGMT
380 _SC_FIFO,
381#define _SC_FIFO _SC_FIFO
382 _SC_PIPE,
383#define _SC_PIPE _SC_PIPE
384 _SC_FILE_ATTRIBUTES,
385#define _SC_FILE_ATTRIBUTES _SC_FILE_ATTRIBUTES
386 _SC_FILE_LOCKING,
387#define _SC_FILE_LOCKING _SC_FILE_LOCKING
388 _SC_FILE_SYSTEM,
389#define _SC_FILE_SYSTEM _SC_FILE_SYSTEM
390 _SC_MONOTONIC_CLOCK,
391#define _SC_MONOTONIC_CLOCK _SC_MONOTONIC_CLOCK
392 _SC_MULTI_PROCESS,
393#define _SC_MULTI_PROCESS _SC_MULTI_PROCESS
394 _SC_SINGLE_PROCESS,
395#define _SC_SINGLE_PROCESS _SC_SINGLE_PROCESS
396 _SC_NETWORKING,
397#define _SC_NETWORKING _SC_NETWORKING
398 _SC_READER_WRITER_LOCKS,
399#define _SC_READER_WRITER_LOCKS _SC_READER_WRITER_LOCKS
400 _SC_SPIN_LOCKS,
401#define _SC_SPIN_LOCKS _SC_SPIN_LOCKS
402 _SC_REGEXP,
403#define _SC_REGEXP _SC_REGEXP
404 _SC_REGEX_VERSION,
405#define _SC_REGEX_VERSION _SC_REGEX_VERSION
406 _SC_SHELL,
407#define _SC_SHELL _SC_SHELL
408 _SC_SIGNALS,
409#define _SC_SIGNALS _SC_SIGNALS
410 _SC_SPAWN,
411#define _SC_SPAWN _SC_SPAWN
412 _SC_SPORADIC_SERVER,
413#define _SC_SPORADIC_SERVER _SC_SPORADIC_SERVER
414 _SC_THREAD_SPORADIC_SERVER,
415#define _SC_THREAD_SPORADIC_SERVER _SC_THREAD_SPORADIC_SERVER
416 _SC_SYSTEM_DATABASE,
417#define _SC_SYSTEM_DATABASE _SC_SYSTEM_DATABASE
418 _SC_SYSTEM_DATABASE_R,
419#define _SC_SYSTEM_DATABASE_R _SC_SYSTEM_DATABASE_R
420 _SC_TIMEOUTS,
421#define _SC_TIMEOUTS _SC_TIMEOUTS
422 _SC_TYPED_MEMORY_OBJECTS,
423#define _SC_TYPED_MEMORY_OBJECTS _SC_TYPED_MEMORY_OBJECTS
424 _SC_USER_GROUPS,
425#define _SC_USER_GROUPS _SC_USER_GROUPS
426 _SC_USER_GROUPS_R,
427#define _SC_USER_GROUPS_R _SC_USER_GROUPS_R
428 _SC_2_PBS,
429#define _SC_2_PBS _SC_2_PBS
430 _SC_2_PBS_ACCOUNTING,
431#define _SC_2_PBS_ACCOUNTING _SC_2_PBS_ACCOUNTING
432 _SC_2_PBS_LOCATE,
433#define _SC_2_PBS_LOCATE _SC_2_PBS_LOCATE
434 _SC_2_PBS_MESSAGE,
435#define _SC_2_PBS_MESSAGE _SC_2_PBS_MESSAGE
436 _SC_2_PBS_TRACK,
437#define _SC_2_PBS_TRACK _SC_2_PBS_TRACK
438 _SC_SYMLOOP_MAX,
439#define _SC_SYMLOOP_MAX _SC_SYMLOOP_MAX
440 _SC_STREAMS,
441#define _SC_STREAMS _SC_STREAMS
442 _SC_2_PBS_CHECKPOINT,
443#define _SC_2_PBS_CHECKPOINT _SC_2_PBS_CHECKPOINT
444
445 _SC_V6_ILP32_OFF32,
446#define _SC_V6_ILP32_OFF32 _SC_V6_ILP32_OFF32
447 _SC_V6_ILP32_OFFBIG,
448#define _SC_V6_ILP32_OFFBIG _SC_V6_ILP32_OFFBIG
449 _SC_V6_LP64_OFF64,
450#define _SC_V6_LP64_OFF64 _SC_V6_LP64_OFF64
451 _SC_V6_LPBIG_OFFBIG,
452#define _SC_V6_LPBIG_OFFBIG _SC_V6_LPBIG_OFFBIG
453
454 _SC_HOST_NAME_MAX,
455#define _SC_HOST_NAME_MAX _SC_HOST_NAME_MAX
456 _SC_TRACE,
457#define _SC_TRACE _SC_TRACE
458 _SC_TRACE_EVENT_FILTER,
459#define _SC_TRACE_EVENT_FILTER _SC_TRACE_EVENT_FILTER
460 _SC_TRACE_INHERIT,
461#define _SC_TRACE_INHERIT _SC_TRACE_INHERIT
462 _SC_TRACE_LOG,
463#define _SC_TRACE_LOG _SC_TRACE_LOG
464
465 _SC_LEVEL1_ICACHE_SIZE,
466#define _SC_LEVEL1_ICACHE_SIZE _SC_LEVEL1_ICACHE_SIZE
467 _SC_LEVEL1_ICACHE_ASSOC,
468#define _SC_LEVEL1_ICACHE_ASSOC _SC_LEVEL1_ICACHE_ASSOC
469 _SC_LEVEL1_ICACHE_LINESIZE,
470#define _SC_LEVEL1_ICACHE_LINESIZE _SC_LEVEL1_ICACHE_LINESIZE
471 _SC_LEVEL1_DCACHE_SIZE,
472#define _SC_LEVEL1_DCACHE_SIZE _SC_LEVEL1_DCACHE_SIZE
473 _SC_LEVEL1_DCACHE_ASSOC,
474#define _SC_LEVEL1_DCACHE_ASSOC _SC_LEVEL1_DCACHE_ASSOC
475 _SC_LEVEL1_DCACHE_LINESIZE,
476#define _SC_LEVEL1_DCACHE_LINESIZE _SC_LEVEL1_DCACHE_LINESIZE
477 _SC_LEVEL2_CACHE_SIZE,
478#define _SC_LEVEL2_CACHE_SIZE _SC_LEVEL2_CACHE_SIZE
479 _SC_LEVEL2_CACHE_ASSOC,
480#define _SC_LEVEL2_CACHE_ASSOC _SC_LEVEL2_CACHE_ASSOC
481 _SC_LEVEL2_CACHE_LINESIZE,
482#define _SC_LEVEL2_CACHE_LINESIZE _SC_LEVEL2_CACHE_LINESIZE
483 _SC_LEVEL3_CACHE_SIZE,
484#define _SC_LEVEL3_CACHE_SIZE _SC_LEVEL3_CACHE_SIZE
485 _SC_LEVEL3_CACHE_ASSOC,
486#define _SC_LEVEL3_CACHE_ASSOC _SC_LEVEL3_CACHE_ASSOC
487 _SC_LEVEL3_CACHE_LINESIZE,
488#define _SC_LEVEL3_CACHE_LINESIZE _SC_LEVEL3_CACHE_LINESIZE
489 _SC_LEVEL4_CACHE_SIZE,
490#define _SC_LEVEL4_CACHE_SIZE _SC_LEVEL4_CACHE_SIZE
491 _SC_LEVEL4_CACHE_ASSOC,
492#define _SC_LEVEL4_CACHE_ASSOC _SC_LEVEL4_CACHE_ASSOC
493 _SC_LEVEL4_CACHE_LINESIZE,
494#define _SC_LEVEL4_CACHE_LINESIZE _SC_LEVEL4_CACHE_LINESIZE
495 /* Leave room here, maybe we need a few more cache levels some day. */
496
497 _SC_IPV6 = _SC_LEVEL1_ICACHE_SIZE + 50,
498#define _SC_IPV6 _SC_IPV6
499 _SC_RAW_SOCKETS,
500#define _SC_RAW_SOCKETS _SC_RAW_SOCKETS
501
502 _SC_V7_ILP32_OFF32,
503#define _SC_V7_ILP32_OFF32 _SC_V7_ILP32_OFF32
504 _SC_V7_ILP32_OFFBIG,
505#define _SC_V7_ILP32_OFFBIG _SC_V7_ILP32_OFFBIG
506 _SC_V7_LP64_OFF64,
507#define _SC_V7_LP64_OFF64 _SC_V7_LP64_OFF64
508 _SC_V7_LPBIG_OFFBIG,
509#define _SC_V7_LPBIG_OFFBIG _SC_V7_LPBIG_OFFBIG
510
511 _SC_SS_REPL_MAX,
512#define _SC_SS_REPL_MAX _SC_SS_REPL_MAX
513
514 _SC_TRACE_EVENT_NAME_MAX,
515#define _SC_TRACE_EVENT_NAME_MAX _SC_TRACE_EVENT_NAME_MAX
516 _SC_TRACE_NAME_MAX,
517#define _SC_TRACE_NAME_MAX _SC_TRACE_NAME_MAX
518 _SC_TRACE_SYS_MAX,
519#define _SC_TRACE_SYS_MAX _SC_TRACE_SYS_MAX
520 _SC_TRACE_USER_EVENT_MAX,
521#define _SC_TRACE_USER_EVENT_MAX _SC_TRACE_USER_EVENT_MAX
522
523 _SC_XOPEN_STREAMS,
524#define _SC_XOPEN_STREAMS _SC_XOPEN_STREAMS
525
526 _SC_THREAD_ROBUST_PRIO_INHERIT,
527#define _SC_THREAD_ROBUST_PRIO_INHERIT _SC_THREAD_ROBUST_PRIO_INHERIT
528 _SC_THREAD_ROBUST_PRIO_PROTECT
529#define _SC_THREAD_ROBUST_PRIO_PROTECT _SC_THREAD_ROBUST_PRIO_PROTECT
530 };
531
532/* Values for the NAME argument to `confstr'. */
533enum
534 {
535 _CS_PATH, /* The default search path. */
536#define _CS_PATH _CS_PATH
537
538 _CS_V6_WIDTH_RESTRICTED_ENVS,
539#define _CS_V6_WIDTH_RESTRICTED_ENVS _CS_V6_WIDTH_RESTRICTED_ENVS
540#define _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS _CS_V6_WIDTH_RESTRICTED_ENVS
541
542 _CS_GNU_LIBC_VERSION,
543#define _CS_GNU_LIBC_VERSION _CS_GNU_LIBC_VERSION
544 _CS_GNU_LIBPTHREAD_VERSION,
545#define _CS_GNU_LIBPTHREAD_VERSION _CS_GNU_LIBPTHREAD_VERSION
546
547 _CS_V5_WIDTH_RESTRICTED_ENVS,
548#define _CS_V5_WIDTH_RESTRICTED_ENVS _CS_V5_WIDTH_RESTRICTED_ENVS
549#define _CS_POSIX_V5_WIDTH_RESTRICTED_ENVS _CS_V5_WIDTH_RESTRICTED_ENVS
550
551 _CS_V7_WIDTH_RESTRICTED_ENVS,
552#define _CS_V7_WIDTH_RESTRICTED_ENVS _CS_V7_WIDTH_RESTRICTED_ENVS
553#define _CS_POSIX_V7_WIDTH_RESTRICTED_ENVS _CS_V7_WIDTH_RESTRICTED_ENVS
554
555 _CS_LFS_CFLAGS = 1000,
556#define _CS_LFS_CFLAGS _CS_LFS_CFLAGS
557 _CS_LFS_LDFLAGS,
558#define _CS_LFS_LDFLAGS _CS_LFS_LDFLAGS
559 _CS_LFS_LIBS,
560#define _CS_LFS_LIBS _CS_LFS_LIBS
561 _CS_LFS_LINTFLAGS,
562#define _CS_LFS_LINTFLAGS _CS_LFS_LINTFLAGS
563 _CS_LFS64_CFLAGS,
564#define _CS_LFS64_CFLAGS _CS_LFS64_CFLAGS
565 _CS_LFS64_LDFLAGS,
566#define _CS_LFS64_LDFLAGS _CS_LFS64_LDFLAGS
567 _CS_LFS64_LIBS,
568#define _CS_LFS64_LIBS _CS_LFS64_LIBS
569 _CS_LFS64_LINTFLAGS,
570#define _CS_LFS64_LINTFLAGS _CS_LFS64_LINTFLAGS
571
572 _CS_XBS5_ILP32_OFF32_CFLAGS = 1100,
573#define _CS_XBS5_ILP32_OFF32_CFLAGS _CS_XBS5_ILP32_OFF32_CFLAGS
574 _CS_XBS5_ILP32_OFF32_LDFLAGS,
575#define _CS_XBS5_ILP32_OFF32_LDFLAGS _CS_XBS5_ILP32_OFF32_LDFLAGS
576 _CS_XBS5_ILP32_OFF32_LIBS,
577#define _CS_XBS5_ILP32_OFF32_LIBS _CS_XBS5_ILP32_OFF32_LIBS
578 _CS_XBS5_ILP32_OFF32_LINTFLAGS,
579#define _CS_XBS5_ILP32_OFF32_LINTFLAGS _CS_XBS5_ILP32_OFF32_LINTFLAGS
580 _CS_XBS5_ILP32_OFFBIG_CFLAGS,
581#define _CS_XBS5_ILP32_OFFBIG_CFLAGS _CS_XBS5_ILP32_OFFBIG_CFLAGS
582 _CS_XBS5_ILP32_OFFBIG_LDFLAGS,
583#define _CS_XBS5_ILP32_OFFBIG_LDFLAGS _CS_XBS5_ILP32_OFFBIG_LDFLAGS
584 _CS_XBS5_ILP32_OFFBIG_LIBS,
585#define _CS_XBS5_ILP32_OFFBIG_LIBS _CS_XBS5_ILP32_OFFBIG_LIBS
586 _CS_XBS5_ILP32_OFFBIG_LINTFLAGS,
587#define _CS_XBS5_ILP32_OFFBIG_LINTFLAGS _CS_XBS5_ILP32_OFFBIG_LINTFLAGS
588 _CS_XBS5_LP64_OFF64_CFLAGS,
589#define _CS_XBS5_LP64_OFF64_CFLAGS _CS_XBS5_LP64_OFF64_CFLAGS
590 _CS_XBS5_LP64_OFF64_LDFLAGS,
591#define _CS_XBS5_LP64_OFF64_LDFLAGS _CS_XBS5_LP64_OFF64_LDFLAGS
592 _CS_XBS5_LP64_OFF64_LIBS,
593#define _CS_XBS5_LP64_OFF64_LIBS _CS_XBS5_LP64_OFF64_LIBS
594 _CS_XBS5_LP64_OFF64_LINTFLAGS,
595#define _CS_XBS5_LP64_OFF64_LINTFLAGS _CS_XBS5_LP64_OFF64_LINTFLAGS
596 _CS_XBS5_LPBIG_OFFBIG_CFLAGS,
597#define _CS_XBS5_LPBIG_OFFBIG_CFLAGS _CS_XBS5_LPBIG_OFFBIG_CFLAGS
598 _CS_XBS5_LPBIG_OFFBIG_LDFLAGS,
599#define _CS_XBS5_LPBIG_OFFBIG_LDFLAGS _CS_XBS5_LPBIG_OFFBIG_LDFLAGS
600 _CS_XBS5_LPBIG_OFFBIG_LIBS,
601#define _CS_XBS5_LPBIG_OFFBIG_LIBS _CS_XBS5_LPBIG_OFFBIG_LIBS
602 _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS,
603#define _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS
604
605 _CS_POSIX_V6_ILP32_OFF32_CFLAGS,
606#define _CS_POSIX_V6_ILP32_OFF32_CFLAGS _CS_POSIX_V6_ILP32_OFF32_CFLAGS
607 _CS_POSIX_V6_ILP32_OFF32_LDFLAGS,
608#define _CS_POSIX_V6_ILP32_OFF32_LDFLAGS _CS_POSIX_V6_ILP32_OFF32_LDFLAGS
609 _CS_POSIX_V6_ILP32_OFF32_LIBS,
610#define _CS_POSIX_V6_ILP32_OFF32_LIBS _CS_POSIX_V6_ILP32_OFF32_LIBS
611 _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS,
612#define _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS
613 _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS,
614#define _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS
615 _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS,
616#define _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS
617 _CS_POSIX_V6_ILP32_OFFBIG_LIBS,
618#define _CS_POSIX_V6_ILP32_OFFBIG_LIBS _CS_POSIX_V6_ILP32_OFFBIG_LIBS
619 _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS,
620#define _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS
621 _CS_POSIX_V6_LP64_OFF64_CFLAGS,
622#define _CS_POSIX_V6_LP64_OFF64_CFLAGS _CS_POSIX_V6_LP64_OFF64_CFLAGS
623 _CS_POSIX_V6_LP64_OFF64_LDFLAGS,
624#define _CS_POSIX_V6_LP64_OFF64_LDFLAGS _CS_POSIX_V6_LP64_OFF64_LDFLAGS
625 _CS_POSIX_V6_LP64_OFF64_LIBS,
626#define _CS_POSIX_V6_LP64_OFF64_LIBS _CS_POSIX_V6_LP64_OFF64_LIBS
627 _CS_POSIX_V6_LP64_OFF64_LINTFLAGS,
628#define _CS_POSIX_V6_LP64_OFF64_LINTFLAGS _CS_POSIX_V6_LP64_OFF64_LINTFLAGS
629 _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS,
630#define _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS
631 _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS,
632#define _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS
633 _CS_POSIX_V6_LPBIG_OFFBIG_LIBS,
634#define _CS_POSIX_V6_LPBIG_OFFBIG_LIBS _CS_POSIX_V6_LPBIG_OFFBIG_LIBS
635 _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS,
636#define _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS
637
638 _CS_POSIX_V7_ILP32_OFF32_CFLAGS,
639#define _CS_POSIX_V7_ILP32_OFF32_CFLAGS _CS_POSIX_V7_ILP32_OFF32_CFLAGS
640 _CS_POSIX_V7_ILP32_OFF32_LDFLAGS,
641#define _CS_POSIX_V7_ILP32_OFF32_LDFLAGS _CS_POSIX_V7_ILP32_OFF32_LDFLAGS
642 _CS_POSIX_V7_ILP32_OFF32_LIBS,
643#define _CS_POSIX_V7_ILP32_OFF32_LIBS _CS_POSIX_V7_ILP32_OFF32_LIBS
644 _CS_POSIX_V7_ILP32_OFF32_LINTFLAGS,
645#define _CS_POSIX_V7_ILP32_OFF32_LINTFLAGS _CS_POSIX_V7_ILP32_OFF32_LINTFLAGS
646 _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS,
647#define _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS
648 _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS,
649#define _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS
650 _CS_POSIX_V7_ILP32_OFFBIG_LIBS,
651#define _CS_POSIX_V7_ILP32_OFFBIG_LIBS _CS_POSIX_V7_ILP32_OFFBIG_LIBS
652 _CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS,
653#define _CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS _CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS
654 _CS_POSIX_V7_LP64_OFF64_CFLAGS,
655#define _CS_POSIX_V7_LP64_OFF64_CFLAGS _CS_POSIX_V7_LP64_OFF64_CFLAGS
656 _CS_POSIX_V7_LP64_OFF64_LDFLAGS,
657#define _CS_POSIX_V7_LP64_OFF64_LDFLAGS _CS_POSIX_V7_LP64_OFF64_LDFLAGS
658 _CS_POSIX_V7_LP64_OFF64_LIBS,
659#define _CS_POSIX_V7_LP64_OFF64_LIBS _CS_POSIX_V7_LP64_OFF64_LIBS
660 _CS_POSIX_V7_LP64_OFF64_LINTFLAGS,
661#define _CS_POSIX_V7_LP64_OFF64_LINTFLAGS _CS_POSIX_V7_LP64_OFF64_LINTFLAGS
662 _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS,
663#define _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS
664 _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS,
665#define _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS
666 _CS_POSIX_V7_LPBIG_OFFBIG_LIBS,
667#define _CS_POSIX_V7_LPBIG_OFFBIG_LIBS _CS_POSIX_V7_LPBIG_OFFBIG_LIBS
668 _CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS,
669#define _CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS _CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS
670
671 _CS_V6_ENV,
672#define _CS_V6_ENV _CS_V6_ENV
673 _CS_V7_ENV
674#define _CS_V7_ENV _CS_V7_ENV
675 };
libc/glibc-include/bits/cpu-set.h created+124
...@@ -0,0 +1,124 @@
1/* Definition of the cpu_set_t structure used by the POSIX 1003.1b-1993
2 scheduling interface.
3 Copyright (C) 1996-2019 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
19
20#ifndef _BITS_CPU_SET_H
21#define _BITS_CPU_SET_H 1
22
23#ifndef _SCHED_H
24# error "Never include <bits/cpu-set.h> directly; use <sched.h> instead."
25#endif
26
27/* Size definition for CPU sets. */
28#define __CPU_SETSIZE 1024
29#define __NCPUBITS (8 * sizeof (__cpu_mask))
30
31/* Type for array elements in 'cpu_set_t'. */
32typedef __CPU_MASK_TYPE __cpu_mask;
33
34/* Basic access functions. */
35#define __CPUELT(cpu) ((cpu) / __NCPUBITS)
36#define __CPUMASK(cpu) ((__cpu_mask) 1 << ((cpu) % __NCPUBITS))
37
38/* Data structure to describe CPU mask. */
39typedef struct
40{
41 __cpu_mask __bits[__CPU_SETSIZE / __NCPUBITS];
42} cpu_set_t;
43
44/* Access functions for CPU masks. */
45#if __GNUC_PREREQ (2, 91)
46# define __CPU_ZERO_S(setsize, cpusetp) \
47 do __builtin_memset (cpusetp, '\0', setsize); while (0)
48#else
49# define __CPU_ZERO_S(setsize, cpusetp) \
50 do { \
51 size_t __i; \
52 size_t __imax = (setsize) / sizeof (__cpu_mask); \
53 __cpu_mask *__bits = (cpusetp)->__bits; \
54 for (__i = 0; __i < __imax; ++__i) \
55 __bits[__i] = 0; \
56 } while (0)
57#endif
58#define __CPU_SET_S(cpu, setsize, cpusetp) \
59 (__extension__ \
60 ({ size_t __cpu = (cpu); \
61 __cpu / 8 < (setsize) \
62 ? (((__cpu_mask *) ((cpusetp)->__bits))[__CPUELT (__cpu)] \
63 |= __CPUMASK (__cpu)) \
64 : 0; }))
65#define __CPU_CLR_S(cpu, setsize, cpusetp) \
66 (__extension__ \
67 ({ size_t __cpu = (cpu); \
68 __cpu / 8 < (setsize) \
69 ? (((__cpu_mask *) ((cpusetp)->__bits))[__CPUELT (__cpu)] \
70 &= ~__CPUMASK (__cpu)) \
71 : 0; }))
72#define __CPU_ISSET_S(cpu, setsize, cpusetp) \
73 (__extension__ \
74 ({ size_t __cpu = (cpu); \
75 __cpu / 8 < (setsize) \
76 ? ((((const __cpu_mask *) ((cpusetp)->__bits))[__CPUELT (__cpu)] \
77 & __CPUMASK (__cpu))) != 0 \
78 : 0; }))
79
80#define __CPU_COUNT_S(setsize, cpusetp) \
81 __sched_cpucount (setsize, cpusetp)
82
83#if __GNUC_PREREQ (2, 91)
84# define __CPU_EQUAL_S(setsize, cpusetp1, cpusetp2) \
85 (__builtin_memcmp (cpusetp1, cpusetp2, setsize) == 0)
86#else
87# define __CPU_EQUAL_S(setsize, cpusetp1, cpusetp2) \
88 (__extension__ \
89 ({ const __cpu_mask *__arr1 = (cpusetp1)->__bits; \
90 const __cpu_mask *__arr2 = (cpusetp2)->__bits; \
91 size_t __imax = (setsize) / sizeof (__cpu_mask); \
92 size_t __i; \
93 for (__i = 0; __i < __imax; ++__i) \
94 if (__arr1[__i] != __arr2[__i]) \
95 break; \
96 __i == __imax; }))
97#endif
98
99#define __CPU_OP_S(setsize, destset, srcset1, srcset2, op) \
100 (__extension__ \
101 ({ cpu_set_t *__dest = (destset); \
102 const __cpu_mask *__arr1 = (srcset1)->__bits; \
103 const __cpu_mask *__arr2 = (srcset2)->__bits; \
104 size_t __imax = (setsize) / sizeof (__cpu_mask); \
105 size_t __i; \
106 for (__i = 0; __i < __imax; ++__i) \
107 ((__cpu_mask *) __dest->__bits)[__i] = __arr1[__i] op __arr2[__i]; \
108 __dest; }))
109
110#define __CPU_ALLOC_SIZE(count) \
111 ((((count) + __NCPUBITS - 1) / __NCPUBITS) * sizeof (__cpu_mask))
112#define __CPU_ALLOC(count) __sched_cpualloc (count)
113#define __CPU_FREE(cpuset) __sched_cpufree (cpuset)
114
115__BEGIN_DECLS
116
117extern int __sched_cpucount (size_t __setsize, const cpu_set_t *__setp)
118 __THROW;
119extern cpu_set_t *__sched_cpualloc (size_t __count) __THROW __wur;
120extern void __sched_cpufree (cpu_set_t *__set) __THROW;
121
122__END_DECLS
123
124#endif /* bits/cpu-set.h */
libc/glibc-include/bits/dirent.h created+59
...@@ -0,0 +1,59 @@
1/* Copyright (C) 1996-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _DIRENT_H
19# error "Never use <bits/dirent.h> directly; include <dirent.h> instead."
20#endif
21
22struct dirent
23 {
24#ifndef __USE_FILE_OFFSET64
25 __ino_t d_ino;
26 __off_t d_off;
27#else
28 __ino64_t d_ino;
29 __off64_t d_off;
30#endif
31 unsigned short int d_reclen;
32 unsigned char d_type;
33 char d_name[256]; /* We must not include limits.h! */
34 };
35
36#ifdef __USE_LARGEFILE64
37struct dirent64
38 {
39 __ino64_t d_ino;
40 __off64_t d_off;
41 unsigned short int d_reclen;
42 unsigned char d_type;
43 char d_name[256]; /* We must not include limits.h! */
44 };
45#endif
46
47#define d_fileno d_ino /* Backwards compatibility. */
48
49#undef _DIRENT_HAVE_D_NAMLEN
50#define _DIRENT_HAVE_D_RECLEN
51#define _DIRENT_HAVE_D_OFF
52#define _DIRENT_HAVE_D_TYPE
53
54#if defined __OFF_T_MATCHES_OFF64_T && defined __INO_T_MATCHES_INO64_T
55/* Inform libc code that these two types are effectively identical. */
56# define _DIRENT_MATCHES_DIRENT64 1
57#else
58# define _DIRENT_MATCHES_DIRENT64 0
59#endif
libc/glibc-include/bits/dlfcn.h created+64
...@@ -0,0 +1,64 @@
1/* System dependent definitions for run-time dynamic loading.
2 Copyright (C) 1996-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _DLFCN_H
20# error "Never use <bits/dlfcn.h> directly; include <dlfcn.h> instead."
21#endif
22
23/* The MODE argument to `dlopen' contains one of the following: */
24#define RTLD_LAZY 0x00001 /* Lazy function call binding. */
25#define RTLD_NOW 0x00002 /* Immediate function call binding. */
26#define RTLD_BINDING_MASK 0x3 /* Mask of binding time value. */
27#define RTLD_NOLOAD 0x00004 /* Do not load the object. */
28#define RTLD_DEEPBIND 0x00008 /* Use deep binding. */
29
30/* If the following bit is set in the MODE argument to `dlopen',
31 the symbols of the loaded object and its dependencies are made
32 visible as if the object were linked directly into the program. */
33#define RTLD_GLOBAL 0x00100
34
35/* Unix98 demands the following flag which is the inverse to RTLD_GLOBAL.
36 The implementation does this by default and so we can define the
37 value to zero. */
38#define RTLD_LOCAL 0
39
40/* Do not delete object when closed. */
41#define RTLD_NODELETE 0x01000
42
43#ifdef __USE_GNU
44/* To support profiling of shared objects it is a good idea to call
45 the function found using `dlsym' using the following macro since
46 these calls do not use the PLT. But this would mean the dynamic
47 loader has no chance to find out when the function is called. The
48 macro applies the necessary magic so that profiling is possible.
49 Rewrite
50 foo = (*fctp) (arg1, arg2);
51 into
52 foo = DL_CALL_FCT (fctp, (arg1, arg2));
53*/
54# define DL_CALL_FCT(fctp, args) \
55 (_dl_mcount_wrapper_check ((void *) (fctp)), (*(fctp)) args)
56
57__BEGIN_DECLS
58
59/* This function calls the profiling functions. */
60extern void _dl_mcount_wrapper_check (void *__selfpc) __THROW;
61
62__END_DECLS
63
64#endif
libc/glibc-include/bits/elfclass.h created+14
...@@ -0,0 +1,14 @@
1/* This file specifies the native word size of the machine, which indicates
2 the ELF file class used for executables and shared objects on this
3 machine. */
4
5#ifndef _LINK_H
6# error "Never use <bits/elfclass.h> directly; include <link.h> instead."
7#endif
8
9#include <bits/wordsize.h>
10
11#define __ELF_NATIVE_CLASS __WORDSIZE
12
13/* The entries in the .hash table always have a size of 32 bits. */
14typedef uint32_t Elf_Symndx;
libc/glibc-include/bits/endian.h created+7
...@@ -0,0 +1,7 @@
1/* i386/x86_64 are little-endian. */
2
3#ifndef _ENDIAN_H
4# error "Never use <bits/endian.h> directly; include <endian.h> instead."
5#endif
6
7#define __BYTE_ORDER __LITTLE_ENDIAN
libc/glibc-include/bits/environments.h created+105
...@@ -0,0 +1,105 @@
1/* Copyright (C) 1999-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _UNISTD_H
19# error "Never include this file directly. Use <unistd.h> instead"
20#endif
21
22#include <bits/wordsize.h>
23
24/* This header should define the following symbols under the described
25 situations. A value `1' means that the model is always supported,
26 `-1' means it is never supported. Undefined means it cannot be
27 statically decided.
28
29 _POSIX_V7_ILP32_OFF32 32bit int, long, pointers, and off_t type
30 _POSIX_V7_ILP32_OFFBIG 32bit int, long, and pointers and larger off_t type
31
32 _POSIX_V7_LP64_OFF32 64bit long and pointers and 32bit off_t type
33 _POSIX_V7_LPBIG_OFFBIG 64bit long and pointers and large off_t type
34
35 The macros _POSIX_V6_ILP32_OFF32, _POSIX_V6_ILP32_OFFBIG,
36 _POSIX_V6_LP64_OFF32, _POSIX_V6_LPBIG_OFFBIG, _XBS5_ILP32_OFF32,
37 _XBS5_ILP32_OFFBIG, _XBS5_LP64_OFF32, and _XBS5_LPBIG_OFFBIG were
38 used in previous versions of the Unix standard and are available
39 only for compatibility.
40*/
41
42#if __WORDSIZE == 64
43
44/* Environments with 32-bit wide pointers are optionally provided.
45 Therefore following macros aren't defined:
46 # undef _POSIX_V7_ILP32_OFF32
47 # undef _POSIX_V7_ILP32_OFFBIG
48 # undef _POSIX_V6_ILP32_OFF32
49 # undef _POSIX_V6_ILP32_OFFBIG
50 # undef _XBS5_ILP32_OFF32
51 # undef _XBS5_ILP32_OFFBIG
52 and users need to check at runtime. */
53
54/* We also have no use (for now) for an environment with bigger pointers
55 and offsets. */
56# define _POSIX_V7_LPBIG_OFFBIG -1
57# define _POSIX_V6_LPBIG_OFFBIG -1
58# define _XBS5_LPBIG_OFFBIG -1
59
60/* By default we have 64-bit wide `long int', pointers and `off_t'. */
61# define _POSIX_V7_LP64_OFF64 1
62# define _POSIX_V6_LP64_OFF64 1
63# define _XBS5_LP64_OFF64 1
64
65#else /* __WORDSIZE == 32 */
66
67/* We have 32-bit wide `int', `long int' and pointers and all platforms
68 support LFS. -mx32 has 64-bit wide `off_t'. */
69# define _POSIX_V7_ILP32_OFFBIG 1
70# define _POSIX_V6_ILP32_OFFBIG 1
71# define _XBS5_ILP32_OFFBIG 1
72
73# ifndef __x86_64__
74/* -m32 has 32-bit wide `off_t'. */
75# define _POSIX_V7_ILP32_OFF32 1
76# define _POSIX_V6_ILP32_OFF32 1
77# define _XBS5_ILP32_OFF32 1
78# endif
79
80/* We optionally provide an environment with the above size but an 64-bit
81 side `off_t'. Therefore we don't define _POSIX_V7_ILP32_OFFBIG. */
82
83/* Environments with 64-bit wide pointers can be provided,
84 so these macros aren't defined:
85 # undef _POSIX_V7_LP64_OFF64
86 # undef _POSIX_V7_LPBIG_OFFBIG
87 # undef _POSIX_V6_LP64_OFF64
88 # undef _POSIX_V6_LPBIG_OFFBIG
89 # undef _XBS5_LP64_OFF64
90 # undef _XBS5_LPBIG_OFFBIG
91 and sysconf tests for it at runtime. */
92
93#endif /* __WORDSIZE == 32 */
94
95#define __ILP32_OFF32_CFLAGS "-m32"
96#define __ILP32_OFF32_LDFLAGS "-m32"
97#if defined __x86_64__ && defined __ILP32__
98# define __ILP32_OFFBIG_CFLAGS "-mx32"
99# define __ILP32_OFFBIG_LDFLAGS "-mx32"
100#else
101# define __ILP32_OFFBIG_CFLAGS "-m32 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
102# define __ILP32_OFFBIG_LDFLAGS "-m32"
103#endif
104#define __LP64_OFF64_CFLAGS "-m64"
105#define __LP64_OFF64_LDFLAGS "-m64"
libc/glibc-include/bits/epoll.h created+29
...@@ -0,0 +1,29 @@
1/* Copyright (C) 2002-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_EPOLL_H
19# error "Never use <bits/epoll.h> directly; include <sys/epoll.h> instead."
20#endif
21
22/* Flags to be passed to epoll_create1. */
23enum
24 {
25 EPOLL_CLOEXEC = 02000000
26#define EPOLL_CLOEXEC EPOLL_CLOEXEC
27 };
28
29#define __EPOLL_PACKED __attribute__ ((__packed__))
libc/glibc-include/bits/errno.h created+53
...@@ -0,0 +1,53 @@
1/* Error constants. Linux specific version.
2 Copyright (C) 1996-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_ERRNO_H
20#define _BITS_ERRNO_H 1
21
22#if !defined _ERRNO_H
23# error "Never include <bits/errno.h> directly; use <errno.h> instead."
24#endif
25
26# include <linux/errno.h>
27
28/* Older Linux headers do not define these constants. */
29# ifndef ENOTSUP
30# define ENOTSUP EOPNOTSUPP
31# endif
32
33# ifndef ECANCELED
34# define ECANCELED 125
35# endif
36
37# ifndef EOWNERDEAD
38# define EOWNERDEAD 130
39# endif
40
41#ifndef ENOTRECOVERABLE
42# define ENOTRECOVERABLE 131
43# endif
44
45# ifndef ERFKILL
46# define ERFKILL 132
47# endif
48
49# ifndef EHWPOISON
50# define EHWPOISON 133
51# endif
52
53#endif /* bits/errno.h. */
libc/glibc-include/bits/error.h created+73
...@@ -0,0 +1,73 @@
1/* Specializations for error functions.
2 Copyright (C) 2007-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _ERROR_H
20# error "Never include <bits/error.h> directly; use <error.h> instead."
21#endif
22
23
24extern void __REDIRECT (__error_alias, (int __status, int __errnum,
25 const char *__format, ...),
26 error)
27 __attribute__ ((__format__ (__printf__, 3, 4)));
28extern void __REDIRECT (__error_noreturn, (int __status, int __errnum,
29 const char *__format, ...),
30 error)
31 __attribute__ ((__noreturn__, __format__ (__printf__, 3, 4)));
32
33
34/* If we know the function will never return make sure the compiler
35 realizes that, too. */
36__extern_always_inline void
37error (int __status, int __errnum, const char *__format, ...)
38{
39 if (__builtin_constant_p (__status) && __status != 0)
40 __error_noreturn (__status, __errnum, __format, __va_arg_pack ());
41 else
42 __error_alias (__status, __errnum, __format, __va_arg_pack ());
43}
44
45
46extern void __REDIRECT (__error_at_line_alias, (int __status, int __errnum,
47 const char *__fname,
48 unsigned int __line,
49 const char *__format, ...),
50 error_at_line)
51 __attribute__ ((__format__ (__printf__, 5, 6)));
52extern void __REDIRECT (__error_at_line_noreturn, (int __status, int __errnum,
53 const char *__fname,
54 unsigned int __line,
55 const char *__format,
56 ...),
57 error_at_line)
58 __attribute__ ((__noreturn__, __format__ (__printf__, 5, 6)));
59
60
61/* If we know the function will never return make sure the compiler
62 realizes that, too. */
63__extern_always_inline void
64error_at_line (int __status, int __errnum, const char *__fname,
65 unsigned int __line, const char *__format, ...)
66{
67 if (__builtin_constant_p (__status) && __status != 0)
68 __error_at_line_noreturn (__status, __errnum, __fname, __line, __format,
69 __va_arg_pack ());
70 else
71 __error_at_line_alias (__status, __errnum, __fname, __line,
72 __format, __va_arg_pack ());
73}
libc/glibc-include/bits/eventfd.h created+31
...@@ -0,0 +1,31 @@
1/* Copyright (C) 2007-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_EVENTFD_H
19# error "Never use <bits/eventfd.h> directly; include <sys/eventfd.h> instead."
20#endif
21
22/* Flags for eventfd. */
23enum
24 {
25 EFD_SEMAPHORE = 00000001,
26#define EFD_SEMAPHORE EFD_SEMAPHORE
27 EFD_CLOEXEC = 02000000,
28#define EFD_CLOEXEC EFD_CLOEXEC
29 EFD_NONBLOCK = 00004000
30#define EFD_NONBLOCK EFD_NONBLOCK
31 };
libc/glibc-include/bits/fcntl-linux.h created+436
...@@ -0,0 +1,436 @@
1/* O_*, F_*, FD_* bit values for Linux.
2 Copyright (C) 2001-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _FCNTL_H
20# error "Never use <bits/fcntl-linux.h> directly; include <fcntl.h> instead."
21#endif
22
23/* This file contains shared definitions between Linux architectures
24 and is included by <bits/fcntl.h> to declare them. The various
25 #ifndef cases allow the architecture specific file to define those
26 values with different values.
27
28 A minimal <bits/fcntl.h> contains just:
29
30 struct flock {...}
31 #ifdef __USE_LARGEFILE64
32 struct flock64 {...}
33 #endif
34 #include <bits/fcntl-linux.h>
35*/
36
37#ifdef __USE_GNU
38# include <bits/types/struct_iovec.h>
39#endif
40
41/* open/fcntl. */
42#define O_ACCMODE 0003
43#define O_RDONLY 00
44#define O_WRONLY 01
45#define O_RDWR 02
46#ifndef O_CREAT
47# define O_CREAT 0100 /* Not fcntl. */
48#endif
49#ifndef O_EXCL
50# define O_EXCL 0200 /* Not fcntl. */
51#endif
52#ifndef O_NOCTTY
53# define O_NOCTTY 0400 /* Not fcntl. */
54#endif
55#ifndef O_TRUNC
56# define O_TRUNC 01000 /* Not fcntl. */
57#endif
58#ifndef O_APPEND
59# define O_APPEND 02000
60#endif
61#ifndef O_NONBLOCK
62# define O_NONBLOCK 04000
63#endif
64#ifndef O_NDELAY
65# define O_NDELAY O_NONBLOCK
66#endif
67#ifndef O_SYNC
68# define O_SYNC 04010000
69#endif
70#define O_FSYNC O_SYNC
71#ifndef O_ASYNC
72# define O_ASYNC 020000
73#endif
74#ifndef __O_LARGEFILE
75# define __O_LARGEFILE 0100000
76#endif
77
78#ifndef __O_DIRECTORY
79# define __O_DIRECTORY 0200000
80#endif
81#ifndef __O_NOFOLLOW
82# define __O_NOFOLLOW 0400000
83#endif
84#ifndef __O_CLOEXEC
85# define __O_CLOEXEC 02000000
86#endif
87#ifndef __O_DIRECT
88# define __O_DIRECT 040000
89#endif
90#ifndef __O_NOATIME
91# define __O_NOATIME 01000000
92#endif
93#ifndef __O_PATH
94# define __O_PATH 010000000
95#endif
96#ifndef __O_DSYNC
97# define __O_DSYNC 010000
98#endif
99#ifndef __O_TMPFILE
100# define __O_TMPFILE (020000000 | __O_DIRECTORY)
101#endif
102
103#ifndef F_GETLK
104# ifndef __USE_FILE_OFFSET64
105# define F_GETLK 5 /* Get record locking info. */
106# define F_SETLK 6 /* Set record locking info (non-blocking). */
107# define F_SETLKW 7 /* Set record locking info (blocking). */
108# else
109# define F_GETLK F_GETLK64 /* Get record locking info. */
110# define F_SETLK F_SETLK64 /* Set record locking info (non-blocking).*/
111# define F_SETLKW F_SETLKW64 /* Set record locking info (blocking). */
112# endif
113#endif
114#ifndef F_GETLK64
115# define F_GETLK64 12 /* Get record locking info. */
116# define F_SETLK64 13 /* Set record locking info (non-blocking). */
117# define F_SETLKW64 14 /* Set record locking info (blocking). */
118#endif
119
120/* open file description locks.
121
122 Usually record locks held by a process are released on *any* close and are
123 not inherited across a fork.
124
125 These cmd values will set locks that conflict with process-associated record
126 locks, but are "owned" by the opened file description, not the process.
127 This means that they are inherited across fork or clone with CLONE_FILES
128 like BSD (flock) locks, and they are only released automatically when the
129 last reference to the the file description against which they were acquired
130 is put. */
131#ifdef __USE_GNU
132# define F_OFD_GETLK 36
133# define F_OFD_SETLK 37
134# define F_OFD_SETLKW 38
135#endif
136
137#ifdef __USE_LARGEFILE64
138# define O_LARGEFILE __O_LARGEFILE
139#endif
140
141#ifdef __USE_XOPEN2K8
142# define O_DIRECTORY __O_DIRECTORY /* Must be a directory. */
143# define O_NOFOLLOW __O_NOFOLLOW /* Do not follow links. */
144# define O_CLOEXEC __O_CLOEXEC /* Set close_on_exec. */
145#endif
146
147#ifdef __USE_GNU
148# define O_DIRECT __O_DIRECT /* Direct disk access. */
149# define O_NOATIME __O_NOATIME /* Do not set atime. */
150# define O_PATH __O_PATH /* Resolve pathname but do not open file. */
151# define O_TMPFILE __O_TMPFILE /* Atomically create nameless file. */
152#endif
153
154/* For now, Linux has no separate synchronicity options for read
155 operations. We define O_RSYNC therefore as the same as O_SYNC
156 since this is a superset. */
157#if defined __USE_POSIX199309 || defined __USE_UNIX98
158# define O_DSYNC __O_DSYNC /* Synchronize data. */
159# if defined __O_RSYNC
160# define O_RSYNC __O_RSYNC /* Synchronize read operations. */
161# else
162# define O_RSYNC O_SYNC /* Synchronize read operations. */
163# endif
164#endif
165
166/* Values for the second argument to `fcntl'. */
167#define F_DUPFD 0 /* Duplicate file descriptor. */
168#define F_GETFD 1 /* Get file descriptor flags. */
169#define F_SETFD 2 /* Set file descriptor flags. */
170#define F_GETFL 3 /* Get file status flags. */
171#define F_SETFL 4 /* Set file status flags. */
172
173#ifndef __F_SETOWN
174# define __F_SETOWN 8
175# define __F_GETOWN 9
176#endif
177
178#if defined __USE_UNIX98 || defined __USE_XOPEN2K8
179# define F_SETOWN __F_SETOWN /* Get owner (process receiving SIGIO). */
180# define F_GETOWN __F_GETOWN /* Set owner (process receiving SIGIO). */
181#endif
182
183#ifndef __F_SETSIG
184# define __F_SETSIG 10 /* Set number of signal to be sent. */
185# define __F_GETSIG 11 /* Get number of signal to be sent. */
186#endif
187#ifndef __F_SETOWN_EX
188# define __F_SETOWN_EX 15 /* Get owner (thread receiving SIGIO). */
189# define __F_GETOWN_EX 16 /* Set owner (thread receiving SIGIO). */
190#endif
191
192#ifdef __USE_GNU
193# define F_SETSIG __F_SETSIG /* Set number of signal to be sent. */
194# define F_GETSIG __F_GETSIG /* Get number of signal to be sent. */
195# define F_SETOWN_EX __F_SETOWN_EX /* Get owner (thread receiving SIGIO). */
196# define F_GETOWN_EX __F_GETOWN_EX /* Set owner (thread receiving SIGIO). */
197#endif
198
199#ifdef __USE_GNU
200# define F_SETLEASE 1024 /* Set a lease. */
201# define F_GETLEASE 1025 /* Enquire what lease is active. */
202# define F_NOTIFY 1026 /* Request notifications on a directory. */
203# define F_SETPIPE_SZ 1031 /* Set pipe page size array. */
204# define F_GETPIPE_SZ 1032 /* Set pipe page size array. */
205# define F_ADD_SEALS 1033 /* Add seals to file. */
206# define F_GET_SEALS 1034 /* Get seals for file. */
207/* Set / get write life time hints. */
208# define F_GET_RW_HINT 1035
209# define F_SET_RW_HINT 1036
210# define F_GET_FILE_RW_HINT 1037
211# define F_SET_FILE_RW_HINT 1038
212#endif
213#ifdef __USE_XOPEN2K8
214# define F_DUPFD_CLOEXEC 1030 /* Duplicate file descriptor with
215 close-on-exit set. */
216#endif
217
218/* For F_[GET|SET]FD. */
219#define FD_CLOEXEC 1 /* Actually anything with low bit set goes */
220
221#ifndef F_RDLCK
222/* For posix fcntl() and `l_type' field of a `struct flock' for lockf(). */
223# define F_RDLCK 0 /* Read lock. */
224# define F_WRLCK 1 /* Write lock. */
225# define F_UNLCK 2 /* Remove lock. */
226#endif
227
228
229/* For old implementation of BSD flock. */
230#ifndef F_EXLCK
231# define F_EXLCK 4 /* or 3 */
232# define F_SHLCK 8 /* or 4 */
233#endif
234
235#ifdef __USE_MISC
236/* Operations for BSD flock, also used by the kernel implementation. */
237# define LOCK_SH 1 /* Shared lock. */
238# define LOCK_EX 2 /* Exclusive lock. */
239# define LOCK_NB 4 /* Or'd with one of the above to prevent
240 blocking. */
241# define LOCK_UN 8 /* Remove lock. */
242#endif
243
244#ifdef __USE_GNU
245# define LOCK_MAND 32 /* This is a mandatory flock: */
246# define LOCK_READ 64 /* ... which allows concurrent read operations. */
247# define LOCK_WRITE 128 /* ... which allows concurrent write operations. */
248# define LOCK_RW 192 /* ... Which allows concurrent read & write operations. */
249#endif
250
251#ifdef __USE_GNU
252/* Types of directory notifications that may be requested with F_NOTIFY. */
253# define DN_ACCESS 0x00000001 /* File accessed. */
254# define DN_MODIFY 0x00000002 /* File modified. */
255# define DN_CREATE 0x00000004 /* File created. */
256# define DN_DELETE 0x00000008 /* File removed. */
257# define DN_RENAME 0x00000010 /* File renamed. */
258# define DN_ATTRIB 0x00000020 /* File changed attributes. */
259# define DN_MULTISHOT 0x80000000 /* Don't remove notifier. */
260#endif
261
262
263#ifdef __USE_GNU
264/* Owner types. */
265enum __pid_type
266 {
267 F_OWNER_TID = 0, /* Kernel thread. */
268 F_OWNER_PID, /* Process. */
269 F_OWNER_PGRP, /* Process group. */
270 F_OWNER_GID = F_OWNER_PGRP /* Alternative, obsolete name. */
271 };
272
273/* Structure to use with F_GETOWN_EX and F_SETOWN_EX. */
274struct f_owner_ex
275 {
276 enum __pid_type type; /* Owner type of ID. */
277 __pid_t pid; /* ID of owner. */
278 };
279#endif
280
281#ifdef __USE_GNU
282/* Types of seals. */
283# define F_SEAL_SEAL 0x0001 /* Prevent further seals from being set. */
284# define F_SEAL_SHRINK 0x0002 /* Prevent file from shrinking. */
285# define F_SEAL_GROW 0x0004 /* Prevent file from growing. */
286# define F_SEAL_WRITE 0x0008 /* Prevent writes. */
287#endif
288
289#ifdef __USE_GNU
290/* Hint values for F_{GET,SET}_RW_HINT. */
291# define RWF_WRITE_LIFE_NOT_SET 0
292# define RWH_WRITE_LIFE_NONE 1
293# define RWH_WRITE_LIFE_SHORT 2
294# define RWH_WRITE_LIFE_MEDIUM 3
295# define RWH_WRITE_LIFE_LONG 4
296# define RWH_WRITE_LIFE_EXTREME 5
297#endif
298
299/* Define some more compatibility macros to be backward compatible with
300 BSD systems which did not managed to hide these kernel macros. */
301#ifdef __USE_MISC
302# define FAPPEND O_APPEND
303# define FFSYNC O_FSYNC
304# define FASYNC O_ASYNC
305# define FNONBLOCK O_NONBLOCK
306# define FNDELAY O_NDELAY
307#endif /* Use misc. */
308
309#ifndef __POSIX_FADV_DONTNEED
310# define __POSIX_FADV_DONTNEED 4
311# define __POSIX_FADV_NOREUSE 5
312#endif
313/* Advise to `posix_fadvise'. */
314#ifdef __USE_XOPEN2K
315# define POSIX_FADV_NORMAL 0 /* No further special treatment. */
316# define POSIX_FADV_RANDOM 1 /* Expect random page references. */
317# define POSIX_FADV_SEQUENTIAL 2 /* Expect sequential page references. */
318# define POSIX_FADV_WILLNEED 3 /* Will need these pages. */
319# define POSIX_FADV_DONTNEED __POSIX_FADV_DONTNEED /* Don't need these pages. */
320# define POSIX_FADV_NOREUSE __POSIX_FADV_NOREUSE /* Data will be accessed once. */
321#endif
322
323
324#ifdef __USE_GNU
325/* Flags for SYNC_FILE_RANGE. */
326# define SYNC_FILE_RANGE_WAIT_BEFORE 1 /* Wait upon writeout of all pages
327 in the range before performing the
328 write. */
329# define SYNC_FILE_RANGE_WRITE 2 /* Initiate writeout of all those
330 dirty pages in the range which are
331 not presently under writeback. */
332# define SYNC_FILE_RANGE_WAIT_AFTER 4 /* Wait upon writeout of all pages in
333 the range after performing the
334 write. */
335
336/* Flags for SPLICE and VMSPLICE. */
337# define SPLICE_F_MOVE 1 /* Move pages instead of copying. */
338# define SPLICE_F_NONBLOCK 2 /* Don't block on the pipe splicing
339 (but we may still block on the fd
340 we splice from/to). */
341# define SPLICE_F_MORE 4 /* Expect more data. */
342# define SPLICE_F_GIFT 8 /* Pages passed in are a gift. */
343
344
345/* Flags for fallocate. */
346# include <linux/falloc.h>
347
348
349/* File handle structure. */
350struct file_handle
351{
352 unsigned int handle_bytes;
353 int handle_type;
354 /* File identifier. */
355 unsigned char f_handle[0];
356};
357
358/* Maximum handle size (for now). */
359# define MAX_HANDLE_SZ 128
360#endif
361
362__BEGIN_DECLS
363
364#ifdef __USE_GNU
365
366/* Provide kernel hint to read ahead. */
367extern __ssize_t readahead (int __fd, __off64_t __offset, size_t __count)
368 __THROW;
369
370
371/* Selective file content synch'ing.
372
373 This function is a possible cancellation point and therefore not
374 marked with __THROW. */
375extern int sync_file_range (int __fd, __off64_t __offset, __off64_t __count,
376 unsigned int __flags);
377
378
379/* Splice address range into a pipe.
380
381 This function is a possible cancellation point and therefore not
382 marked with __THROW. */
383extern __ssize_t vmsplice (int __fdout, const struct iovec *__iov,
384 size_t __count, unsigned int __flags);
385
386/* Splice two files together.
387
388 This function is a possible cancellation point and therefore not
389 marked with __THROW. */
390extern __ssize_t splice (int __fdin, __off64_t *__offin, int __fdout,
391 __off64_t *__offout, size_t __len,
392 unsigned int __flags);
393
394/* In-kernel implementation of tee for pipe buffers.
395
396 This function is a possible cancellation point and therefore not
397 marked with __THROW. */
398extern __ssize_t tee (int __fdin, int __fdout, size_t __len,
399 unsigned int __flags);
400
401/* Reserve storage for the data of the file associated with FD.
402
403 This function is a possible cancellation point and therefore not
404 marked with __THROW. */
405# ifndef __USE_FILE_OFFSET64
406extern int fallocate (int __fd, int __mode, __off_t __offset, __off_t __len);
407# else
408# ifdef __REDIRECT
409extern int __REDIRECT (fallocate, (int __fd, int __mode, __off64_t __offset,
410 __off64_t __len),
411 fallocate64);
412# else
413# define fallocate fallocate64
414# endif
415# endif
416# ifdef __USE_LARGEFILE64
417extern int fallocate64 (int __fd, int __mode, __off64_t __offset,
418 __off64_t __len);
419# endif
420
421
422/* Map file name to file handle. */
423extern int name_to_handle_at (int __dfd, const char *__name,
424 struct file_handle *__handle, int *__mnt_id,
425 int __flags) __THROW;
426
427/* Open file using the file handle.
428
429 This function is a possible cancellation point and therefore not
430 marked with __THROW. */
431extern int open_by_handle_at (int __mountdirfd, struct file_handle *__handle,
432 int __flags);
433
434#endif /* use GNU */
435
436__END_DECLS
libc/glibc-include/bits/fcntl.h created+61
...@@ -0,0 +1,61 @@
1/* O_*, F_*, FD_* bit values for Linux/x86.
2 Copyright (C) 2001-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _FCNTL_H
20# error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
21#endif
22
23#ifdef __x86_64__
24# define __O_LARGEFILE 0
25#endif
26
27#ifdef __x86_64__
28/* Not necessary, we always have 64-bit offsets. */
29# define F_GETLK64 5 /* Get record locking info. */
30# define F_SETLK64 6 /* Set record locking info (non-blocking). */
31# define F_SETLKW64 7 /* Set record locking info (blocking). */
32#endif
33
34
35struct flock
36 {
37 short int l_type; /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK. */
38 short int l_whence; /* Where `l_start' is relative to (like `lseek'). */
39#ifndef __USE_FILE_OFFSET64
40 __off_t l_start; /* Offset where the lock begins. */
41 __off_t l_len; /* Size of the locked area; zero means until EOF. */
42#else
43 __off64_t l_start; /* Offset where the lock begins. */
44 __off64_t l_len; /* Size of the locked area; zero means until EOF. */
45#endif
46 __pid_t l_pid; /* Process holding the lock. */
47 };
48
49#ifdef __USE_LARGEFILE64
50struct flock64
51 {
52 short int l_type; /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK. */
53 short int l_whence; /* Where `l_start' is relative to (like `lseek'). */
54 __off64_t l_start; /* Offset where the lock begins. */
55 __off64_t l_len; /* Size of the locked area; zero means until EOF. */
56 __pid_t l_pid; /* Process holding the lock. */
57 };
58#endif
59
60/* Include generic Linux declarations. */
61#include <bits/fcntl-linux.h>
libc/glibc-include/bits/fcntl2.h created+172
...@@ -0,0 +1,172 @@
1/* Checking macros for fcntl functions.
2 Copyright (C) 2007-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _FCNTL_H
20# error "Never include <bits/fcntl2.h> directly; use <fcntl.h> instead."
21#endif
22
23/* Check that calls to open and openat with O_CREAT or O_TMPFILE set have an
24 appropriate third/fourth parameter. */
25#ifndef __USE_FILE_OFFSET64
26extern int __open_2 (const char *__path, int __oflag) __nonnull ((1));
27extern int __REDIRECT (__open_alias, (const char *__path, int __oflag, ...),
28 open) __nonnull ((1));
29#else
30extern int __REDIRECT (__open_2, (const char *__path, int __oflag),
31 __open64_2) __nonnull ((1));
32extern int __REDIRECT (__open_alias, (const char *__path, int __oflag, ...),
33 open64) __nonnull ((1));
34#endif
35__errordecl (__open_too_many_args,
36 "open can be called either with 2 or 3 arguments, not more");
37__errordecl (__open_missing_mode,
38 "open with O_CREAT or O_TMPFILE in second argument needs 3 arguments");
39
40__fortify_function int
41open (const char *__path, int __oflag, ...)
42{
43 if (__va_arg_pack_len () > 1)
44 __open_too_many_args ();
45
46 if (__builtin_constant_p (__oflag))
47 {
48 if (__OPEN_NEEDS_MODE (__oflag) && __va_arg_pack_len () < 1)
49 {
50 __open_missing_mode ();
51 return __open_2 (__path, __oflag);
52 }
53 return __open_alias (__path, __oflag, __va_arg_pack ());
54 }
55
56 if (__va_arg_pack_len () < 1)
57 return __open_2 (__path, __oflag);
58
59 return __open_alias (__path, __oflag, __va_arg_pack ());
60}
61
62
63#ifdef __USE_LARGEFILE64
64extern int __open64_2 (const char *__path, int __oflag) __nonnull ((1));
65extern int __REDIRECT (__open64_alias, (const char *__path, int __oflag,
66 ...), open64) __nonnull ((1));
67__errordecl (__open64_too_many_args,
68 "open64 can be called either with 2 or 3 arguments, not more");
69__errordecl (__open64_missing_mode,
70 "open64 with O_CREAT or O_TMPFILE in second argument needs 3 arguments");
71
72__fortify_function int
73open64 (const char *__path, int __oflag, ...)
74{
75 if (__va_arg_pack_len () > 1)
76 __open64_too_many_args ();
77
78 if (__builtin_constant_p (__oflag))
79 {
80 if (__OPEN_NEEDS_MODE (__oflag) && __va_arg_pack_len () < 1)
81 {
82 __open64_missing_mode ();
83 return __open64_2 (__path, __oflag);
84 }
85 return __open64_alias (__path, __oflag, __va_arg_pack ());
86 }
87
88 if (__va_arg_pack_len () < 1)
89 return __open64_2 (__path, __oflag);
90
91 return __open64_alias (__path, __oflag, __va_arg_pack ());
92}
93#endif
94
95
96#ifdef __USE_ATFILE
97# ifndef __USE_FILE_OFFSET64
98extern int __openat_2 (int __fd, const char *__path, int __oflag)
99 __nonnull ((2));
100extern int __REDIRECT (__openat_alias, (int __fd, const char *__path,
101 int __oflag, ...), openat)
102 __nonnull ((2));
103# else
104extern int __REDIRECT (__openat_2, (int __fd, const char *__path,
105 int __oflag), __openat64_2)
106 __nonnull ((2));
107extern int __REDIRECT (__openat_alias, (int __fd, const char *__path,
108 int __oflag, ...), openat64)
109 __nonnull ((2));
110# endif
111__errordecl (__openat_too_many_args,
112 "openat can be called either with 3 or 4 arguments, not more");
113__errordecl (__openat_missing_mode,
114 "openat with O_CREAT or O_TMPFILE in third argument needs 4 arguments");
115
116__fortify_function int
117openat (int __fd, const char *__path, int __oflag, ...)
118{
119 if (__va_arg_pack_len () > 1)
120 __openat_too_many_args ();
121
122 if (__builtin_constant_p (__oflag))
123 {
124 if (__OPEN_NEEDS_MODE (__oflag) && __va_arg_pack_len () < 1)
125 {
126 __openat_missing_mode ();
127 return __openat_2 (__fd, __path, __oflag);
128 }
129 return __openat_alias (__fd, __path, __oflag, __va_arg_pack ());
130 }
131
132 if (__va_arg_pack_len () < 1)
133 return __openat_2 (__fd, __path, __oflag);
134
135 return __openat_alias (__fd, __path, __oflag, __va_arg_pack ());
136}
137
138
139# ifdef __USE_LARGEFILE64
140extern int __openat64_2 (int __fd, const char *__path, int __oflag)
141 __nonnull ((2));
142extern int __REDIRECT (__openat64_alias, (int __fd, const char *__path,
143 int __oflag, ...), openat64)
144 __nonnull ((2));
145__errordecl (__openat64_too_many_args,
146 "openat64 can be called either with 3 or 4 arguments, not more");
147__errordecl (__openat64_missing_mode,
148 "openat64 with O_CREAT or O_TMPFILE in third argument needs 4 arguments");
149
150__fortify_function int
151openat64 (int __fd, const char *__path, int __oflag, ...)
152{
153 if (__va_arg_pack_len () > 1)
154 __openat64_too_many_args ();
155
156 if (__builtin_constant_p (__oflag))
157 {
158 if (__OPEN_NEEDS_MODE (__oflag) && __va_arg_pack_len () < 1)
159 {
160 __openat64_missing_mode ();
161 return __openat64_2 (__fd, __path, __oflag);
162 }
163 return __openat64_alias (__fd, __path, __oflag, __va_arg_pack ());
164 }
165
166 if (__va_arg_pack_len () < 1)
167 return __openat64_2 (__fd, __path, __oflag);
168
169 return __openat64_alias (__fd, __path, __oflag, __va_arg_pack ());
170}
171# endif
172#endif
libc/glibc-include/bits/fenv.h created+170
...@@ -0,0 +1,170 @@
1/* Copyright (C) 1997-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _FENV_H
19# error "Never use <bits/fenv.h> directly; include <fenv.h> instead."
20#endif
21
22/* Define bits representing the exception. We use the bit positions
23 of the appropriate bits in the FPU control word. */
24enum
25 {
26 FE_INVALID =
27#define FE_INVALID 0x01
28 FE_INVALID,
29 __FE_DENORM = 0x02,
30 FE_DIVBYZERO =
31#define FE_DIVBYZERO 0x04
32 FE_DIVBYZERO,
33 FE_OVERFLOW =
34#define FE_OVERFLOW 0x08
35 FE_OVERFLOW,
36 FE_UNDERFLOW =
37#define FE_UNDERFLOW 0x10
38 FE_UNDERFLOW,
39 FE_INEXACT =
40#define FE_INEXACT 0x20
41 FE_INEXACT
42 };
43
44#define FE_ALL_EXCEPT \
45 (FE_INEXACT | FE_DIVBYZERO | FE_UNDERFLOW | FE_OVERFLOW | FE_INVALID)
46
47/* The ix87 FPU supports all of the four defined rounding modes. We
48 use again the bit positions in the FPU control word as the values
49 for the appropriate macros. */
50enum
51 {
52 FE_TONEAREST =
53#define FE_TONEAREST 0
54 FE_TONEAREST,
55 FE_DOWNWARD =
56#define FE_DOWNWARD 0x400
57 FE_DOWNWARD,
58 FE_UPWARD =
59#define FE_UPWARD 0x800
60 FE_UPWARD,
61 FE_TOWARDZERO =
62#define FE_TOWARDZERO 0xc00
63 FE_TOWARDZERO
64 };
65
66
67/* Type representing exception flags. */
68typedef unsigned short int fexcept_t;
69
70
71/* Type representing floating-point environment. This structure
72 corresponds to the layout of the block written by the `fstenv'
73 instruction and has additional fields for the contents of the MXCSR
74 register as written by the `stmxcsr' instruction. */
75typedef struct
76 {
77 unsigned short int __control_word;
78 unsigned short int __glibc_reserved1;
79 unsigned short int __status_word;
80 unsigned short int __glibc_reserved2;
81 unsigned short int __tags;
82 unsigned short int __glibc_reserved3;
83 unsigned int __eip;
84 unsigned short int __cs_selector;
85 unsigned int __opcode:11;
86 unsigned int __glibc_reserved4:5;
87 unsigned int __data_offset;
88 unsigned short int __data_selector;
89 unsigned short int __glibc_reserved5;
90#ifdef __x86_64__
91 unsigned int __mxcsr;
92#endif
93 }
94fenv_t;
95
96/* If the default argument is used we use this value. */
97#define FE_DFL_ENV ((const fenv_t *) -1)
98
99#ifdef __USE_GNU
100/* Floating-point environment where none of the exception is masked. */
101# define FE_NOMASK_ENV ((const fenv_t *) -2)
102#endif
103
104#if __GLIBC_USE (IEC_60559_BFP_EXT)
105/* Type representing floating-point control modes. */
106typedef struct
107 {
108 unsigned short int __control_word;
109 unsigned short int __glibc_reserved;
110 unsigned int __mxcsr;
111 }
112femode_t;
113
114/* Default floating-point control modes. */
115# define FE_DFL_MODE ((const femode_t *) -1L)
116#endif
117
118
119#ifdef __USE_EXTERN_INLINES
120__BEGIN_DECLS
121
122/* Optimized versions. */
123#ifndef _LIBC
124extern int __REDIRECT_NTH (__feraiseexcept_renamed, (int), feraiseexcept);
125#endif
126__extern_always_inline void
127__NTH (__feraiseexcept_invalid_divbyzero (int __excepts))
128{
129 if ((FE_INVALID & __excepts) != 0)
130 {
131 /* One example of an invalid operation is 0.0 / 0.0. */
132 float __f = 0.0;
133
134# ifdef __SSE_MATH__
135 __asm__ __volatile__ ("divss %0, %0 " : : "x" (__f));
136# else
137 __asm__ __volatile__ ("fdiv %%st, %%st(0); fwait"
138 : "=t" (__f) : "0" (__f));
139# endif
140 (void) &__f;
141 }
142 if ((FE_DIVBYZERO & __excepts) != 0)
143 {
144 float __f = 1.0;
145 float __g = 0.0;
146
147# ifdef __SSE_MATH__
148 __asm__ __volatile__ ("divss %1, %0" : : "x" (__f), "x" (__g));
149# else
150 __asm__ __volatile__ ("fdivp %%st, %%st(1); fwait"
151 : "=t" (__f) : "0" (__f), "u" (__g) : "st(1)");
152# endif
153 (void) &__f;
154 }
155}
156__extern_inline int
157__NTH (feraiseexcept (int __excepts))
158{
159 if (__builtin_constant_p (__excepts)
160 && (__excepts & ~(FE_INVALID | FE_DIVBYZERO)) == 0)
161 {
162 __feraiseexcept_invalid_divbyzero (__excepts);
163 return 0;
164 }
165
166 return __feraiseexcept_renamed (__excepts);
167}
168
169__END_DECLS
170#endif
libc/glibc-include/bits/fenvinline.h created+8
...@@ -0,0 +1,8 @@
1/* This file provides inline versions of floating-pint environment
2 handling functions. If there were any. */
3
4#ifndef __NO_MATH_INLINES
5
6/* Here is where the code would go. */
7
8#endif
libc/glibc-include/bits/floatn-common.h created+329
...@@ -0,0 +1,329 @@
1/* Macros to control TS 18661-3 glibc features where the same
2 definitions are appropriate for all platforms.
3 Copyright (C) 2017-2019 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
19
20#ifndef _BITS_FLOATN_COMMON_H
21#define _BITS_FLOATN_COMMON_H
22
23#include <features.h>
24#include <bits/long-double.h>
25
26/* This header should be included at the bottom of each bits/floatn.h.
27 It defines the following macros for each _FloatN and _FloatNx type,
28 where the same definitions, or definitions based only on the macros
29 in bits/floatn.h, are appropriate for all glibc configurations. */
30
31/* Defined to 1 if the current compiler invocation provides a
32 floating-point type with the right format for this type, and this
33 glibc includes corresponding *fN or *fNx interfaces for it. */
34#define __HAVE_FLOAT16 0
35#define __HAVE_FLOAT32 1
36#define __HAVE_FLOAT64 1
37#define __HAVE_FLOAT32X 1
38#define __HAVE_FLOAT128X 0
39
40/* Defined to 1 if the corresponding __HAVE_<type> macro is 1 and the
41 type is the first with its format in the sequence of (the default
42 choices for) float, double, long double, _Float16, _Float32,
43 _Float64, _Float128, _Float32x, _Float64x, _Float128x for this
44 glibc; that is, if functions present once per floating-point format
45 rather than once per type are present for this type.
46
47 All configurations supported by glibc have _Float32 the same format
48 as float, _Float64 and _Float32x the same format as double, the
49 _Float64x the same format as either long double or _Float128. No
50 configurations support _Float128x or, as of GCC 7, have compiler
51 support for a type meeting the requirements for _Float128x. */
52#define __HAVE_DISTINCT_FLOAT16 __HAVE_FLOAT16
53#define __HAVE_DISTINCT_FLOAT32 0
54#define __HAVE_DISTINCT_FLOAT64 0
55#define __HAVE_DISTINCT_FLOAT32X 0
56#define __HAVE_DISTINCT_FLOAT64X 0
57#define __HAVE_DISTINCT_FLOAT128X __HAVE_FLOAT128X
58
59/* Defined to 1 if the corresponding _FloatN type is not binary compatible
60 with the corresponding ISO C type in the current compilation unit as
61 opposed to __HAVE_DISTINCT_FLOATN, which indicates the default types built
62 in glibc. */
63#define __HAVE_FLOAT128_UNLIKE_LDBL (__HAVE_DISTINCT_FLOAT128 \
64 && __LDBL_MANT_DIG__ != 113)
65
66/* Defined to 1 if any _FloatN or _FloatNx types that are not
67 ABI-distinct are however distinct types at the C language level (so
68 for the purposes of __builtin_types_compatible_p and _Generic). */
69#if __GNUC_PREREQ (7, 0) && !defined __cplusplus
70# define __HAVE_FLOATN_NOT_TYPEDEF 1
71#else
72# define __HAVE_FLOATN_NOT_TYPEDEF 0
73#endif
74
75#ifndef __ASSEMBLER__
76
77/* Defined to concatenate the literal suffix to be used with _FloatN
78 or _FloatNx types, if __HAVE_<type> is 1. The corresponding
79 literal suffixes exist since GCC 7, for C only. */
80# if __HAVE_FLOAT16
81# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
82/* No corresponding suffix available for this type. */
83# define __f16(x) ((_Float16) x##f)
84# else
85# define __f16(x) x##f16
86# endif
87# endif
88
89# if __HAVE_FLOAT32
90# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
91# define __f32(x) x##f
92# else
93# define __f32(x) x##f32
94# endif
95# endif
96
97# if __HAVE_FLOAT64
98# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
99# ifdef __NO_LONG_DOUBLE_MATH
100# define __f64(x) x##l
101# else
102# define __f64(x) x
103# endif
104# else
105# define __f64(x) x##f64
106# endif
107# endif
108
109# if __HAVE_FLOAT32X
110# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
111# define __f32x(x) x
112# else
113# define __f32x(x) x##f32x
114# endif
115# endif
116
117# if __HAVE_FLOAT64X
118# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
119# if __HAVE_FLOAT64X_LONG_DOUBLE
120# define __f64x(x) x##l
121# else
122# define __f64x(x) __f128 (x)
123# endif
124# else
125# define __f64x(x) x##f64x
126# endif
127# endif
128
129# if __HAVE_FLOAT128X
130# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
131# error "_Float128X supported but no constant suffix"
132# else
133# define __f128x(x) x##f128x
134# endif
135# endif
136
137/* Defined to a complex type if __HAVE_<type> is 1. */
138# if __HAVE_FLOAT16
139# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
140typedef _Complex float __cfloat16 __attribute__ ((__mode__ (__HC__)));
141# define __CFLOAT16 __cfloat16
142# else
143# define __CFLOAT16 _Complex _Float16
144# endif
145# endif
146
147# if __HAVE_FLOAT32
148# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
149# define __CFLOAT32 _Complex float
150# else
151# define __CFLOAT32 _Complex _Float32
152# endif
153# endif
154
155# if __HAVE_FLOAT64
156# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
157# ifdef __NO_LONG_DOUBLE_MATH
158# define __CFLOAT64 _Complex long double
159# else
160# define __CFLOAT64 _Complex double
161# endif
162# else
163# define __CFLOAT64 _Complex _Float64
164# endif
165# endif
166
167# if __HAVE_FLOAT32X
168# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
169# define __CFLOAT32X _Complex double
170# else
171# define __CFLOAT32X _Complex _Float32x
172# endif
173# endif
174
175# if __HAVE_FLOAT64X
176# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
177# if __HAVE_FLOAT64X_LONG_DOUBLE
178# define __CFLOAT64X _Complex long double
179# else
180# define __CFLOAT64X __CFLOAT128
181# endif
182# else
183# define __CFLOAT64X _Complex _Float64x
184# endif
185# endif
186
187# if __HAVE_FLOAT128X
188# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
189# error "_Float128X supported but no complex type"
190# else
191# define __CFLOAT128X _Complex _Float128x
192# endif
193# endif
194
195/* The remaining of this file provides support for older compilers. */
196# if __HAVE_FLOAT16
197
198# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
199typedef float _Float16 __attribute__ ((__mode__ (__HF__)));
200# endif
201
202# if !__GNUC_PREREQ (7, 0)
203# define __builtin_huge_valf16() ((_Float16) __builtin_huge_val ())
204# define __builtin_inff16() ((_Float16) __builtin_inf ())
205# define __builtin_nanf16(x) ((_Float16) __builtin_nan (x))
206# define __builtin_nansf16(x) ((_Float16) __builtin_nans (x))
207# endif
208
209# endif
210
211# if __HAVE_FLOAT32
212
213# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
214typedef float _Float32;
215# endif
216
217# if !__GNUC_PREREQ (7, 0)
218# define __builtin_huge_valf32() (__builtin_huge_valf ())
219# define __builtin_inff32() (__builtin_inff ())
220# define __builtin_nanf32(x) (__builtin_nanf (x))
221# define __builtin_nansf32(x) (__builtin_nansf (x))
222# endif
223
224# endif
225
226# if __HAVE_FLOAT64
227
228/* If double, long double and _Float64 all have the same set of
229 values, TS 18661-3 requires the usual arithmetic conversions on
230 long double and _Float64 to produce _Float64. For this to be the
231 case when building with a compiler without a distinct _Float64
232 type, _Float64 must be a typedef for long double, not for
233 double. */
234
235# ifdef __NO_LONG_DOUBLE_MATH
236
237# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
238typedef long double _Float64;
239# endif
240
241# if !__GNUC_PREREQ (7, 0)
242# define __builtin_huge_valf64() (__builtin_huge_vall ())
243# define __builtin_inff64() (__builtin_infl ())
244# define __builtin_nanf64(x) (__builtin_nanl (x))
245# define __builtin_nansf64(x) (__builtin_nansl (x))
246# endif
247
248# else
249
250# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
251typedef double _Float64;
252# endif
253
254# if !__GNUC_PREREQ (7, 0)
255# define __builtin_huge_valf64() (__builtin_huge_val ())
256# define __builtin_inff64() (__builtin_inf ())
257# define __builtin_nanf64(x) (__builtin_nan (x))
258# define __builtin_nansf64(x) (__builtin_nans (x))
259# endif
260
261# endif
262
263# endif
264
265# if __HAVE_FLOAT32X
266
267# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
268typedef double _Float32x;
269# endif
270
271# if !__GNUC_PREREQ (7, 0)
272# define __builtin_huge_valf32x() (__builtin_huge_val ())
273# define __builtin_inff32x() (__builtin_inf ())
274# define __builtin_nanf32x(x) (__builtin_nan (x))
275# define __builtin_nansf32x(x) (__builtin_nans (x))
276# endif
277
278# endif
279
280# if __HAVE_FLOAT64X
281
282# if __HAVE_FLOAT64X_LONG_DOUBLE
283
284# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
285typedef long double _Float64x;
286# endif
287
288# if !__GNUC_PREREQ (7, 0)
289# define __builtin_huge_valf64x() (__builtin_huge_vall ())
290# define __builtin_inff64x() (__builtin_infl ())
291# define __builtin_nanf64x(x) (__builtin_nanl (x))
292# define __builtin_nansf64x(x) (__builtin_nansl (x))
293# endif
294
295# else
296
297# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
298typedef _Float128 _Float64x;
299# endif
300
301# if !__GNUC_PREREQ (7, 0)
302# define __builtin_huge_valf64x() (__builtin_huge_valf128 ())
303# define __builtin_inff64x() (__builtin_inff128 ())
304# define __builtin_nanf64x(x) (__builtin_nanf128 (x))
305# define __builtin_nansf64x(x) (__builtin_nansf128 (x))
306# endif
307
308# endif
309
310# endif
311
312# if __HAVE_FLOAT128X
313
314# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
315# error "_Float128x supported but no type"
316# endif
317
318# if !__GNUC_PREREQ (7, 0)
319# define __builtin_huge_valf128x() ((_Float128x) __builtin_huge_val ())
320# define __builtin_inff128x() ((_Float128x) __builtin_inf ())
321# define __builtin_nanf128x(x) ((_Float128x) __builtin_nan (x))
322# define __builtin_nansf128x(x) ((_Float128x) __builtin_nans (x))
323# endif
324
325# endif
326
327#endif /* !__ASSEMBLER__. */
328
329#endif /* _BITS_FLOATN_COMMON_H */
libc/glibc-include/bits/floatn.h created+121
...@@ -0,0 +1,121 @@
1/* Macros to control TS 18661-3 glibc features on x86.
2 Copyright (C) 2017-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_FLOATN_H
20#define _BITS_FLOATN_H
21
22#include <features.h>
23
24/* Defined to 1 if the current compiler invocation provides a
25 floating-point type with the IEEE 754 binary128 format, and this
26 glibc includes corresponding *f128 interfaces for it. The required
27 libgcc support was added some time after the basic compiler
28 support, for x86_64 and x86. */
29#if (defined __x86_64__ \
30 ? __GNUC_PREREQ (4, 3) \
31 : (defined __GNU__ ? __GNUC_PREREQ (4, 5) : __GNUC_PREREQ (4, 4)))
32# define __HAVE_FLOAT128 1
33#else
34# define __HAVE_FLOAT128 0
35#endif
36
37/* Defined to 1 if __HAVE_FLOAT128 is 1 and the type is ABI-distinct
38 from the default float, double and long double types in this glibc. */
39#if __HAVE_FLOAT128
40# define __HAVE_DISTINCT_FLOAT128 1
41#else
42# define __HAVE_DISTINCT_FLOAT128 0
43#endif
44
45/* Defined to 1 if the current compiler invocation provides a
46 floating-point type with the right format for _Float64x, and this
47 glibc includes corresponding *f64x interfaces for it. */
48#define __HAVE_FLOAT64X 1
49
50/* Defined to 1 if __HAVE_FLOAT64X is 1 and _Float64x has the format
51 of long double. Otherwise, if __HAVE_FLOAT64X is 1, _Float64x has
52 the format of _Float128, which must be different from that of long
53 double. */
54#define __HAVE_FLOAT64X_LONG_DOUBLE 1
55
56#ifndef __ASSEMBLER__
57
58/* Defined to concatenate the literal suffix to be used with _Float128
59 types, if __HAVE_FLOAT128 is 1. */
60# if __HAVE_FLOAT128
61# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
62/* The literal suffix f128 exists only since GCC 7.0. */
63# define __f128(x) x##q
64# else
65# define __f128(x) x##f128
66# endif
67# endif
68
69/* Defined to a complex binary128 type if __HAVE_FLOAT128 is 1. */
70# if __HAVE_FLOAT128
71# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
72/* Add a typedef for older GCC compilers which don't natively support
73 _Complex _Float128. */
74typedef _Complex float __cfloat128 __attribute__ ((__mode__ (__TC__)));
75# define __CFLOAT128 __cfloat128
76# else
77# define __CFLOAT128 _Complex _Float128
78# endif
79# endif
80
81/* The remaining of this file provides support for older compilers. */
82# if __HAVE_FLOAT128
83
84/* The type _Float128 exists only since GCC 7.0. */
85# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
86typedef __float128 _Float128;
87# endif
88
89/* __builtin_huge_valf128 doesn't exist before GCC 7.0. */
90# if !__GNUC_PREREQ (7, 0)
91# define __builtin_huge_valf128() ((_Float128) __builtin_huge_val ())
92# endif
93
94/* Older GCC has only a subset of built-in functions for _Float128 on
95 x86, and __builtin_infq is not usable in static initializers.
96 Converting a narrower sNaN to _Float128 produces a quiet NaN, so
97 attempts to use _Float128 sNaNs will not work properly with older
98 compilers. */
99# if !__GNUC_PREREQ (7, 0)
100# define __builtin_copysignf128 __builtin_copysignq
101# define __builtin_fabsf128 __builtin_fabsq
102# define __builtin_inff128() ((_Float128) __builtin_inf ())
103# define __builtin_nanf128(x) ((_Float128) __builtin_nan (x))
104# define __builtin_nansf128(x) ((_Float128) __builtin_nans (x))
105# endif
106
107/* In math/math.h, __MATH_TG will expand signbit to __builtin_signbit*,
108 e.g.: __builtin_signbitf128, before GCC 6. However, there has never
109 been a __builtin_signbitf128 in GCC and the type-generic builtin is
110 only available since GCC 6. */
111# if !__GNUC_PREREQ (6, 0)
112# define __builtin_signbitf128 __signbitf128
113# endif
114
115# endif
116
117#endif /* !__ASSEMBLER__. */
118
119#include <bits/floatn-common.h>
120
121#endif /* _BITS_FLOATN_H */
libc/glibc-include/bits/flt-eval-method.h created+33
...@@ -0,0 +1,33 @@
1/* Define __GLIBC_FLT_EVAL_METHOD. x86 version.
2 Copyright (C) 2016-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _MATH_H
20# error "Never use <bits/flt-eval-method.h> directly; include <math.h> instead."
21#endif
22
23#ifdef __FLT_EVAL_METHOD__
24# if __FLT_EVAL_METHOD__ == -1
25# define __GLIBC_FLT_EVAL_METHOD 2
26# else
27# define __GLIBC_FLT_EVAL_METHOD __FLT_EVAL_METHOD__
28# endif
29#elif defined __x86_64__
30# define __GLIBC_FLT_EVAL_METHOD 0
31#else
32# define __GLIBC_FLT_EVAL_METHOD 2
33#endif
libc/glibc-include/bits/fp-fast.h created+39
...@@ -0,0 +1,39 @@
1/* Define FP_FAST_* macros.
2 Copyright (C) 2016-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _MATH_H
20# error "Never use <bits/fp-fast.h> directly; include <math.h> instead."
21#endif
22
23#ifdef __USE_ISOC99
24
25/* The GCC 4.6 compiler will define __FP_FAST_FMA{,F,L} if the fma{,f,l}
26 builtins are supported. */
27# ifdef __FP_FAST_FMA
28# define FP_FAST_FMA 1
29# endif
30
31# ifdef __FP_FAST_FMAF
32# define FP_FAST_FMAF 1
33# endif
34
35# ifdef __FP_FAST_FMAL
36# define FP_FAST_FMAL 1
37# endif
38
39#endif
libc/glibc-include/bits/fp-logb.h created+24
...@@ -0,0 +1,24 @@
1/* Define __FP_LOGB0_IS_MIN and __FP_LOGBNAN_IS_MIN. x86 version.
2 Copyright (C) 2016-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _MATH_H
20# error "Never use <bits/fp-logb.h> directly; include <math.h> instead."
21#endif
22
23#define __FP_LOGB0_IS_MIN 1
24#define __FP_LOGBNAN_IS_MIN 1
libc/glibc-include/bits/getopt_core.h created+96
...@@ -0,0 +1,96 @@
1/* Declarations for getopt (basic, portable features only).
2 Copyright (C) 1989-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library and is also part of gnulib.
4 Patches to this file should be submitted to both projects.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
19
20#ifndef _GETOPT_CORE_H
21#define _GETOPT_CORE_H 1
22
23/* This header should not be used directly; include getopt.h or
24 unistd.h instead. Unlike most bits headers, it does not have
25 a protective #error, because the guard macro for getopt.h in
26 gnulib is not fixed. */
27
28__BEGIN_DECLS
29
30/* For communication from 'getopt' to the caller.
31 When 'getopt' finds an option that takes an argument,
32 the argument value is returned here.
33 Also, when 'ordering' is RETURN_IN_ORDER,
34 each non-option ARGV-element is returned here. */
35
36extern char *optarg;
37
38/* Index in ARGV of the next element to be scanned.
39 This is used for communication to and from the caller
40 and for communication between successive calls to 'getopt'.
41
42 On entry to 'getopt', zero means this is the first call; initialize.
43
44 When 'getopt' returns -1, this is the index of the first of the
45 non-option elements that the caller should itself scan.
46
47 Otherwise, 'optind' communicates from one call to the next
48 how much of ARGV has been scanned so far. */
49
50extern int optind;
51
52/* Callers store zero here to inhibit the error message 'getopt' prints
53 for unrecognized options. */
54
55extern int opterr;
56
57/* Set to an option character which was unrecognized. */
58
59extern int optopt;
60
61/* Get definitions and prototypes for functions to process the
62 arguments in ARGV (ARGC of them, minus the program name) for
63 options given in OPTS.
64
65 Return the option character from OPTS just read. Return -1 when
66 there are no more options. For unrecognized options, or options
67 missing arguments, 'optopt' is set to the option letter, and '?' is
68 returned.
69
70 The OPTS string is a list of characters which are recognized option
71 letters, optionally followed by colons, specifying that that letter
72 takes an argument, to be placed in 'optarg'.
73
74 If a letter in OPTS is followed by two colons, its argument is
75 optional. This behavior is specific to the GNU 'getopt'.
76
77 The argument '--' causes premature termination of argument
78 scanning, explicitly telling 'getopt' that there are no more
79 options.
80
81 If OPTS begins with '-', then non-option arguments are treated as
82 arguments to the option '\1'. This behavior is specific to the GNU
83 'getopt'. If OPTS begins with '+', or POSIXLY_CORRECT is set in
84 the environment, then do not permute arguments.
85
86 For standards compliance, the 'argv' argument has the type
87 char *const *, but this is inaccurate; if argument permutation is
88 enabled, the argv array (not the strings it points to) must be
89 writable. */
90
91extern int getopt (int ___argc, char *const *___argv, const char *__shortopts)
92 __THROW __nonnull ((2, 3));
93
94__END_DECLS
95
96#endif /* getopt_core.h */
libc/glibc-include/bits/getopt_ext.h created+77
...@@ -0,0 +1,77 @@
1/* Declarations for getopt (GNU extensions).
2 Copyright (C) 1989-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library and is also part of gnulib.
4 Patches to this file should be submitted to both projects.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
19
20#ifndef _GETOPT_EXT_H
21#define _GETOPT_EXT_H 1
22
23/* This header should not be used directly; include getopt.h instead.
24 Unlike most bits headers, it does not have a protective #error,
25 because the guard macro for getopt.h in gnulib is not fixed. */
26
27__BEGIN_DECLS
28
29/* Describe the long-named options requested by the application.
30 The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
31 of 'struct option' terminated by an element containing a name which is
32 zero.
33
34 The field 'has_arg' is:
35 no_argument (or 0) if the option does not take an argument,
36 required_argument (or 1) if the option requires an argument,
37 optional_argument (or 2) if the option takes an optional argument.
38
39 If the field 'flag' is not NULL, it points to a variable that is set
40 to the value given in the field 'val' when the option is found, but
41 left unchanged if the option is not found.
42
43 To have a long-named option do something other than set an 'int' to
44 a compiled-in constant, such as set a value from 'optarg', set the
45 option's 'flag' field to zero and its 'val' field to a nonzero
46 value (the equivalent single-letter option character, if there is
47 one). For long options that have a zero 'flag' field, 'getopt'
48 returns the contents of the 'val' field. */
49
50struct option
51{
52 const char *name;
53 /* has_arg can't be an enum because some compilers complain about
54 type mismatches in all the code that assumes it is an int. */
55 int has_arg;
56 int *flag;
57 int val;
58};
59
60/* Names for the values of the 'has_arg' field of 'struct option'. */
61
62#define no_argument 0
63#define required_argument 1
64#define optional_argument 2
65
66extern int getopt_long (int ___argc, char *__getopt_argv_const *___argv,
67 const char *__shortopts,
68 const struct option *__longopts, int *__longind)
69 __THROW __nonnull ((2, 3));
70extern int getopt_long_only (int ___argc, char *__getopt_argv_const *___argv,
71 const char *__shortopts,
72 const struct option *__longopts, int *__longind)
73 __THROW __nonnull ((2, 3));
74
75__END_DECLS
76
77#endif /* getopt_ext.h */
libc/glibc-include/bits/getopt_posix.h created+51
...@@ -0,0 +1,51 @@
1/* Declarations for getopt (POSIX compatibility shim).
2 Copyright (C) 1989-2019 Free Software Foundation, Inc.
3 Unlike the bulk of the getopt implementation, this file is NOT part
4 of gnulib.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
19
20#ifndef _GETOPT_POSIX_H
21#define _GETOPT_POSIX_H 1
22
23#if !defined _UNISTD_H && !defined _STDIO_H
24#error "Never include getopt_posix.h directly; use unistd.h instead."
25#endif
26
27#include <bits/getopt_core.h>
28
29__BEGIN_DECLS
30
31#if defined __USE_POSIX2 && !defined __USE_POSIX_IMPLICITLY \
32 && !defined __USE_GNU && !defined _GETOPT_H
33/* GNU getopt has more functionality than POSIX getopt. When we are
34 explicitly conforming to POSIX and not GNU, and getopt.h (which is
35 not part of POSIX) has not been included, the extra functionality
36 is disabled. */
37# ifdef __REDIRECT
38extern int __REDIRECT_NTH (getopt, (int ___argc, char *const *___argv,
39 const char *__shortopts),
40 __posix_getopt);
41# else
42extern int __posix_getopt (int ___argc, char *const *___argv,
43 const char *__shortopts)
44 __THROW __nonnull ((2, 3));
45# define getopt __posix_getopt
46# endif
47#endif
48
49__END_DECLS
50
51#endif /* getopt_posix.h */
libc/glibc-include/bits/hwcap.h created+23
...@@ -0,0 +1,23 @@
1/* Defines for bits in AT_HWCAP.
2 Copyright (C) 2012-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SYS_AUXV_H
20# error "Never include <bits/hwcap.h> directly; use <sys/auxv.h> instead."
21#endif
22
23/* No bits defined for this architecture. */
libc/glibc-include/bits/in.h created+258
...@@ -0,0 +1,258 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/* Linux version. */
19
20#ifndef _NETINET_IN_H
21# error "Never use <bits/in.h> directly; include <netinet/in.h> instead."
22#endif
23
24/* If the application has already included linux/in6.h from a linux-based
25 kernel then we will not define the IPv6 IPPROTO_* defines, in6_addr (nor the
26 defines), sockaddr_in6, or ipv6_mreq. Same for in6_ptkinfo or ip6_mtuinfo
27 in linux/ipv6.h. The ABI used by the linux-kernel and glibc match exactly.
28 Neither the linux kernel nor glibc should break this ABI without coordination.
29 In upstream kernel 56c176c9 the _UAPI prefix was stripped so we need to check
30 for _LINUX_IN6_H and _IPV6_H now, and keep checking the old versions for
31 maximum backwards compatibility. */
32#if defined _UAPI_LINUX_IN6_H \
33 || defined _UAPI_IPV6_H \
34 || defined _LINUX_IN6_H \
35 || defined _IPV6_H
36/* This is not quite the same API since the kernel always defines s6_addr16 and
37 s6_addr32. This is not a violation of POSIX since POSIX says "at least the
38 following member" and that holds true. */
39# define __USE_KERNEL_IPV6_DEFS 1
40#else
41# define __USE_KERNEL_IPV6_DEFS 0
42#endif
43
44/* Options for use with `getsockopt' and `setsockopt' at the IP level.
45 The first word in the comment at the right is the data type used;
46 "bool" means a boolean value stored in an `int'. */
47#define IP_OPTIONS 4 /* ip_opts; IP per-packet options. */
48#define IP_HDRINCL 3 /* int; Header is included with data. */
49#define IP_TOS 1 /* int; IP type of service and precedence. */
50#define IP_TTL 2 /* int; IP time to live. */
51#define IP_RECVOPTS 6 /* bool; Receive all IP options w/datagram. */
52/* For BSD compatibility. */
53#define IP_RECVRETOPTS IP_RETOPTS /* bool; Receive IP options for response. */
54#define IP_RETOPTS 7 /* ip_opts; Set/get IP per-packet options. */
55#define IP_MULTICAST_IF 32 /* in_addr; set/get IP multicast i/f */
56#define IP_MULTICAST_TTL 33 /* unsigned char; set/get IP multicast ttl */
57#define IP_MULTICAST_LOOP 34 /* bool; set/get IP multicast loopback */
58#define IP_ADD_MEMBERSHIP 35 /* ip_mreq; add an IP group membership */
59#define IP_DROP_MEMBERSHIP 36 /* ip_mreq; drop an IP group membership */
60#define IP_UNBLOCK_SOURCE 37 /* ip_mreq_source: unblock data from source */
61#define IP_BLOCK_SOURCE 38 /* ip_mreq_source: block data from source */
62#define IP_ADD_SOURCE_MEMBERSHIP 39 /* ip_mreq_source: join source group */
63#define IP_DROP_SOURCE_MEMBERSHIP 40 /* ip_mreq_source: leave source group */
64#define IP_MSFILTER 41
65#ifdef __USE_MISC
66# define MCAST_JOIN_GROUP 42 /* group_req: join any-source group */
67# define MCAST_BLOCK_SOURCE 43 /* group_source_req: block from given group */
68# define MCAST_UNBLOCK_SOURCE 44 /* group_source_req: unblock from given group*/
69# define MCAST_LEAVE_GROUP 45 /* group_req: leave any-source group */
70# define MCAST_JOIN_SOURCE_GROUP 46 /* group_source_req: join source-spec gr */
71# define MCAST_LEAVE_SOURCE_GROUP 47 /* group_source_req: leave source-spec gr*/
72# define MCAST_MSFILTER 48
73# define IP_MULTICAST_ALL 49
74# define IP_UNICAST_IF 50
75
76# define MCAST_EXCLUDE 0
77# define MCAST_INCLUDE 1
78#endif
79
80#define IP_ROUTER_ALERT 5 /* bool */
81#define IP_PKTINFO 8 /* bool */
82#define IP_PKTOPTIONS 9
83#define IP_PMTUDISC 10 /* obsolete name? */
84#define IP_MTU_DISCOVER 10 /* int; see below */
85#define IP_RECVERR 11 /* bool */
86#define IP_RECVTTL 12 /* bool */
87#define IP_RECVTOS 13 /* bool */
88#define IP_MTU 14 /* int */
89#define IP_FREEBIND 15
90#define IP_IPSEC_POLICY 16
91#define IP_XFRM_POLICY 17
92#define IP_PASSSEC 18
93#define IP_TRANSPARENT 19
94#define IP_MULTICAST_ALL 49 /* bool */
95
96/* TProxy original addresses */
97#define IP_ORIGDSTADDR 20
98#define IP_RECVORIGDSTADDR IP_ORIGDSTADDR
99
100#define IP_MINTTL 21
101#define IP_NODEFRAG 22
102#define IP_CHECKSUM 23
103#define IP_BIND_ADDRESS_NO_PORT 24
104#define IP_RECVFRAGSIZE 25
105
106/* IP_MTU_DISCOVER arguments. */
107#define IP_PMTUDISC_DONT 0 /* Never send DF frames. */
108#define IP_PMTUDISC_WANT 1 /* Use per route hints. */
109#define IP_PMTUDISC_DO 2 /* Always DF. */
110#define IP_PMTUDISC_PROBE 3 /* Ignore dst pmtu. */
111/* Always use interface mtu (ignores dst pmtu) but don't set DF flag.
112 Also incoming ICMP frag_needed notifications will be ignored on
113 this socket to prevent accepting spoofed ones. */
114#define IP_PMTUDISC_INTERFACE 4
115/* Like IP_PMTUDISC_INTERFACE but allow packets to be fragmented. */
116#define IP_PMTUDISC_OMIT 5
117
118#define IP_MULTICAST_IF 32
119#define IP_MULTICAST_TTL 33
120#define IP_MULTICAST_LOOP 34
121#define IP_ADD_MEMBERSHIP 35
122#define IP_DROP_MEMBERSHIP 36
123#define IP_UNBLOCK_SOURCE 37
124#define IP_BLOCK_SOURCE 38
125#define IP_ADD_SOURCE_MEMBERSHIP 39
126#define IP_DROP_SOURCE_MEMBERSHIP 40
127#define IP_MSFILTER 41
128#define IP_MULTICAST_ALL 49
129#define IP_UNICAST_IF 50
130
131/* To select the IP level. */
132#define SOL_IP 0
133
134#define IP_DEFAULT_MULTICAST_TTL 1
135#define IP_DEFAULT_MULTICAST_LOOP 1
136#define IP_MAX_MEMBERSHIPS 20
137
138#ifdef __USE_MISC
139/* Structure used to describe IP options for IP_OPTIONS and IP_RETOPTS.
140 The `ip_dst' field is used for the first-hop gateway when using a
141 source route (this gets put into the header proper). */
142struct ip_opts
143 {
144 struct in_addr ip_dst; /* First hop; zero without source route. */
145 char ip_opts[40]; /* Actually variable in size. */
146 };
147
148/* Like `struct ip_mreq' but including interface specification by index. */
149struct ip_mreqn
150 {
151 struct in_addr imr_multiaddr; /* IP multicast address of group */
152 struct in_addr imr_address; /* local IP address of interface */
153 int imr_ifindex; /* Interface index */
154 };
155
156/* Structure used for IP_PKTINFO. */
157struct in_pktinfo
158 {
159 int ipi_ifindex; /* Interface index */
160 struct in_addr ipi_spec_dst; /* Routing destination address */
161 struct in_addr ipi_addr; /* Header destination address */
162 };
163#endif
164
165/* Options for use with `getsockopt' and `setsockopt' at the IPv6 level.
166 The first word in the comment at the right is the data type used;
167 "bool" means a boolean value stored in an `int'. */
168#define IPV6_ADDRFORM 1
169#define IPV6_2292PKTINFO 2
170#define IPV6_2292HOPOPTS 3
171#define IPV6_2292DSTOPTS 4
172#define IPV6_2292RTHDR 5
173#define IPV6_2292PKTOPTIONS 6
174#define IPV6_CHECKSUM 7
175#define IPV6_2292HOPLIMIT 8
176
177#define SCM_SRCRT IPV6_RXSRCRT
178
179#define IPV6_NEXTHOP 9
180#define IPV6_AUTHHDR 10
181#define IPV6_UNICAST_HOPS 16
182#define IPV6_MULTICAST_IF 17
183#define IPV6_MULTICAST_HOPS 18
184#define IPV6_MULTICAST_LOOP 19
185#define IPV6_JOIN_GROUP 20
186#define IPV6_LEAVE_GROUP 21
187#define IPV6_ROUTER_ALERT 22
188#define IPV6_MTU_DISCOVER 23
189#define IPV6_MTU 24
190#define IPV6_RECVERR 25
191#define IPV6_V6ONLY 26
192#define IPV6_JOIN_ANYCAST 27
193#define IPV6_LEAVE_ANYCAST 28
194#define IPV6_MULTICAST_ALL 29
195#define IPV6_IPSEC_POLICY 34
196#define IPV6_XFRM_POLICY 35
197#define IPV6_HDRINCL 36
198
199/* Advanced API (RFC3542) (1). */
200#define IPV6_RECVPKTINFO 49
201#define IPV6_PKTINFO 50
202#define IPV6_RECVHOPLIMIT 51
203#define IPV6_HOPLIMIT 52
204#define IPV6_RECVHOPOPTS 53
205#define IPV6_HOPOPTS 54
206#define IPV6_RTHDRDSTOPTS 55
207#define IPV6_RECVRTHDR 56
208#define IPV6_RTHDR 57
209#define IPV6_RECVDSTOPTS 58
210#define IPV6_DSTOPTS 59
211#define IPV6_RECVPATHMTU 60
212#define IPV6_PATHMTU 61
213#define IPV6_DONTFRAG 62
214
215/* Advanced API (RFC3542) (2). */
216#define IPV6_RECVTCLASS 66
217#define IPV6_TCLASS 67
218
219#define IPV6_AUTOFLOWLABEL 70
220
221/* RFC5014. */
222#define IPV6_ADDR_PREFERENCES 72
223
224/* RFC5082. */
225#define IPV6_MINHOPCOUNT 73
226
227#define IPV6_ORIGDSTADDR 74
228#define IPV6_RECVORIGDSTADDR IPV6_ORIGDSTADDR
229#define IPV6_TRANSPARENT 75
230#define IPV6_UNICAST_IF 76
231#define IPV6_RECVFRAGSIZE 77
232#define IPV6_FREEBIND 78
233
234/* Obsolete synonyms for the above. */
235#if !__USE_KERNEL_IPV6_DEFS
236# define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP
237# define IPV6_DROP_MEMBERSHIP IPV6_LEAVE_GROUP
238#endif
239#define IPV6_RXHOPOPTS IPV6_HOPOPTS
240#define IPV6_RXDSTOPTS IPV6_DSTOPTS
241
242/* IPV6_MTU_DISCOVER values. */
243#define IPV6_PMTUDISC_DONT 0 /* Never send DF frames. */
244#define IPV6_PMTUDISC_WANT 1 /* Use per route hints. */
245#define IPV6_PMTUDISC_DO 2 /* Always DF. */
246#define IPV6_PMTUDISC_PROBE 3 /* Ignore dst pmtu. */
247#define IPV6_PMTUDISC_INTERFACE 4 /* See IP_PMTUDISC_INTERFACE. */
248#define IPV6_PMTUDISC_OMIT 5 /* See IP_PMTUDISC_OMIT. */
249
250/* Socket level values for IPv6. */
251#define SOL_IPV6 41
252#define SOL_ICMPV6 58
253
254/* Routing header options for IPv6. */
255#define IPV6_RTHDR_LOOSE 0 /* Hop doesn't need to be neighbour. */
256#define IPV6_RTHDR_STRICT 1 /* Hop must be a neighbour. */
257
258#define IPV6_RTHDR_TYPE_0 0 /* IPv6 Routing header type 0. */
libc/glibc-include/bits/indirect-return.h created+37
...@@ -0,0 +1,37 @@
1/* Definition of __INDIRECT_RETURN. x86 version.
2 Copyright (C) 2018-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _UCONTEXT_H
20# error "Never include <bits/indirect-return.h> directly; use <ucontext.h> instead."
21#endif
22
23/* On x86, swapcontext returns via indirect branch when the shadow stack
24 is enabled. Define __INDIRECT_RETURN to indicate whether swapcontext
25 returns via indirect branch. */
26#if defined __CET__ && (__CET__ & 2) != 0
27# if __glibc_has_attribute (__indirect_return__)
28# define __INDIRECT_RETURN __attribute__ ((__indirect_return__))
29# else
30/* Newer compilers provide the indirect_return attribute, but without
31 it we can use returns_twice to affect the optimizer in the same
32 way and avoid unsafe optimizations. */
33# define __INDIRECT_RETURN __attribute__ ((__returns_twice__))
34# endif
35#else
36# define __INDIRECT_RETURN
37#endif
libc/glibc-include/bits/initspin.h created+1
...@@ -0,0 +1 @@
1/* No thread support. */
libc/glibc-include/bits/inotify.h created+29
...@@ -0,0 +1,29 @@
1/* Copyright (C) 2005-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_INOTIFY_H
19# error "Never use <bits/inotify.h> directly; include <sys/inotify.h> instead."
20#endif
21
22/* Flags for the parameter of inotify_init1. */
23enum
24 {
25 IN_CLOEXEC = 02000000,
26#define IN_CLOEXEC IN_CLOEXEC
27 IN_NONBLOCK = 00004000
28#define IN_NONBLOCK IN_NONBLOCK
29 };
libc/glibc-include/bits/ioctl-types.h created+77
...@@ -0,0 +1,77 @@
1/* Structure types for pre-termios terminal ioctls. Linux version.
2 Copyright (C) 1996-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SYS_IOCTL_H
20# error "Never use <bits/ioctl-types.h> directly; include <sys/ioctl.h> instead."
21#endif
22
23/* Get definition of constants for use with `ioctl'. */
24#include <asm/ioctls.h>
25
26
27struct winsize
28 {
29 unsigned short int ws_row;
30 unsigned short int ws_col;
31 unsigned short int ws_xpixel;
32 unsigned short int ws_ypixel;
33 };
34
35#define NCC 8
36struct termio
37 {
38 unsigned short int c_iflag; /* input mode flags */
39 unsigned short int c_oflag; /* output mode flags */
40 unsigned short int c_cflag; /* control mode flags */
41 unsigned short int c_lflag; /* local mode flags */
42 unsigned char c_line; /* line discipline */
43 unsigned char c_cc[NCC]; /* control characters */
44};
45
46/* modem lines */
47#define TIOCM_LE 0x001
48#define TIOCM_DTR 0x002
49#define TIOCM_RTS 0x004
50#define TIOCM_ST 0x008
51#define TIOCM_SR 0x010
52#define TIOCM_CTS 0x020
53#define TIOCM_CAR 0x040
54#define TIOCM_RNG 0x080
55#define TIOCM_DSR 0x100
56#define TIOCM_CD TIOCM_CAR
57#define TIOCM_RI TIOCM_RNG
58
59/* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */
60
61/* line disciplines */
62#define N_TTY 0
63#define N_SLIP 1
64#define N_MOUSE 2
65#define N_PPP 3
66#define N_STRIP 4
67#define N_AX25 5
68#define N_X25 6 /* X.25 async */
69#define N_6PACK 7
70#define N_MASC 8 /* Mobitex module */
71#define N_R3964 9 /* Simatic R3964 module */
72#define N_PROFIBUS_FDL 10 /* Profibus */
73#define N_IRDA 11 /* Linux IR */
74#define N_SMSBLOCK 12 /* SMS block mode */
75#define N_HDLC 13 /* synchronous HDLC */
76#define N_SYNC_PPP 14 /* synchronous PPP */
77#define N_HCI 15 /* Bluetooth HCI UART */
libc/glibc-include/bits/ioctls.h created+108
...@@ -0,0 +1,108 @@
1/* Copyright (C) 1996-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_IOCTL_H
19# error "Never use <bits/ioctls.h> directly; include <sys/ioctl.h> instead."
20#endif
21
22/* Use the definitions from the kernel header files. */
23#include <asm/ioctls.h>
24
25/* Routing table calls. */
26#define SIOCADDRT 0x890B /* add routing table entry */
27#define SIOCDELRT 0x890C /* delete routing table entry */
28#define SIOCRTMSG 0x890D /* call to routing system */
29
30/* Socket configuration controls. */
31#define SIOCGIFNAME 0x8910 /* get iface name */
32#define SIOCSIFLINK 0x8911 /* set iface channel */
33#define SIOCGIFCONF 0x8912 /* get iface list */
34#define SIOCGIFFLAGS 0x8913 /* get flags */
35#define SIOCSIFFLAGS 0x8914 /* set flags */
36#define SIOCGIFADDR 0x8915 /* get PA address */
37#define SIOCSIFADDR 0x8916 /* set PA address */
38#define SIOCGIFDSTADDR 0x8917 /* get remote PA address */
39#define SIOCSIFDSTADDR 0x8918 /* set remote PA address */
40#define SIOCGIFBRDADDR 0x8919 /* get broadcast PA address */
41#define SIOCSIFBRDADDR 0x891a /* set broadcast PA address */
42#define SIOCGIFNETMASK 0x891b /* get network PA mask */
43#define SIOCSIFNETMASK 0x891c /* set network PA mask */
44#define SIOCGIFMETRIC 0x891d /* get metric */
45#define SIOCSIFMETRIC 0x891e /* set metric */
46#define SIOCGIFMEM 0x891f /* get memory address (BSD) */
47#define SIOCSIFMEM 0x8920 /* set memory address (BSD) */
48#define SIOCGIFMTU 0x8921 /* get MTU size */
49#define SIOCSIFMTU 0x8922 /* set MTU size */
50#define SIOCSIFNAME 0x8923 /* set interface name */
51#define SIOCSIFHWADDR 0x8924 /* set hardware address */
52#define SIOCGIFENCAP 0x8925 /* get/set encapsulations */
53#define SIOCSIFENCAP 0x8926
54#define SIOCGIFHWADDR 0x8927 /* Get hardware address */
55#define SIOCGIFSLAVE 0x8929 /* Driver slaving support */
56#define SIOCSIFSLAVE 0x8930
57#define SIOCADDMULTI 0x8931 /* Multicast address lists */
58#define SIOCDELMULTI 0x8932
59#define SIOCGIFINDEX 0x8933 /* name -> if_index mapping */
60#define SIOGIFINDEX SIOCGIFINDEX /* misprint compatibility :-) */
61#define SIOCSIFPFLAGS 0x8934 /* set/get extended flags set */
62#define SIOCGIFPFLAGS 0x8935
63#define SIOCDIFADDR 0x8936 /* delete PA address */
64#define SIOCSIFHWBROADCAST 0x8937 /* set hardware broadcast addr */
65#define SIOCGIFCOUNT 0x8938 /* get number of devices */
66
67#define SIOCGIFBR 0x8940 /* Bridging support */
68#define SIOCSIFBR 0x8941 /* Set bridging options */
69
70#define SIOCGIFTXQLEN 0x8942 /* Get the tx queue length */
71#define SIOCSIFTXQLEN 0x8943 /* Set the tx queue length */
72
73
74/* ARP cache control calls. */
75 /* 0x8950 - 0x8952 * obsolete calls, don't re-use */
76#define SIOCDARP 0x8953 /* delete ARP table entry */
77#define SIOCGARP 0x8954 /* get ARP table entry */
78#define SIOCSARP 0x8955 /* set ARP table entry */
79
80/* RARP cache control calls. */
81#define SIOCDRARP 0x8960 /* delete RARP table entry */
82#define SIOCGRARP 0x8961 /* get RARP table entry */
83#define SIOCSRARP 0x8962 /* set RARP table entry */
84
85/* Driver configuration calls */
86
87#define SIOCGIFMAP 0x8970 /* Get device parameters */
88#define SIOCSIFMAP 0x8971 /* Set device parameters */
89
90/* DLCI configuration calls */
91
92#define SIOCADDDLCI 0x8980 /* Create new DLCI device */
93#define SIOCDELDLCI 0x8981 /* Delete DLCI device */
94
95/* Device private ioctl calls. */
96
97/* These 16 ioctls are available to devices via the do_ioctl() device
98 vector. Each device should include this file and redefine these
99 names as their own. Because these are device dependent it is a good
100 idea _NOT_ to issue them to random objects and hope. */
101
102#define SIOCDEVPRIVATE 0x89F0 /* to 89FF */
103
104/*
105 * These 16 ioctl calls are protocol private
106 */
107
108#define SIOCPROTOPRIVATE 0x89E0 /* to 89EF */
libc/glibc-include/bits/ipc.h created+55
...@@ -0,0 +1,55 @@
1/* Copyright (C) 1995-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_IPC_H
19# error "Never use <bits/ipc.h> directly; include <sys/ipc.h> instead."
20#endif
21
22#include <bits/types.h>
23
24/* Mode bits for `msgget', `semget', and `shmget'. */
25#define IPC_CREAT 01000 /* Create key if key does not exist. */
26#define IPC_EXCL 02000 /* Fail if key exists. */
27#define IPC_NOWAIT 04000 /* Return error on wait. */
28
29/* Control commands for `msgctl', `semctl', and `shmctl'. */
30#define IPC_RMID 0 /* Remove identifier. */
31#define IPC_SET 1 /* Set `ipc_perm' options. */
32#define IPC_STAT 2 /* Get `ipc_perm' options. */
33#ifdef __USE_GNU
34# define IPC_INFO 3 /* See ipcs. */
35#endif
36
37/* Special key values. */
38#define IPC_PRIVATE ((__key_t) 0) /* Private key. */
39
40
41/* Data structure used to pass permission information to IPC operations. */
42struct ipc_perm
43 {
44 __key_t __key; /* Key. */
45 __uid_t uid; /* Owner's user ID. */
46 __gid_t gid; /* Owner's group ID. */
47 __uid_t cuid; /* Creator's user ID. */
48 __gid_t cgid; /* Creator's group ID. */
49 unsigned short int mode; /* Read/write permission. */
50 unsigned short int __pad1;
51 unsigned short int __seq; /* Sequence number. */
52 unsigned short int __pad2;
53 __syscall_ulong_t __glibc_reserved1;
54 __syscall_ulong_t __glibc_reserved2;
55 };
libc/glibc-include/bits/ipctypes.h created+33
...@@ -0,0 +1,33 @@
1/* bits/ipctypes.h -- Define some types used by SysV IPC/MSG/SHM.
2 Copyright (C) 2012-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SYS_IPC_H
20# error "Never use <bits/ipctypes.h> directly; include <sys/ipc.h> instead."
21#endif
22
23#ifndef _BITS_IPCTYPES_H
24#define _BITS_IPCTYPES_H 1
25
26/* Used in `struct shmid_ds'. */
27# ifdef __x86_64__
28typedef int __ipc_pid_t;
29# else
30typedef unsigned short int __ipc_pid_t;
31# endif
32
33#endif /* bits/ipctypes.h */
libc/glibc-include/bits/iscanonical.h created+54
...@@ -0,0 +1,54 @@
1/* Define iscanonical macro. ldbl-96 version.
2 Copyright (C) 2016-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _MATH_H
20# error "Never use <bits/iscanonical.h> directly; include <math.h> instead."
21#endif
22
23extern int __iscanonicall (long double __x)
24 __THROW __attribute__ ((__const__));
25#define __iscanonicalf(x) ((void) (__typeof (x)) (x), 1)
26#define __iscanonical(x) ((void) (__typeof (x)) (x), 1)
27#if __HAVE_DISTINCT_FLOAT128
28# define __iscanonicalf128(x) ((void) (__typeof (x)) (x), 1)
29#endif
30
31/* Return nonzero value if X is canonical. In IEEE interchange binary
32 formats, all values are canonical, but the argument must still be
33 converted to its semantic type for any exceptions arising from the
34 conversion, before being discarded; in extended precision, there
35 are encodings that are not consistently handled as corresponding to
36 any particular value of the type, and we return 0 for those. */
37#ifndef __cplusplus
38# define iscanonical(x) __MATH_TG ((x), __iscanonical, (x))
39#else
40/* In C++ mode, __MATH_TG cannot be used, because it relies on
41 __builtin_types_compatible_p, which is a C-only builtin. On the
42 other hand, overloading provides the means to distinguish between
43 the floating-point types. The overloading resolution will match
44 the correct parameter (regardless of type qualifiers (i.e.: const
45 and volatile)). */
46extern "C++" {
47inline int iscanonical (float __val) { return __iscanonicalf (__val); }
48inline int iscanonical (double __val) { return __iscanonical (__val); }
49inline int iscanonical (long double __val) { return __iscanonicall (__val); }
50# if __HAVE_DISTINCT_FLOAT128
51inline int iscanonical (_Float128 __val) { return __iscanonicalf128 (__val); }
52# endif
53}
54#endif /* __cplusplus */
libc/glibc-include/bits/libc-header-start.h created+70
...@@ -0,0 +1,70 @@
1/* Handle feature test macros at the start of a header.
2 Copyright (C) 2016-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19/* This header is internal to glibc and should not be included outside
20 of glibc headers. Headers including it must define
21 __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION first. This header
22 cannot have multiple include guards because ISO C feature test
23 macros depend on the definition of the macro when an affected
24 header is included, not when the first system header is
25 included. */
26
27#ifndef __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION
28# error "Never include <bits/libc-header-start.h> directly."
29#endif
30
31#undef __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION
32
33#include <features.h>
34
35/* ISO/IEC TR 24731-2:2010 defines the __STDC_WANT_LIB_EXT2__
36 macro. */
37#undef __GLIBC_USE_LIB_EXT2
38#if (defined __USE_GNU \
39 || (defined __STDC_WANT_LIB_EXT2__ && __STDC_WANT_LIB_EXT2__ > 0))
40# define __GLIBC_USE_LIB_EXT2 1
41#else
42# define __GLIBC_USE_LIB_EXT2 0
43#endif
44
45/* ISO/IEC TS 18661-1:2014 defines the __STDC_WANT_IEC_60559_BFP_EXT__
46 macro. */
47#undef __GLIBC_USE_IEC_60559_BFP_EXT
48#if defined __USE_GNU || defined __STDC_WANT_IEC_60559_BFP_EXT__
49# define __GLIBC_USE_IEC_60559_BFP_EXT 1
50#else
51# define __GLIBC_USE_IEC_60559_BFP_EXT 0
52#endif
53
54/* ISO/IEC TS 18661-4:2015 defines the
55 __STDC_WANT_IEC_60559_FUNCS_EXT__ macro. */
56#undef __GLIBC_USE_IEC_60559_FUNCS_EXT
57#if defined __USE_GNU || defined __STDC_WANT_IEC_60559_FUNCS_EXT__
58# define __GLIBC_USE_IEC_60559_FUNCS_EXT 1
59#else
60# define __GLIBC_USE_IEC_60559_FUNCS_EXT 0
61#endif
62
63/* ISO/IEC TS 18661-3:2015 defines the
64 __STDC_WANT_IEC_60559_TYPES_EXT__ macro. */
65#undef __GLIBC_USE_IEC_60559_TYPES_EXT
66#if defined __USE_GNU || defined __STDC_WANT_IEC_60559_TYPES_EXT__
67# define __GLIBC_USE_IEC_60559_TYPES_EXT 1
68#else
69# define __GLIBC_USE_IEC_60559_TYPES_EXT 0
70#endif
libc/glibc-include/bits/libm-simd-decl-stubs.h created+101
...@@ -0,0 +1,101 @@
1/* Empty definitions required for __MATHCALL_VEC unfolding in mathcalls.h.
2 Copyright (C) 2014-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _MATH_H
20# error "Never include <bits/libm-simd-decl-stubs.h> directly;\
21 include <math.h> instead."
22#endif
23
24/* Needed definitions could be generated with:
25 for func in $(grep __MATHCALL_VEC math/bits/mathcalls.h |\
26 sed -r "s|__MATHCALL_VEC.?\(||; s|,.*||"); do
27 echo "#define __DECL_SIMD_${func}";
28 echo "#define __DECL_SIMD_${func}f";
29 echo "#define __DECL_SIMD_${func}l";
30 done
31 */
32
33#ifndef _BITS_LIBM_SIMD_DECL_STUBS_H
34#define _BITS_LIBM_SIMD_DECL_STUBS_H 1
35
36#define __DECL_SIMD_cos
37#define __DECL_SIMD_cosf
38#define __DECL_SIMD_cosl
39#define __DECL_SIMD_cosf16
40#define __DECL_SIMD_cosf32
41#define __DECL_SIMD_cosf64
42#define __DECL_SIMD_cosf128
43#define __DECL_SIMD_cosf32x
44#define __DECL_SIMD_cosf64x
45#define __DECL_SIMD_cosf128x
46
47#define __DECL_SIMD_sin
48#define __DECL_SIMD_sinf
49#define __DECL_SIMD_sinl
50#define __DECL_SIMD_sinf16
51#define __DECL_SIMD_sinf32
52#define __DECL_SIMD_sinf64
53#define __DECL_SIMD_sinf128
54#define __DECL_SIMD_sinf32x
55#define __DECL_SIMD_sinf64x
56#define __DECL_SIMD_sinf128x
57
58#define __DECL_SIMD_sincos
59#define __DECL_SIMD_sincosf
60#define __DECL_SIMD_sincosl
61#define __DECL_SIMD_sincosf16
62#define __DECL_SIMD_sincosf32
63#define __DECL_SIMD_sincosf64
64#define __DECL_SIMD_sincosf128
65#define __DECL_SIMD_sincosf32x
66#define __DECL_SIMD_sincosf64x
67#define __DECL_SIMD_sincosf128x
68
69#define __DECL_SIMD_log
70#define __DECL_SIMD_logf
71#define __DECL_SIMD_logl
72#define __DECL_SIMD_logf16
73#define __DECL_SIMD_logf32
74#define __DECL_SIMD_logf64
75#define __DECL_SIMD_logf128
76#define __DECL_SIMD_logf32x
77#define __DECL_SIMD_logf64x
78#define __DECL_SIMD_logf128x
79
80#define __DECL_SIMD_exp
81#define __DECL_SIMD_expf
82#define __DECL_SIMD_expl
83#define __DECL_SIMD_expf16
84#define __DECL_SIMD_expf32
85#define __DECL_SIMD_expf64
86#define __DECL_SIMD_expf128
87#define __DECL_SIMD_expf32x
88#define __DECL_SIMD_expf64x
89#define __DECL_SIMD_expf128x
90
91#define __DECL_SIMD_pow
92#define __DECL_SIMD_powf
93#define __DECL_SIMD_powl
94#define __DECL_SIMD_powf16
95#define __DECL_SIMD_powf32
96#define __DECL_SIMD_powf64
97#define __DECL_SIMD_powf128
98#define __DECL_SIMD_powf32x
99#define __DECL_SIMD_powf64x
100#define __DECL_SIMD_powf128x
101#endif
libc/glibc-include/bits/link.h created+159
...@@ -0,0 +1,159 @@
1/* Copyright (C) 2004-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _LINK_H
19# error "Never include <bits/link.h> directly; use <link.h> instead."
20#endif
21
22
23#ifndef __x86_64__
24/* Registers for entry into PLT on IA-32. */
25typedef struct La_i86_regs
26{
27 uint32_t lr_edx;
28 uint32_t lr_ecx;
29 uint32_t lr_eax;
30 uint32_t lr_ebp;
31 uint32_t lr_esp;
32} La_i86_regs;
33
34/* Return values for calls from PLT on IA-32. */
35typedef struct La_i86_retval
36{
37 uint32_t lrv_eax;
38 uint32_t lrv_edx;
39 long double lrv_st0;
40 long double lrv_st1;
41 uint64_t lrv_bnd0;
42 uint64_t lrv_bnd1;
43} La_i86_retval;
44
45
46__BEGIN_DECLS
47
48extern Elf32_Addr la_i86_gnu_pltenter (Elf32_Sym *__sym, unsigned int __ndx,
49 uintptr_t *__refcook,
50 uintptr_t *__defcook,
51 La_i86_regs *__regs,
52 unsigned int *__flags,
53 const char *__symname,
54 long int *__framesizep);
55extern unsigned int la_i86_gnu_pltexit (Elf32_Sym *__sym, unsigned int __ndx,
56 uintptr_t *__refcook,
57 uintptr_t *__defcook,
58 const La_i86_regs *__inregs,
59 La_i86_retval *__outregs,
60 const char *symname);
61
62__END_DECLS
63
64#else
65
66/* Registers for entry into PLT on x86-64. */
67# if __GNUC_PREREQ (4,0)
68typedef float La_x86_64_xmm __attribute__ ((__vector_size__ (16)));
69typedef float La_x86_64_ymm
70 __attribute__ ((__vector_size__ (32), __aligned__ (16)));
71typedef double La_x86_64_zmm
72 __attribute__ ((__vector_size__ (64), __aligned__ (16)));
73# else
74typedef float La_x86_64_xmm __attribute__ ((__mode__ (__V4SF__)));
75# endif
76
77typedef union
78{
79# if __GNUC_PREREQ (4,0)
80 La_x86_64_ymm ymm[2];
81 La_x86_64_zmm zmm[1];
82# endif
83 La_x86_64_xmm xmm[4];
84} La_x86_64_vector __attribute__ ((__aligned__ (16)));
85
86typedef struct La_x86_64_regs
87{
88 uint64_t lr_rdx;
89 uint64_t lr_r8;
90 uint64_t lr_r9;
91 uint64_t lr_rcx;
92 uint64_t lr_rsi;
93 uint64_t lr_rdi;
94 uint64_t lr_rbp;
95 uint64_t lr_rsp;
96 La_x86_64_xmm lr_xmm[8];
97 La_x86_64_vector lr_vector[8];
98#ifndef __ILP32__
99 __int128_t lr_bnd[4];
100#endif
101} La_x86_64_regs;
102
103/* Return values for calls from PLT on x86-64. */
104typedef struct La_x86_64_retval
105{
106 uint64_t lrv_rax;
107 uint64_t lrv_rdx;
108 La_x86_64_xmm lrv_xmm0;
109 La_x86_64_xmm lrv_xmm1;
110 long double lrv_st0;
111 long double lrv_st1;
112 La_x86_64_vector lrv_vector0;
113 La_x86_64_vector lrv_vector1;
114#ifndef __ILP32__
115 __int128_t lrv_bnd0;
116 __int128_t lrv_bnd1;
117#endif
118} La_x86_64_retval;
119
120#define La_x32_regs La_x86_64_regs
121#define La_x32_retval La_x86_64_retval
122
123__BEGIN_DECLS
124
125extern Elf64_Addr la_x86_64_gnu_pltenter (Elf64_Sym *__sym,
126 unsigned int __ndx,
127 uintptr_t *__refcook,
128 uintptr_t *__defcook,
129 La_x86_64_regs *__regs,
130 unsigned int *__flags,
131 const char *__symname,
132 long int *__framesizep);
133extern unsigned int la_x86_64_gnu_pltexit (Elf64_Sym *__sym,
134 unsigned int __ndx,
135 uintptr_t *__refcook,
136 uintptr_t *__defcook,
137 const La_x86_64_regs *__inregs,
138 La_x86_64_retval *__outregs,
139 const char *__symname);
140
141extern Elf32_Addr la_x32_gnu_pltenter (Elf32_Sym *__sym,
142 unsigned int __ndx,
143 uintptr_t *__refcook,
144 uintptr_t *__defcook,
145 La_x32_regs *__regs,
146 unsigned int *__flags,
147 const char *__symname,
148 long int *__framesizep);
149extern unsigned int la_x32_gnu_pltexit (Elf32_Sym *__sym,
150 unsigned int __ndx,
151 uintptr_t *__refcook,
152 uintptr_t *__defcook,
153 const La_x32_regs *__inregs,
154 La_x32_retval *__outregs,
155 const char *__symname);
156
157__END_DECLS
158
159#endif
libc/glibc-include/bits/local_lim.h created+99
...@@ -0,0 +1,99 @@
1/* Minimum guaranteed maximum values for system limits. Linux version.
2 Copyright (C) 1993-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If
17 not, see <http://www.gnu.org/licenses/>. */
18
19/* The kernel header pollutes the namespace with the NR_OPEN symbol
20 and defines LINK_MAX although filesystems have different maxima. A
21 similar thing is true for OPEN_MAX: the limit can be changed at
22 runtime and therefore the macro must not be defined. Remove this
23 after including the header if necessary. */
24#ifndef NR_OPEN
25# define __undef_NR_OPEN
26#endif
27#ifndef LINK_MAX
28# define __undef_LINK_MAX
29#endif
30#ifndef OPEN_MAX
31# define __undef_OPEN_MAX
32#endif
33#ifndef ARG_MAX
34# define __undef_ARG_MAX
35#endif
36
37/* The kernel sources contain a file with all the needed information. */
38#include <linux/limits.h>
39
40/* Have to remove NR_OPEN? */
41#ifdef __undef_NR_OPEN
42# undef NR_OPEN
43# undef __undef_NR_OPEN
44#endif
45/* Have to remove LINK_MAX? */
46#ifdef __undef_LINK_MAX
47# undef LINK_MAX
48# undef __undef_LINK_MAX
49#endif
50/* Have to remove OPEN_MAX? */
51#ifdef __undef_OPEN_MAX
52# undef OPEN_MAX
53# undef __undef_OPEN_MAX
54#endif
55/* Have to remove ARG_MAX? */
56#ifdef __undef_ARG_MAX
57# undef ARG_MAX
58# undef __undef_ARG_MAX
59#endif
60
61/* The number of data keys per process. */
62#define _POSIX_THREAD_KEYS_MAX 128
63/* This is the value this implementation supports. */
64#define PTHREAD_KEYS_MAX 1024
65
66/* Controlling the iterations of destructors for thread-specific data. */
67#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4
68/* Number of iterations this implementation does. */
69#define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS
70
71/* The number of threads per process. */
72#define _POSIX_THREAD_THREADS_MAX 64
73/* We have no predefined limit on the number of threads. */
74#undef PTHREAD_THREADS_MAX
75
76/* Maximum amount by which a process can descrease its asynchronous I/O
77 priority level. */
78#define AIO_PRIO_DELTA_MAX 20
79
80/* Minimum size for a thread. We are free to choose a reasonable value. */
81#define PTHREAD_STACK_MIN 16384
82
83/* Maximum number of timer expiration overruns. */
84#define DELAYTIMER_MAX 2147483647
85
86/* Maximum tty name length. */
87#define TTY_NAME_MAX 32
88
89/* Maximum login name length. This is arbitrary. */
90#define LOGIN_NAME_MAX 256
91
92/* Maximum host name length. */
93#define HOST_NAME_MAX 64
94
95/* Maximum message queue priority level. */
96#define MQ_PRIO_MAX 32768
97
98/* Maximum value the semaphore can have. */
99#define SEM_VALUE_MAX (2147483647)
libc/glibc-include/bits/locale.h created+40
...@@ -0,0 +1,40 @@
1/* Definition of locale category symbol values.
2 Copyright (C) 2001-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#if !defined _LOCALE_H && !defined _LANGINFO_H
20# error "Never use <bits/locale.h> directly; include <locale.h> instead."
21#endif
22
23#ifndef _BITS_LOCALE_H
24#define _BITS_LOCALE_H 1
25
26#define __LC_CTYPE 0
27#define __LC_NUMERIC 1
28#define __LC_TIME 2
29#define __LC_COLLATE 3
30#define __LC_MONETARY 4
31#define __LC_MESSAGES 5
32#define __LC_ALL 6
33#define __LC_PAPER 7
34#define __LC_NAME 8
35#define __LC_ADDRESS 9
36#define __LC_TELEPHONE 10
37#define __LC_MEASUREMENT 11
38#define __LC_IDENTIFICATION 12
39
40#endif /* bits/locale.h */
libc/glibc-include/bits/long-double.h created+20
...@@ -0,0 +1,20 @@
1/* Properties of long double type. ldbl-96 version.
2 Copyright (C) 2016-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19/* long double is distinct from double, so there is nothing to
20 define here. */
libc/glibc-include/bits/math-finite.h created+197
...@@ -0,0 +1,197 @@
1/* Entry points to finite-math-only compiler runs.
2 Copyright (C) 2011-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _MATH_H
20# error "Never use <bits/math-finite.h> directly; include <math.h> instead."
21#endif
22
23#define __REDIRFROM(...) __REDIRFROM_X(__VA_ARGS__)
24
25#define __REDIRTO(...) __REDIRTO_X(__VA_ARGS__)
26
27#define __MATH_REDIRCALL_X(from, args, to) \
28 extern _Mdouble_ __REDIRECT_NTH (from, args, to)
29#define __MATH_REDIRCALL(function, reentrant, args) \
30 __MATH_REDIRCALL_X \
31 (__REDIRFROM (function, reentrant), args, \
32 __REDIRTO (function, reentrant))
33#define __MATH_REDIRCALL_2(from, reentrant, args, to) \
34 __MATH_REDIRCALL_X \
35 (__REDIRFROM (from, reentrant), args, \
36 __REDIRTO (to, reentrant))
37
38#define __MATH_REDIRCALL_INTERNAL(function, reentrant, args) \
39 __MATH_REDIRCALL_X \
40 (__REDIRFROM (__CONCAT (__, function), \
41 __CONCAT (reentrant, _finite)), \
42 args, __REDIRTO (function, _r))
43
44
45/* acos. */
46__MATH_REDIRCALL (acos, , (_Mdouble_));
47
48#if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
49/* acosh. */
50__MATH_REDIRCALL (acosh, , (_Mdouble_));
51#endif
52
53/* asin. */
54__MATH_REDIRCALL (asin, , (_Mdouble_));
55
56/* atan2. */
57__MATH_REDIRCALL (atan2, , (_Mdouble_, _Mdouble_));
58
59#if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
60/* atanh. */
61__MATH_REDIRCALL (atanh, , (_Mdouble_));
62#endif
63
64/* cosh. */
65__MATH_REDIRCALL (cosh, , (_Mdouble_));
66
67/* exp. */
68__MATH_REDIRCALL (exp, , (_Mdouble_));
69
70#if __GLIBC_USE (IEC_60559_FUNCS_EXT)
71/* exp10. */
72__MATH_REDIRCALL (exp10, , (_Mdouble_));
73#endif
74
75#ifdef __USE_ISOC99
76/* exp2. */
77__MATH_REDIRCALL (exp2, , (_Mdouble_));
78#endif
79
80/* fmod. */
81__MATH_REDIRCALL (fmod, , (_Mdouble_, _Mdouble_));
82
83#if defined __USE_XOPEN || defined __USE_ISOC99
84/* hypot. */
85__MATH_REDIRCALL (hypot, , (_Mdouble_, _Mdouble_));
86#endif
87
88#if (__MATH_DECLARING_DOUBLE && (defined __USE_MISC || defined __USE_XOPEN)) \
89 || (!__MATH_DECLARING_DOUBLE && defined __USE_MISC)
90/* j0. */
91__MATH_REDIRCALL (j0, , (_Mdouble_));
92
93/* y0. */
94__MATH_REDIRCALL (y0, , (_Mdouble_));
95
96/* j1. */
97__MATH_REDIRCALL (j1, , (_Mdouble_));
98
99/* y1. */
100__MATH_REDIRCALL (y1, , (_Mdouble_));
101
102/* jn. */
103__MATH_REDIRCALL (jn, , (int, _Mdouble_));
104
105/* yn. */
106__MATH_REDIRCALL (yn, , (int, _Mdouble_));
107#endif
108
109#ifdef __USE_MISC
110/* lgamma_r. */
111__MATH_REDIRCALL (lgamma, _r, (_Mdouble_, int *));
112#endif
113
114/* Redirect __lgammal_r_finite to __lgamma_r_finite when __NO_LONG_DOUBLE_MATH
115 is set and to itself otherwise. It also redirects __lgamma_r_finite and
116 __lgammaf_r_finite to themselves. */
117__MATH_REDIRCALL_INTERNAL (lgamma, _r, (_Mdouble_, int *));
118
119#if ((defined __USE_XOPEN || defined __USE_ISOC99) \
120 && defined __extern_always_inline)
121/* lgamma. */
122__extern_always_inline _Mdouble_
123__NTH (__REDIRFROM (lgamma, ) (_Mdouble_ __d))
124{
125# if defined __USE_MISC || defined __USE_XOPEN
126 return __REDIRTO (lgamma, _r) (__d, &signgam);
127# else
128 int __local_signgam = 0;
129 return __REDIRTO (lgamma, _r) (__d, &__local_signgam);
130# endif
131}
132#endif
133
134#if ((defined __USE_MISC || (defined __USE_XOPEN && !defined __USE_XOPEN2K)) \
135 && defined __extern_always_inline) && !__MATH_DECLARING_FLOATN
136/* gamma. */
137__extern_always_inline _Mdouble_
138__NTH (__REDIRFROM (gamma, ) (_Mdouble_ __d))
139{
140 return __REDIRTO (lgamma, _r) (__d, &signgam);
141}
142#endif
143
144/* log. */
145__MATH_REDIRCALL (log, , (_Mdouble_));
146
147/* log10. */
148__MATH_REDIRCALL (log10, , (_Mdouble_));
149
150#ifdef __USE_ISOC99
151/* log2. */
152__MATH_REDIRCALL (log2, , (_Mdouble_));
153#endif
154
155/* pow. */
156__MATH_REDIRCALL (pow, , (_Mdouble_, _Mdouble_));
157
158#if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
159/* remainder. */
160__MATH_REDIRCALL (remainder, , (_Mdouble_, _Mdouble_));
161#endif
162
163#if ((__MATH_DECLARING_DOUBLE \
164 && (defined __USE_MISC \
165 || (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8))) \
166 || (!defined __MATH_DECLARE_LDOUBLE && defined __USE_MISC)) \
167 && !__MATH_DECLARING_FLOATN
168/* scalb. */
169__MATH_REDIRCALL (scalb, , (_Mdouble_, _Mdouble_));
170#endif
171
172/* sinh. */
173__MATH_REDIRCALL (sinh, , (_Mdouble_));
174
175/* sqrt. */
176__MATH_REDIRCALL (sqrt, , (_Mdouble_));
177
178#if defined __USE_ISOC99 && defined __extern_always_inline
179/* tgamma. */
180extern _Mdouble_
181__REDIRFROM (__gamma, _r_finite) (_Mdouble_, int *);
182
183__extern_always_inline _Mdouble_
184__NTH (__REDIRFROM (tgamma, ) (_Mdouble_ __d))
185{
186 int __local_signgam = 0;
187 _Mdouble_ __res = __REDIRTO (gamma, _r) (__d, &__local_signgam);
188 return __local_signgam < 0 ? -__res : __res;
189}
190#endif
191
192#undef __REDIRFROM
193#undef __REDIRTO
194#undef __MATH_REDIRCALL
195#undef __MATH_REDIRCALL_2
196#undef __MATH_REDIRCALL_INTERNAL
197#undef __MATH_REDIRCALL_X
libc/glibc-include/bits/math-vector.h created+63
...@@ -0,0 +1,63 @@
1/* Platform-specific SIMD declarations of math functions.
2 Copyright (C) 2014-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _MATH_H
20# error "Never include <bits/math-vector.h> directly;\
21 include <math.h> instead."
22#endif
23
24/* Get default empty definitions for simd declarations. */
25#include <bits/libm-simd-decl-stubs.h>
26
27#if defined __x86_64__ && defined __FAST_MATH__
28# if defined _OPENMP && _OPENMP >= 201307
29/* OpenMP case. */
30# define __DECL_SIMD_x86_64 _Pragma ("omp declare simd notinbranch")
31# elif __GNUC_PREREQ (6,0)
32/* W/o OpenMP use GCC 6.* __attribute__ ((__simd__)). */
33# define __DECL_SIMD_x86_64 __attribute__ ((__simd__ ("notinbranch")))
34# endif
35
36# ifdef __DECL_SIMD_x86_64
37# undef __DECL_SIMD_cos
38# define __DECL_SIMD_cos __DECL_SIMD_x86_64
39# undef __DECL_SIMD_cosf
40# define __DECL_SIMD_cosf __DECL_SIMD_x86_64
41# undef __DECL_SIMD_sin
42# define __DECL_SIMD_sin __DECL_SIMD_x86_64
43# undef __DECL_SIMD_sinf
44# define __DECL_SIMD_sinf __DECL_SIMD_x86_64
45# undef __DECL_SIMD_sincos
46# define __DECL_SIMD_sincos __DECL_SIMD_x86_64
47# undef __DECL_SIMD_sincosf
48# define __DECL_SIMD_sincosf __DECL_SIMD_x86_64
49# undef __DECL_SIMD_log
50# define __DECL_SIMD_log __DECL_SIMD_x86_64
51# undef __DECL_SIMD_logf
52# define __DECL_SIMD_logf __DECL_SIMD_x86_64
53# undef __DECL_SIMD_exp
54# define __DECL_SIMD_exp __DECL_SIMD_x86_64
55# undef __DECL_SIMD_expf
56# define __DECL_SIMD_expf __DECL_SIMD_x86_64
57# undef __DECL_SIMD_pow
58# define __DECL_SIMD_pow __DECL_SIMD_x86_64
59# undef __DECL_SIMD_powf
60# define __DECL_SIMD_powf __DECL_SIMD_x86_64
61
62# endif
63#endif
libc/glibc-include/bits/mathcalls-helper-functions.h created+43
...@@ -0,0 +1,43 @@
1/* Prototype declarations for math classification macros helpers.
2 Copyright (C) 2017-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19
20/* Classify given number. */
21__MATHDECL_1 (int, __fpclassify,, (_Mdouble_ __value))
22 __attribute__ ((__const__));
23
24/* Test for negative number. */
25__MATHDECL_1 (int, __signbit,, (_Mdouble_ __value))
26 __attribute__ ((__const__));
27
28/* Return 0 if VALUE is finite or NaN, +1 if it
29 is +Infinity, -1 if it is -Infinity. */
30__MATHDECL_1 (int, __isinf,, (_Mdouble_ __value)) __attribute__ ((__const__));
31
32/* Return nonzero if VALUE is finite and not NaN. Used by isfinite macro. */
33__MATHDECL_1 (int, __finite,, (_Mdouble_ __value)) __attribute__ ((__const__));
34
35/* Return nonzero if VALUE is not a number. */
36__MATHDECL_1 (int, __isnan,, (_Mdouble_ __value)) __attribute__ ((__const__));
37
38/* Test equality. */
39__MATHDECL_1 (int, __iseqsig,, (_Mdouble_ __x, _Mdouble_ __y));
40
41/* Test for signaling NaN. */
42__MATHDECL_1 (int, __issignaling,, (_Mdouble_ __value))
43 __attribute__ ((__const__));
libc/glibc-include/bits/mathcalls-narrow.h created+33
...@@ -0,0 +1,33 @@
1/* Declare functions returning a narrower type.
2 Copyright (C) 2018-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _MATH_H
20# error "Never include <bits/mathcalls-narrow.h> directly; include <math.h> instead."
21#endif
22
23/* Add. */
24__MATHCALL_NARROW (__MATHCALL_NAME (add), __MATHCALL_REDIR_NAME (add), 2);
25
26/* Divide. */
27__MATHCALL_NARROW (__MATHCALL_NAME (div), __MATHCALL_REDIR_NAME (div), 2);
28
29/* Multiply. */
30__MATHCALL_NARROW (__MATHCALL_NAME (mul), __MATHCALL_REDIR_NAME (mul), 2);
31
32/* Subtract. */
33__MATHCALL_NARROW (__MATHCALL_NAME (sub), __MATHCALL_REDIR_NAME (sub), 2);
libc/glibc-include/bits/mathcalls.h created+397
...@@ -0,0 +1,397 @@
1/* Prototype declarations for math functions; helper file for <math.h>.
2 Copyright (C) 1996-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19/* NOTE: Because of the special way this file is used by <math.h>, this
20 file must NOT be protected from multiple inclusion as header files
21 usually are.
22
23 This file provides prototype declarations for the math functions.
24 Most functions are declared using the macro:
25
26 __MATHCALL (NAME,[_r], (ARGS...));
27
28 This means there is a function `NAME' returning `double' and a function
29 `NAMEf' returning `float'. Each place `_Mdouble_' appears in the
30 prototype, that is actually `double' in the prototype for `NAME' and
31 `float' in the prototype for `NAMEf'. Reentrant variant functions are
32 called `NAME_r' and `NAMEf_r'.
33
34 Functions returning other types like `int' are declared using the macro:
35
36 __MATHDECL (TYPE, NAME,[_r], (ARGS...));
37
38 This is just like __MATHCALL but for a function returning `TYPE'
39 instead of `_Mdouble_'. In all of these cases, there is still
40 both a `NAME' and a `NAMEf' that takes `float' arguments.
41
42 Note that there must be no whitespace before the argument passed for
43 NAME, to make token pasting work with -traditional. */
44
45#ifndef _MATH_H
46# error "Never include <bits/mathcalls.h> directly; include <math.h> instead."
47#endif
48
49
50/* Trigonometric functions. */
51
52/* Arc cosine of X. */
53__MATHCALL (acos,, (_Mdouble_ __x));
54/* Arc sine of X. */
55__MATHCALL (asin,, (_Mdouble_ __x));
56/* Arc tangent of X. */
57__MATHCALL (atan,, (_Mdouble_ __x));
58/* Arc tangent of Y/X. */
59__MATHCALL (atan2,, (_Mdouble_ __y, _Mdouble_ __x));
60
61/* Cosine of X. */
62__MATHCALL_VEC (cos,, (_Mdouble_ __x));
63/* Sine of X. */
64__MATHCALL_VEC (sin,, (_Mdouble_ __x));
65/* Tangent of X. */
66__MATHCALL (tan,, (_Mdouble_ __x));
67
68/* Hyperbolic functions. */
69
70/* Hyperbolic cosine of X. */
71__MATHCALL (cosh,, (_Mdouble_ __x));
72/* Hyperbolic sine of X. */
73__MATHCALL (sinh,, (_Mdouble_ __x));
74/* Hyperbolic tangent of X. */
75__MATHCALL (tanh,, (_Mdouble_ __x));
76
77#ifdef __USE_GNU
78/* Cosine and sine of X. */
79__MATHDECL_VEC (void,sincos,,
80 (_Mdouble_ __x, _Mdouble_ *__sinx, _Mdouble_ *__cosx));
81#endif
82
83#if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
84/* Hyperbolic arc cosine of X. */
85__MATHCALL (acosh,, (_Mdouble_ __x));
86/* Hyperbolic arc sine of X. */
87__MATHCALL (asinh,, (_Mdouble_ __x));
88/* Hyperbolic arc tangent of X. */
89__MATHCALL (atanh,, (_Mdouble_ __x));
90#endif
91
92/* Exponential and logarithmic functions. */
93
94/* Exponential function of X. */
95__MATHCALL_VEC (exp,, (_Mdouble_ __x));
96
97/* Break VALUE into a normalized fraction and an integral power of 2. */
98__MATHCALL (frexp,, (_Mdouble_ __x, int *__exponent));
99
100/* X times (two to the EXP power). */
101__MATHCALL (ldexp,, (_Mdouble_ __x, int __exponent));
102
103/* Natural logarithm of X. */
104__MATHCALL_VEC (log,, (_Mdouble_ __x));
105
106/* Base-ten logarithm of X. */
107__MATHCALL (log10,, (_Mdouble_ __x));
108
109/* Break VALUE into integral and fractional parts. */
110__MATHCALL (modf,, (_Mdouble_ __x, _Mdouble_ *__iptr)) __nonnull ((2));
111
112#if __GLIBC_USE (IEC_60559_FUNCS_EXT)
113/* Compute exponent to base ten. */
114__MATHCALL (exp10,, (_Mdouble_ __x));
115#endif
116
117#if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
118/* Return exp(X) - 1. */
119__MATHCALL (expm1,, (_Mdouble_ __x));
120
121/* Return log(1 + X). */
122__MATHCALL (log1p,, (_Mdouble_ __x));
123
124/* Return the base 2 signed integral exponent of X. */
125__MATHCALL (logb,, (_Mdouble_ __x));
126#endif
127
128#ifdef __USE_ISOC99
129/* Compute base-2 exponential of X. */
130__MATHCALL (exp2,, (_Mdouble_ __x));
131
132/* Compute base-2 logarithm of X. */
133__MATHCALL (log2,, (_Mdouble_ __x));
134#endif
135
136
137/* Power functions. */
138
139/* Return X to the Y power. */
140__MATHCALL_VEC (pow,, (_Mdouble_ __x, _Mdouble_ __y));
141
142/* Return the square root of X. */
143__MATHCALL (sqrt,, (_Mdouble_ __x));
144
145#if defined __USE_XOPEN || defined __USE_ISOC99
146/* Return `sqrt(X*X + Y*Y)'. */
147__MATHCALL (hypot,, (_Mdouble_ __x, _Mdouble_ __y));
148#endif
149
150#if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
151/* Return the cube root of X. */
152__MATHCALL (cbrt,, (_Mdouble_ __x));
153#endif
154
155
156/* Nearest integer, absolute value, and remainder functions. */
157
158/* Smallest integral value not less than X. */
159__MATHCALLX (ceil,, (_Mdouble_ __x), (__const__));
160
161/* Absolute value of X. */
162__MATHCALLX (fabs,, (_Mdouble_ __x), (__const__));
163
164/* Largest integer not greater than X. */
165__MATHCALLX (floor,, (_Mdouble_ __x), (__const__));
166
167/* Floating-point modulo remainder of X/Y. */
168__MATHCALL (fmod,, (_Mdouble_ __x, _Mdouble_ __y));
169
170#ifdef __USE_MISC
171# if ((!defined __cplusplus \
172 || __cplusplus < 201103L /* isinf conflicts with C++11. */ \
173 || __MATH_DECLARING_DOUBLE == 0)) /* isinff or isinfl don't. */ \
174 && !__MATH_DECLARING_FLOATN
175/* Return 0 if VALUE is finite or NaN, +1 if it
176 is +Infinity, -1 if it is -Infinity. */
177__MATHDECL_1 (int,isinf,, (_Mdouble_ __value)) __attribute__ ((__const__));
178# endif
179
180# if !__MATH_DECLARING_FLOATN
181/* Return nonzero if VALUE is finite and not NaN. */
182__MATHDECL_1 (int,finite,, (_Mdouble_ __value)) __attribute__ ((__const__));
183
184/* Return the remainder of X/Y. */
185__MATHCALL (drem,, (_Mdouble_ __x, _Mdouble_ __y));
186
187
188/* Return the fractional part of X after dividing out `ilogb (X)'. */
189__MATHCALL (significand,, (_Mdouble_ __x));
190# endif
191
192#endif /* Use misc. */
193
194#ifdef __USE_ISOC99
195/* Return X with its signed changed to Y's. */
196__MATHCALLX (copysign,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
197#endif
198
199#ifdef __USE_ISOC99
200/* Return representation of qNaN for double type. */
201__MATHCALL (nan,, (const char *__tagb));
202#endif
203
204
205#if defined __USE_MISC || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
206# if ((!defined __cplusplus \
207 || __cplusplus < 201103L /* isnan conflicts with C++11. */ \
208 || __MATH_DECLARING_DOUBLE == 0)) /* isnanf or isnanl don't. */ \
209 && !__MATH_DECLARING_FLOATN
210/* Return nonzero if VALUE is not a number. */
211__MATHDECL_1 (int,isnan,, (_Mdouble_ __value)) __attribute__ ((__const__));
212# endif
213#endif
214
215#if defined __USE_MISC || (defined __USE_XOPEN && __MATH_DECLARING_DOUBLE)
216/* Bessel functions. */
217__MATHCALL (j0,, (_Mdouble_));
218__MATHCALL (j1,, (_Mdouble_));
219__MATHCALL (jn,, (int, _Mdouble_));
220__MATHCALL (y0,, (_Mdouble_));
221__MATHCALL (y1,, (_Mdouble_));
222__MATHCALL (yn,, (int, _Mdouble_));
223#endif
224
225
226#if defined __USE_XOPEN || defined __USE_ISOC99
227/* Error and gamma functions. */
228__MATHCALL (erf,, (_Mdouble_));
229__MATHCALL (erfc,, (_Mdouble_));
230__MATHCALL (lgamma,, (_Mdouble_));
231#endif
232
233#ifdef __USE_ISOC99
234/* True gamma function. */
235__MATHCALL (tgamma,, (_Mdouble_));
236#endif
237
238#if defined __USE_MISC || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
239# if !__MATH_DECLARING_FLOATN
240/* Obsolete alias for `lgamma'. */
241__MATHCALL (gamma,, (_Mdouble_));
242# endif
243#endif
244
245#ifdef __USE_MISC
246/* Reentrant version of lgamma. This function uses the global variable
247 `signgam'. The reentrant version instead takes a pointer and stores
248 the value through it. */
249__MATHCALL (lgamma,_r, (_Mdouble_, int *__signgamp));
250#endif
251
252
253#if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
254/* Return the integer nearest X in the direction of the
255 prevailing rounding mode. */
256__MATHCALL (rint,, (_Mdouble_ __x));
257
258/* Return X + epsilon if X < Y, X - epsilon if X > Y. */
259__MATHCALL (nextafter,, (_Mdouble_ __x, _Mdouble_ __y));
260# if defined __USE_ISOC99 && !defined __LDBL_COMPAT && !__MATH_DECLARING_FLOATN
261__MATHCALL (nexttoward,, (_Mdouble_ __x, long double __y));
262# endif
263
264# if __GLIBC_USE (IEC_60559_BFP_EXT) || __MATH_DECLARING_FLOATN
265/* Return X - epsilon. */
266__MATHCALL (nextdown,, (_Mdouble_ __x));
267/* Return X + epsilon. */
268__MATHCALL (nextup,, (_Mdouble_ __x));
269# endif
270
271/* Return the remainder of integer divison X / Y with infinite precision. */
272__MATHCALL (remainder,, (_Mdouble_ __x, _Mdouble_ __y));
273
274# ifdef __USE_ISOC99
275/* Return X times (2 to the Nth power). */
276__MATHCALL (scalbn,, (_Mdouble_ __x, int __n));
277# endif
278
279/* Return the binary exponent of X, which must be nonzero. */
280__MATHDECL (int,ilogb,, (_Mdouble_ __x));
281#endif
282
283#if __GLIBC_USE (IEC_60559_BFP_EXT) || __MATH_DECLARING_FLOATN
284/* Like ilogb, but returning long int. */
285__MATHDECL (long int, llogb,, (_Mdouble_ __x));
286#endif
287
288#ifdef __USE_ISOC99
289/* Return X times (2 to the Nth power). */
290__MATHCALL (scalbln,, (_Mdouble_ __x, long int __n));
291
292/* Round X to integral value in floating-point format using current
293 rounding direction, but do not raise inexact exception. */
294__MATHCALL (nearbyint,, (_Mdouble_ __x));
295
296/* Round X to nearest integral value, rounding halfway cases away from
297 zero. */
298__MATHCALLX (round,, (_Mdouble_ __x), (__const__));
299
300/* Round X to the integral value in floating-point format nearest but
301 not larger in magnitude. */
302__MATHCALLX (trunc,, (_Mdouble_ __x), (__const__));
303
304/* Compute remainder of X and Y and put in *QUO a value with sign of x/y
305 and magnitude congruent `mod 2^n' to the magnitude of the integral
306 quotient x/y, with n >= 3. */
307__MATHCALL (remquo,, (_Mdouble_ __x, _Mdouble_ __y, int *__quo));
308
309
310/* Conversion functions. */
311
312/* Round X to nearest integral value according to current rounding
313 direction. */
314__MATHDECL (long int,lrint,, (_Mdouble_ __x));
315__extension__
316__MATHDECL (long long int,llrint,, (_Mdouble_ __x));
317
318/* Round X to nearest integral value, rounding halfway cases away from
319 zero. */
320__MATHDECL (long int,lround,, (_Mdouble_ __x));
321__extension__
322__MATHDECL (long long int,llround,, (_Mdouble_ __x));
323
324
325/* Return positive difference between X and Y. */
326__MATHCALL (fdim,, (_Mdouble_ __x, _Mdouble_ __y));
327
328/* Return maximum numeric value from X and Y. */
329__MATHCALLX (fmax,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
330
331/* Return minimum numeric value from X and Y. */
332__MATHCALLX (fmin,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
333
334/* Multiply-add function computed as a ternary operation. */
335__MATHCALL (fma,, (_Mdouble_ __x, _Mdouble_ __y, _Mdouble_ __z));
336#endif /* Use ISO C99. */
337
338#if __GLIBC_USE (IEC_60559_BFP_EXT) || __MATH_DECLARING_FLOATN
339/* Round X to nearest integer value, rounding halfway cases to even. */
340__MATHCALLX (roundeven,, (_Mdouble_ __x), (__const__));
341
342/* Round X to nearest signed integer value, not raising inexact, with
343 control of rounding direction and width of result. */
344__MATHDECL (__intmax_t, fromfp,, (_Mdouble_ __x, int __round,
345 unsigned int __width));
346
347/* Round X to nearest unsigned integer value, not raising inexact,
348 with control of rounding direction and width of result. */
349__MATHDECL (__uintmax_t, ufromfp,, (_Mdouble_ __x, int __round,
350 unsigned int __width));
351
352/* Round X to nearest signed integer value, raising inexact for
353 non-integers, with control of rounding direction and width of
354 result. */
355__MATHDECL (__intmax_t, fromfpx,, (_Mdouble_ __x, int __round,
356 unsigned int __width));
357
358/* Round X to nearest unsigned integer value, raising inexact for
359 non-integers, with control of rounding direction and width of
360 result. */
361__MATHDECL (__uintmax_t, ufromfpx,, (_Mdouble_ __x, int __round,
362 unsigned int __width));
363
364/* Return value with maximum magnitude. */
365__MATHCALLX (fmaxmag,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
366
367/* Return value with minimum magnitude. */
368__MATHCALLX (fminmag,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
369
370/* Total order operation. */
371__MATHDECL_1 (int, totalorder,, (_Mdouble_ __x, _Mdouble_ __y))
372 __attribute__ ((__const__));
373
374/* Total order operation on absolute values. */
375__MATHDECL_1 (int, totalordermag,, (_Mdouble_ __x, _Mdouble_ __y))
376 __attribute__ ((__const__));
377
378/* Canonicalize floating-point representation. */
379__MATHDECL_1 (int, canonicalize,, (_Mdouble_ *__cx, const _Mdouble_ *__x));
380
381/* Get NaN payload. */
382__MATHCALL (getpayload,, (const _Mdouble_ *__x));
383
384/* Set quiet NaN payload. */
385__MATHDECL_1 (int, setpayload,, (_Mdouble_ *__x, _Mdouble_ __payload));
386
387/* Set signaling NaN payload. */
388__MATHDECL_1 (int, setpayloadsig,, (_Mdouble_ *__x, _Mdouble_ __payload));
389#endif
390
391#if (defined __USE_MISC || (defined __USE_XOPEN_EXTENDED \
392 && __MATH_DECLARING_DOUBLE \
393 && !defined __USE_XOPEN2K8)) \
394 && !__MATH_DECLARING_FLOATN
395/* Return X times (2 to the Nth power). */
396__MATHCALL (scalb,, (_Mdouble_ __x, _Mdouble_ __n));
397#endif
libc/glibc-include/bits/mathdef.h created+20
...@@ -0,0 +1,20 @@
1/* Copyright (C) 1997-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _COMPLEX_H
19# error "Never use <bits/mathdef.h> directly; include <complex.h> instead"
20#endif
libc/glibc-include/bits/mathinline.h created+12
...@@ -0,0 +1,12 @@
1/* This file should provide inline versions of math functions.
2
3 Surround GCC-specific parts with #ifdef __GNUC__, and use `__extern_inline'.
4
5 This file should define __MATH_INLINES if functions are actually defined as
6 inlines. */
7
8#if !defined __NO_MATH_INLINES && defined __OPTIMIZE__
9
10/* Here goes the real code. */
11
12#endif
libc/glibc-include/bits/mman-linux.h created+111
...@@ -0,0 +1,111 @@
1/* Definitions for POSIX memory map interface. Linux generic version.
2 Copyright (C) 2001-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SYS_MMAN_H
20# error "Never use <bits/mman-linux.h> directly; include <sys/mman.h> instead."
21#endif
22
23/* The following definitions basically come from the kernel headers.
24 But the kernel header is not namespace clean. */
25
26
27/* Protections are chosen from these bits, OR'd together. The
28 implementation does not necessarily support PROT_EXEC or PROT_WRITE
29 without PROT_READ. The only guarantees are that no writing will be
30 allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */
31
32#define PROT_READ 0x1 /* Page can be read. */
33#define PROT_WRITE 0x2 /* Page can be written. */
34#define PROT_EXEC 0x4 /* Page can be executed. */
35#define PROT_NONE 0x0 /* Page can not be accessed. */
36#define PROT_GROWSDOWN 0x01000000 /* Extend change to start of
37 growsdown vma (mprotect only). */
38#define PROT_GROWSUP 0x02000000 /* Extend change to start of
39 growsup vma (mprotect only). */
40
41/* Sharing types (must choose one and only one of these). */
42#define MAP_SHARED 0x01 /* Share changes. */
43#define MAP_PRIVATE 0x02 /* Changes are private. */
44#ifdef __USE_MISC
45# define MAP_SHARED_VALIDATE 0x03 /* Share changes and validate
46 extension flags. */
47# define MAP_TYPE 0x0f /* Mask for type of mapping. */
48#endif
49
50/* Other flags. */
51#define MAP_FIXED 0x10 /* Interpret addr exactly. */
52#ifdef __USE_MISC
53# define MAP_FILE 0
54# ifdef __MAP_ANONYMOUS
55# define MAP_ANONYMOUS __MAP_ANONYMOUS /* Don't use a file. */
56# else
57# define MAP_ANONYMOUS 0x20 /* Don't use a file. */
58# endif
59# define MAP_ANON MAP_ANONYMOUS
60/* When MAP_HUGETLB is set bits [26:31] encode the log2 of the huge page size. */
61# define MAP_HUGE_SHIFT 26
62# define MAP_HUGE_MASK 0x3f
63#endif
64
65/* Flags to `msync'. */
66#define MS_ASYNC 1 /* Sync memory asynchronously. */
67#define MS_SYNC 4 /* Synchronous memory sync. */
68#define MS_INVALIDATE 2 /* Invalidate the caches. */
69
70/* Advice to `madvise'. */
71#ifdef __USE_MISC
72# define MADV_NORMAL 0 /* No further special treatment. */
73# define MADV_RANDOM 1 /* Expect random page references. */
74# define MADV_SEQUENTIAL 2 /* Expect sequential page references. */
75# define MADV_WILLNEED 3 /* Will need these pages. */
76# define MADV_DONTNEED 4 /* Don't need these pages. */
77# define MADV_FREE 8 /* Free pages only if memory pressure. */
78# define MADV_REMOVE 9 /* Remove these pages and resources. */
79# define MADV_DONTFORK 10 /* Do not inherit across fork. */
80# define MADV_DOFORK 11 /* Do inherit across fork. */
81# define MADV_MERGEABLE 12 /* KSM may merge identical pages. */
82# define MADV_UNMERGEABLE 13 /* KSM may not merge identical pages. */
83# define MADV_HUGEPAGE 14 /* Worth backing with hugepages. */
84# define MADV_NOHUGEPAGE 15 /* Not worth backing with hugepages. */
85# define MADV_DONTDUMP 16 /* Explicity exclude from the core dump,
86 overrides the coredump filter bits. */
87# define MADV_DODUMP 17 /* Clear the MADV_DONTDUMP flag. */
88# define MADV_WIPEONFORK 18 /* Zero memory on fork, child only. */
89# define MADV_KEEPONFORK 19 /* Undo MADV_WIPEONFORK. */
90# define MADV_HWPOISON 100 /* Poison a page for testing. */
91#endif
92
93/* The POSIX people had to invent similar names for the same things. */
94#ifdef __USE_XOPEN2K
95# define POSIX_MADV_NORMAL 0 /* No further special treatment. */
96# define POSIX_MADV_RANDOM 1 /* Expect random page references. */
97# define POSIX_MADV_SEQUENTIAL 2 /* Expect sequential page references. */
98# define POSIX_MADV_WILLNEED 3 /* Will need these pages. */
99# define POSIX_MADV_DONTNEED 4 /* Don't need these pages. */
100#endif
101
102/* Flags for `mlockall'. */
103#ifndef MCL_CURRENT
104# define MCL_CURRENT 1 /* Lock all currently mapped pages. */
105# define MCL_FUTURE 2 /* Lock all additions to address
106 space. */
107# define MCL_ONFAULT 4 /* Lock all pages that are
108 faulted in. */
109#endif
110
111#include <bits/mman-shared.h>
libc/glibc-include/bits/mman-map-flags-generic.h created+42
...@@ -0,0 +1,42 @@
1/* Definitions for POSIX memory map interface. Linux/generic version.
2 Copyright (C) 1997-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SYS_MMAN_H
20# error "Never use <bits/mman-map-flags-generic.h> directly; include <sys/mman.h> instead."
21#endif
22
23/* These definitions are appropriate for architectures that, in the
24 Linux kernel, either have no uapi/asm/mman.h, or have one that
25 includes asm-generic/mman.h without any changes to the values of
26 the MAP_* flags defined in that header. */
27
28#ifdef __USE_MISC
29# define MAP_GROWSDOWN 0x00100 /* Stack-like segment. */
30# define MAP_DENYWRITE 0x00800 /* ETXTBSY. */
31# define MAP_EXECUTABLE 0x01000 /* Mark it as an executable. */
32# define MAP_LOCKED 0x02000 /* Lock the mapping. */
33# define MAP_NORESERVE 0x04000 /* Don't check for reservations. */
34# define MAP_POPULATE 0x08000 /* Populate (prefault) pagetables. */
35# define MAP_NONBLOCK 0x10000 /* Do not block on IO. */
36# define MAP_STACK 0x20000 /* Allocation is for a stack. */
37# define MAP_HUGETLB 0x40000 /* Create huge page mapping. */
38# define MAP_SYNC 0x80000 /* Perform synchronous page
39 faults for the mapping. */
40# define MAP_FIXED_NOREPLACE 0x100000 /* MAP_FIXED but do not unmap
41 underlying mapping. */
42#endif
libc/glibc-include/bits/mman-shared.h created+80
...@@ -0,0 +1,80 @@
1/* Memory-mapping-related declarations/definitions, not architecture-specific.
2 Copyright (C) 2017-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SYS_MMAN_H
20# error "Never use <bits/mman-shared.h> directly; include <sys/mman.h> instead."
21#endif
22
23#ifdef __USE_GNU
24/* Flags for mremap. */
25# define MREMAP_MAYMOVE 1
26# define MREMAP_FIXED 2
27
28/* Flags for memfd_create. */
29# ifndef MFD_CLOEXEC
30# define MFD_CLOEXEC 1U
31# define MFD_ALLOW_SEALING 2U
32# define MFD_HUGETLB 4U
33# endif
34
35/* Flags for mlock2. */
36# ifndef MLOCK_ONFAULT
37# define MLOCK_ONFAULT 1U
38# endif
39
40/* Access rights for pkey_alloc. */
41# ifndef PKEY_DISABLE_ACCESS
42# define PKEY_DISABLE_ACCESS 0x1
43# define PKEY_DISABLE_WRITE 0x2
44# endif
45
46__BEGIN_DECLS
47
48/* Create a new memory file descriptor. NAME is a name for debugging.
49 FLAGS is a combination of the MFD_* constants. */
50int memfd_create (const char *__name, unsigned int __flags) __THROW;
51
52/* Lock pages from ADDR (inclusive) to ADDR + LENGTH (exclusive) into
53 memory. FLAGS is a combination of the MLOCK_* flags above. */
54int mlock2 (const void *__addr, size_t __length, unsigned int __flags) __THROW;
55
56/* Allocate a new protection key, with the PKEY_DISABLE_* bits
57 specified in ACCESS_RIGHTS. The protection key mask for the
58 current thread is updated to match the access privilege for the new
59 key. */
60int pkey_alloc (unsigned int __flags, unsigned int __access_rights) __THROW;
61
62/* Update the access rights for the current thread for KEY, which must
63 have been allocated using pkey_alloc. */
64int pkey_set (int __key, unsigned int __access_rights) __THROW;
65
66/* Return the access rights for the current thread for KEY, which must
67 have been allocated using pkey_alloc. */
68int pkey_get (int __key) __THROW;
69
70/* Free an allocated protection key, which must have been allocated
71 using pkey_alloc. */
72int pkey_free (int __key) __THROW;
73
74/* Apply memory protection flags for KEY to the specified address
75 range. */
76int pkey_mprotect (void *__addr, size_t __len, int __prot, int __pkey) __THROW;
77
78__END_DECLS
79
80#endif /* __USE_GNU */
libc/glibc-include/bits/mman.h created+34
...@@ -0,0 +1,34 @@
1/* Definitions for POSIX memory map interface. Linux/x86_64 version.
2 Copyright (C) 2001-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SYS_MMAN_H
20# error "Never use <bits/mman.h> directly; include <sys/mman.h> instead."
21#endif
22
23/* The following definitions basically come from the kernel headers.
24 But the kernel header is not namespace clean. */
25
26/* Other flags. */
27#ifdef __USE_MISC
28# define MAP_32BIT 0x40 /* Only give out 32-bit addresses. */
29#endif
30
31#include <bits/mman-map-flags-generic.h>
32
33/* Include generic Linux declarations. */
34#include <bits/mman-linux.h>
libc/glibc-include/bits/monetary-ldbl.h created+27
...@@ -0,0 +1,27 @@
1/* -mlong-double-64 compatibility mode for monetary functions.
2 Copyright (C) 2006-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _MONETARY_H
20# error "Never include <bits/monetary-ldbl.h> directly; use <monetary.h> instead."
21#endif
22
23__LDBL_REDIR_DECL (strfmon)
24
25#ifdef __USE_GNU
26__LDBL_REDIR_DECL (strfmon_l)
27#endif
libc/glibc-include/bits/mqueue.h created+33
...@@ -0,0 +1,33 @@
1/* Copyright (C) 2004-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _MQUEUE_H
19# error "Never use <bits/mqueue.h> directly; include <mqueue.h> instead."
20#endif
21
22#include <bits/types.h>
23
24typedef int mqd_t;
25
26struct mq_attr
27{
28 __syscall_slong_t mq_flags; /* Message queue flags. */
29 __syscall_slong_t mq_maxmsg; /* Maximum number of messages. */
30 __syscall_slong_t mq_msgsize; /* Maximum message size. */
31 __syscall_slong_t mq_curmsgs; /* Number of messages currently queued. */
32 __syscall_slong_t __pad[4];
33};
libc/glibc-include/bits/mqueue2.h created+57
...@@ -0,0 +1,57 @@
1/* Checking macros for mq functions.
2 Copyright (C) 2007-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _FCNTL_H
20# error "Never include <bits/mqueue2.h> directly; use <mqueue.h> instead."
21#endif
22
23/* Check that calls to mq_open with O_CREAT set have an appropriate third and fourth
24 parameter. */
25extern mqd_t mq_open (const char *__name, int __oflag, ...)
26 __THROW __nonnull ((1));
27extern mqd_t __mq_open_2 (const char *__name, int __oflag)
28 __THROW __nonnull ((1));
29extern mqd_t __REDIRECT_NTH (__mq_open_alias, (const char *__name,
30 int __oflag, ...), mq_open)
31 __nonnull ((1));
32__errordecl (__mq_open_wrong_number_of_args,
33 "mq_open can be called either with 2 or 4 arguments");
34__errordecl (__mq_open_missing_mode_and_attr,
35 "mq_open with O_CREAT in second argument needs 4 arguments");
36
37__fortify_function mqd_t
38__NTH (mq_open (const char *__name, int __oflag, ...))
39{
40 if (__va_arg_pack_len () != 0 && __va_arg_pack_len () != 2)
41 __mq_open_wrong_number_of_args ();
42
43 if (__builtin_constant_p (__oflag))
44 {
45 if ((__oflag & O_CREAT) != 0 && __va_arg_pack_len () == 0)
46 {
47 __mq_open_missing_mode_and_attr ();
48 return __mq_open_2 (__name, __oflag);
49 }
50 return __mq_open_alias (__name, __oflag, __va_arg_pack ());
51 }
52
53 if (__va_arg_pack_len () == 0)
54 return __mq_open_2 (__name, __oflag);
55
56 return __mq_open_alias (__name, __oflag, __va_arg_pack ());
57}
libc/glibc-include/bits/msq-pad.h created+31
...@@ -0,0 +1,31 @@
1/* Define where padding goes in struct msqid_ds. Generic version.
2 Copyright (C) 2018-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SYS_MSG_H
20# error "Never use <bits/msq-pad.h> directly; include <sys/msg.h> instead."
21#endif
22
23#include <bits/timesize.h>
24
25/* On most architectures, padding goes after time fields for 32-bit
26 systems and is omitted for 64-bit systems. Some architectures pad
27 before time fields instead, or omit padding despite being
28 32-bit. */
29
30#define __MSQ_PAD_AFTER_TIME (__TIMESIZE == 32)
31#define __MSQ_PAD_BEFORE_TIME 0
libc/glibc-include/bits/msq.h created+86
...@@ -0,0 +1,86 @@
1/* Copyright (C) 1995-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_MSG_H
19# error "Never use <bits/msq.h> directly; include <sys/msg.h> instead."
20#endif
21
22#include <bits/types.h>
23#include <bits/msq-pad.h>
24
25/* Define options for message queue functions. */
26#define MSG_NOERROR 010000 /* no error if message is too big */
27#ifdef __USE_GNU
28# define MSG_EXCEPT 020000 /* recv any msg except of specified type */
29# define MSG_COPY 040000 /* copy (not remove) all queue messages */
30#endif
31
32/* Types used in the structure definition. */
33typedef __syscall_ulong_t msgqnum_t;
34typedef __syscall_ulong_t msglen_t;
35
36#if __MSQ_PAD_BEFORE_TIME
37# define __MSQ_PAD_TIME(NAME, RES) \
38 unsigned long int __glibc_reserved ## RES; __time_t NAME
39#elif __MSQ_PAD_AFTER_TIME
40# define __MSQ_PAD_TIME(NAME, RES) \
41 __time_t NAME; unsigned long int __glibc_reserved ## RES
42#else
43# define __MSQ_PAD_TIME(NAME, RES) \
44 __time_t NAME
45#endif
46
47/* Structure of record for one message inside the kernel.
48 The type `struct msg' is opaque. */
49struct msqid_ds
50{
51 struct ipc_perm msg_perm; /* structure describing operation permission */
52 __MSQ_PAD_TIME (msg_stime, 1); /* time of last msgsnd command */
53 __MSQ_PAD_TIME (msg_rtime, 2); /* time of last msgrcv command */
54 __MSQ_PAD_TIME (msg_ctime, 3); /* time of last change */
55 __syscall_ulong_t __msg_cbytes; /* current number of bytes on queue */
56 msgqnum_t msg_qnum; /* number of messages currently on queue */
57 msglen_t msg_qbytes; /* max number of bytes allowed on queue */
58 __pid_t msg_lspid; /* pid of last msgsnd() */
59 __pid_t msg_lrpid; /* pid of last msgrcv() */
60 __syscall_ulong_t __glibc_reserved4;
61 __syscall_ulong_t __glibc_reserved5;
62};
63
64#ifdef __USE_MISC
65
66# define msg_cbytes __msg_cbytes
67
68/* ipcs ctl commands */
69# define MSG_STAT 11
70# define MSG_INFO 12
71# define MSG_STAT_ANY 13
72
73/* buffer for msgctl calls IPC_INFO, MSG_INFO */
74struct msginfo
75 {
76 int msgpool;
77 int msgmap;
78 int msgmax;
79 int msgmnb;
80 int msgmni;
81 int msgssz;
82 int msgtql;
83 unsigned short int msgseg;
84 };
85
86#endif /* __USE_MISC */
libc/glibc-include/bits/netdb.h created+32
...@@ -0,0 +1,32 @@
1/* Copyright (C) 1996-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _NETDB_H
19# error "Never include <bits/netdb.h> directly; use <netdb.h> instead."
20#endif
21
22
23/* Description of data base entry for a single network. NOTE: here a
24 poor assumption is made. The network number is expected to fit
25 into an unsigned long int variable. */
26struct netent
27{
28 char *n_name; /* Official name of network. */
29 char **n_aliases; /* Alias list. */
30 int n_addrtype; /* Net address type. */
31 uint32_t n_net; /* Network number. */
32};
libc/glibc-include/bits/param.h created+42
...@@ -0,0 +1,42 @@
1/* Old-style Unix parameters and limits. Linux version.
2 Copyright (C) 1995-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SYS_PARAM_H
20# error "Never use <bits/param.h> directly; include <sys/param.h> instead."
21#endif
22
23#ifndef ARG_MAX
24# define __undef_ARG_MAX
25#endif
26
27#include <linux/limits.h>
28#include <linux/param.h>
29
30/* The kernel headers define ARG_MAX. The value is wrong, though. */
31#ifdef __undef_ARG_MAX
32# undef ARG_MAX
33# undef __undef_ARG_MAX
34#endif
35
36#define MAXSYMLINKS 20
37
38/* The following are not really correct but it is a value we used for a
39 long time and which seems to be usable. People should not use NOFILE
40 and NCARGS anyway. */
41#define NOFILE 256
42#define NCARGS 131072
libc/glibc-include/bits/poll.h created+49
...@@ -0,0 +1,49 @@
1/* Copyright (C) 1997-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_POLL_H
19# error "Never use <bits/poll.h> directly; include <sys/poll.h> instead."
20#endif
21
22/* Event types that can be polled for. These bits may be set in `events'
23 to indicate the interesting event types; they will appear in `revents'
24 to indicate the status of the file descriptor. */
25#define POLLIN 0x001 /* There is data to read. */
26#define POLLPRI 0x002 /* There is urgent data to read. */
27#define POLLOUT 0x004 /* Writing now will not block. */
28
29#if defined __USE_XOPEN || defined __USE_XOPEN2K8
30/* These values are defined in XPG4.2. */
31# define POLLRDNORM 0x040 /* Normal data may be read. */
32# define POLLRDBAND 0x080 /* Priority data may be read. */
33# define POLLWRNORM 0x100 /* Writing now will not block. */
34# define POLLWRBAND 0x200 /* Priority data may be written. */
35#endif
36
37#ifdef __USE_GNU
38/* These are extensions for Linux. */
39# define POLLMSG 0x400
40# define POLLREMOVE 0x1000
41# define POLLRDHUP 0x2000
42#endif
43
44/* Event types always implicitly polled for. These bits need not be set in
45 `events', but they will appear in `revents' to indicate the status of
46 the file descriptor. */
47#define POLLERR 0x008 /* Error condition. */
48#define POLLHUP 0x010 /* Hung up. */
49#define POLLNVAL 0x020 /* Invalid polling request. */
libc/glibc-include/bits/poll2.h created+81
...@@ -0,0 +1,81 @@
1/* Checking macros for poll functions.
2 Copyright (C) 2012-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SYS_POLL_H
20# error "Never include <bits/poll2.h> directly; use <sys/poll.h> instead."
21#endif
22
23
24__BEGIN_DECLS
25
26extern int __REDIRECT (__poll_alias, (struct pollfd *__fds, nfds_t __nfds,
27 int __timeout), poll);
28extern int __poll_chk (struct pollfd *__fds, nfds_t __nfds, int __timeout,
29 __SIZE_TYPE__ __fdslen);
30extern int __REDIRECT (__poll_chk_warn, (struct pollfd *__fds, nfds_t __nfds,
31 int __timeout, __SIZE_TYPE__ __fdslen),
32 __poll_chk)
33 __warnattr ("poll called with fds buffer too small file nfds entries");
34
35__fortify_function int
36poll (struct pollfd *__fds, nfds_t __nfds, int __timeout)
37{
38 if (__bos (__fds) != (__SIZE_TYPE__) -1)
39 {
40 if (! __builtin_constant_p (__nfds))
41 return __poll_chk (__fds, __nfds, __timeout, __bos (__fds));
42 else if (__bos (__fds) / sizeof (*__fds) < __nfds)
43 return __poll_chk_warn (__fds, __nfds, __timeout, __bos (__fds));
44 }
45
46 return __poll_alias (__fds, __nfds, __timeout);
47}
48
49
50#ifdef __USE_GNU
51extern int __REDIRECT (__ppoll_alias, (struct pollfd *__fds, nfds_t __nfds,
52 const struct timespec *__timeout,
53 const __sigset_t *__ss), ppoll);
54extern int __ppoll_chk (struct pollfd *__fds, nfds_t __nfds,
55 const struct timespec *__timeout,
56 const __sigset_t *__ss, __SIZE_TYPE__ __fdslen);
57extern int __REDIRECT (__ppoll_chk_warn, (struct pollfd *__fds, nfds_t __nfds,
58 const struct timespec *__timeout,
59 const __sigset_t *__ss,
60 __SIZE_TYPE__ __fdslen),
61 __ppoll_chk)
62 __warnattr ("ppoll called with fds buffer too small file nfds entries");
63
64__fortify_function int
65ppoll (struct pollfd *__fds, nfds_t __nfds, const struct timespec *__timeout,
66 const __sigset_t *__ss)
67{
68 if (__bos (__fds) != (__SIZE_TYPE__) -1)
69 {
70 if (! __builtin_constant_p (__nfds))
71 return __ppoll_chk (__fds, __nfds, __timeout, __ss, __bos (__fds));
72 else if (__bos (__fds) / sizeof (*__fds) < __nfds)
73 return __ppoll_chk_warn (__fds, __nfds, __timeout, __ss,
74 __bos (__fds));
75 }
76
77 return __ppoll_alias (__fds, __nfds, __timeout, __ss);
78}
79#endif
80
81__END_DECLS
libc/glibc-include/bits/posix1_lim.h created+183
...@@ -0,0 +1,183 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/*
19 * POSIX Standard: 2.9.2 Minimum Values Added to <limits.h>
20 *
21 * Never include this file directly; use <limits.h> instead.
22 */
23
24#ifndef _BITS_POSIX1_LIM_H
25#define _BITS_POSIX1_LIM_H 1
26
27#include <bits/wordsize.h>
28
29/* These are the standard-mandated minimum values. */
30
31/* Minimum number of operations in one list I/O call. */
32#define _POSIX_AIO_LISTIO_MAX 2
33
34/* Minimal number of outstanding asynchronous I/O operations. */
35#define _POSIX_AIO_MAX 1
36
37/* Maximum length of arguments to `execve', including environment. */
38#define _POSIX_ARG_MAX 4096
39
40/* Maximum simultaneous processes per real user ID. */
41#ifdef __USE_XOPEN2K
42# define _POSIX_CHILD_MAX 25
43#else
44# define _POSIX_CHILD_MAX 6
45#endif
46
47/* Minimal number of timer expiration overruns. */
48#define _POSIX_DELAYTIMER_MAX 32
49
50/* Maximum length of a host name (not including the terminating null)
51 as returned from the GETHOSTNAME function. */
52#define _POSIX_HOST_NAME_MAX 255
53
54/* Maximum link count of a file. */
55#define _POSIX_LINK_MAX 8
56
57/* Maximum length of login name. */
58#define _POSIX_LOGIN_NAME_MAX 9
59
60/* Number of bytes in a terminal canonical input queue. */
61#define _POSIX_MAX_CANON 255
62
63/* Number of bytes for which space will be
64 available in a terminal input queue. */
65#define _POSIX_MAX_INPUT 255
66
67/* Maximum number of message queues open for a process. */
68#define _POSIX_MQ_OPEN_MAX 8
69
70/* Maximum number of supported message priorities. */
71#define _POSIX_MQ_PRIO_MAX 32
72
73/* Number of bytes in a filename. */
74#define _POSIX_NAME_MAX 14
75
76/* Number of simultaneous supplementary group IDs per process. */
77#ifdef __USE_XOPEN2K
78# define _POSIX_NGROUPS_MAX 8
79#else
80# define _POSIX_NGROUPS_MAX 0
81#endif
82
83/* Number of files one process can have open at once. */
84#ifdef __USE_XOPEN2K
85# define _POSIX_OPEN_MAX 20
86#else
87# define _POSIX_OPEN_MAX 16
88#endif
89
90#if !defined __USE_XOPEN2K || defined __USE_GNU
91/* Number of descriptors that a process may examine with `pselect' or
92 `select'. */
93# define _POSIX_FD_SETSIZE _POSIX_OPEN_MAX
94#endif
95
96/* Number of bytes in a pathname. */
97#define _POSIX_PATH_MAX 256
98
99/* Number of bytes than can be written atomically to a pipe. */
100#define _POSIX_PIPE_BUF 512
101
102/* The number of repeated occurrences of a BRE permitted by the
103 REGEXEC and REGCOMP functions when using the interval notation. */
104#define _POSIX_RE_DUP_MAX 255
105
106/* Minimal number of realtime signals reserved for the application. */
107#define _POSIX_RTSIG_MAX 8
108
109/* Number of semaphores a process can have. */
110#define _POSIX_SEM_NSEMS_MAX 256
111
112/* Maximal value of a semaphore. */
113#define _POSIX_SEM_VALUE_MAX 32767
114
115/* Number of pending realtime signals. */
116#define _POSIX_SIGQUEUE_MAX 32
117
118/* Largest value of a `ssize_t'. */
119#define _POSIX_SSIZE_MAX 32767
120
121/* Number of streams a process can have open at once. */
122#define _POSIX_STREAM_MAX 8
123
124/* The number of bytes in a symbolic link. */
125#define _POSIX_SYMLINK_MAX 255
126
127/* The number of symbolic links that can be traversed in the
128 resolution of a pathname in the absence of a loop. */
129#define _POSIX_SYMLOOP_MAX 8
130
131/* Number of timer for a process. */
132#define _POSIX_TIMER_MAX 32
133
134/* Maximum number of characters in a tty name. */
135#define _POSIX_TTY_NAME_MAX 9
136
137/* Maximum length of a timezone name (element of `tzname'). */
138#ifdef __USE_XOPEN2K
139# define _POSIX_TZNAME_MAX 6
140#else
141# define _POSIX_TZNAME_MAX 3
142#endif
143
144#if !defined __USE_XOPEN2K || defined __USE_GNU
145/* Maximum number of connections that can be queued on a socket. */
146# define _POSIX_QLIMIT 1
147
148/* Maximum number of bytes that can be buffered on a socket for send
149 or receive. */
150# define _POSIX_HIWAT _POSIX_PIPE_BUF
151
152/* Maximum number of elements in an `iovec' array. */
153# define _POSIX_UIO_MAXIOV 16
154#endif
155
156/* Maximum clock resolution in nanoseconds. */
157#define _POSIX_CLOCKRES_MIN 20000000
158
159
160/* Get the implementation-specific values for the above. */
161#include <bits/local_lim.h>
162
163
164#ifndef SSIZE_MAX
165/* ssize_t is not formally required to be the signed type
166 corresponding to size_t, but it is for all configurations supported
167 by glibc. */
168# if __WORDSIZE == 64 || __WORDSIZE32_SIZE_ULONG
169# define SSIZE_MAX LONG_MAX
170# else
171# define SSIZE_MAX INT_MAX
172# endif
173#endif
174
175
176/* This value is a guaranteed minimum maximum.
177 The current maximum can be got from `sysconf'. */
178
179#ifndef NGROUPS_MAX
180# define NGROUPS_MAX 8
181#endif
182
183#endif /* bits/posix1_lim.h */
libc/glibc-include/bits/posix2_lim.h created+90
...@@ -0,0 +1,90 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/*
19 * Never include this file directly; include <limits.h> instead.
20 */
21
22#ifndef _BITS_POSIX2_LIM_H
23#define _BITS_POSIX2_LIM_H 1
24
25
26/* The maximum `ibase' and `obase' values allowed by the `bc' utility. */
27#define _POSIX2_BC_BASE_MAX 99
28
29/* The maximum number of elements allowed in an array by the `bc' utility. */
30#define _POSIX2_BC_DIM_MAX 2048
31
32/* The maximum `scale' value allowed by the `bc' utility. */
33#define _POSIX2_BC_SCALE_MAX 99
34
35/* The maximum length of a string constant accepted by the `bc' utility. */
36#define _POSIX2_BC_STRING_MAX 1000
37
38/* The maximum number of weights that can be assigned to an entry of
39 the LC_COLLATE `order' keyword in the locale definition file. */
40#define _POSIX2_COLL_WEIGHTS_MAX 2
41
42/* The maximum number of expressions that can be nested
43 within parentheses by the `expr' utility. */
44#define _POSIX2_EXPR_NEST_MAX 32
45
46/* The maximum length, in bytes, of an input line. */
47#define _POSIX2_LINE_MAX 2048
48
49/* The maximum number of repeated occurrences of a regular expression
50 permitted when using the interval notation `\{M,N\}'. */
51#define _POSIX2_RE_DUP_MAX 255
52
53/* The maximum number of bytes in a character class name. We have no
54 fixed limit, 2048 is a high number. */
55#define _POSIX2_CHARCLASS_NAME_MAX 14
56
57
58/* These values are implementation-specific,
59 and may vary within the implementation.
60 Their precise values can be obtained from sysconf. */
61
62#ifndef BC_BASE_MAX
63#define BC_BASE_MAX _POSIX2_BC_BASE_MAX
64#endif
65#ifndef BC_DIM_MAX
66#define BC_DIM_MAX _POSIX2_BC_DIM_MAX
67#endif
68#ifndef BC_SCALE_MAX
69#define BC_SCALE_MAX _POSIX2_BC_SCALE_MAX
70#endif
71#ifndef BC_STRING_MAX
72#define BC_STRING_MAX _POSIX2_BC_STRING_MAX
73#endif
74#ifndef COLL_WEIGHTS_MAX
75#define COLL_WEIGHTS_MAX 255
76#endif
77#ifndef EXPR_NEST_MAX
78#define EXPR_NEST_MAX _POSIX2_EXPR_NEST_MAX
79#endif
80#ifndef LINE_MAX
81#define LINE_MAX _POSIX2_LINE_MAX
82#endif
83#ifndef CHARCLASS_NAME_MAX
84#define CHARCLASS_NAME_MAX 2048
85#endif
86
87/* This value is defined like this in regex.h. */
88#define RE_DUP_MAX (0x7fff)
89
90#endif /* bits/posix2_lim.h */
libc/glibc-include/bits/posix_opt.h created+191
...@@ -0,0 +1,191 @@
1/* Define POSIX options for Linux.
2 Copyright (C) 1996-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If
17 not, see <http://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_POSIX_OPT_H
20#define _BITS_POSIX_OPT_H 1
21
22/* Job control is supported. */
23#define _POSIX_JOB_CONTROL 1
24
25/* Processes have a saved set-user-ID and a saved set-group-ID. */
26#define _POSIX_SAVED_IDS 1
27
28/* Priority scheduling is supported. */
29#define _POSIX_PRIORITY_SCHEDULING 200809L
30
31/* Synchronizing file data is supported. */
32#define _POSIX_SYNCHRONIZED_IO 200809L
33
34/* The fsync function is present. */
35#define _POSIX_FSYNC 200809L
36
37/* Mapping of files to memory is supported. */
38#define _POSIX_MAPPED_FILES 200809L
39
40/* Locking of all memory is supported. */
41#define _POSIX_MEMLOCK 200809L
42
43/* Locking of ranges of memory is supported. */
44#define _POSIX_MEMLOCK_RANGE 200809L
45
46/* Setting of memory protections is supported. */
47#define _POSIX_MEMORY_PROTECTION 200809L
48
49/* Some filesystems allow all users to change file ownership. */
50#define _POSIX_CHOWN_RESTRICTED 0
51
52/* `c_cc' member of 'struct termios' structure can be disabled by
53 using the value _POSIX_VDISABLE. */
54#define _POSIX_VDISABLE '\0'
55
56/* Filenames are not silently truncated. */
57#define _POSIX_NO_TRUNC 1
58
59/* X/Open realtime support is available. */
60#define _XOPEN_REALTIME 1
61
62/* X/Open thread realtime support is available. */
63#define _XOPEN_REALTIME_THREADS 1
64
65/* XPG4.2 shared memory is supported. */
66#define _XOPEN_SHM 1
67
68/* Tell we have POSIX threads. */
69#define _POSIX_THREADS 200809L
70
71/* We have the reentrant functions described in POSIX. */
72#define _POSIX_REENTRANT_FUNCTIONS 1
73#define _POSIX_THREAD_SAFE_FUNCTIONS 200809L
74
75/* We provide priority scheduling for threads. */
76#define _POSIX_THREAD_PRIORITY_SCHEDULING 200809L
77
78/* We support user-defined stack sizes. */
79#define _POSIX_THREAD_ATTR_STACKSIZE 200809L
80
81/* We support user-defined stacks. */
82#define _POSIX_THREAD_ATTR_STACKADDR 200809L
83
84/* We support priority inheritence. */
85#define _POSIX_THREAD_PRIO_INHERIT 200809L
86
87/* We support priority protection, though only for non-robust
88 mutexes. */
89#define _POSIX_THREAD_PRIO_PROTECT 200809L
90
91#ifdef __USE_XOPEN2K8
92/* We support priority inheritence for robust mutexes. */
93# define _POSIX_THREAD_ROBUST_PRIO_INHERIT 200809L
94
95/* We do not support priority protection for robust mutexes. */
96# define _POSIX_THREAD_ROBUST_PRIO_PROTECT -1
97#endif
98
99/* We support POSIX.1b semaphores. */
100#define _POSIX_SEMAPHORES 200809L
101
102/* Real-time signals are supported. */
103#define _POSIX_REALTIME_SIGNALS 200809L
104
105/* We support asynchronous I/O. */
106#define _POSIX_ASYNCHRONOUS_IO 200809L
107#define _POSIX_ASYNC_IO 1
108/* Alternative name for Unix98. */
109#define _LFS_ASYNCHRONOUS_IO 1
110/* Support for prioritization is also available. */
111#define _POSIX_PRIORITIZED_IO 200809L
112
113/* The LFS support in asynchronous I/O is also available. */
114#define _LFS64_ASYNCHRONOUS_IO 1
115
116/* The rest of the LFS is also available. */
117#define _LFS_LARGEFILE 1
118#define _LFS64_LARGEFILE 1
119#define _LFS64_STDIO 1
120
121/* POSIX shared memory objects are implemented. */
122#define _POSIX_SHARED_MEMORY_OBJECTS 200809L
123
124/* CPU-time clocks support needs to be checked at runtime. */
125#define _POSIX_CPUTIME 0
126
127/* Clock support in threads must be also checked at runtime. */
128#define _POSIX_THREAD_CPUTIME 0
129
130/* GNU libc provides regular expression handling. */
131#define _POSIX_REGEXP 1
132
133/* Reader/Writer locks are available. */
134#define _POSIX_READER_WRITER_LOCKS 200809L
135
136/* We have a POSIX shell. */
137#define _POSIX_SHELL 1
138
139/* We support the Timeouts option. */
140#define _POSIX_TIMEOUTS 200809L
141
142/* We support spinlocks. */
143#define _POSIX_SPIN_LOCKS 200809L
144
145/* The `spawn' function family is supported. */
146#define _POSIX_SPAWN 200809L
147
148/* We have POSIX timers. */
149#define _POSIX_TIMERS 200809L
150
151/* The barrier functions are available. */
152#define _POSIX_BARRIERS 200809L
153
154/* POSIX message queues are available. */
155#define _POSIX_MESSAGE_PASSING 200809L
156
157/* Thread process-shared synchronization is supported. */
158#define _POSIX_THREAD_PROCESS_SHARED 200809L
159
160/* The monotonic clock might be available. */
161#define _POSIX_MONOTONIC_CLOCK 0
162
163/* The clock selection interfaces are available. */
164#define _POSIX_CLOCK_SELECTION 200809L
165
166/* Advisory information interfaces are available. */
167#define _POSIX_ADVISORY_INFO 200809L
168
169/* IPv6 support is available. */
170#define _POSIX_IPV6 200809L
171
172/* Raw socket support is available. */
173#define _POSIX_RAW_SOCKETS 200809L
174
175/* We have at least one terminal. */
176#define _POSIX2_CHAR_TERM 200809L
177
178/* Neither process nor thread sporadic server interfaces is available. */
179#define _POSIX_SPORADIC_SERVER -1
180#define _POSIX_THREAD_SPORADIC_SERVER -1
181
182/* trace.h is not available. */
183#define _POSIX_TRACE -1
184#define _POSIX_TRACE_EVENT_FILTER -1
185#define _POSIX_TRACE_INHERIT -1
186#define _POSIX_TRACE_LOG -1
187
188/* Typed memory objects are not available. */
189#define _POSIX_TYPED_MEMORY_OBJECTS -1
190
191#endif /* bits/posix_opt.h */
libc/glibc-include/bits/printf-ldbl.h created+23
...@@ -0,0 +1,23 @@
1/* -mlong-double-64 compatibility mode for <printf.h> functions.
2 Copyright (C) 2006-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _PRINTF_H
20# error "Never include <bits/printf-ldbl.h> directly; use <printf.h> instead."
21#endif
22
23__LDBL_REDIR_DECL (printf_size)
libc/glibc-include/bits/procfs-extra.h created+22
...@@ -0,0 +1,22 @@
1/* Extra sys/procfs.h definitions. Generic Linux version.
2 Copyright (C) 2018-2019 Free Software Foundation, Inc.
3
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
19
20#ifndef _SYS_PROCFS_H
21# error "Never include <bits/procfs-extra.h> directly; use <sys/procfs.h> instead."
22#endif
libc/glibc-include/bits/procfs-id.h created+30
...@@ -0,0 +1,30 @@
1/* Types of pr_uid and pr_gid in struct elf_prpsinfo. x86 version.
2 Copyright (C) 2018-2019 Free Software Foundation, Inc.
3
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
19
20#ifndef _SYS_PROCFS_H
21# error "Never include <bits/procfs-id.h> directly; use <sys/procfs.h> instead."
22#endif
23
24#if __WORDSIZE == 32
25typedef unsigned short int __pr_uid_t;
26typedef unsigned short int __pr_gid_t;
27#else
28typedef unsigned int __pr_uid_t;
29typedef unsigned int __pr_gid_t;
30#endif
libc/glibc-include/bits/procfs-prregset.h created+25
...@@ -0,0 +1,25 @@
1/* Types of prgregset_t and prfpregset_t. Generic Linux version.
2 Copyright (C) 2018-2019 Free Software Foundation, Inc.
3
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
19
20#ifndef _SYS_PROCFS_H
21# error "Never include <bits/procfs-prregset.h> directly; use <sys/procfs.h> instead."
22#endif
23
24typedef elf_gregset_t __prgregset_t;
25typedef elf_fpregset_t __prfpregset_t;
libc/glibc-include/bits/procfs.h created+50
...@@ -0,0 +1,50 @@
1/* Types for registers for sys/procfs.h. x86 version.
2 Copyright (C) 2001-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SYS_PROCFS_H
20# error "Never include <bits/procfs.h> directly; use <sys/procfs.h> instead."
21#endif
22
23/* Type for a general-purpose register. */
24#ifdef __x86_64__
25__extension__ typedef unsigned long long elf_greg_t;
26#else
27typedef unsigned long elf_greg_t;
28#endif
29
30/* And the whole bunch of them. We could have used `struct
31 user_regs_struct' directly in the typedef, but tradition says that
32 the register set is an array, which does have some peculiar
33 semantics, so leave it that way. */
34#define ELF_NGREG (sizeof (struct user_regs_struct) / sizeof(elf_greg_t))
35typedef elf_greg_t elf_gregset_t[ELF_NGREG];
36
37#ifndef __x86_64__
38/* Register set for the floating-point registers. */
39typedef struct user_fpregs_struct elf_fpregset_t;
40
41/* Register set for the extended floating-point registers. Includes
42 the Pentium III SSE registers in addition to the classic
43 floating-point stuff. */
44typedef struct user_fpxregs_struct elf_fpxregset_t;
45#else
46/* Register set for the extended floating-point registers. Includes
47 the Pentium III SSE registers in addition to the classic
48 floating-point stuff. */
49typedef struct user_fpregs_struct elf_fpregset_t;
50#endif
libc/glibc-include/bits/pthreadtypes-arch.h created+106
...@@ -0,0 +1,106 @@
1/* Copyright (C) 2002-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _BITS_PTHREADTYPES_ARCH_H
19#define _BITS_PTHREADTYPES_ARCH_H 1
20
21#include <bits/wordsize.h>
22
23#ifdef __x86_64__
24# if __WORDSIZE == 64
25# define __SIZEOF_PTHREAD_MUTEX_T 40
26# define __SIZEOF_PTHREAD_ATTR_T 56
27# define __SIZEOF_PTHREAD_MUTEX_T 40
28# define __SIZEOF_PTHREAD_RWLOCK_T 56
29# define __SIZEOF_PTHREAD_BARRIER_T 32
30# else
31# define __SIZEOF_PTHREAD_MUTEX_T 32
32# define __SIZEOF_PTHREAD_ATTR_T 32
33# define __SIZEOF_PTHREAD_MUTEX_T 32
34# define __SIZEOF_PTHREAD_RWLOCK_T 44
35# define __SIZEOF_PTHREAD_BARRIER_T 20
36# endif
37#else
38# define __SIZEOF_PTHREAD_MUTEX_T 24
39# define __SIZEOF_PTHREAD_ATTR_T 36
40# define __SIZEOF_PTHREAD_MUTEX_T 24
41# define __SIZEOF_PTHREAD_RWLOCK_T 32
42# define __SIZEOF_PTHREAD_BARRIER_T 20
43#endif
44#define __SIZEOF_PTHREAD_MUTEXATTR_T 4
45#define __SIZEOF_PTHREAD_COND_T 48
46#define __SIZEOF_PTHREAD_CONDATTR_T 4
47#define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
48#define __SIZEOF_PTHREAD_BARRIERATTR_T 4
49
50/* Definitions for internal mutex struct. */
51#define __PTHREAD_COMPAT_PADDING_MID
52#define __PTHREAD_COMPAT_PADDING_END
53#define __PTHREAD_MUTEX_LOCK_ELISION 1
54#ifdef __x86_64__
55# define __PTHREAD_MUTEX_NUSERS_AFTER_KIND 0
56# define __PTHREAD_MUTEX_USE_UNION 0
57#else
58# define __PTHREAD_MUTEX_NUSERS_AFTER_KIND 1
59# define __PTHREAD_MUTEX_USE_UNION 1
60#endif
61
62#define __LOCK_ALIGNMENT
63#define __ONCE_ALIGNMENT
64
65struct __pthread_rwlock_arch_t
66{
67 unsigned int __readers;
68 unsigned int __writers;
69 unsigned int __wrphase_futex;
70 unsigned int __writers_futex;
71 unsigned int __pad3;
72 unsigned int __pad4;
73#ifdef __x86_64__
74 int __cur_writer;
75 int __shared;
76 signed char __rwelision;
77# ifdef __ILP32__
78 unsigned char __pad1[3];
79# define __PTHREAD_RWLOCK_ELISION_EXTRA 0, { 0, 0, 0 }
80# else
81 unsigned char __pad1[7];
82# define __PTHREAD_RWLOCK_ELISION_EXTRA 0, { 0, 0, 0, 0, 0, 0, 0 }
83# endif
84 unsigned long int __pad2;
85 /* FLAGS must stay at this position in the structure to maintain
86 binary compatibility. */
87 unsigned int __flags;
88# define __PTHREAD_RWLOCK_INT_FLAGS_SHARED 1
89#else
90 /* FLAGS must stay at this position in the structure to maintain
91 binary compatibility. */
92 unsigned char __flags;
93 unsigned char __shared;
94 signed char __rwelision;
95# define __PTHREAD_RWLOCK_ELISION_EXTRA 0
96 unsigned char __pad2;
97 int __cur_writer;
98#endif
99};
100
101#ifndef __x86_64__
102/* Extra attributes for the cleanup functions. */
103# define __cleanup_fct_attribute __attribute__ ((__regparm__ (1)))
104#endif
105
106#endif /* bits/pthreadtypes.h */
libc/glibc-include/bits/pthreadtypes.h created+121
...@@ -0,0 +1,121 @@
1/* Declaration of common pthread types for all architectures.
2 Copyright (C) 2017-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_PTHREADTYPES_COMMON_H
20# define _BITS_PTHREADTYPES_COMMON_H 1
21
22/* For internal mutex and condition variable definitions. */
23#include <bits/thread-shared-types.h>
24
25/* Thread identifiers. The structure of the attribute type is not
26 exposed on purpose. */
27typedef unsigned long int pthread_t;
28
29
30/* Data structures for mutex handling. The structure of the attribute
31 type is not exposed on purpose. */
32typedef union
33{
34 char __size[__SIZEOF_PTHREAD_MUTEXATTR_T];
35 int __align;
36} pthread_mutexattr_t;
37
38
39/* Data structure for condition variable handling. The structure of
40 the attribute type is not exposed on purpose. */
41typedef union
42{
43 char __size[__SIZEOF_PTHREAD_CONDATTR_T];
44 int __align;
45} pthread_condattr_t;
46
47
48/* Keys for thread-specific data */
49typedef unsigned int pthread_key_t;
50
51
52/* Once-only execution */
53typedef int __ONCE_ALIGNMENT pthread_once_t;
54
55
56union pthread_attr_t
57{
58 char __size[__SIZEOF_PTHREAD_ATTR_T];
59 long int __align;
60};
61#ifndef __have_pthread_attr_t
62typedef union pthread_attr_t pthread_attr_t;
63# define __have_pthread_attr_t 1
64#endif
65
66
67typedef union
68{
69 struct __pthread_mutex_s __data;
70 char __size[__SIZEOF_PTHREAD_MUTEX_T];
71 long int __align;
72} pthread_mutex_t;
73
74
75typedef union
76{
77 struct __pthread_cond_s __data;
78 char __size[__SIZEOF_PTHREAD_COND_T];
79 __extension__ long long int __align;
80} pthread_cond_t;
81
82
83#if defined __USE_UNIX98 || defined __USE_XOPEN2K
84/* Data structure for reader-writer lock variable handling. The
85 structure of the attribute type is deliberately not exposed. */
86typedef union
87{
88 struct __pthread_rwlock_arch_t __data;
89 char __size[__SIZEOF_PTHREAD_RWLOCK_T];
90 long int __align;
91} pthread_rwlock_t;
92
93typedef union
94{
95 char __size[__SIZEOF_PTHREAD_RWLOCKATTR_T];
96 long int __align;
97} pthread_rwlockattr_t;
98#endif
99
100
101#ifdef __USE_XOPEN2K
102/* POSIX spinlock data type. */
103typedef volatile int pthread_spinlock_t;
104
105
106/* POSIX barriers data type. The structure of the type is
107 deliberately not exposed. */
108typedef union
109{
110 char __size[__SIZEOF_PTHREAD_BARRIER_T];
111 long int __align;
112} pthread_barrier_t;
113
114typedef union
115{
116 char __size[__SIZEOF_PTHREAD_BARRIERATTR_T];
117 int __align;
118} pthread_barrierattr_t;
119#endif
120
121#endif
libc/glibc-include/bits/ptrace-shared.h created+85
...@@ -0,0 +1,85 @@
1/* `ptrace' debugger support interface. Linux version,
2 not architecture-specific.
3 Copyright (C) 1996-2019 Free Software Foundation, Inc.
4
5 This file is part of the GNU C Library.
6
7 The GNU C Library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
11
12 The GNU C Library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with the GNU C Library; if not, see
19 <http://www.gnu.org/licenses/>. */
20
21#ifndef _SYS_PTRACE_H
22# error "Never use <bits/ptrace-shared.h> directly; include <sys/ptrace.h> instead."
23#endif
24
25/* Options set using PTRACE_SETOPTIONS. */
26enum __ptrace_setoptions
27{
28 PTRACE_O_TRACESYSGOOD = 0x00000001,
29 PTRACE_O_TRACEFORK = 0x00000002,
30 PTRACE_O_TRACEVFORK = 0x00000004,
31 PTRACE_O_TRACECLONE = 0x00000008,
32 PTRACE_O_TRACEEXEC = 0x00000010,
33 PTRACE_O_TRACEVFORKDONE = 0x00000020,
34 PTRACE_O_TRACEEXIT = 0x00000040,
35 PTRACE_O_TRACESECCOMP = 0x00000080,
36 PTRACE_O_EXITKILL = 0x00100000,
37 PTRACE_O_SUSPEND_SECCOMP = 0x00200000,
38 PTRACE_O_MASK = 0x003000ff
39};
40
41enum __ptrace_eventcodes
42{
43/* Wait extended result codes for the above trace options. */
44 PTRACE_EVENT_FORK = 1,
45 PTRACE_EVENT_VFORK = 2,
46 PTRACE_EVENT_CLONE = 3,
47 PTRACE_EVENT_EXEC = 4,
48 PTRACE_EVENT_VFORK_DONE = 5,
49 PTRACE_EVENT_EXIT = 6,
50 PTRACE_EVENT_SECCOMP = 7,
51/* Extended result codes enabled by means other than options. */
52 PTRACE_EVENT_STOP = 128
53};
54
55/* Arguments for PTRACE_PEEKSIGINFO. */
56struct __ptrace_peeksiginfo_args
57{
58 __uint64_t off; /* From which siginfo to start. */
59 __uint32_t flags; /* Flags for peeksiginfo. */
60 __int32_t nr; /* How many siginfos to take. */
61};
62
63enum __ptrace_peeksiginfo_flags
64{
65 /* Read signals from a shared (process wide) queue. */
66 PTRACE_PEEKSIGINFO_SHARED = (1 << 0)
67};
68
69/* Argument and results of PTRACE_SECCOMP_GET_METADATA. */
70struct __ptrace_seccomp_metadata
71{
72 __uint64_t filter_off; /* Input: which filter. */
73 __uint64_t flags; /* Output: filter's flags. */
74};
75
76/* Perform process tracing functions. REQUEST is one of the values
77 above, and determines the action to be taken.
78 For all requests except PTRACE_TRACEME, PID specifies the process to be
79 traced.
80
81 PID and the other arguments described above for the various requests should
82 appear (those that are used for the particular request) as:
83 pid_t PID, void *ADDR, int DATA, void *ADDR2
84 after REQUEST. */
85extern long int ptrace (enum __ptrace_request __request, ...) __THROW;
libc/glibc-include/bits/resource.h created+223
...@@ -0,0 +1,223 @@
1/* Bit values & structures for resource limits. Linux version.
2 Copyright (C) 1994-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SYS_RESOURCE_H
20# error "Never use <bits/resource.h> directly; include <sys/resource.h> instead."
21#endif
22
23#include <bits/types.h>
24
25/* Transmute defines to enumerations. The macro re-definitions are
26 necessary because some programs want to test for operating system
27 features with #ifdef RUSAGE_SELF. In ISO C the reflexive
28 definition is a no-op. */
29
30/* Kinds of resource limit. */
31enum __rlimit_resource
32{
33 /* Per-process CPU limit, in seconds. */
34 RLIMIT_CPU = 0,
35#define RLIMIT_CPU RLIMIT_CPU
36
37 /* Largest file that can be created, in bytes. */
38 RLIMIT_FSIZE = 1,
39#define RLIMIT_FSIZE RLIMIT_FSIZE
40
41 /* Maximum size of data segment, in bytes. */
42 RLIMIT_DATA = 2,
43#define RLIMIT_DATA RLIMIT_DATA
44
45 /* Maximum size of stack segment, in bytes. */
46 RLIMIT_STACK = 3,
47#define RLIMIT_STACK RLIMIT_STACK
48
49 /* Largest core file that can be created, in bytes. */
50 RLIMIT_CORE = 4,
51#define RLIMIT_CORE RLIMIT_CORE
52
53 /* Largest resident set size, in bytes.
54 This affects swapping; processes that are exceeding their
55 resident set size will be more likely to have physical memory
56 taken from them. */
57 __RLIMIT_RSS = 5,
58#define RLIMIT_RSS __RLIMIT_RSS
59
60 /* Number of open files. */
61 RLIMIT_NOFILE = 7,
62 __RLIMIT_OFILE = RLIMIT_NOFILE, /* BSD name for same. */
63#define RLIMIT_NOFILE RLIMIT_NOFILE
64#define RLIMIT_OFILE __RLIMIT_OFILE
65
66 /* Address space limit. */
67 RLIMIT_AS = 9,
68#define RLIMIT_AS RLIMIT_AS
69
70 /* Number of processes. */
71 __RLIMIT_NPROC = 6,
72#define RLIMIT_NPROC __RLIMIT_NPROC
73
74 /* Locked-in-memory address space. */
75 __RLIMIT_MEMLOCK = 8,
76#define RLIMIT_MEMLOCK __RLIMIT_MEMLOCK
77
78 /* Maximum number of file locks. */
79 __RLIMIT_LOCKS = 10,
80#define RLIMIT_LOCKS __RLIMIT_LOCKS
81
82 /* Maximum number of pending signals. */
83 __RLIMIT_SIGPENDING = 11,
84#define RLIMIT_SIGPENDING __RLIMIT_SIGPENDING
85
86 /* Maximum bytes in POSIX message queues. */
87 __RLIMIT_MSGQUEUE = 12,
88#define RLIMIT_MSGQUEUE __RLIMIT_MSGQUEUE
89
90 /* Maximum nice priority allowed to raise to.
91 Nice levels 19 .. -20 correspond to 0 .. 39
92 values of this resource limit. */
93 __RLIMIT_NICE = 13,
94#define RLIMIT_NICE __RLIMIT_NICE
95
96 /* Maximum realtime priority allowed for non-priviledged
97 processes. */
98 __RLIMIT_RTPRIO = 14,
99#define RLIMIT_RTPRIO __RLIMIT_RTPRIO
100
101 /* Maximum CPU time in µs that a process scheduled under a real-time
102 scheduling policy may consume without making a blocking system
103 call before being forcibly descheduled. */
104 __RLIMIT_RTTIME = 15,
105#define RLIMIT_RTTIME __RLIMIT_RTTIME
106
107 __RLIMIT_NLIMITS = 16,
108 __RLIM_NLIMITS = __RLIMIT_NLIMITS
109#define RLIMIT_NLIMITS __RLIMIT_NLIMITS
110#define RLIM_NLIMITS __RLIM_NLIMITS
111};
112
113/* Value to indicate that there is no limit. */
114#ifndef __USE_FILE_OFFSET64
115# define RLIM_INFINITY ((__rlim_t) -1)
116#else
117# define RLIM_INFINITY 0xffffffffffffffffuLL
118#endif
119
120#ifdef __USE_LARGEFILE64
121# define RLIM64_INFINITY 0xffffffffffffffffuLL
122#endif
123
124/* We can represent all limits. */
125#define RLIM_SAVED_MAX RLIM_INFINITY
126#define RLIM_SAVED_CUR RLIM_INFINITY
127
128
129/* Type for resource quantity measurement. */
130#ifndef __USE_FILE_OFFSET64
131typedef __rlim_t rlim_t;
132#else
133typedef __rlim64_t rlim_t;
134#endif
135#ifdef __USE_LARGEFILE64
136typedef __rlim64_t rlim64_t;
137#endif
138
139struct rlimit
140 {
141 /* The current (soft) limit. */
142 rlim_t rlim_cur;
143 /* The hard limit. */
144 rlim_t rlim_max;
145 };
146
147#ifdef __USE_LARGEFILE64
148struct rlimit64
149 {
150 /* The current (soft) limit. */
151 rlim64_t rlim_cur;
152 /* The hard limit. */
153 rlim64_t rlim_max;
154 };
155#endif
156
157/* Whose usage statistics do you want? */
158enum __rusage_who
159{
160 /* The calling process. */
161 RUSAGE_SELF = 0,
162#define RUSAGE_SELF RUSAGE_SELF
163
164 /* All of its terminated child processes. */
165 RUSAGE_CHILDREN = -1
166#define RUSAGE_CHILDREN RUSAGE_CHILDREN
167
168#ifdef __USE_GNU
169 ,
170 /* The calling thread. */
171 RUSAGE_THREAD = 1
172# define RUSAGE_THREAD RUSAGE_THREAD
173 /* Name for the same functionality on Solaris. */
174# define RUSAGE_LWP RUSAGE_THREAD
175#endif
176};
177
178#include <bits/types/struct_timeval.h>
179#include <bits/types/struct_rusage.h>
180
181/* Priority limits. */
182#define PRIO_MIN -20 /* Minimum priority a process can have. */
183#define PRIO_MAX 20 /* Maximum priority a process can have. */
184
185/* The type of the WHICH argument to `getpriority' and `setpriority',
186 indicating what flavor of entity the WHO argument specifies. */
187enum __priority_which
188{
189 PRIO_PROCESS = 0, /* WHO is a process ID. */
190#define PRIO_PROCESS PRIO_PROCESS
191 PRIO_PGRP = 1, /* WHO is a process group ID. */
192#define PRIO_PGRP PRIO_PGRP
193 PRIO_USER = 2 /* WHO is a user ID. */
194#define PRIO_USER PRIO_USER
195};
196
197
198__BEGIN_DECLS
199
200#ifdef __USE_GNU
201/* Modify and return resource limits of a process atomically. */
202# ifndef __USE_FILE_OFFSET64
203extern int prlimit (__pid_t __pid, enum __rlimit_resource __resource,
204 const struct rlimit *__new_limit,
205 struct rlimit *__old_limit) __THROW;
206# else
207# ifdef __REDIRECT_NTH
208extern int __REDIRECT_NTH (prlimit, (__pid_t __pid,
209 enum __rlimit_resource __resource,
210 const struct rlimit *__new_limit,
211 struct rlimit *__old_limit), prlimit64);
212# else
213# define prlimit prlimit64
214# endif
215# endif
216# ifdef __USE_LARGEFILE64
217extern int prlimit64 (__pid_t __pid, enum __rlimit_resource __resource,
218 const struct rlimit64 *__new_limit,
219 struct rlimit64 *__old_limit) __THROW;
220# endif
221#endif
222
223__END_DECLS
libc/glibc-include/bits/sched.h created+98
...@@ -0,0 +1,98 @@
1/* Definitions of constants and data structure for POSIX 1003.1b-1993
2 scheduling interface.
3 Copyright (C) 1996-2019 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
19
20#ifndef _BITS_SCHED_H
21#define _BITS_SCHED_H 1
22
23#ifndef _SCHED_H
24# error "Never include <bits/sched.h> directly; use <sched.h> instead."
25#endif
26
27/* Scheduling algorithms. */
28#define SCHED_OTHER 0
29#define SCHED_FIFO 1
30#define SCHED_RR 2
31#ifdef __USE_GNU
32# define SCHED_BATCH 3
33# define SCHED_ISO 4
34# define SCHED_IDLE 5
35# define SCHED_DEADLINE 6
36
37# define SCHED_RESET_ON_FORK 0x40000000
38#endif
39
40#ifdef __USE_GNU
41/* Cloning flags. */
42# define CSIGNAL 0x000000ff /* Signal mask to be sent at exit. */
43# define CLONE_VM 0x00000100 /* Set if VM shared between processes. */
44# define CLONE_FS 0x00000200 /* Set if fs info shared between processes. */
45# define CLONE_FILES 0x00000400 /* Set if open files shared between processes. */
46# define CLONE_SIGHAND 0x00000800 /* Set if signal handlers shared. */
47# define CLONE_PTRACE 0x00002000 /* Set if tracing continues on the child. */
48# define CLONE_VFORK 0x00004000 /* Set if the parent wants the child to
49 wake it up on mm_release. */
50# define CLONE_PARENT 0x00008000 /* Set if we want to have the same
51 parent as the cloner. */
52# define CLONE_THREAD 0x00010000 /* Set to add to same thread group. */
53# define CLONE_NEWNS 0x00020000 /* Set to create new namespace. */
54# define CLONE_SYSVSEM 0x00040000 /* Set to shared SVID SEM_UNDO semantics. */
55# define CLONE_SETTLS 0x00080000 /* Set TLS info. */
56# define CLONE_PARENT_SETTID 0x00100000 /* Store TID in userlevel buffer
57 before MM copy. */
58# define CLONE_CHILD_CLEARTID 0x00200000 /* Register exit futex and memory
59 location to clear. */
60# define CLONE_DETACHED 0x00400000 /* Create clone detached. */
61# define CLONE_UNTRACED 0x00800000 /* Set if the tracing process can't
62 force CLONE_PTRACE on this clone. */
63# define CLONE_CHILD_SETTID 0x01000000 /* Store TID in userlevel buffer in
64 the child. */
65# define CLONE_NEWCGROUP 0x02000000 /* New cgroup namespace. */
66# define CLONE_NEWUTS 0x04000000 /* New utsname group. */
67# define CLONE_NEWIPC 0x08000000 /* New ipcs. */
68# define CLONE_NEWUSER 0x10000000 /* New user namespace. */
69# define CLONE_NEWPID 0x20000000 /* New pid namespace. */
70# define CLONE_NEWNET 0x40000000 /* New network namespace. */
71# define CLONE_IO 0x80000000 /* Clone I/O context. */
72#endif
73
74#include <bits/types/struct_sched_param.h>
75
76__BEGIN_DECLS
77
78#ifdef __USE_GNU
79/* Clone current process. */
80extern int clone (int (*__fn) (void *__arg), void *__child_stack,
81 int __flags, void *__arg, ...) __THROW;
82
83/* Unshare the specified resources. */
84extern int unshare (int __flags) __THROW;
85
86/* Get index of currently used CPU. */
87extern int sched_getcpu (void) __THROW;
88
89/* Get currently used CPU and NUMA node. */
90extern int getcpu (unsigned int *, unsigned int *) __THROW;
91
92/* Switch process to namespace of type NSTYPE indicated by FD. */
93extern int setns (int __fd, int __nstype) __THROW;
94#endif
95
96__END_DECLS
97
98#endif /* bits/sched.h */
libc/glibc-include/bits/select.h created+63
...@@ -0,0 +1,63 @@
1/* Copyright (C) 1997-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_SELECT_H
19# error "Never use <bits/select.h> directly; include <sys/select.h> instead."
20#endif
21
22#include <bits/wordsize.h>
23
24
25#if defined __GNUC__ && __GNUC__ >= 2
26
27# if __WORDSIZE == 64
28# define __FD_ZERO_STOS "stosq"
29# else
30# define __FD_ZERO_STOS "stosl"
31# endif
32
33# define __FD_ZERO(fdsp) \
34 do { \
35 int __d0, __d1; \
36 __asm__ __volatile__ ("cld; rep; " __FD_ZERO_STOS \
37 : "=c" (__d0), "=D" (__d1) \
38 : "a" (0), "0" (sizeof (fd_set) \
39 / sizeof (__fd_mask)), \
40 "1" (&__FDS_BITS (fdsp)[0]) \
41 : "memory"); \
42 } while (0)
43
44#else /* ! GNU CC */
45
46/* We don't use `memset' because this would require a prototype and
47 the array isn't too big. */
48# define __FD_ZERO(set) \
49 do { \
50 unsigned int __i; \
51 fd_set *__arr = (set); \
52 for (__i = 0; __i < sizeof (fd_set) / sizeof (__fd_mask); ++__i) \
53 __FDS_BITS (__arr)[__i] = 0; \
54 } while (0)
55
56#endif /* GNU CC */
57
58#define __FD_SET(d, set) \
59 ((void) (__FDS_BITS (set)[__FD_ELT (d)] |= __FD_MASK (d)))
60#define __FD_CLR(d, set) \
61 ((void) (__FDS_BITS (set)[__FD_ELT (d)] &= ~__FD_MASK (d)))
62#define __FD_ISSET(d, set) \
63 ((__FDS_BITS (set)[__FD_ELT (d)] & __FD_MASK (d)) != 0)
libc/glibc-include/bits/select2.h created+35
...@@ -0,0 +1,35 @@
1/* Checking macros for select functions.
2 Copyright (C) 2011-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SYS_SELECT_H
20# error "Never include <bits/select2.h> directly; use <sys/select.h> instead."
21#endif
22
23/* Helper functions to issue warnings and errors when needed. */
24extern long int __fdelt_chk (long int __d);
25extern long int __fdelt_warn (long int __d)
26 __warnattr ("bit outside of fd_set selected");
27#undef __FD_ELT
28#define __FD_ELT(d) \
29 __extension__ \
30 ({ long int __d = (d); \
31 (__builtin_constant_p (__d) \
32 ? (0 <= __d && __d < __FD_SETSIZE \
33 ? (__d / __NFDBITS) \
34 : __fdelt_warn (__d)) \
35 : __fdelt_chk (__d)); })
libc/glibc-include/bits/sem-pad.h created+24
...@@ -0,0 +1,24 @@
1/* Define where padding goes in struct semid_ds. x86 version.
2 Copyright (C) 2018-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SYS_SEM_H
20# error "Never use <bits/sem-pad.h> directly; include <sys/sem.h> instead."
21#endif
22
23#define __SEM_PAD_AFTER_TIME 1
24#define __SEM_PAD_BEFORE_TIME 0
libc/glibc-include/bits/sem.h created+97
...@@ -0,0 +1,97 @@
1/* Copyright (C) 1995-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_SEM_H
19# error "Never include <bits/sem.h> directly; use <sys/sem.h> instead."
20#endif
21
22#include <sys/types.h>
23#include <bits/sem-pad.h>
24
25/* Flags for `semop'. */
26#define SEM_UNDO 0x1000 /* undo the operation on exit */
27
28/* Commands for `semctl'. */
29#define GETPID 11 /* get sempid */
30#define GETVAL 12 /* get semval */
31#define GETALL 13 /* get all semval's */
32#define GETNCNT 14 /* get semncnt */
33#define GETZCNT 15 /* get semzcnt */
34#define SETVAL 16 /* set semval */
35#define SETALL 17 /* set all semval's */
36
37
38#if __SEM_PAD_BEFORE_TIME
39# define __SEM_PAD_TIME(NAME, RES) \
40 __syscall_ulong_t __glibc_reserved ## RES; __time_t NAME
41#elif __SEM_PAD_AFTER_TIME
42# define __SEM_PAD_TIME(NAME, RES) \
43 __time_t NAME; __syscall_ulong_t __glibc_reserved ## RES
44#else
45# define __SEM_PAD_TIME(NAME, RES) \
46 __time_t NAME
47#endif
48
49/* Data structure describing a set of semaphores. */
50struct semid_ds
51{
52 struct ipc_perm sem_perm; /* operation permission struct */
53 __SEM_PAD_TIME (sem_otime, 1); /* last semop() time */
54 __SEM_PAD_TIME (sem_ctime, 2); /* last time changed by semctl() */
55 __syscall_ulong_t sem_nsems; /* number of semaphores in set */
56 __syscall_ulong_t __glibc_reserved3;
57 __syscall_ulong_t __glibc_reserved4;
58};
59
60/* The user should define a union like the following to use it for arguments
61 for `semctl'.
62
63 union semun
64 {
65 int val; <= value for SETVAL
66 struct semid_ds *buf; <= buffer for IPC_STAT & IPC_SET
67 unsigned short int *array; <= array for GETALL & SETALL
68 struct seminfo *__buf; <= buffer for IPC_INFO
69 };
70
71 Previous versions of this file used to define this union but this is
72 incorrect. One can test the macro _SEM_SEMUN_UNDEFINED to see whether
73 one must define the union or not. */
74#define _SEM_SEMUN_UNDEFINED 1
75
76#ifdef __USE_MISC
77
78/* ipcs ctl cmds */
79# define SEM_STAT 18
80# define SEM_INFO 19
81# define SEM_STAT_ANY 20
82
83struct seminfo
84{
85 int semmap;
86 int semmni;
87 int semmns;
88 int semmnu;
89 int semmsl;
90 int semopm;
91 int semume;
92 int semusz;
93 int semvmx;
94 int semaem;
95};
96
97#endif /* __USE_MISC */
libc/glibc-include/bits/semaphore.h created+40
...@@ -0,0 +1,40 @@
1/* Copyright (C) 2002-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SEMAPHORE_H
20# error "Never use <bits/semaphore.h> directly; include <semaphore.h> instead."
21#endif
22
23#include <bits/wordsize.h>
24
25#if __WORDSIZE == 64
26# define __SIZEOF_SEM_T 32
27#else
28# define __SIZEOF_SEM_T 16
29#endif
30
31
32/* Value returned if `sem_open' failed. */
33#define SEM_FAILED ((sem_t *) 0)
34
35
36typedef union
37{
38 char __size[__SIZEOF_SEM_T];
39 long int __align;
40} sem_t;
libc/glibc-include/bits/setjmp.h created+40
...@@ -0,0 +1,40 @@
1/* Copyright (C) 2001-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/* Define the machine-dependent type `jmp_buf'. x86-64 version. */
19#ifndef _BITS_SETJMP_H
20#define _BITS_SETJMP_H 1
21
22#if !defined _SETJMP_H && !defined _PTHREAD_H
23# error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead."
24#endif
25
26#include <bits/wordsize.h>
27
28#ifndef _ASM
29
30# if __WORDSIZE == 64
31typedef long int __jmp_buf[8];
32# elif defined __x86_64__
33__extension__ typedef long long int __jmp_buf[8];
34# else
35typedef int __jmp_buf[6];
36# endif
37
38#endif
39
40#endif /* bits/setjmp.h */
libc/glibc-include/bits/setjmp2.h created+40
...@@ -0,0 +1,40 @@
1/* Checking macros for setjmp functions.
2 Copyright (C) 2009-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SETJMP_H
20# error "Never include <bits/setjmp2.h> directly; use <setjmp.h> instead."
21#endif
22
23/* Variant of the longjmp functions which perform some sanity checking. */
24#ifdef __REDIRECT_NTH
25extern void __REDIRECT_NTHNL (longjmp,
26 (struct __jmp_buf_tag __env[1], int __val),
27 __longjmp_chk) __attribute__ ((__noreturn__));
28extern void __REDIRECT_NTHNL (_longjmp,
29 (struct __jmp_buf_tag __env[1], int __val),
30 __longjmp_chk) __attribute__ ((__noreturn__));
31extern void __REDIRECT_NTHNL (siglongjmp,
32 (struct __jmp_buf_tag __env[1], int __val),
33 __longjmp_chk) __attribute__ ((__noreturn__));
34#else
35extern void __longjmp_chk (struct __jmp_buf_tag __env[1], int __val),
36 __THROWNL __attribute__ ((__noreturn__));
37# define longjmp __longjmp_chk
38# define _longjmp __longjmp_chk
39# define siglongjmp __longjmp_chk
40#endif
libc/glibc-include/bits/shm-pad.h created+37
...@@ -0,0 +1,37 @@
1/* Define where padding goes in struct shmid_ds. Generic version.
2 Copyright (C) 2018-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SYS_SHM_H
20# error "Never use <bits/shm-pad.h> directly; include <sys/shm.h> instead."
21#endif
22
23#include <bits/timesize.h>
24
25/* On most architectures, padding goes after time fields for 32-bit
26 systems and is omitted for 64-bit systems. Some architectures pad
27 before time fields instead, or omit padding despite being 32-bit,
28 or include it despite being 64-bit. Furthermore, some
29 architectures place shm_segsz after the time fields rather than
30 before them, with or without padding there. This must match the
31 layout used for struct shmid64_ds in <asm/shmbuf.h>, as glibc does
32 not do layout conversions for this structure. */
33
34#define __SHM_PAD_AFTER_TIME (__TIMESIZE == 32)
35#define __SHM_PAD_BEFORE_TIME 0
36#define __SHM_SEGSZ_AFTER_TIME 0
37#define __SHM_PAD_BETWEEN_TIME_AND_SEGSZ 0
libc/glibc-include/bits/shm.h created+118
...@@ -0,0 +1,118 @@
1/* Copyright (C) 1995-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_SHM_H
19# error "Never include <bits/shm.h> directly; use <sys/shm.h> instead."
20#endif
21
22#include <bits/types.h>
23#include <bits/wordsize.h>
24#include <bits/shmlba.h>
25#include <bits/shm-pad.h>
26
27/* Permission flag for shmget. */
28#define SHM_R 0400 /* or S_IRUGO from <linux/stat.h> */
29#define SHM_W 0200 /* or S_IWUGO from <linux/stat.h> */
30
31/* Flags for `shmat'. */
32#define SHM_RDONLY 010000 /* attach read-only else read-write */
33#define SHM_RND 020000 /* round attach address to SHMLBA */
34#define SHM_REMAP 040000 /* take-over region on attach */
35#define SHM_EXEC 0100000 /* execution access */
36
37/* Commands for `shmctl'. */
38#define SHM_LOCK 11 /* lock segment (root only) */
39#define SHM_UNLOCK 12 /* unlock segment (root only) */
40
41__BEGIN_DECLS
42
43/* Type to count number of attaches. */
44typedef __syscall_ulong_t shmatt_t;
45
46#if __SHM_PAD_BEFORE_TIME
47# define __SHM_PAD_TIME(NAME, RES) \
48 unsigned long int __glibc_reserved ## RES; __time_t NAME
49#elif __SHM_PAD_AFTER_TIME
50# define __SHM_PAD_TIME(NAME, RES) \
51 __time_t NAME; unsigned long int __glibc_reserved ## RES
52#else
53# define __SHM_PAD_TIME(NAME, RES) \
54 __time_t NAME
55#endif
56
57/* Data structure describing a shared memory segment. */
58struct shmid_ds
59 {
60 struct ipc_perm shm_perm; /* operation permission struct */
61#if !__SHM_SEGSZ_AFTER_TIME
62 size_t shm_segsz; /* size of segment in bytes */
63#endif
64 __SHM_PAD_TIME (shm_atime, 1); /* time of last shmat() */
65 __SHM_PAD_TIME (shm_dtime, 2); /* time of last shmdt() */
66 __SHM_PAD_TIME (shm_ctime, 3); /* time of last change by shmctl() */
67#if __SHM_PAD_BETWEEN_TIME_AND_SEGSZ
68 unsigned long int __glibc_reserved4;
69#endif
70#if __SHM_SEGSZ_AFTER_TIME
71 size_t shm_segsz; /* size of segment in bytes */
72#endif
73 __pid_t shm_cpid; /* pid of creator */
74 __pid_t shm_lpid; /* pid of last shmop */
75 shmatt_t shm_nattch; /* number of current attaches */
76 __syscall_ulong_t __glibc_reserved5;
77 __syscall_ulong_t __glibc_reserved6;
78 };
79
80#ifdef __USE_MISC
81
82/* ipcs ctl commands */
83# define SHM_STAT 13
84# define SHM_INFO 14
85# define SHM_STAT_ANY 15
86
87/* shm_mode upper byte flags */
88# define SHM_DEST 01000 /* segment will be destroyed on last detach */
89# define SHM_LOCKED 02000 /* segment will not be swapped */
90# define SHM_HUGETLB 04000 /* segment is mapped via hugetlb */
91# define SHM_NORESERVE 010000 /* don't check for reservations */
92
93struct shminfo
94 {
95 __syscall_ulong_t shmmax;
96 __syscall_ulong_t shmmin;
97 __syscall_ulong_t shmmni;
98 __syscall_ulong_t shmseg;
99 __syscall_ulong_t shmall;
100 __syscall_ulong_t __glibc_reserved1;
101 __syscall_ulong_t __glibc_reserved2;
102 __syscall_ulong_t __glibc_reserved3;
103 __syscall_ulong_t __glibc_reserved4;
104 };
105
106struct shm_info
107 {
108 int used_ids;
109 __syscall_ulong_t shm_tot; /* total allocated shm */
110 __syscall_ulong_t shm_rss; /* total resident shm */
111 __syscall_ulong_t shm_swp; /* total swapped shm */
112 __syscall_ulong_t swap_attempts;
113 __syscall_ulong_t swap_successes;
114 };
115
116#endif /* __USE_MISC */
117
118__END_DECLS
libc/glibc-include/bits/shmlba.h created+29
...@@ -0,0 +1,29 @@
1/* Define SHMLBA. Generic version.
2 Copyright (C) 2018-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SYS_SHM_H
20# error "Never use <bits/shmlba.h> directly; include <sys/shm.h> instead."
21#endif
22
23__BEGIN_DECLS
24
25/* Segment low boundary address multiple. */
26#define SHMLBA (__getpagesize ())
27extern int __getpagesize (void) __THROW __attribute__ ((__const__));
28
29__END_DECLS
libc/glibc-include/bits/sigaction.h created+83
...@@ -0,0 +1,83 @@
1/* The proper definitions for Linux's sigaction.
2 Copyright (C) 1993-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_SIGACTION_H
20#define _BITS_SIGACTION_H 1
21
22#ifndef _SIGNAL_H
23# error "Never include <bits/sigaction.h> directly; use <signal.h> instead."
24#endif
25
26/* Structure describing the action to be taken when a signal arrives. */
27struct sigaction
28 {
29 /* Signal handler. */
30#if defined __USE_POSIX199309 || defined __USE_XOPEN_EXTENDED
31 union
32 {
33 /* Used if SA_SIGINFO is not set. */
34 __sighandler_t sa_handler;
35 /* Used if SA_SIGINFO is set. */
36 void (*sa_sigaction) (int, siginfo_t *, void *);
37 }
38 __sigaction_handler;
39# define sa_handler __sigaction_handler.sa_handler
40# define sa_sigaction __sigaction_handler.sa_sigaction
41#else
42 __sighandler_t sa_handler;
43#endif
44
45 /* Additional set of signals to be blocked. */
46 __sigset_t sa_mask;
47
48 /* Special flags. */
49 int sa_flags;
50
51 /* Restore handler. */
52 void (*sa_restorer) (void);
53 };
54
55/* Bits in `sa_flags'. */
56#define SA_NOCLDSTOP 1 /* Don't send SIGCHLD when children stop. */
57#define SA_NOCLDWAIT 2 /* Don't create zombie on child death. */
58#define SA_SIGINFO 4 /* Invoke signal-catching function with
59 three arguments instead of one. */
60#if defined __USE_XOPEN_EXTENDED || defined __USE_MISC
61# define SA_ONSTACK 0x08000000 /* Use signal stack by using `sa_restorer'. */
62#endif
63#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
64# define SA_RESTART 0x10000000 /* Restart syscall on signal return. */
65# define SA_NODEFER 0x40000000 /* Don't automatically block the signal when
66 its handler is being executed. */
67# define SA_RESETHAND 0x80000000 /* Reset to SIG_DFL on entry to handler. */
68#endif
69#ifdef __USE_MISC
70# define SA_INTERRUPT 0x20000000 /* Historical no-op. */
71
72/* Some aliases for the SA_ constants. */
73# define SA_NOMASK SA_NODEFER
74# define SA_ONESHOT SA_RESETHAND
75# define SA_STACK SA_ONSTACK
76#endif
77
78/* Values for the HOW argument to `sigprocmask'. */
79#define SIG_BLOCK 0 /* Block signals. */
80#define SIG_UNBLOCK 1 /* Unblock signals. */
81#define SIG_SETMASK 2 /* Set the set of blocked signals. */
82
83#endif
libc/glibc-include/bits/sigcontext.h created+196
...@@ -0,0 +1,196 @@
1/* Copyright (C) 2002-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _BITS_SIGCONTEXT_H
19#define _BITS_SIGCONTEXT_H 1
20
21#if !defined _SIGNAL_H && !defined _SYS_UCONTEXT_H
22# error "Never use <bits/sigcontext.h> directly; include <signal.h> instead."
23#endif
24
25#include <bits/types.h>
26
27#define FP_XSTATE_MAGIC1 0x46505853U
28#define FP_XSTATE_MAGIC2 0x46505845U
29#define FP_XSTATE_MAGIC2_SIZE sizeof(FP_XSTATE_MAGIC2)
30
31struct _fpx_sw_bytes
32{
33 __uint32_t magic1;
34 __uint32_t extended_size;
35 __uint64_t xstate_bv;
36 __uint32_t xstate_size;
37 __uint32_t __glibc_reserved1[7];
38};
39
40struct _fpreg
41{
42 unsigned short significand[4];
43 unsigned short exponent;
44};
45
46struct _fpxreg
47{
48 unsigned short significand[4];
49 unsigned short exponent;
50 unsigned short __glibc_reserved1[3];
51};
52
53struct _xmmreg
54{
55 __uint32_t element[4];
56};
57
58
59
60#ifndef __x86_64__
61
62struct _fpstate
63{
64 /* Regular FPU environment. */
65 __uint32_t cw;
66 __uint32_t sw;
67 __uint32_t tag;
68 __uint32_t ipoff;
69 __uint32_t cssel;
70 __uint32_t dataoff;
71 __uint32_t datasel;
72 struct _fpreg _st[8];
73 unsigned short status;
74 unsigned short magic;
75
76 /* FXSR FPU environment. */
77 __uint32_t _fxsr_env[6];
78 __uint32_t mxcsr;
79 __uint32_t __glibc_reserved1;
80 struct _fpxreg _fxsr_st[8];
81 struct _xmmreg _xmm[8];
82 __uint32_t __glibc_reserved2[56];
83};
84
85#ifndef sigcontext_struct
86/* Kernel headers before 2.1.1 define a struct sigcontext_struct, but
87 we need sigcontext. Some packages have come to rely on
88 sigcontext_struct being defined on 32-bit x86, so define this for
89 their benefit. */
90# define sigcontext_struct sigcontext
91#endif
92
93#define X86_FXSR_MAGIC 0x0000
94
95struct sigcontext
96{
97 unsigned short gs, __gsh;
98 unsigned short fs, __fsh;
99 unsigned short es, __esh;
100 unsigned short ds, __dsh;
101 unsigned long edi;
102 unsigned long esi;
103 unsigned long ebp;
104 unsigned long esp;
105 unsigned long ebx;
106 unsigned long edx;
107 unsigned long ecx;
108 unsigned long eax;
109 unsigned long trapno;
110 unsigned long err;
111 unsigned long eip;
112 unsigned short cs, __csh;
113 unsigned long eflags;
114 unsigned long esp_at_signal;
115 unsigned short ss, __ssh;
116 struct _fpstate * fpstate;
117 unsigned long oldmask;
118 unsigned long cr2;
119};
120
121#else /* __x86_64__ */
122
123struct _fpstate
124{
125 /* FPU environment matching the 64-bit FXSAVE layout. */
126 __uint16_t cwd;
127 __uint16_t swd;
128 __uint16_t ftw;
129 __uint16_t fop;
130 __uint64_t rip;
131 __uint64_t rdp;
132 __uint32_t mxcsr;
133 __uint32_t mxcr_mask;
134 struct _fpxreg _st[8];
135 struct _xmmreg _xmm[16];
136 __uint32_t __glibc_reserved1[24];
137};
138
139struct sigcontext
140{
141 __uint64_t r8;
142 __uint64_t r9;
143 __uint64_t r10;
144 __uint64_t r11;
145 __uint64_t r12;
146 __uint64_t r13;
147 __uint64_t r14;
148 __uint64_t r15;
149 __uint64_t rdi;
150 __uint64_t rsi;
151 __uint64_t rbp;
152 __uint64_t rbx;
153 __uint64_t rdx;
154 __uint64_t rax;
155 __uint64_t rcx;
156 __uint64_t rsp;
157 __uint64_t rip;
158 __uint64_t eflags;
159 unsigned short cs;
160 unsigned short gs;
161 unsigned short fs;
162 unsigned short __pad0;
163 __uint64_t err;
164 __uint64_t trapno;
165 __uint64_t oldmask;
166 __uint64_t cr2;
167 __extension__ union
168 {
169 struct _fpstate * fpstate;
170 __uint64_t __fpstate_word;
171 };
172 __uint64_t __reserved1 [8];
173};
174
175#endif /* __x86_64__ */
176
177struct _xsave_hdr
178{
179 __uint64_t xstate_bv;
180 __uint64_t __glibc_reserved1[2];
181 __uint64_t __glibc_reserved2[5];
182};
183
184struct _ymmh_state
185{
186 __uint32_t ymmh_space[64];
187};
188
189struct _xstate
190{
191 struct _fpstate fpstate;
192 struct _xsave_hdr xstate_hdr;
193 struct _ymmh_state ymmh;
194};
195
196#endif /* _BITS_SIGCONTEXT_H */
libc/glibc-include/bits/sigevent-consts.h created+41
...@@ -0,0 +1,41 @@
1/* sigevent constants. Linux version.
2 Copyright (C) 1997-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_SIGEVENT_CONSTS_H
20#define _BITS_SIGEVENT_CONSTS_H 1
21
22#if !defined _SIGNAL_H && !defined _AIO_H
23#error "Don't include <bits/sigevent-consts.h> directly; use <signal.h> instead."
24#endif
25
26/* `sigev_notify' values. */
27enum
28{
29 SIGEV_SIGNAL = 0, /* Notify via signal. */
30# define SIGEV_SIGNAL SIGEV_SIGNAL
31 SIGEV_NONE, /* Other notification: meaningless. */
32# define SIGEV_NONE SIGEV_NONE
33 SIGEV_THREAD, /* Deliver via thread creation. */
34# define SIGEV_THREAD SIGEV_THREAD
35
36 SIGEV_THREAD_ID = 4 /* Send signal to specific thread.
37 This is a Linux extension. */
38#define SIGEV_THREAD_ID SIGEV_THREAD_ID
39};
40
41#endif
libc/glibc-include/bits/siginfo-arch.h created+17
...@@ -0,0 +1,17 @@
1/* Architecture-specific adjustments to siginfo_t. x86 version. */
2#ifndef _BITS_SIGINFO_ARCH_H
3#define _BITS_SIGINFO_ARCH_H 1
4
5#if defined __x86_64__ && __WORDSIZE == 32
6/* si_utime and si_stime must be 4 byte aligned for x32 to match the
7 kernel. We align siginfo_t to 8 bytes so that si_utime and
8 si_stime are actually aligned to 8 bytes since their offsets are
9 multiple of 8 bytes. Note: with some compilers, the alignment
10 attribute would be ignored if it were put in __SI_CLOCK_T instead
11 of encapsulated in a typedef. */
12typedef __clock_t __attribute__ ((__aligned__ (4))) __sigchld_clock_t;
13# define __SI_ALIGNMENT __attribute__ ((__aligned__ (8)))
14# define __SI_CLOCK_T __sigchld_clock_t
15#endif
16
17#endif
libc/glibc-include/bits/siginfo-consts-arch.h created+7
...@@ -0,0 +1,7 @@
1/* Architecture-specific additional siginfo constants. */
2#ifndef _BITS_SIGINFO_CONSTS_ARCH_H
3#define _BITS_SIGINFO_CONSTS_ARCH_H 1
4
5/* This architecture has no additional siginfo constants. */
6
7#endif
libc/glibc-include/bits/siginfo-consts.h created+212
...@@ -0,0 +1,212 @@
1/* siginfo constants. Linux version.
2 Copyright (C) 1997-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_SIGINFO_CONSTS_H
20#define _BITS_SIGINFO_CONSTS_H 1
21
22#ifndef _SIGNAL_H
23#error "Don't include <bits/siginfo-consts.h> directly; use <signal.h> instead."
24#endif
25
26/* Most of these constants are uniform across all architectures, but there
27 is one exception. */
28#include <bits/siginfo-arch.h>
29#ifndef __SI_ASYNCIO_AFTER_SIGIO
30# define __SI_ASYNCIO_AFTER_SIGIO 1
31#endif
32
33/* Values for `si_code'. Positive values are reserved for kernel-generated
34 signals. */
35enum
36{
37 SI_ASYNCNL = -60, /* Sent by asynch name lookup completion. */
38 SI_DETHREAD = -7, /* Sent by execve killing subsidiary
39 threads. */
40 SI_TKILL, /* Sent by tkill. */
41 SI_SIGIO, /* Sent by queued SIGIO. */
42#if __SI_ASYNCIO_AFTER_SIGIO
43 SI_ASYNCIO, /* Sent by AIO completion. */
44 SI_MESGQ, /* Sent by real time mesq state change. */
45 SI_TIMER, /* Sent by timer expiration. */
46#else
47 SI_MESGQ,
48 SI_TIMER,
49 SI_ASYNCIO,
50#endif
51 SI_QUEUE, /* Sent by sigqueue. */
52 SI_USER, /* Sent by kill, sigsend. */
53 SI_KERNEL = 0x80 /* Send by kernel. */
54
55#define SI_ASYNCNL SI_ASYNCNL
56#define SI_DETHREAD SI_DETHREAD
57#define SI_TKILL SI_TKILL
58#define SI_SIGIO SI_SIGIO
59#define SI_ASYNCIO SI_ASYNCIO
60#define SI_MESGQ SI_MESGQ
61#define SI_TIMER SI_TIMER
62#define SI_ASYNCIO SI_ASYNCIO
63#define SI_QUEUE SI_QUEUE
64#define SI_USER SI_USER
65#define SI_KERNEL SI_KERNEL
66};
67
68
69# if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
70/* `si_code' values for SIGILL signal. */
71enum
72{
73 ILL_ILLOPC = 1, /* Illegal opcode. */
74# define ILL_ILLOPC ILL_ILLOPC
75 ILL_ILLOPN, /* Illegal operand. */
76# define ILL_ILLOPN ILL_ILLOPN
77 ILL_ILLADR, /* Illegal addressing mode. */
78# define ILL_ILLADR ILL_ILLADR
79 ILL_ILLTRP, /* Illegal trap. */
80# define ILL_ILLTRP ILL_ILLTRP
81 ILL_PRVOPC, /* Privileged opcode. */
82# define ILL_PRVOPC ILL_PRVOPC
83 ILL_PRVREG, /* Privileged register. */
84# define ILL_PRVREG ILL_PRVREG
85 ILL_COPROC, /* Coprocessor error. */
86# define ILL_COPROC ILL_COPROC
87 ILL_BADSTK, /* Internal stack error. */
88# define ILL_BADSTK ILL_BADSTK
89 ILL_BADIADDR /* Unimplemented instruction address. */
90# define ILL_BADIADDR ILL_BADIADDR
91};
92
93/* `si_code' values for SIGFPE signal. */
94enum
95{
96 FPE_INTDIV = 1, /* Integer divide by zero. */
97# define FPE_INTDIV FPE_INTDIV
98 FPE_INTOVF, /* Integer overflow. */
99# define FPE_INTOVF FPE_INTOVF
100 FPE_FLTDIV, /* Floating point divide by zero. */
101# define FPE_FLTDIV FPE_FLTDIV
102 FPE_FLTOVF, /* Floating point overflow. */
103# define FPE_FLTOVF FPE_FLTOVF
104 FPE_FLTUND, /* Floating point underflow. */
105# define FPE_FLTUND FPE_FLTUND
106 FPE_FLTRES, /* Floating point inexact result. */
107# define FPE_FLTRES FPE_FLTRES
108 FPE_FLTINV, /* Floating point invalid operation. */
109# define FPE_FLTINV FPE_FLTINV
110 FPE_FLTSUB, /* Subscript out of range. */
111# define FPE_FLTSUB FPE_FLTSUB
112 FPE_FLTUNK = 14, /* Undiagnosed floating-point exception. */
113# define FPE_FLTUNK FPE_FLTUNK
114 FPE_CONDTRAP /* Trap on condition. */
115# define FPE_CONDTRAP FPE_CONDTRAP
116};
117
118/* `si_code' values for SIGSEGV signal. */
119enum
120{
121 SEGV_MAPERR = 1, /* Address not mapped to object. */
122# define SEGV_MAPERR SEGV_MAPERR
123 SEGV_ACCERR, /* Invalid permissions for mapped object. */
124# define SEGV_ACCERR SEGV_ACCERR
125 SEGV_BNDERR, /* Bounds checking failure. */
126# define SEGV_BNDERR SEGV_BNDERR
127 SEGV_PKUERR, /* Protection key checking failure. */
128# define SEGV_PKUERR SEGV_PKUERR
129 SEGV_ACCADI, /* ADI not enabled for mapped object. */
130# define SEGV_ACCADI SEGV_ACCADI
131 SEGV_ADIDERR, /* Disrupting MCD error. */
132# define SEGV_ADIDERR SEGV_ADIDERR
133 SEGV_ADIPERR /* Precise MCD exception. */
134# define SEGV_ADIPERR SEGV_ADIPERR
135};
136
137/* `si_code' values for SIGBUS signal. */
138enum
139{
140 BUS_ADRALN = 1, /* Invalid address alignment. */
141# define BUS_ADRALN BUS_ADRALN
142 BUS_ADRERR, /* Non-existant physical address. */
143# define BUS_ADRERR BUS_ADRERR
144 BUS_OBJERR, /* Object specific hardware error. */
145# define BUS_OBJERR BUS_OBJERR
146 BUS_MCEERR_AR, /* Hardware memory error: action required. */
147# define BUS_MCEERR_AR BUS_MCEERR_AR
148 BUS_MCEERR_AO /* Hardware memory error: action optional. */
149# define BUS_MCEERR_AO BUS_MCEERR_AO
150};
151# endif
152
153# ifdef __USE_XOPEN_EXTENDED
154/* `si_code' values for SIGTRAP signal. */
155enum
156{
157 TRAP_BRKPT = 1, /* Process breakpoint. */
158# define TRAP_BRKPT TRAP_BRKPT
159 TRAP_TRACE, /* Process trace trap. */
160# define TRAP_TRACE TRAP_TRACE
161 TRAP_BRANCH, /* Process taken branch trap. */
162# define TRAP_BRANCH TRAP_BRANCH
163 TRAP_HWBKPT, /* Hardware breakpoint/watchpoint. */
164# define TRAP_HWBKPT TRAP_HWBKPT
165 TRAP_UNK /* Undiagnosed trap. */
166# define TRAP_UNK TRAP_UNK
167};
168# endif
169
170# if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
171/* `si_code' values for SIGCHLD signal. */
172enum
173{
174 CLD_EXITED = 1, /* Child has exited. */
175# define CLD_EXITED CLD_EXITED
176 CLD_KILLED, /* Child was killed. */
177# define CLD_KILLED CLD_KILLED
178 CLD_DUMPED, /* Child terminated abnormally. */
179# define CLD_DUMPED CLD_DUMPED
180 CLD_TRAPPED, /* Traced child has trapped. */
181# define CLD_TRAPPED CLD_TRAPPED
182 CLD_STOPPED, /* Child has stopped. */
183# define CLD_STOPPED CLD_STOPPED
184 CLD_CONTINUED /* Stopped child has continued. */
185# define CLD_CONTINUED CLD_CONTINUED
186};
187
188/* `si_code' values for SIGPOLL signal. */
189enum
190{
191 POLL_IN = 1, /* Data input available. */
192# define POLL_IN POLL_IN
193 POLL_OUT, /* Output buffers available. */
194# define POLL_OUT POLL_OUT
195 POLL_MSG, /* Input message available. */
196# define POLL_MSG POLL_MSG
197 POLL_ERR, /* I/O error. */
198# define POLL_ERR POLL_ERR
199 POLL_PRI, /* High priority input available. */
200# define POLL_PRI POLL_PRI
201 POLL_HUP /* Device disconnected. */
202# define POLL_HUP POLL_HUP
203};
204# endif
205
206/* Architectures might also add architecture-specific constants.
207 These are all considered GNU extensions. */
208#ifdef __USE_GNU
209# include <bits/siginfo-consts-arch.h>
210#endif
211
212#endif
libc/glibc-include/bits/signalfd.h created+29
...@@ -0,0 +1,29 @@
1/* Copyright (C) 2007-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_SIGNALFD_H
19# error "Never use <bits/signalfd.h> directly; include <sys/signalfd.h> instead."
20#endif
21
22/* Flags for signalfd. */
23enum
24 {
25 SFD_CLOEXEC = 02000000,
26#define SFD_CLOEXEC SFD_CLOEXEC
27 SFD_NONBLOCK = 00004000
28#define SFD_NONBLOCK SFD_NONBLOCK
29 };
libc/glibc-include/bits/signum-generic.h created+102
...@@ -0,0 +1,102 @@
1/* Signal number constants. Generic template.
2 Copyright (C) 1991-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_SIGNUM_GENERIC_H
20#define _BITS_SIGNUM_GENERIC_H 1
21
22#ifndef _SIGNAL_H
23#error "Never include <bits/signum-generic.h> directly; use <signal.h> instead."
24#endif
25
26/* Fake signal functions. */
27
28#define SIG_ERR ((__sighandler_t) -1) /* Error return. */
29#define SIG_DFL ((__sighandler_t) 0) /* Default action. */
30#define SIG_IGN ((__sighandler_t) 1) /* Ignore signal. */
31
32#ifdef __USE_XOPEN
33# define SIG_HOLD ((__sighandler_t) 2) /* Add signal to hold mask. */
34#endif
35
36/* We define here all the signal names listed in POSIX (1003.1-2008);
37 as of 1003.1-2013, no additional signals have been added by POSIX.
38 We also define here signal names that historically exist in every
39 real-world POSIX variant (e.g. SIGWINCH).
40
41 Signals in the 1-15 range are defined with their historical numbers.
42 For other signals, we use the BSD numbers.
43 There are two unallocated signal numbers in the 1-31 range: 7 and 29.
44 Signal number 0 is reserved for use as kill(pid, 0), to test whether
45 a process exists without sending it a signal. */
46
47/* ISO C99 signals. */
48#define SIGINT 2 /* Interactive attention signal. */
49#define SIGILL 4 /* Illegal instruction. */
50#define SIGABRT 6 /* Abnormal termination. */
51#define SIGFPE 8 /* Erroneous arithmetic operation. */
52#define SIGSEGV 11 /* Invalid access to storage. */
53#define SIGTERM 15 /* Termination request. */
54
55/* Historical signals specified by POSIX. */
56#define SIGHUP 1 /* Hangup. */
57#define SIGQUIT 3 /* Quit. */
58#define SIGTRAP 5 /* Trace/breakpoint trap. */
59#define SIGKILL 9 /* Killed. */
60#define SIGBUS 10 /* Bus error. */
61#define SIGSYS 12 /* Bad system call. */
62#define SIGPIPE 13 /* Broken pipe. */
63#define SIGALRM 14 /* Alarm clock. */
64
65/* New(er) POSIX signals (1003.1-2008, 1003.1-2013). */
66#define SIGURG 16 /* Urgent data is available at a socket. */
67#define SIGSTOP 17 /* Stop, unblockable. */
68#define SIGTSTP 18 /* Keyboard stop. */
69#define SIGCONT 19 /* Continue. */
70#define SIGCHLD 20 /* Child terminated or stopped. */
71#define SIGTTIN 21 /* Background read from control terminal. */
72#define SIGTTOU 22 /* Background write to control terminal. */
73#define SIGPOLL 23 /* Pollable event occurred (System V). */
74#define SIGXCPU 24 /* CPU time limit exceeded. */
75#define SIGXFSZ 25 /* File size limit exceeded. */
76#define SIGVTALRM 26 /* Virtual timer expired. */
77#define SIGPROF 27 /* Profiling timer expired. */
78#define SIGUSR1 30 /* User-defined signal 1. */
79#define SIGUSR2 31 /* User-defined signal 2. */
80
81/* Nonstandard signals found in all modern POSIX systems
82 (including both BSD and Linux). */
83#define SIGWINCH 28 /* Window size change (4.3 BSD, Sun). */
84
85/* Archaic names for compatibility. */
86#define SIGIO SIGPOLL /* I/O now possible (4.2 BSD). */
87#define SIGIOT SIGABRT /* IOT instruction, abort() on a PDP-11. */
88#define SIGCLD SIGCHLD /* Old System V name */
89
90/* Not all systems support real-time signals. bits/signum.h indicates
91 that they are supported by overriding __SIGRTMAX to a value greater
92 than __SIGRTMIN. These constants give the kernel-level hard limits,
93 but some real-time signals may be used internally by glibc. Do not
94 use these constants in application code; use SIGRTMIN and SIGRTMAX
95 (defined in signal.h) instead. */
96#define __SIGRTMIN 32
97#define __SIGRTMAX __SIGRTMIN
98
99/* Biggest signal number + 1 (including real-time signals). */
100#define _NSIG (__SIGRTMAX + 1)
101
102#endif /* bits/signum-generic.h. */
libc/glibc-include/bits/signum.h created+58
...@@ -0,0 +1,58 @@
1/* Signal number definitions. Linux version.
2 Copyright (C) 1995-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_SIGNUM_H
20#define _BITS_SIGNUM_H 1
21
22#ifndef _SIGNAL_H
23#error "Never include <bits/signum.h> directly; use <signal.h> instead."
24#endif
25
26#include <bits/signum-generic.h>
27
28/* Adjustments and additions to the signal number constants for
29 most Linux systems. */
30
31#define SIGSTKFLT 16 /* Stack fault (obsolete). */
32#define SIGPWR 30 /* Power failure imminent. */
33
34#undef SIGBUS
35#define SIGBUS 7
36#undef SIGUSR1
37#define SIGUSR1 10
38#undef SIGUSR2
39#define SIGUSR2 12
40#undef SIGCHLD
41#define SIGCHLD 17
42#undef SIGCONT
43#define SIGCONT 18
44#undef SIGSTOP
45#define SIGSTOP 19
46#undef SIGTSTP
47#define SIGTSTP 20
48#undef SIGURG
49#define SIGURG 23
50#undef SIGPOLL
51#define SIGPOLL 29
52#undef SIGSYS
53#define SIGSYS 31
54
55#undef __SIGRTMAX
56#define __SIGRTMAX 64
57
58#endif /* <signal.h> included. */
libc/glibc-include/bits/sigstack.h created+32
...@@ -0,0 +1,32 @@
1/* sigstack, sigaltstack definitions.
2 Copyright (C) 1998-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_SIGSTACK_H
20#define _BITS_SIGSTACK_H 1
21
22#if !defined _SIGNAL_H && !defined _SYS_UCONTEXT_H
23# error "Never include this file directly. Use <signal.h> instead"
24#endif
25
26/* Minimum stack size for a signal handler. */
27#define MINSIGSTKSZ 2048
28
29/* System default stack size. */
30#define SIGSTKSZ 8192
31
32#endif /* bits/sigstack.h */
libc/glibc-include/bits/sigthread.h created+44
...@@ -0,0 +1,44 @@
1/* Signal handling function for threaded programs.
2 Copyright (C) 1998-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If
17 not, see <http://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_SIGTHREAD_H
20#define _BITS_SIGTHREAD_H 1
21
22#if !defined _SIGNAL_H && !defined _PTHREAD_H
23# error "Never include this file directly. Use <signal.h> instead"
24#endif
25
26/* Functions for handling signals. */
27#include <bits/types/__sigset_t.h>
28
29/* Modify the signal mask for the calling thread. The arguments have
30 the same meaning as for sigprocmask(2). */
31extern int pthread_sigmask (int __how,
32 const __sigset_t *__restrict __newmask,
33 __sigset_t *__restrict __oldmask)__THROW;
34
35/* Send signal SIGNO to the given thread. */
36extern int pthread_kill (pthread_t __threadid, int __signo) __THROW;
37
38#ifdef __USE_GNU
39/* Queue signal and data to a thread. */
40extern int pthread_sigqueue (pthread_t __threadid, int __signo,
41 const union sigval __value) __THROW;
42#endif
43
44#endif /* bits/sigthread.h */
libc/glibc-include/bits/sockaddr.h created+42
...@@ -0,0 +1,42 @@
1/* Definition of struct sockaddr_* common members and sizes, generic version.
2 Copyright (C) 1995-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19/*
20 * Never include this file directly; use <sys/socket.h> instead.
21 */
22
23#ifndef _BITS_SOCKADDR_H
24#define _BITS_SOCKADDR_H 1
25
26
27/* POSIX.1g specifies this type name for the `sa_family' member. */
28typedef unsigned short int sa_family_t;
29
30/* This macro is used to declare the initial common members
31 of the data types used for socket addresses, `struct sockaddr',
32 `struct sockaddr_in', `struct sockaddr_un', etc. */
33
34#define __SOCKADDR_COMMON(sa_prefix) \
35 sa_family_t sa_prefix##family
36
37#define __SOCKADDR_COMMON_SIZE (sizeof (unsigned short int))
38
39/* Size of struct sockaddr_storage. */
40#define _SS_SIZE 128
41
42#endif /* bits/sockaddr.h */
libc/glibc-include/bits/socket.h created+453
...@@ -0,0 +1,453 @@
1/* System-specific socket constants and types. Linux version.
2 Copyright (C) 1991-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef __BITS_SOCKET_H
20#define __BITS_SOCKET_H
21
22#ifndef _SYS_SOCKET_H
23# error "Never include <bits/socket.h> directly; use <sys/socket.h> instead."
24#endif
25
26#define __need_size_t
27#include <stddef.h>
28
29#include <sys/types.h>
30
31/* Type for length arguments in socket calls. */
32#ifndef __socklen_t_defined
33typedef __socklen_t socklen_t;
34# define __socklen_t_defined
35#endif
36
37/* Get the architecture-dependent definition of enum __socket_type. */
38#include <bits/socket_type.h>
39
40/* Protocol families. */
41#define PF_UNSPEC 0 /* Unspecified. */
42#define PF_LOCAL 1 /* Local to host (pipes and file-domain). */
43#define PF_UNIX PF_LOCAL /* POSIX name for PF_LOCAL. */
44#define PF_FILE PF_LOCAL /* Another non-standard name for PF_LOCAL. */
45#define PF_INET 2 /* IP protocol family. */
46#define PF_AX25 3 /* Amateur Radio AX.25. */
47#define PF_IPX 4 /* Novell Internet Protocol. */
48#define PF_APPLETALK 5 /* Appletalk DDP. */
49#define PF_NETROM 6 /* Amateur radio NetROM. */
50#define PF_BRIDGE 7 /* Multiprotocol bridge. */
51#define PF_ATMPVC 8 /* ATM PVCs. */
52#define PF_X25 9 /* Reserved for X.25 project. */
53#define PF_INET6 10 /* IP version 6. */
54#define PF_ROSE 11 /* Amateur Radio X.25 PLP. */
55#define PF_DECnet 12 /* Reserved for DECnet project. */
56#define PF_NETBEUI 13 /* Reserved for 802.2LLC project. */
57#define PF_SECURITY 14 /* Security callback pseudo AF. */
58#define PF_KEY 15 /* PF_KEY key management API. */
59#define PF_NETLINK 16
60#define PF_ROUTE PF_NETLINK /* Alias to emulate 4.4BSD. */
61#define PF_PACKET 17 /* Packet family. */
62#define PF_ASH 18 /* Ash. */
63#define PF_ECONET 19 /* Acorn Econet. */
64#define PF_ATMSVC 20 /* ATM SVCs. */
65#define PF_RDS 21 /* RDS sockets. */
66#define PF_SNA 22 /* Linux SNA Project */
67#define PF_IRDA 23 /* IRDA sockets. */
68#define PF_PPPOX 24 /* PPPoX sockets. */
69#define PF_WANPIPE 25 /* Wanpipe API sockets. */
70#define PF_LLC 26 /* Linux LLC. */
71#define PF_IB 27 /* Native InfiniBand address. */
72#define PF_MPLS 28 /* MPLS. */
73#define PF_CAN 29 /* Controller Area Network. */
74#define PF_TIPC 30 /* TIPC sockets. */
75#define PF_BLUETOOTH 31 /* Bluetooth sockets. */
76#define PF_IUCV 32 /* IUCV sockets. */
77#define PF_RXRPC 33 /* RxRPC sockets. */
78#define PF_ISDN 34 /* mISDN sockets. */
79#define PF_PHONET 35 /* Phonet sockets. */
80#define PF_IEEE802154 36 /* IEEE 802.15.4 sockets. */
81#define PF_CAIF 37 /* CAIF sockets. */
82#define PF_ALG 38 /* Algorithm sockets. */
83#define PF_NFC 39 /* NFC sockets. */
84#define PF_VSOCK 40 /* vSockets. */
85#define PF_KCM 41 /* Kernel Connection Multiplexor. */
86#define PF_QIPCRTR 42 /* Qualcomm IPC Router. */
87#define PF_SMC 43 /* SMC sockets. */
88#define PF_XDP 44 /* XDP sockets. */
89#define PF_MAX 45 /* For now.. */
90
91/* Address families. */
92#define AF_UNSPEC PF_UNSPEC
93#define AF_LOCAL PF_LOCAL
94#define AF_UNIX PF_UNIX
95#define AF_FILE PF_FILE
96#define AF_INET PF_INET
97#define AF_AX25 PF_AX25
98#define AF_IPX PF_IPX
99#define AF_APPLETALK PF_APPLETALK
100#define AF_NETROM PF_NETROM
101#define AF_BRIDGE PF_BRIDGE
102#define AF_ATMPVC PF_ATMPVC
103#define AF_X25 PF_X25
104#define AF_INET6 PF_INET6
105#define AF_ROSE PF_ROSE
106#define AF_DECnet PF_DECnet
107#define AF_NETBEUI PF_NETBEUI
108#define AF_SECURITY PF_SECURITY
109#define AF_KEY PF_KEY
110#define AF_NETLINK PF_NETLINK
111#define AF_ROUTE PF_ROUTE
112#define AF_PACKET PF_PACKET
113#define AF_ASH PF_ASH
114#define AF_ECONET PF_ECONET
115#define AF_ATMSVC PF_ATMSVC
116#define AF_RDS PF_RDS
117#define AF_SNA PF_SNA
118#define AF_IRDA PF_IRDA
119#define AF_PPPOX PF_PPPOX
120#define AF_WANPIPE PF_WANPIPE
121#define AF_LLC PF_LLC
122#define AF_IB PF_IB
123#define AF_MPLS PF_MPLS
124#define AF_CAN PF_CAN
125#define AF_TIPC PF_TIPC
126#define AF_BLUETOOTH PF_BLUETOOTH
127#define AF_IUCV PF_IUCV
128#define AF_RXRPC PF_RXRPC
129#define AF_ISDN PF_ISDN
130#define AF_PHONET PF_PHONET
131#define AF_IEEE802154 PF_IEEE802154
132#define AF_CAIF PF_CAIF
133#define AF_ALG PF_ALG
134#define AF_NFC PF_NFC
135#define AF_VSOCK PF_VSOCK
136#define AF_KCM PF_KCM
137#define AF_QIPCRTR PF_QIPCRTR
138#define AF_SMC PF_SMC
139#define AF_XDP PF_XDP
140#define AF_MAX PF_MAX
141
142/* Socket level values. Others are defined in the appropriate headers.
143
144 XXX These definitions also should go into the appropriate headers as
145 far as they are available. */
146#define SOL_RAW 255
147#define SOL_DECNET 261
148#define SOL_X25 262
149#define SOL_PACKET 263
150#define SOL_ATM 264 /* ATM layer (cell level). */
151#define SOL_AAL 265 /* ATM Adaption Layer (packet level). */
152#define SOL_IRDA 266
153#define SOL_NETBEUI 267
154#define SOL_LLC 268
155#define SOL_DCCP 269
156#define SOL_NETLINK 270
157#define SOL_TIPC 271
158#define SOL_RXRPC 272
159#define SOL_PPPOL2TP 273
160#define SOL_BLUETOOTH 274
161#define SOL_PNPIPE 275
162#define SOL_RDS 276
163#define SOL_IUCV 277
164#define SOL_CAIF 278
165#define SOL_ALG 279
166#define SOL_NFC 280
167#define SOL_KCM 281
168#define SOL_TLS 282
169#define SOL_XDP 283
170
171/* Maximum queue length specifiable by listen. */
172#define SOMAXCONN 128
173
174/* Get the definition of the macro to define the common sockaddr members. */
175#include <bits/sockaddr.h>
176
177/* Structure describing a generic socket address. */
178struct sockaddr
179 {
180 __SOCKADDR_COMMON (sa_); /* Common data: address family and length. */
181 char sa_data[14]; /* Address data. */
182 };
183
184
185/* Structure large enough to hold any socket address (with the historical
186 exception of AF_UNIX). */
187#define __ss_aligntype unsigned long int
188#define _SS_PADSIZE \
189 (_SS_SIZE - __SOCKADDR_COMMON_SIZE - sizeof (__ss_aligntype))
190
191struct sockaddr_storage
192 {
193 __SOCKADDR_COMMON (ss_); /* Address family, etc. */
194 char __ss_padding[_SS_PADSIZE];
195 __ss_aligntype __ss_align; /* Force desired alignment. */
196 };
197
198
199/* Bits in the FLAGS argument to `send', `recv', et al. */
200enum
201 {
202 MSG_OOB = 0x01, /* Process out-of-band data. */
203#define MSG_OOB MSG_OOB
204 MSG_PEEK = 0x02, /* Peek at incoming messages. */
205#define MSG_PEEK MSG_PEEK
206 MSG_DONTROUTE = 0x04, /* Don't use local routing. */
207#define MSG_DONTROUTE MSG_DONTROUTE
208#ifdef __USE_GNU
209 /* DECnet uses a different name. */
210 MSG_TRYHARD = MSG_DONTROUTE,
211# define MSG_TRYHARD MSG_DONTROUTE
212#endif
213 MSG_CTRUNC = 0x08, /* Control data lost before delivery. */
214#define MSG_CTRUNC MSG_CTRUNC
215 MSG_PROXY = 0x10, /* Supply or ask second address. */
216#define MSG_PROXY MSG_PROXY
217 MSG_TRUNC = 0x20,
218#define MSG_TRUNC MSG_TRUNC
219 MSG_DONTWAIT = 0x40, /* Nonblocking IO. */
220#define MSG_DONTWAIT MSG_DONTWAIT
221 MSG_EOR = 0x80, /* End of record. */
222#define MSG_EOR MSG_EOR
223 MSG_WAITALL = 0x100, /* Wait for a full request. */
224#define MSG_WAITALL MSG_WAITALL
225 MSG_FIN = 0x200,
226#define MSG_FIN MSG_FIN
227 MSG_SYN = 0x400,
228#define MSG_SYN MSG_SYN
229 MSG_CONFIRM = 0x800, /* Confirm path validity. */
230#define MSG_CONFIRM MSG_CONFIRM
231 MSG_RST = 0x1000,
232#define MSG_RST MSG_RST
233 MSG_ERRQUEUE = 0x2000, /* Fetch message from error queue. */
234#define MSG_ERRQUEUE MSG_ERRQUEUE
235 MSG_NOSIGNAL = 0x4000, /* Do not generate SIGPIPE. */
236#define MSG_NOSIGNAL MSG_NOSIGNAL
237 MSG_MORE = 0x8000, /* Sender will send more. */
238#define MSG_MORE MSG_MORE
239 MSG_WAITFORONE = 0x10000, /* Wait for at least one packet to return.*/
240#define MSG_WAITFORONE MSG_WAITFORONE
241 MSG_BATCH = 0x40000, /* sendmmsg: more messages coming. */
242#define MSG_BATCH MSG_BATCH
243 MSG_ZEROCOPY = 0x4000000, /* Use user data in kernel path. */
244#define MSG_ZEROCOPY MSG_ZEROCOPY
245 MSG_FASTOPEN = 0x20000000, /* Send data in TCP SYN. */
246#define MSG_FASTOPEN MSG_FASTOPEN
247
248 MSG_CMSG_CLOEXEC = 0x40000000 /* Set close_on_exit for file
249 descriptor received through
250 SCM_RIGHTS. */
251#define MSG_CMSG_CLOEXEC MSG_CMSG_CLOEXEC
252 };
253
254
255/* Structure describing messages sent by
256 `sendmsg' and received by `recvmsg'. */
257struct msghdr
258 {
259 void *msg_name; /* Address to send to/receive from. */
260 socklen_t msg_namelen; /* Length of address data. */
261
262 struct iovec *msg_iov; /* Vector of data to send/receive into. */
263 size_t msg_iovlen; /* Number of elements in the vector. */
264
265 void *msg_control; /* Ancillary data (eg BSD filedesc passing). */
266 size_t msg_controllen; /* Ancillary data buffer length.
267 !! The type should be socklen_t but the
268 definition of the kernel is incompatible
269 with this. */
270
271 int msg_flags; /* Flags on received message. */
272 };
273
274/* Structure used for storage of ancillary data object information. */
275struct cmsghdr
276 {
277 size_t cmsg_len; /* Length of data in cmsg_data plus length
278 of cmsghdr structure.
279 !! The type should be socklen_t but the
280 definition of the kernel is incompatible
281 with this. */
282 int cmsg_level; /* Originating protocol. */
283 int cmsg_type; /* Protocol specific type. */
284#if __glibc_c99_flexarr_available
285 __extension__ unsigned char __cmsg_data __flexarr; /* Ancillary data. */
286#endif
287 };
288
289/* Ancillary data object manipulation macros. */
290#if __glibc_c99_flexarr_available
291# define CMSG_DATA(cmsg) ((cmsg)->__cmsg_data)
292#else
293# define CMSG_DATA(cmsg) ((unsigned char *) ((struct cmsghdr *) (cmsg) + 1))
294#endif
295#define CMSG_NXTHDR(mhdr, cmsg) __cmsg_nxthdr (mhdr, cmsg)
296#define CMSG_FIRSTHDR(mhdr) \
297 ((size_t) (mhdr)->msg_controllen >= sizeof (struct cmsghdr) \
298 ? (struct cmsghdr *) (mhdr)->msg_control : (struct cmsghdr *) 0)
299#define CMSG_ALIGN(len) (((len) + sizeof (size_t) - 1) \
300 & (size_t) ~(sizeof (size_t) - 1))
301#define CMSG_SPACE(len) (CMSG_ALIGN (len) \
302 + CMSG_ALIGN (sizeof (struct cmsghdr)))
303#define CMSG_LEN(len) (CMSG_ALIGN (sizeof (struct cmsghdr)) + (len))
304
305extern struct cmsghdr *__cmsg_nxthdr (struct msghdr *__mhdr,
306 struct cmsghdr *__cmsg) __THROW;
307#ifdef __USE_EXTERN_INLINES
308# ifndef _EXTERN_INLINE
309# define _EXTERN_INLINE __extern_inline
310# endif
311_EXTERN_INLINE struct cmsghdr *
312__NTH (__cmsg_nxthdr (struct msghdr *__mhdr, struct cmsghdr *__cmsg))
313{
314 if ((size_t) __cmsg->cmsg_len < sizeof (struct cmsghdr))
315 /* The kernel header does this so there may be a reason. */
316 return (struct cmsghdr *) 0;
317
318 __cmsg = (struct cmsghdr *) ((unsigned char *) __cmsg
319 + CMSG_ALIGN (__cmsg->cmsg_len));
320 if ((unsigned char *) (__cmsg + 1) > ((unsigned char *) __mhdr->msg_control
321 + __mhdr->msg_controllen)
322 || ((unsigned char *) __cmsg + CMSG_ALIGN (__cmsg->cmsg_len)
323 > ((unsigned char *) __mhdr->msg_control + __mhdr->msg_controllen)))
324 /* No more entries. */
325 return (struct cmsghdr *) 0;
326 return __cmsg;
327}
328#endif /* Use `extern inline'. */
329
330/* Socket level message types. This must match the definitions in
331 <linux/socket.h>. */
332enum
333 {
334 SCM_RIGHTS = 0x01 /* Transfer file descriptors. */
335#define SCM_RIGHTS SCM_RIGHTS
336#ifdef __USE_GNU
337 , SCM_CREDENTIALS = 0x02 /* Credentials passing. */
338# define SCM_CREDENTIALS SCM_CREDENTIALS
339#endif
340 };
341
342#ifdef __USE_GNU
343/* User visible structure for SCM_CREDENTIALS message */
344struct ucred
345{
346 pid_t pid; /* PID of sending process. */
347 uid_t uid; /* UID of sending process. */
348 gid_t gid; /* GID of sending process. */
349};
350#endif
351
352/* Ugly workaround for unclean kernel headers. */
353#ifndef __USE_MISC
354# ifndef FIOGETOWN
355# define __SYS_SOCKET_H_undef_FIOGETOWN
356# endif
357# ifndef FIOSETOWN
358# define __SYS_SOCKET_H_undef_FIOSETOWN
359# endif
360# ifndef SIOCATMARK
361# define __SYS_SOCKET_H_undef_SIOCATMARK
362# endif
363# ifndef SIOCGPGRP
364# define __SYS_SOCKET_H_undef_SIOCGPGRP
365# endif
366# ifndef SIOCGSTAMP
367# define __SYS_SOCKET_H_undef_SIOCGSTAMP
368# endif
369# ifndef SIOCGSTAMPNS
370# define __SYS_SOCKET_H_undef_SIOCGSTAMPNS
371# endif
372# ifndef SIOCSPGRP
373# define __SYS_SOCKET_H_undef_SIOCSPGRP
374# endif
375#endif
376#ifndef IOCSIZE_MASK
377# define __SYS_SOCKET_H_undef_IOCSIZE_MASK
378#endif
379#ifndef IOCSIZE_SHIFT
380# define __SYS_SOCKET_H_undef_IOCSIZE_SHIFT
381#endif
382#ifndef IOC_IN
383# define __SYS_SOCKET_H_undef_IOC_IN
384#endif
385#ifndef IOC_INOUT
386# define __SYS_SOCKET_H_undef_IOC_INOUT
387#endif
388#ifndef IOC_OUT
389# define __SYS_SOCKET_H_undef_IOC_OUT
390#endif
391
392/* Get socket manipulation related informations from kernel headers. */
393#include <asm/socket.h>
394
395#ifndef __USE_MISC
396# ifdef __SYS_SOCKET_H_undef_FIOGETOWN
397# undef __SYS_SOCKET_H_undef_FIOGETOWN
398# undef FIOGETOWN
399# endif
400# ifdef __SYS_SOCKET_H_undef_FIOSETOWN
401# undef __SYS_SOCKET_H_undef_FIOSETOWN
402# undef FIOSETOWN
403# endif
404# ifdef __SYS_SOCKET_H_undef_SIOCATMARK
405# undef __SYS_SOCKET_H_undef_SIOCATMARK
406# undef SIOCATMARK
407# endif
408# ifdef __SYS_SOCKET_H_undef_SIOCGPGRP
409# undef __SYS_SOCKET_H_undef_SIOCGPGRP
410# undef SIOCGPGRP
411# endif
412# ifdef __SYS_SOCKET_H_undef_SIOCGSTAMP
413# undef __SYS_SOCKET_H_undef_SIOCGSTAMP
414# undef SIOCGSTAMP
415# endif
416# ifdef __SYS_SOCKET_H_undef_SIOCGSTAMPNS
417# undef __SYS_SOCKET_H_undef_SIOCGSTAMPNS
418# undef SIOCGSTAMPNS
419# endif
420# ifdef __SYS_SOCKET_H_undef_SIOCSPGRP
421# undef __SYS_SOCKET_H_undef_SIOCSPGRP
422# undef SIOCSPGRP
423# endif
424#endif
425#ifdef __SYS_SOCKET_H_undef_IOCSIZE_MASK
426# undef __SYS_SOCKET_H_undef_IOCSIZE_MASK
427# undef IOCSIZE_MASK
428#endif
429#ifdef __SYS_SOCKET_H_undef_IOCSIZE_SHIFT
430# undef __SYS_SOCKET_H_undef_IOCSIZE_SHIFT
431# undef IOCSIZE_SHIFT
432#endif
433#ifdef __SYS_SOCKET_H_undef_IOC_IN
434# undef __SYS_SOCKET_H_undef_IOC_IN
435# undef IOC_IN
436#endif
437#ifdef __SYS_SOCKET_H_undef_IOC_INOUT
438# undef __SYS_SOCKET_H_undef_IOC_INOUT
439# undef IOC_INOUT
440#endif
441#ifdef __SYS_SOCKET_H_undef_IOC_OUT
442# undef __SYS_SOCKET_H_undef_IOC_OUT
443# undef IOC_OUT
444#endif
445
446/* Structure used to manipulate the SO_LINGER option. */
447struct linger
448 {
449 int l_onoff; /* Nonzero to linger on close. */
450 int l_linger; /* Time to linger. */
451 };
452
453#endif /* bits/socket.h */
libc/glibc-include/bits/socket2.h created+77
...@@ -0,0 +1,77 @@
1/* Checking macros for socket functions.
2 Copyright (C) 2005-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SYS_SOCKET_H
20# error "Never include <bits/socket2.h> directly; use <sys/socket.h> instead."
21#endif
22
23extern ssize_t __recv_chk (int __fd, void *__buf, size_t __n, size_t __buflen,
24 int __flags);
25extern ssize_t __REDIRECT (__recv_alias, (int __fd, void *__buf, size_t __n,
26 int __flags), recv);
27extern ssize_t __REDIRECT (__recv_chk_warn,
28 (int __fd, void *__buf, size_t __n, size_t __buflen,
29 int __flags), __recv_chk)
30 __warnattr ("recv called with bigger length than size of destination "
31 "buffer");
32
33__fortify_function ssize_t
34recv (int __fd, void *__buf, size_t __n, int __flags)
35{
36 if (__bos0 (__buf) != (size_t) -1)
37 {
38 if (!__builtin_constant_p (__n))
39 return __recv_chk (__fd, __buf, __n, __bos0 (__buf), __flags);
40
41 if (__n > __bos0 (__buf))
42 return __recv_chk_warn (__fd, __buf, __n, __bos0 (__buf), __flags);
43 }
44 return __recv_alias (__fd, __buf, __n, __flags);
45}
46
47extern ssize_t __recvfrom_chk (int __fd, void *__restrict __buf, size_t __n,
48 size_t __buflen, int __flags,
49 __SOCKADDR_ARG __addr,
50 socklen_t *__restrict __addr_len);
51extern ssize_t __REDIRECT (__recvfrom_alias,
52 (int __fd, void *__restrict __buf, size_t __n,
53 int __flags, __SOCKADDR_ARG __addr,
54 socklen_t *__restrict __addr_len), recvfrom);
55extern ssize_t __REDIRECT (__recvfrom_chk_warn,
56 (int __fd, void *__restrict __buf, size_t __n,
57 size_t __buflen, int __flags,
58 __SOCKADDR_ARG __addr,
59 socklen_t *__restrict __addr_len), __recvfrom_chk)
60 __warnattr ("recvfrom called with bigger length than size of "
61 "destination buffer");
62
63__fortify_function ssize_t
64recvfrom (int __fd, void *__restrict __buf, size_t __n, int __flags,
65 __SOCKADDR_ARG __addr, socklen_t *__restrict __addr_len)
66{
67 if (__bos0 (__buf) != (size_t) -1)
68 {
69 if (!__builtin_constant_p (__n))
70 return __recvfrom_chk (__fd, __buf, __n, __bos0 (__buf), __flags,
71 __addr, __addr_len);
72 if (__n > __bos0 (__buf))
73 return __recvfrom_chk_warn (__fd, __buf, __n, __bos0 (__buf), __flags,
74 __addr, __addr_len);
75 }
76 return __recvfrom_alias (__fd, __buf, __n, __flags, __addr, __addr_len);
77}
libc/glibc-include/bits/socket_type.h created+55
...@@ -0,0 +1,55 @@
1/* Define enum __socket_type for generic Linux.
2 Copyright (C) 1991-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SYS_SOCKET_H
20# error "Never include <bits/socket_type.h> directly; use <sys/socket.h> instead."
21#endif
22
23/* Types of sockets. */
24enum __socket_type
25{
26 SOCK_STREAM = 1, /* Sequenced, reliable, connection-based
27 byte streams. */
28#define SOCK_STREAM SOCK_STREAM
29 SOCK_DGRAM = 2, /* Connectionless, unreliable datagrams
30 of fixed maximum length. */
31#define SOCK_DGRAM SOCK_DGRAM
32 SOCK_RAW = 3, /* Raw protocol interface. */
33#define SOCK_RAW SOCK_RAW
34 SOCK_RDM = 4, /* Reliably-delivered messages. */
35#define SOCK_RDM SOCK_RDM
36 SOCK_SEQPACKET = 5, /* Sequenced, reliable, connection-based,
37 datagrams of fixed maximum length. */
38#define SOCK_SEQPACKET SOCK_SEQPACKET
39 SOCK_DCCP = 6, /* Datagram Congestion Control Protocol. */
40#define SOCK_DCCP SOCK_DCCP
41 SOCK_PACKET = 10, /* Linux specific way of getting packets
42 at the dev level. For writing rarp and
43 other similar things on the user level. */
44#define SOCK_PACKET SOCK_PACKET
45
46 /* Flags to be ORed into the type parameter of socket and socketpair and
47 used for the flags parameter of paccept. */
48
49 SOCK_CLOEXEC = 02000000, /* Atomically set close-on-exec flag for the
50 new descriptor(s). */
51#define SOCK_CLOEXEC SOCK_CLOEXEC
52 SOCK_NONBLOCK = 00004000 /* Atomically mark descriptor(s) as
53 non-blocking. */
54#define SOCK_NONBLOCK SOCK_NONBLOCK
55};
libc/glibc-include/bits/ss_flags.h created+35
...@@ -0,0 +1,35 @@
1/* ss_flags values for stack_t. Linux version.
2 Copyright (C) 1998-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_SS_FLAGS_H
20#define _BITS_SS_FLAGS_H 1
21
22#if !defined _SIGNAL_H && !defined _SYS_UCONTEXT_H
23# error "Never include this file directly. Use <signal.h> instead"
24#endif
25
26/* Possible values for `ss_flags'. */
27enum
28{
29 SS_ONSTACK = 1,
30#define SS_ONSTACK SS_ONSTACK
31 SS_DISABLE
32#define SS_DISABLE SS_DISABLE
33};
34
35#endif /* bits/ss_flags.h */
libc/glibc-include/bits/stab.def created+233
...@@ -0,0 +1,233 @@
1/* Table of DBX symbol codes for the GNU system.
2 Copyright (C) 1988, 1997-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19/* This contains contribution from Cygnus Support. */
20
21/* Global variable. Only the name is significant.
22 To find the address, look in the corresponding external symbol. */
23__define_stab (N_GSYM, 0x20, "GSYM")
24
25/* Function name for BSD Fortran. Only the name is significant.
26 To find the address, look in the corresponding external symbol. */
27__define_stab (N_FNAME, 0x22, "FNAME")
28
29/* Function name or text-segment variable for C. Value is its address.
30 Desc is supposedly starting line number, but GCC doesn't set it
31 and DBX seems not to miss it. */
32__define_stab (N_FUN, 0x24, "FUN")
33
34/* Data-segment variable with internal linkage. Value is its address.
35 "Static Sym". */
36__define_stab (N_STSYM, 0x26, "STSYM")
37
38/* BSS-segment variable with internal linkage. Value is its address. */
39__define_stab (N_LCSYM, 0x28, "LCSYM")
40
41/* Name of main routine. Only the name is significant.
42 This is not used in C. */
43__define_stab (N_MAIN, 0x2a, "MAIN")
44
45/* Global symbol in Pascal.
46 Supposedly the value is its line number; I'm skeptical. */
47__define_stab (N_PC, 0x30, "PC")
48
49/* Number of symbols: 0, files,,funcs,lines according to Ultrix V4.0. */
50__define_stab (N_NSYMS, 0x32, "NSYMS")
51
52/* "No DST map for sym: name, ,0,type,ignored" according to Ultrix V4.0. */
53__define_stab (N_NOMAP, 0x34, "NOMAP")
54
55/* New stab from Solaris. I don't know what it means, but it
56 don't seem to contain useful information. */
57__define_stab (N_OBJ, 0x38, "OBJ")
58
59/* New stab from Solaris. I don't know what it means, but it
60 don't seem to contain useful information. Possibly related to the
61 optimization flags used in this module. */
62__define_stab (N_OPT, 0x3c, "OPT")
63
64/* Register variable. Value is number of register. */
65__define_stab (N_RSYM, 0x40, "RSYM")
66
67/* Modula-2 compilation unit. Can someone say what info it contains? */
68__define_stab (N_M2C, 0x42, "M2C")
69
70/* Line number in text segment. Desc is the line number;
71 value is corresponding address. */
72__define_stab (N_SLINE, 0x44, "SLINE")
73
74/* Similar, for data segment. */
75__define_stab (N_DSLINE, 0x46, "DSLINE")
76
77/* Similar, for bss segment. */
78__define_stab (N_BSLINE, 0x48, "BSLINE")
79
80/* Sun's source-code browser stabs. ?? Don't know what the fields are.
81 Supposedly the field is "path to associated .cb file". THIS VALUE
82 OVERLAPS WITH N_BSLINE! */
83__define_stab (N_BROWS, 0x48, "BROWS")
84
85/* GNU Modula-2 definition module dependency. Value is the modification time
86 of the definition file. Other is non-zero if it is imported with the
87 GNU M2 keyword %INITIALIZE. Perhaps N_M2C can be used if there
88 are enough empty fields? */
89__define_stab(N_DEFD, 0x4a, "DEFD")
90
91/* THE FOLLOWING TWO STAB VALUES CONFLICT. Happily, one is for Modula-2
92 and one is for C++. Still,... */
93/* GNU C++ exception variable. Name is variable name. */
94__define_stab (N_EHDECL, 0x50, "EHDECL")
95/* Modula2 info "for imc": name,,0,0,0 according to Ultrix V4.0. */
96__define_stab (N_MOD2, 0x50, "MOD2")
97
98/* GNU C++ `catch' clause. Value is its address. Desc is nonzero if
99 this entry is immediately followed by a CAUGHT stab saying what exception
100 was caught. Multiple CAUGHT stabs means that multiple exceptions
101 can be caught here. If Desc is 0, it means all exceptions are caught
102 here. */
103__define_stab (N_CATCH, 0x54, "CATCH")
104
105/* Structure or union element. Value is offset in the structure. */
106__define_stab (N_SSYM, 0x60, "SSYM")
107
108/* Name of main source file.
109 Value is starting text address of the compilation. */
110__define_stab (N_SO, 0x64, "SO")
111
112/* Automatic variable in the stack. Value is offset from frame pointer.
113 Also used for type descriptions. */
114__define_stab (N_LSYM, 0x80, "LSYM")
115
116/* Beginning of an include file. Only Sun uses this.
117 In an object file, only the name is significant.
118 The Sun linker puts data into some of the other fields. */
119__define_stab (N_BINCL, 0x82, "BINCL")
120
121/* Name of sub-source file (#include file).
122 Value is starting text address of the compilation. */
123__define_stab (N_SOL, 0x84, "SOL")
124
125/* Parameter variable. Value is offset from argument pointer.
126 (On most machines the argument pointer is the same as the frame pointer. */
127__define_stab (N_PSYM, 0xa0, "PSYM")
128
129/* End of an include file. No name.
130 This and N_BINCL act as brackets around the file's output.
131 In an object file, there is no significant data in this entry.
132 The Sun linker puts data into some of the fields. */
133__define_stab (N_EINCL, 0xa2, "EINCL")
134
135/* Alternate entry point. Value is its address. */
136__define_stab (N_ENTRY, 0xa4, "ENTRY")
137
138/* Beginning of lexical block.
139 The desc is the nesting level in lexical blocks.
140 The value is the address of the start of the text for the block.
141 The variables declared inside the block *precede* the N_LBRAC symbol. */
142__define_stab (N_LBRAC, 0xc0, "LBRAC")
143
144/* Place holder for deleted include file. Replaces a N_BINCL and everything
145 up to the corresponding N_EINCL. The Sun linker generates these when
146 it finds multiple identical copies of the symbols from an include file.
147 This appears only in output from the Sun linker. */
148__define_stab (N_EXCL, 0xc2, "EXCL")
149
150/* Modula-2 scope information. Can someone say what info it contains? */
151__define_stab (N_SCOPE, 0xc4, "SCOPE")
152
153/* End of a lexical block. Desc matches the N_LBRAC's desc.
154 The value is the address of the end of the text for the block. */
155__define_stab (N_RBRAC, 0xe0, "RBRAC")
156
157/* Begin named common block. Only the name is significant. */
158__define_stab (N_BCOMM, 0xe2, "BCOMM")
159
160/* End named common block. Only the name is significant
161 (and it should match the N_BCOMM). */
162__define_stab (N_ECOMM, 0xe4, "ECOMM")
163
164/* End common (local name): value is address.
165 I'm not sure how this is used. */
166__define_stab (N_ECOML, 0xe8, "ECOML")
167
168/* These STAB's are used on Gould systems for Non-Base register symbols
169 or something like that. FIXME. I have assigned the values at random
170 since I don't have a Gould here. Fixups from Gould folk welcome... */
171__define_stab (N_NBTEXT, 0xF0, "NBTEXT")
172__define_stab (N_NBDATA, 0xF2, "NBDATA")
173__define_stab (N_NBBSS, 0xF4, "NBBSS")
174__define_stab (N_NBSTS, 0xF6, "NBSTS")
175__define_stab (N_NBLCS, 0xF8, "NBLCS")
176
177/* Second symbol entry containing a length-value for the preceding entry.
178 The value is the length. */
179__define_stab (N_LENG, 0xfe, "LENG")
180
181/* The above information, in matrix format.
182
183 STAB MATRIX
184 _________________________________________________
185 | 00 - 1F are not dbx stab symbols |
186 | In most cases, the low bit is the EXTernal bit|
187
188 | 00 UNDEF | 02 ABS | 04 TEXT | 06 DATA |
189 | 01 |EXT | 03 |EXT | 05 |EXT | 07 |EXT |
190
191 | 08 BSS | 0A INDR | 0C FN_SEQ | 0E |
192 | 09 |EXT | 0B | 0D | 0F |
193
194 | 10 | 12 COMM | 14 SETA | 16 SETT |
195 | 11 | 13 | 15 | 17 |
196
197 | 18 SETD | 1A SETB | 1C SETV | 1E WARNING|
198 | 19 | 1B | 1D | 1F FN |
199
200 |_______________________________________________|
201 | Debug entries with bit 01 set are unused. |
202 | 20 GSYM | 22 FNAME | 24 FUN | 26 STSYM |
203 | 28 LCSYM | 2A MAIN | 2C | 2E |
204 | 30 PC | 32 NSYMS | 34 NOMAP | 36 |
205 | 38 OBJ | 3A | 3C OPT | 3E |
206 | 40 RSYM | 42 M2C | 44 SLINE | 46 DSLINE |
207 | 48 BSLINE*| 4A DEFD | 4C | 4E |
208 | 50 EHDECL*| 52 | 54 CATCH | 56 |
209 | 58 | 5A | 5C | 5E |
210 | 60 SSYM | 62 | 64 SO | 66 |
211 | 68 | 6A | 6C | 6E |
212 | 70 | 72 | 74 | 76 |
213 | 78 | 7A | 7C | 7E |
214 | 80 LSYM | 82 BINCL | 84 SOL | 86 |
215 | 88 | 8A | 8C | 8E |
216 | 90 | 92 | 94 | 96 |
217 | 98 | 9A | 9C | 9E |
218 | A0 PSYM | A2 EINCL | A4 ENTRY | A6 |
219 | A8 | AA | AC | AE |
220 | B0 | B2 | B4 | B6 |
221 | B8 | BA | BC | BE |
222 | C0 LBRAC | C2 EXCL | C4 SCOPE | C6 |
223 | C8 | CA | CC | CE |
224 | D0 | D2 | D4 | D6 |
225 | D8 | DA | DC | DE |
226 | E0 RBRAC | E2 BCOMM | E4 ECOMM | E6 |
227 | E8 ECOML | EA | EC | EE |
228 | F0 | F2 | F4 | F6 |
229 | F8 | FA | FC | FE LENG |
230 +-----------------------------------------------+
231 * 50 EHDECL is also MOD2.
232 * 48 BSLINE is also BROWS.
233 */
libc/glibc-include/bits/stat.h created+210
...@@ -0,0 +1,210 @@
1/* Copyright (C) 1999-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#if !defined _SYS_STAT_H && !defined _FCNTL_H
19# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
20#endif
21
22#ifndef _BITS_STAT_H
23#define _BITS_STAT_H 1
24
25/* Versions of the `struct stat' data structure. */
26#ifndef __x86_64__
27# define _STAT_VER_LINUX_OLD 1
28# define _STAT_VER_KERNEL 1
29# define _STAT_VER_SVR4 2
30# define _STAT_VER_LINUX 3
31
32/* i386 versions of the `xmknod' interface. */
33# define _MKNOD_VER_LINUX 1
34# define _MKNOD_VER_SVR4 2
35# define _MKNOD_VER _MKNOD_VER_LINUX /* The bits defined below. */
36#else
37# define _STAT_VER_KERNEL 0
38# define _STAT_VER_LINUX 1
39
40/* x86-64 versions of the `xmknod' interface. */
41# define _MKNOD_VER_LINUX 0
42#endif
43
44#define _STAT_VER _STAT_VER_LINUX
45
46struct stat
47 {
48 __dev_t st_dev; /* Device. */
49#ifndef __x86_64__
50 unsigned short int __pad1;
51#endif
52#if defined __x86_64__ || !defined __USE_FILE_OFFSET64
53 __ino_t st_ino; /* File serial number. */
54#else
55 __ino_t __st_ino; /* 32bit file serial number. */
56#endif
57#ifndef __x86_64__
58 __mode_t st_mode; /* File mode. */
59 __nlink_t st_nlink; /* Link count. */
60#else
61 __nlink_t st_nlink; /* Link count. */
62 __mode_t st_mode; /* File mode. */
63#endif
64 __uid_t st_uid; /* User ID of the file's owner. */
65 __gid_t st_gid; /* Group ID of the file's group.*/
66#ifdef __x86_64__
67 int __pad0;
68#endif
69 __dev_t st_rdev; /* Device number, if device. */
70#ifndef __x86_64__
71 unsigned short int __pad2;
72#endif
73#if defined __x86_64__ || !defined __USE_FILE_OFFSET64
74 __off_t st_size; /* Size of file, in bytes. */
75#else
76 __off64_t st_size; /* Size of file, in bytes. */
77#endif
78 __blksize_t st_blksize; /* Optimal block size for I/O. */
79#if defined __x86_64__ || !defined __USE_FILE_OFFSET64
80 __blkcnt_t st_blocks; /* Number 512-byte blocks allocated. */
81#else
82 __blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
83#endif
84#ifdef __USE_XOPEN2K8
85 /* Nanosecond resolution timestamps are stored in a format
86 equivalent to 'struct timespec'. This is the type used
87 whenever possible but the Unix namespace rules do not allow the
88 identifier 'timespec' to appear in the <sys/stat.h> header.
89 Therefore we have to handle the use of this header in strictly
90 standard-compliant sources special. */
91 struct timespec st_atim; /* Time of last access. */
92 struct timespec st_mtim; /* Time of last modification. */
93 struct timespec st_ctim; /* Time of last status change. */
94# define st_atime st_atim.tv_sec /* Backward compatibility. */
95# define st_mtime st_mtim.tv_sec
96# define st_ctime st_ctim.tv_sec
97#else
98 __time_t st_atime; /* Time of last access. */
99 __syscall_ulong_t st_atimensec; /* Nscecs of last access. */
100 __time_t st_mtime; /* Time of last modification. */
101 __syscall_ulong_t st_mtimensec; /* Nsecs of last modification. */
102 __time_t st_ctime; /* Time of last status change. */
103 __syscall_ulong_t st_ctimensec; /* Nsecs of last status change. */
104#endif
105#ifdef __x86_64__
106 __syscall_slong_t __glibc_reserved[3];
107#else
108# ifndef __USE_FILE_OFFSET64
109 unsigned long int __glibc_reserved4;
110 unsigned long int __glibc_reserved5;
111# else
112 __ino64_t st_ino; /* File serial number. */
113# endif
114#endif
115 };
116
117#ifdef __USE_LARGEFILE64
118/* Note stat64 has the same shape as stat for x86-64. */
119struct stat64
120 {
121 __dev_t st_dev; /* Device. */
122# ifdef __x86_64__
123 __ino64_t st_ino; /* File serial number. */
124 __nlink_t st_nlink; /* Link count. */
125 __mode_t st_mode; /* File mode. */
126# else
127 unsigned int __pad1;
128 __ino_t __st_ino; /* 32bit file serial number. */
129 __mode_t st_mode; /* File mode. */
130 __nlink_t st_nlink; /* Link count. */
131# endif
132 __uid_t st_uid; /* User ID of the file's owner. */
133 __gid_t st_gid; /* Group ID of the file's group.*/
134# ifdef __x86_64__
135 int __pad0;
136 __dev_t st_rdev; /* Device number, if device. */
137 __off_t st_size; /* Size of file, in bytes. */
138# else
139 __dev_t st_rdev; /* Device number, if device. */
140 unsigned int __pad2;
141 __off64_t st_size; /* Size of file, in bytes. */
142# endif
143 __blksize_t st_blksize; /* Optimal block size for I/O. */
144 __blkcnt64_t st_blocks; /* Nr. 512-byte blocks allocated. */
145# ifdef __USE_XOPEN2K8
146 /* Nanosecond resolution timestamps are stored in a format
147 equivalent to 'struct timespec'. This is the type used
148 whenever possible but the Unix namespace rules do not allow the
149 identifier 'timespec' to appear in the <sys/stat.h> header.
150 Therefore we have to handle the use of this header in strictly
151 standard-compliant sources special. */
152 struct timespec st_atim; /* Time of last access. */
153 struct timespec st_mtim; /* Time of last modification. */
154 struct timespec st_ctim; /* Time of last status change. */
155# else
156 __time_t st_atime; /* Time of last access. */
157 __syscall_ulong_t st_atimensec; /* Nscecs of last access. */
158 __time_t st_mtime; /* Time of last modification. */
159 __syscall_ulong_t st_mtimensec; /* Nsecs of last modification. */
160 __time_t st_ctime; /* Time of last status change. */
161 __syscall_ulong_t st_ctimensec; /* Nsecs of last status change. */
162# endif
163# ifdef __x86_64__
164 __syscall_slong_t __glibc_reserved[3];
165# else
166 __ino64_t st_ino; /* File serial number. */
167# endif
168 };
169#endif
170
171/* Tell code we have these members. */
172#define _STATBUF_ST_BLKSIZE
173#define _STATBUF_ST_RDEV
174/* Nanosecond resolution time values are supported. */
175#define _STATBUF_ST_NSEC
176
177/* Encoding of the file mode. */
178
179#define __S_IFMT 0170000 /* These bits determine file type. */
180
181/* File types. */
182#define __S_IFDIR 0040000 /* Directory. */
183#define __S_IFCHR 0020000 /* Character device. */
184#define __S_IFBLK 0060000 /* Block device. */
185#define __S_IFREG 0100000 /* Regular file. */
186#define __S_IFIFO 0010000 /* FIFO. */
187#define __S_IFLNK 0120000 /* Symbolic link. */
188#define __S_IFSOCK 0140000 /* Socket. */
189
190/* POSIX.1b objects. Note that these macros always evaluate to zero. But
191 they do it by enforcing the correct use of the macros. */
192#define __S_TYPEISMQ(buf) ((buf)->st_mode - (buf)->st_mode)
193#define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode)
194#define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode)
195
196/* Protection bits. */
197
198#define __S_ISUID 04000 /* Set user ID on execution. */
199#define __S_ISGID 02000 /* Set group ID on execution. */
200#define __S_ISVTX 01000 /* Save swapped text after use (sticky). */
201#define __S_IREAD 0400 /* Read by owner. */
202#define __S_IWRITE 0200 /* Write by owner. */
203#define __S_IEXEC 0100 /* Execute by owner. */
204
205#ifdef __USE_ATFILE
206# define UTIME_NOW ((1l << 30) - 1l)
207# define UTIME_OMIT ((1l << 30) - 2l)
208#endif
209
210#endif /* bits/stat.h */
libc/glibc-include/bits/statfs.h created+69
...@@ -0,0 +1,69 @@
1/* Copyright (C) 1997-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_STATFS_H
19# error "Never include <bits/statfs.h> directly; use <sys/statfs.h> instead."
20#endif
21
22#include <bits/types.h>
23
24struct statfs
25 {
26 __fsword_t f_type;
27 __fsword_t f_bsize;
28#ifndef __USE_FILE_OFFSET64
29 __fsblkcnt_t f_blocks;
30 __fsblkcnt_t f_bfree;
31 __fsblkcnt_t f_bavail;
32 __fsfilcnt_t f_files;
33 __fsfilcnt_t f_ffree;
34#else
35 __fsblkcnt64_t f_blocks;
36 __fsblkcnt64_t f_bfree;
37 __fsblkcnt64_t f_bavail;
38 __fsfilcnt64_t f_files;
39 __fsfilcnt64_t f_ffree;
40#endif
41 __fsid_t f_fsid;
42 __fsword_t f_namelen;
43 __fsword_t f_frsize;
44 __fsword_t f_flags;
45 __fsword_t f_spare[4];
46 };
47
48#ifdef __USE_LARGEFILE64
49struct statfs64
50 {
51 __fsword_t f_type;
52 __fsword_t f_bsize;
53 __fsblkcnt64_t f_blocks;
54 __fsblkcnt64_t f_bfree;
55 __fsblkcnt64_t f_bavail;
56 __fsfilcnt64_t f_files;
57 __fsfilcnt64_t f_ffree;
58 __fsid_t f_fsid;
59 __fsword_t f_namelen;
60 __fsword_t f_frsize;
61 __fsword_t f_flags;
62 __fsword_t f_spare[4];
63 };
64#endif
65
66/* Tell code we have these members. */
67#define _STATFS_F_NAMELEN
68#define _STATFS_F_FRSIZE
69#define _STATFS_F_FLAGS
libc/glibc-include/bits/statvfs.h created+109
...@@ -0,0 +1,109 @@
1/* Copyright (C) 1997-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_STATVFS_H
19# error "Never include <bits/statvfs.h> directly; use <sys/statvfs.h> instead."
20#endif
21
22#include <bits/types.h> /* For __fsblkcnt_t and __fsfilcnt_t. */
23
24#if (__WORDSIZE == 32 \
25 && (!defined __SYSCALL_WORDSIZE || __SYSCALL_WORDSIZE == 32))
26#define _STATVFSBUF_F_UNUSED
27#endif
28
29struct statvfs
30 {
31 unsigned long int f_bsize;
32 unsigned long int f_frsize;
33#ifndef __USE_FILE_OFFSET64
34 __fsblkcnt_t f_blocks;
35 __fsblkcnt_t f_bfree;
36 __fsblkcnt_t f_bavail;
37 __fsfilcnt_t f_files;
38 __fsfilcnt_t f_ffree;
39 __fsfilcnt_t f_favail;
40#else
41 __fsblkcnt64_t f_blocks;
42 __fsblkcnt64_t f_bfree;
43 __fsblkcnt64_t f_bavail;
44 __fsfilcnt64_t f_files;
45 __fsfilcnt64_t f_ffree;
46 __fsfilcnt64_t f_favail;
47#endif
48 unsigned long int f_fsid;
49#ifdef _STATVFSBUF_F_UNUSED
50 int __f_unused;
51#endif
52 unsigned long int f_flag;
53 unsigned long int f_namemax;
54 int __f_spare[6];
55 };
56
57#ifdef __USE_LARGEFILE64
58struct statvfs64
59 {
60 unsigned long int f_bsize;
61 unsigned long int f_frsize;
62 __fsblkcnt64_t f_blocks;
63 __fsblkcnt64_t f_bfree;
64 __fsblkcnt64_t f_bavail;
65 __fsfilcnt64_t f_files;
66 __fsfilcnt64_t f_ffree;
67 __fsfilcnt64_t f_favail;
68 unsigned long int f_fsid;
69#ifdef _STATVFSBUF_F_UNUSED
70 int __f_unused;
71#endif
72 unsigned long int f_flag;
73 unsigned long int f_namemax;
74 int __f_spare[6];
75 };
76#endif
77
78/* Definitions for the flag in `f_flag'. These definitions should be
79 kept in sync with the definitions in <sys/mount.h>. */
80enum
81{
82 ST_RDONLY = 1, /* Mount read-only. */
83#define ST_RDONLY ST_RDONLY
84 ST_NOSUID = 2 /* Ignore suid and sgid bits. */
85#define ST_NOSUID ST_NOSUID
86#ifdef __USE_GNU
87 ,
88 ST_NODEV = 4, /* Disallow access to device special files. */
89# define ST_NODEV ST_NODEV
90 ST_NOEXEC = 8, /* Disallow program execution. */
91# define ST_NOEXEC ST_NOEXEC
92 ST_SYNCHRONOUS = 16, /* Writes are synced at once. */
93# define ST_SYNCHRONOUS ST_SYNCHRONOUS
94 ST_MANDLOCK = 64, /* Allow mandatory locks on an FS. */
95# define ST_MANDLOCK ST_MANDLOCK
96 ST_WRITE = 128, /* Write on file/directory/symlink. */
97# define ST_WRITE ST_WRITE
98 ST_APPEND = 256, /* Append-only file. */
99# define ST_APPEND ST_APPEND
100 ST_IMMUTABLE = 512, /* Immutable file. */
101# define ST_IMMUTABLE ST_IMMUTABLE
102 ST_NOATIME = 1024, /* Do not update access times. */
103# define ST_NOATIME ST_NOATIME
104 ST_NODIRATIME = 2048, /* Do not update directory access times. */
105# define ST_NODIRATIME ST_NODIRATIME
106 ST_RELATIME = 4096 /* Update atime relative to mtime/ctime. */
107# define ST_RELATIME ST_RELATIME
108#endif /* Use GNU. */
109};
libc/glibc-include/bits/statx.h created+91
...@@ -0,0 +1,91 @@
1/* statx-related definitions and declarations.
2 Copyright (C) 2018-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19/* This interface is based on <linux/stat.h> in Linux. */
20
21#ifndef _SYS_STAT_H
22# error Never include <bits/stat.x.h> directly, include <sys/stat.h> instead.
23#endif
24
25struct statx_timestamp
26{
27 __int64_t tv_sec;
28 __uint32_t tv_nsec;
29 __int32_t __statx_timestamp_pad1[1];
30};
31
32/* Warning: The kernel may add additional fields to this struct in the
33 future. Only use this struct for calling the statx function, not
34 for storing data. (Expansion will be controlled by the mask
35 argument of the statx function.) */
36struct statx
37{
38 __uint32_t stx_mask;
39 __uint32_t stx_blksize;
40 __uint64_t stx_attributes;
41 __uint32_t stx_nlink;
42 __uint32_t stx_uid;
43 __uint32_t stx_gid;
44 __uint16_t stx_mode;
45 __uint16_t __statx_pad1[1];
46 __uint64_t stx_ino;
47 __uint64_t stx_size;
48 __uint64_t stx_blocks;
49 __uint64_t stx_attributes_mask;
50 struct statx_timestamp stx_atime;
51 struct statx_timestamp stx_btime;
52 struct statx_timestamp stx_ctime;
53 struct statx_timestamp stx_mtime;
54 __uint32_t stx_rdev_major;
55 __uint32_t stx_rdev_minor;
56 __uint32_t stx_dev_major;
57 __uint32_t stx_dev_minor;
58 __uint64_t __statx_pad2[14];
59};
60
61#define STATX_TYPE 0x0001U
62#define STATX_MODE 0x0002U
63#define STATX_NLINK 0x0004U
64#define STATX_UID 0x0008U
65#define STATX_GID 0x0010U
66#define STATX_ATIME 0x0020U
67#define STATX_MTIME 0x0040U
68#define STATX_CTIME 0x0080U
69#define STATX_INO 0x0100U
70#define STATX_SIZE 0x0200U
71#define STATX_BLOCKS 0x0400U
72#define STATX_BASIC_STATS 0x07ffU
73#define STATX_ALL 0x0fffU
74#define STATX_BTIME 0x0800U
75#define STATX__RESERVED 0x80000000U
76
77#define STATX_ATTR_COMPRESSED 0x0004
78#define STATX_ATTR_IMMUTABLE 0x0010
79#define STATX_ATTR_APPEND 0x0020
80#define STATX_ATTR_NODUMP 0x0040
81#define STATX_ATTR_ENCRYPTED 0x0800
82#define STATX_ATTR_AUTOMOUNT 0x1000
83
84__BEGIN_DECLS
85
86/* Fill *BUF with information about PATH in DIRFD. */
87int statx (int __dirfd, const char *__restrict __path, int __flags,
88 unsigned int __mask, struct statx *__restrict __buf)
89 __THROW __nonnull ((2, 5));
90
91__END_DECLS
libc/glibc-include/bits/stdint-intn.h created+29
...@@ -0,0 +1,29 @@
1/* Define intN_t types.
2 Copyright (C) 2017-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_STDINT_INTN_H
20#define _BITS_STDINT_INTN_H 1
21
22#include <bits/types.h>
23
24typedef __int8_t int8_t;
25typedef __int16_t int16_t;
26typedef __int32_t int32_t;
27typedef __int64_t int64_t;
28
29#endif /* bits/stdint-intn.h */
libc/glibc-include/bits/stdint-uintn.h created+29
...@@ -0,0 +1,29 @@
1/* Define uintN_t types.
2 Copyright (C) 2017-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_STDINT_UINTN_H
20#define _BITS_STDINT_UINTN_H 1
21
22#include <bits/types.h>
23
24typedef __uint8_t uint8_t;
25typedef __uint16_t uint16_t;
26typedef __uint32_t uint32_t;
27typedef __uint64_t uint64_t;
28
29#endif /* bits/stdint-uintn.h */
libc/glibc-include/bits/stdio-ldbl.h created+92
...@@ -0,0 +1,92 @@
1/* -mlong-double-64 compatibility mode for stdio functions.
2 Copyright (C) 2006-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _STDIO_H
20# error "Never include <bits/stdio-ldbl.h> directly; use <stdio.h> instead."
21#endif
22
23__LDBL_REDIR_DECL (fprintf)
24__LDBL_REDIR_DECL (printf)
25__LDBL_REDIR_DECL (sprintf)
26__LDBL_REDIR_DECL (vfprintf)
27__LDBL_REDIR_DECL (vprintf)
28__LDBL_REDIR_DECL (vsprintf)
29#if !__GLIBC_USE (DEPRECATED_SCANF)
30__LDBL_REDIR1_DECL (fscanf, __nldbl___isoc99_fscanf)
31__LDBL_REDIR1_DECL (scanf, __nldbl___isoc99_scanf)
32__LDBL_REDIR1_DECL (sscanf, __nldbl___isoc99_sscanf)
33#else
34__LDBL_REDIR_DECL (fscanf)
35__LDBL_REDIR_DECL (scanf)
36__LDBL_REDIR_DECL (sscanf)
37#endif
38
39#if defined __USE_ISOC99 || defined __USE_UNIX98
40__LDBL_REDIR_DECL (snprintf)
41__LDBL_REDIR_DECL (vsnprintf)
42#endif
43
44#ifdef __USE_ISOC99
45# if !__GLIBC_USE (DEPRECATED_SCANF)
46__LDBL_REDIR1_DECL (vfscanf, __nldbl___isoc99_vfscanf)
47__LDBL_REDIR1_DECL (vscanf, __nldbl___isoc99_vscanf)
48__LDBL_REDIR1_DECL (vsscanf, __nldbl___isoc99_vsscanf)
49# else
50__LDBL_REDIR_DECL (vfscanf)
51__LDBL_REDIR_DECL (vsscanf)
52__LDBL_REDIR_DECL (vscanf)
53# endif
54#endif
55
56#ifdef __USE_XOPEN2K8
57__LDBL_REDIR_DECL (vdprintf)
58__LDBL_REDIR_DECL (dprintf)
59#endif
60
61#ifdef __USE_GNU
62__LDBL_REDIR_DECL (vasprintf)
63__LDBL_REDIR_DECL (__asprintf)
64__LDBL_REDIR_DECL (asprintf)
65__LDBL_REDIR_DECL (obstack_printf)
66__LDBL_REDIR_DECL (obstack_vprintf)
67#endif
68
69#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
70__LDBL_REDIR_DECL (__sprintf_chk)
71__LDBL_REDIR_DECL (__vsprintf_chk)
72# if defined __USE_ISOC99 || defined __USE_UNIX98
73__LDBL_REDIR_DECL (__snprintf_chk)
74__LDBL_REDIR_DECL (__vsnprintf_chk)
75# endif
76# if __USE_FORTIFY_LEVEL > 1
77__LDBL_REDIR_DECL (__fprintf_chk)
78__LDBL_REDIR_DECL (__printf_chk)
79__LDBL_REDIR_DECL (__vfprintf_chk)
80__LDBL_REDIR_DECL (__vprintf_chk)
81# ifdef __USE_XOPEN2K8
82__LDBL_REDIR_DECL (__dprintf_chk)
83__LDBL_REDIR_DECL (__vdprintf_chk)
84# endif
85# ifdef __USE_GNU
86__LDBL_REDIR_DECL (__asprintf_chk)
87__LDBL_REDIR_DECL (__vasprintf_chk)
88__LDBL_REDIR_DECL (__obstack_printf_chk)
89__LDBL_REDIR_DECL (__obstack_vprintf_chk)
90# endif
91# endif
92#endif
libc/glibc-include/bits/stdio.h created+195
...@@ -0,0 +1,195 @@
1/* Optimizing macros and inline functions for stdio functions.
2 Copyright (C) 1998-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_STDIO_H
20#define _BITS_STDIO_H 1
21
22#ifndef _STDIO_H
23# error "Never include <bits/stdio.h> directly; use <stdio.h> instead."
24#endif
25
26#ifndef __extern_inline
27# define __STDIO_INLINE inline
28#else
29# define __STDIO_INLINE __extern_inline
30#endif
31
32
33#ifdef __USE_EXTERN_INLINES
34/* For -D_FORTIFY_SOURCE{,=2} bits/stdio2.h will define a different
35 inline. */
36# if !(__USE_FORTIFY_LEVEL > 0 && defined __fortify_function)
37/* Write formatted output to stdout from argument list ARG. */
38__STDIO_INLINE int
39vprintf (const char *__restrict __fmt, __gnuc_va_list __arg)
40{
41 return vfprintf (stdout, __fmt, __arg);
42}
43# endif
44
45/* Read a character from stdin. */
46__STDIO_INLINE int
47getchar (void)
48{
49 return getc (stdin);
50}
51
52
53# ifdef __USE_MISC
54/* Faster version when locking is not necessary. */
55__STDIO_INLINE int
56fgetc_unlocked (FILE *__fp)
57{
58 return __getc_unlocked_body (__fp);
59}
60# endif /* misc */
61
62
63# ifdef __USE_POSIX
64/* This is defined in POSIX.1:1996. */
65__STDIO_INLINE int
66getc_unlocked (FILE *__fp)
67{
68 return __getc_unlocked_body (__fp);
69}
70
71/* This is defined in POSIX.1:1996. */
72__STDIO_INLINE int
73getchar_unlocked (void)
74{
75 return __getc_unlocked_body (stdin);
76}
77# endif /* POSIX */
78
79
80/* Write a character to stdout. */
81__STDIO_INLINE int
82putchar (int __c)
83{
84 return putc (__c, stdout);
85}
86
87
88# ifdef __USE_MISC
89/* Faster version when locking is not necessary. */
90__STDIO_INLINE int
91fputc_unlocked (int __c, FILE *__stream)
92{
93 return __putc_unlocked_body (__c, __stream);
94}
95# endif /* misc */
96
97
98# ifdef __USE_POSIX
99/* This is defined in POSIX.1:1996. */
100__STDIO_INLINE int
101putc_unlocked (int __c, FILE *__stream)
102{
103 return __putc_unlocked_body (__c, __stream);
104}
105
106/* This is defined in POSIX.1:1996. */
107__STDIO_INLINE int
108putchar_unlocked (int __c)
109{
110 return __putc_unlocked_body (__c, stdout);
111}
112# endif /* POSIX */
113
114
115# ifdef __USE_GNU
116/* Like `getdelim', but reads up to a newline. */
117__STDIO_INLINE __ssize_t
118getline (char **__lineptr, size_t *__n, FILE *__stream)
119{
120 return __getdelim (__lineptr, __n, '\n', __stream);
121}
122# endif /* GNU */
123
124
125# ifdef __USE_MISC
126/* Faster versions when locking is not required. */
127__STDIO_INLINE int
128__NTH (feof_unlocked (FILE *__stream))
129{
130 return __feof_unlocked_body (__stream);
131}
132
133/* Faster versions when locking is not required. */
134__STDIO_INLINE int
135__NTH (ferror_unlocked (FILE *__stream))
136{
137 return __ferror_unlocked_body (__stream);
138}
139# endif /* misc */
140
141#endif /* Use extern inlines. */
142
143
144#if defined __USE_MISC && defined __GNUC__ && defined __OPTIMIZE__ \
145 && !defined __cplusplus
146/* Perform some simple optimizations. */
147# define fread_unlocked(ptr, size, n, stream) \
148 (__extension__ ((__builtin_constant_p (size) && __builtin_constant_p (n) \
149 && (size_t) (size) * (size_t) (n) <= 8 \
150 && (size_t) (size) != 0) \
151 ? ({ char *__ptr = (char *) (ptr); \
152 FILE *__stream = (stream); \
153 size_t __cnt; \
154 for (__cnt = (size_t) (size) * (size_t) (n); \
155 __cnt > 0; --__cnt) \
156 { \
157 int __c = getc_unlocked (__stream); \
158 if (__c == EOF) \
159 break; \
160 *__ptr++ = __c; \
161 } \
162 ((size_t) (size) * (size_t) (n) - __cnt) \
163 / (size_t) (size); }) \
164 : (((__builtin_constant_p (size) && (size_t) (size) == 0) \
165 || (__builtin_constant_p (n) && (size_t) (n) == 0)) \
166 /* Evaluate all parameters once. */ \
167 ? ((void) (ptr), (void) (stream), (void) (size), \
168 (void) (n), (size_t) 0) \
169 : fread_unlocked (ptr, size, n, stream))))
170
171# define fwrite_unlocked(ptr, size, n, stream) \
172 (__extension__ ((__builtin_constant_p (size) && __builtin_constant_p (n) \
173 && (size_t) (size) * (size_t) (n) <= 8 \
174 && (size_t) (size) != 0) \
175 ? ({ const char *__ptr = (const char *) (ptr); \
176 FILE *__stream = (stream); \
177 size_t __cnt; \
178 for (__cnt = (size_t) (size) * (size_t) (n); \
179 __cnt > 0; --__cnt) \
180 if (putc_unlocked (*__ptr++, __stream) == EOF) \
181 break; \
182 ((size_t) (size) * (size_t) (n) - __cnt) \
183 / (size_t) (size); }) \
184 : (((__builtin_constant_p (size) && (size_t) (size) == 0) \
185 || (__builtin_constant_p (n) && (size_t) (n) == 0)) \
186 /* Evaluate all parameters once. */ \
187 ? ((void) (ptr), (void) (stream), (void) (size), \
188 (void) (n), (size_t) 0) \
189 : fwrite_unlocked (ptr, size, n, stream))))
190#endif
191
192/* Define helper macro. */
193#undef __STDIO_INLINE
194
195#endif /* bits/stdio.h. */
libc/glibc-include/bits/stdio2.h created+386
...@@ -0,0 +1,386 @@
1/* Checking macros for stdio functions.
2 Copyright (C) 2004-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_STDIO2_H
20#define _BITS_STDIO2_H 1
21
22#ifndef _STDIO_H
23# error "Never include <bits/stdio2.h> directly; use <stdio.h> instead."
24#endif
25
26extern int __sprintf_chk (char *__restrict __s, int __flag, size_t __slen,
27 const char *__restrict __format, ...) __THROW;
28extern int __vsprintf_chk (char *__restrict __s, int __flag, size_t __slen,
29 const char *__restrict __format,
30 __gnuc_va_list __ap) __THROW;
31
32#ifdef __va_arg_pack
33__fortify_function int
34__NTH (sprintf (char *__restrict __s, const char *__restrict __fmt, ...))
35{
36 return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
37 __bos (__s), __fmt, __va_arg_pack ());
38}
39#elif !defined __cplusplus
40# define sprintf(str, ...) \
41 __builtin___sprintf_chk (str, __USE_FORTIFY_LEVEL - 1, __bos (str), \
42 __VA_ARGS__)
43#endif
44
45__fortify_function int
46__NTH (vsprintf (char *__restrict __s, const char *__restrict __fmt,
47 __gnuc_va_list __ap))
48{
49 return __builtin___vsprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
50 __bos (__s), __fmt, __ap);
51}
52
53#if defined __USE_ISOC99 || defined __USE_UNIX98
54
55extern int __snprintf_chk (char *__restrict __s, size_t __n, int __flag,
56 size_t __slen, const char *__restrict __format,
57 ...) __THROW;
58extern int __vsnprintf_chk (char *__restrict __s, size_t __n, int __flag,
59 size_t __slen, const char *__restrict __format,
60 __gnuc_va_list __ap) __THROW;
61
62# ifdef __va_arg_pack
63__fortify_function int
64__NTH (snprintf (char *__restrict __s, size_t __n,
65 const char *__restrict __fmt, ...))
66{
67 return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
68 __bos (__s), __fmt, __va_arg_pack ());
69}
70# elif !defined __cplusplus
71# define snprintf(str, len, ...) \
72 __builtin___snprintf_chk (str, len, __USE_FORTIFY_LEVEL - 1, __bos (str), \
73 __VA_ARGS__)
74# endif
75
76__fortify_function int
77__NTH (vsnprintf (char *__restrict __s, size_t __n,
78 const char *__restrict __fmt, __gnuc_va_list __ap))
79{
80 return __builtin___vsnprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
81 __bos (__s), __fmt, __ap);
82}
83
84#endif
85
86#if __USE_FORTIFY_LEVEL > 1
87
88extern int __fprintf_chk (FILE *__restrict __stream, int __flag,
89 const char *__restrict __format, ...);
90extern int __printf_chk (int __flag, const char *__restrict __format, ...);
91extern int __vfprintf_chk (FILE *__restrict __stream, int __flag,
92 const char *__restrict __format, __gnuc_va_list __ap);
93extern int __vprintf_chk (int __flag, const char *__restrict __format,
94 __gnuc_va_list __ap);
95
96# ifdef __va_arg_pack
97__fortify_function int
98fprintf (FILE *__restrict __stream, const char *__restrict __fmt, ...)
99{
100 return __fprintf_chk (__stream, __USE_FORTIFY_LEVEL - 1, __fmt,
101 __va_arg_pack ());
102}
103
104__fortify_function int
105printf (const char *__restrict __fmt, ...)
106{
107 return __printf_chk (__USE_FORTIFY_LEVEL - 1, __fmt, __va_arg_pack ());
108}
109# elif !defined __cplusplus
110# define printf(...) \
111 __printf_chk (__USE_FORTIFY_LEVEL - 1, __VA_ARGS__)
112# define fprintf(stream, ...) \
113 __fprintf_chk (stream, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__)
114# endif
115
116__fortify_function int
117vprintf (const char *__restrict __fmt, __gnuc_va_list __ap)
118{
119#ifdef __USE_EXTERN_INLINES
120 return __vfprintf_chk (stdout, __USE_FORTIFY_LEVEL - 1, __fmt, __ap);
121#else
122 return __vprintf_chk (__USE_FORTIFY_LEVEL - 1, __fmt, __ap);
123#endif
124}
125
126__fortify_function int
127vfprintf (FILE *__restrict __stream,
128 const char *__restrict __fmt, __gnuc_va_list __ap)
129{
130 return __vfprintf_chk (__stream, __USE_FORTIFY_LEVEL - 1, __fmt, __ap);
131}
132
133# ifdef __USE_XOPEN2K8
134extern int __dprintf_chk (int __fd, int __flag, const char *__restrict __fmt,
135 ...) __attribute__ ((__format__ (__printf__, 3, 4)));
136extern int __vdprintf_chk (int __fd, int __flag,
137 const char *__restrict __fmt, __gnuc_va_list __arg)
138 __attribute__ ((__format__ (__printf__, 3, 0)));
139
140# ifdef __va_arg_pack
141__fortify_function int
142dprintf (int __fd, const char *__restrict __fmt, ...)
143{
144 return __dprintf_chk (__fd, __USE_FORTIFY_LEVEL - 1, __fmt,
145 __va_arg_pack ());
146}
147# elif !defined __cplusplus
148# define dprintf(fd, ...) \
149 __dprintf_chk (fd, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__)
150# endif
151
152__fortify_function int
153vdprintf (int __fd, const char *__restrict __fmt, __gnuc_va_list __ap)
154{
155 return __vdprintf_chk (__fd, __USE_FORTIFY_LEVEL - 1, __fmt, __ap);
156}
157# endif
158
159# ifdef __USE_GNU
160
161extern int __asprintf_chk (char **__restrict __ptr, int __flag,
162 const char *__restrict __fmt, ...)
163 __THROW __attribute__ ((__format__ (__printf__, 3, 4))) __wur;
164extern int __vasprintf_chk (char **__restrict __ptr, int __flag,
165 const char *__restrict __fmt, __gnuc_va_list __arg)
166 __THROW __attribute__ ((__format__ (__printf__, 3, 0))) __wur;
167extern int __obstack_printf_chk (struct obstack *__restrict __obstack,
168 int __flag, const char *__restrict __format,
169 ...)
170 __THROW __attribute__ ((__format__ (__printf__, 3, 4)));
171extern int __obstack_vprintf_chk (struct obstack *__restrict __obstack,
172 int __flag,
173 const char *__restrict __format,
174 __gnuc_va_list __args)
175 __THROW __attribute__ ((__format__ (__printf__, 3, 0)));
176
177# ifdef __va_arg_pack
178__fortify_function int
179__NTH (asprintf (char **__restrict __ptr, const char *__restrict __fmt, ...))
180{
181 return __asprintf_chk (__ptr, __USE_FORTIFY_LEVEL - 1, __fmt,
182 __va_arg_pack ());
183}
184
185__fortify_function int
186__NTH (__asprintf (char **__restrict __ptr, const char *__restrict __fmt,
187 ...))
188{
189 return __asprintf_chk (__ptr, __USE_FORTIFY_LEVEL - 1, __fmt,
190 __va_arg_pack ());
191}
192
193__fortify_function int
194__NTH (obstack_printf (struct obstack *__restrict __obstack,
195 const char *__restrict __fmt, ...))
196{
197 return __obstack_printf_chk (__obstack, __USE_FORTIFY_LEVEL - 1, __fmt,
198 __va_arg_pack ());
199}
200# elif !defined __cplusplus
201# define asprintf(ptr, ...) \
202 __asprintf_chk (ptr, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__)
203# define __asprintf(ptr, ...) \
204 __asprintf_chk (ptr, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__)
205# define obstack_printf(obstack, ...) \
206 __obstack_printf_chk (obstack, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__)
207# endif
208
209__fortify_function int
210__NTH (vasprintf (char **__restrict __ptr, const char *__restrict __fmt,
211 __gnuc_va_list __ap))
212{
213 return __vasprintf_chk (__ptr, __USE_FORTIFY_LEVEL - 1, __fmt, __ap);
214}
215
216__fortify_function int
217__NTH (obstack_vprintf (struct obstack *__restrict __obstack,
218 const char *__restrict __fmt, __gnuc_va_list __ap))
219{
220 return __obstack_vprintf_chk (__obstack, __USE_FORTIFY_LEVEL - 1, __fmt,
221 __ap);
222}
223
224# endif
225
226#endif
227
228#if __GLIBC_USE (DEPRECATED_GETS)
229extern char *__gets_chk (char *__str, size_t) __wur;
230extern char *__REDIRECT (__gets_warn, (char *__str), gets)
231 __wur __warnattr ("please use fgets or getline instead, gets can't "
232 "specify buffer size");
233
234__fortify_function __wur char *
235gets (char *__str)
236{
237 if (__bos (__str) != (size_t) -1)
238 return __gets_chk (__str, __bos (__str));
239 return __gets_warn (__str);
240}
241#endif
242
243extern char *__fgets_chk (char *__restrict __s, size_t __size, int __n,
244 FILE *__restrict __stream) __wur;
245extern char *__REDIRECT (__fgets_alias,
246 (char *__restrict __s, int __n,
247 FILE *__restrict __stream), fgets) __wur;
248extern char *__REDIRECT (__fgets_chk_warn,
249 (char *__restrict __s, size_t __size, int __n,
250 FILE *__restrict __stream), __fgets_chk)
251 __wur __warnattr ("fgets called with bigger size than length "
252 "of destination buffer");
253
254__fortify_function __wur char *
255fgets (char *__restrict __s, int __n, FILE *__restrict __stream)
256{
257 if (__bos (__s) != (size_t) -1)
258 {
259 if (!__builtin_constant_p (__n) || __n <= 0)
260 return __fgets_chk (__s, __bos (__s), __n, __stream);
261
262 if ((size_t) __n > __bos (__s))
263 return __fgets_chk_warn (__s, __bos (__s), __n, __stream);
264 }
265 return __fgets_alias (__s, __n, __stream);
266}
267
268extern size_t __fread_chk (void *__restrict __ptr, size_t __ptrlen,
269 size_t __size, size_t __n,
270 FILE *__restrict __stream) __wur;
271extern size_t __REDIRECT (__fread_alias,
272 (void *__restrict __ptr, size_t __size,
273 size_t __n, FILE *__restrict __stream),
274 fread) __wur;
275extern size_t __REDIRECT (__fread_chk_warn,
276 (void *__restrict __ptr, size_t __ptrlen,
277 size_t __size, size_t __n,
278 FILE *__restrict __stream),
279 __fread_chk)
280 __wur __warnattr ("fread called with bigger size * nmemb than length "
281 "of destination buffer");
282
283__fortify_function __wur size_t
284fread (void *__restrict __ptr, size_t __size, size_t __n,
285 FILE *__restrict __stream)
286{
287 if (__bos0 (__ptr) != (size_t) -1)
288 {
289 if (!__builtin_constant_p (__size)
290 || !__builtin_constant_p (__n)
291 || (__size | __n) >= (((size_t) 1) << (8 * sizeof (size_t) / 2)))
292 return __fread_chk (__ptr, __bos0 (__ptr), __size, __n, __stream);
293
294 if (__size * __n > __bos0 (__ptr))
295 return __fread_chk_warn (__ptr, __bos0 (__ptr), __size, __n, __stream);
296 }
297 return __fread_alias (__ptr, __size, __n, __stream);
298}
299
300#ifdef __USE_GNU
301extern char *__fgets_unlocked_chk (char *__restrict __s, size_t __size,
302 int __n, FILE *__restrict __stream) __wur;
303extern char *__REDIRECT (__fgets_unlocked_alias,
304 (char *__restrict __s, int __n,
305 FILE *__restrict __stream), fgets_unlocked) __wur;
306extern char *__REDIRECT (__fgets_unlocked_chk_warn,
307 (char *__restrict __s, size_t __size, int __n,
308 FILE *__restrict __stream), __fgets_unlocked_chk)
309 __wur __warnattr ("fgets_unlocked called with bigger size than length "
310 "of destination buffer");
311
312__fortify_function __wur char *
313fgets_unlocked (char *__restrict __s, int __n, FILE *__restrict __stream)
314{
315 if (__bos (__s) != (size_t) -1)
316 {
317 if (!__builtin_constant_p (__n) || __n <= 0)
318 return __fgets_unlocked_chk (__s, __bos (__s), __n, __stream);
319
320 if ((size_t) __n > __bos (__s))
321 return __fgets_unlocked_chk_warn (__s, __bos (__s), __n, __stream);
322 }
323 return __fgets_unlocked_alias (__s, __n, __stream);
324}
325#endif
326
327#ifdef __USE_MISC
328# undef fread_unlocked
329extern size_t __fread_unlocked_chk (void *__restrict __ptr, size_t __ptrlen,
330 size_t __size, size_t __n,
331 FILE *__restrict __stream) __wur;
332extern size_t __REDIRECT (__fread_unlocked_alias,
333 (void *__restrict __ptr, size_t __size,
334 size_t __n, FILE *__restrict __stream),
335 fread_unlocked) __wur;
336extern size_t __REDIRECT (__fread_unlocked_chk_warn,
337 (void *__restrict __ptr, size_t __ptrlen,
338 size_t __size, size_t __n,
339 FILE *__restrict __stream),
340 __fread_unlocked_chk)
341 __wur __warnattr ("fread_unlocked called with bigger size * nmemb than "
342 "length of destination buffer");
343
344__fortify_function __wur size_t
345fread_unlocked (void *__restrict __ptr, size_t __size, size_t __n,
346 FILE *__restrict __stream)
347{
348 if (__bos0 (__ptr) != (size_t) -1)
349 {
350 if (!__builtin_constant_p (__size)
351 || !__builtin_constant_p (__n)
352 || (__size | __n) >= (((size_t) 1) << (8 * sizeof (size_t) / 2)))
353 return __fread_unlocked_chk (__ptr, __bos0 (__ptr), __size, __n,
354 __stream);
355
356 if (__size * __n > __bos0 (__ptr))
357 return __fread_unlocked_chk_warn (__ptr, __bos0 (__ptr), __size, __n,
358 __stream);
359 }
360
361# ifdef __USE_EXTERN_INLINES
362 if (__builtin_constant_p (__size)
363 && __builtin_constant_p (__n)
364 && (__size | __n) < (((size_t) 1) << (8 * sizeof (size_t) / 2))
365 && __size * __n <= 8)
366 {
367 size_t __cnt = __size * __n;
368 char *__cptr = (char *) __ptr;
369 if (__cnt == 0)
370 return 0;
371
372 for (; __cnt > 0; --__cnt)
373 {
374 int __c = getc_unlocked (__stream);
375 if (__c == EOF)
376 break;
377 *__cptr++ = __c;
378 }
379 return (__cptr - (char *) __ptr) / __size;
380 }
381# endif
382 return __fread_unlocked_alias (__ptr, __size, __n, __stream);
383}
384#endif
385
386#endif /* bits/stdio2.h. */
libc/glibc-include/bits/stdio_lim.h created+39
...@@ -0,0 +1,39 @@
1/* Copyright (C) 1994-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _BITS_STDIO_LIM_H
19#define _BITS_STDIO_LIM_H 1
20
21#ifndef _STDIO_H
22# error "Never include <bits/stdio_lim.h> directly; use <stdio.h> instead."
23#endif
24
25#define L_tmpnam 20
26#define TMP_MAX 238328
27#define FILENAME_MAX 4096
28
29#ifdef __USE_POSIX
30# define L_ctermid 9
31# if !defined __USE_XOPEN2K || defined __USE_GNU
32# define L_cuserid 9
33# endif
34#endif
35
36#undef FOPEN_MAX
37#define FOPEN_MAX 16
38
39#endif /* bits/stdio_lim.h */
libc/glibc-include/bits/stdlib-bsearch.h created+43
...@@ -0,0 +1,43 @@
1/* Perform binary search - inline version.
2 Copyright (C) 1991-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19__extern_inline void *
20bsearch (const void *__key, const void *__base, size_t __nmemb, size_t __size,
21 __compar_fn_t __compar)
22{
23 size_t __l, __u, __idx;
24 const void *__p;
25 int __comparison;
26
27 __l = 0;
28 __u = __nmemb;
29 while (__l < __u)
30 {
31 __idx = (__l + __u) / 2;
32 __p = (void *) (((const char *) __base) + (__idx * __size));
33 __comparison = (*__compar) (__key, __p);
34 if (__comparison < 0)
35 __u = __idx;
36 else if (__comparison > 0)
37 __l = __idx + 1;
38 else
39 return (void *) __p;
40 }
41
42 return NULL;
43}
libc/glibc-include/bits/stdlib-float.h created+29
...@@ -0,0 +1,29 @@
1/* Floating-point inline functions for stdlib.h.
2 Copyright (C) 2012-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _STDLIB_H
20# error "Never use <bits/stdlib-float.h> directly; include <stdlib.h> instead."
21#endif
22
23#ifdef __USE_EXTERN_INLINES
24__extern_inline double
25__NTH (atof (const char *__nptr))
26{
27 return strtod (__nptr, (char **) NULL);
28}
29#endif /* Optimizing and Inlining. */
libc/glibc-include/bits/stdlib-ldbl.h created+41
...@@ -0,0 +1,41 @@
1/* -mlong-double-64 compatibility mode for <stdlib.h> functions.
2 Copyright (C) 2006-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _STDLIB_H
20# error "Never include <bits/stdlib-ldbl.h> directly; use <stdlib.h> instead."
21#endif
22
23#ifdef __USE_ISOC99
24__LDBL_REDIR1_DECL (strtold, strtod)
25#endif
26
27#ifdef __USE_GNU
28__LDBL_REDIR1_DECL (strtold_l, strtod_l)
29#endif
30
31#if __GLIBC_USE (IEC_60559_BFP_EXT)
32__LDBL_REDIR1_DECL (strfroml, strfromd)
33#endif
34
35#ifdef __USE_MISC
36__LDBL_REDIR1_DECL (qecvt, ecvt)
37__LDBL_REDIR1_DECL (qfcvt, fcvt)
38__LDBL_REDIR1_DECL (qgcvt, gcvt)
39__LDBL_REDIR1_DECL (qecvt_r, ecvt_r)
40__LDBL_REDIR1_DECL (qfcvt_r, fcvt_r)
41#endif
libc/glibc-include/bits/stdlib.h created+155
...@@ -0,0 +1,155 @@
1/* Checking macros for stdlib functions.
2 Copyright (C) 2005-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _STDLIB_H
20# error "Never include <bits/stdlib.h> directly; use <stdlib.h> instead."
21#endif
22
23extern char *__realpath_chk (const char *__restrict __name,
24 char *__restrict __resolved,
25 size_t __resolvedlen) __THROW __wur;
26extern char *__REDIRECT_NTH (__realpath_alias,
27 (const char *__restrict __name,
28 char *__restrict __resolved), realpath) __wur;
29extern char *__REDIRECT_NTH (__realpath_chk_warn,
30 (const char *__restrict __name,
31 char *__restrict __resolved,
32 size_t __resolvedlen), __realpath_chk) __wur
33 __warnattr ("second argument of realpath must be either NULL or at "
34 "least PATH_MAX bytes long buffer");
35
36__fortify_function __wur char *
37__NTH (realpath (const char *__restrict __name, char *__restrict __resolved))
38{
39 if (__bos (__resolved) != (size_t) -1)
40 {
41#if defined _LIBC_LIMITS_H_ && defined PATH_MAX
42 if (__bos (__resolved) < PATH_MAX)
43 return __realpath_chk_warn (__name, __resolved, __bos (__resolved));
44#endif
45 return __realpath_chk (__name, __resolved, __bos (__resolved));
46 }
47
48 return __realpath_alias (__name, __resolved);
49}
50
51
52extern int __ptsname_r_chk (int __fd, char *__buf, size_t __buflen,
53 size_t __nreal) __THROW __nonnull ((2));
54extern int __REDIRECT_NTH (__ptsname_r_alias, (int __fd, char *__buf,
55 size_t __buflen), ptsname_r)
56 __nonnull ((2));
57extern int __REDIRECT_NTH (__ptsname_r_chk_warn,
58 (int __fd, char *__buf, size_t __buflen,
59 size_t __nreal), __ptsname_r_chk)
60 __nonnull ((2)) __warnattr ("ptsname_r called with buflen bigger than "
61 "size of buf");
62
63__fortify_function int
64__NTH (ptsname_r (int __fd, char *__buf, size_t __buflen))
65{
66 if (__bos (__buf) != (size_t) -1)
67 {
68 if (!__builtin_constant_p (__buflen))
69 return __ptsname_r_chk (__fd, __buf, __buflen, __bos (__buf));
70 if (__buflen > __bos (__buf))
71 return __ptsname_r_chk_warn (__fd, __buf, __buflen, __bos (__buf));
72 }
73 return __ptsname_r_alias (__fd, __buf, __buflen);
74}
75
76
77extern int __wctomb_chk (char *__s, wchar_t __wchar, size_t __buflen)
78 __THROW __wur;
79extern int __REDIRECT_NTH (__wctomb_alias, (char *__s, wchar_t __wchar),
80 wctomb) __wur;
81
82__fortify_function __wur int
83__NTH (wctomb (char *__s, wchar_t __wchar))
84{
85 /* We would have to include <limits.h> to get a definition of MB_LEN_MAX.
86 But this would only disturb the namespace. So we define our own
87 version here. */
88#define __STDLIB_MB_LEN_MAX 16
89#if defined MB_LEN_MAX && MB_LEN_MAX != __STDLIB_MB_LEN_MAX
90# error "Assumed value of MB_LEN_MAX wrong"
91#endif
92 if (__bos (__s) != (size_t) -1 && __STDLIB_MB_LEN_MAX > __bos (__s))
93 return __wctomb_chk (__s, __wchar, __bos (__s));
94 return __wctomb_alias (__s, __wchar);
95}
96
97
98extern size_t __mbstowcs_chk (wchar_t *__restrict __dst,
99 const char *__restrict __src,
100 size_t __len, size_t __dstlen) __THROW;
101extern size_t __REDIRECT_NTH (__mbstowcs_alias,
102 (wchar_t *__restrict __dst,
103 const char *__restrict __src,
104 size_t __len), mbstowcs);
105extern size_t __REDIRECT_NTH (__mbstowcs_chk_warn,
106 (wchar_t *__restrict __dst,
107 const char *__restrict __src,
108 size_t __len, size_t __dstlen), __mbstowcs_chk)
109 __warnattr ("mbstowcs called with dst buffer smaller than len "
110 "* sizeof (wchar_t)");
111
112__fortify_function size_t
113__NTH (mbstowcs (wchar_t *__restrict __dst, const char *__restrict __src,
114 size_t __len))
115{
116 if (__bos (__dst) != (size_t) -1)
117 {
118 if (!__builtin_constant_p (__len))
119 return __mbstowcs_chk (__dst, __src, __len,
120 __bos (__dst) / sizeof (wchar_t));
121
122 if (__len > __bos (__dst) / sizeof (wchar_t))
123 return __mbstowcs_chk_warn (__dst, __src, __len,
124 __bos (__dst) / sizeof (wchar_t));
125 }
126 return __mbstowcs_alias (__dst, __src, __len);
127}
128
129
130extern size_t __wcstombs_chk (char *__restrict __dst,
131 const wchar_t *__restrict __src,
132 size_t __len, size_t __dstlen) __THROW;
133extern size_t __REDIRECT_NTH (__wcstombs_alias,
134 (char *__restrict __dst,
135 const wchar_t *__restrict __src,
136 size_t __len), wcstombs);
137extern size_t __REDIRECT_NTH (__wcstombs_chk_warn,
138 (char *__restrict __dst,
139 const wchar_t *__restrict __src,
140 size_t __len, size_t __dstlen), __wcstombs_chk)
141 __warnattr ("wcstombs called with dst buffer smaller than len");
142
143__fortify_function size_t
144__NTH (wcstombs (char *__restrict __dst, const wchar_t *__restrict __src,
145 size_t __len))
146{
147 if (__bos (__dst) != (size_t) -1)
148 {
149 if (!__builtin_constant_p (__len))
150 return __wcstombs_chk (__dst, __src, __len, __bos (__dst));
151 if (__len > __bos (__dst))
152 return __wcstombs_chk_warn (__dst, __src, __len, __bos (__dst));
153 }
154 return __wcstombs_alias (__dst, __src, __len);
155}
libc/glibc-include/bits/string_fortified.h created+139
...@@ -0,0 +1,139 @@
1/* Copyright (C) 2004-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _BITS_STRING_FORTIFIED_H
19#define _BITS_STRING_FORTIFIED_H 1
20
21#ifndef _STRING_H
22# error "Never use <bits/string_fortified.h> directly; include <string.h> instead."
23#endif
24
25#if !__GNUC_PREREQ (5,0)
26__warndecl (__warn_memset_zero_len,
27 "memset used with constant zero length parameter; this could be due to transposed parameters");
28#endif
29
30__fortify_function void *
31__NTH (memcpy (void *__restrict __dest, const void *__restrict __src,
32 size_t __len))
33{
34 return __builtin___memcpy_chk (__dest, __src, __len, __bos0 (__dest));
35}
36
37__fortify_function void *
38__NTH (memmove (void *__dest, const void *__src, size_t __len))
39{
40 return __builtin___memmove_chk (__dest, __src, __len, __bos0 (__dest));
41}
42
43#ifdef __USE_GNU
44__fortify_function void *
45__NTH (mempcpy (void *__restrict __dest, const void *__restrict __src,
46 size_t __len))
47{
48 return __builtin___mempcpy_chk (__dest, __src, __len, __bos0 (__dest));
49}
50#endif
51
52
53/* The first two tests here help to catch a somewhat common problem
54 where the second and third parameter are transposed. This is
55 especially problematic if the intended fill value is zero. In this
56 case no work is done at all. We detect these problems by referring
57 non-existing functions. */
58__fortify_function void *
59__NTH (memset (void *__dest, int __ch, size_t __len))
60{
61 /* GCC-5.0 and newer implements these checks in the compiler, so we don't
62 need them here. */
63#if !__GNUC_PREREQ (5,0)
64 if (__builtin_constant_p (__len) && __len == 0
65 && (!__builtin_constant_p (__ch) || __ch != 0))
66 {
67 __warn_memset_zero_len ();
68 return __dest;
69 }
70#endif
71 return __builtin___memset_chk (__dest, __ch, __len, __bos0 (__dest));
72}
73
74#ifdef __USE_MISC
75# include <bits/strings_fortified.h>
76
77void __explicit_bzero_chk (void *__dest, size_t __len, size_t __destlen)
78 __THROW __nonnull ((1));
79
80__fortify_function void
81__NTH (explicit_bzero (void *__dest, size_t __len))
82{
83 __explicit_bzero_chk (__dest, __len, __bos0 (__dest));
84}
85#endif
86
87__fortify_function char *
88__NTH (strcpy (char *__restrict __dest, const char *__restrict __src))
89{
90 return __builtin___strcpy_chk (__dest, __src, __bos (__dest));
91}
92
93#ifdef __USE_GNU
94__fortify_function char *
95__NTH (stpcpy (char *__restrict __dest, const char *__restrict __src))
96{
97 return __builtin___stpcpy_chk (__dest, __src, __bos (__dest));
98}
99#endif
100
101
102__fortify_function char *
103__NTH (strncpy (char *__restrict __dest, const char *__restrict __src,
104 size_t __len))
105{
106 return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
107}
108
109/* XXX We have no corresponding builtin yet. */
110extern char *__stpncpy_chk (char *__dest, const char *__src, size_t __n,
111 size_t __destlen) __THROW;
112extern char *__REDIRECT_NTH (__stpncpy_alias, (char *__dest, const char *__src,
113 size_t __n), stpncpy);
114
115__fortify_function char *
116__NTH (stpncpy (char *__dest, const char *__src, size_t __n))
117{
118 if (__bos (__dest) != (size_t) -1
119 && (!__builtin_constant_p (__n) || __n > __bos (__dest)))
120 return __stpncpy_chk (__dest, __src, __n, __bos (__dest));
121 return __stpncpy_alias (__dest, __src, __n);
122}
123
124
125__fortify_function char *
126__NTH (strcat (char *__restrict __dest, const char *__restrict __src))
127{
128 return __builtin___strcat_chk (__dest, __src, __bos (__dest));
129}
130
131
132__fortify_function char *
133__NTH (strncat (char *__restrict __dest, const char *__restrict __src,
134 size_t __len))
135{
136 return __builtin___strncat_chk (__dest, __src, __len, __bos (__dest));
137}
138
139#endif /* bits/string_fortified.h */
libc/glibc-include/bits/strings_fortified.h created+34
...@@ -0,0 +1,34 @@
1/* Fortify macros for strings.h functions.
2 Copyright (C) 2017-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef __STRINGS_FORTIFIED
20# define __STRINGS_FORTIFIED 1
21
22__fortify_function void
23__NTH (bcopy (const void *__src, void *__dest, size_t __len))
24{
25 (void) __builtin___memmove_chk (__dest, __src, __len, __bos0 (__dest));
26}
27
28__fortify_function void
29__NTH (bzero (void *__dest, size_t __len))
30{
31 (void) __builtin___memset_chk (__dest, '\0', __len, __bos0 (__dest));
32}
33
34#endif
libc/glibc-include/bits/stropts.h created+230
...@@ -0,0 +1,230 @@
1/* Copyright (C) 1998-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _STROPTS_H
19# error "Never include <bits/stropts.h> directly; use <stropts.h> instead."
20#endif
21
22#ifndef _BITS_STROPTS_H
23#define _BITS_STROPTS_H 1
24
25#include <bits/types.h>
26
27/* Macros used as `request' argument to `ioctl'. */
28#define __SID ('S' << 8)
29
30#define I_NREAD (__SID | 1) /* Counts the number of data bytes in the data
31 block in the first message. */
32#define I_PUSH (__SID | 2) /* Push STREAMS module onto top of the current
33 STREAM, just below the STREAM head. */
34#define I_POP (__SID | 3) /* Remove STREAMS module from just below the
35 STREAM head. */
36#define I_LOOK (__SID | 4) /* Retrieve the name of the module just below
37 the STREAM head and place it in a character
38 string. */
39#define I_FLUSH (__SID | 5) /* Flush all input and/or output. */
40#define I_SRDOPT (__SID | 6) /* Sets the read mode. */
41#define I_GRDOPT (__SID | 7) /* Returns the current read mode setting. */
42#define I_STR (__SID | 8) /* Construct an internal STREAMS `ioctl'
43 message and send that message downstream. */
44#define I_SETSIG (__SID | 9) /* Inform the STREAM head that the process
45 wants the SIGPOLL signal issued. */
46#define I_GETSIG (__SID |10) /* Return the events for which the calling
47 process is currently registered to be sent
48 a SIGPOLL signal. */
49#define I_FIND (__SID |11) /* Compares the names of all modules currently
50 present in the STREAM to the name pointed to
51 by `arg'. */
52#define I_LINK (__SID |12) /* Connect two STREAMs. */
53#define I_UNLINK (__SID |13) /* Disconnects the two STREAMs. */
54#define I_PEEK (__SID |15) /* Allows a process to retrieve the information
55 in the first message on the STREAM head read
56 queue without taking the message off the
57 queue. */
58#define I_FDINSERT (__SID |16) /* Create a message from the specified
59 buffer(s), adds information about another
60 STREAM, and send the message downstream. */
61#define I_SENDFD (__SID |17) /* Requests the STREAM associated with `fildes'
62 to send a message, containing a file
63 pointer, to the STREAM head at the other end
64 of a STREAMS pipe. */
65#define I_RECVFD (__SID |14) /* Non-EFT definition. */
66#define I_SWROPT (__SID |19) /* Set the write mode. */
67#define I_GWROPT (__SID |20) /* Return the current write mode setting. */
68#define I_LIST (__SID |21) /* List all the module names on the STREAM, up
69 to and including the topmost driver name. */
70#define I_PLINK (__SID |22) /* Connect two STREAMs with a persistent
71 link. */
72#define I_PUNLINK (__SID |23) /* Disconnect the two STREAMs that were
73 connected with a persistent link. */
74#define I_FLUSHBAND (__SID |28) /* Flush only band specified. */
75#define I_CKBAND (__SID |29) /* Check if the message of a given priority
76 band exists on the STREAM head read
77 queue. */
78#define I_GETBAND (__SID |30) /* Return the priority band of the first
79 message on the STREAM head read queue. */
80#define I_ATMARK (__SID |31) /* See if the current message on the STREAM
81 head read queue is "marked" by some module
82 downstream. */
83#define I_SETCLTIME (__SID |32) /* Set the time the STREAM head will delay when
84 a STREAM is closing and there is data on
85 the write queues. */
86#define I_GETCLTIME (__SID |33) /* Get current value for closing timeout. */
87#define I_CANPUT (__SID |34) /* Check if a certain band is writable. */
88
89
90/* Used in `I_LOOK' request. */
91#define FMNAMESZ 8 /* compatibility w/UnixWare/Solaris. */
92
93/* Flush options. */
94#define FLUSHR 0x01 /* Flush read queues. */
95#define FLUSHW 0x02 /* Flush write queues. */
96#define FLUSHRW 0x03 /* Flush read and write queues. */
97#ifdef __USE_GNU
98# define FLUSHBAND 0x04 /* Flush only specified band. */
99#endif
100
101/* Possible arguments for `I_SETSIG'. */
102#define S_INPUT 0x0001 /* A message, other than a high-priority
103 message, has arrived. */
104#define S_HIPRI 0x0002 /* A high-priority message is present. */
105#define S_OUTPUT 0x0004 /* The write queue for normal data is no longer
106 full. */
107#define S_MSG 0x0008 /* A STREAMS signal message that contains the
108 SIGPOLL signal reaches the front of the
109 STREAM head read queue. */
110#define S_ERROR 0x0010 /* Notification of an error condition. */
111#define S_HANGUP 0x0020 /* Notification of a hangup. */
112#define S_RDNORM 0x0040 /* A normal message has arrived. */
113#define S_WRNORM S_OUTPUT
114#define S_RDBAND 0x0080 /* A message with a non-zero priority has
115 arrived. */
116#define S_WRBAND 0x0100 /* The write queue for a non-zero priority
117 band is no longer full. */
118#define S_BANDURG 0x0200 /* When used in conjunction with S_RDBAND,
119 SIGURG is generated instead of SIGPOLL when
120 a priority message reaches the front of the
121 STREAM head read queue. */
122
123/* Option for `I_PEEK'. */
124#define RS_HIPRI 0x01 /* Only look for high-priority messages. */
125
126/* Options for `I_SRDOPT'. */
127#define RNORM 0x0000 /* Byte-STREAM mode, the default. */
128#define RMSGD 0x0001 /* Message-discard mode. */
129#define RMSGN 0x0002 /* Message-nondiscard mode. */
130#define RPROTDAT 0x0004 /* Deliver the control part of a message as
131 data. */
132#define RPROTDIS 0x0008 /* Discard the control part of a message,
133 delivering any data part. */
134#define RPROTNORM 0x0010 /* Fail `read' with EBADMSG if a message
135 containing a control part is at the front
136 of the STREAM head read queue. */
137#ifdef __USE_GNU
138# define RPROTMASK 0x001C /* The RPROT bits */
139#endif
140
141/* Possible mode for `I_SWROPT'. */
142#define SNDZERO 0x001 /* Send a zero-length message downstream when a
143 `write' of 0 bytes occurs. */
144#ifdef __USE_GNU
145# define SNDPIPE 0x002 /* Send SIGPIPE on write and putmsg if
146 sd_werror is set. */
147#endif
148
149/* Arguments for `I_ATMARK'. */
150#define ANYMARK 0x01 /* Check if the message is marked. */
151#define LASTMARK 0x02 /* Check if the message is the last one marked
152 on the queue. */
153
154/* Argument for `I_UNLINK'. */
155#ifdef __USE_GNU
156# define MUXID_ALL (-1) /* Unlink all STREAMs linked to the STREAM
157 associated with `fildes'. */
158#endif
159
160
161/* Macros for `getmsg', `getpmsg', `putmsg' and `putpmsg'. */
162#define MSG_HIPRI 0x01 /* Send/receive high priority message. */
163#define MSG_ANY 0x02 /* Receive any message. */
164#define MSG_BAND 0x04 /* Receive message from specified band. */
165
166/* Values returned by getmsg and getpmsg */
167#define MORECTL 1 /* More control information is left in
168 message. */
169#define MOREDATA 2 /* More data is left in message. */
170
171
172/* Structure used for the I_FLUSHBAND ioctl on streams. */
173struct bandinfo
174 {
175 unsigned char bi_pri;
176 int bi_flag;
177 };
178
179struct strbuf
180 {
181 int maxlen; /* Maximum buffer length. */
182 int len; /* Length of data. */
183 char *buf; /* Pointer to buffer. */
184 };
185
186struct strpeek
187 {
188 struct strbuf ctlbuf;
189 struct strbuf databuf;
190 t_uscalar_t flags; /* UnixWare/Solaris compatibility. */
191 };
192
193struct strfdinsert
194 {
195 struct strbuf ctlbuf;
196 struct strbuf databuf;
197 t_uscalar_t flags; /* UnixWare/Solaris compatibility. */
198 int fildes;
199 int offset;
200 };
201
202struct strioctl
203 {
204 int ic_cmd;
205 int ic_timout;
206 int ic_len;
207 char *ic_dp;
208 };
209
210struct strrecvfd
211 {
212 int fd;
213 uid_t uid;
214 gid_t gid;
215 char __fill[8]; /* UnixWare/Solaris compatibility */
216 };
217
218
219struct str_mlist
220 {
221 char l_name[FMNAMESZ + 1];
222 };
223
224struct str_list
225 {
226 int sl_nmods;
227 struct str_mlist *sl_modlist;
228 };
229
230#endif /* bits/stropts.h */
libc/glibc-include/bits/sys_errlist.h created+32
...@@ -0,0 +1,32 @@
1/* Declare sys_errlist and sys_nerr, or don't. Compatibility (do) version.
2 Copyright (C) 2002-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _STDIO_H
20# error "Never include <bits/sys_errlist.h> directly; use <stdio.h> instead."
21#endif
22
23/* sys_errlist and sys_nerr are deprecated. Use strerror instead. */
24
25#ifdef __USE_MISC
26extern int sys_nerr;
27extern const char *const sys_errlist[];
28#endif
29#ifdef __USE_GNU
30extern int _sys_nerr;
31extern const char *const _sys_errlist[];
32#endif
libc/glibc-include/bits/syscall.h created+2321
...@@ -0,0 +1,2321 @@
1/* Generated at libc build time from syscall list. */
2/* The system call list corresponds to kernel 4.20. */
3
4#ifndef _SYSCALL_H
5# error "Never use <bits/syscall.h> directly; include <sys/syscall.h> instead."
6#endif
7
8#define __GLIBC_LINUX_VERSION_CODE 267264
9
10#ifdef __NR_FAST_atomic_update
11# define SYS_FAST_atomic_update __NR_FAST_atomic_update
12#endif
13
14#ifdef __NR_FAST_cmpxchg
15# define SYS_FAST_cmpxchg __NR_FAST_cmpxchg
16#endif
17
18#ifdef __NR_FAST_cmpxchg64
19# define SYS_FAST_cmpxchg64 __NR_FAST_cmpxchg64
20#endif
21
22#ifdef __NR__llseek
23# define SYS__llseek __NR__llseek
24#endif
25
26#ifdef __NR__newselect
27# define SYS__newselect __NR__newselect
28#endif
29
30#ifdef __NR__sysctl
31# define SYS__sysctl __NR__sysctl
32#endif
33
34#ifdef __NR_accept
35# define SYS_accept __NR_accept
36#endif
37
38#ifdef __NR_accept4
39# define SYS_accept4 __NR_accept4
40#endif
41
42#ifdef __NR_access
43# define SYS_access __NR_access
44#endif
45
46#ifdef __NR_acct
47# define SYS_acct __NR_acct
48#endif
49
50#ifdef __NR_acl_get
51# define SYS_acl_get __NR_acl_get
52#endif
53
54#ifdef __NR_acl_set
55# define SYS_acl_set __NR_acl_set
56#endif
57
58#ifdef __NR_add_key
59# define SYS_add_key __NR_add_key
60#endif
61
62#ifdef __NR_adjtimex
63# define SYS_adjtimex __NR_adjtimex
64#endif
65
66#ifdef __NR_afs_syscall
67# define SYS_afs_syscall __NR_afs_syscall
68#endif
69
70#ifdef __NR_alarm
71# define SYS_alarm __NR_alarm
72#endif
73
74#ifdef __NR_alloc_hugepages
75# define SYS_alloc_hugepages __NR_alloc_hugepages
76#endif
77
78#ifdef __NR_arch_prctl
79# define SYS_arch_prctl __NR_arch_prctl
80#endif
81
82#ifdef __NR_arm_fadvise64_64
83# define SYS_arm_fadvise64_64 __NR_arm_fadvise64_64
84#endif
85
86#ifdef __NR_arm_sync_file_range
87# define SYS_arm_sync_file_range __NR_arm_sync_file_range
88#endif
89
90#ifdef __NR_atomic_barrier
91# define SYS_atomic_barrier __NR_atomic_barrier
92#endif
93
94#ifdef __NR_atomic_cmpxchg_32
95# define SYS_atomic_cmpxchg_32 __NR_atomic_cmpxchg_32
96#endif
97
98#ifdef __NR_attrctl
99# define SYS_attrctl __NR_attrctl
100#endif
101
102#ifdef __NR_bdflush
103# define SYS_bdflush __NR_bdflush
104#endif
105
106#ifdef __NR_bind
107# define SYS_bind __NR_bind
108#endif
109
110#ifdef __NR_bpf
111# define SYS_bpf __NR_bpf
112#endif
113
114#ifdef __NR_break
115# define SYS_break __NR_break
116#endif
117
118#ifdef __NR_brk
119# define SYS_brk __NR_brk
120#endif
121
122#ifdef __NR_cachectl
123# define SYS_cachectl __NR_cachectl
124#endif
125
126#ifdef __NR_cacheflush
127# define SYS_cacheflush __NR_cacheflush
128#endif
129
130#ifdef __NR_capget
131# define SYS_capget __NR_capget
132#endif
133
134#ifdef __NR_capset
135# define SYS_capset __NR_capset
136#endif
137
138#ifdef __NR_chdir
139# define SYS_chdir __NR_chdir
140#endif
141
142#ifdef __NR_chmod
143# define SYS_chmod __NR_chmod
144#endif
145
146#ifdef __NR_chown
147# define SYS_chown __NR_chown
148#endif
149
150#ifdef __NR_chown32
151# define SYS_chown32 __NR_chown32
152#endif
153
154#ifdef __NR_chroot
155# define SYS_chroot __NR_chroot
156#endif
157
158#ifdef __NR_clock_adjtime
159# define SYS_clock_adjtime __NR_clock_adjtime
160#endif
161
162#ifdef __NR_clock_getres
163# define SYS_clock_getres __NR_clock_getres
164#endif
165
166#ifdef __NR_clock_gettime
167# define SYS_clock_gettime __NR_clock_gettime
168#endif
169
170#ifdef __NR_clock_nanosleep
171# define SYS_clock_nanosleep __NR_clock_nanosleep
172#endif
173
174#ifdef __NR_clock_settime
175# define SYS_clock_settime __NR_clock_settime
176#endif
177
178#ifdef __NR_clone
179# define SYS_clone __NR_clone
180#endif
181
182#ifdef __NR_clone2
183# define SYS_clone2 __NR_clone2
184#endif
185
186#ifdef __NR_close
187# define SYS_close __NR_close
188#endif
189
190#ifdef __NR_cmpxchg_badaddr
191# define SYS_cmpxchg_badaddr __NR_cmpxchg_badaddr
192#endif
193
194#ifdef __NR_connect
195# define SYS_connect __NR_connect
196#endif
197
198#ifdef __NR_copy_file_range
199# define SYS_copy_file_range __NR_copy_file_range
200#endif
201
202#ifdef __NR_creat
203# define SYS_creat __NR_creat
204#endif
205
206#ifdef __NR_create_module
207# define SYS_create_module __NR_create_module
208#endif
209
210#ifdef __NR_delete_module
211# define SYS_delete_module __NR_delete_module
212#endif
213
214#ifdef __NR_dipc
215# define SYS_dipc __NR_dipc
216#endif
217
218#ifdef __NR_dup
219# define SYS_dup __NR_dup
220#endif
221
222#ifdef __NR_dup2
223# define SYS_dup2 __NR_dup2
224#endif
225
226#ifdef __NR_dup3
227# define SYS_dup3 __NR_dup3
228#endif
229
230#ifdef __NR_epoll_create
231# define SYS_epoll_create __NR_epoll_create
232#endif
233
234#ifdef __NR_epoll_create1
235# define SYS_epoll_create1 __NR_epoll_create1
236#endif
237
238#ifdef __NR_epoll_ctl
239# define SYS_epoll_ctl __NR_epoll_ctl
240#endif
241
242#ifdef __NR_epoll_ctl_old
243# define SYS_epoll_ctl_old __NR_epoll_ctl_old
244#endif
245
246#ifdef __NR_epoll_pwait
247# define SYS_epoll_pwait __NR_epoll_pwait
248#endif
249
250#ifdef __NR_epoll_wait
251# define SYS_epoll_wait __NR_epoll_wait
252#endif
253
254#ifdef __NR_epoll_wait_old
255# define SYS_epoll_wait_old __NR_epoll_wait_old
256#endif
257
258#ifdef __NR_eventfd
259# define SYS_eventfd __NR_eventfd
260#endif
261
262#ifdef __NR_eventfd2
263# define SYS_eventfd2 __NR_eventfd2
264#endif
265
266#ifdef __NR_exec_with_loader
267# define SYS_exec_with_loader __NR_exec_with_loader
268#endif
269
270#ifdef __NR_execv
271# define SYS_execv __NR_execv
272#endif
273
274#ifdef __NR_execve
275# define SYS_execve __NR_execve
276#endif
277
278#ifdef __NR_execveat
279# define SYS_execveat __NR_execveat
280#endif
281
282#ifdef __NR_exit
283# define SYS_exit __NR_exit
284#endif
285
286#ifdef __NR_exit_group
287# define SYS_exit_group __NR_exit_group
288#endif
289
290#ifdef __NR_faccessat
291# define SYS_faccessat __NR_faccessat
292#endif
293
294#ifdef __NR_fadvise64
295# define SYS_fadvise64 __NR_fadvise64
296#endif
297
298#ifdef __NR_fadvise64_64
299# define SYS_fadvise64_64 __NR_fadvise64_64
300#endif
301
302#ifdef __NR_fallocate
303# define SYS_fallocate __NR_fallocate
304#endif
305
306#ifdef __NR_fanotify_init
307# define SYS_fanotify_init __NR_fanotify_init
308#endif
309
310#ifdef __NR_fanotify_mark
311# define SYS_fanotify_mark __NR_fanotify_mark
312#endif
313
314#ifdef __NR_fchdir
315# define SYS_fchdir __NR_fchdir
316#endif
317
318#ifdef __NR_fchmod
319# define SYS_fchmod __NR_fchmod
320#endif
321
322#ifdef __NR_fchmodat
323# define SYS_fchmodat __NR_fchmodat
324#endif
325
326#ifdef __NR_fchown
327# define SYS_fchown __NR_fchown
328#endif
329
330#ifdef __NR_fchown32
331# define SYS_fchown32 __NR_fchown32
332#endif
333
334#ifdef __NR_fchownat
335# define SYS_fchownat __NR_fchownat
336#endif
337
338#ifdef __NR_fcntl
339# define SYS_fcntl __NR_fcntl
340#endif
341
342#ifdef __NR_fcntl64
343# define SYS_fcntl64 __NR_fcntl64
344#endif
345
346#ifdef __NR_fdatasync
347# define SYS_fdatasync __NR_fdatasync
348#endif
349
350#ifdef __NR_fgetxattr
351# define SYS_fgetxattr __NR_fgetxattr
352#endif
353
354#ifdef __NR_finit_module
355# define SYS_finit_module __NR_finit_module
356#endif
357
358#ifdef __NR_flistxattr
359# define SYS_flistxattr __NR_flistxattr
360#endif
361
362#ifdef __NR_flock
363# define SYS_flock __NR_flock
364#endif
365
366#ifdef __NR_fork
367# define SYS_fork __NR_fork
368#endif
369
370#ifdef __NR_free_hugepages
371# define SYS_free_hugepages __NR_free_hugepages
372#endif
373
374#ifdef __NR_fremovexattr
375# define SYS_fremovexattr __NR_fremovexattr
376#endif
377
378#ifdef __NR_fsetxattr
379# define SYS_fsetxattr __NR_fsetxattr
380#endif
381
382#ifdef __NR_fstat
383# define SYS_fstat __NR_fstat
384#endif
385
386#ifdef __NR_fstat64
387# define SYS_fstat64 __NR_fstat64
388#endif
389
390#ifdef __NR_fstatat64
391# define SYS_fstatat64 __NR_fstatat64
392#endif
393
394#ifdef __NR_fstatfs
395# define SYS_fstatfs __NR_fstatfs
396#endif
397
398#ifdef __NR_fstatfs64
399# define SYS_fstatfs64 __NR_fstatfs64
400#endif
401
402#ifdef __NR_fsync
403# define SYS_fsync __NR_fsync
404#endif
405
406#ifdef __NR_ftime
407# define SYS_ftime __NR_ftime
408#endif
409
410#ifdef __NR_ftruncate
411# define SYS_ftruncate __NR_ftruncate
412#endif
413
414#ifdef __NR_ftruncate64
415# define SYS_ftruncate64 __NR_ftruncate64
416#endif
417
418#ifdef __NR_futex
419# define SYS_futex __NR_futex
420#endif
421
422#ifdef __NR_futimesat
423# define SYS_futimesat __NR_futimesat
424#endif
425
426#ifdef __NR_get_kernel_syms
427# define SYS_get_kernel_syms __NR_get_kernel_syms
428#endif
429
430#ifdef __NR_get_mempolicy
431# define SYS_get_mempolicy __NR_get_mempolicy
432#endif
433
434#ifdef __NR_get_robust_list
435# define SYS_get_robust_list __NR_get_robust_list
436#endif
437
438#ifdef __NR_get_thread_area
439# define SYS_get_thread_area __NR_get_thread_area
440#endif
441
442#ifdef __NR_getcpu
443# define SYS_getcpu __NR_getcpu
444#endif
445
446#ifdef __NR_getcwd
447# define SYS_getcwd __NR_getcwd
448#endif
449
450#ifdef __NR_getdents
451# define SYS_getdents __NR_getdents
452#endif
453
454#ifdef __NR_getdents64
455# define SYS_getdents64 __NR_getdents64
456#endif
457
458#ifdef __NR_getdomainname
459# define SYS_getdomainname __NR_getdomainname
460#endif
461
462#ifdef __NR_getdtablesize
463# define SYS_getdtablesize __NR_getdtablesize
464#endif
465
466#ifdef __NR_getegid
467# define SYS_getegid __NR_getegid
468#endif
469
470#ifdef __NR_getegid32
471# define SYS_getegid32 __NR_getegid32
472#endif
473
474#ifdef __NR_geteuid
475# define SYS_geteuid __NR_geteuid
476#endif
477
478#ifdef __NR_geteuid32
479# define SYS_geteuid32 __NR_geteuid32
480#endif
481
482#ifdef __NR_getgid
483# define SYS_getgid __NR_getgid
484#endif
485
486#ifdef __NR_getgid32
487# define SYS_getgid32 __NR_getgid32
488#endif
489
490#ifdef __NR_getgroups
491# define SYS_getgroups __NR_getgroups
492#endif
493
494#ifdef __NR_getgroups32
495# define SYS_getgroups32 __NR_getgroups32
496#endif
497
498#ifdef __NR_gethostname
499# define SYS_gethostname __NR_gethostname
500#endif
501
502#ifdef __NR_getitimer
503# define SYS_getitimer __NR_getitimer
504#endif
505
506#ifdef __NR_getpagesize
507# define SYS_getpagesize __NR_getpagesize
508#endif
509
510#ifdef __NR_getpeername
511# define SYS_getpeername __NR_getpeername
512#endif
513
514#ifdef __NR_getpgid
515# define SYS_getpgid __NR_getpgid
516#endif
517
518#ifdef __NR_getpgrp
519# define SYS_getpgrp __NR_getpgrp
520#endif
521
522#ifdef __NR_getpid
523# define SYS_getpid __NR_getpid
524#endif
525
526#ifdef __NR_getpmsg
527# define SYS_getpmsg __NR_getpmsg
528#endif
529
530#ifdef __NR_getppid
531# define SYS_getppid __NR_getppid
532#endif
533
534#ifdef __NR_getpriority
535# define SYS_getpriority __NR_getpriority
536#endif
537
538#ifdef __NR_getrandom
539# define SYS_getrandom __NR_getrandom
540#endif
541
542#ifdef __NR_getresgid
543# define SYS_getresgid __NR_getresgid
544#endif
545
546#ifdef __NR_getresgid32
547# define SYS_getresgid32 __NR_getresgid32
548#endif
549
550#ifdef __NR_getresuid
551# define SYS_getresuid __NR_getresuid
552#endif
553
554#ifdef __NR_getresuid32
555# define SYS_getresuid32 __NR_getresuid32
556#endif
557
558#ifdef __NR_getrlimit
559# define SYS_getrlimit __NR_getrlimit
560#endif
561
562#ifdef __NR_getrusage
563# define SYS_getrusage __NR_getrusage
564#endif
565
566#ifdef __NR_getsid
567# define SYS_getsid __NR_getsid
568#endif
569
570#ifdef __NR_getsockname
571# define SYS_getsockname __NR_getsockname
572#endif
573
574#ifdef __NR_getsockopt
575# define SYS_getsockopt __NR_getsockopt
576#endif
577
578#ifdef __NR_gettid
579# define SYS_gettid __NR_gettid
580#endif
581
582#ifdef __NR_gettimeofday
583# define SYS_gettimeofday __NR_gettimeofday
584#endif
585
586#ifdef __NR_getuid
587# define SYS_getuid __NR_getuid
588#endif
589
590#ifdef __NR_getuid32
591# define SYS_getuid32 __NR_getuid32
592#endif
593
594#ifdef __NR_getunwind
595# define SYS_getunwind __NR_getunwind
596#endif
597
598#ifdef __NR_getxattr
599# define SYS_getxattr __NR_getxattr
600#endif
601
602#ifdef __NR_getxgid
603# define SYS_getxgid __NR_getxgid
604#endif
605
606#ifdef __NR_getxpid
607# define SYS_getxpid __NR_getxpid
608#endif
609
610#ifdef __NR_getxuid
611# define SYS_getxuid __NR_getxuid
612#endif
613
614#ifdef __NR_gtty
615# define SYS_gtty __NR_gtty
616#endif
617
618#ifdef __NR_idle
619# define SYS_idle __NR_idle
620#endif
621
622#ifdef __NR_init_module
623# define SYS_init_module __NR_init_module
624#endif
625
626#ifdef __NR_inotify_add_watch
627# define SYS_inotify_add_watch __NR_inotify_add_watch
628#endif
629
630#ifdef __NR_inotify_init
631# define SYS_inotify_init __NR_inotify_init
632#endif
633
634#ifdef __NR_inotify_init1
635# define SYS_inotify_init1 __NR_inotify_init1
636#endif
637
638#ifdef __NR_inotify_rm_watch
639# define SYS_inotify_rm_watch __NR_inotify_rm_watch
640#endif
641
642#ifdef __NR_io_cancel
643# define SYS_io_cancel __NR_io_cancel
644#endif
645
646#ifdef __NR_io_destroy
647# define SYS_io_destroy __NR_io_destroy
648#endif
649
650#ifdef __NR_io_getevents
651# define SYS_io_getevents __NR_io_getevents
652#endif
653
654#ifdef __NR_io_pgetevents
655# define SYS_io_pgetevents __NR_io_pgetevents
656#endif
657
658#ifdef __NR_io_setup
659# define SYS_io_setup __NR_io_setup
660#endif
661
662#ifdef __NR_io_submit
663# define SYS_io_submit __NR_io_submit
664#endif
665
666#ifdef __NR_ioctl
667# define SYS_ioctl __NR_ioctl
668#endif
669
670#ifdef __NR_ioperm
671# define SYS_ioperm __NR_ioperm
672#endif
673
674#ifdef __NR_iopl
675# define SYS_iopl __NR_iopl
676#endif
677
678#ifdef __NR_ioprio_get
679# define SYS_ioprio_get __NR_ioprio_get
680#endif
681
682#ifdef __NR_ioprio_set
683# define SYS_ioprio_set __NR_ioprio_set
684#endif
685
686#ifdef __NR_ipc
687# define SYS_ipc __NR_ipc
688#endif
689
690#ifdef __NR_kcmp
691# define SYS_kcmp __NR_kcmp
692#endif
693
694#ifdef __NR_kern_features
695# define SYS_kern_features __NR_kern_features
696#endif
697
698#ifdef __NR_kexec_file_load
699# define SYS_kexec_file_load __NR_kexec_file_load
700#endif
701
702#ifdef __NR_kexec_load
703# define SYS_kexec_load __NR_kexec_load
704#endif
705
706#ifdef __NR_keyctl
707# define SYS_keyctl __NR_keyctl
708#endif
709
710#ifdef __NR_kill
711# define SYS_kill __NR_kill
712#endif
713
714#ifdef __NR_lchown
715# define SYS_lchown __NR_lchown
716#endif
717
718#ifdef __NR_lchown32
719# define SYS_lchown32 __NR_lchown32
720#endif
721
722#ifdef __NR_lgetxattr
723# define SYS_lgetxattr __NR_lgetxattr
724#endif
725
726#ifdef __NR_link
727# define SYS_link __NR_link
728#endif
729
730#ifdef __NR_linkat
731# define SYS_linkat __NR_linkat
732#endif
733
734#ifdef __NR_listen
735# define SYS_listen __NR_listen
736#endif
737
738#ifdef __NR_listxattr
739# define SYS_listxattr __NR_listxattr
740#endif
741
742#ifdef __NR_llistxattr
743# define SYS_llistxattr __NR_llistxattr
744#endif
745
746#ifdef __NR_llseek
747# define SYS_llseek __NR_llseek
748#endif
749
750#ifdef __NR_lock
751# define SYS_lock __NR_lock
752#endif
753
754#ifdef __NR_lookup_dcookie
755# define SYS_lookup_dcookie __NR_lookup_dcookie
756#endif
757
758#ifdef __NR_lremovexattr
759# define SYS_lremovexattr __NR_lremovexattr
760#endif
761
762#ifdef __NR_lseek
763# define SYS_lseek __NR_lseek
764#endif
765
766#ifdef __NR_lsetxattr
767# define SYS_lsetxattr __NR_lsetxattr
768#endif
769
770#ifdef __NR_lstat
771# define SYS_lstat __NR_lstat
772#endif
773
774#ifdef __NR_lstat64
775# define SYS_lstat64 __NR_lstat64
776#endif
777
778#ifdef __NR_madvise
779# define SYS_madvise __NR_madvise
780#endif
781
782#ifdef __NR_mbind
783# define SYS_mbind __NR_mbind
784#endif
785
786#ifdef __NR_membarrier
787# define SYS_membarrier __NR_membarrier
788#endif
789
790#ifdef __NR_memfd_create
791# define SYS_memfd_create __NR_memfd_create
792#endif
793
794#ifdef __NR_memory_ordering
795# define SYS_memory_ordering __NR_memory_ordering
796#endif
797
798#ifdef __NR_migrate_pages
799# define SYS_migrate_pages __NR_migrate_pages
800#endif
801
802#ifdef __NR_mincore
803# define SYS_mincore __NR_mincore
804#endif
805
806#ifdef __NR_mkdir
807# define SYS_mkdir __NR_mkdir
808#endif
809
810#ifdef __NR_mkdirat
811# define SYS_mkdirat __NR_mkdirat
812#endif
813
814#ifdef __NR_mknod
815# define SYS_mknod __NR_mknod
816#endif
817
818#ifdef __NR_mknodat
819# define SYS_mknodat __NR_mknodat
820#endif
821
822#ifdef __NR_mlock
823# define SYS_mlock __NR_mlock
824#endif
825
826#ifdef __NR_mlock2
827# define SYS_mlock2 __NR_mlock2
828#endif
829
830#ifdef __NR_mlockall
831# define SYS_mlockall __NR_mlockall
832#endif
833
834#ifdef __NR_mmap
835# define SYS_mmap __NR_mmap
836#endif
837
838#ifdef __NR_mmap2
839# define SYS_mmap2 __NR_mmap2
840#endif
841
842#ifdef __NR_modify_ldt
843# define SYS_modify_ldt __NR_modify_ldt
844#endif
845
846#ifdef __NR_mount
847# define SYS_mount __NR_mount
848#endif
849
850#ifdef __NR_move_pages
851# define SYS_move_pages __NR_move_pages
852#endif
853
854#ifdef __NR_mprotect
855# define SYS_mprotect __NR_mprotect
856#endif
857
858#ifdef __NR_mpx
859# define SYS_mpx __NR_mpx
860#endif
861
862#ifdef __NR_mq_getsetattr
863# define SYS_mq_getsetattr __NR_mq_getsetattr
864#endif
865
866#ifdef __NR_mq_notify
867# define SYS_mq_notify __NR_mq_notify
868#endif
869
870#ifdef __NR_mq_open
871# define SYS_mq_open __NR_mq_open
872#endif
873
874#ifdef __NR_mq_timedreceive
875# define SYS_mq_timedreceive __NR_mq_timedreceive
876#endif
877
878#ifdef __NR_mq_timedsend
879# define SYS_mq_timedsend __NR_mq_timedsend
880#endif
881
882#ifdef __NR_mq_unlink
883# define SYS_mq_unlink __NR_mq_unlink
884#endif
885
886#ifdef __NR_mremap
887# define SYS_mremap __NR_mremap
888#endif
889
890#ifdef __NR_msgctl
891# define SYS_msgctl __NR_msgctl
892#endif
893
894#ifdef __NR_msgget
895# define SYS_msgget __NR_msgget
896#endif
897
898#ifdef __NR_msgrcv
899# define SYS_msgrcv __NR_msgrcv
900#endif
901
902#ifdef __NR_msgsnd
903# define SYS_msgsnd __NR_msgsnd
904#endif
905
906#ifdef __NR_msync
907# define SYS_msync __NR_msync
908#endif
909
910#ifdef __NR_multiplexer
911# define SYS_multiplexer __NR_multiplexer
912#endif
913
914#ifdef __NR_munlock
915# define SYS_munlock __NR_munlock
916#endif
917
918#ifdef __NR_munlockall
919# define SYS_munlockall __NR_munlockall
920#endif
921
922#ifdef __NR_munmap
923# define SYS_munmap __NR_munmap
924#endif
925
926#ifdef __NR_name_to_handle_at
927# define SYS_name_to_handle_at __NR_name_to_handle_at
928#endif
929
930#ifdef __NR_nanosleep
931# define SYS_nanosleep __NR_nanosleep
932#endif
933
934#ifdef __NR_newfstatat
935# define SYS_newfstatat __NR_newfstatat
936#endif
937
938#ifdef __NR_nfsservctl
939# define SYS_nfsservctl __NR_nfsservctl
940#endif
941
942#ifdef __NR_ni_syscall
943# define SYS_ni_syscall __NR_ni_syscall
944#endif
945
946#ifdef __NR_nice
947# define SYS_nice __NR_nice
948#endif
949
950#ifdef __NR_old_adjtimex
951# define SYS_old_adjtimex __NR_old_adjtimex
952#endif
953
954#ifdef __NR_oldfstat
955# define SYS_oldfstat __NR_oldfstat
956#endif
957
958#ifdef __NR_oldlstat
959# define SYS_oldlstat __NR_oldlstat
960#endif
961
962#ifdef __NR_oldolduname
963# define SYS_oldolduname __NR_oldolduname
964#endif
965
966#ifdef __NR_oldstat
967# define SYS_oldstat __NR_oldstat
968#endif
969
970#ifdef __NR_oldumount
971# define SYS_oldumount __NR_oldumount
972#endif
973
974#ifdef __NR_olduname
975# define SYS_olduname __NR_olduname
976#endif
977
978#ifdef __NR_open
979# define SYS_open __NR_open
980#endif
981
982#ifdef __NR_open_by_handle_at
983# define SYS_open_by_handle_at __NR_open_by_handle_at
984#endif
985
986#ifdef __NR_openat
987# define SYS_openat __NR_openat
988#endif
989
990#ifdef __NR_osf_adjtime
991# define SYS_osf_adjtime __NR_osf_adjtime
992#endif
993
994#ifdef __NR_osf_afs_syscall
995# define SYS_osf_afs_syscall __NR_osf_afs_syscall
996#endif
997
998#ifdef __NR_osf_alt_plock
999# define SYS_osf_alt_plock __NR_osf_alt_plock
1000#endif
1001
1002#ifdef __NR_osf_alt_setsid
1003# define SYS_osf_alt_setsid __NR_osf_alt_setsid
1004#endif
1005
1006#ifdef __NR_osf_alt_sigpending
1007# define SYS_osf_alt_sigpending __NR_osf_alt_sigpending
1008#endif
1009
1010#ifdef __NR_osf_asynch_daemon
1011# define SYS_osf_asynch_daemon __NR_osf_asynch_daemon
1012#endif
1013
1014#ifdef __NR_osf_audcntl
1015# define SYS_osf_audcntl __NR_osf_audcntl
1016#endif
1017
1018#ifdef __NR_osf_audgen
1019# define SYS_osf_audgen __NR_osf_audgen
1020#endif
1021
1022#ifdef __NR_osf_chflags
1023# define SYS_osf_chflags __NR_osf_chflags
1024#endif
1025
1026#ifdef __NR_osf_execve
1027# define SYS_osf_execve __NR_osf_execve
1028#endif
1029
1030#ifdef __NR_osf_exportfs
1031# define SYS_osf_exportfs __NR_osf_exportfs
1032#endif
1033
1034#ifdef __NR_osf_fchflags
1035# define SYS_osf_fchflags __NR_osf_fchflags
1036#endif
1037
1038#ifdef __NR_osf_fdatasync
1039# define SYS_osf_fdatasync __NR_osf_fdatasync
1040#endif
1041
1042#ifdef __NR_osf_fpathconf
1043# define SYS_osf_fpathconf __NR_osf_fpathconf
1044#endif
1045
1046#ifdef __NR_osf_fstat
1047# define SYS_osf_fstat __NR_osf_fstat
1048#endif
1049
1050#ifdef __NR_osf_fstatfs
1051# define SYS_osf_fstatfs __NR_osf_fstatfs
1052#endif
1053
1054#ifdef __NR_osf_fstatfs64
1055# define SYS_osf_fstatfs64 __NR_osf_fstatfs64
1056#endif
1057
1058#ifdef __NR_osf_fuser
1059# define SYS_osf_fuser __NR_osf_fuser
1060#endif
1061
1062#ifdef __NR_osf_getaddressconf
1063# define SYS_osf_getaddressconf __NR_osf_getaddressconf
1064#endif
1065
1066#ifdef __NR_osf_getdirentries
1067# define SYS_osf_getdirentries __NR_osf_getdirentries
1068#endif
1069
1070#ifdef __NR_osf_getdomainname
1071# define SYS_osf_getdomainname __NR_osf_getdomainname
1072#endif
1073
1074#ifdef __NR_osf_getfh
1075# define SYS_osf_getfh __NR_osf_getfh
1076#endif
1077
1078#ifdef __NR_osf_getfsstat
1079# define SYS_osf_getfsstat __NR_osf_getfsstat
1080#endif
1081
1082#ifdef __NR_osf_gethostid
1083# define SYS_osf_gethostid __NR_osf_gethostid
1084#endif
1085
1086#ifdef __NR_osf_getitimer
1087# define SYS_osf_getitimer __NR_osf_getitimer
1088#endif
1089
1090#ifdef __NR_osf_getlogin
1091# define SYS_osf_getlogin __NR_osf_getlogin
1092#endif
1093
1094#ifdef __NR_osf_getmnt
1095# define SYS_osf_getmnt __NR_osf_getmnt
1096#endif
1097
1098#ifdef __NR_osf_getrusage
1099# define SYS_osf_getrusage __NR_osf_getrusage
1100#endif
1101
1102#ifdef __NR_osf_getsysinfo
1103# define SYS_osf_getsysinfo __NR_osf_getsysinfo
1104#endif
1105
1106#ifdef __NR_osf_gettimeofday
1107# define SYS_osf_gettimeofday __NR_osf_gettimeofday
1108#endif
1109
1110#ifdef __NR_osf_kloadcall
1111# define SYS_osf_kloadcall __NR_osf_kloadcall
1112#endif
1113
1114#ifdef __NR_osf_kmodcall
1115# define SYS_osf_kmodcall __NR_osf_kmodcall
1116#endif
1117
1118#ifdef __NR_osf_lstat
1119# define SYS_osf_lstat __NR_osf_lstat
1120#endif
1121
1122#ifdef __NR_osf_memcntl
1123# define SYS_osf_memcntl __NR_osf_memcntl
1124#endif
1125
1126#ifdef __NR_osf_mincore
1127# define SYS_osf_mincore __NR_osf_mincore
1128#endif
1129
1130#ifdef __NR_osf_mount
1131# define SYS_osf_mount __NR_osf_mount
1132#endif
1133
1134#ifdef __NR_osf_mremap
1135# define SYS_osf_mremap __NR_osf_mremap
1136#endif
1137
1138#ifdef __NR_osf_msfs_syscall
1139# define SYS_osf_msfs_syscall __NR_osf_msfs_syscall
1140#endif
1141
1142#ifdef __NR_osf_msleep
1143# define SYS_osf_msleep __NR_osf_msleep
1144#endif
1145
1146#ifdef __NR_osf_mvalid
1147# define SYS_osf_mvalid __NR_osf_mvalid
1148#endif
1149
1150#ifdef __NR_osf_mwakeup
1151# define SYS_osf_mwakeup __NR_osf_mwakeup
1152#endif
1153
1154#ifdef __NR_osf_naccept
1155# define SYS_osf_naccept __NR_osf_naccept
1156#endif
1157
1158#ifdef __NR_osf_nfssvc
1159# define SYS_osf_nfssvc __NR_osf_nfssvc
1160#endif
1161
1162#ifdef __NR_osf_ngetpeername
1163# define SYS_osf_ngetpeername __NR_osf_ngetpeername
1164#endif
1165
1166#ifdef __NR_osf_ngetsockname
1167# define SYS_osf_ngetsockname __NR_osf_ngetsockname
1168#endif
1169
1170#ifdef __NR_osf_nrecvfrom
1171# define SYS_osf_nrecvfrom __NR_osf_nrecvfrom
1172#endif
1173
1174#ifdef __NR_osf_nrecvmsg
1175# define SYS_osf_nrecvmsg __NR_osf_nrecvmsg
1176#endif
1177
1178#ifdef __NR_osf_nsendmsg
1179# define SYS_osf_nsendmsg __NR_osf_nsendmsg
1180#endif
1181
1182#ifdef __NR_osf_ntp_adjtime
1183# define SYS_osf_ntp_adjtime __NR_osf_ntp_adjtime
1184#endif
1185
1186#ifdef __NR_osf_ntp_gettime
1187# define SYS_osf_ntp_gettime __NR_osf_ntp_gettime
1188#endif
1189
1190#ifdef __NR_osf_old_creat
1191# define SYS_osf_old_creat __NR_osf_old_creat
1192#endif
1193
1194#ifdef __NR_osf_old_fstat
1195# define SYS_osf_old_fstat __NR_osf_old_fstat
1196#endif
1197
1198#ifdef __NR_osf_old_getpgrp
1199# define SYS_osf_old_getpgrp __NR_osf_old_getpgrp
1200#endif
1201
1202#ifdef __NR_osf_old_killpg
1203# define SYS_osf_old_killpg __NR_osf_old_killpg
1204#endif
1205
1206#ifdef __NR_osf_old_lstat
1207# define SYS_osf_old_lstat __NR_osf_old_lstat
1208#endif
1209
1210#ifdef __NR_osf_old_open
1211# define SYS_osf_old_open __NR_osf_old_open
1212#endif
1213
1214#ifdef __NR_osf_old_sigaction
1215# define SYS_osf_old_sigaction __NR_osf_old_sigaction
1216#endif
1217
1218#ifdef __NR_osf_old_sigblock
1219# define SYS_osf_old_sigblock __NR_osf_old_sigblock
1220#endif
1221
1222#ifdef __NR_osf_old_sigreturn
1223# define SYS_osf_old_sigreturn __NR_osf_old_sigreturn
1224#endif
1225
1226#ifdef __NR_osf_old_sigsetmask
1227# define SYS_osf_old_sigsetmask __NR_osf_old_sigsetmask
1228#endif
1229
1230#ifdef __NR_osf_old_sigvec
1231# define SYS_osf_old_sigvec __NR_osf_old_sigvec
1232#endif
1233
1234#ifdef __NR_osf_old_stat
1235# define SYS_osf_old_stat __NR_osf_old_stat
1236#endif
1237
1238#ifdef __NR_osf_old_vadvise
1239# define SYS_osf_old_vadvise __NR_osf_old_vadvise
1240#endif
1241
1242#ifdef __NR_osf_old_vtrace
1243# define SYS_osf_old_vtrace __NR_osf_old_vtrace
1244#endif
1245
1246#ifdef __NR_osf_old_wait
1247# define SYS_osf_old_wait __NR_osf_old_wait
1248#endif
1249
1250#ifdef __NR_osf_oldquota
1251# define SYS_osf_oldquota __NR_osf_oldquota
1252#endif
1253
1254#ifdef __NR_osf_pathconf
1255# define SYS_osf_pathconf __NR_osf_pathconf
1256#endif
1257
1258#ifdef __NR_osf_pid_block
1259# define SYS_osf_pid_block __NR_osf_pid_block
1260#endif
1261
1262#ifdef __NR_osf_pid_unblock
1263# define SYS_osf_pid_unblock __NR_osf_pid_unblock
1264#endif
1265
1266#ifdef __NR_osf_plock
1267# define SYS_osf_plock __NR_osf_plock
1268#endif
1269
1270#ifdef __NR_osf_priocntlset
1271# define SYS_osf_priocntlset __NR_osf_priocntlset
1272#endif
1273
1274#ifdef __NR_osf_profil
1275# define SYS_osf_profil __NR_osf_profil
1276#endif
1277
1278#ifdef __NR_osf_proplist_syscall
1279# define SYS_osf_proplist_syscall __NR_osf_proplist_syscall
1280#endif
1281
1282#ifdef __NR_osf_reboot
1283# define SYS_osf_reboot __NR_osf_reboot
1284#endif
1285
1286#ifdef __NR_osf_revoke
1287# define SYS_osf_revoke __NR_osf_revoke
1288#endif
1289
1290#ifdef __NR_osf_sbrk
1291# define SYS_osf_sbrk __NR_osf_sbrk
1292#endif
1293
1294#ifdef __NR_osf_security
1295# define SYS_osf_security __NR_osf_security
1296#endif
1297
1298#ifdef __NR_osf_select
1299# define SYS_osf_select __NR_osf_select
1300#endif
1301
1302#ifdef __NR_osf_set_program_attributes
1303# define SYS_osf_set_program_attributes __NR_osf_set_program_attributes
1304#endif
1305
1306#ifdef __NR_osf_set_speculative
1307# define SYS_osf_set_speculative __NR_osf_set_speculative
1308#endif
1309
1310#ifdef __NR_osf_sethostid
1311# define SYS_osf_sethostid __NR_osf_sethostid
1312#endif
1313
1314#ifdef __NR_osf_setitimer
1315# define SYS_osf_setitimer __NR_osf_setitimer
1316#endif
1317
1318#ifdef __NR_osf_setlogin
1319# define SYS_osf_setlogin __NR_osf_setlogin
1320#endif
1321
1322#ifdef __NR_osf_setsysinfo
1323# define SYS_osf_setsysinfo __NR_osf_setsysinfo
1324#endif
1325
1326#ifdef __NR_osf_settimeofday
1327# define SYS_osf_settimeofday __NR_osf_settimeofday
1328#endif
1329
1330#ifdef __NR_osf_shmat
1331# define SYS_osf_shmat __NR_osf_shmat
1332#endif
1333
1334#ifdef __NR_osf_signal
1335# define SYS_osf_signal __NR_osf_signal
1336#endif
1337
1338#ifdef __NR_osf_sigprocmask
1339# define SYS_osf_sigprocmask __NR_osf_sigprocmask
1340#endif
1341
1342#ifdef __NR_osf_sigsendset
1343# define SYS_osf_sigsendset __NR_osf_sigsendset
1344#endif
1345
1346#ifdef __NR_osf_sigstack
1347# define SYS_osf_sigstack __NR_osf_sigstack
1348#endif
1349
1350#ifdef __NR_osf_sigwaitprim
1351# define SYS_osf_sigwaitprim __NR_osf_sigwaitprim
1352#endif
1353
1354#ifdef __NR_osf_sstk
1355# define SYS_osf_sstk __NR_osf_sstk
1356#endif
1357
1358#ifdef __NR_osf_stat
1359# define SYS_osf_stat __NR_osf_stat
1360#endif
1361
1362#ifdef __NR_osf_statfs
1363# define SYS_osf_statfs __NR_osf_statfs
1364#endif
1365
1366#ifdef __NR_osf_statfs64
1367# define SYS_osf_statfs64 __NR_osf_statfs64
1368#endif
1369
1370#ifdef __NR_osf_subsys_info
1371# define SYS_osf_subsys_info __NR_osf_subsys_info
1372#endif
1373
1374#ifdef __NR_osf_swapctl
1375# define SYS_osf_swapctl __NR_osf_swapctl
1376#endif
1377
1378#ifdef __NR_osf_swapon
1379# define SYS_osf_swapon __NR_osf_swapon
1380#endif
1381
1382#ifdef __NR_osf_syscall
1383# define SYS_osf_syscall __NR_osf_syscall
1384#endif
1385
1386#ifdef __NR_osf_sysinfo
1387# define SYS_osf_sysinfo __NR_osf_sysinfo
1388#endif
1389
1390#ifdef __NR_osf_table
1391# define SYS_osf_table __NR_osf_table
1392#endif
1393
1394#ifdef __NR_osf_uadmin
1395# define SYS_osf_uadmin __NR_osf_uadmin
1396#endif
1397
1398#ifdef __NR_osf_usleep_thread
1399# define SYS_osf_usleep_thread __NR_osf_usleep_thread
1400#endif
1401
1402#ifdef __NR_osf_uswitch
1403# define SYS_osf_uswitch __NR_osf_uswitch
1404#endif
1405
1406#ifdef __NR_osf_utc_adjtime
1407# define SYS_osf_utc_adjtime __NR_osf_utc_adjtime
1408#endif
1409
1410#ifdef __NR_osf_utc_gettime
1411# define SYS_osf_utc_gettime __NR_osf_utc_gettime
1412#endif
1413
1414#ifdef __NR_osf_utimes
1415# define SYS_osf_utimes __NR_osf_utimes
1416#endif
1417
1418#ifdef __NR_osf_utsname
1419# define SYS_osf_utsname __NR_osf_utsname
1420#endif
1421
1422#ifdef __NR_osf_wait4
1423# define SYS_osf_wait4 __NR_osf_wait4
1424#endif
1425
1426#ifdef __NR_osf_waitid
1427# define SYS_osf_waitid __NR_osf_waitid
1428#endif
1429
1430#ifdef __NR_pause
1431# define SYS_pause __NR_pause
1432#endif
1433
1434#ifdef __NR_pciconfig_iobase
1435# define SYS_pciconfig_iobase __NR_pciconfig_iobase
1436#endif
1437
1438#ifdef __NR_pciconfig_read
1439# define SYS_pciconfig_read __NR_pciconfig_read
1440#endif
1441
1442#ifdef __NR_pciconfig_write
1443# define SYS_pciconfig_write __NR_pciconfig_write
1444#endif
1445
1446#ifdef __NR_perf_event_open
1447# define SYS_perf_event_open __NR_perf_event_open
1448#endif
1449
1450#ifdef __NR_perfctr
1451# define SYS_perfctr __NR_perfctr
1452#endif
1453
1454#ifdef __NR_perfmonctl
1455# define SYS_perfmonctl __NR_perfmonctl
1456#endif
1457
1458#ifdef __NR_personality
1459# define SYS_personality __NR_personality
1460#endif
1461
1462#ifdef __NR_pipe
1463# define SYS_pipe __NR_pipe
1464#endif
1465
1466#ifdef __NR_pipe2
1467# define SYS_pipe2 __NR_pipe2
1468#endif
1469
1470#ifdef __NR_pivot_root
1471# define SYS_pivot_root __NR_pivot_root
1472#endif
1473
1474#ifdef __NR_pkey_alloc
1475# define SYS_pkey_alloc __NR_pkey_alloc
1476#endif
1477
1478#ifdef __NR_pkey_free
1479# define SYS_pkey_free __NR_pkey_free
1480#endif
1481
1482#ifdef __NR_pkey_mprotect
1483# define SYS_pkey_mprotect __NR_pkey_mprotect
1484#endif
1485
1486#ifdef __NR_poll
1487# define SYS_poll __NR_poll
1488#endif
1489
1490#ifdef __NR_ppoll
1491# define SYS_ppoll __NR_ppoll
1492#endif
1493
1494#ifdef __NR_prctl
1495# define SYS_prctl __NR_prctl
1496#endif
1497
1498#ifdef __NR_pread64
1499# define SYS_pread64 __NR_pread64
1500#endif
1501
1502#ifdef __NR_preadv
1503# define SYS_preadv __NR_preadv
1504#endif
1505
1506#ifdef __NR_preadv2
1507# define SYS_preadv2 __NR_preadv2
1508#endif
1509
1510#ifdef __NR_prlimit64
1511# define SYS_prlimit64 __NR_prlimit64
1512#endif
1513
1514#ifdef __NR_process_vm_readv
1515# define SYS_process_vm_readv __NR_process_vm_readv
1516#endif
1517
1518#ifdef __NR_process_vm_writev
1519# define SYS_process_vm_writev __NR_process_vm_writev
1520#endif
1521
1522#ifdef __NR_prof
1523# define SYS_prof __NR_prof
1524#endif
1525
1526#ifdef __NR_profil
1527# define SYS_profil __NR_profil
1528#endif
1529
1530#ifdef __NR_pselect6
1531# define SYS_pselect6 __NR_pselect6
1532#endif
1533
1534#ifdef __NR_ptrace
1535# define SYS_ptrace __NR_ptrace
1536#endif
1537
1538#ifdef __NR_putpmsg
1539# define SYS_putpmsg __NR_putpmsg
1540#endif
1541
1542#ifdef __NR_pwrite64
1543# define SYS_pwrite64 __NR_pwrite64
1544#endif
1545
1546#ifdef __NR_pwritev
1547# define SYS_pwritev __NR_pwritev
1548#endif
1549
1550#ifdef __NR_pwritev2
1551# define SYS_pwritev2 __NR_pwritev2
1552#endif
1553
1554#ifdef __NR_query_module
1555# define SYS_query_module __NR_query_module
1556#endif
1557
1558#ifdef __NR_quotactl
1559# define SYS_quotactl __NR_quotactl
1560#endif
1561
1562#ifdef __NR_read
1563# define SYS_read __NR_read
1564#endif
1565
1566#ifdef __NR_readahead
1567# define SYS_readahead __NR_readahead
1568#endif
1569
1570#ifdef __NR_readdir
1571# define SYS_readdir __NR_readdir
1572#endif
1573
1574#ifdef __NR_readlink
1575# define SYS_readlink __NR_readlink
1576#endif
1577
1578#ifdef __NR_readlinkat
1579# define SYS_readlinkat __NR_readlinkat
1580#endif
1581
1582#ifdef __NR_readv
1583# define SYS_readv __NR_readv
1584#endif
1585
1586#ifdef __NR_reboot
1587# define SYS_reboot __NR_reboot
1588#endif
1589
1590#ifdef __NR_recv
1591# define SYS_recv __NR_recv
1592#endif
1593
1594#ifdef __NR_recvfrom
1595# define SYS_recvfrom __NR_recvfrom
1596#endif
1597
1598#ifdef __NR_recvmmsg
1599# define SYS_recvmmsg __NR_recvmmsg
1600#endif
1601
1602#ifdef __NR_recvmsg
1603# define SYS_recvmsg __NR_recvmsg
1604#endif
1605
1606#ifdef __NR_remap_file_pages
1607# define SYS_remap_file_pages __NR_remap_file_pages
1608#endif
1609
1610#ifdef __NR_removexattr
1611# define SYS_removexattr __NR_removexattr
1612#endif
1613
1614#ifdef __NR_rename
1615# define SYS_rename __NR_rename
1616#endif
1617
1618#ifdef __NR_renameat
1619# define SYS_renameat __NR_renameat
1620#endif
1621
1622#ifdef __NR_renameat2
1623# define SYS_renameat2 __NR_renameat2
1624#endif
1625
1626#ifdef __NR_request_key
1627# define SYS_request_key __NR_request_key
1628#endif
1629
1630#ifdef __NR_restart_syscall
1631# define SYS_restart_syscall __NR_restart_syscall
1632#endif
1633
1634#ifdef __NR_riscv_flush_icache
1635# define SYS_riscv_flush_icache __NR_riscv_flush_icache
1636#endif
1637
1638#ifdef __NR_rmdir
1639# define SYS_rmdir __NR_rmdir
1640#endif
1641
1642#ifdef __NR_rseq
1643# define SYS_rseq __NR_rseq
1644#endif
1645
1646#ifdef __NR_rt_sigaction
1647# define SYS_rt_sigaction __NR_rt_sigaction
1648#endif
1649
1650#ifdef __NR_rt_sigpending
1651# define SYS_rt_sigpending __NR_rt_sigpending
1652#endif
1653
1654#ifdef __NR_rt_sigprocmask
1655# define SYS_rt_sigprocmask __NR_rt_sigprocmask
1656#endif
1657
1658#ifdef __NR_rt_sigqueueinfo
1659# define SYS_rt_sigqueueinfo __NR_rt_sigqueueinfo
1660#endif
1661
1662#ifdef __NR_rt_sigreturn
1663# define SYS_rt_sigreturn __NR_rt_sigreturn
1664#endif
1665
1666#ifdef __NR_rt_sigsuspend
1667# define SYS_rt_sigsuspend __NR_rt_sigsuspend
1668#endif
1669
1670#ifdef __NR_rt_sigtimedwait
1671# define SYS_rt_sigtimedwait __NR_rt_sigtimedwait
1672#endif
1673
1674#ifdef __NR_rt_tgsigqueueinfo
1675# define SYS_rt_tgsigqueueinfo __NR_rt_tgsigqueueinfo
1676#endif
1677
1678#ifdef __NR_rtas
1679# define SYS_rtas __NR_rtas
1680#endif
1681
1682#ifdef __NR_s390_guarded_storage
1683# define SYS_s390_guarded_storage __NR_s390_guarded_storage
1684#endif
1685
1686#ifdef __NR_s390_pci_mmio_read
1687# define SYS_s390_pci_mmio_read __NR_s390_pci_mmio_read
1688#endif
1689
1690#ifdef __NR_s390_pci_mmio_write
1691# define SYS_s390_pci_mmio_write __NR_s390_pci_mmio_write
1692#endif
1693
1694#ifdef __NR_s390_runtime_instr
1695# define SYS_s390_runtime_instr __NR_s390_runtime_instr
1696#endif
1697
1698#ifdef __NR_s390_sthyi
1699# define SYS_s390_sthyi __NR_s390_sthyi
1700#endif
1701
1702#ifdef __NR_sched_get_affinity
1703# define SYS_sched_get_affinity __NR_sched_get_affinity
1704#endif
1705
1706#ifdef __NR_sched_get_priority_max
1707# define SYS_sched_get_priority_max __NR_sched_get_priority_max
1708#endif
1709
1710#ifdef __NR_sched_get_priority_min
1711# define SYS_sched_get_priority_min __NR_sched_get_priority_min
1712#endif
1713
1714#ifdef __NR_sched_getaffinity
1715# define SYS_sched_getaffinity __NR_sched_getaffinity
1716#endif
1717
1718#ifdef __NR_sched_getattr
1719# define SYS_sched_getattr __NR_sched_getattr
1720#endif
1721
1722#ifdef __NR_sched_getparam
1723# define SYS_sched_getparam __NR_sched_getparam
1724#endif
1725
1726#ifdef __NR_sched_getscheduler
1727# define SYS_sched_getscheduler __NR_sched_getscheduler
1728#endif
1729
1730#ifdef __NR_sched_rr_get_interval
1731# define SYS_sched_rr_get_interval __NR_sched_rr_get_interval
1732#endif
1733
1734#ifdef __NR_sched_set_affinity
1735# define SYS_sched_set_affinity __NR_sched_set_affinity
1736#endif
1737
1738#ifdef __NR_sched_setaffinity
1739# define SYS_sched_setaffinity __NR_sched_setaffinity
1740#endif
1741
1742#ifdef __NR_sched_setattr
1743# define SYS_sched_setattr __NR_sched_setattr
1744#endif
1745
1746#ifdef __NR_sched_setparam
1747# define SYS_sched_setparam __NR_sched_setparam
1748#endif
1749
1750#ifdef __NR_sched_setscheduler
1751# define SYS_sched_setscheduler __NR_sched_setscheduler
1752#endif
1753
1754#ifdef __NR_sched_yield
1755# define SYS_sched_yield __NR_sched_yield
1756#endif
1757
1758#ifdef __NR_seccomp
1759# define SYS_seccomp __NR_seccomp
1760#endif
1761
1762#ifdef __NR_security
1763# define SYS_security __NR_security
1764#endif
1765
1766#ifdef __NR_select
1767# define SYS_select __NR_select
1768#endif
1769
1770#ifdef __NR_semctl
1771# define SYS_semctl __NR_semctl
1772#endif
1773
1774#ifdef __NR_semget
1775# define SYS_semget __NR_semget
1776#endif
1777
1778#ifdef __NR_semop
1779# define SYS_semop __NR_semop
1780#endif
1781
1782#ifdef __NR_semtimedop
1783# define SYS_semtimedop __NR_semtimedop
1784#endif
1785
1786#ifdef __NR_send
1787# define SYS_send __NR_send
1788#endif
1789
1790#ifdef __NR_sendfile
1791# define SYS_sendfile __NR_sendfile
1792#endif
1793
1794#ifdef __NR_sendfile64
1795# define SYS_sendfile64 __NR_sendfile64
1796#endif
1797
1798#ifdef __NR_sendmmsg
1799# define SYS_sendmmsg __NR_sendmmsg
1800#endif
1801
1802#ifdef __NR_sendmsg
1803# define SYS_sendmsg __NR_sendmsg
1804#endif
1805
1806#ifdef __NR_sendto
1807# define SYS_sendto __NR_sendto
1808#endif
1809
1810#ifdef __NR_set_mempolicy
1811# define SYS_set_mempolicy __NR_set_mempolicy
1812#endif
1813
1814#ifdef __NR_set_robust_list
1815# define SYS_set_robust_list __NR_set_robust_list
1816#endif
1817
1818#ifdef __NR_set_thread_area
1819# define SYS_set_thread_area __NR_set_thread_area
1820#endif
1821
1822#ifdef __NR_set_tid_address
1823# define SYS_set_tid_address __NR_set_tid_address
1824#endif
1825
1826#ifdef __NR_setdomainname
1827# define SYS_setdomainname __NR_setdomainname
1828#endif
1829
1830#ifdef __NR_setfsgid
1831# define SYS_setfsgid __NR_setfsgid
1832#endif
1833
1834#ifdef __NR_setfsgid32
1835# define SYS_setfsgid32 __NR_setfsgid32
1836#endif
1837
1838#ifdef __NR_setfsuid
1839# define SYS_setfsuid __NR_setfsuid
1840#endif
1841
1842#ifdef __NR_setfsuid32
1843# define SYS_setfsuid32 __NR_setfsuid32
1844#endif
1845
1846#ifdef __NR_setgid
1847# define SYS_setgid __NR_setgid
1848#endif
1849
1850#ifdef __NR_setgid32
1851# define SYS_setgid32 __NR_setgid32
1852#endif
1853
1854#ifdef __NR_setgroups
1855# define SYS_setgroups __NR_setgroups
1856#endif
1857
1858#ifdef __NR_setgroups32
1859# define SYS_setgroups32 __NR_setgroups32
1860#endif
1861
1862#ifdef __NR_sethae
1863# define SYS_sethae __NR_sethae
1864#endif
1865
1866#ifdef __NR_sethostname
1867# define SYS_sethostname __NR_sethostname
1868#endif
1869
1870#ifdef __NR_setitimer
1871# define SYS_setitimer __NR_setitimer
1872#endif
1873
1874#ifdef __NR_setns
1875# define SYS_setns __NR_setns
1876#endif
1877
1878#ifdef __NR_setpgid
1879# define SYS_setpgid __NR_setpgid
1880#endif
1881
1882#ifdef __NR_setpgrp
1883# define SYS_setpgrp __NR_setpgrp
1884#endif
1885
1886#ifdef __NR_setpriority
1887# define SYS_setpriority __NR_setpriority
1888#endif
1889
1890#ifdef __NR_setregid
1891# define SYS_setregid __NR_setregid
1892#endif
1893
1894#ifdef __NR_setregid32
1895# define SYS_setregid32 __NR_setregid32
1896#endif
1897
1898#ifdef __NR_setresgid
1899# define SYS_setresgid __NR_setresgid
1900#endif
1901
1902#ifdef __NR_setresgid32
1903# define SYS_setresgid32 __NR_setresgid32
1904#endif
1905
1906#ifdef __NR_setresuid
1907# define SYS_setresuid __NR_setresuid
1908#endif
1909
1910#ifdef __NR_setresuid32
1911# define SYS_setresuid32 __NR_setresuid32
1912#endif
1913
1914#ifdef __NR_setreuid
1915# define SYS_setreuid __NR_setreuid
1916#endif
1917
1918#ifdef __NR_setreuid32
1919# define SYS_setreuid32 __NR_setreuid32
1920#endif
1921
1922#ifdef __NR_setrlimit
1923# define SYS_setrlimit __NR_setrlimit
1924#endif
1925
1926#ifdef __NR_setsid
1927# define SYS_setsid __NR_setsid
1928#endif
1929
1930#ifdef __NR_setsockopt
1931# define SYS_setsockopt __NR_setsockopt
1932#endif
1933
1934#ifdef __NR_settimeofday
1935# define SYS_settimeofday __NR_settimeofday
1936#endif
1937
1938#ifdef __NR_setuid
1939# define SYS_setuid __NR_setuid
1940#endif
1941
1942#ifdef __NR_setuid32
1943# define SYS_setuid32 __NR_setuid32
1944#endif
1945
1946#ifdef __NR_setxattr
1947# define SYS_setxattr __NR_setxattr
1948#endif
1949
1950#ifdef __NR_sgetmask
1951# define SYS_sgetmask __NR_sgetmask
1952#endif
1953
1954#ifdef __NR_shmat
1955# define SYS_shmat __NR_shmat
1956#endif
1957
1958#ifdef __NR_shmctl
1959# define SYS_shmctl __NR_shmctl
1960#endif
1961
1962#ifdef __NR_shmdt
1963# define SYS_shmdt __NR_shmdt
1964#endif
1965
1966#ifdef __NR_shmget
1967# define SYS_shmget __NR_shmget
1968#endif
1969
1970#ifdef __NR_shutdown
1971# define SYS_shutdown __NR_shutdown
1972#endif
1973
1974#ifdef __NR_sigaction
1975# define SYS_sigaction __NR_sigaction
1976#endif
1977
1978#ifdef __NR_sigaltstack
1979# define SYS_sigaltstack __NR_sigaltstack
1980#endif
1981
1982#ifdef __NR_signal
1983# define SYS_signal __NR_signal
1984#endif
1985
1986#ifdef __NR_signalfd
1987# define SYS_signalfd __NR_signalfd
1988#endif
1989
1990#ifdef __NR_signalfd4
1991# define SYS_signalfd4 __NR_signalfd4
1992#endif
1993
1994#ifdef __NR_sigpending
1995# define SYS_sigpending __NR_sigpending
1996#endif
1997
1998#ifdef __NR_sigprocmask
1999# define SYS_sigprocmask __NR_sigprocmask
2000#endif
2001
2002#ifdef __NR_sigreturn
2003# define SYS_sigreturn __NR_sigreturn
2004#endif
2005
2006#ifdef __NR_sigsuspend
2007# define SYS_sigsuspend __NR_sigsuspend
2008#endif
2009
2010#ifdef __NR_socket
2011# define SYS_socket __NR_socket
2012#endif
2013
2014#ifdef __NR_socketcall
2015# define SYS_socketcall __NR_socketcall
2016#endif
2017
2018#ifdef __NR_socketpair
2019# define SYS_socketpair __NR_socketpair
2020#endif
2021
2022#ifdef __NR_splice
2023# define SYS_splice __NR_splice
2024#endif
2025
2026#ifdef __NR_spu_create
2027# define SYS_spu_create __NR_spu_create
2028#endif
2029
2030#ifdef __NR_spu_run
2031# define SYS_spu_run __NR_spu_run
2032#endif
2033
2034#ifdef __NR_ssetmask
2035# define SYS_ssetmask __NR_ssetmask
2036#endif
2037
2038#ifdef __NR_stat
2039# define SYS_stat __NR_stat
2040#endif
2041
2042#ifdef __NR_stat64
2043# define SYS_stat64 __NR_stat64
2044#endif
2045
2046#ifdef __NR_statfs
2047# define SYS_statfs __NR_statfs
2048#endif
2049
2050#ifdef __NR_statfs64
2051# define SYS_statfs64 __NR_statfs64
2052#endif
2053
2054#ifdef __NR_statx
2055# define SYS_statx __NR_statx
2056#endif
2057
2058#ifdef __NR_stime
2059# define SYS_stime __NR_stime
2060#endif
2061
2062#ifdef __NR_stty
2063# define SYS_stty __NR_stty
2064#endif
2065
2066#ifdef __NR_subpage_prot
2067# define SYS_subpage_prot __NR_subpage_prot
2068#endif
2069
2070#ifdef __NR_swapcontext
2071# define SYS_swapcontext __NR_swapcontext
2072#endif
2073
2074#ifdef __NR_swapoff
2075# define SYS_swapoff __NR_swapoff
2076#endif
2077
2078#ifdef __NR_swapon
2079# define SYS_swapon __NR_swapon
2080#endif
2081
2082#ifdef __NR_switch_endian
2083# define SYS_switch_endian __NR_switch_endian
2084#endif
2085
2086#ifdef __NR_symlink
2087# define SYS_symlink __NR_symlink
2088#endif
2089
2090#ifdef __NR_symlinkat
2091# define SYS_symlinkat __NR_symlinkat
2092#endif
2093
2094#ifdef __NR_sync
2095# define SYS_sync __NR_sync
2096#endif
2097
2098#ifdef __NR_sync_file_range
2099# define SYS_sync_file_range __NR_sync_file_range
2100#endif
2101
2102#ifdef __NR_sync_file_range2
2103# define SYS_sync_file_range2 __NR_sync_file_range2
2104#endif
2105
2106#ifdef __NR_syncfs
2107# define SYS_syncfs __NR_syncfs
2108#endif
2109
2110#ifdef __NR_sys_debug_setcontext
2111# define SYS_sys_debug_setcontext __NR_sys_debug_setcontext
2112#endif
2113
2114#ifdef __NR_sys_epoll_create
2115# define SYS_sys_epoll_create __NR_sys_epoll_create
2116#endif
2117
2118#ifdef __NR_sys_epoll_ctl
2119# define SYS_sys_epoll_ctl __NR_sys_epoll_ctl
2120#endif
2121
2122#ifdef __NR_sys_epoll_wait
2123# define SYS_sys_epoll_wait __NR_sys_epoll_wait
2124#endif
2125
2126#ifdef __NR_syscall
2127# define SYS_syscall __NR_syscall
2128#endif
2129
2130#ifdef __NR_sysfs
2131# define SYS_sysfs __NR_sysfs
2132#endif
2133
2134#ifdef __NR_sysinfo
2135# define SYS_sysinfo __NR_sysinfo
2136#endif
2137
2138#ifdef __NR_syslog
2139# define SYS_syslog __NR_syslog
2140#endif
2141
2142#ifdef __NR_sysmips
2143# define SYS_sysmips __NR_sysmips
2144#endif
2145
2146#ifdef __NR_tee
2147# define SYS_tee __NR_tee
2148#endif
2149
2150#ifdef __NR_tgkill
2151# define SYS_tgkill __NR_tgkill
2152#endif
2153
2154#ifdef __NR_time
2155# define SYS_time __NR_time
2156#endif
2157
2158#ifdef __NR_timer_create
2159# define SYS_timer_create __NR_timer_create
2160#endif
2161
2162#ifdef __NR_timer_delete
2163# define SYS_timer_delete __NR_timer_delete
2164#endif
2165
2166#ifdef __NR_timer_getoverrun
2167# define SYS_timer_getoverrun __NR_timer_getoverrun
2168#endif
2169
2170#ifdef __NR_timer_gettime
2171# define SYS_timer_gettime __NR_timer_gettime
2172#endif
2173
2174#ifdef __NR_timer_settime
2175# define SYS_timer_settime __NR_timer_settime
2176#endif
2177
2178#ifdef __NR_timerfd
2179# define SYS_timerfd __NR_timerfd
2180#endif
2181
2182#ifdef __NR_timerfd_create
2183# define SYS_timerfd_create __NR_timerfd_create
2184#endif
2185
2186#ifdef __NR_timerfd_gettime
2187# define SYS_timerfd_gettime __NR_timerfd_gettime
2188#endif
2189
2190#ifdef __NR_timerfd_settime
2191# define SYS_timerfd_settime __NR_timerfd_settime
2192#endif
2193
2194#ifdef __NR_times
2195# define SYS_times __NR_times
2196#endif
2197
2198#ifdef __NR_tkill
2199# define SYS_tkill __NR_tkill
2200#endif
2201
2202#ifdef __NR_truncate
2203# define SYS_truncate __NR_truncate
2204#endif
2205
2206#ifdef __NR_truncate64
2207# define SYS_truncate64 __NR_truncate64
2208#endif
2209
2210#ifdef __NR_tuxcall
2211# define SYS_tuxcall __NR_tuxcall
2212#endif
2213
2214#ifdef __NR_ugetrlimit
2215# define SYS_ugetrlimit __NR_ugetrlimit
2216#endif
2217
2218#ifdef __NR_ulimit
2219# define SYS_ulimit __NR_ulimit
2220#endif
2221
2222#ifdef __NR_umask
2223# define SYS_umask __NR_umask
2224#endif
2225
2226#ifdef __NR_umount
2227# define SYS_umount __NR_umount
2228#endif
2229
2230#ifdef __NR_umount2
2231# define SYS_umount2 __NR_umount2
2232#endif
2233
2234#ifdef __NR_uname
2235# define SYS_uname __NR_uname
2236#endif
2237
2238#ifdef __NR_unlink
2239# define SYS_unlink __NR_unlink
2240#endif
2241
2242#ifdef __NR_unlinkat
2243# define SYS_unlinkat __NR_unlinkat
2244#endif
2245
2246#ifdef __NR_unshare
2247# define SYS_unshare __NR_unshare
2248#endif
2249
2250#ifdef __NR_uselib
2251# define SYS_uselib __NR_uselib
2252#endif
2253
2254#ifdef __NR_userfaultfd
2255# define SYS_userfaultfd __NR_userfaultfd
2256#endif
2257
2258#ifdef __NR_ustat
2259# define SYS_ustat __NR_ustat
2260#endif
2261
2262#ifdef __NR_utime
2263# define SYS_utime __NR_utime
2264#endif
2265
2266#ifdef __NR_utimensat
2267# define SYS_utimensat __NR_utimensat
2268#endif
2269
2270#ifdef __NR_utimes
2271# define SYS_utimes __NR_utimes
2272#endif
2273
2274#ifdef __NR_utrap_install
2275# define SYS_utrap_install __NR_utrap_install
2276#endif
2277
2278#ifdef __NR_vfork
2279# define SYS_vfork __NR_vfork
2280#endif
2281
2282#ifdef __NR_vhangup
2283# define SYS_vhangup __NR_vhangup
2284#endif
2285
2286#ifdef __NR_vm86
2287# define SYS_vm86 __NR_vm86
2288#endif
2289
2290#ifdef __NR_vm86old
2291# define SYS_vm86old __NR_vm86old
2292#endif
2293
2294#ifdef __NR_vmsplice
2295# define SYS_vmsplice __NR_vmsplice
2296#endif
2297
2298#ifdef __NR_vserver
2299# define SYS_vserver __NR_vserver
2300#endif
2301
2302#ifdef __NR_wait4
2303# define SYS_wait4 __NR_wait4
2304#endif
2305
2306#ifdef __NR_waitid
2307# define SYS_waitid __NR_waitid
2308#endif
2309
2310#ifdef __NR_waitpid
2311# define SYS_waitpid __NR_waitpid
2312#endif
2313
2314#ifdef __NR_write
2315# define SYS_write __NR_write
2316#endif
2317
2318#ifdef __NR_writev
2319# define SYS_writev __NR_writev
2320#endif
2321
libc/glibc-include/bits/sysctl.h created+20
...@@ -0,0 +1,20 @@
1/* Copyright (C) 2012-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#if defined __x86_64__ && defined __ILP32__
19# error "sysctl system call is unsupported in x32 kernel"
20#endif
libc/glibc-include/bits/syslog-ldbl.h created+35
...@@ -0,0 +1,35 @@
1/* -mlong-double-64 compatibility mode for syslog functions.
2 Copyright (C) 2006-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SYS_SYSLOG_H
20# error "Never include <bits/syslog-ldbl.h> directly; use <sys/syslog.h> instead."
21#endif
22
23__LDBL_REDIR_DECL (syslog)
24
25#ifdef __USE_MISC
26__LDBL_REDIR_DECL (vsyslog)
27#endif
28
29#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
30__LDBL_REDIR_DECL (__syslog_chk)
31
32# ifdef __USE_MISC
33__LDBL_REDIR_DECL (__vsyslog_chk)
34# endif
35#endif
libc/glibc-include/bits/syslog-path.h created+28
...@@ -0,0 +1,28 @@
1/* <bits/syslog-path.h> -- _PATH_LOG definition
2 Copyright (C) 2006-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SYS_SYSLOG_H
20# error "Never include this file directly. Use <sys/syslog.h> instead"
21#endif
22
23#ifndef _BITS_SYSLOG_PATH_H
24#define _BITS_SYSLOG_PATH_H 1
25
26#define _PATH_LOG "/dev/log"
27
28#endif /* bits/syslog-path.h */
libc/glibc-include/bits/syslog.h created+49
...@@ -0,0 +1,49 @@
1/* Checking macros for syslog functions.
2 Copyright (C) 2005-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SYS_SYSLOG_H
20# error "Never include <bits/syslog.h> directly; use <sys/syslog.h> instead."
21#endif
22
23
24extern void __syslog_chk (int __pri, int __flag, const char *__fmt, ...)
25 __attribute__ ((__format__ (__printf__, 3, 4)));
26
27#ifdef __va_arg_pack
28__fortify_function void
29syslog (int __pri, const char *__fmt, ...)
30{
31 __syslog_chk (__pri, __USE_FORTIFY_LEVEL - 1, __fmt, __va_arg_pack ());
32}
33#elif !defined __cplusplus
34# define syslog(pri, ...) \
35 __syslog_chk (pri, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__)
36#endif
37
38
39#ifdef __USE_MISC
40extern void __vsyslog_chk (int __pri, int __flag, const char *__fmt,
41 __gnuc_va_list __ap)
42 __attribute__ ((__format__ (__printf__, 3, 0)));
43
44__fortify_function void
45vsyslog (int __pri, const char *__fmt, __gnuc_va_list __ap)
46{
47 __vsyslog_chk (__pri, __USE_FORTIFY_LEVEL - 1, __fmt, __ap);
48}
49#endif
libc/glibc-include/bits/sysmacros.h created+74
...@@ -0,0 +1,74 @@
1/* Definitions of macros to access `dev_t' values.
2 Copyright (C) 1996-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_SYSMACROS_H
20#define _BITS_SYSMACROS_H 1
21
22#ifndef _SYS_SYSMACROS_H
23# error "Never include <bits/sysmacros.h> directly; use <sys/sysmacros.h> instead."
24#endif
25
26/* dev_t in glibc is a 64-bit quantity, with 32-bit major and minor numbers.
27 Our default encoding is MMMM Mmmm mmmM MMmm, where M is a hex digit of
28 the major number and m is a hex digit of the minor number. This is
29 downward compatible with legacy systems where dev_t is 16 bits wide,
30 encoded as MMmm. It is also downward compatible with the Linux kernel,
31 which (as of 2016) uses 32-bit dev_t, encoded as mmmM MMmm.
32
33 Systems that use an incompatible encoding for dev_t should override this
34 file in the appropriate sysdeps subdirectory. */
35
36#define __SYSMACROS_DECLARE_MAJOR(DECL_TEMPL) \
37 DECL_TEMPL(unsigned int, major, (__dev_t __dev))
38
39#define __SYSMACROS_DEFINE_MAJOR(DECL_TEMPL) \
40 __SYSMACROS_DECLARE_MAJOR (DECL_TEMPL) \
41 { \
42 unsigned int __major; \
43 __major = ((__dev & (__dev_t) 0x00000000000fff00u) >> 8); \
44 __major |= ((__dev & (__dev_t) 0xfffff00000000000u) >> 32); \
45 return __major; \
46 }
47
48#define __SYSMACROS_DECLARE_MINOR(DECL_TEMPL) \
49 DECL_TEMPL(unsigned int, minor, (__dev_t __dev))
50
51#define __SYSMACROS_DEFINE_MINOR(DECL_TEMPL) \
52 __SYSMACROS_DECLARE_MINOR (DECL_TEMPL) \
53 { \
54 unsigned int __minor; \
55 __minor = ((__dev & (__dev_t) 0x00000000000000ffu) >> 0); \
56 __minor |= ((__dev & (__dev_t) 0x00000ffffff00000u) >> 12); \
57 return __minor; \
58 }
59
60#define __SYSMACROS_DECLARE_MAKEDEV(DECL_TEMPL) \
61 DECL_TEMPL(__dev_t, makedev, (unsigned int __major, unsigned int __minor))
62
63#define __SYSMACROS_DEFINE_MAKEDEV(DECL_TEMPL) \
64 __SYSMACROS_DECLARE_MAKEDEV (DECL_TEMPL) \
65 { \
66 __dev_t __dev; \
67 __dev = (((__dev_t) (__major & 0x00000fffu)) << 8); \
68 __dev |= (((__dev_t) (__major & 0xfffff000u)) << 32); \
69 __dev |= (((__dev_t) (__minor & 0x000000ffu)) << 0); \
70 __dev |= (((__dev_t) (__minor & 0xffffff00u)) << 12); \
71 return __dev; \
72 }
73
74#endif /* bits/sysmacros.h */
libc/glibc-include/bits/termios-baud.h created+48
...@@ -0,0 +1,48 @@
1/* termios baud rate selection definitions. Linux/generic version.
2 Copyright (C) 2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _TERMIOS_H
20# error "Never include <bits/termios-baud.h> directly; use <termios.h> instead."
21#endif
22
23#ifdef __USE_MISC
24# define CBAUD 000000010017 /* Baud speed mask (not in POSIX). */
25# define CBAUDEX 000000010000 /* Extra baud speed mask, included in CBAUD.
26 (not in POSIX). */
27# define CIBAUD 002003600000 /* Input baud rate (not used). */
28# define CMSPAR 010000000000 /* Mark or space (stick) parity. */
29# define CRTSCTS 020000000000 /* Flow control. */
30#endif
31
32/* Extra output baud rates (not in POSIX). */
33#define B57600 0010001
34#define B115200 0010002
35#define B230400 0010003
36#define B460800 0010004
37#define B500000 0010005
38#define B576000 0010006
39#define B921600 0010007
40#define B1000000 0010010
41#define B1152000 0010011
42#define B1500000 0010012
43#define B2000000 0010013
44#define B2500000 0010014
45#define B3000000 0010015
46#define B3500000 0010016
47#define B4000000 0010017
48#define __MAX_BAUD B4000000
libc/glibc-include/bits/termios-c_cc.h created+40
...@@ -0,0 +1,40 @@
1/* termios c_cc symbolic constant definitions. Linux/generic version.
2 Copyright (C) 2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _TERMIOS_H
20# error "Never include <bits/termios_c_cc.h> directly; use <termios.h> instead."
21#endif
22
23/* c_cc characters */
24#define VINTR 0
25#define VQUIT 1
26#define VERASE 2
27#define VKILL 3
28#define VEOF 4
29#define VTIME 5
30#define VMIN 6
31#define VSWTC 7
32#define VSTART 8
33#define VSTOP 9
34#define VSUSP 10
35#define VEOL 11
36#define VREPRINT 12
37#define VDISCARD 13
38#define VWERASE 14
39#define VLNEXT 15
40#define VEOL2 16
libc/glibc-include/bits/termios-c_cflag.h created+34
...@@ -0,0 +1,34 @@
1/* termios control mode definitions. Linux/generic version.
2 Copyright (C) 2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _TERMIOS_H
20# error "Never include <bits/termios-c_cflag.h> directly; use <termios.h> instead."
21#endif
22
23/* c_cflag bits. */
24#define CSIZE 0000060
25#define CS5 0000000
26#define CS6 0000020
27#define CS7 0000040
28#define CS8 0000060
29#define CSTOPB 0000100
30#define CREAD 0000200
31#define PARENB 0000400
32#define PARODD 0001000
33#define HUPCL 0002000
34#define CLOCAL 0004000
libc/glibc-include/bits/termios-c_iflag.h created+40
...@@ -0,0 +1,40 @@
1/* termios input mode definitions. Linux/generic version.
2 Copyright (C) 2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _TERMIOS_H
20# error "Never include <bits/termios-ciflags.h> directly; use <termios.h> instead."
21#endif
22
23/* c_iflag bits */
24#define IGNBRK 0000001 /* Ignore break condition. */
25#define BRKINT 0000002 /* Signal interrupt on break. */
26#define IGNPAR 0000004 /* Ignore characters with parity errors. */
27#define PARMRK 0000010 /* Mark parity and framing errors. */
28#define INPCK 0000020 /* Enable input parity check. */
29#define ISTRIP 0000040 /* Strip 8th bit off characters. */
30#define INLCR 0000100 /* Map NL to CR on input. */
31#define IGNCR 0000200 /* Ignore CR. */
32#define ICRNL 0000400 /* Map CR to NL on input. */
33#define IUCLC 0001000 /* Map uppercase characters to lowercase on input
34 (not in POSIX). */
35#define IXON 0002000 /* Enable start/stop output control. */
36#define IXANY 0004000 /* Enable any character to restart output. */
37#define IXOFF 0010000 /* Enable start/stop input control. */
38#define IMAXBEL 0020000 /* Ring bell when input queue is full
39 (not in POSIX). */
40#define IUTF8 0040000 /* Input is UTF8 (not in POSIX). */
libc/glibc-include/bits/termios-c_lflag.h created+58
...@@ -0,0 +1,58 @@
1/* termios local mode definitions. Linux/generic version.
2 Copyright (C) 2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _TERMIOS_H
20# error "Never include <bits/termios-c_lflag.h> directly; use <termios.h> instead."
21#endif
22
23/* c_lflag bits */
24#define ISIG 0000001 /* Enable signals. */
25#define ICANON 0000002 /* Canonical input (erase and kill processing). */
26#if defined __USE_MISC || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
27# define XCASE 0000004
28#endif
29#define ECHO 0000010 /* Enable echo. */
30#define ECHOE 0000020 /* Echo erase character as error-correcting
31 backspace. */
32#define ECHOK 0000040 /* Echo KILL. */
33#define ECHONL 0000100 /* Echo NL. */
34#define NOFLSH 0000200 /* Disable flush after interrupt or quit. */
35#define TOSTOP 0000400 /* Send SIGTTOU for background output. */
36#ifdef __USE_MISC
37# define ECHOCTL 0001000 /* If ECHO is also set, terminal special characters
38 other than TAB, NL, START, and STOP are echoed as
39 ^X, where X is the character with ASCII code 0x40
40 greater than the special character
41 (not in POSIX). */
42# define ECHOPRT 0002000 /* If ICANON and ECHO are also set, characters are
43 printed as they are being erased
44 (not in POSIX). */
45# define ECHOKE 0004000 /* If ICANON is also set, KILL is echoed by erasing
46 each character on the line, as specified by ECHOE
47 and ECHOPRT (not in POSIX). */
48# define FLUSHO 0010000 /* Output is being flushed. This flag is toggled by
49 typing the DISCARD character (not in POSIX). */
50# define PENDIN 0040000 /* All characters in the input queue are reprinted
51 when the next character is read
52 (not in POSIX). */
53#endif
54#define IEXTEN 0100000 /* Enable implementation-defined input
55 processing. */
56#ifdef __USE_MISC
57# define EXTPROC 0200000
58#endif
libc/glibc-include/bits/termios-c_oflag.h created+61
...@@ -0,0 +1,61 @@
1/* termios output mode definitions. Linux/generic version.
2 Copyright (C) 2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _TERMIOS_H
20# error "Never include <bits/termios-c_oflag.h> directly; use <termios.h> instead."
21#endif
22
23/* c_oflag bits */
24#define OPOST 0000001 /* Post-process output. */
25#define OLCUC 0000002 /* Map lowercase characters to uppercase on output.
26 (not in POSIX). */
27#define ONLCR 0000004 /* Map NL to CR-NL on output. */
28#define OCRNL 0000010 /* Map CR to NL on output. */
29#define ONOCR 0000020 /* No CR output at column 0. */
30#define ONLRET 0000040 /* NL performs CR function. */
31#define OFILL 0000100 /* Use fill characters for delay. */
32#define OFDEL 0000200 /* Fill is DEL. */
33#if defined __USE_MISC || defined __USE_XOPEN
34# define NLDLY 0000400 /* Select newline delays: */
35# define NL0 0000000 /* Newline type 0. */
36# define NL1 0000400 /* Newline type 1. */
37# define CRDLY 0003000 /* Select carriage-return delays: */
38# define CR0 0000000 /* Carriage-return delay type 0. */
39# define CR1 0001000 /* Carriage-return delay type 1. */
40# define CR2 0002000 /* Carriage-return delay type 2. */
41# define CR3 0003000 /* Carriage-return delay type 3. */
42# define TABDLY 0014000 /* Select horizontal-tab delays: */
43# define TAB0 0000000 /* Horizontal-tab delay type 0. */
44# define TAB1 0004000 /* Horizontal-tab delay type 1. */
45# define TAB2 0010000 /* Horizontal-tab delay type 2. */
46# define TAB3 0014000 /* Expand tabs to spaces. */
47# define BSDLY 0020000 /* Select backspace delays: */
48# define BS0 0000000 /* Backspace-delay type 0. */
49# define BS1 0020000 /* Backspace-delay type 1. */
50# define FFDLY 0100000 /* Select form-feed delays: */
51# define FF0 0000000 /* Form-feed delay type 0. */
52# define FF1 0100000 /* Form-feed delay type 1. */
53#endif
54
55#define VTDLY 0040000 /* Select vertical-tab delays: */
56#define VT0 0000000 /* Vertical-tab delay type 0. */
57#define VT1 0040000 /* Vertical-tab delay type 1. */
58
59#ifdef __USE_MISC
60# define XTABS 0014000
61#endif
libc/glibc-include/bits/termios-misc.h created+21
...@@ -0,0 +1,21 @@
1/* termios baud platform specific definitions. Linux/generic version.
2 Copyright (C) 2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _TERMIOS_H
20# error "Never include <bits/termios-misc.h> directly; use <termios.h> instead."
21#endif
libc/glibc-include/bits/termios-struct.h created+36
...@@ -0,0 +1,36 @@
1/* struct termios definition. Linux/generic version.
2 Copyright (C) 2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _TERMIOS_H
20# error "Never include <bits/termios-struct.h> directly; use <termios.h> instead."
21#endif
22
23#define NCCS 32
24struct termios
25 {
26 tcflag_t c_iflag; /* input mode flags */
27 tcflag_t c_oflag; /* output mode flags */
28 tcflag_t c_cflag; /* control mode flags */
29 tcflag_t c_lflag; /* local mode flags */
30 cc_t c_line; /* line discipline */
31 cc_t c_cc[NCCS]; /* control characters */
32 speed_t c_ispeed; /* input speed */
33 speed_t c_ospeed; /* output speed */
34#define _HAVE_STRUCT_TERMIOS_C_ISPEED 1
35#define _HAVE_STRUCT_TERMIOS_C_OSPEED 1
36 };
libc/glibc-include/bits/termios-tcflow.h created+26
...@@ -0,0 +1,26 @@
1/* termios tcflag symbolic contants definitions. Linux/generic version.
2 Copyright (C) 2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _TERMIOS_H
20# error "Never include <bits/termios-tcflow.h> directly; use <termios.h> instead."
21#endif
22
23/* tcsetattr uses these. */
24#define TCSANOW 0
25#define TCSADRAIN 1
26#define TCSAFLUSH 2
libc/glibc-include/bits/termios.h created+76
...@@ -0,0 +1,76 @@
1/* termios type and macro definitions. Linux version.
2 Copyright (C) 1993-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _TERMIOS_H
20# error "Never include <bits/termios.h> directly; use <termios.h> instead."
21#endif
22
23typedef unsigned char cc_t;
24typedef unsigned int speed_t;
25typedef unsigned int tcflag_t;
26
27#include <bits/termios-struct.h>
28#include <bits/termios-c_cc.h>
29#include <bits/termios-c_iflag.h>
30#include <bits/termios-c_oflag.h>
31
32/* c_cflag bit meaning */
33#define B0 0000000 /* hang up */
34#define B50 0000001
35#define B75 0000002
36#define B110 0000003
37#define B134 0000004
38#define B150 0000005
39#define B200 0000006
40#define B300 0000007
41#define B600 0000010
42#define B1200 0000011
43#define B1800 0000012
44#define B2400 0000013
45#define B4800 0000014
46#define B9600 0000015
47#define B19200 0000016
48#define B38400 0000017
49#ifdef __USE_MISC
50# define EXTA B19200
51# define EXTB B38400
52#endif
53#include <bits/termios-baud.h>
54
55#include <bits/termios-c_cflag.h>
56#include <bits/termios-c_lflag.h>
57
58#ifdef __USE_MISC
59/* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */
60# define TIOCSER_TEMT 0x01 /* Transmitter physically empty */
61#endif
62
63/* tcflow() and TCXONC use these */
64#define TCOOFF 0
65#define TCOON 1
66#define TCIOFF 2
67#define TCION 3
68
69/* tcflush() and TCFLSH use these */
70#define TCIFLUSH 0
71#define TCOFLUSH 1
72#define TCIOFLUSH 2
73
74#include <bits/termios-tcflow.h>
75
76#include <bits/termios-misc.h>
libc/glibc-include/bits/thread-shared-types.h created+198
...@@ -0,0 +1,198 @@
1/* Common threading primitives definitions for both POSIX and C11.
2 Copyright (C) 2017-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _THREAD_SHARED_TYPES_H
20#define _THREAD_SHARED_TYPES_H 1
21
22/* Arch-specific definitions. Each architecture must define the following
23 macros to define the expected sizes of pthread data types:
24
25 __SIZEOF_PTHREAD_ATTR_T - size of pthread_attr_t.
26 __SIZEOF_PTHREAD_MUTEX_T - size of pthread_mutex_t.
27 __SIZEOF_PTHREAD_MUTEXATTR_T - size of pthread_mutexattr_t.
28 __SIZEOF_PTHREAD_COND_T - size of pthread_cond_t.
29 __SIZEOF_PTHREAD_CONDATTR_T - size of pthread_condattr_t.
30 __SIZEOF_PTHREAD_RWLOCK_T - size of pthread_rwlock_t.
31 __SIZEOF_PTHREAD_RWLOCKATTR_T - size of pthread_rwlockattr_t.
32 __SIZEOF_PTHREAD_BARRIER_T - size of pthread_barrier_t.
33 __SIZEOF_PTHREAD_BARRIERATTR_T - size of pthread_barrierattr_t.
34
35 Also, the following macros must be define for internal pthread_mutex_t
36 struct definitions (struct __pthread_mutex_s):
37
38 __PTHREAD_COMPAT_PADDING_MID - any additional members after 'kind'
39 and before '__spin' (for 64 bits) or
40 '__nusers' (for 32 bits).
41 __PTHREAD_COMPAT_PADDING_END - any additional members at the end of
42 the internal structure.
43 __PTHREAD_MUTEX_LOCK_ELISION - 1 if the architecture supports lock
44 elision or 0 otherwise.
45 __PTHREAD_MUTEX_NUSERS_AFTER_KIND - control where to put __nusers. The
46 preferred value for new architectures
47 is 0.
48 __PTHREAD_MUTEX_USE_UNION - control whether internal __spins and
49 __list will be place inside a union for
50 linuxthreads compatibility.
51 The preferred value for new architectures
52 is 0.
53
54 For a new port the preferred values for the required defines are:
55
56 #define __PTHREAD_COMPAT_PADDING_MID
57 #define __PTHREAD_COMPAT_PADDING_END
58 #define __PTHREAD_MUTEX_LOCK_ELISION 0
59 #define __PTHREAD_MUTEX_NUSERS_AFTER_KIND 0
60 #define __PTHREAD_MUTEX_USE_UNION 0
61
62 __PTHREAD_MUTEX_LOCK_ELISION can be set to 1 if the hardware plans to
63 eventually support lock elision using transactional memory.
64
65 The additional macro defines any constraint for the lock alignment
66 inside the thread structures:
67
68 __LOCK_ALIGNMENT - for internal lock/futex usage.
69
70 Same idea but for the once locking primitive:
71
72 __ONCE_ALIGNMENT - for pthread_once_t/once_flag definition.
73
74 And finally the internal pthread_rwlock_t (struct __pthread_rwlock_arch_t)
75 must be defined.
76 */
77#include <bits/pthreadtypes-arch.h>
78
79/* Common definition of pthread_mutex_t. */
80
81#if !__PTHREAD_MUTEX_USE_UNION
82typedef struct __pthread_internal_list
83{
84 struct __pthread_internal_list *__prev;
85 struct __pthread_internal_list *__next;
86} __pthread_list_t;
87#else
88typedef struct __pthread_internal_slist
89{
90 struct __pthread_internal_slist *__next;
91} __pthread_slist_t;
92#endif
93
94/* Lock elision support. */
95#if __PTHREAD_MUTEX_LOCK_ELISION
96# if !__PTHREAD_MUTEX_USE_UNION
97# define __PTHREAD_SPINS_DATA \
98 short __spins; \
99 short __elision
100# define __PTHREAD_SPINS 0, 0
101# else
102# define __PTHREAD_SPINS_DATA \
103 struct \
104 { \
105 short __espins; \
106 short __eelision; \
107 } __elision_data
108# define __PTHREAD_SPINS { 0, 0 }
109# define __spins __elision_data.__espins
110# define __elision __elision_data.__eelision
111# endif
112#else
113# define __PTHREAD_SPINS_DATA int __spins
114/* Mutex __spins initializer used by PTHREAD_MUTEX_INITIALIZER. */
115# define __PTHREAD_SPINS 0
116#endif
117
118struct __pthread_mutex_s
119{
120 int __lock __LOCK_ALIGNMENT;
121 unsigned int __count;
122 int __owner;
123#if !__PTHREAD_MUTEX_NUSERS_AFTER_KIND
124 unsigned int __nusers;
125#endif
126 /* KIND must stay at this position in the structure to maintain
127 binary compatibility with static initializers.
128
129 Concurrency notes:
130 The __kind of a mutex is initialized either by the static
131 PTHREAD_MUTEX_INITIALIZER or by a call to pthread_mutex_init.
132
133 After a mutex has been initialized, the __kind of a mutex is usually not
134 changed. BUT it can be set to -1 in pthread_mutex_destroy or elision can
135 be enabled. This is done concurrently in the pthread_mutex_*lock functions
136 by using the macro FORCE_ELISION. This macro is only defined for
137 architectures which supports lock elision.
138
139 For elision, there are the flags PTHREAD_MUTEX_ELISION_NP and
140 PTHREAD_MUTEX_NO_ELISION_NP which can be set in addition to the already set
141 type of a mutex.
142 Before a mutex is initialized, only PTHREAD_MUTEX_NO_ELISION_NP can be set
143 with pthread_mutexattr_settype.
144 After a mutex has been initialized, the functions pthread_mutex_*lock can
145 enable elision - if the mutex-type and the machine supports it - by setting
146 the flag PTHREAD_MUTEX_ELISION_NP. This is done concurrently. Afterwards
147 the lock / unlock functions are using specific elision code-paths. */
148 int __kind;
149 __PTHREAD_COMPAT_PADDING_MID
150#if __PTHREAD_MUTEX_NUSERS_AFTER_KIND
151 unsigned int __nusers;
152#endif
153#if !__PTHREAD_MUTEX_USE_UNION
154 __PTHREAD_SPINS_DATA;
155 __pthread_list_t __list;
156# define __PTHREAD_MUTEX_HAVE_PREV 1
157#else
158 __extension__ union
159 {
160 __PTHREAD_SPINS_DATA;
161 __pthread_slist_t __list;
162 };
163# define __PTHREAD_MUTEX_HAVE_PREV 0
164#endif
165 __PTHREAD_COMPAT_PADDING_END
166};
167
168
169/* Common definition of pthread_cond_t. */
170
171struct __pthread_cond_s
172{
173 __extension__ union
174 {
175 __extension__ unsigned long long int __wseq;
176 struct
177 {
178 unsigned int __low;
179 unsigned int __high;
180 } __wseq32;
181 };
182 __extension__ union
183 {
184 __extension__ unsigned long long int __g1_start;
185 struct
186 {
187 unsigned int __low;
188 unsigned int __high;
189 } __g1_start32;
190 };
191 unsigned int __g_refs[2] __LOCK_ALIGNMENT;
192 unsigned int __g_size[2];
193 unsigned int __g1_orig_size;
194 unsigned int __wrefs;
195 unsigned int __g_signals[2];
196};
197
198#endif /* _THREAD_SHARED_TYPES_H */
libc/glibc-include/bits/time.h created+83
...@@ -0,0 +1,83 @@
1/* System-dependent timing definitions. Linux version.
2 Copyright (C) 1996-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19/*
20 * Never include this file directly; use <time.h> instead.
21 */
22
23#ifndef _BITS_TIME_H
24#define _BITS_TIME_H 1
25
26#include <bits/types.h>
27
28/* ISO/IEC 9899:1999 7.23.1: Components of time
29 The macro `CLOCKS_PER_SEC' is an expression with type `clock_t' that is
30 the number per second of the value returned by the `clock' function. */
31/* CAE XSH, Issue 4, Version 2: <time.h>
32 The value of CLOCKS_PER_SEC is required to be 1 million on all
33 XSI-conformant systems. */
34#define CLOCKS_PER_SEC ((__clock_t) 1000000)
35
36#if (!defined __STRICT_ANSI__ || defined __USE_POSIX) \
37 && !defined __USE_XOPEN2K
38/* Even though CLOCKS_PER_SEC has such a strange value CLK_TCK
39 presents the real value for clock ticks per second for the system. */
40extern long int __sysconf (int);
41# define CLK_TCK ((__clock_t) __sysconf (2)) /* 2 is _SC_CLK_TCK */
42#endif
43
44#ifdef __USE_POSIX199309
45/* Identifier for system-wide realtime clock. */
46# define CLOCK_REALTIME 0
47/* Monotonic system-wide clock. */
48# define CLOCK_MONOTONIC 1
49/* High-resolution timer from the CPU. */
50# define CLOCK_PROCESS_CPUTIME_ID 2
51/* Thread-specific CPU-time clock. */
52# define CLOCK_THREAD_CPUTIME_ID 3
53/* Monotonic system-wide clock, not adjusted for frequency scaling. */
54# define CLOCK_MONOTONIC_RAW 4
55/* Identifier for system-wide realtime clock, updated only on ticks. */
56# define CLOCK_REALTIME_COARSE 5
57/* Monotonic system-wide clock, updated only on ticks. */
58# define CLOCK_MONOTONIC_COARSE 6
59/* Monotonic system-wide clock that includes time spent in suspension. */
60# define CLOCK_BOOTTIME 7
61/* Like CLOCK_REALTIME but also wakes suspended system. */
62# define CLOCK_REALTIME_ALARM 8
63/* Like CLOCK_BOOTTIME but also wakes suspended system. */
64# define CLOCK_BOOTTIME_ALARM 9
65/* Like CLOCK_REALTIME but in International Atomic Time. */
66# define CLOCK_TAI 11
67
68/* Flag to indicate time is absolute. */
69# define TIMER_ABSTIME 1
70#endif
71
72#ifdef __USE_GNU
73# include <bits/timex.h>
74
75__BEGIN_DECLS
76
77/* Tune a POSIX clock. */
78extern int clock_adjtime (__clockid_t __clock_id, struct timex *__utx) __THROW;
79
80__END_DECLS
81#endif /* use GNU */
82
83#endif /* bits/time.h */
libc/glibc-include/bits/time64.h created+36
...@@ -0,0 +1,36 @@
1/* bits/time64.h -- underlying types for __time64_t. Generic version.
2 Copyright (C) 2018-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_TYPES_H
20# error "Never include <bits/time64.h> directly; use <sys/types.h> instead."
21#endif
22
23#ifndef _BITS_TIME64_H
24#define _BITS_TIME64_H 1
25
26/* Define __TIME64_T_TYPE so that it is always a 64-bit type. */
27
28#if __TIMESIZE == 64
29/* If we already have 64-bit time type then use it. */
30# define __TIME64_T_TYPE __TIME_T_TYPE
31#else
32/* Define a 64-bit time type alongsize the 32-bit one. */
33# define __TIME64_T_TYPE __SQUAD_TYPE
34#endif
35
36#endif /* bits/time64.h */
libc/glibc-include/bits/timerfd.h created+29
...@@ -0,0 +1,29 @@
1/* Copyright (C) 2008-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_TIMERFD_H
19# error "Never use <bits/timerfd.h> directly; include <sys/timerfd.h> instead."
20#endif
21
22/* Bits to be set in the FLAGS parameter of `timerfd_create'. */
23enum
24 {
25 TFD_CLOEXEC = 02000000,
26#define TFD_CLOEXEC TFD_CLOEXEC
27 TFD_NONBLOCK = 00004000
28#define TFD_NONBLOCK TFD_NONBLOCK
29 };
libc/glibc-include/bits/timesize.h created+25
...@@ -0,0 +1,25 @@
1/* Bit size of the time_t type at glibc build time, x86-64 and x32 case.
2 Copyright (C) 2018-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#if defined __x86_64__ && defined __ILP32__
20/* For x32, time is 64-bit even though word size is 32-bit. */
21# define __TIMESIZE 64
22#else
23/* For others, time size is word size. */
24# define __TIMESIZE __WORDSIZE
25#endif
libc/glibc-include/bits/timex.h created+110
...@@ -0,0 +1,110 @@
1/* Copyright (C) 1995-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _BITS_TIMEX_H
19#define _BITS_TIMEX_H 1
20
21#include <bits/types.h>
22#include <bits/types/struct_timeval.h>
23
24/* These definitions from linux/timex.h as of 3.18. */
25
26struct timex
27{
28 unsigned int modes; /* mode selector */
29 __syscall_slong_t offset; /* time offset (usec) */
30 __syscall_slong_t freq; /* frequency offset (scaled ppm) */
31 __syscall_slong_t maxerror; /* maximum error (usec) */
32 __syscall_slong_t esterror; /* estimated error (usec) */
33 int status; /* clock command/status */
34 __syscall_slong_t constant; /* pll time constant */
35 __syscall_slong_t precision; /* clock precision (usec) (ro) */
36 __syscall_slong_t tolerance; /* clock frequency tolerance (ppm) (ro) */
37 struct timeval time; /* (read only, except for ADJ_SETOFFSET) */
38 __syscall_slong_t tick; /* (modified) usecs between clock ticks */
39 __syscall_slong_t ppsfreq; /* pps frequency (scaled ppm) (ro) */
40 __syscall_slong_t jitter; /* pps jitter (us) (ro) */
41 int shift; /* interval duration (s) (shift) (ro) */
42 __syscall_slong_t stabil; /* pps stability (scaled ppm) (ro) */
43 __syscall_slong_t jitcnt; /* jitter limit exceeded (ro) */
44 __syscall_slong_t calcnt; /* calibration intervals (ro) */
45 __syscall_slong_t errcnt; /* calibration errors (ro) */
46 __syscall_slong_t stbcnt; /* stability limit exceeded (ro) */
47
48 int tai; /* TAI offset (ro) */
49
50 /* ??? */
51 int :32; int :32; int :32; int :32;
52 int :32; int :32; int :32; int :32;
53 int :32; int :32; int :32;
54};
55
56/* Mode codes (timex.mode) */
57#define ADJ_OFFSET 0x0001 /* time offset */
58#define ADJ_FREQUENCY 0x0002 /* frequency offset */
59#define ADJ_MAXERROR 0x0004 /* maximum time error */
60#define ADJ_ESTERROR 0x0008 /* estimated time error */
61#define ADJ_STATUS 0x0010 /* clock status */
62#define ADJ_TIMECONST 0x0020 /* pll time constant */
63#define ADJ_TAI 0x0080 /* set TAI offset */
64#define ADJ_SETOFFSET 0x0100 /* add 'time' to current time */
65#define ADJ_MICRO 0x1000 /* select microsecond resolution */
66#define ADJ_NANO 0x2000 /* select nanosecond resolution */
67#define ADJ_TICK 0x4000 /* tick value */
68#define ADJ_OFFSET_SINGLESHOT 0x8001 /* old-fashioned adjtime */
69#define ADJ_OFFSET_SS_READ 0xa001 /* read-only adjtime */
70
71/* xntp 3.4 compatibility names */
72#define MOD_OFFSET ADJ_OFFSET
73#define MOD_FREQUENCY ADJ_FREQUENCY
74#define MOD_MAXERROR ADJ_MAXERROR
75#define MOD_ESTERROR ADJ_ESTERROR
76#define MOD_STATUS ADJ_STATUS
77#define MOD_TIMECONST ADJ_TIMECONST
78#define MOD_CLKB ADJ_TICK
79#define MOD_CLKA ADJ_OFFSET_SINGLESHOT /* 0x8000 in original */
80#define MOD_TAI ADJ_TAI
81#define MOD_MICRO ADJ_MICRO
82#define MOD_NANO ADJ_NANO
83
84
85/* Status codes (timex.status) */
86#define STA_PLL 0x0001 /* enable PLL updates (rw) */
87#define STA_PPSFREQ 0x0002 /* enable PPS freq discipline (rw) */
88#define STA_PPSTIME 0x0004 /* enable PPS time discipline (rw) */
89#define STA_FLL 0x0008 /* select frequency-lock mode (rw) */
90
91#define STA_INS 0x0010 /* insert leap (rw) */
92#define STA_DEL 0x0020 /* delete leap (rw) */
93#define STA_UNSYNC 0x0040 /* clock unsynchronized (rw) */
94#define STA_FREQHOLD 0x0080 /* hold frequency (rw) */
95
96#define STA_PPSSIGNAL 0x0100 /* PPS signal present (ro) */
97#define STA_PPSJITTER 0x0200 /* PPS signal jitter exceeded (ro) */
98#define STA_PPSWANDER 0x0400 /* PPS signal wander exceeded (ro) */
99#define STA_PPSERROR 0x0800 /* PPS signal calibration error (ro) */
100
101#define STA_CLOCKERR 0x1000 /* clock hardware fault (ro) */
102#define STA_NANO 0x2000 /* resolution (0 = us, 1 = ns) (ro) */
103#define STA_MODE 0x4000 /* mode (0 = PLL, 1 = FLL) (ro) */
104#define STA_CLK 0x8000 /* clock source (0 = A, 1 = B) (ro) */
105
106/* Read-only bits */
107#define STA_RONLY (STA_PPSSIGNAL | STA_PPSJITTER | STA_PPSWANDER | \
108 STA_PPSERROR | STA_CLOCKERR | STA_NANO | STA_MODE | STA_CLK)
109
110#endif /* bits/timex.h */
libc/glibc-include/bits/types.h created+224
...@@ -0,0 +1,224 @@
1/* bits/types.h -- definitions of __*_t types underlying *_t types.
2 Copyright (C) 2002-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19/*
20 * Never include this file directly; use <sys/types.h> instead.
21 */
22
23#ifndef _BITS_TYPES_H
24#define _BITS_TYPES_H 1
25
26#include <features.h>
27#include <bits/wordsize.h>
28#include <bits/timesize.h>
29
30/* Convenience types. */
31typedef unsigned char __u_char;
32typedef unsigned short int __u_short;
33typedef unsigned int __u_int;
34typedef unsigned long int __u_long;
35
36/* Fixed-size types, underlying types depend on word size and compiler. */
37typedef signed char __int8_t;
38typedef unsigned char __uint8_t;
39typedef signed short int __int16_t;
40typedef unsigned short int __uint16_t;
41typedef signed int __int32_t;
42typedef unsigned int __uint32_t;
43#if __WORDSIZE == 64
44typedef signed long int __int64_t;
45typedef unsigned long int __uint64_t;
46#else
47__extension__ typedef signed long long int __int64_t;
48__extension__ typedef unsigned long long int __uint64_t;
49#endif
50
51/* Smallest types with at least a given width. */
52typedef __int8_t __int_least8_t;
53typedef __uint8_t __uint_least8_t;
54typedef __int16_t __int_least16_t;
55typedef __uint16_t __uint_least16_t;
56typedef __int32_t __int_least32_t;
57typedef __uint32_t __uint_least32_t;
58typedef __int64_t __int_least64_t;
59typedef __uint64_t __uint_least64_t;
60
61/* quad_t is also 64 bits. */
62#if __WORDSIZE == 64
63typedef long int __quad_t;
64typedef unsigned long int __u_quad_t;
65#else
66__extension__ typedef long long int __quad_t;
67__extension__ typedef unsigned long long int __u_quad_t;
68#endif
69
70/* Largest integral types. */
71#if __WORDSIZE == 64
72typedef long int __intmax_t;
73typedef unsigned long int __uintmax_t;
74#else
75__extension__ typedef long long int __intmax_t;
76__extension__ typedef unsigned long long int __uintmax_t;
77#endif
78
79
80/* The machine-dependent file <bits/typesizes.h> defines __*_T_TYPE
81 macros for each of the OS types we define below. The definitions
82 of those macros must use the following macros for underlying types.
83 We define __S<SIZE>_TYPE and __U<SIZE>_TYPE for the signed and unsigned
84 variants of each of the following integer types on this machine.
85
86 16 -- "natural" 16-bit type (always short)
87 32 -- "natural" 32-bit type (always int)
88 64 -- "natural" 64-bit type (long or long long)
89 LONG32 -- 32-bit type, traditionally long
90 QUAD -- 64-bit type, always long long
91 WORD -- natural type of __WORDSIZE bits (int or long)
92 LONGWORD -- type of __WORDSIZE bits, traditionally long
93
94 We distinguish WORD/LONGWORD, 32/LONG32, and 64/QUAD so that the
95 conventional uses of `long' or `long long' type modifiers match the
96 types we define, even when a less-adorned type would be the same size.
97 This matters for (somewhat) portably writing printf/scanf formats for
98 these types, where using the appropriate l or ll format modifiers can
99 make the typedefs and the formats match up across all GNU platforms. If
100 we used `long' when it's 64 bits where `long long' is expected, then the
101 compiler would warn about the formats not matching the argument types,
102 and the programmer changing them to shut up the compiler would break the
103 program's portability.
104
105 Here we assume what is presently the case in all the GCC configurations
106 we support: long long is always 64 bits, long is always word/address size,
107 and int is always 32 bits. */
108
109#define __S16_TYPE short int
110#define __U16_TYPE unsigned short int
111#define __S32_TYPE int
112#define __U32_TYPE unsigned int
113#define __SLONGWORD_TYPE long int
114#define __ULONGWORD_TYPE unsigned long int
115#if __WORDSIZE == 32
116# define __SQUAD_TYPE __quad_t
117# define __UQUAD_TYPE __u_quad_t
118# define __SWORD_TYPE int
119# define __UWORD_TYPE unsigned int
120# define __SLONG32_TYPE long int
121# define __ULONG32_TYPE unsigned long int
122# define __S64_TYPE __quad_t
123# define __U64_TYPE __u_quad_t
124/* We want __extension__ before typedef's that use nonstandard base types
125 such as `long long' in C89 mode. */
126# define __STD_TYPE __extension__ typedef
127#elif __WORDSIZE == 64
128# define __SQUAD_TYPE long int
129# define __UQUAD_TYPE unsigned long int
130# define __SWORD_TYPE long int
131# define __UWORD_TYPE unsigned long int
132# define __SLONG32_TYPE int
133# define __ULONG32_TYPE unsigned int
134# define __S64_TYPE long int
135# define __U64_TYPE unsigned long int
136/* No need to mark the typedef with __extension__. */
137# define __STD_TYPE typedef
138#else
139# error
140#endif
141#include <bits/typesizes.h> /* Defines __*_T_TYPE macros. */
142#include <bits/time64.h> /* Defines __TIME*_T_TYPE macros. */
143
144
145__STD_TYPE __DEV_T_TYPE __dev_t; /* Type of device numbers. */
146__STD_TYPE __UID_T_TYPE __uid_t; /* Type of user identifications. */
147__STD_TYPE __GID_T_TYPE __gid_t; /* Type of group identifications. */
148__STD_TYPE __INO_T_TYPE __ino_t; /* Type of file serial numbers. */
149__STD_TYPE __INO64_T_TYPE __ino64_t; /* Type of file serial numbers (LFS).*/
150__STD_TYPE __MODE_T_TYPE __mode_t; /* Type of file attribute bitmasks. */
151__STD_TYPE __NLINK_T_TYPE __nlink_t; /* Type of file link counts. */
152__STD_TYPE __OFF_T_TYPE __off_t; /* Type of file sizes and offsets. */
153__STD_TYPE __OFF64_T_TYPE __off64_t; /* Type of file sizes and offsets (LFS). */
154__STD_TYPE __PID_T_TYPE __pid_t; /* Type of process identifications. */
155__STD_TYPE __FSID_T_TYPE __fsid_t; /* Type of file system IDs. */
156__STD_TYPE __CLOCK_T_TYPE __clock_t; /* Type of CPU usage counts. */
157__STD_TYPE __RLIM_T_TYPE __rlim_t; /* Type for resource measurement. */
158__STD_TYPE __RLIM64_T_TYPE __rlim64_t; /* Type for resource measurement (LFS). */
159__STD_TYPE __ID_T_TYPE __id_t; /* General type for IDs. */
160__STD_TYPE __TIME_T_TYPE __time_t; /* Seconds since the Epoch. */
161__STD_TYPE __USECONDS_T_TYPE __useconds_t; /* Count of microseconds. */
162__STD_TYPE __SUSECONDS_T_TYPE __suseconds_t; /* Signed count of microseconds. */
163
164__STD_TYPE __DADDR_T_TYPE __daddr_t; /* The type of a disk address. */
165__STD_TYPE __KEY_T_TYPE __key_t; /* Type of an IPC key. */
166
167/* Clock ID used in clock and timer functions. */
168__STD_TYPE __CLOCKID_T_TYPE __clockid_t;
169
170/* Timer ID returned by `timer_create'. */
171__STD_TYPE __TIMER_T_TYPE __timer_t;
172
173/* Type to represent block size. */
174__STD_TYPE __BLKSIZE_T_TYPE __blksize_t;
175
176/* Types from the Large File Support interface. */
177
178/* Type to count number of disk blocks. */
179__STD_TYPE __BLKCNT_T_TYPE __blkcnt_t;
180__STD_TYPE __BLKCNT64_T_TYPE __blkcnt64_t;
181
182/* Type to count file system blocks. */
183__STD_TYPE __FSBLKCNT_T_TYPE __fsblkcnt_t;
184__STD_TYPE __FSBLKCNT64_T_TYPE __fsblkcnt64_t;
185
186/* Type to count file system nodes. */
187__STD_TYPE __FSFILCNT_T_TYPE __fsfilcnt_t;
188__STD_TYPE __FSFILCNT64_T_TYPE __fsfilcnt64_t;
189
190/* Type of miscellaneous file system fields. */
191__STD_TYPE __FSWORD_T_TYPE __fsword_t;
192
193__STD_TYPE __SSIZE_T_TYPE __ssize_t; /* Type of a byte count, or error. */
194
195/* Signed long type used in system calls. */
196__STD_TYPE __SYSCALL_SLONG_TYPE __syscall_slong_t;
197/* Unsigned long type used in system calls. */
198__STD_TYPE __SYSCALL_ULONG_TYPE __syscall_ulong_t;
199
200/* These few don't really vary by system, they always correspond
201 to one of the other defined types. */
202typedef __off64_t __loff_t; /* Type of file sizes and offsets (LFS). */
203typedef char *__caddr_t;
204
205/* Duplicates info from stdint.h but this is used in unistd.h. */
206__STD_TYPE __SWORD_TYPE __intptr_t;
207
208/* Duplicate info from sys/socket.h. */
209__STD_TYPE __U32_TYPE __socklen_t;
210
211/* C99: An integer type that can be accessed as an atomic entity,
212 even in the presence of asynchronous interrupts.
213 It is not currently necessary for this to be machine-specific. */
214typedef int __sig_atomic_t;
215
216#if __TIMESIZE == 64
217# define __time64_t __time_t
218#else
219__STD_TYPE __TIME64_T_TYPE __time64_t; /* Seconds since the Epoch. */
220#endif
221
222#undef __STD_TYPE
223
224#endif /* bits/types.h */
libc/glibc-include/bits/types/FILE.h created+9
...@@ -0,0 +1,9 @@
1#ifndef __FILE_defined
2#define __FILE_defined 1
3
4struct _IO_FILE;
5
6/* The opaque type of streams. This is the definition used elsewhere. */
7typedef struct _IO_FILE FILE;
8
9#endif
libc/glibc-include/bits/types/__FILE.h created+7
...@@ -0,0 +1,7 @@
1#ifndef ____FILE_defined
2#define ____FILE_defined 1
3
4struct _IO_FILE;
5typedef struct _IO_FILE __FILE;
6
7#endif
libc/glibc-include/bits/types/__fpos64_t.h created+16
...@@ -0,0 +1,16 @@
1#ifndef _____fpos64_t_defined
2#define _____fpos64_t_defined 1
3
4#include <bits/types.h>
5#include <bits/types/__mbstate_t.h>
6
7/* The tag name of this struct is _G_fpos64_t to preserve historic
8 C++ mangled names for functions taking fpos_t and/or fpos64_t
9 arguments. That name should not be used in new code. */
10typedef struct _G_fpos64_t
11{
12 __off64_t __pos;
13 __mbstate_t __state;
14} __fpos64_t;
15
16#endif
libc/glibc-include/bits/types/__fpos_t.h created+16
...@@ -0,0 +1,16 @@
1#ifndef _____fpos_t_defined
2#define _____fpos_t_defined 1
3
4#include <bits/types.h>
5#include <bits/types/__mbstate_t.h>
6
7/* The tag name of this struct is _G_fpos_t to preserve historic
8 C++ mangled names for functions taking fpos_t arguments.
9 That name should not be used in new code. */
10typedef struct _G_fpos_t
11{
12 __off_t __pos;
13 __mbstate_t __state;
14} __fpos_t;
15
16#endif
libc/glibc-include/bits/types/__locale_t.h created+44
...@@ -0,0 +1,44 @@
1/* Definition of struct __locale_struct and __locale_t.
2 Copyright (C) 1997-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
19
20#ifndef _BITS_TYPES___LOCALE_T_H
21#define _BITS_TYPES___LOCALE_T_H 1
22
23/* POSIX.1-2008: the locale_t type, representing a locale context
24 (implementation-namespace version). This type should be treated
25 as opaque by applications; some details are exposed for the sake of
26 efficiency in e.g. ctype functions. */
27
28struct __locale_struct
29{
30 /* Note: LC_ALL is not a valid index into this array. */
31 struct __locale_data *__locales[13]; /* 13 = __LC_LAST. */
32
33 /* To increase the speed of this solution we add some special members. */
34 const unsigned short int *__ctype_b;
35 const int *__ctype_tolower;
36 const int *__ctype_toupper;
37
38 /* Note: LC_ALL is not a valid index into this array. */
39 const char *__names[13];
40};
41
42typedef struct __locale_struct *__locale_t;
43
44#endif /* bits/types/__locale_t.h */
libc/glibc-include/bits/types/__mbstate_t.h created+23
...@@ -0,0 +1,23 @@
1#ifndef ____mbstate_t_defined
2#define ____mbstate_t_defined 1
3
4/* Integral type unchanged by default argument promotions that can
5 hold any value corresponding to members of the extended character
6 set, as well as at least one value that does not correspond to any
7 member of the extended character set. */
8#ifndef __WINT_TYPE__
9# define __WINT_TYPE__ unsigned int
10#endif
11
12/* Conversion state information. */
13typedef struct
14{
15 int __count;
16 union
17 {
18 __WINT_TYPE__ __wch;
19 char __wchb[4];
20 } __value; /* Value so far. */
21} __mbstate_t;
22
23#endif
libc/glibc-include/bits/types/__sigset_t.h created+10
...@@ -0,0 +1,10 @@
1#ifndef ____sigset_t_defined
2#define ____sigset_t_defined
3
4#define _SIGSET_NWORDS (1024 / (8 * sizeof (unsigned long int)))
5typedef struct
6{
7 unsigned long int __val[_SIGSET_NWORDS];
8} __sigset_t;
9
10#endif
libc/glibc-include/bits/types/__sigval_t.h created+41
...@@ -0,0 +1,41 @@
1/* Define __sigval_t.
2 Copyright (C) 1997-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef ____sigval_t_defined
20#define ____sigval_t_defined
21
22/* Type for data associated with a signal. */
23#ifdef __USE_POSIX199309
24union sigval
25{
26 int sival_int;
27 void *sival_ptr;
28};
29
30typedef union sigval __sigval_t;
31#else
32union __sigval
33{
34 int __sival_int;
35 void *__sival_ptr;
36};
37
38typedef union __sigval __sigval_t;
39#endif
40
41#endif
libc/glibc-include/bits/types/clock_t.h created+9
...@@ -0,0 +1,9 @@
1#ifndef __clock_t_defined
2#define __clock_t_defined 1
3
4#include <bits/types.h>
5
6/* Returned by `clock'. */
7typedef __clock_t clock_t;
8
9#endif
libc/glibc-include/bits/types/clockid_t.h created+9
...@@ -0,0 +1,9 @@
1#ifndef __clockid_t_defined
2#define __clockid_t_defined 1
3
4#include <bits/types.h>
5
6/* Clock ID used in clock and timer functions. */
7typedef __clockid_t clockid_t;
8
9#endif
libc/glibc-include/bits/types/cookie_io_functions_t.h created+63
...@@ -0,0 +1,63 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef __cookie_io_functions_t_defined
19#define __cookie_io_functions_t_defined 1
20
21#include <bits/types.h>
22
23/* Functions to do I/O and file management for a stream. */
24
25/* Read NBYTES bytes from COOKIE into a buffer pointed to by BUF.
26 Return number of bytes read. */
27typedef __ssize_t cookie_read_function_t (void *__cookie, char *__buf,
28 size_t __nbytes);
29
30/* Write NBYTES bytes pointed to by BUF to COOKIE. Write all NBYTES bytes
31 unless there is an error. Return number of bytes written. If
32 there is an error, return 0 and do not write anything. If the file
33 has been opened for append (__mode.__append set), then set the file
34 pointer to the end of the file and then do the write; if not, just
35 write at the current file pointer. */
36typedef __ssize_t cookie_write_function_t (void *__cookie, const char *__buf,
37 size_t __nbytes);
38
39/* Move COOKIE's file position to *POS bytes from the
40 beginning of the file (if W is SEEK_SET),
41 the current position (if W is SEEK_CUR),
42 or the end of the file (if W is SEEK_END).
43 Set *POS to the new file position.
44 Returns zero if successful, nonzero if not. */
45typedef int cookie_seek_function_t (void *__cookie, __off64_t *__pos, int __w);
46
47/* Close COOKIE. */
48typedef int cookie_close_function_t (void *__cookie);
49
50/* The structure with the cookie function pointers.
51 The tag name of this struct is _IO_cookie_io_functions_t to
52 preserve historic C++ mangled names for functions taking
53 cookie_io_functions_t arguments. That name should not be used in
54 new code. */
55typedef struct _IO_cookie_io_functions_t
56{
57 cookie_read_function_t *read; /* Read bytes. */
58 cookie_write_function_t *write; /* Write bytes. */
59 cookie_seek_function_t *seek; /* Seek/tell file position. */
60 cookie_close_function_t *close; /* Close file. */
61} cookie_io_functions_t;
62
63#endif
libc/glibc-include/bits/types/error_t.h created+24
...@@ -0,0 +1,24 @@
1/* Define error_t.
2 Copyright (C) 1991-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef __error_t_defined
20# define __error_t_defined 1
21
22typedef int error_t;
23
24#endif
libc/glibc-include/bits/types/locale_t.h created+26
...@@ -0,0 +1,26 @@
1/* Definition of locale_t.
2 Copyright (C) 2017-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_TYPES_LOCALE_T_H
20#define _BITS_TYPES_LOCALE_T_H 1
21
22#include <bits/types/__locale_t.h>
23
24typedef __locale_t locale_t;
25
26#endif /* bits/types/locale_t.h */
libc/glibc-include/bits/types/mbstate_t.h created+8
...@@ -0,0 +1,8 @@
1#ifndef __mbstate_t_defined
2#define __mbstate_t_defined 1
3
4#include <bits/types/__mbstate_t.h>
5
6typedef __mbstate_t mbstate_t;
7
8#endif
libc/glibc-include/bits/types/res_state.h created+61
...@@ -0,0 +1,61 @@
1#ifndef __res_state_defined
2#define __res_state_defined 1
3
4#include <sys/types.h>
5#include <netinet/in.h>
6
7/* res_state: the global state used by the resolver stub. */
8#define MAXNS 3 /* max # name servers we'll track */
9#define MAXDFLSRCH 3 /* # default domain levels to try */
10#define MAXDNSRCH 6 /* max # domains in search path */
11#define MAXRESOLVSORT 10 /* number of net to sort on */
12
13struct __res_state {
14 int retrans; /* retransmition time interval */
15 int retry; /* number of times to retransmit */
16 unsigned long options; /* option flags - see below. */
17 int nscount; /* number of name servers */
18 struct sockaddr_in
19 nsaddr_list[MAXNS]; /* address of name server */
20 unsigned short id; /* current message id */
21 /* 2 byte hole here. */
22 char *dnsrch[MAXDNSRCH+1]; /* components of domain to search */
23 char defdname[256]; /* default domain (deprecated) */
24 unsigned long pfcode; /* RES_PRF_ flags - see below. */
25 unsigned ndots:4; /* threshold for initial abs. query */
26 unsigned nsort:4; /* number of elements in sort_list[] */
27 unsigned ipv6_unavail:1; /* connecting to IPv6 server failed */
28 unsigned unused:23;
29 struct {
30 struct in_addr addr;
31 uint32_t mask;
32 } sort_list[MAXRESOLVSORT];
33 /* 4 byte hole here on 64-bit architectures. */
34 void * __glibc_unused_qhook;
35 void * __glibc_unused_rhook;
36 int res_h_errno; /* last one set for this context */
37 int _vcsock; /* PRIVATE: for res_send VC i/o */
38 unsigned int _flags; /* PRIVATE: see below */
39 /* 4 byte hole here on 64-bit architectures. */
40 union {
41 char pad[52]; /* On an i386 this means 512b total. */
42 struct {
43 uint16_t nscount;
44 uint16_t nsmap[MAXNS];
45 int nssocks[MAXNS];
46 uint16_t nscount6;
47 uint16_t nsinit;
48 struct sockaddr_in6 *nsaddrs[MAXNS];
49#ifdef _LIBC
50 unsigned long long int __glibc_extension_index
51 __attribute__((packed));
52#else
53 unsigned int __glibc_reserved[2];
54#endif
55 } _ext;
56 } _u;
57};
58
59typedef struct __res_state *res_state;
60
61#endif /* __res_state_defined */
libc/glibc-include/bits/types/sig_atomic_t.h created+10
...@@ -0,0 +1,10 @@
1#ifndef __sig_atomic_t_defined
2#define __sig_atomic_t_defined 1
3
4#include <bits/types.h>
5
6/* An integral type that can be modified atomically, without the
7 possibility of a signal arriving in the middle of the operation. */
8typedef __sig_atomic_t sig_atomic_t;
9
10#endif
libc/glibc-include/bits/types/sigevent_t.h created+48
...@@ -0,0 +1,48 @@
1#ifndef __sigevent_t_defined
2#define __sigevent_t_defined 1
3
4#include <bits/wordsize.h>
5#include <bits/types.h>
6#include <bits/types/__sigval_t.h>
7
8#define __SIGEV_MAX_SIZE 64
9#if __WORDSIZE == 64
10# define __SIGEV_PAD_SIZE ((__SIGEV_MAX_SIZE / sizeof (int)) - 4)
11#else
12# define __SIGEV_PAD_SIZE ((__SIGEV_MAX_SIZE / sizeof (int)) - 3)
13#endif
14
15/* Forward declaration. */
16#ifndef __have_pthread_attr_t
17typedef union pthread_attr_t pthread_attr_t;
18# define __have_pthread_attr_t 1
19#endif
20
21/* Structure to transport application-defined values with signals. */
22typedef struct sigevent
23 {
24 __sigval_t sigev_value;
25 int sigev_signo;
26 int sigev_notify;
27
28 union
29 {
30 int _pad[__SIGEV_PAD_SIZE];
31
32 /* When SIGEV_SIGNAL and SIGEV_THREAD_ID set, LWP ID of the
33 thread to receive the signal. */
34 __pid_t _tid;
35
36 struct
37 {
38 void (*_function) (__sigval_t); /* Function to start. */
39 pthread_attr_t *_attribute; /* Thread attributes. */
40 } _sigev_thread;
41 } _sigev_un;
42 } sigevent_t;
43
44/* POSIX names to access some of the members. */
45#define sigev_notify_function _sigev_un._sigev_thread._function
46#define sigev_notify_attributes _sigev_un._sigev_thread._attribute
47
48#endif
libc/glibc-include/bits/types/siginfo_t.h created+151
...@@ -0,0 +1,151 @@
1#ifndef __siginfo_t_defined
2#define __siginfo_t_defined 1
3
4#include <bits/wordsize.h>
5#include <bits/types.h>
6#include <bits/types/__sigval_t.h>
7
8#define __SI_MAX_SIZE 128
9#if __WORDSIZE == 64
10# define __SI_PAD_SIZE ((__SI_MAX_SIZE / sizeof (int)) - 4)
11#else
12# define __SI_PAD_SIZE ((__SI_MAX_SIZE / sizeof (int)) - 3)
13#endif
14
15/* Some fields of siginfo_t have architecture-specific variations. */
16#include <bits/siginfo-arch.h>
17#ifndef __SI_ALIGNMENT
18# define __SI_ALIGNMENT /* nothing */
19#endif
20#ifndef __SI_BAND_TYPE
21# define __SI_BAND_TYPE long int
22#endif
23#ifndef __SI_CLOCK_T
24# define __SI_CLOCK_T __clock_t
25#endif
26#ifndef __SI_ERRNO_THEN_CODE
27# define __SI_ERRNO_THEN_CODE 1
28#endif
29#ifndef __SI_HAVE_SIGSYS
30# define __SI_HAVE_SIGSYS 1
31#endif
32#ifndef __SI_SIGFAULT_ADDL
33# define __SI_SIGFAULT_ADDL /* nothing */
34#endif
35
36typedef struct
37 {
38 int si_signo; /* Signal number. */
39#if __SI_ERRNO_THEN_CODE
40 int si_errno; /* If non-zero, an errno value associated with
41 this signal, as defined in <errno.h>. */
42 int si_code; /* Signal code. */
43#else
44 int si_code;
45 int si_errno;
46#endif
47#if __WORDSIZE == 64
48 int __pad0; /* Explicit padding. */
49#endif
50
51 union
52 {
53 int _pad[__SI_PAD_SIZE];
54
55 /* kill(). */
56 struct
57 {
58 __pid_t si_pid; /* Sending process ID. */
59 __uid_t si_uid; /* Real user ID of sending process. */
60 } _kill;
61
62 /* POSIX.1b timers. */
63 struct
64 {
65 int si_tid; /* Timer ID. */
66 int si_overrun; /* Overrun count. */
67 __sigval_t si_sigval; /* Signal value. */
68 } _timer;
69
70 /* POSIX.1b signals. */
71 struct
72 {
73 __pid_t si_pid; /* Sending process ID. */
74 __uid_t si_uid; /* Real user ID of sending process. */
75 __sigval_t si_sigval; /* Signal value. */
76 } _rt;
77
78 /* SIGCHLD. */
79 struct
80 {
81 __pid_t si_pid; /* Which child. */
82 __uid_t si_uid; /* Real user ID of sending process. */
83 int si_status; /* Exit value or signal. */
84 __SI_CLOCK_T si_utime;
85 __SI_CLOCK_T si_stime;
86 } _sigchld;
87
88 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS. */
89 struct
90 {
91 void *si_addr; /* Faulting insn/memory ref. */
92 __SI_SIGFAULT_ADDL
93 short int si_addr_lsb; /* Valid LSB of the reported address. */
94 union
95 {
96 /* used when si_code=SEGV_BNDERR */
97 struct
98 {
99 void *_lower;
100 void *_upper;
101 } _addr_bnd;
102 /* used when si_code=SEGV_PKUERR */
103 __uint32_t _pkey;
104 } _bounds;
105 } _sigfault;
106
107 /* SIGPOLL. */
108 struct
109 {
110 __SI_BAND_TYPE si_band; /* Band event for SIGPOLL. */
111 int si_fd;
112 } _sigpoll;
113
114 /* SIGSYS. */
115#if __SI_HAVE_SIGSYS
116 struct
117 {
118 void *_call_addr; /* Calling user insn. */
119 int _syscall; /* Triggering system call number. */
120 unsigned int _arch; /* AUDIT_ARCH_* of syscall. */
121 } _sigsys;
122#endif
123 } _sifields;
124 } siginfo_t __SI_ALIGNMENT;
125
126
127/* X/Open requires some more fields with fixed names. */
128#define si_pid _sifields._kill.si_pid
129#define si_uid _sifields._kill.si_uid
130#define si_timerid _sifields._timer.si_tid
131#define si_overrun _sifields._timer.si_overrun
132#define si_status _sifields._sigchld.si_status
133#define si_utime _sifields._sigchld.si_utime
134#define si_stime _sifields._sigchld.si_stime
135#define si_value _sifields._rt.si_sigval
136#define si_int _sifields._rt.si_sigval.sival_int
137#define si_ptr _sifields._rt.si_sigval.sival_ptr
138#define si_addr _sifields._sigfault.si_addr
139#define si_addr_lsb _sifields._sigfault.si_addr_lsb
140#define si_lower _sifields._sigfault._bounds._addr_bnd._lower
141#define si_upper _sifields._sigfault._bounds._addr_bnd._upper
142#define si_pkey _sifields._sigfault._bounds._pkey
143#define si_band _sifields._sigpoll.si_band
144#define si_fd _sifields._sigpoll.si_fd
145#if __SI_HAVE_SIGSYS
146# define si_call_addr _sifields._sigsys._call_addr
147# define si_syscall _sifields._sigsys._syscall
148# define si_arch _sifields._sigsys._arch
149#endif
150
151#endif
libc/glibc-include/bits/types/sigset_t.h created+9
...@@ -0,0 +1,9 @@
1#ifndef __sigset_t_defined
2#define __sigset_t_defined 1
3
4#include <bits/types/__sigset_t.h>
5
6/* A set of signals to be blocked, unblocked, or waited for. */
7typedef __sigset_t sigset_t;
8
9#endif
libc/glibc-include/bits/types/sigval_t.h created+18
...@@ -0,0 +1,18 @@
1#ifndef __sigval_t_defined
2#define __sigval_t_defined
3
4#include <bits/types/__sigval_t.h>
5
6/* To avoid sigval_t (not a standard type name) having C++ name
7 mangling depending on whether the selected standard includes union
8 sigval, it should not be defined at all when using a standard for
9 which the sigval name is not reserved; in that case, headers should
10 not include <bits/types/sigval_t.h> and should use only the
11 internal __sigval_t name. */
12#ifndef __USE_POSIX199309
13# error "sigval_t defined for standard not including union sigval"
14#endif
15
16typedef __sigval_t sigval_t;
17
18#endif
libc/glibc-include/bits/types/stack_t.h created+33
...@@ -0,0 +1,33 @@
1/* Define stack_t. Linux version.
2 Copyright (C) 1998-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef __stack_t_defined
20#define __stack_t_defined 1
21
22#define __need_size_t
23#include <stddef.h>
24
25/* Structure describing a signal stack. */
26typedef struct
27 {
28 void *ss_sp;
29 int ss_flags;
30 size_t ss_size;
31 } stack_t;
32
33#endif
libc/glibc-include/bits/types/struct_FILE.h created+120
...@@ -0,0 +1,120 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef __struct_FILE_defined
19#define __struct_FILE_defined 1
20
21/* Caution: The contents of this file are not part of the official
22 stdio.h API. However, much of it is part of the official *binary*
23 interface, and therefore cannot be changed. */
24
25#if defined _IO_USE_OLD_IO_FILE && !defined _LIBC
26# error "_IO_USE_OLD_IO_FILE should only be defined when building libc itself"
27#endif
28
29#if defined _IO_lock_t_defined && !defined _LIBC
30# error "_IO_lock_t_defined should only be defined when building libc itself"
31#endif
32
33#include <bits/types.h>
34
35struct _IO_FILE;
36struct _IO_marker;
37struct _IO_codecvt;
38struct _IO_wide_data;
39
40/* During the build of glibc itself, _IO_lock_t will already have been
41 defined by internal headers. */
42#ifndef _IO_lock_t_defined
43typedef void _IO_lock_t;
44#endif
45
46/* The tag name of this struct is _IO_FILE to preserve historic
47 C++ mangled names for functions taking FILE* arguments.
48 That name should not be used in new code. */
49struct _IO_FILE
50{
51 int _flags; /* High-order word is _IO_MAGIC; rest is flags. */
52
53 /* The following pointers correspond to the C++ streambuf protocol. */
54 char *_IO_read_ptr; /* Current read pointer */
55 char *_IO_read_end; /* End of get area. */
56 char *_IO_read_base; /* Start of putback+get area. */
57 char *_IO_write_base; /* Start of put area. */
58 char *_IO_write_ptr; /* Current put pointer. */
59 char *_IO_write_end; /* End of put area. */
60 char *_IO_buf_base; /* Start of reserve area. */
61 char *_IO_buf_end; /* End of reserve area. */
62
63 /* The following fields are used to support backing up and undo. */
64 char *_IO_save_base; /* Pointer to start of non-current get area. */
65 char *_IO_backup_base; /* Pointer to first valid character of backup area */
66 char *_IO_save_end; /* Pointer to end of non-current get area. */
67
68 struct _IO_marker *_markers;
69
70 struct _IO_FILE *_chain;
71
72 int _fileno;
73 int _flags2;
74 __off_t _old_offset; /* This used to be _offset but it's too small. */
75
76 /* 1+column number of pbase(); 0 is unknown. */
77 unsigned short _cur_column;
78 signed char _vtable_offset;
79 char _shortbuf[1];
80
81 _IO_lock_t *_lock;
82#ifdef _IO_USE_OLD_IO_FILE
83};
84
85struct _IO_FILE_complete
86{
87 struct _IO_FILE _file;
88#endif
89 __off64_t _offset;
90 /* Wide character stream stuff. */
91 struct _IO_codecvt *_codecvt;
92 struct _IO_wide_data *_wide_data;
93 struct _IO_FILE *_freeres_list;
94 void *_freeres_buf;
95 size_t __pad5;
96 int _mode;
97 /* Make sure we don't get into trouble again. */
98 char _unused2[15 * sizeof (int) - 4 * sizeof (void *) - sizeof (size_t)];
99};
100
101/* These macros are used by bits/stdio.h and internal headers. */
102#define __getc_unlocked_body(_fp) \
103 (__glibc_unlikely ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end) \
104 ? __uflow (_fp) : *(unsigned char *) (_fp)->_IO_read_ptr++)
105
106#define __putc_unlocked_body(_ch, _fp) \
107 (__glibc_unlikely ((_fp)->_IO_write_ptr >= (_fp)->_IO_write_end) \
108 ? __overflow (_fp, (unsigned char) (_ch)) \
109 : (unsigned char) (*(_fp)->_IO_write_ptr++ = (_ch)))
110
111#define _IO_EOF_SEEN 0x0010
112#define __feof_unlocked_body(_fp) (((_fp)->_flags & _IO_EOF_SEEN) != 0)
113
114#define _IO_ERR_SEEN 0x0020
115#define __ferror_unlocked_body(_fp) (((_fp)->_flags & _IO_ERR_SEEN) != 0)
116
117#define _IO_USER_LOCK 0x8000
118/* Many more flag bits are defined internally. */
119
120#endif
libc/glibc-include/bits/types/struct_iovec.h created+32
...@@ -0,0 +1,32 @@
1/* Define struct iovec.
2 Copyright (C) 1996-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef __iovec_defined
20#define __iovec_defined 1
21
22#define __need_size_t
23#include <stddef.h>
24
25/* Structure for scatter/gather I/O. */
26struct iovec
27 {
28 void *iov_base; /* Pointer to data. */
29 size_t iov_len; /* Length of data. */
30 };
31
32#endif
libc/glibc-include/bits/types/struct_itimerspec.h created+14
...@@ -0,0 +1,14 @@
1#ifndef __itimerspec_defined
2#define __itimerspec_defined 1
3
4#include <bits/types.h>
5#include <bits/types/struct_timespec.h>
6
7/* POSIX.1b structure for timer start values and intervals. */
8struct itimerspec
9 {
10 struct timespec it_interval;
11 struct timespec it_value;
12 };
13
14#endif
libc/glibc-include/bits/types/struct_osockaddr.h created+12
...@@ -0,0 +1,12 @@
1#ifndef __osockaddr_defined
2#define __osockaddr_defined 1
3
4/* This is the 4.3 BSD `struct sockaddr' format, which is used as wire
5 format in the grotty old 4.3 `talk' protocol. */
6struct osockaddr
7{
8 unsigned short int sa_family;
9 unsigned char sa_data[14];
10};
11
12#endif
libc/glibc-include/bits/types/struct_rusage.h created+131
...@@ -0,0 +1,131 @@
1/* Define struct rusage.
2 Copyright (C) 1994-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef __rusage_defined
20#define __rusage_defined 1
21
22#include <bits/types.h>
23#include <bits/types/struct_timeval.h>
24
25/* Structure which says how much of each resource has been used. If
26 the system does not keep track of a particular value, the struct
27 field is always zero. */
28
29/* The purpose of all the unions is to have the kernel-compatible layout
30 while keeping the API type as 'long int', and among machines where
31 __syscall_slong_t is not 'long int', this only does the right thing
32 for little-endian ones, like x32. */
33struct rusage
34 {
35 /* Total amount of user time used. */
36 struct timeval ru_utime;
37 /* Total amount of system time used. */
38 struct timeval ru_stime;
39 /* Maximum resident set size (in kilobytes). */
40 __extension__ union
41 {
42 long int ru_maxrss;
43 __syscall_slong_t __ru_maxrss_word;
44 };
45 /* Amount of sharing of text segment memory
46 with other processes (kilobyte-seconds). */
47 __extension__ union
48 {
49 long int ru_ixrss;
50 __syscall_slong_t __ru_ixrss_word;
51 };
52 /* Amount of data segment memory used (kilobyte-seconds). */
53 __extension__ union
54 {
55 long int ru_idrss;
56 __syscall_slong_t __ru_idrss_word;
57 };
58 /* Amount of stack memory used (kilobyte-seconds). */
59 __extension__ union
60 {
61 long int ru_isrss;
62 __syscall_slong_t __ru_isrss_word;
63 };
64 /* Number of soft page faults (i.e. those serviced by reclaiming
65 a page from the list of pages awaiting reallocation. */
66 __extension__ union
67 {
68 long int ru_minflt;
69 __syscall_slong_t __ru_minflt_word;
70 };
71 /* Number of hard page faults (i.e. those that required I/O). */
72 __extension__ union
73 {
74 long int ru_majflt;
75 __syscall_slong_t __ru_majflt_word;
76 };
77 /* Number of times a process was swapped out of physical memory. */
78 __extension__ union
79 {
80 long int ru_nswap;
81 __syscall_slong_t __ru_nswap_word;
82 };
83 /* Number of input operations via the file system. Note: This
84 and `ru_oublock' do not include operations with the cache. */
85 __extension__ union
86 {
87 long int ru_inblock;
88 __syscall_slong_t __ru_inblock_word;
89 };
90 /* Number of output operations via the file system. */
91 __extension__ union
92 {
93 long int ru_oublock;
94 __syscall_slong_t __ru_oublock_word;
95 };
96 /* Number of IPC messages sent. */
97 __extension__ union
98 {
99 long int ru_msgsnd;
100 __syscall_slong_t __ru_msgsnd_word;
101 };
102 /* Number of IPC messages received. */
103 __extension__ union
104 {
105 long int ru_msgrcv;
106 __syscall_slong_t __ru_msgrcv_word;
107 };
108 /* Number of signals delivered. */
109 __extension__ union
110 {
111 long int ru_nsignals;
112 __syscall_slong_t __ru_nsignals_word;
113 };
114 /* Number of voluntary context switches, i.e. because the process
115 gave up the process before it had to (usually to wait for some
116 resource to be available). */
117 __extension__ union
118 {
119 long int ru_nvcsw;
120 __syscall_slong_t __ru_nvcsw_word;
121 };
122 /* Number of involuntary context switches, i.e. a higher priority process
123 became runnable or the current process used up its time slice. */
124 __extension__ union
125 {
126 long int ru_nivcsw;
127 __syscall_slong_t __ru_nivcsw_word;
128 };
129 };
130
131#endif
libc/glibc-include/bits/types/struct_sched_param.h created+28
...@@ -0,0 +1,28 @@
1/* Sched parameter structure. Generic version.
2 Copyright (C) 1996-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_TYPES_STRUCT_SCHED_PARAM
20#define _BITS_TYPES_STRUCT_SCHED_PARAM 1
21
22/* Data structure to describe a process' schedulability. */
23struct sched_param
24{
25 int sched_priority;
26};
27
28#endif /* bits/types/struct_sched_param.h */
libc/glibc-include/bits/types/struct_sigstack.h created+29
...@@ -0,0 +1,29 @@
1/* Define struct sigstack.
2 Copyright (C) 1998-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef __sigstack_defined
20#define __sigstack_defined 1
21
22/* Structure describing a signal stack (obsolete). */
23struct sigstack
24 {
25 void *ss_sp; /* Signal stack pointer. */
26 int ss_onstack; /* Nonzero if executing on this stack. */
27 };
28
29#endif
libc/glibc-include/bits/types/struct_timespec.h created+15
...@@ -0,0 +1,15 @@
1/* NB: Include guard matches what <linux/time.h> uses. */
2#ifndef _STRUCT_TIMESPEC
3#define _STRUCT_TIMESPEC 1
4
5#include <bits/types.h>
6
7/* POSIX.1b structure for a time value. This is like a `struct timeval' but
8 has nanoseconds instead of microseconds. */
9struct timespec
10{
11 __time_t tv_sec; /* Seconds. */
12 __syscall_slong_t tv_nsec; /* Nanoseconds. */
13};
14
15#endif
libc/glibc-include/bits/types/struct_timeval.h created+13
...@@ -0,0 +1,13 @@
1#ifndef __timeval_defined
2#define __timeval_defined 1
3
4#include <bits/types.h>
5
6/* A time value that is accurate to the nearest
7 microsecond but also has a range of years. */
8struct timeval
9{
10 __time_t tv_sec; /* Seconds. */
11 __suseconds_t tv_usec; /* Microseconds. */
12};
13#endif
libc/glibc-include/bits/types/struct_tm.h created+28
...@@ -0,0 +1,28 @@
1#ifndef __struct_tm_defined
2#define __struct_tm_defined 1
3
4#include <bits/types.h>
5
6/* ISO C `broken-down time' structure. */
7struct tm
8{
9 int tm_sec; /* Seconds. [0-60] (1 leap second) */
10 int tm_min; /* Minutes. [0-59] */
11 int tm_hour; /* Hours. [0-23] */
12 int tm_mday; /* Day. [1-31] */
13 int tm_mon; /* Month. [0-11] */
14 int tm_year; /* Year - 1900. */
15 int tm_wday; /* Day of week. [0-6] */
16 int tm_yday; /* Days in year.[0-365] */
17 int tm_isdst; /* DST. [-1/0/1]*/
18
19# ifdef __USE_MISC
20 long int tm_gmtoff; /* Seconds east of UTC. */
21 const char *tm_zone; /* Timezone abbreviation. */
22# else
23 long int __tm_gmtoff; /* Seconds east of UTC. */
24 const char *__tm_zone; /* Timezone abbreviation. */
25# endif
26};
27
28#endif
libc/glibc-include/bits/types/time_t.h created+9
...@@ -0,0 +1,9 @@
1#ifndef __time_t_defined
2#define __time_t_defined 1
3
4#include <bits/types.h>
5
6/* Returned by `time'. */
7typedef __time_t time_t;
8
9#endif
libc/glibc-include/bits/types/timer_t.h created+9
...@@ -0,0 +1,9 @@
1#ifndef __timer_t_defined
2#define __timer_t_defined 1
3
4#include <bits/types.h>
5
6/* Timer ID returned by `timer_create'. */
7typedef __timer_t timer_t;
8
9#endif
libc/glibc-include/bits/types/wint_t.h created+23
...@@ -0,0 +1,23 @@
1#ifndef __wint_t_defined
2#define __wint_t_defined 1
3
4/* Some versions of stddef.h provide wint_t, even though neither the
5 C nor C++ standards, nor POSIX, specifies this. We assume that
6 stddef.h will define the macro _WINT_T if and only if it provides
7 wint_t, and conversely, that it will avoid providing wint_t if
8 _WINT_T is already defined. */
9#ifndef _WINT_T
10#define _WINT_T 1
11
12/* Integral type unchanged by default argument promotions that can
13 hold any value corresponding to members of the extended character
14 set, as well as at least one value that does not correspond to any
15 member of the extended character set. */
16#ifndef __WINT_TYPE__
17# define __WINT_TYPE__ unsigned int
18#endif
19
20typedef __WINT_TYPE__ wint_t;
21
22#endif /* _WINT_T */
23#endif /* bits/types/wint_t.h */
libc/glibc-include/bits/typesizes.h created+95
...@@ -0,0 +1,95 @@
1/* bits/typesizes.h -- underlying types for *_t. Linux/x86-64 version.
2 Copyright (C) 2012-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_TYPES_H
20# error "Never include <bits/typesizes.h> directly; use <sys/types.h> instead."
21#endif
22
23#ifndef _BITS_TYPESIZES_H
24#define _BITS_TYPESIZES_H 1
25
26/* See <bits/types.h> for the meaning of these macros. This file exists so
27 that <bits/types.h> need not vary across different GNU platforms. */
28
29/* X32 kernel interface is 64-bit. */
30#if defined __x86_64__ && defined __ILP32__
31# define __SYSCALL_SLONG_TYPE __SQUAD_TYPE
32# define __SYSCALL_ULONG_TYPE __UQUAD_TYPE
33#else
34# define __SYSCALL_SLONG_TYPE __SLONGWORD_TYPE
35# define __SYSCALL_ULONG_TYPE __ULONGWORD_TYPE
36#endif
37
38#define __DEV_T_TYPE __UQUAD_TYPE
39#define __UID_T_TYPE __U32_TYPE
40#define __GID_T_TYPE __U32_TYPE
41#define __INO_T_TYPE __SYSCALL_ULONG_TYPE
42#define __INO64_T_TYPE __UQUAD_TYPE
43#define __MODE_T_TYPE __U32_TYPE
44#ifdef __x86_64__
45# define __NLINK_T_TYPE __SYSCALL_ULONG_TYPE
46# define __FSWORD_T_TYPE __SYSCALL_SLONG_TYPE
47#else
48# define __NLINK_T_TYPE __UWORD_TYPE
49# define __FSWORD_T_TYPE __SWORD_TYPE
50#endif
51#define __OFF_T_TYPE __SYSCALL_SLONG_TYPE
52#define __OFF64_T_TYPE __SQUAD_TYPE
53#define __PID_T_TYPE __S32_TYPE
54#define __RLIM_T_TYPE __SYSCALL_ULONG_TYPE
55#define __RLIM64_T_TYPE __UQUAD_TYPE
56#define __BLKCNT_T_TYPE __SYSCALL_SLONG_TYPE
57#define __BLKCNT64_T_TYPE __SQUAD_TYPE
58#define __FSBLKCNT_T_TYPE __SYSCALL_ULONG_TYPE
59#define __FSBLKCNT64_T_TYPE __UQUAD_TYPE
60#define __FSFILCNT_T_TYPE __SYSCALL_ULONG_TYPE
61#define __FSFILCNT64_T_TYPE __UQUAD_TYPE
62#define __ID_T_TYPE __U32_TYPE
63#define __CLOCK_T_TYPE __SYSCALL_SLONG_TYPE
64#define __TIME_T_TYPE __SYSCALL_SLONG_TYPE
65#define __USECONDS_T_TYPE __U32_TYPE
66#define __SUSECONDS_T_TYPE __SYSCALL_SLONG_TYPE
67#define __DADDR_T_TYPE __S32_TYPE
68#define __KEY_T_TYPE __S32_TYPE
69#define __CLOCKID_T_TYPE __S32_TYPE
70#define __TIMER_T_TYPE void *
71#define __BLKSIZE_T_TYPE __SYSCALL_SLONG_TYPE
72#define __FSID_T_TYPE struct { int __val[2]; }
73#define __SSIZE_T_TYPE __SWORD_TYPE
74#define __CPU_MASK_TYPE __SYSCALL_ULONG_TYPE
75
76#ifdef __x86_64__
77/* Tell the libc code that off_t and off64_t are actually the same type
78 for all ABI purposes, even if possibly expressed as different base types
79 for C type-checking purposes. */
80# define __OFF_T_MATCHES_OFF64_T 1
81
82/* Same for ino_t and ino64_t. */
83# define __INO_T_MATCHES_INO64_T 1
84
85/* And for __rlim_t and __rlim64_t. */
86# define __RLIM_T_MATCHES_RLIM64_T 1
87#else
88# define __RLIM_T_MATCHES_RLIM64_T 0
89#endif
90
91/* Number of descriptors that can fit in an `fd_set'. */
92#define __FD_SETSIZE 1024
93
94
95#endif /* bits/typesizes.h */
libc/glibc-include/bits/uintn-identity.h created+50
...@@ -0,0 +1,50 @@
1/* Inline functions to return unsigned integer values unchanged.
2 Copyright (C) 2017-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#if !defined _NETINET_IN_H && !defined _ENDIAN_H
20# error "Never use <bits/uintn-identity.h> directly; include <netinet/in.h> or <endian.h> instead."
21#endif
22
23#ifndef _BITS_UINTN_IDENTITY_H
24#define _BITS_UINTN_IDENTITY_H 1
25
26#include <bits/types.h>
27
28/* These inline functions are to ensure the appropriate type
29 conversions and associated diagnostics from macros that convert to
30 a given endianness. */
31
32static __inline __uint16_t
33__uint16_identity (__uint16_t __x)
34{
35 return __x;
36}
37
38static __inline __uint32_t
39__uint32_identity (__uint32_t __x)
40{
41 return __x;
42}
43
44static __inline __uint64_t
45__uint64_identity (__uint64_t __x)
46{
47 return __x;
48}
49
50#endif /* _BITS_UINTN_IDENTITY_H. */
libc/glibc-include/bits/uio-ext.h created+53
...@@ -0,0 +1,53 @@
1/* Operating system-specific extensions to sys/uio.h - Linux version.
2 Copyright (C) 1996-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_UIO_EXT_H
20#define _BITS_UIO_EXT_H 1
21
22#ifndef _SYS_UIO_H
23# error "Never include <bits/uio-ext.h> directly; use <sys/uio.h> instead."
24#endif
25
26__BEGIN_DECLS
27
28/* Read from another process' address space. */
29extern ssize_t process_vm_readv (pid_t __pid, const struct iovec *__lvec,
30 unsigned long int __liovcnt,
31 const struct iovec *__rvec,
32 unsigned long int __riovcnt,
33 unsigned long int __flags)
34 __THROW;
35
36/* Write to another process' address space. */
37extern ssize_t process_vm_writev (pid_t __pid, const struct iovec *__lvec,
38 unsigned long int __liovcnt,
39 const struct iovec *__rvec,
40 unsigned long int __riovcnt,
41 unsigned long int __flags)
42 __THROW;
43
44/* Flags for preadv2/pwritev2. */
45#define RWF_HIPRI 0x00000001 /* High priority request. */
46#define RWF_DSYNC 0x00000002 /* per-IO O_DSYNC. */
47#define RWF_SYNC 0x00000004 /* per-IO O_SYNC. */
48#define RWF_NOWAIT 0x00000008 /* per-IO nonblocking mode. */
49#define RWF_APPEND 0x00000010 /* per-IO O_APPEND. */
50
51__END_DECLS
52
53#endif /* bits/uio-ext.h */
libc/glibc-include/bits/uio_lim.h created+32
...@@ -0,0 +1,32 @@
1/* Implementation limits related to sys/uio.h - Linux version.
2 Copyright (C) 2017-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_UIO_LIM_H
20#define _BITS_UIO_LIM_H 1
21
22/* Maximum length of the 'struct iovec' array in a single call to
23 readv or writev.
24
25 This macro has different values in different kernel versions. The
26 latest versions of the kernel use 1024 and this is good choice. Since
27 the C library implementation of readv/writev is able to emulate the
28 functionality even if the currently running kernel does not support
29 this large value the readv/writev call will not fail because of this. */
30#define __IOV_MAX 1024
31
32#endif
libc/glibc-include/bits/unistd.h created+385
...@@ -0,0 +1,385 @@
1/* Checking macros for unistd functions.
2 Copyright (C) 2005-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _UNISTD_H
20# error "Never include <bits/unistd.h> directly; use <unistd.h> instead."
21#endif
22
23extern ssize_t __read_chk (int __fd, void *__buf, size_t __nbytes,
24 size_t __buflen) __wur;
25extern ssize_t __REDIRECT (__read_alias, (int __fd, void *__buf,
26 size_t __nbytes), read) __wur;
27extern ssize_t __REDIRECT (__read_chk_warn,
28 (int __fd, void *__buf, size_t __nbytes,
29 size_t __buflen), __read_chk)
30 __wur __warnattr ("read called with bigger length than size of "
31 "the destination buffer");
32
33__fortify_function __wur ssize_t
34read (int __fd, void *__buf, size_t __nbytes)
35{
36 if (__bos0 (__buf) != (size_t) -1)
37 {
38 if (!__builtin_constant_p (__nbytes))
39 return __read_chk (__fd, __buf, __nbytes, __bos0 (__buf));
40
41 if (__nbytes > __bos0 (__buf))
42 return __read_chk_warn (__fd, __buf, __nbytes, __bos0 (__buf));
43 }
44 return __read_alias (__fd, __buf, __nbytes);
45}
46
47#ifdef __USE_UNIX98
48extern ssize_t __pread_chk (int __fd, void *__buf, size_t __nbytes,
49 __off_t __offset, size_t __bufsize) __wur;
50extern ssize_t __pread64_chk (int __fd, void *__buf, size_t __nbytes,
51 __off64_t __offset, size_t __bufsize) __wur;
52extern ssize_t __REDIRECT (__pread_alias,
53 (int __fd, void *__buf, size_t __nbytes,
54 __off_t __offset), pread) __wur;
55extern ssize_t __REDIRECT (__pread64_alias,
56 (int __fd, void *__buf, size_t __nbytes,
57 __off64_t __offset), pread64) __wur;
58extern ssize_t __REDIRECT (__pread_chk_warn,
59 (int __fd, void *__buf, size_t __nbytes,
60 __off_t __offset, size_t __bufsize), __pread_chk)
61 __wur __warnattr ("pread called with bigger length than size of "
62 "the destination buffer");
63extern ssize_t __REDIRECT (__pread64_chk_warn,
64 (int __fd, void *__buf, size_t __nbytes,
65 __off64_t __offset, size_t __bufsize),
66 __pread64_chk)
67 __wur __warnattr ("pread64 called with bigger length than size of "
68 "the destination buffer");
69
70# ifndef __USE_FILE_OFFSET64
71__fortify_function __wur ssize_t
72pread (int __fd, void *__buf, size_t __nbytes, __off_t __offset)
73{
74 if (__bos0 (__buf) != (size_t) -1)
75 {
76 if (!__builtin_constant_p (__nbytes))
77 return __pread_chk (__fd, __buf, __nbytes, __offset, __bos0 (__buf));
78
79 if ( __nbytes > __bos0 (__buf))
80 return __pread_chk_warn (__fd, __buf, __nbytes, __offset,
81 __bos0 (__buf));
82 }
83 return __pread_alias (__fd, __buf, __nbytes, __offset);
84}
85# else
86__fortify_function __wur ssize_t
87pread (int __fd, void *__buf, size_t __nbytes, __off64_t __offset)
88{
89 if (__bos0 (__buf) != (size_t) -1)
90 {
91 if (!__builtin_constant_p (__nbytes))
92 return __pread64_chk (__fd, __buf, __nbytes, __offset, __bos0 (__buf));
93
94 if ( __nbytes > __bos0 (__buf))
95 return __pread64_chk_warn (__fd, __buf, __nbytes, __offset,
96 __bos0 (__buf));
97 }
98
99 return __pread64_alias (__fd, __buf, __nbytes, __offset);
100}
101# endif
102
103# ifdef __USE_LARGEFILE64
104__fortify_function __wur ssize_t
105pread64 (int __fd, void *__buf, size_t __nbytes, __off64_t __offset)
106{
107 if (__bos0 (__buf) != (size_t) -1)
108 {
109 if (!__builtin_constant_p (__nbytes))
110 return __pread64_chk (__fd, __buf, __nbytes, __offset, __bos0 (__buf));
111
112 if ( __nbytes > __bos0 (__buf))
113 return __pread64_chk_warn (__fd, __buf, __nbytes, __offset,
114 __bos0 (__buf));
115 }
116
117 return __pread64_alias (__fd, __buf, __nbytes, __offset);
118}
119# endif
120#endif
121
122#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K
123extern ssize_t __readlink_chk (const char *__restrict __path,
124 char *__restrict __buf, size_t __len,
125 size_t __buflen)
126 __THROW __nonnull ((1, 2)) __wur;
127extern ssize_t __REDIRECT_NTH (__readlink_alias,
128 (const char *__restrict __path,
129 char *__restrict __buf, size_t __len), readlink)
130 __nonnull ((1, 2)) __wur;
131extern ssize_t __REDIRECT_NTH (__readlink_chk_warn,
132 (const char *__restrict __path,
133 char *__restrict __buf, size_t __len,
134 size_t __buflen), __readlink_chk)
135 __nonnull ((1, 2)) __wur __warnattr ("readlink called with bigger length "
136 "than size of destination buffer");
137
138__fortify_function __nonnull ((1, 2)) __wur ssize_t
139__NTH (readlink (const char *__restrict __path, char *__restrict __buf,
140 size_t __len))
141{
142 if (__bos (__buf) != (size_t) -1)
143 {
144 if (!__builtin_constant_p (__len))
145 return __readlink_chk (__path, __buf, __len, __bos (__buf));
146
147 if ( __len > __bos (__buf))
148 return __readlink_chk_warn (__path, __buf, __len, __bos (__buf));
149 }
150 return __readlink_alias (__path, __buf, __len);
151}
152#endif
153
154#ifdef __USE_ATFILE
155extern ssize_t __readlinkat_chk (int __fd, const char *__restrict __path,
156 char *__restrict __buf, size_t __len,
157 size_t __buflen)
158 __THROW __nonnull ((2, 3)) __wur;
159extern ssize_t __REDIRECT_NTH (__readlinkat_alias,
160 (int __fd, const char *__restrict __path,
161 char *__restrict __buf, size_t __len),
162 readlinkat)
163 __nonnull ((2, 3)) __wur;
164extern ssize_t __REDIRECT_NTH (__readlinkat_chk_warn,
165 (int __fd, const char *__restrict __path,
166 char *__restrict __buf, size_t __len,
167 size_t __buflen), __readlinkat_chk)
168 __nonnull ((2, 3)) __wur __warnattr ("readlinkat called with bigger "
169 "length than size of destination "
170 "buffer");
171
172__fortify_function __nonnull ((2, 3)) __wur ssize_t
173__NTH (readlinkat (int __fd, const char *__restrict __path,
174 char *__restrict __buf, size_t __len))
175{
176 if (__bos (__buf) != (size_t) -1)
177 {
178 if (!__builtin_constant_p (__len))
179 return __readlinkat_chk (__fd, __path, __buf, __len, __bos (__buf));
180
181 if (__len > __bos (__buf))
182 return __readlinkat_chk_warn (__fd, __path, __buf, __len,
183 __bos (__buf));
184 }
185 return __readlinkat_alias (__fd, __path, __buf, __len);
186}
187#endif
188
189extern char *__getcwd_chk (char *__buf, size_t __size, size_t __buflen)
190 __THROW __wur;
191extern char *__REDIRECT_NTH (__getcwd_alias,
192 (char *__buf, size_t __size), getcwd) __wur;
193extern char *__REDIRECT_NTH (__getcwd_chk_warn,
194 (char *__buf, size_t __size, size_t __buflen),
195 __getcwd_chk)
196 __wur __warnattr ("getcwd caller with bigger length than size of "
197 "destination buffer");
198
199__fortify_function __wur char *
200__NTH (getcwd (char *__buf, size_t __size))
201{
202 if (__bos (__buf) != (size_t) -1)
203 {
204 if (!__builtin_constant_p (__size))
205 return __getcwd_chk (__buf, __size, __bos (__buf));
206
207 if (__size > __bos (__buf))
208 return __getcwd_chk_warn (__buf, __size, __bos (__buf));
209 }
210 return __getcwd_alias (__buf, __size);
211}
212
213#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
214extern char *__getwd_chk (char *__buf, size_t buflen)
215 __THROW __nonnull ((1)) __wur;
216extern char *__REDIRECT_NTH (__getwd_warn, (char *__buf), getwd)
217 __nonnull ((1)) __wur __warnattr ("please use getcwd instead, as getwd "
218 "doesn't specify buffer size");
219
220__fortify_function __nonnull ((1)) __attribute_deprecated__ __wur char *
221__NTH (getwd (char *__buf))
222{
223 if (__bos (__buf) != (size_t) -1)
224 return __getwd_chk (__buf, __bos (__buf));
225 return __getwd_warn (__buf);
226}
227#endif
228
229extern size_t __confstr_chk (int __name, char *__buf, size_t __len,
230 size_t __buflen) __THROW;
231extern size_t __REDIRECT_NTH (__confstr_alias, (int __name, char *__buf,
232 size_t __len), confstr);
233extern size_t __REDIRECT_NTH (__confstr_chk_warn,
234 (int __name, char *__buf, size_t __len,
235 size_t __buflen), __confstr_chk)
236 __warnattr ("confstr called with bigger length than size of destination "
237 "buffer");
238
239__fortify_function size_t
240__NTH (confstr (int __name, char *__buf, size_t __len))
241{
242 if (__bos (__buf) != (size_t) -1)
243 {
244 if (!__builtin_constant_p (__len))
245 return __confstr_chk (__name, __buf, __len, __bos (__buf));
246
247 if (__bos (__buf) < __len)
248 return __confstr_chk_warn (__name, __buf, __len, __bos (__buf));
249 }
250 return __confstr_alias (__name, __buf, __len);
251}
252
253
254extern int __getgroups_chk (int __size, __gid_t __list[], size_t __listlen)
255 __THROW __wur;
256extern int __REDIRECT_NTH (__getgroups_alias, (int __size, __gid_t __list[]),
257 getgroups) __wur;
258extern int __REDIRECT_NTH (__getgroups_chk_warn,
259 (int __size, __gid_t __list[], size_t __listlen),
260 __getgroups_chk)
261 __wur __warnattr ("getgroups called with bigger group count than what "
262 "can fit into destination buffer");
263
264__fortify_function int
265__NTH (getgroups (int __size, __gid_t __list[]))
266{
267 if (__bos (__list) != (size_t) -1)
268 {
269 if (!__builtin_constant_p (__size) || __size < 0)
270 return __getgroups_chk (__size, __list, __bos (__list));
271
272 if (__size * sizeof (__gid_t) > __bos (__list))
273 return __getgroups_chk_warn (__size, __list, __bos (__list));
274 }
275 return __getgroups_alias (__size, __list);
276}
277
278
279extern int __ttyname_r_chk (int __fd, char *__buf, size_t __buflen,
280 size_t __nreal) __THROW __nonnull ((2));
281extern int __REDIRECT_NTH (__ttyname_r_alias, (int __fd, char *__buf,
282 size_t __buflen), ttyname_r)
283 __nonnull ((2));
284extern int __REDIRECT_NTH (__ttyname_r_chk_warn,
285 (int __fd, char *__buf, size_t __buflen,
286 size_t __nreal), __ttyname_r_chk)
287 __nonnull ((2)) __warnattr ("ttyname_r called with bigger buflen than "
288 "size of destination buffer");
289
290__fortify_function int
291__NTH (ttyname_r (int __fd, char *__buf, size_t __buflen))
292{
293 if (__bos (__buf) != (size_t) -1)
294 {
295 if (!__builtin_constant_p (__buflen))
296 return __ttyname_r_chk (__fd, __buf, __buflen, __bos (__buf));
297
298 if (__buflen > __bos (__buf))
299 return __ttyname_r_chk_warn (__fd, __buf, __buflen, __bos (__buf));
300 }
301 return __ttyname_r_alias (__fd, __buf, __buflen);
302}
303
304
305#ifdef __USE_POSIX199506
306extern int __getlogin_r_chk (char *__buf, size_t __buflen, size_t __nreal)
307 __nonnull ((1));
308extern int __REDIRECT (__getlogin_r_alias, (char *__buf, size_t __buflen),
309 getlogin_r) __nonnull ((1));
310extern int __REDIRECT (__getlogin_r_chk_warn,
311 (char *__buf, size_t __buflen, size_t __nreal),
312 __getlogin_r_chk)
313 __nonnull ((1)) __warnattr ("getlogin_r called with bigger buflen than "
314 "size of destination buffer");
315
316__fortify_function int
317getlogin_r (char *__buf, size_t __buflen)
318{
319 if (__bos (__buf) != (size_t) -1)
320 {
321 if (!__builtin_constant_p (__buflen))
322 return __getlogin_r_chk (__buf, __buflen, __bos (__buf));
323
324 if (__buflen > __bos (__buf))
325 return __getlogin_r_chk_warn (__buf, __buflen, __bos (__buf));
326 }
327 return __getlogin_r_alias (__buf, __buflen);
328}
329#endif
330
331
332#if defined __USE_MISC || defined __USE_UNIX98
333extern int __gethostname_chk (char *__buf, size_t __buflen, size_t __nreal)
334 __THROW __nonnull ((1));
335extern int __REDIRECT_NTH (__gethostname_alias, (char *__buf, size_t __buflen),
336 gethostname) __nonnull ((1));
337extern int __REDIRECT_NTH (__gethostname_chk_warn,
338 (char *__buf, size_t __buflen, size_t __nreal),
339 __gethostname_chk)
340 __nonnull ((1)) __warnattr ("gethostname called with bigger buflen than "
341 "size of destination buffer");
342
343__fortify_function int
344__NTH (gethostname (char *__buf, size_t __buflen))
345{
346 if (__bos (__buf) != (size_t) -1)
347 {
348 if (!__builtin_constant_p (__buflen))
349 return __gethostname_chk (__buf, __buflen, __bos (__buf));
350
351 if (__buflen > __bos (__buf))
352 return __gethostname_chk_warn (__buf, __buflen, __bos (__buf));
353 }
354 return __gethostname_alias (__buf, __buflen);
355}
356#endif
357
358
359#if defined __USE_MISC || (defined __USE_XOPEN && !defined __USE_UNIX98)
360extern int __getdomainname_chk (char *__buf, size_t __buflen, size_t __nreal)
361 __THROW __nonnull ((1)) __wur;
362extern int __REDIRECT_NTH (__getdomainname_alias, (char *__buf,
363 size_t __buflen),
364 getdomainname) __nonnull ((1)) __wur;
365extern int __REDIRECT_NTH (__getdomainname_chk_warn,
366 (char *__buf, size_t __buflen, size_t __nreal),
367 __getdomainname_chk)
368 __nonnull ((1)) __wur __warnattr ("getdomainname called with bigger "
369 "buflen than size of destination "
370 "buffer");
371
372__fortify_function int
373__NTH (getdomainname (char *__buf, size_t __buflen))
374{
375 if (__bos (__buf) != (size_t) -1)
376 {
377 if (!__builtin_constant_p (__buflen))
378 return __getdomainname_chk (__buf, __buflen, __bos (__buf));
379
380 if (__buflen > __bos (__buf))
381 return __getdomainname_chk_warn (__buf, __buflen, __bos (__buf));
382 }
383 return __getdomainname_alias (__buf, __buflen);
384}
385#endif
libc/glibc-include/bits/utmp.h created+126
...@@ -0,0 +1,126 @@
1/* The `struct utmp' type, describing entries in the utmp file. GNU version.
2 Copyright (C) 1993-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _UTMP_H
20# error "Never include <bits/utmp.h> directly; use <utmp.h> instead."
21#endif
22
23#include <paths.h>
24#include <sys/time.h>
25#include <sys/types.h>
26#include <bits/wordsize.h>
27
28
29#define UT_LINESIZE 32
30#define UT_NAMESIZE 32
31#define UT_HOSTSIZE 256
32
33
34/* The structure describing an entry in the database of
35 previous logins. */
36struct lastlog
37 {
38#if __WORDSIZE_TIME64_COMPAT32
39 int32_t ll_time;
40#else
41 __time_t ll_time;
42#endif
43 char ll_line[UT_LINESIZE];
44 char ll_host[UT_HOSTSIZE];
45 };
46
47
48/* The structure describing the status of a terminated process. This
49 type is used in `struct utmp' below. */
50struct exit_status
51 {
52 short int e_termination; /* Process termination status. */
53 short int e_exit; /* Process exit status. */
54 };
55
56
57/* The structure describing an entry in the user accounting database. */
58struct utmp
59{
60 short int ut_type; /* Type of login. */
61 pid_t ut_pid; /* Process ID of login process. */
62 char ut_line[UT_LINESIZE]
63 __attribute_nonstring__; /* Devicename. */
64 char ut_id[4]; /* Inittab ID. */
65 char ut_user[UT_NAMESIZE]
66 __attribute_nonstring__; /* Username. */
67 char ut_host[UT_HOSTSIZE]
68 __attribute_nonstring__; /* Hostname for remote login. */
69 struct exit_status ut_exit; /* Exit status of a process marked
70 as DEAD_PROCESS. */
71/* The ut_session and ut_tv fields must be the same size when compiled
72 32- and 64-bit. This allows data files and shared memory to be
73 shared between 32- and 64-bit applications. */
74#if __WORDSIZE_TIME64_COMPAT32
75 int32_t ut_session; /* Session ID, used for windowing. */
76 struct
77 {
78 int32_t tv_sec; /* Seconds. */
79 int32_t tv_usec; /* Microseconds. */
80 } ut_tv; /* Time entry was made. */
81#else
82 long int ut_session; /* Session ID, used for windowing. */
83 struct timeval ut_tv; /* Time entry was made. */
84#endif
85
86 int32_t ut_addr_v6[4]; /* Internet address of remote host. */
87 char __glibc_reserved[20]; /* Reserved for future use. */
88};
89
90/* Backwards compatibility hacks. */
91#define ut_name ut_user
92#ifndef _NO_UT_TIME
93/* We have a problem here: `ut_time' is also used otherwise. Define
94 _NO_UT_TIME if the compiler complains. */
95# define ut_time ut_tv.tv_sec
96#endif
97#define ut_xtime ut_tv.tv_sec
98#define ut_addr ut_addr_v6[0]
99
100
101/* Values for the `ut_type' field of a `struct utmp'. */
102#define EMPTY 0 /* No valid user accounting information. */
103
104#define RUN_LVL 1 /* The system's runlevel. */
105#define BOOT_TIME 2 /* Time of system boot. */
106#define NEW_TIME 3 /* Time after system clock changed. */
107#define OLD_TIME 4 /* Time when system clock changed. */
108
109#define INIT_PROCESS 5 /* Process spawned by the init process. */
110#define LOGIN_PROCESS 6 /* Session leader of a logged in user. */
111#define USER_PROCESS 7 /* Normal process. */
112#define DEAD_PROCESS 8 /* Terminated process. */
113
114#define ACCOUNTING 9
115
116/* Old Linux name for the EMPTY type. */
117#define UT_UNKNOWN EMPTY
118
119
120/* Tell the user that we have a modern system with UT_HOST, UT_PID,
121 UT_TYPE, UT_ID and UT_TV fields. */
122#define _HAVE_UT_TYPE 1
123#define _HAVE_UT_PID 1
124#define _HAVE_UT_ID 1
125#define _HAVE_UT_TV 1
126#define _HAVE_UT_HOST 1
libc/glibc-include/bits/utmpx.h created+102
...@@ -0,0 +1,102 @@
1/* Structures and definitions for the user accounting database. GNU version.
2 Copyright (C) 1997-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _UTMPX_H
20# error "Never include <bits/utmpx.h> directly; use <utmpx.h> instead."
21#endif
22
23#include <bits/types.h>
24#include <sys/time.h>
25#include <bits/wordsize.h>
26
27
28#ifdef __USE_GNU
29# include <paths.h>
30# define _PATH_UTMPX _PATH_UTMP
31# define _PATH_WTMPX _PATH_WTMP
32#endif
33
34
35#define __UT_LINESIZE 32
36#define __UT_NAMESIZE 32
37#define __UT_HOSTSIZE 256
38
39
40/* The structure describing the status of a terminated process. This
41 type is used in `struct utmpx' below. */
42struct __exit_status
43 {
44#ifdef __USE_GNU
45 short int e_termination; /* Process termination status. */
46 short int e_exit; /* Process exit status. */
47#else
48 short int __e_termination; /* Process termination status. */
49 short int __e_exit; /* Process exit status. */
50#endif
51 };
52
53
54/* The structure describing an entry in the user accounting database. */
55struct utmpx
56{
57 short int ut_type; /* Type of login. */
58 __pid_t ut_pid; /* Process ID of login process. */
59 char ut_line[__UT_LINESIZE]; /* Devicename. */
60 char ut_id[4]; /* Inittab ID. */
61 char ut_user[__UT_NAMESIZE]; /* Username. */
62 char ut_host[__UT_HOSTSIZE]; /* Hostname for remote login. */
63 struct __exit_status ut_exit; /* Exit status of a process marked
64 as DEAD_PROCESS. */
65
66/* The fields ut_session and ut_tv must be the same size when compiled
67 32- and 64-bit. This allows files and shared memory to be shared
68 between 32- and 64-bit applications. */
69#if __WORDSIZE_TIME64_COMPAT32
70 __int32_t ut_session; /* Session ID, used for windowing. */
71 struct
72 {
73 __int32_t tv_sec; /* Seconds. */
74 __int32_t tv_usec; /* Microseconds. */
75 } ut_tv; /* Time entry was made. */
76#else
77 long int ut_session; /* Session ID, used for windowing. */
78 struct timeval ut_tv; /* Time entry was made. */
79#endif
80 __int32_t ut_addr_v6[4]; /* Internet address of remote host. */
81 char __glibc_reserved[20]; /* Reserved for future use. */
82};
83
84
85/* Values for the `ut_type' field of a `struct utmpx'. */
86#define EMPTY 0 /* No valid user accounting information. */
87
88#ifdef __USE_GNU
89# define RUN_LVL 1 /* The system's runlevel. */
90#endif
91#define BOOT_TIME 2 /* Time of system boot. */
92#define NEW_TIME 3 /* Time after system clock changed. */
93#define OLD_TIME 4 /* Time when system clock changed. */
94
95#define INIT_PROCESS 5 /* Process spawned by the init process. */
96#define LOGIN_PROCESS 6 /* Session leader of a logged in user. */
97#define USER_PROCESS 7 /* Normal process. */
98#define DEAD_PROCESS 8 /* Terminated process. */
99
100#ifdef __USE_GNU
101# define ACCOUNTING 9 /* System accounting. */
102#endif
libc/glibc-include/bits/utsname.h created+28
...@@ -0,0 +1,28 @@
1/* Copyright (C) 1995-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_UTSNAME_H
19# error "Never include <bits/utsname.h> directly; use <sys/utsname.h> instead."
20#endif
21
22/* Length of the entries in `struct utsname' is 65. */
23#define _UTSNAME_LENGTH 65
24
25/* Linux provides as additional information in the `struct utsname'
26 the name of the current domain. Define _UTSNAME_DOMAIN_LENGTH
27 to a value != 0 to activate this entry. */
28#define _UTSNAME_DOMAIN_LENGTH _UTSNAME_LENGTH
libc/glibc-include/bits/waitflags.h created+39
...@@ -0,0 +1,39 @@
1/* Definitions of flag bits for `waitpid' et al.
2 Copyright (C) 1992-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#if !defined _SYS_WAIT_H && !defined _STDLIB_H
20# error "Never include <bits/waitflags.h> directly; use <sys/wait.h> instead."
21#endif
22
23
24/* Bits in the third argument to `waitpid'. */
25#define WNOHANG 1 /* Don't block waiting. */
26#define WUNTRACED 2 /* Report status of stopped children. */
27
28/* Bits in the fourth argument to `waitid'. */
29#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
30# define WSTOPPED 2 /* Report stopped child (same as WUNTRACED). */
31# define WEXITED 4 /* Report dead child. */
32# define WCONTINUED 8 /* Report continued child. */
33# define WNOWAIT 0x01000000 /* Don't reap, just poll status. */
34#endif
35
36#define __WNOTHREAD 0x20000000 /* Don't wait on children of other threads
37 in this group */
38#define __WALL 0x40000000 /* Wait for any child. */
39#define __WCLONE 0x80000000 /* Wait for cloned process. */
libc/glibc-include/bits/waitstatus.h created+59
...@@ -0,0 +1,59 @@
1/* Definitions of status bits for `wait' et al.
2 Copyright (C) 1992-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#if !defined _SYS_WAIT_H && !defined _STDLIB_H
20# error "Never include <bits/waitstatus.h> directly; use <sys/wait.h> instead."
21#endif
22
23
24/* Everything extant so far uses these same bits. */
25
26
27/* If WIFEXITED(STATUS), the low-order 8 bits of the status. */
28#define __WEXITSTATUS(status) (((status) & 0xff00) >> 8)
29
30/* If WIFSIGNALED(STATUS), the terminating signal. */
31#define __WTERMSIG(status) ((status) & 0x7f)
32
33/* If WIFSTOPPED(STATUS), the signal that stopped the child. */
34#define __WSTOPSIG(status) __WEXITSTATUS(status)
35
36/* Nonzero if STATUS indicates normal termination. */
37#define __WIFEXITED(status) (__WTERMSIG(status) == 0)
38
39/* Nonzero if STATUS indicates termination by a signal. */
40#define __WIFSIGNALED(status) \
41 (((signed char) (((status) & 0x7f) + 1) >> 1) > 0)
42
43/* Nonzero if STATUS indicates the child is stopped. */
44#define __WIFSTOPPED(status) (((status) & 0xff) == 0x7f)
45
46/* Nonzero if STATUS indicates the child continued after a stop. We only
47 define this if <bits/waitflags.h> provides the WCONTINUED flag bit. */
48#ifdef WCONTINUED
49# define __WIFCONTINUED(status) ((status) == __W_CONTINUED)
50#endif
51
52/* Nonzero if STATUS indicates the child dumped core. */
53#define __WCOREDUMP(status) ((status) & __WCOREFLAG)
54
55/* Macros for constructing status values. */
56#define __W_EXITCODE(ret, sig) ((ret) << 8 | (sig))
57#define __W_STOPCODE(sig) ((sig) << 8 | 0x7f)
58#define __W_CONTINUED 0xffff
59#define __WCOREFLAG 0x80
libc/glibc-include/bits/wchar-ldbl.h created+67
...@@ -0,0 +1,67 @@
1/* -mlong-double-64 compatibility mode for <wchar.h> functions.
2 Copyright (C) 2006-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _WCHAR_H
20# error "Never include <bits/wchar-ldbl.h> directly; use <wchar.h> instead."
21#endif
22
23#if defined __USE_ISOC95 || defined __USE_UNIX98
24__LDBL_REDIR_DECL (fwprintf);
25__LDBL_REDIR_DECL (wprintf);
26__LDBL_REDIR_DECL (swprintf);
27__LDBL_REDIR_DECL (vfwprintf);
28__LDBL_REDIR_DECL (vwprintf);
29__LDBL_REDIR_DECL (vswprintf);
30# if !__GLIBC_USE (DEPRECATED_SCANF)
31__LDBL_REDIR1_DECL (fwscanf, __nldbl___isoc99_fwscanf)
32__LDBL_REDIR1_DECL (wscanf, __nldbl___isoc99_wscanf)
33__LDBL_REDIR1_DECL (swscanf, __nldbl___isoc99_swscanf)
34# else
35__LDBL_REDIR_DECL (fwscanf);
36__LDBL_REDIR_DECL (wscanf);
37__LDBL_REDIR_DECL (swscanf);
38# endif
39#endif
40
41#ifdef __USE_ISOC99
42__LDBL_REDIR1_DECL (wcstold, wcstod);
43# if !__GLIBC_USE (DEPRECATED_SCANF)
44__LDBL_REDIR1_DECL (vfwscanf, __nldbl___isoc99_vfwscanf)
45__LDBL_REDIR1_DECL (vwscanf, __nldbl___isoc99_vwscanf)
46__LDBL_REDIR1_DECL (vswscanf, __nldbl___isoc99_vswscanf)
47# else
48__LDBL_REDIR_DECL (vfwscanf);
49__LDBL_REDIR_DECL (vwscanf);
50__LDBL_REDIR_DECL (vswscanf);
51# endif
52#endif
53
54#ifdef __USE_GNU
55__LDBL_REDIR1_DECL (wcstold_l, wcstod_l);
56#endif
57
58#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
59__LDBL_REDIR_DECL (__swprintf_chk)
60__LDBL_REDIR_DECL (__vswprintf_chk)
61# if __USE_FORTIFY_LEVEL > 1
62__LDBL_REDIR_DECL (__fwprintf_chk)
63__LDBL_REDIR_DECL (__wprintf_chk)
64__LDBL_REDIR_DECL (__vfwprintf_chk)
65__LDBL_REDIR_DECL (__vwprintf_chk)
66# endif
67#endif
libc/glibc-include/bits/wchar.h created+49
...@@ -0,0 +1,49 @@
1/* wchar_t type related definitions.
2 Copyright (C) 2000-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_WCHAR_H
20#define _BITS_WCHAR_H 1
21
22/* The fallback definitions, for when __WCHAR_MAX__ or __WCHAR_MIN__
23 are not defined, give the right value and type as long as both int
24 and wchar_t are 32-bit types. Adding L'\0' to a constant value
25 ensures that the type is correct; it is necessary to use (L'\0' +
26 0) rather than just L'\0' so that the type in C++ is the promoted
27 version of wchar_t rather than the distinct wchar_t type itself.
28 Because wchar_t in preprocessor #if expressions is treated as
29 intmax_t or uintmax_t, the expression (L'\0' - 1) would have the
30 wrong value for WCHAR_MAX in such expressions and so cannot be used
31 to define __WCHAR_MAX in the unsigned case. */
32
33#ifdef __WCHAR_MAX__
34# define __WCHAR_MAX __WCHAR_MAX__
35#elif L'\0' - 1 > 0
36# define __WCHAR_MAX (0xffffffffu + L'\0')
37#else
38# define __WCHAR_MAX (0x7fffffff + L'\0')
39#endif
40
41#ifdef __WCHAR_MIN__
42# define __WCHAR_MIN __WCHAR_MIN__
43#elif L'\0' - 1 > 0
44# define __WCHAR_MIN (L'\0' + 0)
45#else
46# define __WCHAR_MIN (-__WCHAR_MAX - 1)
47#endif
48
49#endif /* bits/wchar.h */
libc/glibc-include/bits/wchar2.h created+593
...@@ -0,0 +1,593 @@
1/* Checking macros for wchar functions.
2 Copyright (C) 2005-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _WCHAR_H
20# error "Never include <bits/wchar2.h> directly; use <wchar.h> instead."
21#endif
22
23
24extern wchar_t *__wmemcpy_chk (wchar_t *__restrict __s1,
25 const wchar_t *__restrict __s2, size_t __n,
26 size_t __ns1) __THROW;
27extern wchar_t *__REDIRECT_NTH (__wmemcpy_alias,
28 (wchar_t *__restrict __s1,
29 const wchar_t *__restrict __s2, size_t __n),
30 wmemcpy);
31extern wchar_t *__REDIRECT_NTH (__wmemcpy_chk_warn,
32 (wchar_t *__restrict __s1,
33 const wchar_t *__restrict __s2, size_t __n,
34 size_t __ns1), __wmemcpy_chk)
35 __warnattr ("wmemcpy called with length bigger than size of destination "
36 "buffer");
37
38__fortify_function wchar_t *
39__NTH (wmemcpy (wchar_t *__restrict __s1, const wchar_t *__restrict __s2,
40 size_t __n))
41{
42 if (__bos0 (__s1) != (size_t) -1)
43 {
44 if (!__builtin_constant_p (__n))
45 return __wmemcpy_chk (__s1, __s2, __n,
46 __bos0 (__s1) / sizeof (wchar_t));
47
48 if (__n > __bos0 (__s1) / sizeof (wchar_t))
49 return __wmemcpy_chk_warn (__s1, __s2, __n,
50 __bos0 (__s1) / sizeof (wchar_t));
51 }
52 return __wmemcpy_alias (__s1, __s2, __n);
53}
54
55
56extern wchar_t *__wmemmove_chk (wchar_t *__s1, const wchar_t *__s2,
57 size_t __n, size_t __ns1) __THROW;
58extern wchar_t *__REDIRECT_NTH (__wmemmove_alias, (wchar_t *__s1,
59 const wchar_t *__s2,
60 size_t __n), wmemmove);
61extern wchar_t *__REDIRECT_NTH (__wmemmove_chk_warn,
62 (wchar_t *__s1, const wchar_t *__s2,
63 size_t __n, size_t __ns1), __wmemmove_chk)
64 __warnattr ("wmemmove called with length bigger than size of destination "
65 "buffer");
66
67__fortify_function wchar_t *
68__NTH (wmemmove (wchar_t *__s1, const wchar_t *__s2, size_t __n))
69{
70 if (__bos0 (__s1) != (size_t) -1)
71 {
72 if (!__builtin_constant_p (__n))
73 return __wmemmove_chk (__s1, __s2, __n,
74 __bos0 (__s1) / sizeof (wchar_t));
75
76 if (__n > __bos0 (__s1) / sizeof (wchar_t))
77 return __wmemmove_chk_warn (__s1, __s2, __n,
78 __bos0 (__s1) / sizeof (wchar_t));
79 }
80 return __wmemmove_alias (__s1, __s2, __n);
81}
82
83
84#ifdef __USE_GNU
85extern wchar_t *__wmempcpy_chk (wchar_t *__restrict __s1,
86 const wchar_t *__restrict __s2, size_t __n,
87 size_t __ns1) __THROW;
88extern wchar_t *__REDIRECT_NTH (__wmempcpy_alias,
89 (wchar_t *__restrict __s1,
90 const wchar_t *__restrict __s2,
91 size_t __n), wmempcpy);
92extern wchar_t *__REDIRECT_NTH (__wmempcpy_chk_warn,
93 (wchar_t *__restrict __s1,
94 const wchar_t *__restrict __s2, size_t __n,
95 size_t __ns1), __wmempcpy_chk)
96 __warnattr ("wmempcpy called with length bigger than size of destination "
97 "buffer");
98
99__fortify_function wchar_t *
100__NTH (wmempcpy (wchar_t *__restrict __s1, const wchar_t *__restrict __s2,
101 size_t __n))
102{
103 if (__bos0 (__s1) != (size_t) -1)
104 {
105 if (!__builtin_constant_p (__n))
106 return __wmempcpy_chk (__s1, __s2, __n,
107 __bos0 (__s1) / sizeof (wchar_t));
108
109 if (__n > __bos0 (__s1) / sizeof (wchar_t))
110 return __wmempcpy_chk_warn (__s1, __s2, __n,
111 __bos0 (__s1) / sizeof (wchar_t));
112 }
113 return __wmempcpy_alias (__s1, __s2, __n);
114}
115#endif
116
117
118extern wchar_t *__wmemset_chk (wchar_t *__s, wchar_t __c, size_t __n,
119 size_t __ns) __THROW;
120extern wchar_t *__REDIRECT_NTH (__wmemset_alias, (wchar_t *__s, wchar_t __c,
121 size_t __n), wmemset);
122extern wchar_t *__REDIRECT_NTH (__wmemset_chk_warn,
123 (wchar_t *__s, wchar_t __c, size_t __n,
124 size_t __ns), __wmemset_chk)
125 __warnattr ("wmemset called with length bigger than size of destination "
126 "buffer");
127
128__fortify_function wchar_t *
129__NTH (wmemset (wchar_t *__s, wchar_t __c, size_t __n))
130{
131 if (__bos0 (__s) != (size_t) -1)
132 {
133 if (!__builtin_constant_p (__n))
134 return __wmemset_chk (__s, __c, __n, __bos0 (__s) / sizeof (wchar_t));
135
136 if (__n > __bos0 (__s) / sizeof (wchar_t))
137 return __wmemset_chk_warn (__s, __c, __n,
138 __bos0 (__s) / sizeof (wchar_t));
139 }
140 return __wmemset_alias (__s, __c, __n);
141}
142
143
144extern wchar_t *__wcscpy_chk (wchar_t *__restrict __dest,
145 const wchar_t *__restrict __src,
146 size_t __n) __THROW;
147extern wchar_t *__REDIRECT_NTH (__wcscpy_alias,
148 (wchar_t *__restrict __dest,
149 const wchar_t *__restrict __src), wcscpy);
150
151__fortify_function wchar_t *
152__NTH (wcscpy (wchar_t *__restrict __dest, const wchar_t *__restrict __src))
153{
154 if (__bos (__dest) != (size_t) -1)
155 return __wcscpy_chk (__dest, __src, __bos (__dest) / sizeof (wchar_t));
156 return __wcscpy_alias (__dest, __src);
157}
158
159
160extern wchar_t *__wcpcpy_chk (wchar_t *__restrict __dest,
161 const wchar_t *__restrict __src,
162 size_t __destlen) __THROW;
163extern wchar_t *__REDIRECT_NTH (__wcpcpy_alias,
164 (wchar_t *__restrict __dest,
165 const wchar_t *__restrict __src), wcpcpy);
166
167__fortify_function wchar_t *
168__NTH (wcpcpy (wchar_t *__restrict __dest, const wchar_t *__restrict __src))
169{
170 if (__bos (__dest) != (size_t) -1)
171 return __wcpcpy_chk (__dest, __src, __bos (__dest) / sizeof (wchar_t));
172 return __wcpcpy_alias (__dest, __src);
173}
174
175
176extern wchar_t *__wcsncpy_chk (wchar_t *__restrict __dest,
177 const wchar_t *__restrict __src, size_t __n,
178 size_t __destlen) __THROW;
179extern wchar_t *__REDIRECT_NTH (__wcsncpy_alias,
180 (wchar_t *__restrict __dest,
181 const wchar_t *__restrict __src,
182 size_t __n), wcsncpy);
183extern wchar_t *__REDIRECT_NTH (__wcsncpy_chk_warn,
184 (wchar_t *__restrict __dest,
185 const wchar_t *__restrict __src,
186 size_t __n, size_t __destlen), __wcsncpy_chk)
187 __warnattr ("wcsncpy called with length bigger than size of destination "
188 "buffer");
189
190__fortify_function wchar_t *
191__NTH (wcsncpy (wchar_t *__restrict __dest, const wchar_t *__restrict __src,
192 size_t __n))
193{
194 if (__bos (__dest) != (size_t) -1)
195 {
196 if (!__builtin_constant_p (__n))
197 return __wcsncpy_chk (__dest, __src, __n,
198 __bos (__dest) / sizeof (wchar_t));
199 if (__n > __bos (__dest) / sizeof (wchar_t))
200 return __wcsncpy_chk_warn (__dest, __src, __n,
201 __bos (__dest) / sizeof (wchar_t));
202 }
203 return __wcsncpy_alias (__dest, __src, __n);
204}
205
206
207extern wchar_t *__wcpncpy_chk (wchar_t *__restrict __dest,
208 const wchar_t *__restrict __src, size_t __n,
209 size_t __destlen) __THROW;
210extern wchar_t *__REDIRECT_NTH (__wcpncpy_alias,
211 (wchar_t *__restrict __dest,
212 const wchar_t *__restrict __src,
213 size_t __n), wcpncpy);
214extern wchar_t *__REDIRECT_NTH (__wcpncpy_chk_warn,
215 (wchar_t *__restrict __dest,
216 const wchar_t *__restrict __src,
217 size_t __n, size_t __destlen), __wcpncpy_chk)
218 __warnattr ("wcpncpy called with length bigger than size of destination "
219 "buffer");
220
221__fortify_function wchar_t *
222__NTH (wcpncpy (wchar_t *__restrict __dest, const wchar_t *__restrict __src,
223 size_t __n))
224{
225 if (__bos (__dest) != (size_t) -1)
226 {
227 if (!__builtin_constant_p (__n))
228 return __wcpncpy_chk (__dest, __src, __n,
229 __bos (__dest) / sizeof (wchar_t));
230 if (__n > __bos (__dest) / sizeof (wchar_t))
231 return __wcpncpy_chk_warn (__dest, __src, __n,
232 __bos (__dest) / sizeof (wchar_t));
233 }
234 return __wcpncpy_alias (__dest, __src, __n);
235}
236
237
238extern wchar_t *__wcscat_chk (wchar_t *__restrict __dest,
239 const wchar_t *__restrict __src,
240 size_t __destlen) __THROW;
241extern wchar_t *__REDIRECT_NTH (__wcscat_alias,
242 (wchar_t *__restrict __dest,
243 const wchar_t *__restrict __src), wcscat);
244
245__fortify_function wchar_t *
246__NTH (wcscat (wchar_t *__restrict __dest, const wchar_t *__restrict __src))
247{
248 if (__bos (__dest) != (size_t) -1)
249 return __wcscat_chk (__dest, __src, __bos (__dest) / sizeof (wchar_t));
250 return __wcscat_alias (__dest, __src);
251}
252
253
254extern wchar_t *__wcsncat_chk (wchar_t *__restrict __dest,
255 const wchar_t *__restrict __src,
256 size_t __n, size_t __destlen) __THROW;
257extern wchar_t *__REDIRECT_NTH (__wcsncat_alias,
258 (wchar_t *__restrict __dest,
259 const wchar_t *__restrict __src,
260 size_t __n), wcsncat);
261
262__fortify_function wchar_t *
263__NTH (wcsncat (wchar_t *__restrict __dest, const wchar_t *__restrict __src,
264 size_t __n))
265{
266 if (__bos (__dest) != (size_t) -1)
267 return __wcsncat_chk (__dest, __src, __n,
268 __bos (__dest) / sizeof (wchar_t));
269 return __wcsncat_alias (__dest, __src, __n);
270}
271
272
273extern int __swprintf_chk (wchar_t *__restrict __s, size_t __n,
274 int __flag, size_t __s_len,
275 const wchar_t *__restrict __format, ...)
276 __THROW /* __attribute__ ((__format__ (__wprintf__, 5, 6))) */;
277
278extern int __REDIRECT_NTH_LDBL (__swprintf_alias,
279 (wchar_t *__restrict __s, size_t __n,
280 const wchar_t *__restrict __fmt, ...),
281 swprintf);
282
283#ifdef __va_arg_pack
284__fortify_function int
285__NTH (swprintf (wchar_t *__restrict __s, size_t __n,
286 const wchar_t *__restrict __fmt, ...))
287{
288 if (__bos (__s) != (size_t) -1 || __USE_FORTIFY_LEVEL > 1)
289 return __swprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
290 __bos (__s) / sizeof (wchar_t),
291 __fmt, __va_arg_pack ());
292 return __swprintf_alias (__s, __n, __fmt, __va_arg_pack ());
293}
294#elif !defined __cplusplus
295/* XXX We might want to have support in gcc for swprintf. */
296# define swprintf(s, n, ...) \
297 (__bos (s) != (size_t) -1 || __USE_FORTIFY_LEVEL > 1 \
298 ? __swprintf_chk (s, n, __USE_FORTIFY_LEVEL - 1, \
299 __bos (s) / sizeof (wchar_t), __VA_ARGS__) \
300 : swprintf (s, n, __VA_ARGS__))
301#endif
302
303extern int __vswprintf_chk (wchar_t *__restrict __s, size_t __n,
304 int __flag, size_t __s_len,
305 const wchar_t *__restrict __format,
306 __gnuc_va_list __arg)
307 __THROW /* __attribute__ ((__format__ (__wprintf__, 5, 0))) */;
308
309extern int __REDIRECT_NTH_LDBL (__vswprintf_alias,
310 (wchar_t *__restrict __s, size_t __n,
311 const wchar_t *__restrict __fmt,
312 __gnuc_va_list __ap), vswprintf);
313
314__fortify_function int
315__NTH (vswprintf (wchar_t *__restrict __s, size_t __n,
316 const wchar_t *__restrict __fmt, __gnuc_va_list __ap))
317{
318 if (__bos (__s) != (size_t) -1 || __USE_FORTIFY_LEVEL > 1)
319 return __vswprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
320 __bos (__s) / sizeof (wchar_t), __fmt, __ap);
321 return __vswprintf_alias (__s, __n, __fmt, __ap);
322}
323
324
325#if __USE_FORTIFY_LEVEL > 1
326
327extern int __fwprintf_chk (__FILE *__restrict __stream, int __flag,
328 const wchar_t *__restrict __format, ...);
329extern int __wprintf_chk (int __flag, const wchar_t *__restrict __format,
330 ...);
331extern int __vfwprintf_chk (__FILE *__restrict __stream, int __flag,
332 const wchar_t *__restrict __format,
333 __gnuc_va_list __ap);
334extern int __vwprintf_chk (int __flag, const wchar_t *__restrict __format,
335 __gnuc_va_list __ap);
336
337# ifdef __va_arg_pack
338__fortify_function int
339wprintf (const wchar_t *__restrict __fmt, ...)
340{
341 return __wprintf_chk (__USE_FORTIFY_LEVEL - 1, __fmt, __va_arg_pack ());
342}
343
344__fortify_function int
345fwprintf (__FILE *__restrict __stream, const wchar_t *__restrict __fmt, ...)
346{
347 return __fwprintf_chk (__stream, __USE_FORTIFY_LEVEL - 1, __fmt,
348 __va_arg_pack ());
349}
350# elif !defined __cplusplus
351# define wprintf(...) \
352 __wprintf_chk (__USE_FORTIFY_LEVEL - 1, __VA_ARGS__)
353# define fwprintf(stream, ...) \
354 __fwprintf_chk (stream, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__)
355# endif
356
357__fortify_function int
358vwprintf (const wchar_t *__restrict __fmt, __gnuc_va_list __ap)
359{
360 return __vwprintf_chk (__USE_FORTIFY_LEVEL - 1, __fmt, __ap);
361}
362
363__fortify_function int
364vfwprintf (__FILE *__restrict __stream,
365 const wchar_t *__restrict __fmt, __gnuc_va_list __ap)
366{
367 return __vfwprintf_chk (__stream, __USE_FORTIFY_LEVEL - 1, __fmt, __ap);
368}
369
370#endif
371
372extern wchar_t *__fgetws_chk (wchar_t *__restrict __s, size_t __size, int __n,
373 __FILE *__restrict __stream) __wur;
374extern wchar_t *__REDIRECT (__fgetws_alias,
375 (wchar_t *__restrict __s, int __n,
376 __FILE *__restrict __stream), fgetws) __wur;
377extern wchar_t *__REDIRECT (__fgetws_chk_warn,
378 (wchar_t *__restrict __s, size_t __size, int __n,
379 __FILE *__restrict __stream), __fgetws_chk)
380 __wur __warnattr ("fgetws called with bigger size than length "
381 "of destination buffer");
382
383__fortify_function __wur wchar_t *
384fgetws (wchar_t *__restrict __s, int __n, __FILE *__restrict __stream)
385{
386 if (__bos (__s) != (size_t) -1)
387 {
388 if (!__builtin_constant_p (__n) || __n <= 0)
389 return __fgetws_chk (__s, __bos (__s) / sizeof (wchar_t),
390 __n, __stream);
391
392 if ((size_t) __n > __bos (__s) / sizeof (wchar_t))
393 return __fgetws_chk_warn (__s, __bos (__s) / sizeof (wchar_t),
394 __n, __stream);
395 }
396 return __fgetws_alias (__s, __n, __stream);
397}
398
399#ifdef __USE_GNU
400extern wchar_t *__fgetws_unlocked_chk (wchar_t *__restrict __s, size_t __size,
401 int __n, __FILE *__restrict __stream)
402 __wur;
403extern wchar_t *__REDIRECT (__fgetws_unlocked_alias,
404 (wchar_t *__restrict __s, int __n,
405 __FILE *__restrict __stream), fgetws_unlocked)
406 __wur;
407extern wchar_t *__REDIRECT (__fgetws_unlocked_chk_warn,
408 (wchar_t *__restrict __s, size_t __size, int __n,
409 __FILE *__restrict __stream),
410 __fgetws_unlocked_chk)
411 __wur __warnattr ("fgetws_unlocked called with bigger size than length "
412 "of destination buffer");
413
414__fortify_function __wur wchar_t *
415fgetws_unlocked (wchar_t *__restrict __s, int __n, __FILE *__restrict __stream)
416{
417 if (__bos (__s) != (size_t) -1)
418 {
419 if (!__builtin_constant_p (__n) || __n <= 0)
420 return __fgetws_unlocked_chk (__s, __bos (__s) / sizeof (wchar_t),
421 __n, __stream);
422
423 if ((size_t) __n > __bos (__s) / sizeof (wchar_t))
424 return __fgetws_unlocked_chk_warn (__s, __bos (__s) / sizeof (wchar_t),
425 __n, __stream);
426 }
427 return __fgetws_unlocked_alias (__s, __n, __stream);
428}
429#endif
430
431
432extern size_t __wcrtomb_chk (char *__restrict __s, wchar_t __wchar,
433 mbstate_t *__restrict __p,
434 size_t __buflen) __THROW __wur;
435extern size_t __REDIRECT_NTH (__wcrtomb_alias,
436 (char *__restrict __s, wchar_t __wchar,
437 mbstate_t *__restrict __ps), wcrtomb) __wur;
438
439__fortify_function __wur size_t
440__NTH (wcrtomb (char *__restrict __s, wchar_t __wchar,
441 mbstate_t *__restrict __ps))
442{
443 /* We would have to include <limits.h> to get a definition of MB_LEN_MAX.
444 But this would only disturb the namespace. So we define our own
445 version here. */
446#define __WCHAR_MB_LEN_MAX 16
447#if defined MB_LEN_MAX && MB_LEN_MAX != __WCHAR_MB_LEN_MAX
448# error "Assumed value of MB_LEN_MAX wrong"
449#endif
450 if (__bos (__s) != (size_t) -1 && __WCHAR_MB_LEN_MAX > __bos (__s))
451 return __wcrtomb_chk (__s, __wchar, __ps, __bos (__s));
452 return __wcrtomb_alias (__s, __wchar, __ps);
453}
454
455
456extern size_t __mbsrtowcs_chk (wchar_t *__restrict __dst,
457 const char **__restrict __src,
458 size_t __len, mbstate_t *__restrict __ps,
459 size_t __dstlen) __THROW;
460extern size_t __REDIRECT_NTH (__mbsrtowcs_alias,
461 (wchar_t *__restrict __dst,
462 const char **__restrict __src,
463 size_t __len, mbstate_t *__restrict __ps),
464 mbsrtowcs);
465extern size_t __REDIRECT_NTH (__mbsrtowcs_chk_warn,
466 (wchar_t *__restrict __dst,
467 const char **__restrict __src,
468 size_t __len, mbstate_t *__restrict __ps,
469 size_t __dstlen), __mbsrtowcs_chk)
470 __warnattr ("mbsrtowcs called with dst buffer smaller than len "
471 "* sizeof (wchar_t)");
472
473__fortify_function size_t
474__NTH (mbsrtowcs (wchar_t *__restrict __dst, const char **__restrict __src,
475 size_t __len, mbstate_t *__restrict __ps))
476{
477 if (__bos (__dst) != (size_t) -1)
478 {
479 if (!__builtin_constant_p (__len))
480 return __mbsrtowcs_chk (__dst, __src, __len, __ps,
481 __bos (__dst) / sizeof (wchar_t));
482
483 if (__len > __bos (__dst) / sizeof (wchar_t))
484 return __mbsrtowcs_chk_warn (__dst, __src, __len, __ps,
485 __bos (__dst) / sizeof (wchar_t));
486 }
487 return __mbsrtowcs_alias (__dst, __src, __len, __ps);
488}
489
490
491extern size_t __wcsrtombs_chk (char *__restrict __dst,
492 const wchar_t **__restrict __src,
493 size_t __len, mbstate_t *__restrict __ps,
494 size_t __dstlen) __THROW;
495extern size_t __REDIRECT_NTH (__wcsrtombs_alias,
496 (char *__restrict __dst,
497 const wchar_t **__restrict __src,
498 size_t __len, mbstate_t *__restrict __ps),
499 wcsrtombs);
500extern size_t __REDIRECT_NTH (__wcsrtombs_chk_warn,
501 (char *__restrict __dst,
502 const wchar_t **__restrict __src,
503 size_t __len, mbstate_t *__restrict __ps,
504 size_t __dstlen), __wcsrtombs_chk)
505 __warnattr ("wcsrtombs called with dst buffer smaller than len");
506
507__fortify_function size_t
508__NTH (wcsrtombs (char *__restrict __dst, const wchar_t **__restrict __src,
509 size_t __len, mbstate_t *__restrict __ps))
510{
511 if (__bos (__dst) != (size_t) -1)
512 {
513 if (!__builtin_constant_p (__len))
514 return __wcsrtombs_chk (__dst, __src, __len, __ps, __bos (__dst));
515
516 if (__len > __bos (__dst))
517 return __wcsrtombs_chk_warn (__dst, __src, __len, __ps, __bos (__dst));
518 }
519 return __wcsrtombs_alias (__dst, __src, __len, __ps);
520}
521
522
523#ifdef __USE_GNU
524extern size_t __mbsnrtowcs_chk (wchar_t *__restrict __dst,
525 const char **__restrict __src, size_t __nmc,
526 size_t __len, mbstate_t *__restrict __ps,
527 size_t __dstlen) __THROW;
528extern size_t __REDIRECT_NTH (__mbsnrtowcs_alias,
529 (wchar_t *__restrict __dst,
530 const char **__restrict __src, size_t __nmc,
531 size_t __len, mbstate_t *__restrict __ps),
532 mbsnrtowcs);
533extern size_t __REDIRECT_NTH (__mbsnrtowcs_chk_warn,
534 (wchar_t *__restrict __dst,
535 const char **__restrict __src, size_t __nmc,
536 size_t __len, mbstate_t *__restrict __ps,
537 size_t __dstlen), __mbsnrtowcs_chk)
538 __warnattr ("mbsnrtowcs called with dst buffer smaller than len "
539 "* sizeof (wchar_t)");
540
541__fortify_function size_t
542__NTH (mbsnrtowcs (wchar_t *__restrict __dst, const char **__restrict __src,
543 size_t __nmc, size_t __len, mbstate_t *__restrict __ps))
544{
545 if (__bos (__dst) != (size_t) -1)
546 {
547 if (!__builtin_constant_p (__len))
548 return __mbsnrtowcs_chk (__dst, __src, __nmc, __len, __ps,
549 __bos (__dst) / sizeof (wchar_t));
550
551 if (__len > __bos (__dst) / sizeof (wchar_t))
552 return __mbsnrtowcs_chk_warn (__dst, __src, __nmc, __len, __ps,
553 __bos (__dst) / sizeof (wchar_t));
554 }
555 return __mbsnrtowcs_alias (__dst, __src, __nmc, __len, __ps);
556}
557
558
559extern size_t __wcsnrtombs_chk (char *__restrict __dst,
560 const wchar_t **__restrict __src,
561 size_t __nwc, size_t __len,
562 mbstate_t *__restrict __ps, size_t __dstlen)
563 __THROW;
564extern size_t __REDIRECT_NTH (__wcsnrtombs_alias,
565 (char *__restrict __dst,
566 const wchar_t **__restrict __src,
567 size_t __nwc, size_t __len,
568 mbstate_t *__restrict __ps), wcsnrtombs);
569extern size_t __REDIRECT_NTH (__wcsnrtombs_chk_warn,
570 (char *__restrict __dst,
571 const wchar_t **__restrict __src,
572 size_t __nwc, size_t __len,
573 mbstate_t *__restrict __ps,
574 size_t __dstlen), __wcsnrtombs_chk)
575 __warnattr ("wcsnrtombs called with dst buffer smaller than len");
576
577__fortify_function size_t
578__NTH (wcsnrtombs (char *__restrict __dst, const wchar_t **__restrict __src,
579 size_t __nwc, size_t __len, mbstate_t *__restrict __ps))
580{
581 if (__bos (__dst) != (size_t) -1)
582 {
583 if (!__builtin_constant_p (__len))
584 return __wcsnrtombs_chk (__dst, __src, __nwc, __len, __ps,
585 __bos (__dst));
586
587 if (__len > __bos (__dst))
588 return __wcsnrtombs_chk_warn (__dst, __src, __nwc, __len, __ps,
589 __bos (__dst));
590 }
591 return __wcsnrtombs_alias (__dst, __src, __nwc, __len, __ps);
592}
593#endif
libc/glibc-include/bits/wctype-wchar.h created+173
...@@ -0,0 +1,173 @@
1/* Copyright (C) 1996-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/*
19 * ISO C99 Standard: 7.25
20 * Wide character classification and mapping utilities <wctype.h>
21 */
22
23#ifndef _BITS_WCTYPE_WCHAR_H
24#define _BITS_WCTYPE_WCHAR_H 1
25
26#if !defined _WCTYPE_H && !defined _WCHAR_H
27#error "Never include <bits/wctype-wchar.h> directly; include <wctype.h> or <wchar.h> instead."
28#endif
29
30#include <bits/types.h>
31#include <bits/types/wint_t.h>
32
33/* The definitions in this header are specified to appear in <wctype.h>
34 in ISO C99, but in <wchar.h> in Unix98. _GNU_SOURCE follows C99. */
35
36/* Scalar type that can hold values which represent locale-specific
37 character classifications. */
38typedef unsigned long int wctype_t;
39
40# ifndef _ISwbit
41/* The characteristics are stored always in network byte order (big
42 endian). We define the bit value interpretations here dependent on the
43 machine's byte order. */
44
45# include <endian.h>
46# if __BYTE_ORDER == __BIG_ENDIAN
47# define _ISwbit(bit) (1 << (bit))
48# else /* __BYTE_ORDER == __LITTLE_ENDIAN */
49# define _ISwbit(bit) \
50 ((bit) < 8 ? (int) ((1UL << (bit)) << 24) \
51 : ((bit) < 16 ? (int) ((1UL << (bit)) << 8) \
52 : ((bit) < 24 ? (int) ((1UL << (bit)) >> 8) \
53 : (int) ((1UL << (bit)) >> 24))))
54# endif
55
56enum
57{
58 __ISwupper = 0, /* UPPERCASE. */
59 __ISwlower = 1, /* lowercase. */
60 __ISwalpha = 2, /* Alphabetic. */
61 __ISwdigit = 3, /* Numeric. */
62 __ISwxdigit = 4, /* Hexadecimal numeric. */
63 __ISwspace = 5, /* Whitespace. */
64 __ISwprint = 6, /* Printing. */
65 __ISwgraph = 7, /* Graphical. */
66 __ISwblank = 8, /* Blank (usually SPC and TAB). */
67 __ISwcntrl = 9, /* Control character. */
68 __ISwpunct = 10, /* Punctuation. */
69 __ISwalnum = 11, /* Alphanumeric. */
70
71 _ISwupper = _ISwbit (__ISwupper), /* UPPERCASE. */
72 _ISwlower = _ISwbit (__ISwlower), /* lowercase. */
73 _ISwalpha = _ISwbit (__ISwalpha), /* Alphabetic. */
74 _ISwdigit = _ISwbit (__ISwdigit), /* Numeric. */
75 _ISwxdigit = _ISwbit (__ISwxdigit), /* Hexadecimal numeric. */
76 _ISwspace = _ISwbit (__ISwspace), /* Whitespace. */
77 _ISwprint = _ISwbit (__ISwprint), /* Printing. */
78 _ISwgraph = _ISwbit (__ISwgraph), /* Graphical. */
79 _ISwblank = _ISwbit (__ISwblank), /* Blank (usually SPC and TAB). */
80 _ISwcntrl = _ISwbit (__ISwcntrl), /* Control character. */
81 _ISwpunct = _ISwbit (__ISwpunct), /* Punctuation. */
82 _ISwalnum = _ISwbit (__ISwalnum) /* Alphanumeric. */
83};
84# endif /* Not _ISwbit */
85
86
87__BEGIN_DECLS
88
89/*
90 * Wide-character classification functions: 7.15.2.1.
91 */
92
93/* Test for any wide character for which `iswalpha' or `iswdigit' is
94 true. */
95extern int iswalnum (wint_t __wc) __THROW;
96
97/* Test for any wide character for which `iswupper' or 'iswlower' is
98 true, or any wide character that is one of a locale-specific set of
99 wide-characters for which none of `iswcntrl', `iswdigit',
100 `iswpunct', or `iswspace' is true. */
101extern int iswalpha (wint_t __wc) __THROW;
102
103/* Test for any control wide character. */
104extern int iswcntrl (wint_t __wc) __THROW;
105
106/* Test for any wide character that corresponds to a decimal-digit
107 character. */
108extern int iswdigit (wint_t __wc) __THROW;
109
110/* Test for any wide character for which `iswprint' is true and
111 `iswspace' is false. */
112extern int iswgraph (wint_t __wc) __THROW;
113
114/* Test for any wide character that corresponds to a lowercase letter
115 or is one of a locale-specific set of wide characters for which
116 none of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */
117extern int iswlower (wint_t __wc) __THROW;
118
119/* Test for any printing wide character. */
120extern int iswprint (wint_t __wc) __THROW;
121
122/* Test for any printing wide character that is one of a
123 locale-specific et of wide characters for which neither `iswspace'
124 nor `iswalnum' is true. */
125extern int iswpunct (wint_t __wc) __THROW;
126
127/* Test for any wide character that corresponds to a locale-specific
128 set of wide characters for which none of `iswalnum', `iswgraph', or
129 `iswpunct' is true. */
130extern int iswspace (wint_t __wc) __THROW;
131
132/* Test for any wide character that corresponds to an uppercase letter
133 or is one of a locale-specific set of wide character for which none
134 of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */
135extern int iswupper (wint_t __wc) __THROW;
136
137/* Test for any wide character that corresponds to a hexadecimal-digit
138 character equivalent to that performed be the functions described
139 in the previous subclause. */
140extern int iswxdigit (wint_t __wc) __THROW;
141
142/* Test for any wide character that corresponds to a standard blank
143 wide character or a locale-specific set of wide characters for
144 which `iswalnum' is false. */
145# ifdef __USE_ISOC99
146extern int iswblank (wint_t __wc) __THROW;
147# endif
148
149/*
150 * Extensible wide-character classification functions: 7.15.2.2.
151 */
152
153/* Construct value that describes a class of wide characters identified
154 by the string argument PROPERTY. */
155extern wctype_t wctype (const char *__property) __THROW;
156
157/* Determine whether the wide-character WC has the property described by
158 DESC. */
159extern int iswctype (wint_t __wc, wctype_t __desc) __THROW;
160
161/*
162 * Wide-character case-mapping functions: 7.15.3.1.
163 */
164
165/* Converts an uppercase letter to the corresponding lowercase letter. */
166extern wint_t towlower (wint_t __wc) __THROW;
167
168/* Converts an lowercase letter to the corresponding uppercase letter. */
169extern wint_t towupper (wint_t __wc) __THROW;
170
171__END_DECLS
172
173#endif /* bits/wctype-wchar.h. */
libc/glibc-include/bits/wordsize.h created+17
...@@ -0,0 +1,17 @@
1/* Determine the wordsize from the preprocessor defines. */
2
3#if defined __x86_64__ && !defined __ILP32__
4# define __WORDSIZE 64
5#else
6# define __WORDSIZE 32
7#define __WORDSIZE32_SIZE_ULONG 0
8#define __WORDSIZE32_PTRDIFF_LONG 0
9#endif
10
11#ifdef __x86_64__
12# define __WORDSIZE_TIME64_COMPAT32 1
13/* Both x86-64 and x32 use the 64-bit system call interface. */
14# define __SYSCALL_WORDSIZE 64
15#else
16# define __WORDSIZE_TIME64_COMPAT32 0
17#endif
libc/glibc-include/bits/xopen_lim.h created+148
...@@ -0,0 +1,148 @@
1/* Copyright (C) 1996-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/*
19 * Never include this file directly; use <limits.h> instead.
20 */
21
22/* Additional definitions from X/Open Portability Guide, Issue 4, Version 2
23 System Interfaces and Headers, 4.16 <limits.h>
24
25 Please note only the values which are not greater than the minimum
26 stated in the standard document are listed. The `sysconf' functions
27 should be used to obtain the actual value. */
28
29#ifndef _XOPEN_LIM_H
30#define _XOPEN_LIM_H 1
31
32/* We do not provide fixed values for
33
34 ARG_MAX Maximum length of argument to the `exec' function
35 including environment data.
36
37 ATEXIT_MAX Maximum number of functions that may be registered
38 with `atexit'.
39
40 CHILD_MAX Maximum number of simultaneous processes per real
41 user ID.
42
43 OPEN_MAX Maximum number of files that one process can have open
44 at anyone time.
45
46 PAGESIZE
47 PAGE_SIZE Size of bytes of a page.
48
49 PASS_MAX Maximum number of significant bytes in a password.
50
51 We only provide a fixed limit for
52
53 IOV_MAX Maximum number of `iovec' structures that one process has
54 available for use with `readv' or writev'.
55
56 if this is indeed fixed by the underlying system.
57*/
58
59
60/* Maximum number of `iovec' structures that may be used in a single call
61 to `readv', `writev', etc. */
62#define _XOPEN_IOV_MAX _POSIX_UIO_MAXIOV
63
64#include <bits/uio_lim.h>
65#ifdef __IOV_MAX
66# define IOV_MAX __IOV_MAX
67#else
68# undef IOV_MAX
69#endif
70
71/* Maximum value of `digit' in calls to the `printf' and `scanf'
72 functions. We have no limit, so return a reasonable value. */
73#define NL_ARGMAX _POSIX_ARG_MAX
74
75/* Maximum number of bytes in a `LANG' name. We have no limit. */
76#define NL_LANGMAX _POSIX2_LINE_MAX
77
78/* Maximum message number. We have no limit. */
79#define NL_MSGMAX INT_MAX
80
81/* Maximum number of bytes in N-to-1 collation mapping. We have no
82 limit. */
83#if defined __USE_GNU || !defined __USE_XOPEN2K8
84# define NL_NMAX INT_MAX
85#endif
86
87/* Maximum set number. We have no limit. */
88#define NL_SETMAX INT_MAX
89
90/* Maximum number of bytes in a message. We have no limit. */
91#define NL_TEXTMAX INT_MAX
92
93/* Default process priority. */
94#define NZERO 20
95
96
97/* Number of bits in a word of type `int'. */
98#ifdef INT_MAX
99# if INT_MAX == 32767
100# define WORD_BIT 16
101# else
102# if INT_MAX == 2147483647
103# define WORD_BIT 32
104# else
105/* Safe assumption. */
106# define WORD_BIT 64
107# endif
108# endif
109#elif defined __INT_MAX__
110# if __INT_MAX__ == 32767
111# define WORD_BIT 16
112# else
113# if __INT_MAX__ == 2147483647
114# define WORD_BIT 32
115# else
116/* Safe assumption. */
117# define WORD_BIT 64
118# endif
119# endif
120#else
121# define WORD_BIT 32
122#endif
123
124/* Number of bits in a word of type `long int'. */
125#ifdef LONG_MAX
126# if LONG_MAX == 2147483647
127# define LONG_BIT 32
128# else
129/* Safe assumption. */
130# define LONG_BIT 64
131# endif
132#elif defined __LONG_MAX__
133# if __LONG_MAX__ == 2147483647
134# define LONG_BIT 32
135# else
136/* Safe assumption. */
137# define LONG_BIT 64
138# endif
139#else
140# include <bits/wordsize.h>
141# if __WORDSIZE == 64
142# define LONG_BIT 64
143# else
144# define LONG_BIT 32
145# endif
146#endif
147
148#endif /* bits/xopen_lim.h */
libc/glibc-include/bits/xtitypes.h created+33
...@@ -0,0 +1,33 @@
1/* bits/xtitypes.h -- Define some types used by <bits/stropts.h>. x86-64.
2 Copyright (C) 2002-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _STROPTS_H
20# error "Never include <bits/xtitypes.h> directly; use <stropts.h> instead."
21#endif
22
23#ifndef _BITS_XTITYPES_H
24#define _BITS_XTITYPES_H 1
25
26#include <bits/types.h>
27
28/* This type is used by some structs in <bits/stropts.h>. */
29typedef __SLONG32_TYPE __t_scalar_t;
30typedef __ULONG32_TYPE __t_uscalar_t;
31
32
33#endif /* bits/xtitypes.h */
libc/glibc-include/byteswap.h created+39
...@@ -0,0 +1,39 @@
1/* Copyright (C) 1997-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _BYTESWAP_H
19#define _BYTESWAP_H 1
20
21#include <features.h>
22
23/* Get the machine specific, optimized definitions. */
24#include <bits/byteswap.h>
25
26
27/* The following definitions must all be macros since otherwise some
28 of the possible optimizations are not possible. */
29
30/* Return a value with all bytes in the 16 bit argument swapped. */
31#define bswap_16(x) __bswap_16 (x)
32
33/* Return a value with all bytes in the 32 bit argument swapped. */
34#define bswap_32(x) __bswap_32 (x)
35
36/* Return a value with all bytes in the 64 bit argument swapped. */
37#define bswap_64(x) __bswap_64 (x)
38
39#endif /* byteswap.h */
libc/glibc-include/complex.h created+224
...@@ -0,0 +1,224 @@
1/* Copyright (C) 1997-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/*
19 * ISO C99: 7.3 Complex arithmetic <complex.h>
20 */
21
22#ifndef _COMPLEX_H
23#define _COMPLEX_H 1
24
25#define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION
26#include <bits/libc-header-start.h>
27
28/* Get general and ISO C99 specific information. */
29#include <bits/mathdef.h>
30
31/* Gather machine-dependent _FloatN type support. */
32#include <bits/floatn.h>
33
34__BEGIN_DECLS
35
36/* We might need to add support for more compilers here. But since ISO
37 C99 is out hopefully all maintained compilers will soon provide the data
38 types `float complex' and `double complex'. */
39#if __GNUC_PREREQ (2, 7) && !__GNUC_PREREQ (2, 97)
40# define _Complex __complex__
41#endif
42
43#define complex _Complex
44
45/* Narrowest imaginary unit. This depends on the floating-point
46 evaluation method.
47 XXX This probably has to go into a gcc related file. */
48#define _Complex_I (__extension__ 1.0iF)
49
50/* Another more descriptive name is `I'.
51 XXX Once we have the imaginary support switch this to _Imaginary_I. */
52#undef I
53#define I _Complex_I
54
55#if defined __USE_ISOC11 && __GNUC_PREREQ (4, 7)
56/* Macros to expand into expression of specified complex type. */
57# define CMPLX(x, y) __builtin_complex ((double) (x), (double) (y))
58# define CMPLXF(x, y) __builtin_complex ((float) (x), (float) (y))
59# define CMPLXL(x, y) __builtin_complex ((long double) (x), (long double) (y))
60#endif
61
62#if __HAVE_FLOAT16 && __GLIBC_USE (IEC_60559_TYPES_EXT)
63# define CMPLXF16(x, y) __builtin_complex ((_Float16) (x), (_Float16) (y))
64#endif
65
66#if __HAVE_FLOAT32 && __GLIBC_USE (IEC_60559_TYPES_EXT)
67# define CMPLXF32(x, y) __builtin_complex ((_Float32) (x), (_Float32) (y))
68#endif
69
70#if __HAVE_FLOAT64 && __GLIBC_USE (IEC_60559_TYPES_EXT)
71# define CMPLXF64(x, y) __builtin_complex ((_Float64) (x), (_Float64) (y))
72#endif
73
74#if __HAVE_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT)
75# define CMPLXF128(x, y) __builtin_complex ((_Float128) (x), (_Float128) (y))
76#endif
77
78#if __HAVE_FLOAT32X && __GLIBC_USE (IEC_60559_TYPES_EXT)
79# define CMPLXF32X(x, y) __builtin_complex ((_Float32x) (x), (_Float32x) (y))
80#endif
81
82#if __HAVE_FLOAT64X && __GLIBC_USE (IEC_60559_TYPES_EXT)
83# define CMPLXF64X(x, y) __builtin_complex ((_Float64x) (x), (_Float64x) (y))
84#endif
85
86#if __HAVE_FLOAT128X && __GLIBC_USE (IEC_60559_TYPES_EXT)
87# define CMPLXF128X(x, y) \
88 __builtin_complex ((_Float128x) (x), (_Float128x) (y))
89#endif
90
91/* The file <bits/cmathcalls.h> contains the prototypes for all the
92 actual math functions. These macros are used for those prototypes,
93 so we can easily declare each function as both `name' and `__name',
94 and can declare the float versions `namef' and `__namef'. */
95
96#define __MATHCALL(function, args) \
97 __MATHDECL (_Mdouble_complex_,function, args)
98#define __MATHDECL(type, function, args) \
99 __MATHDECL_1(type, function, args); \
100 __MATHDECL_1(type, __CONCAT(__,function), args)
101#define __MATHDECL_1(type, function, args) \
102 extern type __MATH_PRECNAME(function) args __THROW
103
104#define _Mdouble_ double
105#define __MATH_PRECNAME(name) name
106#include <bits/cmathcalls.h>
107#undef _Mdouble_
108#undef __MATH_PRECNAME
109
110/* Now the float versions. */
111#define _Mdouble_ float
112#define __MATH_PRECNAME(name) name##f
113#include <bits/cmathcalls.h>
114#undef _Mdouble_
115#undef __MATH_PRECNAME
116
117/* And the long double versions. It is non-critical to define them
118 here unconditionally since `long double' is required in ISO C99. */
119#if !(defined __NO_LONG_DOUBLE_MATH && defined _LIBC) \
120 || defined __LDBL_COMPAT
121# ifdef __LDBL_COMPAT
122# undef __MATHDECL_1
123# define __MATHDECL_1(type, function, args) \
124 extern type __REDIRECT_NTH(__MATH_PRECNAME(function), args, function)
125# endif
126
127# define _Mdouble_ long double
128# define __MATH_PRECNAME(name) name##l
129# include <bits/cmathcalls.h>
130#endif
131#undef _Mdouble_
132#undef __MATH_PRECNAME
133
134#if (__HAVE_DISTINCT_FLOAT16 || (__HAVE_FLOAT16 && !defined _LIBC)) \
135 && __GLIBC_USE (IEC_60559_TYPES_EXT)
136# undef _Mdouble_complex_
137# define _Mdouble_complex_ __CFLOAT16
138# define _Mdouble_ _Float16
139# define __MATH_PRECNAME(name) name##f16
140# include <bits/cmathcalls.h>
141# undef _Mdouble_
142# undef __MATH_PRECNAME
143# undef _Mdouble_complex_
144#endif
145
146#if (__HAVE_DISTINCT_FLOAT32 || (__HAVE_FLOAT32 && !defined _LIBC)) \
147 && __GLIBC_USE (IEC_60559_TYPES_EXT)
148# undef _Mdouble_complex_
149# define _Mdouble_complex_ __CFLOAT32
150# define _Mdouble_ _Float32
151# define __MATH_PRECNAME(name) name##f32
152# include <bits/cmathcalls.h>
153# undef _Mdouble_
154# undef __MATH_PRECNAME
155# undef _Mdouble_complex_
156#endif
157
158#if (__HAVE_DISTINCT_FLOAT64 || (__HAVE_FLOAT64 && !defined _LIBC)) \
159 && __GLIBC_USE (IEC_60559_TYPES_EXT)
160# undef _Mdouble_complex_
161# define _Mdouble_complex_ __CFLOAT64
162# define _Mdouble_ _Float64
163# define __MATH_PRECNAME(name) name##f64
164# include <bits/cmathcalls.h>
165# undef _Mdouble_
166# undef __MATH_PRECNAME
167# undef _Mdouble_complex_
168#endif
169
170#if (__HAVE_DISTINCT_FLOAT128 || (__HAVE_FLOAT128 && !defined _LIBC)) \
171 && __GLIBC_USE (IEC_60559_TYPES_EXT)
172# undef _Mdouble_complex_
173# define _Mdouble_complex_ __CFLOAT128
174# define _Mdouble_ _Float128
175# define __MATH_PRECNAME(name) name##f128
176# include <bits/cmathcalls.h>
177# undef _Mdouble_
178# undef __MATH_PRECNAME
179# undef _Mdouble_complex_
180#endif
181
182#if (__HAVE_DISTINCT_FLOAT32X || (__HAVE_FLOAT32X && !defined _LIBC)) \
183 && __GLIBC_USE (IEC_60559_TYPES_EXT)
184# undef _Mdouble_complex_
185# define _Mdouble_complex_ __CFLOAT32X
186# define _Mdouble_ _Float32x
187# define __MATH_PRECNAME(name) name##f32x
188# include <bits/cmathcalls.h>
189# undef _Mdouble_
190# undef __MATH_PRECNAME
191# undef _Mdouble_complex_
192#endif
193
194#if (__HAVE_DISTINCT_FLOAT64X || (__HAVE_FLOAT64X && !defined _LIBC)) \
195 && __GLIBC_USE (IEC_60559_TYPES_EXT)
196# undef _Mdouble_complex_
197# define _Mdouble_complex_ __CFLOAT64X
198# define _Mdouble_ _Float64x
199# define __MATH_PRECNAME(name) name##f64x
200# include <bits/cmathcalls.h>
201# undef _Mdouble_
202# undef __MATH_PRECNAME
203# undef _Mdouble_complex_
204#endif
205
206#if (__HAVE_DISTINCT_FLOAT128X || (__HAVE_FLOAT128X && !defined _LIBC)) \
207 && __GLIBC_USE (IEC_60559_TYPES_EXT)
208# undef _Mdouble_complex_
209# define _Mdouble_complex_ __CFLOAT128X
210# define _Mdouble_ _Float128x
211# define __MATH_PRECNAME(name) name##f128x
212# include <bits/cmathcalls.h>
213# undef _Mdouble_
214# undef __MATH_PRECNAME
215# undef _Mdouble_complex_
216#endif
217
218#undef __MATHDECL_1
219#undef __MATHDECL
220#undef __MATHCALL
221
222__END_DECLS
223
224#endif /* complex.h */
libc/glibc-include/cpio.h created+73
...@@ -0,0 +1,73 @@
1/* Extended cpio format from POSIX.1.
2 This file is part of the GNU C Library.
3 Copyright (C) 1992-2019 Free Software Foundation, Inc.
4 NOTE: The canonical source of this file is maintained with the GNU cpio.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
19
20#ifndef _CPIO_H
21#define _CPIO_H 1
22
23/* A cpio archive consists of a sequence of files.
24 Each file has a 76 byte header,
25 a variable length, NUL terminated filename,
26 and variable length file data.
27 A header for a filename "TRAILER!!!" indicates the end of the archive. */
28
29/* All the fields in the header are ISO 646 (approximately ASCII) strings
30 of octal numbers, left padded, not NUL terminated.
31
32 Field Name Length in Bytes Notes
33 c_magic 6 must be "070707"
34 c_dev 6
35 c_ino 6
36 c_mode 6 see below for value
37 c_uid 6
38 c_gid 6
39 c_nlink 6
40 c_rdev 6 only valid for chr and blk special files
41 c_mtime 11
42 c_namesize 6 count includes terminating NUL in pathname
43 c_filesize 11 must be 0 for FIFOs and directories */
44
45/* Value for the field `c_magic'. */
46#define MAGIC "070707"
47
48/* Values for c_mode, OR'd together: */
49
50#define C_IRUSR 000400
51#define C_IWUSR 000200
52#define C_IXUSR 000100
53#define C_IRGRP 000040
54#define C_IWGRP 000020
55#define C_IXGRP 000010
56#define C_IROTH 000004
57#define C_IWOTH 000002
58#define C_IXOTH 000001
59
60#define C_ISUID 004000
61#define C_ISGID 002000
62#define C_ISVTX 001000
63
64#define C_ISBLK 060000
65#define C_ISCHR 020000
66#define C_ISDIR 040000
67#define C_ISFIFO 010000
68#define C_ISSOCK 0140000
69#define C_ISLNK 0120000
70#define C_ISCTG 0110000
71#define C_ISREG 0100000
72
73#endif /* cpio.h */
libc/glibc-include/crypt.h created+70
...@@ -0,0 +1,70 @@
1/*
2 * UFC-crypt: ultra fast crypt(3) implementation
3 *
4 * Copyright (C) 1991-2019 Free Software Foundation, Inc.
5 *
6 * The GNU C Library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * The GNU C Library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with the GNU C Library; if not, see
18 * <http://www.gnu.org/licenses/>.
19 *
20 * @(#)crypt.h 1.5 12/20/96
21 *
22 */
23
24#ifndef _CRYPT_H
25#define _CRYPT_H 1
26
27#include <features.h>
28
29__BEGIN_DECLS
30
31/* One-way hash PHRASE, returning a string suitable for storage in the
32 user database. SALT selects the one-way function to use, and
33 ensures that no two users' hashes are the same, even if they use
34 the same passphrase. The return value points to static storage
35 which will be overwritten by the next call to crypt. */
36extern char *crypt (const char *__phrase, const char *__salt)
37 __THROW __nonnull ((1, 2));
38
39#ifdef __USE_GNU
40
41/* This structure provides scratch and output buffers for 'crypt_r'.
42 Its contents should not be accessed directly. */
43struct crypt_data
44 {
45 char keysched[16 * 8];
46 char sb0[32768];
47 char sb1[32768];
48 char sb2[32768];
49 char sb3[32768];
50 /* end-of-aligment-critical-data */
51 char crypt_3_buf[14];
52 char current_salt[2];
53 long int current_saltbits;
54 int direction, initialized;
55 };
56
57/* Thread-safe version of 'crypt'.
58 DATA must point to a 'struct crypt_data' allocated by the caller.
59 Before the first call to 'crypt_r' with a new 'struct crypt_data',
60 that object must be initialized to all zeroes. The pointer
61 returned, if not NULL, will point within DATA. (It will still be
62 overwritten by the next call to 'crypt_r' with the same DATA.) */
63extern char *crypt_r (const char *__phrase, const char *__salt,
64 struct crypt_data * __restrict __data)
65 __THROW __nonnull ((1, 2, 3));
66#endif
67
68__END_DECLS
69
70#endif /* crypt.h */
libc/glibc-include/ctype.h created+329
...@@ -0,0 +1,329 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/*
19 * ISO C99 Standard 7.4: Character handling <ctype.h>
20 */
21
22#ifndef _CTYPE_H
23#define _CTYPE_H 1
24
25#include <features.h>
26#include <bits/types.h>
27
28__BEGIN_DECLS
29
30#ifndef _ISbit
31/* These are all the characteristics of characters.
32 If there get to be more than 16 distinct characteristics,
33 many things must be changed that use `unsigned short int's.
34
35 The characteristics are stored always in network byte order (big
36 endian). We define the bit value interpretations here dependent on the
37 machine's byte order. */
38
39# include <endian.h>
40# if __BYTE_ORDER == __BIG_ENDIAN
41# define _ISbit(bit) (1 << (bit))
42# else /* __BYTE_ORDER == __LITTLE_ENDIAN */
43# define _ISbit(bit) ((bit) < 8 ? ((1 << (bit)) << 8) : ((1 << (bit)) >> 8))
44# endif
45
46enum
47{
48 _ISupper = _ISbit (0), /* UPPERCASE. */
49 _ISlower = _ISbit (1), /* lowercase. */
50 _ISalpha = _ISbit (2), /* Alphabetic. */
51 _ISdigit = _ISbit (3), /* Numeric. */
52 _ISxdigit = _ISbit (4), /* Hexadecimal numeric. */
53 _ISspace = _ISbit (5), /* Whitespace. */
54 _ISprint = _ISbit (6), /* Printing. */
55 _ISgraph = _ISbit (7), /* Graphical. */
56 _ISblank = _ISbit (8), /* Blank (usually SPC and TAB). */
57 _IScntrl = _ISbit (9), /* Control character. */
58 _ISpunct = _ISbit (10), /* Punctuation. */
59 _ISalnum = _ISbit (11) /* Alphanumeric. */
60};
61#endif /* ! _ISbit */
62
63/* These are defined in ctype-info.c.
64 The declarations here must match those in localeinfo.h.
65
66 In the thread-specific locale model (see `uselocale' in <locale.h>)
67 we cannot use global variables for these as was done in the past.
68 Instead, the following accessor functions return the address of
69 each variable, which is local to the current thread if multithreaded.
70
71 These point into arrays of 384, so they can be indexed by any `unsigned
72 char' value [0,255]; by EOF (-1); or by any `signed char' value
73 [-128,-1). ISO C requires that the ctype functions work for `unsigned
74 char' values and for EOF; we also support negative `signed char' values
75 for broken old programs. The case conversion arrays are of `int's
76 rather than `unsigned char's because tolower (EOF) must be EOF, which
77 doesn't fit into an `unsigned char'. But today more important is that
78 the arrays are also used for multi-byte character sets. */
79extern const unsigned short int **__ctype_b_loc (void)
80 __THROW __attribute__ ((__const__));
81extern const __int32_t **__ctype_tolower_loc (void)
82 __THROW __attribute__ ((__const__));
83extern const __int32_t **__ctype_toupper_loc (void)
84 __THROW __attribute__ ((__const__));
85
86
87#ifndef __cplusplus
88# define __isctype(c, type) \
89 ((*__ctype_b_loc ())[(int) (c)] & (unsigned short int) type)
90#elif defined __USE_EXTERN_INLINES
91# define __isctype_f(type) \
92 __extern_inline int \
93 is##type (int __c) __THROW \
94 { \
95 return (*__ctype_b_loc ())[(int) (__c)] & (unsigned short int) _IS##type; \
96 }
97#endif
98
99#define __isascii(c) (((c) & ~0x7f) == 0) /* If C is a 7 bit value. */
100#define __toascii(c) ((c) & 0x7f) /* Mask off high bits. */
101
102#define __exctype(name) extern int name (int) __THROW
103
104/* The following names are all functions:
105 int isCHARACTERISTIC(int c);
106 which return nonzero iff C has CHARACTERISTIC.
107 For the meaning of the characteristic names, see the `enum' above. */
108__exctype (isalnum);
109__exctype (isalpha);
110__exctype (iscntrl);
111__exctype (isdigit);
112__exctype (islower);
113__exctype (isgraph);
114__exctype (isprint);
115__exctype (ispunct);
116__exctype (isspace);
117__exctype (isupper);
118__exctype (isxdigit);
119
120
121/* Return the lowercase version of C. */
122extern int tolower (int __c) __THROW;
123
124/* Return the uppercase version of C. */
125extern int toupper (int __c) __THROW;
126
127
128/* ISO C99 introduced one new function. */
129#ifdef __USE_ISOC99
130__exctype (isblank);
131#endif
132
133#ifdef __USE_GNU
134/* Test C for a set of character classes according to MASK. */
135extern int isctype (int __c, int __mask) __THROW;
136#endif
137
138#if defined __USE_MISC || defined __USE_XOPEN
139
140/* Return nonzero iff C is in the ASCII set
141 (i.e., is no more than 7 bits wide). */
142extern int isascii (int __c) __THROW;
143
144/* Return the part of C that is in the ASCII set
145 (i.e., the low-order 7 bits of C). */
146extern int toascii (int __c) __THROW;
147
148/* These are the same as `toupper' and `tolower' except that they do not
149 check the argument for being in the range of a `char'. */
150__exctype (_toupper);
151__exctype (_tolower);
152#endif /* Use X/Open or use misc. */
153
154/* This code is needed for the optimized mapping functions. */
155#define __tobody(c, f, a, args) \
156 (__extension__ \
157 ({ int __res; \
158 if (sizeof (c) > 1) \
159 { \
160 if (__builtin_constant_p (c)) \
161 { \
162 int __c = (c); \
163 __res = __c < -128 || __c > 255 ? __c : (a)[__c]; \
164 } \
165 else \
166 __res = f args; \
167 } \
168 else \
169 __res = (a)[(int) (c)]; \
170 __res; }))
171
172#if !defined __NO_CTYPE
173# ifdef __isctype_f
174__isctype_f (alnum)
175__isctype_f (alpha)
176__isctype_f (cntrl)
177__isctype_f (digit)
178__isctype_f (lower)
179__isctype_f (graph)
180__isctype_f (print)
181__isctype_f (punct)
182__isctype_f (space)
183__isctype_f (upper)
184__isctype_f (xdigit)
185# ifdef __USE_ISOC99
186__isctype_f (blank)
187# endif
188# elif defined __isctype
189# define isalnum(c) __isctype((c), _ISalnum)
190# define isalpha(c) __isctype((c), _ISalpha)
191# define iscntrl(c) __isctype((c), _IScntrl)
192# define isdigit(c) __isctype((c), _ISdigit)
193# define islower(c) __isctype((c), _ISlower)
194# define isgraph(c) __isctype((c), _ISgraph)
195# define isprint(c) __isctype((c), _ISprint)
196# define ispunct(c) __isctype((c), _ISpunct)
197# define isspace(c) __isctype((c), _ISspace)
198# define isupper(c) __isctype((c), _ISupper)
199# define isxdigit(c) __isctype((c), _ISxdigit)
200# ifdef __USE_ISOC99
201# define isblank(c) __isctype((c), _ISblank)
202# endif
203# endif
204
205# ifdef __USE_EXTERN_INLINES
206__extern_inline int
207__NTH (tolower (int __c))
208{
209 return __c >= -128 && __c < 256 ? (*__ctype_tolower_loc ())[__c] : __c;
210}
211
212__extern_inline int
213__NTH (toupper (int __c))
214{
215 return __c >= -128 && __c < 256 ? (*__ctype_toupper_loc ())[__c] : __c;
216}
217# endif
218
219# if __GNUC__ >= 2 && defined __OPTIMIZE__ && !defined __cplusplus
220# define tolower(c) __tobody (c, tolower, *__ctype_tolower_loc (), (c))
221# define toupper(c) __tobody (c, toupper, *__ctype_toupper_loc (), (c))
222# endif /* Optimizing gcc */
223
224# if defined __USE_MISC || defined __USE_XOPEN
225# define isascii(c) __isascii (c)
226# define toascii(c) __toascii (c)
227
228# define _tolower(c) ((int) (*__ctype_tolower_loc ())[(int) (c)])
229# define _toupper(c) ((int) (*__ctype_toupper_loc ())[(int) (c)])
230# endif
231
232#endif /* Not __NO_CTYPE. */
233
234
235#ifdef __USE_XOPEN2K8
236/* POSIX.1-2008 extended locale interface (see locale.h). */
237# include <bits/types/locale_t.h>
238
239/* These definitions are similar to the ones above but all functions
240 take as an argument a handle for the locale which shall be used. */
241# define __isctype_l(c, type, locale) \
242 ((locale)->__ctype_b[(int) (c)] & (unsigned short int) type)
243
244# define __exctype_l(name) \
245 extern int name (int, locale_t) __THROW
246
247/* The following names are all functions:
248 int isCHARACTERISTIC(int c, locale_t *locale);
249 which return nonzero iff C has CHARACTERISTIC.
250 For the meaning of the characteristic names, see the `enum' above. */
251__exctype_l (isalnum_l);
252__exctype_l (isalpha_l);
253__exctype_l (iscntrl_l);
254__exctype_l (isdigit_l);
255__exctype_l (islower_l);
256__exctype_l (isgraph_l);
257__exctype_l (isprint_l);
258__exctype_l (ispunct_l);
259__exctype_l (isspace_l);
260__exctype_l (isupper_l);
261__exctype_l (isxdigit_l);
262
263__exctype_l (isblank_l);
264
265
266/* Return the lowercase version of C in locale L. */
267extern int __tolower_l (int __c, locale_t __l) __THROW;
268extern int tolower_l (int __c, locale_t __l) __THROW;
269
270/* Return the uppercase version of C. */
271extern int __toupper_l (int __c, locale_t __l) __THROW;
272extern int toupper_l (int __c, locale_t __l) __THROW;
273
274# if __GNUC__ >= 2 && defined __OPTIMIZE__ && !defined __cplusplus
275# define __tolower_l(c, locale) \
276 __tobody (c, __tolower_l, (locale)->__ctype_tolower, (c, locale))
277# define __toupper_l(c, locale) \
278 __tobody (c, __toupper_l, (locale)->__ctype_toupper, (c, locale))
279# define tolower_l(c, locale) __tolower_l ((c), (locale))
280# define toupper_l(c, locale) __toupper_l ((c), (locale))
281# endif /* Optimizing gcc */
282
283
284# ifndef __NO_CTYPE
285# define __isalnum_l(c,l) __isctype_l((c), _ISalnum, (l))
286# define __isalpha_l(c,l) __isctype_l((c), _ISalpha, (l))
287# define __iscntrl_l(c,l) __isctype_l((c), _IScntrl, (l))
288# define __isdigit_l(c,l) __isctype_l((c), _ISdigit, (l))
289# define __islower_l(c,l) __isctype_l((c), _ISlower, (l))
290# define __isgraph_l(c,l) __isctype_l((c), _ISgraph, (l))
291# define __isprint_l(c,l) __isctype_l((c), _ISprint, (l))
292# define __ispunct_l(c,l) __isctype_l((c), _ISpunct, (l))
293# define __isspace_l(c,l) __isctype_l((c), _ISspace, (l))
294# define __isupper_l(c,l) __isctype_l((c), _ISupper, (l))
295# define __isxdigit_l(c,l) __isctype_l((c), _ISxdigit, (l))
296
297# define __isblank_l(c,l) __isctype_l((c), _ISblank, (l))
298
299# ifdef __USE_MISC
300# define __isascii_l(c,l) ((l), __isascii (c))
301# define __toascii_l(c,l) ((l), __toascii (c))
302# endif
303
304# define isalnum_l(c,l) __isalnum_l ((c), (l))
305# define isalpha_l(c,l) __isalpha_l ((c), (l))
306# define iscntrl_l(c,l) __iscntrl_l ((c), (l))
307# define isdigit_l(c,l) __isdigit_l ((c), (l))
308# define islower_l(c,l) __islower_l ((c), (l))
309# define isgraph_l(c,l) __isgraph_l ((c), (l))
310# define isprint_l(c,l) __isprint_l ((c), (l))
311# define ispunct_l(c,l) __ispunct_l ((c), (l))
312# define isspace_l(c,l) __isspace_l ((c), (l))
313# define isupper_l(c,l) __isupper_l ((c), (l))
314# define isxdigit_l(c,l) __isxdigit_l ((c), (l))
315
316# define isblank_l(c,l) __isblank_l ((c), (l))
317
318# ifdef __USE_MISC
319# define isascii_l(c,l) __isascii_l ((c), (l))
320# define toascii_l(c,l) __toascii_l ((c), (l))
321# endif
322
323# endif /* Not __NO_CTYPE. */
324
325#endif /* Use POSIX 2008. */
326
327__END_DECLS
328
329#endif /* ctype.h */
libc/glibc-include/dirent.h created+404
...@@ -0,0 +1,404 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/*
19 * POSIX Standard: 5.1.2 Directory Operations <dirent.h>
20 */
21
22#ifndef _DIRENT_H
23#define _DIRENT_H 1
24
25#include <features.h>
26
27__BEGIN_DECLS
28
29#include <bits/types.h>
30
31#ifdef __USE_XOPEN
32# ifndef __ino_t_defined
33# ifndef __USE_FILE_OFFSET64
34typedef __ino_t ino_t;
35# else
36typedef __ino64_t ino_t;
37# endif
38# define __ino_t_defined
39# endif
40# if defined __USE_LARGEFILE64 && !defined __ino64_t_defined
41typedef __ino64_t ino64_t;
42# define __ino64_t_defined
43# endif
44#endif
45
46/* This file defines `struct dirent'.
47
48 It defines the macro `_DIRENT_HAVE_D_NAMLEN' iff there is a `d_namlen'
49 member that gives the length of `d_name'.
50
51 It defines the macro `_DIRENT_HAVE_D_RECLEN' iff there is a `d_reclen'
52 member that gives the size of the entire directory entry.
53
54 It defines the macro `_DIRENT_HAVE_D_OFF' iff there is a `d_off'
55 member that gives the file offset of the next directory entry.
56
57 It defines the macro `_DIRENT_HAVE_D_TYPE' iff there is a `d_type'
58 member that gives the type of the file.
59 */
60
61#include <bits/dirent.h>
62
63#if defined __USE_MISC && !defined d_fileno
64# define d_ino d_fileno /* Backward compatibility. */
65#endif
66
67/* These macros extract size information from a `struct dirent *'.
68 They may evaluate their argument multiple times, so it must not
69 have side effects. Each of these may involve a relatively costly
70 call to `strlen' on some systems, so these values should be cached.
71
72 _D_EXACT_NAMLEN (DP) returns the length of DP->d_name, not including
73 its terminating null character.
74
75 _D_ALLOC_NAMLEN (DP) returns a size at least (_D_EXACT_NAMLEN (DP) + 1);
76 that is, the allocation size needed to hold the DP->d_name string.
77 Use this macro when you don't need the exact length, just an upper bound.
78 This macro is less likely to require calling `strlen' than _D_EXACT_NAMLEN.
79 */
80
81#ifdef _DIRENT_HAVE_D_NAMLEN
82# define _D_EXACT_NAMLEN(d) ((d)->d_namlen)
83# define _D_ALLOC_NAMLEN(d) (_D_EXACT_NAMLEN (d) + 1)
84#else
85# define _D_EXACT_NAMLEN(d) (strlen ((d)->d_name))
86# ifdef _DIRENT_HAVE_D_RECLEN
87# define _D_ALLOC_NAMLEN(d) (((char *) (d) + (d)->d_reclen) - &(d)->d_name[0])
88# else
89# define _D_ALLOC_NAMLEN(d) (sizeof (d)->d_name > 1 ? sizeof (d)->d_name : \
90 _D_EXACT_NAMLEN (d) + 1)
91# endif
92#endif
93
94
95#ifdef __USE_MISC
96/* File types for `d_type'. */
97enum
98 {
99 DT_UNKNOWN = 0,
100# define DT_UNKNOWN DT_UNKNOWN
101 DT_FIFO = 1,
102# define DT_FIFO DT_FIFO
103 DT_CHR = 2,
104# define DT_CHR DT_CHR
105 DT_DIR = 4,
106# define DT_DIR DT_DIR
107 DT_BLK = 6,
108# define DT_BLK DT_BLK
109 DT_REG = 8,
110# define DT_REG DT_REG
111 DT_LNK = 10,
112# define DT_LNK DT_LNK
113 DT_SOCK = 12,
114# define DT_SOCK DT_SOCK
115 DT_WHT = 14
116# define DT_WHT DT_WHT
117 };
118
119/* Convert between stat structure types and directory types. */
120# define IFTODT(mode) (((mode) & 0170000) >> 12)
121# define DTTOIF(dirtype) ((dirtype) << 12)
122#endif
123
124
125/* This is the data type of directory stream objects.
126 The actual structure is opaque to users. */
127typedef struct __dirstream DIR;
128
129/* Open a directory stream on NAME.
130 Return a DIR stream on the directory, or NULL if it could not be opened.
131
132 This function is a possible cancellation point and therefore not
133 marked with __THROW. */
134extern DIR *opendir (const char *__name) __nonnull ((1));
135
136#ifdef __USE_XOPEN2K8
137/* Same as opendir, but open the stream on the file descriptor FD.
138
139 This function is a possible cancellation point and therefore not
140 marked with __THROW. */
141extern DIR *fdopendir (int __fd);
142#endif
143
144/* Close the directory stream DIRP.
145 Return 0 if successful, -1 if not.
146
147 This function is a possible cancellation point and therefore not
148 marked with __THROW. */
149extern int closedir (DIR *__dirp) __nonnull ((1));
150
151/* Read a directory entry from DIRP. Return a pointer to a `struct
152 dirent' describing the entry, or NULL for EOF or error. The
153 storage returned may be overwritten by a later readdir call on the
154 same DIR stream.
155
156 If the Large File Support API is selected we have to use the
157 appropriate interface.
158
159 This function is a possible cancellation point and therefore not
160 marked with __THROW. */
161#ifndef __USE_FILE_OFFSET64
162extern struct dirent *readdir (DIR *__dirp) __nonnull ((1));
163#else
164# ifdef __REDIRECT
165extern struct dirent *__REDIRECT (readdir, (DIR *__dirp), readdir64)
166 __nonnull ((1));
167# else
168# define readdir readdir64
169# endif
170#endif
171
172#ifdef __USE_LARGEFILE64
173extern struct dirent64 *readdir64 (DIR *__dirp) __nonnull ((1));
174#endif
175
176#ifdef __USE_POSIX
177/* Reentrant version of `readdir'. Return in RESULT a pointer to the
178 next entry.
179
180 This function is a possible cancellation point and therefore not
181 marked with __THROW. */
182# ifndef __USE_FILE_OFFSET64
183extern int readdir_r (DIR *__restrict __dirp,
184 struct dirent *__restrict __entry,
185 struct dirent **__restrict __result)
186 __nonnull ((1, 2, 3)) __attribute_deprecated__;
187# else
188# ifdef __REDIRECT
189extern int __REDIRECT (readdir_r,
190 (DIR *__restrict __dirp,
191 struct dirent *__restrict __entry,
192 struct dirent **__restrict __result),
193 readdir64_r)
194 __nonnull ((1, 2, 3)) __attribute_deprecated__;
195# else
196# define readdir_r readdir64_r
197# endif
198# endif
199
200# ifdef __USE_LARGEFILE64
201extern int readdir64_r (DIR *__restrict __dirp,
202 struct dirent64 *__restrict __entry,
203 struct dirent64 **__restrict __result)
204 __nonnull ((1, 2, 3)) __attribute_deprecated__;
205# endif
206#endif /* POSIX or misc */
207
208/* Rewind DIRP to the beginning of the directory. */
209extern void rewinddir (DIR *__dirp) __THROW __nonnull ((1));
210
211#if defined __USE_MISC || defined __USE_XOPEN
212# include <bits/types.h>
213
214/* Seek to position POS on DIRP. */
215extern void seekdir (DIR *__dirp, long int __pos) __THROW __nonnull ((1));
216
217/* Return the current position of DIRP. */
218extern long int telldir (DIR *__dirp) __THROW __nonnull ((1));
219#endif
220
221#ifdef __USE_XOPEN2K8
222
223/* Return the file descriptor used by DIRP. */
224extern int dirfd (DIR *__dirp) __THROW __nonnull ((1));
225
226# if defined __OPTIMIZE__ && defined _DIR_dirfd
227# define dirfd(dirp) _DIR_dirfd (dirp)
228# endif
229
230# ifdef __USE_MISC
231# ifndef MAXNAMLEN
232/* Get the definitions of the POSIX.1 limits. */
233# include <bits/posix1_lim.h>
234
235/* `MAXNAMLEN' is the BSD name for what POSIX calls `NAME_MAX'. */
236# ifdef NAME_MAX
237# define MAXNAMLEN NAME_MAX
238# else
239# define MAXNAMLEN 255
240# endif
241# endif
242# endif
243
244# define __need_size_t
245# include <stddef.h>
246
247/* Scan the directory DIR, calling SELECTOR on each directory entry.
248 Entries for which SELECT returns nonzero are individually malloc'd,
249 sorted using qsort with CMP, and collected in a malloc'd array in
250 *NAMELIST. Returns the number of entries selected, or -1 on error.
251
252 This function is a cancellation point and therefore not marked with
253 __THROW. */
254# ifndef __USE_FILE_OFFSET64
255extern int scandir (const char *__restrict __dir,
256 struct dirent ***__restrict __namelist,
257 int (*__selector) (const struct dirent *),
258 int (*__cmp) (const struct dirent **,
259 const struct dirent **))
260 __nonnull ((1, 2));
261# else
262# ifdef __REDIRECT
263extern int __REDIRECT (scandir,
264 (const char *__restrict __dir,
265 struct dirent ***__restrict __namelist,
266 int (*__selector) (const struct dirent *),
267 int (*__cmp) (const struct dirent **,
268 const struct dirent **)),
269 scandir64) __nonnull ((1, 2));
270# else
271# define scandir scandir64
272# endif
273# endif
274
275# if defined __USE_GNU && defined __USE_LARGEFILE64
276/* This function is like `scandir' but it uses the 64bit dirent structure.
277 Please note that the CMP function must now work with struct dirent64 **. */
278extern int scandir64 (const char *__restrict __dir,
279 struct dirent64 ***__restrict __namelist,
280 int (*__selector) (const struct dirent64 *),
281 int (*__cmp) (const struct dirent64 **,
282 const struct dirent64 **))
283 __nonnull ((1, 2));
284# endif
285
286# ifdef __USE_GNU
287/* Similar to `scandir' but a relative DIR name is interpreted relative
288 to the directory for which DFD is a descriptor.
289
290 This function is a cancellation point and therefore not marked with
291 __THROW. */
292# ifndef __USE_FILE_OFFSET64
293extern int scandirat (int __dfd, const char *__restrict __dir,
294 struct dirent ***__restrict __namelist,
295 int (*__selector) (const struct dirent *),
296 int (*__cmp) (const struct dirent **,
297 const struct dirent **))
298 __nonnull ((2, 3));
299# else
300# ifdef __REDIRECT
301extern int __REDIRECT (scandirat,
302 (int __dfd, const char *__restrict __dir,
303 struct dirent ***__restrict __namelist,
304 int (*__selector) (const struct dirent *),
305 int (*__cmp) (const struct dirent **,
306 const struct dirent **)),
307 scandirat64) __nonnull ((2, 3));
308# else
309# define scandirat scandirat64
310# endif
311# endif
312
313/* This function is like `scandir' but it uses the 64bit dirent structure.
314 Please note that the CMP function must now work with struct dirent64 **. */
315extern int scandirat64 (int __dfd, const char *__restrict __dir,
316 struct dirent64 ***__restrict __namelist,
317 int (*__selector) (const struct dirent64 *),
318 int (*__cmp) (const struct dirent64 **,
319 const struct dirent64 **))
320 __nonnull ((2, 3));
321# endif
322
323/* Function to compare two `struct dirent's alphabetically. */
324# ifndef __USE_FILE_OFFSET64
325extern int alphasort (const struct dirent **__e1,
326 const struct dirent **__e2)
327 __THROW __attribute_pure__ __nonnull ((1, 2));
328# else
329# ifdef __REDIRECT
330extern int __REDIRECT_NTH (alphasort,
331 (const struct dirent **__e1,
332 const struct dirent **__e2),
333 alphasort64) __attribute_pure__ __nonnull ((1, 2));
334# else
335# define alphasort alphasort64
336# endif
337# endif
338
339# if defined __USE_GNU && defined __USE_LARGEFILE64
340extern int alphasort64 (const struct dirent64 **__e1,
341 const struct dirent64 **__e2)
342 __THROW __attribute_pure__ __nonnull ((1, 2));
343# endif
344#endif /* Use XPG7. */
345
346
347#ifdef __USE_MISC
348/* Read directory entries from FD into BUF, reading at most NBYTES.
349 Reading starts at offset *BASEP, and *BASEP is updated with the new
350 position after reading. Returns the number of bytes read; zero when at
351 end of directory; or -1 for errors. */
352# ifndef __USE_FILE_OFFSET64
353extern __ssize_t getdirentries (int __fd, char *__restrict __buf,
354 size_t __nbytes,
355 __off_t *__restrict __basep)
356 __THROW __nonnull ((2, 4));
357# else
358# ifdef __REDIRECT
359extern __ssize_t __REDIRECT_NTH (getdirentries,
360 (int __fd, char *__restrict __buf,
361 size_t __nbytes,
362 __off64_t *__restrict __basep),
363 getdirentries64) __nonnull ((2, 4));
364# else
365# define getdirentries getdirentries64
366# endif
367# endif
368
369# ifdef __USE_LARGEFILE64
370extern __ssize_t getdirentries64 (int __fd, char *__restrict __buf,
371 size_t __nbytes,
372 __off64_t *__restrict __basep)
373 __THROW __nonnull ((2, 4));
374# endif
375#endif /* Use misc. */
376
377#ifdef __USE_GNU
378/* Function to compare two `struct dirent's by name & version. */
379# ifndef __USE_FILE_OFFSET64
380extern int versionsort (const struct dirent **__e1,
381 const struct dirent **__e2)
382 __THROW __attribute_pure__ __nonnull ((1, 2));
383# else
384# ifdef __REDIRECT
385extern int __REDIRECT_NTH (versionsort,
386 (const struct dirent **__e1,
387 const struct dirent **__e2),
388 versionsort64)
389 __attribute_pure__ __nonnull ((1, 2));
390# else
391# define versionsort versionsort64
392# endif
393# endif
394
395# ifdef __USE_LARGEFILE64
396extern int versionsort64 (const struct dirent64 **__e1,
397 const struct dirent64 **__e2)
398 __THROW __attribute_pure__ __nonnull ((1, 2));
399# endif
400#endif /* Use GNU. */
401
402__END_DECLS
403
404#endif /* dirent.h */
libc/glibc-include/dlfcn.h created+190
...@@ -0,0 +1,190 @@
1/* User functions for run-time dynamic loading.
2 Copyright (C) 1995-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _DLFCN_H
20#define _DLFCN_H 1
21
22#include <features.h>
23#define __need_size_t
24#include <stddef.h>
25
26/* Collect various system dependent definitions and declarations. */
27#include <bits/dlfcn.h>
28
29
30#ifdef __USE_GNU
31/* If the first argument of `dlsym' or `dlvsym' is set to RTLD_NEXT
32 the run-time address of the symbol called NAME in the next shared
33 object is returned. The "next" relation is defined by the order
34 the shared objects were loaded. */
35# define RTLD_NEXT ((void *) -1l)
36
37/* If the first argument to `dlsym' or `dlvsym' is set to RTLD_DEFAULT
38 the run-time address of the symbol called NAME in the global scope
39 is returned. */
40# define RTLD_DEFAULT ((void *) 0)
41
42
43/* Type for namespace indeces. */
44typedef long int Lmid_t;
45
46/* Special namespace ID values. */
47# define LM_ID_BASE 0 /* Initial namespace. */
48# define LM_ID_NEWLM -1 /* For dlmopen: request new namespace. */
49#endif
50
51
52__BEGIN_DECLS
53
54/* Open the shared object FILE and map it in; return a handle that can be
55 passed to `dlsym' to get symbol values from it. */
56extern void *dlopen (const char *__file, int __mode) __THROWNL;
57
58/* Unmap and close a shared object opened by `dlopen'.
59 The handle cannot be used again after calling `dlclose'. */
60extern int dlclose (void *__handle) __THROWNL __nonnull ((1));
61
62/* Find the run-time address in the shared object HANDLE refers to
63 of the symbol called NAME. */
64extern void *dlsym (void *__restrict __handle,
65 const char *__restrict __name) __THROW __nonnull ((2));
66
67#ifdef __USE_GNU
68/* Like `dlopen', but request object to be allocated in a new namespace. */
69extern void *dlmopen (Lmid_t __nsid, const char *__file, int __mode) __THROWNL;
70
71/* Find the run-time address in the shared object HANDLE refers to
72 of the symbol called NAME with VERSION. */
73extern void *dlvsym (void *__restrict __handle,
74 const char *__restrict __name,
75 const char *__restrict __version)
76 __THROW __nonnull ((2, 3));
77#endif
78
79/* When any of the above functions fails, call this function
80 to return a string describing the error. Each call resets
81 the error string so that a following call returns null. */
82extern char *dlerror (void) __THROW;
83
84
85#ifdef __USE_GNU
86/* Structure containing information about object searched using
87 `dladdr'. */
88typedef struct
89{
90 const char *dli_fname; /* File name of defining object. */
91 void *dli_fbase; /* Load address of that object. */
92 const char *dli_sname; /* Name of nearest symbol. */
93 void *dli_saddr; /* Exact value of nearest symbol. */
94} Dl_info;
95
96/* Fill in *INFO with the following information about ADDRESS.
97 Returns 0 iff no shared object's segments contain that address. */
98extern int dladdr (const void *__address, Dl_info *__info)
99 __THROW __nonnull ((2));
100
101/* Same as `dladdr', but additionally sets *EXTRA_INFO according to FLAGS. */
102extern int dladdr1 (const void *__address, Dl_info *__info,
103 void **__extra_info, int __flags) __THROW __nonnull ((2));
104
105/* These are the possible values for the FLAGS argument to `dladdr1'.
106 This indicates what extra information is stored at *EXTRA_INFO.
107 It may also be zero, in which case the EXTRA_INFO argument is not used. */
108enum
109 {
110 /* Matching symbol table entry (const ElfNN_Sym *). */
111 RTLD_DL_SYMENT = 1,
112
113 /* The object containing the address (struct link_map *). */
114 RTLD_DL_LINKMAP = 2
115 };
116
117
118/* Get information about the shared object HANDLE refers to.
119 REQUEST is from among the values below, and determines the use of ARG.
120
121 On success, returns zero. On failure, returns -1 and records an error
122 message to be fetched with `dlerror'. */
123extern int dlinfo (void *__restrict __handle,
124 int __request, void *__restrict __arg)
125 __THROW __nonnull ((1, 3));
126
127/* These are the possible values for the REQUEST argument to `dlinfo'. */
128enum
129 {
130 /* Treat ARG as `lmid_t *'; store namespace ID for HANDLE there. */
131 RTLD_DI_LMID = 1,
132
133 /* Treat ARG as `struct link_map **';
134 store the `struct link_map *' for HANDLE there. */
135 RTLD_DI_LINKMAP = 2,
136
137 RTLD_DI_CONFIGADDR = 3, /* Unsupported, defined by Solaris. */
138
139 /* Treat ARG as `Dl_serinfo *' (see below), and fill in to describe the
140 directories that will be searched for dependencies of this object.
141 RTLD_DI_SERINFOSIZE fills in just the `dls_cnt' and `dls_size'
142 entries to indicate the size of the buffer that must be passed to
143 RTLD_DI_SERINFO to fill in the full information. */
144 RTLD_DI_SERINFO = 4,
145 RTLD_DI_SERINFOSIZE = 5,
146
147 /* Treat ARG as `char *', and store there the directory name used to
148 expand $ORIGIN in this shared object's dependency file names. */
149 RTLD_DI_ORIGIN = 6,
150
151 RTLD_DI_PROFILENAME = 7, /* Unsupported, defined by Solaris. */
152 RTLD_DI_PROFILEOUT = 8, /* Unsupported, defined by Solaris. */
153
154 /* Treat ARG as `size_t *', and store there the TLS module ID
155 of this object's PT_TLS segment, as used in TLS relocations;
156 store zero if this object does not define a PT_TLS segment. */
157 RTLD_DI_TLS_MODID = 9,
158
159 /* Treat ARG as `void **', and store there a pointer to the calling
160 thread's TLS block corresponding to this object's PT_TLS segment.
161 Store a null pointer if this object does not define a PT_TLS
162 segment, or if the calling thread has not allocated a block for it. */
163 RTLD_DI_TLS_DATA = 10,
164
165 RTLD_DI_MAX = 10
166 };
167
168
169/* This is the type of elements in `Dl_serinfo', below.
170 The `dls_name' member points to space in the buffer passed to `dlinfo'. */
171typedef struct
172{
173 char *dls_name; /* Name of library search path directory. */
174 unsigned int dls_flags; /* Indicates where this directory came from. */
175} Dl_serpath;
176
177/* This is the structure that must be passed (by reference) to `dlinfo' for
178 the RTLD_DI_SERINFO and RTLD_DI_SERINFOSIZE requests. */
179typedef struct
180{
181 size_t dls_size; /* Size in bytes of the whole buffer. */
182 unsigned int dls_cnt; /* Number of elements in `dls_serpath'. */
183 Dl_serpath dls_serpath[1]; /* Actually longer, dls_cnt elements. */
184} Dl_serinfo;
185#endif /* __USE_GNU */
186
187
188__END_DECLS
189
190#endif /* dlfcn.h */
libc/glibc-include/elf.h created+4001
...@@ -0,0 +1,4001 @@
1/* This file defines standard ELF types, structures, and macros.
2 Copyright (C) 1995-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _ELF_H
20#define _ELF_H 1
21
22#include <features.h>
23
24__BEGIN_DECLS
25
26/* Standard ELF types. */
27
28#include <stdint.h>
29
30/* Type for a 16-bit quantity. */
31typedef uint16_t Elf32_Half;
32typedef uint16_t Elf64_Half;
33
34/* Types for signed and unsigned 32-bit quantities. */
35typedef uint32_t Elf32_Word;
36typedef int32_t Elf32_Sword;
37typedef uint32_t Elf64_Word;
38typedef int32_t Elf64_Sword;
39
40/* Types for signed and unsigned 64-bit quantities. */
41typedef uint64_t Elf32_Xword;
42typedef int64_t Elf32_Sxword;
43typedef uint64_t Elf64_Xword;
44typedef int64_t Elf64_Sxword;
45
46/* Type of addresses. */
47typedef uint32_t Elf32_Addr;
48typedef uint64_t Elf64_Addr;
49
50/* Type of file offsets. */
51typedef uint32_t Elf32_Off;
52typedef uint64_t Elf64_Off;
53
54/* Type for section indices, which are 16-bit quantities. */
55typedef uint16_t Elf32_Section;
56typedef uint16_t Elf64_Section;
57
58/* Type for version symbol information. */
59typedef Elf32_Half Elf32_Versym;
60typedef Elf64_Half Elf64_Versym;
61
62
63/* The ELF file header. This appears at the start of every ELF file. */
64
65#define EI_NIDENT (16)
66
67typedef struct
68{
69 unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */
70 Elf32_Half e_type; /* Object file type */
71 Elf32_Half e_machine; /* Architecture */
72 Elf32_Word e_version; /* Object file version */
73 Elf32_Addr e_entry; /* Entry point virtual address */
74 Elf32_Off e_phoff; /* Program header table file offset */
75 Elf32_Off e_shoff; /* Section header table file offset */
76 Elf32_Word e_flags; /* Processor-specific flags */
77 Elf32_Half e_ehsize; /* ELF header size in bytes */
78 Elf32_Half e_phentsize; /* Program header table entry size */
79 Elf32_Half e_phnum; /* Program header table entry count */
80 Elf32_Half e_shentsize; /* Section header table entry size */
81 Elf32_Half e_shnum; /* Section header table entry count */
82 Elf32_Half e_shstrndx; /* Section header string table index */
83} Elf32_Ehdr;
84
85typedef struct
86{
87 unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */
88 Elf64_Half e_type; /* Object file type */
89 Elf64_Half e_machine; /* Architecture */
90 Elf64_Word e_version; /* Object file version */
91 Elf64_Addr e_entry; /* Entry point virtual address */
92 Elf64_Off e_phoff; /* Program header table file offset */
93 Elf64_Off e_shoff; /* Section header table file offset */
94 Elf64_Word e_flags; /* Processor-specific flags */
95 Elf64_Half e_ehsize; /* ELF header size in bytes */
96 Elf64_Half e_phentsize; /* Program header table entry size */
97 Elf64_Half e_phnum; /* Program header table entry count */
98 Elf64_Half e_shentsize; /* Section header table entry size */
99 Elf64_Half e_shnum; /* Section header table entry count */
100 Elf64_Half e_shstrndx; /* Section header string table index */
101} Elf64_Ehdr;
102
103/* Fields in the e_ident array. The EI_* macros are indices into the
104 array. The macros under each EI_* macro are the values the byte
105 may have. */
106
107#define EI_MAG0 0 /* File identification byte 0 index */
108#define ELFMAG0 0x7f /* Magic number byte 0 */
109
110#define EI_MAG1 1 /* File identification byte 1 index */
111#define ELFMAG1 'E' /* Magic number byte 1 */
112
113#define EI_MAG2 2 /* File identification byte 2 index */
114#define ELFMAG2 'L' /* Magic number byte 2 */
115
116#define EI_MAG3 3 /* File identification byte 3 index */
117#define ELFMAG3 'F' /* Magic number byte 3 */
118
119/* Conglomeration of the identification bytes, for easy testing as a word. */
120#define ELFMAG "\177ELF"
121#define SELFMAG 4
122
123#define EI_CLASS 4 /* File class byte index */
124#define ELFCLASSNONE 0 /* Invalid class */
125#define ELFCLASS32 1 /* 32-bit objects */
126#define ELFCLASS64 2 /* 64-bit objects */
127#define ELFCLASSNUM 3
128
129#define EI_DATA 5 /* Data encoding byte index */
130#define ELFDATANONE 0 /* Invalid data encoding */
131#define ELFDATA2LSB 1 /* 2's complement, little endian */
132#define ELFDATA2MSB 2 /* 2's complement, big endian */
133#define ELFDATANUM 3
134
135#define EI_VERSION 6 /* File version byte index */
136 /* Value must be EV_CURRENT */
137
138#define EI_OSABI 7 /* OS ABI identification */
139#define ELFOSABI_NONE 0 /* UNIX System V ABI */
140#define ELFOSABI_SYSV 0 /* Alias. */
141#define ELFOSABI_HPUX 1 /* HP-UX */
142#define ELFOSABI_NETBSD 2 /* NetBSD. */
143#define ELFOSABI_GNU 3 /* Object uses GNU ELF extensions. */
144#define ELFOSABI_LINUX ELFOSABI_GNU /* Compatibility alias. */
145#define ELFOSABI_SOLARIS 6 /* Sun Solaris. */
146#define ELFOSABI_AIX 7 /* IBM AIX. */
147#define ELFOSABI_IRIX 8 /* SGI Irix. */
148#define ELFOSABI_FREEBSD 9 /* FreeBSD. */
149#define ELFOSABI_TRU64 10 /* Compaq TRU64 UNIX. */
150#define ELFOSABI_MODESTO 11 /* Novell Modesto. */
151#define ELFOSABI_OPENBSD 12 /* OpenBSD. */
152#define ELFOSABI_ARM_AEABI 64 /* ARM EABI */
153#define ELFOSABI_ARM 97 /* ARM */
154#define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */
155
156#define EI_ABIVERSION 8 /* ABI version */
157
158#define EI_PAD 9 /* Byte index of padding bytes */
159
160/* Legal values for e_type (object file type). */
161
162#define ET_NONE 0 /* No file type */
163#define ET_REL 1 /* Relocatable file */
164#define ET_EXEC 2 /* Executable file */
165#define ET_DYN 3 /* Shared object file */
166#define ET_CORE 4 /* Core file */
167#define ET_NUM 5 /* Number of defined types */
168#define ET_LOOS 0xfe00 /* OS-specific range start */
169#define ET_HIOS 0xfeff /* OS-specific range end */
170#define ET_LOPROC 0xff00 /* Processor-specific range start */
171#define ET_HIPROC 0xffff /* Processor-specific range end */
172
173/* Legal values for e_machine (architecture). */
174
175#define EM_NONE 0 /* No machine */
176#define EM_M32 1 /* AT&T WE 32100 */
177#define EM_SPARC 2 /* SUN SPARC */
178#define EM_386 3 /* Intel 80386 */
179#define EM_68K 4 /* Motorola m68k family */
180#define EM_88K 5 /* Motorola m88k family */
181#define EM_IAMCU 6 /* Intel MCU */
182#define EM_860 7 /* Intel 80860 */
183#define EM_MIPS 8 /* MIPS R3000 big-endian */
184#define EM_S370 9 /* IBM System/370 */
185#define EM_MIPS_RS3_LE 10 /* MIPS R3000 little-endian */
186 /* reserved 11-14 */
187#define EM_PARISC 15 /* HPPA */
188 /* reserved 16 */
189#define EM_VPP500 17 /* Fujitsu VPP500 */
190#define EM_SPARC32PLUS 18 /* Sun's "v8plus" */
191#define EM_960 19 /* Intel 80960 */
192#define EM_PPC 20 /* PowerPC */
193#define EM_PPC64 21 /* PowerPC 64-bit */
194#define EM_S390 22 /* IBM S390 */
195#define EM_SPU 23 /* IBM SPU/SPC */
196 /* reserved 24-35 */
197#define EM_V800 36 /* NEC V800 series */
198#define EM_FR20 37 /* Fujitsu FR20 */
199#define EM_RH32 38 /* TRW RH-32 */
200#define EM_RCE 39 /* Motorola RCE */
201#define EM_ARM 40 /* ARM */
202#define EM_FAKE_ALPHA 41 /* Digital Alpha */
203#define EM_SH 42 /* Hitachi SH */
204#define EM_SPARCV9 43 /* SPARC v9 64-bit */
205#define EM_TRICORE 44 /* Siemens Tricore */
206#define EM_ARC 45 /* Argonaut RISC Core */
207#define EM_H8_300 46 /* Hitachi H8/300 */
208#define EM_H8_300H 47 /* Hitachi H8/300H */
209#define EM_H8S 48 /* Hitachi H8S */
210#define EM_H8_500 49 /* Hitachi H8/500 */
211#define EM_IA_64 50 /* Intel Merced */
212#define EM_MIPS_X 51 /* Stanford MIPS-X */
213#define EM_COLDFIRE 52 /* Motorola Coldfire */
214#define EM_68HC12 53 /* Motorola M68HC12 */
215#define EM_MMA 54 /* Fujitsu MMA Multimedia Accelerator */
216#define EM_PCP 55 /* Siemens PCP */
217#define EM_NCPU 56 /* Sony nCPU embeeded RISC */
218#define EM_NDR1 57 /* Denso NDR1 microprocessor */
219#define EM_STARCORE 58 /* Motorola Start*Core processor */
220#define EM_ME16 59 /* Toyota ME16 processor */
221#define EM_ST100 60 /* STMicroelectronic ST100 processor */
222#define EM_TINYJ 61 /* Advanced Logic Corp. Tinyj emb.fam */
223#define EM_X86_64 62 /* AMD x86-64 architecture */
224#define EM_PDSP 63 /* Sony DSP Processor */
225#define EM_PDP10 64 /* Digital PDP-10 */
226#define EM_PDP11 65 /* Digital PDP-11 */
227#define EM_FX66 66 /* Siemens FX66 microcontroller */
228#define EM_ST9PLUS 67 /* STMicroelectronics ST9+ 8/16 mc */
229#define EM_ST7 68 /* STmicroelectronics ST7 8 bit mc */
230#define EM_68HC16 69 /* Motorola MC68HC16 microcontroller */
231#define EM_68HC11 70 /* Motorola MC68HC11 microcontroller */
232#define EM_68HC08 71 /* Motorola MC68HC08 microcontroller */
233#define EM_68HC05 72 /* Motorola MC68HC05 microcontroller */
234#define EM_SVX 73 /* Silicon Graphics SVx */
235#define EM_ST19 74 /* STMicroelectronics ST19 8 bit mc */
236#define EM_VAX 75 /* Digital VAX */
237#define EM_CRIS 76 /* Axis Communications 32-bit emb.proc */
238#define EM_JAVELIN 77 /* Infineon Technologies 32-bit emb.proc */
239#define EM_FIREPATH 78 /* Element 14 64-bit DSP Processor */
240#define EM_ZSP 79 /* LSI Logic 16-bit DSP Processor */
241#define EM_MMIX 80 /* Donald Knuth's educational 64-bit proc */
242#define EM_HUANY 81 /* Harvard University machine-independent object files */
243#define EM_PRISM 82 /* SiTera Prism */
244#define EM_AVR 83 /* Atmel AVR 8-bit microcontroller */
245#define EM_FR30 84 /* Fujitsu FR30 */
246#define EM_D10V 85 /* Mitsubishi D10V */
247#define EM_D30V 86 /* Mitsubishi D30V */
248#define EM_V850 87 /* NEC v850 */
249#define EM_M32R 88 /* Mitsubishi M32R */
250#define EM_MN10300 89 /* Matsushita MN10300 */
251#define EM_MN10200 90 /* Matsushita MN10200 */
252#define EM_PJ 91 /* picoJava */
253#define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor */
254#define EM_ARC_COMPACT 93 /* ARC International ARCompact */
255#define EM_XTENSA 94 /* Tensilica Xtensa Architecture */
256#define EM_VIDEOCORE 95 /* Alphamosaic VideoCore */
257#define EM_TMM_GPP 96 /* Thompson Multimedia General Purpose Proc */
258#define EM_NS32K 97 /* National Semi. 32000 */
259#define EM_TPC 98 /* Tenor Network TPC */
260#define EM_SNP1K 99 /* Trebia SNP 1000 */
261#define EM_ST200 100 /* STMicroelectronics ST200 */
262#define EM_IP2K 101 /* Ubicom IP2xxx */
263#define EM_MAX 102 /* MAX processor */
264#define EM_CR 103 /* National Semi. CompactRISC */
265#define EM_F2MC16 104 /* Fujitsu F2MC16 */
266#define EM_MSP430 105 /* Texas Instruments msp430 */
267#define EM_BLACKFIN 106 /* Analog Devices Blackfin DSP */
268#define EM_SE_C33 107 /* Seiko Epson S1C33 family */
269#define EM_SEP 108 /* Sharp embedded microprocessor */
270#define EM_ARCA 109 /* Arca RISC */
271#define EM_UNICORE 110 /* PKU-Unity & MPRC Peking Uni. mc series */
272#define EM_EXCESS 111 /* eXcess configurable cpu */
273#define EM_DXP 112 /* Icera Semi. Deep Execution Processor */
274#define EM_ALTERA_NIOS2 113 /* Altera Nios II */
275#define EM_CRX 114 /* National Semi. CompactRISC CRX */
276#define EM_XGATE 115 /* Motorola XGATE */
277#define EM_C166 116 /* Infineon C16x/XC16x */
278#define EM_M16C 117 /* Renesas M16C */
279#define EM_DSPIC30F 118 /* Microchip Technology dsPIC30F */
280#define EM_CE 119 /* Freescale Communication Engine RISC */
281#define EM_M32C 120 /* Renesas M32C */
282 /* reserved 121-130 */
283#define EM_TSK3000 131 /* Altium TSK3000 */
284#define EM_RS08 132 /* Freescale RS08 */
285#define EM_SHARC 133 /* Analog Devices SHARC family */
286#define EM_ECOG2 134 /* Cyan Technology eCOG2 */
287#define EM_SCORE7 135 /* Sunplus S+core7 RISC */
288#define EM_DSP24 136 /* New Japan Radio (NJR) 24-bit DSP */
289#define EM_VIDEOCORE3 137 /* Broadcom VideoCore III */
290#define EM_LATTICEMICO32 138 /* RISC for Lattice FPGA */
291#define EM_SE_C17 139 /* Seiko Epson C17 */
292#define EM_TI_C6000 140 /* Texas Instruments TMS320C6000 DSP */
293#define EM_TI_C2000 141 /* Texas Instruments TMS320C2000 DSP */
294#define EM_TI_C5500 142 /* Texas Instruments TMS320C55x DSP */
295#define EM_TI_ARP32 143 /* Texas Instruments App. Specific RISC */
296#define EM_TI_PRU 144 /* Texas Instruments Prog. Realtime Unit */
297 /* reserved 145-159 */
298#define EM_MMDSP_PLUS 160 /* STMicroelectronics 64bit VLIW DSP */
299#define EM_CYPRESS_M8C 161 /* Cypress M8C */
300#define EM_R32C 162 /* Renesas R32C */
301#define EM_TRIMEDIA 163 /* NXP Semi. TriMedia */
302#define EM_QDSP6 164 /* QUALCOMM DSP6 */
303#define EM_8051 165 /* Intel 8051 and variants */
304#define EM_STXP7X 166 /* STMicroelectronics STxP7x */
305#define EM_NDS32 167 /* Andes Tech. compact code emb. RISC */
306#define EM_ECOG1X 168 /* Cyan Technology eCOG1X */
307#define EM_MAXQ30 169 /* Dallas Semi. MAXQ30 mc */
308#define EM_XIMO16 170 /* New Japan Radio (NJR) 16-bit DSP */
309#define EM_MANIK 171 /* M2000 Reconfigurable RISC */
310#define EM_CRAYNV2 172 /* Cray NV2 vector architecture */
311#define EM_RX 173 /* Renesas RX */
312#define EM_METAG 174 /* Imagination Tech. META */
313#define EM_MCST_ELBRUS 175 /* MCST Elbrus */
314#define EM_ECOG16 176 /* Cyan Technology eCOG16 */
315#define EM_CR16 177 /* National Semi. CompactRISC CR16 */
316#define EM_ETPU 178 /* Freescale Extended Time Processing Unit */
317#define EM_SLE9X 179 /* Infineon Tech. SLE9X */
318#define EM_L10M 180 /* Intel L10M */
319#define EM_K10M 181 /* Intel K10M */
320 /* reserved 182 */
321#define EM_AARCH64 183 /* ARM AARCH64 */
322 /* reserved 184 */
323#define EM_AVR32 185 /* Amtel 32-bit microprocessor */
324#define EM_STM8 186 /* STMicroelectronics STM8 */
325#define EM_TILE64 187 /* Tileta TILE64 */
326#define EM_TILEPRO 188 /* Tilera TILEPro */
327#define EM_MICROBLAZE 189 /* Xilinx MicroBlaze */
328#define EM_CUDA 190 /* NVIDIA CUDA */
329#define EM_TILEGX 191 /* Tilera TILE-Gx */
330#define EM_CLOUDSHIELD 192 /* CloudShield */
331#define EM_COREA_1ST 193 /* KIPO-KAIST Core-A 1st gen. */
332#define EM_COREA_2ND 194 /* KIPO-KAIST Core-A 2nd gen. */
333#define EM_ARC_COMPACT2 195 /* Synopsys ARCompact V2 */
334#define EM_OPEN8 196 /* Open8 RISC */
335#define EM_RL78 197 /* Renesas RL78 */
336#define EM_VIDEOCORE5 198 /* Broadcom VideoCore V */
337#define EM_78KOR 199 /* Renesas 78KOR */
338#define EM_56800EX 200 /* Freescale 56800EX DSC */
339#define EM_BA1 201 /* Beyond BA1 */
340#define EM_BA2 202 /* Beyond BA2 */
341#define EM_XCORE 203 /* XMOS xCORE */
342#define EM_MCHP_PIC 204 /* Microchip 8-bit PIC(r) */
343 /* reserved 205-209 */
344#define EM_KM32 210 /* KM211 KM32 */
345#define EM_KMX32 211 /* KM211 KMX32 */
346#define EM_EMX16 212 /* KM211 KMX16 */
347#define EM_EMX8 213 /* KM211 KMX8 */
348#define EM_KVARC 214 /* KM211 KVARC */
349#define EM_CDP 215 /* Paneve CDP */
350#define EM_COGE 216 /* Cognitive Smart Memory Processor */
351#define EM_COOL 217 /* Bluechip CoolEngine */
352#define EM_NORC 218 /* Nanoradio Optimized RISC */
353#define EM_CSR_KALIMBA 219 /* CSR Kalimba */
354#define EM_Z80 220 /* Zilog Z80 */
355#define EM_VISIUM 221 /* Controls and Data Services VISIUMcore */
356#define EM_FT32 222 /* FTDI Chip FT32 */
357#define EM_MOXIE 223 /* Moxie processor */
358#define EM_AMDGPU 224 /* AMD GPU */
359 /* reserved 225-242 */
360#define EM_RISCV 243 /* RISC-V */
361
362#define EM_BPF 247 /* Linux BPF -- in-kernel virtual machine */
363#define EM_CSKY 252 /* C_SKY */
364
365#define EM_NUM 253
366
367/* Old spellings/synonyms. */
368
369#define EM_ARC_A5 EM_ARC_COMPACT
370
371/* If it is necessary to assign new unofficial EM_* values, please
372 pick large random numbers (0x8523, 0xa7f2, etc.) to minimize the
373 chances of collision with official or non-GNU unofficial values. */
374
375#define EM_ALPHA 0x9026
376
377/* Legal values for e_version (version). */
378
379#define EV_NONE 0 /* Invalid ELF version */
380#define EV_CURRENT 1 /* Current version */
381#define EV_NUM 2
382
383/* Section header. */
384
385typedef struct
386{
387 Elf32_Word sh_name; /* Section name (string tbl index) */
388 Elf32_Word sh_type; /* Section type */
389 Elf32_Word sh_flags; /* Section flags */
390 Elf32_Addr sh_addr; /* Section virtual addr at execution */
391 Elf32_Off sh_offset; /* Section file offset */
392 Elf32_Word sh_size; /* Section size in bytes */
393 Elf32_Word sh_link; /* Link to another section */
394 Elf32_Word sh_info; /* Additional section information */
395 Elf32_Word sh_addralign; /* Section alignment */
396 Elf32_Word sh_entsize; /* Entry size if section holds table */
397} Elf32_Shdr;
398
399typedef struct
400{
401 Elf64_Word sh_name; /* Section name (string tbl index) */
402 Elf64_Word sh_type; /* Section type */
403 Elf64_Xword sh_flags; /* Section flags */
404 Elf64_Addr sh_addr; /* Section virtual addr at execution */
405 Elf64_Off sh_offset; /* Section file offset */
406 Elf64_Xword sh_size; /* Section size in bytes */
407 Elf64_Word sh_link; /* Link to another section */
408 Elf64_Word sh_info; /* Additional section information */
409 Elf64_Xword sh_addralign; /* Section alignment */
410 Elf64_Xword sh_entsize; /* Entry size if section holds table */
411} Elf64_Shdr;
412
413/* Special section indices. */
414
415#define SHN_UNDEF 0 /* Undefined section */
416#define SHN_LORESERVE 0xff00 /* Start of reserved indices */
417#define SHN_LOPROC 0xff00 /* Start of processor-specific */
418#define SHN_BEFORE 0xff00 /* Order section before all others
419 (Solaris). */
420#define SHN_AFTER 0xff01 /* Order section after all others
421 (Solaris). */
422#define SHN_HIPROC 0xff1f /* End of processor-specific */
423#define SHN_LOOS 0xff20 /* Start of OS-specific */
424#define SHN_HIOS 0xff3f /* End of OS-specific */
425#define SHN_ABS 0xfff1 /* Associated symbol is absolute */
426#define SHN_COMMON 0xfff2 /* Associated symbol is common */
427#define SHN_XINDEX 0xffff /* Index is in extra table. */
428#define SHN_HIRESERVE 0xffff /* End of reserved indices */
429
430/* Legal values for sh_type (section type). */
431
432#define SHT_NULL 0 /* Section header table entry unused */
433#define SHT_PROGBITS 1 /* Program data */
434#define SHT_SYMTAB 2 /* Symbol table */
435#define SHT_STRTAB 3 /* String table */
436#define SHT_RELA 4 /* Relocation entries with addends */
437#define SHT_HASH 5 /* Symbol hash table */
438#define SHT_DYNAMIC 6 /* Dynamic linking information */
439#define SHT_NOTE 7 /* Notes */
440#define SHT_NOBITS 8 /* Program space with no data (bss) */
441#define SHT_REL 9 /* Relocation entries, no addends */
442#define SHT_SHLIB 10 /* Reserved */
443#define SHT_DYNSYM 11 /* Dynamic linker symbol table */
444#define SHT_INIT_ARRAY 14 /* Array of constructors */
445#define SHT_FINI_ARRAY 15 /* Array of destructors */
446#define SHT_PREINIT_ARRAY 16 /* Array of pre-constructors */
447#define SHT_GROUP 17 /* Section group */
448#define SHT_SYMTAB_SHNDX 18 /* Extended section indeces */
449#define SHT_NUM 19 /* Number of defined types. */
450#define SHT_LOOS 0x60000000 /* Start OS-specific. */
451#define SHT_GNU_ATTRIBUTES 0x6ffffff5 /* Object attributes. */
452#define SHT_GNU_HASH 0x6ffffff6 /* GNU-style hash table. */
453#define SHT_GNU_LIBLIST 0x6ffffff7 /* Prelink library list */
454#define SHT_CHECKSUM 0x6ffffff8 /* Checksum for DSO content. */
455#define SHT_LOSUNW 0x6ffffffa /* Sun-specific low bound. */
456#define SHT_SUNW_move 0x6ffffffa
457#define SHT_SUNW_COMDAT 0x6ffffffb
458#define SHT_SUNW_syminfo 0x6ffffffc
459#define SHT_GNU_verdef 0x6ffffffd /* Version definition section. */
460#define SHT_GNU_verneed 0x6ffffffe /* Version needs section. */
461#define SHT_GNU_versym 0x6fffffff /* Version symbol table. */
462#define SHT_HISUNW 0x6fffffff /* Sun-specific high bound. */
463#define SHT_HIOS 0x6fffffff /* End OS-specific type */
464#define SHT_LOPROC 0x70000000 /* Start of processor-specific */
465#define SHT_HIPROC 0x7fffffff /* End of processor-specific */
466#define SHT_LOUSER 0x80000000 /* Start of application-specific */
467#define SHT_HIUSER 0x8fffffff /* End of application-specific */
468
469/* Legal values for sh_flags (section flags). */
470
471#define SHF_WRITE (1 << 0) /* Writable */
472#define SHF_ALLOC (1 << 1) /* Occupies memory during execution */
473#define SHF_EXECINSTR (1 << 2) /* Executable */
474#define SHF_MERGE (1 << 4) /* Might be merged */
475#define SHF_STRINGS (1 << 5) /* Contains nul-terminated strings */
476#define SHF_INFO_LINK (1 << 6) /* `sh_info' contains SHT index */
477#define SHF_LINK_ORDER (1 << 7) /* Preserve order after combining */
478#define SHF_OS_NONCONFORMING (1 << 8) /* Non-standard OS specific handling
479 required */
480#define SHF_GROUP (1 << 9) /* Section is member of a group. */
481#define SHF_TLS (1 << 10) /* Section hold thread-local data. */
482#define SHF_COMPRESSED (1 << 11) /* Section with compressed data. */
483#define SHF_MASKOS 0x0ff00000 /* OS-specific. */
484#define SHF_MASKPROC 0xf0000000 /* Processor-specific */
485#define SHF_ORDERED (1 << 30) /* Special ordering requirement
486 (Solaris). */
487#define SHF_EXCLUDE (1U << 31) /* Section is excluded unless
488 referenced or allocated (Solaris).*/
489
490/* Section compression header. Used when SHF_COMPRESSED is set. */
491
492typedef struct
493{
494 Elf32_Word ch_type; /* Compression format. */
495 Elf32_Word ch_size; /* Uncompressed data size. */
496 Elf32_Word ch_addralign; /* Uncompressed data alignment. */
497} Elf32_Chdr;
498
499typedef struct
500{
501 Elf64_Word ch_type; /* Compression format. */
502 Elf64_Word ch_reserved;
503 Elf64_Xword ch_size; /* Uncompressed data size. */
504 Elf64_Xword ch_addralign; /* Uncompressed data alignment. */
505} Elf64_Chdr;
506
507/* Legal values for ch_type (compression algorithm). */
508#define ELFCOMPRESS_ZLIB 1 /* ZLIB/DEFLATE algorithm. */
509#define ELFCOMPRESS_LOOS 0x60000000 /* Start of OS-specific. */
510#define ELFCOMPRESS_HIOS 0x6fffffff /* End of OS-specific. */
511#define ELFCOMPRESS_LOPROC 0x70000000 /* Start of processor-specific. */
512#define ELFCOMPRESS_HIPROC 0x7fffffff /* End of processor-specific. */
513
514/* Section group handling. */
515#define GRP_COMDAT 0x1 /* Mark group as COMDAT. */
516
517/* Symbol table entry. */
518
519typedef struct
520{
521 Elf32_Word st_name; /* Symbol name (string tbl index) */
522 Elf32_Addr st_value; /* Symbol value */
523 Elf32_Word st_size; /* Symbol size */
524 unsigned char st_info; /* Symbol type and binding */
525 unsigned char st_other; /* Symbol visibility */
526 Elf32_Section st_shndx; /* Section index */
527} Elf32_Sym;
528
529typedef struct
530{
531 Elf64_Word st_name; /* Symbol name (string tbl index) */
532 unsigned char st_info; /* Symbol type and binding */
533 unsigned char st_other; /* Symbol visibility */
534 Elf64_Section st_shndx; /* Section index */
535 Elf64_Addr st_value; /* Symbol value */
536 Elf64_Xword st_size; /* Symbol size */
537} Elf64_Sym;
538
539/* The syminfo section if available contains additional information about
540 every dynamic symbol. */
541
542typedef struct
543{
544 Elf32_Half si_boundto; /* Direct bindings, symbol bound to */
545 Elf32_Half si_flags; /* Per symbol flags */
546} Elf32_Syminfo;
547
548typedef struct
549{
550 Elf64_Half si_boundto; /* Direct bindings, symbol bound to */
551 Elf64_Half si_flags; /* Per symbol flags */
552} Elf64_Syminfo;
553
554/* Possible values for si_boundto. */
555#define SYMINFO_BT_SELF 0xffff /* Symbol bound to self */
556#define SYMINFO_BT_PARENT 0xfffe /* Symbol bound to parent */
557#define SYMINFO_BT_LOWRESERVE 0xff00 /* Beginning of reserved entries */
558
559/* Possible bitmasks for si_flags. */
560#define SYMINFO_FLG_DIRECT 0x0001 /* Direct bound symbol */
561#define SYMINFO_FLG_PASSTHRU 0x0002 /* Pass-thru symbol for translator */
562#define SYMINFO_FLG_COPY 0x0004 /* Symbol is a copy-reloc */
563#define SYMINFO_FLG_LAZYLOAD 0x0008 /* Symbol bound to object to be lazy
564 loaded */
565/* Syminfo version values. */
566#define SYMINFO_NONE 0
567#define SYMINFO_CURRENT 1
568#define SYMINFO_NUM 2
569
570
571/* How to extract and insert information held in the st_info field. */
572
573#define ELF32_ST_BIND(val) (((unsigned char) (val)) >> 4)
574#define ELF32_ST_TYPE(val) ((val) & 0xf)
575#define ELF32_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf))
576
577/* Both Elf32_Sym and Elf64_Sym use the same one-byte st_info field. */
578#define ELF64_ST_BIND(val) ELF32_ST_BIND (val)
579#define ELF64_ST_TYPE(val) ELF32_ST_TYPE (val)
580#define ELF64_ST_INFO(bind, type) ELF32_ST_INFO ((bind), (type))
581
582/* Legal values for ST_BIND subfield of st_info (symbol binding). */
583
584#define STB_LOCAL 0 /* Local symbol */
585#define STB_GLOBAL 1 /* Global symbol */
586#define STB_WEAK 2 /* Weak symbol */
587#define STB_NUM 3 /* Number of defined types. */
588#define STB_LOOS 10 /* Start of OS-specific */
589#define STB_GNU_UNIQUE 10 /* Unique symbol. */
590#define STB_HIOS 12 /* End of OS-specific */
591#define STB_LOPROC 13 /* Start of processor-specific */
592#define STB_HIPROC 15 /* End of processor-specific */
593
594/* Legal values for ST_TYPE subfield of st_info (symbol type). */
595
596#define STT_NOTYPE 0 /* Symbol type is unspecified */
597#define STT_OBJECT 1 /* Symbol is a data object */
598#define STT_FUNC 2 /* Symbol is a code object */
599#define STT_SECTION 3 /* Symbol associated with a section */
600#define STT_FILE 4 /* Symbol's name is file name */
601#define STT_COMMON 5 /* Symbol is a common data object */
602#define STT_TLS 6 /* Symbol is thread-local data object*/
603#define STT_NUM 7 /* Number of defined types. */
604#define STT_LOOS 10 /* Start of OS-specific */
605#define STT_GNU_IFUNC 10 /* Symbol is indirect code object */
606#define STT_HIOS 12 /* End of OS-specific */
607#define STT_LOPROC 13 /* Start of processor-specific */
608#define STT_HIPROC 15 /* End of processor-specific */
609
610
611/* Symbol table indices are found in the hash buckets and chain table
612 of a symbol hash table section. This special index value indicates
613 the end of a chain, meaning no further symbols are found in that bucket. */
614
615#define STN_UNDEF 0 /* End of a chain. */
616
617
618/* How to extract and insert information held in the st_other field. */
619
620#define ELF32_ST_VISIBILITY(o) ((o) & 0x03)
621
622/* For ELF64 the definitions are the same. */
623#define ELF64_ST_VISIBILITY(o) ELF32_ST_VISIBILITY (o)
624
625/* Symbol visibility specification encoded in the st_other field. */
626#define STV_DEFAULT 0 /* Default symbol visibility rules */
627#define STV_INTERNAL 1 /* Processor specific hidden class */
628#define STV_HIDDEN 2 /* Sym unavailable in other modules */
629#define STV_PROTECTED 3 /* Not preemptible, not exported */
630
631
632/* Relocation table entry without addend (in section of type SHT_REL). */
633
634typedef struct
635{
636 Elf32_Addr r_offset; /* Address */
637 Elf32_Word r_info; /* Relocation type and symbol index */
638} Elf32_Rel;
639
640/* I have seen two different definitions of the Elf64_Rel and
641 Elf64_Rela structures, so we'll leave them out until Novell (or
642 whoever) gets their act together. */
643/* The following, at least, is used on Sparc v9, MIPS, and Alpha. */
644
645typedef struct
646{
647 Elf64_Addr r_offset; /* Address */
648 Elf64_Xword r_info; /* Relocation type and symbol index */
649} Elf64_Rel;
650
651/* Relocation table entry with addend (in section of type SHT_RELA). */
652
653typedef struct
654{
655 Elf32_Addr r_offset; /* Address */
656 Elf32_Word r_info; /* Relocation type and symbol index */
657 Elf32_Sword r_addend; /* Addend */
658} Elf32_Rela;
659
660typedef struct
661{
662 Elf64_Addr r_offset; /* Address */
663 Elf64_Xword r_info; /* Relocation type and symbol index */
664 Elf64_Sxword r_addend; /* Addend */
665} Elf64_Rela;
666
667/* How to extract and insert information held in the r_info field. */
668
669#define ELF32_R_SYM(val) ((val) >> 8)
670#define ELF32_R_TYPE(val) ((val) & 0xff)
671#define ELF32_R_INFO(sym, type) (((sym) << 8) + ((type) & 0xff))
672
673#define ELF64_R_SYM(i) ((i) >> 32)
674#define ELF64_R_TYPE(i) ((i) & 0xffffffff)
675#define ELF64_R_INFO(sym,type) ((((Elf64_Xword) (sym)) << 32) + (type))
676
677/* Program segment header. */
678
679typedef struct
680{
681 Elf32_Word p_type; /* Segment type */
682 Elf32_Off p_offset; /* Segment file offset */
683 Elf32_Addr p_vaddr; /* Segment virtual address */
684 Elf32_Addr p_paddr; /* Segment physical address */
685 Elf32_Word p_filesz; /* Segment size in file */
686 Elf32_Word p_memsz; /* Segment size in memory */
687 Elf32_Word p_flags; /* Segment flags */
688 Elf32_Word p_align; /* Segment alignment */
689} Elf32_Phdr;
690
691typedef struct
692{
693 Elf64_Word p_type; /* Segment type */
694 Elf64_Word p_flags; /* Segment flags */
695 Elf64_Off p_offset; /* Segment file offset */
696 Elf64_Addr p_vaddr; /* Segment virtual address */
697 Elf64_Addr p_paddr; /* Segment physical address */
698 Elf64_Xword p_filesz; /* Segment size in file */
699 Elf64_Xword p_memsz; /* Segment size in memory */
700 Elf64_Xword p_align; /* Segment alignment */
701} Elf64_Phdr;
702
703/* Special value for e_phnum. This indicates that the real number of
704 program headers is too large to fit into e_phnum. Instead the real
705 value is in the field sh_info of section 0. */
706
707#define PN_XNUM 0xffff
708
709/* Legal values for p_type (segment type). */
710
711#define PT_NULL 0 /* Program header table entry unused */
712#define PT_LOAD 1 /* Loadable program segment */
713#define PT_DYNAMIC 2 /* Dynamic linking information */
714#define PT_INTERP 3 /* Program interpreter */
715#define PT_NOTE 4 /* Auxiliary information */
716#define PT_SHLIB 5 /* Reserved */
717#define PT_PHDR 6 /* Entry for header table itself */
718#define PT_TLS 7 /* Thread-local storage segment */
719#define PT_NUM 8 /* Number of defined types */
720#define PT_LOOS 0x60000000 /* Start of OS-specific */
721#define PT_GNU_EH_FRAME 0x6474e550 /* GCC .eh_frame_hdr segment */
722#define PT_GNU_STACK 0x6474e551 /* Indicates stack executability */
723#define PT_GNU_RELRO 0x6474e552 /* Read-only after relocation */
724#define PT_LOSUNW 0x6ffffffa
725#define PT_SUNWBSS 0x6ffffffa /* Sun Specific segment */
726#define PT_SUNWSTACK 0x6ffffffb /* Stack segment */
727#define PT_HISUNW 0x6fffffff
728#define PT_HIOS 0x6fffffff /* End of OS-specific */
729#define PT_LOPROC 0x70000000 /* Start of processor-specific */
730#define PT_HIPROC 0x7fffffff /* End of processor-specific */
731
732/* Legal values for p_flags (segment flags). */
733
734#define PF_X (1 << 0) /* Segment is executable */
735#define PF_W (1 << 1) /* Segment is writable */
736#define PF_R (1 << 2) /* Segment is readable */
737#define PF_MASKOS 0x0ff00000 /* OS-specific */
738#define PF_MASKPROC 0xf0000000 /* Processor-specific */
739
740/* Legal values for note segment descriptor types for core files. */
741
742#define NT_PRSTATUS 1 /* Contains copy of prstatus struct */
743#define NT_PRFPREG 2 /* Contains copy of fpregset
744 struct. */
745#define NT_FPREGSET 2 /* Contains copy of fpregset struct */
746#define NT_PRPSINFO 3 /* Contains copy of prpsinfo struct */
747#define NT_PRXREG 4 /* Contains copy of prxregset struct */
748#define NT_TASKSTRUCT 4 /* Contains copy of task structure */
749#define NT_PLATFORM 5 /* String from sysinfo(SI_PLATFORM) */
750#define NT_AUXV 6 /* Contains copy of auxv array */
751#define NT_GWINDOWS 7 /* Contains copy of gwindows struct */
752#define NT_ASRS 8 /* Contains copy of asrset struct */
753#define NT_PSTATUS 10 /* Contains copy of pstatus struct */
754#define NT_PSINFO 13 /* Contains copy of psinfo struct */
755#define NT_PRCRED 14 /* Contains copy of prcred struct */
756#define NT_UTSNAME 15 /* Contains copy of utsname struct */
757#define NT_LWPSTATUS 16 /* Contains copy of lwpstatus struct */
758#define NT_LWPSINFO 17 /* Contains copy of lwpinfo struct */
759#define NT_PRFPXREG 20 /* Contains copy of fprxregset struct */
760#define NT_SIGINFO 0x53494749 /* Contains copy of siginfo_t,
761 size might increase */
762#define NT_FILE 0x46494c45 /* Contains information about mapped
763 files */
764#define NT_PRXFPREG 0x46e62b7f /* Contains copy of user_fxsr_struct */
765#define NT_PPC_VMX 0x100 /* PowerPC Altivec/VMX registers */
766#define NT_PPC_SPE 0x101 /* PowerPC SPE/EVR registers */
767#define NT_PPC_VSX 0x102 /* PowerPC VSX registers */
768#define NT_PPC_TAR 0x103 /* Target Address Register */
769#define NT_PPC_PPR 0x104 /* Program Priority Register */
770#define NT_PPC_DSCR 0x105 /* Data Stream Control Register */
771#define NT_PPC_EBB 0x106 /* Event Based Branch Registers */
772#define NT_PPC_PMU 0x107 /* Performance Monitor Registers */
773#define NT_PPC_TM_CGPR 0x108 /* TM checkpointed GPR Registers */
774#define NT_PPC_TM_CFPR 0x109 /* TM checkpointed FPR Registers */
775#define NT_PPC_TM_CVMX 0x10a /* TM checkpointed VMX Registers */
776#define NT_PPC_TM_CVSX 0x10b /* TM checkpointed VSX Registers */
777#define NT_PPC_TM_SPR 0x10c /* TM Special Purpose Registers */
778#define NT_PPC_TM_CTAR 0x10d /* TM checkpointed Target Address
779 Register */
780#define NT_PPC_TM_CPPR 0x10e /* TM checkpointed Program Priority
781 Register */
782#define NT_PPC_TM_CDSCR 0x10f /* TM checkpointed Data Stream Control
783 Register */
784#define NT_PPC_PKEY 0x110 /* Memory Protection Keys
785 registers. */
786#define NT_386_TLS 0x200 /* i386 TLS slots (struct user_desc) */
787#define NT_386_IOPERM 0x201 /* x86 io permission bitmap (1=deny) */
788#define NT_X86_XSTATE 0x202 /* x86 extended state using xsave */
789#define NT_S390_HIGH_GPRS 0x300 /* s390 upper register halves */
790#define NT_S390_TIMER 0x301 /* s390 timer register */
791#define NT_S390_TODCMP 0x302 /* s390 TOD clock comparator register */
792#define NT_S390_TODPREG 0x303 /* s390 TOD programmable register */
793#define NT_S390_CTRS 0x304 /* s390 control registers */
794#define NT_S390_PREFIX 0x305 /* s390 prefix register */
795#define NT_S390_LAST_BREAK 0x306 /* s390 breaking event address */
796#define NT_S390_SYSTEM_CALL 0x307 /* s390 system call restart data */
797#define NT_S390_TDB 0x308 /* s390 transaction diagnostic block */
798#define NT_S390_VXRS_LOW 0x309 /* s390 vector registers 0-15
799 upper half. */
800#define NT_S390_VXRS_HIGH 0x30a /* s390 vector registers 16-31. */
801#define NT_S390_GS_CB 0x30b /* s390 guarded storage registers. */
802#define NT_S390_GS_BC 0x30c /* s390 guarded storage
803 broadcast control block. */
804#define NT_S390_RI_CB 0x30d /* s390 runtime instrumentation. */
805#define NT_ARM_VFP 0x400 /* ARM VFP/NEON registers */
806#define NT_ARM_TLS 0x401 /* ARM TLS register */
807#define NT_ARM_HW_BREAK 0x402 /* ARM hardware breakpoint registers */
808#define NT_ARM_HW_WATCH 0x403 /* ARM hardware watchpoint registers */
809#define NT_ARM_SYSTEM_CALL 0x404 /* ARM system call number */
810#define NT_ARM_SVE 0x405 /* ARM Scalable Vector Extension
811 registers */
812#define NT_VMCOREDD 0x700 /* Vmcore Device Dump Note. */
813#define NT_MIPS_DSP 0x800 /* MIPS DSP ASE registers. */
814#define NT_MIPS_FP_MODE 0x801 /* MIPS floating-point mode. */
815
816/* Legal values for the note segment descriptor types for object files. */
817
818#define NT_VERSION 1 /* Contains a version string. */
819
820
821/* Dynamic section entry. */
822
823typedef struct
824{
825 Elf32_Sword d_tag; /* Dynamic entry type */
826 union
827 {
828 Elf32_Word d_val; /* Integer value */
829 Elf32_Addr d_ptr; /* Address value */
830 } d_un;
831} Elf32_Dyn;
832
833typedef struct
834{
835 Elf64_Sxword d_tag; /* Dynamic entry type */
836 union
837 {
838 Elf64_Xword d_val; /* Integer value */
839 Elf64_Addr d_ptr; /* Address value */
840 } d_un;
841} Elf64_Dyn;
842
843/* Legal values for d_tag (dynamic entry type). */
844
845#define DT_NULL 0 /* Marks end of dynamic section */
846#define DT_NEEDED 1 /* Name of needed library */
847#define DT_PLTRELSZ 2 /* Size in bytes of PLT relocs */
848#define DT_PLTGOT 3 /* Processor defined value */
849#define DT_HASH 4 /* Address of symbol hash table */
850#define DT_STRTAB 5 /* Address of string table */
851#define DT_SYMTAB 6 /* Address of symbol table */
852#define DT_RELA 7 /* Address of Rela relocs */
853#define DT_RELASZ 8 /* Total size of Rela relocs */
854#define DT_RELAENT 9 /* Size of one Rela reloc */
855#define DT_STRSZ 10 /* Size of string table */
856#define DT_SYMENT 11 /* Size of one symbol table entry */
857#define DT_INIT 12 /* Address of init function */
858#define DT_FINI 13 /* Address of termination function */
859#define DT_SONAME 14 /* Name of shared object */
860#define DT_RPATH 15 /* Library search path (deprecated) */
861#define DT_SYMBOLIC 16 /* Start symbol search here */
862#define DT_REL 17 /* Address of Rel relocs */
863#define DT_RELSZ 18 /* Total size of Rel relocs */
864#define DT_RELENT 19 /* Size of one Rel reloc */
865#define DT_PLTREL 20 /* Type of reloc in PLT */
866#define DT_DEBUG 21 /* For debugging; unspecified */
867#define DT_TEXTREL 22 /* Reloc might modify .text */
868#define DT_JMPREL 23 /* Address of PLT relocs */
869#define DT_BIND_NOW 24 /* Process relocations of object */
870#define DT_INIT_ARRAY 25 /* Array with addresses of init fct */
871#define DT_FINI_ARRAY 26 /* Array with addresses of fini fct */
872#define DT_INIT_ARRAYSZ 27 /* Size in bytes of DT_INIT_ARRAY */
873#define DT_FINI_ARRAYSZ 28 /* Size in bytes of DT_FINI_ARRAY */
874#define DT_RUNPATH 29 /* Library search path */
875#define DT_FLAGS 30 /* Flags for the object being loaded */
876#define DT_ENCODING 32 /* Start of encoded range */
877#define DT_PREINIT_ARRAY 32 /* Array with addresses of preinit fct*/
878#define DT_PREINIT_ARRAYSZ 33 /* size in bytes of DT_PREINIT_ARRAY */
879#define DT_SYMTAB_SHNDX 34 /* Address of SYMTAB_SHNDX section */
880#define DT_NUM 35 /* Number used */
881#define DT_LOOS 0x6000000d /* Start of OS-specific */
882#define DT_HIOS 0x6ffff000 /* End of OS-specific */
883#define DT_LOPROC 0x70000000 /* Start of processor-specific */
884#define DT_HIPROC 0x7fffffff /* End of processor-specific */
885#define DT_PROCNUM DT_MIPS_NUM /* Most used by any processor */
886
887/* DT_* entries which fall between DT_VALRNGHI & DT_VALRNGLO use the
888 Dyn.d_un.d_val field of the Elf*_Dyn structure. This follows Sun's
889 approach. */
890#define DT_VALRNGLO 0x6ffffd00
891#define DT_GNU_PRELINKED 0x6ffffdf5 /* Prelinking timestamp */
892#define DT_GNU_CONFLICTSZ 0x6ffffdf6 /* Size of conflict section */
893#define DT_GNU_LIBLISTSZ 0x6ffffdf7 /* Size of library list */
894#define DT_CHECKSUM 0x6ffffdf8
895#define DT_PLTPADSZ 0x6ffffdf9
896#define DT_MOVEENT 0x6ffffdfa
897#define DT_MOVESZ 0x6ffffdfb
898#define DT_FEATURE_1 0x6ffffdfc /* Feature selection (DTF_*). */
899#define DT_POSFLAG_1 0x6ffffdfd /* Flags for DT_* entries, effecting
900 the following DT_* entry. */
901#define DT_SYMINSZ 0x6ffffdfe /* Size of syminfo table (in bytes) */
902#define DT_SYMINENT 0x6ffffdff /* Entry size of syminfo */
903#define DT_VALRNGHI 0x6ffffdff
904#define DT_VALTAGIDX(tag) (DT_VALRNGHI - (tag)) /* Reverse order! */
905#define DT_VALNUM 12
906
907/* DT_* entries which fall between DT_ADDRRNGHI & DT_ADDRRNGLO use the
908 Dyn.d_un.d_ptr field of the Elf*_Dyn structure.
909
910 If any adjustment is made to the ELF object after it has been
911 built these entries will need to be adjusted. */
912#define DT_ADDRRNGLO 0x6ffffe00
913#define DT_GNU_HASH 0x6ffffef5 /* GNU-style hash table. */
914#define DT_TLSDESC_PLT 0x6ffffef6
915#define DT_TLSDESC_GOT 0x6ffffef7
916#define DT_GNU_CONFLICT 0x6ffffef8 /* Start of conflict section */
917#define DT_GNU_LIBLIST 0x6ffffef9 /* Library list */
918#define DT_CONFIG 0x6ffffefa /* Configuration information. */
919#define DT_DEPAUDIT 0x6ffffefb /* Dependency auditing. */
920#define DT_AUDIT 0x6ffffefc /* Object auditing. */
921#define DT_PLTPAD 0x6ffffefd /* PLT padding. */
922#define DT_MOVETAB 0x6ffffefe /* Move table. */
923#define DT_SYMINFO 0x6ffffeff /* Syminfo table. */
924#define DT_ADDRRNGHI 0x6ffffeff
925#define DT_ADDRTAGIDX(tag) (DT_ADDRRNGHI - (tag)) /* Reverse order! */
926#define DT_ADDRNUM 11
927
928/* The versioning entry types. The next are defined as part of the
929 GNU extension. */
930#define DT_VERSYM 0x6ffffff0
931
932#define DT_RELACOUNT 0x6ffffff9
933#define DT_RELCOUNT 0x6ffffffa
934
935/* These were chosen by Sun. */
936#define DT_FLAGS_1 0x6ffffffb /* State flags, see DF_1_* below. */
937#define DT_VERDEF 0x6ffffffc /* Address of version definition
938 table */
939#define DT_VERDEFNUM 0x6ffffffd /* Number of version definitions */
940#define DT_VERNEED 0x6ffffffe /* Address of table with needed
941 versions */
942#define DT_VERNEEDNUM 0x6fffffff /* Number of needed versions */
943#define DT_VERSIONTAGIDX(tag) (DT_VERNEEDNUM - (tag)) /* Reverse order! */
944#define DT_VERSIONTAGNUM 16
945
946/* Sun added these machine-independent extensions in the "processor-specific"
947 range. Be compatible. */
948#define DT_AUXILIARY 0x7ffffffd /* Shared object to load before self */
949#define DT_FILTER 0x7fffffff /* Shared object to get values from */
950#define DT_EXTRATAGIDX(tag) ((Elf32_Word)-((Elf32_Sword) (tag) <<1>>1)-1)
951#define DT_EXTRANUM 3
952
953/* Values of `d_un.d_val' in the DT_FLAGS entry. */
954#define DF_ORIGIN 0x00000001 /* Object may use DF_ORIGIN */
955#define DF_SYMBOLIC 0x00000002 /* Symbol resolutions starts here */
956#define DF_TEXTREL 0x00000004 /* Object contains text relocations */
957#define DF_BIND_NOW 0x00000008 /* No lazy binding for this object */
958#define DF_STATIC_TLS 0x00000010 /* Module uses the static TLS model */
959
960/* State flags selectable in the `d_un.d_val' element of the DT_FLAGS_1
961 entry in the dynamic section. */
962#define DF_1_NOW 0x00000001 /* Set RTLD_NOW for this object. */
963#define DF_1_GLOBAL 0x00000002 /* Set RTLD_GLOBAL for this object. */
964#define DF_1_GROUP 0x00000004 /* Set RTLD_GROUP for this object. */
965#define DF_1_NODELETE 0x00000008 /* Set RTLD_NODELETE for this object.*/
966#define DF_1_LOADFLTR 0x00000010 /* Trigger filtee loading at runtime.*/
967#define DF_1_INITFIRST 0x00000020 /* Set RTLD_INITFIRST for this object*/
968#define DF_1_NOOPEN 0x00000040 /* Set RTLD_NOOPEN for this object. */
969#define DF_1_ORIGIN 0x00000080 /* $ORIGIN must be handled. */
970#define DF_1_DIRECT 0x00000100 /* Direct binding enabled. */
971#define DF_1_TRANS 0x00000200
972#define DF_1_INTERPOSE 0x00000400 /* Object is used to interpose. */
973#define DF_1_NODEFLIB 0x00000800 /* Ignore default lib search path. */
974#define DF_1_NODUMP 0x00001000 /* Object can't be dldump'ed. */
975#define DF_1_CONFALT 0x00002000 /* Configuration alternative created.*/
976#define DF_1_ENDFILTEE 0x00004000 /* Filtee terminates filters search. */
977#define DF_1_DISPRELDNE 0x00008000 /* Disp reloc applied at build time. */
978#define DF_1_DISPRELPND 0x00010000 /* Disp reloc applied at run-time. */
979#define DF_1_NODIRECT 0x00020000 /* Object has no-direct binding. */
980#define DF_1_IGNMULDEF 0x00040000
981#define DF_1_NOKSYMS 0x00080000
982#define DF_1_NOHDR 0x00100000
983#define DF_1_EDITED 0x00200000 /* Object is modified after built. */
984#define DF_1_NORELOC 0x00400000
985#define DF_1_SYMINTPOSE 0x00800000 /* Object has individual interposers. */
986#define DF_1_GLOBAUDIT 0x01000000 /* Global auditing required. */
987#define DF_1_SINGLETON 0x02000000 /* Singleton symbols are used. */
988#define DF_1_STUB 0x04000000
989#define DF_1_PIE 0x08000000
990
991/* Flags for the feature selection in DT_FEATURE_1. */
992#define DTF_1_PARINIT 0x00000001
993#define DTF_1_CONFEXP 0x00000002
994
995/* Flags in the DT_POSFLAG_1 entry effecting only the next DT_* entry. */
996#define DF_P1_LAZYLOAD 0x00000001 /* Lazyload following object. */
997#define DF_P1_GROUPPERM 0x00000002 /* Symbols from next object are not
998 generally available. */
999
1000/* Version definition sections. */
1001
1002typedef struct
1003{
1004 Elf32_Half vd_version; /* Version revision */
1005 Elf32_Half vd_flags; /* Version information */
1006 Elf32_Half vd_ndx; /* Version Index */
1007 Elf32_Half vd_cnt; /* Number of associated aux entries */
1008 Elf32_Word vd_hash; /* Version name hash value */
1009 Elf32_Word vd_aux; /* Offset in bytes to verdaux array */
1010 Elf32_Word vd_next; /* Offset in bytes to next verdef
1011 entry */
1012} Elf32_Verdef;
1013
1014typedef struct
1015{
1016 Elf64_Half vd_version; /* Version revision */
1017 Elf64_Half vd_flags; /* Version information */
1018 Elf64_Half vd_ndx; /* Version Index */
1019 Elf64_Half vd_cnt; /* Number of associated aux entries */
1020 Elf64_Word vd_hash; /* Version name hash value */
1021 Elf64_Word vd_aux; /* Offset in bytes to verdaux array */
1022 Elf64_Word vd_next; /* Offset in bytes to next verdef
1023 entry */
1024} Elf64_Verdef;
1025
1026
1027/* Legal values for vd_version (version revision). */
1028#define VER_DEF_NONE 0 /* No version */
1029#define VER_DEF_CURRENT 1 /* Current version */
1030#define VER_DEF_NUM 2 /* Given version number */
1031
1032/* Legal values for vd_flags (version information flags). */
1033#define VER_FLG_BASE 0x1 /* Version definition of file itself */
1034#define VER_FLG_WEAK 0x2 /* Weak version identifier */
1035
1036/* Versym symbol index values. */
1037#define VER_NDX_LOCAL 0 /* Symbol is local. */
1038#define VER_NDX_GLOBAL 1 /* Symbol is global. */
1039#define VER_NDX_LORESERVE 0xff00 /* Beginning of reserved entries. */
1040#define VER_NDX_ELIMINATE 0xff01 /* Symbol is to be eliminated. */
1041
1042/* Auxialiary version information. */
1043
1044typedef struct
1045{
1046 Elf32_Word vda_name; /* Version or dependency names */
1047 Elf32_Word vda_next; /* Offset in bytes to next verdaux
1048 entry */
1049} Elf32_Verdaux;
1050
1051typedef struct
1052{
1053 Elf64_Word vda_name; /* Version or dependency names */
1054 Elf64_Word vda_next; /* Offset in bytes to next verdaux
1055 entry */
1056} Elf64_Verdaux;
1057
1058
1059/* Version dependency section. */
1060
1061typedef struct
1062{
1063 Elf32_Half vn_version; /* Version of structure */
1064 Elf32_Half vn_cnt; /* Number of associated aux entries */
1065 Elf32_Word vn_file; /* Offset of filename for this
1066 dependency */
1067 Elf32_Word vn_aux; /* Offset in bytes to vernaux array */
1068 Elf32_Word vn_next; /* Offset in bytes to next verneed
1069 entry */
1070} Elf32_Verneed;
1071
1072typedef struct
1073{
1074 Elf64_Half vn_version; /* Version of structure */
1075 Elf64_Half vn_cnt; /* Number of associated aux entries */
1076 Elf64_Word vn_file; /* Offset of filename for this
1077 dependency */
1078 Elf64_Word vn_aux; /* Offset in bytes to vernaux array */
1079 Elf64_Word vn_next; /* Offset in bytes to next verneed
1080 entry */
1081} Elf64_Verneed;
1082
1083
1084/* Legal values for vn_version (version revision). */
1085#define VER_NEED_NONE 0 /* No version */
1086#define VER_NEED_CURRENT 1 /* Current version */
1087#define VER_NEED_NUM 2 /* Given version number */
1088
1089/* Auxiliary needed version information. */
1090
1091typedef struct
1092{
1093 Elf32_Word vna_hash; /* Hash value of dependency name */
1094 Elf32_Half vna_flags; /* Dependency specific information */
1095 Elf32_Half vna_other; /* Unused */
1096 Elf32_Word vna_name; /* Dependency name string offset */
1097 Elf32_Word vna_next; /* Offset in bytes to next vernaux
1098 entry */
1099} Elf32_Vernaux;
1100
1101typedef struct
1102{
1103 Elf64_Word vna_hash; /* Hash value of dependency name */
1104 Elf64_Half vna_flags; /* Dependency specific information */
1105 Elf64_Half vna_other; /* Unused */
1106 Elf64_Word vna_name; /* Dependency name string offset */
1107 Elf64_Word vna_next; /* Offset in bytes to next vernaux
1108 entry */
1109} Elf64_Vernaux;
1110
1111
1112/* Legal values for vna_flags. */
1113#define VER_FLG_WEAK 0x2 /* Weak version identifier */
1114
1115
1116/* Auxiliary vector. */
1117
1118/* This vector is normally only used by the program interpreter. The
1119 usual definition in an ABI supplement uses the name auxv_t. The
1120 vector is not usually defined in a standard <elf.h> file, but it
1121 can't hurt. We rename it to avoid conflicts. The sizes of these
1122 types are an arrangement between the exec server and the program
1123 interpreter, so we don't fully specify them here. */
1124
1125typedef struct
1126{
1127 uint32_t a_type; /* Entry type */
1128 union
1129 {
1130 uint32_t a_val; /* Integer value */
1131 /* We use to have pointer elements added here. We cannot do that,
1132 though, since it does not work when using 32-bit definitions
1133 on 64-bit platforms and vice versa. */
1134 } a_un;
1135} Elf32_auxv_t;
1136
1137typedef struct
1138{
1139 uint64_t a_type; /* Entry type */
1140 union
1141 {
1142 uint64_t a_val; /* Integer value */
1143 /* We use to have pointer elements added here. We cannot do that,
1144 though, since it does not work when using 32-bit definitions
1145 on 64-bit platforms and vice versa. */
1146 } a_un;
1147} Elf64_auxv_t;
1148
1149/* Legal values for a_type (entry type). */
1150
1151#define AT_NULL 0 /* End of vector */
1152#define AT_IGNORE 1 /* Entry should be ignored */
1153#define AT_EXECFD 2 /* File descriptor of program */
1154#define AT_PHDR 3 /* Program headers for program */
1155#define AT_PHENT 4 /* Size of program header entry */
1156#define AT_PHNUM 5 /* Number of program headers */
1157#define AT_PAGESZ 6 /* System page size */
1158#define AT_BASE 7 /* Base address of interpreter */
1159#define AT_FLAGS 8 /* Flags */
1160#define AT_ENTRY 9 /* Entry point of program */
1161#define AT_NOTELF 10 /* Program is not ELF */
1162#define AT_UID 11 /* Real uid */
1163#define AT_EUID 12 /* Effective uid */
1164#define AT_GID 13 /* Real gid */
1165#define AT_EGID 14 /* Effective gid */
1166#define AT_CLKTCK 17 /* Frequency of times() */
1167
1168/* Some more special a_type values describing the hardware. */
1169#define AT_PLATFORM 15 /* String identifying platform. */
1170#define AT_HWCAP 16 /* Machine-dependent hints about
1171 processor capabilities. */
1172
1173/* This entry gives some information about the FPU initialization
1174 performed by the kernel. */
1175#define AT_FPUCW 18 /* Used FPU control word. */
1176
1177/* Cache block sizes. */
1178#define AT_DCACHEBSIZE 19 /* Data cache block size. */
1179#define AT_ICACHEBSIZE 20 /* Instruction cache block size. */
1180#define AT_UCACHEBSIZE 21 /* Unified cache block size. */
1181
1182/* A special ignored value for PPC, used by the kernel to control the
1183 interpretation of the AUXV. Must be > 16. */
1184#define AT_IGNOREPPC 22 /* Entry should be ignored. */
1185
1186#define AT_SECURE 23 /* Boolean, was exec setuid-like? */
1187
1188#define AT_BASE_PLATFORM 24 /* String identifying real platforms.*/
1189
1190#define AT_RANDOM 25 /* Address of 16 random bytes. */
1191
1192#define AT_HWCAP2 26 /* More machine-dependent hints about
1193 processor capabilities. */
1194
1195#define AT_EXECFN 31 /* Filename of executable. */
1196
1197/* Pointer to the global system page used for system calls and other
1198 nice things. */
1199#define AT_SYSINFO 32
1200#define AT_SYSINFO_EHDR 33
1201
1202/* Shapes of the caches. Bits 0-3 contains associativity; bits 4-7 contains
1203 log2 of line size; mask those to get cache size. */
1204#define AT_L1I_CACHESHAPE 34
1205#define AT_L1D_CACHESHAPE 35
1206#define AT_L2_CACHESHAPE 36
1207#define AT_L3_CACHESHAPE 37
1208
1209/* Shapes of the caches, with more room to describe them.
1210 *GEOMETRY are comprised of cache line size in bytes in the bottom 16 bits
1211 and the cache associativity in the next 16 bits. */
1212#define AT_L1I_CACHESIZE 40
1213#define AT_L1I_CACHEGEOMETRY 41
1214#define AT_L1D_CACHESIZE 42
1215#define AT_L1D_CACHEGEOMETRY 43
1216#define AT_L2_CACHESIZE 44
1217#define AT_L2_CACHEGEOMETRY 45
1218#define AT_L3_CACHESIZE 46
1219#define AT_L3_CACHEGEOMETRY 47
1220
1221#define AT_MINSIGSTKSZ 51 /* Stack needed for signal delivery
1222 (AArch64). */
1223
1224/* Note section contents. Each entry in the note section begins with
1225 a header of a fixed form. */
1226
1227typedef struct
1228{
1229 Elf32_Word n_namesz; /* Length of the note's name. */
1230 Elf32_Word n_descsz; /* Length of the note's descriptor. */
1231 Elf32_Word n_type; /* Type of the note. */
1232} Elf32_Nhdr;
1233
1234typedef struct
1235{
1236 Elf64_Word n_namesz; /* Length of the note's name. */
1237 Elf64_Word n_descsz; /* Length of the note's descriptor. */
1238 Elf64_Word n_type; /* Type of the note. */
1239} Elf64_Nhdr;
1240
1241/* Known names of notes. */
1242
1243/* Solaris entries in the note section have this name. */
1244#define ELF_NOTE_SOLARIS "SUNW Solaris"
1245
1246/* Note entries for GNU systems have this name. */
1247#define ELF_NOTE_GNU "GNU"
1248
1249
1250/* Defined types of notes for Solaris. */
1251
1252/* Value of descriptor (one word) is desired pagesize for the binary. */
1253#define ELF_NOTE_PAGESIZE_HINT 1
1254
1255
1256/* Defined note types for GNU systems. */
1257
1258/* ABI information. The descriptor consists of words:
1259 word 0: OS descriptor
1260 word 1: major version of the ABI
1261 word 2: minor version of the ABI
1262 word 3: subminor version of the ABI
1263*/
1264#define NT_GNU_ABI_TAG 1
1265#define ELF_NOTE_ABI NT_GNU_ABI_TAG /* Old name. */
1266
1267/* Known OSes. These values can appear in word 0 of an
1268 NT_GNU_ABI_TAG note section entry. */
1269#define ELF_NOTE_OS_LINUX 0
1270#define ELF_NOTE_OS_GNU 1
1271#define ELF_NOTE_OS_SOLARIS2 2
1272#define ELF_NOTE_OS_FREEBSD 3
1273
1274/* Synthetic hwcap information. The descriptor begins with two words:
1275 word 0: number of entries
1276 word 1: bitmask of enabled entries
1277 Then follow variable-length entries, one byte followed by a
1278 '\0'-terminated hwcap name string. The byte gives the bit
1279 number to test if enabled, (1U << bit) & bitmask. */
1280#define NT_GNU_HWCAP 2
1281
1282/* Build ID bits as generated by ld --build-id.
1283 The descriptor consists of any nonzero number of bytes. */
1284#define NT_GNU_BUILD_ID 3
1285
1286/* Version note generated by GNU gold containing a version string. */
1287#define NT_GNU_GOLD_VERSION 4
1288
1289/* Program property. */
1290#define NT_GNU_PROPERTY_TYPE_0 5
1291
1292/* Note section name of program property. */
1293#define NOTE_GNU_PROPERTY_SECTION_NAME ".note.gnu.property"
1294
1295/* Values used in GNU .note.gnu.property notes (NT_GNU_PROPERTY_TYPE_0). */
1296
1297/* Stack size. */
1298#define GNU_PROPERTY_STACK_SIZE 1
1299/* No copy relocation on protected data symbol. */
1300#define GNU_PROPERTY_NO_COPY_ON_PROTECTED 2
1301
1302/* Processor-specific semantics, lo */
1303#define GNU_PROPERTY_LOPROC 0xc0000000
1304/* Processor-specific semantics, hi */
1305#define GNU_PROPERTY_HIPROC 0xdfffffff
1306/* Application-specific semantics, lo */
1307#define GNU_PROPERTY_LOUSER 0xe0000000
1308/* Application-specific semantics, hi */
1309#define GNU_PROPERTY_HIUSER 0xffffffff
1310
1311/* The x86 instruction sets indicated by the corresponding bits are
1312 used in program. Their support in the hardware is optional. */
1313#define GNU_PROPERTY_X86_ISA_1_USED 0xc0000000
1314/* The x86 instruction sets indicated by the corresponding bits are
1315 used in program and they must be supported by the hardware. */
1316#define GNU_PROPERTY_X86_ISA_1_NEEDED 0xc0000001
1317/* X86 processor-specific features used in program. */
1318#define GNU_PROPERTY_X86_FEATURE_1_AND 0xc0000002
1319
1320#define GNU_PROPERTY_X86_ISA_1_486 (1U << 0)
1321#define GNU_PROPERTY_X86_ISA_1_586 (1U << 1)
1322#define GNU_PROPERTY_X86_ISA_1_686 (1U << 2)
1323#define GNU_PROPERTY_X86_ISA_1_SSE (1U << 3)
1324#define GNU_PROPERTY_X86_ISA_1_SSE2 (1U << 4)
1325#define GNU_PROPERTY_X86_ISA_1_SSE3 (1U << 5)
1326#define GNU_PROPERTY_X86_ISA_1_SSSE3 (1U << 6)
1327#define GNU_PROPERTY_X86_ISA_1_SSE4_1 (1U << 7)
1328#define GNU_PROPERTY_X86_ISA_1_SSE4_2 (1U << 8)
1329#define GNU_PROPERTY_X86_ISA_1_AVX (1U << 9)
1330#define GNU_PROPERTY_X86_ISA_1_AVX2 (1U << 10)
1331#define GNU_PROPERTY_X86_ISA_1_AVX512F (1U << 11)
1332#define GNU_PROPERTY_X86_ISA_1_AVX512CD (1U << 12)
1333#define GNU_PROPERTY_X86_ISA_1_AVX512ER (1U << 13)
1334#define GNU_PROPERTY_X86_ISA_1_AVX512PF (1U << 14)
1335#define GNU_PROPERTY_X86_ISA_1_AVX512VL (1U << 15)
1336#define GNU_PROPERTY_X86_ISA_1_AVX512DQ (1U << 16)
1337#define GNU_PROPERTY_X86_ISA_1_AVX512BW (1U << 17)
1338
1339/* This indicates that all executable sections are compatible with
1340 IBT. */
1341#define GNU_PROPERTY_X86_FEATURE_1_IBT (1U << 0)
1342/* This indicates that all executable sections are compatible with
1343 SHSTK. */
1344#define GNU_PROPERTY_X86_FEATURE_1_SHSTK (1U << 1)
1345
1346/* Move records. */
1347typedef struct
1348{
1349 Elf32_Xword m_value; /* Symbol value. */
1350 Elf32_Word m_info; /* Size and index. */
1351 Elf32_Word m_poffset; /* Symbol offset. */
1352 Elf32_Half m_repeat; /* Repeat count. */
1353 Elf32_Half m_stride; /* Stride info. */
1354} Elf32_Move;
1355
1356typedef struct
1357{
1358 Elf64_Xword m_value; /* Symbol value. */
1359 Elf64_Xword m_info; /* Size and index. */
1360 Elf64_Xword m_poffset; /* Symbol offset. */
1361 Elf64_Half m_repeat; /* Repeat count. */
1362 Elf64_Half m_stride; /* Stride info. */
1363} Elf64_Move;
1364
1365/* Macro to construct move records. */
1366#define ELF32_M_SYM(info) ((info) >> 8)
1367#define ELF32_M_SIZE(info) ((unsigned char) (info))
1368#define ELF32_M_INFO(sym, size) (((sym) << 8) + (unsigned char) (size))
1369
1370#define ELF64_M_SYM(info) ELF32_M_SYM (info)
1371#define ELF64_M_SIZE(info) ELF32_M_SIZE (info)
1372#define ELF64_M_INFO(sym, size) ELF32_M_INFO (sym, size)
1373
1374
1375/* Motorola 68k specific definitions. */
1376
1377/* Values for Elf32_Ehdr.e_flags. */
1378#define EF_CPU32 0x00810000
1379
1380/* m68k relocs. */
1381
1382#define R_68K_NONE 0 /* No reloc */
1383#define R_68K_32 1 /* Direct 32 bit */
1384#define R_68K_16 2 /* Direct 16 bit */
1385#define R_68K_8 3 /* Direct 8 bit */
1386#define R_68K_PC32 4 /* PC relative 32 bit */
1387#define R_68K_PC16 5 /* PC relative 16 bit */
1388#define R_68K_PC8 6 /* PC relative 8 bit */
1389#define R_68K_GOT32 7 /* 32 bit PC relative GOT entry */
1390#define R_68K_GOT16 8 /* 16 bit PC relative GOT entry */
1391#define R_68K_GOT8 9 /* 8 bit PC relative GOT entry */
1392#define R_68K_GOT32O 10 /* 32 bit GOT offset */
1393#define R_68K_GOT16O 11 /* 16 bit GOT offset */
1394#define R_68K_GOT8O 12 /* 8 bit GOT offset */
1395#define R_68K_PLT32 13 /* 32 bit PC relative PLT address */
1396#define R_68K_PLT16 14 /* 16 bit PC relative PLT address */
1397#define R_68K_PLT8 15 /* 8 bit PC relative PLT address */
1398#define R_68K_PLT32O 16 /* 32 bit PLT offset */
1399#define R_68K_PLT16O 17 /* 16 bit PLT offset */
1400#define R_68K_PLT8O 18 /* 8 bit PLT offset */
1401#define R_68K_COPY 19 /* Copy symbol at runtime */
1402#define R_68K_GLOB_DAT 20 /* Create GOT entry */
1403#define R_68K_JMP_SLOT 21 /* Create PLT entry */
1404#define R_68K_RELATIVE 22 /* Adjust by program base */
1405#define R_68K_TLS_GD32 25 /* 32 bit GOT offset for GD */
1406#define R_68K_TLS_GD16 26 /* 16 bit GOT offset for GD */
1407#define R_68K_TLS_GD8 27 /* 8 bit GOT offset for GD */
1408#define R_68K_TLS_LDM32 28 /* 32 bit GOT offset for LDM */
1409#define R_68K_TLS_LDM16 29 /* 16 bit GOT offset for LDM */
1410#define R_68K_TLS_LDM8 30 /* 8 bit GOT offset for LDM */
1411#define R_68K_TLS_LDO32 31 /* 32 bit module-relative offset */
1412#define R_68K_TLS_LDO16 32 /* 16 bit module-relative offset */
1413#define R_68K_TLS_LDO8 33 /* 8 bit module-relative offset */
1414#define R_68K_TLS_IE32 34 /* 32 bit GOT offset for IE */
1415#define R_68K_TLS_IE16 35 /* 16 bit GOT offset for IE */
1416#define R_68K_TLS_IE8 36 /* 8 bit GOT offset for IE */
1417#define R_68K_TLS_LE32 37 /* 32 bit offset relative to
1418 static TLS block */
1419#define R_68K_TLS_LE16 38 /* 16 bit offset relative to
1420 static TLS block */
1421#define R_68K_TLS_LE8 39 /* 8 bit offset relative to
1422 static TLS block */
1423#define R_68K_TLS_DTPMOD32 40 /* 32 bit module number */
1424#define R_68K_TLS_DTPREL32 41 /* 32 bit module-relative offset */
1425#define R_68K_TLS_TPREL32 42 /* 32 bit TP-relative offset */
1426/* Keep this the last entry. */
1427#define R_68K_NUM 43
1428
1429/* Intel 80386 specific definitions. */
1430
1431/* i386 relocs. */
1432
1433#define R_386_NONE 0 /* No reloc */
1434#define R_386_32 1 /* Direct 32 bit */
1435#define R_386_PC32 2 /* PC relative 32 bit */
1436#define R_386_GOT32 3 /* 32 bit GOT entry */
1437#define R_386_PLT32 4 /* 32 bit PLT address */
1438#define R_386_COPY 5 /* Copy symbol at runtime */
1439#define R_386_GLOB_DAT 6 /* Create GOT entry */
1440#define R_386_JMP_SLOT 7 /* Create PLT entry */
1441#define R_386_RELATIVE 8 /* Adjust by program base */
1442#define R_386_GOTOFF 9 /* 32 bit offset to GOT */
1443#define R_386_GOTPC 10 /* 32 bit PC relative offset to GOT */
1444#define R_386_32PLT 11
1445#define R_386_TLS_TPOFF 14 /* Offset in static TLS block */
1446#define R_386_TLS_IE 15 /* Address of GOT entry for static TLS
1447 block offset */
1448#define R_386_TLS_GOTIE 16 /* GOT entry for static TLS block
1449 offset */
1450#define R_386_TLS_LE 17 /* Offset relative to static TLS
1451 block */
1452#define R_386_TLS_GD 18 /* Direct 32 bit for GNU version of
1453 general dynamic thread local data */
1454#define R_386_TLS_LDM 19 /* Direct 32 bit for GNU version of
1455 local dynamic thread local data
1456 in LE code */
1457#define R_386_16 20
1458#define R_386_PC16 21
1459#define R_386_8 22
1460#define R_386_PC8 23
1461#define R_386_TLS_GD_32 24 /* Direct 32 bit for general dynamic
1462 thread local data */
1463#define R_386_TLS_GD_PUSH 25 /* Tag for pushl in GD TLS code */
1464#define R_386_TLS_GD_CALL 26 /* Relocation for call to
1465 __tls_get_addr() */
1466#define R_386_TLS_GD_POP 27 /* Tag for popl in GD TLS code */
1467#define R_386_TLS_LDM_32 28 /* Direct 32 bit for local dynamic
1468 thread local data in LE code */
1469#define R_386_TLS_LDM_PUSH 29 /* Tag for pushl in LDM TLS code */
1470#define R_386_TLS_LDM_CALL 30 /* Relocation for call to
1471 __tls_get_addr() in LDM code */
1472#define R_386_TLS_LDM_POP 31 /* Tag for popl in LDM TLS code */
1473#define R_386_TLS_LDO_32 32 /* Offset relative to TLS block */
1474#define R_386_TLS_IE_32 33 /* GOT entry for negated static TLS
1475 block offset */
1476#define R_386_TLS_LE_32 34 /* Negated offset relative to static
1477 TLS block */
1478#define R_386_TLS_DTPMOD32 35 /* ID of module containing symbol */
1479#define R_386_TLS_DTPOFF32 36 /* Offset in TLS block */
1480#define R_386_TLS_TPOFF32 37 /* Negated offset in static TLS block */
1481#define R_386_SIZE32 38 /* 32-bit symbol size */
1482#define R_386_TLS_GOTDESC 39 /* GOT offset for TLS descriptor. */
1483#define R_386_TLS_DESC_CALL 40 /* Marker of call through TLS
1484 descriptor for
1485 relaxation. */
1486#define R_386_TLS_DESC 41 /* TLS descriptor containing
1487 pointer to code and to
1488 argument, returning the TLS
1489 offset for the symbol. */
1490#define R_386_IRELATIVE 42 /* Adjust indirectly by program base */
1491#define R_386_GOT32X 43 /* Load from 32 bit GOT entry,
1492 relaxable. */
1493/* Keep this the last entry. */
1494#define R_386_NUM 44
1495
1496/* SUN SPARC specific definitions. */
1497
1498/* Legal values for ST_TYPE subfield of st_info (symbol type). */
1499
1500#define STT_SPARC_REGISTER 13 /* Global register reserved to app. */
1501
1502/* Values for Elf64_Ehdr.e_flags. */
1503
1504#define EF_SPARCV9_MM 3
1505#define EF_SPARCV9_TSO 0
1506#define EF_SPARCV9_PSO 1
1507#define EF_SPARCV9_RMO 2
1508#define EF_SPARC_LEDATA 0x800000 /* little endian data */
1509#define EF_SPARC_EXT_MASK 0xFFFF00
1510#define EF_SPARC_32PLUS 0x000100 /* generic V8+ features */
1511#define EF_SPARC_SUN_US1 0x000200 /* Sun UltraSPARC1 extensions */
1512#define EF_SPARC_HAL_R1 0x000400 /* HAL R1 extensions */
1513#define EF_SPARC_SUN_US3 0x000800 /* Sun UltraSPARCIII extensions */
1514
1515/* SPARC relocs. */
1516
1517#define R_SPARC_NONE 0 /* No reloc */
1518#define R_SPARC_8 1 /* Direct 8 bit */
1519#define R_SPARC_16 2 /* Direct 16 bit */
1520#define R_SPARC_32 3 /* Direct 32 bit */
1521#define R_SPARC_DISP8 4 /* PC relative 8 bit */
1522#define R_SPARC_DISP16 5 /* PC relative 16 bit */
1523#define R_SPARC_DISP32 6 /* PC relative 32 bit */
1524#define R_SPARC_WDISP30 7 /* PC relative 30 bit shifted */
1525#define R_SPARC_WDISP22 8 /* PC relative 22 bit shifted */
1526#define R_SPARC_HI22 9 /* High 22 bit */
1527#define R_SPARC_22 10 /* Direct 22 bit */
1528#define R_SPARC_13 11 /* Direct 13 bit */
1529#define R_SPARC_LO10 12 /* Truncated 10 bit */
1530#define R_SPARC_GOT10 13 /* Truncated 10 bit GOT entry */
1531#define R_SPARC_GOT13 14 /* 13 bit GOT entry */
1532#define R_SPARC_GOT22 15 /* 22 bit GOT entry shifted */
1533#define R_SPARC_PC10 16 /* PC relative 10 bit truncated */
1534#define R_SPARC_PC22 17 /* PC relative 22 bit shifted */
1535#define R_SPARC_WPLT30 18 /* 30 bit PC relative PLT address */
1536#define R_SPARC_COPY 19 /* Copy symbol at runtime */
1537#define R_SPARC_GLOB_DAT 20 /* Create GOT entry */
1538#define R_SPARC_JMP_SLOT 21 /* Create PLT entry */
1539#define R_SPARC_RELATIVE 22 /* Adjust by program base */
1540#define R_SPARC_UA32 23 /* Direct 32 bit unaligned */
1541
1542/* Additional Sparc64 relocs. */
1543
1544#define R_SPARC_PLT32 24 /* Direct 32 bit ref to PLT entry */
1545#define R_SPARC_HIPLT22 25 /* High 22 bit PLT entry */
1546#define R_SPARC_LOPLT10 26 /* Truncated 10 bit PLT entry */
1547#define R_SPARC_PCPLT32 27 /* PC rel 32 bit ref to PLT entry */
1548#define R_SPARC_PCPLT22 28 /* PC rel high 22 bit PLT entry */
1549#define R_SPARC_PCPLT10 29 /* PC rel trunc 10 bit PLT entry */
1550#define R_SPARC_10 30 /* Direct 10 bit */
1551#define R_SPARC_11 31 /* Direct 11 bit */
1552#define R_SPARC_64 32 /* Direct 64 bit */
1553#define R_SPARC_OLO10 33 /* 10bit with secondary 13bit addend */
1554#define R_SPARC_HH22 34 /* Top 22 bits of direct 64 bit */
1555#define R_SPARC_HM10 35 /* High middle 10 bits of ... */
1556#define R_SPARC_LM22 36 /* Low middle 22 bits of ... */
1557#define R_SPARC_PC_HH22 37 /* Top 22 bits of pc rel 64 bit */
1558#define R_SPARC_PC_HM10 38 /* High middle 10 bit of ... */
1559#define R_SPARC_PC_LM22 39 /* Low miggle 22 bits of ... */
1560#define R_SPARC_WDISP16 40 /* PC relative 16 bit shifted */
1561#define R_SPARC_WDISP19 41 /* PC relative 19 bit shifted */
1562#define R_SPARC_GLOB_JMP 42 /* was part of v9 ABI but was removed */
1563#define R_SPARC_7 43 /* Direct 7 bit */
1564#define R_SPARC_5 44 /* Direct 5 bit */
1565#define R_SPARC_6 45 /* Direct 6 bit */
1566#define R_SPARC_DISP64 46 /* PC relative 64 bit */
1567#define R_SPARC_PLT64 47 /* Direct 64 bit ref to PLT entry */
1568#define R_SPARC_HIX22 48 /* High 22 bit complemented */
1569#define R_SPARC_LOX10 49 /* Truncated 11 bit complemented */
1570#define R_SPARC_H44 50 /* Direct high 12 of 44 bit */
1571#define R_SPARC_M44 51 /* Direct mid 22 of 44 bit */
1572#define R_SPARC_L44 52 /* Direct low 10 of 44 bit */
1573#define R_SPARC_REGISTER 53 /* Global register usage */
1574#define R_SPARC_UA64 54 /* Direct 64 bit unaligned */
1575#define R_SPARC_UA16 55 /* Direct 16 bit unaligned */
1576#define R_SPARC_TLS_GD_HI22 56
1577#define R_SPARC_TLS_GD_LO10 57
1578#define R_SPARC_TLS_GD_ADD 58
1579#define R_SPARC_TLS_GD_CALL 59
1580#define R_SPARC_TLS_LDM_HI22 60
1581#define R_SPARC_TLS_LDM_LO10 61
1582#define R_SPARC_TLS_LDM_ADD 62
1583#define R_SPARC_TLS_LDM_CALL 63
1584#define R_SPARC_TLS_LDO_HIX22 64
1585#define R_SPARC_TLS_LDO_LOX10 65
1586#define R_SPARC_TLS_LDO_ADD 66
1587#define R_SPARC_TLS_IE_HI22 67
1588#define R_SPARC_TLS_IE_LO10 68
1589#define R_SPARC_TLS_IE_LD 69
1590#define R_SPARC_TLS_IE_LDX 70
1591#define R_SPARC_TLS_IE_ADD 71
1592#define R_SPARC_TLS_LE_HIX22 72
1593#define R_SPARC_TLS_LE_LOX10 73
1594#define R_SPARC_TLS_DTPMOD32 74
1595#define R_SPARC_TLS_DTPMOD64 75
1596#define R_SPARC_TLS_DTPOFF32 76
1597#define R_SPARC_TLS_DTPOFF64 77
1598#define R_SPARC_TLS_TPOFF32 78
1599#define R_SPARC_TLS_TPOFF64 79
1600#define R_SPARC_GOTDATA_HIX22 80
1601#define R_SPARC_GOTDATA_LOX10 81
1602#define R_SPARC_GOTDATA_OP_HIX22 82
1603#define R_SPARC_GOTDATA_OP_LOX10 83
1604#define R_SPARC_GOTDATA_OP 84
1605#define R_SPARC_H34 85
1606#define R_SPARC_SIZE32 86
1607#define R_SPARC_SIZE64 87
1608#define R_SPARC_WDISP10 88
1609#define R_SPARC_JMP_IREL 248
1610#define R_SPARC_IRELATIVE 249
1611#define R_SPARC_GNU_VTINHERIT 250
1612#define R_SPARC_GNU_VTENTRY 251
1613#define R_SPARC_REV32 252
1614/* Keep this the last entry. */
1615#define R_SPARC_NUM 253
1616
1617/* For Sparc64, legal values for d_tag of Elf64_Dyn. */
1618
1619#define DT_SPARC_REGISTER 0x70000001
1620#define DT_SPARC_NUM 2
1621
1622/* MIPS R3000 specific definitions. */
1623
1624/* Legal values for e_flags field of Elf32_Ehdr. */
1625
1626#define EF_MIPS_NOREORDER 1 /* A .noreorder directive was used. */
1627#define EF_MIPS_PIC 2 /* Contains PIC code. */
1628#define EF_MIPS_CPIC 4 /* Uses PIC calling sequence. */
1629#define EF_MIPS_XGOT 8
1630#define EF_MIPS_64BIT_WHIRL 16
1631#define EF_MIPS_ABI2 32
1632#define EF_MIPS_ABI_ON32 64
1633#define EF_MIPS_FP64 512 /* Uses FP64 (12 callee-saved). */
1634#define EF_MIPS_NAN2008 1024 /* Uses IEEE 754-2008 NaN encoding. */
1635#define EF_MIPS_ARCH 0xf0000000 /* MIPS architecture level. */
1636
1637/* Legal values for MIPS architecture level. */
1638
1639#define EF_MIPS_ARCH_1 0x00000000 /* -mips1 code. */
1640#define EF_MIPS_ARCH_2 0x10000000 /* -mips2 code. */
1641#define EF_MIPS_ARCH_3 0x20000000 /* -mips3 code. */
1642#define EF_MIPS_ARCH_4 0x30000000 /* -mips4 code. */
1643#define EF_MIPS_ARCH_5 0x40000000 /* -mips5 code. */
1644#define EF_MIPS_ARCH_32 0x50000000 /* MIPS32 code. */
1645#define EF_MIPS_ARCH_64 0x60000000 /* MIPS64 code. */
1646#define EF_MIPS_ARCH_32R2 0x70000000 /* MIPS32r2 code. */
1647#define EF_MIPS_ARCH_64R2 0x80000000 /* MIPS64r2 code. */
1648
1649/* The following are unofficial names and should not be used. */
1650
1651#define E_MIPS_ARCH_1 EF_MIPS_ARCH_1
1652#define E_MIPS_ARCH_2 EF_MIPS_ARCH_2
1653#define E_MIPS_ARCH_3 EF_MIPS_ARCH_3
1654#define E_MIPS_ARCH_4 EF_MIPS_ARCH_4
1655#define E_MIPS_ARCH_5 EF_MIPS_ARCH_5
1656#define E_MIPS_ARCH_32 EF_MIPS_ARCH_32
1657#define E_MIPS_ARCH_64 EF_MIPS_ARCH_64
1658
1659/* Special section indices. */
1660
1661#define SHN_MIPS_ACOMMON 0xff00 /* Allocated common symbols. */
1662#define SHN_MIPS_TEXT 0xff01 /* Allocated test symbols. */
1663#define SHN_MIPS_DATA 0xff02 /* Allocated data symbols. */
1664#define SHN_MIPS_SCOMMON 0xff03 /* Small common symbols. */
1665#define SHN_MIPS_SUNDEFINED 0xff04 /* Small undefined symbols. */
1666
1667/* Legal values for sh_type field of Elf32_Shdr. */
1668
1669#define SHT_MIPS_LIBLIST 0x70000000 /* Shared objects used in link. */
1670#define SHT_MIPS_MSYM 0x70000001
1671#define SHT_MIPS_CONFLICT 0x70000002 /* Conflicting symbols. */
1672#define SHT_MIPS_GPTAB 0x70000003 /* Global data area sizes. */
1673#define SHT_MIPS_UCODE 0x70000004 /* Reserved for SGI/MIPS compilers */
1674#define SHT_MIPS_DEBUG 0x70000005 /* MIPS ECOFF debugging info. */
1675#define SHT_MIPS_REGINFO 0x70000006 /* Register usage information. */
1676#define SHT_MIPS_PACKAGE 0x70000007
1677#define SHT_MIPS_PACKSYM 0x70000008
1678#define SHT_MIPS_RELD 0x70000009
1679#define SHT_MIPS_IFACE 0x7000000b
1680#define SHT_MIPS_CONTENT 0x7000000c
1681#define SHT_MIPS_OPTIONS 0x7000000d /* Miscellaneous options. */
1682#define SHT_MIPS_SHDR 0x70000010
1683#define SHT_MIPS_FDESC 0x70000011
1684#define SHT_MIPS_EXTSYM 0x70000012
1685#define SHT_MIPS_DENSE 0x70000013
1686#define SHT_MIPS_PDESC 0x70000014
1687#define SHT_MIPS_LOCSYM 0x70000015
1688#define SHT_MIPS_AUXSYM 0x70000016
1689#define SHT_MIPS_OPTSYM 0x70000017
1690#define SHT_MIPS_LOCSTR 0x70000018
1691#define SHT_MIPS_LINE 0x70000019
1692#define SHT_MIPS_RFDESC 0x7000001a
1693#define SHT_MIPS_DELTASYM 0x7000001b
1694#define SHT_MIPS_DELTAINST 0x7000001c
1695#define SHT_MIPS_DELTACLASS 0x7000001d
1696#define SHT_MIPS_DWARF 0x7000001e /* DWARF debugging information. */
1697#define SHT_MIPS_DELTADECL 0x7000001f
1698#define SHT_MIPS_SYMBOL_LIB 0x70000020
1699#define SHT_MIPS_EVENTS 0x70000021 /* Event section. */
1700#define SHT_MIPS_TRANSLATE 0x70000022
1701#define SHT_MIPS_PIXIE 0x70000023
1702#define SHT_MIPS_XLATE 0x70000024
1703#define SHT_MIPS_XLATE_DEBUG 0x70000025
1704#define SHT_MIPS_WHIRL 0x70000026
1705#define SHT_MIPS_EH_REGION 0x70000027
1706#define SHT_MIPS_XLATE_OLD 0x70000028
1707#define SHT_MIPS_PDR_EXCEPTION 0x70000029
1708
1709/* Legal values for sh_flags field of Elf32_Shdr. */
1710
1711#define SHF_MIPS_GPREL 0x10000000 /* Must be in global data area. */
1712#define SHF_MIPS_MERGE 0x20000000
1713#define SHF_MIPS_ADDR 0x40000000
1714#define SHF_MIPS_STRINGS 0x80000000
1715#define SHF_MIPS_NOSTRIP 0x08000000
1716#define SHF_MIPS_LOCAL 0x04000000
1717#define SHF_MIPS_NAMES 0x02000000
1718#define SHF_MIPS_NODUPE 0x01000000
1719
1720
1721/* Symbol tables. */
1722
1723/* MIPS specific values for `st_other'. */
1724#define STO_MIPS_DEFAULT 0x0
1725#define STO_MIPS_INTERNAL 0x1
1726#define STO_MIPS_HIDDEN 0x2
1727#define STO_MIPS_PROTECTED 0x3
1728#define STO_MIPS_PLT 0x8
1729#define STO_MIPS_SC_ALIGN_UNUSED 0xff
1730
1731/* MIPS specific values for `st_info'. */
1732#define STB_MIPS_SPLIT_COMMON 13
1733
1734/* Entries found in sections of type SHT_MIPS_GPTAB. */
1735
1736typedef union
1737{
1738 struct
1739 {
1740 Elf32_Word gt_current_g_value; /* -G value used for compilation. */
1741 Elf32_Word gt_unused; /* Not used. */
1742 } gt_header; /* First entry in section. */
1743 struct
1744 {
1745 Elf32_Word gt_g_value; /* If this value were used for -G. */
1746 Elf32_Word gt_bytes; /* This many bytes would be used. */
1747 } gt_entry; /* Subsequent entries in section. */
1748} Elf32_gptab;
1749
1750/* Entry found in sections of type SHT_MIPS_REGINFO. */
1751
1752typedef struct
1753{
1754 Elf32_Word ri_gprmask; /* General registers used. */
1755 Elf32_Word ri_cprmask[4]; /* Coprocessor registers used. */
1756 Elf32_Sword ri_gp_value; /* $gp register value. */
1757} Elf32_RegInfo;
1758
1759/* Entries found in sections of type SHT_MIPS_OPTIONS. */
1760
1761typedef struct
1762{
1763 unsigned char kind; /* Determines interpretation of the
1764 variable part of descriptor. */
1765 unsigned char size; /* Size of descriptor, including header. */
1766 Elf32_Section section; /* Section header index of section affected,
1767 0 for global options. */
1768 Elf32_Word info; /* Kind-specific information. */
1769} Elf_Options;
1770
1771/* Values for `kind' field in Elf_Options. */
1772
1773#define ODK_NULL 0 /* Undefined. */
1774#define ODK_REGINFO 1 /* Register usage information. */
1775#define ODK_EXCEPTIONS 2 /* Exception processing options. */
1776#define ODK_PAD 3 /* Section padding options. */
1777#define ODK_HWPATCH 4 /* Hardware workarounds performed */
1778#define ODK_FILL 5 /* record the fill value used by the linker. */
1779#define ODK_TAGS 6 /* reserve space for desktop tools to write. */
1780#define ODK_HWAND 7 /* HW workarounds. 'AND' bits when merging. */
1781#define ODK_HWOR 8 /* HW workarounds. 'OR' bits when merging. */
1782
1783/* Values for `info' in Elf_Options for ODK_EXCEPTIONS entries. */
1784
1785#define OEX_FPU_MIN 0x1f /* FPE's which MUST be enabled. */
1786#define OEX_FPU_MAX 0x1f00 /* FPE's which MAY be enabled. */
1787#define OEX_PAGE0 0x10000 /* page zero must be mapped. */
1788#define OEX_SMM 0x20000 /* Force sequential memory mode? */
1789#define OEX_FPDBUG 0x40000 /* Force floating point debug mode? */
1790#define OEX_PRECISEFP OEX_FPDBUG
1791#define OEX_DISMISS 0x80000 /* Dismiss invalid address faults? */
1792
1793#define OEX_FPU_INVAL 0x10
1794#define OEX_FPU_DIV0 0x08
1795#define OEX_FPU_OFLO 0x04
1796#define OEX_FPU_UFLO 0x02
1797#define OEX_FPU_INEX 0x01
1798
1799/* Masks for `info' in Elf_Options for an ODK_HWPATCH entry. */
1800
1801#define OHW_R4KEOP 0x1 /* R4000 end-of-page patch. */
1802#define OHW_R8KPFETCH 0x2 /* may need R8000 prefetch patch. */
1803#define OHW_R5KEOP 0x4 /* R5000 end-of-page patch. */
1804#define OHW_R5KCVTL 0x8 /* R5000 cvt.[ds].l bug. clean=1. */
1805
1806#define OPAD_PREFIX 0x1
1807#define OPAD_POSTFIX 0x2
1808#define OPAD_SYMBOL 0x4
1809
1810/* Entry found in `.options' section. */
1811
1812typedef struct
1813{
1814 Elf32_Word hwp_flags1; /* Extra flags. */
1815 Elf32_Word hwp_flags2; /* Extra flags. */
1816} Elf_Options_Hw;
1817
1818/* Masks for `info' in ElfOptions for ODK_HWAND and ODK_HWOR entries. */
1819
1820#define OHWA0_R4KEOP_CHECKED 0x00000001
1821#define OHWA1_R4KEOP_CLEAN 0x00000002
1822
1823/* MIPS relocs. */
1824
1825#define R_MIPS_NONE 0 /* No reloc */
1826#define R_MIPS_16 1 /* Direct 16 bit */
1827#define R_MIPS_32 2 /* Direct 32 bit */
1828#define R_MIPS_REL32 3 /* PC relative 32 bit */
1829#define R_MIPS_26 4 /* Direct 26 bit shifted */
1830#define R_MIPS_HI16 5 /* High 16 bit */
1831#define R_MIPS_LO16 6 /* Low 16 bit */
1832#define R_MIPS_GPREL16 7 /* GP relative 16 bit */
1833#define R_MIPS_LITERAL 8 /* 16 bit literal entry */
1834#define R_MIPS_GOT16 9 /* 16 bit GOT entry */
1835#define R_MIPS_PC16 10 /* PC relative 16 bit */
1836#define R_MIPS_CALL16 11 /* 16 bit GOT entry for function */
1837#define R_MIPS_GPREL32 12 /* GP relative 32 bit */
1838
1839#define R_MIPS_SHIFT5 16
1840#define R_MIPS_SHIFT6 17
1841#define R_MIPS_64 18
1842#define R_MIPS_GOT_DISP 19
1843#define R_MIPS_GOT_PAGE 20
1844#define R_MIPS_GOT_OFST 21
1845#define R_MIPS_GOT_HI16 22
1846#define R_MIPS_GOT_LO16 23
1847#define R_MIPS_SUB 24
1848#define R_MIPS_INSERT_A 25
1849#define R_MIPS_INSERT_B 26
1850#define R_MIPS_DELETE 27
1851#define R_MIPS_HIGHER 28
1852#define R_MIPS_HIGHEST 29
1853#define R_MIPS_CALL_HI16 30
1854#define R_MIPS_CALL_LO16 31
1855#define R_MIPS_SCN_DISP 32
1856#define R_MIPS_REL16 33
1857#define R_MIPS_ADD_IMMEDIATE 34
1858#define R_MIPS_PJUMP 35
1859#define R_MIPS_RELGOT 36
1860#define R_MIPS_JALR 37
1861#define R_MIPS_TLS_DTPMOD32 38 /* Module number 32 bit */
1862#define R_MIPS_TLS_DTPREL32 39 /* Module-relative offset 32 bit */
1863#define R_MIPS_TLS_DTPMOD64 40 /* Module number 64 bit */
1864#define R_MIPS_TLS_DTPREL64 41 /* Module-relative offset 64 bit */
1865#define R_MIPS_TLS_GD 42 /* 16 bit GOT offset for GD */
1866#define R_MIPS_TLS_LDM 43 /* 16 bit GOT offset for LDM */
1867#define R_MIPS_TLS_DTPREL_HI16 44 /* Module-relative offset, high 16 bits */
1868#define R_MIPS_TLS_DTPREL_LO16 45 /* Module-relative offset, low 16 bits */
1869#define R_MIPS_TLS_GOTTPREL 46 /* 16 bit GOT offset for IE */
1870#define R_MIPS_TLS_TPREL32 47 /* TP-relative offset, 32 bit */
1871#define R_MIPS_TLS_TPREL64 48 /* TP-relative offset, 64 bit */
1872#define R_MIPS_TLS_TPREL_HI16 49 /* TP-relative offset, high 16 bits */
1873#define R_MIPS_TLS_TPREL_LO16 50 /* TP-relative offset, low 16 bits */
1874#define R_MIPS_GLOB_DAT 51
1875#define R_MIPS_COPY 126
1876#define R_MIPS_JUMP_SLOT 127
1877/* Keep this the last entry. */
1878#define R_MIPS_NUM 128
1879
1880/* Legal values for p_type field of Elf32_Phdr. */
1881
1882#define PT_MIPS_REGINFO 0x70000000 /* Register usage information. */
1883#define PT_MIPS_RTPROC 0x70000001 /* Runtime procedure table. */
1884#define PT_MIPS_OPTIONS 0x70000002
1885#define PT_MIPS_ABIFLAGS 0x70000003 /* FP mode requirement. */
1886
1887/* Special program header types. */
1888
1889#define PF_MIPS_LOCAL 0x10000000
1890
1891/* Legal values for d_tag field of Elf32_Dyn. */
1892
1893#define DT_MIPS_RLD_VERSION 0x70000001 /* Runtime linker interface version */
1894#define DT_MIPS_TIME_STAMP 0x70000002 /* Timestamp */
1895#define DT_MIPS_ICHECKSUM 0x70000003 /* Checksum */
1896#define DT_MIPS_IVERSION 0x70000004 /* Version string (string tbl index) */
1897#define DT_MIPS_FLAGS 0x70000005 /* Flags */
1898#define DT_MIPS_BASE_ADDRESS 0x70000006 /* Base address */
1899#define DT_MIPS_MSYM 0x70000007
1900#define DT_MIPS_CONFLICT 0x70000008 /* Address of CONFLICT section */
1901#define DT_MIPS_LIBLIST 0x70000009 /* Address of LIBLIST section */
1902#define DT_MIPS_LOCAL_GOTNO 0x7000000a /* Number of local GOT entries */
1903#define DT_MIPS_CONFLICTNO 0x7000000b /* Number of CONFLICT entries */
1904#define DT_MIPS_LIBLISTNO 0x70000010 /* Number of LIBLIST entries */
1905#define DT_MIPS_SYMTABNO 0x70000011 /* Number of DYNSYM entries */
1906#define DT_MIPS_UNREFEXTNO 0x70000012 /* First external DYNSYM */
1907#define DT_MIPS_GOTSYM 0x70000013 /* First GOT entry in DYNSYM */
1908#define DT_MIPS_HIPAGENO 0x70000014 /* Number of GOT page table entries */
1909#define DT_MIPS_RLD_MAP 0x70000016 /* Address of run time loader map. */
1910#define DT_MIPS_DELTA_CLASS 0x70000017 /* Delta C++ class definition. */
1911#define DT_MIPS_DELTA_CLASS_NO 0x70000018 /* Number of entries in
1912 DT_MIPS_DELTA_CLASS. */
1913#define DT_MIPS_DELTA_INSTANCE 0x70000019 /* Delta C++ class instances. */
1914#define DT_MIPS_DELTA_INSTANCE_NO 0x7000001a /* Number of entries in
1915 DT_MIPS_DELTA_INSTANCE. */
1916#define DT_MIPS_DELTA_RELOC 0x7000001b /* Delta relocations. */
1917#define DT_MIPS_DELTA_RELOC_NO 0x7000001c /* Number of entries in
1918 DT_MIPS_DELTA_RELOC. */
1919#define DT_MIPS_DELTA_SYM 0x7000001d /* Delta symbols that Delta
1920 relocations refer to. */
1921#define DT_MIPS_DELTA_SYM_NO 0x7000001e /* Number of entries in
1922 DT_MIPS_DELTA_SYM. */
1923#define DT_MIPS_DELTA_CLASSSYM 0x70000020 /* Delta symbols that hold the
1924 class declaration. */
1925#define DT_MIPS_DELTA_CLASSSYM_NO 0x70000021 /* Number of entries in
1926 DT_MIPS_DELTA_CLASSSYM. */
1927#define DT_MIPS_CXX_FLAGS 0x70000022 /* Flags indicating for C++ flavor. */
1928#define DT_MIPS_PIXIE_INIT 0x70000023
1929#define DT_MIPS_SYMBOL_LIB 0x70000024
1930#define DT_MIPS_LOCALPAGE_GOTIDX 0x70000025
1931#define DT_MIPS_LOCAL_GOTIDX 0x70000026
1932#define DT_MIPS_HIDDEN_GOTIDX 0x70000027
1933#define DT_MIPS_PROTECTED_GOTIDX 0x70000028
1934#define DT_MIPS_OPTIONS 0x70000029 /* Address of .options. */
1935#define DT_MIPS_INTERFACE 0x7000002a /* Address of .interface. */
1936#define DT_MIPS_DYNSTR_ALIGN 0x7000002b
1937#define DT_MIPS_INTERFACE_SIZE 0x7000002c /* Size of the .interface section. */
1938#define DT_MIPS_RLD_TEXT_RESOLVE_ADDR 0x7000002d /* Address of rld_text_rsolve
1939 function stored in GOT. */
1940#define DT_MIPS_PERF_SUFFIX 0x7000002e /* Default suffix of dso to be added
1941 by rld on dlopen() calls. */
1942#define DT_MIPS_COMPACT_SIZE 0x7000002f /* (O32)Size of compact rel section. */
1943#define DT_MIPS_GP_VALUE 0x70000030 /* GP value for aux GOTs. */
1944#define DT_MIPS_AUX_DYNAMIC 0x70000031 /* Address of aux .dynamic. */
1945/* The address of .got.plt in an executable using the new non-PIC ABI. */
1946#define DT_MIPS_PLTGOT 0x70000032
1947/* The base of the PLT in an executable using the new non-PIC ABI if that
1948 PLT is writable. For a non-writable PLT, this is omitted or has a zero
1949 value. */
1950#define DT_MIPS_RWPLT 0x70000034
1951/* An alternative description of the classic MIPS RLD_MAP that is usable
1952 in a PIE as it stores a relative offset from the address of the tag
1953 rather than an absolute address. */
1954#define DT_MIPS_RLD_MAP_REL 0x70000035
1955#define DT_MIPS_NUM 0x36
1956
1957/* Legal values for DT_MIPS_FLAGS Elf32_Dyn entry. */
1958
1959#define RHF_NONE 0 /* No flags */
1960#define RHF_QUICKSTART (1 << 0) /* Use quickstart */
1961#define RHF_NOTPOT (1 << 1) /* Hash size not power of 2 */
1962#define RHF_NO_LIBRARY_REPLACEMENT (1 << 2) /* Ignore LD_LIBRARY_PATH */
1963#define RHF_NO_MOVE (1 << 3)
1964#define RHF_SGI_ONLY (1 << 4)
1965#define RHF_GUARANTEE_INIT (1 << 5)
1966#define RHF_DELTA_C_PLUS_PLUS (1 << 6)
1967#define RHF_GUARANTEE_START_INIT (1 << 7)
1968#define RHF_PIXIE (1 << 8)
1969#define RHF_DEFAULT_DELAY_LOAD (1 << 9)
1970#define RHF_REQUICKSTART (1 << 10)
1971#define RHF_REQUICKSTARTED (1 << 11)
1972#define RHF_CORD (1 << 12)
1973#define RHF_NO_UNRES_UNDEF (1 << 13)
1974#define RHF_RLD_ORDER_SAFE (1 << 14)
1975
1976/* Entries found in sections of type SHT_MIPS_LIBLIST. */
1977
1978typedef struct
1979{
1980 Elf32_Word l_name; /* Name (string table index) */
1981 Elf32_Word l_time_stamp; /* Timestamp */
1982 Elf32_Word l_checksum; /* Checksum */
1983 Elf32_Word l_version; /* Interface version */
1984 Elf32_Word l_flags; /* Flags */
1985} Elf32_Lib;
1986
1987typedef struct
1988{
1989 Elf64_Word l_name; /* Name (string table index) */
1990 Elf64_Word l_time_stamp; /* Timestamp */
1991 Elf64_Word l_checksum; /* Checksum */
1992 Elf64_Word l_version; /* Interface version */
1993 Elf64_Word l_flags; /* Flags */
1994} Elf64_Lib;
1995
1996
1997/* Legal values for l_flags. */
1998
1999#define LL_NONE 0
2000#define LL_EXACT_MATCH (1 << 0) /* Require exact match */
2001#define LL_IGNORE_INT_VER (1 << 1) /* Ignore interface version */
2002#define LL_REQUIRE_MINOR (1 << 2)
2003#define LL_EXPORTS (1 << 3)
2004#define LL_DELAY_LOAD (1 << 4)
2005#define LL_DELTA (1 << 5)
2006
2007/* Entries found in sections of type SHT_MIPS_CONFLICT. */
2008
2009typedef Elf32_Addr Elf32_Conflict;
2010
2011typedef struct
2012{
2013 /* Version of flags structure. */
2014 Elf32_Half version;
2015 /* The level of the ISA: 1-5, 32, 64. */
2016 unsigned char isa_level;
2017 /* The revision of ISA: 0 for MIPS V and below, 1-n otherwise. */
2018 unsigned char isa_rev;
2019 /* The size of general purpose registers. */
2020 unsigned char gpr_size;
2021 /* The size of co-processor 1 registers. */
2022 unsigned char cpr1_size;
2023 /* The size of co-processor 2 registers. */
2024 unsigned char cpr2_size;
2025 /* The floating-point ABI. */
2026 unsigned char fp_abi;
2027 /* Processor-specific extension. */
2028 Elf32_Word isa_ext;
2029 /* Mask of ASEs used. */
2030 Elf32_Word ases;
2031 /* Mask of general flags. */
2032 Elf32_Word flags1;
2033 Elf32_Word flags2;
2034} Elf_MIPS_ABIFlags_v0;
2035
2036/* Values for the register size bytes of an abi flags structure. */
2037
2038#define MIPS_AFL_REG_NONE 0x00 /* No registers. */
2039#define MIPS_AFL_REG_32 0x01 /* 32-bit registers. */
2040#define MIPS_AFL_REG_64 0x02 /* 64-bit registers. */
2041#define MIPS_AFL_REG_128 0x03 /* 128-bit registers. */
2042
2043/* Masks for the ases word of an ABI flags structure. */
2044
2045#define MIPS_AFL_ASE_DSP 0x00000001 /* DSP ASE. */
2046#define MIPS_AFL_ASE_DSPR2 0x00000002 /* DSP R2 ASE. */
2047#define MIPS_AFL_ASE_EVA 0x00000004 /* Enhanced VA Scheme. */
2048#define MIPS_AFL_ASE_MCU 0x00000008 /* MCU (MicroController) ASE. */
2049#define MIPS_AFL_ASE_MDMX 0x00000010 /* MDMX ASE. */
2050#define MIPS_AFL_ASE_MIPS3D 0x00000020 /* MIPS-3D ASE. */
2051#define MIPS_AFL_ASE_MT 0x00000040 /* MT ASE. */
2052#define MIPS_AFL_ASE_SMARTMIPS 0x00000080 /* SmartMIPS ASE. */
2053#define MIPS_AFL_ASE_VIRT 0x00000100 /* VZ ASE. */
2054#define MIPS_AFL_ASE_MSA 0x00000200 /* MSA ASE. */
2055#define MIPS_AFL_ASE_MIPS16 0x00000400 /* MIPS16 ASE. */
2056#define MIPS_AFL_ASE_MICROMIPS 0x00000800 /* MICROMIPS ASE. */
2057#define MIPS_AFL_ASE_XPA 0x00001000 /* XPA ASE. */
2058#define MIPS_AFL_ASE_MASK 0x00001fff /* All ASEs. */
2059
2060/* Values for the isa_ext word of an ABI flags structure. */
2061
2062#define MIPS_AFL_EXT_XLR 1 /* RMI Xlr instruction. */
2063#define MIPS_AFL_EXT_OCTEON2 2 /* Cavium Networks Octeon2. */
2064#define MIPS_AFL_EXT_OCTEONP 3 /* Cavium Networks OcteonP. */
2065#define MIPS_AFL_EXT_LOONGSON_3A 4 /* Loongson 3A. */
2066#define MIPS_AFL_EXT_OCTEON 5 /* Cavium Networks Octeon. */
2067#define MIPS_AFL_EXT_5900 6 /* MIPS R5900 instruction. */
2068#define MIPS_AFL_EXT_4650 7 /* MIPS R4650 instruction. */
2069#define MIPS_AFL_EXT_4010 8 /* LSI R4010 instruction. */
2070#define MIPS_AFL_EXT_4100 9 /* NEC VR4100 instruction. */
2071#define MIPS_AFL_EXT_3900 10 /* Toshiba R3900 instruction. */
2072#define MIPS_AFL_EXT_10000 11 /* MIPS R10000 instruction. */
2073#define MIPS_AFL_EXT_SB1 12 /* Broadcom SB-1 instruction. */
2074#define MIPS_AFL_EXT_4111 13 /* NEC VR4111/VR4181 instruction. */
2075#define MIPS_AFL_EXT_4120 14 /* NEC VR4120 instruction. */
2076#define MIPS_AFL_EXT_5400 15 /* NEC VR5400 instruction. */
2077#define MIPS_AFL_EXT_5500 16 /* NEC VR5500 instruction. */
2078#define MIPS_AFL_EXT_LOONGSON_2E 17 /* ST Microelectronics Loongson 2E. */
2079#define MIPS_AFL_EXT_LOONGSON_2F 18 /* ST Microelectronics Loongson 2F. */
2080
2081/* Masks for the flags1 word of an ABI flags structure. */
2082#define MIPS_AFL_FLAGS1_ODDSPREG 1 /* Uses odd single-precision registers. */
2083
2084/* Object attribute values. */
2085enum
2086{
2087 /* Not tagged or not using any ABIs affected by the differences. */
2088 Val_GNU_MIPS_ABI_FP_ANY = 0,
2089 /* Using hard-float -mdouble-float. */
2090 Val_GNU_MIPS_ABI_FP_DOUBLE = 1,
2091 /* Using hard-float -msingle-float. */
2092 Val_GNU_MIPS_ABI_FP_SINGLE = 2,
2093 /* Using soft-float. */
2094 Val_GNU_MIPS_ABI_FP_SOFT = 3,
2095 /* Using -mips32r2 -mfp64. */
2096 Val_GNU_MIPS_ABI_FP_OLD_64 = 4,
2097 /* Using -mfpxx. */
2098 Val_GNU_MIPS_ABI_FP_XX = 5,
2099 /* Using -mips32r2 -mfp64. */
2100 Val_GNU_MIPS_ABI_FP_64 = 6,
2101 /* Using -mips32r2 -mfp64 -mno-odd-spreg. */
2102 Val_GNU_MIPS_ABI_FP_64A = 7,
2103 /* Maximum allocated FP ABI value. */
2104 Val_GNU_MIPS_ABI_FP_MAX = 7
2105};
2106
2107/* HPPA specific definitions. */
2108
2109/* Legal values for e_flags field of Elf32_Ehdr. */
2110
2111#define EF_PARISC_TRAPNIL 0x00010000 /* Trap nil pointer dereference. */
2112#define EF_PARISC_EXT 0x00020000 /* Program uses arch. extensions. */
2113#define EF_PARISC_LSB 0x00040000 /* Program expects little endian. */
2114#define EF_PARISC_WIDE 0x00080000 /* Program expects wide mode. */
2115#define EF_PARISC_NO_KABP 0x00100000 /* No kernel assisted branch
2116 prediction. */
2117#define EF_PARISC_LAZYSWAP 0x00400000 /* Allow lazy swapping. */
2118#define EF_PARISC_ARCH 0x0000ffff /* Architecture version. */
2119
2120/* Defined values for `e_flags & EF_PARISC_ARCH' are: */
2121
2122#define EFA_PARISC_1_0 0x020b /* PA-RISC 1.0 big-endian. */
2123#define EFA_PARISC_1_1 0x0210 /* PA-RISC 1.1 big-endian. */
2124#define EFA_PARISC_2_0 0x0214 /* PA-RISC 2.0 big-endian. */
2125
2126/* Additional section indeces. */
2127
2128#define SHN_PARISC_ANSI_COMMON 0xff00 /* Section for tenatively declared
2129 symbols in ANSI C. */
2130#define SHN_PARISC_HUGE_COMMON 0xff01 /* Common blocks in huge model. */
2131
2132/* Legal values for sh_type field of Elf32_Shdr. */
2133
2134#define SHT_PARISC_EXT 0x70000000 /* Contains product specific ext. */
2135#define SHT_PARISC_UNWIND 0x70000001 /* Unwind information. */
2136#define SHT_PARISC_DOC 0x70000002 /* Debug info for optimized code. */
2137
2138/* Legal values for sh_flags field of Elf32_Shdr. */
2139
2140#define SHF_PARISC_SHORT 0x20000000 /* Section with short addressing. */
2141#define SHF_PARISC_HUGE 0x40000000 /* Section far from gp. */
2142#define SHF_PARISC_SBP 0x80000000 /* Static branch prediction code. */
2143
2144/* Legal values for ST_TYPE subfield of st_info (symbol type). */
2145
2146#define STT_PARISC_MILLICODE 13 /* Millicode function entry point. */
2147
2148#define STT_HP_OPAQUE (STT_LOOS + 0x1)
2149#define STT_HP_STUB (STT_LOOS + 0x2)
2150
2151/* HPPA relocs. */
2152
2153#define R_PARISC_NONE 0 /* No reloc. */
2154#define R_PARISC_DIR32 1 /* Direct 32-bit reference. */
2155#define R_PARISC_DIR21L 2 /* Left 21 bits of eff. address. */
2156#define R_PARISC_DIR17R 3 /* Right 17 bits of eff. address. */
2157#define R_PARISC_DIR17F 4 /* 17 bits of eff. address. */
2158#define R_PARISC_DIR14R 6 /* Right 14 bits of eff. address. */
2159#define R_PARISC_PCREL32 9 /* 32-bit rel. address. */
2160#define R_PARISC_PCREL21L 10 /* Left 21 bits of rel. address. */
2161#define R_PARISC_PCREL17R 11 /* Right 17 bits of rel. address. */
2162#define R_PARISC_PCREL17F 12 /* 17 bits of rel. address. */
2163#define R_PARISC_PCREL14R 14 /* Right 14 bits of rel. address. */
2164#define R_PARISC_DPREL21L 18 /* Left 21 bits of rel. address. */
2165#define R_PARISC_DPREL14R 22 /* Right 14 bits of rel. address. */
2166#define R_PARISC_GPREL21L 26 /* GP-relative, left 21 bits. */
2167#define R_PARISC_GPREL14R 30 /* GP-relative, right 14 bits. */
2168#define R_PARISC_LTOFF21L 34 /* LT-relative, left 21 bits. */
2169#define R_PARISC_LTOFF14R 38 /* LT-relative, right 14 bits. */
2170#define R_PARISC_SECREL32 41 /* 32 bits section rel. address. */
2171#define R_PARISC_SEGBASE 48 /* No relocation, set segment base. */
2172#define R_PARISC_SEGREL32 49 /* 32 bits segment rel. address. */
2173#define R_PARISC_PLTOFF21L 50 /* PLT rel. address, left 21 bits. */
2174#define R_PARISC_PLTOFF14R 54 /* PLT rel. address, right 14 bits. */
2175#define R_PARISC_LTOFF_FPTR32 57 /* 32 bits LT-rel. function pointer. */
2176#define R_PARISC_LTOFF_FPTR21L 58 /* LT-rel. fct ptr, left 21 bits. */
2177#define R_PARISC_LTOFF_FPTR14R 62 /* LT-rel. fct ptr, right 14 bits. */
2178#define R_PARISC_FPTR64 64 /* 64 bits function address. */
2179#define R_PARISC_PLABEL32 65 /* 32 bits function address. */
2180#define R_PARISC_PLABEL21L 66 /* Left 21 bits of fdesc address. */
2181#define R_PARISC_PLABEL14R 70 /* Right 14 bits of fdesc address. */
2182#define R_PARISC_PCREL64 72 /* 64 bits PC-rel. address. */
2183#define R_PARISC_PCREL22F 74 /* 22 bits PC-rel. address. */
2184#define R_PARISC_PCREL14WR 75 /* PC-rel. address, right 14 bits. */
2185#define R_PARISC_PCREL14DR 76 /* PC rel. address, right 14 bits. */
2186#define R_PARISC_PCREL16F 77 /* 16 bits PC-rel. address. */
2187#define R_PARISC_PCREL16WF 78 /* 16 bits PC-rel. address. */
2188#define R_PARISC_PCREL16DF 79 /* 16 bits PC-rel. address. */
2189#define R_PARISC_DIR64 80 /* 64 bits of eff. address. */
2190#define R_PARISC_DIR14WR 83 /* 14 bits of eff. address. */
2191#define R_PARISC_DIR14DR 84 /* 14 bits of eff. address. */
2192#define R_PARISC_DIR16F 85 /* 16 bits of eff. address. */
2193#define R_PARISC_DIR16WF 86 /* 16 bits of eff. address. */
2194#define R_PARISC_DIR16DF 87 /* 16 bits of eff. address. */
2195#define R_PARISC_GPREL64 88 /* 64 bits of GP-rel. address. */
2196#define R_PARISC_GPREL14WR 91 /* GP-rel. address, right 14 bits. */
2197#define R_PARISC_GPREL14DR 92 /* GP-rel. address, right 14 bits. */
2198#define R_PARISC_GPREL16F 93 /* 16 bits GP-rel. address. */
2199#define R_PARISC_GPREL16WF 94 /* 16 bits GP-rel. address. */
2200#define R_PARISC_GPREL16DF 95 /* 16 bits GP-rel. address. */
2201#define R_PARISC_LTOFF64 96 /* 64 bits LT-rel. address. */
2202#define R_PARISC_LTOFF14WR 99 /* LT-rel. address, right 14 bits. */
2203#define R_PARISC_LTOFF14DR 100 /* LT-rel. address, right 14 bits. */
2204#define R_PARISC_LTOFF16F 101 /* 16 bits LT-rel. address. */
2205#define R_PARISC_LTOFF16WF 102 /* 16 bits LT-rel. address. */
2206#define R_PARISC_LTOFF16DF 103 /* 16 bits LT-rel. address. */
2207#define R_PARISC_SECREL64 104 /* 64 bits section rel. address. */
2208#define R_PARISC_SEGREL64 112 /* 64 bits segment rel. address. */
2209#define R_PARISC_PLTOFF14WR 115 /* PLT-rel. address, right 14 bits. */
2210#define R_PARISC_PLTOFF14DR 116 /* PLT-rel. address, right 14 bits. */
2211#define R_PARISC_PLTOFF16F 117 /* 16 bits LT-rel. address. */
2212#define R_PARISC_PLTOFF16WF 118 /* 16 bits PLT-rel. address. */
2213#define R_PARISC_PLTOFF16DF 119 /* 16 bits PLT-rel. address. */
2214#define R_PARISC_LTOFF_FPTR64 120 /* 64 bits LT-rel. function ptr. */
2215#define R_PARISC_LTOFF_FPTR14WR 123 /* LT-rel. fct. ptr., right 14 bits. */
2216#define R_PARISC_LTOFF_FPTR14DR 124 /* LT-rel. fct. ptr., right 14 bits. */
2217#define R_PARISC_LTOFF_FPTR16F 125 /* 16 bits LT-rel. function ptr. */
2218#define R_PARISC_LTOFF_FPTR16WF 126 /* 16 bits LT-rel. function ptr. */
2219#define R_PARISC_LTOFF_FPTR16DF 127 /* 16 bits LT-rel. function ptr. */
2220#define R_PARISC_LORESERVE 128
2221#define R_PARISC_COPY 128 /* Copy relocation. */
2222#define R_PARISC_IPLT 129 /* Dynamic reloc, imported PLT */
2223#define R_PARISC_EPLT 130 /* Dynamic reloc, exported PLT */
2224#define R_PARISC_TPREL32 153 /* 32 bits TP-rel. address. */
2225#define R_PARISC_TPREL21L 154 /* TP-rel. address, left 21 bits. */
2226#define R_PARISC_TPREL14R 158 /* TP-rel. address, right 14 bits. */
2227#define R_PARISC_LTOFF_TP21L 162 /* LT-TP-rel. address, left 21 bits. */
2228#define R_PARISC_LTOFF_TP14R 166 /* LT-TP-rel. address, right 14 bits.*/
2229#define R_PARISC_LTOFF_TP14F 167 /* 14 bits LT-TP-rel. address. */
2230#define R_PARISC_TPREL64 216 /* 64 bits TP-rel. address. */
2231#define R_PARISC_TPREL14WR 219 /* TP-rel. address, right 14 bits. */
2232#define R_PARISC_TPREL14DR 220 /* TP-rel. address, right 14 bits. */
2233#define R_PARISC_TPREL16F 221 /* 16 bits TP-rel. address. */
2234#define R_PARISC_TPREL16WF 222 /* 16 bits TP-rel. address. */
2235#define R_PARISC_TPREL16DF 223 /* 16 bits TP-rel. address. */
2236#define R_PARISC_LTOFF_TP64 224 /* 64 bits LT-TP-rel. address. */
2237#define R_PARISC_LTOFF_TP14WR 227 /* LT-TP-rel. address, right 14 bits.*/
2238#define R_PARISC_LTOFF_TP14DR 228 /* LT-TP-rel. address, right 14 bits.*/
2239#define R_PARISC_LTOFF_TP16F 229 /* 16 bits LT-TP-rel. address. */
2240#define R_PARISC_LTOFF_TP16WF 230 /* 16 bits LT-TP-rel. address. */
2241#define R_PARISC_LTOFF_TP16DF 231 /* 16 bits LT-TP-rel. address. */
2242#define R_PARISC_GNU_VTENTRY 232
2243#define R_PARISC_GNU_VTINHERIT 233
2244#define R_PARISC_TLS_GD21L 234 /* GD 21-bit left. */
2245#define R_PARISC_TLS_GD14R 235 /* GD 14-bit right. */
2246#define R_PARISC_TLS_GDCALL 236 /* GD call to __t_g_a. */
2247#define R_PARISC_TLS_LDM21L 237 /* LD module 21-bit left. */
2248#define R_PARISC_TLS_LDM14R 238 /* LD module 14-bit right. */
2249#define R_PARISC_TLS_LDMCALL 239 /* LD module call to __t_g_a. */
2250#define R_PARISC_TLS_LDO21L 240 /* LD offset 21-bit left. */
2251#define R_PARISC_TLS_LDO14R 241 /* LD offset 14-bit right. */
2252#define R_PARISC_TLS_DTPMOD32 242 /* DTP module 32-bit. */
2253#define R_PARISC_TLS_DTPMOD64 243 /* DTP module 64-bit. */
2254#define R_PARISC_TLS_DTPOFF32 244 /* DTP offset 32-bit. */
2255#define R_PARISC_TLS_DTPOFF64 245 /* DTP offset 32-bit. */
2256#define R_PARISC_TLS_LE21L R_PARISC_TPREL21L
2257#define R_PARISC_TLS_LE14R R_PARISC_TPREL14R
2258#define R_PARISC_TLS_IE21L R_PARISC_LTOFF_TP21L
2259#define R_PARISC_TLS_IE14R R_PARISC_LTOFF_TP14R
2260#define R_PARISC_TLS_TPREL32 R_PARISC_TPREL32
2261#define R_PARISC_TLS_TPREL64 R_PARISC_TPREL64
2262#define R_PARISC_HIRESERVE 255
2263
2264/* Legal values for p_type field of Elf32_Phdr/Elf64_Phdr. */
2265
2266#define PT_HP_TLS (PT_LOOS + 0x0)
2267#define PT_HP_CORE_NONE (PT_LOOS + 0x1)
2268#define PT_HP_CORE_VERSION (PT_LOOS + 0x2)
2269#define PT_HP_CORE_KERNEL (PT_LOOS + 0x3)
2270#define PT_HP_CORE_COMM (PT_LOOS + 0x4)
2271#define PT_HP_CORE_PROC (PT_LOOS + 0x5)
2272#define PT_HP_CORE_LOADABLE (PT_LOOS + 0x6)
2273#define PT_HP_CORE_STACK (PT_LOOS + 0x7)
2274#define PT_HP_CORE_SHM (PT_LOOS + 0x8)
2275#define PT_HP_CORE_MMF (PT_LOOS + 0x9)
2276#define PT_HP_PARALLEL (PT_LOOS + 0x10)
2277#define PT_HP_FASTBIND (PT_LOOS + 0x11)
2278#define PT_HP_OPT_ANNOT (PT_LOOS + 0x12)
2279#define PT_HP_HSL_ANNOT (PT_LOOS + 0x13)
2280#define PT_HP_STACK (PT_LOOS + 0x14)
2281
2282#define PT_PARISC_ARCHEXT 0x70000000
2283#define PT_PARISC_UNWIND 0x70000001
2284
2285/* Legal values for p_flags field of Elf32_Phdr/Elf64_Phdr. */
2286
2287#define PF_PARISC_SBP 0x08000000
2288
2289#define PF_HP_PAGE_SIZE 0x00100000
2290#define PF_HP_FAR_SHARED 0x00200000
2291#define PF_HP_NEAR_SHARED 0x00400000
2292#define PF_HP_CODE 0x01000000
2293#define PF_HP_MODIFY 0x02000000
2294#define PF_HP_LAZYSWAP 0x04000000
2295#define PF_HP_SBP 0x08000000
2296
2297
2298/* Alpha specific definitions. */
2299
2300/* Legal values for e_flags field of Elf64_Ehdr. */
2301
2302#define EF_ALPHA_32BIT 1 /* All addresses must be < 2GB. */
2303#define EF_ALPHA_CANRELAX 2 /* Relocations for relaxing exist. */
2304
2305/* Legal values for sh_type field of Elf64_Shdr. */
2306
2307/* These two are primerily concerned with ECOFF debugging info. */
2308#define SHT_ALPHA_DEBUG 0x70000001
2309#define SHT_ALPHA_REGINFO 0x70000002
2310
2311/* Legal values for sh_flags field of Elf64_Shdr. */
2312
2313#define SHF_ALPHA_GPREL 0x10000000
2314
2315/* Legal values for st_other field of Elf64_Sym. */
2316#define STO_ALPHA_NOPV 0x80 /* No PV required. */
2317#define STO_ALPHA_STD_GPLOAD 0x88 /* PV only used for initial ldgp. */
2318
2319/* Alpha relocs. */
2320
2321#define R_ALPHA_NONE 0 /* No reloc */
2322#define R_ALPHA_REFLONG 1 /* Direct 32 bit */
2323#define R_ALPHA_REFQUAD 2 /* Direct 64 bit */
2324#define R_ALPHA_GPREL32 3 /* GP relative 32 bit */
2325#define R_ALPHA_LITERAL 4 /* GP relative 16 bit w/optimization */
2326#define R_ALPHA_LITUSE 5 /* Optimization hint for LITERAL */
2327#define R_ALPHA_GPDISP 6 /* Add displacement to GP */
2328#define R_ALPHA_BRADDR 7 /* PC+4 relative 23 bit shifted */
2329#define R_ALPHA_HINT 8 /* PC+4 relative 16 bit shifted */
2330#define R_ALPHA_SREL16 9 /* PC relative 16 bit */
2331#define R_ALPHA_SREL32 10 /* PC relative 32 bit */
2332#define R_ALPHA_SREL64 11 /* PC relative 64 bit */
2333#define R_ALPHA_GPRELHIGH 17 /* GP relative 32 bit, high 16 bits */
2334#define R_ALPHA_GPRELLOW 18 /* GP relative 32 bit, low 16 bits */
2335#define R_ALPHA_GPREL16 19 /* GP relative 16 bit */
2336#define R_ALPHA_COPY 24 /* Copy symbol at runtime */
2337#define R_ALPHA_GLOB_DAT 25 /* Create GOT entry */
2338#define R_ALPHA_JMP_SLOT 26 /* Create PLT entry */
2339#define R_ALPHA_RELATIVE 27 /* Adjust by program base */
2340#define R_ALPHA_TLS_GD_HI 28
2341#define R_ALPHA_TLSGD 29
2342#define R_ALPHA_TLS_LDM 30
2343#define R_ALPHA_DTPMOD64 31
2344#define R_ALPHA_GOTDTPREL 32
2345#define R_ALPHA_DTPREL64 33
2346#define R_ALPHA_DTPRELHI 34
2347#define R_ALPHA_DTPRELLO 35
2348#define R_ALPHA_DTPREL16 36
2349#define R_ALPHA_GOTTPREL 37
2350#define R_ALPHA_TPREL64 38
2351#define R_ALPHA_TPRELHI 39
2352#define R_ALPHA_TPRELLO 40
2353#define R_ALPHA_TPREL16 41
2354/* Keep this the last entry. */
2355#define R_ALPHA_NUM 46
2356
2357/* Magic values of the LITUSE relocation addend. */
2358#define LITUSE_ALPHA_ADDR 0
2359#define LITUSE_ALPHA_BASE 1
2360#define LITUSE_ALPHA_BYTOFF 2
2361#define LITUSE_ALPHA_JSR 3
2362#define LITUSE_ALPHA_TLS_GD 4
2363#define LITUSE_ALPHA_TLS_LDM 5
2364
2365/* Legal values for d_tag of Elf64_Dyn. */
2366#define DT_ALPHA_PLTRO (DT_LOPROC + 0)
2367#define DT_ALPHA_NUM 1
2368
2369/* PowerPC specific declarations */
2370
2371/* Values for Elf32/64_Ehdr.e_flags. */
2372#define EF_PPC_EMB 0x80000000 /* PowerPC embedded flag */
2373
2374/* Cygnus local bits below */
2375#define EF_PPC_RELOCATABLE 0x00010000 /* PowerPC -mrelocatable flag*/
2376#define EF_PPC_RELOCATABLE_LIB 0x00008000 /* PowerPC -mrelocatable-lib
2377 flag */
2378
2379/* PowerPC relocations defined by the ABIs */
2380#define R_PPC_NONE 0
2381#define R_PPC_ADDR32 1 /* 32bit absolute address */
2382#define R_PPC_ADDR24 2 /* 26bit address, 2 bits ignored. */
2383#define R_PPC_ADDR16 3 /* 16bit absolute address */
2384#define R_PPC_ADDR16_LO 4 /* lower 16bit of absolute address */
2385#define R_PPC_ADDR16_HI 5 /* high 16bit of absolute address */
2386#define R_PPC_ADDR16_HA 6 /* adjusted high 16bit */
2387#define R_PPC_ADDR14 7 /* 16bit address, 2 bits ignored */
2388#define R_PPC_ADDR14_BRTAKEN 8
2389#define R_PPC_ADDR14_BRNTAKEN 9
2390#define R_PPC_REL24 10 /* PC relative 26 bit */
2391#define R_PPC_REL14 11 /* PC relative 16 bit */
2392#define R_PPC_REL14_BRTAKEN 12
2393#define R_PPC_REL14_BRNTAKEN 13
2394#define R_PPC_GOT16 14
2395#define R_PPC_GOT16_LO 15
2396#define R_PPC_GOT16_HI 16
2397#define R_PPC_GOT16_HA 17
2398#define R_PPC_PLTREL24 18
2399#define R_PPC_COPY 19
2400#define R_PPC_GLOB_DAT 20
2401#define R_PPC_JMP_SLOT 21
2402#define R_PPC_RELATIVE 22
2403#define R_PPC_LOCAL24PC 23
2404#define R_PPC_UADDR32 24
2405#define R_PPC_UADDR16 25
2406#define R_PPC_REL32 26
2407#define R_PPC_PLT32 27
2408#define R_PPC_PLTREL32 28
2409#define R_PPC_PLT16_LO 29
2410#define R_PPC_PLT16_HI 30
2411#define R_PPC_PLT16_HA 31
2412#define R_PPC_SDAREL16 32
2413#define R_PPC_SECTOFF 33
2414#define R_PPC_SECTOFF_LO 34
2415#define R_PPC_SECTOFF_HI 35
2416#define R_PPC_SECTOFF_HA 36
2417
2418/* PowerPC relocations defined for the TLS access ABI. */
2419#define R_PPC_TLS 67 /* none (sym+add)@tls */
2420#define R_PPC_DTPMOD32 68 /* word32 (sym+add)@dtpmod */
2421#define R_PPC_TPREL16 69 /* half16* (sym+add)@tprel */
2422#define R_PPC_TPREL16_LO 70 /* half16 (sym+add)@tprel@l */
2423#define R_PPC_TPREL16_HI 71 /* half16 (sym+add)@tprel@h */
2424#define R_PPC_TPREL16_HA 72 /* half16 (sym+add)@tprel@ha */
2425#define R_PPC_TPREL32 73 /* word32 (sym+add)@tprel */
2426#define R_PPC_DTPREL16 74 /* half16* (sym+add)@dtprel */
2427#define R_PPC_DTPREL16_LO 75 /* half16 (sym+add)@dtprel@l */
2428#define R_PPC_DTPREL16_HI 76 /* half16 (sym+add)@dtprel@h */
2429#define R_PPC_DTPREL16_HA 77 /* half16 (sym+add)@dtprel@ha */
2430#define R_PPC_DTPREL32 78 /* word32 (sym+add)@dtprel */
2431#define R_PPC_GOT_TLSGD16 79 /* half16* (sym+add)@got@tlsgd */
2432#define R_PPC_GOT_TLSGD16_LO 80 /* half16 (sym+add)@got@tlsgd@l */
2433#define R_PPC_GOT_TLSGD16_HI 81 /* half16 (sym+add)@got@tlsgd@h */
2434#define R_PPC_GOT_TLSGD16_HA 82 /* half16 (sym+add)@got@tlsgd@ha */
2435#define R_PPC_GOT_TLSLD16 83 /* half16* (sym+add)@got@tlsld */
2436#define R_PPC_GOT_TLSLD16_LO 84 /* half16 (sym+add)@got@tlsld@l */
2437#define R_PPC_GOT_TLSLD16_HI 85 /* half16 (sym+add)@got@tlsld@h */
2438#define R_PPC_GOT_TLSLD16_HA 86 /* half16 (sym+add)@got@tlsld@ha */
2439#define R_PPC_GOT_TPREL16 87 /* half16* (sym+add)@got@tprel */
2440#define R_PPC_GOT_TPREL16_LO 88 /* half16 (sym+add)@got@tprel@l */
2441#define R_PPC_GOT_TPREL16_HI 89 /* half16 (sym+add)@got@tprel@h */
2442#define R_PPC_GOT_TPREL16_HA 90 /* half16 (sym+add)@got@tprel@ha */
2443#define R_PPC_GOT_DTPREL16 91 /* half16* (sym+add)@got@dtprel */
2444#define R_PPC_GOT_DTPREL16_LO 92 /* half16* (sym+add)@got@dtprel@l */
2445#define R_PPC_GOT_DTPREL16_HI 93 /* half16* (sym+add)@got@dtprel@h */
2446#define R_PPC_GOT_DTPREL16_HA 94 /* half16* (sym+add)@got@dtprel@ha */
2447#define R_PPC_TLSGD 95 /* none (sym+add)@tlsgd */
2448#define R_PPC_TLSLD 96 /* none (sym+add)@tlsld */
2449
2450/* The remaining relocs are from the Embedded ELF ABI, and are not
2451 in the SVR4 ELF ABI. */
2452#define R_PPC_EMB_NADDR32 101
2453#define R_PPC_EMB_NADDR16 102
2454#define R_PPC_EMB_NADDR16_LO 103
2455#define R_PPC_EMB_NADDR16_HI 104
2456#define R_PPC_EMB_NADDR16_HA 105
2457#define R_PPC_EMB_SDAI16 106
2458#define R_PPC_EMB_SDA2I16 107
2459#define R_PPC_EMB_SDA2REL 108
2460#define R_PPC_EMB_SDA21 109 /* 16 bit offset in SDA */
2461#define R_PPC_EMB_MRKREF 110
2462#define R_PPC_EMB_RELSEC16 111
2463#define R_PPC_EMB_RELST_LO 112
2464#define R_PPC_EMB_RELST_HI 113
2465#define R_PPC_EMB_RELST_HA 114
2466#define R_PPC_EMB_BIT_FLD 115
2467#define R_PPC_EMB_RELSDA 116 /* 16 bit relative offset in SDA */
2468
2469/* Diab tool relocations. */
2470#define R_PPC_DIAB_SDA21_LO 180 /* like EMB_SDA21, but lower 16 bit */
2471#define R_PPC_DIAB_SDA21_HI 181 /* like EMB_SDA21, but high 16 bit */
2472#define R_PPC_DIAB_SDA21_HA 182 /* like EMB_SDA21, adjusted high 16 */
2473#define R_PPC_DIAB_RELSDA_LO 183 /* like EMB_RELSDA, but lower 16 bit */
2474#define R_PPC_DIAB_RELSDA_HI 184 /* like EMB_RELSDA, but high 16 bit */
2475#define R_PPC_DIAB_RELSDA_HA 185 /* like EMB_RELSDA, adjusted high 16 */
2476
2477/* GNU extension to support local ifunc. */
2478#define R_PPC_IRELATIVE 248
2479
2480/* GNU relocs used in PIC code sequences. */
2481#define R_PPC_REL16 249 /* half16 (sym+add-.) */
2482#define R_PPC_REL16_LO 250 /* half16 (sym+add-.)@l */
2483#define R_PPC_REL16_HI 251 /* half16 (sym+add-.)@h */
2484#define R_PPC_REL16_HA 252 /* half16 (sym+add-.)@ha */
2485
2486/* This is a phony reloc to handle any old fashioned TOC16 references
2487 that may still be in object files. */
2488#define R_PPC_TOC16 255
2489
2490/* PowerPC specific values for the Dyn d_tag field. */
2491#define DT_PPC_GOT (DT_LOPROC + 0)
2492#define DT_PPC_OPT (DT_LOPROC + 1)
2493#define DT_PPC_NUM 2
2494
2495/* PowerPC specific values for the DT_PPC_OPT Dyn entry. */
2496#define PPC_OPT_TLS 1
2497
2498/* PowerPC64 relocations defined by the ABIs */
2499#define R_PPC64_NONE R_PPC_NONE
2500#define R_PPC64_ADDR32 R_PPC_ADDR32 /* 32bit absolute address */
2501#define R_PPC64_ADDR24 R_PPC_ADDR24 /* 26bit address, word aligned */
2502#define R_PPC64_ADDR16 R_PPC_ADDR16 /* 16bit absolute address */
2503#define R_PPC64_ADDR16_LO R_PPC_ADDR16_LO /* lower 16bits of address */
2504#define R_PPC64_ADDR16_HI R_PPC_ADDR16_HI /* high 16bits of address. */
2505#define R_PPC64_ADDR16_HA R_PPC_ADDR16_HA /* adjusted high 16bits. */
2506#define R_PPC64_ADDR14 R_PPC_ADDR14 /* 16bit address, word aligned */
2507#define R_PPC64_ADDR14_BRTAKEN R_PPC_ADDR14_BRTAKEN
2508#define R_PPC64_ADDR14_BRNTAKEN R_PPC_ADDR14_BRNTAKEN
2509#define R_PPC64_REL24 R_PPC_REL24 /* PC-rel. 26 bit, word aligned */
2510#define R_PPC64_REL14 R_PPC_REL14 /* PC relative 16 bit */
2511#define R_PPC64_REL14_BRTAKEN R_PPC_REL14_BRTAKEN
2512#define R_PPC64_REL14_BRNTAKEN R_PPC_REL14_BRNTAKEN
2513#define R_PPC64_GOT16 R_PPC_GOT16
2514#define R_PPC64_GOT16_LO R_PPC_GOT16_LO
2515#define R_PPC64_GOT16_HI R_PPC_GOT16_HI
2516#define R_PPC64_GOT16_HA R_PPC_GOT16_HA
2517
2518#define R_PPC64_COPY R_PPC_COPY
2519#define R_PPC64_GLOB_DAT R_PPC_GLOB_DAT
2520#define R_PPC64_JMP_SLOT R_PPC_JMP_SLOT
2521#define R_PPC64_RELATIVE R_PPC_RELATIVE
2522
2523#define R_PPC64_UADDR32 R_PPC_UADDR32
2524#define R_PPC64_UADDR16 R_PPC_UADDR16
2525#define R_PPC64_REL32 R_PPC_REL32
2526#define R_PPC64_PLT32 R_PPC_PLT32
2527#define R_PPC64_PLTREL32 R_PPC_PLTREL32
2528#define R_PPC64_PLT16_LO R_PPC_PLT16_LO
2529#define R_PPC64_PLT16_HI R_PPC_PLT16_HI
2530#define R_PPC64_PLT16_HA R_PPC_PLT16_HA
2531
2532#define R_PPC64_SECTOFF R_PPC_SECTOFF
2533#define R_PPC64_SECTOFF_LO R_PPC_SECTOFF_LO
2534#define R_PPC64_SECTOFF_HI R_PPC_SECTOFF_HI
2535#define R_PPC64_SECTOFF_HA R_PPC_SECTOFF_HA
2536#define R_PPC64_ADDR30 37 /* word30 (S + A - P) >> 2 */
2537#define R_PPC64_ADDR64 38 /* doubleword64 S + A */
2538#define R_PPC64_ADDR16_HIGHER 39 /* half16 #higher(S + A) */
2539#define R_PPC64_ADDR16_HIGHERA 40 /* half16 #highera(S + A) */
2540#define R_PPC64_ADDR16_HIGHEST 41 /* half16 #highest(S + A) */
2541#define R_PPC64_ADDR16_HIGHESTA 42 /* half16 #highesta(S + A) */
2542#define R_PPC64_UADDR64 43 /* doubleword64 S + A */
2543#define R_PPC64_REL64 44 /* doubleword64 S + A - P */
2544#define R_PPC64_PLT64 45 /* doubleword64 L + A */
2545#define R_PPC64_PLTREL64 46 /* doubleword64 L + A - P */
2546#define R_PPC64_TOC16 47 /* half16* S + A - .TOC */
2547#define R_PPC64_TOC16_LO 48 /* half16 #lo(S + A - .TOC.) */
2548#define R_PPC64_TOC16_HI 49 /* half16 #hi(S + A - .TOC.) */
2549#define R_PPC64_TOC16_HA 50 /* half16 #ha(S + A - .TOC.) */
2550#define R_PPC64_TOC 51 /* doubleword64 .TOC */
2551#define R_PPC64_PLTGOT16 52 /* half16* M + A */
2552#define R_PPC64_PLTGOT16_LO 53 /* half16 #lo(M + A) */
2553#define R_PPC64_PLTGOT16_HI 54 /* half16 #hi(M + A) */
2554#define R_PPC64_PLTGOT16_HA 55 /* half16 #ha(M + A) */
2555
2556#define R_PPC64_ADDR16_DS 56 /* half16ds* (S + A) >> 2 */
2557#define R_PPC64_ADDR16_LO_DS 57 /* half16ds #lo(S + A) >> 2 */
2558#define R_PPC64_GOT16_DS 58 /* half16ds* (G + A) >> 2 */
2559#define R_PPC64_GOT16_LO_DS 59 /* half16ds #lo(G + A) >> 2 */
2560#define R_PPC64_PLT16_LO_DS 60 /* half16ds #lo(L + A) >> 2 */
2561#define R_PPC64_SECTOFF_DS 61 /* half16ds* (R + A) >> 2 */
2562#define R_PPC64_SECTOFF_LO_DS 62 /* half16ds #lo(R + A) >> 2 */
2563#define R_PPC64_TOC16_DS 63 /* half16ds* (S + A - .TOC.) >> 2 */
2564#define R_PPC64_TOC16_LO_DS 64 /* half16ds #lo(S + A - .TOC.) >> 2 */
2565#define R_PPC64_PLTGOT16_DS 65 /* half16ds* (M + A) >> 2 */
2566#define R_PPC64_PLTGOT16_LO_DS 66 /* half16ds #lo(M + A) >> 2 */
2567
2568/* PowerPC64 relocations defined for the TLS access ABI. */
2569#define R_PPC64_TLS 67 /* none (sym+add)@tls */
2570#define R_PPC64_DTPMOD64 68 /* doubleword64 (sym+add)@dtpmod */
2571#define R_PPC64_TPREL16 69 /* half16* (sym+add)@tprel */
2572#define R_PPC64_TPREL16_LO 70 /* half16 (sym+add)@tprel@l */
2573#define R_PPC64_TPREL16_HI 71 /* half16 (sym+add)@tprel@h */
2574#define R_PPC64_TPREL16_HA 72 /* half16 (sym+add)@tprel@ha */
2575#define R_PPC64_TPREL64 73 /* doubleword64 (sym+add)@tprel */
2576#define R_PPC64_DTPREL16 74 /* half16* (sym+add)@dtprel */
2577#define R_PPC64_DTPREL16_LO 75 /* half16 (sym+add)@dtprel@l */
2578#define R_PPC64_DTPREL16_HI 76 /* half16 (sym+add)@dtprel@h */
2579#define R_PPC64_DTPREL16_HA 77 /* half16 (sym+add)@dtprel@ha */
2580#define R_PPC64_DTPREL64 78 /* doubleword64 (sym+add)@dtprel */
2581#define R_PPC64_GOT_TLSGD16 79 /* half16* (sym+add)@got@tlsgd */
2582#define R_PPC64_GOT_TLSGD16_LO 80 /* half16 (sym+add)@got@tlsgd@l */
2583#define R_PPC64_GOT_TLSGD16_HI 81 /* half16 (sym+add)@got@tlsgd@h */
2584#define R_PPC64_GOT_TLSGD16_HA 82 /* half16 (sym+add)@got@tlsgd@ha */
2585#define R_PPC64_GOT_TLSLD16 83 /* half16* (sym+add)@got@tlsld */
2586#define R_PPC64_GOT_TLSLD16_LO 84 /* half16 (sym+add)@got@tlsld@l */
2587#define R_PPC64_GOT_TLSLD16_HI 85 /* half16 (sym+add)@got@tlsld@h */
2588#define R_PPC64_GOT_TLSLD16_HA 86 /* half16 (sym+add)@got@tlsld@ha */
2589#define R_PPC64_GOT_TPREL16_DS 87 /* half16ds* (sym+add)@got@tprel */
2590#define R_PPC64_GOT_TPREL16_LO_DS 88 /* half16ds (sym+add)@got@tprel@l */
2591#define R_PPC64_GOT_TPREL16_HI 89 /* half16 (sym+add)@got@tprel@h */
2592#define R_PPC64_GOT_TPREL16_HA 90 /* half16 (sym+add)@got@tprel@ha */
2593#define R_PPC64_GOT_DTPREL16_DS 91 /* half16ds* (sym+add)@got@dtprel */
2594#define R_PPC64_GOT_DTPREL16_LO_DS 92 /* half16ds (sym+add)@got@dtprel@l */
2595#define R_PPC64_GOT_DTPREL16_HI 93 /* half16 (sym+add)@got@dtprel@h */
2596#define R_PPC64_GOT_DTPREL16_HA 94 /* half16 (sym+add)@got@dtprel@ha */
2597#define R_PPC64_TPREL16_DS 95 /* half16ds* (sym+add)@tprel */
2598#define R_PPC64_TPREL16_LO_DS 96 /* half16ds (sym+add)@tprel@l */
2599#define R_PPC64_TPREL16_HIGHER 97 /* half16 (sym+add)@tprel@higher */
2600#define R_PPC64_TPREL16_HIGHERA 98 /* half16 (sym+add)@tprel@highera */
2601#define R_PPC64_TPREL16_HIGHEST 99 /* half16 (sym+add)@tprel@highest */
2602#define R_PPC64_TPREL16_HIGHESTA 100 /* half16 (sym+add)@tprel@highesta */
2603#define R_PPC64_DTPREL16_DS 101 /* half16ds* (sym+add)@dtprel */
2604#define R_PPC64_DTPREL16_LO_DS 102 /* half16ds (sym+add)@dtprel@l */
2605#define R_PPC64_DTPREL16_HIGHER 103 /* half16 (sym+add)@dtprel@higher */
2606#define R_PPC64_DTPREL16_HIGHERA 104 /* half16 (sym+add)@dtprel@highera */
2607#define R_PPC64_DTPREL16_HIGHEST 105 /* half16 (sym+add)@dtprel@highest */
2608#define R_PPC64_DTPREL16_HIGHESTA 106 /* half16 (sym+add)@dtprel@highesta */
2609#define R_PPC64_TLSGD 107 /* none (sym+add)@tlsgd */
2610#define R_PPC64_TLSLD 108 /* none (sym+add)@tlsld */
2611#define R_PPC64_TOCSAVE 109 /* none */
2612
2613/* Added when HA and HI relocs were changed to report overflows. */
2614#define R_PPC64_ADDR16_HIGH 110
2615#define R_PPC64_ADDR16_HIGHA 111
2616#define R_PPC64_TPREL16_HIGH 112
2617#define R_PPC64_TPREL16_HIGHA 113
2618#define R_PPC64_DTPREL16_HIGH 114
2619#define R_PPC64_DTPREL16_HIGHA 115
2620
2621/* GNU extension to support local ifunc. */
2622#define R_PPC64_JMP_IREL 247
2623#define R_PPC64_IRELATIVE 248
2624#define R_PPC64_REL16 249 /* half16 (sym+add-.) */
2625#define R_PPC64_REL16_LO 250 /* half16 (sym+add-.)@l */
2626#define R_PPC64_REL16_HI 251 /* half16 (sym+add-.)@h */
2627#define R_PPC64_REL16_HA 252 /* half16 (sym+add-.)@ha */
2628
2629/* e_flags bits specifying ABI.
2630 1 for original function descriptor using ABI,
2631 2 for revised ABI without function descriptors,
2632 0 for unspecified or not using any features affected by the differences. */
2633#define EF_PPC64_ABI 3
2634
2635/* PowerPC64 specific values for the Dyn d_tag field. */
2636#define DT_PPC64_GLINK (DT_LOPROC + 0)
2637#define DT_PPC64_OPD (DT_LOPROC + 1)
2638#define DT_PPC64_OPDSZ (DT_LOPROC + 2)
2639#define DT_PPC64_OPT (DT_LOPROC + 3)
2640#define DT_PPC64_NUM 4
2641
2642/* PowerPC64 specific bits in the DT_PPC64_OPT Dyn entry. */
2643#define PPC64_OPT_TLS 1
2644#define PPC64_OPT_MULTI_TOC 2
2645#define PPC64_OPT_LOCALENTRY 4
2646
2647/* PowerPC64 specific values for the Elf64_Sym st_other field. */
2648#define STO_PPC64_LOCAL_BIT 5
2649#define STO_PPC64_LOCAL_MASK (7 << STO_PPC64_LOCAL_BIT)
2650#define PPC64_LOCAL_ENTRY_OFFSET(other) \
2651 (((1 << (((other) & STO_PPC64_LOCAL_MASK) >> STO_PPC64_LOCAL_BIT)) >> 2) << 2)
2652
2653
2654/* ARM specific declarations */
2655
2656/* Processor specific flags for the ELF header e_flags field. */
2657#define EF_ARM_RELEXEC 0x01
2658#define EF_ARM_HASENTRY 0x02
2659#define EF_ARM_INTERWORK 0x04
2660#define EF_ARM_APCS_26 0x08
2661#define EF_ARM_APCS_FLOAT 0x10
2662#define EF_ARM_PIC 0x20
2663#define EF_ARM_ALIGN8 0x40 /* 8-bit structure alignment is in use */
2664#define EF_ARM_NEW_ABI 0x80
2665#define EF_ARM_OLD_ABI 0x100
2666#define EF_ARM_SOFT_FLOAT 0x200
2667#define EF_ARM_VFP_FLOAT 0x400
2668#define EF_ARM_MAVERICK_FLOAT 0x800
2669
2670#define EF_ARM_ABI_FLOAT_SOFT 0x200 /* NB conflicts with EF_ARM_SOFT_FLOAT */
2671#define EF_ARM_ABI_FLOAT_HARD 0x400 /* NB conflicts with EF_ARM_VFP_FLOAT */
2672
2673
2674/* Other constants defined in the ARM ELF spec. version B-01. */
2675/* NB. These conflict with values defined above. */
2676#define EF_ARM_SYMSARESORTED 0x04
2677#define EF_ARM_DYNSYMSUSESEGIDX 0x08
2678#define EF_ARM_MAPSYMSFIRST 0x10
2679#define EF_ARM_EABIMASK 0XFF000000
2680
2681/* Constants defined in AAELF. */
2682#define EF_ARM_BE8 0x00800000
2683#define EF_ARM_LE8 0x00400000
2684
2685#define EF_ARM_EABI_VERSION(flags) ((flags) & EF_ARM_EABIMASK)
2686#define EF_ARM_EABI_UNKNOWN 0x00000000
2687#define EF_ARM_EABI_VER1 0x01000000
2688#define EF_ARM_EABI_VER2 0x02000000
2689#define EF_ARM_EABI_VER3 0x03000000
2690#define EF_ARM_EABI_VER4 0x04000000
2691#define EF_ARM_EABI_VER5 0x05000000
2692
2693/* Additional symbol types for Thumb. */
2694#define STT_ARM_TFUNC STT_LOPROC /* A Thumb function. */
2695#define STT_ARM_16BIT STT_HIPROC /* A Thumb label. */
2696
2697/* ARM-specific values for sh_flags */
2698#define SHF_ARM_ENTRYSECT 0x10000000 /* Section contains an entry point */
2699#define SHF_ARM_COMDEF 0x80000000 /* Section may be multiply defined
2700 in the input to a link step. */
2701
2702/* ARM-specific program header flags */
2703#define PF_ARM_SB 0x10000000 /* Segment contains the location
2704 addressed by the static base. */
2705#define PF_ARM_PI 0x20000000 /* Position-independent segment. */
2706#define PF_ARM_ABS 0x40000000 /* Absolute segment. */
2707
2708/* Processor specific values for the Phdr p_type field. */
2709#define PT_ARM_EXIDX (PT_LOPROC + 1) /* ARM unwind segment. */
2710
2711/* Processor specific values for the Shdr sh_type field. */
2712#define SHT_ARM_EXIDX (SHT_LOPROC + 1) /* ARM unwind section. */
2713#define SHT_ARM_PREEMPTMAP (SHT_LOPROC + 2) /* Preemption details. */
2714#define SHT_ARM_ATTRIBUTES (SHT_LOPROC + 3) /* ARM attributes section. */
2715
2716
2717/* AArch64 relocs. */
2718
2719#define R_AARCH64_NONE 0 /* No relocation. */
2720
2721/* ILP32 AArch64 relocs. */
2722#define R_AARCH64_P32_ABS32 1 /* Direct 32 bit. */
2723#define R_AARCH64_P32_COPY 180 /* Copy symbol at runtime. */
2724#define R_AARCH64_P32_GLOB_DAT 181 /* Create GOT entry. */
2725#define R_AARCH64_P32_JUMP_SLOT 182 /* Create PLT entry. */
2726#define R_AARCH64_P32_RELATIVE 183 /* Adjust by program base. */
2727#define R_AARCH64_P32_TLS_DTPMOD 184 /* Module number, 32 bit. */
2728#define R_AARCH64_P32_TLS_DTPREL 185 /* Module-relative offset, 32 bit. */
2729#define R_AARCH64_P32_TLS_TPREL 186 /* TP-relative offset, 32 bit. */
2730#define R_AARCH64_P32_TLSDESC 187 /* TLS Descriptor. */
2731#define R_AARCH64_P32_IRELATIVE 188 /* STT_GNU_IFUNC relocation. */
2732
2733/* LP64 AArch64 relocs. */
2734#define R_AARCH64_ABS64 257 /* Direct 64 bit. */
2735#define R_AARCH64_ABS32 258 /* Direct 32 bit. */
2736#define R_AARCH64_ABS16 259 /* Direct 16-bit. */
2737#define R_AARCH64_PREL64 260 /* PC-relative 64-bit. */
2738#define R_AARCH64_PREL32 261 /* PC-relative 32-bit. */
2739#define R_AARCH64_PREL16 262 /* PC-relative 16-bit. */
2740#define R_AARCH64_MOVW_UABS_G0 263 /* Dir. MOVZ imm. from bits 15:0. */
2741#define R_AARCH64_MOVW_UABS_G0_NC 264 /* Likewise for MOVK; no check. */
2742#define R_AARCH64_MOVW_UABS_G1 265 /* Dir. MOVZ imm. from bits 31:16. */
2743#define R_AARCH64_MOVW_UABS_G1_NC 266 /* Likewise for MOVK; no check. */
2744#define R_AARCH64_MOVW_UABS_G2 267 /* Dir. MOVZ imm. from bits 47:32. */
2745#define R_AARCH64_MOVW_UABS_G2_NC 268 /* Likewise for MOVK; no check. */
2746#define R_AARCH64_MOVW_UABS_G3 269 /* Dir. MOV{K,Z} imm. from 63:48. */
2747#define R_AARCH64_MOVW_SABS_G0 270 /* Dir. MOV{N,Z} imm. from 15:0. */
2748#define R_AARCH64_MOVW_SABS_G1 271 /* Dir. MOV{N,Z} imm. from 31:16. */
2749#define R_AARCH64_MOVW_SABS_G2 272 /* Dir. MOV{N,Z} imm. from 47:32. */
2750#define R_AARCH64_LD_PREL_LO19 273 /* PC-rel. LD imm. from bits 20:2. */
2751#define R_AARCH64_ADR_PREL_LO21 274 /* PC-rel. ADR imm. from bits 20:0. */
2752#define R_AARCH64_ADR_PREL_PG_HI21 275 /* Page-rel. ADRP imm. from 32:12. */
2753#define R_AARCH64_ADR_PREL_PG_HI21_NC 276 /* Likewise; no overflow check. */
2754#define R_AARCH64_ADD_ABS_LO12_NC 277 /* Dir. ADD imm. from bits 11:0. */
2755#define R_AARCH64_LDST8_ABS_LO12_NC 278 /* Likewise for LD/ST; no check. */
2756#define R_AARCH64_TSTBR14 279 /* PC-rel. TBZ/TBNZ imm. from 15:2. */
2757#define R_AARCH64_CONDBR19 280 /* PC-rel. cond. br. imm. from 20:2. */
2758#define R_AARCH64_JUMP26 282 /* PC-rel. B imm. from bits 27:2. */
2759#define R_AARCH64_CALL26 283 /* Likewise for CALL. */
2760#define R_AARCH64_LDST16_ABS_LO12_NC 284 /* Dir. ADD imm. from bits 11:1. */
2761#define R_AARCH64_LDST32_ABS_LO12_NC 285 /* Likewise for bits 11:2. */
2762#define R_AARCH64_LDST64_ABS_LO12_NC 286 /* Likewise for bits 11:3. */
2763#define R_AARCH64_MOVW_PREL_G0 287 /* PC-rel. MOV{N,Z} imm. from 15:0. */
2764#define R_AARCH64_MOVW_PREL_G0_NC 288 /* Likewise for MOVK; no check. */
2765#define R_AARCH64_MOVW_PREL_G1 289 /* PC-rel. MOV{N,Z} imm. from 31:16. */
2766#define R_AARCH64_MOVW_PREL_G1_NC 290 /* Likewise for MOVK; no check. */
2767#define R_AARCH64_MOVW_PREL_G2 291 /* PC-rel. MOV{N,Z} imm. from 47:32. */
2768#define R_AARCH64_MOVW_PREL_G2_NC 292 /* Likewise for MOVK; no check. */
2769#define R_AARCH64_MOVW_PREL_G3 293 /* PC-rel. MOV{N,Z} imm. from 63:48. */
2770#define R_AARCH64_LDST128_ABS_LO12_NC 299 /* Dir. ADD imm. from bits 11:4. */
2771#define R_AARCH64_MOVW_GOTOFF_G0 300 /* GOT-rel. off. MOV{N,Z} imm. 15:0. */
2772#define R_AARCH64_MOVW_GOTOFF_G0_NC 301 /* Likewise for MOVK; no check. */
2773#define R_AARCH64_MOVW_GOTOFF_G1 302 /* GOT-rel. o. MOV{N,Z} imm. 31:16. */
2774#define R_AARCH64_MOVW_GOTOFF_G1_NC 303 /* Likewise for MOVK; no check. */
2775#define R_AARCH64_MOVW_GOTOFF_G2 304 /* GOT-rel. o. MOV{N,Z} imm. 47:32. */
2776#define R_AARCH64_MOVW_GOTOFF_G2_NC 305 /* Likewise for MOVK; no check. */
2777#define R_AARCH64_MOVW_GOTOFF_G3 306 /* GOT-rel. o. MOV{N,Z} imm. 63:48. */
2778#define R_AARCH64_GOTREL64 307 /* GOT-relative 64-bit. */
2779#define R_AARCH64_GOTREL32 308 /* GOT-relative 32-bit. */
2780#define R_AARCH64_GOT_LD_PREL19 309 /* PC-rel. GOT off. load imm. 20:2. */
2781#define R_AARCH64_LD64_GOTOFF_LO15 310 /* GOT-rel. off. LD/ST imm. 14:3. */
2782#define R_AARCH64_ADR_GOT_PAGE 311 /* P-page-rel. GOT off. ADRP 32:12. */
2783#define R_AARCH64_LD64_GOT_LO12_NC 312 /* Dir. GOT off. LD/ST imm. 11:3. */
2784#define R_AARCH64_LD64_GOTPAGE_LO15 313 /* GOT-page-rel. GOT off. LD/ST 14:3 */
2785#define R_AARCH64_TLSGD_ADR_PREL21 512 /* PC-relative ADR imm. 20:0. */
2786#define R_AARCH64_TLSGD_ADR_PAGE21 513 /* page-rel. ADRP imm. 32:12. */
2787#define R_AARCH64_TLSGD_ADD_LO12_NC 514 /* direct ADD imm. from 11:0. */
2788#define R_AARCH64_TLSGD_MOVW_G1 515 /* GOT-rel. MOV{N,Z} 31:16. */
2789#define R_AARCH64_TLSGD_MOVW_G0_NC 516 /* GOT-rel. MOVK imm. 15:0. */
2790#define R_AARCH64_TLSLD_ADR_PREL21 517 /* Like 512; local dynamic model. */
2791#define R_AARCH64_TLSLD_ADR_PAGE21 518 /* Like 513; local dynamic model. */
2792#define R_AARCH64_TLSLD_ADD_LO12_NC 519 /* Like 514; local dynamic model. */
2793#define R_AARCH64_TLSLD_MOVW_G1 520 /* Like 515; local dynamic model. */
2794#define R_AARCH64_TLSLD_MOVW_G0_NC 521 /* Like 516; local dynamic model. */
2795#define R_AARCH64_TLSLD_LD_PREL19 522 /* TLS PC-rel. load imm. 20:2. */
2796#define R_AARCH64_TLSLD_MOVW_DTPREL_G2 523 /* TLS DTP-rel. MOV{N,Z} 47:32. */
2797#define R_AARCH64_TLSLD_MOVW_DTPREL_G1 524 /* TLS DTP-rel. MOV{N,Z} 31:16. */
2798#define R_AARCH64_TLSLD_MOVW_DTPREL_G1_NC 525 /* Likewise; MOVK; no check. */
2799#define R_AARCH64_TLSLD_MOVW_DTPREL_G0 526 /* TLS DTP-rel. MOV{N,Z} 15:0. */
2800#define R_AARCH64_TLSLD_MOVW_DTPREL_G0_NC 527 /* Likewise; MOVK; no check. */
2801#define R_AARCH64_TLSLD_ADD_DTPREL_HI12 528 /* DTP-rel. ADD imm. from 23:12. */
2802#define R_AARCH64_TLSLD_ADD_DTPREL_LO12 529 /* DTP-rel. ADD imm. from 11:0. */
2803#define R_AARCH64_TLSLD_ADD_DTPREL_LO12_NC 530 /* Likewise; no ovfl. check. */
2804#define R_AARCH64_TLSLD_LDST8_DTPREL_LO12 531 /* DTP-rel. LD/ST imm. 11:0. */
2805#define R_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC 532 /* Likewise; no check. */
2806#define R_AARCH64_TLSLD_LDST16_DTPREL_LO12 533 /* DTP-rel. LD/ST imm. 11:1. */
2807#define R_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC 534 /* Likewise; no check. */
2808#define R_AARCH64_TLSLD_LDST32_DTPREL_LO12 535 /* DTP-rel. LD/ST imm. 11:2. */
2809#define R_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC 536 /* Likewise; no check. */
2810#define R_AARCH64_TLSLD_LDST64_DTPREL_LO12 537 /* DTP-rel. LD/ST imm. 11:3. */
2811#define R_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC 538 /* Likewise; no check. */
2812#define R_AARCH64_TLSIE_MOVW_GOTTPREL_G1 539 /* GOT-rel. MOV{N,Z} 31:16. */
2813#define R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC 540 /* GOT-rel. MOVK 15:0. */
2814#define R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21 541 /* Page-rel. ADRP 32:12. */
2815#define R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC 542 /* Direct LD off. 11:3. */
2816#define R_AARCH64_TLSIE_LD_GOTTPREL_PREL19 543 /* PC-rel. load imm. 20:2. */
2817#define R_AARCH64_TLSLE_MOVW_TPREL_G2 544 /* TLS TP-rel. MOV{N,Z} 47:32. */
2818#define R_AARCH64_TLSLE_MOVW_TPREL_G1 545 /* TLS TP-rel. MOV{N,Z} 31:16. */
2819#define R_AARCH64_TLSLE_MOVW_TPREL_G1_NC 546 /* Likewise; MOVK; no check. */
2820#define R_AARCH64_TLSLE_MOVW_TPREL_G0 547 /* TLS TP-rel. MOV{N,Z} 15:0. */
2821#define R_AARCH64_TLSLE_MOVW_TPREL_G0_NC 548 /* Likewise; MOVK; no check. */
2822#define R_AARCH64_TLSLE_ADD_TPREL_HI12 549 /* TP-rel. ADD imm. 23:12. */
2823#define R_AARCH64_TLSLE_ADD_TPREL_LO12 550 /* TP-rel. ADD imm. 11:0. */
2824#define R_AARCH64_TLSLE_ADD_TPREL_LO12_NC 551 /* Likewise; no ovfl. check. */
2825#define R_AARCH64_TLSLE_LDST8_TPREL_LO12 552 /* TP-rel. LD/ST off. 11:0. */
2826#define R_AARCH64_TLSLE_LDST8_TPREL_LO12_NC 553 /* Likewise; no ovfl. check. */
2827#define R_AARCH64_TLSLE_LDST16_TPREL_LO12 554 /* TP-rel. LD/ST off. 11:1. */
2828#define R_AARCH64_TLSLE_LDST16_TPREL_LO12_NC 555 /* Likewise; no check. */
2829#define R_AARCH64_TLSLE_LDST32_TPREL_LO12 556 /* TP-rel. LD/ST off. 11:2. */
2830#define R_AARCH64_TLSLE_LDST32_TPREL_LO12_NC 557 /* Likewise; no check. */
2831#define R_AARCH64_TLSLE_LDST64_TPREL_LO12 558 /* TP-rel. LD/ST off. 11:3. */
2832#define R_AARCH64_TLSLE_LDST64_TPREL_LO12_NC 559 /* Likewise; no check. */
2833#define R_AARCH64_TLSDESC_LD_PREL19 560 /* PC-rel. load immediate 20:2. */
2834#define R_AARCH64_TLSDESC_ADR_PREL21 561 /* PC-rel. ADR immediate 20:0. */
2835#define R_AARCH64_TLSDESC_ADR_PAGE21 562 /* Page-rel. ADRP imm. 32:12. */
2836#define R_AARCH64_TLSDESC_LD64_LO12 563 /* Direct LD off. from 11:3. */
2837#define R_AARCH64_TLSDESC_ADD_LO12 564 /* Direct ADD imm. from 11:0. */
2838#define R_AARCH64_TLSDESC_OFF_G1 565 /* GOT-rel. MOV{N,Z} imm. 31:16. */
2839#define R_AARCH64_TLSDESC_OFF_G0_NC 566 /* GOT-rel. MOVK imm. 15:0; no ck. */
2840#define R_AARCH64_TLSDESC_LDR 567 /* Relax LDR. */
2841#define R_AARCH64_TLSDESC_ADD 568 /* Relax ADD. */
2842#define R_AARCH64_TLSDESC_CALL 569 /* Relax BLR. */
2843#define R_AARCH64_TLSLE_LDST128_TPREL_LO12 570 /* TP-rel. LD/ST off. 11:4. */
2844#define R_AARCH64_TLSLE_LDST128_TPREL_LO12_NC 571 /* Likewise; no check. */
2845#define R_AARCH64_TLSLD_LDST128_DTPREL_LO12 572 /* DTP-rel. LD/ST imm. 11:4. */
2846#define R_AARCH64_TLSLD_LDST128_DTPREL_LO12_NC 573 /* Likewise; no check. */
2847#define R_AARCH64_COPY 1024 /* Copy symbol at runtime. */
2848#define R_AARCH64_GLOB_DAT 1025 /* Create GOT entry. */
2849#define R_AARCH64_JUMP_SLOT 1026 /* Create PLT entry. */
2850#define R_AARCH64_RELATIVE 1027 /* Adjust by program base. */
2851#define R_AARCH64_TLS_DTPMOD 1028 /* Module number, 64 bit. */
2852#define R_AARCH64_TLS_DTPREL 1029 /* Module-relative offset, 64 bit. */
2853#define R_AARCH64_TLS_TPREL 1030 /* TP-relative offset, 64 bit. */
2854#define R_AARCH64_TLSDESC 1031 /* TLS Descriptor. */
2855#define R_AARCH64_IRELATIVE 1032 /* STT_GNU_IFUNC relocation. */
2856
2857/* ARM relocs. */
2858
2859#define R_ARM_NONE 0 /* No reloc */
2860#define R_ARM_PC24 1 /* Deprecated PC relative 26
2861 bit branch. */
2862#define R_ARM_ABS32 2 /* Direct 32 bit */
2863#define R_ARM_REL32 3 /* PC relative 32 bit */
2864#define R_ARM_PC13 4
2865#define R_ARM_ABS16 5 /* Direct 16 bit */
2866#define R_ARM_ABS12 6 /* Direct 12 bit */
2867#define R_ARM_THM_ABS5 7 /* Direct & 0x7C (LDR, STR). */
2868#define R_ARM_ABS8 8 /* Direct 8 bit */
2869#define R_ARM_SBREL32 9
2870#define R_ARM_THM_PC22 10 /* PC relative 24 bit (Thumb32 BL). */
2871#define R_ARM_THM_PC8 11 /* PC relative & 0x3FC
2872 (Thumb16 LDR, ADD, ADR). */
2873#define R_ARM_AMP_VCALL9 12
2874#define R_ARM_SWI24 13 /* Obsolete static relocation. */
2875#define R_ARM_TLS_DESC 13 /* Dynamic relocation. */
2876#define R_ARM_THM_SWI8 14 /* Reserved. */
2877#define R_ARM_XPC25 15 /* Reserved. */
2878#define R_ARM_THM_XPC22 16 /* Reserved. */
2879#define R_ARM_TLS_DTPMOD32 17 /* ID of module containing symbol */
2880#define R_ARM_TLS_DTPOFF32 18 /* Offset in TLS block */
2881#define R_ARM_TLS_TPOFF32 19 /* Offset in static TLS block */
2882#define R_ARM_COPY 20 /* Copy symbol at runtime */
2883#define R_ARM_GLOB_DAT 21 /* Create GOT entry */
2884#define R_ARM_JUMP_SLOT 22 /* Create PLT entry */
2885#define R_ARM_RELATIVE 23 /* Adjust by program base */
2886#define R_ARM_GOTOFF 24 /* 32 bit offset to GOT */
2887#define R_ARM_GOTPC 25 /* 32 bit PC relative offset to GOT */
2888#define R_ARM_GOT32 26 /* 32 bit GOT entry */
2889#define R_ARM_PLT32 27 /* Deprecated, 32 bit PLT address. */
2890#define R_ARM_CALL 28 /* PC relative 24 bit (BL, BLX). */
2891#define R_ARM_JUMP24 29 /* PC relative 24 bit
2892 (B, BL<cond>). */
2893#define R_ARM_THM_JUMP24 30 /* PC relative 24 bit (Thumb32 B.W). */
2894#define R_ARM_BASE_ABS 31 /* Adjust by program base. */
2895#define R_ARM_ALU_PCREL_7_0 32 /* Obsolete. */
2896#define R_ARM_ALU_PCREL_15_8 33 /* Obsolete. */
2897#define R_ARM_ALU_PCREL_23_15 34 /* Obsolete. */
2898#define R_ARM_LDR_SBREL_11_0 35 /* Deprecated, prog. base relative. */
2899#define R_ARM_ALU_SBREL_19_12 36 /* Deprecated, prog. base relative. */
2900#define R_ARM_ALU_SBREL_27_20 37 /* Deprecated, prog. base relative. */
2901#define R_ARM_TARGET1 38
2902#define R_ARM_SBREL31 39 /* Program base relative. */
2903#define R_ARM_V4BX 40
2904#define R_ARM_TARGET2 41
2905#define R_ARM_PREL31 42 /* 32 bit PC relative. */
2906#define R_ARM_MOVW_ABS_NC 43 /* Direct 16-bit (MOVW). */
2907#define R_ARM_MOVT_ABS 44 /* Direct high 16-bit (MOVT). */
2908#define R_ARM_MOVW_PREL_NC 45 /* PC relative 16-bit (MOVW). */
2909#define R_ARM_MOVT_PREL 46 /* PC relative (MOVT). */
2910#define R_ARM_THM_MOVW_ABS_NC 47 /* Direct 16 bit (Thumb32 MOVW). */
2911#define R_ARM_THM_MOVT_ABS 48 /* Direct high 16 bit
2912 (Thumb32 MOVT). */
2913#define R_ARM_THM_MOVW_PREL_NC 49 /* PC relative 16 bit
2914 (Thumb32 MOVW). */
2915#define R_ARM_THM_MOVT_PREL 50 /* PC relative high 16 bit
2916 (Thumb32 MOVT). */
2917#define R_ARM_THM_JUMP19 51 /* PC relative 20 bit
2918 (Thumb32 B<cond>.W). */
2919#define R_ARM_THM_JUMP6 52 /* PC relative X & 0x7E
2920 (Thumb16 CBZ, CBNZ). */
2921#define R_ARM_THM_ALU_PREL_11_0 53 /* PC relative 12 bit
2922 (Thumb32 ADR.W). */
2923#define R_ARM_THM_PC12 54 /* PC relative 12 bit
2924 (Thumb32 LDR{D,SB,H,SH}). */
2925#define R_ARM_ABS32_NOI 55 /* Direct 32-bit. */
2926#define R_ARM_REL32_NOI 56 /* PC relative 32-bit. */
2927#define R_ARM_ALU_PC_G0_NC 57 /* PC relative (ADD, SUB). */
2928#define R_ARM_ALU_PC_G0 58 /* PC relative (ADD, SUB). */
2929#define R_ARM_ALU_PC_G1_NC 59 /* PC relative (ADD, SUB). */
2930#define R_ARM_ALU_PC_G1 60 /* PC relative (ADD, SUB). */
2931#define R_ARM_ALU_PC_G2 61 /* PC relative (ADD, SUB). */
2932#define R_ARM_LDR_PC_G1 62 /* PC relative (LDR,STR,LDRB,STRB). */
2933#define R_ARM_LDR_PC_G2 63 /* PC relative (LDR,STR,LDRB,STRB). */
2934#define R_ARM_LDRS_PC_G0 64 /* PC relative (STR{D,H},
2935 LDR{D,SB,H,SH}). */
2936#define R_ARM_LDRS_PC_G1 65 /* PC relative (STR{D,H},
2937 LDR{D,SB,H,SH}). */
2938#define R_ARM_LDRS_PC_G2 66 /* PC relative (STR{D,H},
2939 LDR{D,SB,H,SH}). */
2940#define R_ARM_LDC_PC_G0 67 /* PC relative (LDC, STC). */
2941#define R_ARM_LDC_PC_G1 68 /* PC relative (LDC, STC). */
2942#define R_ARM_LDC_PC_G2 69 /* PC relative (LDC, STC). */
2943#define R_ARM_ALU_SB_G0_NC 70 /* Program base relative (ADD,SUB). */
2944#define R_ARM_ALU_SB_G0 71 /* Program base relative (ADD,SUB). */
2945#define R_ARM_ALU_SB_G1_NC 72 /* Program base relative (ADD,SUB). */
2946#define R_ARM_ALU_SB_G1 73 /* Program base relative (ADD,SUB). */
2947#define R_ARM_ALU_SB_G2 74 /* Program base relative (ADD,SUB). */
2948#define R_ARM_LDR_SB_G0 75 /* Program base relative (LDR,
2949 STR, LDRB, STRB). */
2950#define R_ARM_LDR_SB_G1 76 /* Program base relative
2951 (LDR, STR, LDRB, STRB). */
2952#define R_ARM_LDR_SB_G2 77 /* Program base relative
2953 (LDR, STR, LDRB, STRB). */
2954#define R_ARM_LDRS_SB_G0 78 /* Program base relative
2955 (LDR, STR, LDRB, STRB). */
2956#define R_ARM_LDRS_SB_G1 79 /* Program base relative
2957 (LDR, STR, LDRB, STRB). */
2958#define R_ARM_LDRS_SB_G2 80 /* Program base relative
2959 (LDR, STR, LDRB, STRB). */
2960#define R_ARM_LDC_SB_G0 81 /* Program base relative (LDC,STC). */
2961#define R_ARM_LDC_SB_G1 82 /* Program base relative (LDC,STC). */
2962#define R_ARM_LDC_SB_G2 83 /* Program base relative (LDC,STC). */
2963#define R_ARM_MOVW_BREL_NC 84 /* Program base relative 16
2964 bit (MOVW). */
2965#define R_ARM_MOVT_BREL 85 /* Program base relative high
2966 16 bit (MOVT). */
2967#define R_ARM_MOVW_BREL 86 /* Program base relative 16
2968 bit (MOVW). */
2969#define R_ARM_THM_MOVW_BREL_NC 87 /* Program base relative 16
2970 bit (Thumb32 MOVW). */
2971#define R_ARM_THM_MOVT_BREL 88 /* Program base relative high
2972 16 bit (Thumb32 MOVT). */
2973#define R_ARM_THM_MOVW_BREL 89 /* Program base relative 16
2974 bit (Thumb32 MOVW). */
2975#define R_ARM_TLS_GOTDESC 90
2976#define R_ARM_TLS_CALL 91
2977#define R_ARM_TLS_DESCSEQ 92 /* TLS relaxation. */
2978#define R_ARM_THM_TLS_CALL 93
2979#define R_ARM_PLT32_ABS 94
2980#define R_ARM_GOT_ABS 95 /* GOT entry. */
2981#define R_ARM_GOT_PREL 96 /* PC relative GOT entry. */
2982#define R_ARM_GOT_BREL12 97 /* GOT entry relative to GOT
2983 origin (LDR). */
2984#define R_ARM_GOTOFF12 98 /* 12 bit, GOT entry relative
2985 to GOT origin (LDR, STR). */
2986#define R_ARM_GOTRELAX 99
2987#define R_ARM_GNU_VTENTRY 100
2988#define R_ARM_GNU_VTINHERIT 101
2989#define R_ARM_THM_PC11 102 /* PC relative & 0xFFE (Thumb16 B). */
2990#define R_ARM_THM_PC9 103 /* PC relative & 0x1FE
2991 (Thumb16 B/B<cond>). */
2992#define R_ARM_TLS_GD32 104 /* PC-rel 32 bit for global dynamic
2993 thread local data */
2994#define R_ARM_TLS_LDM32 105 /* PC-rel 32 bit for local dynamic
2995 thread local data */
2996#define R_ARM_TLS_LDO32 106 /* 32 bit offset relative to TLS
2997 block */
2998#define R_ARM_TLS_IE32 107 /* PC-rel 32 bit for GOT entry of
2999 static TLS block offset */
3000#define R_ARM_TLS_LE32 108 /* 32 bit offset relative to static
3001 TLS block */
3002#define R_ARM_TLS_LDO12 109 /* 12 bit relative to TLS
3003 block (LDR, STR). */
3004#define R_ARM_TLS_LE12 110 /* 12 bit relative to static
3005 TLS block (LDR, STR). */
3006#define R_ARM_TLS_IE12GP 111 /* 12 bit GOT entry relative
3007 to GOT origin (LDR). */
3008#define R_ARM_ME_TOO 128 /* Obsolete. */
3009#define R_ARM_THM_TLS_DESCSEQ 129
3010#define R_ARM_THM_TLS_DESCSEQ16 129
3011#define R_ARM_THM_TLS_DESCSEQ32 130
3012#define R_ARM_THM_GOT_BREL12 131 /* GOT entry relative to GOT
3013 origin, 12 bit (Thumb32 LDR). */
3014#define R_ARM_IRELATIVE 160
3015#define R_ARM_RXPC25 249
3016#define R_ARM_RSBREL32 250
3017#define R_ARM_THM_RPC22 251
3018#define R_ARM_RREL32 252
3019#define R_ARM_RABS22 253
3020#define R_ARM_RPC24 254
3021#define R_ARM_RBASE 255
3022/* Keep this the last entry. */
3023#define R_ARM_NUM 256
3024
3025/* csky */
3026#define R_CKCORE_NONE 0 /* no reloc */
3027#define R_CKCORE_ADDR32 1 /* direct 32 bit (S + A) */
3028#define R_CKCORE_PCRELIMM8BY4 2 /* disp ((S + A - P) >> 2) & 0xff */
3029#define R_CKCORE_PCRELIMM11BY2 3 /* disp ((S + A - P) >> 1) & 0x7ff */
3030#define R_CKCORE_PCREL32 5 /* 32-bit rel (S + A - P) */
3031#define R_CKCORE_PCRELJSR_IMM11BY2 6 /* disp ((S + A - P) >>1) & 0x7ff */
3032#define R_CKCORE_RELATIVE 9 /* 32 bit adjust program base(B + A)*/
3033#define R_CKCORE_COPY 10 /* 32 bit adjust by program base */
3034#define R_CKCORE_GLOB_DAT 11 /* off between got and sym (S) */
3035#define R_CKCORE_JUMP_SLOT 12 /* PLT entry (S) */
3036#define R_CKCORE_GOTOFF 13 /* offset to GOT (S + A - GOT) */
3037#define R_CKCORE_GOTPC 14 /* PC offset to GOT (GOT + A - P) */
3038#define R_CKCORE_GOT32 15 /* 32 bit GOT entry (G) */
3039#define R_CKCORE_PLT32 16 /* 32 bit PLT entry (G) */
3040#define R_CKCORE_ADDRGOT 17 /* GOT entry in GLOB_DAT (GOT + G) */
3041#define R_CKCORE_ADDRPLT 18 /* PLT entry in GLOB_DAT (GOT + G) */
3042#define R_CKCORE_PCREL_IMM26BY2 19 /* ((S + A - P) >> 1) & 0x3ffffff */
3043#define R_CKCORE_PCREL_IMM16BY2 20 /* disp ((S + A - P) >> 1) & 0xffff */
3044#define R_CKCORE_PCREL_IMM16BY4 21 /* disp ((S + A - P) >> 2) & 0xffff */
3045#define R_CKCORE_PCREL_IMM10BY2 22 /* disp ((S + A - P) >> 1) & 0x3ff */
3046#define R_CKCORE_PCREL_IMM10BY4 23 /* disp ((S + A - P) >> 2) & 0x3ff */
3047#define R_CKCORE_ADDR_HI16 24 /* high & low 16 bit ADDR */
3048 /* ((S + A) >> 16) & 0xffff */
3049#define R_CKCORE_ADDR_LO16 25 /* (S + A) & 0xffff */
3050#define R_CKCORE_GOTPC_HI16 26 /* high & low 16 bit GOTPC */
3051 /* ((GOT + A - P) >> 16) & 0xffff */
3052#define R_CKCORE_GOTPC_LO16 27 /* (GOT + A - P) & 0xffff */
3053#define R_CKCORE_GOTOFF_HI16 28 /* high & low 16 bit GOTOFF */
3054 /* ((S + A - GOT) >> 16) & 0xffff */
3055#define R_CKCORE_GOTOFF_LO16 29 /* (S + A - GOT) & 0xffff */
3056#define R_CKCORE_GOT12 30 /* 12 bit disp GOT entry (G) */
3057#define R_CKCORE_GOT_HI16 31 /* high & low 16 bit GOT */
3058 /* (G >> 16) & 0xffff */
3059#define R_CKCORE_GOT_LO16 32 /* (G & 0xffff) */
3060#define R_CKCORE_PLT12 33 /* 12 bit disp PLT entry (G) */
3061#define R_CKCORE_PLT_HI16 34 /* high & low 16 bit PLT */
3062 /* (G >> 16) & 0xffff */
3063#define R_CKCORE_PLT_LO16 35 /* G & 0xffff */
3064#define R_CKCORE_ADDRGOT_HI16 36 /* high & low 16 bit ADDRGOT */
3065 /* (GOT + G * 4) & 0xffff */
3066#define R_CKCORE_ADDRGOT_LO16 37 /* (GOT + G * 4) & 0xffff */
3067#define R_CKCORE_ADDRPLT_HI16 38 /* high & low 16 bit ADDRPLT */
3068 /* ((GOT + G * 4) >> 16) & 0xFFFF */
3069#define R_CKCORE_ADDRPLT_LO16 39 /* (GOT+G*4) & 0xffff */
3070#define R_CKCORE_PCREL_JSR_IMM26BY2 40 /* disp ((S+A-P) >>1) & x3ffffff */
3071#define R_CKCORE_TOFFSET_LO16 41 /* (S+A-BTEXT) & 0xffff */
3072#define R_CKCORE_DOFFSET_LO16 42 /* (S+A-BTEXT) & 0xffff */
3073#define R_CKCORE_PCREL_IMM18BY2 43 /* disp ((S+A-P) >>1) & 0x3ffff */
3074#define R_CKCORE_DOFFSET_IMM18 44 /* disp (S+A-BDATA) & 0x3ffff */
3075#define R_CKCORE_DOFFSET_IMM18BY2 45 /* disp ((S+A-BDATA)>>1) & 0x3ffff */
3076#define R_CKCORE_DOFFSET_IMM18BY4 46 /* disp ((S+A-BDATA)>>2) & 0x3ffff */
3077#define R_CKCORE_GOT_IMM18BY4 48 /* disp (G >> 2) */
3078#define R_CKCORE_PLT_IMM18BY4 49 /* disp (G >> 2) */
3079#define R_CKCORE_PCREL_IMM7BY4 50 /* disp ((S+A-P) >>2) & 0x7f */
3080#define R_CKCORE_TLS_LE32 51 /* 32 bit offset to TLS block */
3081#define R_CKCORE_TLS_IE32 52
3082#define R_CKCORE_TLS_GD32 53
3083#define R_CKCORE_TLS_LDM32 54
3084#define R_CKCORE_TLS_LDO32 55
3085#define R_CKCORE_TLS_DTPMOD32 56
3086#define R_CKCORE_TLS_DTPOFF32 57
3087#define R_CKCORE_TLS_TPOFF32 58
3088
3089/* IA-64 specific declarations. */
3090
3091/* Processor specific flags for the Ehdr e_flags field. */
3092#define EF_IA_64_MASKOS 0x0000000f /* os-specific flags */
3093#define EF_IA_64_ABI64 0x00000010 /* 64-bit ABI */
3094#define EF_IA_64_ARCH 0xff000000 /* arch. version mask */
3095
3096/* Processor specific values for the Phdr p_type field. */
3097#define PT_IA_64_ARCHEXT (PT_LOPROC + 0) /* arch extension bits */
3098#define PT_IA_64_UNWIND (PT_LOPROC + 1) /* ia64 unwind bits */
3099#define PT_IA_64_HP_OPT_ANOT (PT_LOOS + 0x12)
3100#define PT_IA_64_HP_HSL_ANOT (PT_LOOS + 0x13)
3101#define PT_IA_64_HP_STACK (PT_LOOS + 0x14)
3102
3103/* Processor specific flags for the Phdr p_flags field. */
3104#define PF_IA_64_NORECOV 0x80000000 /* spec insns w/o recovery */
3105
3106/* Processor specific values for the Shdr sh_type field. */
3107#define SHT_IA_64_EXT (SHT_LOPROC + 0) /* extension bits */
3108#define SHT_IA_64_UNWIND (SHT_LOPROC + 1) /* unwind bits */
3109
3110/* Processor specific flags for the Shdr sh_flags field. */
3111#define SHF_IA_64_SHORT 0x10000000 /* section near gp */
3112#define SHF_IA_64_NORECOV 0x20000000 /* spec insns w/o recovery */
3113
3114/* Processor specific values for the Dyn d_tag field. */
3115#define DT_IA_64_PLT_RESERVE (DT_LOPROC + 0)
3116#define DT_IA_64_NUM 1
3117
3118/* IA-64 relocations. */
3119#define R_IA64_NONE 0x00 /* none */
3120#define R_IA64_IMM14 0x21 /* symbol + addend, add imm14 */
3121#define R_IA64_IMM22 0x22 /* symbol + addend, add imm22 */
3122#define R_IA64_IMM64 0x23 /* symbol + addend, mov imm64 */
3123#define R_IA64_DIR32MSB 0x24 /* symbol + addend, data4 MSB */
3124#define R_IA64_DIR32LSB 0x25 /* symbol + addend, data4 LSB */
3125#define R_IA64_DIR64MSB 0x26 /* symbol + addend, data8 MSB */
3126#define R_IA64_DIR64LSB 0x27 /* symbol + addend, data8 LSB */
3127#define R_IA64_GPREL22 0x2a /* @gprel(sym + add), add imm22 */
3128#define R_IA64_GPREL64I 0x2b /* @gprel(sym + add), mov imm64 */
3129#define R_IA64_GPREL32MSB 0x2c /* @gprel(sym + add), data4 MSB */
3130#define R_IA64_GPREL32LSB 0x2d /* @gprel(sym + add), data4 LSB */
3131#define R_IA64_GPREL64MSB 0x2e /* @gprel(sym + add), data8 MSB */
3132#define R_IA64_GPREL64LSB 0x2f /* @gprel(sym + add), data8 LSB */
3133#define R_IA64_LTOFF22 0x32 /* @ltoff(sym + add), add imm22 */
3134#define R_IA64_LTOFF64I 0x33 /* @ltoff(sym + add), mov imm64 */
3135#define R_IA64_PLTOFF22 0x3a /* @pltoff(sym + add), add imm22 */
3136#define R_IA64_PLTOFF64I 0x3b /* @pltoff(sym + add), mov imm64 */
3137#define R_IA64_PLTOFF64MSB 0x3e /* @pltoff(sym + add), data8 MSB */
3138#define R_IA64_PLTOFF64LSB 0x3f /* @pltoff(sym + add), data8 LSB */
3139#define R_IA64_FPTR64I 0x43 /* @fptr(sym + add), mov imm64 */
3140#define R_IA64_FPTR32MSB 0x44 /* @fptr(sym + add), data4 MSB */
3141#define R_IA64_FPTR32LSB 0x45 /* @fptr(sym + add), data4 LSB */
3142#define R_IA64_FPTR64MSB 0x46 /* @fptr(sym + add), data8 MSB */
3143#define R_IA64_FPTR64LSB 0x47 /* @fptr(sym + add), data8 LSB */
3144#define R_IA64_PCREL60B 0x48 /* @pcrel(sym + add), brl */
3145#define R_IA64_PCREL21B 0x49 /* @pcrel(sym + add), ptb, call */
3146#define R_IA64_PCREL21M 0x4a /* @pcrel(sym + add), chk.s */
3147#define R_IA64_PCREL21F 0x4b /* @pcrel(sym + add), fchkf */
3148#define R_IA64_PCREL32MSB 0x4c /* @pcrel(sym + add), data4 MSB */
3149#define R_IA64_PCREL32LSB 0x4d /* @pcrel(sym + add), data4 LSB */
3150#define R_IA64_PCREL64MSB 0x4e /* @pcrel(sym + add), data8 MSB */
3151#define R_IA64_PCREL64LSB 0x4f /* @pcrel(sym + add), data8 LSB */
3152#define R_IA64_LTOFF_FPTR22 0x52 /* @ltoff(@fptr(s+a)), imm22 */
3153#define R_IA64_LTOFF_FPTR64I 0x53 /* @ltoff(@fptr(s+a)), imm64 */
3154#define R_IA64_LTOFF_FPTR32MSB 0x54 /* @ltoff(@fptr(s+a)), data4 MSB */
3155#define R_IA64_LTOFF_FPTR32LSB 0x55 /* @ltoff(@fptr(s+a)), data4 LSB */
3156#define R_IA64_LTOFF_FPTR64MSB 0x56 /* @ltoff(@fptr(s+a)), data8 MSB */
3157#define R_IA64_LTOFF_FPTR64LSB 0x57 /* @ltoff(@fptr(s+a)), data8 LSB */
3158#define R_IA64_SEGREL32MSB 0x5c /* @segrel(sym + add), data4 MSB */
3159#define R_IA64_SEGREL32LSB 0x5d /* @segrel(sym + add), data4 LSB */
3160#define R_IA64_SEGREL64MSB 0x5e /* @segrel(sym + add), data8 MSB */
3161#define R_IA64_SEGREL64LSB 0x5f /* @segrel(sym + add), data8 LSB */
3162#define R_IA64_SECREL32MSB 0x64 /* @secrel(sym + add), data4 MSB */
3163#define R_IA64_SECREL32LSB 0x65 /* @secrel(sym + add), data4 LSB */
3164#define R_IA64_SECREL64MSB 0x66 /* @secrel(sym + add), data8 MSB */
3165#define R_IA64_SECREL64LSB 0x67 /* @secrel(sym + add), data8 LSB */
3166#define R_IA64_REL32MSB 0x6c /* data 4 + REL */
3167#define R_IA64_REL32LSB 0x6d /* data 4 + REL */
3168#define R_IA64_REL64MSB 0x6e /* data 8 + REL */
3169#define R_IA64_REL64LSB 0x6f /* data 8 + REL */
3170#define R_IA64_LTV32MSB 0x74 /* symbol + addend, data4 MSB */
3171#define R_IA64_LTV32LSB 0x75 /* symbol + addend, data4 LSB */
3172#define R_IA64_LTV64MSB 0x76 /* symbol + addend, data8 MSB */
3173#define R_IA64_LTV64LSB 0x77 /* symbol + addend, data8 LSB */
3174#define R_IA64_PCREL21BI 0x79 /* @pcrel(sym + add), 21bit inst */
3175#define R_IA64_PCREL22 0x7a /* @pcrel(sym + add), 22bit inst */
3176#define R_IA64_PCREL64I 0x7b /* @pcrel(sym + add), 64bit inst */
3177#define R_IA64_IPLTMSB 0x80 /* dynamic reloc, imported PLT, MSB */
3178#define R_IA64_IPLTLSB 0x81 /* dynamic reloc, imported PLT, LSB */
3179#define R_IA64_COPY 0x84 /* copy relocation */
3180#define R_IA64_SUB 0x85 /* Addend and symbol difference */
3181#define R_IA64_LTOFF22X 0x86 /* LTOFF22, relaxable. */
3182#define R_IA64_LDXMOV 0x87 /* Use of LTOFF22X. */
3183#define R_IA64_TPREL14 0x91 /* @tprel(sym + add), imm14 */
3184#define R_IA64_TPREL22 0x92 /* @tprel(sym + add), imm22 */
3185#define R_IA64_TPREL64I 0x93 /* @tprel(sym + add), imm64 */
3186#define R_IA64_TPREL64MSB 0x96 /* @tprel(sym + add), data8 MSB */
3187#define R_IA64_TPREL64LSB 0x97 /* @tprel(sym + add), data8 LSB */
3188#define R_IA64_LTOFF_TPREL22 0x9a /* @ltoff(@tprel(s+a)), imm2 */
3189#define R_IA64_DTPMOD64MSB 0xa6 /* @dtpmod(sym + add), data8 MSB */
3190#define R_IA64_DTPMOD64LSB 0xa7 /* @dtpmod(sym + add), data8 LSB */
3191#define R_IA64_LTOFF_DTPMOD22 0xaa /* @ltoff(@dtpmod(sym + add)), imm22 */
3192#define R_IA64_DTPREL14 0xb1 /* @dtprel(sym + add), imm14 */
3193#define R_IA64_DTPREL22 0xb2 /* @dtprel(sym + add), imm22 */
3194#define R_IA64_DTPREL64I 0xb3 /* @dtprel(sym + add), imm64 */
3195#define R_IA64_DTPREL32MSB 0xb4 /* @dtprel(sym + add), data4 MSB */
3196#define R_IA64_DTPREL32LSB 0xb5 /* @dtprel(sym + add), data4 LSB */
3197#define R_IA64_DTPREL64MSB 0xb6 /* @dtprel(sym + add), data8 MSB */
3198#define R_IA64_DTPREL64LSB 0xb7 /* @dtprel(sym + add), data8 LSB */
3199#define R_IA64_LTOFF_DTPREL22 0xba /* @ltoff(@dtprel(s+a)), imm22 */
3200
3201/* SH specific declarations */
3202
3203/* Processor specific flags for the ELF header e_flags field. */
3204#define EF_SH_MACH_MASK 0x1f
3205#define EF_SH_UNKNOWN 0x0
3206#define EF_SH1 0x1
3207#define EF_SH2 0x2
3208#define EF_SH3 0x3
3209#define EF_SH_DSP 0x4
3210#define EF_SH3_DSP 0x5
3211#define EF_SH4AL_DSP 0x6
3212#define EF_SH3E 0x8
3213#define EF_SH4 0x9
3214#define EF_SH2E 0xb
3215#define EF_SH4A 0xc
3216#define EF_SH2A 0xd
3217#define EF_SH4_NOFPU 0x10
3218#define EF_SH4A_NOFPU 0x11
3219#define EF_SH4_NOMMU_NOFPU 0x12
3220#define EF_SH2A_NOFPU 0x13
3221#define EF_SH3_NOMMU 0x14
3222#define EF_SH2A_SH4_NOFPU 0x15
3223#define EF_SH2A_SH3_NOFPU 0x16
3224#define EF_SH2A_SH4 0x17
3225#define EF_SH2A_SH3E 0x18
3226
3227/* SH relocs. */
3228#define R_SH_NONE 0
3229#define R_SH_DIR32 1
3230#define R_SH_REL32 2
3231#define R_SH_DIR8WPN 3
3232#define R_SH_IND12W 4
3233#define R_SH_DIR8WPL 5
3234#define R_SH_DIR8WPZ 6
3235#define R_SH_DIR8BP 7
3236#define R_SH_DIR8W 8
3237#define R_SH_DIR8L 9
3238#define R_SH_SWITCH16 25
3239#define R_SH_SWITCH32 26
3240#define R_SH_USES 27
3241#define R_SH_COUNT 28
3242#define R_SH_ALIGN 29
3243#define R_SH_CODE 30
3244#define R_SH_DATA 31
3245#define R_SH_LABEL 32
3246#define R_SH_SWITCH8 33
3247#define R_SH_GNU_VTINHERIT 34
3248#define R_SH_GNU_VTENTRY 35
3249#define R_SH_TLS_GD_32 144
3250#define R_SH_TLS_LD_32 145
3251#define R_SH_TLS_LDO_32 146
3252#define R_SH_TLS_IE_32 147
3253#define R_SH_TLS_LE_32 148
3254#define R_SH_TLS_DTPMOD32 149
3255#define R_SH_TLS_DTPOFF32 150
3256#define R_SH_TLS_TPOFF32 151
3257#define R_SH_GOT32 160
3258#define R_SH_PLT32 161
3259#define R_SH_COPY 162
3260#define R_SH_GLOB_DAT 163
3261#define R_SH_JMP_SLOT 164
3262#define R_SH_RELATIVE 165
3263#define R_SH_GOTOFF 166
3264#define R_SH_GOTPC 167
3265/* Keep this the last entry. */
3266#define R_SH_NUM 256
3267
3268/* S/390 specific definitions. */
3269
3270/* Valid values for the e_flags field. */
3271
3272#define EF_S390_HIGH_GPRS 0x00000001 /* High GPRs kernel facility needed. */
3273
3274/* Additional s390 relocs */
3275
3276#define R_390_NONE 0 /* No reloc. */
3277#define R_390_8 1 /* Direct 8 bit. */
3278#define R_390_12 2 /* Direct 12 bit. */
3279#define R_390_16 3 /* Direct 16 bit. */
3280#define R_390_32 4 /* Direct 32 bit. */
3281#define R_390_PC32 5 /* PC relative 32 bit. */
3282#define R_390_GOT12 6 /* 12 bit GOT offset. */
3283#define R_390_GOT32 7 /* 32 bit GOT offset. */
3284#define R_390_PLT32 8 /* 32 bit PC relative PLT address. */
3285#define R_390_COPY 9 /* Copy symbol at runtime. */
3286#define R_390_GLOB_DAT 10 /* Create GOT entry. */
3287#define R_390_JMP_SLOT 11 /* Create PLT entry. */
3288#define R_390_RELATIVE 12 /* Adjust by program base. */
3289#define R_390_GOTOFF32 13 /* 32 bit offset to GOT. */
3290#define R_390_GOTPC 14 /* 32 bit PC relative offset to GOT. */
3291#define R_390_GOT16 15 /* 16 bit GOT offset. */
3292#define R_390_PC16 16 /* PC relative 16 bit. */
3293#define R_390_PC16DBL 17 /* PC relative 16 bit shifted by 1. */
3294#define R_390_PLT16DBL 18 /* 16 bit PC rel. PLT shifted by 1. */
3295#define R_390_PC32DBL 19 /* PC relative 32 bit shifted by 1. */
3296#define R_390_PLT32DBL 20 /* 32 bit PC rel. PLT shifted by 1. */
3297#define R_390_GOTPCDBL 21 /* 32 bit PC rel. GOT shifted by 1. */
3298#define R_390_64 22 /* Direct 64 bit. */
3299#define R_390_PC64 23 /* PC relative 64 bit. */
3300#define R_390_GOT64 24 /* 64 bit GOT offset. */
3301#define R_390_PLT64 25 /* 64 bit PC relative PLT address. */
3302#define R_390_GOTENT 26 /* 32 bit PC rel. to GOT entry >> 1. */
3303#define R_390_GOTOFF16 27 /* 16 bit offset to GOT. */
3304#define R_390_GOTOFF64 28 /* 64 bit offset to GOT. */
3305#define R_390_GOTPLT12 29 /* 12 bit offset to jump slot. */
3306#define R_390_GOTPLT16 30 /* 16 bit offset to jump slot. */
3307#define R_390_GOTPLT32 31 /* 32 bit offset to jump slot. */
3308#define R_390_GOTPLT64 32 /* 64 bit offset to jump slot. */
3309#define R_390_GOTPLTENT 33 /* 32 bit rel. offset to jump slot. */
3310#define R_390_PLTOFF16 34 /* 16 bit offset from GOT to PLT. */
3311#define R_390_PLTOFF32 35 /* 32 bit offset from GOT to PLT. */
3312#define R_390_PLTOFF64 36 /* 16 bit offset from GOT to PLT. */
3313#define R_390_TLS_LOAD 37 /* Tag for load insn in TLS code. */
3314#define R_390_TLS_GDCALL 38 /* Tag for function call in general
3315 dynamic TLS code. */
3316#define R_390_TLS_LDCALL 39 /* Tag for function call in local
3317 dynamic TLS code. */
3318#define R_390_TLS_GD32 40 /* Direct 32 bit for general dynamic
3319 thread local data. */
3320#define R_390_TLS_GD64 41 /* Direct 64 bit for general dynamic
3321 thread local data. */
3322#define R_390_TLS_GOTIE12 42 /* 12 bit GOT offset for static TLS
3323 block offset. */
3324#define R_390_TLS_GOTIE32 43 /* 32 bit GOT offset for static TLS
3325 block offset. */
3326#define R_390_TLS_GOTIE64 44 /* 64 bit GOT offset for static TLS
3327 block offset. */
3328#define R_390_TLS_LDM32 45 /* Direct 32 bit for local dynamic
3329 thread local data in LE code. */
3330#define R_390_TLS_LDM64 46 /* Direct 64 bit for local dynamic
3331 thread local data in LE code. */
3332#define R_390_TLS_IE32 47 /* 32 bit address of GOT entry for
3333 negated static TLS block offset. */
3334#define R_390_TLS_IE64 48 /* 64 bit address of GOT entry for
3335 negated static TLS block offset. */
3336#define R_390_TLS_IEENT 49 /* 32 bit rel. offset to GOT entry for
3337 negated static TLS block offset. */
3338#define R_390_TLS_LE32 50 /* 32 bit negated offset relative to
3339 static TLS block. */
3340#define R_390_TLS_LE64 51 /* 64 bit negated offset relative to
3341 static TLS block. */
3342#define R_390_TLS_LDO32 52 /* 32 bit offset relative to TLS
3343 block. */
3344#define R_390_TLS_LDO64 53 /* 64 bit offset relative to TLS
3345 block. */
3346#define R_390_TLS_DTPMOD 54 /* ID of module containing symbol. */
3347#define R_390_TLS_DTPOFF 55 /* Offset in TLS block. */
3348#define R_390_TLS_TPOFF 56 /* Negated offset in static TLS
3349 block. */
3350#define R_390_20 57 /* Direct 20 bit. */
3351#define R_390_GOT20 58 /* 20 bit GOT offset. */
3352#define R_390_GOTPLT20 59 /* 20 bit offset to jump slot. */
3353#define R_390_TLS_GOTIE20 60 /* 20 bit GOT offset for static TLS
3354 block offset. */
3355#define R_390_IRELATIVE 61 /* STT_GNU_IFUNC relocation. */
3356/* Keep this the last entry. */
3357#define R_390_NUM 62
3358
3359
3360/* CRIS relocations. */
3361#define R_CRIS_NONE 0
3362#define R_CRIS_8 1
3363#define R_CRIS_16 2
3364#define R_CRIS_32 3
3365#define R_CRIS_8_PCREL 4
3366#define R_CRIS_16_PCREL 5
3367#define R_CRIS_32_PCREL 6
3368#define R_CRIS_GNU_VTINHERIT 7
3369#define R_CRIS_GNU_VTENTRY 8
3370#define R_CRIS_COPY 9
3371#define R_CRIS_GLOB_DAT 10
3372#define R_CRIS_JUMP_SLOT 11
3373#define R_CRIS_RELATIVE 12
3374#define R_CRIS_16_GOT 13
3375#define R_CRIS_32_GOT 14
3376#define R_CRIS_16_GOTPLT 15
3377#define R_CRIS_32_GOTPLT 16
3378#define R_CRIS_32_GOTREL 17
3379#define R_CRIS_32_PLT_GOTREL 18
3380#define R_CRIS_32_PLT_PCREL 19
3381
3382#define R_CRIS_NUM 20
3383
3384
3385/* AMD x86-64 relocations. */
3386#define R_X86_64_NONE 0 /* No reloc */
3387#define R_X86_64_64 1 /* Direct 64 bit */
3388#define R_X86_64_PC32 2 /* PC relative 32 bit signed */
3389#define R_X86_64_GOT32 3 /* 32 bit GOT entry */
3390#define R_X86_64_PLT32 4 /* 32 bit PLT address */
3391#define R_X86_64_COPY 5 /* Copy symbol at runtime */
3392#define R_X86_64_GLOB_DAT 6 /* Create GOT entry */
3393#define R_X86_64_JUMP_SLOT 7 /* Create PLT entry */
3394#define R_X86_64_RELATIVE 8 /* Adjust by program base */
3395#define R_X86_64_GOTPCREL 9 /* 32 bit signed PC relative
3396 offset to GOT */
3397#define R_X86_64_32 10 /* Direct 32 bit zero extended */
3398#define R_X86_64_32S 11 /* Direct 32 bit sign extended */
3399#define R_X86_64_16 12 /* Direct 16 bit zero extended */
3400#define R_X86_64_PC16 13 /* 16 bit sign extended pc relative */
3401#define R_X86_64_8 14 /* Direct 8 bit sign extended */
3402#define R_X86_64_PC8 15 /* 8 bit sign extended pc relative */
3403#define R_X86_64_DTPMOD64 16 /* ID of module containing symbol */
3404#define R_X86_64_DTPOFF64 17 /* Offset in module's TLS block */
3405#define R_X86_64_TPOFF64 18 /* Offset in initial TLS block */
3406#define R_X86_64_TLSGD 19 /* 32 bit signed PC relative offset
3407 to two GOT entries for GD symbol */
3408#define R_X86_64_TLSLD 20 /* 32 bit signed PC relative offset
3409 to two GOT entries for LD symbol */
3410#define R_X86_64_DTPOFF32 21 /* Offset in TLS block */
3411#define R_X86_64_GOTTPOFF 22 /* 32 bit signed PC relative offset
3412 to GOT entry for IE symbol */
3413#define R_X86_64_TPOFF32 23 /* Offset in initial TLS block */
3414#define R_X86_64_PC64 24 /* PC relative 64 bit */
3415#define R_X86_64_GOTOFF64 25 /* 64 bit offset to GOT */
3416#define R_X86_64_GOTPC32 26 /* 32 bit signed pc relative
3417 offset to GOT */
3418#define R_X86_64_GOT64 27 /* 64-bit GOT entry offset */
3419#define R_X86_64_GOTPCREL64 28 /* 64-bit PC relative offset
3420 to GOT entry */
3421#define R_X86_64_GOTPC64 29 /* 64-bit PC relative offset to GOT */
3422#define R_X86_64_GOTPLT64 30 /* like GOT64, says PLT entry needed */
3423#define R_X86_64_PLTOFF64 31 /* 64-bit GOT relative offset
3424 to PLT entry */
3425#define R_X86_64_SIZE32 32 /* Size of symbol plus 32-bit addend */
3426#define R_X86_64_SIZE64 33 /* Size of symbol plus 64-bit addend */
3427#define R_X86_64_GOTPC32_TLSDESC 34 /* GOT offset for TLS descriptor. */
3428#define R_X86_64_TLSDESC_CALL 35 /* Marker for call through TLS
3429 descriptor. */
3430#define R_X86_64_TLSDESC 36 /* TLS descriptor. */
3431#define R_X86_64_IRELATIVE 37 /* Adjust indirectly by program base */
3432#define R_X86_64_RELATIVE64 38 /* 64-bit adjust by program base */
3433 /* 39 Reserved was R_X86_64_PC32_BND */
3434 /* 40 Reserved was R_X86_64_PLT32_BND */
3435#define R_X86_64_GOTPCRELX 41 /* Load from 32 bit signed pc relative
3436 offset to GOT entry without REX
3437 prefix, relaxable. */
3438#define R_X86_64_REX_GOTPCRELX 42 /* Load from 32 bit signed pc relative
3439 offset to GOT entry with REX prefix,
3440 relaxable. */
3441#define R_X86_64_NUM 43
3442
3443/* x86-64 sh_type values. */
3444#define SHT_X86_64_UNWIND 0x70000001 /* Unwind information. */
3445
3446
3447/* AM33 relocations. */
3448#define R_MN10300_NONE 0 /* No reloc. */
3449#define R_MN10300_32 1 /* Direct 32 bit. */
3450#define R_MN10300_16 2 /* Direct 16 bit. */
3451#define R_MN10300_8 3 /* Direct 8 bit. */
3452#define R_MN10300_PCREL32 4 /* PC-relative 32-bit. */
3453#define R_MN10300_PCREL16 5 /* PC-relative 16-bit signed. */
3454#define R_MN10300_PCREL8 6 /* PC-relative 8-bit signed. */
3455#define R_MN10300_GNU_VTINHERIT 7 /* Ancient C++ vtable garbage... */
3456#define R_MN10300_GNU_VTENTRY 8 /* ... collection annotation. */
3457#define R_MN10300_24 9 /* Direct 24 bit. */
3458#define R_MN10300_GOTPC32 10 /* 32-bit PCrel offset to GOT. */
3459#define R_MN10300_GOTPC16 11 /* 16-bit PCrel offset to GOT. */
3460#define R_MN10300_GOTOFF32 12 /* 32-bit offset from GOT. */
3461#define R_MN10300_GOTOFF24 13 /* 24-bit offset from GOT. */
3462#define R_MN10300_GOTOFF16 14 /* 16-bit offset from GOT. */
3463#define R_MN10300_PLT32 15 /* 32-bit PCrel to PLT entry. */
3464#define R_MN10300_PLT16 16 /* 16-bit PCrel to PLT entry. */
3465#define R_MN10300_GOT32 17 /* 32-bit offset to GOT entry. */
3466#define R_MN10300_GOT24 18 /* 24-bit offset to GOT entry. */
3467#define R_MN10300_GOT16 19 /* 16-bit offset to GOT entry. */
3468#define R_MN10300_COPY 20 /* Copy symbol at runtime. */
3469#define R_MN10300_GLOB_DAT 21 /* Create GOT entry. */
3470#define R_MN10300_JMP_SLOT 22 /* Create PLT entry. */
3471#define R_MN10300_RELATIVE 23 /* Adjust by program base. */
3472#define R_MN10300_TLS_GD 24 /* 32-bit offset for global dynamic. */
3473#define R_MN10300_TLS_LD 25 /* 32-bit offset for local dynamic. */
3474#define R_MN10300_TLS_LDO 26 /* Module-relative offset. */
3475#define R_MN10300_TLS_GOTIE 27 /* GOT offset for static TLS block
3476 offset. */
3477#define R_MN10300_TLS_IE 28 /* GOT address for static TLS block
3478 offset. */
3479#define R_MN10300_TLS_LE 29 /* Offset relative to static TLS
3480 block. */
3481#define R_MN10300_TLS_DTPMOD 30 /* ID of module containing symbol. */
3482#define R_MN10300_TLS_DTPOFF 31 /* Offset in module TLS block. */
3483#define R_MN10300_TLS_TPOFF 32 /* Offset in static TLS block. */
3484#define R_MN10300_SYM_DIFF 33 /* Adjustment for next reloc as needed
3485 by linker relaxation. */
3486#define R_MN10300_ALIGN 34 /* Alignment requirement for linker
3487 relaxation. */
3488#define R_MN10300_NUM 35
3489
3490
3491/* M32R relocs. */
3492#define R_M32R_NONE 0 /* No reloc. */
3493#define R_M32R_16 1 /* Direct 16 bit. */
3494#define R_M32R_32 2 /* Direct 32 bit. */
3495#define R_M32R_24 3 /* Direct 24 bit. */
3496#define R_M32R_10_PCREL 4 /* PC relative 10 bit shifted. */
3497#define R_M32R_18_PCREL 5 /* PC relative 18 bit shifted. */
3498#define R_M32R_26_PCREL 6 /* PC relative 26 bit shifted. */
3499#define R_M32R_HI16_ULO 7 /* High 16 bit with unsigned low. */
3500#define R_M32R_HI16_SLO 8 /* High 16 bit with signed low. */
3501#define R_M32R_LO16 9 /* Low 16 bit. */
3502#define R_M32R_SDA16 10 /* 16 bit offset in SDA. */
3503#define R_M32R_GNU_VTINHERIT 11
3504#define R_M32R_GNU_VTENTRY 12
3505/* M32R relocs use SHT_RELA. */
3506#define R_M32R_16_RELA 33 /* Direct 16 bit. */
3507#define R_M32R_32_RELA 34 /* Direct 32 bit. */
3508#define R_M32R_24_RELA 35 /* Direct 24 bit. */
3509#define R_M32R_10_PCREL_RELA 36 /* PC relative 10 bit shifted. */
3510#define R_M32R_18_PCREL_RELA 37 /* PC relative 18 bit shifted. */
3511#define R_M32R_26_PCREL_RELA 38 /* PC relative 26 bit shifted. */
3512#define R_M32R_HI16_ULO_RELA 39 /* High 16 bit with unsigned low */
3513#define R_M32R_HI16_SLO_RELA 40 /* High 16 bit with signed low */
3514#define R_M32R_LO16_RELA 41 /* Low 16 bit */
3515#define R_M32R_SDA16_RELA 42 /* 16 bit offset in SDA */
3516#define R_M32R_RELA_GNU_VTINHERIT 43
3517#define R_M32R_RELA_GNU_VTENTRY 44
3518#define R_M32R_REL32 45 /* PC relative 32 bit. */
3519
3520#define R_M32R_GOT24 48 /* 24 bit GOT entry */
3521#define R_M32R_26_PLTREL 49 /* 26 bit PC relative to PLT shifted */
3522#define R_M32R_COPY 50 /* Copy symbol at runtime */
3523#define R_M32R_GLOB_DAT 51 /* Create GOT entry */
3524#define R_M32R_JMP_SLOT 52 /* Create PLT entry */
3525#define R_M32R_RELATIVE 53 /* Adjust by program base */
3526#define R_M32R_GOTOFF 54 /* 24 bit offset to GOT */
3527#define R_M32R_GOTPC24 55 /* 24 bit PC relative offset to GOT */
3528#define R_M32R_GOT16_HI_ULO 56 /* High 16 bit GOT entry with unsigned
3529 low */
3530#define R_M32R_GOT16_HI_SLO 57 /* High 16 bit GOT entry with signed
3531 low */
3532#define R_M32R_GOT16_LO 58 /* Low 16 bit GOT entry */
3533#define R_M32R_GOTPC_HI_ULO 59 /* High 16 bit PC relative offset to
3534 GOT with unsigned low */
3535#define R_M32R_GOTPC_HI_SLO 60 /* High 16 bit PC relative offset to
3536 GOT with signed low */
3537#define R_M32R_GOTPC_LO 61 /* Low 16 bit PC relative offset to
3538 GOT */
3539#define R_M32R_GOTOFF_HI_ULO 62 /* High 16 bit offset to GOT
3540 with unsigned low */
3541#define R_M32R_GOTOFF_HI_SLO 63 /* High 16 bit offset to GOT
3542 with signed low */
3543#define R_M32R_GOTOFF_LO 64 /* Low 16 bit offset to GOT */
3544#define R_M32R_NUM 256 /* Keep this the last entry. */
3545
3546/* MicroBlaze relocations */
3547#define R_MICROBLAZE_NONE 0 /* No reloc. */
3548#define R_MICROBLAZE_32 1 /* Direct 32 bit. */
3549#define R_MICROBLAZE_32_PCREL 2 /* PC relative 32 bit. */
3550#define R_MICROBLAZE_64_PCREL 3 /* PC relative 64 bit. */
3551#define R_MICROBLAZE_32_PCREL_LO 4 /* Low 16 bits of PCREL32. */
3552#define R_MICROBLAZE_64 5 /* Direct 64 bit. */
3553#define R_MICROBLAZE_32_LO 6 /* Low 16 bit. */
3554#define R_MICROBLAZE_SRO32 7 /* Read-only small data area. */
3555#define R_MICROBLAZE_SRW32 8 /* Read-write small data area. */
3556#define R_MICROBLAZE_64_NONE 9 /* No reloc. */
3557#define R_MICROBLAZE_32_SYM_OP_SYM 10 /* Symbol Op Symbol relocation. */
3558#define R_MICROBLAZE_GNU_VTINHERIT 11 /* GNU C++ vtable hierarchy. */
3559#define R_MICROBLAZE_GNU_VTENTRY 12 /* GNU C++ vtable member usage. */
3560#define R_MICROBLAZE_GOTPC_64 13 /* PC-relative GOT offset. */
3561#define R_MICROBLAZE_GOT_64 14 /* GOT entry offset. */
3562#define R_MICROBLAZE_PLT_64 15 /* PLT offset (PC-relative). */
3563#define R_MICROBLAZE_REL 16 /* Adjust by program base. */
3564#define R_MICROBLAZE_JUMP_SLOT 17 /* Create PLT entry. */
3565#define R_MICROBLAZE_GLOB_DAT 18 /* Create GOT entry. */
3566#define R_MICROBLAZE_GOTOFF_64 19 /* 64 bit offset to GOT. */
3567#define R_MICROBLAZE_GOTOFF_32 20 /* 32 bit offset to GOT. */
3568#define R_MICROBLAZE_COPY 21 /* Runtime copy. */
3569#define R_MICROBLAZE_TLS 22 /* TLS Reloc. */
3570#define R_MICROBLAZE_TLSGD 23 /* TLS General Dynamic. */
3571#define R_MICROBLAZE_TLSLD 24 /* TLS Local Dynamic. */
3572#define R_MICROBLAZE_TLSDTPMOD32 25 /* TLS Module ID. */
3573#define R_MICROBLAZE_TLSDTPREL32 26 /* TLS Offset Within TLS Block. */
3574#define R_MICROBLAZE_TLSDTPREL64 27 /* TLS Offset Within TLS Block. */
3575#define R_MICROBLAZE_TLSGOTTPREL32 28 /* TLS Offset From Thread Pointer. */
3576#define R_MICROBLAZE_TLSTPREL32 29 /* TLS Offset From Thread Pointer. */
3577
3578/* Legal values for d_tag (dynamic entry type). */
3579#define DT_NIOS2_GP 0x70000002 /* Address of _gp. */
3580
3581/* Nios II relocations. */
3582#define R_NIOS2_NONE 0 /* No reloc. */
3583#define R_NIOS2_S16 1 /* Direct signed 16 bit. */
3584#define R_NIOS2_U16 2 /* Direct unsigned 16 bit. */
3585#define R_NIOS2_PCREL16 3 /* PC relative 16 bit. */
3586#define R_NIOS2_CALL26 4 /* Direct call. */
3587#define R_NIOS2_IMM5 5 /* 5 bit constant expression. */
3588#define R_NIOS2_CACHE_OPX 6 /* 5 bit expression, shift 22. */
3589#define R_NIOS2_IMM6 7 /* 6 bit constant expression. */
3590#define R_NIOS2_IMM8 8 /* 8 bit constant expression. */
3591#define R_NIOS2_HI16 9 /* High 16 bit. */
3592#define R_NIOS2_LO16 10 /* Low 16 bit. */
3593#define R_NIOS2_HIADJ16 11 /* High 16 bit, adjusted. */
3594#define R_NIOS2_BFD_RELOC_32 12 /* 32 bit symbol value + addend. */
3595#define R_NIOS2_BFD_RELOC_16 13 /* 16 bit symbol value + addend. */
3596#define R_NIOS2_BFD_RELOC_8 14 /* 8 bit symbol value + addend. */
3597#define R_NIOS2_GPREL 15 /* 16 bit GP pointer offset. */
3598#define R_NIOS2_GNU_VTINHERIT 16 /* GNU C++ vtable hierarchy. */
3599#define R_NIOS2_GNU_VTENTRY 17 /* GNU C++ vtable member usage. */
3600#define R_NIOS2_UJMP 18 /* Unconditional branch. */
3601#define R_NIOS2_CJMP 19 /* Conditional branch. */
3602#define R_NIOS2_CALLR 20 /* Indirect call through register. */
3603#define R_NIOS2_ALIGN 21 /* Alignment requirement for
3604 linker relaxation. */
3605#define R_NIOS2_GOT16 22 /* 16 bit GOT entry. */
3606#define R_NIOS2_CALL16 23 /* 16 bit GOT entry for function. */
3607#define R_NIOS2_GOTOFF_LO 24 /* %lo of offset to GOT pointer. */
3608#define R_NIOS2_GOTOFF_HA 25 /* %hiadj of offset to GOT pointer. */
3609#define R_NIOS2_PCREL_LO 26 /* %lo of PC relative offset. */
3610#define R_NIOS2_PCREL_HA 27 /* %hiadj of PC relative offset. */
3611#define R_NIOS2_TLS_GD16 28 /* 16 bit GOT offset for TLS GD. */
3612#define R_NIOS2_TLS_LDM16 29 /* 16 bit GOT offset for TLS LDM. */
3613#define R_NIOS2_TLS_LDO16 30 /* 16 bit module relative offset. */
3614#define R_NIOS2_TLS_IE16 31 /* 16 bit GOT offset for TLS IE. */
3615#define R_NIOS2_TLS_LE16 32 /* 16 bit LE TP-relative offset. */
3616#define R_NIOS2_TLS_DTPMOD 33 /* Module number. */
3617#define R_NIOS2_TLS_DTPREL 34 /* Module-relative offset. */
3618#define R_NIOS2_TLS_TPREL 35 /* TP-relative offset. */
3619#define R_NIOS2_COPY 36 /* Copy symbol at runtime. */
3620#define R_NIOS2_GLOB_DAT 37 /* Create GOT entry. */
3621#define R_NIOS2_JUMP_SLOT 38 /* Create PLT entry. */
3622#define R_NIOS2_RELATIVE 39 /* Adjust by program base. */
3623#define R_NIOS2_GOTOFF 40 /* 16 bit offset to GOT pointer. */
3624#define R_NIOS2_CALL26_NOAT 41 /* Direct call in .noat section. */
3625#define R_NIOS2_GOT_LO 42 /* %lo() of GOT entry. */
3626#define R_NIOS2_GOT_HA 43 /* %hiadj() of GOT entry. */
3627#define R_NIOS2_CALL_LO 44 /* %lo() of function GOT entry. */
3628#define R_NIOS2_CALL_HA 45 /* %hiadj() of function GOT entry. */
3629
3630/* TILEPro relocations. */
3631#define R_TILEPRO_NONE 0 /* No reloc */
3632#define R_TILEPRO_32 1 /* Direct 32 bit */
3633#define R_TILEPRO_16 2 /* Direct 16 bit */
3634#define R_TILEPRO_8 3 /* Direct 8 bit */
3635#define R_TILEPRO_32_PCREL 4 /* PC relative 32 bit */
3636#define R_TILEPRO_16_PCREL 5 /* PC relative 16 bit */
3637#define R_TILEPRO_8_PCREL 6 /* PC relative 8 bit */
3638#define R_TILEPRO_LO16 7 /* Low 16 bit */
3639#define R_TILEPRO_HI16 8 /* High 16 bit */
3640#define R_TILEPRO_HA16 9 /* High 16 bit, adjusted */
3641#define R_TILEPRO_COPY 10 /* Copy relocation */
3642#define R_TILEPRO_GLOB_DAT 11 /* Create GOT entry */
3643#define R_TILEPRO_JMP_SLOT 12 /* Create PLT entry */
3644#define R_TILEPRO_RELATIVE 13 /* Adjust by program base */
3645#define R_TILEPRO_BROFF_X1 14 /* X1 pipe branch offset */
3646#define R_TILEPRO_JOFFLONG_X1 15 /* X1 pipe jump offset */
3647#define R_TILEPRO_JOFFLONG_X1_PLT 16 /* X1 pipe jump offset to PLT */
3648#define R_TILEPRO_IMM8_X0 17 /* X0 pipe 8-bit */
3649#define R_TILEPRO_IMM8_Y0 18 /* Y0 pipe 8-bit */
3650#define R_TILEPRO_IMM8_X1 19 /* X1 pipe 8-bit */
3651#define R_TILEPRO_IMM8_Y1 20 /* Y1 pipe 8-bit */
3652#define R_TILEPRO_MT_IMM15_X1 21 /* X1 pipe mtspr */
3653#define R_TILEPRO_MF_IMM15_X1 22 /* X1 pipe mfspr */
3654#define R_TILEPRO_IMM16_X0 23 /* X0 pipe 16-bit */
3655#define R_TILEPRO_IMM16_X1 24 /* X1 pipe 16-bit */
3656#define R_TILEPRO_IMM16_X0_LO 25 /* X0 pipe low 16-bit */
3657#define R_TILEPRO_IMM16_X1_LO 26 /* X1 pipe low 16-bit */
3658#define R_TILEPRO_IMM16_X0_HI 27 /* X0 pipe high 16-bit */
3659#define R_TILEPRO_IMM16_X1_HI 28 /* X1 pipe high 16-bit */
3660#define R_TILEPRO_IMM16_X0_HA 29 /* X0 pipe high 16-bit, adjusted */
3661#define R_TILEPRO_IMM16_X1_HA 30 /* X1 pipe high 16-bit, adjusted */
3662#define R_TILEPRO_IMM16_X0_PCREL 31 /* X0 pipe PC relative 16 bit */
3663#define R_TILEPRO_IMM16_X1_PCREL 32 /* X1 pipe PC relative 16 bit */
3664#define R_TILEPRO_IMM16_X0_LO_PCREL 33 /* X0 pipe PC relative low 16 bit */
3665#define R_TILEPRO_IMM16_X1_LO_PCREL 34 /* X1 pipe PC relative low 16 bit */
3666#define R_TILEPRO_IMM16_X0_HI_PCREL 35 /* X0 pipe PC relative high 16 bit */
3667#define R_TILEPRO_IMM16_X1_HI_PCREL 36 /* X1 pipe PC relative high 16 bit */
3668#define R_TILEPRO_IMM16_X0_HA_PCREL 37 /* X0 pipe PC relative ha() 16 bit */
3669#define R_TILEPRO_IMM16_X1_HA_PCREL 38 /* X1 pipe PC relative ha() 16 bit */
3670#define R_TILEPRO_IMM16_X0_GOT 39 /* X0 pipe 16-bit GOT offset */
3671#define R_TILEPRO_IMM16_X1_GOT 40 /* X1 pipe 16-bit GOT offset */
3672#define R_TILEPRO_IMM16_X0_GOT_LO 41 /* X0 pipe low 16-bit GOT offset */
3673#define R_TILEPRO_IMM16_X1_GOT_LO 42 /* X1 pipe low 16-bit GOT offset */
3674#define R_TILEPRO_IMM16_X0_GOT_HI 43 /* X0 pipe high 16-bit GOT offset */
3675#define R_TILEPRO_IMM16_X1_GOT_HI 44 /* X1 pipe high 16-bit GOT offset */
3676#define R_TILEPRO_IMM16_X0_GOT_HA 45 /* X0 pipe ha() 16-bit GOT offset */
3677#define R_TILEPRO_IMM16_X1_GOT_HA 46 /* X1 pipe ha() 16-bit GOT offset */
3678#define R_TILEPRO_MMSTART_X0 47 /* X0 pipe mm "start" */
3679#define R_TILEPRO_MMEND_X0 48 /* X0 pipe mm "end" */
3680#define R_TILEPRO_MMSTART_X1 49 /* X1 pipe mm "start" */
3681#define R_TILEPRO_MMEND_X1 50 /* X1 pipe mm "end" */
3682#define R_TILEPRO_SHAMT_X0 51 /* X0 pipe shift amount */
3683#define R_TILEPRO_SHAMT_X1 52 /* X1 pipe shift amount */
3684#define R_TILEPRO_SHAMT_Y0 53 /* Y0 pipe shift amount */
3685#define R_TILEPRO_SHAMT_Y1 54 /* Y1 pipe shift amount */
3686#define R_TILEPRO_DEST_IMM8_X1 55 /* X1 pipe destination 8-bit */
3687/* Relocs 56-59 are currently not defined. */
3688#define R_TILEPRO_TLS_GD_CALL 60 /* "jal" for TLS GD */
3689#define R_TILEPRO_IMM8_X0_TLS_GD_ADD 61 /* X0 pipe "addi" for TLS GD */
3690#define R_TILEPRO_IMM8_X1_TLS_GD_ADD 62 /* X1 pipe "addi" for TLS GD */
3691#define R_TILEPRO_IMM8_Y0_TLS_GD_ADD 63 /* Y0 pipe "addi" for TLS GD */
3692#define R_TILEPRO_IMM8_Y1_TLS_GD_ADD 64 /* Y1 pipe "addi" for TLS GD */
3693#define R_TILEPRO_TLS_IE_LOAD 65 /* "lw_tls" for TLS IE */
3694#define R_TILEPRO_IMM16_X0_TLS_GD 66 /* X0 pipe 16-bit TLS GD offset */
3695#define R_TILEPRO_IMM16_X1_TLS_GD 67 /* X1 pipe 16-bit TLS GD offset */
3696#define R_TILEPRO_IMM16_X0_TLS_GD_LO 68 /* X0 pipe low 16-bit TLS GD offset */
3697#define R_TILEPRO_IMM16_X1_TLS_GD_LO 69 /* X1 pipe low 16-bit TLS GD offset */
3698#define R_TILEPRO_IMM16_X0_TLS_GD_HI 70 /* X0 pipe high 16-bit TLS GD offset */
3699#define R_TILEPRO_IMM16_X1_TLS_GD_HI 71 /* X1 pipe high 16-bit TLS GD offset */
3700#define R_TILEPRO_IMM16_X0_TLS_GD_HA 72 /* X0 pipe ha() 16-bit TLS GD offset */
3701#define R_TILEPRO_IMM16_X1_TLS_GD_HA 73 /* X1 pipe ha() 16-bit TLS GD offset */
3702#define R_TILEPRO_IMM16_X0_TLS_IE 74 /* X0 pipe 16-bit TLS IE offset */
3703#define R_TILEPRO_IMM16_X1_TLS_IE 75 /* X1 pipe 16-bit TLS IE offset */
3704#define R_TILEPRO_IMM16_X0_TLS_IE_LO 76 /* X0 pipe low 16-bit TLS IE offset */
3705#define R_TILEPRO_IMM16_X1_TLS_IE_LO 77 /* X1 pipe low 16-bit TLS IE offset */
3706#define R_TILEPRO_IMM16_X0_TLS_IE_HI 78 /* X0 pipe high 16-bit TLS IE offset */
3707#define R_TILEPRO_IMM16_X1_TLS_IE_HI 79 /* X1 pipe high 16-bit TLS IE offset */
3708#define R_TILEPRO_IMM16_X0_TLS_IE_HA 80 /* X0 pipe ha() 16-bit TLS IE offset */
3709#define R_TILEPRO_IMM16_X1_TLS_IE_HA 81 /* X1 pipe ha() 16-bit TLS IE offset */
3710#define R_TILEPRO_TLS_DTPMOD32 82 /* ID of module containing symbol */
3711#define R_TILEPRO_TLS_DTPOFF32 83 /* Offset in TLS block */
3712#define R_TILEPRO_TLS_TPOFF32 84 /* Offset in static TLS block */
3713#define R_TILEPRO_IMM16_X0_TLS_LE 85 /* X0 pipe 16-bit TLS LE offset */
3714#define R_TILEPRO_IMM16_X1_TLS_LE 86 /* X1 pipe 16-bit TLS LE offset */
3715#define R_TILEPRO_IMM16_X0_TLS_LE_LO 87 /* X0 pipe low 16-bit TLS LE offset */
3716#define R_TILEPRO_IMM16_X1_TLS_LE_LO 88 /* X1 pipe low 16-bit TLS LE offset */
3717#define R_TILEPRO_IMM16_X0_TLS_LE_HI 89 /* X0 pipe high 16-bit TLS LE offset */
3718#define R_TILEPRO_IMM16_X1_TLS_LE_HI 90 /* X1 pipe high 16-bit TLS LE offset */
3719#define R_TILEPRO_IMM16_X0_TLS_LE_HA 91 /* X0 pipe ha() 16-bit TLS LE offset */
3720#define R_TILEPRO_IMM16_X1_TLS_LE_HA 92 /* X1 pipe ha() 16-bit TLS LE offset */
3721
3722#define R_TILEPRO_GNU_VTINHERIT 128 /* GNU C++ vtable hierarchy */
3723#define R_TILEPRO_GNU_VTENTRY 129 /* GNU C++ vtable member usage */
3724
3725#define R_TILEPRO_NUM 130
3726
3727
3728/* TILE-Gx relocations. */
3729#define R_TILEGX_NONE 0 /* No reloc */
3730#define R_TILEGX_64 1 /* Direct 64 bit */
3731#define R_TILEGX_32 2 /* Direct 32 bit */
3732#define R_TILEGX_16 3 /* Direct 16 bit */
3733#define R_TILEGX_8 4 /* Direct 8 bit */
3734#define R_TILEGX_64_PCREL 5 /* PC relative 64 bit */
3735#define R_TILEGX_32_PCREL 6 /* PC relative 32 bit */
3736#define R_TILEGX_16_PCREL 7 /* PC relative 16 bit */
3737#define R_TILEGX_8_PCREL 8 /* PC relative 8 bit */
3738#define R_TILEGX_HW0 9 /* hword 0 16-bit */
3739#define R_TILEGX_HW1 10 /* hword 1 16-bit */
3740#define R_TILEGX_HW2 11 /* hword 2 16-bit */
3741#define R_TILEGX_HW3 12 /* hword 3 16-bit */
3742#define R_TILEGX_HW0_LAST 13 /* last hword 0 16-bit */
3743#define R_TILEGX_HW1_LAST 14 /* last hword 1 16-bit */
3744#define R_TILEGX_HW2_LAST 15 /* last hword 2 16-bit */
3745#define R_TILEGX_COPY 16 /* Copy relocation */
3746#define R_TILEGX_GLOB_DAT 17 /* Create GOT entry */
3747#define R_TILEGX_JMP_SLOT 18 /* Create PLT entry */
3748#define R_TILEGX_RELATIVE 19 /* Adjust by program base */
3749#define R_TILEGX_BROFF_X1 20 /* X1 pipe branch offset */
3750#define R_TILEGX_JUMPOFF_X1 21 /* X1 pipe jump offset */
3751#define R_TILEGX_JUMPOFF_X1_PLT 22 /* X1 pipe jump offset to PLT */
3752#define R_TILEGX_IMM8_X0 23 /* X0 pipe 8-bit */
3753#define R_TILEGX_IMM8_Y0 24 /* Y0 pipe 8-bit */
3754#define R_TILEGX_IMM8_X1 25 /* X1 pipe 8-bit */
3755#define R_TILEGX_IMM8_Y1 26 /* Y1 pipe 8-bit */
3756#define R_TILEGX_DEST_IMM8_X1 27 /* X1 pipe destination 8-bit */
3757#define R_TILEGX_MT_IMM14_X1 28 /* X1 pipe mtspr */
3758#define R_TILEGX_MF_IMM14_X1 29 /* X1 pipe mfspr */
3759#define R_TILEGX_MMSTART_X0 30 /* X0 pipe mm "start" */
3760#define R_TILEGX_MMEND_X0 31 /* X0 pipe mm "end" */
3761#define R_TILEGX_SHAMT_X0 32 /* X0 pipe shift amount */
3762#define R_TILEGX_SHAMT_X1 33 /* X1 pipe shift amount */
3763#define R_TILEGX_SHAMT_Y0 34 /* Y0 pipe shift amount */
3764#define R_TILEGX_SHAMT_Y1 35 /* Y1 pipe shift amount */
3765#define R_TILEGX_IMM16_X0_HW0 36 /* X0 pipe hword 0 */
3766#define R_TILEGX_IMM16_X1_HW0 37 /* X1 pipe hword 0 */
3767#define R_TILEGX_IMM16_X0_HW1 38 /* X0 pipe hword 1 */
3768#define R_TILEGX_IMM16_X1_HW1 39 /* X1 pipe hword 1 */
3769#define R_TILEGX_IMM16_X0_HW2 40 /* X0 pipe hword 2 */
3770#define R_TILEGX_IMM16_X1_HW2 41 /* X1 pipe hword 2 */
3771#define R_TILEGX_IMM16_X0_HW3 42 /* X0 pipe hword 3 */
3772#define R_TILEGX_IMM16_X1_HW3 43 /* X1 pipe hword 3 */
3773#define R_TILEGX_IMM16_X0_HW0_LAST 44 /* X0 pipe last hword 0 */
3774#define R_TILEGX_IMM16_X1_HW0_LAST 45 /* X1 pipe last hword 0 */
3775#define R_TILEGX_IMM16_X0_HW1_LAST 46 /* X0 pipe last hword 1 */
3776#define R_TILEGX_IMM16_X1_HW1_LAST 47 /* X1 pipe last hword 1 */
3777#define R_TILEGX_IMM16_X0_HW2_LAST 48 /* X0 pipe last hword 2 */
3778#define R_TILEGX_IMM16_X1_HW2_LAST 49 /* X1 pipe last hword 2 */
3779#define R_TILEGX_IMM16_X0_HW0_PCREL 50 /* X0 pipe PC relative hword 0 */
3780#define R_TILEGX_IMM16_X1_HW0_PCREL 51 /* X1 pipe PC relative hword 0 */
3781#define R_TILEGX_IMM16_X0_HW1_PCREL 52 /* X0 pipe PC relative hword 1 */
3782#define R_TILEGX_IMM16_X1_HW1_PCREL 53 /* X1 pipe PC relative hword 1 */
3783#define R_TILEGX_IMM16_X0_HW2_PCREL 54 /* X0 pipe PC relative hword 2 */
3784#define R_TILEGX_IMM16_X1_HW2_PCREL 55 /* X1 pipe PC relative hword 2 */
3785#define R_TILEGX_IMM16_X0_HW3_PCREL 56 /* X0 pipe PC relative hword 3 */
3786#define R_TILEGX_IMM16_X1_HW3_PCREL 57 /* X1 pipe PC relative hword 3 */
3787#define R_TILEGX_IMM16_X0_HW0_LAST_PCREL 58 /* X0 pipe PC-rel last hword 0 */
3788#define R_TILEGX_IMM16_X1_HW0_LAST_PCREL 59 /* X1 pipe PC-rel last hword 0 */
3789#define R_TILEGX_IMM16_X0_HW1_LAST_PCREL 60 /* X0 pipe PC-rel last hword 1 */
3790#define R_TILEGX_IMM16_X1_HW1_LAST_PCREL 61 /* X1 pipe PC-rel last hword 1 */
3791#define R_TILEGX_IMM16_X0_HW2_LAST_PCREL 62 /* X0 pipe PC-rel last hword 2 */
3792#define R_TILEGX_IMM16_X1_HW2_LAST_PCREL 63 /* X1 pipe PC-rel last hword 2 */
3793#define R_TILEGX_IMM16_X0_HW0_GOT 64 /* X0 pipe hword 0 GOT offset */
3794#define R_TILEGX_IMM16_X1_HW0_GOT 65 /* X1 pipe hword 0 GOT offset */
3795#define R_TILEGX_IMM16_X0_HW0_PLT_PCREL 66 /* X0 pipe PC-rel PLT hword 0 */
3796#define R_TILEGX_IMM16_X1_HW0_PLT_PCREL 67 /* X1 pipe PC-rel PLT hword 0 */
3797#define R_TILEGX_IMM16_X0_HW1_PLT_PCREL 68 /* X0 pipe PC-rel PLT hword 1 */
3798#define R_TILEGX_IMM16_X1_HW1_PLT_PCREL 69 /* X1 pipe PC-rel PLT hword 1 */
3799#define R_TILEGX_IMM16_X0_HW2_PLT_PCREL 70 /* X0 pipe PC-rel PLT hword 2 */
3800#define R_TILEGX_IMM16_X1_HW2_PLT_PCREL 71 /* X1 pipe PC-rel PLT hword 2 */
3801#define R_TILEGX_IMM16_X0_HW0_LAST_GOT 72 /* X0 pipe last hword 0 GOT offset */
3802#define R_TILEGX_IMM16_X1_HW0_LAST_GOT 73 /* X1 pipe last hword 0 GOT offset */
3803#define R_TILEGX_IMM16_X0_HW1_LAST_GOT 74 /* X0 pipe last hword 1 GOT offset */
3804#define R_TILEGX_IMM16_X1_HW1_LAST_GOT 75 /* X1 pipe last hword 1 GOT offset */
3805#define R_TILEGX_IMM16_X0_HW3_PLT_PCREL 76 /* X0 pipe PC-rel PLT hword 3 */
3806#define R_TILEGX_IMM16_X1_HW3_PLT_PCREL 77 /* X1 pipe PC-rel PLT hword 3 */
3807#define R_TILEGX_IMM16_X0_HW0_TLS_GD 78 /* X0 pipe hword 0 TLS GD offset */
3808#define R_TILEGX_IMM16_X1_HW0_TLS_GD 79 /* X1 pipe hword 0 TLS GD offset */
3809#define R_TILEGX_IMM16_X0_HW0_TLS_LE 80 /* X0 pipe hword 0 TLS LE offset */
3810#define R_TILEGX_IMM16_X1_HW0_TLS_LE 81 /* X1 pipe hword 0 TLS LE offset */
3811#define R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE 82 /* X0 pipe last hword 0 LE off */
3812#define R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE 83 /* X1 pipe last hword 0 LE off */
3813#define R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE 84 /* X0 pipe last hword 1 LE off */
3814#define R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE 85 /* X1 pipe last hword 1 LE off */
3815#define R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD 86 /* X0 pipe last hword 0 GD off */
3816#define R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD 87 /* X1 pipe last hword 0 GD off */
3817#define R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD 88 /* X0 pipe last hword 1 GD off */
3818#define R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD 89 /* X1 pipe last hword 1 GD off */
3819/* Relocs 90-91 are currently not defined. */
3820#define R_TILEGX_IMM16_X0_HW0_TLS_IE 92 /* X0 pipe hword 0 TLS IE offset */
3821#define R_TILEGX_IMM16_X1_HW0_TLS_IE 93 /* X1 pipe hword 0 TLS IE offset */
3822#define R_TILEGX_IMM16_X0_HW0_LAST_PLT_PCREL 94 /* X0 pipe PC-rel PLT last hword 0 */
3823#define R_TILEGX_IMM16_X1_HW0_LAST_PLT_PCREL 95 /* X1 pipe PC-rel PLT last hword 0 */
3824#define R_TILEGX_IMM16_X0_HW1_LAST_PLT_PCREL 96 /* X0 pipe PC-rel PLT last hword 1 */
3825#define R_TILEGX_IMM16_X1_HW1_LAST_PLT_PCREL 97 /* X1 pipe PC-rel PLT last hword 1 */
3826#define R_TILEGX_IMM16_X0_HW2_LAST_PLT_PCREL 98 /* X0 pipe PC-rel PLT last hword 2 */
3827#define R_TILEGX_IMM16_X1_HW2_LAST_PLT_PCREL 99 /* X1 pipe PC-rel PLT last hword 2 */
3828#define R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE 100 /* X0 pipe last hword 0 IE off */
3829#define R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE 101 /* X1 pipe last hword 0 IE off */
3830#define R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE 102 /* X0 pipe last hword 1 IE off */
3831#define R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE 103 /* X1 pipe last hword 1 IE off */
3832/* Relocs 104-105 are currently not defined. */
3833#define R_TILEGX_TLS_DTPMOD64 106 /* 64-bit ID of symbol's module */
3834#define R_TILEGX_TLS_DTPOFF64 107 /* 64-bit offset in TLS block */
3835#define R_TILEGX_TLS_TPOFF64 108 /* 64-bit offset in static TLS block */
3836#define R_TILEGX_TLS_DTPMOD32 109 /* 32-bit ID of symbol's module */
3837#define R_TILEGX_TLS_DTPOFF32 110 /* 32-bit offset in TLS block */
3838#define R_TILEGX_TLS_TPOFF32 111 /* 32-bit offset in static TLS block */
3839#define R_TILEGX_TLS_GD_CALL 112 /* "jal" for TLS GD */
3840#define R_TILEGX_IMM8_X0_TLS_GD_ADD 113 /* X0 pipe "addi" for TLS GD */
3841#define R_TILEGX_IMM8_X1_TLS_GD_ADD 114 /* X1 pipe "addi" for TLS GD */
3842#define R_TILEGX_IMM8_Y0_TLS_GD_ADD 115 /* Y0 pipe "addi" for TLS GD */
3843#define R_TILEGX_IMM8_Y1_TLS_GD_ADD 116 /* Y1 pipe "addi" for TLS GD */
3844#define R_TILEGX_TLS_IE_LOAD 117 /* "ld_tls" for TLS IE */
3845#define R_TILEGX_IMM8_X0_TLS_ADD 118 /* X0 pipe "addi" for TLS GD/IE */
3846#define R_TILEGX_IMM8_X1_TLS_ADD 119 /* X1 pipe "addi" for TLS GD/IE */
3847#define R_TILEGX_IMM8_Y0_TLS_ADD 120 /* Y0 pipe "addi" for TLS GD/IE */
3848#define R_TILEGX_IMM8_Y1_TLS_ADD 121 /* Y1 pipe "addi" for TLS GD/IE */
3849
3850#define R_TILEGX_GNU_VTINHERIT 128 /* GNU C++ vtable hierarchy */
3851#define R_TILEGX_GNU_VTENTRY 129 /* GNU C++ vtable member usage */
3852
3853#define R_TILEGX_NUM 130
3854
3855/* RISC-V ELF Flags */
3856#define EF_RISCV_RVC 0x0001
3857#define EF_RISCV_FLOAT_ABI 0x0006
3858#define EF_RISCV_FLOAT_ABI_SOFT 0x0000
3859#define EF_RISCV_FLOAT_ABI_SINGLE 0x0002
3860#define EF_RISCV_FLOAT_ABI_DOUBLE 0x0004
3861#define EF_RISCV_FLOAT_ABI_QUAD 0x0006
3862
3863/* RISC-V relocations. */
3864#define R_RISCV_NONE 0
3865#define R_RISCV_32 1
3866#define R_RISCV_64 2
3867#define R_RISCV_RELATIVE 3
3868#define R_RISCV_COPY 4
3869#define R_RISCV_JUMP_SLOT 5
3870#define R_RISCV_TLS_DTPMOD32 6
3871#define R_RISCV_TLS_DTPMOD64 7
3872#define R_RISCV_TLS_DTPREL32 8
3873#define R_RISCV_TLS_DTPREL64 9
3874#define R_RISCV_TLS_TPREL32 10
3875#define R_RISCV_TLS_TPREL64 11
3876#define R_RISCV_BRANCH 16
3877#define R_RISCV_JAL 17
3878#define R_RISCV_CALL 18
3879#define R_RISCV_CALL_PLT 19
3880#define R_RISCV_GOT_HI20 20
3881#define R_RISCV_TLS_GOT_HI20 21
3882#define R_RISCV_TLS_GD_HI20 22
3883#define R_RISCV_PCREL_HI20 23
3884#define R_RISCV_PCREL_LO12_I 24
3885#define R_RISCV_PCREL_LO12_S 25
3886#define R_RISCV_HI20 26
3887#define R_RISCV_LO12_I 27
3888#define R_RISCV_LO12_S 28
3889#define R_RISCV_TPREL_HI20 29
3890#define R_RISCV_TPREL_LO12_I 30
3891#define R_RISCV_TPREL_LO12_S 31
3892#define R_RISCV_TPREL_ADD 32
3893#define R_RISCV_ADD8 33
3894#define R_RISCV_ADD16 34
3895#define R_RISCV_ADD32 35
3896#define R_RISCV_ADD64 36
3897#define R_RISCV_SUB8 37
3898#define R_RISCV_SUB16 38
3899#define R_RISCV_SUB32 39
3900#define R_RISCV_SUB64 40
3901#define R_RISCV_GNU_VTINHERIT 41
3902#define R_RISCV_GNU_VTENTRY 42
3903#define R_RISCV_ALIGN 43
3904#define R_RISCV_RVC_BRANCH 44
3905#define R_RISCV_RVC_JUMP 45
3906#define R_RISCV_RVC_LUI 46
3907#define R_RISCV_GPREL_I 47
3908#define R_RISCV_GPREL_S 48
3909#define R_RISCV_TPREL_I 49
3910#define R_RISCV_TPREL_S 50
3911#define R_RISCV_RELAX 51
3912#define R_RISCV_SUB6 52
3913#define R_RISCV_SET6 53
3914#define R_RISCV_SET8 54
3915#define R_RISCV_SET16 55
3916#define R_RISCV_SET32 56
3917#define R_RISCV_32_PCREL 57
3918
3919#define R_RISCV_NUM 58
3920
3921/* BPF specific declarations. */
3922
3923#define R_BPF_NONE 0 /* No reloc */
3924#define R_BPF_64_64 1
3925#define R_BPF_64_32 10
3926
3927/* Imagination Meta specific relocations. */
3928
3929#define R_METAG_HIADDR16 0
3930#define R_METAG_LOADDR16 1
3931#define R_METAG_ADDR32 2 /* 32bit absolute address */
3932#define R_METAG_NONE 3 /* No reloc */
3933#define R_METAG_RELBRANCH 4
3934#define R_METAG_GETSETOFF 5
3935
3936/* Backward compatability */
3937#define R_METAG_REG32OP1 6
3938#define R_METAG_REG32OP2 7
3939#define R_METAG_REG32OP3 8
3940#define R_METAG_REG16OP1 9
3941#define R_METAG_REG16OP2 10
3942#define R_METAG_REG16OP3 11
3943#define R_METAG_REG32OP4 12
3944
3945#define R_METAG_HIOG 13
3946#define R_METAG_LOOG 14
3947
3948#define R_METAG_REL8 15
3949#define R_METAG_REL16 16
3950
3951/* GNU */
3952#define R_METAG_GNU_VTINHERIT 30
3953#define R_METAG_GNU_VTENTRY 31
3954
3955/* PIC relocations */
3956#define R_METAG_HI16_GOTOFF 32
3957#define R_METAG_LO16_GOTOFF 33
3958#define R_METAG_GETSET_GOTOFF 34
3959#define R_METAG_GETSET_GOT 35
3960#define R_METAG_HI16_GOTPC 36
3961#define R_METAG_LO16_GOTPC 37
3962#define R_METAG_HI16_PLT 38
3963#define R_METAG_LO16_PLT 39
3964#define R_METAG_RELBRANCH_PLT 40
3965#define R_METAG_GOTOFF 41
3966#define R_METAG_PLT 42
3967#define R_METAG_COPY 43
3968#define R_METAG_JMP_SLOT 44
3969#define R_METAG_RELATIVE 45
3970#define R_METAG_GLOB_DAT 46
3971
3972/* TLS relocations */
3973#define R_METAG_TLS_GD 47
3974#define R_METAG_TLS_LDM 48
3975#define R_METAG_TLS_LDO_HI16 49
3976#define R_METAG_TLS_LDO_LO16 50
3977#define R_METAG_TLS_LDO 51
3978#define R_METAG_TLS_IE 52
3979#define R_METAG_TLS_IENONPIC 53
3980#define R_METAG_TLS_IENONPIC_HI16 54
3981#define R_METAG_TLS_IENONPIC_LO16 55
3982#define R_METAG_TLS_TPOFF 56
3983#define R_METAG_TLS_DTPMOD 57
3984#define R_METAG_TLS_DTPOFF 58
3985#define R_METAG_TLS_LE 59
3986#define R_METAG_TLS_LE_HI16 60
3987#define R_METAG_TLS_LE_LO16 61
3988
3989/* NDS32 relocations. */
3990#define R_NDS32_NONE 0
3991#define R_NDS32_32_RELA 20
3992#define R_NDS32_COPY 39
3993#define R_NDS32_GLOB_DAT 40
3994#define R_NDS32_JMP_SLOT 41
3995#define R_NDS32_RELATIVE 42
3996#define R_NDS32_TLS_TPOFF 102
3997#define R_NDS32_TLS_DESC 119
3998
3999__END_DECLS
4000
4001#endif /* elf.h */
libc/glibc-include/endian.h created+97
...@@ -0,0 +1,97 @@
1/* Copyright (C) 1992-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _ENDIAN_H
19#define _ENDIAN_H 1
20
21#include <features.h>
22
23/* Definitions for byte order, according to significance of bytes,
24 from low addresses to high addresses. The value is what you get by
25 putting '4' in the most significant byte, '3' in the second most
26 significant byte, '2' in the second least significant byte, and '1'
27 in the least significant byte, and then writing down one digit for
28 each byte, starting with the byte at the lowest address at the left,
29 and proceeding to the byte with the highest address at the right. */
30
31#define __LITTLE_ENDIAN 1234
32#define __BIG_ENDIAN 4321
33#define __PDP_ENDIAN 3412
34
35/* This file defines `__BYTE_ORDER' for the particular machine. */
36#include <bits/endian.h>
37
38/* Some machines may need to use a different endianness for floating point
39 values. */
40#ifndef __FLOAT_WORD_ORDER
41# define __FLOAT_WORD_ORDER __BYTE_ORDER
42#endif
43
44#ifdef __USE_MISC
45# define LITTLE_ENDIAN __LITTLE_ENDIAN
46# define BIG_ENDIAN __BIG_ENDIAN
47# define PDP_ENDIAN __PDP_ENDIAN
48# define BYTE_ORDER __BYTE_ORDER
49#endif
50
51#if __BYTE_ORDER == __LITTLE_ENDIAN
52# define __LONG_LONG_PAIR(HI, LO) LO, HI
53#elif __BYTE_ORDER == __BIG_ENDIAN
54# define __LONG_LONG_PAIR(HI, LO) HI, LO
55#endif
56
57
58#if defined __USE_MISC && !defined __ASSEMBLER__
59/* Conversion interfaces. */
60# include <bits/byteswap.h>
61# include <bits/uintn-identity.h>
62
63# if __BYTE_ORDER == __LITTLE_ENDIAN
64# define htobe16(x) __bswap_16 (x)
65# define htole16(x) __uint16_identity (x)
66# define be16toh(x) __bswap_16 (x)
67# define le16toh(x) __uint16_identity (x)
68
69# define htobe32(x) __bswap_32 (x)
70# define htole32(x) __uint32_identity (x)
71# define be32toh(x) __bswap_32 (x)
72# define le32toh(x) __uint32_identity (x)
73
74# define htobe64(x) __bswap_64 (x)
75# define htole64(x) __uint64_identity (x)
76# define be64toh(x) __bswap_64 (x)
77# define le64toh(x) __uint64_identity (x)
78
79# else
80# define htobe16(x) __uint16_identity (x)
81# define htole16(x) __bswap_16 (x)
82# define be16toh(x) __uint16_identity (x)
83# define le16toh(x) __bswap_16 (x)
84
85# define htobe32(x) __uint32_identity (x)
86# define htole32(x) __bswap_32 (x)
87# define be32toh(x) __uint32_identity (x)
88# define le32toh(x) __bswap_32 (x)
89
90# define htobe64(x) __uint64_identity (x)
91# define htole64(x) __bswap_64 (x)
92# define be64toh(x) __uint64_identity (x)
93# define le64toh(x) __bswap_64 (x)
94# endif
95#endif
96
97#endif /* endian.h */
libc/glibc-include/envz.h created+73
...@@ -0,0 +1,73 @@
1/* Routines for dealing with '\0' separated environment vectors
2 Copyright (C) 1995-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _ENVZ_H
20#define _ENVZ_H 1
21
22#include <features.h>
23
24#include <errno.h>
25
26/* Envz's are argz's too, and should be created etc., using the same
27 routines. */
28#include <argz.h>
29
30__BEGIN_DECLS
31
32/* Returns a pointer to the entry in ENVZ for NAME, or 0 if there is none. */
33extern char *envz_entry (const char *__restrict __envz, size_t __envz_len,
34 const char *__restrict __name)
35 __THROW __attribute_pure__;
36
37/* Returns a pointer to the value portion of the entry in ENVZ for NAME, or 0
38 if there is none. */
39extern char *envz_get (const char *__restrict __envz, size_t __envz_len,
40 const char *__restrict __name)
41 __THROW __attribute_pure__;
42
43/* Adds an entry for NAME with value VALUE to ENVZ & ENVZ_LEN. If an entry
44 with the same name already exists in ENVZ, it is removed. If VALUE is
45 NULL, then the new entry will a special null one, for which envz_get will
46 return NULL, although envz_entry will still return an entry; this is handy
47 because when merging with another envz, the null entry can override an
48 entry in the other one. Null entries can be removed with envz_strip (). */
49extern error_t envz_add (char **__restrict __envz,
50 size_t *__restrict __envz_len,
51 const char *__restrict __name,
52 const char *__restrict __value) __THROW;
53
54/* Adds each entry in ENVZ2 to ENVZ & ENVZ_LEN, as if with envz_add(). If
55 OVERRIDE is true, then values in ENVZ2 will supersede those with the same
56 name in ENV, otherwise not. */
57extern error_t envz_merge (char **__restrict __envz,
58 size_t *__restrict __envz_len,
59 const char *__restrict __envz2,
60 size_t __envz2_len, int __override) __THROW;
61
62/* Remove the entry for NAME from ENVZ & ENVZ_LEN, if any. */
63extern void envz_remove (char **__restrict __envz,
64 size_t *__restrict __envz_len,
65 const char *__restrict __name) __THROW;
66
67/* Remove null entries. */
68extern void envz_strip (char **__restrict __envz,
69 size_t *__restrict __envz_len) __THROW;
70
71__END_DECLS
72
73#endif /* envz.h */
libc/glibc-include/err.h created+57
...@@ -0,0 +1,57 @@
1/* 4.4BSD utility functions for error messages.
2 Copyright (C) 1995-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _ERR_H
20#define _ERR_H 1
21
22#include <features.h>
23
24#define __need___va_list
25#include <stdarg.h>
26#ifndef __GNUC_VA_LIST
27# define __gnuc_va_list void *
28#endif
29
30__BEGIN_DECLS
31
32/* Print "program: ", FORMAT, ": ", the standard error string for errno,
33 and a newline, on stderr. */
34extern void warn (const char *__format, ...)
35 __attribute__ ((__format__ (__printf__, 1, 2)));
36extern void vwarn (const char *__format, __gnuc_va_list)
37 __attribute__ ((__format__ (__printf__, 1, 0)));
38
39/* Likewise, but without ": " and the standard error string. */
40extern void warnx (const char *__format, ...)
41 __attribute__ ((__format__ (__printf__, 1, 2)));
42extern void vwarnx (const char *__format, __gnuc_va_list)
43 __attribute__ ((__format__ (__printf__, 1, 0)));
44
45/* Likewise, and then exit with STATUS. */
46extern void err (int __status, const char *__format, ...)
47 __attribute__ ((__noreturn__, __format__ (__printf__, 2, 3)));
48extern void verr (int __status, const char *__format, __gnuc_va_list)
49 __attribute__ ((__noreturn__, __format__ (__printf__, 2, 0)));
50extern void errx (int __status, const char *__format, ...)
51 __attribute__ ((__noreturn__, __format__ (__printf__, 2, 3)));
52extern void verrx (int __status, const char *, __gnuc_va_list)
53 __attribute__ ((__noreturn__, __format__ (__printf__, 2, 0)));
54
55__END_DECLS
56
57#endif /* err.h */
libc/glibc-include/errno.h created+55
...@@ -0,0 +1,55 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/*
19 * ISO C99 Standard: 7.5 Errors <errno.h>
20 */
21
22#ifndef _ERRNO_H
23#define _ERRNO_H 1
24
25#include <features.h>
26
27/* The system-specific definitions of the E* constants, as macros. */
28#include <bits/errno.h>
29
30/* When included from assembly language, this header only provides the
31 E* constants. */
32#ifndef __ASSEMBLER__
33
34__BEGIN_DECLS
35
36/* The error code set by various library functions. */
37extern int *__errno_location (void) __THROW __attribute_const__;
38# define errno (*__errno_location ())
39
40# ifdef __USE_GNU
41
42/* The full and simple forms of the name with which the program was
43 invoked. These variables are set up automatically at startup based on
44 the value of argv[0]. */
45extern char *program_invocation_name;
46extern char *program_invocation_short_name;
47
48#include <bits/types/error_t.h>
49
50# endif /* __USE_GNU */
51
52__END_DECLS
53
54#endif /* !__ASSEMBLER__ */
55#endif /* errno.h */
libc/glibc-include/error.h created+57
...@@ -0,0 +1,57 @@
1/* Declaration for error-reporting function
2 Copyright (C) 1995-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _ERROR_H
20#define _ERROR_H 1
21
22#include <features.h>
23
24
25__BEGIN_DECLS
26
27/* Print a message with `fprintf (stderr, FORMAT, ...)';
28 if ERRNUM is nonzero, follow it with ": " and strerror (ERRNUM).
29 If STATUS is nonzero, terminate the program with `exit (STATUS)'. */
30
31extern void error (int __status, int __errnum, const char *__format, ...)
32 __attribute__ ((__format__ (__printf__, 3, 4)));
33
34extern void error_at_line (int __status, int __errnum, const char *__fname,
35 unsigned int __lineno, const char *__format, ...)
36 __attribute__ ((__format__ (__printf__, 5, 6)));
37
38/* If NULL, error will flush stdout, then print on stderr the program
39 name, a colon and a space. Otherwise, error will call this
40 function without parameters instead. */
41extern void (*error_print_progname) (void);
42
43/* This variable is incremented each time `error' is called. */
44extern unsigned int error_message_count;
45
46/* Sometimes we want to have at most one error per line. This
47 variable controls whether this mode is selected or not. */
48extern int error_one_per_line;
49
50
51#if defined __extern_always_inline && defined __va_arg_pack
52# include <bits/error.h>
53#endif
54
55__END_DECLS
56
57#endif /* error.h */
libc/glibc-include/execinfo.h created+43
...@@ -0,0 +1,43 @@
1/* Copyright (C) 1998-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _EXECINFO_H
19#define _EXECINFO_H 1
20
21#include <features.h>
22
23__BEGIN_DECLS
24
25/* Store up to SIZE return address of the current program state in
26 ARRAY and return the exact number of values stored. */
27extern int backtrace (void **__array, int __size) __nonnull ((1));
28
29
30/* Return names of functions from the backtrace list in ARRAY in a newly
31 malloc()ed memory block. */
32extern char **backtrace_symbols (void *const *__array, int __size)
33 __THROW __nonnull ((1));
34
35
36/* This function is similar to backtrace_symbols() but it writes the result
37 immediately to a file. */
38extern void backtrace_symbols_fd (void *const *__array, int __size, int __fd)
39 __THROW __nonnull ((1));
40
41__END_DECLS
42
43#endif /* execinfo.h */
libc/glibc-include/fcntl.h created+333
...@@ -0,0 +1,333 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/*
19 * POSIX Standard: 6.5 File Control Operations <fcntl.h>
20 */
21
22#ifndef _FCNTL_H
23#define _FCNTL_H 1
24
25#include <features.h>
26
27/* This must be early so <bits/fcntl.h> can define types winningly. */
28__BEGIN_DECLS
29
30/* Get __mode_t, __dev_t and __off_t .*/
31#include <bits/types.h>
32
33/* Get the definitions of O_*, F_*, FD_*: all the
34 numbers and flag bits for `open', `fcntl', et al. */
35#include <bits/fcntl.h>
36
37/* Detect if open needs mode as a third argument (or for openat as a fourth
38 argument). */
39#ifdef __O_TMPFILE
40# define __OPEN_NEEDS_MODE(oflag) \
41 (((oflag) & O_CREAT) != 0 || ((oflag) & __O_TMPFILE) == __O_TMPFILE)
42#else
43# define __OPEN_NEEDS_MODE(oflag) (((oflag) & O_CREAT) != 0)
44#endif
45
46/* POSIX.1-2001 specifies that these types are defined by <fcntl.h>.
47 Earlier POSIX standards permitted any type ending in `_t' to be defined
48 by any POSIX header, so we don't conditionalize the definitions here. */
49#ifndef __mode_t_defined
50typedef __mode_t mode_t;
51# define __mode_t_defined
52#endif
53
54#ifndef __off_t_defined
55# ifndef __USE_FILE_OFFSET64
56typedef __off_t off_t;
57# else
58typedef __off64_t off_t;
59# endif
60# define __off_t_defined
61#endif
62
63#if defined __USE_LARGEFILE64 && !defined __off64_t_defined
64typedef __off64_t off64_t;
65# define __off64_t_defined
66#endif
67
68#ifndef __pid_t_defined
69typedef __pid_t pid_t;
70# define __pid_t_defined
71#endif
72
73/* For XPG all symbols from <sys/stat.h> should also be available. */
74#ifdef __USE_XOPEN2K8
75# include <bits/types/struct_timespec.h>
76#endif
77#if defined __USE_XOPEN || defined __USE_XOPEN2K8
78# include <bits/stat.h>
79
80# define S_IFMT __S_IFMT
81# define S_IFDIR __S_IFDIR
82# define S_IFCHR __S_IFCHR
83# define S_IFBLK __S_IFBLK
84# define S_IFREG __S_IFREG
85# ifdef __S_IFIFO
86# define S_IFIFO __S_IFIFO
87# endif
88# ifdef __S_IFLNK
89# define S_IFLNK __S_IFLNK
90# endif
91# if (defined __USE_UNIX98 || defined __USE_XOPEN2K8) && defined __S_IFSOCK
92# define S_IFSOCK __S_IFSOCK
93# endif
94
95/* Protection bits. */
96
97# define S_ISUID __S_ISUID /* Set user ID on execution. */
98# define S_ISGID __S_ISGID /* Set group ID on execution. */
99
100# if defined __USE_MISC || defined __USE_XOPEN
101/* Save swapped text after use (sticky bit). This is pretty well obsolete. */
102# define S_ISVTX __S_ISVTX
103# endif
104
105# define S_IRUSR __S_IREAD /* Read by owner. */
106# define S_IWUSR __S_IWRITE /* Write by owner. */
107# define S_IXUSR __S_IEXEC /* Execute by owner. */
108/* Read, write, and execute by owner. */
109# define S_IRWXU (__S_IREAD|__S_IWRITE|__S_IEXEC)
110
111# define S_IRGRP (S_IRUSR >> 3) /* Read by group. */
112# define S_IWGRP (S_IWUSR >> 3) /* Write by group. */
113# define S_IXGRP (S_IXUSR >> 3) /* Execute by group. */
114/* Read, write, and execute by group. */
115# define S_IRWXG (S_IRWXU >> 3)
116
117# define S_IROTH (S_IRGRP >> 3) /* Read by others. */
118# define S_IWOTH (S_IWGRP >> 3) /* Write by others. */
119# define S_IXOTH (S_IXGRP >> 3) /* Execute by others. */
120/* Read, write, and execute by others. */
121# define S_IRWXO (S_IRWXG >> 3)
122#endif
123
124#ifdef __USE_MISC
125# ifndef R_OK /* Verbatim from <unistd.h>. Ugh. */
126/* Values for the second argument to access.
127 These may be OR'd together. */
128# define R_OK 4 /* Test for read permission. */
129# define W_OK 2 /* Test for write permission. */
130# define X_OK 1 /* Test for execute permission. */
131# define F_OK 0 /* Test for existence. */
132# endif
133#endif /* Use misc. */
134
135/* XPG wants the following symbols. <stdio.h> has the same definitions. */
136#if defined __USE_XOPEN || defined __USE_XOPEN2K8
137# define SEEK_SET 0 /* Seek from beginning of file. */
138# define SEEK_CUR 1 /* Seek from current position. */
139# define SEEK_END 2 /* Seek from end of file. */
140#endif /* XPG */
141
142/* The constants AT_REMOVEDIR and AT_EACCESS have the same value. AT_EACCESS
143 is meaningful only to faccessat, while AT_REMOVEDIR is meaningful only to
144 unlinkat. The two functions do completely different things and therefore,
145 the flags can be allowed to overlap. For example, passing AT_REMOVEDIR to
146 faccessat would be undefined behavior and thus treating it equivalent to
147 AT_EACCESS is valid undefined behavior. */
148#ifdef __USE_ATFILE
149# define AT_FDCWD -100 /* Special value used to indicate
150 the *at functions should use the
151 current working directory. */
152# define AT_SYMLINK_NOFOLLOW 0x100 /* Do not follow symbolic links. */
153# define AT_REMOVEDIR 0x200 /* Remove directory instead of
154 unlinking file. */
155# define AT_SYMLINK_FOLLOW 0x400 /* Follow symbolic links. */
156# ifdef __USE_GNU
157# define AT_NO_AUTOMOUNT 0x800 /* Suppress terminal automount
158 traversal. */
159# define AT_EMPTY_PATH 0x1000 /* Allow empty relative pathname. */
160# define AT_STATX_SYNC_TYPE 0x6000
161# define AT_STATX_SYNC_AS_STAT 0x0000
162# define AT_STATX_FORCE_SYNC 0x2000
163# define AT_STATX_DONT_SYNC 0x4000
164# endif
165# define AT_EACCESS 0x200 /* Test access permitted for
166 effective IDs, not real IDs. */
167#endif
168
169/* Do the file control operation described by CMD on FD.
170 The remaining arguments are interpreted depending on CMD.
171
172 This function is a cancellation point and therefore not marked with
173 __THROW. */
174#ifndef __USE_FILE_OFFSET64
175extern int fcntl (int __fd, int __cmd, ...);
176#else
177# ifdef __REDIRECT
178extern int __REDIRECT (fcntl, (int __fd, int __cmd, ...), fcntl64);
179# else
180# define fcntl fcntl64
181# endif
182#endif
183#ifdef __USE_LARGEFILE64
184extern int fcntl64 (int __fd, int __cmd, ...);
185#endif
186
187/* Open FILE and return a new file descriptor for it, or -1 on error.
188 OFLAG determines the type of access used. If O_CREAT or O_TMPFILE is set
189 in OFLAG, the third argument is taken as a `mode_t', the mode of the
190 created file.
191
192 This function is a cancellation point and therefore not marked with
193 __THROW. */
194#ifndef __USE_FILE_OFFSET64
195extern int open (const char *__file, int __oflag, ...) __nonnull ((1));
196#else
197# ifdef __REDIRECT
198extern int __REDIRECT (open, (const char *__file, int __oflag, ...), open64)
199 __nonnull ((1));
200# else
201# define open open64
202# endif
203#endif
204#ifdef __USE_LARGEFILE64
205extern int open64 (const char *__file, int __oflag, ...) __nonnull ((1));
206#endif
207
208#ifdef __USE_ATFILE
209/* Similar to `open' but a relative path name is interpreted relative to
210 the directory for which FD is a descriptor.
211
212 NOTE: some other `openat' implementation support additional functionality
213 through this interface, especially using the O_XATTR flag. This is not
214 yet supported here.
215
216 This function is a cancellation point and therefore not marked with
217 __THROW. */
218# ifndef __USE_FILE_OFFSET64
219extern int openat (int __fd, const char *__file, int __oflag, ...)
220 __nonnull ((2));
221# else
222# ifdef __REDIRECT
223extern int __REDIRECT (openat, (int __fd, const char *__file, int __oflag,
224 ...), openat64) __nonnull ((2));
225# else
226# define openat openat64
227# endif
228# endif
229# ifdef __USE_LARGEFILE64
230extern int openat64 (int __fd, const char *__file, int __oflag, ...)
231 __nonnull ((2));
232# endif
233#endif
234
235/* Create and open FILE, with mode MODE. This takes an `int' MODE
236 argument because that is what `mode_t' will be widened to.
237
238 This function is a cancellation point and therefore not marked with
239 __THROW. */
240#ifndef __USE_FILE_OFFSET64
241extern int creat (const char *__file, mode_t __mode) __nonnull ((1));
242#else
243# ifdef __REDIRECT
244extern int __REDIRECT (creat, (const char *__file, mode_t __mode),
245 creat64) __nonnull ((1));
246# else
247# define creat creat64
248# endif
249#endif
250#ifdef __USE_LARGEFILE64
251extern int creat64 (const char *__file, mode_t __mode) __nonnull ((1));
252#endif
253
254#if !defined F_LOCK && (defined __USE_MISC || (defined __USE_XOPEN_EXTENDED \
255 && !defined __USE_POSIX))
256/* NOTE: These declarations also appear in <unistd.h>; be sure to keep both
257 files consistent. Some systems have them there and some here, and some
258 software depends on the macros being defined without including both. */
259
260/* `lockf' is a simpler interface to the locking facilities of `fcntl'.
261 LEN is always relative to the current file position.
262 The CMD argument is one of the following. */
263
264# define F_ULOCK 0 /* Unlock a previously locked region. */
265# define F_LOCK 1 /* Lock a region for exclusive use. */
266# define F_TLOCK 2 /* Test and lock a region for exclusive use. */
267# define F_TEST 3 /* Test a region for other processes locks. */
268
269# ifndef __USE_FILE_OFFSET64
270extern int lockf (int __fd, int __cmd, off_t __len);
271# else
272# ifdef __REDIRECT
273extern int __REDIRECT (lockf, (int __fd, int __cmd, __off64_t __len), lockf64);
274# else
275# define lockf lockf64
276# endif
277# endif
278# ifdef __USE_LARGEFILE64
279extern int lockf64 (int __fd, int __cmd, off64_t __len);
280# endif
281#endif
282
283#ifdef __USE_XOPEN2K
284/* Advice the system about the expected behaviour of the application with
285 respect to the file associated with FD. */
286# ifndef __USE_FILE_OFFSET64
287extern int posix_fadvise (int __fd, off_t __offset, off_t __len,
288 int __advise) __THROW;
289# else
290 # ifdef __REDIRECT_NTH
291extern int __REDIRECT_NTH (posix_fadvise, (int __fd, __off64_t __offset,
292 __off64_t __len, int __advise),
293 posix_fadvise64);
294# else
295# define posix_fadvise posix_fadvise64
296# endif
297# endif
298# ifdef __USE_LARGEFILE64
299extern int posix_fadvise64 (int __fd, off64_t __offset, off64_t __len,
300 int __advise) __THROW;
301# endif
302
303
304/* Reserve storage for the data of the file associated with FD.
305
306 This function is a possible cancellation point and therefore not
307 marked with __THROW. */
308# ifndef __USE_FILE_OFFSET64
309extern int posix_fallocate (int __fd, off_t __offset, off_t __len);
310# else
311 # ifdef __REDIRECT
312extern int __REDIRECT (posix_fallocate, (int __fd, __off64_t __offset,
313 __off64_t __len),
314 posix_fallocate64);
315# else
316# define posix_fallocate posix_fallocate64
317# endif
318# endif
319# ifdef __USE_LARGEFILE64
320extern int posix_fallocate64 (int __fd, off64_t __offset, off64_t __len);
321# endif
322#endif
323
324
325/* Define some inlines helping to catch common problems. */
326#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function \
327 && defined __va_arg_pack_len
328# include <bits/fcntl2.h>
329#endif
330
331__END_DECLS
332
333#endif /* fcntl.h */
libc/glibc-include/features.h created+477
...@@ -0,0 +1,477 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _FEATURES_H
19#define _FEATURES_H 1
20
21/* These are defined by the user (or the compiler)
22 to specify the desired environment:
23
24 __STRICT_ANSI__ ISO Standard C.
25 _ISOC99_SOURCE Extensions to ISO C89 from ISO C99.
26 _ISOC11_SOURCE Extensions to ISO C99 from ISO C11.
27 __STDC_WANT_LIB_EXT2__
28 Extensions to ISO C99 from TR 27431-2:2010.
29 __STDC_WANT_IEC_60559_BFP_EXT__
30 Extensions to ISO C11 from TS 18661-1:2014.
31 __STDC_WANT_IEC_60559_FUNCS_EXT__
32 Extensions to ISO C11 from TS 18661-4:2015.
33 __STDC_WANT_IEC_60559_TYPES_EXT__
34 Extensions to ISO C11 from TS 18661-3:2015.
35
36 _POSIX_SOURCE IEEE Std 1003.1.
37 _POSIX_C_SOURCE If ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2;
38 if >=199309L, add IEEE Std 1003.1b-1993;
39 if >=199506L, add IEEE Std 1003.1c-1995;
40 if >=200112L, all of IEEE 1003.1-2004
41 if >=200809L, all of IEEE 1003.1-2008
42 _XOPEN_SOURCE Includes POSIX and XPG things. Set to 500 if
43 Single Unix conformance is wanted, to 600 for the
44 sixth revision, to 700 for the seventh revision.
45 _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions.
46 _LARGEFILE_SOURCE Some more functions for correct standard I/O.
47 _LARGEFILE64_SOURCE Additional functionality from LFS for large files.
48 _FILE_OFFSET_BITS=N Select default filesystem interface.
49 _ATFILE_SOURCE Additional *at interfaces.
50 _GNU_SOURCE All of the above, plus GNU extensions.
51 _DEFAULT_SOURCE The default set of features (taking precedence over
52 __STRICT_ANSI__).
53
54 _FORTIFY_SOURCE Add security hardening to many library functions.
55 Set to 1 or 2; 2 performs stricter checks than 1.
56
57 _REENTRANT, _THREAD_SAFE
58 Obsolete; equivalent to _POSIX_C_SOURCE=199506L.
59
60 The `-ansi' switch to the GNU C compiler, and standards conformance
61 options such as `-std=c99', define __STRICT_ANSI__. If none of
62 these are defined, or if _DEFAULT_SOURCE is defined, the default is
63 to have _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to
64 200809L, as well as enabling miscellaneous functions from BSD and
65 SVID. If more than one of these are defined, they accumulate. For
66 example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE together
67 give you ISO C, 1003.1, and 1003.2, but nothing else.
68
69 These are defined by this file and are used by the
70 header files to decide what to declare or define:
71
72 __GLIBC_USE (F) Define things from feature set F. This is defined
73 to 1 or 0; the subsequent macros are either defined
74 or undefined, and those tests should be moved to
75 __GLIBC_USE.
76 __USE_ISOC11 Define ISO C11 things.
77 __USE_ISOC99 Define ISO C99 things.
78 __USE_ISOC95 Define ISO C90 AMD1 (C95) things.
79 __USE_ISOCXX11 Define ISO C++11 things.
80 __USE_POSIX Define IEEE Std 1003.1 things.
81 __USE_POSIX2 Define IEEE Std 1003.2 things.
82 __USE_POSIX199309 Define IEEE Std 1003.1, and .1b things.
83 __USE_POSIX199506 Define IEEE Std 1003.1, .1b, .1c and .1i things.
84 __USE_XOPEN Define XPG things.
85 __USE_XOPEN_EXTENDED Define X/Open Unix things.
86 __USE_UNIX98 Define Single Unix V2 things.
87 __USE_XOPEN2K Define XPG6 things.
88 __USE_XOPEN2KXSI Define XPG6 XSI things.
89 __USE_XOPEN2K8 Define XPG7 things.
90 __USE_XOPEN2K8XSI Define XPG7 XSI things.
91 __USE_LARGEFILE Define correct standard I/O things.
92 __USE_LARGEFILE64 Define LFS things with separate names.
93 __USE_FILE_OFFSET64 Define 64bit interface as default.
94 __USE_MISC Define things from 4.3BSD or System V Unix.
95 __USE_ATFILE Define *at interfaces and AT_* constants for them.
96 __USE_GNU Define GNU extensions.
97 __USE_FORTIFY_LEVEL Additional security measures used, according to level.
98
99 The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are
100 defined by this file unconditionally. `__GNU_LIBRARY__' is provided
101 only for compatibility. All new code should use the other symbols
102 to test for features.
103
104 All macros listed above as possibly being defined by this file are
105 explicitly undefined if they are not explicitly defined.
106 Feature-test macros that are not defined by the user or compiler
107 but are implied by the other feature-test macros defined (or by the
108 lack of any definitions) are defined by the file.
109
110 ISO C feature test macros depend on the definition of the macro
111 when an affected header is included, not when the first system
112 header is included, and so they are handled in
113 <bits/libc-header-start.h>, which does not have a multiple include
114 guard. Feature test macros that can be handled from the first
115 system header included are handled here. */
116
117
118/* Undefine everything, so we get a clean slate. */
119#undef __USE_ISOC11
120#undef __USE_ISOC99
121#undef __USE_ISOC95
122#undef __USE_ISOCXX11
123#undef __USE_POSIX
124#undef __USE_POSIX2
125#undef __USE_POSIX199309
126#undef __USE_POSIX199506
127#undef __USE_XOPEN
128#undef __USE_XOPEN_EXTENDED
129#undef __USE_UNIX98
130#undef __USE_XOPEN2K
131#undef __USE_XOPEN2KXSI
132#undef __USE_XOPEN2K8
133#undef __USE_XOPEN2K8XSI
134#undef __USE_LARGEFILE
135#undef __USE_LARGEFILE64
136#undef __USE_FILE_OFFSET64
137#undef __USE_MISC
138#undef __USE_ATFILE
139#undef __USE_GNU
140#undef __USE_FORTIFY_LEVEL
141#undef __KERNEL_STRICT_NAMES
142#undef __GLIBC_USE_DEPRECATED_GETS
143#undef __GLIBC_USE_DEPRECATED_SCANF
144
145/* Suppress kernel-name space pollution unless user expressedly asks
146 for it. */
147#ifndef _LOOSE_KERNEL_NAMES
148# define __KERNEL_STRICT_NAMES
149#endif
150
151/* Convenience macro to test the version of gcc.
152 Use like this:
153 #if __GNUC_PREREQ (2,8)
154 ... code requiring gcc 2.8 or later ...
155 #endif
156 Note: only works for GCC 2.0 and later, because __GNUC_MINOR__ was
157 added in 2.0. */
158#if defined __GNUC__ && defined __GNUC_MINOR__
159# define __GNUC_PREREQ(maj, min) \
160 ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
161#else
162# define __GNUC_PREREQ(maj, min) 0
163#endif
164
165/* Similarly for clang. Features added to GCC after version 4.2 may
166 or may not also be available in clang, and clang's definitions of
167 __GNUC(_MINOR)__ are fixed at 4 and 2 respectively. Not all such
168 features can be queried via __has_extension/__has_feature. */
169#if defined __clang_major__ && defined __clang_minor__
170# define __glibc_clang_prereq(maj, min) \
171 ((__clang_major__ << 16) + __clang_minor__ >= ((maj) << 16) + (min))
172#else
173# define __glibc_clang_prereq(maj, min) 0
174#endif
175
176/* Whether to use feature set F. */
177#define __GLIBC_USE(F) __GLIBC_USE_ ## F
178
179/* _BSD_SOURCE and _SVID_SOURCE are deprecated aliases for
180 _DEFAULT_SOURCE. If _DEFAULT_SOURCE is present we do not
181 issue a warning; the expectation is that the source is being
182 transitioned to use the new macro. */
183#if (defined _BSD_SOURCE || defined _SVID_SOURCE) \
184 && !defined _DEFAULT_SOURCE
185# warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE"
186# undef _DEFAULT_SOURCE
187# define _DEFAULT_SOURCE 1
188#endif
189
190/* If _GNU_SOURCE was defined by the user, turn on all the other features. */
191#ifdef _GNU_SOURCE
192# undef _ISOC95_SOURCE
193# define _ISOC95_SOURCE 1
194# undef _ISOC99_SOURCE
195# define _ISOC99_SOURCE 1
196# undef _ISOC11_SOURCE
197# define _ISOC11_SOURCE 1
198# undef _POSIX_SOURCE
199# define _POSIX_SOURCE 1
200# undef _POSIX_C_SOURCE
201# define _POSIX_C_SOURCE 200809L
202# undef _XOPEN_SOURCE
203# define _XOPEN_SOURCE 700
204# undef _XOPEN_SOURCE_EXTENDED
205# define _XOPEN_SOURCE_EXTENDED 1
206# undef _LARGEFILE64_SOURCE
207# define _LARGEFILE64_SOURCE 1
208# undef _DEFAULT_SOURCE
209# define _DEFAULT_SOURCE 1
210# undef _ATFILE_SOURCE
211# define _ATFILE_SOURCE 1
212#endif
213
214/* If nothing (other than _GNU_SOURCE and _DEFAULT_SOURCE) is defined,
215 define _DEFAULT_SOURCE. */
216#if (defined _DEFAULT_SOURCE \
217 || (!defined __STRICT_ANSI__ \
218 && !defined _ISOC99_SOURCE && !defined _ISOC11_SOURCE \
219 && !defined _POSIX_SOURCE && !defined _POSIX_C_SOURCE \
220 && !defined _XOPEN_SOURCE))
221# undef _DEFAULT_SOURCE
222# define _DEFAULT_SOURCE 1
223#endif
224
225/* This is to enable the ISO C11 extension. */
226#if (defined _ISOC11_SOURCE \
227 || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 201112L))
228# define __USE_ISOC11 1
229#endif
230
231/* This is to enable the ISO C99 extension. */
232#if (defined _ISOC99_SOURCE || defined _ISOC11_SOURCE \
233 || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L))
234# define __USE_ISOC99 1
235#endif
236
237/* This is to enable the ISO C90 Amendment 1:1995 extension. */
238#if (defined _ISOC99_SOURCE || defined _ISOC11_SOURCE \
239 || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199409L))
240# define __USE_ISOC95 1
241#endif
242
243#ifdef __cplusplus
244/* This is to enable compatibility for ISO C++17. */
245# if __cplusplus >= 201703L
246# define __USE_ISOC11 1
247# endif
248/* This is to enable compatibility for ISO C++11.
249 Check the temporary macro for now, too. */
250# if __cplusplus >= 201103L || defined __GXX_EXPERIMENTAL_CXX0X__
251# define __USE_ISOCXX11 1
252# define __USE_ISOC99 1
253# endif
254#endif
255
256/* If none of the ANSI/POSIX macros are defined, or if _DEFAULT_SOURCE
257 is defined, use POSIX.1-2008 (or another version depending on
258 _XOPEN_SOURCE). */
259#ifdef _DEFAULT_SOURCE
260# if !defined _POSIX_SOURCE && !defined _POSIX_C_SOURCE
261# define __USE_POSIX_IMPLICITLY 1
262# endif
263# undef _POSIX_SOURCE
264# define _POSIX_SOURCE 1
265# undef _POSIX_C_SOURCE
266# define _POSIX_C_SOURCE 200809L
267#endif
268
269#if ((!defined __STRICT_ANSI__ \
270 || (defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) >= 500)) \
271 && !defined _POSIX_SOURCE && !defined _POSIX_C_SOURCE)
272# define _POSIX_SOURCE 1
273# if defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) < 500
274# define _POSIX_C_SOURCE 2
275# elif defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) < 600
276# define _POSIX_C_SOURCE 199506L
277# elif defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) < 700
278# define _POSIX_C_SOURCE 200112L
279# else
280# define _POSIX_C_SOURCE 200809L
281# endif
282# define __USE_POSIX_IMPLICITLY 1
283#endif
284
285/* Some C libraries once required _REENTRANT and/or _THREAD_SAFE to be
286 defined in all multithreaded code. GNU libc has not required this
287 for many years. We now treat them as compatibility synonyms for
288 _POSIX_C_SOURCE=199506L, which is the earliest level of POSIX with
289 comprehensive support for multithreaded code. Using them never
290 lowers the selected level of POSIX conformance, only raises it. */
291#if ((!defined _POSIX_C_SOURCE || (_POSIX_C_SOURCE - 0) < 199506L) \
292 && (defined _REENTRANT || defined _THREAD_SAFE))
293# define _POSIX_SOURCE 1
294# undef _POSIX_C_SOURCE
295# define _POSIX_C_SOURCE 199506L
296#endif
297
298#if (defined _POSIX_SOURCE \
299 || (defined _POSIX_C_SOURCE && _POSIX_C_SOURCE >= 1) \
300 || defined _XOPEN_SOURCE)
301# define __USE_POSIX 1
302#endif
303
304#if defined _POSIX_C_SOURCE && _POSIX_C_SOURCE >= 2 || defined _XOPEN_SOURCE
305# define __USE_POSIX2 1
306#endif
307
308#if defined _POSIX_C_SOURCE && (_POSIX_C_SOURCE - 0) >= 199309L
309# define __USE_POSIX199309 1
310#endif
311
312#if defined _POSIX_C_SOURCE && (_POSIX_C_SOURCE - 0) >= 199506L
313# define __USE_POSIX199506 1
314#endif
315
316#if defined _POSIX_C_SOURCE && (_POSIX_C_SOURCE - 0) >= 200112L
317# define __USE_XOPEN2K 1
318# undef __USE_ISOC95
319# define __USE_ISOC95 1
320# undef __USE_ISOC99
321# define __USE_ISOC99 1
322#endif
323
324#if defined _POSIX_C_SOURCE && (_POSIX_C_SOURCE - 0) >= 200809L
325# define __USE_XOPEN2K8 1
326# undef _ATFILE_SOURCE
327# define _ATFILE_SOURCE 1
328#endif
329
330#ifdef _XOPEN_SOURCE
331# define __USE_XOPEN 1
332# if (_XOPEN_SOURCE - 0) >= 500
333# define __USE_XOPEN_EXTENDED 1
334# define __USE_UNIX98 1
335# undef _LARGEFILE_SOURCE
336# define _LARGEFILE_SOURCE 1
337# if (_XOPEN_SOURCE - 0) >= 600
338# if (_XOPEN_SOURCE - 0) >= 700
339# define __USE_XOPEN2K8 1
340# define __USE_XOPEN2K8XSI 1
341# endif
342# define __USE_XOPEN2K 1
343# define __USE_XOPEN2KXSI 1
344# undef __USE_ISOC95
345# define __USE_ISOC95 1
346# undef __USE_ISOC99
347# define __USE_ISOC99 1
348# endif
349# else
350# ifdef _XOPEN_SOURCE_EXTENDED
351# define __USE_XOPEN_EXTENDED 1
352# endif
353# endif
354#endif
355
356#ifdef _LARGEFILE_SOURCE
357# define __USE_LARGEFILE 1
358#endif
359
360#ifdef _LARGEFILE64_SOURCE
361# define __USE_LARGEFILE64 1
362#endif
363
364#if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS == 64
365# define __USE_FILE_OFFSET64 1
366#endif
367
368#if defined _DEFAULT_SOURCE
369# define __USE_MISC 1
370#endif
371
372#ifdef _ATFILE_SOURCE
373# define __USE_ATFILE 1
374#endif
375
376#ifdef _GNU_SOURCE
377# define __USE_GNU 1
378#endif
379
380#if defined _FORTIFY_SOURCE && _FORTIFY_SOURCE > 0
381# if !defined __OPTIMIZE__ || __OPTIMIZE__ <= 0
382# warning _FORTIFY_SOURCE requires compiling with optimization (-O)
383# elif !__GNUC_PREREQ (4, 1)
384# warning _FORTIFY_SOURCE requires GCC 4.1 or later
385# elif _FORTIFY_SOURCE > 1
386# define __USE_FORTIFY_LEVEL 2
387# else
388# define __USE_FORTIFY_LEVEL 1
389# endif
390#endif
391#ifndef __USE_FORTIFY_LEVEL
392# define __USE_FORTIFY_LEVEL 0
393#endif
394
395/* The function 'gets' existed in C89, but is impossible to use
396 safely. It has been removed from ISO C11 and ISO C++14. Note: for
397 compatibility with various implementations of <cstdio>, this test
398 must consider only the value of __cplusplus when compiling C++. */
399#if defined __cplusplus ? __cplusplus >= 201402L : defined __USE_ISOC11
400# define __GLIBC_USE_DEPRECATED_GETS 0
401#else
402# define __GLIBC_USE_DEPRECATED_GETS 1
403#endif
404
405/* GNU formerly extended the scanf functions with modified format
406 specifiers %as, %aS, and %a[...] that allocate a buffer for the
407 input using malloc. This extension conflicts with ISO C99, which
408 defines %a as a standalone format specifier that reads a floating-
409 point number; moreover, POSIX.1-2008 provides the same feature
410 using the modifier letter 'm' instead (%ms, %mS, %m[...]).
411
412 We now follow C99 unless GNU extensions are active and the compiler
413 is specifically in C89 or C++98 mode (strict or not). For
414 instance, with GCC, -std=gnu11 will have C99-compliant scanf with
415 or without -D_GNU_SOURCE, but -std=c89 -D_GNU_SOURCE will have the
416 old extension. */
417#if defined __USE_GNU && \
418 (defined __cplusplus \
419 ? (__cplusplus < 201103L && !defined __GXX_EXPERIMENTAL_CXX0X__) \
420 : (!defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L))
421# define __GLIBC_USE_DEPRECATED_SCANF 1
422#else
423# define __GLIBC_USE_DEPRECATED_SCANF 0
424#endif
425
426/* Get definitions of __STDC_* predefined macros, if the compiler has
427 not preincluded this header automatically. */
428#include <stdc-predef.h>
429
430/* This macro indicates that the installed library is the GNU C Library.
431 For historic reasons the value now is 6 and this will stay from now
432 on. The use of this variable is deprecated. Use __GLIBC__ and
433 __GLIBC_MINOR__ now (see below) when you want to test for a specific
434 GNU C library version and use the values in <gnu/lib-names.h> to get
435 the sonames of the shared libraries. */
436#undef __GNU_LIBRARY__
437#define __GNU_LIBRARY__ 6
438
439/* Major and minor version number of the GNU C library package. Use
440 these macros to test for features in specific releases. */
441#define __GLIBC__ 2
442#define __GLIBC_MINOR__ 29
443
444#define __GLIBC_PREREQ(maj, min) \
445 ((__GLIBC__ << 16) + __GLIBC_MINOR__ >= ((maj) << 16) + (min))
446
447/* This is here only because every header file already includes this one. */
448#ifndef __ASSEMBLER__
449# ifndef _SYS_CDEFS_H
450# include <sys/cdefs.h>
451# endif
452
453/* If we don't have __REDIRECT, prototypes will be missing if
454 __USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. */
455# if defined __USE_FILE_OFFSET64 && !defined __REDIRECT
456# define __USE_LARGEFILE 1
457# define __USE_LARGEFILE64 1
458# endif
459
460#endif /* !ASSEMBLER */
461
462/* Decide whether we can define 'extern inline' functions in headers. */
463#if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \
464 && !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__ \
465 && defined __extern_inline
466# define __USE_EXTERN_INLINES 1
467#endif
468
469
470/* This is here only because every header file already includes this one.
471 Get the definitions of all the appropriate `__stub_FUNCTION' symbols.
472 <gnu/stubs.h> contains `#define __stub_FUNCTION' when FUNCTION is a stub
473 that will always return failure (and set errno to ENOSYS). */
474#include <gnu/stubs.h>
475
476
477#endif /* features.h */
libc/glibc-include/fenv.h created+174
...@@ -0,0 +1,174 @@
1/* Copyright (C) 1997-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/*
19 * ISO C99 7.6: Floating-point environment <fenv.h>
20 */
21
22#ifndef _FENV_H
23#define _FENV_H 1
24
25#define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION
26#include <bits/libc-header-start.h>
27
28/* Get the architecture dependend definitions. The following definitions
29 are expected to be done:
30
31 fenv_t type for object representing an entire floating-point
32 environment
33
34 FE_DFL_ENV macro of type pointer to fenv_t to be used as the argument
35 to functions taking an argument of type fenv_t; in this
36 case the default environment will be used
37
38 fexcept_t type for object representing the floating-point exception
39 flags including status associated with the flags
40
41 femode_t type for object representing floating-point control modes
42
43 FE_DFL_MODE macro of type pointer to const femode_t to be used as the
44 argument to fesetmode; in this case the default control
45 modes will be used
46
47 The following macros are defined iff the implementation supports this
48 kind of exception.
49 FE_INEXACT inexact result
50 FE_DIVBYZERO division by zero
51 FE_UNDERFLOW result not representable due to underflow
52 FE_OVERFLOW result not representable due to overflow
53 FE_INVALID invalid operation
54
55 FE_ALL_EXCEPT bitwise OR of all supported exceptions
56
57 The next macros are defined iff the appropriate rounding mode is
58 supported by the implementation.
59 FE_TONEAREST round to nearest
60 FE_UPWARD round toward +Inf
61 FE_DOWNWARD round toward -Inf
62 FE_TOWARDZERO round toward 0
63*/
64#include <bits/fenv.h>
65
66__BEGIN_DECLS
67
68/* Floating-point exception handling. */
69
70/* Clear the supported exceptions represented by EXCEPTS. */
71extern int feclearexcept (int __excepts) __THROW;
72
73/* Store implementation-defined representation of the exception flags
74 indicated by EXCEPTS in the object pointed to by FLAGP. */
75extern int fegetexceptflag (fexcept_t *__flagp, int __excepts) __THROW;
76
77/* Raise the supported exceptions represented by EXCEPTS. */
78extern int feraiseexcept (int __excepts) __THROW;
79
80#if __GLIBC_USE (IEC_60559_BFP_EXT)
81/* Set the supported exception flags represented by EXCEPTS, without
82 causing enabled traps to be taken. */
83extern int fesetexcept (int __excepts) __THROW;
84#endif
85
86/* Set complete status for exceptions indicated by EXCEPTS according to
87 the representation in the object pointed to by FLAGP. */
88extern int fesetexceptflag (const fexcept_t *__flagp, int __excepts) __THROW;
89
90/* Determine which of subset of the exceptions specified by EXCEPTS are
91 currently set. */
92extern int fetestexcept (int __excepts) __THROW;
93
94#if __GLIBC_USE (IEC_60559_BFP_EXT)
95/* Determine which of subset of the exceptions specified by EXCEPTS
96 are set in *FLAGP. */
97extern int fetestexceptflag (const fexcept_t *__flagp, int __excepts) __THROW;
98#endif
99
100
101/* Rounding control. */
102
103/* Get current rounding direction. */
104extern int fegetround (void) __THROW __attribute_pure__;
105
106/* Establish the rounding direction represented by ROUND. */
107extern int fesetround (int __rounding_direction) __THROW;
108
109
110/* Floating-point environment. */
111
112/* Store the current floating-point environment in the object pointed
113 to by ENVP. */
114extern int fegetenv (fenv_t *__envp) __THROW;
115
116/* Save the current environment in the object pointed to by ENVP, clear
117 exception flags and install a non-stop mode (if available) for all
118 exceptions. */
119extern int feholdexcept (fenv_t *__envp) __THROW;
120
121/* Establish the floating-point environment represented by the object
122 pointed to by ENVP. */
123extern int fesetenv (const fenv_t *__envp) __THROW;
124
125/* Save current exceptions in temporary storage, install environment
126 represented by object pointed to by ENVP and raise exceptions
127 according to saved exceptions. */
128extern int feupdateenv (const fenv_t *__envp) __THROW;
129
130
131/* Control modes. */
132
133#if __GLIBC_USE (IEC_60559_BFP_EXT)
134/* Store the current floating-point control modes in the object
135 pointed to by MODEP. */
136extern int fegetmode (femode_t *__modep) __THROW;
137
138/* Establish the floating-point control modes represented by the
139 object pointed to by MODEP. */
140extern int fesetmode (const femode_t *__modep) __THROW;
141#endif
142
143/* Include optimization. */
144#ifdef __OPTIMIZE__
145# include <bits/fenvinline.h>
146#endif
147
148/* NaN support. */
149
150#if (__GLIBC_USE (IEC_60559_BFP_EXT) \
151 && defined FE_INVALID \
152 && defined __SUPPORT_SNAN__)
153# define FE_SNANS_ALWAYS_SIGNAL 1
154#endif
155
156#ifdef __USE_GNU
157
158/* Enable individual exceptions. Will not enable more exceptions than
159 EXCEPTS specifies. Returns the previous enabled exceptions if all
160 exceptions are successfully set, otherwise returns -1. */
161extern int feenableexcept (int __excepts) __THROW;
162
163/* Disable individual exceptions. Will not disable more exceptions than
164 EXCEPTS specifies. Returns the previous enabled exceptions if all
165 exceptions are successfully disabled, otherwise returns -1. */
166extern int fedisableexcept (int __excepts) __THROW;
167
168/* Return enabled exceptions. */
169extern int fegetexcept (void) __THROW;
170#endif
171
172__END_DECLS
173
174#endif /* fenv.h */
libc/glibc-include/fmtmsg.h created+105
...@@ -0,0 +1,105 @@
1/* Message display handling.
2 Copyright (C) 1997-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef __FMTMSG_H
20#define __FMTMSG_H 1
21
22#include <features.h>
23
24
25__BEGIN_DECLS
26
27/* Values to control `fmtmsg' function. */
28enum
29{
30 MM_HARD = 0x001, /* Source of the condition is hardware. */
31#define MM_HARD MM_HARD
32 MM_SOFT = 0x002, /* Source of the condition is software. */
33#define MM_SOFT MM_SOFT
34 MM_FIRM = 0x004, /* Source of the condition is firmware. */
35#define MM_FIRM MM_FIRM
36 MM_APPL = 0x008, /* Condition detected by application. */
37#define MM_APPL MM_APPL
38 MM_UTIL = 0x010, /* Condition detected by utility. */
39#define MM_UTIL MM_UTIL
40 MM_OPSYS = 0x020, /* Condition detected by operating system. */
41#define MM_OPSYS MM_OPSYS
42 MM_RECOVER = 0x040, /* Recoverable error. */
43#define MM_RECOVER MM_RECOVER
44 MM_NRECOV = 0x080, /* Non-recoverable error. */
45#define MM_NRECOV MM_NRECOV
46 MM_PRINT = 0x100, /* Display message in standard error. */
47#define MM_PRINT MM_PRINT
48 MM_CONSOLE = 0x200 /* Display message on system console. */
49#define MM_CONSOLE MM_CONSOLE
50};
51
52/* Values to be for SEVERITY parameter of `fmtmsg'. */
53enum
54{
55 MM_NOSEV = 0, /* No severity level provided for the message. */
56#define MM_NOSEV MM_NOSEV
57 MM_HALT, /* Error causing application to halt. */
58#define MM_HALT MM_HALT
59 MM_ERROR, /* Application has encountered a non-fatal fault. */
60#define MM_ERROR MM_ERROR
61 MM_WARNING, /* Application has detected unusual non-error
62 condition. */
63#define MM_WARNING MM_WARNING
64 MM_INFO /* Informative message. */
65#define MM_INFO MM_INFO
66};
67
68
69/* Macros which can be used as null values for the arguments of `fmtmsg'. */
70#define MM_NULLLBL ((char *) 0)
71#define MM_NULLSEV 0
72#define MM_NULLMC ((long int) 0)
73#define MM_NULLTXT ((char *) 0)
74#define MM_NULLACT ((char *) 0)
75#define MM_NULLTAG ((char *) 0)
76
77
78/* Possible return values of `fmtmsg'. */
79enum
80{
81 MM_NOTOK = -1,
82#define MM_NOTOK MM_NOTOK
83 MM_OK = 0,
84#define MM_OK MM_OK
85 MM_NOMSG = 1,
86#define MM_NOMSG MM_NOMSG
87 MM_NOCON = 4
88#define MM_NOCON MM_NOCON
89};
90
91
92/* Print message with given CLASSIFICATION, LABEL, SEVERITY, TEXT, ACTION
93 and TAG to console or standard error. */
94extern int fmtmsg (long int __classification, const char *__label,
95 int __severity, const char *__text,
96 const char *__action, const char *__tag);
97
98#ifdef __USE_MISC
99/* Add or remove severity level. */
100extern int addseverity (int __severity, const char *__string) __THROW;
101#endif
102
103__END_DECLS
104
105#endif /* fmtmsg.h */
libc/glibc-include/fnmatch.h created+62
...@@ -0,0 +1,62 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _FNMATCH_H
19#define _FNMATCH_H 1
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25/* We #undef these before defining them because some losing systems
26 (HP-UX A.08.07 for example) define these in <unistd.h>. */
27#undef FNM_PATHNAME
28#undef FNM_NOESCAPE
29#undef FNM_PERIOD
30
31/* Bits set in the FLAGS argument to `fnmatch'. */
32#define FNM_PATHNAME (1 << 0) /* No wildcard can ever match `/'. */
33#define FNM_NOESCAPE (1 << 1) /* Backslashes don't quote special chars. */
34#define FNM_PERIOD (1 << 2) /* Leading `.' is matched only explicitly. */
35
36#if !defined _POSIX_C_SOURCE || _POSIX_C_SOURCE < 2 || defined _GNU_SOURCE
37# define FNM_FILE_NAME FNM_PATHNAME /* Preferred GNU name. */
38# define FNM_LEADING_DIR (1 << 3) /* Ignore `/...' after a match. */
39# define FNM_CASEFOLD (1 << 4) /* Compare without regard to case. */
40# define FNM_EXTMATCH (1 << 5) /* Use ksh-like extended matching. */
41#endif
42
43/* Value returned by `fnmatch' if STRING does not match PATTERN. */
44#define FNM_NOMATCH 1
45
46/* This value is returned if the implementation does not support
47 `fnmatch'. Since this is not the case here it will never be
48 returned but the conformance test suites still require the symbol
49 to be defined. */
50#ifdef _XOPEN_SOURCE
51# define FNM_NOSYS (-1)
52#endif
53
54/* Match NAME against the filename pattern PATTERN,
55 returning zero if it matches, FNM_NOMATCH if not. */
56extern int fnmatch (const char *__pattern, const char *__name, int __flags);
57
58#ifdef __cplusplus
59}
60#endif
61
62#endif /* fnmatch.h */
libc/glibc-include/fpu_control.h created+109
...@@ -0,0 +1,109 @@
1/* FPU control word bits. x86 version.
2 Copyright (C) 1993-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Olaf Flebbe.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
19
20#ifndef _FPU_CONTROL_H
21#define _FPU_CONTROL_H 1
22
23/* Note that this file sets on x86-64 only the x87 FPU, it does not
24 touch the SSE unit. */
25
26/* Here is the dirty part. Set up your 387 through the control word
27 * (cw) register.
28 *
29 * 15-13 12 11-10 9-8 7-6 5 4 3 2 1 0
30 * | reserved | IC | RC | PC | reserved | PM | UM | OM | ZM | DM | IM
31 *
32 * IM: Invalid operation mask
33 * DM: Denormalized operand mask
34 * ZM: Zero-divide mask
35 * OM: Overflow mask
36 * UM: Underflow mask
37 * PM: Precision (inexact result) mask
38 *
39 * Mask bit is 1 means no interrupt.
40 *
41 * PC: Precision control
42 * 11 - round to extended precision
43 * 10 - round to double precision
44 * 00 - round to single precision
45 *
46 * RC: Rounding control
47 * 00 - rounding to nearest
48 * 01 - rounding down (toward - infinity)
49 * 10 - rounding up (toward + infinity)
50 * 11 - rounding toward zero
51 *
52 * IC: Infinity control
53 * That is for 8087 and 80287 only.
54 *
55 * The hardware default is 0x037f which we use.
56 */
57
58#include <features.h>
59
60/* masking of interrupts */
61#define _FPU_MASK_IM 0x01
62#define _FPU_MASK_DM 0x02
63#define _FPU_MASK_ZM 0x04
64#define _FPU_MASK_OM 0x08
65#define _FPU_MASK_UM 0x10
66#define _FPU_MASK_PM 0x20
67
68/* precision control */
69#define _FPU_EXTENDED 0x300 /* libm requires double extended precision. */
70#define _FPU_DOUBLE 0x200
71#define _FPU_SINGLE 0x0
72
73/* rounding control */
74#define _FPU_RC_NEAREST 0x0 /* RECOMMENDED */
75#define _FPU_RC_DOWN 0x400
76#define _FPU_RC_UP 0x800
77#define _FPU_RC_ZERO 0xC00
78
79#define _FPU_RESERVED 0xF0C0 /* Reserved bits in cw */
80
81
82/* The fdlibm code requires strict IEEE double precision arithmetic,
83 and no interrupts for exceptions, rounding to nearest. */
84
85#define _FPU_DEFAULT 0x037f
86
87/* IEEE: same as above. */
88#define _FPU_IEEE 0x037f
89
90/* Type of the control word. */
91typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
92
93/* Macros for accessing the hardware control word. "*&" is used to
94 work around a bug in older versions of GCC. __volatile__ is used
95 to support combination of writing the control register and reading
96 it back. Without __volatile__, the old value may be used for reading
97 back under compiler optimization.
98
99 Note that the use of these macros is not sufficient anymore with
100 recent hardware nor on x86-64. Some floating point operations are
101 executed in the SSE/SSE2 engines which have their own control and
102 status register. */
103#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
104#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
105
106/* Default control word set at startup. */
107extern fpu_control_t __fpu_control;
108
109#endif /* fpu_control.h */
libc/glibc-include/fstab.h created+79
...@@ -0,0 +1,79 @@
1/*
2 * Copyright (c) 1980, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 4. Neither the name of the University nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * @(#)fstab.h 8.1 (Berkeley) 6/2/93
30 */
31
32#ifndef _FSTAB_H
33#define _FSTAB_H 1
34
35#include <features.h>
36
37/*
38 * File system table, see fstab(5).
39 *
40 * Used by dump, mount, umount, swapon, fsck, df, ...
41 *
42 * For ufs fs_spec field is the block special name. Programs that want to
43 * use the character special name must create that name by prepending a 'r'
44 * after the right most slash. Quota files are always named "quotas", so
45 * if type is "rq", then use concatenation of fs_file and "quotas" to locate
46 * quota file.
47 */
48#define _PATH_FSTAB "/etc/fstab"
49#define FSTAB "/etc/fstab" /* deprecated */
50
51#define FSTAB_RW "rw" /* read/write device */
52#define FSTAB_RQ "rq" /* read/write with quotas */
53#define FSTAB_RO "ro" /* read-only device */
54#define FSTAB_SW "sw" /* swap device */
55#define FSTAB_XX "xx" /* ignore totally */
56
57struct fstab
58 {
59 char *fs_spec; /* block special device name */
60 char *fs_file; /* file system path prefix */
61 char *fs_vfstype; /* File system type, ufs, nfs */
62 char *fs_mntops; /* Mount options ala -o */
63 const char *fs_type; /* FSTAB_* from fs_mntops */
64 int fs_freq; /* dump frequency, in days */
65 int fs_passno; /* pass number on parallel dump */
66 };
67
68
69__BEGIN_DECLS
70
71extern struct fstab *getfsent (void) __THROW;
72extern struct fstab *getfsspec (const char *__name) __THROW;
73extern struct fstab *getfsfile (const char *__name) __THROW;
74extern int setfsent (void) __THROW;
75extern void endfsent (void) __THROW;
76
77__END_DECLS
78
79#endif /* fstab.h */
libc/glibc-include/fts.h created+215
...@@ -0,0 +1,215 @@
1/* File tree traversal functions declarations.
2 Copyright (C) 1994-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19/*
20 * Copyright (c) 1989, 1993
21 * The Regents of the University of California. All rights reserved.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the above copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 4. Neither the name of the University nor the names of its contributors
32 * may be used to endorse or promote products derived from this software
33 * without specific prior written permission.
34 *
35 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
36 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
37 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
38 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
39 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
40 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
41 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
42 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
43 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
44 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
45 * SUCH DAMAGE.
46 *
47 * @(#)fts.h 8.3 (Berkeley) 8/14/94
48 */
49
50#ifndef _FTS_H
51#define _FTS_H 1
52
53#include <features.h>
54#include <sys/types.h>
55
56
57typedef struct {
58 struct _ftsent *fts_cur; /* current node */
59 struct _ftsent *fts_child; /* linked list of children */
60 struct _ftsent **fts_array; /* sort array */
61 dev_t fts_dev; /* starting device # */
62 char *fts_path; /* path for this descent */
63 int fts_rfd; /* fd for root */
64 int fts_pathlen; /* sizeof(path) */
65 int fts_nitems; /* elements in the sort array */
66 int (*fts_compar) (const void *, const void *); /* compare fn */
67
68#define FTS_COMFOLLOW 0x0001 /* follow command line symlinks */
69#define FTS_LOGICAL 0x0002 /* logical walk */
70#define FTS_NOCHDIR 0x0004 /* don't change directories */
71#define FTS_NOSTAT 0x0008 /* don't get stat info */
72#define FTS_PHYSICAL 0x0010 /* physical walk */
73#define FTS_SEEDOT 0x0020 /* return dot and dot-dot */
74#define FTS_XDEV 0x0040 /* don't cross devices */
75#define FTS_WHITEOUT 0x0080 /* return whiteout information */
76#define FTS_OPTIONMASK 0x00ff /* valid user option mask */
77
78#define FTS_NAMEONLY 0x0100 /* (private) child names only */
79#define FTS_STOP 0x0200 /* (private) unrecoverable error */
80 int fts_options; /* fts_open options, global flags */
81} FTS;
82
83#ifdef __USE_LARGEFILE64
84typedef struct {
85 struct _ftsent64 *fts_cur; /* current node */
86 struct _ftsent64 *fts_child; /* linked list of children */
87 struct _ftsent64 **fts_array; /* sort array */
88 dev_t fts_dev; /* starting device # */
89 char *fts_path; /* path for this descent */
90 int fts_rfd; /* fd for root */
91 int fts_pathlen; /* sizeof(path) */
92 int fts_nitems; /* elements in the sort array */
93 int (*fts_compar) (const void *, const void *); /* compare fn */
94 int fts_options; /* fts_open options, global flags */
95} FTS64;
96#endif
97
98typedef struct _ftsent {
99 struct _ftsent *fts_cycle; /* cycle node */
100 struct _ftsent *fts_parent; /* parent directory */
101 struct _ftsent *fts_link; /* next file in directory */
102 long fts_number; /* local numeric value */
103 void *fts_pointer; /* local address value */
104 char *fts_accpath; /* access path */
105 char *fts_path; /* root path */
106 int fts_errno; /* errno for this node */
107 int fts_symfd; /* fd for symlink */
108 unsigned short fts_pathlen; /* strlen(fts_path) */
109 unsigned short fts_namelen; /* strlen(fts_name) */
110
111 ino_t fts_ino; /* inode */
112 dev_t fts_dev; /* device */
113 nlink_t fts_nlink; /* link count */
114
115#define FTS_ROOTPARENTLEVEL -1
116#define FTS_ROOTLEVEL 0
117 short fts_level; /* depth (-1 to N) */
118
119#define FTS_D 1 /* preorder directory */
120#define FTS_DC 2 /* directory that causes cycles */
121#define FTS_DEFAULT 3 /* none of the above */
122#define FTS_DNR 4 /* unreadable directory */
123#define FTS_DOT 5 /* dot or dot-dot */
124#define FTS_DP 6 /* postorder directory */
125#define FTS_ERR 7 /* error; errno is set */
126#define FTS_F 8 /* regular file */
127#define FTS_INIT 9 /* initialized only */
128#define FTS_NS 10 /* stat(2) failed */
129#define FTS_NSOK 11 /* no stat(2) requested */
130#define FTS_SL 12 /* symbolic link */
131#define FTS_SLNONE 13 /* symbolic link without target */
132#define FTS_W 14 /* whiteout object */
133 unsigned short fts_info; /* user flags for FTSENT structure */
134
135#define FTS_DONTCHDIR 0x01 /* don't chdir .. to the parent */
136#define FTS_SYMFOLLOW 0x02 /* followed a symlink to get here */
137 unsigned short fts_flags; /* private flags for FTSENT structure */
138
139#define FTS_AGAIN 1 /* read node again */
140#define FTS_FOLLOW 2 /* follow symbolic link */
141#define FTS_NOINSTR 3 /* no instructions */
142#define FTS_SKIP 4 /* discard node */
143 unsigned short fts_instr; /* fts_set() instructions */
144
145 struct stat *fts_statp; /* stat(2) information */
146 char fts_name[1]; /* file name */
147} FTSENT;
148
149#ifdef __USE_LARGEFILE64
150typedef struct _ftsent64 {
151 struct _ftsent64 *fts_cycle; /* cycle node */
152 struct _ftsent64 *fts_parent; /* parent directory */
153 struct _ftsent64 *fts_link; /* next file in directory */
154 long fts_number; /* local numeric value */
155 void *fts_pointer; /* local address value */
156 char *fts_accpath; /* access path */
157 char *fts_path; /* root path */
158 int fts_errno; /* errno for this node */
159 int fts_symfd; /* fd for symlink */
160 unsigned short fts_pathlen; /* strlen(fts_path) */
161 unsigned short fts_namelen; /* strlen(fts_name) */
162
163 ino64_t fts_ino; /* inode */
164 dev_t fts_dev; /* device */
165 nlink_t fts_nlink; /* link count */
166
167 short fts_level; /* depth (-1 to N) */
168
169 unsigned short fts_info; /* user flags for FTSENT structure */
170
171 unsigned short fts_flags; /* private flags for FTSENT structure */
172
173 unsigned short fts_instr; /* fts_set() instructions */
174
175 struct stat64 *fts_statp; /* stat(2) information */
176 char fts_name[1]; /* file name */
177} FTSENT64;
178#endif
179
180__BEGIN_DECLS
181#ifndef __USE_FILE_OFFSET64
182FTSENT *fts_children (FTS *, int);
183int fts_close (FTS *);
184FTS *fts_open (char * const *, int,
185 int (*)(const FTSENT **, const FTSENT **));
186FTSENT *fts_read (FTS *);
187int fts_set (FTS *, FTSENT *, int) __THROW;
188#else
189# ifdef __REDIRECT
190FTSENT *__REDIRECT (fts_children, (FTS *, int), fts64_children);
191int __REDIRECT (fts_close, (FTS *), fts64_close);
192FTS *__REDIRECT (fts_open, (char * const *, int,
193 int (*)(const FTSENT **, const FTSENT **)),
194 fts64_open);
195FTSENT *__REDIRECT (fts_read, (FTS *), fts64_read);
196int __REDIRECT_NTH (fts_set, (FTS *, FTSENT *, int), fts64_set);
197# else
198# define fts_children fts64_children
199# define fts_close fts64_close
200# define fts_open fts64_open
201# define fts_read fts64_read
202# define fts_set fts64_set
203# endif
204#endif
205#ifdef __USE_LARGEFILE64
206FTSENT64 *fts64_children (FTS64 *, int);
207int fts64_close (FTS64 *);
208FTS64 *fts64_open (char * const *, int,
209 int (*)(const FTSENT64 **, const FTSENT64 **));
210FTSENT64 *fts64_read (FTS64 *);
211int fts64_set (FTS64 *, FTSENT64 *, int) __THROW;
212#endif
213__END_DECLS
214
215#endif /* fts.h */
libc/glibc-include/ftw.h created+177
...@@ -0,0 +1,177 @@
1/* Copyright (C) 1992-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/*
19 * X/Open Portability Guide 4.2: ftw.h
20 */
21
22#ifndef _FTW_H
23#define _FTW_H 1
24
25#include <features.h>
26
27#include <sys/types.h>
28#include <sys/stat.h>
29
30
31__BEGIN_DECLS
32
33/* Values for the FLAG argument to the user function passed to `ftw'
34 and 'nftw'. */
35enum
36{
37 FTW_F, /* Regular file. */
38#define FTW_F FTW_F
39 FTW_D, /* Directory. */
40#define FTW_D FTW_D
41 FTW_DNR, /* Unreadable directory. */
42#define FTW_DNR FTW_DNR
43 FTW_NS, /* Unstatable file. */
44#define FTW_NS FTW_NS
45
46#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
47
48 FTW_SL, /* Symbolic link. */
49# define FTW_SL FTW_SL
50#endif
51
52#ifdef __USE_XOPEN_EXTENDED
53/* These flags are only passed from the `nftw' function. */
54 FTW_DP, /* Directory, all subdirs have been visited. */
55# define FTW_DP FTW_DP
56 FTW_SLN /* Symbolic link naming non-existing file. */
57# define FTW_SLN FTW_SLN
58
59#endif /* extended X/Open */
60};
61
62
63#ifdef __USE_XOPEN_EXTENDED
64/* Flags for fourth argument of `nftw'. */
65enum
66{
67 FTW_PHYS = 1, /* Perform physical walk, ignore symlinks. */
68# define FTW_PHYS FTW_PHYS
69 FTW_MOUNT = 2, /* Report only files on same file system as the
70 argument. */
71# define FTW_MOUNT FTW_MOUNT
72 FTW_CHDIR = 4, /* Change to current directory while processing it. */
73# define FTW_CHDIR FTW_CHDIR
74 FTW_DEPTH = 8 /* Report files in directory before directory itself.*/
75# define FTW_DEPTH FTW_DEPTH
76# ifdef __USE_GNU
77 ,
78 FTW_ACTIONRETVAL = 16 /* Assume callback to return FTW_* values instead of
79 zero to continue and non-zero to terminate. */
80# define FTW_ACTIONRETVAL FTW_ACTIONRETVAL
81# endif
82};
83
84#ifdef __USE_GNU
85/* Return values from callback functions. */
86enum
87{
88 FTW_CONTINUE = 0, /* Continue with next sibling or for FTW_D with the
89 first child. */
90# define FTW_CONTINUE FTW_CONTINUE
91 FTW_STOP = 1, /* Return from `ftw' or `nftw' with FTW_STOP as return
92 value. */
93# define FTW_STOP FTW_STOP
94 FTW_SKIP_SUBTREE = 2, /* Only meaningful for FTW_D: Don't walk through the
95 subtree, instead just continue with its next
96 sibling. */
97# define FTW_SKIP_SUBTREE FTW_SKIP_SUBTREE
98 FTW_SKIP_SIBLINGS = 3,/* Continue with FTW_DP callback for current directory
99 (if FTW_DEPTH) and then its siblings. */
100# define FTW_SKIP_SIBLINGS FTW_SKIP_SIBLINGS
101};
102#endif
103
104/* Structure used for fourth argument to callback function for `nftw'. */
105struct FTW
106 {
107 int base;
108 int level;
109 };
110#endif /* extended X/Open */
111
112
113/* Convenient types for callback functions. */
114typedef int (*__ftw_func_t) (const char *__filename,
115 const struct stat *__status, int __flag);
116#ifdef __USE_LARGEFILE64
117typedef int (*__ftw64_func_t) (const char *__filename,
118 const struct stat64 *__status, int __flag);
119#endif
120#ifdef __USE_XOPEN_EXTENDED
121typedef int (*__nftw_func_t) (const char *__filename,
122 const struct stat *__status, int __flag,
123 struct FTW *__info);
124# ifdef __USE_LARGEFILE64
125typedef int (*__nftw64_func_t) (const char *__filename,
126 const struct stat64 *__status,
127 int __flag, struct FTW *__info);
128# endif
129#endif
130
131/* Call a function on every element in a directory tree.
132
133 This function is a possible cancellation point and therefore not
134 marked with __THROW. */
135#ifndef __USE_FILE_OFFSET64
136extern int ftw (const char *__dir, __ftw_func_t __func, int __descriptors)
137 __nonnull ((1, 2));
138#else
139# ifdef __REDIRECT
140extern int __REDIRECT (ftw, (const char *__dir, __ftw_func_t __func,
141 int __descriptors), ftw64) __nonnull ((1, 2));
142# else
143# define ftw ftw64
144# endif
145#endif
146#ifdef __USE_LARGEFILE64
147extern int ftw64 (const char *__dir, __ftw64_func_t __func,
148 int __descriptors) __nonnull ((1, 2));
149#endif
150
151#ifdef __USE_XOPEN_EXTENDED
152/* Call a function on every element in a directory tree. FLAG allows
153 to specify the behaviour more detailed.
154
155 This function is a possible cancellation point and therefore not
156 marked with __THROW. */
157# ifndef __USE_FILE_OFFSET64
158extern int nftw (const char *__dir, __nftw_func_t __func, int __descriptors,
159 int __flag) __nonnull ((1, 2));
160# else
161# ifdef __REDIRECT
162extern int __REDIRECT (nftw, (const char *__dir, __nftw_func_t __func,
163 int __descriptors, int __flag), nftw64)
164 __nonnull ((1, 2));
165# else
166# define nftw nftw64
167# endif
168# endif
169# ifdef __USE_LARGEFILE64
170extern int nftw64 (const char *__dir, __nftw64_func_t __func,
171 int __descriptors, int __flag) __nonnull ((1, 2));
172# endif
173#endif
174
175__END_DECLS
176
177#endif /* ftw.h */
libc/glibc-include/gconv.h created+154
...@@ -0,0 +1,154 @@
1/* Copyright (C) 1997-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/* This header provides no interface for a user to the internals of
19 the gconv implementation in the libc. Therefore there is no use
20 for these definitions beside for writing additional gconv modules. */
21
22#ifndef _GCONV_H
23#define _GCONV_H 1
24
25#include <features.h>
26#include <bits/types/__mbstate_t.h>
27#include <bits/types/wint_t.h>
28
29#define __need_size_t
30#define __need_wchar_t
31#include <stddef.h>
32
33/* ISO 10646 value used to signal invalid value. */
34#define __UNKNOWN_10646_CHAR ((wchar_t) 0xfffd)
35
36/* Error codes for gconv functions. */
37enum
38{
39 __GCONV_OK = 0,
40 __GCONV_NOCONV,
41 __GCONV_NODB,
42 __GCONV_NOMEM,
43
44 __GCONV_EMPTY_INPUT,
45 __GCONV_FULL_OUTPUT,
46 __GCONV_ILLEGAL_INPUT,
47 __GCONV_INCOMPLETE_INPUT,
48
49 __GCONV_ILLEGAL_DESCRIPTOR,
50 __GCONV_INTERNAL_ERROR
51};
52
53
54/* Flags the `__gconv_open' function can set. */
55enum
56{
57 __GCONV_IS_LAST = 0x0001,
58 __GCONV_IGNORE_ERRORS = 0x0002,
59 __GCONV_SWAP = 0x0004,
60 __GCONV_TRANSLIT = 0x0008
61};
62
63
64/* Forward declarations. */
65struct __gconv_step;
66struct __gconv_step_data;
67struct __gconv_loaded_object;
68
69
70/* Type of a conversion function. */
71typedef int (*__gconv_fct) (struct __gconv_step *, struct __gconv_step_data *,
72 const unsigned char **, const unsigned char *,
73 unsigned char **, size_t *, int, int);
74
75/* Type of a specialized conversion function for a single byte to INTERNAL. */
76typedef wint_t (*__gconv_btowc_fct) (struct __gconv_step *, unsigned char);
77
78/* Constructor and destructor for local data for conversion step. */
79typedef int (*__gconv_init_fct) (struct __gconv_step *);
80typedef void (*__gconv_end_fct) (struct __gconv_step *);
81
82
83/* Description of a conversion step. */
84struct __gconv_step
85{
86 struct __gconv_loaded_object *__shlib_handle;
87 const char *__modname;
88
89 int __counter;
90
91 char *__from_name;
92 char *__to_name;
93
94 __gconv_fct __fct;
95 __gconv_btowc_fct __btowc_fct;
96 __gconv_init_fct __init_fct;
97 __gconv_end_fct __end_fct;
98
99 /* Information about the number of bytes needed or produced in this
100 step. This helps optimizing the buffer sizes. */
101 int __min_needed_from;
102 int __max_needed_from;
103 int __min_needed_to;
104 int __max_needed_to;
105
106 /* Flag whether this is a stateful encoding or not. */
107 int __stateful;
108
109 void *__data; /* Pointer to step-local data. */
110};
111
112/* Additional data for steps in use of conversion descriptor. This is
113 allocated by the `init' function. */
114struct __gconv_step_data
115{
116 unsigned char *__outbuf; /* Output buffer for this step. */
117 unsigned char *__outbufend; /* Address of first byte after the output
118 buffer. */
119
120 /* Is this the last module in the chain. */
121 int __flags;
122
123 /* Counter for number of invocations of the module function for this
124 descriptor. */
125 int __invocation_counter;
126
127 /* Flag whether this is an internal use of the module (in the mb*towc*
128 and wc*tomb* functions) or regular with iconv(3). */
129 int __internal_use;
130
131 __mbstate_t *__statep;
132 __mbstate_t __state; /* This element must not be used directly by
133 any module; always use STATEP! */
134};
135
136
137/* Combine conversion step description with data. */
138typedef struct __gconv_info
139{
140 size_t __nsteps;
141 struct __gconv_step *__steps;
142 __extension__ struct __gconv_step_data __data[0];
143} *__gconv_t;
144
145/* Transliteration using the locale's data. */
146extern int __gconv_transliterate (struct __gconv_step *step,
147 struct __gconv_step_data *step_data,
148 const unsigned char *inbufstart,
149 const unsigned char **inbufp,
150 const unsigned char *inbufend,
151 unsigned char **outbufstart,
152 size_t *irreversible);
153
154#endif /* gconv.h */
libc/glibc-include/getopt.h created+38
...@@ -0,0 +1,38 @@
1/* Declarations for getopt.
2 Copyright (C) 1989-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Unlike the bulk of the getopt implementation, this file is NOT part
5 of gnulib; gnulib also has a getopt.h but it is different.
6
7 The GNU C Library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
11
12 The GNU C Library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with the GNU C Library; if not, see
19 <http://www.gnu.org/licenses/>. */
20
21#ifndef _GETOPT_H
22#define _GETOPT_H 1
23
24#include <features.h>
25
26/* The type of the 'argv' argument to getopt_long and getopt_long_only
27 is properly 'char **', since both functions may write to the array
28 (in order to move all the options to the beginning). However, for
29 compatibility with old versions of LSB, glibc has to use 'char *const *'
30 instead. */
31#ifndef __getopt_argv_const
32# define __getopt_argv_const const
33#endif
34
35#include <bits/getopt_core.h>
36#include <bits/getopt_ext.h>
37
38#endif /* getopt.h */
libc/glibc-include/glob.h created+181
...@@ -0,0 +1,181 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _GLOB_H
19#define _GLOB_H 1
20
21#include <sys/cdefs.h>
22
23__BEGIN_DECLS
24
25/* We need `size_t' for the following definitions. */
26#ifndef __size_t
27typedef __SIZE_TYPE__ __size_t;
28# if defined __USE_XOPEN || defined __USE_XOPEN2K8
29typedef __SIZE_TYPE__ size_t;
30# endif
31#else
32/* The GNU CC stddef.h version defines __size_t as empty. We need a real
33 definition. */
34# undef __size_t
35# define __size_t size_t
36#endif
37
38/* Bits set in the FLAGS argument to `glob'. */
39#define GLOB_ERR (1 << 0)/* Return on read errors. */
40#define GLOB_MARK (1 << 1)/* Append a slash to each name. */
41#define GLOB_NOSORT (1 << 2)/* Don't sort the names. */
42#define GLOB_DOOFFS (1 << 3)/* Insert PGLOB->gl_offs NULLs. */
43#define GLOB_NOCHECK (1 << 4)/* If nothing matches, return the pattern. */
44#define GLOB_APPEND (1 << 5)/* Append to results of a previous call. */
45#define GLOB_NOESCAPE (1 << 6)/* Backslashes don't quote metacharacters. */
46#define GLOB_PERIOD (1 << 7)/* Leading `.' can be matched by metachars. */
47
48#if !defined __USE_POSIX2 || defined __USE_MISC
49# define GLOB_MAGCHAR (1 << 8)/* Set in gl_flags if any metachars seen. */
50# define GLOB_ALTDIRFUNC (1 << 9)/* Use gl_opendir et al functions. */
51# define GLOB_BRACE (1 << 10)/* Expand "{a,b}" to "a" "b". */
52# define GLOB_NOMAGIC (1 << 11)/* If no magic chars, return the pattern. */
53# define GLOB_TILDE (1 << 12)/* Expand ~user and ~ to home directories. */
54# define GLOB_ONLYDIR (1 << 13)/* Match only directories. */
55# define GLOB_TILDE_CHECK (1 << 14)/* Like GLOB_TILDE but return an error
56 if the user name is not available. */
57# define __GLOB_FLAGS (GLOB_ERR|GLOB_MARK|GLOB_NOSORT|GLOB_DOOFFS| \
58 GLOB_NOESCAPE|GLOB_NOCHECK|GLOB_APPEND| \
59 GLOB_PERIOD|GLOB_ALTDIRFUNC|GLOB_BRACE| \
60 GLOB_NOMAGIC|GLOB_TILDE|GLOB_ONLYDIR|GLOB_TILDE_CHECK)
61#else
62# define __GLOB_FLAGS (GLOB_ERR|GLOB_MARK|GLOB_NOSORT|GLOB_DOOFFS| \
63 GLOB_NOESCAPE|GLOB_NOCHECK|GLOB_APPEND| \
64 GLOB_PERIOD)
65#endif
66
67/* Error returns from `glob'. */
68#define GLOB_NOSPACE 1 /* Ran out of memory. */
69#define GLOB_ABORTED 2 /* Read error. */
70#define GLOB_NOMATCH 3 /* No matches found. */
71#define GLOB_NOSYS 4 /* Not implemented. */
72#ifdef __USE_GNU
73/* Previous versions of this file defined GLOB_ABEND instead of
74 GLOB_ABORTED. Provide a compatibility definition here. */
75# define GLOB_ABEND GLOB_ABORTED
76#endif
77
78/* Structure describing a globbing run. */
79#ifdef __USE_GNU
80struct stat;
81#endif
82typedef struct
83 {
84 __size_t gl_pathc; /* Count of paths matched by the pattern. */
85 char **gl_pathv; /* List of matched pathnames. */
86 __size_t gl_offs; /* Slots to reserve in `gl_pathv'. */
87 int gl_flags; /* Set to FLAGS, maybe | GLOB_MAGCHAR. */
88
89 /* If the GLOB_ALTDIRFUNC flag is set, the following functions
90 are used instead of the normal file access functions. */
91 void (*gl_closedir) (void *);
92#ifdef __USE_GNU
93 struct dirent *(*gl_readdir) (void *);
94#else
95 void *(*gl_readdir) (void *);
96#endif
97 void *(*gl_opendir) (const char *);
98#ifdef __USE_GNU
99 int (*gl_lstat) (const char *__restrict, struct stat *__restrict);
100 int (*gl_stat) (const char *__restrict, struct stat *__restrict);
101#else
102 int (*gl_lstat) (const char *__restrict, void *__restrict);
103 int (*gl_stat) (const char *__restrict, void *__restrict);
104#endif
105 } glob_t;
106
107#ifdef __USE_LARGEFILE64
108# ifdef __USE_GNU
109struct stat64;
110# endif
111typedef struct
112 {
113 __size_t gl_pathc;
114 char **gl_pathv;
115 __size_t gl_offs;
116 int gl_flags;
117
118 /* If the GLOB_ALTDIRFUNC flag is set, the following functions
119 are used instead of the normal file access functions. */
120 void (*gl_closedir) (void *);
121# ifdef __USE_GNU
122 struct dirent64 *(*gl_readdir) (void *);
123# else
124 void *(*gl_readdir) (void *);
125# endif
126 void *(*gl_opendir) (const char *);
127# ifdef __USE_GNU
128 int (*gl_lstat) (const char *__restrict, struct stat64 *__restrict);
129 int (*gl_stat) (const char *__restrict, struct stat64 *__restrict);
130# else
131 int (*gl_lstat) (const char *__restrict, void *__restrict);
132 int (*gl_stat) (const char *__restrict, void *__restrict);
133# endif
134 } glob64_t;
135#endif
136
137/* Do glob searching for PATTERN, placing results in PGLOB.
138 The bits defined above may be set in FLAGS.
139 If a directory cannot be opened or read and ERRFUNC is not nil,
140 it is called with the pathname that caused the error, and the
141 `errno' value from the failing call; if it returns non-zero
142 `glob' returns GLOB_ABEND; if it returns zero, the error is ignored.
143 If memory cannot be allocated for PGLOB, GLOB_NOSPACE is returned.
144 Otherwise, `glob' returns zero. */
145#if !defined __USE_FILE_OFFSET64
146extern int glob (const char *__restrict __pattern, int __flags,
147 int (*__errfunc) (const char *, int),
148 glob_t *__restrict __pglob) __THROW;
149
150/* Free storage allocated in PGLOB by a previous `glob' call. */
151extern void globfree (glob_t *__pglob) __THROW;
152#else
153extern int __REDIRECT_NTH (glob, (const char *__restrict __pattern,
154 int __flags,
155 int (*__errfunc) (const char *, int),
156 glob_t *__restrict __pglob), glob64);
157
158extern void __REDIRECT_NTH (globfree, (glob_t *__pglob), globfree64);
159#endif
160
161#ifdef __USE_LARGEFILE64
162extern int glob64 (const char *__restrict __pattern, int __flags,
163 int (*__errfunc) (const char *, int),
164 glob64_t *__restrict __pglob) __THROW;
165
166extern void globfree64 (glob64_t *__pglob) __THROW;
167#endif
168
169
170#ifdef __USE_GNU
171/* Return nonzero if PATTERN contains any metacharacters.
172 Metacharacters can be quoted with backslashes if QUOTE is nonzero.
173
174 This function is not part of the interface specified by POSIX.2
175 but several programs want to use it. */
176extern int glob_pattern_p (const char *__pattern, int __quote) __THROW;
177#endif
178
179__END_DECLS
180
181#endif /* glob.h */
libc/glibc-include/gnu-versions.h created+52
...@@ -0,0 +1,52 @@
1/* Header with interface version macros for library pieces copied elsewhere.
2 Copyright (C) 1995-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _GNU_VERSIONS_H
20#define _GNU_VERSIONS_H 1
21
22/* This file exists to define these few macros. Each specifies a version
23 number associated with the library interface of a piece of the C library
24 which is also distributed with other GNU packages. These pieces are
25 both part of the GNU C library and also distributed with other GNU
26 packages so those packages may use their facilities on systems lacking
27 the GNU C library. The source files for each piece surround all their
28 code with `#ifndef ELIDE_CODE' after defining it with this:
29
30 #define OBSTACK_INTERFACE_VERSION 1
31 #if !defined (_LIBC) && defined (__GNU_LIBRARY__) && __GNU_LIBRARY__ > 1
32 #include <gnu-versions.h>
33 #if _GNU_OBSTACK_INTERFACE_VERSION == OBSTACK_INTERFACE_VERSION
34 #define ELIDE_CODE
35 #endif
36 #endif
37
38 This allows those one to avoid compiling those files when part of a GNU
39 package not libc, on a system using a GNU C library that supports the
40 same interface.
41
42 Please preserve the format of the comments after each macro. And
43 remember, if any of these versions change, the libc.so major version
44 number must change too (so avoid it)! */
45
46#define _GNU_OBSTACK_INTERFACE_VERSION 1 /* vs malloc/obstack.c */
47#define _GNU_REGEX_INTERFACE_VERSION 1 /* vs posix/regex.c */
48#define _GNU_GLOB_INTERFACE_VERSION 2 /* vs posix/glob.c */
49#define _GNU_GETOPT_INTERFACE_VERSION 2 /* vs posix/getopt.c and
50 posix/getopt1.c */
51
52#endif /* gnu-versions.h */
libc/glibc-include/gnu/lib-names-64.h created+31
...@@ -0,0 +1,31 @@
1/* This file is automatically generated. */
2#ifndef __GNU_LIB_NAMES_H
3# error "Never use <gnu/lib-names-64.h> directly; include <gnu/lib-names.h> instead."
4#endif
5
6#define LD_LINUX_X86_64_SO "ld-linux-x86-64.so.2"
7#define LD_SO "ld-linux-x86-64.so.2"
8#define LIBANL_SO "libanl.so.1"
9#define LIBBROKENLOCALE_SO "libBrokenLocale.so.1"
10#define LIBCRYPT_SO "libcrypt.so.1"
11#define LIBC_SO "libc.so.6"
12#define LIBDL_SO "libdl.so.2"
13#define LIBGCC_S_SO "libgcc_s.so.1"
14#define LIBMVEC_SO "libmvec.so.1"
15#define LIBM_SO "libm.so.6"
16#define LIBNSL_SO "libnsl.so.1"
17#define LIBNSS_COMPAT_SO "libnss_compat.so.2"
18#define LIBNSS_DB_SO "libnss_db.so.2"
19#define LIBNSS_DNS_SO "libnss_dns.so.2"
20#define LIBNSS_FILES_SO "libnss_files.so.2"
21#define LIBNSS_HESIOD_SO "libnss_hesiod.so.2"
22#define LIBNSS_LDAP_SO "libnss_ldap.so.2"
23#define LIBNSS_NISPLUS_SO "libnss_nisplus.so.2"
24#define LIBNSS_NIS_SO "libnss_nis.so.2"
25#define LIBNSS_TEST1_SO "libnss_test1.so.2"
26#define LIBNSS_TEST2_SO "libnss_test2.so.2"
27#define LIBPTHREAD_SO "libpthread.so.0"
28#define LIBRESOLV_SO "libresolv.so.2"
29#define LIBRT_SO "librt.so.1"
30#define LIBTHREAD_DB_SO "libthread_db.so.1"
31#define LIBUTIL_SO "libutil.so.1"
libc/glibc-include/gnu/lib-names.h created+17
...@@ -0,0 +1,17 @@
1/* This file is automatically generated.
2 It defines macros to allow user program to find the shared
3 library files which come as part of GNU libc. */
4#ifndef __GNU_LIB_NAMES_H
5#define __GNU_LIB_NAMES_H 1
6
7#if !defined __x86_64__
8# include <gnu/lib-names-32.h>
9#endif
10#if defined __x86_64__ && defined __LP64__
11# include <gnu/lib-names-64.h>
12#endif
13#if defined __x86_64__ && defined __ILP32__
14# include <gnu/lib-names-x32.h>
15#endif
16
17#endif /* gnu/lib-names.h */
libc/glibc-include/gnu/libc-version.h created+34
...@@ -0,0 +1,34 @@
1/* Interface to GNU libc specific functions for version information.
2 Copyright (C) 1998-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _GNU_LIBC_VERSION_H
20#define _GNU_LIBC_VERSION_H 1
21
22#include <features.h>
23
24__BEGIN_DECLS
25
26/* Return string describing release status of currently running GNU libc. */
27extern const char *gnu_get_libc_release (void) __THROW;
28
29/* Return string describing version of currently running GNU libc. */
30extern const char *gnu_get_libc_version (void) __THROW;
31
32__END_DECLS
33
34#endif /* gnu/libc-version.h */
libc/glibc-include/gnu/stubs-64.h created+23
...@@ -0,0 +1,23 @@
1/* This file is automatically generated.
2 It defines a symbol `__stub_FUNCTION' for each function
3 in the C library which is a stub, meaning it will fail
4 every time called, usually setting errno to ENOSYS. */
5
6#ifdef _LIBC
7 #error Applications may not define the macro _LIBC
8#endif
9
10#define __stub___compat_bdflush
11#define __stub_chflags
12#define __stub_fattach
13#define __stub_fchflags
14#define __stub_fdetach
15#define __stub_getmsg
16#define __stub_gtty
17#define __stub_lchmod
18#define __stub_putmsg
19#define __stub_revoke
20#define __stub_setlogin
21#define __stub_sigreturn
22#define __stub_sstk
23#define __stub_stty
libc/glibc-include/gnu/stubs.h created+14
...@@ -0,0 +1,14 @@
1/* This file is automatically generated.
2 This file selects the right generated file of `__stub_FUNCTION' macros
3 based on the architecture being compiled for. */
4
5
6#if !defined __x86_64__
7# include <gnu/stubs-32.h>
8#endif
9#if defined __x86_64__ && defined __LP64__
10# include <gnu/stubs-64.h>
11#endif
12#if defined __x86_64__ && defined __ILP32__
13# include <gnu/stubs-x32.h>
14#endif
libc/glibc-include/grp.h created+203
...@@ -0,0 +1,203 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/*
19 * POSIX Standard: 9.2.1 Group Database Access <grp.h>
20 */
21
22#ifndef _GRP_H
23#define _GRP_H 1
24
25#include <features.h>
26
27__BEGIN_DECLS
28
29#include <bits/types.h>
30
31#define __need_size_t
32#include <stddef.h>
33
34
35/* For the Single Unix specification we must define this type here. */
36#if (defined __USE_XOPEN || defined __USE_XOPEN2K) && !defined __gid_t_defined
37typedef __gid_t gid_t;
38# define __gid_t_defined
39#endif
40
41/* The group structure. */
42struct group
43 {
44 char *gr_name; /* Group name. */
45 char *gr_passwd; /* Password. */
46 __gid_t gr_gid; /* Group ID. */
47 char **gr_mem; /* Member list. */
48 };
49
50
51#ifdef __USE_MISC
52# include <bits/types/FILE.h>
53#endif
54
55
56#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
57/* Rewind the group-file stream.
58
59 This function is a possible cancellation point and therefore not
60 marked with __THROW. */
61extern void setgrent (void);
62
63/* Close the group-file stream.
64
65 This function is a possible cancellation point and therefore not
66 marked with __THROW. */
67extern void endgrent (void);
68
69/* Read an entry from the group-file stream, opening it if necessary.
70
71 This function is a possible cancellation point and therefore not
72 marked with __THROW. */
73extern struct group *getgrent (void);
74#endif
75
76#ifdef __USE_MISC
77/* Read a group entry from STREAM.
78
79 This function is not part of POSIX and therefore no official
80 cancellation point. But due to similarity with an POSIX interface
81 or due to the implementation it is a cancellation point and
82 therefore not marked with __THROW. */
83extern struct group *fgetgrent (FILE *__stream);
84#endif
85
86#ifdef __USE_GNU
87/* Write the given entry onto the given stream.
88
89 This function is not part of POSIX and therefore no official
90 cancellation point. But due to similarity with an POSIX interface
91 or due to the implementation it is a cancellation point and
92 therefore not marked with __THROW. */
93extern int putgrent (const struct group *__restrict __p,
94 FILE *__restrict __f);
95#endif
96
97/* Search for an entry with a matching group ID.
98
99 This function is a possible cancellation point and therefore not
100 marked with __THROW. */
101extern struct group *getgrgid (__gid_t __gid);
102
103/* Search for an entry with a matching group name.
104
105 This function is a possible cancellation point and therefore not
106 marked with __THROW. */
107extern struct group *getgrnam (const char *__name);
108
109#ifdef __USE_POSIX
110
111# ifdef __USE_MISC
112/* Reasonable value for the buffer sized used in the reentrant
113 functions below. But better use `sysconf'. */
114# define NSS_BUFLEN_GROUP 1024
115# endif
116
117/* Reentrant versions of some of the functions above.
118
119 PLEASE NOTE: the `getgrent_r' function is not (yet) standardized.
120 The interface may change in later versions of this library. But
121 the interface is designed following the principals used for the
122 other reentrant functions so the chances are good this is what the
123 POSIX people would choose.
124
125 This function is not part of POSIX and therefore no official
126 cancellation point. But due to similarity with an POSIX interface
127 or due to the implementation it is a cancellation point and
128 therefore not marked with __THROW. */
129
130# ifdef __USE_GNU
131extern int getgrent_r (struct group *__restrict __resultbuf,
132 char *__restrict __buffer, size_t __buflen,
133 struct group **__restrict __result);
134# endif
135
136/* Search for an entry with a matching group ID.
137
138 This function is a possible cancellation point and therefore not
139 marked with __THROW. */
140extern int getgrgid_r (__gid_t __gid, struct group *__restrict __resultbuf,
141 char *__restrict __buffer, size_t __buflen,
142 struct group **__restrict __result);
143
144/* Search for an entry with a matching group name.
145
146 This function is a possible cancellation point and therefore not
147 marked with __THROW. */
148extern int getgrnam_r (const char *__restrict __name,
149 struct group *__restrict __resultbuf,
150 char *__restrict __buffer, size_t __buflen,
151 struct group **__restrict __result);
152
153# ifdef __USE_MISC
154/* Read a group entry from STREAM. This function is not standardized
155 an probably never will.
156
157 This function is not part of POSIX and therefore no official
158 cancellation point. But due to similarity with an POSIX interface
159 or due to the implementation it is a cancellation point and
160 therefore not marked with __THROW. */
161extern int fgetgrent_r (FILE *__restrict __stream,
162 struct group *__restrict __resultbuf,
163 char *__restrict __buffer, size_t __buflen,
164 struct group **__restrict __result);
165# endif
166
167#endif /* POSIX or reentrant */
168
169
170#ifdef __USE_MISC
171
172# define __need_size_t
173# include <stddef.h>
174
175/* Set the group set for the current user to GROUPS (N of them). */
176extern int setgroups (size_t __n, const __gid_t *__groups) __THROW;
177
178/* Store at most *NGROUPS members of the group set for USER into
179 *GROUPS. Also include GROUP. The actual number of groups found is
180 returned in *NGROUPS. Return -1 if the if *NGROUPS is too small.
181
182 This function is not part of POSIX and therefore no official
183 cancellation point. But due to similarity with an POSIX interface
184 or due to the implementation it is a cancellation point and
185 therefore not marked with __THROW. */
186extern int getgrouplist (const char *__user, __gid_t __group,
187 __gid_t *__groups, int *__ngroups);
188
189/* Initialize the group set for the current user
190 by reading the group database and using all groups
191 of which USER is a member. Also include GROUP.
192
193 This function is not part of POSIX and therefore no official
194 cancellation point. But due to similarity with an POSIX interface
195 or due to the implementation it is a cancellation point and
196 therefore not marked with __THROW. */
197extern int initgroups (const char *__user, __gid_t __group);
198
199#endif /* Use misc. */
200
201__END_DECLS
202
203#endif /* grp.h */
libc/glibc-include/gshadow.h created+128
...@@ -0,0 +1,128 @@
1/* Copyright (C) 2009-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/* Declaration of types and functions for shadow group suite. */
19
20#ifndef _GSHADOW_H
21#define _GSHADOW_H 1
22
23#include <features.h>
24#include <paths.h>
25#include <bits/types/FILE.h>
26
27#define __need_size_t
28#include <stddef.h>
29
30/* Path to the user database files. */
31#define GSHADOW _PATH_GSHADOW
32
33
34__BEGIN_DECLS
35
36/* Structure of the group file. */
37struct sgrp
38 {
39 char *sg_namp; /* Group name. */
40 char *sg_passwd; /* Encrypted password. */
41 char **sg_adm; /* Group administrator list. */
42 char **sg_mem; /* Group member list. */
43 };
44
45
46/* Open database for reading.
47
48 This function is not part of POSIX and therefore no official
49 cancellation point. But due to similarity with an POSIX interface
50 or due to the implementation it is a cancellation point and
51 therefore not marked with __THROW. */
52extern void setsgent (void);
53
54/* Close database.
55
56 This function is not part of POSIX and therefore no official
57 cancellation point. But due to similarity with an POSIX interface
58 or due to the implementation it is a cancellation point and
59 therefore not marked with __THROW. */
60extern void endsgent (void);
61
62/* Get next entry from database, perhaps after opening the file.
63
64 This function is not part of POSIX and therefore no official
65 cancellation point. But due to similarity with an POSIX interface
66 or due to the implementation it is a cancellation point and
67 therefore not marked with __THROW. */
68extern struct sgrp *getsgent (void);
69
70/* Get shadow entry matching NAME.
71
72 This function is not part of POSIX and therefore no official
73 cancellation point. But due to similarity with an POSIX interface
74 or due to the implementation it is a cancellation point and
75 therefore not marked with __THROW. */
76extern struct sgrp *getsgnam (const char *__name);
77
78/* Read shadow entry from STRING.
79
80 This function is not part of POSIX and therefore no official
81 cancellation point. But due to similarity with an POSIX interface
82 or due to the implementation it is a cancellation point and
83 therefore not marked with __THROW. */
84extern struct sgrp *sgetsgent (const char *__string);
85
86/* Read next shadow entry from STREAM.
87
88 This function is not part of POSIX and therefore no official
89 cancellation point. But due to similarity with an POSIX interface
90 or due to the implementation it is a cancellation point and
91 therefore not marked with __THROW. */
92extern struct sgrp *fgetsgent (FILE *__stream);
93
94/* Write line containing shadow password entry to stream.
95
96 This function is not part of POSIX and therefore no official
97 cancellation point. But due to similarity with an POSIX interface
98 or due to the implementation it is a cancellation point and
99 therefore not marked with __THROW. */
100extern int putsgent (const struct sgrp *__g, FILE *__stream);
101
102
103#ifdef __USE_MISC
104/* Reentrant versions of some of the functions above.
105
106 These functions are not part of POSIX and therefore no official
107 cancellation point. But due to similarity with an POSIX interface
108 or due to the implementation they are cancellation points and
109 therefore not marked with __THROW. */
110extern int getsgent_r (struct sgrp *__result_buf, char *__buffer,
111 size_t __buflen, struct sgrp **__result);
112
113extern int getsgnam_r (const char *__name, struct sgrp *__result_buf,
114 char *__buffer, size_t __buflen,
115 struct sgrp **__result);
116
117extern int sgetsgent_r (const char *__string, struct sgrp *__result_buf,
118 char *__buffer, size_t __buflen,
119 struct sgrp **__result);
120
121extern int fgetsgent_r (FILE *__stream, struct sgrp *__result_buf,
122 char *__buffer, size_t __buflen,
123 struct sgrp **__result);
124#endif /* misc */
125
126__END_DECLS
127
128#endif /* gshadow.h */
libc/glibc-include/iconv.h created+55
...@@ -0,0 +1,55 @@
1/* Copyright (C) 1997-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _ICONV_H
19#define _ICONV_H 1
20
21#include <features.h>
22#define __need_size_t
23#include <stddef.h>
24
25
26__BEGIN_DECLS
27
28/* Identifier for conversion method from one codeset to another. */
29typedef void *iconv_t;
30
31
32/* Allocate descriptor for code conversion from codeset FROMCODE to
33 codeset TOCODE.
34
35 This function is a possible cancellation point and therefore not
36 marked with __THROW. */
37extern iconv_t iconv_open (const char *__tocode, const char *__fromcode);
38
39/* Convert at most *INBYTESLEFT bytes from *INBUF according to the
40 code conversion algorithm specified by CD and place up to
41 *OUTBYTESLEFT bytes in buffer at *OUTBUF. */
42extern size_t iconv (iconv_t __cd, char **__restrict __inbuf,
43 size_t *__restrict __inbytesleft,
44 char **__restrict __outbuf,
45 size_t *__restrict __outbytesleft);
46
47/* Free resources allocated for descriptor CD for code conversion.
48
49 This function is a possible cancellation point and therefore not
50 marked with __THROW. */
51extern int iconv_close (iconv_t __cd);
52
53__END_DECLS
54
55#endif /* iconv.h */
libc/glibc-include/ieee754.h created+198
...@@ -0,0 +1,198 @@
1/* Copyright (C) 1992-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _IEEE754_H
19
20#define _IEEE754_H 1
21#include <features.h>
22
23#include <endian.h>
24
25__BEGIN_DECLS
26
27union ieee754_float
28 {
29 float f;
30
31 /* This is the IEEE 754 single-precision format. */
32 struct
33 {
34#if __BYTE_ORDER == __BIG_ENDIAN
35 unsigned int negative:1;
36 unsigned int exponent:8;
37 unsigned int mantissa:23;
38#endif /* Big endian. */
39#if __BYTE_ORDER == __LITTLE_ENDIAN
40 unsigned int mantissa:23;
41 unsigned int exponent:8;
42 unsigned int negative:1;
43#endif /* Little endian. */
44 } ieee;
45
46 /* This format makes it easier to see if a NaN is a signalling NaN. */
47 struct
48 {
49#if __BYTE_ORDER == __BIG_ENDIAN
50 unsigned int negative:1;
51 unsigned int exponent:8;
52 unsigned int quiet_nan:1;
53 unsigned int mantissa:22;
54#endif /* Big endian. */
55#if __BYTE_ORDER == __LITTLE_ENDIAN
56 unsigned int mantissa:22;
57 unsigned int quiet_nan:1;
58 unsigned int exponent:8;
59 unsigned int negative:1;
60#endif /* Little endian. */
61 } ieee_nan;
62 };
63
64#define IEEE754_FLOAT_BIAS 0x7f /* Added to exponent. */
65
66
67union ieee754_double
68 {
69 double d;
70
71 /* This is the IEEE 754 double-precision format. */
72 struct
73 {
74#if __BYTE_ORDER == __BIG_ENDIAN
75 unsigned int negative:1;
76 unsigned int exponent:11;
77 /* Together these comprise the mantissa. */
78 unsigned int mantissa0:20;
79 unsigned int mantissa1:32;
80#endif /* Big endian. */
81#if __BYTE_ORDER == __LITTLE_ENDIAN
82# if __FLOAT_WORD_ORDER == __BIG_ENDIAN
83 unsigned int mantissa0:20;
84 unsigned int exponent:11;
85 unsigned int negative:1;
86 unsigned int mantissa1:32;
87# else
88 /* Together these comprise the mantissa. */
89 unsigned int mantissa1:32;
90 unsigned int mantissa0:20;
91 unsigned int exponent:11;
92 unsigned int negative:1;
93# endif
94#endif /* Little endian. */
95 } ieee;
96
97 /* This format makes it easier to see if a NaN is a signalling NaN. */
98 struct
99 {
100#if __BYTE_ORDER == __BIG_ENDIAN
101 unsigned int negative:1;
102 unsigned int exponent:11;
103 unsigned int quiet_nan:1;
104 /* Together these comprise the mantissa. */
105 unsigned int mantissa0:19;
106 unsigned int mantissa1:32;
107#else
108# if __FLOAT_WORD_ORDER == __BIG_ENDIAN
109 unsigned int mantissa0:19;
110 unsigned int quiet_nan:1;
111 unsigned int exponent:11;
112 unsigned int negative:1;
113 unsigned int mantissa1:32;
114# else
115 /* Together these comprise the mantissa. */
116 unsigned int mantissa1:32;
117 unsigned int mantissa0:19;
118 unsigned int quiet_nan:1;
119 unsigned int exponent:11;
120 unsigned int negative:1;
121# endif
122#endif
123 } ieee_nan;
124 };
125
126#define IEEE754_DOUBLE_BIAS 0x3ff /* Added to exponent. */
127
128
129union ieee854_long_double
130 {
131 long double d;
132
133 /* This is the IEEE 854 double-extended-precision format. */
134 struct
135 {
136#if __BYTE_ORDER == __BIG_ENDIAN
137 unsigned int negative:1;
138 unsigned int exponent:15;
139 unsigned int empty:16;
140 unsigned int mantissa0:32;
141 unsigned int mantissa1:32;
142#endif
143#if __BYTE_ORDER == __LITTLE_ENDIAN
144# if __FLOAT_WORD_ORDER == __BIG_ENDIAN
145 unsigned int exponent:15;
146 unsigned int negative:1;
147 unsigned int empty:16;
148 unsigned int mantissa0:32;
149 unsigned int mantissa1:32;
150# else
151 unsigned int mantissa1:32;
152 unsigned int mantissa0:32;
153 unsigned int exponent:15;
154 unsigned int negative:1;
155 unsigned int empty:16;
156# endif
157#endif
158 } ieee;
159
160 /* This is for NaNs in the IEEE 854 double-extended-precision format. */
161 struct
162 {
163#if __BYTE_ORDER == __BIG_ENDIAN
164 unsigned int negative:1;
165 unsigned int exponent:15;
166 unsigned int empty:16;
167 unsigned int one:1;
168 unsigned int quiet_nan:1;
169 unsigned int mantissa0:30;
170 unsigned int mantissa1:32;
171#endif
172#if __BYTE_ORDER == __LITTLE_ENDIAN
173# if __FLOAT_WORD_ORDER == __BIG_ENDIAN
174 unsigned int exponent:15;
175 unsigned int negative:1;
176 unsigned int empty:16;
177 unsigned int mantissa0:30;
178 unsigned int quiet_nan:1;
179 unsigned int one:1;
180 unsigned int mantissa1:32;
181# else
182 unsigned int mantissa1:32;
183 unsigned int mantissa0:30;
184 unsigned int quiet_nan:1;
185 unsigned int one:1;
186 unsigned int exponent:15;
187 unsigned int negative:1;
188 unsigned int empty:16;
189# endif
190#endif
191 } ieee_nan;
192 };
193
194#define IEEE854_LONG_DOUBLE_BIAS 0x3fff
195
196__END_DECLS
197
198#endif /* ieee754.h */
libc/glibc-include/ifaddrs.h created+73
...@@ -0,0 +1,73 @@
1/* ifaddrs.h -- declarations for getting network interface addresses
2 Copyright (C) 2002-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _IFADDRS_H
20#define _IFADDRS_H 1
21
22#include <features.h>
23#include <sys/socket.h>
24
25__BEGIN_DECLS
26
27/* The `getifaddrs' function generates a linked list of these structures.
28 Each element of the list describes one network interface. */
29struct ifaddrs
30{
31 struct ifaddrs *ifa_next; /* Pointer to the next structure. */
32
33 char *ifa_name; /* Name of this network interface. */
34 unsigned int ifa_flags; /* Flags as from SIOCGIFFLAGS ioctl. */
35
36 struct sockaddr *ifa_addr; /* Network address of this interface. */
37 struct sockaddr *ifa_netmask; /* Netmask of this interface. */
38 union
39 {
40 /* At most one of the following two is valid. If the IFF_BROADCAST
41 bit is set in `ifa_flags', then `ifa_broadaddr' is valid. If the
42 IFF_POINTOPOINT bit is set, then `ifa_dstaddr' is valid.
43 It is never the case that both these bits are set at once. */
44 struct sockaddr *ifu_broadaddr; /* Broadcast address of this interface. */
45 struct sockaddr *ifu_dstaddr; /* Point-to-point destination address. */
46 } ifa_ifu;
47 /* These very same macros are defined by <net/if.h> for `struct ifaddr'.
48 So if they are defined already, the existing definitions will be fine. */
49# ifndef ifa_broadaddr
50# define ifa_broadaddr ifa_ifu.ifu_broadaddr
51# endif
52# ifndef ifa_dstaddr
53# define ifa_dstaddr ifa_ifu.ifu_dstaddr
54# endif
55
56 void *ifa_data; /* Address-specific data (may be unused). */
57};
58
59
60/* Create a linked list of `struct ifaddrs' structures, one for each
61 network interface on the host machine. If successful, store the
62 list in *IFAP and return 0. On errors, return -1 and set `errno'.
63
64 The storage returned in *IFAP is allocated dynamically and can
65 only be properly freed by passing it to `freeifaddrs'. */
66extern int getifaddrs (struct ifaddrs **__ifap) __THROW;
67
68/* Reclaim the storage allocated by a previous `getifaddrs' call. */
69extern void freeifaddrs (struct ifaddrs *__ifa) __THROW;
70
71__END_DECLS
72
73#endif /* ifaddrs.h */
libc/glibc-include/inttypes.h created+434
...@@ -0,0 +1,434 @@
1/* Copyright (C) 1997-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/*
19 * ISO C99: 7.8 Format conversion of integer types <inttypes.h>
20 */
21
22#ifndef _INTTYPES_H
23#define _INTTYPES_H 1
24
25#include <features.h>
26/* Get the type definitions. */
27#include <stdint.h>
28
29/* Get a definition for wchar_t. But we must not define wchar_t itself. */
30#ifndef ____gwchar_t_defined
31# ifdef __cplusplus
32# define __gwchar_t wchar_t
33# elif defined __WCHAR_TYPE__
34typedef __WCHAR_TYPE__ __gwchar_t;
35# else
36# define __need_wchar_t
37# include <stddef.h>
38typedef wchar_t __gwchar_t;
39# endif
40# define ____gwchar_t_defined 1
41#endif
42
43# if __WORDSIZE == 64
44# define __PRI64_PREFIX "l"
45# define __PRIPTR_PREFIX "l"
46# else
47# define __PRI64_PREFIX "ll"
48# define __PRIPTR_PREFIX
49# endif
50
51/* Macros for printing format specifiers. */
52
53/* Decimal notation. */
54# define PRId8 "d"
55# define PRId16 "d"
56# define PRId32 "d"
57# define PRId64 __PRI64_PREFIX "d"
58
59# define PRIdLEAST8 "d"
60# define PRIdLEAST16 "d"
61# define PRIdLEAST32 "d"
62# define PRIdLEAST64 __PRI64_PREFIX "d"
63
64# define PRIdFAST8 "d"
65# define PRIdFAST16 __PRIPTR_PREFIX "d"
66# define PRIdFAST32 __PRIPTR_PREFIX "d"
67# define PRIdFAST64 __PRI64_PREFIX "d"
68
69
70# define PRIi8 "i"
71# define PRIi16 "i"
72# define PRIi32 "i"
73# define PRIi64 __PRI64_PREFIX "i"
74
75# define PRIiLEAST8 "i"
76# define PRIiLEAST16 "i"
77# define PRIiLEAST32 "i"
78# define PRIiLEAST64 __PRI64_PREFIX "i"
79
80# define PRIiFAST8 "i"
81# define PRIiFAST16 __PRIPTR_PREFIX "i"
82# define PRIiFAST32 __PRIPTR_PREFIX "i"
83# define PRIiFAST64 __PRI64_PREFIX "i"
84
85/* Octal notation. */
86# define PRIo8 "o"
87# define PRIo16 "o"
88# define PRIo32 "o"
89# define PRIo64 __PRI64_PREFIX "o"
90
91# define PRIoLEAST8 "o"
92# define PRIoLEAST16 "o"
93# define PRIoLEAST32 "o"
94# define PRIoLEAST64 __PRI64_PREFIX "o"
95
96# define PRIoFAST8 "o"
97# define PRIoFAST16 __PRIPTR_PREFIX "o"
98# define PRIoFAST32 __PRIPTR_PREFIX "o"
99# define PRIoFAST64 __PRI64_PREFIX "o"
100
101/* Unsigned integers. */
102# define PRIu8 "u"
103# define PRIu16 "u"
104# define PRIu32 "u"
105# define PRIu64 __PRI64_PREFIX "u"
106
107# define PRIuLEAST8 "u"
108# define PRIuLEAST16 "u"
109# define PRIuLEAST32 "u"
110# define PRIuLEAST64 __PRI64_PREFIX "u"
111
112# define PRIuFAST8 "u"
113# define PRIuFAST16 __PRIPTR_PREFIX "u"
114# define PRIuFAST32 __PRIPTR_PREFIX "u"
115# define PRIuFAST64 __PRI64_PREFIX "u"
116
117/* lowercase hexadecimal notation. */
118# define PRIx8 "x"
119# define PRIx16 "x"
120# define PRIx32 "x"
121# define PRIx64 __PRI64_PREFIX "x"
122
123# define PRIxLEAST8 "x"
124# define PRIxLEAST16 "x"
125# define PRIxLEAST32 "x"
126# define PRIxLEAST64 __PRI64_PREFIX "x"
127
128# define PRIxFAST8 "x"
129# define PRIxFAST16 __PRIPTR_PREFIX "x"
130# define PRIxFAST32 __PRIPTR_PREFIX "x"
131# define PRIxFAST64 __PRI64_PREFIX "x"
132
133/* UPPERCASE hexadecimal notation. */
134# define PRIX8 "X"
135# define PRIX16 "X"
136# define PRIX32 "X"
137# define PRIX64 __PRI64_PREFIX "X"
138
139# define PRIXLEAST8 "X"
140# define PRIXLEAST16 "X"
141# define PRIXLEAST32 "X"
142# define PRIXLEAST64 __PRI64_PREFIX "X"
143
144# define PRIXFAST8 "X"
145# define PRIXFAST16 __PRIPTR_PREFIX "X"
146# define PRIXFAST32 __PRIPTR_PREFIX "X"
147# define PRIXFAST64 __PRI64_PREFIX "X"
148
149
150/* Macros for printing `intmax_t' and `uintmax_t'. */
151# define PRIdMAX __PRI64_PREFIX "d"
152# define PRIiMAX __PRI64_PREFIX "i"
153# define PRIoMAX __PRI64_PREFIX "o"
154# define PRIuMAX __PRI64_PREFIX "u"
155# define PRIxMAX __PRI64_PREFIX "x"
156# define PRIXMAX __PRI64_PREFIX "X"
157
158
159/* Macros for printing `intptr_t' and `uintptr_t'. */
160# define PRIdPTR __PRIPTR_PREFIX "d"
161# define PRIiPTR __PRIPTR_PREFIX "i"
162# define PRIoPTR __PRIPTR_PREFIX "o"
163# define PRIuPTR __PRIPTR_PREFIX "u"
164# define PRIxPTR __PRIPTR_PREFIX "x"
165# define PRIXPTR __PRIPTR_PREFIX "X"
166
167
168/* Macros for scanning format specifiers. */
169
170/* Signed decimal notation. */
171# define SCNd8 "hhd"
172# define SCNd16 "hd"
173# define SCNd32 "d"
174# define SCNd64 __PRI64_PREFIX "d"
175
176# define SCNdLEAST8 "hhd"
177# define SCNdLEAST16 "hd"
178# define SCNdLEAST32 "d"
179# define SCNdLEAST64 __PRI64_PREFIX "d"
180
181# define SCNdFAST8 "hhd"
182# define SCNdFAST16 __PRIPTR_PREFIX "d"
183# define SCNdFAST32 __PRIPTR_PREFIX "d"
184# define SCNdFAST64 __PRI64_PREFIX "d"
185
186/* Signed decimal notation. */
187# define SCNi8 "hhi"
188# define SCNi16 "hi"
189# define SCNi32 "i"
190# define SCNi64 __PRI64_PREFIX "i"
191
192# define SCNiLEAST8 "hhi"
193# define SCNiLEAST16 "hi"
194# define SCNiLEAST32 "i"
195# define SCNiLEAST64 __PRI64_PREFIX "i"
196
197# define SCNiFAST8 "hhi"
198# define SCNiFAST16 __PRIPTR_PREFIX "i"
199# define SCNiFAST32 __PRIPTR_PREFIX "i"
200# define SCNiFAST64 __PRI64_PREFIX "i"
201
202/* Unsigned decimal notation. */
203# define SCNu8 "hhu"
204# define SCNu16 "hu"
205# define SCNu32 "u"
206# define SCNu64 __PRI64_PREFIX "u"
207
208# define SCNuLEAST8 "hhu"
209# define SCNuLEAST16 "hu"
210# define SCNuLEAST32 "u"
211# define SCNuLEAST64 __PRI64_PREFIX "u"
212
213# define SCNuFAST8 "hhu"
214# define SCNuFAST16 __PRIPTR_PREFIX "u"
215# define SCNuFAST32 __PRIPTR_PREFIX "u"
216# define SCNuFAST64 __PRI64_PREFIX "u"
217
218/* Octal notation. */
219# define SCNo8 "hho"
220# define SCNo16 "ho"
221# define SCNo32 "o"
222# define SCNo64 __PRI64_PREFIX "o"
223
224# define SCNoLEAST8 "hho"
225# define SCNoLEAST16 "ho"
226# define SCNoLEAST32 "o"
227# define SCNoLEAST64 __PRI64_PREFIX "o"
228
229# define SCNoFAST8 "hho"
230# define SCNoFAST16 __PRIPTR_PREFIX "o"
231# define SCNoFAST32 __PRIPTR_PREFIX "o"
232# define SCNoFAST64 __PRI64_PREFIX "o"
233
234/* Hexadecimal notation. */
235# define SCNx8 "hhx"
236# define SCNx16 "hx"
237# define SCNx32 "x"
238# define SCNx64 __PRI64_PREFIX "x"
239
240# define SCNxLEAST8 "hhx"
241# define SCNxLEAST16 "hx"
242# define SCNxLEAST32 "x"
243# define SCNxLEAST64 __PRI64_PREFIX "x"
244
245# define SCNxFAST8 "hhx"
246# define SCNxFAST16 __PRIPTR_PREFIX "x"
247# define SCNxFAST32 __PRIPTR_PREFIX "x"
248# define SCNxFAST64 __PRI64_PREFIX "x"
249
250
251/* Macros for scanning `intmax_t' and `uintmax_t'. */
252# define SCNdMAX __PRI64_PREFIX "d"
253# define SCNiMAX __PRI64_PREFIX "i"
254# define SCNoMAX __PRI64_PREFIX "o"
255# define SCNuMAX __PRI64_PREFIX "u"
256# define SCNxMAX __PRI64_PREFIX "x"
257
258/* Macros for scaning `intptr_t' and `uintptr_t'. */
259# define SCNdPTR __PRIPTR_PREFIX "d"
260# define SCNiPTR __PRIPTR_PREFIX "i"
261# define SCNoPTR __PRIPTR_PREFIX "o"
262# define SCNuPTR __PRIPTR_PREFIX "u"
263# define SCNxPTR __PRIPTR_PREFIX "x"
264
265
266__BEGIN_DECLS
267
268#if __WORDSIZE == 64
269
270/* We have to define the `uintmax_t' type using `ldiv_t'. */
271typedef struct
272 {
273 long int quot; /* Quotient. */
274 long int rem; /* Remainder. */
275 } imaxdiv_t;
276
277#else
278
279/* We have to define the `uintmax_t' type using `lldiv_t'. */
280typedef struct
281 {
282 __extension__ long long int quot; /* Quotient. */
283 __extension__ long long int rem; /* Remainder. */
284 } imaxdiv_t;
285
286#endif
287
288
289/* Compute absolute value of N. */
290extern intmax_t imaxabs (intmax_t __n) __THROW __attribute__ ((__const__));
291
292/* Return the `imaxdiv_t' representation of the value of NUMER over DENOM. */
293extern imaxdiv_t imaxdiv (intmax_t __numer, intmax_t __denom)
294 __THROW __attribute__ ((__const__));
295
296/* Like `strtol' but convert to `intmax_t'. */
297extern intmax_t strtoimax (const char *__restrict __nptr,
298 char **__restrict __endptr, int __base) __THROW;
299
300/* Like `strtoul' but convert to `uintmax_t'. */
301extern uintmax_t strtoumax (const char *__restrict __nptr,
302 char ** __restrict __endptr, int __base) __THROW;
303
304/* Like `wcstol' but convert to `intmax_t'. */
305extern intmax_t wcstoimax (const __gwchar_t *__restrict __nptr,
306 __gwchar_t **__restrict __endptr, int __base)
307 __THROW;
308
309/* Like `wcstoul' but convert to `uintmax_t'. */
310extern uintmax_t wcstoumax (const __gwchar_t *__restrict __nptr,
311 __gwchar_t ** __restrict __endptr, int __base)
312 __THROW;
313
314#ifdef __USE_EXTERN_INLINES
315
316# if __WORDSIZE == 64
317
318extern long int __strtol_internal (const char *__restrict __nptr,
319 char **__restrict __endptr,
320 int __base, int __group)
321 __THROW __nonnull ((1)) __wur;
322/* Like `strtol' but convert to `intmax_t'. */
323__extern_inline intmax_t
324__NTH (strtoimax (const char *__restrict nptr, char **__restrict endptr,
325 int base))
326{
327 return __strtol_internal (nptr, endptr, base, 0);
328}
329
330extern unsigned long int __strtoul_internal (const char *__restrict __nptr,
331 char ** __restrict __endptr,
332 int __base, int __group)
333 __THROW __nonnull ((1)) __wur;
334/* Like `strtoul' but convert to `uintmax_t'. */
335__extern_inline uintmax_t
336__NTH (strtoumax (const char *__restrict nptr, char **__restrict endptr,
337 int base))
338{
339 return __strtoul_internal (nptr, endptr, base, 0);
340}
341
342extern long int __wcstol_internal (const __gwchar_t * __restrict __nptr,
343 __gwchar_t **__restrict __endptr,
344 int __base, int __group)
345 __THROW __nonnull ((1)) __wur;
346/* Like `wcstol' but convert to `intmax_t'. */
347__extern_inline intmax_t
348__NTH (wcstoimax (const __gwchar_t *__restrict nptr,
349 __gwchar_t **__restrict endptr, int base))
350{
351 return __wcstol_internal (nptr, endptr, base, 0);
352}
353
354extern unsigned long int __wcstoul_internal (const __gwchar_t *
355 __restrict __nptr,
356 __gwchar_t **
357 __restrict __endptr,
358 int __base, int __group)
359 __THROW __nonnull ((1)) __wur;
360/* Like `wcstoul' but convert to `uintmax_t'. */
361__extern_inline uintmax_t
362__NTH (wcstoumax (const __gwchar_t *__restrict nptr,
363 __gwchar_t **__restrict endptr, int base))
364{
365 return __wcstoul_internal (nptr, endptr, base, 0);
366}
367
368# else /* __WORDSIZE == 32 */
369
370__extension__
371extern long long int __strtoll_internal (const char *__restrict __nptr,
372 char **__restrict __endptr,
373 int __base, int __group)
374 __THROW __nonnull ((1)) __wur;
375/* Like `strtol' but convert to `intmax_t'. */
376__extern_inline intmax_t
377__NTH (strtoimax (const char *__restrict nptr, char **__restrict endptr,
378 int base))
379{
380 return __strtoll_internal (nptr, endptr, base, 0);
381}
382
383__extension__
384extern unsigned long long int __strtoull_internal (const char *
385 __restrict __nptr,
386 char **
387 __restrict __endptr,
388 int __base,
389 int __group)
390 __THROW __nonnull ((1)) __wur;
391/* Like `strtoul' but convert to `uintmax_t'. */
392__extern_inline uintmax_t
393__NTH (strtoumax (const char *__restrict nptr, char **__restrict endptr,
394 int base))
395{
396 return __strtoull_internal (nptr, endptr, base, 0);
397}
398
399__extension__
400extern long long int __wcstoll_internal (const __gwchar_t *__restrict __nptr,
401 __gwchar_t **__restrict __endptr,
402 int __base, int __group)
403 __THROW __nonnull ((1)) __wur;
404/* Like `wcstol' but convert to `intmax_t'. */
405__extern_inline intmax_t
406__NTH (wcstoimax (const __gwchar_t *__restrict nptr,
407 __gwchar_t **__restrict endptr, int base))
408{
409 return __wcstoll_internal (nptr, endptr, base, 0);
410}
411
412
413__extension__
414extern unsigned long long int __wcstoull_internal (const __gwchar_t *
415 __restrict __nptr,
416 __gwchar_t **
417 __restrict __endptr,
418 int __base,
419 int __group)
420 __THROW __nonnull ((1)) __wur;
421/* Like `wcstoul' but convert to `uintmax_t'. */
422__extern_inline uintmax_t
423__NTH (wcstoumax (const __gwchar_t *__restrict nptr,
424 __gwchar_t **__restrict endptr, int base))
425{
426 return __wcstoull_internal (nptr, endptr, base, 0);
427}
428
429# endif /* __WORDSIZE == 32 */
430#endif /* Use extern inlines. */
431
432__END_DECLS
433
434#endif /* inttypes.h */
libc/glibc-include/langinfo.h created+674
...@@ -0,0 +1,674 @@
1/* Access to locale-dependent parameters.
2 Copyright (C) 1995-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _LANGINFO_H
20#define _LANGINFO_H 1
21
22/* Get the type definition. */
23#include <nl_types.h>
24
25#include <bits/locale.h> /* Define the __LC_* category names. */
26
27
28__BEGIN_DECLS
29
30/* Construct an `nl_item' value for `nl_langinfo' from a locale category
31 (LC_*) and an item index within the category. Some code may depend on
32 the item values within a category increasing monotonically with the
33 indices. */
34#define _NL_ITEM(category, index) (((category) << 16) | (index))
35
36/* Extract the category and item index from a constructed `nl_item' value. */
37#define _NL_ITEM_CATEGORY(item) ((int) (item) >> 16)
38#define _NL_ITEM_INDEX(item) ((int) (item) & 0xffff)
39
40/* Enumeration of locale items that can be queried with `nl_langinfo'. */
41enum
42{
43 /* LC_TIME category: date and time formatting. */
44
45 /* Abbreviated days of the week. */
46 ABDAY_1 = _NL_ITEM (__LC_TIME, 0), /* Sun */
47#define ABDAY_1 ABDAY_1
48 ABDAY_2,
49#define ABDAY_2 ABDAY_2
50 ABDAY_3,
51#define ABDAY_3 ABDAY_3
52 ABDAY_4,
53#define ABDAY_4 ABDAY_4
54 ABDAY_5,
55#define ABDAY_5 ABDAY_5
56 ABDAY_6,
57#define ABDAY_6 ABDAY_6
58 ABDAY_7,
59#define ABDAY_7 ABDAY_7
60
61 /* Long-named days of the week. */
62 DAY_1, /* Sunday */
63#define DAY_1 DAY_1
64 DAY_2, /* Monday */
65#define DAY_2 DAY_2
66 DAY_3, /* Tuesday */
67#define DAY_3 DAY_3
68 DAY_4, /* Wednesday */
69#define DAY_4 DAY_4
70 DAY_5, /* Thursday */
71#define DAY_5 DAY_5
72 DAY_6, /* Friday */
73#define DAY_6 DAY_6
74 DAY_7, /* Saturday */
75#define DAY_7 DAY_7
76
77 /* Abbreviated month names, in the grammatical form used when the month
78 is a part of a complete date. */
79 ABMON_1, /* Jan */
80#define ABMON_1 ABMON_1
81 ABMON_2,
82#define ABMON_2 ABMON_2
83 ABMON_3,
84#define ABMON_3 ABMON_3
85 ABMON_4,
86#define ABMON_4 ABMON_4
87 ABMON_5,
88#define ABMON_5 ABMON_5
89 ABMON_6,
90#define ABMON_6 ABMON_6
91 ABMON_7,
92#define ABMON_7 ABMON_7
93 ABMON_8,
94#define ABMON_8 ABMON_8
95 ABMON_9,
96#define ABMON_9 ABMON_9
97 ABMON_10,
98#define ABMON_10 ABMON_10
99 ABMON_11,
100#define ABMON_11 ABMON_11
101 ABMON_12,
102#define ABMON_12 ABMON_12
103
104 /* Long month names, in the grammatical form used when the month
105 is a part of a complete date. */
106 MON_1, /* January */
107#define MON_1 MON_1
108 MON_2,
109#define MON_2 MON_2
110 MON_3,
111#define MON_3 MON_3
112 MON_4,
113#define MON_4 MON_4
114 MON_5,
115#define MON_5 MON_5
116 MON_6,
117#define MON_6 MON_6
118 MON_7,
119#define MON_7 MON_7
120 MON_8,
121#define MON_8 MON_8
122 MON_9,
123#define MON_9 MON_9
124 MON_10,
125#define MON_10 MON_10
126 MON_11,
127#define MON_11 MON_11
128 MON_12,
129#define MON_12 MON_12
130
131 AM_STR, /* Ante meridiem string. */
132#define AM_STR AM_STR
133 PM_STR, /* Post meridiem string. */
134#define PM_STR PM_STR
135
136 D_T_FMT, /* Date and time format for strftime. */
137#define D_T_FMT D_T_FMT
138 D_FMT, /* Date format for strftime. */
139#define D_FMT D_FMT
140 T_FMT, /* Time format for strftime. */
141#define T_FMT T_FMT
142 T_FMT_AMPM, /* 12-hour time format for strftime. */
143#define T_FMT_AMPM T_FMT_AMPM
144
145 ERA, /* Alternate era. */
146#define ERA ERA
147 __ERA_YEAR, /* Year in alternate era format. */
148#ifdef __USE_GNU
149# define ERA_YEAR __ERA_YEAR
150#endif
151 ERA_D_FMT, /* Date in alternate era format. */
152#define ERA_D_FMT ERA_D_FMT
153 ALT_DIGITS, /* Alternate symbols for digits. */
154#define ALT_DIGITS ALT_DIGITS
155 ERA_D_T_FMT, /* Date and time in alternate era format. */
156#define ERA_D_T_FMT ERA_D_T_FMT
157 ERA_T_FMT, /* Time in alternate era format. */
158#define ERA_T_FMT ERA_T_FMT
159
160 _NL_TIME_ERA_NUM_ENTRIES, /* Number entries in the era arrays. */
161 _NL_TIME_ERA_ENTRIES, /* Structure with era entries in usable form.*/
162
163 _NL_WABDAY_1, /* Sun */
164 _NL_WABDAY_2,
165 _NL_WABDAY_3,
166 _NL_WABDAY_4,
167 _NL_WABDAY_5,
168 _NL_WABDAY_6,
169 _NL_WABDAY_7,
170
171 /* Long-named days of the week. */
172 _NL_WDAY_1, /* Sunday */
173 _NL_WDAY_2, /* Monday */
174 _NL_WDAY_3, /* Tuesday */
175 _NL_WDAY_4, /* Wednesday */
176 _NL_WDAY_5, /* Thursday */
177 _NL_WDAY_6, /* Friday */
178 _NL_WDAY_7, /* Saturday */
179
180 /* Abbreviated month names, in the grammatical form used when the month
181 is a part of a complete date. */
182 _NL_WABMON_1, /* Jan */
183 _NL_WABMON_2,
184 _NL_WABMON_3,
185 _NL_WABMON_4,
186 _NL_WABMON_5,
187 _NL_WABMON_6,
188 _NL_WABMON_7,
189 _NL_WABMON_8,
190 _NL_WABMON_9,
191 _NL_WABMON_10,
192 _NL_WABMON_11,
193 _NL_WABMON_12,
194
195 /* Long month names, in the grammatical form used when the month
196 is a part of a complete date. */
197 _NL_WMON_1, /* January */
198 _NL_WMON_2,
199 _NL_WMON_3,
200 _NL_WMON_4,
201 _NL_WMON_5,
202 _NL_WMON_6,
203 _NL_WMON_7,
204 _NL_WMON_8,
205 _NL_WMON_9,
206 _NL_WMON_10,
207 _NL_WMON_11,
208 _NL_WMON_12,
209
210 _NL_WAM_STR, /* Ante meridiem string. */
211 _NL_WPM_STR, /* Post meridiem string. */
212
213 _NL_WD_T_FMT, /* Date and time format for strftime. */
214 _NL_WD_FMT, /* Date format for strftime. */
215 _NL_WT_FMT, /* Time format for strftime. */
216 _NL_WT_FMT_AMPM, /* 12-hour time format for strftime. */
217
218 _NL_WERA_YEAR, /* Year in alternate era format. */
219 _NL_WERA_D_FMT, /* Date in alternate era format. */
220 _NL_WALT_DIGITS, /* Alternate symbols for digits. */
221 _NL_WERA_D_T_FMT, /* Date and time in alternate era format. */
222 _NL_WERA_T_FMT, /* Time in alternate era format. */
223
224 _NL_TIME_WEEK_NDAYS,
225 _NL_TIME_WEEK_1STDAY,
226 _NL_TIME_WEEK_1STWEEK,
227 _NL_TIME_FIRST_WEEKDAY,
228 _NL_TIME_FIRST_WORKDAY,
229 _NL_TIME_CAL_DIRECTION,
230 _NL_TIME_TIMEZONE,
231
232 _DATE_FMT, /* strftime format for date. */
233#define _DATE_FMT _DATE_FMT
234 _NL_W_DATE_FMT,
235
236 _NL_TIME_CODESET,
237
238 /* Long month names, in the grammatical form used when the month
239 is named by itself. */
240 __ALTMON_1, /* January */
241 __ALTMON_2,
242 __ALTMON_3,
243 __ALTMON_4,
244 __ALTMON_5,
245 __ALTMON_6,
246 __ALTMON_7,
247 __ALTMON_8,
248 __ALTMON_9,
249 __ALTMON_10,
250 __ALTMON_11,
251 __ALTMON_12,
252#ifdef __USE_GNU
253# define ALTMON_1 __ALTMON_1
254# define ALTMON_2 __ALTMON_2
255# define ALTMON_3 __ALTMON_3
256# define ALTMON_4 __ALTMON_4
257# define ALTMON_5 __ALTMON_5
258# define ALTMON_6 __ALTMON_6
259# define ALTMON_7 __ALTMON_7
260# define ALTMON_8 __ALTMON_8
261# define ALTMON_9 __ALTMON_9
262# define ALTMON_10 __ALTMON_10
263# define ALTMON_11 __ALTMON_11
264# define ALTMON_12 __ALTMON_12
265#endif
266
267 /* Long month names, in the grammatical form used when the month
268 is named by itself. */
269 _NL_WALTMON_1, /* January */
270 _NL_WALTMON_2,
271 _NL_WALTMON_3,
272 _NL_WALTMON_4,
273 _NL_WALTMON_5,
274 _NL_WALTMON_6,
275 _NL_WALTMON_7,
276 _NL_WALTMON_8,
277 _NL_WALTMON_9,
278 _NL_WALTMON_10,
279 _NL_WALTMON_11,
280 _NL_WALTMON_12,
281
282 /* Abbreviated month names, in the grammatical form used when the month
283 is named by itself. */
284 _NL_ABALTMON_1, /* Jan */
285 _NL_ABALTMON_2,
286 _NL_ABALTMON_3,
287 _NL_ABALTMON_4,
288 _NL_ABALTMON_5,
289 _NL_ABALTMON_6,
290 _NL_ABALTMON_7,
291 _NL_ABALTMON_8,
292 _NL_ABALTMON_9,
293 _NL_ABALTMON_10,
294 _NL_ABALTMON_11,
295 _NL_ABALTMON_12,
296
297 /* Abbreviated month names, in the grammatical form used when the month
298 is named by itself. */
299 _NL_WABALTMON_1, /* Jan */
300 _NL_WABALTMON_2,
301 _NL_WABALTMON_3,
302 _NL_WABALTMON_4,
303 _NL_WABALTMON_5,
304 _NL_WABALTMON_6,
305 _NL_WABALTMON_7,
306 _NL_WABALTMON_8,
307 _NL_WABALTMON_9,
308 _NL_WABALTMON_10,
309 _NL_WABALTMON_11,
310 _NL_WABALTMON_12,
311
312 _NL_NUM_LC_TIME, /* Number of indices in LC_TIME category. */
313
314 /* LC_COLLATE category: text sorting.
315 This information is accessed by the strcoll and strxfrm functions.
316 These `nl_langinfo' names are used only internally. */
317 _NL_COLLATE_NRULES = _NL_ITEM (__LC_COLLATE, 0),
318 _NL_COLLATE_RULESETS,
319 _NL_COLLATE_TABLEMB,
320 _NL_COLLATE_WEIGHTMB,
321 _NL_COLLATE_EXTRAMB,
322 _NL_COLLATE_INDIRECTMB,
323 _NL_COLLATE_GAP1,
324 _NL_COLLATE_GAP2,
325 _NL_COLLATE_GAP3,
326 _NL_COLLATE_TABLEWC,
327 _NL_COLLATE_WEIGHTWC,
328 _NL_COLLATE_EXTRAWC,
329 _NL_COLLATE_INDIRECTWC,
330 _NL_COLLATE_SYMB_HASH_SIZEMB,
331 _NL_COLLATE_SYMB_TABLEMB,
332 _NL_COLLATE_SYMB_EXTRAMB,
333 _NL_COLLATE_COLLSEQMB,
334 _NL_COLLATE_COLLSEQWC,
335 _NL_COLLATE_CODESET,
336 _NL_NUM_LC_COLLATE,
337
338 /* LC_CTYPE category: character classification.
339 This information is accessed by the functions in <ctype.h>.
340 These `nl_langinfo' names are used only internally. */
341 _NL_CTYPE_CLASS = _NL_ITEM (__LC_CTYPE, 0),
342 _NL_CTYPE_TOUPPER,
343 _NL_CTYPE_GAP1,
344 _NL_CTYPE_TOLOWER,
345 _NL_CTYPE_GAP2,
346 _NL_CTYPE_CLASS32,
347 _NL_CTYPE_GAP3,
348 _NL_CTYPE_GAP4,
349 _NL_CTYPE_GAP5,
350 _NL_CTYPE_GAP6,
351 _NL_CTYPE_CLASS_NAMES,
352 _NL_CTYPE_MAP_NAMES,
353 _NL_CTYPE_WIDTH,
354 _NL_CTYPE_MB_CUR_MAX,
355 _NL_CTYPE_CODESET_NAME,
356 CODESET = _NL_CTYPE_CODESET_NAME,
357#define CODESET CODESET
358 _NL_CTYPE_TOUPPER32,
359 _NL_CTYPE_TOLOWER32,
360 _NL_CTYPE_CLASS_OFFSET,
361 _NL_CTYPE_MAP_OFFSET,
362 _NL_CTYPE_INDIGITS_MB_LEN,
363 _NL_CTYPE_INDIGITS0_MB,
364 _NL_CTYPE_INDIGITS1_MB,
365 _NL_CTYPE_INDIGITS2_MB,
366 _NL_CTYPE_INDIGITS3_MB,
367 _NL_CTYPE_INDIGITS4_MB,
368 _NL_CTYPE_INDIGITS5_MB,
369 _NL_CTYPE_INDIGITS6_MB,
370 _NL_CTYPE_INDIGITS7_MB,
371 _NL_CTYPE_INDIGITS8_MB,
372 _NL_CTYPE_INDIGITS9_MB,
373 _NL_CTYPE_INDIGITS_WC_LEN,
374 _NL_CTYPE_INDIGITS0_WC,
375 _NL_CTYPE_INDIGITS1_WC,
376 _NL_CTYPE_INDIGITS2_WC,
377 _NL_CTYPE_INDIGITS3_WC,
378 _NL_CTYPE_INDIGITS4_WC,
379 _NL_CTYPE_INDIGITS5_WC,
380 _NL_CTYPE_INDIGITS6_WC,
381 _NL_CTYPE_INDIGITS7_WC,
382 _NL_CTYPE_INDIGITS8_WC,
383 _NL_CTYPE_INDIGITS9_WC,
384 _NL_CTYPE_OUTDIGIT0_MB,
385 _NL_CTYPE_OUTDIGIT1_MB,
386 _NL_CTYPE_OUTDIGIT2_MB,
387 _NL_CTYPE_OUTDIGIT3_MB,
388 _NL_CTYPE_OUTDIGIT4_MB,
389 _NL_CTYPE_OUTDIGIT5_MB,
390 _NL_CTYPE_OUTDIGIT6_MB,
391 _NL_CTYPE_OUTDIGIT7_MB,
392 _NL_CTYPE_OUTDIGIT8_MB,
393 _NL_CTYPE_OUTDIGIT9_MB,
394 _NL_CTYPE_OUTDIGIT0_WC,
395 _NL_CTYPE_OUTDIGIT1_WC,
396 _NL_CTYPE_OUTDIGIT2_WC,
397 _NL_CTYPE_OUTDIGIT3_WC,
398 _NL_CTYPE_OUTDIGIT4_WC,
399 _NL_CTYPE_OUTDIGIT5_WC,
400 _NL_CTYPE_OUTDIGIT6_WC,
401 _NL_CTYPE_OUTDIGIT7_WC,
402 _NL_CTYPE_OUTDIGIT8_WC,
403 _NL_CTYPE_OUTDIGIT9_WC,
404 _NL_CTYPE_TRANSLIT_TAB_SIZE,
405 _NL_CTYPE_TRANSLIT_FROM_IDX,
406 _NL_CTYPE_TRANSLIT_FROM_TBL,
407 _NL_CTYPE_TRANSLIT_TO_IDX,
408 _NL_CTYPE_TRANSLIT_TO_TBL,
409 _NL_CTYPE_TRANSLIT_DEFAULT_MISSING_LEN,
410 _NL_CTYPE_TRANSLIT_DEFAULT_MISSING,
411 _NL_CTYPE_TRANSLIT_IGNORE_LEN,
412 _NL_CTYPE_TRANSLIT_IGNORE,
413 _NL_CTYPE_MAP_TO_NONASCII,
414 _NL_CTYPE_NONASCII_CASE,
415 _NL_CTYPE_EXTRA_MAP_1,
416 _NL_CTYPE_EXTRA_MAP_2,
417 _NL_CTYPE_EXTRA_MAP_3,
418 _NL_CTYPE_EXTRA_MAP_4,
419 _NL_CTYPE_EXTRA_MAP_5,
420 _NL_CTYPE_EXTRA_MAP_6,
421 _NL_CTYPE_EXTRA_MAP_7,
422 _NL_CTYPE_EXTRA_MAP_8,
423 _NL_CTYPE_EXTRA_MAP_9,
424 _NL_CTYPE_EXTRA_MAP_10,
425 _NL_CTYPE_EXTRA_MAP_11,
426 _NL_CTYPE_EXTRA_MAP_12,
427 _NL_CTYPE_EXTRA_MAP_13,
428 _NL_CTYPE_EXTRA_MAP_14,
429 _NL_NUM_LC_CTYPE,
430
431 /* LC_MONETARY category: formatting of monetary quantities.
432 These items each correspond to a member of `struct lconv',
433 defined in <locale.h>. */
434 __INT_CURR_SYMBOL = _NL_ITEM (__LC_MONETARY, 0),
435#ifdef __USE_GNU
436# define INT_CURR_SYMBOL __INT_CURR_SYMBOL
437#endif
438 __CURRENCY_SYMBOL,
439#ifdef __USE_GNU
440# define CURRENCY_SYMBOL __CURRENCY_SYMBOL
441#endif
442 __MON_DECIMAL_POINT,
443#ifdef __USE_GNU
444# define MON_DECIMAL_POINT __MON_DECIMAL_POINT
445#endif
446 __MON_THOUSANDS_SEP,
447#ifdef __USE_GNU
448# define MON_THOUSANDS_SEP __MON_THOUSANDS_SEP
449#endif
450 __MON_GROUPING,
451#ifdef __USE_GNU
452# define MON_GROUPING __MON_GROUPING
453#endif
454 __POSITIVE_SIGN,
455#ifdef __USE_GNU
456# define POSITIVE_SIGN __POSITIVE_SIGN
457#endif
458 __NEGATIVE_SIGN,
459#ifdef __USE_GNU
460# define NEGATIVE_SIGN __NEGATIVE_SIGN
461#endif
462 __INT_FRAC_DIGITS,
463#ifdef __USE_GNU
464# define INT_FRAC_DIGITS __INT_FRAC_DIGITS
465#endif
466 __FRAC_DIGITS,
467#ifdef __USE_GNU
468# define FRAC_DIGITS __FRAC_DIGITS
469#endif
470 __P_CS_PRECEDES,
471#ifdef __USE_GNU
472# define P_CS_PRECEDES __P_CS_PRECEDES
473#endif
474 __P_SEP_BY_SPACE,
475#ifdef __USE_GNU
476# define P_SEP_BY_SPACE __P_SEP_BY_SPACE
477#endif
478 __N_CS_PRECEDES,
479#ifdef __USE_GNU
480# define N_CS_PRECEDES __N_CS_PRECEDES
481#endif
482 __N_SEP_BY_SPACE,
483#ifdef __USE_GNU
484# define N_SEP_BY_SPACE __N_SEP_BY_SPACE
485#endif
486 __P_SIGN_POSN,
487#ifdef __USE_GNU
488# define P_SIGN_POSN __P_SIGN_POSN
489#endif
490 __N_SIGN_POSN,
491#ifdef __USE_GNU
492# define N_SIGN_POSN __N_SIGN_POSN
493#endif
494 _NL_MONETARY_CRNCYSTR,
495#define CRNCYSTR _NL_MONETARY_CRNCYSTR
496 __INT_P_CS_PRECEDES,
497#ifdef __USE_GNU
498# define INT_P_CS_PRECEDES __INT_P_CS_PRECEDES
499#endif
500 __INT_P_SEP_BY_SPACE,
501#ifdef __USE_GNU
502# define INT_P_SEP_BY_SPACE __INT_P_SEP_BY_SPACE
503#endif
504 __INT_N_CS_PRECEDES,
505#ifdef __USE_GNU
506# define INT_N_CS_PRECEDES __INT_N_CS_PRECEDES
507#endif
508 __INT_N_SEP_BY_SPACE,
509#ifdef __USE_GNU
510# define INT_N_SEP_BY_SPACE __INT_N_SEP_BY_SPACE
511#endif
512 __INT_P_SIGN_POSN,
513#ifdef __USE_GNU
514# define INT_P_SIGN_POSN __INT_P_SIGN_POSN
515#endif
516 __INT_N_SIGN_POSN,
517#ifdef __USE_GNU
518# define INT_N_SIGN_POSN __INT_N_SIGN_POSN
519#endif
520 _NL_MONETARY_DUO_INT_CURR_SYMBOL,
521 _NL_MONETARY_DUO_CURRENCY_SYMBOL,
522 _NL_MONETARY_DUO_INT_FRAC_DIGITS,
523 _NL_MONETARY_DUO_FRAC_DIGITS,
524 _NL_MONETARY_DUO_P_CS_PRECEDES,
525 _NL_MONETARY_DUO_P_SEP_BY_SPACE,
526 _NL_MONETARY_DUO_N_CS_PRECEDES,
527 _NL_MONETARY_DUO_N_SEP_BY_SPACE,
528 _NL_MONETARY_DUO_INT_P_CS_PRECEDES,
529 _NL_MONETARY_DUO_INT_P_SEP_BY_SPACE,
530 _NL_MONETARY_DUO_INT_N_CS_PRECEDES,
531 _NL_MONETARY_DUO_INT_N_SEP_BY_SPACE,
532 _NL_MONETARY_DUO_P_SIGN_POSN,
533 _NL_MONETARY_DUO_N_SIGN_POSN,
534 _NL_MONETARY_DUO_INT_P_SIGN_POSN,
535 _NL_MONETARY_DUO_INT_N_SIGN_POSN,
536 _NL_MONETARY_UNO_VALID_FROM,
537 _NL_MONETARY_UNO_VALID_TO,
538 _NL_MONETARY_DUO_VALID_FROM,
539 _NL_MONETARY_DUO_VALID_TO,
540 _NL_MONETARY_CONVERSION_RATE,
541 _NL_MONETARY_DECIMAL_POINT_WC,
542 _NL_MONETARY_THOUSANDS_SEP_WC,
543 _NL_MONETARY_CODESET,
544 _NL_NUM_LC_MONETARY,
545
546 /* LC_NUMERIC category: formatting of numbers.
547 These also correspond to members of `struct lconv'; see <locale.h>. */
548 __DECIMAL_POINT = _NL_ITEM (__LC_NUMERIC, 0),
549#ifdef __USE_GNU
550# define DECIMAL_POINT __DECIMAL_POINT
551#endif
552 RADIXCHAR = __DECIMAL_POINT,
553#define RADIXCHAR RADIXCHAR
554 __THOUSANDS_SEP,
555#ifdef __USE_GNU
556# define THOUSANDS_SEP __THOUSANDS_SEP
557#endif
558 THOUSEP = __THOUSANDS_SEP,
559#define THOUSEP THOUSEP
560 __GROUPING,
561#ifdef __USE_GNU
562# define GROUPING __GROUPING
563#endif
564 _NL_NUMERIC_DECIMAL_POINT_WC,
565 _NL_NUMERIC_THOUSANDS_SEP_WC,
566 _NL_NUMERIC_CODESET,
567 _NL_NUM_LC_NUMERIC,
568
569 __YESEXPR = _NL_ITEM (__LC_MESSAGES, 0), /* Regex matching ``yes'' input. */
570#define YESEXPR __YESEXPR
571 __NOEXPR, /* Regex matching ``no'' input. */
572#define NOEXPR __NOEXPR
573 __YESSTR, /* Output string for ``yes''. */
574#if defined __USE_GNU || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
575# define YESSTR __YESSTR
576#endif
577 __NOSTR, /* Output string for ``no''. */
578#if defined __USE_GNU || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
579# define NOSTR __NOSTR
580#endif
581 _NL_MESSAGES_CODESET,
582 _NL_NUM_LC_MESSAGES,
583
584 _NL_PAPER_HEIGHT = _NL_ITEM (__LC_PAPER, 0),
585 _NL_PAPER_WIDTH,
586 _NL_PAPER_CODESET,
587 _NL_NUM_LC_PAPER,
588
589 _NL_NAME_NAME_FMT = _NL_ITEM (__LC_NAME, 0),
590 _NL_NAME_NAME_GEN,
591 _NL_NAME_NAME_MR,
592 _NL_NAME_NAME_MRS,
593 _NL_NAME_NAME_MISS,
594 _NL_NAME_NAME_MS,
595 _NL_NAME_CODESET,
596 _NL_NUM_LC_NAME,
597
598 _NL_ADDRESS_POSTAL_FMT = _NL_ITEM (__LC_ADDRESS, 0),
599 _NL_ADDRESS_COUNTRY_NAME,
600 _NL_ADDRESS_COUNTRY_POST,
601 _NL_ADDRESS_COUNTRY_AB2,
602 _NL_ADDRESS_COUNTRY_AB3,
603 _NL_ADDRESS_COUNTRY_CAR,
604 _NL_ADDRESS_COUNTRY_NUM,
605 _NL_ADDRESS_COUNTRY_ISBN,
606 _NL_ADDRESS_LANG_NAME,
607 _NL_ADDRESS_LANG_AB,
608 _NL_ADDRESS_LANG_TERM,
609 _NL_ADDRESS_LANG_LIB,
610 _NL_ADDRESS_CODESET,
611 _NL_NUM_LC_ADDRESS,
612
613 _NL_TELEPHONE_TEL_INT_FMT = _NL_ITEM (__LC_TELEPHONE, 0),
614 _NL_TELEPHONE_TEL_DOM_FMT,
615 _NL_TELEPHONE_INT_SELECT,
616 _NL_TELEPHONE_INT_PREFIX,
617 _NL_TELEPHONE_CODESET,
618 _NL_NUM_LC_TELEPHONE,
619
620 _NL_MEASUREMENT_MEASUREMENT = _NL_ITEM (__LC_MEASUREMENT, 0),
621 _NL_MEASUREMENT_CODESET,
622 _NL_NUM_LC_MEASUREMENT,
623
624 _NL_IDENTIFICATION_TITLE = _NL_ITEM (__LC_IDENTIFICATION, 0),
625 _NL_IDENTIFICATION_SOURCE,
626 _NL_IDENTIFICATION_ADDRESS,
627 _NL_IDENTIFICATION_CONTACT,
628 _NL_IDENTIFICATION_EMAIL,
629 _NL_IDENTIFICATION_TEL,
630 _NL_IDENTIFICATION_FAX,
631 _NL_IDENTIFICATION_LANGUAGE,
632 _NL_IDENTIFICATION_TERRITORY,
633 _NL_IDENTIFICATION_AUDIENCE,
634 _NL_IDENTIFICATION_APPLICATION,
635 _NL_IDENTIFICATION_ABBREVIATION,
636 _NL_IDENTIFICATION_REVISION,
637 _NL_IDENTIFICATION_DATE,
638 _NL_IDENTIFICATION_CATEGORY,
639 _NL_IDENTIFICATION_CODESET,
640 _NL_NUM_LC_IDENTIFICATION,
641
642 /* This marks the highest value used. */
643 _NL_NUM
644};
645
646/* This macro produces an item you can pass to `nl_langinfo' or
647 `nl_langinfo_l' to get the name of the locale in use for CATEGORY. */
648#define _NL_LOCALE_NAME(category) _NL_ITEM ((category), \
649 _NL_ITEM_INDEX (-1))
650#ifdef __USE_GNU
651# define NL_LOCALE_NAME(category) _NL_LOCALE_NAME (category)
652#endif
653
654
655/* Return the current locale's value for ITEM.
656 If ITEM is invalid, an empty string is returned.
657
658 The string returned will not change until `setlocale' is called;
659 it is usually in read-only memory and cannot be modified. */
660
661extern char *nl_langinfo (nl_item __item) __THROW;
662
663
664#ifdef __USE_XOPEN2K8
665/* POSIX.1-2008 extended locale interface (see locale.h). */
666# include <bits/types/locale_t.h>
667
668/* Just like nl_langinfo but get the information from the locale object L. */
669extern char *nl_langinfo_l (nl_item __item, locale_t __l);
670#endif
671
672__END_DECLS
673
674#endif /* langinfo.h */
libc/glibc-include/lastlog.h created+4
...@@ -0,0 +1,4 @@
1/* This header file is used in 4.3BSD to define `struct lastlog',
2 which we define in <bits/utmp.h>. */
3
4#include <utmp.h>
libc/glibc-include/libgen.h created+39
...@@ -0,0 +1,39 @@
1/* Copyright (C) 1996-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _LIBGEN_H
19#define _LIBGEN_H 1
20
21#include <features.h>
22
23__BEGIN_DECLS
24
25/* Return directory part of PATH or "." if none is available. */
26extern char *dirname (char *__path) __THROW;
27
28/* Return final component of PATH.
29
30 This is the weird XPG version of this function. It sometimes will
31 modify its argument. Therefore we normally use the GNU version (in
32 <string.h>) and only if this header is included make the XPG
33 version available under the real name. */
34extern char *__xpg_basename (char *__path) __THROW;
35#define basename __xpg_basename
36
37__END_DECLS
38
39#endif /* libgen.h */
libc/glibc-include/libintl.h created+123
...@@ -0,0 +1,123 @@
1/* Message catalogs for internationalization.
2 Copyright (C) 1995-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 This file is derived from the file libgettext.h in the GNU gettext package.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
19
20#ifndef _LIBINTL_H
21#define _LIBINTL_H 1
22
23#include <features.h>
24
25/* We define an additional symbol to signal that we use the GNU
26 implementation of gettext. */
27#define __USE_GNU_GETTEXT 1
28
29/* Provide information about the supported file formats. Returns the
30 maximum minor revision number supported for a given major revision. */
31#define __GNU_GETTEXT_SUPPORTED_REVISION(major) \
32 ((major) == 0 ? 1 : -1)
33
34__BEGIN_DECLS
35
36/* Look up MSGID in the current default message catalog for the current
37 LC_MESSAGES locale. If not found, returns MSGID itself (the default
38 text). */
39extern char *gettext (const char *__msgid)
40 __THROW __attribute_format_arg__ (1);
41
42/* Look up MSGID in the DOMAINNAME message catalog for the current
43 LC_MESSAGES locale. */
44extern char *dgettext (const char *__domainname, const char *__msgid)
45 __THROW __attribute_format_arg__ (2);
46extern char *__dgettext (const char *__domainname, const char *__msgid)
47 __THROW __attribute_format_arg__ (2);
48
49/* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY
50 locale. */
51extern char *dcgettext (const char *__domainname,
52 const char *__msgid, int __category)
53 __THROW __attribute_format_arg__ (2);
54extern char *__dcgettext (const char *__domainname,
55 const char *__msgid, int __category)
56 __THROW __attribute_format_arg__ (2);
57
58
59/* Similar to `gettext' but select the plural form corresponding to the
60 number N. */
61extern char *ngettext (const char *__msgid1, const char *__msgid2,
62 unsigned long int __n)
63 __THROW __attribute_format_arg__ (1) __attribute_format_arg__ (2);
64
65/* Similar to `dgettext' but select the plural form corresponding to the
66 number N. */
67extern char *dngettext (const char *__domainname, const char *__msgid1,
68 const char *__msgid2, unsigned long int __n)
69 __THROW __attribute_format_arg__ (2) __attribute_format_arg__ (3);
70
71/* Similar to `dcgettext' but select the plural form corresponding to the
72 number N. */
73extern char *dcngettext (const char *__domainname, const char *__msgid1,
74 const char *__msgid2, unsigned long int __n,
75 int __category)
76 __THROW __attribute_format_arg__ (2) __attribute_format_arg__ (3);
77
78
79/* Set the current default message catalog to DOMAINNAME.
80 If DOMAINNAME is null, return the current default.
81 If DOMAINNAME is "", reset to the default of "messages". */
82extern char *textdomain (const char *__domainname) __THROW;
83
84/* Specify that the DOMAINNAME message catalog will be found
85 in DIRNAME rather than in the system locale data base. */
86extern char *bindtextdomain (const char *__domainname,
87 const char *__dirname) __THROW;
88
89/* Specify the character encoding in which the messages from the
90 DOMAINNAME message catalog will be returned. */
91extern char *bind_textdomain_codeset (const char *__domainname,
92 const char *__codeset) __THROW;
93
94
95/* Optimized version of the function above. */
96#if defined __OPTIMIZE__ && !defined __cplusplus
97
98/* We need NULL for `gettext'. */
99# define __need_NULL
100# include <stddef.h>
101
102/* We need LC_MESSAGES for `dgettext'. */
103# include <locale.h>
104
105/* These must be macros. Inlined functions are useless because the
106 `__builtin_constant_p' predicate in dcgettext would always return
107 false. */
108
109# define gettext(msgid) dgettext (NULL, msgid)
110
111# define dgettext(domainname, msgid) \
112 dcgettext (domainname, msgid, LC_MESSAGES)
113
114# define ngettext(msgid1, msgid2, n) dngettext (NULL, msgid1, msgid2, n)
115
116# define dngettext(domainname, msgid1, msgid2, n) \
117 dcngettext (domainname, msgid1, msgid2, n, LC_MESSAGES)
118
119#endif /* Optimizing. */
120
121__END_DECLS
122
123#endif /* libintl.h */
libc/glibc-include/limits.h created+192
...@@ -0,0 +1,192 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/*
19 * ISO C99 Standard: 7.10/5.2.4.2.1 Sizes of integer types <limits.h>
20 */
21
22#ifndef _LIBC_LIMITS_H_
23#define _LIBC_LIMITS_H_ 1
24
25#define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION
26#include <bits/libc-header-start.h>
27
28
29/* Maximum length of any multibyte character in any locale.
30 We define this value here since the gcc header does not define
31 the correct value. */
32#define MB_LEN_MAX 16
33
34
35/* If we are not using GNU CC we have to define all the symbols ourself.
36 Otherwise use gcc's definitions (see below). */
37#if !defined __GNUC__ || __GNUC__ < 2
38
39/* We only protect from multiple inclusion here, because all the other
40 #include's protect themselves, and in GCC 2 we may #include_next through
41 multiple copies of this file before we get to GCC's. */
42# ifndef _LIMITS_H
43# define _LIMITS_H 1
44
45#include <bits/wordsize.h>
46
47/* We don't have #include_next.
48 Define ANSI <limits.h> for standard 32-bit words. */
49
50/* These assume 8-bit `char's, 16-bit `short int's,
51 and 32-bit `int's and `long int's. */
52
53/* Number of bits in a `char'. */
54# define CHAR_BIT 8
55
56/* Minimum and maximum values a `signed char' can hold. */
57# define SCHAR_MIN (-128)
58# define SCHAR_MAX 127
59
60/* Maximum value an `unsigned char' can hold. (Minimum is 0.) */
61# define UCHAR_MAX 255
62
63/* Minimum and maximum values a `char' can hold. */
64# ifdef __CHAR_UNSIGNED__
65# define CHAR_MIN 0
66# define CHAR_MAX UCHAR_MAX
67# else
68# define CHAR_MIN SCHAR_MIN
69# define CHAR_MAX SCHAR_MAX
70# endif
71
72/* Minimum and maximum values a `signed short int' can hold. */
73# define SHRT_MIN (-32768)
74# define SHRT_MAX 32767
75
76/* Maximum value an `unsigned short int' can hold. (Minimum is 0.) */
77# define USHRT_MAX 65535
78
79/* Minimum and maximum values a `signed int' can hold. */
80# define INT_MIN (-INT_MAX - 1)
81# define INT_MAX 2147483647
82
83/* Maximum value an `unsigned int' can hold. (Minimum is 0.) */
84# define UINT_MAX 4294967295U
85
86/* Minimum and maximum values a `signed long int' can hold. */
87# if __WORDSIZE == 64
88# define LONG_MAX 9223372036854775807L
89# else
90# define LONG_MAX 2147483647L
91# endif
92# define LONG_MIN (-LONG_MAX - 1L)
93
94/* Maximum value an `unsigned long int' can hold. (Minimum is 0.) */
95# if __WORDSIZE == 64
96# define ULONG_MAX 18446744073709551615UL
97# else
98# define ULONG_MAX 4294967295UL
99# endif
100
101# ifdef __USE_ISOC99
102
103/* Minimum and maximum values a `signed long long int' can hold. */
104# define LLONG_MAX 9223372036854775807LL
105# define LLONG_MIN (-LLONG_MAX - 1LL)
106
107/* Maximum value an `unsigned long long int' can hold. (Minimum is 0.) */
108# define ULLONG_MAX 18446744073709551615ULL
109
110# endif /* ISO C99 */
111
112# endif /* limits.h */
113#endif /* GCC 2. */
114
115#endif /* !_LIBC_LIMITS_H_ */
116
117 /* Get the compiler's limits.h, which defines almost all the ISO constants.
118
119 We put this #include_next outside the double inclusion check because
120 it should be possible to include this file more than once and still get
121 the definitions from gcc's header. */
122#if defined __GNUC__ && !defined _GCC_LIMITS_H_
123/* `_GCC_LIMITS_H_' is what GCC's file defines. */
124# include_next <limits.h>
125#endif
126
127/* The <limits.h> files in some gcc versions don't define LLONG_MIN,
128 LLONG_MAX, and ULLONG_MAX. Instead only the values gcc defined for
129 ages are available. */
130#if defined __USE_ISOC99 && defined __GNUC__
131# ifndef LLONG_MIN
132# define LLONG_MIN (-LLONG_MAX-1)
133# endif
134# ifndef LLONG_MAX
135# define LLONG_MAX __LONG_LONG_MAX__
136# endif
137# ifndef ULLONG_MAX
138# define ULLONG_MAX (LLONG_MAX * 2ULL + 1)
139# endif
140#endif
141
142/* The integer width macros are not defined by GCC's <limits.h> before
143 GCC 7, or if _GNU_SOURCE rather than
144 __STDC_WANT_IEC_60559_BFP_EXT__ is used to enable this feature. */
145#if __GLIBC_USE (IEC_60559_BFP_EXT)
146# ifndef CHAR_WIDTH
147# define CHAR_WIDTH 8
148# endif
149# ifndef SCHAR_WIDTH
150# define SCHAR_WIDTH 8
151# endif
152# ifndef UCHAR_WIDTH
153# define UCHAR_WIDTH 8
154# endif
155# ifndef SHRT_WIDTH
156# define SHRT_WIDTH 16
157# endif
158# ifndef USHRT_WIDTH
159# define USHRT_WIDTH 16
160# endif
161# ifndef INT_WIDTH
162# define INT_WIDTH 32
163# endif
164# ifndef UINT_WIDTH
165# define UINT_WIDTH 32
166# endif
167# ifndef LONG_WIDTH
168# define LONG_WIDTH __WORDSIZE
169# endif
170# ifndef ULONG_WIDTH
171# define ULONG_WIDTH __WORDSIZE
172# endif
173# ifndef LLONG_WIDTH
174# define LLONG_WIDTH 64
175# endif
176# ifndef ULLONG_WIDTH
177# define ULLONG_WIDTH 64
178# endif
179#endif /* Use IEC_60559_BFP_EXT. */
180
181#ifdef __USE_POSIX
182/* POSIX adds things to <limits.h>. */
183# include <bits/posix1_lim.h>
184#endif
185
186#ifdef __USE_POSIX2
187# include <bits/posix2_lim.h>
188#endif
189
190#ifdef __USE_XOPEN
191# include <bits/xopen_lim.h>
192#endif
libc/glibc-include/link.h created+194
...@@ -0,0 +1,194 @@
1/* Data structure for communication from the run-time dynamic linker for
2 loaded ELF shared objects.
3 Copyright (C) 1995-2019 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
19
20#ifndef _LINK_H
21#define _LINK_H 1
22
23#include <features.h>
24#include <elf.h>
25#include <dlfcn.h>
26#include <sys/types.h>
27
28/* We use this macro to refer to ELF types independent of the native wordsize.
29 `ElfW(TYPE)' is used in place of `Elf32_TYPE' or `Elf64_TYPE'. */
30#define ElfW(type) _ElfW (Elf, __ELF_NATIVE_CLASS, type)
31#define _ElfW(e,w,t) _ElfW_1 (e, w, _##t)
32#define _ElfW_1(e,w,t) e##w##t
33
34#include <bits/elfclass.h> /* Defines __ELF_NATIVE_CLASS. */
35#include <bits/link.h>
36
37/* Rendezvous structure used by the run-time dynamic linker to communicate
38 details of shared object loading to the debugger. If the executable's
39 dynamic section has a DT_DEBUG element, the run-time linker sets that
40 element's value to the address where this structure can be found. */
41
42struct r_debug
43 {
44 int r_version; /* Version number for this protocol. */
45
46 struct link_map *r_map; /* Head of the chain of loaded objects. */
47
48 /* This is the address of a function internal to the run-time linker,
49 that will always be called when the linker begins to map in a
50 library or unmap it, and again when the mapping change is complete.
51 The debugger can set a breakpoint at this address if it wants to
52 notice shared object mapping changes. */
53 ElfW(Addr) r_brk;
54 enum
55 {
56 /* This state value describes the mapping change taking place when
57 the `r_brk' address is called. */
58 RT_CONSISTENT, /* Mapping change is complete. */
59 RT_ADD, /* Beginning to add a new object. */
60 RT_DELETE /* Beginning to remove an object mapping. */
61 } r_state;
62
63 ElfW(Addr) r_ldbase; /* Base address the linker is loaded at. */
64 };
65
66/* This is the instance of that structure used by the dynamic linker. */
67extern struct r_debug _r_debug;
68
69/* This symbol refers to the "dynamic structure" in the `.dynamic' section
70 of whatever module refers to `_DYNAMIC'. So, to find its own
71 `struct r_debug', a program could do:
72 for (dyn = _DYNAMIC; dyn->d_tag != DT_NULL; ++dyn)
73 if (dyn->d_tag == DT_DEBUG)
74 r_debug = (struct r_debug *) dyn->d_un.d_ptr;
75 */
76extern ElfW(Dyn) _DYNAMIC[];
77
78/* Structure describing a loaded shared object. The `l_next' and `l_prev'
79 members form a chain of all the shared objects loaded at startup.
80
81 These data structures exist in space used by the run-time dynamic linker;
82 modifying them may have disastrous results. */
83
84struct link_map
85 {
86 /* These first few members are part of the protocol with the debugger.
87 This is the same format used in SVR4. */
88
89 ElfW(Addr) l_addr; /* Difference between the address in the ELF
90 file and the addresses in memory. */
91 char *l_name; /* Absolute file name object was found in. */
92 ElfW(Dyn) *l_ld; /* Dynamic section of the shared object. */
93 struct link_map *l_next, *l_prev; /* Chain of loaded objects. */
94 };
95
96#ifdef __USE_GNU
97
98/* Version numbers for la_version handshake interface. */
99#define LAV_CURRENT 1
100
101/* Activity types signaled through la_activity. */
102enum
103 {
104 LA_ACT_CONSISTENT, /* Link map consistent again. */
105 LA_ACT_ADD, /* New object will be added. */
106 LA_ACT_DELETE /* Objects will be removed. */
107 };
108
109/* Values representing origin of name for dynamic loading. */
110enum
111 {
112 LA_SER_ORIG = 0x01, /* Original name. */
113 LA_SER_LIBPATH = 0x02, /* Directory from LD_LIBRARY_PATH. */
114 LA_SER_RUNPATH = 0x04, /* Directory from RPATH/RUNPATH. */
115 LA_SER_CONFIG = 0x08, /* Found through ldconfig. */
116 LA_SER_DEFAULT = 0x40, /* Default directory. */
117 LA_SER_SECURE = 0x80 /* Unused. */
118 };
119
120/* Values for la_objopen return value. */
121enum
122 {
123 LA_FLG_BINDTO = 0x01, /* Audit symbols bound to this object. */
124 LA_FLG_BINDFROM = 0x02 /* Audit symbols bound from this object. */
125 };
126
127/* Values for la_symbind flags parameter. */
128enum
129 {
130 LA_SYMB_NOPLTENTER = 0x01, /* la_pltenter will not be called. */
131 LA_SYMB_NOPLTEXIT = 0x02, /* la_pltexit will not be called. */
132 LA_SYMB_STRUCTCALL = 0x04, /* Return value is a structure. */
133 LA_SYMB_DLSYM = 0x08, /* Binding due to dlsym call. */
134 LA_SYMB_ALTVALUE = 0x10 /* Value has been changed by a previous
135 la_symbind call. */
136 };
137
138struct dl_phdr_info
139 {
140 ElfW(Addr) dlpi_addr;
141 const char *dlpi_name;
142 const ElfW(Phdr) *dlpi_phdr;
143 ElfW(Half) dlpi_phnum;
144
145 /* Note: Following members were introduced after the first
146 version of this structure was available. Check the SIZE
147 argument passed to the dl_iterate_phdr callback to determine
148 whether or not each later member is available. */
149
150 /* Incremented when a new object may have been added. */
151 __extension__ unsigned long long int dlpi_adds;
152 /* Incremented when an object may have been removed. */
153 __extension__ unsigned long long int dlpi_subs;
154
155 /* If there is a PT_TLS segment, its module ID as used in
156 TLS relocations, else zero. */
157 size_t dlpi_tls_modid;
158
159 /* The address of the calling thread's instance of this module's
160 PT_TLS segment, if it has one and it has been allocated
161 in the calling thread, otherwise a null pointer. */
162 void *dlpi_tls_data;
163 };
164
165__BEGIN_DECLS
166
167extern int dl_iterate_phdr (int (*__callback) (struct dl_phdr_info *,
168 size_t, void *),
169 void *__data);
170
171
172/* Prototypes for the ld.so auditing interfaces. These are not
173 defined anywhere in ld.so but instead have to be provided by the
174 auditing DSO. */
175extern unsigned int la_version (unsigned int __version);
176extern void la_activity (uintptr_t *__cookie, unsigned int __flag);
177extern char *la_objsearch (const char *__name, uintptr_t *__cookie,
178 unsigned int __flag);
179extern unsigned int la_objopen (struct link_map *__map, Lmid_t __lmid,
180 uintptr_t *__cookie);
181extern void la_preinit (uintptr_t *__cookie);
182extern uintptr_t la_symbind32 (Elf32_Sym *__sym, unsigned int __ndx,
183 uintptr_t *__refcook, uintptr_t *__defcook,
184 unsigned int *__flags, const char *__symname);
185extern uintptr_t la_symbind64 (Elf64_Sym *__sym, unsigned int __ndx,
186 uintptr_t *__refcook, uintptr_t *__defcook,
187 unsigned int *__flags, const char *__symname);
188extern unsigned int la_objclose (uintptr_t *__cookie);
189
190__END_DECLS
191
192#endif
193
194#endif /* link.h */
libc/glibc-include/locale.h created+197
...@@ -0,0 +1,197 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/*
19 * ISO C99 Standard: 7.11 Localization <locale.h>
20 */
21
22#ifndef _LOCALE_H
23#define _LOCALE_H 1
24
25#include <features.h>
26
27#define __need_NULL
28#include <stddef.h>
29#include <bits/locale.h>
30
31__BEGIN_DECLS
32
33/* These are the possibilities for the first argument to setlocale.
34 The code assumes that the lowest LC_* symbol has the value zero. */
35#define LC_CTYPE __LC_CTYPE
36#define LC_NUMERIC __LC_NUMERIC
37#define LC_TIME __LC_TIME
38#define LC_COLLATE __LC_COLLATE
39#define LC_MONETARY __LC_MONETARY
40#define LC_MESSAGES __LC_MESSAGES
41#define LC_ALL __LC_ALL
42#define LC_PAPER __LC_PAPER
43#define LC_NAME __LC_NAME
44#define LC_ADDRESS __LC_ADDRESS
45#define LC_TELEPHONE __LC_TELEPHONE
46#define LC_MEASUREMENT __LC_MEASUREMENT
47#define LC_IDENTIFICATION __LC_IDENTIFICATION
48
49
50/* Structure giving information about numeric and monetary notation. */
51struct lconv
52{
53 /* Numeric (non-monetary) information. */
54
55 char *decimal_point; /* Decimal point character. */
56 char *thousands_sep; /* Thousands separator. */
57 /* Each element is the number of digits in each group;
58 elements with higher indices are farther left.
59 An element with value CHAR_MAX means that no further grouping is done.
60 An element with value 0 means that the previous element is used
61 for all groups farther left. */
62 char *grouping;
63
64 /* Monetary information. */
65
66 /* First three chars are a currency symbol from ISO 4217.
67 Fourth char is the separator. Fifth char is '\0'. */
68 char *int_curr_symbol;
69 char *currency_symbol; /* Local currency symbol. */
70 char *mon_decimal_point; /* Decimal point character. */
71 char *mon_thousands_sep; /* Thousands separator. */
72 char *mon_grouping; /* Like `grouping' element (above). */
73 char *positive_sign; /* Sign for positive values. */
74 char *negative_sign; /* Sign for negative values. */
75 char int_frac_digits; /* Int'l fractional digits. */
76 char frac_digits; /* Local fractional digits. */
77 /* 1 if currency_symbol precedes a positive value, 0 if succeeds. */
78 char p_cs_precedes;
79 /* 1 iff a space separates currency_symbol from a positive value. */
80 char p_sep_by_space;
81 /* 1 if currency_symbol precedes a negative value, 0 if succeeds. */
82 char n_cs_precedes;
83 /* 1 iff a space separates currency_symbol from a negative value. */
84 char n_sep_by_space;
85 /* Positive and negative sign positions:
86 0 Parentheses surround the quantity and currency_symbol.
87 1 The sign string precedes the quantity and currency_symbol.
88 2 The sign string follows the quantity and currency_symbol.
89 3 The sign string immediately precedes the currency_symbol.
90 4 The sign string immediately follows the currency_symbol. */
91 char p_sign_posn;
92 char n_sign_posn;
93#ifdef __USE_ISOC99
94 /* 1 if int_curr_symbol precedes a positive value, 0 if succeeds. */
95 char int_p_cs_precedes;
96 /* 1 iff a space separates int_curr_symbol from a positive value. */
97 char int_p_sep_by_space;
98 /* 1 if int_curr_symbol precedes a negative value, 0 if succeeds. */
99 char int_n_cs_precedes;
100 /* 1 iff a space separates int_curr_symbol from a negative value. */
101 char int_n_sep_by_space;
102 /* Positive and negative sign positions:
103 0 Parentheses surround the quantity and int_curr_symbol.
104 1 The sign string precedes the quantity and int_curr_symbol.
105 2 The sign string follows the quantity and int_curr_symbol.
106 3 The sign string immediately precedes the int_curr_symbol.
107 4 The sign string immediately follows the int_curr_symbol. */
108 char int_p_sign_posn;
109 char int_n_sign_posn;
110#else
111 char __int_p_cs_precedes;
112 char __int_p_sep_by_space;
113 char __int_n_cs_precedes;
114 char __int_n_sep_by_space;
115 char __int_p_sign_posn;
116 char __int_n_sign_posn;
117#endif
118};
119
120
121/* Set and/or return the current locale. */
122extern char *setlocale (int __category, const char *__locale) __THROW;
123
124/* Return the numeric/monetary information for the current locale. */
125extern struct lconv *localeconv (void) __THROW;
126
127
128#ifdef __USE_XOPEN2K8
129/* POSIX.1-2008 extends the locale interface with functions for
130 explicit creation and manipulation of 'locale_t' objects
131 representing locale contexts, and a set of parallel
132 locale-sensitive text processing functions that take a locale_t
133 argument. This enables applications to work with data from
134 multiple locales simultaneously and thread-safely. */
135# include <bits/types/locale_t.h>
136
137/* Return a reference to a data structure representing a set of locale
138 datasets. Unlike for the CATEGORY parameter for `setlocale' the
139 CATEGORY_MASK parameter here uses a single bit for each category,
140 made by OR'ing together LC_*_MASK bits above. */
141extern locale_t newlocale (int __category_mask, const char *__locale,
142 locale_t __base) __THROW;
143
144/* These are the bits that can be set in the CATEGORY_MASK argument to
145 `newlocale'. In the GNU implementation, LC_FOO_MASK has the value
146 of (1 << LC_FOO), but this is not a part of the interface that
147 callers can assume will be true. */
148# define LC_CTYPE_MASK (1 << __LC_CTYPE)
149# define LC_NUMERIC_MASK (1 << __LC_NUMERIC)
150# define LC_TIME_MASK (1 << __LC_TIME)
151# define LC_COLLATE_MASK (1 << __LC_COLLATE)
152# define LC_MONETARY_MASK (1 << __LC_MONETARY)
153# define LC_MESSAGES_MASK (1 << __LC_MESSAGES)
154# define LC_PAPER_MASK (1 << __LC_PAPER)
155# define LC_NAME_MASK (1 << __LC_NAME)
156# define LC_ADDRESS_MASK (1 << __LC_ADDRESS)
157# define LC_TELEPHONE_MASK (1 << __LC_TELEPHONE)
158# define LC_MEASUREMENT_MASK (1 << __LC_MEASUREMENT)
159# define LC_IDENTIFICATION_MASK (1 << __LC_IDENTIFICATION)
160# define LC_ALL_MASK (LC_CTYPE_MASK \
161 | LC_NUMERIC_MASK \
162 | LC_TIME_MASK \
163 | LC_COLLATE_MASK \
164 | LC_MONETARY_MASK \
165 | LC_MESSAGES_MASK \
166 | LC_PAPER_MASK \
167 | LC_NAME_MASK \
168 | LC_ADDRESS_MASK \
169 | LC_TELEPHONE_MASK \
170 | LC_MEASUREMENT_MASK \
171 | LC_IDENTIFICATION_MASK \
172 )
173
174/* Return a duplicate of the set of locale in DATASET. All usage
175 counters are increased if necessary. */
176extern locale_t duplocale (locale_t __dataset) __THROW;
177
178/* Free the data associated with a locale dataset previously returned
179 by a call to `setlocale_r'. */
180extern void freelocale (locale_t __dataset) __THROW;
181
182/* Switch the current thread's locale to DATASET.
183 If DATASET is null, instead just return the current setting.
184 The special value LC_GLOBAL_LOCALE is the initial setting
185 for all threads and can also be installed any time, meaning
186 the thread uses the global settings controlled by `setlocale'. */
187extern locale_t uselocale (locale_t __dataset) __THROW;
188
189/* This value can be passed to `uselocale' and may be returned by it.
190 Passing this value to any other function has undefined behavior. */
191# define LC_GLOBAL_LOCALE ((locale_t) -1L)
192
193#endif
194
195__END_DECLS
196
197#endif /* locale.h */
libc/glibc-include/malloc.h created+164
...@@ -0,0 +1,164 @@
1/* Prototypes and definition for malloc implementation.
2 Copyright (C) 1996-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _MALLOC_H
20#define _MALLOC_H 1
21
22#include <features.h>
23#include <stddef.h>
24#include <stdio.h>
25
26#ifdef _LIBC
27# define __MALLOC_HOOK_VOLATILE
28# define __MALLOC_DEPRECATED
29#else
30# define __MALLOC_HOOK_VOLATILE volatile
31# define __MALLOC_DEPRECATED __attribute_deprecated__
32#endif
33
34
35__BEGIN_DECLS
36
37/* Allocate SIZE bytes of memory. */
38extern void *malloc (size_t __size) __THROW __attribute_malloc__ __wur;
39
40/* Allocate NMEMB elements of SIZE bytes each, all initialized to 0. */
41extern void *calloc (size_t __nmemb, size_t __size)
42__THROW __attribute_malloc__ __wur;
43
44/* Re-allocate the previously allocated block in __ptr, making the new
45 block SIZE bytes long. */
46/* __attribute_malloc__ is not used, because if realloc returns
47 the same pointer that was passed to it, aliasing needs to be allowed
48 between objects pointed by the old and new pointers. */
49extern void *realloc (void *__ptr, size_t __size)
50__THROW __attribute_warn_unused_result__;
51
52/* Re-allocate the previously allocated block in PTR, making the new
53 block large enough for NMEMB elements of SIZE bytes each. */
54/* __attribute_malloc__ is not used, because if reallocarray returns
55 the same pointer that was passed to it, aliasing needs to be allowed
56 between objects pointed by the old and new pointers. */
57extern void *reallocarray (void *__ptr, size_t __nmemb, size_t __size)
58__THROW __attribute_warn_unused_result__;
59
60/* Free a block allocated by `malloc', `realloc' or `calloc'. */
61extern void free (void *__ptr) __THROW;
62
63/* Allocate SIZE bytes allocated to ALIGNMENT bytes. */
64extern void *memalign (size_t __alignment, size_t __size)
65__THROW __attribute_malloc__ __wur;
66
67/* Allocate SIZE bytes on a page boundary. */
68extern void *valloc (size_t __size) __THROW __attribute_malloc__ __wur;
69
70/* Equivalent to valloc(minimum-page-that-holds(n)), that is, round up
71 __size to nearest pagesize. */
72extern void *pvalloc (size_t __size) __THROW __attribute_malloc__ __wur;
73
74/* Underlying allocation function; successive calls should return
75 contiguous pieces of memory. */
76extern void *(*__morecore) (ptrdiff_t __size);
77
78/* Default value of `__morecore'. */
79extern void *__default_morecore (ptrdiff_t __size)
80__THROW __attribute_malloc__;
81
82/* SVID2/XPG mallinfo structure */
83
84struct mallinfo
85{
86 int arena; /* non-mmapped space allocated from system */
87 int ordblks; /* number of free chunks */
88 int smblks; /* number of fastbin blocks */
89 int hblks; /* number of mmapped regions */
90 int hblkhd; /* space in mmapped regions */
91 int usmblks; /* always 0, preserved for backwards compatibility */
92 int fsmblks; /* space available in freed fastbin blocks */
93 int uordblks; /* total allocated space */
94 int fordblks; /* total free space */
95 int keepcost; /* top-most, releasable (via malloc_trim) space */
96};
97
98/* Returns a copy of the updated current mallinfo. */
99extern struct mallinfo mallinfo (void) __THROW;
100
101/* SVID2/XPG mallopt options */
102#ifndef M_MXFAST
103# define M_MXFAST 1 /* maximum request size for "fastbins" */
104#endif
105#ifndef M_NLBLKS
106# define M_NLBLKS 2 /* UNUSED in this malloc */
107#endif
108#ifndef M_GRAIN
109# define M_GRAIN 3 /* UNUSED in this malloc */
110#endif
111#ifndef M_KEEP
112# define M_KEEP 4 /* UNUSED in this malloc */
113#endif
114
115/* mallopt options that actually do something */
116#define M_TRIM_THRESHOLD -1
117#define M_TOP_PAD -2
118#define M_MMAP_THRESHOLD -3
119#define M_MMAP_MAX -4
120#define M_CHECK_ACTION -5
121#define M_PERTURB -6
122#define M_ARENA_TEST -7
123#define M_ARENA_MAX -8
124
125/* General SVID/XPG interface to tunable parameters. */
126extern int mallopt (int __param, int __val) __THROW;
127
128/* Release all but __pad bytes of freed top-most memory back to the
129 system. Return 1 if successful, else 0. */
130extern int malloc_trim (size_t __pad) __THROW;
131
132/* Report the number of usable allocated bytes associated with allocated
133 chunk __ptr. */
134extern size_t malloc_usable_size (void *__ptr) __THROW;
135
136/* Prints brief summary statistics on stderr. */
137extern void malloc_stats (void) __THROW;
138
139/* Output information about state of allocator to stream FP. */
140extern int malloc_info (int __options, FILE *__fp) __THROW;
141
142/* Hooks for debugging and user-defined versions. */
143extern void (*__MALLOC_HOOK_VOLATILE __free_hook) (void *__ptr,
144 const void *)
145__MALLOC_DEPRECATED;
146extern void *(*__MALLOC_HOOK_VOLATILE __malloc_hook)(size_t __size,
147 const void *)
148__MALLOC_DEPRECATED;
149extern void *(*__MALLOC_HOOK_VOLATILE __realloc_hook)(void *__ptr,
150 size_t __size,
151 const void *)
152__MALLOC_DEPRECATED;
153extern void *(*__MALLOC_HOOK_VOLATILE __memalign_hook)(size_t __alignment,
154 size_t __size,
155 const void *)
156__MALLOC_DEPRECATED;
157extern void (*__MALLOC_HOOK_VOLATILE __after_morecore_hook) (void);
158
159/* Activate a standard set of debugging hooks. */
160extern void __malloc_check_init (void) __THROW __MALLOC_DEPRECATED;
161
162
163__END_DECLS
164#endif /* malloc.h */
libc/glibc-include/math.h created+1556
...@@ -0,0 +1,1556 @@
1/* Declarations for math functions.
2 Copyright (C) 1991-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19/*
20 * ISO C99 Standard: 7.12 Mathematics <math.h>
21 */
22
23#ifndef _MATH_H
24#define _MATH_H 1
25
26#define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION
27#include <bits/libc-header-start.h>
28
29#if defined log && defined __GNUC__
30# warning A macro called log was already defined when <math.h> was included.
31# warning This will cause compilation problems.
32#endif
33
34__BEGIN_DECLS
35
36/* Get definitions of __intmax_t and __uintmax_t. */
37#include <bits/types.h>
38
39/* Get machine-dependent vector math functions declarations. */
40#include <bits/math-vector.h>
41
42/* Gather machine dependent type support. */
43#include <bits/floatn.h>
44
45/* Value returned on overflow. With IEEE 754 floating point, this is
46 +Infinity, otherwise the largest representable positive value. */
47#if __GNUC_PREREQ (3, 3)
48# define HUGE_VAL (__builtin_huge_val ())
49#else
50/* This may provoke compiler warnings, and may not be rounded to
51 +Infinity in all IEEE 754 rounding modes, but is the best that can
52 be done in ISO C while remaining a constant expression. 10,000 is
53 greater than the maximum (decimal) exponent for all supported
54 floating-point formats and widths. */
55# define HUGE_VAL 1e10000
56#endif
57#ifdef __USE_ISOC99
58# if __GNUC_PREREQ (3, 3)
59# define HUGE_VALF (__builtin_huge_valf ())
60# define HUGE_VALL (__builtin_huge_vall ())
61# else
62# define HUGE_VALF 1e10000f
63# define HUGE_VALL 1e10000L
64# endif
65#endif
66#if __HAVE_FLOAT16 && __GLIBC_USE (IEC_60559_TYPES_EXT)
67# define HUGE_VAL_F16 (__builtin_huge_valf16 ())
68#endif
69#if __HAVE_FLOAT32 && __GLIBC_USE (IEC_60559_TYPES_EXT)
70# define HUGE_VAL_F32 (__builtin_huge_valf32 ())
71#endif
72#if __HAVE_FLOAT64 && __GLIBC_USE (IEC_60559_TYPES_EXT)
73# define HUGE_VAL_F64 (__builtin_huge_valf64 ())
74#endif
75#if __HAVE_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT)
76# define HUGE_VAL_F128 (__builtin_huge_valf128 ())
77#endif
78#if __HAVE_FLOAT32X && __GLIBC_USE (IEC_60559_TYPES_EXT)
79# define HUGE_VAL_F32X (__builtin_huge_valf32x ())
80#endif
81#if __HAVE_FLOAT64X && __GLIBC_USE (IEC_60559_TYPES_EXT)
82# define HUGE_VAL_F64X (__builtin_huge_valf64x ())
83#endif
84#if __HAVE_FLOAT128X && __GLIBC_USE (IEC_60559_TYPES_EXT)
85# define HUGE_VAL_F128X (__builtin_huge_valf128x ())
86#endif
87
88#ifdef __USE_ISOC99
89/* IEEE positive infinity. */
90# if __GNUC_PREREQ (3, 3)
91# define INFINITY (__builtin_inff ())
92# else
93# define INFINITY HUGE_VALF
94# endif
95
96/* IEEE Not A Number. */
97# if __GNUC_PREREQ (3, 3)
98# define NAN (__builtin_nanf (""))
99# else
100/* This will raise an "invalid" exception outside static initializers,
101 but is the best that can be done in ISO C while remaining a
102 constant expression. */
103# define NAN (0.0f / 0.0f)
104# endif
105#endif /* __USE_ISOC99 */
106
107#if __GLIBC_USE (IEC_60559_BFP_EXT)
108/* Signaling NaN macros, if supported. */
109# if __GNUC_PREREQ (3, 3)
110# define SNANF (__builtin_nansf (""))
111# define SNAN (__builtin_nans (""))
112# define SNANL (__builtin_nansl (""))
113# endif
114#endif
115#if __HAVE_FLOAT16 && __GLIBC_USE (IEC_60559_TYPES_EXT)
116# define SNANF16 (__builtin_nansf16 (""))
117#endif
118#if __HAVE_FLOAT32 && __GLIBC_USE (IEC_60559_TYPES_EXT)
119# define SNANF32 (__builtin_nansf32 (""))
120#endif
121#if __HAVE_FLOAT64 && __GLIBC_USE (IEC_60559_TYPES_EXT)
122# define SNANF64 (__builtin_nansf64 (""))
123#endif
124#if __HAVE_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT)
125# define SNANF128 (__builtin_nansf128 (""))
126#endif
127#if __HAVE_FLOAT32X && __GLIBC_USE (IEC_60559_TYPES_EXT)
128# define SNANF32X (__builtin_nansf32x (""))
129#endif
130#if __HAVE_FLOAT64X && __GLIBC_USE (IEC_60559_TYPES_EXT)
131# define SNANF64X (__builtin_nansf64x (""))
132#endif
133#if __HAVE_FLOAT128X && __GLIBC_USE (IEC_60559_TYPES_EXT)
134# define SNANF128X (__builtin_nansf128x (""))
135#endif
136
137/* Get __GLIBC_FLT_EVAL_METHOD. */
138#include <bits/flt-eval-method.h>
139
140#ifdef __USE_ISOC99
141/* Define the following typedefs.
142
143 float_t floating-point type at least as wide as `float' used
144 to evaluate `float' expressions
145 double_t floating-point type at least as wide as `double' used
146 to evaluate `double' expressions
147*/
148# if __GLIBC_FLT_EVAL_METHOD == 0 || __GLIBC_FLT_EVAL_METHOD == 16
149typedef float float_t;
150typedef double double_t;
151# elif __GLIBC_FLT_EVAL_METHOD == 1
152typedef double float_t;
153typedef double double_t;
154# elif __GLIBC_FLT_EVAL_METHOD == 2
155typedef long double float_t;
156typedef long double double_t;
157# elif __GLIBC_FLT_EVAL_METHOD == 32
158typedef _Float32 float_t;
159typedef double double_t;
160# elif __GLIBC_FLT_EVAL_METHOD == 33
161typedef _Float32x float_t;
162typedef _Float32x double_t;
163# elif __GLIBC_FLT_EVAL_METHOD == 64
164typedef _Float64 float_t;
165typedef _Float64 double_t;
166# elif __GLIBC_FLT_EVAL_METHOD == 65
167typedef _Float64x float_t;
168typedef _Float64x double_t;
169# elif __GLIBC_FLT_EVAL_METHOD == 128
170typedef _Float128 float_t;
171typedef _Float128 double_t;
172# elif __GLIBC_FLT_EVAL_METHOD == 129
173typedef _Float128x float_t;
174typedef _Float128x double_t;
175# else
176# error "Unknown __GLIBC_FLT_EVAL_METHOD"
177# endif
178#endif
179
180/* Define macros for the return values of ilogb and llogb, based on
181 __FP_LOGB0_IS_MIN and __FP_LOGBNAN_IS_MIN.
182
183 FP_ILOGB0 Expands to a value returned by `ilogb (0.0)'.
184 FP_ILOGBNAN Expands to a value returned by `ilogb (NAN)'.
185 FP_LLOGB0 Expands to a value returned by `llogb (0.0)'.
186 FP_LLOGBNAN Expands to a value returned by `llogb (NAN)'.
187
188*/
189
190#include <bits/fp-logb.h>
191#ifdef __USE_ISOC99
192# if __FP_LOGB0_IS_MIN
193# define FP_ILOGB0 (-2147483647 - 1)
194# else
195# define FP_ILOGB0 (-2147483647)
196# endif
197# if __FP_LOGBNAN_IS_MIN
198# define FP_ILOGBNAN (-2147483647 - 1)
199# else
200# define FP_ILOGBNAN 2147483647
201# endif
202#endif
203#if __GLIBC_USE (IEC_60559_BFP_EXT)
204# if __WORDSIZE == 32
205# define __FP_LONG_MAX 0x7fffffffL
206# else
207# define __FP_LONG_MAX 0x7fffffffffffffffL
208# endif
209# if __FP_LOGB0_IS_MIN
210# define FP_LLOGB0 (-__FP_LONG_MAX - 1)
211# else
212# define FP_LLOGB0 (-__FP_LONG_MAX)
213# endif
214# if __FP_LOGBNAN_IS_MIN
215# define FP_LLOGBNAN (-__FP_LONG_MAX - 1)
216# else
217# define FP_LLOGBNAN __FP_LONG_MAX
218# endif
219#endif
220
221/* Get the architecture specific values describing the floating-point
222 evaluation. The following symbols will get defined:
223
224 FP_FAST_FMA
225 FP_FAST_FMAF
226 FP_FAST_FMAL
227 If defined it indicates that the `fma' function
228 generally executes about as fast as a multiply and an add.
229 This macro is defined only iff the `fma' function is
230 implemented directly with a hardware multiply-add instructions.
231*/
232
233#include <bits/fp-fast.h>
234
235#if __GLIBC_USE (IEC_60559_BFP_EXT)
236/* Rounding direction macros for fromfp functions. */
237enum
238 {
239 FP_INT_UPWARD =
240# define FP_INT_UPWARD 0
241 FP_INT_UPWARD,
242 FP_INT_DOWNWARD =
243# define FP_INT_DOWNWARD 1
244 FP_INT_DOWNWARD,
245 FP_INT_TOWARDZERO =
246# define FP_INT_TOWARDZERO 2
247 FP_INT_TOWARDZERO,
248 FP_INT_TONEARESTFROMZERO =
249# define FP_INT_TONEARESTFROMZERO 3
250 FP_INT_TONEARESTFROMZERO,
251 FP_INT_TONEAREST =
252# define FP_INT_TONEAREST 4
253 FP_INT_TONEAREST,
254 };
255#endif
256
257/* The file <bits/mathcalls.h> contains the prototypes for all the
258 actual math functions. These macros are used for those prototypes,
259 so we can easily declare each function as both `name' and `__name',
260 and can declare the float versions `namef' and `__namef'. */
261
262#define __SIMD_DECL(function) __CONCAT (__DECL_SIMD_, function)
263
264#define __MATHCALL_VEC(function, suffix, args) \
265 __SIMD_DECL (__MATH_PRECNAME (function, suffix)) \
266 __MATHCALL (function, suffix, args)
267
268#define __MATHDECL_VEC(type, function,suffix, args) \
269 __SIMD_DECL (__MATH_PRECNAME (function, suffix)) \
270 __MATHDECL(type, function,suffix, args)
271
272#define __MATHCALL(function,suffix, args) \
273 __MATHDECL (_Mdouble_,function,suffix, args)
274#define __MATHDECL(type, function,suffix, args) \
275 __MATHDECL_1(type, function,suffix, args); \
276 __MATHDECL_1(type, __CONCAT(__,function),suffix, args)
277#define __MATHCALLX(function,suffix, args, attrib) \
278 __MATHDECLX (_Mdouble_,function,suffix, args, attrib)
279#define __MATHDECLX(type, function,suffix, args, attrib) \
280 __MATHDECL_1(type, function,suffix, args) __attribute__ (attrib); \
281 __MATHDECL_1(type, __CONCAT(__,function),suffix, args) __attribute__ (attrib)
282#define __MATHDECL_1(type, function,suffix, args) \
283 extern type __MATH_PRECNAME(function,suffix) args __THROW
284
285#define _Mdouble_ double
286#define __MATH_PRECNAME(name,r) __CONCAT(name,r)
287#define __MATH_DECLARING_DOUBLE 1
288#define __MATH_DECLARING_FLOATN 0
289#include <bits/mathcalls-helper-functions.h>
290#include <bits/mathcalls.h>
291#undef _Mdouble_
292#undef __MATH_PRECNAME
293#undef __MATH_DECLARING_DOUBLE
294#undef __MATH_DECLARING_FLOATN
295
296#ifdef __USE_ISOC99
297
298
299/* Include the file of declarations again, this time using `float'
300 instead of `double' and appending f to each function name. */
301
302# define _Mdouble_ float
303# define __MATH_PRECNAME(name,r) name##f##r
304# define __MATH_DECLARING_DOUBLE 0
305# define __MATH_DECLARING_FLOATN 0
306# include <bits/mathcalls-helper-functions.h>
307# include <bits/mathcalls.h>
308# undef _Mdouble_
309# undef __MATH_PRECNAME
310# undef __MATH_DECLARING_DOUBLE
311# undef __MATH_DECLARING_FLOATN
312
313# if !(defined __NO_LONG_DOUBLE_MATH && defined _LIBC) \
314 || defined __LDBL_COMPAT \
315 || defined _LIBC_TEST
316# ifdef __LDBL_COMPAT
317
318# ifdef __USE_ISOC99
319extern float __nldbl_nexttowardf (float __x, long double __y)
320 __THROW __attribute__ ((__const__));
321# ifdef __REDIRECT_NTH
322extern float __REDIRECT_NTH (nexttowardf, (float __x, long double __y),
323 __nldbl_nexttowardf)
324 __attribute__ ((__const__));
325extern double __REDIRECT_NTH (nexttoward, (double __x, long double __y),
326 nextafter) __attribute__ ((__const__));
327extern long double __REDIRECT_NTH (nexttowardl,
328 (long double __x, long double __y),
329 nextafter) __attribute__ ((__const__));
330# endif
331# endif
332
333# undef __MATHDECL_1
334# define __MATHDECL_2(type, function,suffix, args, alias) \
335 extern type __REDIRECT_NTH(__MATH_PRECNAME(function,suffix), \
336 args, alias)
337# define __MATHDECL_1(type, function,suffix, args) \
338 __MATHDECL_2(type, function,suffix, args, __CONCAT(function,suffix))
339# endif
340
341/* Include the file of declarations again, this time using `long double'
342 instead of `double' and appending l to each function name. */
343
344# define _Mdouble_ long double
345# define __MATH_PRECNAME(name,r) name##l##r
346# define __MATH_DECLARING_DOUBLE 0
347# define __MATH_DECLARING_FLOATN 0
348# define __MATH_DECLARE_LDOUBLE 1
349# include <bits/mathcalls-helper-functions.h>
350# include <bits/mathcalls.h>
351# undef _Mdouble_
352# undef __MATH_PRECNAME
353# undef __MATH_DECLARING_DOUBLE
354# undef __MATH_DECLARING_FLOATN
355
356# endif /* !(__NO_LONG_DOUBLE_MATH && _LIBC) || __LDBL_COMPAT */
357
358#endif /* Use ISO C99. */
359
360/* Include the file of declarations for _FloatN and _FloatNx
361 types. */
362
363#if __HAVE_DISTINCT_FLOAT16 || (__HAVE_FLOAT16 && !defined _LIBC)
364# define _Mdouble_ _Float16
365# define __MATH_PRECNAME(name,r) name##f16##r
366# define __MATH_DECLARING_DOUBLE 0
367# define __MATH_DECLARING_FLOATN 1
368# if __HAVE_DISTINCT_FLOAT16
369# include <bits/mathcalls-helper-functions.h>
370# endif
371# if __GLIBC_USE (IEC_60559_TYPES_EXT)
372# include <bits/mathcalls.h>
373# endif
374# undef _Mdouble_
375# undef __MATH_PRECNAME
376# undef __MATH_DECLARING_DOUBLE
377# undef __MATH_DECLARING_FLOATN
378#endif /* __HAVE_DISTINCT_FLOAT16 || (__HAVE_FLOAT16 && !_LIBC). */
379
380#if __HAVE_DISTINCT_FLOAT32 || (__HAVE_FLOAT32 && !defined _LIBC)
381# define _Mdouble_ _Float32
382# define __MATH_PRECNAME(name,r) name##f32##r
383# define __MATH_DECLARING_DOUBLE 0
384# define __MATH_DECLARING_FLOATN 1
385# if __HAVE_DISTINCT_FLOAT32
386# include <bits/mathcalls-helper-functions.h>
387# endif
388# if __GLIBC_USE (IEC_60559_TYPES_EXT)
389# include <bits/mathcalls.h>
390# endif
391# undef _Mdouble_
392# undef __MATH_PRECNAME
393# undef __MATH_DECLARING_DOUBLE
394# undef __MATH_DECLARING_FLOATN
395#endif /* __HAVE_DISTINCT_FLOAT32 || (__HAVE_FLOAT32 && !_LIBC). */
396
397#if __HAVE_DISTINCT_FLOAT64 || (__HAVE_FLOAT64 && !defined _LIBC)
398# define _Mdouble_ _Float64
399# define __MATH_PRECNAME(name,r) name##f64##r
400# define __MATH_DECLARING_DOUBLE 0
401# define __MATH_DECLARING_FLOATN 1
402# if __HAVE_DISTINCT_FLOAT64
403# include <bits/mathcalls-helper-functions.h>
404# endif
405# if __GLIBC_USE (IEC_60559_TYPES_EXT)
406# include <bits/mathcalls.h>
407# endif
408# undef _Mdouble_
409# undef __MATH_PRECNAME
410# undef __MATH_DECLARING_DOUBLE
411# undef __MATH_DECLARING_FLOATN
412#endif /* __HAVE_DISTINCT_FLOAT64 || (__HAVE_FLOAT64 && !_LIBC). */
413
414#if __HAVE_DISTINCT_FLOAT128 || (__HAVE_FLOAT128 && !defined _LIBC)
415# define _Mdouble_ _Float128
416# define __MATH_PRECNAME(name,r) name##f128##r
417# define __MATH_DECLARING_DOUBLE 0
418# define __MATH_DECLARING_FLOATN 1
419# if __HAVE_DISTINCT_FLOAT128
420# include <bits/mathcalls-helper-functions.h>
421# endif
422# if __GLIBC_USE (IEC_60559_TYPES_EXT)
423# include <bits/mathcalls.h>
424# endif
425# undef _Mdouble_
426# undef __MATH_PRECNAME
427# undef __MATH_DECLARING_DOUBLE
428# undef __MATH_DECLARING_FLOATN
429#endif /* __HAVE_DISTINCT_FLOAT128 || (__HAVE_FLOAT128 && !_LIBC). */
430
431#if __HAVE_DISTINCT_FLOAT32X || (__HAVE_FLOAT32X && !defined _LIBC)
432# define _Mdouble_ _Float32x
433# define __MATH_PRECNAME(name,r) name##f32x##r
434# define __MATH_DECLARING_DOUBLE 0
435# define __MATH_DECLARING_FLOATN 1
436# if __HAVE_DISTINCT_FLOAT32X
437# include <bits/mathcalls-helper-functions.h>
438# endif
439# if __GLIBC_USE (IEC_60559_TYPES_EXT)
440# include <bits/mathcalls.h>
441# endif
442# undef _Mdouble_
443# undef __MATH_PRECNAME
444# undef __MATH_DECLARING_DOUBLE
445# undef __MATH_DECLARING_FLOATN
446#endif /* __HAVE_DISTINCT_FLOAT32X || (__HAVE_FLOAT32X && !_LIBC). */
447
448#if __HAVE_DISTINCT_FLOAT64X || (__HAVE_FLOAT64X && !defined _LIBC)
449# define _Mdouble_ _Float64x
450# define __MATH_PRECNAME(name,r) name##f64x##r
451# define __MATH_DECLARING_DOUBLE 0
452# define __MATH_DECLARING_FLOATN 1
453# if __HAVE_DISTINCT_FLOAT64X
454# include <bits/mathcalls-helper-functions.h>
455# endif
456# if __GLIBC_USE (IEC_60559_TYPES_EXT)
457# include <bits/mathcalls.h>
458# endif
459# undef _Mdouble_
460# undef __MATH_PRECNAME
461# undef __MATH_DECLARING_DOUBLE
462# undef __MATH_DECLARING_FLOATN
463#endif /* __HAVE_DISTINCT_FLOAT64X || (__HAVE_FLOAT64X && !_LIBC). */
464
465#if __HAVE_DISTINCT_FLOAT128X || (__HAVE_FLOAT128X && !defined _LIBC)
466# define _Mdouble_ _Float128x
467# define __MATH_PRECNAME(name,r) name##f128x##r
468# define __MATH_DECLARING_DOUBLE 0
469# define __MATH_DECLARING_FLOATN 1
470# if __HAVE_DISTINCT_FLOAT128X
471# include <bits/mathcalls-helper-functions.h>
472# endif
473# if __GLIBC_USE (IEC_60559_TYPES_EXT)
474# include <bits/mathcalls.h>
475# endif
476# undef _Mdouble_
477# undef __MATH_PRECNAME
478# undef __MATH_DECLARING_DOUBLE
479# undef __MATH_DECLARING_FLOATN
480#endif /* __HAVE_DISTINCT_FLOAT128X || (__HAVE_FLOAT128X && !_LIBC). */
481
482#undef __MATHDECL_1
483#undef __MATHDECL
484#undef __MATHCALL
485
486/* Declare functions returning a narrower type. */
487#define __MATHCALL_NARROW_ARGS_1 (_Marg_ __x)
488#define __MATHCALL_NARROW_ARGS_2 (_Marg_ __x, _Marg_ __y)
489#define __MATHCALL_NARROW_ARGS_3 (_Marg_ __x, _Marg_ __y, _Marg_ __z)
490#define __MATHCALL_NARROW_NORMAL(func, nargs) \
491 extern _Mret_ func __MATHCALL_NARROW_ARGS_ ## nargs __THROW
492#define __MATHCALL_NARROW_REDIR(func, redir, nargs) \
493 extern _Mret_ __REDIRECT_NTH (func, __MATHCALL_NARROW_ARGS_ ## nargs, \
494 redir)
495#define __MATHCALL_NARROW(func, redir, nargs) \
496 __MATHCALL_NARROW_NORMAL (func, nargs)
497
498#if __GLIBC_USE (IEC_60559_BFP_EXT)
499
500# define _Mret_ float
501# define _Marg_ double
502# define __MATHCALL_NAME(name) f ## name
503# include <bits/mathcalls-narrow.h>
504# undef _Mret_
505# undef _Marg_
506# undef __MATHCALL_NAME
507
508# define _Mret_ float
509# define _Marg_ long double
510# define __MATHCALL_NAME(name) f ## name ## l
511# ifdef __LDBL_COMPAT
512# define __MATHCALL_REDIR_NAME(name) f ## name
513# undef __MATHCALL_NARROW
514# define __MATHCALL_NARROW(func, redir, nargs) \
515 __MATHCALL_NARROW_REDIR (func, redir, nargs)
516# endif
517# include <bits/mathcalls-narrow.h>
518# undef _Mret_
519# undef _Marg_
520# undef __MATHCALL_NAME
521# ifdef __LDBL_COMPAT
522# undef __MATHCALL_REDIR_NAME
523# undef __MATHCALL_NARROW
524# define __MATHCALL_NARROW(func, redir, nargs) \
525 __MATHCALL_NARROW_NORMAL (func, nargs)
526# endif
527
528# define _Mret_ double
529# define _Marg_ long double
530# define __MATHCALL_NAME(name) d ## name ## l
531# ifdef __LDBL_COMPAT
532# define __MATHCALL_REDIR_NAME(name) __nldbl_d ## name ## l
533# undef __MATHCALL_NARROW
534# define __MATHCALL_NARROW(func, redir, nargs) \
535 __MATHCALL_NARROW_REDIR (func, redir, nargs)
536# endif
537# include <bits/mathcalls-narrow.h>
538# undef _Mret_
539# undef _Marg_
540# undef __MATHCALL_NAME
541# ifdef __LDBL_COMPAT
542# undef __MATHCALL_REDIR_NAME
543# undef __MATHCALL_NARROW
544# define __MATHCALL_NARROW(func, redir, nargs) \
545 __MATHCALL_NARROW_NORMAL (func, nargs)
546# endif
547
548#endif
549
550#if __GLIBC_USE (IEC_60559_TYPES_EXT)
551
552# if __HAVE_FLOAT16 && __HAVE_FLOAT32
553# define _Mret_ _Float16
554# define _Marg_ _Float32
555# define __MATHCALL_NAME(name) f16 ## name ## f32
556# include <bits/mathcalls-narrow.h>
557# undef _Mret_
558# undef _Marg_
559# undef __MATHCALL_NAME
560# endif
561
562# if __HAVE_FLOAT16 && __HAVE_FLOAT32X
563# define _Mret_ _Float16
564# define _Marg_ _Float32x
565# define __MATHCALL_NAME(name) f16 ## name ## f32x
566# include <bits/mathcalls-narrow.h>
567# undef _Mret_
568# undef _Marg_
569# undef __MATHCALL_NAME
570# endif
571
572# if __HAVE_FLOAT16 && __HAVE_FLOAT64
573# define _Mret_ _Float16
574# define _Marg_ _Float64
575# define __MATHCALL_NAME(name) f16 ## name ## f64
576# include <bits/mathcalls-narrow.h>
577# undef _Mret_
578# undef _Marg_
579# undef __MATHCALL_NAME
580# endif
581
582# if __HAVE_FLOAT16 && __HAVE_FLOAT64X
583# define _Mret_ _Float16
584# define _Marg_ _Float64x
585# define __MATHCALL_NAME(name) f16 ## name ## f64x
586# include <bits/mathcalls-narrow.h>
587# undef _Mret_
588# undef _Marg_
589# undef __MATHCALL_NAME
590# endif
591
592# if __HAVE_FLOAT16 && __HAVE_FLOAT128
593# define _Mret_ _Float16
594# define _Marg_ _Float128
595# define __MATHCALL_NAME(name) f16 ## name ## f128
596# include <bits/mathcalls-narrow.h>
597# undef _Mret_
598# undef _Marg_
599# undef __MATHCALL_NAME
600# endif
601
602# if __HAVE_FLOAT16 && __HAVE_FLOAT128X
603# define _Mret_ _Float16
604# define _Marg_ _Float128x
605# define __MATHCALL_NAME(name) f16 ## name ## f128x
606# include <bits/mathcalls-narrow.h>
607# undef _Mret_
608# undef _Marg_
609# undef __MATHCALL_NAME
610# endif
611
612# if __HAVE_FLOAT32 && __HAVE_FLOAT32X
613# define _Mret_ _Float32
614# define _Marg_ _Float32x
615# define __MATHCALL_NAME(name) f32 ## name ## f32x
616# include <bits/mathcalls-narrow.h>
617# undef _Mret_
618# undef _Marg_
619# undef __MATHCALL_NAME
620# endif
621
622# if __HAVE_FLOAT32 && __HAVE_FLOAT64
623# define _Mret_ _Float32
624# define _Marg_ _Float64
625# define __MATHCALL_NAME(name) f32 ## name ## f64
626# include <bits/mathcalls-narrow.h>
627# undef _Mret_
628# undef _Marg_
629# undef __MATHCALL_NAME
630# endif
631
632# if __HAVE_FLOAT32 && __HAVE_FLOAT64X
633# define _Mret_ _Float32
634# define _Marg_ _Float64x
635# define __MATHCALL_NAME(name) f32 ## name ## f64x
636# include <bits/mathcalls-narrow.h>
637# undef _Mret_
638# undef _Marg_
639# undef __MATHCALL_NAME
640# endif
641
642# if __HAVE_FLOAT32 && __HAVE_FLOAT128
643# define _Mret_ _Float32
644# define _Marg_ _Float128
645# define __MATHCALL_NAME(name) f32 ## name ## f128
646# include <bits/mathcalls-narrow.h>
647# undef _Mret_
648# undef _Marg_
649# undef __MATHCALL_NAME
650# endif
651
652# if __HAVE_FLOAT32 && __HAVE_FLOAT128X
653# define _Mret_ _Float32
654# define _Marg_ _Float128x
655# define __MATHCALL_NAME(name) f32 ## name ## f128x
656# include <bits/mathcalls-narrow.h>
657# undef _Mret_
658# undef _Marg_
659# undef __MATHCALL_NAME
660# endif
661
662# if __HAVE_FLOAT32X && __HAVE_FLOAT64
663# define _Mret_ _Float32x
664# define _Marg_ _Float64
665# define __MATHCALL_NAME(name) f32x ## name ## f64
666# include <bits/mathcalls-narrow.h>
667# undef _Mret_
668# undef _Marg_
669# undef __MATHCALL_NAME
670# endif
671
672# if __HAVE_FLOAT32X && __HAVE_FLOAT64X
673# define _Mret_ _Float32x
674# define _Marg_ _Float64x
675# define __MATHCALL_NAME(name) f32x ## name ## f64x
676# include <bits/mathcalls-narrow.h>
677# undef _Mret_
678# undef _Marg_
679# undef __MATHCALL_NAME
680# endif
681
682# if __HAVE_FLOAT32X && __HAVE_FLOAT128
683# define _Mret_ _Float32x
684# define _Marg_ _Float128
685# define __MATHCALL_NAME(name) f32x ## name ## f128
686# include <bits/mathcalls-narrow.h>
687# undef _Mret_
688# undef _Marg_
689# undef __MATHCALL_NAME
690# endif
691
692# if __HAVE_FLOAT32X && __HAVE_FLOAT128X
693# define _Mret_ _Float32x
694# define _Marg_ _Float128x
695# define __MATHCALL_NAME(name) f32x ## name ## f128x
696# include <bits/mathcalls-narrow.h>
697# undef _Mret_
698# undef _Marg_
699# undef __MATHCALL_NAME
700# endif
701
702# if __HAVE_FLOAT64 && __HAVE_FLOAT64X
703# define _Mret_ _Float64
704# define _Marg_ _Float64x
705# define __MATHCALL_NAME(name) f64 ## name ## f64x
706# include <bits/mathcalls-narrow.h>
707# undef _Mret_
708# undef _Marg_
709# undef __MATHCALL_NAME
710# endif
711
712# if __HAVE_FLOAT64 && __HAVE_FLOAT128
713# define _Mret_ _Float64
714# define _Marg_ _Float128
715# define __MATHCALL_NAME(name) f64 ## name ## f128
716# include <bits/mathcalls-narrow.h>
717# undef _Mret_
718# undef _Marg_
719# undef __MATHCALL_NAME
720# endif
721
722# if __HAVE_FLOAT64 && __HAVE_FLOAT128X
723# define _Mret_ _Float64
724# define _Marg_ _Float128x
725# define __MATHCALL_NAME(name) f64 ## name ## f128x
726# include <bits/mathcalls-narrow.h>
727# undef _Mret_
728# undef _Marg_
729# undef __MATHCALL_NAME
730# endif
731
732# if __HAVE_FLOAT64X && __HAVE_FLOAT128
733# define _Mret_ _Float64x
734# define _Marg_ _Float128
735# define __MATHCALL_NAME(name) f64x ## name ## f128
736# include <bits/mathcalls-narrow.h>
737# undef _Mret_
738# undef _Marg_
739# undef __MATHCALL_NAME
740# endif
741
742# if __HAVE_FLOAT64X && __HAVE_FLOAT128X
743# define _Mret_ _Float64x
744# define _Marg_ _Float128x
745# define __MATHCALL_NAME(name) f64x ## name ## f128x
746# include <bits/mathcalls-narrow.h>
747# undef _Mret_
748# undef _Marg_
749# undef __MATHCALL_NAME
750# endif
751
752# if __HAVE_FLOAT128 && __HAVE_FLOAT128X
753# define _Mret_ _Float128
754# define _Marg_ _Float128x
755# define __MATHCALL_NAME(name) f128 ## name ## f128x
756# include <bits/mathcalls-narrow.h>
757# undef _Mret_
758# undef _Marg_
759# undef __MATHCALL_NAME
760# endif
761
762#endif
763
764#undef __MATHCALL_NARROW_ARGS_1
765#undef __MATHCALL_NARROW_ARGS_2
766#undef __MATHCALL_NARROW_ARGS_3
767#undef __MATHCALL_NARROW_NORMAL
768#undef __MATHCALL_NARROW_REDIR
769#undef __MATHCALL_NARROW
770
771#if defined __USE_MISC || defined __USE_XOPEN
772/* This variable is used by `gamma' and `lgamma'. */
773extern int signgam;
774#endif
775
776#if (__HAVE_DISTINCT_FLOAT16 \
777 || __HAVE_DISTINCT_FLOAT32 \
778 || __HAVE_DISTINCT_FLOAT64 \
779 || __HAVE_DISTINCT_FLOAT32X \
780 || __HAVE_DISTINCT_FLOAT64X \
781 || __HAVE_DISTINCT_FLOAT128X)
782# error "Unsupported _FloatN or _FloatNx types for <math.h>."
783#endif
784
785/* Depending on the type of TG_ARG, call an appropriately suffixed
786 version of FUNC with arguments (including parentheses) ARGS.
787 Suffixed functions may not exist for long double if it has the same
788 format as double, or for other types with the same format as float,
789 double or long double. The behavior is undefined if the argument
790 does not have a real floating type. The definition may use a
791 conditional expression, so all suffixed versions of FUNC must
792 return the same type (FUNC may include a cast if necessary rather
793 than being a single identifier). */
794#ifdef __NO_LONG_DOUBLE_MATH
795# if __HAVE_DISTINCT_FLOAT128
796# error "Distinct _Float128 without distinct long double not supported."
797# endif
798# define __MATH_TG(TG_ARG, FUNC, ARGS) \
799 (sizeof (TG_ARG) == sizeof (float) ? FUNC ## f ARGS : FUNC ARGS)
800#elif __HAVE_DISTINCT_FLOAT128
801# if __HAVE_GENERIC_SELECTION
802# if __HAVE_FLOATN_NOT_TYPEDEF && __HAVE_FLOAT32
803# define __MATH_TG_F32(FUNC, ARGS) _Float32: FUNC ## f ARGS,
804# else
805# define __MATH_TG_F32(FUNC, ARGS)
806# endif
807# if __HAVE_FLOATN_NOT_TYPEDEF && __HAVE_FLOAT64X
808# if __HAVE_FLOAT64X_LONG_DOUBLE
809# define __MATH_TG_F64X(FUNC, ARGS) _Float64x: FUNC ## l ARGS,
810# else
811# define __MATH_TG_F64X(FUNC, ARGS) _Float64x: FUNC ## f128 ARGS,
812# endif
813# else
814# define __MATH_TG_F64X(FUNC, ARGS)
815# endif
816# define __MATH_TG(TG_ARG, FUNC, ARGS) \
817 _Generic ((TG_ARG), \
818 float: FUNC ## f ARGS, \
819 __MATH_TG_F32 (FUNC, ARGS) \
820 default: FUNC ARGS, \
821 long double: FUNC ## l ARGS, \
822 __MATH_TG_F64X (FUNC, ARGS) \
823 _Float128: FUNC ## f128 ARGS)
824# else
825# if __HAVE_FLOATN_NOT_TYPEDEF
826# error "Non-typedef _FloatN but no _Generic."
827# endif
828# define __MATH_TG(TG_ARG, FUNC, ARGS) \
829 __builtin_choose_expr \
830 (__builtin_types_compatible_p (__typeof (TG_ARG), float), \
831 FUNC ## f ARGS, \
832 __builtin_choose_expr \
833 (__builtin_types_compatible_p (__typeof (TG_ARG), double), \
834 FUNC ARGS, \
835 __builtin_choose_expr \
836 (__builtin_types_compatible_p (__typeof (TG_ARG), long double), \
837 FUNC ## l ARGS, \
838 FUNC ## f128 ARGS)))
839# endif
840#else
841# define __MATH_TG(TG_ARG, FUNC, ARGS) \
842 (sizeof (TG_ARG) == sizeof (float) \
843 ? FUNC ## f ARGS \
844 : sizeof (TG_ARG) == sizeof (double) \
845 ? FUNC ARGS \
846 : FUNC ## l ARGS)
847#endif
848
849/* ISO C99 defines some generic macros which work on any data type. */
850#ifdef __USE_ISOC99
851
852/* All floating-point numbers can be put in one of these categories. */
853enum
854 {
855 FP_NAN =
856# define FP_NAN 0
857 FP_NAN,
858 FP_INFINITE =
859# define FP_INFINITE 1
860 FP_INFINITE,
861 FP_ZERO =
862# define FP_ZERO 2
863 FP_ZERO,
864 FP_SUBNORMAL =
865# define FP_SUBNORMAL 3
866 FP_SUBNORMAL,
867 FP_NORMAL =
868# define FP_NORMAL 4
869 FP_NORMAL
870 };
871
872/* GCC bug 66462 means we cannot use the math builtins with -fsignaling-nan,
873 so disable builtins if this is enabled. When fixed in a newer GCC,
874 the __SUPPORT_SNAN__ check may be skipped for those versions. */
875
876/* Return number of classification appropriate for X. */
877# if __GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__ \
878 && (!defined __OPTIMIZE_SIZE__ || defined __cplusplus)
879 /* The check for __cplusplus allows the use of the builtin, even
880 when optimization for size is on. This is provided for
881 libstdc++, only to let its configure test work when it is built
882 with -Os. No further use of this definition of fpclassify is
883 expected in C++ mode, since libstdc++ provides its own version
884 of fpclassify in cmath (which undefines fpclassify). */
885# define fpclassify(x) __builtin_fpclassify (FP_NAN, FP_INFINITE, \
886 FP_NORMAL, FP_SUBNORMAL, FP_ZERO, x)
887# else
888# define fpclassify(x) __MATH_TG ((x), __fpclassify, (x))
889# endif
890
891/* Return nonzero value if sign of X is negative. */
892# if __GNUC_PREREQ (6,0)
893# define signbit(x) __builtin_signbit (x)
894# elif defined __cplusplus
895 /* In C++ mode, __MATH_TG cannot be used, because it relies on
896 __builtin_types_compatible_p, which is a C-only builtin.
897 The check for __cplusplus allows the use of the builtin instead of
898 __MATH_TG. This is provided for libstdc++, only to let its configure
899 test work. No further use of this definition of signbit is expected
900 in C++ mode, since libstdc++ provides its own version of signbit
901 in cmath (which undefines signbit). */
902# define signbit(x) __builtin_signbitl (x)
903# elif __GNUC_PREREQ (4,0)
904# define signbit(x) __MATH_TG ((x), __builtin_signbit, (x))
905# else
906# define signbit(x) __MATH_TG ((x), __signbit, (x))
907# endif
908
909/* Return nonzero value if X is not +-Inf or NaN. */
910# if __GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__
911# define isfinite(x) __builtin_isfinite (x)
912# else
913# define isfinite(x) __MATH_TG ((x), __finite, (x))
914# endif
915
916/* Return nonzero value if X is neither zero, subnormal, Inf, nor NaN. */
917# if __GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__
918# define isnormal(x) __builtin_isnormal (x)
919# else
920# define isnormal(x) (fpclassify (x) == FP_NORMAL)
921# endif
922
923/* Return nonzero value if X is a NaN. We could use `fpclassify' but
924 we already have this functions `__isnan' and it is faster. */
925# if __GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__
926# define isnan(x) __builtin_isnan (x)
927# else
928# define isnan(x) __MATH_TG ((x), __isnan, (x))
929# endif
930
931/* Return nonzero value if X is positive or negative infinity. */
932# if __HAVE_DISTINCT_FLOAT128 && !__GNUC_PREREQ (7,0) \
933 && !defined __SUPPORT_SNAN__ && !defined __cplusplus
934 /* Since __builtin_isinf_sign is broken for float128 before GCC 7.0,
935 use the helper function, __isinff128, with older compilers. This is
936 only provided for C mode, because in C++ mode, GCC has no support
937 for __builtin_types_compatible_p (and when in C++ mode, this macro is
938 not used anyway, because libstdc++ headers undefine it). */
939# define isinf(x) \
940 (__builtin_types_compatible_p (__typeof (x), _Float128) \
941 ? __isinff128 (x) : __builtin_isinf_sign (x))
942# elif __GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__
943# define isinf(x) __builtin_isinf_sign (x)
944# else
945# define isinf(x) __MATH_TG ((x), __isinf, (x))
946# endif
947
948/* Bitmasks for the math_errhandling macro. */
949# define MATH_ERRNO 1 /* errno set by math functions. */
950# define MATH_ERREXCEPT 2 /* Exceptions raised by math functions. */
951
952/* By default all math functions support both errno and exception handling
953 (except for soft floating point implementations which may only support
954 errno handling). If errno handling is disabled, exceptions are still
955 supported by GLIBC. Set math_errhandling to 0 with -ffast-math (this is
956 nonconforming but it is more useful than leaving it undefined). */
957# ifdef __FAST_MATH__
958# define math_errhandling 0
959# elif defined __NO_MATH_ERRNO__
960# define math_errhandling (MATH_ERREXCEPT)
961# else
962# define math_errhandling (MATH_ERRNO | MATH_ERREXCEPT)
963# endif
964
965#endif /* Use ISO C99. */
966
967#if __GLIBC_USE (IEC_60559_BFP_EXT)
968# include <bits/iscanonical.h>
969
970/* Return nonzero value if X is a signaling NaN. */
971# ifndef __cplusplus
972# define issignaling(x) __MATH_TG ((x), __issignaling, (x))
973# else
974 /* In C++ mode, __MATH_TG cannot be used, because it relies on
975 __builtin_types_compatible_p, which is a C-only builtin. On the
976 other hand, overloading provides the means to distinguish between
977 the floating-point types. The overloading resolution will match
978 the correct parameter (regardless of type qualifiers (i.e.: const
979 and volatile)). */
980extern "C++" {
981inline int issignaling (float __val) { return __issignalingf (__val); }
982inline int issignaling (double __val) { return __issignaling (__val); }
983inline int
984issignaling (long double __val)
985{
986# ifdef __NO_LONG_DOUBLE_MATH
987 return __issignaling (__val);
988# else
989 return __issignalingl (__val);
990# endif
991}
992# if __HAVE_FLOAT128_UNLIKE_LDBL
993/* When using an IEEE 128-bit long double, _Float128 is defined as long double
994 in C++. */
995inline int issignaling (_Float128 __val) { return __issignalingf128 (__val); }
996# endif
997} /* extern C++ */
998# endif
999
1000/* Return nonzero value if X is subnormal. */
1001# define issubnormal(x) (fpclassify (x) == FP_SUBNORMAL)
1002
1003/* Return nonzero value if X is zero. */
1004# ifndef __cplusplus
1005# ifdef __SUPPORT_SNAN__
1006# define iszero(x) (fpclassify (x) == FP_ZERO)
1007# else
1008# define iszero(x) (((__typeof (x)) (x)) == 0)
1009# endif
1010# else /* __cplusplus */
1011extern "C++" {
1012# ifdef __SUPPORT_SNAN__
1013inline int
1014iszero (float __val)
1015{
1016 return __fpclassifyf (__val) == FP_ZERO;
1017}
1018inline int
1019iszero (double __val)
1020{
1021 return __fpclassify (__val) == FP_ZERO;
1022}
1023inline int
1024iszero (long double __val)
1025{
1026# ifdef __NO_LONG_DOUBLE_MATH
1027 return __fpclassify (__val) == FP_ZERO;
1028# else
1029 return __fpclassifyl (__val) == FP_ZERO;
1030# endif
1031}
1032# if __HAVE_FLOAT128_UNLIKE_LDBL
1033 /* When using an IEEE 128-bit long double, _Float128 is defined as long double
1034 in C++. */
1035inline int
1036iszero (_Float128 __val)
1037{
1038 return __fpclassifyf128 (__val) == FP_ZERO;
1039}
1040# endif
1041# else
1042template <class __T> inline bool
1043iszero (__T __val)
1044{
1045 return __val == 0;
1046}
1047# endif
1048} /* extern C++ */
1049# endif /* __cplusplus */
1050#endif /* Use IEC_60559_BFP_EXT. */
1051
1052#ifdef __USE_XOPEN
1053/* X/Open wants another strange constant. */
1054# define MAXFLOAT 3.40282347e+38F
1055#endif
1056
1057
1058/* Some useful constants. */
1059#if defined __USE_MISC || defined __USE_XOPEN
1060# define M_E 2.7182818284590452354 /* e */
1061# define M_LOG2E 1.4426950408889634074 /* log_2 e */
1062# define M_LOG10E 0.43429448190325182765 /* log_10 e */
1063# define M_LN2 0.69314718055994530942 /* log_e 2 */
1064# define M_LN10 2.30258509299404568402 /* log_e 10 */
1065# define M_PI 3.14159265358979323846 /* pi */
1066# define M_PI_2 1.57079632679489661923 /* pi/2 */
1067# define M_PI_4 0.78539816339744830962 /* pi/4 */
1068# define M_1_PI 0.31830988618379067154 /* 1/pi */
1069# define M_2_PI 0.63661977236758134308 /* 2/pi */
1070# define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */
1071# define M_SQRT2 1.41421356237309504880 /* sqrt(2) */
1072# define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */
1073#endif
1074
1075/* The above constants are not adequate for computation using `long double's.
1076 Therefore we provide as an extension constants with similar names as a
1077 GNU extension. Provide enough digits for the 128-bit IEEE quad. */
1078#ifdef __USE_GNU
1079# define M_El 2.718281828459045235360287471352662498L /* e */
1080# define M_LOG2El 1.442695040888963407359924681001892137L /* log_2 e */
1081# define M_LOG10El 0.434294481903251827651128918916605082L /* log_10 e */
1082# define M_LN2l 0.693147180559945309417232121458176568L /* log_e 2 */
1083# define M_LN10l 2.302585092994045684017991454684364208L /* log_e 10 */
1084# define M_PIl 3.141592653589793238462643383279502884L /* pi */
1085# define M_PI_2l 1.570796326794896619231321691639751442L /* pi/2 */
1086# define M_PI_4l 0.785398163397448309615660845819875721L /* pi/4 */
1087# define M_1_PIl 0.318309886183790671537767526745028724L /* 1/pi */
1088# define M_2_PIl 0.636619772367581343075535053490057448L /* 2/pi */
1089# define M_2_SQRTPIl 1.128379167095512573896158903121545172L /* 2/sqrt(pi) */
1090# define M_SQRT2l 1.414213562373095048801688724209698079L /* sqrt(2) */
1091# define M_SQRT1_2l 0.707106781186547524400844362104849039L /* 1/sqrt(2) */
1092#endif
1093
1094#if __HAVE_FLOAT16 && defined __USE_GNU
1095# define M_Ef16 __f16 (2.718281828459045235360287471352662498) /* e */
1096# define M_LOG2Ef16 __f16 (1.442695040888963407359924681001892137) /* log_2 e */
1097# define M_LOG10Ef16 __f16 (0.434294481903251827651128918916605082) /* log_10 e */
1098# define M_LN2f16 __f16 (0.693147180559945309417232121458176568) /* log_e 2 */
1099# define M_LN10f16 __f16 (2.302585092994045684017991454684364208) /* log_e 10 */
1100# define M_PIf16 __f16 (3.141592653589793238462643383279502884) /* pi */
1101# define M_PI_2f16 __f16 (1.570796326794896619231321691639751442) /* pi/2 */
1102# define M_PI_4f16 __f16 (0.785398163397448309615660845819875721) /* pi/4 */
1103# define M_1_PIf16 __f16 (0.318309886183790671537767526745028724) /* 1/pi */
1104# define M_2_PIf16 __f16 (0.636619772367581343075535053490057448) /* 2/pi */
1105# define M_2_SQRTPIf16 __f16 (1.128379167095512573896158903121545172) /* 2/sqrt(pi) */
1106# define M_SQRT2f16 __f16 (1.414213562373095048801688724209698079) /* sqrt(2) */
1107# define M_SQRT1_2f16 __f16 (0.707106781186547524400844362104849039) /* 1/sqrt(2) */
1108#endif
1109
1110#if __HAVE_FLOAT32 && defined __USE_GNU
1111# define M_Ef32 __f32 (2.718281828459045235360287471352662498) /* e */
1112# define M_LOG2Ef32 __f32 (1.442695040888963407359924681001892137) /* log_2 e */
1113# define M_LOG10Ef32 __f32 (0.434294481903251827651128918916605082) /* log_10 e */
1114# define M_LN2f32 __f32 (0.693147180559945309417232121458176568) /* log_e 2 */
1115# define M_LN10f32 __f32 (2.302585092994045684017991454684364208) /* log_e 10 */
1116# define M_PIf32 __f32 (3.141592653589793238462643383279502884) /* pi */
1117# define M_PI_2f32 __f32 (1.570796326794896619231321691639751442) /* pi/2 */
1118# define M_PI_4f32 __f32 (0.785398163397448309615660845819875721) /* pi/4 */
1119# define M_1_PIf32 __f32 (0.318309886183790671537767526745028724) /* 1/pi */
1120# define M_2_PIf32 __f32 (0.636619772367581343075535053490057448) /* 2/pi */
1121# define M_2_SQRTPIf32 __f32 (1.128379167095512573896158903121545172) /* 2/sqrt(pi) */
1122# define M_SQRT2f32 __f32 (1.414213562373095048801688724209698079) /* sqrt(2) */
1123# define M_SQRT1_2f32 __f32 (0.707106781186547524400844362104849039) /* 1/sqrt(2) */
1124#endif
1125
1126#if __HAVE_FLOAT64 && defined __USE_GNU
1127# define M_Ef64 __f64 (2.718281828459045235360287471352662498) /* e */
1128# define M_LOG2Ef64 __f64 (1.442695040888963407359924681001892137) /* log_2 e */
1129# define M_LOG10Ef64 __f64 (0.434294481903251827651128918916605082) /* log_10 e */
1130# define M_LN2f64 __f64 (0.693147180559945309417232121458176568) /* log_e 2 */
1131# define M_LN10f64 __f64 (2.302585092994045684017991454684364208) /* log_e 10 */
1132# define M_PIf64 __f64 (3.141592653589793238462643383279502884) /* pi */
1133# define M_PI_2f64 __f64 (1.570796326794896619231321691639751442) /* pi/2 */
1134# define M_PI_4f64 __f64 (0.785398163397448309615660845819875721) /* pi/4 */
1135# define M_1_PIf64 __f64 (0.318309886183790671537767526745028724) /* 1/pi */
1136# define M_2_PIf64 __f64 (0.636619772367581343075535053490057448) /* 2/pi */
1137# define M_2_SQRTPIf64 __f64 (1.128379167095512573896158903121545172) /* 2/sqrt(pi) */
1138# define M_SQRT2f64 __f64 (1.414213562373095048801688724209698079) /* sqrt(2) */
1139# define M_SQRT1_2f64 __f64 (0.707106781186547524400844362104849039) /* 1/sqrt(2) */
1140#endif
1141
1142#if __HAVE_FLOAT128 && defined __USE_GNU
1143# define M_Ef128 __f128 (2.718281828459045235360287471352662498) /* e */
1144# define M_LOG2Ef128 __f128 (1.442695040888963407359924681001892137) /* log_2 e */
1145# define M_LOG10Ef128 __f128 (0.434294481903251827651128918916605082) /* log_10 e */
1146# define M_LN2f128 __f128 (0.693147180559945309417232121458176568) /* log_e 2 */
1147# define M_LN10f128 __f128 (2.302585092994045684017991454684364208) /* log_e 10 */
1148# define M_PIf128 __f128 (3.141592653589793238462643383279502884) /* pi */
1149# define M_PI_2f128 __f128 (1.570796326794896619231321691639751442) /* pi/2 */
1150# define M_PI_4f128 __f128 (0.785398163397448309615660845819875721) /* pi/4 */
1151# define M_1_PIf128 __f128 (0.318309886183790671537767526745028724) /* 1/pi */
1152# define M_2_PIf128 __f128 (0.636619772367581343075535053490057448) /* 2/pi */
1153# define M_2_SQRTPIf128 __f128 (1.128379167095512573896158903121545172) /* 2/sqrt(pi) */
1154# define M_SQRT2f128 __f128 (1.414213562373095048801688724209698079) /* sqrt(2) */
1155# define M_SQRT1_2f128 __f128 (0.707106781186547524400844362104849039) /* 1/sqrt(2) */
1156#endif
1157
1158#if __HAVE_FLOAT32X && defined __USE_GNU
1159# define M_Ef32x __f32x (2.718281828459045235360287471352662498) /* e */
1160# define M_LOG2Ef32x __f32x (1.442695040888963407359924681001892137) /* log_2 e */
1161# define M_LOG10Ef32x __f32x (0.434294481903251827651128918916605082) /* log_10 e */
1162# define M_LN2f32x __f32x (0.693147180559945309417232121458176568) /* log_e 2 */
1163# define M_LN10f32x __f32x (2.302585092994045684017991454684364208) /* log_e 10 */
1164# define M_PIf32x __f32x (3.141592653589793238462643383279502884) /* pi */
1165# define M_PI_2f32x __f32x (1.570796326794896619231321691639751442) /* pi/2 */
1166# define M_PI_4f32x __f32x (0.785398163397448309615660845819875721) /* pi/4 */
1167# define M_1_PIf32x __f32x (0.318309886183790671537767526745028724) /* 1/pi */
1168# define M_2_PIf32x __f32x (0.636619772367581343075535053490057448) /* 2/pi */
1169# define M_2_SQRTPIf32x __f32x (1.128379167095512573896158903121545172) /* 2/sqrt(pi) */
1170# define M_SQRT2f32x __f32x (1.414213562373095048801688724209698079) /* sqrt(2) */
1171# define M_SQRT1_2f32x __f32x (0.707106781186547524400844362104849039) /* 1/sqrt(2) */
1172#endif
1173
1174#if __HAVE_FLOAT64X && defined __USE_GNU
1175# define M_Ef64x __f64x (2.718281828459045235360287471352662498) /* e */
1176# define M_LOG2Ef64x __f64x (1.442695040888963407359924681001892137) /* log_2 e */
1177# define M_LOG10Ef64x __f64x (0.434294481903251827651128918916605082) /* log_10 e */
1178# define M_LN2f64x __f64x (0.693147180559945309417232121458176568) /* log_e 2 */
1179# define M_LN10f64x __f64x (2.302585092994045684017991454684364208) /* log_e 10 */
1180# define M_PIf64x __f64x (3.141592653589793238462643383279502884) /* pi */
1181# define M_PI_2f64x __f64x (1.570796326794896619231321691639751442) /* pi/2 */
1182# define M_PI_4f64x __f64x (0.785398163397448309615660845819875721) /* pi/4 */
1183# define M_1_PIf64x __f64x (0.318309886183790671537767526745028724) /* 1/pi */
1184# define M_2_PIf64x __f64x (0.636619772367581343075535053490057448) /* 2/pi */
1185# define M_2_SQRTPIf64x __f64x (1.128379167095512573896158903121545172) /* 2/sqrt(pi) */
1186# define M_SQRT2f64x __f64x (1.414213562373095048801688724209698079) /* sqrt(2) */
1187# define M_SQRT1_2f64x __f64x (0.707106781186547524400844362104849039) /* 1/sqrt(2) */
1188#endif
1189
1190#if __HAVE_FLOAT128X && defined __USE_GNU
1191# error "M_* values needed for _Float128x"
1192#endif
1193
1194/* When compiling in strict ISO C compatible mode we must not use the
1195 inline functions since they, among other things, do not set the
1196 `errno' variable correctly. */
1197#if defined __STRICT_ANSI__ && !defined __NO_MATH_INLINES
1198# define __NO_MATH_INLINES 1
1199#endif
1200
1201#ifdef __USE_ISOC99
1202# if __GNUC_PREREQ (3, 1)
1203/* ISO C99 defines some macros to compare number while taking care for
1204 unordered numbers. Many FPUs provide special instructions to support
1205 these operations. Generic support in GCC for these as builtins went
1206 in 2.97, but not all cpus added their patterns until 3.1. Therefore
1207 we enable the builtins from 3.1 onwards and use a generic implementation
1208 othwerwise. */
1209# define isgreater(x, y) __builtin_isgreater(x, y)
1210# define isgreaterequal(x, y) __builtin_isgreaterequal(x, y)
1211# define isless(x, y) __builtin_isless(x, y)
1212# define islessequal(x, y) __builtin_islessequal(x, y)
1213# define islessgreater(x, y) __builtin_islessgreater(x, y)
1214# define isunordered(x, y) __builtin_isunordered(x, y)
1215# else
1216# define isgreater(x, y) \
1217 (__extension__ ({ __typeof__ (x) __x = (x); __typeof__ (y) __y = (y); \
1218 !isunordered (__x, __y) && __x > __y; }))
1219# define isgreaterequal(x, y) \
1220 (__extension__ ({ __typeof__ (x) __x = (x); __typeof__ (y) __y = (y); \
1221 !isunordered (__x, __y) && __x >= __y; }))
1222# define isless(x, y) \
1223 (__extension__ ({ __typeof__ (x) __x = (x); __typeof__ (y) __y = (y); \
1224 !isunordered (__x, __y) && __x < __y; }))
1225# define islessequal(x, y) \
1226 (__extension__ ({ __typeof__ (x) __x = (x); __typeof__ (y) __y = (y); \
1227 !isunordered (__x, __y) && __x <= __y; }))
1228# define islessgreater(x, y) \
1229 (__extension__ ({ __typeof__ (x) __x = (x); __typeof__ (y) __y = (y); \
1230 !isunordered (__x, __y) && __x != __y; }))
1231/* isunordered must always check both operands first for signaling NaNs. */
1232# define isunordered(x, y) \
1233 (__extension__ ({ __typeof__ (x) __u = (x); __typeof__ (y) __v = (y); \
1234 __u != __v && (__u != __u || __v != __v); }))
1235# endif
1236#endif
1237
1238/* Get machine-dependent inline versions (if there are any). */
1239#ifdef __USE_EXTERN_INLINES
1240# include <bits/mathinline.h>
1241#endif
1242
1243/* Define special entry points to use when the compiler got told to
1244 only expect finite results. */
1245#if defined __FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0
1246
1247/* Include bits/math-finite.h for double. */
1248# define _Mdouble_ double
1249# define __MATH_DECLARING_DOUBLE 1
1250# define __MATH_DECLARING_FLOATN 0
1251# define __REDIRFROM_X(function, reentrant) \
1252 function ## reentrant
1253# define __REDIRTO_X(function, reentrant) \
1254 __ ## function ## reentrant ## _finite
1255# include <bits/math-finite.h>
1256# undef _Mdouble_
1257# undef __MATH_DECLARING_DOUBLE
1258# undef __MATH_DECLARING_FLOATN
1259# undef __REDIRFROM_X
1260# undef __REDIRTO_X
1261
1262/* When __USE_ISOC99 is defined, include math-finite for float and
1263 long double, as well. */
1264# ifdef __USE_ISOC99
1265
1266/* Include bits/math-finite.h for float. */
1267# define _Mdouble_ float
1268# define __MATH_DECLARING_DOUBLE 0
1269# define __MATH_DECLARING_FLOATN 0
1270# define __REDIRFROM_X(function, reentrant) \
1271 function ## f ## reentrant
1272# define __REDIRTO_X(function, reentrant) \
1273 __ ## function ## f ## reentrant ## _finite
1274# include <bits/math-finite.h>
1275# undef _Mdouble_
1276# undef __MATH_DECLARING_DOUBLE
1277# undef __MATH_DECLARING_FLOATN
1278# undef __REDIRFROM_X
1279# undef __REDIRTO_X
1280
1281/* Include bits/math-finite.h for long double. */
1282# ifdef __MATH_DECLARE_LDOUBLE
1283# define _Mdouble_ long double
1284# define __MATH_DECLARING_DOUBLE 0
1285# define __MATH_DECLARING_FLOATN 0
1286# define __REDIRFROM_X(function, reentrant) \
1287 function ## l ## reentrant
1288# ifdef __NO_LONG_DOUBLE_MATH
1289# define __REDIRTO_X(function, reentrant) \
1290 __ ## function ## reentrant ## _finite
1291# else
1292# define __REDIRTO_X(function, reentrant) \
1293 __ ## function ## l ## reentrant ## _finite
1294# endif
1295# include <bits/math-finite.h>
1296# undef _Mdouble_
1297# undef __MATH_DECLARING_DOUBLE
1298# undef __MATH_DECLARING_FLOATN
1299# undef __REDIRFROM_X
1300# undef __REDIRTO_X
1301# endif
1302
1303# endif /* __USE_ISOC99. */
1304
1305/* Include bits/math-finite.h for _FloatN and _FloatNx. */
1306
1307# if (__HAVE_DISTINCT_FLOAT16 || (__HAVE_FLOAT16 && !defined _LIBC)) \
1308 && __GLIBC_USE (IEC_60559_TYPES_EXT)
1309# define _Mdouble_ _Float16
1310# define __MATH_DECLARING_DOUBLE 0
1311# define __MATH_DECLARING_FLOATN 1
1312# define __REDIRFROM_X(function, reentrant) \
1313 function ## f16 ## reentrant
1314# if __HAVE_DISTINCT_FLOAT16
1315# define __REDIRTO_X(function, reentrant) \
1316 __ ## function ## f16 ## reentrant ## _finite
1317# else
1318# error "non-disinct _Float16"
1319# endif
1320# include <bits/math-finite.h>
1321# undef _Mdouble_
1322# undef __MATH_DECLARING_DOUBLE
1323# undef __MATH_DECLARING_FLOATN
1324# undef __REDIRFROM_X
1325# undef __REDIRTO_X
1326# endif
1327
1328# if (__HAVE_DISTINCT_FLOAT32 || (__HAVE_FLOAT32 && !defined _LIBC)) \
1329 && __GLIBC_USE (IEC_60559_TYPES_EXT)
1330# define _Mdouble_ _Float32
1331# define __MATH_DECLARING_DOUBLE 0
1332# define __MATH_DECLARING_FLOATN 1
1333# define __REDIRFROM_X(function, reentrant) \
1334 function ## f32 ## reentrant
1335# if __HAVE_DISTINCT_FLOAT32
1336# define __REDIRTO_X(function, reentrant) \
1337 __ ## function ## f32 ## reentrant ## _finite
1338# else
1339# define __REDIRTO_X(function, reentrant) \
1340 __ ## function ## f ## reentrant ## _finite
1341# endif
1342# include <bits/math-finite.h>
1343# undef _Mdouble_
1344# undef __MATH_DECLARING_DOUBLE
1345# undef __MATH_DECLARING_FLOATN
1346# undef __REDIRFROM_X
1347# undef __REDIRTO_X
1348# endif
1349
1350# if (__HAVE_DISTINCT_FLOAT64 || (__HAVE_FLOAT64 && !defined _LIBC)) \
1351 && __GLIBC_USE (IEC_60559_TYPES_EXT)
1352# define _Mdouble_ _Float64
1353# define __MATH_DECLARING_DOUBLE 0
1354# define __MATH_DECLARING_FLOATN 1
1355# define __REDIRFROM_X(function, reentrant) \
1356 function ## f64 ## reentrant
1357# if __HAVE_DISTINCT_FLOAT64
1358# define __REDIRTO_X(function, reentrant) \
1359 __ ## function ## f64 ## reentrant ## _finite
1360# else
1361# define __REDIRTO_X(function, reentrant) \
1362 __ ## function ## reentrant ## _finite
1363# endif
1364# include <bits/math-finite.h>
1365# undef _Mdouble_
1366# undef __MATH_DECLARING_DOUBLE
1367# undef __MATH_DECLARING_FLOATN
1368# undef __REDIRFROM_X
1369# undef __REDIRTO_X
1370# endif
1371
1372# if (__HAVE_DISTINCT_FLOAT128 || (__HAVE_FLOAT128 && !defined _LIBC)) \
1373 && __GLIBC_USE (IEC_60559_TYPES_EXT)
1374# define _Mdouble_ _Float128
1375# define __MATH_DECLARING_DOUBLE 0
1376# define __MATH_DECLARING_FLOATN 1
1377# define __REDIRFROM_X(function, reentrant) \
1378 function ## f128 ## reentrant
1379# if __HAVE_DISTINCT_FLOAT128
1380# define __REDIRTO_X(function, reentrant) \
1381 __ ## function ## f128 ## reentrant ## _finite
1382# else
1383# define __REDIRTO_X(function, reentrant) \
1384 __ ## function ## l ## reentrant ## _finite
1385# endif
1386# include <bits/math-finite.h>
1387# undef _Mdouble_
1388# undef __MATH_DECLARING_DOUBLE
1389# undef __MATH_DECLARING_FLOATN
1390# undef __REDIRFROM_X
1391# undef __REDIRTO_X
1392# endif
1393
1394# if (__HAVE_DISTINCT_FLOAT32X || (__HAVE_FLOAT32X && !defined _LIBC)) \
1395 && __GLIBC_USE (IEC_60559_TYPES_EXT)
1396# define _Mdouble_ _Float32x
1397# define __MATH_DECLARING_DOUBLE 0
1398# define __MATH_DECLARING_FLOATN 1
1399# define __REDIRFROM_X(function, reentrant) \
1400 function ## f32x ## reentrant
1401# if __HAVE_DISTINCT_FLOAT32X
1402# define __REDIRTO_X(function, reentrant) \
1403 __ ## function ## f32x ## reentrant ## _finite
1404# else
1405# define __REDIRTO_X(function, reentrant) \
1406 __ ## function ## reentrant ## _finite
1407# endif
1408# include <bits/math-finite.h>
1409# undef _Mdouble_
1410# undef __MATH_DECLARING_DOUBLE
1411# undef __MATH_DECLARING_FLOATN
1412# undef __REDIRFROM_X
1413# undef __REDIRTO_X
1414# endif
1415
1416# if (__HAVE_DISTINCT_FLOAT64X || (__HAVE_FLOAT64X && !defined _LIBC)) \
1417 && __GLIBC_USE (IEC_60559_TYPES_EXT)
1418# define _Mdouble_ _Float64x
1419# define __MATH_DECLARING_DOUBLE 0
1420# define __MATH_DECLARING_FLOATN 1
1421# define __REDIRFROM_X(function, reentrant) \
1422 function ## f64x ## reentrant
1423# if __HAVE_DISTINCT_FLOAT64X
1424# define __REDIRTO_X(function, reentrant) \
1425 __ ## function ## f64x ## reentrant ## _finite
1426# elif __HAVE_FLOAT64X_LONG_DOUBLE
1427# define __REDIRTO_X(function, reentrant) \
1428 __ ## function ## l ## reentrant ## _finite
1429# else
1430# define __REDIRTO_X(function, reentrant) \
1431 __ ## function ## f128 ## reentrant ## _finite
1432# endif
1433# include <bits/math-finite.h>
1434# undef _Mdouble_
1435# undef __MATH_DECLARING_DOUBLE
1436# undef __MATH_DECLARING_FLOATN
1437# undef __REDIRFROM_X
1438# undef __REDIRTO_X
1439# endif
1440
1441# if (__HAVE_DISTINCT_FLOAT128X || (__HAVE_FLOAT128X && !defined _LIBC)) \
1442 && __GLIBC_USE (IEC_60559_TYPES_EXT)
1443# define _Mdouble_ _Float128x
1444# define __MATH_DECLARING_DOUBLE 0
1445# define __MATH_DECLARING_FLOATN 1
1446# define __REDIRFROM_X(function, reentrant) \
1447 function ## f128x ## reentrant
1448# if __HAVE_DISTINCT_FLOAT128X
1449# define __REDIRTO_X(function, reentrant) \
1450 __ ## function ## f128x ## reentrant ## _finite
1451# else
1452# error "non-disinct _Float128x"
1453# endif
1454# include <bits/math-finite.h>
1455# undef _Mdouble_
1456# undef __MATH_DECLARING_DOUBLE
1457# undef __MATH_DECLARING_FLOATN
1458# undef __REDIRFROM_X
1459# undef __REDIRTO_X
1460# endif
1461
1462#endif /* __FINITE_MATH_ONLY__ > 0. */
1463
1464#if __GLIBC_USE (IEC_60559_BFP_EXT)
1465/* An expression whose type has the widest of the evaluation formats
1466 of X and Y (which are of floating-point types). */
1467# if __FLT_EVAL_METHOD__ == 2 || __FLT_EVAL_METHOD__ > 64
1468# define __MATH_EVAL_FMT2(x, y) ((x) + (y) + 0.0L)
1469# elif __FLT_EVAL_METHOD__ == 1 || __FLT_EVAL_METHOD__ > 32
1470# define __MATH_EVAL_FMT2(x, y) ((x) + (y) + 0.0)
1471# elif __FLT_EVAL_METHOD__ == 0 || __FLT_EVAL_METHOD__ == 32
1472# define __MATH_EVAL_FMT2(x, y) ((x) + (y) + 0.0f)
1473# else
1474# define __MATH_EVAL_FMT2(x, y) ((x) + (y))
1475# endif
1476
1477/* Return X == Y but raising "invalid" and setting errno if X or Y is
1478 a NaN. */
1479# if !defined __cplusplus || (__cplusplus < 201103L && !defined __GNUC__)
1480# define iseqsig(x, y) \
1481 __MATH_TG (__MATH_EVAL_FMT2 (x, y), __iseqsig, ((x), (y)))
1482# else
1483/* In C++ mode, __MATH_TG cannot be used, because it relies on
1484 __builtin_types_compatible_p, which is a C-only builtin. Moreover,
1485 the comparison macros from ISO C take two floating-point arguments,
1486 which need not have the same type. Choosing what underlying function
1487 to call requires evaluating the formats of the arguments, then
1488 selecting which is wider. The macro __MATH_EVAL_FMT2 provides this
1489 information, however, only the type of the macro expansion is
1490 relevant (actually evaluating the expression would be incorrect).
1491 Thus, the type is used as a template parameter for __iseqsig_type,
1492 which calls the appropriate underlying function. */
1493extern "C++" {
1494template<typename> struct __iseqsig_type;
1495
1496template<> struct __iseqsig_type<float>
1497{
1498 static int __call (float __x, float __y) throw ()
1499 {
1500 return __iseqsigf (__x, __y);
1501 }
1502};
1503
1504template<> struct __iseqsig_type<double>
1505{
1506 static int __call (double __x, double __y) throw ()
1507 {
1508 return __iseqsig (__x, __y);
1509 }
1510};
1511
1512template<> struct __iseqsig_type<long double>
1513{
1514 static int __call (long double __x, long double __y) throw ()
1515 {
1516# ifndef __NO_LONG_DOUBLE_MATH
1517 return __iseqsigl (__x, __y);
1518# else
1519 return __iseqsig (__x, __y);
1520# endif
1521 }
1522};
1523
1524# if __HAVE_FLOAT128_UNLIKE_LDBL
1525 /* When using an IEEE 128-bit long double, _Float128 is defined as long double
1526 in C++. */
1527template<> struct __iseqsig_type<_Float128>
1528{
1529 static int __call (_Float128 __x, _Float128 __y) throw ()
1530 {
1531 return __iseqsigf128 (__x, __y);
1532 }
1533};
1534# endif
1535
1536template<typename _T1, typename _T2>
1537inline int
1538iseqsig (_T1 __x, _T2 __y) throw ()
1539{
1540# if __cplusplus >= 201103L
1541 typedef decltype (__MATH_EVAL_FMT2 (__x, __y)) _T3;
1542# else
1543 typedef __typeof (__MATH_EVAL_FMT2 (__x, __y)) _T3;
1544# endif
1545 return __iseqsig_type<_T3>::__call (__x, __y);
1546}
1547
1548} /* extern "C++" */
1549# endif /* __cplusplus */
1550
1551#endif
1552
1553__END_DECLS
1554
1555
1556#endif /* math.h */
libc/glibc-include/mcheck.h created+60
...@@ -0,0 +1,60 @@
1/* Copyright (C) 1996-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _MCHECK_H
19#define _MCHECK_H 1
20
21#include <features.h>
22
23__BEGIN_DECLS
24
25/* Return values for `mprobe': these are the kinds of inconsistencies that
26 `mcheck' enables detection of. */
27enum mcheck_status
28{
29 MCHECK_DISABLED = -1, /* Consistency checking is not turned on. */
30 MCHECK_OK, /* Block is fine. */
31 MCHECK_FREE, /* Block freed twice. */
32 MCHECK_HEAD, /* Memory before the block was clobbered. */
33 MCHECK_TAIL /* Memory after the block was clobbered. */
34};
35
36
37/* Activate a standard collection of debugging hooks. This must be called
38 before `malloc' is ever called. ABORTFUNC is called with an error code
39 (see enum above) when an inconsistency is detected. If ABORTFUNC is
40 null, the standard function prints on stderr and then calls `abort'. */
41extern int mcheck (void (*__abortfunc)(enum mcheck_status)) __THROW;
42
43/* Similar to `mcheck' but performs checks for all block whenever one of
44 the memory handling functions is called. This can be very slow. */
45extern int mcheck_pedantic (void (*__abortfunc)(enum mcheck_status)) __THROW;
46
47/* Force check of all blocks now. */
48extern void mcheck_check_all (void);
49
50/* Check for aberrations in a particular malloc'd block. You must have
51 called `mcheck' already. These are the same checks that `mcheck' does
52 when you free or reallocate a block. */
53extern enum mcheck_status mprobe (void *__ptr) __THROW;
54
55/* Activate a standard collection of tracing hooks. */
56extern void mtrace (void) __THROW;
57extern void muntrace (void) __THROW;
58
59__END_DECLS
60#endif /* mcheck.h */
libc/glibc-include/memory.h created+33
...@@ -0,0 +1,33 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/*
19 * SVID
20 */
21
22#ifndef _MEMORY_H
23#define _MEMORY_H 1
24
25#include <features.h>
26
27
28#ifndef _STRING_H
29# include <string.h>
30#endif /* string.h */
31
32
33#endif /* memory.h */
libc/glibc-include/mntent.h created+95
...@@ -0,0 +1,95 @@
1/* Utilities for reading/writing fstab, mtab, etc.
2 Copyright (C) 1995-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _MNTENT_H
20#define _MNTENT_H 1
21
22#include <features.h>
23#include <paths.h>
24#include <bits/types/FILE.h>
25
26/* File listing canonical interesting mount points. */
27#define MNTTAB _PATH_MNTTAB /* Deprecated alias. */
28
29/* File listing currently active mount points. */
30#define MOUNTED _PATH_MOUNTED /* Deprecated alias. */
31
32
33/* General filesystem types. */
34#define MNTTYPE_IGNORE "ignore" /* Ignore this entry. */
35#define MNTTYPE_NFS "nfs" /* Network file system. */
36#define MNTTYPE_SWAP "swap" /* Swap device. */
37
38
39/* Generic mount options. */
40#define MNTOPT_DEFAULTS "defaults" /* Use all default options. */
41#define MNTOPT_RO "ro" /* Read only. */
42#define MNTOPT_RW "rw" /* Read/write. */
43#define MNTOPT_SUID "suid" /* Set uid allowed. */
44#define MNTOPT_NOSUID "nosuid" /* No set uid allowed. */
45#define MNTOPT_NOAUTO "noauto" /* Do not auto mount. */
46
47
48__BEGIN_DECLS
49
50/* Structure describing a mount table entry. */
51struct mntent
52 {
53 char *mnt_fsname; /* Device or server for filesystem. */
54 char *mnt_dir; /* Directory mounted on. */
55 char *mnt_type; /* Type of filesystem: ufs, nfs, etc. */
56 char *mnt_opts; /* Comma-separated options for fs. */
57 int mnt_freq; /* Dump frequency (in days). */
58 int mnt_passno; /* Pass number for `fsck'. */
59 };
60
61
62/* Prepare to begin reading and/or writing mount table entries from the
63 beginning of FILE. MODE is as for `fopen'. */
64extern FILE *setmntent (const char *__file, const char *__mode) __THROW;
65
66/* Read one mount table entry from STREAM. Returns a pointer to storage
67 reused on the next call, or null for EOF or error (use feof/ferror to
68 check). */
69extern struct mntent *getmntent (FILE *__stream) __THROW;
70
71#ifdef __USE_MISC
72/* Reentrant version of the above function. */
73extern struct mntent *getmntent_r (FILE *__restrict __stream,
74 struct mntent *__restrict __result,
75 char *__restrict __buffer,
76 int __bufsize) __THROW;
77#endif
78
79/* Write the mount table entry described by MNT to STREAM.
80 Return zero on success, nonzero on failure. */
81extern int addmntent (FILE *__restrict __stream,
82 const struct mntent *__restrict __mnt) __THROW;
83
84/* Close a stream opened with `setmntent'. */
85extern int endmntent (FILE *__stream) __THROW;
86
87/* Search MNT->mnt_opts for an option matching OPT.
88 Returns the address of the substring, or null if none found. */
89extern char *hasmntopt (const struct mntent *__mnt,
90 const char *__opt) __THROW;
91
92
93__END_DECLS
94
95#endif /* mntent.h */
libc/glibc-include/monetary.h created+59
...@@ -0,0 +1,59 @@
1/* Header file for monetary value formatting functions.
2 Copyright (C) 1996-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _MONETARY_H
20#define _MONETARY_H 1
21
22#include <features.h>
23
24/* Get needed types. */
25#define __need_size_t
26#include <stddef.h>
27#include <bits/types.h>
28
29#ifndef __ssize_t_defined
30typedef __ssize_t ssize_t;
31# define __ssize_t_defined
32#endif
33
34
35__BEGIN_DECLS
36
37/* Formatting a monetary value according to the current locale. */
38extern ssize_t strfmon (char *__restrict __s, size_t __maxsize,
39 const char *__restrict __format, ...)
40 __THROW __attribute_format_strfmon__ (3, 4);
41
42#ifdef __USE_XOPEN2K8
43/* POSIX.1-2008 extended locale interface (see locale.h). */
44# include <bits/types/locale_t.h>
45
46/* Formatting a monetary value according to the given locale. */
47extern ssize_t strfmon_l (char *__restrict __s, size_t __maxsize,
48 locale_t __loc,
49 const char *__restrict __format, ...)
50 __THROW __attribute_format_strfmon__ (4, 5);
51#endif
52
53#ifdef __LDBL_COMPAT
54# include <bits/monetary-ldbl.h>
55#endif
56
57__END_DECLS
58
59#endif /* monetary.h */
libc/glibc-include/mqueue.h created+98
...@@ -0,0 +1,98 @@
1/* Copyright (C) 2004-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _MQUEUE_H
19#define _MQUEUE_H 1
20
21#include <features.h>
22#include <sys/types.h>
23#include <fcntl.h>
24#include <bits/types/sigevent_t.h>
25#include <bits/types/struct_timespec.h>
26/* Get the definition of mqd_t and struct mq_attr. */
27#include <bits/mqueue.h>
28
29__BEGIN_DECLS
30
31/* Establish connection between a process and a message queue NAME and
32 return message queue descriptor or (mqd_t) -1 on error. OFLAG determines
33 the type of access used. If O_CREAT is on OFLAG, the third argument is
34 taken as a `mode_t', the mode of the created message queue, and the fourth
35 argument is taken as `struct mq_attr *', pointer to message queue
36 attributes. If the fourth argument is NULL, default attributes are
37 used. */
38extern mqd_t mq_open (const char *__name, int __oflag, ...)
39 __THROW __nonnull ((1));
40
41/* Removes the association between message queue descriptor MQDES and its
42 message queue. */
43extern int mq_close (mqd_t __mqdes) __THROW;
44
45/* Query status and attributes of message queue MQDES. */
46extern int mq_getattr (mqd_t __mqdes, struct mq_attr *__mqstat)
47 __THROW __nonnull ((2));
48
49/* Set attributes associated with message queue MQDES and if OMQSTAT is
50 not NULL also query its old attributes. */
51extern int mq_setattr (mqd_t __mqdes,
52 const struct mq_attr *__restrict __mqstat,
53 struct mq_attr *__restrict __omqstat)
54 __THROW __nonnull ((2));
55
56/* Remove message queue named NAME. */
57extern int mq_unlink (const char *__name) __THROW __nonnull ((1));
58
59/* Register notification issued upon message arrival to an empty
60 message queue MQDES. */
61extern int mq_notify (mqd_t __mqdes, const struct sigevent *__notification)
62 __THROW;
63
64/* Receive the oldest from highest priority messages in message queue
65 MQDES. */
66extern ssize_t mq_receive (mqd_t __mqdes, char *__msg_ptr, size_t __msg_len,
67 unsigned int *__msg_prio) __nonnull ((2));
68
69/* Add message pointed by MSG_PTR to message queue MQDES. */
70extern int mq_send (mqd_t __mqdes, const char *__msg_ptr, size_t __msg_len,
71 unsigned int __msg_prio) __nonnull ((2));
72
73#ifdef __USE_XOPEN2K
74/* Receive the oldest from highest priority messages in message queue
75 MQDES, stop waiting if ABS_TIMEOUT expires. */
76extern ssize_t mq_timedreceive (mqd_t __mqdes, char *__restrict __msg_ptr,
77 size_t __msg_len,
78 unsigned int *__restrict __msg_prio,
79 const struct timespec *__restrict __abs_timeout)
80 __nonnull ((2, 5));
81
82/* Add message pointed by MSG_PTR to message queue MQDES, stop blocking
83 on full message queue if ABS_TIMEOUT expires. */
84extern int mq_timedsend (mqd_t __mqdes, const char *__msg_ptr,
85 size_t __msg_len, unsigned int __msg_prio,
86 const struct timespec *__abs_timeout)
87 __nonnull ((2, 5));
88#endif
89
90/* Define some inlines helping to catch common problems. */
91#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function \
92 && defined __va_arg_pack_len
93# include <bits/mqueue2.h>
94#endif
95
96__END_DECLS
97
98#endif /* mqueue.h */
libc/glibc-include/net/ethernet.h created+84
...@@ -0,0 +1,84 @@
1/* Copyright (C) 1997-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/* Based on the FreeBSD version of this file. Curiously, that file
19 lacks a copyright in the header. */
20
21#ifndef __NET_ETHERNET_H
22#define __NET_ETHERNET_H 1
23
24#include <sys/types.h>
25#include <stdint.h>
26
27#include <linux/if_ether.h> /* IEEE 802.3 Ethernet constants */
28
29__BEGIN_DECLS
30
31/* This is a name for the 48 bit ethernet address available on many
32 systems. */
33struct ether_addr
34{
35 uint8_t ether_addr_octet[ETH_ALEN];
36} __attribute__ ((__packed__));
37
38/* 10Mb/s ethernet header */
39struct ether_header
40{
41 uint8_t ether_dhost[ETH_ALEN]; /* destination eth addr */
42 uint8_t ether_shost[ETH_ALEN]; /* source ether addr */
43 uint16_t ether_type; /* packet type ID field */
44} __attribute__ ((__packed__));
45
46/* Ethernet protocol ID's */
47#define ETHERTYPE_PUP 0x0200 /* Xerox PUP */
48#define ETHERTYPE_SPRITE 0x0500 /* Sprite */
49#define ETHERTYPE_IP 0x0800 /* IP */
50#define ETHERTYPE_ARP 0x0806 /* Address resolution */
51#define ETHERTYPE_REVARP 0x8035 /* Reverse ARP */
52#define ETHERTYPE_AT 0x809B /* AppleTalk protocol */
53#define ETHERTYPE_AARP 0x80F3 /* AppleTalk ARP */
54#define ETHERTYPE_VLAN 0x8100 /* IEEE 802.1Q VLAN tagging */
55#define ETHERTYPE_IPX 0x8137 /* IPX */
56#define ETHERTYPE_IPV6 0x86dd /* IP protocol version 6 */
57#define ETHERTYPE_LOOPBACK 0x9000 /* used to test interfaces */
58
59
60#define ETHER_ADDR_LEN ETH_ALEN /* size of ethernet addr */
61#define ETHER_TYPE_LEN 2 /* bytes in type field */
62#define ETHER_CRC_LEN 4 /* bytes in CRC field */
63#define ETHER_HDR_LEN ETH_HLEN /* total octets in header */
64#define ETHER_MIN_LEN (ETH_ZLEN + ETHER_CRC_LEN) /* min packet length */
65#define ETHER_MAX_LEN (ETH_FRAME_LEN + ETHER_CRC_LEN) /* max packet length */
66
67/* make sure ethenet length is valid */
68#define ETHER_IS_VALID_LEN(foo) \
69 ((foo) >= ETHER_MIN_LEN && (foo) <= ETHER_MAX_LEN)
70
71/*
72 * The ETHERTYPE_NTRAILER packet types starting at ETHERTYPE_TRAIL have
73 * (type-ETHERTYPE_TRAIL)*512 bytes of data followed
74 * by an ETHER type (as given above) and then the (variable-length) header.
75 */
76#define ETHERTYPE_TRAIL 0x1000 /* Trailer packet */
77#define ETHERTYPE_NTRAILER 16
78
79#define ETHERMTU ETH_DATA_LEN
80#define ETHERMIN (ETHER_MIN_LEN - ETHER_HDR_LEN - ETHER_CRC_LEN)
81
82__END_DECLS
83
84#endif /* net/ethernet.h */
libc/glibc-include/net/if.h created+204
...@@ -0,0 +1,204 @@
1/* net/if.h -- declarations for inquiring about network interfaces
2 Copyright (C) 1997-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _NET_IF_H
20#define _NET_IF_H 1
21
22#include <features.h>
23
24#ifdef __USE_MISC
25# include <sys/types.h>
26# include <sys/socket.h>
27#endif
28
29
30/* Length of interface name. */
31#define IF_NAMESIZE 16
32
33struct if_nameindex
34 {
35 unsigned int if_index; /* 1, 2, ... */
36 char *if_name; /* null terminated name: "eth0", ... */
37 };
38
39
40#ifdef __USE_MISC
41/* Standard interface flags. */
42enum
43 {
44 IFF_UP = 0x1, /* Interface is up. */
45# define IFF_UP IFF_UP
46 IFF_BROADCAST = 0x2, /* Broadcast address valid. */
47# define IFF_BROADCAST IFF_BROADCAST
48 IFF_DEBUG = 0x4, /* Turn on debugging. */
49# define IFF_DEBUG IFF_DEBUG
50 IFF_LOOPBACK = 0x8, /* Is a loopback net. */
51# define IFF_LOOPBACK IFF_LOOPBACK
52 IFF_POINTOPOINT = 0x10, /* Interface is point-to-point link. */
53# define IFF_POINTOPOINT IFF_POINTOPOINT
54 IFF_NOTRAILERS = 0x20, /* Avoid use of trailers. */
55# define IFF_NOTRAILERS IFF_NOTRAILERS
56 IFF_RUNNING = 0x40, /* Resources allocated. */
57# define IFF_RUNNING IFF_RUNNING
58 IFF_NOARP = 0x80, /* No address resolution protocol. */
59# define IFF_NOARP IFF_NOARP
60 IFF_PROMISC = 0x100, /* Receive all packets. */
61# define IFF_PROMISC IFF_PROMISC
62
63 /* Not supported */
64 IFF_ALLMULTI = 0x200, /* Receive all multicast packets. */
65# define IFF_ALLMULTI IFF_ALLMULTI
66
67 IFF_MASTER = 0x400, /* Master of a load balancer. */
68# define IFF_MASTER IFF_MASTER
69 IFF_SLAVE = 0x800, /* Slave of a load balancer. */
70# define IFF_SLAVE IFF_SLAVE
71
72 IFF_MULTICAST = 0x1000, /* Supports multicast. */
73# define IFF_MULTICAST IFF_MULTICAST
74
75 IFF_PORTSEL = 0x2000, /* Can set media type. */
76# define IFF_PORTSEL IFF_PORTSEL
77 IFF_AUTOMEDIA = 0x4000, /* Auto media select active. */
78# define IFF_AUTOMEDIA IFF_AUTOMEDIA
79 IFF_DYNAMIC = 0x8000 /* Dialup device with changing addresses. */
80# define IFF_DYNAMIC IFF_DYNAMIC
81 };
82
83/* The ifaddr structure contains information about one address of an
84 interface. They are maintained by the different address families,
85 are allocated and attached when an address is set, and are linked
86 together so all addresses for an interface can be located. */
87
88struct ifaddr
89 {
90 struct sockaddr ifa_addr; /* Address of interface. */
91 union
92 {
93 struct sockaddr ifu_broadaddr;
94 struct sockaddr ifu_dstaddr;
95 } ifa_ifu;
96 struct iface *ifa_ifp; /* Back-pointer to interface. */
97 struct ifaddr *ifa_next; /* Next address for interface. */
98 };
99
100# define ifa_broadaddr ifa_ifu.ifu_broadaddr /* broadcast address */
101# define ifa_dstaddr ifa_ifu.ifu_dstaddr /* other end of link */
102
103/* Device mapping structure. I'd just gone off and designed a
104 beautiful scheme using only loadable modules with arguments for
105 driver options and along come the PCMCIA people 8)
106
107 Ah well. The get() side of this is good for WDSETUP, and it'll be
108 handy for debugging things. The set side is fine for now and being
109 very small might be worth keeping for clean configuration. */
110
111struct ifmap
112 {
113 unsigned long int mem_start;
114 unsigned long int mem_end;
115 unsigned short int base_addr;
116 unsigned char irq;
117 unsigned char dma;
118 unsigned char port;
119 /* 3 bytes spare */
120 };
121
122/* Interface request structure used for socket ioctl's. All interface
123 ioctl's must have parameter definitions which begin with ifr_name.
124 The remainder may be interface specific. */
125
126struct ifreq
127 {
128# define IFHWADDRLEN 6
129# define IFNAMSIZ IF_NAMESIZE
130 union
131 {
132 char ifrn_name[IFNAMSIZ]; /* Interface name, e.g. "en0". */
133 } ifr_ifrn;
134
135 union
136 {
137 struct sockaddr ifru_addr;
138 struct sockaddr ifru_dstaddr;
139 struct sockaddr ifru_broadaddr;
140 struct sockaddr ifru_netmask;
141 struct sockaddr ifru_hwaddr;
142 short int ifru_flags;
143 int ifru_ivalue;
144 int ifru_mtu;
145 struct ifmap ifru_map;
146 char ifru_slave[IFNAMSIZ]; /* Just fits the size */
147 char ifru_newname[IFNAMSIZ];
148 __caddr_t ifru_data;
149 } ifr_ifru;
150 };
151# define ifr_name ifr_ifrn.ifrn_name /* interface name */
152# define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */
153# define ifr_addr ifr_ifru.ifru_addr /* address */
154# define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-p lnk */
155# define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */
156# define ifr_netmask ifr_ifru.ifru_netmask /* interface net mask */
157# define ifr_flags ifr_ifru.ifru_flags /* flags */
158# define ifr_metric ifr_ifru.ifru_ivalue /* metric */
159# define ifr_mtu ifr_ifru.ifru_mtu /* mtu */
160# define ifr_map ifr_ifru.ifru_map /* device map */
161# define ifr_slave ifr_ifru.ifru_slave /* slave device */
162# define ifr_data ifr_ifru.ifru_data /* for use by interface */
163# define ifr_ifindex ifr_ifru.ifru_ivalue /* interface index */
164# define ifr_bandwidth ifr_ifru.ifru_ivalue /* link bandwidth */
165# define ifr_qlen ifr_ifru.ifru_ivalue /* queue length */
166# define ifr_newname ifr_ifru.ifru_newname /* New name */
167# define _IOT_ifreq _IOT(_IOTS(char),IFNAMSIZ,_IOTS(char),16,0,0)
168# define _IOT_ifreq_short _IOT(_IOTS(char),IFNAMSIZ,_IOTS(short),1,0,0)
169# define _IOT_ifreq_int _IOT(_IOTS(char),IFNAMSIZ,_IOTS(int),1,0,0)
170
171
172/* Structure used in SIOCGIFCONF request. Used to retrieve interface
173 configuration for machine (useful for programs which must know all
174 networks accessible). */
175
176struct ifconf
177 {
178 int ifc_len; /* Size of buffer. */
179 union
180 {
181 __caddr_t ifcu_buf;
182 struct ifreq *ifcu_req;
183 } ifc_ifcu;
184 };
185# define ifc_buf ifc_ifcu.ifcu_buf /* Buffer address. */
186# define ifc_req ifc_ifcu.ifcu_req /* Array of structures. */
187# define _IOT_ifconf _IOT(_IOTS(struct ifconf),1,0,0,0,0) /* not right */
188#endif /* Misc. */
189
190__BEGIN_DECLS
191
192/* Convert an interface name to an index, and vice versa. */
193extern unsigned int if_nametoindex (const char *__ifname) __THROW;
194extern char *if_indextoname (unsigned int __ifindex, char *__ifname) __THROW;
195
196/* Return a list of all interfaces and their indices. */
197extern struct if_nameindex *if_nameindex (void) __THROW;
198
199/* Free the data returned from if_nameindex. */
200extern void if_freenameindex (struct if_nameindex *__ptr) __THROW;
201
202__END_DECLS
203
204#endif /* net/if.h */
libc/glibc-include/net/if_arp.h created+183
...@@ -0,0 +1,183 @@
1/* Definitions for Address Resolution Protocol.
2 Copyright (C) 1997-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
19
20/* Based on the 4.4BSD and Linux version of this file. */
21
22#ifndef _NET_IF_ARP_H
23#define _NET_IF_ARP_H 1
24
25#include <sys/types.h>
26#include <sys/socket.h>
27#include <stdint.h>
28
29__BEGIN_DECLS
30
31/* Some internals from deep down in the kernel. */
32#define MAX_ADDR_LEN 7
33
34
35/* This structure defines an ethernet arp header. */
36
37/* ARP protocol opcodes. */
38#define ARPOP_REQUEST 1 /* ARP request. */
39#define ARPOP_REPLY 2 /* ARP reply. */
40#define ARPOP_RREQUEST 3 /* RARP request. */
41#define ARPOP_RREPLY 4 /* RARP reply. */
42#define ARPOP_InREQUEST 8 /* InARP request. */
43#define ARPOP_InREPLY 9 /* InARP reply. */
44#define ARPOP_NAK 10 /* (ATM)ARP NAK. */
45
46/* See RFC 826 for protocol description. ARP packets are variable
47 in size; the arphdr structure defines the fixed-length portion.
48 Protocol type values are the same as those for 10 Mb/s Ethernet.
49 It is followed by the variable-sized fields ar_sha, arp_spa,
50 arp_tha and arp_tpa in that order, according to the lengths
51 specified. Field names used correspond to RFC 826. */
52
53struct arphdr
54 {
55 unsigned short int ar_hrd; /* Format of hardware address. */
56 unsigned short int ar_pro; /* Format of protocol address. */
57 unsigned char ar_hln; /* Length of hardware address. */
58 unsigned char ar_pln; /* Length of protocol address. */
59 unsigned short int ar_op; /* ARP opcode (command). */
60#if 0
61 /* Ethernet looks like this : This bit is variable sized
62 however... */
63 unsigned char __ar_sha[ETH_ALEN]; /* Sender hardware address. */
64 unsigned char __ar_sip[4]; /* Sender IP address. */
65 unsigned char __ar_tha[ETH_ALEN]; /* Target hardware address. */
66 unsigned char __ar_tip[4]; /* Target IP address. */
67#endif
68 };
69
70
71/* ARP protocol HARDWARE identifiers. */
72#define ARPHRD_NETROM 0 /* From KA9Q: NET/ROM pseudo. */
73#define ARPHRD_ETHER 1 /* Ethernet 10/100Mbps. */
74#define ARPHRD_EETHER 2 /* Experimental Ethernet. */
75#define ARPHRD_AX25 3 /* AX.25 Level 2. */
76#define ARPHRD_PRONET 4 /* PROnet token ring. */
77#define ARPHRD_CHAOS 5 /* Chaosnet. */
78#define ARPHRD_IEEE802 6 /* IEEE 802.2 Ethernet/TR/TB. */
79#define ARPHRD_ARCNET 7 /* ARCnet. */
80#define ARPHRD_APPLETLK 8 /* APPLEtalk. */
81#define ARPHRD_DLCI 15 /* Frame Relay DLCI. */
82#define ARPHRD_ATM 19 /* ATM. */
83#define ARPHRD_METRICOM 23 /* Metricom STRIP (new IANA id). */
84#define ARPHRD_IEEE1394 24 /* IEEE 1394 IPv4 - RFC 2734. */
85#define ARPHRD_EUI64 27 /* EUI-64. */
86#define ARPHRD_INFINIBAND 32 /* InfiniBand. */
87
88/* Dummy types for non ARP hardware */
89#define ARPHRD_SLIP 256
90#define ARPHRD_CSLIP 257
91#define ARPHRD_SLIP6 258
92#define ARPHRD_CSLIP6 259
93#define ARPHRD_RSRVD 260 /* Notional KISS type. */
94#define ARPHRD_ADAPT 264
95#define ARPHRD_ROSE 270
96#define ARPHRD_X25 271 /* CCITT X.25. */
97#define ARPHRD_HWX25 272 /* Boards with X.25 in firmware. */
98#define ARPHRD_PPP 512
99#define ARPHRD_CISCO 513 /* Cisco HDLC. */
100#define ARPHRD_HDLC ARPHRD_CISCO
101#define ARPHRD_LAPB 516 /* LAPB. */
102#define ARPHRD_DDCMP 517 /* Digital's DDCMP. */
103#define ARPHRD_RAWHDLC 518 /* Raw HDLC. */
104#define ARPHRD_RAWIP 519 /* Raw IP. */
105
106#define ARPHRD_TUNNEL 768 /* IPIP tunnel. */
107#define ARPHRD_TUNNEL6 769 /* IPIP6 tunnel. */
108#define ARPHRD_FRAD 770 /* Frame Relay Access Device. */
109#define ARPHRD_SKIP 771 /* SKIP vif. */
110#define ARPHRD_LOOPBACK 772 /* Loopback device. */
111#define ARPHRD_LOCALTLK 773 /* Localtalk device. */
112#define ARPHRD_FDDI 774 /* Fiber Distributed Data Interface. */
113#define ARPHRD_BIF 775 /* AP1000 BIF. */
114#define ARPHRD_SIT 776 /* sit0 device - IPv6-in-IPv4. */
115#define ARPHRD_IPDDP 777 /* IP-in-DDP tunnel. */
116#define ARPHRD_IPGRE 778 /* GRE over IP. */
117#define ARPHRD_PIMREG 779 /* PIMSM register interface. */
118#define ARPHRD_HIPPI 780 /* High Performance Parallel I'face. */
119#define ARPHRD_ASH 781 /* (Nexus Electronics) Ash. */
120#define ARPHRD_ECONET 782 /* Acorn Econet. */
121#define ARPHRD_IRDA 783 /* Linux-IrDA. */
122#define ARPHRD_FCPP 784 /* Point to point fibrechanel. */
123#define ARPHRD_FCAL 785 /* Fibrechanel arbitrated loop. */
124#define ARPHRD_FCPL 786 /* Fibrechanel public loop. */
125#define ARPHRD_FCFABRIC 787 /* Fibrechanel fabric. */
126#define ARPHRD_IEEE802_TR 800 /* Magic type ident for TR. */
127#define ARPHRD_IEEE80211 801 /* IEEE 802.11. */
128#define ARPHRD_IEEE80211_PRISM 802 /* IEEE 802.11 + Prism2 header. */
129#define ARPHRD_IEEE80211_RADIOTAP 803 /* IEEE 802.11 + radiotap header. */
130#define ARPHRD_IEEE802154 804 /* IEEE 802.15.4 header. */
131#define ARPHRD_IEEE802154_PHY 805 /* IEEE 802.15.4 PHY header. */
132
133#define ARPHRD_VOID 0xFFFF /* Void type, nothing is known. */
134#define ARPHRD_NONE 0xFFFE /* Zero header length. */
135
136
137/* ARP ioctl request. */
138struct arpreq
139 {
140 struct sockaddr arp_pa; /* Protocol address. */
141 struct sockaddr arp_ha; /* Hardware address. */
142 int arp_flags; /* Flags. */
143 struct sockaddr arp_netmask; /* Netmask (only for proxy arps). */
144 char arp_dev[16];
145 };
146
147struct arpreq_old
148 {
149 struct sockaddr arp_pa; /* Protocol address. */
150 struct sockaddr arp_ha; /* Hardware address. */
151 int arp_flags; /* Flags. */
152 struct sockaddr arp_netmask; /* Netmask (only for proxy arps). */
153 };
154
155/* ARP Flag values. */
156#define ATF_COM 0x02 /* Completed entry (ha valid). */
157#define ATF_PERM 0x04 /* Permanent entry. */
158#define ATF_PUBL 0x08 /* Publish entry. */
159#define ATF_USETRAILERS 0x10 /* Has requested trailers. */
160#define ATF_NETMASK 0x20 /* Want to use a netmask (only
161 for proxy entries). */
162#define ATF_DONTPUB 0x40 /* Don't answer this addresses. */
163#define ATF_MAGIC 0x80 /* Automatically added entry. */
164
165
166/* Support for the user space arp daemon, arpd. */
167#define ARPD_UPDATE 0x01
168#define ARPD_LOOKUP 0x02
169#define ARPD_FLUSH 0x03
170
171struct arpd_request
172 {
173 unsigned short int req; /* Request type. */
174 uint32_t ip; /* IP address of entry. */
175 unsigned long int dev; /* Device entry is tied to. */
176 unsigned long int stamp;
177 unsigned long int updated;
178 unsigned char ha[MAX_ADDR_LEN]; /* Hardware address. */
179 };
180
181__END_DECLS
182
183#endif /* net/if_arp.h */
libc/glibc-include/net/if_packet.h created+36
...@@ -0,0 +1,36 @@
1/* Definitions for use with Linux SOCK_PACKET sockets.
2 Copyright (C) 1997-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef __IF_PACKET_H
20#define __IF_PACKET_H
21
22#include <features.h>
23#include <bits/sockaddr.h>
24
25/* This is the SOCK_PACKET address structure as used in Linux 2.0.
26 From Linux 2.1 the AF_PACKET interface is preferred and you should
27 consider using it in place of this one. */
28
29struct sockaddr_pkt
30 {
31 __SOCKADDR_COMMON (spkt_);
32 unsigned char spkt_device[14];
33 unsigned short spkt_protocol;
34 };
35
36#endif
libc/glibc-include/net/if_ppp.h created+171
...@@ -0,0 +1,171 @@
1/* From: if_ppp.h,v 1.3 1995/06/12 11:36:50 paulus Exp */
2
3/*
4 * if_ppp.h - Point-to-Point Protocol definitions.
5 *
6 * Copyright (c) 1989 Carnegie Mellon University.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the name of the University nor the names of its contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY AND
21 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
22 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 * IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS BE LIABLE FOR ANY
25 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
27 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
29 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
31 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33 */
34
35/*
36 * ==FILEVERSION 960926==
37 *
38 * NOTE TO MAINTAINERS:
39 * If you modify this file at all, please set the above date.
40 * if_ppp.h is shipped with a PPP distribution as well as with the kernel;
41 * if everyone increases the FILEVERSION number above, then scripts
42 * can do the right thing when deciding whether to install a new if_ppp.h
43 * file. Don't change the format of that line otherwise, so the
44 * installation script can recognize it.
45 */
46
47
48#ifndef __NET_IF_PPP_H
49#define __NET_IF_PPP_H 1
50
51#include <sys/types.h>
52#include <stdint.h>
53#include <net/if.h>
54#include <sys/ioctl.h>
55#include <net/ppp_defs.h>
56
57__BEGIN_DECLS
58
59/*
60 * Packet sizes
61 */
62
63#define PPP_MTU 1500 /* Default MTU (size of Info field) */
64#define PPP_MAXMRU 65000 /* Largest MRU we allow */
65#define PPP_VERSION "2.2.0"
66#define PPP_MAGIC 0x5002 /* Magic value for the ppp structure */
67#define PROTO_IPX 0x002b /* protocol numbers */
68#define PROTO_DNA_RT 0x0027 /* DNA Routing */
69
70
71/*
72 * Bit definitions for flags.
73 */
74
75#define SC_COMP_PROT 0x00000001 /* protocol compression (output) */
76#define SC_COMP_AC 0x00000002 /* header compression (output) */
77#define SC_COMP_TCP 0x00000004 /* TCP (VJ) compression (output) */
78#define SC_NO_TCP_CCID 0x00000008 /* disable VJ connection-id comp. */
79#define SC_REJ_COMP_AC 0x00000010 /* reject adrs/ctrl comp. on input */
80#define SC_REJ_COMP_TCP 0x00000020 /* reject TCP (VJ) comp. on input */
81#define SC_CCP_OPEN 0x00000040 /* Look at CCP packets */
82#define SC_CCP_UP 0x00000080 /* May send/recv compressed packets */
83#define SC_ENABLE_IP 0x00000100 /* IP packets may be exchanged */
84#define SC_COMP_RUN 0x00001000 /* compressor has been inited */
85#define SC_DECOMP_RUN 0x00002000 /* decompressor has been inited */
86#define SC_DEBUG 0x00010000 /* enable debug messages */
87#define SC_LOG_INPKT 0x00020000 /* log contents of good pkts recvd */
88#define SC_LOG_OUTPKT 0x00040000 /* log contents of pkts sent */
89#define SC_LOG_RAWIN 0x00080000 /* log all chars received */
90#define SC_LOG_FLUSH 0x00100000 /* log all chars flushed */
91#define SC_MASK 0x0fE0ffff /* bits that user can change */
92
93/* state bits */
94#define SC_ESCAPED 0x80000000 /* saw a PPP_ESCAPE */
95#define SC_FLUSH 0x40000000 /* flush input until next PPP_FLAG */
96#define SC_VJ_RESET 0x20000000 /* Need to reset the VJ decompressor */
97#define SC_XMIT_BUSY 0x10000000 /* ppp_write_wakeup is active */
98#define SC_RCV_ODDP 0x08000000 /* have rcvd char with odd parity */
99#define SC_RCV_EVNP 0x04000000 /* have rcvd char with even parity */
100#define SC_RCV_B7_1 0x02000000 /* have rcvd char with bit 7 = 1 */
101#define SC_RCV_B7_0 0x01000000 /* have rcvd char with bit 7 = 0 */
102#define SC_DC_FERROR 0x00800000 /* fatal decomp error detected */
103#define SC_DC_ERROR 0x00400000 /* non-fatal decomp error detected */
104
105/*
106 * Ioctl definitions.
107 */
108
109struct npioctl {
110 int protocol; /* PPP protocol, e.g. PPP_IP */
111 enum NPmode mode;
112};
113
114/* Structure describing a CCP configuration option, for PPPIOCSCOMPRESS */
115struct ppp_option_data {
116 uint8_t *ptr;
117 uint32_t length;
118 int transmit;
119};
120
121/* 'struct ifreq' is only available from net/if.h under __USE_MISC. */
122#ifdef __USE_MISC
123struct ifpppstatsreq {
124 struct ifreq b;
125 struct ppp_stats stats; /* statistic information */
126};
127
128struct ifpppcstatsreq {
129 struct ifreq b;
130 struct ppp_comp_stats stats;
131};
132
133#define ifr__name b.ifr_ifrn.ifrn_name
134#define stats_ptr b.ifr_ifru.ifru_data
135#endif
136
137/*
138 * Ioctl definitions.
139 */
140
141#define PPPIOCGFLAGS _IOR('t', 90, int) /* get configuration flags */
142#define PPPIOCSFLAGS _IOW('t', 89, int) /* set configuration flags */
143#define PPPIOCGASYNCMAP _IOR('t', 88, int) /* get async map */
144#define PPPIOCSASYNCMAP _IOW('t', 87, int) /* set async map */
145#define PPPIOCGUNIT _IOR('t', 86, int) /* get ppp unit number */
146#define PPPIOCGRASYNCMAP _IOR('t', 85, int) /* get receive async map */
147#define PPPIOCSRASYNCMAP _IOW('t', 84, int) /* set receive async map */
148#define PPPIOCGMRU _IOR('t', 83, int) /* get max receive unit */
149#define PPPIOCSMRU _IOW('t', 82, int) /* set max receive unit */
150#define PPPIOCSMAXCID _IOW('t', 81, int) /* set VJ max slot ID */
151#define PPPIOCGXASYNCMAP _IOR('t', 80, ext_accm) /* get extended ACCM */
152#define PPPIOCSXASYNCMAP _IOW('t', 79, ext_accm) /* set extended ACCM */
153#define PPPIOCXFERUNIT _IO('t', 78) /* transfer PPP unit */
154#define PPPIOCSCOMPRESS _IOW('t', 77, struct ppp_option_data)
155#define PPPIOCGNPMODE _IOWR('t', 76, struct npioctl) /* get NP mode */
156#define PPPIOCSNPMODE _IOW('t', 75, struct npioctl) /* set NP mode */
157#define PPPIOCGDEBUG _IOR('t', 65, int) /* Read debug level */
158#define PPPIOCSDEBUG _IOW('t', 64, int) /* Set debug level */
159#define PPPIOCGIDLE _IOR('t', 63, struct ppp_idle) /* get idle time */
160
161#define SIOCGPPPSTATS (SIOCDEVPRIVATE + 0)
162#define SIOCGPPPVER (SIOCDEVPRIVATE + 1) /* NEVER change this!! */
163#define SIOCGPPPCSTATS (SIOCDEVPRIVATE + 2)
164
165#if !defined(ifr_mtu)
166#define ifr_mtu ifr_ifru.ifru_metric
167#endif
168
169__END_DECLS
170
171#endif /* net/if_ppp.h */
libc/glibc-include/net/if_shaper.h created+58
...@@ -0,0 +1,58 @@
1/* Copyright (C) 1998-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _NET_IF_SHAPER_H
19#define _NET_IF_SHAPER_H 1
20
21#include <sys/types.h>
22#include <stdint.h>
23#include <net/if.h>
24#include <sys/ioctl.h>
25
26__BEGIN_DECLS
27
28#define SHAPER_QLEN 10
29/*
30 * This is a bit speed dependant (read it shouldnt be a constant!)
31 *
32 * 5 is about right for 28.8 upwards. Below that double for every
33 * halving of speed or so. - ie about 20 for 9600 baud.
34 */
35#define SHAPER_LATENCY (5 * HZ)
36#define SHAPER_MAXSLIP 2
37#define SHAPER_BURST (HZ / 50) /* Good for >128K then */
38
39#define SHAPER_SET_DEV 0x0001
40#define SHAPER_SET_SPEED 0x0002
41#define SHAPER_GET_DEV 0x0003
42#define SHAPER_GET_SPEED 0x0004
43
44struct shaperconf
45{
46 uint16_t ss_cmd;
47 union
48 {
49 char ssu_name[14];
50 uint32_t ssu_speed;
51 } ss_u;
52#define ss_speed ss_u.ssu_speed
53#define ss_name ss_u.ssu_name
54};
55
56__END_DECLS
57
58#endif /* net/if_shaper.h */
libc/glibc-include/net/if_slip.h created+24
...@@ -0,0 +1,24 @@
1/* Copyright (C) 1997-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _NET_IF_SLIP_H
19#define _NET_IF_SLIP_H 1
20
21/* We can use the kernel header. */
22#include <linux/if_slip.h>
23
24#endif /* net/if_slip.h. */
libc/glibc-include/net/ppp-comp.h created+1
...@@ -0,0 +1 @@
1#include <linux/ppp-comp.h>
libc/glibc-include/net/ppp_defs.h created+8
...@@ -0,0 +1,8 @@
1#ifndef _NET_PPP_DEFS_H
2#define _NET_PPP_DEFS_H 1
3
4#include <bits/types/time_t.h>
5#include <asm/types.h>
6#include <linux/ppp_defs.h>
7
8#endif /* net/ppp_defs.h */
libc/glibc-include/net/route.h created+144
...@@ -0,0 +1,144 @@
1/* Copyright (C) 1997-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/* Based on the 4.4BSD and Linux version of this file. */
19
20#ifndef _NET_ROUTE_H
21#define _NET_ROUTE_H 1
22
23#include <features.h>
24#include <sys/socket.h>
25#include <sys/types.h>
26#include <netinet/in.h>
27#include <bits/wordsize.h>
28
29
30/* This structure gets passed by the SIOCADDRT and SIOCDELRT calls. */
31struct rtentry
32 {
33 unsigned long int rt_pad1;
34 struct sockaddr rt_dst; /* Target address. */
35 struct sockaddr rt_gateway; /* Gateway addr (RTF_GATEWAY). */
36 struct sockaddr rt_genmask; /* Target network mask (IP). */
37 unsigned short int rt_flags;
38 short int rt_pad2;
39 unsigned long int rt_pad3;
40 unsigned char rt_tos;
41 unsigned char rt_class;
42#if __WORDSIZE == 64
43 short int rt_pad4[3];
44#else
45 short int rt_pad4;
46#endif
47 short int rt_metric; /* +1 for binary compatibility! */
48 char *rt_dev; /* Forcing the device at add. */
49 unsigned long int rt_mtu; /* Per route MTU/Window. */
50 unsigned long int rt_window; /* Window clamping. */
51 unsigned short int rt_irtt; /* Initial RTT. */
52 };
53/* Compatibility hack. */
54#define rt_mss rt_mtu
55
56
57struct in6_rtmsg
58 {
59 struct in6_addr rtmsg_dst;
60 struct in6_addr rtmsg_src;
61 struct in6_addr rtmsg_gateway;
62 uint32_t rtmsg_type;
63 uint16_t rtmsg_dst_len;
64 uint16_t rtmsg_src_len;
65 uint32_t rtmsg_metric;
66 unsigned long int rtmsg_info;
67 uint32_t rtmsg_flags;
68 int rtmsg_ifindex;
69 };
70
71
72#define RTF_UP 0x0001 /* Route usable. */
73#define RTF_GATEWAY 0x0002 /* Destination is a gateway. */
74
75#define RTF_HOST 0x0004 /* Host entry (net otherwise). */
76#define RTF_REINSTATE 0x0008 /* Reinstate route after timeout. */
77#define RTF_DYNAMIC 0x0010 /* Created dyn. (by redirect). */
78#define RTF_MODIFIED 0x0020 /* Modified dyn. (by redirect). */
79#define RTF_MTU 0x0040 /* Specific MTU for this route. */
80#define RTF_MSS RTF_MTU /* Compatibility. */
81#define RTF_WINDOW 0x0080 /* Per route window clamping. */
82#define RTF_IRTT 0x0100 /* Initial round trip time. */
83#define RTF_REJECT 0x0200 /* Reject route. */
84#define RTF_STATIC 0x0400 /* Manually injected route. */
85#define RTF_XRESOLVE 0x0800 /* External resolver. */
86#define RTF_NOFORWARD 0x1000 /* Forwarding inhibited. */
87#define RTF_THROW 0x2000 /* Go to next class. */
88#define RTF_NOPMTUDISC 0x4000 /* Do not send packets with DF. */
89
90/* for IPv6 */
91#define RTF_DEFAULT 0x00010000 /* default - learned via ND */
92#define RTF_ALLONLINK 0x00020000 /* fallback, no routers on link */
93#define RTF_ADDRCONF 0x00040000 /* addrconf route - RA */
94
95#define RTF_LINKRT 0x00100000 /* link specific - device match */
96#define RTF_NONEXTHOP 0x00200000 /* route with no nexthop */
97
98#define RTF_CACHE 0x01000000 /* cache entry */
99#define RTF_FLOW 0x02000000 /* flow significant route */
100#define RTF_POLICY 0x04000000 /* policy route */
101
102#define RTCF_VALVE 0x00200000
103#define RTCF_MASQ 0x00400000
104#define RTCF_NAT 0x00800000
105#define RTCF_DOREDIRECT 0x01000000
106#define RTCF_LOG 0x02000000
107#define RTCF_DIRECTSRC 0x04000000
108
109#define RTF_LOCAL 0x80000000
110#define RTF_INTERFACE 0x40000000
111#define RTF_MULTICAST 0x20000000
112#define RTF_BROADCAST 0x10000000
113#define RTF_NAT 0x08000000
114
115#define RTF_ADDRCLASSMASK 0xF8000000
116#define RT_ADDRCLASS(flags) ((uint32_t) flags >> 23)
117
118#define RT_TOS(tos) ((tos) & IPTOS_TOS_MASK)
119
120#define RT_LOCALADDR(flags) ((flags & RTF_ADDRCLASSMASK) \
121 == (RTF_LOCAL|RTF_INTERFACE))
122
123#define RT_CLASS_UNSPEC 0
124#define RT_CLASS_DEFAULT 253
125
126#define RT_CLASS_MAIN 254
127#define RT_CLASS_LOCAL 255
128#define RT_CLASS_MAX 255
129
130
131#define RTMSG_ACK NLMSG_ACK
132#define RTMSG_OVERRUN NLMSG_OVERRUN
133
134#define RTMSG_NEWDEVICE 0x11
135#define RTMSG_DELDEVICE 0x12
136#define RTMSG_NEWROUTE 0x21
137#define RTMSG_DELROUTE 0x22
138#define RTMSG_NEWRULE 0x31
139#define RTMSG_DELRULE 0x32
140#define RTMSG_CONTROL 0x40
141
142#define RTMSG_AR_FAILED 0x51 /* Address Resolution failed. */
143
144#endif /* net/route.h */
libc/glibc-include/netash/ash.h created+39
...@@ -0,0 +1,39 @@
1/* Definitions for use with Linux AF_ASH sockets.
2 Copyright (C) 1998-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _NETASH_ASH_H
20#define _NETASH_ASH_H 1
21
22#include <features.h>
23#include <bits/sockaddr.h>
24
25struct sockaddr_ash
26 {
27 __SOCKADDR_COMMON (sash_); /* Common data: address family etc. */
28 int sash_ifindex; /* Interface to use. */
29 unsigned char sash_channel; /* Realtime or control. */
30 unsigned int sash_plen;
31 unsigned char sash_prefix[16];
32 };
33
34/* Values for `channel' member. */
35#define ASH_CHANNEL_ANY 0
36#define ASH_CHANNEL_CONTROL 1
37#define ASH_CHANNEL_REALTIME 2
38
39#endif /* netash/ash.h */
libc/glibc-include/netatalk/at.h created+28
...@@ -0,0 +1,28 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _NETATALK_AT_H
19#define _NETATALK_AT_H 1
20
21#include <asm/types.h>
22#include <bits/sockaddr.h>
23#include <linux/atalk.h>
24#include <sys/socket.h>
25
26#define SOL_ATALK 258 /* sockopt level for atalk */
27
28#endif /* netatalk/at.h */
libc/glibc-include/netax25/ax25.h created+170
...@@ -0,0 +1,170 @@
1/* Copyright (C) 1997-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _NETAX25_AX25_H
19#define _NETAX25_AX25_H 1
20
21#include <features.h>
22#include <bits/sockaddr.h>
23
24/* Setsockoptions(2) level. Thanks to BSD these must match IPPROTO_xxx. */
25#define SOL_AX25 257
26
27/* AX.25 flags: */
28#define AX25_WINDOW 1
29#define AX25_T1 2
30#define AX25_T2 5
31#define AX25_T3 4
32#define AX25_N2 3
33#define AX25_BACKOFF 6
34#define AX25_EXTSEQ 7
35#define AX25_PIDINCL 8
36#define AX25_IDLE 9
37#define AX25_PACLEN 10
38#define AX25_IPMAXQUEUE 11
39#define AX25_IAMDIGI 12
40#define AX25_KILL 99
41
42/* AX.25 socket ioctls: */
43#define SIOCAX25GETUID (SIOCPROTOPRIVATE)
44#define SIOCAX25ADDUID (SIOCPROTOPRIVATE+1)
45#define SIOCAX25DELUID (SIOCPROTOPRIVATE+2)
46#define SIOCAX25NOUID (SIOCPROTOPRIVATE+3)
47#define SIOCAX25BPQADDR (SIOCPROTOPRIVATE+4)
48#define SIOCAX25GETPARMS (SIOCPROTOPRIVATE+5)
49#define SIOCAX25SETPARMS (SIOCPROTOPRIVATE+6)
50#define SIOCAX25OPTRT (SIOCPROTOPRIVATE+7)
51#define SIOCAX25CTLCON (SIOCPROTOPRIVATE+8)
52#define SIOCAX25GETINFO (SIOCPROTOPRIVATE+9)
53#define SIOCAX25ADDFWD (SIOCPROTOPRIVATE+10)
54#define SIOCAX25DELFWD (SIOCPROTOPRIVATE+11)
55
56/* unknown: */
57#define AX25_NOUID_DEFAULT 0
58#define AX25_NOUID_BLOCK 1
59#define AX25_SET_RT_IPMODE 2
60
61/* Digipeating flags: */
62#define AX25_DIGI_INBAND 0x01 /* Allow digipeating within port */
63#define AX25_DIGI_XBAND 0x02 /* Allow digipeating across ports */
64
65/* Maximim number of digipeaters: */
66#define AX25_MAX_DIGIS 8
67
68
69typedef struct
70 {
71 char ax25_call[7]; /* 6 call + SSID (shifted ascii) */
72 }
73ax25_address;
74
75struct sockaddr_ax25
76 {
77 sa_family_t sax25_family;
78 ax25_address sax25_call;
79 int sax25_ndigis;
80 };
81
82/*
83 * The sockaddr struct with the digipeater adresses:
84 */
85struct full_sockaddr_ax25
86 {
87 struct sockaddr_ax25 fsa_ax25;
88 ax25_address fsa_digipeater[AX25_MAX_DIGIS];
89 };
90#define sax25_uid sax25_ndigis
91
92struct ax25_routes_struct
93 {
94 ax25_address port_addr;
95 ax25_address dest_addr;
96 unsigned char digi_count;
97 ax25_address digi_addr[AX25_MAX_DIGIS];
98 };
99
100/* The AX.25 ioctl structure: */
101struct ax25_ctl_struct
102 {
103 ax25_address port_addr;
104 ax25_address source_addr;
105 ax25_address dest_addr;
106 unsigned int cmd;
107 unsigned long arg;
108 unsigned char digi_count;
109 ax25_address digi_addr[AX25_MAX_DIGIS];
110 };
111
112struct ax25_info_struct
113 {
114 unsigned int n2, n2count;
115 unsigned int t1, t1timer;
116 unsigned int t2, t2timer;
117 unsigned int t3, t3timer;
118 unsigned int idle, idletimer;
119 unsigned int state;
120 unsigned int rcv_q, snd_q;
121 };
122
123struct ax25_fwd_struct
124 {
125 ax25_address port_from;
126 ax25_address port_to;
127 };
128
129/* AX.25 route structure: */
130struct ax25_route_opt_struct
131 {
132 ax25_address port_addr;
133 ax25_address dest_addr;
134 int cmd;
135 int arg;
136 };
137
138/* AX.25 BPQ stuff: */
139struct ax25_bpqaddr_struct
140 {
141 char dev[16];
142 ax25_address addr;
143 };
144
145/* Definitions for the AX.25 `values' fields: */
146#define AX25_VALUES_IPDEFMODE 0 /* 'D'=DG 'V'=VC */
147#define AX25_VALUES_AXDEFMODE 1 /* 8=Normal 128=Extended Seq Nos */
148#define AX25_VALUES_NETROM 2 /* Allow NET/ROM - 0=No 1=Yes */
149#define AX25_VALUES_TEXT 3 /* Allow PID=Text - 0=No 1=Yes */
150#define AX25_VALUES_BACKOFF 4 /* 'E'=Exponential 'L'=Linear */
151#define AX25_VALUES_CONMODE 5 /* Allow connected modes - 0=No 1=Yes */
152#define AX25_VALUES_WINDOW 6 /* Default window size for standard AX.25 */
153#define AX25_VALUES_EWINDOW 7 /* Default window size for extended AX.25 */
154#define AX25_VALUES_T1 8 /* Default T1 timeout value */
155#define AX25_VALUES_T2 9 /* Default T2 timeout value */
156#define AX25_VALUES_T3 10 /* Default T3 timeout value */
157#define AX25_VALUES_N2 11 /* Default N2 value */
158#define AX25_VALUES_DIGI 12 /* Digipeat mode */
159#define AX25_VALUES_IDLE 13 /* mode vc idle timer */
160#define AX25_VALUES_PACLEN 14 /* AX.25 MTU */
161#define AX25_VALUES_IPMAXQUEUE 15 /* Maximum number of buffers enqueued */
162#define AX25_MAX_VALUES 20
163
164struct ax25_parms_struct
165 {
166 ax25_address port_addr;
167 unsigned short values[AX25_MAX_VALUES];
168 };
169
170#endif /* netax25/ax25.h */
libc/glibc-include/netdb.h created+713
...@@ -0,0 +1,713 @@
1 /* Copyright (C) 1996-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/* All data returned by the network data base library are supplied in
19 host order and returned in network order (suitable for use in
20 system calls). */
21
22#ifndef _NETDB_H
23#define _NETDB_H 1
24
25#include <features.h>
26
27#include <netinet/in.h>
28#include <bits/stdint-uintn.h>
29#ifdef __USE_MISC
30/* This is necessary to make this include file properly replace the
31 Sun version. */
32# include <rpc/netdb.h>
33#endif
34
35#ifdef __USE_GNU
36# include <bits/types/sigevent_t.h>
37# include <bits/types/struct_timespec.h>
38#endif
39
40#include <bits/netdb.h>
41
42/* Absolute file name for network data base files. */
43#define _PATH_HEQUIV "/etc/hosts.equiv"
44#define _PATH_HOSTS "/etc/hosts"
45#define _PATH_NETWORKS "/etc/networks"
46#define _PATH_NSSWITCH_CONF "/etc/nsswitch.conf"
47#define _PATH_PROTOCOLS "/etc/protocols"
48#define _PATH_SERVICES "/etc/services"
49
50
51__BEGIN_DECLS
52
53#if defined __USE_MISC || !defined __USE_XOPEN2K8
54/* Error status for non-reentrant lookup functions.
55 We use a macro to access always the thread-specific `h_errno' variable. */
56# define h_errno (*__h_errno_location ())
57
58/* Function to get address of global `h_errno' variable. */
59extern int *__h_errno_location (void) __THROW __attribute__ ((__const__));
60
61
62/* Possible values left in `h_errno'. */
63# define HOST_NOT_FOUND 1 /* Authoritative Answer Host not found. */
64# define TRY_AGAIN 2 /* Non-Authoritative Host not found,
65 or SERVERFAIL. */
66# define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED,
67 NOTIMP. */
68# define NO_DATA 4 /* Valid name, no data record of requested
69 type. */
70#endif
71#ifdef __USE_MISC
72# define NETDB_INTERNAL -1 /* See errno. */
73# define NETDB_SUCCESS 0 /* No problem. */
74# define NO_ADDRESS NO_DATA /* No address, look for MX record. */
75#endif
76
77#if defined __USE_XOPEN2K || defined __USE_XOPEN_EXTENDED
78/* Highest reserved Internet port number. */
79# define IPPORT_RESERVED 1024
80#endif
81
82#ifdef __USE_GNU
83/* Scope delimiter for getaddrinfo(), getnameinfo(). */
84# define SCOPE_DELIMITER '%'
85#endif
86
87#ifdef __USE_MISC
88/* Print error indicated by `h_errno' variable on standard error. STR
89 if non-null is printed before the error string. */
90extern void herror (const char *__str) __THROW;
91
92/* Return string associated with error ERR_NUM. */
93extern const char *hstrerror (int __err_num) __THROW;
94#endif
95
96
97/* Description of data base entry for a single host. */
98struct hostent
99{
100 char *h_name; /* Official name of host. */
101 char **h_aliases; /* Alias list. */
102 int h_addrtype; /* Host address type. */
103 int h_length; /* Length of address. */
104 char **h_addr_list; /* List of addresses from name server. */
105#ifdef __USE_MISC
106# define h_addr h_addr_list[0] /* Address, for backward compatibility.*/
107#endif
108};
109
110/* Open host data base files and mark them as staying open even after
111 a later search if STAY_OPEN is non-zero.
112
113 This function is a possible cancellation point and therefore not
114 marked with __THROW. */
115extern void sethostent (int __stay_open);
116
117/* Close host data base files and clear `stay open' flag.
118
119 This function is a possible cancellation point and therefore not
120 marked with __THROW. */
121extern void endhostent (void);
122
123/* Get next entry from host data base file. Open data base if
124 necessary.
125
126 This function is a possible cancellation point and therefore not
127 marked with __THROW. */
128extern struct hostent *gethostent (void);
129
130/* Return entry from host data base which address match ADDR with
131 length LEN and type TYPE.
132
133 This function is a possible cancellation point and therefore not
134 marked with __THROW. */
135extern struct hostent *gethostbyaddr (const void *__addr, __socklen_t __len,
136 int __type);
137
138/* Return entry from host data base for host with NAME.
139
140 This function is a possible cancellation point and therefore not
141 marked with __THROW. */
142extern struct hostent *gethostbyname (const char *__name);
143
144#ifdef __USE_MISC
145/* Return entry from host data base for host with NAME. AF must be
146 set to the address type which is `AF_INET' for IPv4 or `AF_INET6'
147 for IPv6.
148
149 This function is not part of POSIX and therefore no official
150 cancellation point. But due to similarity with an POSIX interface
151 or due to the implementation it is a cancellation point and
152 therefore not marked with __THROW. */
153extern struct hostent *gethostbyname2 (const char *__name, int __af);
154
155/* Reentrant versions of the functions above. The additional
156 arguments specify a buffer of BUFLEN starting at BUF. The last
157 argument is a pointer to a variable which gets the value which
158 would be stored in the global variable `herrno' by the
159 non-reentrant functions.
160
161 These functions are not part of POSIX and therefore no official
162 cancellation point. But due to similarity with an POSIX interface
163 or due to the implementation they are cancellation points and
164 therefore not marked with __THROW. */
165extern int gethostent_r (struct hostent *__restrict __result_buf,
166 char *__restrict __buf, size_t __buflen,
167 struct hostent **__restrict __result,
168 int *__restrict __h_errnop);
169
170extern int gethostbyaddr_r (const void *__restrict __addr, __socklen_t __len,
171 int __type,
172 struct hostent *__restrict __result_buf,
173 char *__restrict __buf, size_t __buflen,
174 struct hostent **__restrict __result,
175 int *__restrict __h_errnop);
176
177extern int gethostbyname_r (const char *__restrict __name,
178 struct hostent *__restrict __result_buf,
179 char *__restrict __buf, size_t __buflen,
180 struct hostent **__restrict __result,
181 int *__restrict __h_errnop);
182
183extern int gethostbyname2_r (const char *__restrict __name, int __af,
184 struct hostent *__restrict __result_buf,
185 char *__restrict __buf, size_t __buflen,
186 struct hostent **__restrict __result,
187 int *__restrict __h_errnop);
188#endif /* misc */
189
190
191/* Open network data base files and mark them as staying open even
192 after a later search if STAY_OPEN is non-zero.
193
194 This function is a possible cancellation point and therefore not
195 marked with __THROW. */
196extern void setnetent (int __stay_open);
197
198/* Close network data base files and clear `stay open' flag.
199
200 This function is a possible cancellation point and therefore not
201 marked with __THROW. */
202extern void endnetent (void);
203
204/* Get next entry from network data base file. Open data base if
205 necessary.
206
207 This function is a possible cancellation point and therefore not
208 marked with __THROW. */
209extern struct netent *getnetent (void);
210
211/* Return entry from network data base which address match NET and
212 type TYPE.
213
214 This function is a possible cancellation point and therefore not
215 marked with __THROW. */
216extern struct netent *getnetbyaddr (uint32_t __net, int __type);
217
218/* Return entry from network data base for network with NAME.
219
220 This function is a possible cancellation point and therefore not
221 marked with __THROW. */
222extern struct netent *getnetbyname (const char *__name);
223
224#ifdef __USE_MISC
225/* Reentrant versions of the functions above. The additional
226 arguments specify a buffer of BUFLEN starting at BUF. The last
227 argument is a pointer to a variable which gets the value which
228 would be stored in the global variable `herrno' by the
229 non-reentrant functions.
230
231 These functions are not part of POSIX and therefore no official
232 cancellation point. But due to similarity with an POSIX interface
233 or due to the implementation they are cancellation points and
234 therefore not marked with __THROW. */
235extern int getnetent_r (struct netent *__restrict __result_buf,
236 char *__restrict __buf, size_t __buflen,
237 struct netent **__restrict __result,
238 int *__restrict __h_errnop);
239
240extern int getnetbyaddr_r (uint32_t __net, int __type,
241 struct netent *__restrict __result_buf,
242 char *__restrict __buf, size_t __buflen,
243 struct netent **__restrict __result,
244 int *__restrict __h_errnop);
245
246extern int getnetbyname_r (const char *__restrict __name,
247 struct netent *__restrict __result_buf,
248 char *__restrict __buf, size_t __buflen,
249 struct netent **__restrict __result,
250 int *__restrict __h_errnop);
251#endif /* misc */
252
253
254/* Description of data base entry for a single service. */
255struct servent
256{
257 char *s_name; /* Official service name. */
258 char **s_aliases; /* Alias list. */
259 int s_port; /* Port number. */
260 char *s_proto; /* Protocol to use. */
261};
262
263/* Open service data base files and mark them as staying open even
264 after a later search if STAY_OPEN is non-zero.
265
266 This function is a possible cancellation point and therefore not
267 marked with __THROW. */
268extern void setservent (int __stay_open);
269
270/* Close service data base files and clear `stay open' flag.
271
272 This function is a possible cancellation point and therefore not
273 marked with __THROW. */
274extern void endservent (void);
275
276/* Get next entry from service data base file. Open data base if
277 necessary.
278
279 This function is a possible cancellation point and therefore not
280 marked with __THROW. */
281extern struct servent *getservent (void);
282
283/* Return entry from network data base for network with NAME and
284 protocol PROTO.
285
286 This function is a possible cancellation point and therefore not
287 marked with __THROW. */
288extern struct servent *getservbyname (const char *__name, const char *__proto);
289
290/* Return entry from service data base which matches port PORT and
291 protocol PROTO.
292
293 This function is a possible cancellation point and therefore not
294 marked with __THROW. */
295extern struct servent *getservbyport (int __port, const char *__proto);
296
297
298#ifdef __USE_MISC
299/* Reentrant versions of the functions above. The additional
300 arguments specify a buffer of BUFLEN starting at BUF.
301
302 These functions are not part of POSIX and therefore no official
303 cancellation point. But due to similarity with an POSIX interface
304 or due to the implementation they are cancellation points and
305 therefore not marked with __THROW. */
306extern int getservent_r (struct servent *__restrict __result_buf,
307 char *__restrict __buf, size_t __buflen,
308 struct servent **__restrict __result);
309
310extern int getservbyname_r (const char *__restrict __name,
311 const char *__restrict __proto,
312 struct servent *__restrict __result_buf,
313 char *__restrict __buf, size_t __buflen,
314 struct servent **__restrict __result);
315
316extern int getservbyport_r (int __port, const char *__restrict __proto,
317 struct servent *__restrict __result_buf,
318 char *__restrict __buf, size_t __buflen,
319 struct servent **__restrict __result);
320#endif /* misc */
321
322
323/* Description of data base entry for a single service. */
324struct protoent
325{
326 char *p_name; /* Official protocol name. */
327 char **p_aliases; /* Alias list. */
328 int p_proto; /* Protocol number. */
329};
330
331/* Open protocol data base files and mark them as staying open even
332 after a later search if STAY_OPEN is non-zero.
333
334 This function is a possible cancellation point and therefore not
335 marked with __THROW. */
336extern void setprotoent (int __stay_open);
337
338/* Close protocol data base files and clear `stay open' flag.
339
340 This function is a possible cancellation point and therefore not
341 marked with __THROW. */
342extern void endprotoent (void);
343
344/* Get next entry from protocol data base file. Open data base if
345 necessary.
346
347 This function is a possible cancellation point and therefore not
348 marked with __THROW. */
349extern struct protoent *getprotoent (void);
350
351/* Return entry from protocol data base for network with NAME.
352
353 This function is a possible cancellation point and therefore not
354 marked with __THROW. */
355extern struct protoent *getprotobyname (const char *__name);
356
357/* Return entry from protocol data base which number is PROTO.
358
359 This function is a possible cancellation point and therefore not
360 marked with __THROW. */
361extern struct protoent *getprotobynumber (int __proto);
362
363
364#ifdef __USE_MISC
365/* Reentrant versions of the functions above. The additional
366 arguments specify a buffer of BUFLEN starting at BUF.
367
368 These functions are not part of POSIX and therefore no official
369 cancellation point. But due to similarity with an POSIX interface
370 or due to the implementation they are cancellation points and
371 therefore not marked with __THROW. */
372extern int getprotoent_r (struct protoent *__restrict __result_buf,
373 char *__restrict __buf, size_t __buflen,
374 struct protoent **__restrict __result);
375
376extern int getprotobyname_r (const char *__restrict __name,
377 struct protoent *__restrict __result_buf,
378 char *__restrict __buf, size_t __buflen,
379 struct protoent **__restrict __result);
380
381extern int getprotobynumber_r (int __proto,
382 struct protoent *__restrict __result_buf,
383 char *__restrict __buf, size_t __buflen,
384 struct protoent **__restrict __result);
385
386
387/* Establish network group NETGROUP for enumeration.
388
389 This function is not part of POSIX and therefore no official
390 cancellation point. But due to similarity with an POSIX interface
391 or due to the implementation it is a cancellation point and
392 therefore not marked with __THROW. */
393extern int setnetgrent (const char *__netgroup);
394
395/* Free all space allocated by previous `setnetgrent' call.
396
397 This function is not part of POSIX and therefore no official
398 cancellation point. But due to similarity with an POSIX interface
399 or due to the implementation it is a cancellation point and
400 therefore not marked with __THROW. */
401extern void endnetgrent (void);
402
403/* Get next member of netgroup established by last `setnetgrent' call
404 and return pointers to elements in HOSTP, USERP, and DOMAINP.
405
406 This function is not part of POSIX and therefore no official
407 cancellation point. But due to similarity with an POSIX interface
408 or due to the implementation it is a cancellation point and
409 therefore not marked with __THROW. */
410extern int getnetgrent (char **__restrict __hostp,
411 char **__restrict __userp,
412 char **__restrict __domainp);
413
414
415/* Test whether NETGROUP contains the triple (HOST,USER,DOMAIN).
416
417 This function is not part of POSIX and therefore no official
418 cancellation point. But due to similarity with an POSIX interface
419 or due to the implementation it is a cancellation point and
420 therefore not marked with __THROW. */
421extern int innetgr (const char *__netgroup, const char *__host,
422 const char *__user, const char *__domain);
423
424/* Reentrant version of `getnetgrent' where result is placed in BUFFER.
425
426 This function is not part of POSIX and therefore no official
427 cancellation point. But due to similarity with an POSIX interface
428 or due to the implementation it is a cancellation point and
429 therefore not marked with __THROW. */
430extern int getnetgrent_r (char **__restrict __hostp,
431 char **__restrict __userp,
432 char **__restrict __domainp,
433 char *__restrict __buffer, size_t __buflen);
434#endif /* misc */
435
436
437#ifdef __USE_MISC
438/* Call `rshd' at port RPORT on remote machine *AHOST to execute CMD.
439 The local user is LOCUSER, on the remote machine the command is
440 executed as REMUSER. In *FD2P the descriptor to the socket for the
441 connection is returned. The caller must have the right to use a
442 reserved port. When the function returns *AHOST contains the
443 official host name.
444
445 This function is not part of POSIX and therefore no official
446 cancellation point. But due to similarity with an POSIX interface
447 or due to the implementation it is a cancellation point and
448 therefore not marked with __THROW. */
449extern int rcmd (char **__restrict __ahost, unsigned short int __rport,
450 const char *__restrict __locuser,
451 const char *__restrict __remuser,
452 const char *__restrict __cmd, int *__restrict __fd2p);
453
454/* This is the equivalent function where the protocol can be selected
455 and which therefore can be used for IPv6.
456
457 This function is not part of POSIX and therefore no official
458 cancellation point. But due to similarity with an POSIX interface
459 or due to the implementation it is a cancellation point and
460 therefore not marked with __THROW. */
461extern int rcmd_af (char **__restrict __ahost, unsigned short int __rport,
462 const char *__restrict __locuser,
463 const char *__restrict __remuser,
464 const char *__restrict __cmd, int *__restrict __fd2p,
465 sa_family_t __af);
466
467/* Call `rexecd' at port RPORT on remote machine *AHOST to execute
468 CMD. The process runs at the remote machine using the ID of user
469 NAME whose cleartext password is PASSWD. In *FD2P the descriptor
470 to the socket for the connection is returned. When the function
471 returns *AHOST contains the official host name.
472
473 This function is not part of POSIX and therefore no official
474 cancellation point. But due to similarity with an POSIX interface
475 or due to the implementation it is a cancellation point and
476 therefore not marked with __THROW. */
477extern int rexec (char **__restrict __ahost, int __rport,
478 const char *__restrict __name,
479 const char *__restrict __pass,
480 const char *__restrict __cmd, int *__restrict __fd2p);
481
482/* This is the equivalent function where the protocol can be selected
483 and which therefore can be used for IPv6.
484
485 This function is not part of POSIX and therefore no official
486 cancellation point. But due to similarity with an POSIX interface
487 or due to the implementation it is a cancellation point and
488 therefore not marked with __THROW. */
489extern int rexec_af (char **__restrict __ahost, int __rport,
490 const char *__restrict __name,
491 const char *__restrict __pass,
492 const char *__restrict __cmd, int *__restrict __fd2p,
493 sa_family_t __af);
494
495/* Check whether user REMUSER on system RHOST is allowed to login as LOCUSER.
496 If SUSER is not zero the user tries to become superuser. Return 0 if
497 it is possible.
498
499 This function is not part of POSIX and therefore no official
500 cancellation point. But due to similarity with an POSIX interface
501 or due to the implementation it is a cancellation point and
502 therefore not marked with __THROW. */
503extern int ruserok (const char *__rhost, int __suser,
504 const char *__remuser, const char *__locuser);
505
506/* This is the equivalent function where the protocol can be selected
507 and which therefore can be used for IPv6.
508
509 This function is not part of POSIX and therefore no official
510 cancellation point. But due to similarity with an POSIX interface
511 or due to the implementation it is a cancellation point and
512 therefore not marked with __THROW. */
513extern int ruserok_af (const char *__rhost, int __suser,
514 const char *__remuser, const char *__locuser,
515 sa_family_t __af);
516
517/* Check whether user REMUSER on system indicated by IPv4 address
518 RADDR is allowed to login as LOCUSER. Non-IPv4 (e.g., IPv6) are
519 not supported. If SUSER is not zero the user tries to become
520 superuser. Return 0 if it is possible.
521
522 This function is not part of POSIX and therefore no official
523 cancellation point. But due to similarity with an POSIX interface
524 or due to the implementation it is a cancellation point and
525 therefore not marked with __THROW. */
526extern int iruserok (uint32_t __raddr, int __suser,
527 const char *__remuser, const char *__locuser);
528
529/* This is the equivalent function where the pfamiliy if the address
530 pointed to by RADDR is determined by the value of AF. It therefore
531 can be used for IPv6
532
533 This function is not part of POSIX and therefore no official
534 cancellation point. But due to similarity with an POSIX interface
535 or due to the implementation it is a cancellation point and
536 therefore not marked with __THROW. */
537extern int iruserok_af (const void *__raddr, int __suser,
538 const char *__remuser, const char *__locuser,
539 sa_family_t __af);
540
541/* Try to allocate reserved port, returning a descriptor for a socket opened
542 at this port or -1 if unsuccessful. The search for an available port
543 will start at ALPORT and continues with lower numbers.
544
545 This function is not part of POSIX and therefore no official
546 cancellation point. But due to similarity with an POSIX interface
547 or due to the implementation it is a cancellation point and
548 therefore not marked with __THROW. */
549extern int rresvport (int *__alport);
550
551/* This is the equivalent function where the protocol can be selected
552 and which therefore can be used for IPv6.
553
554 This function is not part of POSIX and therefore no official
555 cancellation point. But due to similarity with an POSIX interface
556 or due to the implementation it is a cancellation point and
557 therefore not marked with __THROW. */
558extern int rresvport_af (int *__alport, sa_family_t __af);
559#endif
560
561
562/* Extension from POSIX.1:2001. */
563#ifdef __USE_XOPEN2K
564/* Structure to contain information about address of a service provider. */
565struct addrinfo
566{
567 int ai_flags; /* Input flags. */
568 int ai_family; /* Protocol family for socket. */
569 int ai_socktype; /* Socket type. */
570 int ai_protocol; /* Protocol for socket. */
571 socklen_t ai_addrlen; /* Length of socket address. */
572 struct sockaddr *ai_addr; /* Socket address for socket. */
573 char *ai_canonname; /* Canonical name for service location. */
574 struct addrinfo *ai_next; /* Pointer to next in list. */
575};
576
577# ifdef __USE_GNU
578/* Structure used as control block for asynchronous lookup. */
579struct gaicb
580{
581 const char *ar_name; /* Name to look up. */
582 const char *ar_service; /* Service name. */
583 const struct addrinfo *ar_request; /* Additional request specification. */
584 struct addrinfo *ar_result; /* Pointer to result. */
585 /* The following are internal elements. */
586 int __return;
587 int __glibc_reserved[5];
588};
589
590/* Lookup mode. */
591# define GAI_WAIT 0
592# define GAI_NOWAIT 1
593# endif
594
595/* Possible values for `ai_flags' field in `addrinfo' structure. */
596# define AI_PASSIVE 0x0001 /* Socket address is intended for `bind'. */
597# define AI_CANONNAME 0x0002 /* Request for canonical name. */
598# define AI_NUMERICHOST 0x0004 /* Don't use name resolution. */
599# define AI_V4MAPPED 0x0008 /* IPv4 mapped addresses are acceptable. */
600# define AI_ALL 0x0010 /* Return IPv4 mapped and IPv6 addresses. */
601# define AI_ADDRCONFIG 0x0020 /* Use configuration of this host to choose
602 returned address type.. */
603# ifdef __USE_GNU
604# define AI_IDN 0x0040 /* IDN encode input (assuming it is encoded
605 in the current locale's character set)
606 before looking it up. */
607# define AI_CANONIDN 0x0080 /* Translate canonical name from IDN format. */
608# define AI_IDN_ALLOW_UNASSIGNED \
609 __glibc_macro_warning ("AI_IDN_ALLOW_UNASSIGNED is deprecated") 0x0100
610# define AI_IDN_USE_STD3_ASCII_RULES \
611 __glibc_macro_warning ("AI_IDN_USE_STD3_ASCII_RULES is deprecated") 0x0200
612# endif
613# define AI_NUMERICSERV 0x0400 /* Don't use name resolution. */
614
615/* Error values for `getaddrinfo' function. */
616# define EAI_BADFLAGS -1 /* Invalid value for `ai_flags' field. */
617# define EAI_NONAME -2 /* NAME or SERVICE is unknown. */
618# define EAI_AGAIN -3 /* Temporary failure in name resolution. */
619# define EAI_FAIL -4 /* Non-recoverable failure in name res. */
620# define EAI_FAMILY -6 /* `ai_family' not supported. */
621# define EAI_SOCKTYPE -7 /* `ai_socktype' not supported. */
622# define EAI_SERVICE -8 /* SERVICE not supported for `ai_socktype'. */
623# define EAI_MEMORY -10 /* Memory allocation failure. */
624# define EAI_SYSTEM -11 /* System error returned in `errno'. */
625# define EAI_OVERFLOW -12 /* Argument buffer overflow. */
626# ifdef __USE_GNU
627# define EAI_NODATA -5 /* No address associated with NAME. */
628# define EAI_ADDRFAMILY -9 /* Address family for NAME not supported. */
629# define EAI_INPROGRESS -100 /* Processing request in progress. */
630# define EAI_CANCELED -101 /* Request canceled. */
631# define EAI_NOTCANCELED -102 /* Request not canceled. */
632# define EAI_ALLDONE -103 /* All requests done. */
633# define EAI_INTR -104 /* Interrupted by a signal. */
634# define EAI_IDN_ENCODE -105 /* IDN encoding failed. */
635# endif
636
637# ifdef __USE_MISC
638# define NI_MAXHOST 1025
639# define NI_MAXSERV 32
640# endif
641
642# define NI_NUMERICHOST 1 /* Don't try to look up hostname. */
643# define NI_NUMERICSERV 2 /* Don't convert port number to name. */
644# define NI_NOFQDN 4 /* Only return nodename portion. */
645# define NI_NAMEREQD 8 /* Don't return numeric addresses. */
646# define NI_DGRAM 16 /* Look up UDP service rather than TCP. */
647# ifdef __USE_GNU
648# define NI_IDN 32 /* Convert name from IDN format. */
649# define NI_IDN_ALLOW_UNASSIGNED \
650 __glibc_macro_warning ("NI_IDN_ALLOW_UNASSIGNED is deprecated") 64
651# define NI_IDN_USE_STD3_ASCII_RULES \
652 __glibc_macro_warning ("NI_IDN_USE_STD3_ASCII_RULES is deprecated") 128
653# endif
654
655/* Translate name of a service location and/or a service name to set of
656 socket addresses.
657
658 This function is a possible cancellation point and therefore not
659 marked with __THROW. */
660extern int getaddrinfo (const char *__restrict __name,
661 const char *__restrict __service,
662 const struct addrinfo *__restrict __req,
663 struct addrinfo **__restrict __pai);
664
665/* Free `addrinfo' structure AI including associated storage. */
666extern void freeaddrinfo (struct addrinfo *__ai) __THROW;
667
668/* Convert error return from getaddrinfo() to a string. */
669extern const char *gai_strerror (int __ecode) __THROW;
670
671/* Translate a socket address to a location and service name.
672
673 This function is a possible cancellation point and therefore not
674 marked with __THROW. */
675extern int getnameinfo (const struct sockaddr *__restrict __sa,
676 socklen_t __salen, char *__restrict __host,
677 socklen_t __hostlen, char *__restrict __serv,
678 socklen_t __servlen, int __flags);
679#endif /* POSIX */
680
681#ifdef __USE_GNU
682/* Enqueue ENT requests from the LIST. If MODE is GAI_WAIT wait until all
683 requests are handled. If WAIT is GAI_NOWAIT return immediately after
684 queueing the requests and signal completion according to SIG.
685
686 This function is not part of POSIX and therefore no official
687 cancellation point. But due to similarity with an POSIX interface
688 or due to the implementation it is a cancellation point and
689 therefore not marked with __THROW. */
690extern int getaddrinfo_a (int __mode, struct gaicb *__list[__restrict_arr],
691 int __ent, struct sigevent *__restrict __sig);
692
693/* Suspend execution of the thread until at least one of the ENT requests
694 in LIST is handled. If TIMEOUT is not a null pointer it specifies the
695 longest time the function keeps waiting before returning with an error.
696
697 This function is not part of POSIX and therefore no official
698 cancellation point. But due to similarity with an POSIX interface
699 or due to the implementation it is a cancellation point and
700 therefore not marked with __THROW. */
701extern int gai_suspend (const struct gaicb *const __list[], int __ent,
702 const struct timespec *__timeout);
703
704/* Get the error status of the request REQ. */
705extern int gai_error (struct gaicb *__req) __THROW;
706
707/* Cancel the requests associated with GAICBP. */
708extern int gai_cancel (struct gaicb *__gaicbp) __THROW;
709#endif /* GNU */
710
711__END_DECLS
712
713#endif /* netdb.h */
libc/glibc-include/neteconet/ec.h created+51
...@@ -0,0 +1,51 @@
1/* Definitions for use with Linux AF_ECONET sockets.
2 Copyright (C) 1998-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _NETECONET_EC_H
20#define _NETECONET_EC_H 1
21
22#include <features.h>
23#include <bits/sockaddr.h>
24
25struct ec_addr
26 {
27 unsigned char station; /* Station number. */
28 unsigned char net; /* Network number. */
29 };
30
31struct sockaddr_ec
32 {
33 __SOCKADDR_COMMON (sec_);
34 unsigned char port; /* Port number. */
35 unsigned char cb; /* Control/flag byte. */
36 unsigned char type; /* Type of message. */
37 struct ec_addr addr;
38 unsigned long cookie;
39 };
40
41#define ECTYPE_PACKET_RECEIVED 0 /* Packet received */
42#define ECTYPE_TRANSMIT_STATUS 0x10 /* Transmit completed */
43
44#define ECTYPE_TRANSMIT_OK 1
45#define ECTYPE_TRANSMIT_NOT_LISTENING 2
46#define ECTYPE_TRANSMIT_NET_ERROR 3
47#define ECTYPE_TRANSMIT_NO_CLOCK 4
48#define ECTYPE_TRANSMIT_LINE_JAMMED 5
49#define ECTYPE_TRANSMIT_NOT_PRESENT 6
50
51#endif
libc/glibc-include/netinet/ether.h created+55
...@@ -0,0 +1,55 @@
1/* Functions for storing Ethernet addresses in ASCII and mapping to hostnames.
2 Copyright (C) 1996-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _NETINET_ETHER_H
20#define _NETINET_ETHER_H 1
21
22#include <features.h>
23
24/* Get definition of `struct ether_addr'. */
25#include <netinet/if_ether.h>
26
27#ifdef __USE_MISC
28__BEGIN_DECLS
29
30/* Convert 48 bit Ethernet ADDRess to ASCII. */
31extern char *ether_ntoa (const struct ether_addr *__addr) __THROW;
32extern char *ether_ntoa_r (const struct ether_addr *__addr, char *__buf)
33 __THROW;
34
35/* Convert ASCII string S to 48 bit Ethernet address. */
36extern struct ether_addr *ether_aton (const char *__asc) __THROW;
37extern struct ether_addr *ether_aton_r (const char *__asc,
38 struct ether_addr *__addr) __THROW;
39
40/* Map 48 bit Ethernet number ADDR to HOSTNAME. */
41extern int ether_ntohost (char *__hostname, const struct ether_addr *__addr)
42 __THROW;
43
44/* Map HOSTNAME to 48 bit Ethernet address. */
45extern int ether_hostton (const char *__hostname, struct ether_addr *__addr)
46 __THROW;
47
48/* Scan LINE and set ADDR and HOSTNAME. */
49extern int ether_line (const char *__line, struct ether_addr *__addr,
50 char *__hostname) __THROW;
51
52__END_DECLS
53#endif /* Use misc. */
54
55#endif /* netinet/ether.h */
libc/glibc-include/netinet/icmp6.h created+345
...@@ -0,0 +1,345 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _NETINET_ICMP6_H
19#define _NETINET_ICMP6_H 1
20
21#include <inttypes.h>
22#include <string.h>
23#include <sys/types.h>
24#include <netinet/in.h>
25
26#define ICMP6_FILTER 1
27
28#define ICMP6_FILTER_BLOCK 1
29#define ICMP6_FILTER_PASS 2
30#define ICMP6_FILTER_BLOCKOTHERS 3
31#define ICMP6_FILTER_PASSONLY 4
32
33struct icmp6_filter
34 {
35 uint32_t icmp6_filt[8];
36 };
37
38struct icmp6_hdr
39 {
40 uint8_t icmp6_type; /* type field */
41 uint8_t icmp6_code; /* code field */
42 uint16_t icmp6_cksum; /* checksum field */
43 union
44 {
45 uint32_t icmp6_un_data32[1]; /* type-specific field */
46 uint16_t icmp6_un_data16[2]; /* type-specific field */
47 uint8_t icmp6_un_data8[4]; /* type-specific field */
48 } icmp6_dataun;
49 };
50
51#define icmp6_data32 icmp6_dataun.icmp6_un_data32
52#define icmp6_data16 icmp6_dataun.icmp6_un_data16
53#define icmp6_data8 icmp6_dataun.icmp6_un_data8
54#define icmp6_pptr icmp6_data32[0] /* parameter prob */
55#define icmp6_mtu icmp6_data32[0] /* packet too big */
56#define icmp6_id icmp6_data16[0] /* echo request/reply */
57#define icmp6_seq icmp6_data16[1] /* echo request/reply */
58#define icmp6_maxdelay icmp6_data16[0] /* mcast group membership */
59
60#define ICMP6_DST_UNREACH 1
61#define ICMP6_PACKET_TOO_BIG 2
62#define ICMP6_TIME_EXCEEDED 3
63#define ICMP6_PARAM_PROB 4
64
65#define ICMP6_INFOMSG_MASK 0x80 /* all informational messages */
66
67#define ICMP6_ECHO_REQUEST 128
68#define ICMP6_ECHO_REPLY 129
69#define MLD_LISTENER_QUERY 130
70#define MLD_LISTENER_REPORT 131
71#define MLD_LISTENER_REDUCTION 132
72
73#define ICMP6_DST_UNREACH_NOROUTE 0 /* no route to destination */
74#define ICMP6_DST_UNREACH_ADMIN 1 /* communication with destination */
75 /* administratively prohibited */
76#define ICMP6_DST_UNREACH_BEYONDSCOPE 2 /* beyond scope of source address */
77#define ICMP6_DST_UNREACH_ADDR 3 /* address unreachable */
78#define ICMP6_DST_UNREACH_NOPORT 4 /* bad port */
79
80#define ICMP6_TIME_EXCEED_TRANSIT 0 /* Hop Limit == 0 in transit */
81#define ICMP6_TIME_EXCEED_REASSEMBLY 1 /* Reassembly time out */
82
83#define ICMP6_PARAMPROB_HEADER 0 /* erroneous header field */
84#define ICMP6_PARAMPROB_NEXTHEADER 1 /* unrecognized Next Header */
85#define ICMP6_PARAMPROB_OPTION 2 /* unrecognized IPv6 option */
86
87#define ICMP6_FILTER_WILLPASS(type, filterp) \
88 ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) == 0)
89
90#define ICMP6_FILTER_WILLBLOCK(type, filterp) \
91 ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) != 0)
92
93#define ICMP6_FILTER_SETPASS(type, filterp) \
94 ((((filterp)->icmp6_filt[(type) >> 5]) &= ~(1 << ((type) & 31))))
95
96#define ICMP6_FILTER_SETBLOCK(type, filterp) \
97 ((((filterp)->icmp6_filt[(type) >> 5]) |= (1 << ((type) & 31))))
98
99#define ICMP6_FILTER_SETPASSALL(filterp) \
100 memset (filterp, 0, sizeof (struct icmp6_filter));
101
102#define ICMP6_FILTER_SETBLOCKALL(filterp) \
103 memset (filterp, 0xFF, sizeof (struct icmp6_filter));
104
105#define ND_ROUTER_SOLICIT 133
106#define ND_ROUTER_ADVERT 134
107#define ND_NEIGHBOR_SOLICIT 135
108#define ND_NEIGHBOR_ADVERT 136
109#define ND_REDIRECT 137
110
111struct nd_router_solicit /* router solicitation */
112 {
113 struct icmp6_hdr nd_rs_hdr;
114 /* could be followed by options */
115 };
116
117#define nd_rs_type nd_rs_hdr.icmp6_type
118#define nd_rs_code nd_rs_hdr.icmp6_code
119#define nd_rs_cksum nd_rs_hdr.icmp6_cksum
120#define nd_rs_reserved nd_rs_hdr.icmp6_data32[0]
121
122struct nd_router_advert /* router advertisement */
123 {
124 struct icmp6_hdr nd_ra_hdr;
125 uint32_t nd_ra_reachable; /* reachable time */
126 uint32_t nd_ra_retransmit; /* retransmit timer */
127 /* could be followed by options */
128 };
129
130#define nd_ra_type nd_ra_hdr.icmp6_type
131#define nd_ra_code nd_ra_hdr.icmp6_code
132#define nd_ra_cksum nd_ra_hdr.icmp6_cksum
133#define nd_ra_curhoplimit nd_ra_hdr.icmp6_data8[0]
134#define nd_ra_flags_reserved nd_ra_hdr.icmp6_data8[1]
135#define ND_RA_FLAG_MANAGED 0x80
136#define ND_RA_FLAG_OTHER 0x40
137#define ND_RA_FLAG_HOME_AGENT 0x20
138#define nd_ra_router_lifetime nd_ra_hdr.icmp6_data16[1]
139
140struct nd_neighbor_solicit /* neighbor solicitation */
141 {
142 struct icmp6_hdr nd_ns_hdr;
143 struct in6_addr nd_ns_target; /* target address */
144 /* could be followed by options */
145 };
146
147#define nd_ns_type nd_ns_hdr.icmp6_type
148#define nd_ns_code nd_ns_hdr.icmp6_code
149#define nd_ns_cksum nd_ns_hdr.icmp6_cksum
150#define nd_ns_reserved nd_ns_hdr.icmp6_data32[0]
151
152struct nd_neighbor_advert /* neighbor advertisement */
153 {
154 struct icmp6_hdr nd_na_hdr;
155 struct in6_addr nd_na_target; /* target address */
156 /* could be followed by options */
157 };
158
159#define nd_na_type nd_na_hdr.icmp6_type
160#define nd_na_code nd_na_hdr.icmp6_code
161#define nd_na_cksum nd_na_hdr.icmp6_cksum
162#define nd_na_flags_reserved nd_na_hdr.icmp6_data32[0]
163#if __BYTE_ORDER == __BIG_ENDIAN
164#define ND_NA_FLAG_ROUTER 0x80000000
165#define ND_NA_FLAG_SOLICITED 0x40000000
166#define ND_NA_FLAG_OVERRIDE 0x20000000
167#else /* __BYTE_ORDER == __LITTLE_ENDIAN */
168#define ND_NA_FLAG_ROUTER 0x00000080
169#define ND_NA_FLAG_SOLICITED 0x00000040
170#define ND_NA_FLAG_OVERRIDE 0x00000020
171#endif
172
173struct nd_redirect /* redirect */
174 {
175 struct icmp6_hdr nd_rd_hdr;
176 struct in6_addr nd_rd_target; /* target address */
177 struct in6_addr nd_rd_dst; /* destination address */
178 /* could be followed by options */
179 };
180
181#define nd_rd_type nd_rd_hdr.icmp6_type
182#define nd_rd_code nd_rd_hdr.icmp6_code
183#define nd_rd_cksum nd_rd_hdr.icmp6_cksum
184#define nd_rd_reserved nd_rd_hdr.icmp6_data32[0]
185
186struct nd_opt_hdr /* Neighbor discovery option header */
187 {
188 uint8_t nd_opt_type;
189 uint8_t nd_opt_len; /* in units of 8 octets */
190 /* followed by option specific data */
191 };
192
193#define ND_OPT_SOURCE_LINKADDR 1
194#define ND_OPT_TARGET_LINKADDR 2
195#define ND_OPT_PREFIX_INFORMATION 3
196#define ND_OPT_REDIRECTED_HEADER 4
197#define ND_OPT_MTU 5
198#define ND_OPT_RTR_ADV_INTERVAL 7
199#define ND_OPT_HOME_AGENT_INFO 8
200
201struct nd_opt_prefix_info /* prefix information */
202 {
203 uint8_t nd_opt_pi_type;
204 uint8_t nd_opt_pi_len;
205 uint8_t nd_opt_pi_prefix_len;
206 uint8_t nd_opt_pi_flags_reserved;
207 uint32_t nd_opt_pi_valid_time;
208 uint32_t nd_opt_pi_preferred_time;
209 uint32_t nd_opt_pi_reserved2;
210 struct in6_addr nd_opt_pi_prefix;
211 };
212
213#define ND_OPT_PI_FLAG_ONLINK 0x80
214#define ND_OPT_PI_FLAG_AUTO 0x40
215#define ND_OPT_PI_FLAG_RADDR 0x20
216
217struct nd_opt_rd_hdr /* redirected header */
218 {
219 uint8_t nd_opt_rh_type;
220 uint8_t nd_opt_rh_len;
221 uint16_t nd_opt_rh_reserved1;
222 uint32_t nd_opt_rh_reserved2;
223 /* followed by IP header and data */
224 };
225
226struct nd_opt_mtu /* MTU option */
227 {
228 uint8_t nd_opt_mtu_type;
229 uint8_t nd_opt_mtu_len;
230 uint16_t nd_opt_mtu_reserved;
231 uint32_t nd_opt_mtu_mtu;
232 };
233
234struct mld_hdr
235 {
236 struct icmp6_hdr mld_icmp6_hdr;
237 struct in6_addr mld_addr; /* multicast address */
238 };
239
240#define mld_type mld_icmp6_hdr.icmp6_type
241#define mld_code mld_icmp6_hdr.icmp6_code
242#define mld_cksum mld_icmp6_hdr.icmp6_cksum
243#define mld_maxdelay mld_icmp6_hdr.icmp6_data16[0]
244#define mld_reserved mld_icmp6_hdr.icmp6_data16[1]
245
246#define ICMP6_ROUTER_RENUMBERING 138
247
248struct icmp6_router_renum /* router renumbering header */
249 {
250 struct icmp6_hdr rr_hdr;
251 uint8_t rr_segnum;
252 uint8_t rr_flags;
253 uint16_t rr_maxdelay;
254 uint32_t rr_reserved;
255 };
256
257#define rr_type rr_hdr.icmp6_type
258#define rr_code rr_hdr.icmp6_code
259#define rr_cksum rr_hdr.icmp6_cksum
260#define rr_seqnum rr_hdr.icmp6_data32[0]
261
262/* Router renumbering flags */
263#define ICMP6_RR_FLAGS_TEST 0x80
264#define ICMP6_RR_FLAGS_REQRESULT 0x40
265#define ICMP6_RR_FLAGS_FORCEAPPLY 0x20
266#define ICMP6_RR_FLAGS_SPECSITE 0x10
267#define ICMP6_RR_FLAGS_PREVDONE 0x08
268
269struct rr_pco_match /* match prefix part */
270 {
271 uint8_t rpm_code;
272 uint8_t rpm_len;
273 uint8_t rpm_ordinal;
274 uint8_t rpm_matchlen;
275 uint8_t rpm_minlen;
276 uint8_t rpm_maxlen;
277 uint16_t rpm_reserved;
278 struct in6_addr rpm_prefix;
279 };
280
281/* PCO code values */
282#define RPM_PCO_ADD 1
283#define RPM_PCO_CHANGE 2
284#define RPM_PCO_SETGLOBAL 3
285
286struct rr_pco_use /* use prefix part */
287 {
288 uint8_t rpu_uselen;
289 uint8_t rpu_keeplen;
290 uint8_t rpu_ramask;
291 uint8_t rpu_raflags;
292 uint32_t rpu_vltime;
293 uint32_t rpu_pltime;
294 uint32_t rpu_flags;
295 struct in6_addr rpu_prefix;
296 };
297
298#define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK 0x20
299#define ICMP6_RR_PCOUSE_RAFLAGS_AUTO 0x10
300
301#if __BYTE_ORDER == __BIG_ENDIAN
302# define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80000000
303# define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40000000
304#elif __BYTE_ORDER == __LITTLE_ENDIAN
305# define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80
306# define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40
307#endif
308
309struct rr_result /* router renumbering result message */
310 {
311 uint16_t rrr_flags;
312 uint8_t rrr_ordinal;
313 uint8_t rrr_matchedlen;
314 uint32_t rrr_ifid;
315 struct in6_addr rrr_prefix;
316 };
317
318#if __BYTE_ORDER == __BIG_ENDIAN
319# define ICMP6_RR_RESULT_FLAGS_OOB 0x0002
320# define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0001
321#elif __BYTE_ORDER == __LITTLE_ENDIAN
322# define ICMP6_RR_RESULT_FLAGS_OOB 0x0200
323# define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0100
324#endif
325
326/* Mobile IPv6 extension: Advertisement Interval. */
327struct nd_opt_adv_interval
328 {
329 uint8_t nd_opt_adv_interval_type;
330 uint8_t nd_opt_adv_interval_len;
331 uint16_t nd_opt_adv_interval_reserved;
332 uint32_t nd_opt_adv_interval_ival;
333 };
334
335/* Mobile IPv6 extension: Home Agent Info. */
336struct nd_opt_home_agent_info
337 {
338 uint8_t nd_opt_home_agent_info_type;
339 uint8_t nd_opt_home_agent_info_len;
340 uint16_t nd_opt_home_agent_info_reserved;
341 uint16_t nd_opt_home_agent_info_preference;
342 uint16_t nd_opt_home_agent_info_lifetime;
343 };
344
345#endif /* netinet/icmpv6.h */
libc/glibc-include/netinet/if_ether.h created+104
...@@ -0,0 +1,104 @@
1/* Copyright (C) 1996-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef __NETINET_IF_ETHER_H
19
20#define __NETINET_IF_ETHER_H 1
21#include <features.h>
22#include <sys/types.h>
23
24/* Get definitions from kernel header file. */
25#include <linux/if_ether.h>
26
27#ifdef __USE_MISC
28/*
29 * Copyright (c) 1982, 1986, 1993
30 * The Regents of the University of California. All rights reserved.
31 *
32 * Redistribution and use in source and binary forms, with or without
33 * modification, are permitted provided that the following conditions
34 * are met:
35 * 1. Redistributions of source code must retain the above copyright
36 * notice, this list of conditions and the following disclaimer.
37 * 2. Redistributions in binary form must reproduce the above copyright
38 * notice, this list of conditions and the following disclaimer in the
39 * documentation and/or other materials provided with the distribution.
40 * 4. Neither the name of the University nor the names of its contributors
41 * may be used to endorse or promote products derived from this software
42 * without specific prior written permission.
43 *
44 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
45 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
46 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
47 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
48 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
49 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
50 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
51 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
52 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
53 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
54 * SUCH DAMAGE.
55 *
56 * @(#)if_ether.h 8.3 (Berkeley) 5/2/95
57 * $FreeBSD$
58 */
59
60#include <net/ethernet.h>
61#include <net/if_arp.h>
62
63__BEGIN_DECLS
64/*
65 * Ethernet Address Resolution Protocol.
66 *
67 * See RFC 826 for protocol description. Structure below is adapted
68 * to resolving internet addresses. Field names used correspond to
69 * RFC 826.
70 */
71struct ether_arp {
72 struct arphdr ea_hdr; /* fixed-size header */
73 uint8_t arp_sha[ETH_ALEN]; /* sender hardware address */
74 uint8_t arp_spa[4]; /* sender protocol address */
75 uint8_t arp_tha[ETH_ALEN]; /* target hardware address */
76 uint8_t arp_tpa[4]; /* target protocol address */
77};
78#define arp_hrd ea_hdr.ar_hrd
79#define arp_pro ea_hdr.ar_pro
80#define arp_hln ea_hdr.ar_hln
81#define arp_pln ea_hdr.ar_pln
82#define arp_op ea_hdr.ar_op
83
84/*
85 * Macro to map an IP multicast address to an Ethernet multicast address.
86 * The high-order 25 bits of the Ethernet address are statically assigned,
87 * and the low-order 23 bits are taken from the low end of the IP address.
88 */
89#define ETHER_MAP_IP_MULTICAST(ipaddr, enaddr) \
90 /* struct in_addr *ipaddr; */ \
91 /* uint8_t enaddr[ETH_ALEN]; */ \
92{ \
93 (enaddr)[0] = 0x01; \
94 (enaddr)[1] = 0x00; \
95 (enaddr)[2] = 0x5e; \
96 (enaddr)[3] = ((uint8_t *)ipaddr)[1] & 0x7f; \
97 (enaddr)[4] = ((uint8_t *)ipaddr)[2]; \
98 (enaddr)[5] = ((uint8_t *)ipaddr)[3]; \
99}
100
101__END_DECLS
102#endif /* __USE_MISC */
103
104#endif /* netinet/if_ether.h */
libc/glibc-include/netinet/if_fddi.h created+34
...@@ -0,0 +1,34 @@
1/* Copyright (C) 1997-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _NETINET_IF_FDDI_H
19#define _NETINET_IF_FDDI_H 1
20
21#include <sys/types.h>
22#include <stdint.h>
23#include <linux/if_fddi.h>
24
25#ifdef __USE_MISC
26
27struct fddi_header {
28 uint8_t fddi_fc; /* Frame Control (FC) value */
29 uint8_t fddi_dhost[FDDI_K_ALEN]; /* Destination host */
30 uint8_t fddi_shost[FDDI_K_ALEN]; /* Source host */
31};
32#endif
33
34#endif /* netinet/if_fddi.h */
libc/glibc-include/netinet/if_tr.h created+110
...@@ -0,0 +1,110 @@
1/* Copyright (C) 1997-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _NETINET_IF_TR_H
19#define _NETINET_IF_TR_H 1
20
21#include <sys/types.h>
22#include <stdint.h>
23
24/* IEEE 802.5 Token-Ring magic constants. The frame sizes omit the preamble
25 and FCS/CRC (frame check sequence). */
26#define TR_ALEN 6 /* Octets in one token-ring addr */
27#define TR_HLEN (sizeof (struct trh_hdr) + sizeof (struct trllc))
28#define AC 0x10
29#define LLC_FRAME 0x40
30
31/* LLC and SNAP constants */
32#define EXTENDED_SAP 0xAA
33#define UI_CMD 0x03
34
35/* This is an Token-Ring frame header. */
36struct trh_hdr
37{
38 uint8_t ac; /* access control field */
39 uint8_t fc; /* frame control field */
40 uint8_t daddr[TR_ALEN]; /* destination address */
41 uint8_t saddr[TR_ALEN]; /* source address */
42 uint16_t rcf; /* route control field */
43 uint16_t rseg[8]; /* routing registers */
44};
45
46/* This is an Token-Ring LLC structure */
47struct trllc
48{
49 uint8_t dsap; /* destination SAP */
50 uint8_t ssap; /* source SAP */
51 uint8_t llc; /* LLC control field */
52 uint8_t protid[3]; /* protocol id */
53 uint16_t ethertype; /* ether type field */
54};
55
56/* Token-Ring statistics collection data. */
57struct tr_statistics
58{
59 unsigned long rx_packets; /* total packets received */
60 unsigned long tx_packets; /* total packets transmitted */
61 unsigned long rx_bytes; /* total bytes received */
62 unsigned long tx_bytes; /* total bytes transmitted */
63 unsigned long rx_errors; /* bad packets received */
64 unsigned long tx_errors; /* packet transmit problems */
65 unsigned long rx_dropped; /* no space in linux buffers */
66 unsigned long tx_dropped; /* no space available in linux */
67 unsigned long multicast; /* multicast packets received */
68 unsigned long transmit_collision;
69
70 /* detailed Token-Ring errors. See IBM Token-Ring Network
71 Architecture for more info */
72
73 unsigned long line_errors;
74 unsigned long internal_errors;
75 unsigned long burst_errors;
76 unsigned long A_C_errors;
77 unsigned long abort_delimiters;
78 unsigned long lost_frames;
79 unsigned long recv_congest_count;
80 unsigned long frame_copied_errors;
81 unsigned long frequency_errors;
82 unsigned long token_errors;
83 unsigned long dummy1;
84};
85
86/* source routing stuff */
87#define TR_RII 0x80
88#define TR_RCF_DIR_BIT 0x80
89#define TR_RCF_LEN_MASK 0x1f00
90#define TR_RCF_BROADCAST 0x8000 /* all-routes broadcast */
91#define TR_RCF_LIMITED_BROADCAST 0xC000 /* single-route broadcast */
92#define TR_RCF_FRAME2K 0x20
93#define TR_RCF_BROADCAST_MASK 0xC000
94#define TR_MAXRIFLEN 18
95
96#ifdef __USE_MISC
97
98struct trn_hdr
99{
100 uint8_t trn_ac; /* access control field */
101 uint8_t trn_fc; /* field control field */
102 uint8_t trn_dhost[TR_ALEN]; /* destination host */
103 uint8_t trn_shost[TR_ALEN]; /* source host */
104 uint16_t trn_rcf; /* route control field */
105 uint16_t trn_rseg[8]; /* routing registers */
106};
107
108#endif
109
110#endif /* netinet/if_tr.h */
libc/glibc-include/netinet/igmp.h created+125
...@@ -0,0 +1,125 @@
1/* Copyright (C) 1997-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _NETINET_IGMP_H
19#define _NETINET_IGMP_H 1
20
21#include <sys/cdefs.h>
22#include <sys/types.h>
23
24#ifdef __USE_MISC
25
26#include <netinet/in.h>
27
28__BEGIN_DECLS
29
30/*
31 * Copyright (c) 1988 Stephen Deering.
32 * Copyright (c) 1992, 1993
33 * The Regents of the University of California. All rights reserved.
34 *
35 * This code is derived from software contributed to Berkeley by
36 * Stephen Deering of Stanford University.
37 *
38 * Redistribution and use in source and binary forms, with or without
39 * modification, are permitted provided that the following conditions
40 * are met:
41 * 1. Redistributions of source code must retain the above copyright
42 * notice, this list of conditions and the following disclaimer.
43 * 2. Redistributions in binary form must reproduce the above copyright
44 * notice, this list of conditions and the following disclaimer in the
45 * documentation and/or other materials provided with the distribution.
46 * 4. Neither the name of the University nor the names of its contributors
47 * may be used to endorse or promote products derived from this software
48 * without specific prior written permission.
49 *
50 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
51 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
52 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
53 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
54 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
55 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
56 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
57 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
58 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
59 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
60 * SUCH DAMAGE.
61 *
62 * @(#)igmp.h 8.1 (Berkeley) 6/10/93
63 * $FreeBSD$
64 */
65
66struct igmp {
67 uint8_t igmp_type; /* IGMP type */
68 uint8_t igmp_code; /* routing code */
69 uint16_t igmp_cksum; /* checksum */
70 struct in_addr igmp_group; /* group address */
71};
72
73#define IGMP_MINLEN 8
74
75/*
76 * Message types, including version number.
77 */
78#define IGMP_MEMBERSHIP_QUERY 0x11 /* membership query */
79#define IGMP_V1_MEMBERSHIP_REPORT 0x12 /* Ver. 1 membership report */
80#define IGMP_V2_MEMBERSHIP_REPORT 0x16 /* Ver. 2 membership report */
81#define IGMP_V2_LEAVE_GROUP 0x17 /* Leave-group message */
82
83#define IGMP_DVMRP 0x13 /* DVMRP routing message */
84#define IGMP_PIM 0x14 /* PIM routing message */
85#define IGMP_TRACE 0x15
86
87#define IGMP_MTRACE_RESP 0x1e /* traceroute resp.(to sender)*/
88#define IGMP_MTRACE 0x1f /* mcast traceroute messages */
89
90#define IGMP_MAX_HOST_REPORT_DELAY 10 /* max delay for response to */
91 /* query (in seconds) according */
92 /* to RFC1112 */
93#define IGMP_TIMER_SCALE 10 /* denotes that the igmp code field */
94 /* specifies time in 10th of seconds*/
95
96/*
97 * States for the IGMP v2 state table.
98 */
99#define IGMP_DELAYING_MEMBER 1
100#define IGMP_IDLE_MEMBER 2
101#define IGMP_LAZY_MEMBER 3
102#define IGMP_SLEEPING_MEMBER 4
103#define IGMP_AWAKENING_MEMBER 5
104
105/*
106 * States for IGMP router version cache.
107 */
108#define IGMP_v1_ROUTER 1
109#define IGMP_v2_ROUTER 2
110
111/*
112 * The following four defininitions are for backwards compatibility.
113 * They should be removed as soon as all applications are updated to
114 * use the new constant names.
115 */
116#define IGMP_HOST_MEMBERSHIP_QUERY IGMP_MEMBERSHIP_QUERY
117#define IGMP_HOST_MEMBERSHIP_REPORT IGMP_V1_MEMBERSHIP_REPORT
118#define IGMP_HOST_NEW_MEMBERSHIP_REPORT IGMP_V2_MEMBERSHIP_REPORT
119#define IGMP_HOST_LEAVE_MESSAGE IGMP_V2_LEAVE_GROUP
120
121__END_DECLS
122
123#endif
124
125#endif /* netinet/igmp.h */
libc/glibc-include/netinet/in.h created+632
...@@ -0,0 +1,632 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _NETINET_IN_H
19#define _NETINET_IN_H 1
20
21#include <features.h>
22#include <bits/stdint-uintn.h>
23#include <sys/socket.h>
24#include <bits/types.h>
25
26
27__BEGIN_DECLS
28
29/* Internet address. */
30typedef uint32_t in_addr_t;
31struct in_addr
32 {
33 in_addr_t s_addr;
34 };
35
36/* Get system-specific definitions. */
37#include <bits/in.h>
38
39/* Standard well-defined IP protocols. */
40enum
41 {
42 IPPROTO_IP = 0, /* Dummy protocol for TCP. */
43#define IPPROTO_IP IPPROTO_IP
44 IPPROTO_ICMP = 1, /* Internet Control Message Protocol. */
45#define IPPROTO_ICMP IPPROTO_ICMP
46 IPPROTO_IGMP = 2, /* Internet Group Management Protocol. */
47#define IPPROTO_IGMP IPPROTO_IGMP
48 IPPROTO_IPIP = 4, /* IPIP tunnels (older KA9Q tunnels use 94). */
49#define IPPROTO_IPIP IPPROTO_IPIP
50 IPPROTO_TCP = 6, /* Transmission Control Protocol. */
51#define IPPROTO_TCP IPPROTO_TCP
52 IPPROTO_EGP = 8, /* Exterior Gateway Protocol. */
53#define IPPROTO_EGP IPPROTO_EGP
54 IPPROTO_PUP = 12, /* PUP protocol. */
55#define IPPROTO_PUP IPPROTO_PUP
56 IPPROTO_UDP = 17, /* User Datagram Protocol. */
57#define IPPROTO_UDP IPPROTO_UDP
58 IPPROTO_IDP = 22, /* XNS IDP protocol. */
59#define IPPROTO_IDP IPPROTO_IDP
60 IPPROTO_TP = 29, /* SO Transport Protocol Class 4. */
61#define IPPROTO_TP IPPROTO_TP
62 IPPROTO_DCCP = 33, /* Datagram Congestion Control Protocol. */
63#define IPPROTO_DCCP IPPROTO_DCCP
64 IPPROTO_IPV6 = 41, /* IPv6 header. */
65#define IPPROTO_IPV6 IPPROTO_IPV6
66 IPPROTO_RSVP = 46, /* Reservation Protocol. */
67#define IPPROTO_RSVP IPPROTO_RSVP
68 IPPROTO_GRE = 47, /* General Routing Encapsulation. */
69#define IPPROTO_GRE IPPROTO_GRE
70 IPPROTO_ESP = 50, /* encapsulating security payload. */
71#define IPPROTO_ESP IPPROTO_ESP
72 IPPROTO_AH = 51, /* authentication header. */
73#define IPPROTO_AH IPPROTO_AH
74 IPPROTO_MTP = 92, /* Multicast Transport Protocol. */
75#define IPPROTO_MTP IPPROTO_MTP
76 IPPROTO_BEETPH = 94, /* IP option pseudo header for BEET. */
77#define IPPROTO_BEETPH IPPROTO_BEETPH
78 IPPROTO_ENCAP = 98, /* Encapsulation Header. */
79#define IPPROTO_ENCAP IPPROTO_ENCAP
80 IPPROTO_PIM = 103, /* Protocol Independent Multicast. */
81#define IPPROTO_PIM IPPROTO_PIM
82 IPPROTO_COMP = 108, /* Compression Header Protocol. */
83#define IPPROTO_COMP IPPROTO_COMP
84 IPPROTO_SCTP = 132, /* Stream Control Transmission Protocol. */
85#define IPPROTO_SCTP IPPROTO_SCTP
86 IPPROTO_UDPLITE = 136, /* UDP-Lite protocol. */
87#define IPPROTO_UDPLITE IPPROTO_UDPLITE
88 IPPROTO_MPLS = 137, /* MPLS in IP. */
89#define IPPROTO_MPLS IPPROTO_MPLS
90 IPPROTO_RAW = 255, /* Raw IP packets. */
91#define IPPROTO_RAW IPPROTO_RAW
92 IPPROTO_MAX
93 };
94
95/* If __USE_KERNEL_IPV6_DEFS is 1 then the user has included the kernel
96 network headers first and we should use those ABI-identical definitions
97 instead of our own, otherwise 0. */
98#if !__USE_KERNEL_IPV6_DEFS
99enum
100 {
101 IPPROTO_HOPOPTS = 0, /* IPv6 Hop-by-Hop options. */
102#define IPPROTO_HOPOPTS IPPROTO_HOPOPTS
103 IPPROTO_ROUTING = 43, /* IPv6 routing header. */
104#define IPPROTO_ROUTING IPPROTO_ROUTING
105 IPPROTO_FRAGMENT = 44, /* IPv6 fragmentation header. */
106#define IPPROTO_FRAGMENT IPPROTO_FRAGMENT
107 IPPROTO_ICMPV6 = 58, /* ICMPv6. */
108#define IPPROTO_ICMPV6 IPPROTO_ICMPV6
109 IPPROTO_NONE = 59, /* IPv6 no next header. */
110#define IPPROTO_NONE IPPROTO_NONE
111 IPPROTO_DSTOPTS = 60, /* IPv6 destination options. */
112#define IPPROTO_DSTOPTS IPPROTO_DSTOPTS
113 IPPROTO_MH = 135 /* IPv6 mobility header. */
114#define IPPROTO_MH IPPROTO_MH
115 };
116#endif /* !__USE_KERNEL_IPV6_DEFS */
117
118/* Type to represent a port. */
119typedef uint16_t in_port_t;
120
121/* Standard well-known ports. */
122enum
123 {
124 IPPORT_ECHO = 7, /* Echo service. */
125 IPPORT_DISCARD = 9, /* Discard transmissions service. */
126 IPPORT_SYSTAT = 11, /* System status service. */
127 IPPORT_DAYTIME = 13, /* Time of day service. */
128 IPPORT_NETSTAT = 15, /* Network status service. */
129 IPPORT_FTP = 21, /* File Transfer Protocol. */
130 IPPORT_TELNET = 23, /* Telnet protocol. */
131 IPPORT_SMTP = 25, /* Simple Mail Transfer Protocol. */
132 IPPORT_TIMESERVER = 37, /* Timeserver service. */
133 IPPORT_NAMESERVER = 42, /* Domain Name Service. */
134 IPPORT_WHOIS = 43, /* Internet Whois service. */
135 IPPORT_MTP = 57,
136
137 IPPORT_TFTP = 69, /* Trivial File Transfer Protocol. */
138 IPPORT_RJE = 77,
139 IPPORT_FINGER = 79, /* Finger service. */
140 IPPORT_TTYLINK = 87,
141 IPPORT_SUPDUP = 95, /* SUPDUP protocol. */
142
143
144 IPPORT_EXECSERVER = 512, /* execd service. */
145 IPPORT_LOGINSERVER = 513, /* rlogind service. */
146 IPPORT_CMDSERVER = 514,
147 IPPORT_EFSSERVER = 520,
148
149 /* UDP ports. */
150 IPPORT_BIFFUDP = 512,
151 IPPORT_WHOSERVER = 513,
152 IPPORT_ROUTESERVER = 520,
153
154 /* Ports less than this value are reserved for privileged processes. */
155 IPPORT_RESERVED = 1024,
156
157 /* Ports greater this value are reserved for (non-privileged) servers. */
158 IPPORT_USERRESERVED = 5000
159 };
160
161/* Definitions of the bits in an Internet address integer.
162
163 On subnets, host and network parts are found according to
164 the subnet mask, not these masks. */
165
166#define IN_CLASSA(a) ((((in_addr_t)(a)) & 0x80000000) == 0)
167#define IN_CLASSA_NET 0xff000000
168#define IN_CLASSA_NSHIFT 24
169#define IN_CLASSA_HOST (0xffffffff & ~IN_CLASSA_NET)
170#define IN_CLASSA_MAX 128
171
172#define IN_CLASSB(a) ((((in_addr_t)(a)) & 0xc0000000) == 0x80000000)
173#define IN_CLASSB_NET 0xffff0000
174#define IN_CLASSB_NSHIFT 16
175#define IN_CLASSB_HOST (0xffffffff & ~IN_CLASSB_NET)
176#define IN_CLASSB_MAX 65536
177
178#define IN_CLASSC(a) ((((in_addr_t)(a)) & 0xe0000000) == 0xc0000000)
179#define IN_CLASSC_NET 0xffffff00
180#define IN_CLASSC_NSHIFT 8
181#define IN_CLASSC_HOST (0xffffffff & ~IN_CLASSC_NET)
182
183#define IN_CLASSD(a) ((((in_addr_t)(a)) & 0xf0000000) == 0xe0000000)
184#define IN_MULTICAST(a) IN_CLASSD(a)
185
186#define IN_EXPERIMENTAL(a) ((((in_addr_t)(a)) & 0xe0000000) == 0xe0000000)
187#define IN_BADCLASS(a) ((((in_addr_t)(a)) & 0xf0000000) == 0xf0000000)
188
189/* Address to accept any incoming messages. */
190#define INADDR_ANY ((in_addr_t) 0x00000000)
191/* Address to send to all hosts. */
192#define INADDR_BROADCAST ((in_addr_t) 0xffffffff)
193/* Address indicating an error return. */
194#define INADDR_NONE ((in_addr_t) 0xffffffff)
195
196/* Network number for local host loopback. */
197#define IN_LOOPBACKNET 127
198/* Address to loopback in software to local host. */
199#ifndef INADDR_LOOPBACK
200# define INADDR_LOOPBACK ((in_addr_t) 0x7f000001) /* Inet 127.0.0.1. */
201#endif
202
203/* Defines for Multicast INADDR. */
204#define INADDR_UNSPEC_GROUP ((in_addr_t) 0xe0000000) /* 224.0.0.0 */
205#define INADDR_ALLHOSTS_GROUP ((in_addr_t) 0xe0000001) /* 224.0.0.1 */
206#define INADDR_ALLRTRS_GROUP ((in_addr_t) 0xe0000002) /* 224.0.0.2 */
207#define INADDR_MAX_LOCAL_GROUP ((in_addr_t) 0xe00000ff) /* 224.0.0.255 */
208
209#if !__USE_KERNEL_IPV6_DEFS
210/* IPv6 address */
211struct in6_addr
212 {
213 union
214 {
215 uint8_t __u6_addr8[16];
216 uint16_t __u6_addr16[8];
217 uint32_t __u6_addr32[4];
218 } __in6_u;
219#define s6_addr __in6_u.__u6_addr8
220#ifdef __USE_MISC
221# define s6_addr16 __in6_u.__u6_addr16
222# define s6_addr32 __in6_u.__u6_addr32
223#endif
224 };
225#endif /* !__USE_KERNEL_IPV6_DEFS */
226
227extern const struct in6_addr in6addr_any; /* :: */
228extern const struct in6_addr in6addr_loopback; /* ::1 */
229#define IN6ADDR_ANY_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } }
230#define IN6ADDR_LOOPBACK_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } }
231
232#define INET_ADDRSTRLEN 16
233#define INET6_ADDRSTRLEN 46
234
235
236/* Structure describing an Internet socket address. */
237struct sockaddr_in
238 {
239 __SOCKADDR_COMMON (sin_);
240 in_port_t sin_port; /* Port number. */
241 struct in_addr sin_addr; /* Internet address. */
242
243 /* Pad to size of `struct sockaddr'. */
244 unsigned char sin_zero[sizeof (struct sockaddr) -
245 __SOCKADDR_COMMON_SIZE -
246 sizeof (in_port_t) -
247 sizeof (struct in_addr)];
248 };
249
250#if !__USE_KERNEL_IPV6_DEFS
251/* Ditto, for IPv6. */
252struct sockaddr_in6
253 {
254 __SOCKADDR_COMMON (sin6_);
255 in_port_t sin6_port; /* Transport layer port # */
256 uint32_t sin6_flowinfo; /* IPv6 flow information */
257 struct in6_addr sin6_addr; /* IPv6 address */
258 uint32_t sin6_scope_id; /* IPv6 scope-id */
259 };
260#endif /* !__USE_KERNEL_IPV6_DEFS */
261
262#ifdef __USE_MISC
263/* IPv4 multicast request. */
264struct ip_mreq
265 {
266 /* IP multicast address of group. */
267 struct in_addr imr_multiaddr;
268
269 /* Local IP address of interface. */
270 struct in_addr imr_interface;
271 };
272
273struct ip_mreq_source
274 {
275 /* IP multicast address of group. */
276 struct in_addr imr_multiaddr;
277
278 /* IP address of interface. */
279 struct in_addr imr_interface;
280
281 /* IP address of source. */
282 struct in_addr imr_sourceaddr;
283 };
284#endif
285
286#if !__USE_KERNEL_IPV6_DEFS
287/* Likewise, for IPv6. */
288struct ipv6_mreq
289 {
290 /* IPv6 multicast address of group */
291 struct in6_addr ipv6mr_multiaddr;
292
293 /* local interface */
294 unsigned int ipv6mr_interface;
295 };
296#endif /* !__USE_KERNEL_IPV6_DEFS */
297
298#ifdef __USE_MISC
299/* Multicast group request. */
300struct group_req
301 {
302 /* Interface index. */
303 uint32_t gr_interface;
304
305 /* Group address. */
306 struct sockaddr_storage gr_group;
307 };
308
309struct group_source_req
310 {
311 /* Interface index. */
312 uint32_t gsr_interface;
313
314 /* Group address. */
315 struct sockaddr_storage gsr_group;
316
317 /* Source address. */
318 struct sockaddr_storage gsr_source;
319 };
320
321
322/* Full-state filter operations. */
323struct ip_msfilter
324 {
325 /* IP multicast address of group. */
326 struct in_addr imsf_multiaddr;
327
328 /* Local IP address of interface. */
329 struct in_addr imsf_interface;
330
331 /* Filter mode. */
332 uint32_t imsf_fmode;
333
334 /* Number of source addresses. */
335 uint32_t imsf_numsrc;
336 /* Source addresses. */
337 struct in_addr imsf_slist[1];
338 };
339
340#define IP_MSFILTER_SIZE(numsrc) (sizeof (struct ip_msfilter) \
341 - sizeof (struct in_addr) \
342 + (numsrc) * sizeof (struct in_addr))
343
344struct group_filter
345 {
346 /* Interface index. */
347 uint32_t gf_interface;
348
349 /* Group address. */
350 struct sockaddr_storage gf_group;
351
352 /* Filter mode. */
353 uint32_t gf_fmode;
354
355 /* Number of source addresses. */
356 uint32_t gf_numsrc;
357 /* Source addresses. */
358 struct sockaddr_storage gf_slist[1];
359};
360
361#define GROUP_FILTER_SIZE(numsrc) (sizeof (struct group_filter) \
362 - sizeof (struct sockaddr_storage) \
363 + ((numsrc) \
364 * sizeof (struct sockaddr_storage)))
365#endif
366
367/* Functions to convert between host and network byte order.
368
369 Please note that these functions normally take `unsigned long int' or
370 `unsigned short int' values as arguments and also return them. But
371 this was a short-sighted decision since on different systems the types
372 may have different representations but the values are always the same. */
373
374extern uint32_t ntohl (uint32_t __netlong) __THROW __attribute__ ((__const__));
375extern uint16_t ntohs (uint16_t __netshort)
376 __THROW __attribute__ ((__const__));
377extern uint32_t htonl (uint32_t __hostlong)
378 __THROW __attribute__ ((__const__));
379extern uint16_t htons (uint16_t __hostshort)
380 __THROW __attribute__ ((__const__));
381
382#include <endian.h>
383
384/* Get machine dependent optimized versions of byte swapping functions. */
385#include <bits/byteswap.h>
386#include <bits/uintn-identity.h>
387
388#ifdef __OPTIMIZE__
389/* We can optimize calls to the conversion functions. Either nothing has
390 to be done or we are using directly the byte-swapping functions which
391 often can be inlined. */
392# if __BYTE_ORDER == __BIG_ENDIAN
393/* The host byte order is the same as network byte order,
394 so these functions are all just identity. */
395# define ntohl(x) __uint32_identity (x)
396# define ntohs(x) __uint16_identity (x)
397# define htonl(x) __uint32_identity (x)
398# define htons(x) __uint16_identity (x)
399# else
400# if __BYTE_ORDER == __LITTLE_ENDIAN
401# define ntohl(x) __bswap_32 (x)
402# define ntohs(x) __bswap_16 (x)
403# define htonl(x) __bswap_32 (x)
404# define htons(x) __bswap_16 (x)
405# endif
406# endif
407#endif
408
409#ifdef __GNUC__
410# define IN6_IS_ADDR_UNSPECIFIED(a) \
411 (__extension__ \
412 ({ const struct in6_addr *__a = (const struct in6_addr *) (a); \
413 __a->__in6_u.__u6_addr32[0] == 0 \
414 && __a->__in6_u.__u6_addr32[1] == 0 \
415 && __a->__in6_u.__u6_addr32[2] == 0 \
416 && __a->__in6_u.__u6_addr32[3] == 0; }))
417
418# define IN6_IS_ADDR_LOOPBACK(a) \
419 (__extension__ \
420 ({ const struct in6_addr *__a = (const struct in6_addr *) (a); \
421 __a->__in6_u.__u6_addr32[0] == 0 \
422 && __a->__in6_u.__u6_addr32[1] == 0 \
423 && __a->__in6_u.__u6_addr32[2] == 0 \
424 && __a->__in6_u.__u6_addr32[3] == htonl (1); }))
425
426# define IN6_IS_ADDR_LINKLOCAL(a) \
427 (__extension__ \
428 ({ const struct in6_addr *__a = (const struct in6_addr *) (a); \
429 (__a->__in6_u.__u6_addr32[0] & htonl (0xffc00000)) == htonl (0xfe800000); }))
430
431# define IN6_IS_ADDR_SITELOCAL(a) \
432 (__extension__ \
433 ({ const struct in6_addr *__a = (const struct in6_addr *) (a); \
434 (__a->__in6_u.__u6_addr32[0] & htonl (0xffc00000)) == htonl (0xfec00000); }))
435
436# define IN6_IS_ADDR_V4MAPPED(a) \
437 (__extension__ \
438 ({ const struct in6_addr *__a = (const struct in6_addr *) (a); \
439 __a->__in6_u.__u6_addr32[0] == 0 \
440 && __a->__in6_u.__u6_addr32[1] == 0 \
441 && __a->__in6_u.__u6_addr32[2] == htonl (0xffff); }))
442
443# define IN6_IS_ADDR_V4COMPAT(a) \
444 (__extension__ \
445 ({ const struct in6_addr *__a = (const struct in6_addr *) (a); \
446 __a->__in6_u.__u6_addr32[0] == 0 \
447 && __a->__in6_u.__u6_addr32[1] == 0 \
448 && __a->__in6_u.__u6_addr32[2] == 0 \
449 && ntohl (__a->__in6_u.__u6_addr32[3]) > 1; }))
450
451# define IN6_ARE_ADDR_EQUAL(a,b) \
452 (__extension__ \
453 ({ const struct in6_addr *__a = (const struct in6_addr *) (a); \
454 const struct in6_addr *__b = (const struct in6_addr *) (b); \
455 __a->__in6_u.__u6_addr32[0] == __b->__in6_u.__u6_addr32[0] \
456 && __a->__in6_u.__u6_addr32[1] == __b->__in6_u.__u6_addr32[1] \
457 && __a->__in6_u.__u6_addr32[2] == __b->__in6_u.__u6_addr32[2] \
458 && __a->__in6_u.__u6_addr32[3] == __b->__in6_u.__u6_addr32[3]; }))
459#else
460# define IN6_IS_ADDR_UNSPECIFIED(a) \
461 (((const uint32_t *) (a))[0] == 0 \
462 && ((const uint32_t *) (a))[1] == 0 \
463 && ((const uint32_t *) (a))[2] == 0 \
464 && ((const uint32_t *) (a))[3] == 0)
465
466# define IN6_IS_ADDR_LOOPBACK(a) \
467 (((const uint32_t *) (a))[0] == 0 \
468 && ((const uint32_t *) (a))[1] == 0 \
469 && ((const uint32_t *) (a))[2] == 0 \
470 && ((const uint32_t *) (a))[3] == htonl (1))
471
472# define IN6_IS_ADDR_LINKLOCAL(a) \
473 ((((const uint32_t *) (a))[0] & htonl (0xffc00000)) \
474 == htonl (0xfe800000))
475
476# define IN6_IS_ADDR_SITELOCAL(a) \
477 ((((const uint32_t *) (a))[0] & htonl (0xffc00000)) \
478 == htonl (0xfec00000))
479
480# define IN6_IS_ADDR_V4MAPPED(a) \
481 ((((const uint32_t *) (a))[0] == 0) \
482 && (((const uint32_t *) (a))[1] == 0) \
483 && (((const uint32_t *) (a))[2] == htonl (0xffff)))
484
485# define IN6_IS_ADDR_V4COMPAT(a) \
486 ((((const uint32_t *) (a))[0] == 0) \
487 && (((const uint32_t *) (a))[1] == 0) \
488 && (((const uint32_t *) (a))[2] == 0) \
489 && (ntohl (((const uint32_t *) (a))[3]) > 1))
490
491# define IN6_ARE_ADDR_EQUAL(a,b) \
492 ((((const uint32_t *) (a))[0] == ((const uint32_t *) (b))[0]) \
493 && (((const uint32_t *) (a))[1] == ((const uint32_t *) (b))[1]) \
494 && (((const uint32_t *) (a))[2] == ((const uint32_t *) (b))[2]) \
495 && (((const uint32_t *) (a))[3] == ((const uint32_t *) (b))[3]))
496#endif
497
498#define IN6_IS_ADDR_MULTICAST(a) (((const uint8_t *) (a))[0] == 0xff)
499
500#ifdef __USE_MISC
501/* Bind socket to a privileged IP port. */
502extern int bindresvport (int __sockfd, struct sockaddr_in *__sock_in) __THROW;
503
504/* The IPv6 version of this function. */
505extern int bindresvport6 (int __sockfd, struct sockaddr_in6 *__sock_in)
506 __THROW;
507#endif
508
509
510#define IN6_IS_ADDR_MC_NODELOCAL(a) \
511 (IN6_IS_ADDR_MULTICAST(a) \
512 && ((((const uint8_t *) (a))[1] & 0xf) == 0x1))
513
514#define IN6_IS_ADDR_MC_LINKLOCAL(a) \
515 (IN6_IS_ADDR_MULTICAST(a) \
516 && ((((const uint8_t *) (a))[1] & 0xf) == 0x2))
517
518#define IN6_IS_ADDR_MC_SITELOCAL(a) \
519 (IN6_IS_ADDR_MULTICAST(a) \
520 && ((((const uint8_t *) (a))[1] & 0xf) == 0x5))
521
522#define IN6_IS_ADDR_MC_ORGLOCAL(a) \
523 (IN6_IS_ADDR_MULTICAST(a) \
524 && ((((const uint8_t *) (a))[1] & 0xf) == 0x8))
525
526#define IN6_IS_ADDR_MC_GLOBAL(a) \
527 (IN6_IS_ADDR_MULTICAST(a) \
528 && ((((const uint8_t *) (a))[1] & 0xf) == 0xe))
529
530
531#ifdef __USE_GNU
532struct cmsghdr; /* Forward declaration. */
533
534#if !__USE_KERNEL_IPV6_DEFS
535/* IPv6 packet information. */
536struct in6_pktinfo
537 {
538 struct in6_addr ipi6_addr; /* src/dst IPv6 address */
539 unsigned int ipi6_ifindex; /* send/recv interface index */
540 };
541
542/* IPv6 MTU information. */
543struct ip6_mtuinfo
544 {
545 struct sockaddr_in6 ip6m_addr; /* dst address including zone ID */
546 uint32_t ip6m_mtu; /* path MTU in host byte order */
547 };
548#endif /* !__USE_KERNEL_IPV6_DEFS */
549
550/* Obsolete hop-by-hop and Destination Options Processing (RFC 2292). */
551extern int inet6_option_space (int __nbytes)
552 __THROW __attribute_deprecated__;
553extern int inet6_option_init (void *__bp, struct cmsghdr **__cmsgp,
554 int __type) __THROW __attribute_deprecated__;
555extern int inet6_option_append (struct cmsghdr *__cmsg,
556 const uint8_t *__typep, int __multx,
557 int __plusy) __THROW __attribute_deprecated__;
558extern uint8_t *inet6_option_alloc (struct cmsghdr *__cmsg, int __datalen,
559 int __multx, int __plusy)
560 __THROW __attribute_deprecated__;
561extern int inet6_option_next (const struct cmsghdr *__cmsg,
562 uint8_t **__tptrp)
563 __THROW __attribute_deprecated__;
564extern int inet6_option_find (const struct cmsghdr *__cmsg,
565 uint8_t **__tptrp, int __type)
566 __THROW __attribute_deprecated__;
567
568
569/* Hop-by-Hop and Destination Options Processing (RFC 3542). */
570extern int inet6_opt_init (void *__extbuf, socklen_t __extlen) __THROW;
571extern int inet6_opt_append (void *__extbuf, socklen_t __extlen, int __offset,
572 uint8_t __type, socklen_t __len, uint8_t __align,
573 void **__databufp) __THROW;
574extern int inet6_opt_finish (void *__extbuf, socklen_t __extlen, int __offset)
575 __THROW;
576extern int inet6_opt_set_val (void *__databuf, int __offset, void *__val,
577 socklen_t __vallen) __THROW;
578extern int inet6_opt_next (void *__extbuf, socklen_t __extlen, int __offset,
579 uint8_t *__typep, socklen_t *__lenp,
580 void **__databufp) __THROW;
581extern int inet6_opt_find (void *__extbuf, socklen_t __extlen, int __offset,
582 uint8_t __type, socklen_t *__lenp,
583 void **__databufp) __THROW;
584extern int inet6_opt_get_val (void *__databuf, int __offset, void *__val,
585 socklen_t __vallen) __THROW;
586
587
588/* Routing Header Option (RFC 3542). */
589extern socklen_t inet6_rth_space (int __type, int __segments) __THROW;
590extern void *inet6_rth_init (void *__bp, socklen_t __bp_len, int __type,
591 int __segments) __THROW;
592extern int inet6_rth_add (void *__bp, const struct in6_addr *__addr) __THROW;
593extern int inet6_rth_reverse (const void *__in, void *__out) __THROW;
594extern int inet6_rth_segments (const void *__bp) __THROW;
595extern struct in6_addr *inet6_rth_getaddr (const void *__bp, int __index)
596 __THROW;
597
598
599/* Multicast source filter support. */
600
601/* Get IPv4 source filter. */
602extern int getipv4sourcefilter (int __s, struct in_addr __interface_addr,
603 struct in_addr __group, uint32_t *__fmode,
604 uint32_t *__numsrc, struct in_addr *__slist)
605 __THROW;
606
607/* Set IPv4 source filter. */
608extern int setipv4sourcefilter (int __s, struct in_addr __interface_addr,
609 struct in_addr __group, uint32_t __fmode,
610 uint32_t __numsrc,
611 const struct in_addr *__slist)
612 __THROW;
613
614
615/* Get source filter. */
616extern int getsourcefilter (int __s, uint32_t __interface_addr,
617 const struct sockaddr *__group,
618 socklen_t __grouplen, uint32_t *__fmode,
619 uint32_t *__numsrc,
620 struct sockaddr_storage *__slist) __THROW;
621
622/* Set source filter. */
623extern int setsourcefilter (int __s, uint32_t __interface_addr,
624 const struct sockaddr *__group,
625 socklen_t __grouplen, uint32_t __fmode,
626 uint32_t __numsrc,
627 const struct sockaddr_storage *__slist) __THROW;
628#endif /* use GNU */
629
630__END_DECLS
631
632#endif /* netinet/in.h */
libc/glibc-include/netinet/in_systm.h created+40
...@@ -0,0 +1,40 @@
1/* System specific type definitions for networking code.
2 Copyright (C) 1997-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _NETINET_IN_SYSTM_H
20#define _NETINET_IN_SYSTM_H 1
21
22#include <sys/types.h>
23#include <stdint.h>
24
25__BEGIN_DECLS
26
27/*
28 * Network order versions of various data types. Unfortunately, BSD
29 * assumes specific sizes for shorts (16 bit) and longs (32 bit) which
30 * don't hold in general. As a consequence, the network order versions
31 * may not reflect the actual size of the native data types.
32 */
33
34typedef uint16_t n_short; /* short as received from the net */
35typedef uint32_t n_long; /* long as received from the net */
36typedef uint32_t n_time; /* ms since 00:00 GMT, byte rev */
37
38__END_DECLS
39
40#endif /* netinet/in_systm.h */
libc/glibc-include/netinet/ip.h created+302
...@@ -0,0 +1,302 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef __NETINET_IP_H
19#define __NETINET_IP_H 1
20
21#include <features.h>
22#include <sys/types.h>
23
24#include <netinet/in.h>
25
26__BEGIN_DECLS
27
28struct timestamp
29 {
30 uint8_t len;
31 uint8_t ptr;
32#if __BYTE_ORDER == __LITTLE_ENDIAN
33 unsigned int flags:4;
34 unsigned int overflow:4;
35#elif __BYTE_ORDER == __BIG_ENDIAN
36 unsigned int overflow:4;
37 unsigned int flags:4;
38#else
39# error "Please fix <bits/endian.h>"
40#endif
41 uint32_t data[9];
42 };
43
44struct iphdr
45 {
46#if __BYTE_ORDER == __LITTLE_ENDIAN
47 unsigned int ihl:4;
48 unsigned int version:4;
49#elif __BYTE_ORDER == __BIG_ENDIAN
50 unsigned int version:4;
51 unsigned int ihl:4;
52#else
53# error "Please fix <bits/endian.h>"
54#endif
55 uint8_t tos;
56 uint16_t tot_len;
57 uint16_t id;
58 uint16_t frag_off;
59 uint8_t ttl;
60 uint8_t protocol;
61 uint16_t check;
62 uint32_t saddr;
63 uint32_t daddr;
64 /*The options start here. */
65 };
66
67#ifdef __USE_MISC
68/*
69 * Copyright (c) 1982, 1986, 1993
70 * The Regents of the University of California. All rights reserved.
71 *
72 * Redistribution and use in source and binary forms, with or without
73 * modification, are permitted provided that the following conditions
74 * are met:
75 * 1. Redistributions of source code must retain the above copyright
76 * notice, this list of conditions and the following disclaimer.
77 * 2. Redistributions in binary form must reproduce the above copyright
78 * notice, this list of conditions and the following disclaimer in the
79 * documentation and/or other materials provided with the distribution.
80 * 4. Neither the name of the University nor the names of its contributors
81 * may be used to endorse or promote products derived from this software
82 * without specific prior written permission.
83 *
84 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
85 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
86 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
87 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
88 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
89 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
90 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
91 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
92 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
93 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
94 * SUCH DAMAGE.
95 *
96 * @(#)ip.h 8.1 (Berkeley) 6/10/93
97 */
98
99/*
100 * Definitions for internet protocol version 4.
101 * Per RFC 791, September 1981.
102 */
103
104/*
105 * Structure of an internet header, naked of options.
106 */
107struct ip
108 {
109#if __BYTE_ORDER == __LITTLE_ENDIAN
110 unsigned int ip_hl:4; /* header length */
111 unsigned int ip_v:4; /* version */
112#endif
113#if __BYTE_ORDER == __BIG_ENDIAN
114 unsigned int ip_v:4; /* version */
115 unsigned int ip_hl:4; /* header length */
116#endif
117 uint8_t ip_tos; /* type of service */
118 unsigned short ip_len; /* total length */
119 unsigned short ip_id; /* identification */
120 unsigned short ip_off; /* fragment offset field */
121#define IP_RF 0x8000 /* reserved fragment flag */
122#define IP_DF 0x4000 /* dont fragment flag */
123#define IP_MF 0x2000 /* more fragments flag */
124#define IP_OFFMASK 0x1fff /* mask for fragmenting bits */
125 uint8_t ip_ttl; /* time to live */
126 uint8_t ip_p; /* protocol */
127 unsigned short ip_sum; /* checksum */
128 struct in_addr ip_src, ip_dst; /* source and dest address */
129 };
130
131/*
132 * Time stamp option structure.
133 */
134struct ip_timestamp
135 {
136 uint8_t ipt_code; /* IPOPT_TS */
137 uint8_t ipt_len; /* size of structure (variable) */
138 uint8_t ipt_ptr; /* index of current entry */
139#if __BYTE_ORDER == __LITTLE_ENDIAN
140 unsigned int ipt_flg:4; /* flags, see below */
141 unsigned int ipt_oflw:4; /* overflow counter */
142#endif
143#if __BYTE_ORDER == __BIG_ENDIAN
144 unsigned int ipt_oflw:4; /* overflow counter */
145 unsigned int ipt_flg:4; /* flags, see below */
146#endif
147 uint32_t data[9];
148 };
149#endif /* __USE_MISC */
150
151#define IPVERSION 4 /* IP version number */
152#define IP_MAXPACKET 65535 /* maximum packet size */
153
154/*
155 * Definitions for Explicit Congestion Notification (ECN)
156 *
157 * Taken from RFC-3168, Section 5.
158 */
159
160#define IPTOS_ECN_MASK 0x03
161#define IPTOS_ECN(x) ((x) & IPTOS_ECN_MASK)
162#define IPTOS_ECN_NOT_ECT 0x00
163#define IPTOS_ECN_ECT1 0x01
164#define IPTOS_ECN_ECT0 0x02
165#define IPTOS_ECN_CE 0x03
166
167/*
168 * Definitions for IP differentiated services code points (DSCP)
169 *
170 * Taken from RFC-2597, Section 6 and RFC-2598, Section 2.3.
171 */
172
173#define IPTOS_DSCP_MASK 0xfc
174#define IPTOS_DSCP(x) ((x) & IPTOS_DSCP_MASK)
175#define IPTOS_DSCP_AF11 0x28
176#define IPTOS_DSCP_AF12 0x30
177#define IPTOS_DSCP_AF13 0x38
178#define IPTOS_DSCP_AF21 0x48
179#define IPTOS_DSCP_AF22 0x50
180#define IPTOS_DSCP_AF23 0x58
181#define IPTOS_DSCP_AF31 0x68
182#define IPTOS_DSCP_AF32 0x70
183#define IPTOS_DSCP_AF33 0x78
184#define IPTOS_DSCP_AF41 0x88
185#define IPTOS_DSCP_AF42 0x90
186#define IPTOS_DSCP_AF43 0x98
187#define IPTOS_DSCP_EF 0xb8
188
189/*
190 * In RFC 2474, Section 4.2.2.1, the Class Selector Codepoints subsume
191 * the old ToS Precedence values.
192 */
193
194#define IPTOS_CLASS_MASK 0xe0
195#define IPTOS_CLASS(class) ((class) & IPTOS_CLASS_MASK)
196#define IPTOS_CLASS_CS0 0x00
197#define IPTOS_CLASS_CS1 0x20
198#define IPTOS_CLASS_CS2 0x40
199#define IPTOS_CLASS_CS3 0x60
200#define IPTOS_CLASS_CS4 0x80
201#define IPTOS_CLASS_CS5 0xa0
202#define IPTOS_CLASS_CS6 0xc0
203#define IPTOS_CLASS_CS7 0xe0
204
205#define IPTOS_CLASS_DEFAULT IPTOS_CLASS_CS0
206
207/*
208 * Definitions for IP type of service (ip_tos) [deprecated; use DSCP
209 * and CS definitions above instead.]
210 */
211#define IPTOS_TOS_MASK 0x1E
212#define IPTOS_TOS(tos) ((tos) & IPTOS_TOS_MASK)
213#define IPTOS_LOWDELAY 0x10
214#define IPTOS_THROUGHPUT 0x08
215#define IPTOS_RELIABILITY 0x04
216#define IPTOS_LOWCOST 0x02
217#define IPTOS_MINCOST IPTOS_LOWCOST
218
219/*
220 * Definitions for IP precedence (also in ip_tos) [also deprecated.]
221 */
222#define IPTOS_PREC_MASK IPTOS_CLASS_MASK
223#define IPTOS_PREC(tos) IPTOS_CLASS(tos)
224#define IPTOS_PREC_NETCONTROL IPTOS_CLASS_CS7
225#define IPTOS_PREC_INTERNETCONTROL IPTOS_CLASS_CS6
226#define IPTOS_PREC_CRITIC_ECP IPTOS_CLASS_CS5
227#define IPTOS_PREC_FLASHOVERRIDE IPTOS_CLASS_CS4
228#define IPTOS_PREC_FLASH IPTOS_CLASS_CS3
229#define IPTOS_PREC_IMMEDIATE IPTOS_CLASS_CS2
230#define IPTOS_PREC_PRIORITY IPTOS_CLASS_CS1
231#define IPTOS_PREC_ROUTINE IPTOS_CLASS_CS0
232
233/*
234 * Definitions for options.
235 */
236#define IPOPT_COPY 0x80
237#define IPOPT_CLASS_MASK 0x60
238#define IPOPT_NUMBER_MASK 0x1f
239
240#define IPOPT_COPIED(o) ((o) & IPOPT_COPY)
241#define IPOPT_CLASS(o) ((o) & IPOPT_CLASS_MASK)
242#define IPOPT_NUMBER(o) ((o) & IPOPT_NUMBER_MASK)
243
244#define IPOPT_CONTROL 0x00
245#define IPOPT_RESERVED1 0x20
246#define IPOPT_DEBMEAS 0x40
247#define IPOPT_MEASUREMENT IPOPT_DEBMEAS
248#define IPOPT_RESERVED2 0x60
249
250#define IPOPT_EOL 0 /* end of option list */
251#define IPOPT_END IPOPT_EOL
252#define IPOPT_NOP 1 /* no operation */
253#define IPOPT_NOOP IPOPT_NOP
254
255#define IPOPT_RR 7 /* record packet route */
256#define IPOPT_TS 68 /* timestamp */
257#define IPOPT_TIMESTAMP IPOPT_TS
258#define IPOPT_SECURITY 130 /* provide s,c,h,tcc */
259#define IPOPT_SEC IPOPT_SECURITY
260#define IPOPT_LSRR 131 /* loose source route */
261#define IPOPT_SATID 136 /* satnet id */
262#define IPOPT_SID IPOPT_SATID
263#define IPOPT_SSRR 137 /* strict source route */
264#define IPOPT_RA 148 /* router alert */
265
266/*
267 * Offsets to fields in options other than EOL and NOP.
268 */
269#define IPOPT_OPTVAL 0 /* option ID */
270#define IPOPT_OLEN 1 /* option length */
271#define IPOPT_OFFSET 2 /* offset within option */
272#define IPOPT_MINOFF 4 /* min value of above */
273
274#define MAX_IPOPTLEN 40
275
276/* flag bits for ipt_flg */
277#define IPOPT_TS_TSONLY 0 /* timestamps only */
278#define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */
279#define IPOPT_TS_PRESPEC 3 /* specified modules only */
280
281/* bits for security (not byte swapped) */
282#define IPOPT_SECUR_UNCLASS 0x0000
283#define IPOPT_SECUR_CONFID 0xf135
284#define IPOPT_SECUR_EFTO 0x789a
285#define IPOPT_SECUR_MMMM 0xbc4d
286#define IPOPT_SECUR_RESTR 0xaf13
287#define IPOPT_SECUR_SECRET 0xd788
288#define IPOPT_SECUR_TOPSECRET 0x6bc5
289
290/*
291 * Internet implementation parameters.
292 */
293#define MAXTTL 255 /* maximum time to live (seconds) */
294#define IPDEFTTL 64 /* default ttl, from RFC 1340 */
295#define IPFRAGTTL 60 /* time to live for frags, slowhz */
296#define IPTTLDEC 1 /* subtracted when forwarding */
297
298#define IP_MSS 576 /* default maximum segment size */
299
300__END_DECLS
301
302#endif /* netinet/ip.h */
libc/glibc-include/netinet/ip6.h created+188
...@@ -0,0 +1,188 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _NETINET_IP6_H
19#define _NETINET_IP6_H 1
20
21#include <inttypes.h>
22#include <netinet/in.h>
23
24struct ip6_hdr
25 {
26 union
27 {
28 struct ip6_hdrctl
29 {
30 uint32_t ip6_un1_flow; /* 4 bits version, 8 bits TC,
31 20 bits flow-ID */
32 uint16_t ip6_un1_plen; /* payload length */
33 uint8_t ip6_un1_nxt; /* next header */
34 uint8_t ip6_un1_hlim; /* hop limit */
35 } ip6_un1;
36 uint8_t ip6_un2_vfc; /* 4 bits version, top 4 bits tclass */
37 } ip6_ctlun;
38 struct in6_addr ip6_src; /* source address */
39 struct in6_addr ip6_dst; /* destination address */
40 };
41
42#define ip6_vfc ip6_ctlun.ip6_un2_vfc
43#define ip6_flow ip6_ctlun.ip6_un1.ip6_un1_flow
44#define ip6_plen ip6_ctlun.ip6_un1.ip6_un1_plen
45#define ip6_nxt ip6_ctlun.ip6_un1.ip6_un1_nxt
46#define ip6_hlim ip6_ctlun.ip6_un1.ip6_un1_hlim
47#define ip6_hops ip6_ctlun.ip6_un1.ip6_un1_hlim
48
49/* Generic extension header. */
50struct ip6_ext
51 {
52 uint8_t ip6e_nxt; /* next header. */
53 uint8_t ip6e_len; /* length in units of 8 octets. */
54 };
55
56/* Hop-by-Hop options header. */
57struct ip6_hbh
58 {
59 uint8_t ip6h_nxt; /* next header. */
60 uint8_t ip6h_len; /* length in units of 8 octets. */
61 /* followed by options */
62 };
63
64/* Destination options header */
65struct ip6_dest
66 {
67 uint8_t ip6d_nxt; /* next header */
68 uint8_t ip6d_len; /* length in units of 8 octets */
69 /* followed by options */
70 };
71
72/* Routing header */
73struct ip6_rthdr
74 {
75 uint8_t ip6r_nxt; /* next header */
76 uint8_t ip6r_len; /* length in units of 8 octets */
77 uint8_t ip6r_type; /* routing type */
78 uint8_t ip6r_segleft; /* segments left */
79 /* followed by routing type specific data */
80 };
81
82/* Type 0 Routing header */
83struct ip6_rthdr0
84 {
85 uint8_t ip6r0_nxt; /* next header */
86 uint8_t ip6r0_len; /* length in units of 8 octets */
87 uint8_t ip6r0_type; /* always zero */
88 uint8_t ip6r0_segleft; /* segments left */
89 uint8_t ip6r0_reserved; /* reserved field */
90 uint8_t ip6r0_slmap[3]; /* strict/loose bit map */
91 /* followed by up to 127 struct in6_addr */
92 struct in6_addr ip6r0_addr[0];
93 };
94
95/* Fragment header */
96struct ip6_frag
97 {
98 uint8_t ip6f_nxt; /* next header */
99 uint8_t ip6f_reserved; /* reserved field */
100 uint16_t ip6f_offlg; /* offset, reserved, and flag */
101 uint32_t ip6f_ident; /* identification */
102 };
103
104#if __BYTE_ORDER == __BIG_ENDIAN
105# define IP6F_OFF_MASK 0xfff8 /* mask out offset from _offlg */
106# define IP6F_RESERVED_MASK 0x0006 /* reserved bits in ip6f_offlg */
107# define IP6F_MORE_FRAG 0x0001 /* more-fragments flag */
108#else /* __BYTE_ORDER == __LITTLE_ENDIAN */
109# define IP6F_OFF_MASK 0xf8ff /* mask out offset from _offlg */
110# define IP6F_RESERVED_MASK 0x0600 /* reserved bits in ip6f_offlg */
111# define IP6F_MORE_FRAG 0x0100 /* more-fragments flag */
112#endif
113
114/* IPv6 options */
115struct ip6_opt
116 {
117 uint8_t ip6o_type;
118 uint8_t ip6o_len;
119 };
120
121/* The high-order 3 bits of the option type define the behavior
122 * when processing an unknown option and whether or not the option
123 * content changes in flight.
124 */
125#define IP6OPT_TYPE(o) ((o) & 0xc0)
126#define IP6OPT_TYPE_SKIP 0x00
127#define IP6OPT_TYPE_DISCARD 0x40
128#define IP6OPT_TYPE_FORCEICMP 0x80
129#define IP6OPT_TYPE_ICMP 0xc0
130#define IP6OPT_TYPE_MUTABLE 0x20
131
132/* Special option types for padding. */
133#define IP6OPT_PAD1 0
134#define IP6OPT_PADN 1
135
136#define IP6OPT_JUMBO 0xc2
137#define IP6OPT_NSAP_ADDR 0xc3
138#define IP6OPT_TUNNEL_LIMIT 0x04
139#define IP6OPT_ROUTER_ALERT 0x05
140
141/* Jumbo Payload Option */
142struct ip6_opt_jumbo
143 {
144 uint8_t ip6oj_type;
145 uint8_t ip6oj_len;
146 uint8_t ip6oj_jumbo_len[4];
147 };
148#define IP6OPT_JUMBO_LEN 6
149
150/* NSAP Address Option */
151struct ip6_opt_nsap
152 {
153 uint8_t ip6on_type;
154 uint8_t ip6on_len;
155 uint8_t ip6on_src_nsap_len;
156 uint8_t ip6on_dst_nsap_len;
157 /* followed by source NSAP */
158 /* followed by destination NSAP */
159 };
160
161/* Tunnel Limit Option */
162struct ip6_opt_tunnel
163 {
164 uint8_t ip6ot_type;
165 uint8_t ip6ot_len;
166 uint8_t ip6ot_encap_limit;
167 };
168
169/* Router Alert Option */
170struct ip6_opt_router
171 {
172 uint8_t ip6or_type;
173 uint8_t ip6or_len;
174 uint8_t ip6or_value[2];
175 };
176
177/* Router alert values (in network byte order) */
178#if __BYTE_ORDER == __BIG_ENDIAN
179# define IP6_ALERT_MLD 0x0000
180# define IP6_ALERT_RSVP 0x0001
181# define IP6_ALERT_AN 0x0002
182#else /* __BYTE_ORDER == __LITTLE_ENDIAN */
183# define IP6_ALERT_MLD 0x0000
184# define IP6_ALERT_RSVP 0x0100
185# define IP6_ALERT_AN 0x0200
186#endif
187
188#endif /* netinet/ip6.h */
libc/glibc-include/netinet/ip_icmp.h created+282
...@@ -0,0 +1,282 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef __NETINET_IP_ICMP_H
19#define __NETINET_IP_ICMP_H 1
20
21#include <sys/types.h>
22#include <stdint.h>
23
24__BEGIN_DECLS
25
26struct icmphdr
27{
28 uint8_t type; /* message type */
29 uint8_t code; /* type sub-code */
30 uint16_t checksum;
31 union
32 {
33 struct
34 {
35 uint16_t id;
36 uint16_t sequence;
37 } echo; /* echo datagram */
38 uint32_t gateway; /* gateway address */
39 struct
40 {
41 uint16_t __glibc_reserved;
42 uint16_t mtu;
43 } frag; /* path mtu discovery */
44 } un;
45};
46
47#define ICMP_ECHOREPLY 0 /* Echo Reply */
48#define ICMP_DEST_UNREACH 3 /* Destination Unreachable */
49#define ICMP_SOURCE_QUENCH 4 /* Source Quench */
50#define ICMP_REDIRECT 5 /* Redirect (change route) */
51#define ICMP_ECHO 8 /* Echo Request */
52#define ICMP_TIME_EXCEEDED 11 /* Time Exceeded */
53#define ICMP_PARAMETERPROB 12 /* Parameter Problem */
54#define ICMP_TIMESTAMP 13 /* Timestamp Request */
55#define ICMP_TIMESTAMPREPLY 14 /* Timestamp Reply */
56#define ICMP_INFO_REQUEST 15 /* Information Request */
57#define ICMP_INFO_REPLY 16 /* Information Reply */
58#define ICMP_ADDRESS 17 /* Address Mask Request */
59#define ICMP_ADDRESSREPLY 18 /* Address Mask Reply */
60#define NR_ICMP_TYPES 18
61
62
63/* Codes for UNREACH. */
64#define ICMP_NET_UNREACH 0 /* Network Unreachable */
65#define ICMP_HOST_UNREACH 1 /* Host Unreachable */
66#define ICMP_PROT_UNREACH 2 /* Protocol Unreachable */
67#define ICMP_PORT_UNREACH 3 /* Port Unreachable */
68#define ICMP_FRAG_NEEDED 4 /* Fragmentation Needed/DF set */
69#define ICMP_SR_FAILED 5 /* Source Route failed */
70#define ICMP_NET_UNKNOWN 6
71#define ICMP_HOST_UNKNOWN 7
72#define ICMP_HOST_ISOLATED 8
73#define ICMP_NET_ANO 9
74#define ICMP_HOST_ANO 10
75#define ICMP_NET_UNR_TOS 11
76#define ICMP_HOST_UNR_TOS 12
77#define ICMP_PKT_FILTERED 13 /* Packet filtered */
78#define ICMP_PREC_VIOLATION 14 /* Precedence violation */
79#define ICMP_PREC_CUTOFF 15 /* Precedence cut off */
80#define NR_ICMP_UNREACH 15 /* instead of hardcoding immediate value */
81
82/* Codes for REDIRECT. */
83#define ICMP_REDIR_NET 0 /* Redirect Net */
84#define ICMP_REDIR_HOST 1 /* Redirect Host */
85#define ICMP_REDIR_NETTOS 2 /* Redirect Net for TOS */
86#define ICMP_REDIR_HOSTTOS 3 /* Redirect Host for TOS */
87
88/* Codes for TIME_EXCEEDED. */
89#define ICMP_EXC_TTL 0 /* TTL count exceeded */
90#define ICMP_EXC_FRAGTIME 1 /* Fragment Reass time exceeded */
91
92
93#ifdef __USE_MISC
94/*
95 * Copyright (c) 1982, 1986, 1993
96 * The Regents of the University of California. All rights reserved.
97 *
98 * Redistribution and use in source and binary forms, with or without
99 * modification, are permitted provided that the following conditions
100 * are met:
101 * 1. Redistributions of source code must retain the above copyright
102 * notice, this list of conditions and the following disclaimer.
103 * 2. Redistributions in binary form must reproduce the above copyright
104 * notice, this list of conditions and the following disclaimer in the
105 * documentation and/or other materials provided with the distribution.
106 * 4. Neither the name of the University nor the names of its contributors
107 * may be used to endorse or promote products derived from this software
108 * without specific prior written permission.
109 *
110 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
111 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
112 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
113 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
114 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
115 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
116 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
117 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
118 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
119 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
120 * SUCH DAMAGE.
121 *
122 * @(#)ip_icmp.h 8.1 (Berkeley) 6/10/93
123 */
124
125#include <netinet/in.h>
126#include <netinet/ip.h>
127
128/*
129 * Internal of an ICMP Router Advertisement
130 */
131struct icmp_ra_addr
132{
133 uint32_t ira_addr;
134 uint32_t ira_preference;
135};
136
137struct icmp
138{
139 uint8_t icmp_type; /* type of message, see below */
140 uint8_t icmp_code; /* type sub code */
141 uint16_t icmp_cksum; /* ones complement checksum of struct */
142 union
143 {
144 unsigned char ih_pptr; /* ICMP_PARAMPROB */
145 struct in_addr ih_gwaddr; /* gateway address */
146 struct ih_idseq /* echo datagram */
147 {
148 uint16_t icd_id;
149 uint16_t icd_seq;
150 } ih_idseq;
151 uint32_t ih_void;
152
153 /* ICMP_UNREACH_NEEDFRAG -- Path MTU Discovery (RFC1191) */
154 struct ih_pmtu
155 {
156 uint16_t ipm_void;
157 uint16_t ipm_nextmtu;
158 } ih_pmtu;
159
160 struct ih_rtradv
161 {
162 uint8_t irt_num_addrs;
163 uint8_t irt_wpa;
164 uint16_t irt_lifetime;
165 } ih_rtradv;
166 } icmp_hun;
167#define icmp_pptr icmp_hun.ih_pptr
168#define icmp_gwaddr icmp_hun.ih_gwaddr
169#define icmp_id icmp_hun.ih_idseq.icd_id
170#define icmp_seq icmp_hun.ih_idseq.icd_seq
171#define icmp_void icmp_hun.ih_void
172#define icmp_pmvoid icmp_hun.ih_pmtu.ipm_void
173#define icmp_nextmtu icmp_hun.ih_pmtu.ipm_nextmtu
174#define icmp_num_addrs icmp_hun.ih_rtradv.irt_num_addrs
175#define icmp_wpa icmp_hun.ih_rtradv.irt_wpa
176#define icmp_lifetime icmp_hun.ih_rtradv.irt_lifetime
177 union
178 {
179 struct
180 {
181 uint32_t its_otime;
182 uint32_t its_rtime;
183 uint32_t its_ttime;
184 } id_ts;
185 struct
186 {
187 struct ip idi_ip;
188 /* options and then 64 bits of data */
189 } id_ip;
190 struct icmp_ra_addr id_radv;
191 uint32_t id_mask;
192 uint8_t id_data[1];
193 } icmp_dun;
194#define icmp_otime icmp_dun.id_ts.its_otime
195#define icmp_rtime icmp_dun.id_ts.its_rtime
196#define icmp_ttime icmp_dun.id_ts.its_ttime
197#define icmp_ip icmp_dun.id_ip.idi_ip
198#define icmp_radv icmp_dun.id_radv
199#define icmp_mask icmp_dun.id_mask
200#define icmp_data icmp_dun.id_data
201};
202
203/*
204 * Lower bounds on packet lengths for various types.
205 * For the error advice packets must first insure that the
206 * packet is large enough to contain the returned ip header.
207 * Only then can we do the check to see if 64 bits of packet
208 * data have been returned, since we need to check the returned
209 * ip header length.
210 */
211#define ICMP_MINLEN 8 /* abs minimum */
212#define ICMP_TSLEN (8 + 3 * sizeof (n_time)) /* timestamp */
213#define ICMP_MASKLEN 12 /* address mask */
214#define ICMP_ADVLENMIN (8 + sizeof (struct ip) + 8) /* min */
215#ifndef _IP_VHL
216#define ICMP_ADVLEN(p) (8 + ((p)->icmp_ip.ip_hl << 2) + 8)
217 /* N.B.: must separately check that ip_hl >= 5 */
218#else
219#define ICMP_ADVLEN(p) (8 + (IP_VHL_HL((p)->icmp_ip.ip_vhl) << 2) + 8)
220 /* N.B.: must separately check that header length >= 5 */
221#endif
222
223/* Definition of type and code fields. */
224/* defined above: ICMP_ECHOREPLY, ICMP_REDIRECT, ICMP_ECHO */
225#define ICMP_UNREACH 3 /* dest unreachable, codes: */
226#define ICMP_SOURCEQUENCH 4 /* packet lost, slow down */
227#define ICMP_ROUTERADVERT 9 /* router advertisement */
228#define ICMP_ROUTERSOLICIT 10 /* router solicitation */
229#define ICMP_TIMXCEED 11 /* time exceeded, code: */
230#define ICMP_PARAMPROB 12 /* ip header bad */
231#define ICMP_TSTAMP 13 /* timestamp request */
232#define ICMP_TSTAMPREPLY 14 /* timestamp reply */
233#define ICMP_IREQ 15 /* information request */
234#define ICMP_IREQREPLY 16 /* information reply */
235#define ICMP_MASKREQ 17 /* address mask request */
236#define ICMP_MASKREPLY 18 /* address mask reply */
237
238#define ICMP_MAXTYPE 18
239
240/* UNREACH codes */
241#define ICMP_UNREACH_NET 0 /* bad net */
242#define ICMP_UNREACH_HOST 1 /* bad host */
243#define ICMP_UNREACH_PROTOCOL 2 /* bad protocol */
244#define ICMP_UNREACH_PORT 3 /* bad port */
245#define ICMP_UNREACH_NEEDFRAG 4 /* IP_DF caused drop */
246#define ICMP_UNREACH_SRCFAIL 5 /* src route failed */
247#define ICMP_UNREACH_NET_UNKNOWN 6 /* unknown net */
248#define ICMP_UNREACH_HOST_UNKNOWN 7 /* unknown host */
249#define ICMP_UNREACH_ISOLATED 8 /* src host isolated */
250#define ICMP_UNREACH_NET_PROHIB 9 /* net denied */
251#define ICMP_UNREACH_HOST_PROHIB 10 /* host denied */
252#define ICMP_UNREACH_TOSNET 11 /* bad tos for net */
253#define ICMP_UNREACH_TOSHOST 12 /* bad tos for host */
254#define ICMP_UNREACH_FILTER_PROHIB 13 /* admin prohib */
255#define ICMP_UNREACH_HOST_PRECEDENCE 14 /* host prec vio. */
256#define ICMP_UNREACH_PRECEDENCE_CUTOFF 15 /* prec cutoff */
257
258/* REDIRECT codes */
259#define ICMP_REDIRECT_NET 0 /* for network */
260#define ICMP_REDIRECT_HOST 1 /* for host */
261#define ICMP_REDIRECT_TOSNET 2 /* for tos and net */
262#define ICMP_REDIRECT_TOSHOST 3 /* for tos and host */
263
264/* TIMEXCEED codes */
265#define ICMP_TIMXCEED_INTRANS 0 /* ttl==0 in transit */
266#define ICMP_TIMXCEED_REASS 1 /* ttl==0 in reass */
267
268/* PARAMPROB code */
269#define ICMP_PARAMPROB_OPTABSENT 1 /* req. opt. absent */
270
271#define ICMP_INFOTYPE(type) \
272 ((type) == ICMP_ECHOREPLY || (type) == ICMP_ECHO || \
273 (type) == ICMP_ROUTERADVERT || (type) == ICMP_ROUTERSOLICIT || \
274 (type) == ICMP_TSTAMP || (type) == ICMP_TSTAMPREPLY || \
275 (type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || \
276 (type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY)
277
278#endif /* __USE_MISC */
279
280__END_DECLS
281
282#endif /* netinet/ip_icmp.h */
libc/glibc-include/netinet/tcp.h created+348
...@@ -0,0 +1,348 @@
1/*
2 * Copyright (c) 1982, 1986, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 4. Neither the name of the University nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * @(#)tcp.h 8.1 (Berkeley) 6/10/93
30 */
31
32#ifndef _NETINET_TCP_H
33#define _NETINET_TCP_H 1
34
35#include <features.h>
36
37/*
38 * User-settable options (used with setsockopt).
39 */
40#define TCP_NODELAY 1 /* Don't delay send to coalesce packets */
41#define TCP_MAXSEG 2 /* Set maximum segment size */
42#define TCP_CORK 3 /* Control sending of partial frames */
43#define TCP_KEEPIDLE 4 /* Start keeplives after this period */
44#define TCP_KEEPINTVL 5 /* Interval between keepalives */
45#define TCP_KEEPCNT 6 /* Number of keepalives before death */
46#define TCP_SYNCNT 7 /* Number of SYN retransmits */
47#define TCP_LINGER2 8 /* Life time of orphaned FIN-WAIT-2 state */
48#define TCP_DEFER_ACCEPT 9 /* Wake up listener only when data arrive */
49#define TCP_WINDOW_CLAMP 10 /* Bound advertised window */
50#define TCP_INFO 11 /* Information about this connection. */
51#define TCP_QUICKACK 12 /* Bock/reenable quick ACKs. */
52#define TCP_CONGESTION 13 /* Congestion control algorithm. */
53#define TCP_MD5SIG 14 /* TCP MD5 Signature (RFC2385) */
54#define TCP_COOKIE_TRANSACTIONS 15 /* TCP Cookie Transactions */
55#define TCP_THIN_LINEAR_TIMEOUTS 16 /* Use linear timeouts for thin streams*/
56#define TCP_THIN_DUPACK 17 /* Fast retrans. after 1 dupack */
57#define TCP_USER_TIMEOUT 18 /* How long for loss retry before timeout */
58#define TCP_REPAIR 19 /* TCP sock is under repair right now */
59#define TCP_REPAIR_QUEUE 20 /* Set TCP queue to repair */
60#define TCP_QUEUE_SEQ 21 /* Set sequence number of repaired queue. */
61#define TCP_REPAIR_OPTIONS 22 /* Repair TCP connection options */
62#define TCP_FASTOPEN 23 /* Enable FastOpen on listeners */
63#define TCP_TIMESTAMP 24 /* TCP time stamp */
64#define TCP_NOTSENT_LOWAT 25 /* Limit number of unsent bytes in
65 write queue. */
66#define TCP_CC_INFO 26 /* Get Congestion Control
67 (optional) info. */
68#define TCP_SAVE_SYN 27 /* Record SYN headers for new
69 connections. */
70#define TCP_SAVED_SYN 28 /* Get SYN headers recorded for
71 connection. */
72#define TCP_REPAIR_WINDOW 29 /* Get/set window parameters. */
73#define TCP_FASTOPEN_CONNECT 30 /* Attempt FastOpen with connect. */
74#define TCP_ULP 31 /* Attach a ULP to a TCP connection. */
75#define TCP_MD5SIG_EXT 32 /* TCP MD5 Signature with extensions. */
76#define TCP_FASTOPEN_KEY 33 /* Set the key for Fast Open (cookie). */
77#define TCP_FASTOPEN_NO_COOKIE 34 /* Enable TFO without a TFO cookie. */
78#define TCP_ZEROCOPY_RECEIVE 35
79#define TCP_INQ 36 /* Notify bytes available to read
80 as a cmsg on read. */
81#define TCP_CM_INQ TCP_INQ
82
83#define TCP_REPAIR_ON 1
84#define TCP_REPAIR_OFF 0
85#define TCP_REPAIR_OFF_NO_WP -1
86
87#ifdef __USE_MISC
88# include <sys/types.h>
89# include <sys/socket.h>
90# include <stdint.h>
91
92typedef uint32_t tcp_seq;
93/*
94 * TCP header.
95 * Per RFC 793, September, 1981.
96 */
97struct tcphdr
98 {
99 __extension__ union
100 {
101 struct
102 {
103 uint16_t th_sport; /* source port */
104 uint16_t th_dport; /* destination port */
105 tcp_seq th_seq; /* sequence number */
106 tcp_seq th_ack; /* acknowledgement number */
107# if __BYTE_ORDER == __LITTLE_ENDIAN
108 uint8_t th_x2:4; /* (unused) */
109 uint8_t th_off:4; /* data offset */
110# endif
111# if __BYTE_ORDER == __BIG_ENDIAN
112 uint8_t th_off:4; /* data offset */
113 uint8_t th_x2:4; /* (unused) */
114# endif
115 uint8_t th_flags;
116# define TH_FIN 0x01
117# define TH_SYN 0x02
118# define TH_RST 0x04
119# define TH_PUSH 0x08
120# define TH_ACK 0x10
121# define TH_URG 0x20
122 uint16_t th_win; /* window */
123 uint16_t th_sum; /* checksum */
124 uint16_t th_urp; /* urgent pointer */
125 };
126 struct
127 {
128 uint16_t source;
129 uint16_t dest;
130 uint32_t seq;
131 uint32_t ack_seq;
132# if __BYTE_ORDER == __LITTLE_ENDIAN
133 uint16_t res1:4;
134 uint16_t doff:4;
135 uint16_t fin:1;
136 uint16_t syn:1;
137 uint16_t rst:1;
138 uint16_t psh:1;
139 uint16_t ack:1;
140 uint16_t urg:1;
141 uint16_t res2:2;
142# elif __BYTE_ORDER == __BIG_ENDIAN
143 uint16_t doff:4;
144 uint16_t res1:4;
145 uint16_t res2:2;
146 uint16_t urg:1;
147 uint16_t ack:1;
148 uint16_t psh:1;
149 uint16_t rst:1;
150 uint16_t syn:1;
151 uint16_t fin:1;
152# else
153# error "Adjust your <bits/endian.h> defines"
154# endif
155 uint16_t window;
156 uint16_t check;
157 uint16_t urg_ptr;
158 };
159 };
160};
161
162enum
163{
164 TCP_ESTABLISHED = 1,
165 TCP_SYN_SENT,
166 TCP_SYN_RECV,
167 TCP_FIN_WAIT1,
168 TCP_FIN_WAIT2,
169 TCP_TIME_WAIT,
170 TCP_CLOSE,
171 TCP_CLOSE_WAIT,
172 TCP_LAST_ACK,
173 TCP_LISTEN,
174 TCP_CLOSING /* now a valid state */
175};
176
177# define TCPOPT_EOL 0
178# define TCPOPT_NOP 1
179# define TCPOPT_MAXSEG 2
180# define TCPOLEN_MAXSEG 4
181# define TCPOPT_WINDOW 3
182# define TCPOLEN_WINDOW 3
183# define TCPOPT_SACK_PERMITTED 4 /* Experimental */
184# define TCPOLEN_SACK_PERMITTED 2
185# define TCPOPT_SACK 5 /* Experimental */
186# define TCPOPT_TIMESTAMP 8
187# define TCPOLEN_TIMESTAMP 10
188# define TCPOLEN_TSTAMP_APPA (TCPOLEN_TIMESTAMP+2) /* appendix A */
189
190# define TCPOPT_TSTAMP_HDR \
191 (TCPOPT_NOP<<24|TCPOPT_NOP<<16|TCPOPT_TIMESTAMP<<8|TCPOLEN_TIMESTAMP)
192
193/*
194 * Default maximum segment size for TCP.
195 * With an IP MSS of 576, this is 536,
196 * but 512 is probably more convenient.
197 * This should be defined as MIN(512, IP_MSS - sizeof (struct tcpiphdr)).
198 */
199# define TCP_MSS 512
200
201# define TCP_MAXWIN 65535 /* largest value for (unscaled) window */
202
203# define TCP_MAX_WINSHIFT 14 /* maximum window shift */
204
205# define SOL_TCP 6 /* TCP level */
206
207
208# define TCPI_OPT_TIMESTAMPS 1
209# define TCPI_OPT_SACK 2
210# define TCPI_OPT_WSCALE 4
211# define TCPI_OPT_ECN 8 /* ECN was negociated at TCP session init */
212# define TCPI_OPT_ECN_SEEN 16 /* we received at least one packet with ECT */
213# define TCPI_OPT_SYN_DATA 32 /* SYN-ACK acked data in SYN sent or rcvd */
214
215/* Values for tcpi_state. */
216enum tcp_ca_state
217{
218 TCP_CA_Open = 0,
219 TCP_CA_Disorder = 1,
220 TCP_CA_CWR = 2,
221 TCP_CA_Recovery = 3,
222 TCP_CA_Loss = 4
223};
224
225struct tcp_info
226{
227 uint8_t tcpi_state;
228 uint8_t tcpi_ca_state;
229 uint8_t tcpi_retransmits;
230 uint8_t tcpi_probes;
231 uint8_t tcpi_backoff;
232 uint8_t tcpi_options;
233 uint8_t tcpi_snd_wscale : 4, tcpi_rcv_wscale : 4;
234
235 uint32_t tcpi_rto;
236 uint32_t tcpi_ato;
237 uint32_t tcpi_snd_mss;
238 uint32_t tcpi_rcv_mss;
239
240 uint32_t tcpi_unacked;
241 uint32_t tcpi_sacked;
242 uint32_t tcpi_lost;
243 uint32_t tcpi_retrans;
244 uint32_t tcpi_fackets;
245
246 /* Times. */
247 uint32_t tcpi_last_data_sent;
248 uint32_t tcpi_last_ack_sent; /* Not remembered, sorry. */
249 uint32_t tcpi_last_data_recv;
250 uint32_t tcpi_last_ack_recv;
251
252 /* Metrics. */
253 uint32_t tcpi_pmtu;
254 uint32_t tcpi_rcv_ssthresh;
255 uint32_t tcpi_rtt;
256 uint32_t tcpi_rttvar;
257 uint32_t tcpi_snd_ssthresh;
258 uint32_t tcpi_snd_cwnd;
259 uint32_t tcpi_advmss;
260 uint32_t tcpi_reordering;
261
262 uint32_t tcpi_rcv_rtt;
263 uint32_t tcpi_rcv_space;
264
265 uint32_t tcpi_total_retrans;
266};
267
268
269/* For TCP_MD5SIG socket option. */
270#define TCP_MD5SIG_MAXKEYLEN 80
271
272/* tcp_md5sig extension flags for TCP_MD5SIG_EXT. */
273#define TCP_MD5SIG_FLAG_PREFIX 1 /* Address prefix length. */
274
275struct tcp_md5sig
276{
277 struct sockaddr_storage tcpm_addr; /* Address associated. */
278 uint8_t tcpm_flags; /* Extension flags. */
279 uint8_t tcpm_prefixlen; /* Address prefix. */
280 uint16_t tcpm_keylen; /* Key length. */
281 uint32_t __tcpm_pad; /* Zero. */
282 uint8_t tcpm_key[TCP_MD5SIG_MAXKEYLEN]; /* Key (binary). */
283};
284
285/* For socket repair options. */
286struct tcp_repair_opt
287{
288 uint32_t opt_code;
289 uint32_t opt_val;
290};
291
292/* Queue to repair, for TCP_REPAIR_QUEUE. */
293enum
294{
295 TCP_NO_QUEUE,
296 TCP_RECV_QUEUE,
297 TCP_SEND_QUEUE,
298 TCP_QUEUES_NR,
299};
300
301/* For cookie transactions socket options. */
302#define TCP_COOKIE_MIN 8 /* 64-bits */
303#define TCP_COOKIE_MAX 16 /* 128-bits */
304#define TCP_COOKIE_PAIR_SIZE (2*TCP_COOKIE_MAX)
305
306/* Flags for both getsockopt and setsockopt */
307#define TCP_COOKIE_IN_ALWAYS (1 << 0) /* Discard SYN without cookie */
308#define TCP_COOKIE_OUT_NEVER (1 << 1) /* Prohibit outgoing cookies,
309 * supercedes everything. */
310
311/* Flags for getsockopt */
312#define TCP_S_DATA_IN (1 << 2) /* Was data received? */
313#define TCP_S_DATA_OUT (1 << 3) /* Was data sent? */
314
315#define TCP_MSS_DEFAULT 536U /* IPv4 (RFC1122, RFC2581) */
316#define TCP_MSS_DESIRED 1220U /* IPv6 (tunneled), EDNS0 (RFC3226) */
317
318struct tcp_cookie_transactions
319{
320 uint16_t tcpct_flags;
321 uint8_t __tcpct_pad1;
322 uint8_t tcpct_cookie_desired;
323 uint16_t tcpct_s_data_desired;
324 uint16_t tcpct_used;
325 uint8_t tcpct_value[TCP_MSS_DEFAULT];
326};
327
328/* For use with TCP_REPAIR_WINDOW. */
329struct tcp_repair_window
330{
331 uint32_t snd_wl1;
332 uint32_t snd_wnd;
333 uint32_t max_window;
334 uint32_t rcv_wnd;
335 uint32_t rcv_wup;
336};
337
338/* For use with TCP_ZEROCOPY_RECEIVE. */
339struct tcp_zerocopy_receive
340{
341 uint64_t address; /* In: address of mapping. */
342 uint32_t length; /* In/out: number of bytes to map/mapped. */
343 uint32_t recv_skip_hint; /* Out: amount of bytes to skip. */
344};
345
346#endif /* Misc. */
347
348#endif /* netinet/tcp.h */
libc/glibc-include/netinet/udp.h created+95
...@@ -0,0 +1,95 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/*
19 * Copyright (C) 1982, 1986 Regents of the University of California.
20 * All rights reserved.
21 *
22 * Redistribution and use in source and binary forms, with or without
23 * modification, are permitted provided that the following conditions
24 * are met:
25 * 1. Redistributions of source code must retain the above copyright
26 * notice, this list of conditions and the following disclaimer.
27 * 2. Redistributions in binary form must reproduce the above copyright
28 * notice, this list of conditions and the following disclaimer in the
29 * documentation and/or other materials provided with the distribution.
30 * 4. Neither the name of the University nor the names of its contributors
31 * may be used to endorse or promote products derived from this software
32 * without specific prior written permission.
33 *
34 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
35 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
36 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
37 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
38 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
39 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
40 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
41 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
42 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
43 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
44 * SUCH DAMAGE.
45 */
46
47#ifndef __NETINET_UDP_H
48#define __NETINET_UDP_H 1
49
50#include <sys/types.h>
51#include <stdint.h>
52
53/* UDP header as specified by RFC 768, August 1980. */
54
55struct udphdr
56{
57 __extension__ union
58 {
59 struct
60 {
61 uint16_t uh_sport; /* source port */
62 uint16_t uh_dport; /* destination port */
63 uint16_t uh_ulen; /* udp length */
64 uint16_t uh_sum; /* udp checksum */
65 };
66 struct
67 {
68 uint16_t source;
69 uint16_t dest;
70 uint16_t len;
71 uint16_t check;
72 };
73 };
74};
75
76/* UDP socket options */
77#define UDP_CORK 1 /* Never send partially complete segments. */
78#define UDP_ENCAP 100 /* Set the socket to accept
79 encapsulated packets. */
80#define UDP_NO_CHECK6_TX 101 /* Disable sending checksum for UDP
81 over IPv6. */
82#define UDP_NO_CHECK6_RX 102 /* Disable accepting checksum for UDP
83 over IPv6. */
84#define UDP_SEGMENT 103 /* Set GSO segmentation size. */
85
86/* UDP encapsulation types */
87#define UDP_ENCAP_ESPINUDP_NON_IKE 1 /* draft-ietf-ipsec-nat-t-ike-00/01 */
88#define UDP_ENCAP_ESPINUDP 2 /* draft-ietf-ipsec-udp-encaps-06 */
89#define UDP_ENCAP_L2TPINUDP 3 /* rfc2661 */
90#define UDP_ENCAP_GTP0 4 /* GSM TS 09.60 */
91#define UDP_ENCAP_GTP1U 5 /* 3GPP TS 29.060 */
92
93#define SOL_UDP 17 /* sockopt level for UDP */
94
95#endif /* netinet/udp.h */
libc/glibc-include/netipx/ipx.h created+111
...@@ -0,0 +1,111 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef __NETIPX_IPX_H
19#define __NETIPX_IPX_H 1
20
21#include <sys/types.h>
22#include <stdint.h>
23#include <bits/sockaddr.h>
24
25__BEGIN_DECLS
26
27#define SOL_IPX 256 /* sockopt level */
28
29#define IPX_TYPE 1
30#define IPX_NODE_LEN 6
31#define IPX_MTU 576
32
33struct sockaddr_ipx
34 {
35 sa_family_t sipx_family;
36 uint16_t sipx_port;
37 uint32_t sipx_network;
38 unsigned char sipx_node[IPX_NODE_LEN];
39 uint8_t sipx_type;
40 unsigned char sipx_zero; /* 16 byte fill */
41 };
42
43/*
44 * So we can fit the extra info for SIOCSIFADDR into the address nicely
45 */
46
47#define sipx_special sipx_port
48#define sipx_action sipx_zero
49#define IPX_DLTITF 0
50#define IPX_CRTITF 1
51
52typedef struct ipx_route_definition
53 {
54 unsigned long ipx_network;
55 unsigned long ipx_router_network;
56 unsigned char ipx_router_node[IPX_NODE_LEN];
57 }
58ipx_route_definition;
59
60typedef struct ipx_interface_definition
61 {
62 unsigned long ipx_network;
63 unsigned char ipx_device[16];
64 unsigned char ipx_dlink_type;
65#define IPX_FRAME_NONE 0
66#define IPX_FRAME_SNAP 1
67#define IPX_FRAME_8022 2
68#define IPX_FRAME_ETHERII 3
69#define IPX_FRAME_8023 4
70#define IPX_FRAME_TR_8022 5
71 unsigned char ipx_special;
72#define IPX_SPECIAL_NONE 0
73#define IPX_PRIMARY 1
74#define IPX_INTERNAL 2
75 unsigned char ipx_node[IPX_NODE_LEN];
76 }
77ipx_interface_definition;
78
79typedef struct ipx_config_data
80 {
81 unsigned char ipxcfg_auto_select_primary;
82 unsigned char ipxcfg_auto_create_interfaces;
83 }
84ipx_config_data;
85
86/*
87 * OLD Route Definition for backward compatibility.
88 */
89
90struct ipx_route_def
91 {
92 unsigned long ipx_network;
93 unsigned long ipx_router_network;
94#define IPX_ROUTE_NO_ROUTER 0
95 unsigned char ipx_router_node[IPX_NODE_LEN];
96 unsigned char ipx_device[16];
97 unsigned short ipx_flags;
98#define IPX_RT_SNAP 8
99#define IPX_RT_8022 4
100#define IPX_RT_BLUEBOOK 2
101#define IPX_RT_ROUTED 1
102 };
103
104#define SIOCAIPXITFCRT (SIOCPROTOPRIVATE)
105#define SIOCAIPXPRISLT (SIOCPROTOPRIVATE + 1)
106#define SIOCIPXCFGDATA (SIOCPROTOPRIVATE + 2)
107#define SIOCIPXNCPCONN (SIOCPROTOPRIVATE + 3)
108
109__END_DECLS
110
111#endif /* netipx/ipx.h */
libc/glibc-include/netiucv/iucv.h created+48
...@@ -0,0 +1,48 @@
1/* Copyright (C) 2007-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef __NETIUCV_IUCV_H
19#define __NETIUCV_IUCV_H 1
20
21#include <features.h>
22#include <bits/sockaddr.h>
23
24__BEGIN_DECLS
25
26struct sockaddr_iucv
27 {
28 __SOCKADDR_COMMON (siucv_);
29 unsigned short siucv_port; /* Reserved */
30 unsigned int siucv_addr; /* Reserved */
31 char siucv_nodeid[8]; /* Reserved */
32 char siucv_user_id[8]; /* Guest User Id */
33 char siucv_name[8]; /* Application Name */
34 };
35
36__END_DECLS
37
38#define SOL_IUCV 277 /* IUCV level */
39
40/* IUCV socket options (SOL_IUCV) */
41#define SO_IPRMDATA_MSG 0x0080 /* Send/recv IPRM_DATA msgs */
42#define SO_MSGLIMIT 0x1000 /* Get/set IUCV MSGLIMIT */
43#define SO_MSGSIZE 0x0800 /* Get maximum msgsize */
44
45/* IUCV related control messages (scm) */
46#define SCM_IUCV_TRGCLS 0x0001 /* Target class control message */
47
48#endif
libc/glibc-include/netpacket/packet.h created+81
...@@ -0,0 +1,81 @@
1/* Definitions for use with Linux AF_PACKET sockets.
2 Copyright (C) 1998-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef __NETPACKET_PACKET_H
20#define __NETPACKET_PACKET_H 1
21
22struct sockaddr_ll
23 {
24 unsigned short int sll_family;
25 unsigned short int sll_protocol;
26 int sll_ifindex;
27 unsigned short int sll_hatype;
28 unsigned char sll_pkttype;
29 unsigned char sll_halen;
30 unsigned char sll_addr[8];
31 };
32
33/* Packet types. */
34
35#define PACKET_HOST 0 /* To us. */
36#define PACKET_BROADCAST 1 /* To all. */
37#define PACKET_MULTICAST 2 /* To group. */
38#define PACKET_OTHERHOST 3 /* To someone else. */
39#define PACKET_OUTGOING 4 /* Originated by us . */
40#define PACKET_LOOPBACK 5
41#define PACKET_FASTROUTE 6
42
43/* Packet socket options. */
44
45#define PACKET_ADD_MEMBERSHIP 1
46#define PACKET_DROP_MEMBERSHIP 2
47#define PACKET_RECV_OUTPUT 3
48#define PACKET_RX_RING 5
49#define PACKET_STATISTICS 6
50#define PACKET_COPY_THRESH 7
51#define PACKET_AUXDATA 8
52#define PACKET_ORIGDEV 9
53#define PACKET_VERSION 10
54#define PACKET_HDRLEN 11
55#define PACKET_RESERVE 12
56#define PACKET_TX_RING 13
57#define PACKET_LOSS 14
58#define PACKET_VNET_HDR 15
59#define PACKET_TX_TIMESTAMP 16
60#define PACKET_TIMESTAMP 17
61#define PACKET_FANOUT 18
62#define PACKET_TX_HAS_OFF 19
63#define PACKET_QDISC_BYPASS 20
64#define PACKET_ROLLOVER_STATS 21
65#define PACKET_FANOUT_DATA 22
66#define PACKET_IGNORE_OUTGOING 23
67
68struct packet_mreq
69 {
70 int mr_ifindex;
71 unsigned short int mr_type;
72 unsigned short int mr_alen;
73 unsigned char mr_address[8];
74 };
75
76#define PACKET_MR_MULTICAST 0
77#define PACKET_MR_PROMISC 1
78#define PACKET_MR_ALLMULTI 2
79#define PACKET_MR_UNICAST 3
80
81#endif /* netpacket/packet.h */
libc/glibc-include/netrom/netrom.h created+83
...@@ -0,0 +1,83 @@
1/* Copyright (C) 1997-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _NETROM_NETROM_H
19#define _NETROM_NETROM_H 1
20
21#include <netax25/ax25.h>
22
23/* Setsockoptions(2) level. Thanks to BSD these must match IPPROTO_xxx. */
24#define SOL_NETROM 259
25
26/* NetRom control values: */
27#define NETROM_T1 1
28#define NETROM_T2 2
29#define NETROM_N2 3
30#define NETROM_PACLEN 5
31#define NETROM_T4 6
32#define NETROM_IDLE 7
33
34#define NETROM_KILL 99
35
36/* Type of route: */
37#define NETROM_NEIGH 0
38#define NETROM_NODE 1
39
40struct nr_route_struct
41 {
42 int type;
43 ax25_address callsign;
44 char device[16];
45 unsigned int quality;
46 char mnemonic[7];
47 ax25_address neighbour;
48 unsigned int obs_count;
49 unsigned int ndigis;
50 ax25_address digipeaters[AX25_MAX_DIGIS];
51 };
52
53/* NetRom socket ioctls: */
54#define SIOCNRGETPARMS (SIOCPROTOPRIVATE+0)
55#define SIOCNRSETPARMS (SIOCPROTOPRIVATE+1)
56#define SIOCNRDECOBS (SIOCPROTOPRIVATE+2)
57#define SIOCNRRTCTL (SIOCPROTOPRIVATE+3)
58#define SIOCNRCTLCON (SIOCPROTOPRIVATE+4)
59
60/* NetRom parameter structure: */
61struct nr_parms_struct
62 {
63 unsigned int quality;
64 unsigned int obs_count;
65 unsigned int ttl;
66 unsigned int timeout;
67 unsigned int ack_delay;
68 unsigned int busy_delay;
69 unsigned int tries;
70 unsigned int window;
71 unsigned int paclen;
72 };
73
74/* NetRom control structure: */
75struct nr_ctl_struct
76 {
77 unsigned char index;
78 unsigned char id;
79 unsigned int cmd;
80 unsigned long arg;
81 };
82
83#endif /* netrom/netrom.h */
libc/glibc-include/netrose/rose.h created+118
...@@ -0,0 +1,118 @@
1/* Definitions for Rose packet radio address family.
2 Copyright (C) 1998-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19/* What follows is copied from the 2.1.93 <linux/rose.h>. */
20
21#ifndef _NETROSE_ROSE_H
22#define _NETROSE_ROSE_H 1
23
24#include <sys/socket.h>
25#include <netax25/ax25.h>
26
27/* Socket level values. */
28#define SOL_ROSE 260
29
30
31/* These are the public elements of the Linux kernel Rose
32 implementation. For kernel AX.25 see the file ax25.h. This file
33 requires ax25.h for the definition of the ax25_address structure. */
34#define ROSE_MTU 251
35
36#define ROSE_MAX_DIGIS 6
37
38#define ROSE_DEFER 1
39#define ROSE_T1 2
40#define ROSE_T2 3
41#define ROSE_T3 4
42#define ROSE_IDLE 5
43#define ROSE_QBITINCL 6
44#define ROSE_HOLDBACK 7
45
46#define SIOCRSGCAUSE (SIOCPROTOPRIVATE + 0)
47#define SIOCRSSCAUSE (SIOCPROTOPRIVATE + 1)
48#define SIOCRSL2CALL (SIOCPROTOPRIVATE + 2)
49#define SIOCRSSL2CALL (SIOCPROTOPRIVATE + 2)
50#define SIOCRSACCEPT (SIOCPROTOPRIVATE + 3)
51#define SIOCRSCLRRT (SIOCPROTOPRIVATE + 4)
52#define SIOCRSGL2CALL (SIOCPROTOPRIVATE + 5)
53#define SIOCRSGFACILITIES (SIOCPROTOPRIVATE + 6)
54
55#define ROSE_DTE_ORIGINATED 0x00
56#define ROSE_NUMBER_BUSY 0x01
57#define ROSE_INVALID_FACILITY 0x03
58#define ROSE_NETWORK_CONGESTION 0x05
59#define ROSE_OUT_OF_ORDER 0x09
60#define ROSE_ACCESS_BARRED 0x0B
61#define ROSE_NOT_OBTAINABLE 0x0D
62#define ROSE_REMOTE_PROCEDURE 0x11
63#define ROSE_LOCAL_PROCEDURE 0x13
64#define ROSE_SHIP_ABSENT 0x39
65
66
67typedef struct
68{
69 char rose_addr[5];
70} rose_address;
71
72struct sockaddr_rose
73{
74 sa_family_t srose_family;
75 rose_address srose_addr;
76 ax25_address srose_call;
77 int srose_ndigis;
78 ax25_address srose_digi;
79};
80
81struct full_sockaddr_rose
82{
83 sa_family_t srose_family;
84 rose_address srose_addr;
85 ax25_address srose_call;
86 unsigned int srose_ndigis;
87 ax25_address srose_digis[ROSE_MAX_DIGIS];
88};
89
90struct rose_route_struct
91{
92 rose_address address;
93 unsigned short int mask;
94 ax25_address neighbour;
95 char device[16];
96 unsigned char ndigis;
97 ax25_address digipeaters[AX25_MAX_DIGIS];
98};
99
100struct rose_cause_struct
101{
102 unsigned char cause;
103 unsigned char diagnostic;
104};
105
106struct rose_facilities_struct
107{
108 rose_address source_addr, dest_addr;
109 ax25_address source_call, dest_call;
110 unsigned char source_ndigis, dest_ndigis;
111 ax25_address source_digis[ROSE_MAX_DIGIS];
112 ax25_address dest_digis[ROSE_MAX_DIGIS];
113 unsigned int rand;
114 rose_address fail_addr;
115 ax25_address fail_call;
116};
117
118#endif /* netrose/rose.h */
libc/glibc-include/nfs/nfs.h created+1
...@@ -0,0 +1 @@
1#include <linux/nfs.h>
libc/glibc-include/nl_types.h created+54
...@@ -0,0 +1,54 @@
1/* Copyright (C) 1996-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _NL_TYPES_H
19#define _NL_TYPES_H 1
20
21#include <features.h>
22
23/* The default message set used by the gencat program. */
24#define NL_SETD 1
25
26/* Value for FLAG parameter of `catgets' to say we want XPG4 compliance. */
27#define NL_CAT_LOCALE 1
28
29
30__BEGIN_DECLS
31
32/* Message catalog descriptor type. */
33typedef void *nl_catd;
34
35/* Type used by `nl_langinfo'. */
36typedef int nl_item;
37
38/* Open message catalog for later use, returning descriptor.
39
40 This function is a possible cancellation point and therefore not
41 marked with __THROW. */
42extern nl_catd catopen (const char *__cat_name, int __flag) __nonnull ((1));
43
44/* Return translation with NUMBER in SET of CATALOG; if not found
45 return STRING. */
46extern char *catgets (nl_catd __catalog, int __set, int __number,
47 const char *__string) __THROW __nonnull ((1));
48
49/* Close message CATALOG. */
50extern int catclose (nl_catd __catalog) __THROW __nonnull ((1));
51
52__END_DECLS
53
54#endif /* nl_types.h */
libc/glibc-include/nss.h created+63
...@@ -0,0 +1,63 @@
1/* Copyright (C) 1996-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/* Define interface to NSS. This is meant for the interface functions
19 and for implementors of new services. */
20
21#ifndef _NSS_H
22#define _NSS_H 1
23
24#include <features.h>
25#include <stdint.h>
26
27
28__BEGIN_DECLS
29
30/* Possible results of lookup using a nss_* function. */
31enum nss_status
32{
33 NSS_STATUS_TRYAGAIN = -2,
34 NSS_STATUS_UNAVAIL,
35 NSS_STATUS_NOTFOUND,
36 NSS_STATUS_SUCCESS,
37 NSS_STATUS_RETURN
38};
39
40
41/* Data structure used for the 'gethostbyname4_r' function. */
42struct gaih_addrtuple
43 {
44 struct gaih_addrtuple *next;
45 char *name;
46 int family;
47 uint32_t addr[4];
48 uint32_t scopeid;
49 };
50
51
52/* Overwrite service selection for database DBNAME using specification
53 in STRING.
54 This function should only be used by system programs which have to
55 work around non-existing services (e.e., while booting).
56 Attention: Using this function repeatedly will slowly eat up the
57 whole memory since previous selection data cannot be freed. */
58extern int __nss_configure_lookup (const char *__dbname,
59 const char *__string) __THROW;
60
61__END_DECLS
62
63#endif /* nss.h */
libc/glibc-include/obstack.h created+515
...@@ -0,0 +1,515 @@
1/* obstack.h - object stack macros
2 Copyright (C) 1988-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19/* Summary:
20
21 All the apparent functions defined here are macros. The idea
22 is that you would use these pre-tested macros to solve a
23 very specific set of problems, and they would run fast.
24 Caution: no side-effects in arguments please!! They may be
25 evaluated MANY times!!
26
27 These macros operate a stack of objects. Each object starts life
28 small, and may grow to maturity. (Consider building a word syllable
29 by syllable.) An object can move while it is growing. Once it has
30 been "finished" it never changes address again. So the "top of the
31 stack" is typically an immature growing object, while the rest of the
32 stack is of mature, fixed size and fixed address objects.
33
34 These routines grab large chunks of memory, using a function you
35 supply, called 'obstack_chunk_alloc'. On occasion, they free chunks,
36 by calling 'obstack_chunk_free'. You must define them and declare
37 them before using any obstack macros.
38
39 Each independent stack is represented by a 'struct obstack'.
40 Each of the obstack macros expects a pointer to such a structure
41 as the first argument.
42
43 One motivation for this package is the problem of growing char strings
44 in symbol tables. Unless you are "fascist pig with a read-only mind"
45 --Gosper's immortal quote from HAKMEM item 154, out of context--you
46 would not like to put any arbitrary upper limit on the length of your
47 symbols.
48
49 In practice this often means you will build many short symbols and a
50 few long symbols. At the time you are reading a symbol you don't know
51 how long it is. One traditional method is to read a symbol into a
52 buffer, realloc()ating the buffer every time you try to read a symbol
53 that is longer than the buffer. This is beaut, but you still will
54 want to copy the symbol from the buffer to a more permanent
55 symbol-table entry say about half the time.
56
57 With obstacks, you can work differently. Use one obstack for all symbol
58 names. As you read a symbol, grow the name in the obstack gradually.
59 When the name is complete, finalize it. Then, if the symbol exists already,
60 free the newly read name.
61
62 The way we do this is to take a large chunk, allocating memory from
63 low addresses. When you want to build a symbol in the chunk you just
64 add chars above the current "high water mark" in the chunk. When you
65 have finished adding chars, because you got to the end of the symbol,
66 you know how long the chars are, and you can create a new object.
67 Mostly the chars will not burst over the highest address of the chunk,
68 because you would typically expect a chunk to be (say) 100 times as
69 long as an average object.
70
71 In case that isn't clear, when we have enough chars to make up
72 the object, THEY ARE ALREADY CONTIGUOUS IN THE CHUNK (guaranteed)
73 so we just point to it where it lies. No moving of chars is
74 needed and this is the second win: potentially long strings need
75 never be explicitly shuffled. Once an object is formed, it does not
76 change its address during its lifetime.
77
78 When the chars burst over a chunk boundary, we allocate a larger
79 chunk, and then copy the partly formed object from the end of the old
80 chunk to the beginning of the new larger chunk. We then carry on
81 accreting characters to the end of the object as we normally would.
82
83 A special macro is provided to add a single char at a time to a
84 growing object. This allows the use of register variables, which
85 break the ordinary 'growth' macro.
86
87 Summary:
88 We allocate large chunks.
89 We carve out one object at a time from the current chunk.
90 Once carved, an object never moves.
91 We are free to append data of any size to the currently
92 growing object.
93 Exactly one object is growing in an obstack at any one time.
94 You can run one obstack per control block.
95 You may have as many control blocks as you dare.
96 Because of the way we do it, you can "unwind" an obstack
97 back to a previous state. (You may remove objects much
98 as you would with a stack.)
99 */
100
101
102/* Don't do the contents of this file more than once. */
103
104#ifndef _OBSTACK_H
105#define _OBSTACK_H 1
106
107/* We need the type of a pointer subtraction. If __PTRDIFF_TYPE__ is
108 defined, as with GNU C, use that; that way we don't pollute the
109 namespace with <stddef.h>'s symbols. Otherwise, include <stddef.h>
110 and use ptrdiff_t. */
111
112#ifdef __PTRDIFF_TYPE__
113# define PTR_INT_TYPE __PTRDIFF_TYPE__
114#else
115# include <stddef.h>
116# define PTR_INT_TYPE ptrdiff_t
117#endif
118
119/* If B is the base of an object addressed by P, return the result of
120 aligning P to the next multiple of A + 1. B and P must be of type
121 char *. A + 1 must be a power of 2. */
122
123#define __BPTR_ALIGN(B, P, A) ((B) + (((P) - (B) + (A)) & ~(A)))
124
125/* Similar to _BPTR_ALIGN (B, P, A), except optimize the common case
126 where pointers can be converted to integers, aligned as integers,
127 and converted back again. If PTR_INT_TYPE is narrower than a
128 pointer (e.g., the AS/400), play it safe and compute the alignment
129 relative to B. Otherwise, use the faster strategy of computing the
130 alignment relative to 0. */
131
132#define __PTR_ALIGN(B, P, A) \
133 __BPTR_ALIGN (sizeof (PTR_INT_TYPE) < sizeof (void *) ? (B) : (char *) 0, \
134 P, A)
135
136#include <string.h>
137
138#ifndef __attribute_pure__
139# define __attribute_pure__ _GL_ATTRIBUTE_PURE
140#endif
141
142#ifdef __cplusplus
143extern "C" {
144#endif
145
146struct _obstack_chunk /* Lives at front of each chunk. */
147{
148 char *limit; /* 1 past end of this chunk */
149 struct _obstack_chunk *prev; /* address of prior chunk or NULL */
150 char contents[4]; /* objects begin here */
151};
152
153struct obstack /* control current object in current chunk */
154{
155 long chunk_size; /* preferred size to allocate chunks in */
156 struct _obstack_chunk *chunk; /* address of current struct obstack_chunk */
157 char *object_base; /* address of object we are building */
158 char *next_free; /* where to add next char to current object */
159 char *chunk_limit; /* address of char after current chunk */
160 union
161 {
162 PTR_INT_TYPE tempint;
163 void *tempptr;
164 } temp; /* Temporary for some macros. */
165 int alignment_mask; /* Mask of alignment for each object. */
166 /* These prototypes vary based on 'use_extra_arg', and we use
167 casts to the prototypeless function type in all assignments,
168 but having prototypes here quiets -Wstrict-prototypes. */
169 struct _obstack_chunk *(*chunkfun) (void *, long);
170 void (*freefun) (void *, struct _obstack_chunk *);
171 void *extra_arg; /* first arg for chunk alloc/dealloc funcs */
172 unsigned use_extra_arg : 1; /* chunk alloc/dealloc funcs take extra arg */
173 unsigned maybe_empty_object : 1; /* There is a possibility that the current
174 chunk contains a zero-length object. This
175 prevents freeing the chunk if we allocate
176 a bigger chunk to replace it. */
177 unsigned alloc_failed : 1; /* No longer used, as we now call the failed
178 handler on error, but retained for binary
179 compatibility. */
180};
181
182/* Declare the external functions we use; they are in obstack.c. */
183
184extern void _obstack_newchunk (struct obstack *, int);
185extern int _obstack_begin (struct obstack *, int, int,
186 void *(*)(long), void (*)(void *));
187extern int _obstack_begin_1 (struct obstack *, int, int,
188 void *(*)(void *, long),
189 void (*)(void *, void *), void *);
190extern int _obstack_memory_used (struct obstack *) __attribute_pure__;
191
192/* The default name of the function for freeing a chunk is 'obstack_free',
193 but gnulib users can override this by defining '__obstack_free'. */
194#ifndef __obstack_free
195# define __obstack_free obstack_free
196#endif
197extern void __obstack_free (struct obstack *, void *);
198
199
200/* Error handler called when 'obstack_chunk_alloc' failed to allocate
201 more memory. This can be set to a user defined function which
202 should either abort gracefully or use longjump - but shouldn't
203 return. The default action is to print a message and abort. */
204extern void (*obstack_alloc_failed_handler) (void);
205
206/* Exit value used when 'print_and_abort' is used. */
207extern int obstack_exit_failure;
208
209/* Pointer to beginning of object being allocated or to be allocated next.
210 Note that this might not be the final address of the object
211 because a new chunk might be needed to hold the final size. */
212
213#define obstack_base(h) ((void *) (h)->object_base)
214
215/* Size for allocating ordinary chunks. */
216
217#define obstack_chunk_size(h) ((h)->chunk_size)
218
219/* Pointer to next byte not yet allocated in current chunk. */
220
221#define obstack_next_free(h) ((h)->next_free)
222
223/* Mask specifying low bits that should be clear in address of an object. */
224
225#define obstack_alignment_mask(h) ((h)->alignment_mask)
226
227/* To prevent prototype warnings provide complete argument list. */
228#define obstack_init(h) \
229 _obstack_begin ((h), 0, 0, \
230 (void *(*)(long))obstack_chunk_alloc, \
231 (void (*)(void *))obstack_chunk_free)
232
233#define obstack_begin(h, size) \
234 _obstack_begin ((h), (size), 0, \
235 (void *(*)(long))obstack_chunk_alloc, \
236 (void (*)(void *))obstack_chunk_free)
237
238#define obstack_specify_allocation(h, size, alignment, chunkfun, freefun) \
239 _obstack_begin ((h), (size), (alignment), \
240 (void *(*)(long))(chunkfun), \
241 (void (*)(void *))(freefun))
242
243#define obstack_specify_allocation_with_arg(h, size, alignment, chunkfun, freefun, arg) \
244 _obstack_begin_1 ((h), (size), (alignment), \
245 (void *(*)(void *, long))(chunkfun), \
246 (void (*)(void *, void *))(freefun), (arg))
247
248#define obstack_chunkfun(h, newchunkfun) \
249 ((h)->chunkfun = (struct _obstack_chunk *(*)(void *, long))(newchunkfun))
250
251#define obstack_freefun(h, newfreefun) \
252 ((h)->freefun = (void (*)(void *, struct _obstack_chunk *))(newfreefun))
253
254#define obstack_1grow_fast(h, achar) (*((h)->next_free)++ = (achar))
255
256#define obstack_blank_fast(h, n) ((h)->next_free += (n))
257
258#define obstack_memory_used(h) _obstack_memory_used (h)
259
260#if defined __GNUC__
261# if ! (2 < __GNUC__ + (8 <= __GNUC_MINOR__))
262# define __extension__
263# endif
264
265/* For GNU C, if not -traditional,
266 we can define these macros to compute all args only once
267 without using a global variable.
268 Also, we can avoid using the 'temp' slot, to make faster code. */
269
270# define obstack_object_size(OBSTACK) \
271 __extension__ \
272 ({ struct obstack const *__o = (OBSTACK); \
273 (unsigned) (__o->next_free - __o->object_base); })
274
275# define obstack_room(OBSTACK) \
276 __extension__ \
277 ({ struct obstack const *__o = (OBSTACK); \
278 (unsigned) (__o->chunk_limit - __o->next_free); })
279
280# define obstack_make_room(OBSTACK, length) \
281 __extension__ \
282 ({ struct obstack *__o = (OBSTACK); \
283 int __len = (length); \
284 if (__o->chunk_limit - __o->next_free < __len) \
285 _obstack_newchunk (__o, __len); \
286 (void) 0; })
287
288# define obstack_empty_p(OBSTACK) \
289 __extension__ \
290 ({ struct obstack const *__o = (OBSTACK); \
291 (__o->chunk->prev == 0 \
292 && __o->next_free == __PTR_ALIGN ((char *) __o->chunk, \
293 __o->chunk->contents, \
294 __o->alignment_mask)); })
295
296# define obstack_grow(OBSTACK, where, length) \
297 __extension__ \
298 ({ struct obstack *__o = (OBSTACK); \
299 int __len = (length); \
300 if (__o->next_free + __len > __o->chunk_limit) \
301 _obstack_newchunk (__o, __len); \
302 memcpy (__o->next_free, where, __len); \
303 __o->next_free += __len; \
304 (void) 0; })
305
306# define obstack_grow0(OBSTACK, where, length) \
307 __extension__ \
308 ({ struct obstack *__o = (OBSTACK); \
309 int __len = (length); \
310 if (__o->next_free + __len + 1 > __o->chunk_limit) \
311 _obstack_newchunk (__o, __len + 1); \
312 memcpy (__o->next_free, where, __len); \
313 __o->next_free += __len; \
314 *(__o->next_free)++ = 0; \
315 (void) 0; })
316
317# define obstack_1grow(OBSTACK, datum) \
318 __extension__ \
319 ({ struct obstack *__o = (OBSTACK); \
320 if (__o->next_free + 1 > __o->chunk_limit) \
321 _obstack_newchunk (__o, 1); \
322 obstack_1grow_fast (__o, datum); \
323 (void) 0; })
324
325/* These assume that the obstack alignment is good enough for pointers
326 or ints, and that the data added so far to the current object
327 shares that much alignment. */
328
329# define obstack_ptr_grow(OBSTACK, datum) \
330 __extension__ \
331 ({ struct obstack *__o = (OBSTACK); \
332 if (__o->next_free + sizeof (void *) > __o->chunk_limit) \
333 _obstack_newchunk (__o, sizeof (void *)); \
334 obstack_ptr_grow_fast (__o, datum); }) \
335
336# define obstack_int_grow(OBSTACK, datum) \
337 __extension__ \
338 ({ struct obstack *__o = (OBSTACK); \
339 if (__o->next_free + sizeof (int) > __o->chunk_limit) \
340 _obstack_newchunk (__o, sizeof (int)); \
341 obstack_int_grow_fast (__o, datum); })
342
343# define obstack_ptr_grow_fast(OBSTACK, aptr) \
344 __extension__ \
345 ({ struct obstack *__o1 = (OBSTACK); \
346 void *__p1 = __o1->next_free; \
347 *(const void **) __p1 = (aptr); \
348 __o1->next_free += sizeof (const void *); \
349 (void) 0; })
350
351# define obstack_int_grow_fast(OBSTACK, aint) \
352 __extension__ \
353 ({ struct obstack *__o1 = (OBSTACK); \
354 void *__p1 = __o1->next_free; \
355 *(int *) __p1 = (aint); \
356 __o1->next_free += sizeof (int); \
357 (void) 0; })
358
359# define obstack_blank(OBSTACK, length) \
360 __extension__ \
361 ({ struct obstack *__o = (OBSTACK); \
362 int __len = (length); \
363 if (__o->chunk_limit - __o->next_free < __len) \
364 _obstack_newchunk (__o, __len); \
365 obstack_blank_fast (__o, __len); \
366 (void) 0; })
367
368# define obstack_alloc(OBSTACK, length) \
369 __extension__ \
370 ({ struct obstack *__h = (OBSTACK); \
371 obstack_blank (__h, (length)); \
372 obstack_finish (__h); })
373
374# define obstack_copy(OBSTACK, where, length) \
375 __extension__ \
376 ({ struct obstack *__h = (OBSTACK); \
377 obstack_grow (__h, (where), (length)); \
378 obstack_finish (__h); })
379
380# define obstack_copy0(OBSTACK, where, length) \
381 __extension__ \
382 ({ struct obstack *__h = (OBSTACK); \
383 obstack_grow0 (__h, (where), (length)); \
384 obstack_finish (__h); })
385
386/* The local variable is named __o1 to avoid a name conflict
387 when obstack_blank is called. */
388# define obstack_finish(OBSTACK) \
389 __extension__ \
390 ({ struct obstack *__o1 = (OBSTACK); \
391 void *__value = (void *) __o1->object_base; \
392 if (__o1->next_free == __value) \
393 __o1->maybe_empty_object = 1; \
394 __o1->next_free \
395 = __PTR_ALIGN (__o1->object_base, __o1->next_free, \
396 __o1->alignment_mask); \
397 if (__o1->next_free - (char *) __o1->chunk \
398 > __o1->chunk_limit - (char *) __o1->chunk) \
399 __o1->next_free = __o1->chunk_limit; \
400 __o1->object_base = __o1->next_free; \
401 __value; })
402
403# define obstack_free(OBSTACK, OBJ) \
404 __extension__ \
405 ({ struct obstack *__o = (OBSTACK); \
406 void *__obj = (OBJ); \
407 if (__obj > (void *) __o->chunk && __obj < (void *) __o->chunk_limit) \
408 __o->next_free = __o->object_base = (char *) __obj; \
409 else (__obstack_free) (__o, __obj); })
410
411#else /* not __GNUC__ */
412
413# define obstack_object_size(h) \
414 (unsigned) ((h)->next_free - (h)->object_base)
415
416# define obstack_room(h) \
417 (unsigned) ((h)->chunk_limit - (h)->next_free)
418
419# define obstack_empty_p(h) \
420 ((h)->chunk->prev == 0 \
421 && (h)->next_free == __PTR_ALIGN ((char *) (h)->chunk, \
422 (h)->chunk->contents, \
423 (h)->alignment_mask))
424
425/* Note that the call to _obstack_newchunk is enclosed in (..., 0)
426 so that we can avoid having void expressions
427 in the arms of the conditional expression.
428 Casting the third operand to void was tried before,
429 but some compilers won't accept it. */
430
431# define obstack_make_room(h, length) \
432 ((h)->temp.tempint = (length), \
433 (((h)->next_free + (h)->temp.tempint > (h)->chunk_limit) \
434 ? (_obstack_newchunk ((h), (h)->temp.tempint), 0) : 0))
435
436# define obstack_grow(h, where, length) \
437 ((h)->temp.tempint = (length), \
438 (((h)->next_free + (h)->temp.tempint > (h)->chunk_limit) \
439 ? (_obstack_newchunk ((h), (h)->temp.tempint), 0) : 0), \
440 memcpy ((h)->next_free, where, (h)->temp.tempint), \
441 (h)->next_free += (h)->temp.tempint)
442
443# define obstack_grow0(h, where, length) \
444 ((h)->temp.tempint = (length), \
445 (((h)->next_free + (h)->temp.tempint + 1 > (h)->chunk_limit) \
446 ? (_obstack_newchunk ((h), (h)->temp.tempint + 1), 0) : 0), \
447 memcpy ((h)->next_free, where, (h)->temp.tempint), \
448 (h)->next_free += (h)->temp.tempint, \
449 *((h)->next_free)++ = 0)
450
451# define obstack_1grow(h, datum) \
452 ((((h)->next_free + 1 > (h)->chunk_limit) \
453 ? (_obstack_newchunk ((h), 1), 0) : 0), \
454 obstack_1grow_fast (h, datum))
455
456# define obstack_ptr_grow(h, datum) \
457 ((((h)->next_free + sizeof (char *) > (h)->chunk_limit) \
458 ? (_obstack_newchunk ((h), sizeof (char *)), 0) : 0), \
459 obstack_ptr_grow_fast (h, datum))
460
461# define obstack_int_grow(h, datum) \
462 ((((h)->next_free + sizeof (int) > (h)->chunk_limit) \
463 ? (_obstack_newchunk ((h), sizeof (int)), 0) : 0), \
464 obstack_int_grow_fast (h, datum))
465
466# define obstack_ptr_grow_fast(h, aptr) \
467 (((const void **) ((h)->next_free += sizeof (void *)))[-1] = (aptr))
468
469# define obstack_int_grow_fast(h, aint) \
470 (((int *) ((h)->next_free += sizeof (int)))[-1] = (aint))
471
472# define obstack_blank(h, length) \
473 ((h)->temp.tempint = (length), \
474 (((h)->chunk_limit - (h)->next_free < (h)->temp.tempint) \
475 ? (_obstack_newchunk ((h), (h)->temp.tempint), 0) : 0), \
476 obstack_blank_fast (h, (h)->temp.tempint))
477
478# define obstack_alloc(h, length) \
479 (obstack_blank ((h), (length)), obstack_finish ((h)))
480
481# define obstack_copy(h, where, length) \
482 (obstack_grow ((h), (where), (length)), obstack_finish ((h)))
483
484# define obstack_copy0(h, where, length) \
485 (obstack_grow0 ((h), (where), (length)), obstack_finish ((h)))
486
487# define obstack_finish(h) \
488 (((h)->next_free == (h)->object_base \
489 ? (((h)->maybe_empty_object = 1), 0) \
490 : 0), \
491 (h)->temp.tempptr = (h)->object_base, \
492 (h)->next_free \
493 = __PTR_ALIGN ((h)->object_base, (h)->next_free, \
494 (h)->alignment_mask), \
495 (((h)->next_free - (char *) (h)->chunk \
496 > (h)->chunk_limit - (char *) (h)->chunk) \
497 ? ((h)->next_free = (h)->chunk_limit) : 0), \
498 (h)->object_base = (h)->next_free, \
499 (h)->temp.tempptr)
500
501# define obstack_free(h, obj) \
502 ((h)->temp.tempint = (char *) (obj) - (char *) (h)->chunk, \
503 ((((h)->temp.tempint > 0 \
504 && (h)->temp.tempint < (h)->chunk_limit - (char *) (h)->chunk)) \
505 ? (void) ((h)->next_free = (h)->object_base \
506 = (h)->temp.tempint + (char *) (h)->chunk) \
507 : (__obstack_free) (h, (h)->temp.tempint + (char *) (h)->chunk)))
508
509#endif /* not __GNUC__ */
510
511#ifdef __cplusplus
512} /* C++ */
513#endif
514
515#endif /* obstack.h */
libc/glibc-include/paths.h created+75
...@@ -0,0 +1,75 @@
1/*
2 * Copyright (c) 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 4. Neither the name of the University nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * @(#)paths.h 8.1 (Berkeley) 6/2/93
30 */
31
32#ifndef _PATHS_H_
33#define _PATHS_H_
34
35/* Default search path. */
36#define _PATH_DEFPATH "/usr/bin:/bin"
37/* All standard utilities path. */
38#define _PATH_STDPATH \
39 "/usr/bin:/bin:/usr/sbin:/sbin"
40
41#define _PATH_BSHELL "/bin/sh"
42#define _PATH_CONSOLE "/dev/console"
43#define _PATH_CSHELL "/bin/csh"
44#define _PATH_DEVDB "/var/run/dev.db"
45#define _PATH_DEVNULL "/dev/null"
46#define _PATH_DRUM "/dev/drum"
47#define _PATH_GSHADOW "/etc/gshadow"
48#define _PATH_KLOG "/proc/kmsg"
49#define _PATH_KMEM "/dev/kmem"
50#define _PATH_LASTLOG "/var/log/lastlog"
51#define _PATH_MAILDIR "/var/mail"
52#define _PATH_MAN "/usr/share/man"
53#define _PATH_MEM "/dev/mem"
54#define _PATH_MNTTAB "/etc/fstab"
55#define _PATH_MOUNTED "/etc/mtab"
56#define _PATH_NOLOGIN "/etc/nologin"
57#define _PATH_PRESERVE "/var/lib"
58#define _PATH_RWHODIR "/var/spool/rwho"
59#define _PATH_SENDMAIL "/usr/sbin/sendmail"
60#define _PATH_SHADOW "/etc/shadow"
61#define _PATH_SHELLS "/etc/shells"
62#define _PATH_TTY "/dev/tty"
63#define _PATH_UNIX "/boot/vmlinux"
64#define _PATH_UTMP "/var/run/utmp"
65#define _PATH_VI "/usr/bin/vi"
66#define _PATH_WTMP "/var/log/wtmp"
67
68/* Provide trailing slash, since mostly used for building pathnames. */
69#define _PATH_DEV "/dev/"
70#define _PATH_TMP "/tmp/"
71#define _PATH_VARDB "/var/db/"
72#define _PATH_VARRUN "/var/run/"
73#define _PATH_VARTMP "/var/tmp/"
74
75#endif /* !_PATHS_H_ */
libc/glibc-include/poll.h created+1
...@@ -0,0 +1 @@
1#include <sys/poll.h>
libc/glibc-include/printf.h created+191
...@@ -0,0 +1,191 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _PRINTF_H
19
20#define _PRINTF_H 1
21#include <features.h>
22
23__BEGIN_DECLS
24
25#include <bits/types/FILE.h>
26
27#define __need_size_t
28#define __need_wchar_t
29#include <stddef.h>
30
31#include <stdarg.h>
32
33
34struct printf_info
35{
36 int prec; /* Precision. */
37 int width; /* Width. */
38 wchar_t spec; /* Format letter. */
39 unsigned int is_long_double:1;/* L flag. */
40 unsigned int is_short:1; /* h flag. */
41 unsigned int is_long:1; /* l flag. */
42 unsigned int alt:1; /* # flag. */
43 unsigned int space:1; /* Space flag. */
44 unsigned int left:1; /* - flag. */
45 unsigned int showsign:1; /* + flag. */
46 unsigned int group:1; /* ' flag. */
47 unsigned int extra:1; /* For special use. */
48 unsigned int is_char:1; /* hh flag. */
49 unsigned int wide:1; /* Nonzero for wide character streams. */
50 unsigned int i18n:1; /* I flag. */
51 unsigned int is_binary128:1; /* Floating-point argument is ABI-compatible
52 with IEC 60559 binary128. */
53 unsigned int __pad:3; /* Unused so far. */
54 unsigned short int user; /* Bits for user-installed modifiers. */
55 wchar_t pad; /* Padding character. */
56};
57
58
59/* Type of a printf specifier-handler function.
60 STREAM is the FILE on which to write output.
61 INFO gives information about the format specification.
62 ARGS is a vector of pointers to the argument data;
63 the number of pointers will be the number returned
64 by the associated arginfo function for the same INFO.
65
66 The function should return the number of characters written,
67 or -1 for errors. */
68
69typedef int printf_function (FILE *__stream,
70 const struct printf_info *__info,
71 const void *const *__args);
72
73/* Type of a printf specifier-arginfo function.
74 INFO gives information about the format specification.
75 N, ARGTYPES, *SIZE has to contain the size of the parameter for
76 user-defined types, and return value are as for parse_printf_format
77 except that -1 should be returned if the handler cannot handle
78 this case. This allows to partially overwrite the functionality
79 of existing format specifiers. */
80
81typedef int printf_arginfo_size_function (const struct printf_info *__info,
82 size_t __n, int *__argtypes,
83 int *__size);
84
85/* Old version of 'printf_arginfo_function' without a SIZE parameter. */
86
87typedef int printf_arginfo_function (const struct printf_info *__info,
88 size_t __n, int *__argtypes);
89
90/* Type of a function to get a value of a user-defined from the
91 variable argument list. */
92typedef void printf_va_arg_function (void *__mem, va_list *__ap);
93
94
95/* Register FUNC to be called to format SPEC specifiers; ARGINFO must be
96 specified to determine how many arguments a SPEC conversion requires and
97 what their types are. */
98
99extern int register_printf_specifier (int __spec, printf_function __func,
100 printf_arginfo_size_function __arginfo)
101 __THROW;
102
103
104/* Obsolete interface similar to register_printf_specifier. It can only
105 handle basic data types because the ARGINFO callback does not return
106 information on the size of the user-defined type. */
107
108extern int register_printf_function (int __spec, printf_function __func,
109 printf_arginfo_function __arginfo)
110 __THROW __attribute_deprecated__;
111
112
113/* Register a new modifier character sequence. If the call succeeds
114 it returns a positive value representing the bit set in the USER
115 field in 'struct printf_info'. */
116
117extern int register_printf_modifier (const wchar_t *__str) __THROW __wur;
118
119
120/* Register variable argument handler for user type. The return value
121 is to be used in ARGINFO functions to signal the use of the
122 type. */
123extern int register_printf_type (printf_va_arg_function __fct) __THROW __wur;
124
125
126/* Parse FMT, and fill in N elements of ARGTYPES with the
127 types needed for the conversions FMT specifies. Returns
128 the number of arguments required by FMT.
129
130 The ARGINFO function registered with a user-defined format is passed a
131 `struct printf_info' describing the format spec being parsed. A width
132 or precision of INT_MIN means a `*' was used to indicate that the
133 width/precision will come from an arg. The function should fill in the
134 array it is passed with the types of the arguments it wants, and return
135 the number of arguments it wants. */
136
137extern size_t parse_printf_format (const char *__restrict __fmt, size_t __n,
138 int *__restrict __argtypes) __THROW;
139
140
141/* Codes returned by `parse_printf_format' for basic types.
142
143 These values cover all the standard format specifications.
144 Users can reserve new values after PA_LAST for their own types
145 using 'register_printf_type'. */
146
147enum
148{ /* C type: */
149 PA_INT, /* int */
150 PA_CHAR, /* int, cast to char */
151 PA_WCHAR, /* wide char */
152 PA_STRING, /* const char *, a '\0'-terminated string */
153 PA_WSTRING, /* const wchar_t *, wide character string */
154 PA_POINTER, /* void * */
155 PA_FLOAT, /* float */
156 PA_DOUBLE, /* double */
157 PA_LAST
158};
159
160/* Flag bits that can be set in a type returned by `parse_printf_format'. */
161#define PA_FLAG_MASK 0xff00
162#define PA_FLAG_LONG_LONG (1 << 8)
163#define PA_FLAG_LONG_DOUBLE PA_FLAG_LONG_LONG
164#define PA_FLAG_LONG (1 << 9)
165#define PA_FLAG_SHORT (1 << 10)
166#define PA_FLAG_PTR (1 << 11)
167
168
169
170/* Function which can be registered as `printf'-handlers. */
171
172/* Print floating point value using using abbreviations for the orders
173 of magnitude used for numbers ('k' for kilo, 'm' for mega etc). If
174 the format specifier is a uppercase character powers of 1000 are
175 used. Otherwise powers of 1024. */
176extern int printf_size (FILE *__restrict __fp,
177 const struct printf_info *__info,
178 const void *const *__restrict __args) __THROW;
179
180/* This is the appropriate argument information function for `printf_size'. */
181extern int printf_size_info (const struct printf_info *__restrict
182 __info, size_t __n, int *__restrict __argtypes)
183 __THROW;
184
185#ifdef __LDBL_COMPAT
186# include <bits/printf-ldbl.h>
187#endif
188
189__END_DECLS
190
191#endif /* printf.h */
libc/glibc-include/proc_service.h created+95
...@@ -0,0 +1,95 @@
1/* Callback interface for libthread_db, functions users must define.
2 Copyright (C) 1999-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _PROC_SERVICE_H
20#define _PROC_SERVICE_H 1
21
22/* The definitions in this file must correspond to those in the debugger. */
23#include <sys/procfs.h>
24
25__BEGIN_DECLS
26
27/* Functions in this interface return one of these status codes. */
28typedef enum
29{
30 PS_OK, /* Generic "call succeeded". */
31 PS_ERR, /* Generic error. */
32 PS_BADPID, /* Bad process handle. */
33 PS_BADLID, /* Bad LWP identifier. */
34 PS_BADADDR, /* Bad address. */
35 PS_NOSYM, /* Could not find given symbol. */
36 PS_NOFREGS /* FPU register set not available for given LWP. */
37} ps_err_e;
38
39
40/* This type is opaque in this interface.
41 It's defined by the user of libthread_db. */
42struct ps_prochandle;
43
44
45/* Read or write process memory at the given address. */
46extern ps_err_e ps_pdread (struct ps_prochandle *,
47 psaddr_t, void *, size_t);
48extern ps_err_e ps_pdwrite (struct ps_prochandle *,
49 psaddr_t, const void *, size_t);
50extern ps_err_e ps_ptread (struct ps_prochandle *,
51 psaddr_t, void *, size_t);
52extern ps_err_e ps_ptwrite (struct ps_prochandle *,
53 psaddr_t, const void *, size_t);
54
55
56/* Get and set the given LWP's general or FPU register set. */
57extern ps_err_e ps_lgetregs (struct ps_prochandle *,
58 lwpid_t, prgregset_t);
59extern ps_err_e ps_lsetregs (struct ps_prochandle *,
60 lwpid_t, const prgregset_t);
61extern ps_err_e ps_lgetfpregs (struct ps_prochandle *,
62 lwpid_t, prfpregset_t *);
63extern ps_err_e ps_lsetfpregs (struct ps_prochandle *,
64 lwpid_t, const prfpregset_t *);
65
66/* Return the PID of the process. */
67extern pid_t ps_getpid (struct ps_prochandle *);
68
69/* Fetch the special per-thread address associated with the given LWP.
70 This call is only used on a few platforms (most use a normal register).
71 The meaning of the `int' parameter is machine-dependent. */
72extern ps_err_e ps_get_thread_area (struct ps_prochandle *,
73 lwpid_t, int, psaddr_t *);
74
75
76/* Look up the named symbol in the named DSO in the symbol tables
77 associated with the process being debugged, filling in *SYM_ADDR
78 with the corresponding run-time address. */
79extern ps_err_e ps_pglobal_lookup (struct ps_prochandle *,
80 const char *object_name,
81 const char *sym_name,
82 psaddr_t *sym_addr);
83
84
85/* Stop or continue the entire process. */
86extern ps_err_e ps_pstop (struct ps_prochandle *);
87extern ps_err_e ps_pcontinue (struct ps_prochandle *);
88
89/* Stop or continue the given LWP alone. */
90extern ps_err_e ps_lstop (struct ps_prochandle *, lwpid_t);
91extern ps_err_e ps_lcontinue (struct ps_prochandle *, lwpid_t);
92
93__END_DECLS
94
95#endif /* proc_service.h */
libc/glibc-include/protocols/routed.h created+101
...@@ -0,0 +1,101 @@
1/*-
2 * Copyright (c) 1983, 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 4. Neither the name of the University nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * @(#)routed.h 8.1 (Berkeley) 6/2/93
30 */
31
32#ifndef _PROTOCOLS_ROUTED_H
33#define _PROTOCOLS_ROUTED_H 1
34
35#include <sys/socket.h>
36/*
37 * Routing Information Protocol
38 *
39 * Derived from Xerox NS Routing Information Protocol
40 * by changing 32-bit net numbers to sockaddr's and
41 * padding stuff to 32-bit boundaries.
42 */
43#define RIPVERSION 1
44
45struct netinfo {
46 struct sockaddr rip_dst; /* destination net/host */
47 int rip_metric; /* cost of route */
48};
49
50struct rip {
51 unsigned char rip_cmd; /* request/response */
52 unsigned char rip_vers; /* protocol version # */
53 unsigned char rip_res1[2]; /* pad to 32-bit boundary */
54 union {
55 struct netinfo ru_nets[1]; /* variable length... */
56 char ru_tracefile[1]; /* ditto ... */
57 } ripun;
58#define rip_nets ripun.ru_nets
59#define rip_tracefile ripun.ru_tracefile
60};
61
62/*
63 * Packet types.
64 */
65#define RIPCMD_REQUEST 1 /* want info */
66#define RIPCMD_RESPONSE 2 /* responding to request */
67#define RIPCMD_TRACEON 3 /* turn tracing on */
68#define RIPCMD_TRACEOFF 4 /* turn it off */
69
70#define RIPCMD_MAX 5
71#ifdef RIPCMDS
72char *ripcmds[RIPCMD_MAX] =
73 { "#0", "REQUEST", "RESPONSE", "TRACEON", "TRACEOFF" };
74#endif
75
76#define HOPCNT_INFINITY 16 /* per Xerox NS */
77#define MAXPACKETSIZE 512 /* max broadcast size */
78
79/*
80 * Timer values used in managing the routing table.
81 * Complete tables are broadcast every SUPPLY_INTERVAL seconds.
82 * If changes occur between updates, dynamic updates containing only changes
83 * may be sent. When these are sent, a timer is set for a random value
84 * between MIN_WAITTIME and MAX_WAITTIME, and no additional dynamic updates
85 * are sent until the timer expires.
86 *
87 * Every update of a routing entry forces an entry's timer to be reset.
88 * After EXPIRE_TIME without updates, the entry is marked invalid,
89 * but held onto until GARBAGE_TIME so that others may
90 * see it "be deleted".
91 */
92#define TIMER_RATE 30 /* alarm clocks every 30 seconds */
93
94#define SUPPLY_INTERVAL 30 /* time to supply tables */
95#define MIN_WAITTIME 2 /* min. interval to broadcast changes */
96#define MAX_WAITTIME 5 /* max. time to delay changes */
97
98#define EXPIRE_TIME 180 /* time to mark entry invalid */
99#define GARBAGE_TIME 240 /* time to garbage collect */
100
101#endif /* protocols/routed.h */
libc/glibc-include/protocols/rwhod.h created+67
...@@ -0,0 +1,67 @@
1/*
2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 4. Neither the name of the University nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * @(#)rwhod.h 8.1 (Berkeley) 6/2/93
30 */
31
32#ifndef _PROTOCOLS_RWHOD_H
33#define _PROTOCOLS_RWHOD_H 1
34
35#include <sys/types.h>
36
37/*
38 * rwho protocol packet format.
39 */
40struct outmp {
41 char out_line[8]; /* tty name */
42 char out_name[8]; /* user id */
43 int32_t out_time; /* time on */
44};
45
46struct whod {
47 char wd_vers; /* protocol version # */
48 char wd_type; /* packet type, see below */
49 char wd_pad[2];
50 int wd_sendtime; /* time stamp by sender */
51 int wd_recvtime; /* time stamp applied by receiver */
52 char wd_hostname[32]; /* hosts's name */
53 int wd_loadav[3]; /* load average as in uptime */
54 int wd_boottime; /* time system booted */
55 struct whoent {
56 struct outmp we_utmp; /* active tty info */
57 int we_idle; /* tty idle time */
58 } wd_we[1024 / sizeof (struct whoent)];
59};
60
61#define WHODVERSION 1
62#define WHODTYPE_STATUS 1 /* host status */
63
64/* We used to define _PATH_RWHODIR here but it's now in <paths.h>. */
65#include <paths.h>
66
67#endif /* protocols/rwhod.h */
libc/glibc-include/protocols/talkd.h created+115
...@@ -0,0 +1,115 @@
1/*
2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 4. Neither the name of the University nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * @(#)talkd.h 8.1 (Berkeley) 6/2/93
30 */
31
32#ifndef _PROTOCOLS_TALKD_H
33#define _PROTOCOLS_TALKD_H 1
34
35/*
36 * This describes the protocol used by the talk server and clients.
37 *
38 * The talk server acts a repository of invitations, responding to
39 * requests by clients wishing to rendezvous for the purpose of
40 * holding a conversation. In normal operation, a client, the caller,
41 * initiates a rendezvous by sending a CTL_MSG to the server of
42 * type LOOK_UP. This causes the server to search its invitation
43 * tables to check if an invitation currently exists for the caller
44 * (to speak to the callee specified in the message). If the lookup
45 * fails, the caller then sends an ANNOUNCE message causing the server
46 * to broadcast an announcement on the callee's login ports requesting
47 * contact. When the callee responds, the local server uses the
48 * recorded invitation to respond with the appropriate rendezvous
49 * address and the caller and callee client programs establish a
50 * stream connection through which the conversation takes place.
51 */
52
53#include <sys/types.h>
54#include <sys/socket.h>
55#include <stdint.h>
56#include <bits/types/struct_osockaddr.h>
57
58/*
59 * Client->server request message format.
60 */
61typedef struct {
62 unsigned char vers; /* protocol version */
63 unsigned char type; /* request type, see below */
64 unsigned char answer; /* not used */
65 unsigned char pad;
66 uint32_t id_num; /* message id */
67 struct osockaddr addr; /* old (4.3) style */
68 struct osockaddr ctl_addr; /* old (4.3) style */
69 int32_t pid; /* caller's process id */
70#define NAME_SIZE 12
71 char l_name[NAME_SIZE];/* caller's name */
72 char r_name[NAME_SIZE];/* callee's name */
73#define TTY_SIZE 16
74 char r_tty[TTY_SIZE];/* callee's tty name */
75} CTL_MSG;
76
77/*
78 * Server->client response message format.
79 */
80typedef struct {
81 unsigned char vers; /* protocol version */
82 unsigned char type; /* type of request message, see below */
83 unsigned char answer; /* response to request message, see below */
84 unsigned char pad;
85 uint32_t id_num; /* message id */
86 struct osockaddr addr; /* address for establishing conversation */
87} CTL_RESPONSE;
88
89#define TALK_VERSION 1 /* protocol version */
90
91/* message type values */
92#define LEAVE_INVITE 0 /* leave invitation with server */
93#define LOOK_UP 1 /* check for invitation by callee */
94#define DELETE 2 /* delete invitation by caller */
95#define ANNOUNCE 3 /* announce invitation by caller */
96
97/* answer values */
98#define SUCCESS 0 /* operation completed properly */
99#define NOT_HERE 1 /* callee not logged in */
100#define FAILED 2 /* operation failed for unexplained reason */
101#define MACHINE_UNKNOWN 3 /* caller's machine name unknown */
102#define PERMISSION_DENIED 4 /* callee's tty doesn't permit announce */
103#define UNKNOWN_REQUEST 5 /* request has invalid type value */
104#define BADVERSION 6 /* request has invalid protocol version */
105#define BADADDR 7 /* request has invalid addr value */
106#define BADCTLADDR 8 /* request has invalid ctl_addr value */
107
108/*
109 * Operational parameters.
110 */
111#define MAX_LIFE 60 /* max time daemon saves invitations */
112/* RING_WAIT should be 10's of seconds less than MAX_LIFE */
113#define RING_WAIT 30 /* time to wait before resending invitation */
114
115#endif /* protocols/talkd.h */
libc/glibc-include/protocols/timed.h created+99
...@@ -0,0 +1,99 @@
1/*
2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 4. Neither the name of the University nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * @(#)timed.h 8.1 (Berkeley) 6/2/93
30 */
31
32#ifndef _PROTOCOLS_TIMED_H
33#define _PROTOCOLS_TIMED_H 1
34
35#include <sys/types.h>
36#include <sys/time.h>
37
38/*
39 * Time Synchronization Protocol
40 */
41
42#define TSPVERSION 1
43#define ANYADDR NULL
44#define MAXHOSTNAMELEN 64
45
46struct tsp {
47 unsigned char tsp_type;
48 unsigned char tsp_vers;
49 unsigned short tsp_seq;
50 union {
51 struct timeval tspu_time;
52 char tspu_hopcnt;
53 } tsp_u;
54 char tsp_name[MAXHOSTNAMELEN];
55};
56
57#define tsp_time tsp_u.tspu_time
58#define tsp_hopcnt tsp_u.tspu_hopcnt
59
60/*
61 * Command types.
62 */
63#define TSP_ANY 0 /* match any types */
64#define TSP_ADJTIME 1 /* send adjtime */
65#define TSP_ACK 2 /* generic acknowledgement */
66#define TSP_MASTERREQ 3 /* ask for master's name */
67#define TSP_MASTERACK 4 /* acknowledge master request */
68#define TSP_SETTIME 5 /* send network time */
69#define TSP_MASTERUP 6 /* inform slaves that master is up */
70#define TSP_SLAVEUP 7 /* slave is up but not polled */
71#define TSP_ELECTION 8 /* advance candidature for master */
72#define TSP_ACCEPT 9 /* support candidature of master */
73#define TSP_REFUSE 10 /* reject candidature of master */
74#define TSP_CONFLICT 11 /* two or more masters present */
75#define TSP_RESOLVE 12 /* masters' conflict resolution */
76#define TSP_QUIT 13 /* reject candidature if master is up */
77#define TSP_DATE 14 /* reset the time (date command) */
78#define TSP_DATEREQ 15 /* remote request to reset the time */
79#define TSP_DATEACK 16 /* acknowledge time setting */
80#define TSP_TRACEON 17 /* turn tracing on */
81#define TSP_TRACEOFF 18 /* turn tracing off */
82#define TSP_MSITE 19 /* find out master's site */
83#define TSP_MSITEREQ 20 /* remote master's site request */
84#define TSP_TEST 21 /* for testing election algo */
85#define TSP_SETDATE 22 /* New from date command */
86#define TSP_SETDATEREQ 23 /* New remote for above */
87#define TSP_LOOP 24 /* loop detection packet */
88
89#define TSPTYPENUMBER 25
90
91#ifdef TSPTYPES
92char *tsptype[TSPTYPENUMBER] =
93 { "ANY", "ADJTIME", "ACK", "MASTERREQ", "MASTERACK", "SETTIME", "MASTERUP",
94 "SLAVEUP", "ELECTION", "ACCEPT", "REFUSE", "CONFLICT", "RESOLVE", "QUIT",
95 "DATE", "DATEREQ", "DATEACK", "TRACEON", "TRACEOFF", "MSITE", "MSITEREQ",
96 "TEST", "SETDATE", "SETDATEREQ", "LOOP" };
97#endif
98
99#endif /* protocols/timed.h */
libc/glibc-include/pthread.h created+1162
...@@ -0,0 +1,1162 @@
1/* Copyright (C) 2002-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _PTHREAD_H
19#define _PTHREAD_H 1
20
21#include <features.h>
22#include <endian.h>
23#include <sched.h>
24#include <time.h>
25
26#include <bits/pthreadtypes.h>
27#include <bits/setjmp.h>
28#include <bits/wordsize.h>
29#include <bits/types/struct_timespec.h>
30
31
32/* Detach state. */
33enum
34{
35 PTHREAD_CREATE_JOINABLE,
36#define PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_JOINABLE
37 PTHREAD_CREATE_DETACHED
38#define PTHREAD_CREATE_DETACHED PTHREAD_CREATE_DETACHED
39};
40
41
42/* Mutex types. */
43enum
44{
45 PTHREAD_MUTEX_TIMED_NP,
46 PTHREAD_MUTEX_RECURSIVE_NP,
47 PTHREAD_MUTEX_ERRORCHECK_NP,
48 PTHREAD_MUTEX_ADAPTIVE_NP
49#if defined __USE_UNIX98 || defined __USE_XOPEN2K8
50 ,
51 PTHREAD_MUTEX_NORMAL = PTHREAD_MUTEX_TIMED_NP,
52 PTHREAD_MUTEX_RECURSIVE = PTHREAD_MUTEX_RECURSIVE_NP,
53 PTHREAD_MUTEX_ERRORCHECK = PTHREAD_MUTEX_ERRORCHECK_NP,
54 PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_NORMAL
55#endif
56#ifdef __USE_GNU
57 /* For compatibility. */
58 , PTHREAD_MUTEX_FAST_NP = PTHREAD_MUTEX_TIMED_NP
59#endif
60};
61
62
63#ifdef __USE_XOPEN2K
64/* Robust mutex or not flags. */
65enum
66{
67 PTHREAD_MUTEX_STALLED,
68 PTHREAD_MUTEX_STALLED_NP = PTHREAD_MUTEX_STALLED,
69 PTHREAD_MUTEX_ROBUST,
70 PTHREAD_MUTEX_ROBUST_NP = PTHREAD_MUTEX_ROBUST
71};
72#endif
73
74
75#if defined __USE_POSIX199506 || defined __USE_UNIX98
76/* Mutex protocols. */
77enum
78{
79 PTHREAD_PRIO_NONE,
80 PTHREAD_PRIO_INHERIT,
81 PTHREAD_PRIO_PROTECT
82};
83#endif
84
85
86#if __PTHREAD_MUTEX_HAVE_PREV
87# define PTHREAD_MUTEX_INITIALIZER \
88 { { 0, 0, 0, 0, 0, __PTHREAD_SPINS, { 0, 0 } } }
89# ifdef __USE_GNU
90# define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \
91 { { 0, 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP, __PTHREAD_SPINS, { 0, 0 } } }
92# define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \
93 { { 0, 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP, __PTHREAD_SPINS, { 0, 0 } } }
94# define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \
95 { { 0, 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP, __PTHREAD_SPINS, { 0, 0 } } }
96
97# endif
98#else
99# define PTHREAD_MUTEX_INITIALIZER \
100 { { 0, 0, 0, 0, 0, { __PTHREAD_SPINS } } }
101# ifdef __USE_GNU
102# define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \
103 { { 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP, 0, { __PTHREAD_SPINS } } }
104# define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \
105 { { 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP, 0, { __PTHREAD_SPINS } } }
106# define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \
107 { { 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP, 0, { __PTHREAD_SPINS } } }
108
109# endif
110#endif
111
112
113/* Read-write lock types. */
114#if defined __USE_UNIX98 || defined __USE_XOPEN2K
115enum
116{
117 PTHREAD_RWLOCK_PREFER_READER_NP,
118 PTHREAD_RWLOCK_PREFER_WRITER_NP,
119 PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP,
120 PTHREAD_RWLOCK_DEFAULT_NP = PTHREAD_RWLOCK_PREFER_READER_NP
121};
122
123/* Define __PTHREAD_RWLOCK_INT_FLAGS_SHARED to 1 if pthread_rwlock_t
124 has the shared field. All 64-bit architectures have the shared field
125 in pthread_rwlock_t. */
126#ifndef __PTHREAD_RWLOCK_INT_FLAGS_SHARED
127# if __WORDSIZE == 64
128# define __PTHREAD_RWLOCK_INT_FLAGS_SHARED 1
129# endif
130#endif
131
132/* Read-write lock initializers. */
133# define PTHREAD_RWLOCK_INITIALIZER \
134 { { 0, 0, 0, 0, 0, 0, 0, 0, __PTHREAD_RWLOCK_ELISION_EXTRA, 0, 0 } }
135# ifdef __USE_GNU
136# ifdef __PTHREAD_RWLOCK_INT_FLAGS_SHARED
137# define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \
138 { { 0, 0, 0, 0, 0, 0, 0, 0, __PTHREAD_RWLOCK_ELISION_EXTRA, 0, \
139 PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
140# else
141# if __BYTE_ORDER == __LITTLE_ENDIAN
142# define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \
143 { { 0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP, \
144 0, __PTHREAD_RWLOCK_ELISION_EXTRA, 0, 0 } }
145# else
146# define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \
147 { { 0, 0, 0, 0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP,\
148 0 } }
149# endif
150# endif
151# endif
152#endif /* Unix98 or XOpen2K */
153
154
155/* Scheduler inheritance. */
156enum
157{
158 PTHREAD_INHERIT_SCHED,
159#define PTHREAD_INHERIT_SCHED PTHREAD_INHERIT_SCHED
160 PTHREAD_EXPLICIT_SCHED
161#define PTHREAD_EXPLICIT_SCHED PTHREAD_EXPLICIT_SCHED
162};
163
164
165/* Scope handling. */
166enum
167{
168 PTHREAD_SCOPE_SYSTEM,
169#define PTHREAD_SCOPE_SYSTEM PTHREAD_SCOPE_SYSTEM
170 PTHREAD_SCOPE_PROCESS
171#define PTHREAD_SCOPE_PROCESS PTHREAD_SCOPE_PROCESS
172};
173
174
175/* Process shared or private flag. */
176enum
177{
178 PTHREAD_PROCESS_PRIVATE,
179#define PTHREAD_PROCESS_PRIVATE PTHREAD_PROCESS_PRIVATE
180 PTHREAD_PROCESS_SHARED
181#define PTHREAD_PROCESS_SHARED PTHREAD_PROCESS_SHARED
182};
183
184
185
186/* Conditional variable handling. */
187#define PTHREAD_COND_INITIALIZER { { {0}, {0}, {0, 0}, {0, 0}, 0, 0, {0, 0} } }
188
189
190/* Cleanup buffers */
191struct _pthread_cleanup_buffer
192{
193 void (*__routine) (void *); /* Function to call. */
194 void *__arg; /* Its argument. */
195 int __canceltype; /* Saved cancellation type. */
196 struct _pthread_cleanup_buffer *__prev; /* Chaining of cleanup functions. */
197};
198
199/* Cancellation */
200enum
201{
202 PTHREAD_CANCEL_ENABLE,
203#define PTHREAD_CANCEL_ENABLE PTHREAD_CANCEL_ENABLE
204 PTHREAD_CANCEL_DISABLE
205#define PTHREAD_CANCEL_DISABLE PTHREAD_CANCEL_DISABLE
206};
207enum
208{
209 PTHREAD_CANCEL_DEFERRED,
210#define PTHREAD_CANCEL_DEFERRED PTHREAD_CANCEL_DEFERRED
211 PTHREAD_CANCEL_ASYNCHRONOUS
212#define PTHREAD_CANCEL_ASYNCHRONOUS PTHREAD_CANCEL_ASYNCHRONOUS
213};
214#define PTHREAD_CANCELED ((void *) -1)
215
216
217/* Single execution handling. */
218#define PTHREAD_ONCE_INIT 0
219
220
221#ifdef __USE_XOPEN2K
222/* Value returned by 'pthread_barrier_wait' for one of the threads after
223 the required number of threads have called this function.
224 -1 is distinct from 0 and all errno constants */
225# define PTHREAD_BARRIER_SERIAL_THREAD -1
226#endif
227
228
229__BEGIN_DECLS
230
231/* Create a new thread, starting with execution of START-ROUTINE
232 getting passed ARG. Creation attributed come from ATTR. The new
233 handle is stored in *NEWTHREAD. */
234extern int pthread_create (pthread_t *__restrict __newthread,
235 const pthread_attr_t *__restrict __attr,
236 void *(*__start_routine) (void *),
237 void *__restrict __arg) __THROWNL __nonnull ((1, 3));
238
239/* Terminate calling thread.
240
241 The registered cleanup handlers are called via exception handling
242 so we cannot mark this function with __THROW.*/
243extern void pthread_exit (void *__retval) __attribute__ ((__noreturn__));
244
245/* Make calling thread wait for termination of the thread TH. The
246 exit status of the thread is stored in *THREAD_RETURN, if THREAD_RETURN
247 is not NULL.
248
249 This function is a cancellation point and therefore not marked with
250 __THROW. */
251extern int pthread_join (pthread_t __th, void **__thread_return);
252
253#ifdef __USE_GNU
254/* Check whether thread TH has terminated. If yes return the status of
255 the thread in *THREAD_RETURN, if THREAD_RETURN is not NULL. */
256extern int pthread_tryjoin_np (pthread_t __th, void **__thread_return) __THROW;
257
258/* Make calling thread wait for termination of the thread TH, but only
259 until TIMEOUT. The exit status of the thread is stored in
260 *THREAD_RETURN, if THREAD_RETURN is not NULL.
261
262 This function is a cancellation point and therefore not marked with
263 __THROW. */
264extern int pthread_timedjoin_np (pthread_t __th, void **__thread_return,
265 const struct timespec *__abstime);
266#endif
267
268/* Indicate that the thread TH is never to be joined with PTHREAD_JOIN.
269 The resources of TH will therefore be freed immediately when it
270 terminates, instead of waiting for another thread to perform PTHREAD_JOIN
271 on it. */
272extern int pthread_detach (pthread_t __th) __THROW;
273
274
275/* Obtain the identifier of the current thread. */
276extern pthread_t pthread_self (void) __THROW __attribute__ ((__const__));
277
278/* Compare two thread identifiers. */
279extern int pthread_equal (pthread_t __thread1, pthread_t __thread2)
280 __THROW __attribute__ ((__const__));
281
282
283/* Thread attribute handling. */
284
285/* Initialize thread attribute *ATTR with default attributes
286 (detachstate is PTHREAD_JOINABLE, scheduling policy is SCHED_OTHER,
287 no user-provided stack). */
288extern int pthread_attr_init (pthread_attr_t *__attr) __THROW __nonnull ((1));
289
290/* Destroy thread attribute *ATTR. */
291extern int pthread_attr_destroy (pthread_attr_t *__attr)
292 __THROW __nonnull ((1));
293
294/* Get detach state attribute. */
295extern int pthread_attr_getdetachstate (const pthread_attr_t *__attr,
296 int *__detachstate)
297 __THROW __nonnull ((1, 2));
298
299/* Set detach state attribute. */
300extern int pthread_attr_setdetachstate (pthread_attr_t *__attr,
301 int __detachstate)
302 __THROW __nonnull ((1));
303
304
305/* Get the size of the guard area created for stack overflow protection. */
306extern int pthread_attr_getguardsize (const pthread_attr_t *__attr,
307 size_t *__guardsize)
308 __THROW __nonnull ((1, 2));
309
310/* Set the size of the guard area created for stack overflow protection. */
311extern int pthread_attr_setguardsize (pthread_attr_t *__attr,
312 size_t __guardsize)
313 __THROW __nonnull ((1));
314
315
316/* Return in *PARAM the scheduling parameters of *ATTR. */
317extern int pthread_attr_getschedparam (const pthread_attr_t *__restrict __attr,
318 struct sched_param *__restrict __param)
319 __THROW __nonnull ((1, 2));
320
321/* Set scheduling parameters (priority, etc) in *ATTR according to PARAM. */
322extern int pthread_attr_setschedparam (pthread_attr_t *__restrict __attr,
323 const struct sched_param *__restrict
324 __param) __THROW __nonnull ((1, 2));
325
326/* Return in *POLICY the scheduling policy of *ATTR. */
327extern int pthread_attr_getschedpolicy (const pthread_attr_t *__restrict
328 __attr, int *__restrict __policy)
329 __THROW __nonnull ((1, 2));
330
331/* Set scheduling policy in *ATTR according to POLICY. */
332extern int pthread_attr_setschedpolicy (pthread_attr_t *__attr, int __policy)
333 __THROW __nonnull ((1));
334
335/* Return in *INHERIT the scheduling inheritance mode of *ATTR. */
336extern int pthread_attr_getinheritsched (const pthread_attr_t *__restrict
337 __attr, int *__restrict __inherit)
338 __THROW __nonnull ((1, 2));
339
340/* Set scheduling inheritance mode in *ATTR according to INHERIT. */
341extern int pthread_attr_setinheritsched (pthread_attr_t *__attr,
342 int __inherit)
343 __THROW __nonnull ((1));
344
345
346/* Return in *SCOPE the scheduling contention scope of *ATTR. */
347extern int pthread_attr_getscope (const pthread_attr_t *__restrict __attr,
348 int *__restrict __scope)
349 __THROW __nonnull ((1, 2));
350
351/* Set scheduling contention scope in *ATTR according to SCOPE. */
352extern int pthread_attr_setscope (pthread_attr_t *__attr, int __scope)
353 __THROW __nonnull ((1));
354
355/* Return the previously set address for the stack. */
356extern int pthread_attr_getstackaddr (const pthread_attr_t *__restrict
357 __attr, void **__restrict __stackaddr)
358 __THROW __nonnull ((1, 2)) __attribute_deprecated__;
359
360/* Set the starting address of the stack of the thread to be created.
361 Depending on whether the stack grows up or down the value must either
362 be higher or lower than all the address in the memory block. The
363 minimal size of the block must be PTHREAD_STACK_MIN. */
364extern int pthread_attr_setstackaddr (pthread_attr_t *__attr,
365 void *__stackaddr)
366 __THROW __nonnull ((1)) __attribute_deprecated__;
367
368/* Return the currently used minimal stack size. */
369extern int pthread_attr_getstacksize (const pthread_attr_t *__restrict
370 __attr, size_t *__restrict __stacksize)
371 __THROW __nonnull ((1, 2));
372
373/* Add information about the minimum stack size needed for the thread
374 to be started. This size must never be less than PTHREAD_STACK_MIN
375 and must also not exceed the system limits. */
376extern int pthread_attr_setstacksize (pthread_attr_t *__attr,
377 size_t __stacksize)
378 __THROW __nonnull ((1));
379
380#ifdef __USE_XOPEN2K
381/* Return the previously set address for the stack. */
382extern int pthread_attr_getstack (const pthread_attr_t *__restrict __attr,
383 void **__restrict __stackaddr,
384 size_t *__restrict __stacksize)
385 __THROW __nonnull ((1, 2, 3));
386
387/* The following two interfaces are intended to replace the last two. They
388 require setting the address as well as the size since only setting the
389 address will make the implementation on some architectures impossible. */
390extern int pthread_attr_setstack (pthread_attr_t *__attr, void *__stackaddr,
391 size_t __stacksize) __THROW __nonnull ((1));
392#endif
393
394#ifdef __USE_GNU
395/* Thread created with attribute ATTR will be limited to run only on
396 the processors represented in CPUSET. */
397extern int pthread_attr_setaffinity_np (pthread_attr_t *__attr,
398 size_t __cpusetsize,
399 const cpu_set_t *__cpuset)
400 __THROW __nonnull ((1, 3));
401
402/* Get bit set in CPUSET representing the processors threads created with
403 ATTR can run on. */
404extern int pthread_attr_getaffinity_np (const pthread_attr_t *__attr,
405 size_t __cpusetsize,
406 cpu_set_t *__cpuset)
407 __THROW __nonnull ((1, 3));
408
409/* Get the default attributes used by pthread_create in this process. */
410extern int pthread_getattr_default_np (pthread_attr_t *__attr)
411 __THROW __nonnull ((1));
412
413/* Set the default attributes to be used by pthread_create in this
414 process. */
415extern int pthread_setattr_default_np (const pthread_attr_t *__attr)
416 __THROW __nonnull ((1));
417
418/* Initialize thread attribute *ATTR with attributes corresponding to the
419 already running thread TH. It shall be called on uninitialized ATTR
420 and destroyed with pthread_attr_destroy when no longer needed. */
421extern int pthread_getattr_np (pthread_t __th, pthread_attr_t *__attr)
422 __THROW __nonnull ((2));
423#endif
424
425
426/* Functions for scheduling control. */
427
428/* Set the scheduling parameters for TARGET_THREAD according to POLICY
429 and *PARAM. */
430extern int pthread_setschedparam (pthread_t __target_thread, int __policy,
431 const struct sched_param *__param)
432 __THROW __nonnull ((3));
433
434/* Return in *POLICY and *PARAM the scheduling parameters for TARGET_THREAD. */
435extern int pthread_getschedparam (pthread_t __target_thread,
436 int *__restrict __policy,
437 struct sched_param *__restrict __param)
438 __THROW __nonnull ((2, 3));
439
440/* Set the scheduling priority for TARGET_THREAD. */
441extern int pthread_setschedprio (pthread_t __target_thread, int __prio)
442 __THROW;
443
444
445#ifdef __USE_GNU
446/* Get thread name visible in the kernel and its interfaces. */
447extern int pthread_getname_np (pthread_t __target_thread, char *__buf,
448 size_t __buflen)
449 __THROW __nonnull ((2));
450
451/* Set thread name visible in the kernel and its interfaces. */
452extern int pthread_setname_np (pthread_t __target_thread, const char *__name)
453 __THROW __nonnull ((2));
454#endif
455
456
457#ifdef __USE_UNIX98
458/* Determine level of concurrency. */
459extern int pthread_getconcurrency (void) __THROW;
460
461/* Set new concurrency level to LEVEL. */
462extern int pthread_setconcurrency (int __level) __THROW;
463#endif
464
465#ifdef __USE_GNU
466/* Yield the processor to another thread or process.
467 This function is similar to the POSIX `sched_yield' function but
468 might be differently implemented in the case of a m-on-n thread
469 implementation. */
470extern int pthread_yield (void) __THROW;
471
472
473/* Limit specified thread TH to run only on the processors represented
474 in CPUSET. */
475extern int pthread_setaffinity_np (pthread_t __th, size_t __cpusetsize,
476 const cpu_set_t *__cpuset)
477 __THROW __nonnull ((3));
478
479/* Get bit set in CPUSET representing the processors TH can run on. */
480extern int pthread_getaffinity_np (pthread_t __th, size_t __cpusetsize,
481 cpu_set_t *__cpuset)
482 __THROW __nonnull ((3));
483#endif
484
485
486/* Functions for handling initialization. */
487
488/* Guarantee that the initialization function INIT_ROUTINE will be called
489 only once, even if pthread_once is executed several times with the
490 same ONCE_CONTROL argument. ONCE_CONTROL must point to a static or
491 extern variable initialized to PTHREAD_ONCE_INIT.
492
493 The initialization functions might throw exception which is why
494 this function is not marked with __THROW. */
495extern int pthread_once (pthread_once_t *__once_control,
496 void (*__init_routine) (void)) __nonnull ((1, 2));
497
498
499/* Functions for handling cancellation.
500
501 Note that these functions are explicitly not marked to not throw an
502 exception in C++ code. If cancellation is implemented by unwinding
503 this is necessary to have the compiler generate the unwind information. */
504
505/* Set cancelability state of current thread to STATE, returning old
506 state in *OLDSTATE if OLDSTATE is not NULL. */
507extern int pthread_setcancelstate (int __state, int *__oldstate);
508
509/* Set cancellation state of current thread to TYPE, returning the old
510 type in *OLDTYPE if OLDTYPE is not NULL. */
511extern int pthread_setcanceltype (int __type, int *__oldtype);
512
513/* Cancel THREAD immediately or at the next possibility. */
514extern int pthread_cancel (pthread_t __th);
515
516/* Test for pending cancellation for the current thread and terminate
517 the thread as per pthread_exit(PTHREAD_CANCELED) if it has been
518 cancelled. */
519extern void pthread_testcancel (void);
520
521
522/* Cancellation handling with integration into exception handling. */
523
524typedef struct
525{
526 struct
527 {
528 __jmp_buf __cancel_jmp_buf;
529 int __mask_was_saved;
530 } __cancel_jmp_buf[1];
531 void *__pad[4];
532} __pthread_unwind_buf_t __attribute__ ((__aligned__));
533
534/* No special attributes by default. */
535#ifndef __cleanup_fct_attribute
536# define __cleanup_fct_attribute
537#endif
538
539
540/* Structure to hold the cleanup handler information. */
541struct __pthread_cleanup_frame
542{
543 void (*__cancel_routine) (void *);
544 void *__cancel_arg;
545 int __do_it;
546 int __cancel_type;
547};
548
549#if defined __GNUC__ && defined __EXCEPTIONS
550# ifdef __cplusplus
551/* Class to handle cancellation handler invocation. */
552class __pthread_cleanup_class
553{
554 void (*__cancel_routine) (void *);
555 void *__cancel_arg;
556 int __do_it;
557 int __cancel_type;
558
559 public:
560 __pthread_cleanup_class (void (*__fct) (void *), void *__arg)
561 : __cancel_routine (__fct), __cancel_arg (__arg), __do_it (1) { }
562 ~__pthread_cleanup_class () { if (__do_it) __cancel_routine (__cancel_arg); }
563 void __setdoit (int __newval) { __do_it = __newval; }
564 void __defer () { pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED,
565 &__cancel_type); }
566 void __restore () const { pthread_setcanceltype (__cancel_type, 0); }
567};
568
569/* Install a cleanup handler: ROUTINE will be called with arguments ARG
570 when the thread is canceled or calls pthread_exit. ROUTINE will also
571 be called with arguments ARG when the matching pthread_cleanup_pop
572 is executed with non-zero EXECUTE argument.
573
574 pthread_cleanup_push and pthread_cleanup_pop are macros and must always
575 be used in matching pairs at the same nesting level of braces. */
576# define pthread_cleanup_push(routine, arg) \
577 do { \
578 __pthread_cleanup_class __clframe (routine, arg)
579
580/* Remove a cleanup handler installed by the matching pthread_cleanup_push.
581 If EXECUTE is non-zero, the handler function is called. */
582# define pthread_cleanup_pop(execute) \
583 __clframe.__setdoit (execute); \
584 } while (0)
585
586# ifdef __USE_GNU
587/* Install a cleanup handler as pthread_cleanup_push does, but also
588 saves the current cancellation type and sets it to deferred
589 cancellation. */
590# define pthread_cleanup_push_defer_np(routine, arg) \
591 do { \
592 __pthread_cleanup_class __clframe (routine, arg); \
593 __clframe.__defer ()
594
595/* Remove a cleanup handler as pthread_cleanup_pop does, but also
596 restores the cancellation type that was in effect when the matching
597 pthread_cleanup_push_defer was called. */
598# define pthread_cleanup_pop_restore_np(execute) \
599 __clframe.__restore (); \
600 __clframe.__setdoit (execute); \
601 } while (0)
602# endif
603# else
604/* Function called to call the cleanup handler. As an extern inline
605 function the compiler is free to decide inlining the change when
606 needed or fall back on the copy which must exist somewhere
607 else. */
608__extern_inline void
609__pthread_cleanup_routine (struct __pthread_cleanup_frame *__frame)
610{
611 if (__frame->__do_it)
612 __frame->__cancel_routine (__frame->__cancel_arg);
613}
614
615/* Install a cleanup handler: ROUTINE will be called with arguments ARG
616 when the thread is canceled or calls pthread_exit. ROUTINE will also
617 be called with arguments ARG when the matching pthread_cleanup_pop
618 is executed with non-zero EXECUTE argument.
619
620 pthread_cleanup_push and pthread_cleanup_pop are macros and must always
621 be used in matching pairs at the same nesting level of braces. */
622# define pthread_cleanup_push(routine, arg) \
623 do { \
624 struct __pthread_cleanup_frame __clframe \
625 __attribute__ ((__cleanup__ (__pthread_cleanup_routine))) \
626 = { .__cancel_routine = (routine), .__cancel_arg = (arg), \
627 .__do_it = 1 };
628
629/* Remove a cleanup handler installed by the matching pthread_cleanup_push.
630 If EXECUTE is non-zero, the handler function is called. */
631# define pthread_cleanup_pop(execute) \
632 __clframe.__do_it = (execute); \
633 } while (0)
634
635# ifdef __USE_GNU
636/* Install a cleanup handler as pthread_cleanup_push does, but also
637 saves the current cancellation type and sets it to deferred
638 cancellation. */
639# define pthread_cleanup_push_defer_np(routine, arg) \
640 do { \
641 struct __pthread_cleanup_frame __clframe \
642 __attribute__ ((__cleanup__ (__pthread_cleanup_routine))) \
643 = { .__cancel_routine = (routine), .__cancel_arg = (arg), \
644 .__do_it = 1 }; \
645 (void) pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, \
646 &__clframe.__cancel_type)
647
648/* Remove a cleanup handler as pthread_cleanup_pop does, but also
649 restores the cancellation type that was in effect when the matching
650 pthread_cleanup_push_defer was called. */
651# define pthread_cleanup_pop_restore_np(execute) \
652 (void) pthread_setcanceltype (__clframe.__cancel_type, NULL); \
653 __clframe.__do_it = (execute); \
654 } while (0)
655# endif
656# endif
657#else
658/* Install a cleanup handler: ROUTINE will be called with arguments ARG
659 when the thread is canceled or calls pthread_exit. ROUTINE will also
660 be called with arguments ARG when the matching pthread_cleanup_pop
661 is executed with non-zero EXECUTE argument.
662
663 pthread_cleanup_push and pthread_cleanup_pop are macros and must always
664 be used in matching pairs at the same nesting level of braces. */
665# define pthread_cleanup_push(routine, arg) \
666 do { \
667 __pthread_unwind_buf_t __cancel_buf; \
668 void (*__cancel_routine) (void *) = (routine); \
669 void *__cancel_arg = (arg); \
670 int __not_first_call = __sigsetjmp ((struct __jmp_buf_tag *) (void *) \
671 __cancel_buf.__cancel_jmp_buf, 0); \
672 if (__glibc_unlikely (__not_first_call)) \
673 { \
674 __cancel_routine (__cancel_arg); \
675 __pthread_unwind_next (&__cancel_buf); \
676 /* NOTREACHED */ \
677 } \
678 \
679 __pthread_register_cancel (&__cancel_buf); \
680 do {
681extern void __pthread_register_cancel (__pthread_unwind_buf_t *__buf)
682 __cleanup_fct_attribute;
683
684/* Remove a cleanup handler installed by the matching pthread_cleanup_push.
685 If EXECUTE is non-zero, the handler function is called. */
686# define pthread_cleanup_pop(execute) \
687 do { } while (0);/* Empty to allow label before pthread_cleanup_pop. */\
688 } while (0); \
689 __pthread_unregister_cancel (&__cancel_buf); \
690 if (execute) \
691 __cancel_routine (__cancel_arg); \
692 } while (0)
693extern void __pthread_unregister_cancel (__pthread_unwind_buf_t *__buf)
694 __cleanup_fct_attribute;
695
696# ifdef __USE_GNU
697/* Install a cleanup handler as pthread_cleanup_push does, but also
698 saves the current cancellation type and sets it to deferred
699 cancellation. */
700# define pthread_cleanup_push_defer_np(routine, arg) \
701 do { \
702 __pthread_unwind_buf_t __cancel_buf; \
703 void (*__cancel_routine) (void *) = (routine); \
704 void *__cancel_arg = (arg); \
705 int __not_first_call = __sigsetjmp ((struct __jmp_buf_tag *) (void *) \
706 __cancel_buf.__cancel_jmp_buf, 0); \
707 if (__glibc_unlikely (__not_first_call)) \
708 { \
709 __cancel_routine (__cancel_arg); \
710 __pthread_unwind_next (&__cancel_buf); \
711 /* NOTREACHED */ \
712 } \
713 \
714 __pthread_register_cancel_defer (&__cancel_buf); \
715 do {
716extern void __pthread_register_cancel_defer (__pthread_unwind_buf_t *__buf)
717 __cleanup_fct_attribute;
718
719/* Remove a cleanup handler as pthread_cleanup_pop does, but also
720 restores the cancellation type that was in effect when the matching
721 pthread_cleanup_push_defer was called. */
722# define pthread_cleanup_pop_restore_np(execute) \
723 do { } while (0);/* Empty to allow label before pthread_cleanup_pop. */\
724 } while (0); \
725 __pthread_unregister_cancel_restore (&__cancel_buf); \
726 if (execute) \
727 __cancel_routine (__cancel_arg); \
728 } while (0)
729extern void __pthread_unregister_cancel_restore (__pthread_unwind_buf_t *__buf)
730 __cleanup_fct_attribute;
731# endif
732
733/* Internal interface to initiate cleanup. */
734extern void __pthread_unwind_next (__pthread_unwind_buf_t *__buf)
735 __cleanup_fct_attribute __attribute__ ((__noreturn__))
736# ifndef SHARED
737 __attribute__ ((__weak__))
738# endif
739 ;
740#endif
741
742/* Function used in the macros. */
743struct __jmp_buf_tag;
744extern int __sigsetjmp (struct __jmp_buf_tag *__env, int __savemask) __THROWNL;
745
746
747/* Mutex handling. */
748
749/* Initialize a mutex. */
750extern int pthread_mutex_init (pthread_mutex_t *__mutex,
751 const pthread_mutexattr_t *__mutexattr)
752 __THROW __nonnull ((1));
753
754/* Destroy a mutex. */
755extern int pthread_mutex_destroy (pthread_mutex_t *__mutex)
756 __THROW __nonnull ((1));
757
758/* Try locking a mutex. */
759extern int pthread_mutex_trylock (pthread_mutex_t *__mutex)
760 __THROWNL __nonnull ((1));
761
762/* Lock a mutex. */
763extern int pthread_mutex_lock (pthread_mutex_t *__mutex)
764 __THROWNL __nonnull ((1));
765
766#ifdef __USE_XOPEN2K
767/* Wait until lock becomes available, or specified time passes. */
768extern int pthread_mutex_timedlock (pthread_mutex_t *__restrict __mutex,
769 const struct timespec *__restrict
770 __abstime) __THROWNL __nonnull ((1, 2));
771#endif
772
773/* Unlock a mutex. */
774extern int pthread_mutex_unlock (pthread_mutex_t *__mutex)
775 __THROWNL __nonnull ((1));
776
777
778/* Get the priority ceiling of MUTEX. */
779extern int pthread_mutex_getprioceiling (const pthread_mutex_t *
780 __restrict __mutex,
781 int *__restrict __prioceiling)
782 __THROW __nonnull ((1, 2));
783
784/* Set the priority ceiling of MUTEX to PRIOCEILING, return old
785 priority ceiling value in *OLD_CEILING. */
786extern int pthread_mutex_setprioceiling (pthread_mutex_t *__restrict __mutex,
787 int __prioceiling,
788 int *__restrict __old_ceiling)
789 __THROW __nonnull ((1, 3));
790
791
792#ifdef __USE_XOPEN2K8
793/* Declare the state protected by MUTEX as consistent. */
794extern int pthread_mutex_consistent (pthread_mutex_t *__mutex)
795 __THROW __nonnull ((1));
796# ifdef __USE_GNU
797extern int pthread_mutex_consistent_np (pthread_mutex_t *__mutex)
798 __THROW __nonnull ((1));
799# endif
800#endif
801
802
803/* Functions for handling mutex attributes. */
804
805/* Initialize mutex attribute object ATTR with default attributes
806 (kind is PTHREAD_MUTEX_TIMED_NP). */
807extern int pthread_mutexattr_init (pthread_mutexattr_t *__attr)
808 __THROW __nonnull ((1));
809
810/* Destroy mutex attribute object ATTR. */
811extern int pthread_mutexattr_destroy (pthread_mutexattr_t *__attr)
812 __THROW __nonnull ((1));
813
814/* Get the process-shared flag of the mutex attribute ATTR. */
815extern int pthread_mutexattr_getpshared (const pthread_mutexattr_t *
816 __restrict __attr,
817 int *__restrict __pshared)
818 __THROW __nonnull ((1, 2));
819
820/* Set the process-shared flag of the mutex attribute ATTR. */
821extern int pthread_mutexattr_setpshared (pthread_mutexattr_t *__attr,
822 int __pshared)
823 __THROW __nonnull ((1));
824
825#if defined __USE_UNIX98 || defined __USE_XOPEN2K8
826/* Return in *KIND the mutex kind attribute in *ATTR. */
827extern int pthread_mutexattr_gettype (const pthread_mutexattr_t *__restrict
828 __attr, int *__restrict __kind)
829 __THROW __nonnull ((1, 2));
830
831/* Set the mutex kind attribute in *ATTR to KIND (either PTHREAD_MUTEX_NORMAL,
832 PTHREAD_MUTEX_RECURSIVE, PTHREAD_MUTEX_ERRORCHECK, or
833 PTHREAD_MUTEX_DEFAULT). */
834extern int pthread_mutexattr_settype (pthread_mutexattr_t *__attr, int __kind)
835 __THROW __nonnull ((1));
836#endif
837
838/* Return in *PROTOCOL the mutex protocol attribute in *ATTR. */
839extern int pthread_mutexattr_getprotocol (const pthread_mutexattr_t *
840 __restrict __attr,
841 int *__restrict __protocol)
842 __THROW __nonnull ((1, 2));
843
844/* Set the mutex protocol attribute in *ATTR to PROTOCOL (either
845 PTHREAD_PRIO_NONE, PTHREAD_PRIO_INHERIT, or PTHREAD_PRIO_PROTECT). */
846extern int pthread_mutexattr_setprotocol (pthread_mutexattr_t *__attr,
847 int __protocol)
848 __THROW __nonnull ((1));
849
850/* Return in *PRIOCEILING the mutex prioceiling attribute in *ATTR. */
851extern int pthread_mutexattr_getprioceiling (const pthread_mutexattr_t *
852 __restrict __attr,
853 int *__restrict __prioceiling)
854 __THROW __nonnull ((1, 2));
855
856/* Set the mutex prioceiling attribute in *ATTR to PRIOCEILING. */
857extern int pthread_mutexattr_setprioceiling (pthread_mutexattr_t *__attr,
858 int __prioceiling)
859 __THROW __nonnull ((1));
860
861#ifdef __USE_XOPEN2K
862/* Get the robustness flag of the mutex attribute ATTR. */
863extern int pthread_mutexattr_getrobust (const pthread_mutexattr_t *__attr,
864 int *__robustness)
865 __THROW __nonnull ((1, 2));
866# ifdef __USE_GNU
867extern int pthread_mutexattr_getrobust_np (const pthread_mutexattr_t *__attr,
868 int *__robustness)
869 __THROW __nonnull ((1, 2));
870# endif
871
872/* Set the robustness flag of the mutex attribute ATTR. */
873extern int pthread_mutexattr_setrobust (pthread_mutexattr_t *__attr,
874 int __robustness)
875 __THROW __nonnull ((1));
876# ifdef __USE_GNU
877extern int pthread_mutexattr_setrobust_np (pthread_mutexattr_t *__attr,
878 int __robustness)
879 __THROW __nonnull ((1));
880# endif
881#endif
882
883
884#if defined __USE_UNIX98 || defined __USE_XOPEN2K
885/* Functions for handling read-write locks. */
886
887/* Initialize read-write lock RWLOCK using attributes ATTR, or use
888 the default values if later is NULL. */
889extern int pthread_rwlock_init (pthread_rwlock_t *__restrict __rwlock,
890 const pthread_rwlockattr_t *__restrict
891 __attr) __THROW __nonnull ((1));
892
893/* Destroy read-write lock RWLOCK. */
894extern int pthread_rwlock_destroy (pthread_rwlock_t *__rwlock)
895 __THROW __nonnull ((1));
896
897/* Acquire read lock for RWLOCK. */
898extern int pthread_rwlock_rdlock (pthread_rwlock_t *__rwlock)
899 __THROWNL __nonnull ((1));
900
901/* Try to acquire read lock for RWLOCK. */
902extern int pthread_rwlock_tryrdlock (pthread_rwlock_t *__rwlock)
903 __THROWNL __nonnull ((1));
904
905# ifdef __USE_XOPEN2K
906/* Try to acquire read lock for RWLOCK or return after specfied time. */
907extern int pthread_rwlock_timedrdlock (pthread_rwlock_t *__restrict __rwlock,
908 const struct timespec *__restrict
909 __abstime) __THROWNL __nonnull ((1, 2));
910# endif
911
912/* Acquire write lock for RWLOCK. */
913extern int pthread_rwlock_wrlock (pthread_rwlock_t *__rwlock)
914 __THROWNL __nonnull ((1));
915
916/* Try to acquire write lock for RWLOCK. */
917extern int pthread_rwlock_trywrlock (pthread_rwlock_t *__rwlock)
918 __THROWNL __nonnull ((1));
919
920# ifdef __USE_XOPEN2K
921/* Try to acquire write lock for RWLOCK or return after specfied time. */
922extern int pthread_rwlock_timedwrlock (pthread_rwlock_t *__restrict __rwlock,
923 const struct timespec *__restrict
924 __abstime) __THROWNL __nonnull ((1, 2));
925# endif
926
927/* Unlock RWLOCK. */
928extern int pthread_rwlock_unlock (pthread_rwlock_t *__rwlock)
929 __THROWNL __nonnull ((1));
930
931
932/* Functions for handling read-write lock attributes. */
933
934/* Initialize attribute object ATTR with default values. */
935extern int pthread_rwlockattr_init (pthread_rwlockattr_t *__attr)
936 __THROW __nonnull ((1));
937
938/* Destroy attribute object ATTR. */
939extern int pthread_rwlockattr_destroy (pthread_rwlockattr_t *__attr)
940 __THROW __nonnull ((1));
941
942/* Return current setting of process-shared attribute of ATTR in PSHARED. */
943extern int pthread_rwlockattr_getpshared (const pthread_rwlockattr_t *
944 __restrict __attr,
945 int *__restrict __pshared)
946 __THROW __nonnull ((1, 2));
947
948/* Set process-shared attribute of ATTR to PSHARED. */
949extern int pthread_rwlockattr_setpshared (pthread_rwlockattr_t *__attr,
950 int __pshared)
951 __THROW __nonnull ((1));
952
953/* Return current setting of reader/writer preference. */
954extern int pthread_rwlockattr_getkind_np (const pthread_rwlockattr_t *
955 __restrict __attr,
956 int *__restrict __pref)
957 __THROW __nonnull ((1, 2));
958
959/* Set reader/write preference. */
960extern int pthread_rwlockattr_setkind_np (pthread_rwlockattr_t *__attr,
961 int __pref) __THROW __nonnull ((1));
962#endif
963
964
965/* Functions for handling conditional variables. */
966
967/* Initialize condition variable COND using attributes ATTR, or use
968 the default values if later is NULL. */
969extern int pthread_cond_init (pthread_cond_t *__restrict __cond,
970 const pthread_condattr_t *__restrict __cond_attr)
971 __THROW __nonnull ((1));
972
973/* Destroy condition variable COND. */
974extern int pthread_cond_destroy (pthread_cond_t *__cond)
975 __THROW __nonnull ((1));
976
977/* Wake up one thread waiting for condition variable COND. */
978extern int pthread_cond_signal (pthread_cond_t *__cond)
979 __THROWNL __nonnull ((1));
980
981/* Wake up all threads waiting for condition variables COND. */
982extern int pthread_cond_broadcast (pthread_cond_t *__cond)
983 __THROWNL __nonnull ((1));
984
985/* Wait for condition variable COND to be signaled or broadcast.
986 MUTEX is assumed to be locked before.
987
988 This function is a cancellation point and therefore not marked with
989 __THROW. */
990extern int pthread_cond_wait (pthread_cond_t *__restrict __cond,
991 pthread_mutex_t *__restrict __mutex)
992 __nonnull ((1, 2));
993
994/* Wait for condition variable COND to be signaled or broadcast until
995 ABSTIME. MUTEX is assumed to be locked before. ABSTIME is an
996 absolute time specification; zero is the beginning of the epoch
997 (00:00:00 GMT, January 1, 1970).
998
999 This function is a cancellation point and therefore not marked with
1000 __THROW. */
1001extern int pthread_cond_timedwait (pthread_cond_t *__restrict __cond,
1002 pthread_mutex_t *__restrict __mutex,
1003 const struct timespec *__restrict __abstime)
1004 __nonnull ((1, 2, 3));
1005
1006/* Functions for handling condition variable attributes. */
1007
1008/* Initialize condition variable attribute ATTR. */
1009extern int pthread_condattr_init (pthread_condattr_t *__attr)
1010 __THROW __nonnull ((1));
1011
1012/* Destroy condition variable attribute ATTR. */
1013extern int pthread_condattr_destroy (pthread_condattr_t *__attr)
1014 __THROW __nonnull ((1));
1015
1016/* Get the process-shared flag of the condition variable attribute ATTR. */
1017extern int pthread_condattr_getpshared (const pthread_condattr_t *
1018 __restrict __attr,
1019 int *__restrict __pshared)
1020 __THROW __nonnull ((1, 2));
1021
1022/* Set the process-shared flag of the condition variable attribute ATTR. */
1023extern int pthread_condattr_setpshared (pthread_condattr_t *__attr,
1024 int __pshared) __THROW __nonnull ((1));
1025
1026#ifdef __USE_XOPEN2K
1027/* Get the clock selected for the condition variable attribute ATTR. */
1028extern int pthread_condattr_getclock (const pthread_condattr_t *
1029 __restrict __attr,
1030 __clockid_t *__restrict __clock_id)
1031 __THROW __nonnull ((1, 2));
1032
1033/* Set the clock selected for the condition variable attribute ATTR. */
1034extern int pthread_condattr_setclock (pthread_condattr_t *__attr,
1035 __clockid_t __clock_id)
1036 __THROW __nonnull ((1));
1037#endif
1038
1039
1040#ifdef __USE_XOPEN2K
1041/* Functions to handle spinlocks. */
1042
1043/* Initialize the spinlock LOCK. If PSHARED is nonzero the spinlock can
1044 be shared between different processes. */
1045extern int pthread_spin_init (pthread_spinlock_t *__lock, int __pshared)
1046 __THROW __nonnull ((1));
1047
1048/* Destroy the spinlock LOCK. */
1049extern int pthread_spin_destroy (pthread_spinlock_t *__lock)
1050 __THROW __nonnull ((1));
1051
1052/* Wait until spinlock LOCK is retrieved. */
1053extern int pthread_spin_lock (pthread_spinlock_t *__lock)
1054 __THROWNL __nonnull ((1));
1055
1056/* Try to lock spinlock LOCK. */
1057extern int pthread_spin_trylock (pthread_spinlock_t *__lock)
1058 __THROWNL __nonnull ((1));
1059
1060/* Release spinlock LOCK. */
1061extern int pthread_spin_unlock (pthread_spinlock_t *__lock)
1062 __THROWNL __nonnull ((1));
1063
1064
1065/* Functions to handle barriers. */
1066
1067/* Initialize BARRIER with the attributes in ATTR. The barrier is
1068 opened when COUNT waiters arrived. */
1069extern int pthread_barrier_init (pthread_barrier_t *__restrict __barrier,
1070 const pthread_barrierattr_t *__restrict
1071 __attr, unsigned int __count)
1072 __THROW __nonnull ((1));
1073
1074/* Destroy a previously dynamically initialized barrier BARRIER. */
1075extern int pthread_barrier_destroy (pthread_barrier_t *__barrier)
1076 __THROW __nonnull ((1));
1077
1078/* Wait on barrier BARRIER. */
1079extern int pthread_barrier_wait (pthread_barrier_t *__barrier)
1080 __THROWNL __nonnull ((1));
1081
1082
1083/* Initialize barrier attribute ATTR. */
1084extern int pthread_barrierattr_init (pthread_barrierattr_t *__attr)
1085 __THROW __nonnull ((1));
1086
1087/* Destroy previously dynamically initialized barrier attribute ATTR. */
1088extern int pthread_barrierattr_destroy (pthread_barrierattr_t *__attr)
1089 __THROW __nonnull ((1));
1090
1091/* Get the process-shared flag of the barrier attribute ATTR. */
1092extern int pthread_barrierattr_getpshared (const pthread_barrierattr_t *
1093 __restrict __attr,
1094 int *__restrict __pshared)
1095 __THROW __nonnull ((1, 2));
1096
1097/* Set the process-shared flag of the barrier attribute ATTR. */
1098extern int pthread_barrierattr_setpshared (pthread_barrierattr_t *__attr,
1099 int __pshared)
1100 __THROW __nonnull ((1));
1101#endif
1102
1103
1104/* Functions for handling thread-specific data. */
1105
1106/* Create a key value identifying a location in the thread-specific
1107 data area. Each thread maintains a distinct thread-specific data
1108 area. DESTR_FUNCTION, if non-NULL, is called with the value
1109 associated to that key when the key is destroyed.
1110 DESTR_FUNCTION is not called if the value associated is NULL when
1111 the key is destroyed. */
1112extern int pthread_key_create (pthread_key_t *__key,
1113 void (*__destr_function) (void *))
1114 __THROW __nonnull ((1));
1115
1116/* Destroy KEY. */
1117extern int pthread_key_delete (pthread_key_t __key) __THROW;
1118
1119/* Return current value of the thread-specific data slot identified by KEY. */
1120extern void *pthread_getspecific (pthread_key_t __key) __THROW;
1121
1122/* Store POINTER in the thread-specific data slot identified by KEY. */
1123extern int pthread_setspecific (pthread_key_t __key,
1124 const void *__pointer) __THROW ;
1125
1126
1127#ifdef __USE_XOPEN2K
1128/* Get ID of CPU-time clock for thread THREAD_ID. */
1129extern int pthread_getcpuclockid (pthread_t __thread_id,
1130 __clockid_t *__clock_id)
1131 __THROW __nonnull ((2));
1132#endif
1133
1134
1135/* Install handlers to be called when a new process is created with FORK.
1136 The PREPARE handler is called in the parent process just before performing
1137 FORK. The PARENT handler is called in the parent process just after FORK.
1138 The CHILD handler is called in the child process. Each of the three
1139 handlers can be NULL, meaning that no handler needs to be called at that
1140 point.
1141 PTHREAD_ATFORK can be called several times, in which case the PREPARE
1142 handlers are called in LIFO order (last added with PTHREAD_ATFORK,
1143 first called before FORK), and the PARENT and CHILD handlers are called
1144 in FIFO (first added, first called). */
1145
1146extern int pthread_atfork (void (*__prepare) (void),
1147 void (*__parent) (void),
1148 void (*__child) (void)) __THROW;
1149
1150
1151#ifdef __USE_EXTERN_INLINES
1152/* Optimizations. */
1153__extern_inline int
1154__NTH (pthread_equal (pthread_t __thread1, pthread_t __thread2))
1155{
1156 return __thread1 == __thread2;
1157}
1158#endif
1159
1160__END_DECLS
1161
1162#endif /* pthread.h */
libc/glibc-include/pty.h created+48
...@@ -0,0 +1,48 @@
1/* Functions for pseudo TTY handling.
2 Copyright (C) 1996-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _PTY_H
20#define _PTY_H 1
21
22#include <features.h>
23
24struct termios;
25struct winsize;
26
27#include <termios.h>
28#include <sys/ioctl.h>
29
30
31__BEGIN_DECLS
32
33/* Create pseudo tty master slave pair with NAME and set terminal
34 attributes according to TERMP and WINP and return handles for both
35 ends in AMASTER and ASLAVE. */
36extern int openpty (int *__amaster, int *__aslave, char *__name,
37 const struct termios *__termp,
38 const struct winsize *__winp) __THROW;
39
40/* Create child process and establish the slave pseudo terminal as the
41 child's controlling terminal. */
42extern int forkpty (int *__amaster, char *__name,
43 const struct termios *__termp,
44 const struct winsize *__winp) __THROW;
45
46__END_DECLS
47
48#endif /* pty.h */
libc/glibc-include/pwd.h created+189
...@@ -0,0 +1,189 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/*
19 * POSIX Standard: 9.2.2 User Database Access <pwd.h>
20 */
21
22#ifndef _PWD_H
23#define _PWD_H 1
24
25#include <features.h>
26
27__BEGIN_DECLS
28
29#include <bits/types.h>
30
31#define __need_size_t
32#include <stddef.h>
33
34#if defined __USE_XOPEN || defined __USE_XOPEN2K
35/* The Single Unix specification says that some more types are
36 available here. */
37# ifndef __gid_t_defined
38typedef __gid_t gid_t;
39# define __gid_t_defined
40# endif
41
42# ifndef __uid_t_defined
43typedef __uid_t uid_t;
44# define __uid_t_defined
45# endif
46#endif
47
48/* A record in the user database. */
49struct passwd
50{
51 char *pw_name; /* Username. */
52 char *pw_passwd; /* Hashed passphrase, if shadow database
53 not in use (see shadow.h). */
54 __uid_t pw_uid; /* User ID. */
55 __gid_t pw_gid; /* Group ID. */
56 char *pw_gecos; /* Real name. */
57 char *pw_dir; /* Home directory. */
58 char *pw_shell; /* Shell program. */
59};
60
61
62#ifdef __USE_MISC
63# include <bits/types/FILE.h>
64#endif
65
66
67#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
68/* Rewind the user database stream.
69
70 This function is a possible cancellation point and therefore not
71 marked with __THROW. */
72extern void setpwent (void);
73
74/* Close the user database stream.
75
76 This function is a possible cancellation point and therefore not
77 marked with __THROW. */
78extern void endpwent (void);
79
80/* Read an entry from the user database stream, opening it if necessary.
81
82 This function is a possible cancellation point and therefore not
83 marked with __THROW. */
84extern struct passwd *getpwent (void);
85#endif
86
87#ifdef __USE_MISC
88/* Read a user database entry from STREAM.
89
90 This function is not part of POSIX and therefore no official
91 cancellation point. But due to similarity with an POSIX interface
92 or due to the implementation it is a cancellation point and
93 therefore not marked with __THROW. */
94extern struct passwd *fgetpwent (FILE *__stream) __nonnull ((1));
95
96/* Write a given user database entry onto the given stream.
97
98 This function is not part of POSIX and therefore no official
99 cancellation point. But due to similarity with an POSIX interface
100 or due to the implementation it is a cancellation point and
101 therefore not marked with __THROW. */
102extern int putpwent (const struct passwd *__restrict __p,
103 FILE *__restrict __f);
104#endif
105
106/* Retrieve the user database entry for the given user ID.
107
108 This function is a possible cancellation point and therefore not
109 marked with __THROW. */
110extern struct passwd *getpwuid (__uid_t __uid);
111
112/* Retrieve the user database entry for the given username.
113
114 This function is a possible cancellation point and therefore not
115 marked with __THROW. */
116extern struct passwd *getpwnam (const char *__name) __nonnull ((1));
117
118#ifdef __USE_POSIX
119
120# ifdef __USE_MISC
121/* Reasonable value for the buffer sized used in the reentrant
122 functions below. But better use `sysconf'. */
123# define NSS_BUFLEN_PASSWD 1024
124# endif
125
126/* Reentrant versions of some of the functions above.
127
128 PLEASE NOTE: the `getpwent_r' function is not (yet) standardized.
129 The interface may change in later versions of this library. But
130 the interface is designed following the principals used for the
131 other reentrant functions so the chances are good this is what the
132 POSIX people would choose. */
133
134# ifdef __USE_MISC
135/* This function is not part of POSIX and therefore no official
136 cancellation point. But due to similarity with an POSIX interface
137 or due to the implementation it is a cancellation point and
138 therefore not marked with __THROW. */
139extern int getpwent_r (struct passwd *__restrict __resultbuf,
140 char *__restrict __buffer, size_t __buflen,
141 struct passwd **__restrict __result)
142 __nonnull ((1, 2, 4));
143# endif
144
145extern int getpwuid_r (__uid_t __uid,
146 struct passwd *__restrict __resultbuf,
147 char *__restrict __buffer, size_t __buflen,
148 struct passwd **__restrict __result)
149 __nonnull ((2, 3, 5));
150
151extern int getpwnam_r (const char *__restrict __name,
152 struct passwd *__restrict __resultbuf,
153 char *__restrict __buffer, size_t __buflen,
154 struct passwd **__restrict __result)
155 __nonnull ((1, 2, 3, 5));
156
157
158# ifdef __USE_MISC
159/* Read a user database entry from STREAM. This function is not
160 standardized and probably never will.
161
162 This function is not part of POSIX and therefore no official
163 cancellation point. But due to similarity with an POSIX interface
164 or due to the implementation it is a cancellation point and
165 therefore not marked with __THROW. */
166extern int fgetpwent_r (FILE *__restrict __stream,
167 struct passwd *__restrict __resultbuf,
168 char *__restrict __buffer, size_t __buflen,
169 struct passwd **__restrict __result)
170 __nonnull ((1, 2, 3, 5));
171# endif
172
173#endif /* POSIX or reentrant */
174
175#ifdef __USE_GNU
176/* Write a traditional /etc/passwd line, based on the user database
177 entry for the given UID, to BUFFER; space for BUFFER must be
178 allocated by the caller.
179
180 This function is not part of POSIX and therefore no official
181 cancellation point. But due to similarity with an POSIX interface
182 or due to the implementation it is a cancellation point and
183 therefore not marked with __THROW. */
184extern int getpw (__uid_t __uid, char *__buffer);
185#endif
186
187__END_DECLS
188
189#endif /* pwd.h */
libc/glibc-include/re_comp.h created+25
...@@ -0,0 +1,25 @@
1/* Copyright (C) 1996-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _RE_COMP_H
19#define _RE_COMP_H 1
20
21/* This is only a wrapper around the <regex.h> file. XPG4.2 mentions
22 this name. */
23#include <regex.h>
24
25#endif /* re_comp.h */
libc/glibc-include/regex.h created+658
...@@ -0,0 +1,658 @@
1/* Definitions for data structures and routines for the regular
2 expression library.
3 Copyright (C) 1985, 1989-2019 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <https://www.gnu.org/licenses/>. */
19
20#ifndef _REGEX_H
21#define _REGEX_H 1
22
23#include <sys/types.h>
24
25/* Allow the use in C++ code. */
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30/* Define __USE_GNU to declare GNU extensions that violate the
31 POSIX name space rules. */
32#ifdef _GNU_SOURCE
33# define __USE_GNU 1
34#endif
35
36#ifdef _REGEX_LARGE_OFFSETS
37
38/* Use types and values that are wide enough to represent signed and
39 unsigned byte offsets in memory. This currently works only when
40 the regex code is used outside of the GNU C library; it is not yet
41 supported within glibc itself, and glibc users should not define
42 _REGEX_LARGE_OFFSETS. */
43
44/* The type of object sizes. */
45typedef size_t __re_size_t;
46
47/* The type of object sizes, in places where the traditional code
48 uses unsigned long int. */
49typedef size_t __re_long_size_t;
50
51#else
52
53/* The traditional GNU regex implementation mishandles strings longer
54 than INT_MAX. */
55typedef unsigned int __re_size_t;
56typedef unsigned long int __re_long_size_t;
57
58#endif
59
60/* The following two types have to be signed and unsigned integer type
61 wide enough to hold a value of a pointer. For most ANSI compilers
62 ptrdiff_t and size_t should be likely OK. Still size of these two
63 types is 2 for Microsoft C. Ugh... */
64typedef long int s_reg_t;
65typedef unsigned long int active_reg_t;
66
67/* The following bits are used to determine the regexp syntax we
68 recognize. The set/not-set meanings are chosen so that Emacs syntax
69 remains the value 0. The bits are given in alphabetical order, and
70 the definitions shifted by one from the previous bit; thus, when we
71 add or remove a bit, only one other definition need change. */
72typedef unsigned long int reg_syntax_t;
73
74#ifdef __USE_GNU
75/* If this bit is not set, then \ inside a bracket expression is literal.
76 If set, then such a \ quotes the following character. */
77# define RE_BACKSLASH_ESCAPE_IN_LISTS ((unsigned long int) 1)
78
79/* If this bit is not set, then + and ? are operators, and \+ and \? are
80 literals.
81 If set, then \+ and \? are operators and + and ? are literals. */
82# define RE_BK_PLUS_QM (RE_BACKSLASH_ESCAPE_IN_LISTS << 1)
83
84/* If this bit is set, then character classes are supported. They are:
85 [:alpha:], [:upper:], [:lower:], [:digit:], [:alnum:], [:xdigit:],
86 [:space:], [:print:], [:punct:], [:graph:], and [:cntrl:].
87 If not set, then character classes are not supported. */
88# define RE_CHAR_CLASSES (RE_BK_PLUS_QM << 1)
89
90/* If this bit is set, then ^ and $ are always anchors (outside bracket
91 expressions, of course).
92 If this bit is not set, then it depends:
93 ^ is an anchor if it is at the beginning of a regular
94 expression or after an open-group or an alternation operator;
95 $ is an anchor if it is at the end of a regular expression, or
96 before a close-group or an alternation operator.
97
98 This bit could be (re)combined with RE_CONTEXT_INDEP_OPS, because
99 POSIX draft 11.2 says that * etc. in leading positions is undefined.
100 We already implemented a previous draft which made those constructs
101 invalid, though, so we haven't changed the code back. */
102# define RE_CONTEXT_INDEP_ANCHORS (RE_CHAR_CLASSES << 1)
103
104/* If this bit is set, then special characters are always special
105 regardless of where they are in the pattern.
106 If this bit is not set, then special characters are special only in
107 some contexts; otherwise they are ordinary. Specifically,
108 * + ? and intervals are only special when not after the beginning,
109 open-group, or alternation operator. */
110# define RE_CONTEXT_INDEP_OPS (RE_CONTEXT_INDEP_ANCHORS << 1)
111
112/* If this bit is set, then *, +, ?, and { cannot be first in an re or
113 immediately after an alternation or begin-group operator. */
114# define RE_CONTEXT_INVALID_OPS (RE_CONTEXT_INDEP_OPS << 1)
115
116/* If this bit is set, then . matches newline.
117 If not set, then it doesn't. */
118# define RE_DOT_NEWLINE (RE_CONTEXT_INVALID_OPS << 1)
119
120/* If this bit is set, then . doesn't match NUL.
121 If not set, then it does. */
122# define RE_DOT_NOT_NULL (RE_DOT_NEWLINE << 1)
123
124/* If this bit is set, nonmatching lists [^...] do not match newline.
125 If not set, they do. */
126# define RE_HAT_LISTS_NOT_NEWLINE (RE_DOT_NOT_NULL << 1)
127
128/* If this bit is set, either \{...\} or {...} defines an
129 interval, depending on RE_NO_BK_BRACES.
130 If not set, \{, \}, {, and } are literals. */
131# define RE_INTERVALS (RE_HAT_LISTS_NOT_NEWLINE << 1)
132
133/* If this bit is set, +, ? and | aren't recognized as operators.
134 If not set, they are. */
135# define RE_LIMITED_OPS (RE_INTERVALS << 1)
136
137/* If this bit is set, newline is an alternation operator.
138 If not set, newline is literal. */
139# define RE_NEWLINE_ALT (RE_LIMITED_OPS << 1)
140
141/* If this bit is set, then '{...}' defines an interval, and \{ and \}
142 are literals.
143 If not set, then '\{...\}' defines an interval. */
144# define RE_NO_BK_BRACES (RE_NEWLINE_ALT << 1)
145
146/* If this bit is set, (...) defines a group, and \( and \) are literals.
147 If not set, \(...\) defines a group, and ( and ) are literals. */
148# define RE_NO_BK_PARENS (RE_NO_BK_BRACES << 1)
149
150/* If this bit is set, then \<digit> matches <digit>.
151 If not set, then \<digit> is a back-reference. */
152# define RE_NO_BK_REFS (RE_NO_BK_PARENS << 1)
153
154/* If this bit is set, then | is an alternation operator, and \| is literal.
155 If not set, then \| is an alternation operator, and | is literal. */
156# define RE_NO_BK_VBAR (RE_NO_BK_REFS << 1)
157
158/* If this bit is set, then an ending range point collating higher
159 than the starting range point, as in [z-a], is invalid.
160 If not set, then when ending range point collates higher than the
161 starting range point, the range is ignored. */
162# define RE_NO_EMPTY_RANGES (RE_NO_BK_VBAR << 1)
163
164/* If this bit is set, then an unmatched ) is ordinary.
165 If not set, then an unmatched ) is invalid. */
166# define RE_UNMATCHED_RIGHT_PAREN_ORD (RE_NO_EMPTY_RANGES << 1)
167
168/* If this bit is set, succeed as soon as we match the whole pattern,
169 without further backtracking. */
170# define RE_NO_POSIX_BACKTRACKING (RE_UNMATCHED_RIGHT_PAREN_ORD << 1)
171
172/* If this bit is set, do not process the GNU regex operators.
173 If not set, then the GNU regex operators are recognized. */
174# define RE_NO_GNU_OPS (RE_NO_POSIX_BACKTRACKING << 1)
175
176/* If this bit is set, turn on internal regex debugging.
177 If not set, and debugging was on, turn it off.
178 This only works if regex.c is compiled -DDEBUG.
179 We define this bit always, so that all that's needed to turn on
180 debugging is to recompile regex.c; the calling code can always have
181 this bit set, and it won't affect anything in the normal case. */
182# define RE_DEBUG (RE_NO_GNU_OPS << 1)
183
184/* If this bit is set, a syntactically invalid interval is treated as
185 a string of ordinary characters. For example, the ERE 'a{1' is
186 treated as 'a\{1'. */
187# define RE_INVALID_INTERVAL_ORD (RE_DEBUG << 1)
188
189/* If this bit is set, then ignore case when matching.
190 If not set, then case is significant. */
191# define RE_ICASE (RE_INVALID_INTERVAL_ORD << 1)
192
193/* This bit is used internally like RE_CONTEXT_INDEP_ANCHORS but only
194 for ^, because it is difficult to scan the regex backwards to find
195 whether ^ should be special. */
196# define RE_CARET_ANCHORS_HERE (RE_ICASE << 1)
197
198/* If this bit is set, then \{ cannot be first in a regex or
199 immediately after an alternation, open-group or \} operator. */
200# define RE_CONTEXT_INVALID_DUP (RE_CARET_ANCHORS_HERE << 1)
201
202/* If this bit is set, then no_sub will be set to 1 during
203 re_compile_pattern. */
204# define RE_NO_SUB (RE_CONTEXT_INVALID_DUP << 1)
205#endif
206
207/* This global variable defines the particular regexp syntax to use (for
208 some interfaces). When a regexp is compiled, the syntax used is
209 stored in the pattern buffer, so changing this does not affect
210 already-compiled regexps. */
211extern reg_syntax_t re_syntax_options;
212
213#ifdef __USE_GNU
214/* Define combinations of the above bits for the standard possibilities.
215 (The [[[ comments delimit what gets put into the Texinfo file, so
216 don't delete them!) */
217/* [[[begin syntaxes]]] */
218# define RE_SYNTAX_EMACS 0
219
220# define RE_SYNTAX_AWK \
221 (RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DOT_NOT_NULL \
222 | RE_NO_BK_PARENS | RE_NO_BK_REFS \
223 | RE_NO_BK_VBAR | RE_NO_EMPTY_RANGES \
224 | RE_DOT_NEWLINE | RE_CONTEXT_INDEP_ANCHORS \
225 | RE_CHAR_CLASSES \
226 | RE_UNMATCHED_RIGHT_PAREN_ORD | RE_NO_GNU_OPS)
227
228# define RE_SYNTAX_GNU_AWK \
229 ((RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS \
230 | RE_INVALID_INTERVAL_ORD) \
231 & ~(RE_DOT_NOT_NULL | RE_CONTEXT_INDEP_OPS \
232 | RE_CONTEXT_INVALID_OPS ))
233
234# define RE_SYNTAX_POSIX_AWK \
235 (RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS \
236 | RE_INTERVALS | RE_NO_GNU_OPS \
237 | RE_INVALID_INTERVAL_ORD)
238
239# define RE_SYNTAX_GREP \
240 ((RE_SYNTAX_POSIX_BASIC | RE_NEWLINE_ALT) \
241 & ~(RE_CONTEXT_INVALID_DUP | RE_DOT_NOT_NULL))
242
243# define RE_SYNTAX_EGREP \
244 ((RE_SYNTAX_POSIX_EXTENDED | RE_INVALID_INTERVAL_ORD | RE_NEWLINE_ALT) \
245 & ~(RE_CONTEXT_INVALID_OPS | RE_DOT_NOT_NULL))
246
247/* POSIX grep -E behavior is no longer incompatible with GNU. */
248# define RE_SYNTAX_POSIX_EGREP \
249 RE_SYNTAX_EGREP
250
251/* P1003.2/D11.2, section 4.20.7.1, lines 5078ff. */
252# define RE_SYNTAX_ED RE_SYNTAX_POSIX_BASIC
253
254# define RE_SYNTAX_SED RE_SYNTAX_POSIX_BASIC
255
256/* Syntax bits common to both basic and extended POSIX regex syntax. */
257# define _RE_SYNTAX_POSIX_COMMON \
258 (RE_CHAR_CLASSES | RE_DOT_NEWLINE | RE_DOT_NOT_NULL \
259 | RE_INTERVALS | RE_NO_EMPTY_RANGES)
260
261# define RE_SYNTAX_POSIX_BASIC \
262 (_RE_SYNTAX_POSIX_COMMON | RE_BK_PLUS_QM | RE_CONTEXT_INVALID_DUP)
263
264/* Differs from ..._POSIX_BASIC only in that RE_BK_PLUS_QM becomes
265 RE_LIMITED_OPS, i.e., \? \+ \| are not recognized. Actually, this
266 isn't minimal, since other operators, such as \`, aren't disabled. */
267# define RE_SYNTAX_POSIX_MINIMAL_BASIC \
268 (_RE_SYNTAX_POSIX_COMMON | RE_LIMITED_OPS)
269
270# define RE_SYNTAX_POSIX_EXTENDED \
271 (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \
272 | RE_CONTEXT_INDEP_OPS | RE_NO_BK_BRACES \
273 | RE_NO_BK_PARENS | RE_NO_BK_VBAR \
274 | RE_CONTEXT_INVALID_OPS | RE_UNMATCHED_RIGHT_PAREN_ORD)
275
276/* Differs from ..._POSIX_EXTENDED in that RE_CONTEXT_INDEP_OPS is
277 removed and RE_NO_BK_REFS is added. */
278# define RE_SYNTAX_POSIX_MINIMAL_EXTENDED \
279 (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \
280 | RE_CONTEXT_INVALID_OPS | RE_NO_BK_BRACES \
281 | RE_NO_BK_PARENS | RE_NO_BK_REFS \
282 | RE_NO_BK_VBAR | RE_UNMATCHED_RIGHT_PAREN_ORD)
283/* [[[end syntaxes]]] */
284
285/* Maximum number of duplicates an interval can allow. POSIX-conforming
286 systems might define this in <limits.h>, but we want our
287 value, so remove any previous define. */
288# ifdef _REGEX_INCLUDE_LIMITS_H
289# include <limits.h>
290# endif
291# ifdef RE_DUP_MAX
292# undef RE_DUP_MAX
293# endif
294
295/* RE_DUP_MAX is 2**15 - 1 because an earlier implementation stored
296 the counter as a 2-byte signed integer. This is no longer true, so
297 RE_DUP_MAX could be increased to (INT_MAX / 10 - 1), or to
298 ((SIZE_MAX - 9) / 10) if _REGEX_LARGE_OFFSETS is defined.
299 However, there would be a huge performance problem if someone
300 actually used a pattern like a\{214748363\}, so RE_DUP_MAX retains
301 its historical value. */
302# define RE_DUP_MAX (0x7fff)
303#endif
304
305
306/* POSIX 'cflags' bits (i.e., information for 'regcomp'). */
307
308/* If this bit is set, then use extended regular expression syntax.
309 If not set, then use basic regular expression syntax. */
310#define REG_EXTENDED 1
311
312/* If this bit is set, then ignore case when matching.
313 If not set, then case is significant. */
314#define REG_ICASE (1 << 1)
315
316/* If this bit is set, then anchors do not match at newline
317 characters in the string.
318 If not set, then anchors do match at newlines. */
319#define REG_NEWLINE (1 << 2)
320
321/* If this bit is set, then report only success or fail in regexec.
322 If not set, then returns differ between not matching and errors. */
323#define REG_NOSUB (1 << 3)
324
325
326/* POSIX 'eflags' bits (i.e., information for regexec). */
327
328/* If this bit is set, then the beginning-of-line operator doesn't match
329 the beginning of the string (presumably because it's not the
330 beginning of a line).
331 If not set, then the beginning-of-line operator does match the
332 beginning of the string. */
333#define REG_NOTBOL 1
334
335/* Like REG_NOTBOL, except for the end-of-line. */
336#define REG_NOTEOL (1 << 1)
337
338/* Use PMATCH[0] to delimit the start and end of the search in the
339 buffer. */
340#define REG_STARTEND (1 << 2)
341
342
343/* If any error codes are removed, changed, or added, update the
344 '__re_error_msgid' table in regcomp.c. */
345
346typedef enum
347{
348 _REG_ENOSYS = -1, /* This will never happen for this implementation. */
349 _REG_NOERROR = 0, /* Success. */
350 _REG_NOMATCH, /* Didn't find a match (for regexec). */
351
352 /* POSIX regcomp return error codes. (In the order listed in the
353 standard.) */
354 _REG_BADPAT, /* Invalid pattern. */
355 _REG_ECOLLATE, /* Invalid collating element. */
356 _REG_ECTYPE, /* Invalid character class name. */
357 _REG_EESCAPE, /* Trailing backslash. */
358 _REG_ESUBREG, /* Invalid back reference. */
359 _REG_EBRACK, /* Unmatched left bracket. */
360 _REG_EPAREN, /* Parenthesis imbalance. */
361 _REG_EBRACE, /* Unmatched \{. */
362 _REG_BADBR, /* Invalid contents of \{\}. */
363 _REG_ERANGE, /* Invalid range end. */
364 _REG_ESPACE, /* Ran out of memory. */
365 _REG_BADRPT, /* No preceding re for repetition op. */
366
367 /* Error codes we've added. */
368 _REG_EEND, /* Premature end. */
369 _REG_ESIZE, /* Too large (e.g., repeat count too large). */
370 _REG_ERPAREN /* Unmatched ) or \); not returned from regcomp. */
371} reg_errcode_t;
372
373#if defined _XOPEN_SOURCE || defined __USE_XOPEN2K
374# define REG_ENOSYS _REG_ENOSYS
375#endif
376#define REG_NOERROR _REG_NOERROR
377#define REG_NOMATCH _REG_NOMATCH
378#define REG_BADPAT _REG_BADPAT
379#define REG_ECOLLATE _REG_ECOLLATE
380#define REG_ECTYPE _REG_ECTYPE
381#define REG_EESCAPE _REG_EESCAPE
382#define REG_ESUBREG _REG_ESUBREG
383#define REG_EBRACK _REG_EBRACK
384#define REG_EPAREN _REG_EPAREN
385#define REG_EBRACE _REG_EBRACE
386#define REG_BADBR _REG_BADBR
387#define REG_ERANGE _REG_ERANGE
388#define REG_ESPACE _REG_ESPACE
389#define REG_BADRPT _REG_BADRPT
390#define REG_EEND _REG_EEND
391#define REG_ESIZE _REG_ESIZE
392#define REG_ERPAREN _REG_ERPAREN
393
394/* This data structure represents a compiled pattern. Before calling
395 the pattern compiler, the fields 'buffer', 'allocated', 'fastmap',
396 and 'translate' can be set. After the pattern has been compiled,
397 the fields 're_nsub', 'not_bol' and 'not_eol' are available. All
398 other fields are private to the regex routines. */
399
400#ifndef RE_TRANSLATE_TYPE
401# define __RE_TRANSLATE_TYPE unsigned char *
402# ifdef __USE_GNU
403# define RE_TRANSLATE_TYPE __RE_TRANSLATE_TYPE
404# endif
405#endif
406
407#ifdef __USE_GNU
408# define __REPB_PREFIX(name) name
409#else
410# define __REPB_PREFIX(name) __##name
411#endif
412
413struct re_pattern_buffer
414{
415 /* Space that holds the compiled pattern. The type
416 'struct re_dfa_t' is private and is not declared here. */
417 struct re_dfa_t *__REPB_PREFIX(buffer);
418
419 /* Number of bytes to which 'buffer' points. */
420 __re_long_size_t __REPB_PREFIX(allocated);
421
422 /* Number of bytes actually used in 'buffer'. */
423 __re_long_size_t __REPB_PREFIX(used);
424
425 /* Syntax setting with which the pattern was compiled. */
426 reg_syntax_t __REPB_PREFIX(syntax);
427
428 /* Pointer to a fastmap, if any, otherwise zero. re_search uses the
429 fastmap, if there is one, to skip over impossible starting points
430 for matches. */
431 char *__REPB_PREFIX(fastmap);
432
433 /* Either a translate table to apply to all characters before
434 comparing them, or zero for no translation. The translation is
435 applied to a pattern when it is compiled and to a string when it
436 is matched. */
437 __RE_TRANSLATE_TYPE __REPB_PREFIX(translate);
438
439 /* Number of subexpressions found by the compiler. */
440 size_t re_nsub;
441
442 /* Zero if this pattern cannot match the empty string, one else.
443 Well, in truth it's used only in 're_search_2', to see whether or
444 not we should use the fastmap, so we don't set this absolutely
445 perfectly; see 're_compile_fastmap' (the "duplicate" case). */
446 unsigned __REPB_PREFIX(can_be_null) : 1;
447
448 /* If REGS_UNALLOCATED, allocate space in the 'regs' structure
449 for 'max (RE_NREGS, re_nsub + 1)' groups.
450 If REGS_REALLOCATE, reallocate space if necessary.
451 If REGS_FIXED, use what's there. */
452#ifdef __USE_GNU
453# define REGS_UNALLOCATED 0
454# define REGS_REALLOCATE 1
455# define REGS_FIXED 2
456#endif
457 unsigned __REPB_PREFIX(regs_allocated) : 2;
458
459 /* Set to zero when 're_compile_pattern' compiles a pattern; set to
460 one by 're_compile_fastmap' if it updates the fastmap. */
461 unsigned __REPB_PREFIX(fastmap_accurate) : 1;
462
463 /* If set, 're_match_2' does not return information about
464 subexpressions. */
465 unsigned __REPB_PREFIX(no_sub) : 1;
466
467 /* If set, a beginning-of-line anchor doesn't match at the beginning
468 of the string. */
469 unsigned __REPB_PREFIX(not_bol) : 1;
470
471 /* Similarly for an end-of-line anchor. */
472 unsigned __REPB_PREFIX(not_eol) : 1;
473
474 /* If true, an anchor at a newline matches. */
475 unsigned __REPB_PREFIX(newline_anchor) : 1;
476};
477
478typedef struct re_pattern_buffer regex_t;
479
480/* Type for byte offsets within the string. POSIX mandates this. */
481#ifdef _REGEX_LARGE_OFFSETS
482/* POSIX 1003.1-2008 requires that regoff_t be at least as wide as
483 ptrdiff_t and ssize_t. We don't know of any hosts where ptrdiff_t
484 is wider than ssize_t, so ssize_t is safe. ptrdiff_t is not
485 visible here, so use ssize_t. */
486typedef ssize_t regoff_t;
487#else
488/* The traditional GNU regex implementation mishandles strings longer
489 than INT_MAX. */
490typedef int regoff_t;
491#endif
492
493
494#ifdef __USE_GNU
495/* This is the structure we store register match data in. See
496 regex.texinfo for a full description of what registers match. */
497struct re_registers
498{
499 __re_size_t num_regs;
500 regoff_t *start;
501 regoff_t *end;
502};
503
504
505/* If 'regs_allocated' is REGS_UNALLOCATED in the pattern buffer,
506 're_match_2' returns information about at least this many registers
507 the first time a 'regs' structure is passed. */
508# ifndef RE_NREGS
509# define RE_NREGS 30
510# endif
511#endif
512
513
514/* POSIX specification for registers. Aside from the different names than
515 're_registers', POSIX uses an array of structures, instead of a
516 structure of arrays. */
517typedef struct
518{
519 regoff_t rm_so; /* Byte offset from string's start to substring's start. */
520 regoff_t rm_eo; /* Byte offset from string's start to substring's end. */
521} regmatch_t;
522
523/* Declarations for routines. */
524
525#ifdef __USE_GNU
526/* Sets the current default syntax to SYNTAX, and return the old syntax.
527 You can also simply assign to the 're_syntax_options' variable. */
528extern reg_syntax_t re_set_syntax (reg_syntax_t __syntax);
529
530/* Compile the regular expression PATTERN, with length LENGTH
531 and syntax given by the global 're_syntax_options', into the buffer
532 BUFFER. Return NULL if successful, and an error string if not.
533
534 To free the allocated storage, you must call 'regfree' on BUFFER.
535 Note that the translate table must either have been initialized by
536 'regcomp', with a malloc'ed value, or set to NULL before calling
537 'regfree'. */
538extern const char *re_compile_pattern (const char *__pattern, size_t __length,
539 struct re_pattern_buffer *__buffer);
540
541
542/* Compile a fastmap for the compiled pattern in BUFFER; used to
543 accelerate searches. Return 0 if successful and -2 if was an
544 internal error. */
545extern int re_compile_fastmap (struct re_pattern_buffer *__buffer);
546
547
548/* Search in the string STRING (with length LENGTH) for the pattern
549 compiled into BUFFER. Start searching at position START, for RANGE
550 characters. Return the starting position of the match, -1 for no
551 match, or -2 for an internal error. Also return register
552 information in REGS (if REGS and BUFFER->no_sub are nonzero). */
553extern regoff_t re_search (struct re_pattern_buffer *__buffer,
554 const char *__String, regoff_t __length,
555 regoff_t __start, regoff_t __range,
556 struct re_registers *__regs);
557
558
559/* Like 're_search', but search in the concatenation of STRING1 and
560 STRING2. Also, stop searching at index START + STOP. */
561extern regoff_t re_search_2 (struct re_pattern_buffer *__buffer,
562 const char *__string1, regoff_t __length1,
563 const char *__string2, regoff_t __length2,
564 regoff_t __start, regoff_t __range,
565 struct re_registers *__regs,
566 regoff_t __stop);
567
568
569/* Like 're_search', but return how many characters in STRING the regexp
570 in BUFFER matched, starting at position START. */
571extern regoff_t re_match (struct re_pattern_buffer *__buffer,
572 const char *__String, regoff_t __length,
573 regoff_t __start, struct re_registers *__regs);
574
575
576/* Relates to 're_match' as 're_search_2' relates to 're_search'. */
577extern regoff_t re_match_2 (struct re_pattern_buffer *__buffer,
578 const char *__string1, regoff_t __length1,
579 const char *__string2, regoff_t __length2,
580 regoff_t __start, struct re_registers *__regs,
581 regoff_t __stop);
582
583
584/* Set REGS to hold NUM_REGS registers, storing them in STARTS and
585 ENDS. Subsequent matches using BUFFER and REGS will use this memory
586 for recording register information. STARTS and ENDS must be
587 allocated with malloc, and must each be at least 'NUM_REGS * sizeof
588 (regoff_t)' bytes long.
589
590 If NUM_REGS == 0, then subsequent matches should allocate their own
591 register data.
592
593 Unless this function is called, the first search or match using
594 BUFFER will allocate its own register data, without
595 freeing the old data. */
596extern void re_set_registers (struct re_pattern_buffer *__buffer,
597 struct re_registers *__regs,
598 __re_size_t __num_regs,
599 regoff_t *__starts, regoff_t *__ends);
600#endif /* Use GNU */
601
602#if defined _REGEX_RE_COMP || (defined _LIBC && defined __USE_MISC)
603# ifndef _CRAY
604/* 4.2 bsd compatibility. */
605extern char *re_comp (const char *);
606extern int re_exec (const char *);
607# endif
608#endif
609
610/* For plain 'restrict', use glibc's __restrict if defined.
611 Otherwise, GCC 2.95 and later have "__restrict"; C99 compilers have
612 "restrict", and "configure" may have defined "restrict".
613 Other compilers use __restrict, __restrict__, and _Restrict, and
614 'configure' might #define 'restrict' to those words, so pick a
615 different name. */
616#ifndef _Restrict_
617# if defined __restrict || 2 < __GNUC__ + (95 <= __GNUC_MINOR__)
618# define _Restrict_ __restrict
619# elif 199901L <= __STDC_VERSION__ || defined restrict
620# define _Restrict_ restrict
621# else
622# define _Restrict_
623# endif
624#endif
625/* For [restrict], use glibc's __restrict_arr if available.
626 Otherwise, GCC 3.1 (not in C++ mode) and C99 support [restrict]. */
627#ifndef _Restrict_arr_
628# ifdef __restrict_arr
629# define _Restrict_arr_ __restrict_arr
630# elif ((199901L <= __STDC_VERSION__ || 3 < __GNUC__ + (1 <= __GNUC_MINOR__)) \
631 && !defined __GNUG__)
632# define _Restrict_arr_ _Restrict_
633# else
634# define _Restrict_arr_
635# endif
636#endif
637
638/* POSIX compatibility. */
639extern int regcomp (regex_t *_Restrict_ __preg,
640 const char *_Restrict_ __pattern,
641 int __cflags);
642
643extern int regexec (const regex_t *_Restrict_ __preg,
644 const char *_Restrict_ __String, size_t __nmatch,
645 regmatch_t __pmatch[_Restrict_arr_],
646 int __eflags);
647
648extern size_t regerror (int __errcode, const regex_t *_Restrict_ __preg,
649 char *_Restrict_ __errbuf, size_t __errbuf_size);
650
651extern void regfree (regex_t *__preg);
652
653
654#ifdef __cplusplus
655}
656#endif /* C++ */
657
658#endif /* regex.h */
libc/glibc-include/regexp.h created+33
...@@ -0,0 +1,33 @@
1/* Copyright (C) 1996-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _REGEXP_H
20#define _REGEXP_H 1
21
22/* The contents of this header file were originally standardized in
23 the Single Unix Specification, Issue 3 (1992). In Issue 4 (1994)
24 the header was marked as TO BE WITHDRAWN, and new applications
25 were encouraged to use <regex.h> instead. It was officially
26 withdrawn from the standard in Issue 6 (aka POSIX.1-2001).
27
28 The GNU C Library provided this header through version 2.22. */
29
30#error "The GNU C Library no longer implements <regexp.h>."
31#error "Please update your code to use <regex.h> instead (no trailing 'p')."
32
33#endif /* regexp.h */
libc/glibc-include/resolv.h created+304
...@@ -0,0 +1,304 @@
1/*
2 * Copyright (c) 1983, 1987, 1989
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 4. Neither the name of the University nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30/*
31 * Portions Copyright (c) 1996-1999 by Internet Software Consortium.
32 *
33 * Permission to use, copy, modify, and distribute this software for any
34 * purpose with or without fee is hereby granted, provided that the above
35 * copyright notice and this permission notice appear in all copies.
36 *
37 * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
38 * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
39 * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
40 * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
41 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
42 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
43 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
44 * SOFTWARE.
45 */
46
47/*
48 * @(#)resolv.h 8.1 (Berkeley) 6/2/93
49 * $BINDId: resolv.h,v 8.31 2000/03/30 20:16:50 vixie Exp $
50 */
51
52#ifndef _RESOLV_H_
53#define _RESOLV_H_
54
55#include <sys/cdefs.h>
56#include <sys/param.h>
57#include <sys/types.h>
58#include <stdio.h>
59#include <netinet/in.h>
60#include <arpa/nameser.h>
61#include <bits/types/res_state.h>
62
63/*
64 * Global defines and variables for resolver stub.
65 */
66#define LOCALDOMAINPARTS 2 /* min levels in name that is "local" */
67
68#define RES_TIMEOUT 5 /* min. seconds between retries */
69#define RES_MAXNDOTS 15 /* should reflect bit field size */
70#define RES_MAXRETRANS 30 /* only for resolv.conf/RES_OPTIONS */
71#define RES_MAXRETRY 5 /* only for resolv.conf/RES_OPTIONS */
72#define RES_DFLRETRY 2 /* Default #/tries. */
73#define RES_MAXTIME 65535 /* Infinity, in milliseconds. */
74
75#define nsaddr nsaddr_list[0] /* for backward compatibility */
76
77/*
78 * Revision information. This is the release date in YYYYMMDD format.
79 * It can change every day so the right thing to do with it is use it
80 * in preprocessor commands such as "#if (__RES > 19931104)". Do not
81 * compare for equality; rather, use it to determine whether your resolver
82 * is new enough to contain a certain feature.
83 */
84
85#define __RES 19991006
86
87/*
88 * Resolver configuration file.
89 * Normally not present, but may contain the address of the
90 * inital name server(s) to query and the domain search list.
91 */
92
93#ifndef _PATH_RESCONF
94#define _PATH_RESCONF "/etc/resolv.conf"
95#endif
96
97struct res_sym {
98 int number; /* Identifying number, like T_MX */
99 char * name; /* Its symbolic name, like "MX" */
100 char * humanname; /* Its fun name, like "mail exchanger" */
101};
102
103/*
104 * Resolver options (keep these in synch with res_debug.c, please)
105 */
106#define RES_INIT 0x00000001 /* address initialized */
107#define RES_DEBUG 0x00000002 /* print debug messages */
108#define RES_AAONLY \
109 __glibc_macro_warning ("RES_AAONLY is deprecated") 0x00000004
110#define RES_USEVC 0x00000008 /* use virtual circuit */
111#define RES_PRIMARY \
112 __glibc_macro_warning ("RES_PRIMARY is deprecated") 0x00000010
113#define RES_IGNTC 0x00000020 /* ignore trucation errors */
114#define RES_RECURSE 0x00000040 /* recursion desired */
115#define RES_DEFNAMES 0x00000080 /* use default domain name */
116#define RES_STAYOPEN 0x00000100 /* Keep TCP socket open */
117#define RES_DNSRCH 0x00000200 /* search up local domain tree */
118#define RES_INSECURE1 0x00000400 /* type 1 security disabled */
119#define RES_INSECURE2 0x00000800 /* type 2 security disabled */
120#define RES_NOALIASES 0x00001000 /* shuts off HOSTALIASES feature */
121#define RES_USE_INET6 \
122 __glibc_macro_warning ("RES_USE_INET6 is deprecated") 0x00002000
123#define RES_ROTATE 0x00004000 /* rotate ns list after each query */
124#define RES_NOCHECKNAME \
125 __glibc_macro_warning ("RES_NOCHECKNAME is deprecated") 0x00008000
126#define RES_KEEPTSIG \
127 __glibc_macro_warning ("RES_KEEPTSIG is deprecated") 0x00010000
128#define RES_BLAST \
129 __glibc_macro_warning ("RES_BLAST is deprecated") 0x00020000
130#define RES_USE_EDNS0 0x00100000 /* Use EDNS0. */
131#define RES_SNGLKUP 0x00200000 /* one outstanding request at a time */
132#define RES_SNGLKUPREOP 0x00400000 /* -"-, but open new socket for each
133 request */
134#define RES_USE_DNSSEC 0x00800000 /* use DNSSEC using OK bit in OPT */
135#define RES_NOTLDQUERY 0x01000000 /* Do not look up unqualified name
136 as a TLD. */
137#define RES_NORELOAD 0x02000000 /* No automatic configuration reload. */
138
139#define RES_DEFAULT (RES_RECURSE|RES_DEFNAMES|RES_DNSRCH)
140
141/*
142 * Resolver "pfcode" values. Used by dig.
143 */
144#define RES_PRF_STATS 0x00000001
145#define RES_PRF_UPDATE 0x00000002
146#define RES_PRF_CLASS 0x00000004
147#define RES_PRF_CMD 0x00000008
148#define RES_PRF_QUES 0x00000010
149#define RES_PRF_ANS 0x00000020
150#define RES_PRF_AUTH 0x00000040
151#define RES_PRF_ADD 0x00000080
152#define RES_PRF_HEAD1 0x00000100
153#define RES_PRF_HEAD2 0x00000200
154#define RES_PRF_TTLID 0x00000400
155#define RES_PRF_HEADX 0x00000800
156#define RES_PRF_QUERY 0x00001000
157#define RES_PRF_REPLY 0x00002000
158#define RES_PRF_INIT 0x00004000
159/* 0x00008000 */
160
161/* Things involving an internal (static) resolver context. */
162__BEGIN_DECLS
163extern struct __res_state *__res_state(void) __attribute__ ((__const__));
164__END_DECLS
165#define _res (*__res_state())
166
167#define fp_nquery __fp_nquery
168#define fp_query __fp_query
169#define hostalias __hostalias
170#define p_query __p_query
171#define res_close __res_close
172#define res_init __res_init
173#define res_isourserver __res_isourserver
174#define res_mkquery __res_mkquery
175#define res_query __res_query
176#define res_querydomain __res_querydomain
177#define res_search __res_search
178#define res_send __res_send
179
180__BEGIN_DECLS
181void fp_nquery (const unsigned char *, int, FILE *) __THROW;
182void fp_query (const unsigned char *, FILE *) __THROW;
183const char * hostalias (const char *) __THROW;
184void p_query (const unsigned char *) __THROW;
185void res_close (void) __THROW;
186int res_init (void) __THROW;
187int res_isourserver (const struct sockaddr_in *) __THROW;
188int res_mkquery (int, const char *, int, int,
189 const unsigned char *, int, const unsigned char *,
190 unsigned char *, int) __THROW;
191int res_query (const char *, int, int, unsigned char *, int)
192 __THROW;
193int res_querydomain (const char *, const char *, int, int,
194 unsigned char *, int) __THROW;
195int res_search (const char *, int, int, unsigned char *, int)
196 __THROW;
197int res_send (const unsigned char *, int, unsigned char *, int)
198 __THROW;
199__END_DECLS
200
201#define b64_ntop __b64_ntop
202#define b64_pton __b64_pton
203#define dn_comp __dn_comp
204#define dn_count_labels __dn_count_labels
205#define dn_expand __dn_expand
206#define dn_skipname __dn_skipname
207#define fp_resstat __fp_resstat
208#define loc_aton __loc_aton
209#define loc_ntoa __loc_ntoa
210#define p_cdname __p_cdname
211#define p_cdnname __p_cdnname
212#define p_class __p_class
213#define p_fqname __p_fqname
214#define p_fqnname __p_fqnname
215#define p_option __p_option
216#define p_time __p_time
217#define p_type __p_type
218#define p_rcode __p_rcode
219#define putlong __putlong
220#define putshort __putshort
221#define res_dnok __res_dnok
222#define res_hnok __res_hnok
223#define res_hostalias __res_hostalias
224#define res_mailok __res_mailok
225#define res_nameinquery __res_nameinquery
226#define res_nclose __res_nclose
227#define res_ninit __res_ninit
228#define res_nmkquery __res_nmkquery
229#define res_nquery __res_nquery
230#define res_nquerydomain __res_nquerydomain
231#define res_nsearch __res_nsearch
232#define res_nsend __res_nsend
233#define res_ownok __res_ownok
234#define res_queriesmatch __res_queriesmatch
235#define res_randomid __res_randomid
236#define sym_ntop __sym_ntop
237#define sym_ntos __sym_ntos
238#define sym_ston __sym_ston
239__BEGIN_DECLS
240int res_hnok (const char *) __THROW;
241int res_ownok (const char *) __THROW;
242int res_mailok (const char *) __THROW;
243int res_dnok (const char *) __THROW;
244int sym_ston (const struct res_sym *, const char *, int *) __THROW;
245const char * sym_ntos (const struct res_sym *, int, int *) __THROW;
246const char * sym_ntop (const struct res_sym *, int, int *) __THROW;
247int b64_ntop (const unsigned char *, size_t, char *, size_t)
248 __THROW;
249int b64_pton (char const *, unsigned char *, size_t) __THROW;
250int loc_aton (const char *__ascii, unsigned char *__binary) __THROW;
251const char * loc_ntoa (const unsigned char *__binary, char *__ascii) __THROW;
252int dn_skipname (const unsigned char *, const unsigned char *)
253 __THROW;
254void putlong (uint32_t, unsigned char *) __THROW;
255void putshort (uint16_t, unsigned char *) __THROW;
256const char * p_class (int) __THROW;
257const char * p_time (uint32_t) __THROW;
258const char * p_type (int) __THROW;
259const char * p_rcode (int) __THROW;
260const unsigned char * p_cdnname (const unsigned char *,
261 const unsigned char *, int, FILE *) __THROW;
262const unsigned char * p_cdname (const unsigned char *, const unsigned char *,
263 FILE *) __THROW;
264const unsigned char * p_fqnname (const unsigned char *__cp,
265 const unsigned char *__msg,
266 int, char *, int) __THROW;
267const unsigned char * p_fqname (const unsigned char *,
268 const unsigned char *, FILE *) __THROW;
269const char * p_option (unsigned long __option) __THROW;
270int dn_count_labels (const char *) __THROW;
271int dn_comp (const char *, unsigned char *, int, unsigned char **,
272 unsigned char **) __THROW;
273int dn_expand (const unsigned char *, const unsigned char *,
274 const unsigned char *, char *, int) __THROW;
275unsigned int res_randomid (void) __THROW;
276int res_nameinquery (const char *, int, int,
277 const unsigned char *,
278 const unsigned char *) __THROW;
279int res_queriesmatch (const unsigned char *,
280 const unsigned char *,
281 const unsigned char *,
282 const unsigned char *) __THROW;
283/* Things involving a resolver context. */
284int res_ninit (res_state) __THROW;
285void fp_resstat (const res_state, FILE *) __THROW;
286const char * res_hostalias (const res_state, const char *, char *, size_t)
287 __THROW;
288int res_nquery (res_state, const char *, int, int,
289 unsigned char *, int) __THROW;
290int res_nsearch (res_state, const char *, int, int,
291 unsigned char *, int) __THROW;
292int res_nquerydomain (res_state, const char *, const char *, int,
293 int, unsigned char *, int) __THROW;
294int res_nmkquery (res_state, int, const char *, int, int,
295 const unsigned char *, int,
296 const unsigned char *, unsigned char *, int)
297 __THROW;
298int res_nsend (res_state, const unsigned char *, int,
299 unsigned char *, int) __THROW;
300void res_nclose (res_state) __THROW;
301
302__END_DECLS
303
304#endif /* !_RESOLV_H_ */
libc/glibc-include/rpc/netdb.h created+74
...@@ -0,0 +1,74 @@
1/* @(#)netdb.h 2.1 88/07/29 3.9 RPCSRC */
2/*
3 * Copyright (c) 2010, Oracle America, Inc.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following
12 * disclaimer in the documentation and/or other materials
13 * provided with the distribution.
14 * * Neither the name of the "Oracle America, Inc." nor the names of its
15 * contributors may be used to endorse or promote products derived
16 * from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
25 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32/* Cleaned up for GNU C library roland@gnu.ai.mit.edu:
33 added multiple inclusion protection and use of <sys/cdefs.h>.
34 In GNU this file is #include'd by <netdb.h>. */
35
36#ifndef _RPC_NETDB_H
37#define _RPC_NETDB_H 1
38
39#include <features.h>
40
41#define __need_size_t
42#include <stddef.h>
43
44__BEGIN_DECLS
45
46struct rpcent
47{
48 char *r_name; /* Name of server for this rpc program. */
49 char **r_aliases; /* Alias list. */
50 int r_number; /* RPC program number. */
51};
52
53extern void setrpcent (int __stayopen) __THROW;
54extern void endrpcent (void) __THROW;
55extern struct rpcent *getrpcbyname (const char *__name) __THROW;
56extern struct rpcent *getrpcbynumber (int __number) __THROW;
57extern struct rpcent *getrpcent (void) __THROW;
58
59#ifdef __USE_MISC
60extern int getrpcbyname_r (const char *__name, struct rpcent *__result_buf,
61 char *__buffer, size_t __buflen,
62 struct rpcent **__result) __THROW;
63
64extern int getrpcbynumber_r (int __number, struct rpcent *__result_buf,
65 char *__buffer, size_t __buflen,
66 struct rpcent **__result) __THROW;
67
68extern int getrpcent_r (struct rpcent *__result_buf, char *__buffer,
69 size_t __buflen, struct rpcent **__result) __THROW;
70#endif
71
72__END_DECLS
73
74#endif /* rpc/netdb.h */
libc/glibc-include/sched.h created+131
...@@ -0,0 +1,131 @@
1/* Definitions for POSIX 1003.1b-1993 (aka POSIX.4) scheduling interface.
2 Copyright (C) 1996-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SCHED_H
20#define _SCHED_H 1
21
22#include <features.h>
23
24/* Get type definitions. */
25#include <bits/types.h>
26
27#define __need_size_t
28#define __need_NULL
29#include <stddef.h>
30
31#include <bits/types/time_t.h>
32#include <bits/types/struct_timespec.h>
33#ifndef __USE_XOPEN2K
34# include <time.h>
35#endif
36
37#ifndef __pid_t_defined
38typedef __pid_t pid_t;
39# define __pid_t_defined
40#endif
41
42/* Get system specific constant and data structure definitions. */
43#include <bits/sched.h>
44#include <bits/cpu-set.h>
45
46/* Backward compatibility. */
47#define sched_priority sched_priority
48#define __sched_priority sched_priority
49
50
51__BEGIN_DECLS
52
53/* Set scheduling parameters for a process. */
54extern int sched_setparam (__pid_t __pid, const struct sched_param *__param)
55 __THROW;
56
57/* Retrieve scheduling parameters for a particular process. */
58extern int sched_getparam (__pid_t __pid, struct sched_param *__param) __THROW;
59
60/* Set scheduling algorithm and/or parameters for a process. */
61extern int sched_setscheduler (__pid_t __pid, int __policy,
62 const struct sched_param *__param) __THROW;
63
64/* Retrieve scheduling algorithm for a particular purpose. */
65extern int sched_getscheduler (__pid_t __pid) __THROW;
66
67/* Yield the processor. */
68extern int sched_yield (void) __THROW;
69
70/* Get maximum priority value for a scheduler. */
71extern int sched_get_priority_max (int __algorithm) __THROW;
72
73/* Get minimum priority value for a scheduler. */
74extern int sched_get_priority_min (int __algorithm) __THROW;
75
76/* Get the SCHED_RR interval for the named process. */
77extern int sched_rr_get_interval (__pid_t __pid, struct timespec *__t) __THROW;
78
79
80#ifdef __USE_GNU
81/* Access macros for `cpu_set'. */
82# define CPU_SETSIZE __CPU_SETSIZE
83# define CPU_SET(cpu, cpusetp) __CPU_SET_S (cpu, sizeof (cpu_set_t), cpusetp)
84# define CPU_CLR(cpu, cpusetp) __CPU_CLR_S (cpu, sizeof (cpu_set_t), cpusetp)
85# define CPU_ISSET(cpu, cpusetp) __CPU_ISSET_S (cpu, sizeof (cpu_set_t), \
86 cpusetp)
87# define CPU_ZERO(cpusetp) __CPU_ZERO_S (sizeof (cpu_set_t), cpusetp)
88# define CPU_COUNT(cpusetp) __CPU_COUNT_S (sizeof (cpu_set_t), cpusetp)
89
90# define CPU_SET_S(cpu, setsize, cpusetp) __CPU_SET_S (cpu, setsize, cpusetp)
91# define CPU_CLR_S(cpu, setsize, cpusetp) __CPU_CLR_S (cpu, setsize, cpusetp)
92# define CPU_ISSET_S(cpu, setsize, cpusetp) __CPU_ISSET_S (cpu, setsize, \
93 cpusetp)
94# define CPU_ZERO_S(setsize, cpusetp) __CPU_ZERO_S (setsize, cpusetp)
95# define CPU_COUNT_S(setsize, cpusetp) __CPU_COUNT_S (setsize, cpusetp)
96
97# define CPU_EQUAL(cpusetp1, cpusetp2) \
98 __CPU_EQUAL_S (sizeof (cpu_set_t), cpusetp1, cpusetp2)
99# define CPU_EQUAL_S(setsize, cpusetp1, cpusetp2) \
100 __CPU_EQUAL_S (setsize, cpusetp1, cpusetp2)
101
102# define CPU_AND(destset, srcset1, srcset2) \
103 __CPU_OP_S (sizeof (cpu_set_t), destset, srcset1, srcset2, &)
104# define CPU_OR(destset, srcset1, srcset2) \
105 __CPU_OP_S (sizeof (cpu_set_t), destset, srcset1, srcset2, |)
106# define CPU_XOR(destset, srcset1, srcset2) \
107 __CPU_OP_S (sizeof (cpu_set_t), destset, srcset1, srcset2, ^)
108# define CPU_AND_S(setsize, destset, srcset1, srcset2) \
109 __CPU_OP_S (setsize, destset, srcset1, srcset2, &)
110# define CPU_OR_S(setsize, destset, srcset1, srcset2) \
111 __CPU_OP_S (setsize, destset, srcset1, srcset2, |)
112# define CPU_XOR_S(setsize, destset, srcset1, srcset2) \
113 __CPU_OP_S (setsize, destset, srcset1, srcset2, ^)
114
115# define CPU_ALLOC_SIZE(count) __CPU_ALLOC_SIZE (count)
116# define CPU_ALLOC(count) __CPU_ALLOC (count)
117# define CPU_FREE(cpuset) __CPU_FREE (cpuset)
118
119
120/* Set the CPU affinity for a task */
121extern int sched_setaffinity (__pid_t __pid, size_t __cpusetsize,
122 const cpu_set_t *__cpuset) __THROW;
123
124/* Get the CPU affinity for a task */
125extern int sched_getaffinity (__pid_t __pid, size_t __cpusetsize,
126 cpu_set_t *__cpuset) __THROW;
127#endif
128
129__END_DECLS
130
131#endif /* sched.h */
libc/glibc-include/scsi/scsi.h created+225
...@@ -0,0 +1,225 @@
1/* Copyright (C) 1998-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/*
19 * This header file contains public constants and structures used by
20 * the scsi code for linux.
21 */
22
23#ifndef _SCSI_SCSI_H
24#define _SCSI_SCSI_H 1
25
26#include <features.h>
27
28/*
29 * SCSI opcodes
30 */
31
32#define TEST_UNIT_READY 0x00
33#define REZERO_UNIT 0x01
34#define REQUEST_SENSE 0x03
35#define FORMAT_UNIT 0x04
36#define READ_BLOCK_LIMITS 0x05
37#define REASSIGN_BLOCKS 0x07
38#define READ_6 0x08
39#define WRITE_6 0x0a
40#define SEEK_6 0x0b
41#define READ_REVERSE 0x0f
42#define WRITE_FILEMARKS 0x10
43#define SPACE 0x11
44#define INQUIRY 0x12
45#define RECOVER_BUFFERED_DATA 0x14
46#define MODE_SELECT 0x15
47#define RESERVE 0x16
48#define RELEASE 0x17
49#define COPY 0x18
50#define ERASE 0x19
51#define MODE_SENSE 0x1a
52#define START_STOP 0x1b
53#define RECEIVE_DIAGNOSTIC 0x1c
54#define SEND_DIAGNOSTIC 0x1d
55#define ALLOW_MEDIUM_REMOVAL 0x1e
56
57#define SET_WINDOW 0x24
58#define READ_CAPACITY 0x25
59#define READ_10 0x28
60#define WRITE_10 0x2a
61#define SEEK_10 0x2b
62#define WRITE_VERIFY 0x2e
63#define VERIFY 0x2f
64#define SEARCH_HIGH 0x30
65#define SEARCH_EQUAL 0x31
66#define SEARCH_LOW 0x32
67#define SET_LIMITS 0x33
68#define PRE_FETCH 0x34
69#define READ_POSITION 0x34
70#define SYNCHRONIZE_CACHE 0x35
71#define LOCK_UNLOCK_CACHE 0x36
72#define READ_DEFECT_DATA 0x37
73#define MEDIUM_SCAN 0x38
74#define COMPARE 0x39
75#define COPY_VERIFY 0x3a
76#define WRITE_BUFFER 0x3b
77#define READ_BUFFER 0x3c
78#define UPDATE_BLOCK 0x3d
79#define READ_LONG 0x3e
80#define WRITE_LONG 0x3f
81#define CHANGE_DEFINITION 0x40
82#define WRITE_SAME 0x41
83#define READ_TOC 0x43
84#define LOG_SELECT 0x4c
85#define LOG_SENSE 0x4d
86#define MODE_SELECT_10 0x55
87#define RESERVE_10 0x56
88#define RELEASE_10 0x57
89#define MODE_SENSE_10 0x5a
90#define PERSISTENT_RESERVE_IN 0x5e
91#define PERSISTENT_RESERVE_OUT 0x5f
92#define MOVE_MEDIUM 0xa5
93#define READ_12 0xa8
94#define WRITE_12 0xaa
95#define WRITE_VERIFY_12 0xae
96#define SEARCH_HIGH_12 0xb0
97#define SEARCH_EQUAL_12 0xb1
98#define SEARCH_LOW_12 0xb2
99#define READ_ELEMENT_STATUS 0xb8
100#define SEND_VOLUME_TAG 0xb6
101#define WRITE_LONG_2 0xea
102
103/*
104 * Status codes
105 */
106
107#define GOOD 0x00
108#define CHECK_CONDITION 0x01
109#define CONDITION_GOOD 0x02
110#define BUSY 0x04
111#define INTERMEDIATE_GOOD 0x08
112#define INTERMEDIATE_C_GOOD 0x0a
113#define RESERVATION_CONFLICT 0x0c
114#define COMMAND_TERMINATED 0x11
115#define QUEUE_FULL 0x14
116
117#define STATUS_MASK 0x3e
118
119/*
120 * SENSE KEYS
121 */
122
123#define NO_SENSE 0x00
124#define RECOVERED_ERROR 0x01
125#define NOT_READY 0x02
126#define MEDIUM_ERROR 0x03
127#define HARDWARE_ERROR 0x04
128#define ILLEGAL_REQUEST 0x05
129#define UNIT_ATTENTION 0x06
130#define DATA_PROTECT 0x07
131#define BLANK_CHECK 0x08
132#define COPY_ABORTED 0x0a
133#define ABORTED_COMMAND 0x0b
134#define VOLUME_OVERFLOW 0x0d
135#define MISCOMPARE 0x0e
136
137
138/*
139 * DEVICE TYPES
140 */
141
142#define TYPE_DISK 0x00
143#define TYPE_TAPE 0x01
144#define TYPE_PROCESSOR 0x03 /* HP scanners use this */
145#define TYPE_WORM 0x04 /* Treated as ROM by our system */
146#define TYPE_ROM 0x05
147#define TYPE_SCANNER 0x06
148#define TYPE_MOD 0x07 /* Magneto-optical disk -
149 * - treated as TYPE_DISK */
150#define TYPE_MEDIUM_CHANGER 0x08
151#define TYPE_ENCLOSURE 0x0d /* Enclosure Services Device */
152#define TYPE_NO_LUN 0x7f
153
154/*
155 * standard mode-select header prepended to all mode-select commands
156 *
157 * moved here from cdrom.h -- kraxel
158 */
159
160struct ccs_modesel_head
161 {
162 unsigned char _r1; /* reserved. */
163 unsigned char medium; /* device-specific medium type. */
164 unsigned char _r2; /* reserved. */
165 unsigned char block_desc_length; /* block descriptor length. */
166 unsigned char density; /* device-specific density code. */
167 unsigned char number_blocks_hi; /* number of blocks in this block
168 desc. */
169 unsigned char number_blocks_med;
170 unsigned char number_blocks_lo;
171 unsigned char _r3;
172 unsigned char block_length_hi; /* block length for blocks in this
173 desc. */
174 unsigned char block_length_med;
175 unsigned char block_length_lo;
176 };
177
178/*
179 * MESSAGE CODES
180 */
181
182#define COMMAND_COMPLETE 0x00
183#define EXTENDED_MESSAGE 0x01
184#define EXTENDED_MODIFY_DATA_POINTER 0x00
185#define EXTENDED_SDTR 0x01
186#define EXTENDED_EXTENDED_IDENTIFY 0x02 /* SCSI-I only */
187#define EXTENDED_WDTR 0x03
188#define SAVE_POINTERS 0x02
189#define RESTORE_POINTERS 0x03
190#define DISCONNECT 0x04
191#define INITIATOR_ERROR 0x05
192#define ABORT 0x06
193#define MESSAGE_REJECT 0x07
194#define NOP 0x08
195#define MSG_PARITY_ERROR 0x09
196#define LINKED_CMD_COMPLETE 0x0a
197#define LINKED_FLG_CMD_COMPLETE 0x0b
198#define BUS_DEVICE_RESET 0x0c
199
200#define INITIATE_RECOVERY 0x0f /* SCSI-II only */
201#define RELEASE_RECOVERY 0x10 /* SCSI-II only */
202
203#define SIMPLE_QUEUE_TAG 0x20
204#define HEAD_OF_QUEUE_TAG 0x21
205#define ORDERED_QUEUE_TAG 0x22
206
207/*
208 * Here are some scsi specific ioctl commands which are sometimes useful.
209 */
210/* These are a few other constants only used by scsi devices. */
211
212#define SCSI_IOCTL_GET_IDLUN 0x5382
213
214/* Used to turn on and off tagged queuing for scsi devices. */
215
216#define SCSI_IOCTL_TAGGED_ENABLE 0x5383
217#define SCSI_IOCTL_TAGGED_DISABLE 0x5384
218
219/* Used to obtain the host number of a device. */
220#define SCSI_IOCTL_PROBE_HOST 0x5385
221
222/* Used to get the bus number for a device. */
223#define SCSI_IOCTL_GET_BUS_NUMBER 0x5386
224
225#endif /* scsi/scsi.h */
libc/glibc-include/scsi/scsi_ioctl.h created+31
...@@ -0,0 +1,31 @@
1/* Copyright (C) 1999-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SCSI_IOCTL_H
19#define _SCSI_IOCTL_H
20
21/* IOCTLs for SCSI. */
22#define SCSI_IOCTL_SEND_COMMAND 1 /* Send a command to the SCSI host. */
23#define SCSI_IOCTL_TEST_UNIT_READY 2 /* Test if unit is ready. */
24#define SCSI_IOCTL_BENCHMARK_COMMAND 3
25#define SCSI_IOCTL_SYNC 4 /* Request synchronous parameters. */
26#define SCSI_IOCTL_START_UNIT 5
27#define SCSI_IOCTL_STOP_UNIT 6
28#define SCSI_IOCTL_DOORLOCK 0x5380 /* Lock the eject mechanism. */
29#define SCSI_IOCTL_DOORUNLOCK 0x5381 /* Unlock the mechanism. */
30
31#endif
libc/glibc-include/scsi/sg.h created+276
...@@ -0,0 +1,276 @@
1/* Copyright (C) 1997-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/*
19 History:
20 Started: Aug 9 by Lawrence Foard (entropy@world.std.com), to allow user
21 process control of SCSI devices.
22 Development Sponsored by Killy Corp. NY NY
23*/
24
25#ifndef _SCSI_SG_H
26#define _SCSI_SG_H 1
27
28#include <features.h>
29#define __need_size_t
30#include <stddef.h>
31
32
33/* New interface introduced in the 3.x SG drivers follows */
34
35/* Same structure as used by readv() Linux system call. It defines one
36 scatter-gather element. */
37typedef struct sg_iovec
38{
39 void * iov_base; /* Starting address */
40 size_t iov_len; /* Length in bytes */
41} sg_iovec_t;
42
43
44typedef struct sg_io_hdr
45{
46 int interface_id; /* [i] 'S' for SCSI generic (required) */
47 int dxfer_direction; /* [i] data transfer direction */
48 unsigned char cmd_len; /* [i] SCSI command length ( <= 16 bytes) */
49 unsigned char mx_sb_len; /* [i] max length to write to sbp */
50 unsigned short int iovec_count; /* [i] 0 implies no scatter gather */
51 unsigned int dxfer_len; /* [i] byte count of data transfer */
52 void * dxferp; /* [i], [*io] points to data transfer memory
53 or scatter gather list */
54 unsigned char * cmdp; /* [i], [*i] points to command to perform */
55 unsigned char * sbp; /* [i], [*o] points to sense_buffer memory */
56 unsigned int timeout; /* [i] MAX_UINT->no timeout (unit: millisec) */
57 unsigned int flags; /* [i] 0 -> default, see SG_FLAG... */
58 int pack_id; /* [i->o] unused internally (normally) */
59 void * usr_ptr; /* [i->o] unused internally */
60 unsigned char status; /* [o] scsi status */
61 unsigned char masked_status;/* [o] shifted, masked scsi status */
62 unsigned char msg_status; /* [o] messaging level data (optional) */
63 unsigned char sb_len_wr; /* [o] byte count actually written to sbp */
64 unsigned short int host_status; /* [o] errors from host adapter */
65 unsigned short int driver_status;/* [o] errors from software driver */
66 int resid; /* [o] dxfer_len - actual_transferred */
67 unsigned int duration; /* [o] time taken by cmd (unit: millisec) */
68 unsigned int info; /* [o] auxiliary information */
69} sg_io_hdr_t;
70
71
72/* Use negative values to flag difference from original sg_header structure. */
73#define SG_DXFER_NONE -1 /* e.g. a SCSI Test Unit Ready command */
74#define SG_DXFER_TO_DEV -2 /* e.g. a SCSI WRITE command */
75#define SG_DXFER_FROM_DEV -3 /* e.g. a SCSI READ command */
76#define SG_DXFER_TO_FROM_DEV -4 /* treated like SG_DXFER_FROM_DEV with the
77 additional property than during indirect
78 IO the user buffer is copied into the
79 kernel buffers before the transfer */
80
81
82/* following flag values can be "or"-ed together */
83#define SG_FLAG_DIRECT_IO 1 /* default is indirect IO */
84#define SG_FLAG_LUN_INHIBIT 2 /* default is to put device's lun into */
85 /* the 2nd byte of SCSI command */
86#define SG_FLAG_NO_DXFER 0x10000 /* no transfer of kernel buffers to/from */
87 /* user space (debug indirect IO) */
88
89/* The following 'info' values are "or"-ed together. */
90#define SG_INFO_OK_MASK 0x1
91#define SG_INFO_OK 0x0 /* no sense, host nor driver "noise" */
92#define SG_INFO_CHECK 0x1 /* something abnormal happened */
93
94#define SG_INFO_DIRECT_IO_MASK 0x6
95#define SG_INFO_INDIRECT_IO 0x0 /* data xfer via kernel buffers (or no xfer) */
96#define SG_INFO_DIRECT_IO 0x2 /* direct IO requested and performed */
97#define SG_INFO_MIXED_IO 0x4 /* part direct, part indirect IO */
98
99
100/* Request information about a specific SG device, used by
101 SG_GET_SCSI_ID ioctl (). */
102struct sg_scsi_id {
103 /* Host number as in "scsi<n>" where 'n' is one of 0, 1, 2 etc. */
104 int host_no;
105 int channel;
106 /* SCSI id of target device. */
107 int scsi_id;
108 int lun;
109 /* TYPE_... defined in <scsi/scsi.h>. */
110 int scsi_type;
111 /* Host (adapter) maximum commands per lun. */
112 short int h_cmd_per_lun;
113 /* Device (or adapter) maximum queue length. */
114 short int d_queue_depth;
115 /* Unused, set to 0 for now. */
116 int unused[2];
117};
118
119/* Used by SG_GET_REQUEST_TABLE ioctl(). */
120typedef struct sg_req_info {
121 char req_state; /* 0 -> not used, 1 -> written, 2 -> ready to read */
122 char orphan; /* 0 -> normal request, 1 -> from interruped SG_IO */
123 char sg_io_owned; /* 0 -> complete with read(), 1 -> owned by SG_IO */
124 char problem; /* 0 -> no problem detected, 1 -> error to report */
125 int pack_id; /* pack_id associated with request */
126 void * usr_ptr; /* user provided pointer (in new interface) */
127 unsigned int duration; /* millisecs elapsed since written (req_state==1)
128 or request duration (req_state==2) */
129 int unused;
130} sg_req_info_t;
131
132
133/* IOCTLs: Those ioctls that are relevant to the SG 3.x drivers follow.
134 [Those that only apply to the SG 2.x drivers are at the end of the file.]
135 (_GET_s yield result via 'int *' 3rd argument unless otherwise indicated) */
136
137#define SG_EMULATED_HOST 0x2203 /* true for emulated host adapter (ATAPI) */
138
139/* Used to configure SCSI command transformation layer for ATAPI devices */
140/* Only supported by the ide-scsi driver */
141#define SG_SET_TRANSFORM 0x2204 /* N.B. 3rd arg is not pointer but value: */
142 /* 3rd arg = 0 to disable transform, 1 to enable it */
143#define SG_GET_TRANSFORM 0x2205
144
145#define SG_SET_RESERVED_SIZE 0x2275 /* request a new reserved buffer size */
146#define SG_GET_RESERVED_SIZE 0x2272 /* actual size of reserved buffer */
147
148/* The following ioctl has a 'sg_scsi_id_t *' object as its 3rd argument. */
149#define SG_GET_SCSI_ID 0x2276 /* Yields fd's bus, chan, dev, lun + type */
150/* SCSI id information can also be obtained from SCSI_IOCTL_GET_IDLUN */
151
152/* Override host setting and always DMA using low memory ( <16MB on i386) */
153#define SG_SET_FORCE_LOW_DMA 0x2279 /* 0-> use adapter setting, 1-> force */
154#define SG_GET_LOW_DMA 0x227a /* 0-> use all ram for dma; 1-> low dma ram */
155
156/* When SG_SET_FORCE_PACK_ID set to 1, pack_id is input to read() which
157 tries to fetch a packet with a matching pack_id, waits, or returns EAGAIN.
158 If pack_id is -1 then read oldest waiting. When ...FORCE_PACK_ID set to 0
159 then pack_id ignored by read() and oldest readable fetched. */
160#define SG_SET_FORCE_PACK_ID 0x227b
161#define SG_GET_PACK_ID 0x227c /* Yields oldest readable pack_id (or -1) */
162
163#define SG_GET_NUM_WAITING 0x227d /* Number of commands awaiting read() */
164
165/* Yields max scatter gather tablesize allowed by current host adapter */
166#define SG_GET_SG_TABLESIZE 0x227F /* 0 implies can't do scatter gather */
167
168#define SG_GET_VERSION_NUM 0x2282 /* Example: version 2.1.34 yields 20134 */
169
170/* Returns -EBUSY if occupied. 3rd argument pointer to int (see next) */
171#define SG_SCSI_RESET 0x2284
172/* Associated values that can be given to SG_SCSI_RESET follow */
173#define SG_SCSI_RESET_NOTHING 0
174#define SG_SCSI_RESET_DEVICE 1
175#define SG_SCSI_RESET_BUS 2
176#define SG_SCSI_RESET_HOST 3
177
178/* synchronous SCSI command ioctl, (only in version 3 interface) */
179#define SG_IO 0x2285 /* similar effect as write() followed by read() */
180
181#define SG_GET_REQUEST_TABLE 0x2286 /* yields table of active requests */
182
183/* How to treat EINTR during SG_IO ioctl(), only in SG 3.x series */
184#define SG_SET_KEEP_ORPHAN 0x2287 /* 1 -> hold for read(), 0 -> drop (def) */
185#define SG_GET_KEEP_ORPHAN 0x2288
186
187
188#define SG_SCATTER_SZ (8 * 4096) /* PAGE_SIZE not available to user */
189/* Largest size (in bytes) a single scatter-gather list element can have.
190 The value must be a power of 2 and <= (PAGE_SIZE * 32) [131072 bytes on
191 i386]. The minimum value is PAGE_SIZE. If scatter-gather not supported
192 by adapter then this value is the largest data block that can be
193 read/written by a single scsi command. The user can find the value of
194 PAGE_SIZE by calling getpagesize() defined in unistd.h . */
195
196#define SG_DEFAULT_RETRIES 1
197
198/* Defaults, commented if they differ from original sg driver */
199#define SG_DEF_FORCE_LOW_DMA 0 /* was 1 -> memory below 16MB on i386 */
200#define SG_DEF_FORCE_PACK_ID 0
201#define SG_DEF_KEEP_ORPHAN 0
202#define SG_DEF_RESERVED_SIZE SG_SCATTER_SZ /* load time option */
203
204/* maximum outstanding requests, write() yields EDOM if exceeded */
205#define SG_MAX_QUEUE 16
206
207#define SG_BIG_BUFF SG_DEF_RESERVED_SIZE /* for backward compatibility */
208
209/* Alternate style type names, "..._t" variants preferred */
210typedef struct sg_io_hdr Sg_io_hdr;
211typedef struct sg_io_vec Sg_io_vec;
212typedef struct sg_scsi_id Sg_scsi_id;
213typedef struct sg_req_info Sg_req_info;
214
215
216/* vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv */
217/* The older SG interface based on the 'sg_header' structure follows. */
218/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ */
219
220#define SG_MAX_SENSE 16 /* this only applies to the sg_header interface */
221
222struct sg_header
223 {
224 /* Length of incoming packet (including header). */
225 int pack_len;
226 /* Maximal length of expected reply. */
227 int reply_len;
228 /* Id number of packet. */
229 int pack_id;
230 /* 0==ok, otherwise error number. */
231 int result;
232 /* Force 12 byte command length for group 6 & 7 commands. */
233 unsigned int twelve_byte:1;
234 /* SCSI status from target. */
235 unsigned int target_status:5;
236 /* Host status (see "DID" codes). */
237 unsigned int host_status:8;
238 /* Driver status+suggestion. */
239 unsigned int driver_status:8;
240 /* Unused. */
241 unsigned int other_flags:10;
242 /* Output in 3 cases:
243 when target_status is CHECK_CONDITION or
244 when target_status is COMMAND_TERMINATED or
245 when (driver_status & DRIVER_SENSE) is true. */
246 unsigned char sense_buffer[SG_MAX_SENSE];
247 };
248
249
250/* IOCTLs: The following are not required (or ignored) when the sg_io_hdr_t
251 interface is used. They are kept for backward compatibility with
252 the original and version 2 drivers. */
253
254#define SG_SET_TIMEOUT 0x2201 /* Set timeout; *(int *)arg==timeout. */
255#define SG_GET_TIMEOUT 0x2202 /* Get timeout; return timeout. */
256
257/* Get/set command queuing state per fd (default is SG_DEF_COMMAND_Q). */
258#define SG_GET_COMMAND_Q 0x2270 /* Yields 0 (queuing off) or 1 (on). */
259#define SG_SET_COMMAND_Q 0x2271 /* Change queuing state with 0 or 1. */
260
261/* Turn on error sense trace (1..8), dump this device to log/console (9)
262 or dump all sg device states ( >9 ) to log/console. */
263#define SG_SET_DEBUG 0x227e /* 0 -> turn off debug */
264
265#define SG_NEXT_CMD_LEN 0x2283 /* Override SCSI command length with given
266 number on the next write() on this file
267 descriptor. */
268
269/* Defaults, commented if they differ from original sg driver */
270#define SG_DEFAULT_TIMEOUT (60*HZ) /* HZ == 'jiffies in 1 second' */
271#define SG_DEF_COMMAND_Q 0 /* command queuing is always on when
272 the new interface is used */
273#define SG_DEF_UNDERRUN_FLAG 0
274
275
276#endif /* scsi/sg.h */
libc/glibc-include/search.h created+174
...@@ -0,0 +1,174 @@
1/* Declarations for System V style searching functions.
2 Copyright (C) 1995-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SEARCH_H
20#define _SEARCH_H 1
21
22#include <features.h>
23
24#define __need_size_t
25#include <stddef.h>
26
27__BEGIN_DECLS
28
29#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
30/* Prototype structure for a linked-list data structure.
31 This is the type used by the `insque' and `remque' functions. */
32
33# ifdef __USE_GNU
34struct qelem
35 {
36 struct qelem *q_forw;
37 struct qelem *q_back;
38 char q_data[1];
39 };
40# endif
41
42
43/* Insert ELEM into a doubly-linked list, after PREV. */
44extern void insque (void *__elem, void *__prev) __THROW;
45
46/* Unlink ELEM from the doubly-linked list that it is in. */
47extern void remque (void *__elem) __THROW;
48#endif
49
50
51/* For use with hsearch(3). */
52#ifndef __COMPAR_FN_T
53# define __COMPAR_FN_T
54typedef int (*__compar_fn_t) (const void *, const void *);
55
56# ifdef __USE_GNU
57typedef __compar_fn_t comparison_fn_t;
58# endif
59#endif
60
61/* Action which shall be performed in the call the hsearch. */
62typedef enum
63 {
64 FIND,
65 ENTER
66 }
67ACTION;
68
69typedef struct entry
70 {
71 char *key;
72 void *data;
73 }
74ENTRY;
75
76/* Opaque type for internal use. */
77struct _ENTRY;
78
79/* Family of hash table handling functions. The functions also
80 have reentrant counterparts ending with _r. The non-reentrant
81 functions all work on a signle internal hashing table. */
82
83/* Search for entry matching ITEM.key in internal hash table. If
84 ACTION is `FIND' return found entry or signal error by returning
85 NULL. If ACTION is `ENTER' replace existing data (if any) with
86 ITEM.data. */
87extern ENTRY *hsearch (ENTRY __item, ACTION __action) __THROW;
88
89/* Create a new hashing table which will at most contain NEL elements. */
90extern int hcreate (size_t __nel) __THROW;
91
92/* Destroy current internal hashing table. */
93extern void hdestroy (void) __THROW;
94
95#ifdef __USE_GNU
96/* Data type for reentrant functions. */
97struct hsearch_data
98 {
99 struct _ENTRY *table;
100 unsigned int size;
101 unsigned int filled;
102 };
103
104/* Reentrant versions which can handle multiple hashing tables at the
105 same time. */
106extern int hsearch_r (ENTRY __item, ACTION __action, ENTRY **__retval,
107 struct hsearch_data *__htab) __THROW;
108extern int hcreate_r (size_t __nel, struct hsearch_data *__htab) __THROW;
109extern void hdestroy_r (struct hsearch_data *__htab) __THROW;
110#endif
111
112
113/* The tsearch routines are very interesting. They make many
114 assumptions about the compiler. It assumes that the first field
115 in node must be the "key" field, which points to the datum.
116 Everything depends on that. */
117/* For tsearch */
118typedef enum
119{
120 preorder,
121 postorder,
122 endorder,
123 leaf
124}
125VISIT;
126
127/* Search for an entry matching the given KEY in the tree pointed to
128 by *ROOTP and insert a new element if not found. */
129extern void *tsearch (const void *__key, void **__rootp,
130 __compar_fn_t __compar);
131
132/* Search for an entry matching the given KEY in the tree pointed to
133 by *ROOTP. If no matching entry is available return NULL. */
134extern void *tfind (const void *__key, void *const *__rootp,
135 __compar_fn_t __compar);
136
137/* Remove the element matching KEY from the tree pointed to by *ROOTP. */
138extern void *tdelete (const void *__restrict __key,
139 void **__restrict __rootp,
140 __compar_fn_t __compar);
141
142#ifndef __ACTION_FN_T
143# define __ACTION_FN_T
144typedef void (*__action_fn_t) (const void *__nodep, VISIT __value,
145 int __level);
146#endif
147
148/* Walk through the whole tree and call the ACTION callback for every node
149 or leaf. */
150extern void twalk (const void *__root, __action_fn_t __action);
151
152#ifdef __USE_GNU
153/* Callback type for function to free a tree node. If the keys are atomic
154 data this function should do nothing. */
155typedef void (*__free_fn_t) (void *__nodep);
156
157/* Destroy the whole tree, call FREEFCT for each node or leaf. */
158extern void tdestroy (void *__root, __free_fn_t __freefct);
159#endif
160
161
162/* Perform linear search for KEY by comparing by COMPAR in an array
163 [BASE,BASE+NMEMB*SIZE). */
164extern void *lfind (const void *__key, const void *__base,
165 size_t *__nmemb, size_t __size, __compar_fn_t __compar);
166
167/* Perform linear search for KEY by comparing by COMPAR function in
168 array [BASE,BASE+NMEMB*SIZE) and insert entry if not found. */
169extern void *lsearch (const void *__key, void *__base,
170 size_t *__nmemb, size_t __size, __compar_fn_t __compar);
171
172__END_DECLS
173
174#endif /* search.h */
libc/glibc-include/semaphore.h created+77
...@@ -0,0 +1,77 @@
1/* Copyright (C) 2002-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SEMAPHORE_H
19#define _SEMAPHORE_H 1
20
21#include <features.h>
22#include <sys/types.h>
23#ifdef __USE_XOPEN2K
24# include <bits/types/struct_timespec.h>
25#endif
26
27/* Get the definition for sem_t. */
28#include <bits/semaphore.h>
29
30
31__BEGIN_DECLS
32
33/* Initialize semaphore object SEM to VALUE. If PSHARED then share it
34 with other processes. */
35extern int sem_init (sem_t *__sem, int __pshared, unsigned int __value)
36 __THROW;
37/* Free resources associated with semaphore object SEM. */
38extern int sem_destroy (sem_t *__sem) __THROW;
39
40/* Open a named semaphore NAME with open flags OFLAG. */
41extern sem_t *sem_open (const char *__name, int __oflag, ...) __THROW;
42
43/* Close descriptor for named semaphore SEM. */
44extern int sem_close (sem_t *__sem) __THROW;
45
46/* Remove named semaphore NAME. */
47extern int sem_unlink (const char *__name) __THROW;
48
49/* Wait for SEM being posted.
50
51 This function is a cancellation point and therefore not marked with
52 __THROW. */
53extern int sem_wait (sem_t *__sem);
54
55#ifdef __USE_XOPEN2K
56/* Similar to `sem_wait' but wait only until ABSTIME.
57
58 This function is a cancellation point and therefore not marked with
59 __THROW. */
60extern int sem_timedwait (sem_t *__restrict __sem,
61 const struct timespec *__restrict __abstime);
62#endif
63
64/* Test whether SEM is posted. */
65extern int sem_trywait (sem_t *__sem) __THROWNL;
66
67/* Post SEM. */
68extern int sem_post (sem_t *__sem) __THROWNL;
69
70/* Get current value of SEM and store it in *SVAL. */
71extern int sem_getvalue (sem_t *__restrict __sem, int *__restrict __sval)
72 __THROW;
73
74
75__END_DECLS
76
77#endif /* semaphore.h */
libc/glibc-include/setjmp.h created+105
...@@ -0,0 +1,105 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/*
19 * ISO C99 Standard: 7.13 Nonlocal jumps <setjmp.h>
20 */
21
22#ifndef _SETJMP_H
23#define _SETJMP_H 1
24
25#include <features.h>
26
27__BEGIN_DECLS
28
29#include <bits/setjmp.h> /* Get `__jmp_buf'. */
30#include <bits/types/__sigset_t.h>
31
32/* Calling environment, plus possibly a saved signal mask. */
33struct __jmp_buf_tag
34 {
35 /* NOTE: The machine-dependent definitions of `__sigsetjmp'
36 assume that a `jmp_buf' begins with a `__jmp_buf' and that
37 `__mask_was_saved' follows it. Do not move these members
38 or add others before it. */
39 __jmp_buf __jmpbuf; /* Calling environment. */
40 int __mask_was_saved; /* Saved the signal mask? */
41 __sigset_t __saved_mask; /* Saved signal mask. */
42 };
43
44
45typedef struct __jmp_buf_tag jmp_buf[1];
46
47/* Store the calling environment in ENV, also saving the signal mask.
48 Return 0. */
49extern int setjmp (jmp_buf __env) __THROWNL;
50
51/* Store the calling environment in ENV, also saving the
52 signal mask if SAVEMASK is nonzero. Return 0.
53 This is the internal name for `sigsetjmp'. */
54extern int __sigsetjmp (struct __jmp_buf_tag __env[1], int __savemask) __THROWNL;
55
56/* Store the calling environment in ENV, not saving the signal mask.
57 Return 0. */
58extern int _setjmp (struct __jmp_buf_tag __env[1]) __THROWNL;
59
60/* Do not save the signal mask. This is equivalent to the `_setjmp'
61 BSD function. */
62#define setjmp(env) _setjmp (env)
63
64
65/* Jump to the environment saved in ENV, making the
66 `setjmp' call there return VAL, or 1 if VAL is 0. */
67extern void longjmp (struct __jmp_buf_tag __env[1], int __val)
68 __THROWNL __attribute__ ((__noreturn__));
69
70#if defined __USE_MISC || defined __USE_XOPEN
71/* Same. Usually `_longjmp' is used with `_setjmp', which does not save
72 the signal mask. But it is how ENV was saved that determines whether
73 `longjmp' restores the mask; `_longjmp' is just an alias. */
74extern void _longjmp (struct __jmp_buf_tag __env[1], int __val)
75 __THROWNL __attribute__ ((__noreturn__));
76#endif
77
78
79#ifdef __USE_POSIX
80/* Use the same type for `jmp_buf' and `sigjmp_buf'.
81 The `__mask_was_saved' flag determines whether
82 or not `longjmp' will restore the signal mask. */
83typedef struct __jmp_buf_tag sigjmp_buf[1];
84
85/* Store the calling environment in ENV, also saving the
86 signal mask if SAVEMASK is nonzero. Return 0. */
87# define sigsetjmp(env, savemask) __sigsetjmp (env, savemask)
88
89/* Jump to the environment saved in ENV, making the
90 sigsetjmp call there return VAL, or 1 if VAL is 0.
91 Restore the signal mask if that sigsetjmp call saved it.
92 This is just an alias `longjmp'. */
93extern void siglongjmp (sigjmp_buf __env, int __val)
94 __THROWNL __attribute__ ((__noreturn__));
95#endif /* Use POSIX. */
96
97
98/* Define helper functions to catch unsafe code. */
99#if __USE_FORTIFY_LEVEL > 0
100# include <bits/setjmp2.h>
101#endif
102
103__END_DECLS
104
105#endif /* setjmp.h */
libc/glibc-include/sgtty.h created+40
...@@ -0,0 +1,40 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SGTTY_H
19#define _SGTTY_H 1
20
21#include <features.h>
22
23#include <sys/ioctl.h>
24
25/* On some systems this type is not defined by <bits/ioctl-types.h>;
26 in that case, the functions are just stubs that return ENOSYS. */
27struct sgttyb;
28
29__BEGIN_DECLS
30
31/* Fill in *PARAMS with terminal parameters associated with FD. */
32extern int gtty (int __fd, struct sgttyb *__params) __THROW;
33
34/* Set the terminal parameters associated with FD to *PARAMS. */
35extern int stty (int __fd, const struct sgttyb *__params) __THROW;
36
37
38__END_DECLS
39
40#endif /* sgtty.h */
libc/glibc-include/shadow.h created+152
...@@ -0,0 +1,152 @@
1/* Copyright (C) 1996-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/* Declaration of types and functions for "shadow" storage of hashed
19 passphrases. The shadow database is like the user database, but is
20 only accessible with special privileges, so that malicious users
21 cannot retrieve everyone else's hashed passphrase to brute-force at
22 their convenience. */
23
24#ifndef _SHADOW_H
25#define _SHADOW_H 1
26
27#include <features.h>
28
29#include <paths.h>
30
31#define __need_size_t
32#include <stddef.h>
33
34#include <bits/types/FILE.h>
35
36/* Paths to the user database files. */
37#define SHADOW _PATH_SHADOW
38
39
40__BEGIN_DECLS
41
42/* A record in the shadow database. */
43struct spwd
44 {
45 char *sp_namp; /* Login name. */
46 char *sp_pwdp; /* Hashed passphrase. */
47 long int sp_lstchg; /* Date of last change. */
48 long int sp_min; /* Minimum number of days between changes. */
49 long int sp_max; /* Maximum number of days between changes. */
50 long int sp_warn; /* Number of days to warn user to change
51 the password. */
52 long int sp_inact; /* Number of days the account may be
53 inactive. */
54 long int sp_expire; /* Number of days since 1970-01-01 until
55 account expires. */
56 unsigned long int sp_flag; /* Reserved. */
57 };
58
59
60/* Open database for reading.
61
62 This function is not part of POSIX and therefore no official
63 cancellation point. But due to similarity with an POSIX interface
64 or due to the implementation it is a cancellation point and
65 therefore not marked with __THROW. */
66extern void setspent (void);
67
68/* Close database.
69
70 This function is not part of POSIX and therefore no official
71 cancellation point. But due to similarity with an POSIX interface
72 or due to the implementation it is a cancellation point and
73 therefore not marked with __THROW. */
74extern void endspent (void);
75
76/* Get next entry from database, perhaps after opening the file.
77
78 This function is not part of POSIX and therefore no official
79 cancellation point. But due to similarity with an POSIX interface
80 or due to the implementation it is a cancellation point and
81 therefore not marked with __THROW. */
82extern struct spwd *getspent (void);
83
84/* Get shadow entry matching NAME.
85
86 This function is not part of POSIX and therefore no official
87 cancellation point. But due to similarity with an POSIX interface
88 or due to the implementation it is a cancellation point and
89 therefore not marked with __THROW. */
90extern struct spwd *getspnam (const char *__name);
91
92/* Read shadow entry from STRING.
93
94 This function is not part of POSIX and therefore no official
95 cancellation point. But due to similarity with an POSIX interface
96 or due to the implementation it is a cancellation point and
97 therefore not marked with __THROW. */
98extern struct spwd *sgetspent (const char *__string);
99
100/* Read next shadow entry from STREAM.
101
102 This function is not part of POSIX and therefore no official
103 cancellation point. But due to similarity with an POSIX interface
104 or due to the implementation it is a cancellation point and
105 therefore not marked with __THROW. */
106extern struct spwd *fgetspent (FILE *__stream);
107
108/* Write line containing shadow entry to stream.
109
110 This function is not part of POSIX and therefore no official
111 cancellation point. But due to similarity with an POSIX interface
112 or due to the implementation it is a cancellation point and
113 therefore not marked with __THROW. */
114extern int putspent (const struct spwd *__p, FILE *__stream);
115
116
117#ifdef __USE_MISC
118/* Reentrant versions of some of the functions above.
119
120 These functions are not part of POSIX and therefore no official
121 cancellation point. But due to similarity with an POSIX interface
122 or due to the implementation they are cancellation points and
123 therefore not marked with __THROW. */
124extern int getspent_r (struct spwd *__result_buf, char *__buffer,
125 size_t __buflen, struct spwd **__result);
126
127extern int getspnam_r (const char *__name, struct spwd *__result_buf,
128 char *__buffer, size_t __buflen,
129 struct spwd **__result);
130
131extern int sgetspent_r (const char *__string, struct spwd *__result_buf,
132 char *__buffer, size_t __buflen,
133 struct spwd **__result);
134
135extern int fgetspent_r (FILE *__stream, struct spwd *__result_buf,
136 char *__buffer, size_t __buflen,
137 struct spwd **__result);
138#endif /* misc */
139
140
141/* The simple locking functionality provided here is not suitable for
142 multi-threaded applications. */
143
144/* Request exclusive access to /etc/passwd and /etc/shadow. */
145extern int lckpwdf (void) __THROW;
146
147/* Release exclusive access to /etc/passwd and /etc/shadow. */
148extern int ulckpwdf (void) __THROW;
149
150__END_DECLS
151
152#endif /* shadow.h */
libc/glibc-include/signal.h created+375
...@@ -0,0 +1,375 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/*
19 * ISO C99 Standard: 7.14 Signal handling <signal.h>
20 */
21
22#ifndef _SIGNAL_H
23#define _SIGNAL_H
24
25#include <features.h>
26
27__BEGIN_DECLS
28
29#include <bits/types.h>
30#include <bits/signum.h>
31
32#include <bits/types/sig_atomic_t.h>
33
34#if defined __USE_POSIX
35#include <bits/types/sigset_t.h>
36#endif
37
38#if defined __USE_XOPEN || defined __USE_XOPEN2K
39# ifndef __pid_t_defined
40typedef __pid_t pid_t;
41# define __pid_t_defined
42#endif
43#ifdef __USE_XOPEN
44# endif
45# ifndef __uid_t_defined
46typedef __uid_t uid_t;
47# define __uid_t_defined
48# endif
49#endif /* Unix98 */
50
51#ifdef __USE_POSIX199309
52/* We need `struct timespec' later on. */
53# include <bits/types/struct_timespec.h>
54#endif
55
56#if defined __USE_POSIX199309 || defined __USE_XOPEN_EXTENDED
57# include <bits/types/siginfo_t.h>
58# include <bits/siginfo-consts.h>
59#endif
60
61#ifdef __USE_MISC
62# include <bits/types/sigval_t.h>
63#endif
64
65#ifdef __USE_POSIX199309
66# include <bits/types/sigevent_t.h>
67# include <bits/sigevent-consts.h>
68#endif
69
70
71/* Type of a signal handler. */
72typedef void (*__sighandler_t) (int);
73
74/* The X/Open definition of `signal' specifies the SVID semantic. Use
75 the additional function `sysv_signal' when X/Open compatibility is
76 requested. */
77extern __sighandler_t __sysv_signal (int __sig, __sighandler_t __handler)
78 __THROW;
79#ifdef __USE_GNU
80extern __sighandler_t sysv_signal (int __sig, __sighandler_t __handler)
81 __THROW;
82#endif
83
84/* Set the handler for the signal SIG to HANDLER, returning the old
85 handler, or SIG_ERR on error.
86 By default `signal' has the BSD semantic. */
87#ifdef __USE_MISC
88extern __sighandler_t signal (int __sig, __sighandler_t __handler)
89 __THROW;
90#else
91/* Make sure the used `signal' implementation is the SVID version. */
92# ifdef __REDIRECT_NTH
93extern __sighandler_t __REDIRECT_NTH (signal,
94 (int __sig, __sighandler_t __handler),
95 __sysv_signal);
96# else
97# define signal __sysv_signal
98# endif
99#endif
100
101#if defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8
102/* The X/Open definition of `signal' conflicts with the BSD version.
103 So they defined another function `bsd_signal'. */
104extern __sighandler_t bsd_signal (int __sig, __sighandler_t __handler)
105 __THROW;
106#endif
107
108/* Send signal SIG to process number PID. If PID is zero,
109 send SIG to all processes in the current process's process group.
110 If PID is < -1, send SIG to all processes in process group - PID. */
111#ifdef __USE_POSIX
112extern int kill (__pid_t __pid, int __sig) __THROW;
113#endif /* Use POSIX. */
114
115#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
116/* Send SIG to all processes in process group PGRP.
117 If PGRP is zero, send SIG to all processes in
118 the current process's process group. */
119extern int killpg (__pid_t __pgrp, int __sig) __THROW;
120#endif /* Use misc || X/Open Unix. */
121
122/* Raise signal SIG, i.e., send SIG to yourself. */
123extern int raise (int __sig) __THROW;
124
125#ifdef __USE_MISC
126/* SVID names for the same things. */
127extern __sighandler_t ssignal (int __sig, __sighandler_t __handler)
128 __THROW;
129extern int gsignal (int __sig) __THROW;
130#endif /* Use misc. */
131
132#ifdef __USE_XOPEN2K8
133/* Print a message describing the meaning of the given signal number. */
134extern void psignal (int __sig, const char *__s);
135
136/* Print a message describing the meaning of the given signal information. */
137extern void psiginfo (const siginfo_t *__pinfo, const char *__s);
138#endif /* POSIX 2008. */
139
140
141
142/* The `sigpause' function in X/Open defines the argument as the
143 signal number. This requires redirecting to another function
144 because the default version in glibc uses an old BSD interface.
145
146 This function is a cancellation point and therefore not marked with
147 __THROW. */
148
149#ifdef __USE_XOPEN_EXTENDED
150# ifdef __GNUC__
151extern int sigpause (int __sig) __asm__ ("__xpg_sigpause");
152# else
153extern int __sigpause (int __sig_or_mask, int __is_sig);
154/* Remove a signal from the signal mask and suspend the process. */
155# define sigpause(sig) __sigpause ((sig), 1)
156# endif
157#endif
158
159
160#ifdef __USE_MISC
161/* None of the following functions should be used anymore. They are here
162 only for compatibility. A single word (`int') is not guaranteed to be
163 enough to hold a complete signal mask and therefore these functions
164 simply do not work in many situations. Use `sigprocmask' instead. */
165
166/* Compute mask for signal SIG. */
167# define sigmask(sig) ((int)(1u << ((sig) - 1)))
168
169/* Block signals in MASK, returning the old mask. */
170extern int sigblock (int __mask) __THROW __attribute_deprecated__;
171
172/* Set the mask of blocked signals to MASK, returning the old mask. */
173extern int sigsetmask (int __mask) __THROW __attribute_deprecated__;
174
175/* Return currently selected signal mask. */
176extern int siggetmask (void) __THROW __attribute_deprecated__;
177#endif /* Use misc. */
178
179
180#ifdef __USE_MISC
181# define NSIG _NSIG
182#endif
183
184#ifdef __USE_GNU
185typedef __sighandler_t sighandler_t;
186#endif
187
188/* 4.4 BSD uses the name `sig_t' for this. */
189#ifdef __USE_MISC
190typedef __sighandler_t sig_t;
191#endif
192
193#ifdef __USE_POSIX
194
195/* Clear all signals from SET. */
196extern int sigemptyset (sigset_t *__set) __THROW __nonnull ((1));
197
198/* Set all signals in SET. */
199extern int sigfillset (sigset_t *__set) __THROW __nonnull ((1));
200
201/* Add SIGNO to SET. */
202extern int sigaddset (sigset_t *__set, int __signo) __THROW __nonnull ((1));
203
204/* Remove SIGNO from SET. */
205extern int sigdelset (sigset_t *__set, int __signo) __THROW __nonnull ((1));
206
207/* Return 1 if SIGNO is in SET, 0 if not. */
208extern int sigismember (const sigset_t *__set, int __signo)
209 __THROW __nonnull ((1));
210
211# ifdef __USE_GNU
212/* Return non-empty value is SET is not empty. */
213extern int sigisemptyset (const sigset_t *__set) __THROW __nonnull ((1));
214
215/* Build new signal set by combining the two inputs set using logical AND. */
216extern int sigandset (sigset_t *__set, const sigset_t *__left,
217 const sigset_t *__right) __THROW __nonnull ((1, 2, 3));
218
219/* Build new signal set by combining the two inputs set using logical OR. */
220extern int sigorset (sigset_t *__set, const sigset_t *__left,
221 const sigset_t *__right) __THROW __nonnull ((1, 2, 3));
222# endif /* GNU */
223
224/* Get the system-specific definitions of `struct sigaction'
225 and the `SA_*' and `SIG_*'. constants. */
226# include <bits/sigaction.h>
227
228/* Get and/or change the set of blocked signals. */
229extern int sigprocmask (int __how, const sigset_t *__restrict __set,
230 sigset_t *__restrict __oset) __THROW;
231
232/* Change the set of blocked signals to SET,
233 wait until a signal arrives, and restore the set of blocked signals.
234
235 This function is a cancellation point and therefore not marked with
236 __THROW. */
237extern int sigsuspend (const sigset_t *__set) __nonnull ((1));
238
239/* Get and/or set the action for signal SIG. */
240extern int sigaction (int __sig, const struct sigaction *__restrict __act,
241 struct sigaction *__restrict __oact) __THROW;
242
243/* Put in SET all signals that are blocked and waiting to be delivered. */
244extern int sigpending (sigset_t *__set) __THROW __nonnull ((1));
245
246
247# ifdef __USE_POSIX199506
248/* Select any of pending signals from SET or wait for any to arrive.
249
250 This function is a cancellation point and therefore not marked with
251 __THROW. */
252extern int sigwait (const sigset_t *__restrict __set, int *__restrict __sig)
253 __nonnull ((1, 2));
254# endif /* Use POSIX 1995. */
255
256# ifdef __USE_POSIX199309
257/* Select any of pending signals from SET and place information in INFO.
258
259 This function is a cancellation point and therefore not marked with
260 __THROW. */
261extern int sigwaitinfo (const sigset_t *__restrict __set,
262 siginfo_t *__restrict __info) __nonnull ((1));
263
264/* Select any of pending signals from SET and place information in INFO.
265 Wait the time specified by TIMEOUT if no signal is pending.
266
267 This function is a cancellation point and therefore not marked with
268 __THROW. */
269extern int sigtimedwait (const sigset_t *__restrict __set,
270 siginfo_t *__restrict __info,
271 const struct timespec *__restrict __timeout)
272 __nonnull ((1));
273
274/* Send signal SIG to the process PID. Associate data in VAL with the
275 signal. */
276extern int sigqueue (__pid_t __pid, int __sig, const union sigval __val)
277 __THROW;
278# endif /* Use POSIX 199306. */
279
280#endif /* Use POSIX. */
281
282#ifdef __USE_MISC
283
284/* Names of the signals. This variable exists only for compatibility.
285 Use `strsignal' instead (see <string.h>). */
286extern const char *const _sys_siglist[_NSIG];
287extern const char *const sys_siglist[_NSIG];
288
289
290/* Get machine-dependent `struct sigcontext' and signal subcodes. */
291# include <bits/sigcontext.h>
292
293/* Restore the state saved in SCP. */
294extern int sigreturn (struct sigcontext *__scp) __THROW;
295
296#endif /* Use misc. */
297
298
299#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
300# define __need_size_t
301# include <stddef.h>
302
303# include <bits/types/stack_t.h>
304# if defined __USE_XOPEN || defined __USE_XOPEN2K8
305/* This will define `ucontext_t' and `mcontext_t'. */
306# include <sys/ucontext.h>
307# endif
308#endif /* Use POSIX.1-2008 or X/Open Unix. */
309
310#if defined __USE_XOPEN_EXTENDED || defined __USE_MISC
311/* If INTERRUPT is nonzero, make signal SIG interrupt system calls
312 (causing them to fail with EINTR); if INTERRUPT is zero, make system
313 calls be restarted after signal SIG. */
314extern int siginterrupt (int __sig, int __interrupt) __THROW;
315
316# include <bits/sigstack.h>
317# include <bits/ss_flags.h>
318
319/* Alternate signal handler stack interface.
320 This interface should always be preferred over `sigstack'. */
321extern int sigaltstack (const stack_t *__restrict __ss,
322 stack_t *__restrict __oss) __THROW;
323#endif /* __USE_XOPEN_EXTENDED || __USE_MISC */
324
325#if ((defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8) \
326 || defined __USE_MISC)
327# include <bits/types/struct_sigstack.h>
328#endif
329
330#if ((defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K) \
331 || defined __USE_MISC)
332/* Run signals handlers on the stack specified by SS (if not NULL).
333 If OSS is not NULL, it is filled in with the old signal stack status.
334 This interface is obsolete and on many platform not implemented. */
335extern int sigstack (struct sigstack *__ss, struct sigstack *__oss)
336 __THROW __attribute_deprecated__;
337#endif
338
339#ifdef __USE_XOPEN_EXTENDED
340/* Simplified interface for signal management. */
341
342/* Add SIG to the calling process' signal mask. */
343extern int sighold (int __sig) __THROW;
344
345/* Remove SIG from the calling process' signal mask. */
346extern int sigrelse (int __sig) __THROW;
347
348/* Set the disposition of SIG to SIG_IGN. */
349extern int sigignore (int __sig) __THROW;
350
351/* Set the disposition of SIG. */
352extern __sighandler_t sigset (int __sig, __sighandler_t __disp) __THROW;
353#endif
354
355#if defined __USE_POSIX199506 || defined __USE_UNIX98
356/* Some of the functions for handling signals in threaded programs must
357 be defined here. */
358# include <bits/pthreadtypes.h>
359# include <bits/sigthread.h>
360#endif /* use Unix98 */
361
362/* The following functions are used internally in the C library and in
363 other code which need deep insights. */
364
365/* Return number of available real-time signal with highest priority. */
366extern int __libc_current_sigrtmin (void) __THROW;
367/* Return number of available real-time signal with lowest priority. */
368extern int __libc_current_sigrtmax (void) __THROW;
369
370#define SIGRTMIN (__libc_current_sigrtmin ())
371#define SIGRTMAX (__libc_current_sigrtmax ())
372
373__END_DECLS
374
375#endif /* not signal.h */
libc/glibc-include/spawn.h created+203
...@@ -0,0 +1,203 @@
1/* Definitions for POSIX spawn interface.
2 Copyright (C) 2000-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SPAWN_H
20#define _SPAWN_H 1
21
22#include <features.h>
23#include <sched.h>
24#include <sys/types.h>
25#include <bits/types/sigset_t.h>
26
27
28/* Data structure to contain attributes for thread creation. */
29typedef struct
30{
31 short int __flags;
32 pid_t __pgrp;
33 sigset_t __sd;
34 sigset_t __ss;
35 struct sched_param __sp;
36 int __policy;
37 int __pad[16];
38} posix_spawnattr_t;
39
40
41/* Data structure to contain information about the actions to be
42 performed in the new process with respect to file descriptors. */
43typedef struct
44{
45 int __allocated;
46 int __used;
47 struct __spawn_action *__actions;
48 int __pad[16];
49} posix_spawn_file_actions_t;
50
51
52/* Flags to be set in the `posix_spawnattr_t'. */
53#define POSIX_SPAWN_RESETIDS 0x01
54#define POSIX_SPAWN_SETPGROUP 0x02
55#define POSIX_SPAWN_SETSIGDEF 0x04
56#define POSIX_SPAWN_SETSIGMASK 0x08
57#define POSIX_SPAWN_SETSCHEDPARAM 0x10
58#define POSIX_SPAWN_SETSCHEDULER 0x20
59#ifdef __USE_GNU
60# define POSIX_SPAWN_USEVFORK 0x40
61# define POSIX_SPAWN_SETSID 0x80
62#endif
63
64
65__BEGIN_DECLS
66
67/* Spawn a new process executing PATH with the attributes describes in *ATTRP.
68 Before running the process perform the actions described in FILE-ACTIONS.
69
70 This function is a possible cancellation point and therefore not
71 marked with __THROW. */
72extern int posix_spawn (pid_t *__restrict __pid,
73 const char *__restrict __path,
74 const posix_spawn_file_actions_t *__restrict
75 __file_actions,
76 const posix_spawnattr_t *__restrict __attrp,
77 char *const __argv[__restrict_arr],
78 char *const __envp[__restrict_arr]);
79
80/* Similar to `posix_spawn' but search for FILE in the PATH.
81
82 This function is a possible cancellation point and therefore not
83 marked with __THROW. */
84extern int posix_spawnp (pid_t *__pid, const char *__file,
85 const posix_spawn_file_actions_t *__file_actions,
86 const posix_spawnattr_t *__attrp,
87 char *const __argv[], char *const __envp[]);
88
89
90/* Initialize data structure with attributes for `spawn' to default values. */
91extern int posix_spawnattr_init (posix_spawnattr_t *__attr) __THROW;
92
93/* Free resources associated with ATTR. */
94extern int posix_spawnattr_destroy (posix_spawnattr_t *__attr) __THROW;
95
96/* Store signal mask for signals with default handling from ATTR in
97 SIGDEFAULT. */
98extern int posix_spawnattr_getsigdefault (const posix_spawnattr_t *
99 __restrict __attr,
100 sigset_t *__restrict __sigdefault)
101 __THROW;
102
103/* Set signal mask for signals with default handling in ATTR to SIGDEFAULT. */
104extern int posix_spawnattr_setsigdefault (posix_spawnattr_t *__restrict __attr,
105 const sigset_t *__restrict
106 __sigdefault)
107 __THROW;
108
109/* Store signal mask for the new process from ATTR in SIGMASK. */
110extern int posix_spawnattr_getsigmask (const posix_spawnattr_t *__restrict
111 __attr,
112 sigset_t *__restrict __sigmask) __THROW;
113
114/* Set signal mask for the new process in ATTR to SIGMASK. */
115extern int posix_spawnattr_setsigmask (posix_spawnattr_t *__restrict __attr,
116 const sigset_t *__restrict __sigmask)
117 __THROW;
118
119/* Get flag word from the attribute structure. */
120extern int posix_spawnattr_getflags (const posix_spawnattr_t *__restrict
121 __attr,
122 short int *__restrict __flags) __THROW;
123
124/* Store flags in the attribute structure. */
125extern int posix_spawnattr_setflags (posix_spawnattr_t *_attr,
126 short int __flags) __THROW;
127
128/* Get process group ID from the attribute structure. */
129extern int posix_spawnattr_getpgroup (const posix_spawnattr_t *__restrict
130 __attr, pid_t *__restrict __pgroup)
131 __THROW;
132
133/* Store process group ID in the attribute structure. */
134extern int posix_spawnattr_setpgroup (posix_spawnattr_t *__attr,
135 pid_t __pgroup) __THROW;
136
137/* Get scheduling policy from the attribute structure. */
138extern int posix_spawnattr_getschedpolicy (const posix_spawnattr_t *
139 __restrict __attr,
140 int *__restrict __schedpolicy)
141 __THROW;
142
143/* Store scheduling policy in the attribute structure. */
144extern int posix_spawnattr_setschedpolicy (posix_spawnattr_t *__attr,
145 int __schedpolicy) __THROW;
146
147/* Get scheduling parameters from the attribute structure. */
148extern int posix_spawnattr_getschedparam (const posix_spawnattr_t *
149 __restrict __attr,
150 struct sched_param *__restrict
151 __schedparam) __THROW;
152
153/* Store scheduling parameters in the attribute structure. */
154extern int posix_spawnattr_setschedparam (posix_spawnattr_t *__restrict __attr,
155 const struct sched_param *
156 __restrict __schedparam) __THROW;
157
158
159/* Initialize data structure for file attribute for `spawn' call. */
160extern int posix_spawn_file_actions_init (posix_spawn_file_actions_t *
161 __file_actions) __THROW;
162
163/* Free resources associated with FILE-ACTIONS. */
164extern int posix_spawn_file_actions_destroy (posix_spawn_file_actions_t *
165 __file_actions) __THROW;
166
167/* Add an action to FILE-ACTIONS which tells the implementation to call
168 `open' for the given file during the `spawn' call. */
169extern int posix_spawn_file_actions_addopen (posix_spawn_file_actions_t *
170 __restrict __file_actions,
171 int __fd,
172 const char *__restrict __path,
173 int __oflag, mode_t __mode)
174 __THROW;
175
176/* Add an action to FILE-ACTIONS which tells the implementation to call
177 `close' for the given file descriptor during the `spawn' call. */
178extern int posix_spawn_file_actions_addclose (posix_spawn_file_actions_t *
179 __file_actions, int __fd)
180 __THROW;
181
182/* Add an action to FILE-ACTIONS which tells the implementation to call
183 `dup2' for the given file descriptors during the `spawn' call. */
184extern int posix_spawn_file_actions_adddup2 (posix_spawn_file_actions_t *
185 __file_actions,
186 int __fd, int __newfd) __THROW;
187
188#ifdef __USE_GNU
189/* Add an action changing the directory to PATH during spawn. This
190 affects the subsequent file actions. */
191extern int posix_spawn_file_actions_addchdir_np (posix_spawn_file_actions_t *,
192 const char *__path) __THROW;
193
194/* Add an action changing the directory to FD during spawn. This
195 affects the subsequent file actions. FD is not duplicated and must
196 be open when the file action is executed. */
197extern int posix_spawn_file_actions_addfchdir_np (posix_spawn_file_actions_t *,
198 int __fd) __THROW;
199#endif
200
201__END_DECLS
202
203#endif /* spawn.h */
libc/glibc-include/stab.h created+17
...@@ -0,0 +1,17 @@
1#ifndef __GNU_STAB__
2
3/* Indicate the GNU stab.h is in use. */
4
5#define __GNU_STAB__
6
7#define __define_stab(NAME, CODE, STRING) NAME=CODE,
8
9enum __stab_debug_code
10{
11#include <bits/stab.def>
12LAST_UNUSED_STAB_CODE
13};
14
15#undef __define_stab
16
17#endif /* __GNU_STAB_ */
libc/glibc-include/stdc-predef.h created+60
...@@ -0,0 +1,60 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _STDC_PREDEF_H
19#define _STDC_PREDEF_H 1
20
21/* This header is separate from features.h so that the compiler can
22 include it implicitly at the start of every compilation. It must
23 not itself include <features.h> or any other header that includes
24 <features.h> because the implicit include comes before any feature
25 test macros that may be defined in a source file before it first
26 explicitly includes a system header. GCC knows the name of this
27 header in order to preinclude it. */
28
29/* glibc's intent is to support the IEC 559 math functionality, real
30 and complex. If the GCC (4.9 and later) predefined macros
31 specifying compiler intent are available, use them to determine
32 whether the overall intent is to support these features; otherwise,
33 presume an older compiler has intent to support these features and
34 define these macros by default. */
35
36#ifdef __GCC_IEC_559
37# if __GCC_IEC_559 > 0
38# define __STDC_IEC_559__ 1
39# endif
40#else
41# define __STDC_IEC_559__ 1
42#endif
43
44#ifdef __GCC_IEC_559_COMPLEX
45# if __GCC_IEC_559_COMPLEX > 0
46# define __STDC_IEC_559_COMPLEX__ 1
47# endif
48#else
49# define __STDC_IEC_559_COMPLEX__ 1
50#endif
51
52/* wchar_t uses Unicode 10.0.0. Version 10.0 of the Unicode Standard is
53 synchronized with ISO/IEC 10646:2017, fifth edition, plus
54 the following additions from Amendment 1 to the fifth edition:
55 - 56 emoji characters
56 - 285 hentaigana
57 - 3 additional Zanabazar Square characters */
58#define __STDC_ISO_10646__ 201706L
59
60#endif
libc/glibc-include/stdint.h created+319
...@@ -0,0 +1,319 @@
1/* Copyright (C) 1997-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/*
19 * ISO C99: 7.18 Integer types <stdint.h>
20 */
21
22#ifndef _STDINT_H
23#define _STDINT_H 1
24
25#define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION
26#include <bits/libc-header-start.h>
27#include <bits/types.h>
28#include <bits/wchar.h>
29#include <bits/wordsize.h>
30
31/* Exact integral types. */
32
33/* Signed. */
34#include <bits/stdint-intn.h>
35
36/* Unsigned. */
37#include <bits/stdint-uintn.h>
38
39
40/* Small types. */
41
42/* Signed. */
43typedef __int_least8_t int_least8_t;
44typedef __int_least16_t int_least16_t;
45typedef __int_least32_t int_least32_t;
46typedef __int_least64_t int_least64_t;
47
48/* Unsigned. */
49typedef __uint_least8_t uint_least8_t;
50typedef __uint_least16_t uint_least16_t;
51typedef __uint_least32_t uint_least32_t;
52typedef __uint_least64_t uint_least64_t;
53
54
55/* Fast types. */
56
57/* Signed. */
58typedef signed char int_fast8_t;
59#if __WORDSIZE == 64
60typedef long int int_fast16_t;
61typedef long int int_fast32_t;
62typedef long int int_fast64_t;
63#else
64typedef int int_fast16_t;
65typedef int int_fast32_t;
66__extension__
67typedef long long int int_fast64_t;
68#endif
69
70/* Unsigned. */
71typedef unsigned char uint_fast8_t;
72#if __WORDSIZE == 64
73typedef unsigned long int uint_fast16_t;
74typedef unsigned long int uint_fast32_t;
75typedef unsigned long int uint_fast64_t;
76#else
77typedef unsigned int uint_fast16_t;
78typedef unsigned int uint_fast32_t;
79__extension__
80typedef unsigned long long int uint_fast64_t;
81#endif
82
83
84/* Types for `void *' pointers. */
85#if __WORDSIZE == 64
86# ifndef __intptr_t_defined
87typedef long int intptr_t;
88# define __intptr_t_defined
89# endif
90typedef unsigned long int uintptr_t;
91#else
92# ifndef __intptr_t_defined
93typedef int intptr_t;
94# define __intptr_t_defined
95# endif
96typedef unsigned int uintptr_t;
97#endif
98
99
100/* Largest integral types. */
101typedef __intmax_t intmax_t;
102typedef __uintmax_t uintmax_t;
103
104
105# if __WORDSIZE == 64
106# define __INT64_C(c) c ## L
107# define __UINT64_C(c) c ## UL
108# else
109# define __INT64_C(c) c ## LL
110# define __UINT64_C(c) c ## ULL
111# endif
112
113/* Limits of integral types. */
114
115/* Minimum of signed integral types. */
116# define INT8_MIN (-128)
117# define INT16_MIN (-32767-1)
118# define INT32_MIN (-2147483647-1)
119# define INT64_MIN (-__INT64_C(9223372036854775807)-1)
120/* Maximum of signed integral types. */
121# define INT8_MAX (127)
122# define INT16_MAX (32767)
123# define INT32_MAX (2147483647)
124# define INT64_MAX (__INT64_C(9223372036854775807))
125
126/* Maximum of unsigned integral types. */
127# define UINT8_MAX (255)
128# define UINT16_MAX (65535)
129# define UINT32_MAX (4294967295U)
130# define UINT64_MAX (__UINT64_C(18446744073709551615))
131
132
133/* Minimum of signed integral types having a minimum size. */
134# define INT_LEAST8_MIN (-128)
135# define INT_LEAST16_MIN (-32767-1)
136# define INT_LEAST32_MIN (-2147483647-1)
137# define INT_LEAST64_MIN (-__INT64_C(9223372036854775807)-1)
138/* Maximum of signed integral types having a minimum size. */
139# define INT_LEAST8_MAX (127)
140# define INT_LEAST16_MAX (32767)
141# define INT_LEAST32_MAX (2147483647)
142# define INT_LEAST64_MAX (__INT64_C(9223372036854775807))
143
144/* Maximum of unsigned integral types having a minimum size. */
145# define UINT_LEAST8_MAX (255)
146# define UINT_LEAST16_MAX (65535)
147# define UINT_LEAST32_MAX (4294967295U)
148# define UINT_LEAST64_MAX (__UINT64_C(18446744073709551615))
149
150
151/* Minimum of fast signed integral types having a minimum size. */
152# define INT_FAST8_MIN (-128)
153# if __WORDSIZE == 64
154# define INT_FAST16_MIN (-9223372036854775807L-1)
155# define INT_FAST32_MIN (-9223372036854775807L-1)
156# else
157# define INT_FAST16_MIN (-2147483647-1)
158# define INT_FAST32_MIN (-2147483647-1)
159# endif
160# define INT_FAST64_MIN (-__INT64_C(9223372036854775807)-1)
161/* Maximum of fast signed integral types having a minimum size. */
162# define INT_FAST8_MAX (127)
163# if __WORDSIZE == 64
164# define INT_FAST16_MAX (9223372036854775807L)
165# define INT_FAST32_MAX (9223372036854775807L)
166# else
167# define INT_FAST16_MAX (2147483647)
168# define INT_FAST32_MAX (2147483647)
169# endif
170# define INT_FAST64_MAX (__INT64_C(9223372036854775807))
171
172/* Maximum of fast unsigned integral types having a minimum size. */
173# define UINT_FAST8_MAX (255)
174# if __WORDSIZE == 64
175# define UINT_FAST16_MAX (18446744073709551615UL)
176# define UINT_FAST32_MAX (18446744073709551615UL)
177# else
178# define UINT_FAST16_MAX (4294967295U)
179# define UINT_FAST32_MAX (4294967295U)
180# endif
181# define UINT_FAST64_MAX (__UINT64_C(18446744073709551615))
182
183
184/* Values to test for integral types holding `void *' pointer. */
185# if __WORDSIZE == 64
186# define INTPTR_MIN (-9223372036854775807L-1)
187# define INTPTR_MAX (9223372036854775807L)
188# define UINTPTR_MAX (18446744073709551615UL)
189# else
190# define INTPTR_MIN (-2147483647-1)
191# define INTPTR_MAX (2147483647)
192# define UINTPTR_MAX (4294967295U)
193# endif
194
195
196/* Minimum for largest signed integral type. */
197# define INTMAX_MIN (-__INT64_C(9223372036854775807)-1)
198/* Maximum for largest signed integral type. */
199# define INTMAX_MAX (__INT64_C(9223372036854775807))
200
201/* Maximum for largest unsigned integral type. */
202# define UINTMAX_MAX (__UINT64_C(18446744073709551615))
203
204
205/* Limits of other integer types. */
206
207/* Limits of `ptrdiff_t' type. */
208# if __WORDSIZE == 64
209# define PTRDIFF_MIN (-9223372036854775807L-1)
210# define PTRDIFF_MAX (9223372036854775807L)
211# else
212# if __WORDSIZE32_PTRDIFF_LONG
213# define PTRDIFF_MIN (-2147483647L-1)
214# define PTRDIFF_MAX (2147483647L)
215# else
216# define PTRDIFF_MIN (-2147483647-1)
217# define PTRDIFF_MAX (2147483647)
218# endif
219# endif
220
221/* Limits of `sig_atomic_t'. */
222# define SIG_ATOMIC_MIN (-2147483647-1)
223# define SIG_ATOMIC_MAX (2147483647)
224
225/* Limit of `size_t' type. */
226# if __WORDSIZE == 64
227# define SIZE_MAX (18446744073709551615UL)
228# else
229# if __WORDSIZE32_SIZE_ULONG
230# define SIZE_MAX (4294967295UL)
231# else
232# define SIZE_MAX (4294967295U)
233# endif
234# endif
235
236/* Limits of `wchar_t'. */
237# ifndef WCHAR_MIN
238/* These constants might also be defined in <wchar.h>. */
239# define WCHAR_MIN __WCHAR_MIN
240# define WCHAR_MAX __WCHAR_MAX
241# endif
242
243/* Limits of `wint_t'. */
244# define WINT_MIN (0u)
245# define WINT_MAX (4294967295u)
246
247/* Signed. */
248# define INT8_C(c) c
249# define INT16_C(c) c
250# define INT32_C(c) c
251# if __WORDSIZE == 64
252# define INT64_C(c) c ## L
253# else
254# define INT64_C(c) c ## LL
255# endif
256
257/* Unsigned. */
258# define UINT8_C(c) c
259# define UINT16_C(c) c
260# define UINT32_C(c) c ## U
261# if __WORDSIZE == 64
262# define UINT64_C(c) c ## UL
263# else
264# define UINT64_C(c) c ## ULL
265# endif
266
267/* Maximal type. */
268# if __WORDSIZE == 64
269# define INTMAX_C(c) c ## L
270# define UINTMAX_C(c) c ## UL
271# else
272# define INTMAX_C(c) c ## LL
273# define UINTMAX_C(c) c ## ULL
274# endif
275
276#if __GLIBC_USE (IEC_60559_BFP_EXT)
277
278# define INT8_WIDTH 8
279# define UINT8_WIDTH 8
280# define INT16_WIDTH 16
281# define UINT16_WIDTH 16
282# define INT32_WIDTH 32
283# define UINT32_WIDTH 32
284# define INT64_WIDTH 64
285# define UINT64_WIDTH 64
286
287# define INT_LEAST8_WIDTH 8
288# define UINT_LEAST8_WIDTH 8
289# define INT_LEAST16_WIDTH 16
290# define UINT_LEAST16_WIDTH 16
291# define INT_LEAST32_WIDTH 32
292# define UINT_LEAST32_WIDTH 32
293# define INT_LEAST64_WIDTH 64
294# define UINT_LEAST64_WIDTH 64
295
296# define INT_FAST8_WIDTH 8
297# define UINT_FAST8_WIDTH 8
298# define INT_FAST16_WIDTH __WORDSIZE
299# define UINT_FAST16_WIDTH __WORDSIZE
300# define INT_FAST32_WIDTH __WORDSIZE
301# define UINT_FAST32_WIDTH __WORDSIZE
302# define INT_FAST64_WIDTH 64
303# define UINT_FAST64_WIDTH 64
304
305# define INTPTR_WIDTH __WORDSIZE
306# define UINTPTR_WIDTH __WORDSIZE
307
308# define INTMAX_WIDTH 64
309# define UINTMAX_WIDTH 64
310
311# define PTRDIFF_WIDTH __WORDSIZE
312# define SIG_ATOMIC_WIDTH 32
313# define SIZE_WIDTH __WORDSIZE
314# define WCHAR_WIDTH 32
315# define WINT_WIDTH 32
316
317#endif
318
319#endif /* stdint.h */
libc/glibc-include/stdio.h created+875
...@@ -0,0 +1,875 @@
1/* Define ISO C stdio on top of C++ iostreams.
2 Copyright (C) 1991-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19/*
20 * ISO C99 Standard: 7.19 Input/output <stdio.h>
21 */
22
23#ifndef _STDIO_H
24#define _STDIO_H 1
25
26#define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION
27#include <bits/libc-header-start.h>
28
29__BEGIN_DECLS
30
31#define __need_size_t
32#define __need_NULL
33#include <stddef.h>
34
35#define __need___va_list
36#include <stdarg.h>
37
38#include <bits/types.h>
39#include <bits/types/__fpos_t.h>
40#include <bits/types/__fpos64_t.h>
41#include <bits/types/__FILE.h>
42#include <bits/types/FILE.h>
43#include <bits/types/struct_FILE.h>
44
45#ifdef __USE_GNU
46# include <bits/types/cookie_io_functions_t.h>
47#endif
48
49#if defined __USE_XOPEN || defined __USE_XOPEN2K8
50# ifdef __GNUC__
51# ifndef _VA_LIST_DEFINED
52typedef __gnuc_va_list va_list;
53# define _VA_LIST_DEFINED
54# endif
55# else
56# include <stdarg.h>
57# endif
58#endif
59
60#if defined __USE_UNIX98 || defined __USE_XOPEN2K
61# ifndef __off_t_defined
62# ifndef __USE_FILE_OFFSET64
63typedef __off_t off_t;
64# else
65typedef __off64_t off_t;
66# endif
67# define __off_t_defined
68# endif
69# if defined __USE_LARGEFILE64 && !defined __off64_t_defined
70typedef __off64_t off64_t;
71# define __off64_t_defined
72# endif
73#endif
74
75#ifdef __USE_XOPEN2K8
76# ifndef __ssize_t_defined
77typedef __ssize_t ssize_t;
78# define __ssize_t_defined
79# endif
80#endif
81
82/* The type of the second argument to `fgetpos' and `fsetpos'. */
83#ifndef __USE_FILE_OFFSET64
84typedef __fpos_t fpos_t;
85#else
86typedef __fpos64_t fpos_t;
87#endif
88#ifdef __USE_LARGEFILE64
89typedef __fpos64_t fpos64_t;
90#endif
91
92/* The possibilities for the third argument to `setvbuf'. */
93#define _IOFBF 0 /* Fully buffered. */
94#define _IOLBF 1 /* Line buffered. */
95#define _IONBF 2 /* No buffering. */
96
97
98/* Default buffer size. */
99#define BUFSIZ 8192
100
101
102/* The value returned by fgetc and similar functions to indicate the
103 end of the file. */
104#define EOF (-1)
105
106
107/* The possibilities for the third argument to `fseek'.
108 These values should not be changed. */
109#define SEEK_SET 0 /* Seek from beginning of file. */
110#define SEEK_CUR 1 /* Seek from current position. */
111#define SEEK_END 2 /* Seek from end of file. */
112#ifdef __USE_GNU
113# define SEEK_DATA 3 /* Seek to next data. */
114# define SEEK_HOLE 4 /* Seek to next hole. */
115#endif
116
117
118#if defined __USE_MISC || defined __USE_XOPEN
119/* Default path prefix for `tempnam' and `tmpnam'. */
120# define P_tmpdir "/tmp"
121#endif
122
123
124/* Get the values:
125 L_tmpnam How long an array of chars must be to be passed to `tmpnam'.
126 TMP_MAX The minimum number of unique filenames generated by tmpnam
127 (and tempnam when it uses tmpnam's name space),
128 or tempnam (the two are separate).
129 L_ctermid How long an array to pass to `ctermid'.
130 L_cuserid How long an array to pass to `cuserid'.
131 FOPEN_MAX Minimum number of files that can be open at once.
132 FILENAME_MAX Maximum length of a filename. */
133#include <bits/stdio_lim.h>
134
135
136/* Standard streams. */
137extern FILE *stdin; /* Standard input stream. */
138extern FILE *stdout; /* Standard output stream. */
139extern FILE *stderr; /* Standard error output stream. */
140/* C89/C99 say they're macros. Make them happy. */
141#define stdin stdin
142#define stdout stdout
143#define stderr stderr
144
145/* Remove file FILENAME. */
146extern int remove (const char *__filename) __THROW;
147/* Rename file OLD to NEW. */
148extern int rename (const char *__old, const char *__new) __THROW;
149
150#ifdef __USE_ATFILE
151/* Rename file OLD relative to OLDFD to NEW relative to NEWFD. */
152extern int renameat (int __oldfd, const char *__old, int __newfd,
153 const char *__new) __THROW;
154#endif
155
156#ifdef __USE_GNU
157/* Flags for renameat2. */
158# define RENAME_NOREPLACE (1 << 0)
159# define RENAME_EXCHANGE (1 << 1)
160# define RENAME_WHITEOUT (1 << 2)
161
162/* Rename file OLD relative to OLDFD to NEW relative to NEWFD, with
163 additional flags. */
164extern int renameat2 (int __oldfd, const char *__old, int __newfd,
165 const char *__new, unsigned int __flags) __THROW;
166#endif
167
168/* Create a temporary file and open it read/write.
169
170 This function is a possible cancellation point and therefore not
171 marked with __THROW. */
172#ifndef __USE_FILE_OFFSET64
173extern FILE *tmpfile (void) __wur;
174#else
175# ifdef __REDIRECT
176extern FILE *__REDIRECT (tmpfile, (void), tmpfile64) __wur;
177# else
178# define tmpfile tmpfile64
179# endif
180#endif
181
182#ifdef __USE_LARGEFILE64
183extern FILE *tmpfile64 (void) __wur;
184#endif
185
186/* Generate a temporary filename. */
187extern char *tmpnam (char *__s) __THROW __wur;
188
189#ifdef __USE_MISC
190/* This is the reentrant variant of `tmpnam'. The only difference is
191 that it does not allow S to be NULL. */
192extern char *tmpnam_r (char *__s) __THROW __wur;
193#endif
194
195
196#if defined __USE_MISC || defined __USE_XOPEN
197/* Generate a unique temporary filename using up to five characters of PFX
198 if it is not NULL. The directory to put this file in is searched for
199 as follows: First the environment variable "TMPDIR" is checked.
200 If it contains the name of a writable directory, that directory is used.
201 If not and if DIR is not NULL, that value is checked. If that fails,
202 P_tmpdir is tried and finally "/tmp". The storage for the filename
203 is allocated by `malloc'. */
204extern char *tempnam (const char *__dir, const char *__pfx)
205 __THROW __attribute_malloc__ __wur;
206#endif
207
208
209/* Close STREAM.
210
211 This function is a possible cancellation point and therefore not
212 marked with __THROW. */
213extern int fclose (FILE *__stream);
214/* Flush STREAM, or all streams if STREAM is NULL.
215
216 This function is a possible cancellation point and therefore not
217 marked with __THROW. */
218extern int fflush (FILE *__stream);
219
220#ifdef __USE_MISC
221/* Faster versions when locking is not required.
222
223 This function is not part of POSIX and therefore no official
224 cancellation point. But due to similarity with an POSIX interface
225 or due to the implementation it is a cancellation point and
226 therefore not marked with __THROW. */
227extern int fflush_unlocked (FILE *__stream);
228#endif
229
230#ifdef __USE_GNU
231/* Close all streams.
232
233 This function is not part of POSIX and therefore no official
234 cancellation point. But due to similarity with an POSIX interface
235 or due to the implementation it is a cancellation point and
236 therefore not marked with __THROW. */
237extern int fcloseall (void);
238#endif
239
240
241#ifndef __USE_FILE_OFFSET64
242/* Open a file and create a new stream for it.
243
244 This function is a possible cancellation point and therefore not
245 marked with __THROW. */
246extern FILE *fopen (const char *__restrict __filename,
247 const char *__restrict __modes) __wur;
248/* Open a file, replacing an existing stream with it.
249
250 This function is a possible cancellation point and therefore not
251 marked with __THROW. */
252extern FILE *freopen (const char *__restrict __filename,
253 const char *__restrict __modes,
254 FILE *__restrict __stream) __wur;
255#else
256# ifdef __REDIRECT
257extern FILE *__REDIRECT (fopen, (const char *__restrict __filename,
258 const char *__restrict __modes), fopen64)
259 __wur;
260extern FILE *__REDIRECT (freopen, (const char *__restrict __filename,
261 const char *__restrict __modes,
262 FILE *__restrict __stream), freopen64)
263 __wur;
264# else
265# define fopen fopen64
266# define freopen freopen64
267# endif
268#endif
269#ifdef __USE_LARGEFILE64
270extern FILE *fopen64 (const char *__restrict __filename,
271 const char *__restrict __modes) __wur;
272extern FILE *freopen64 (const char *__restrict __filename,
273 const char *__restrict __modes,
274 FILE *__restrict __stream) __wur;
275#endif
276
277#ifdef __USE_POSIX
278/* Create a new stream that refers to an existing system file descriptor. */
279extern FILE *fdopen (int __fd, const char *__modes) __THROW __wur;
280#endif
281
282#ifdef __USE_GNU
283/* Create a new stream that refers to the given magic cookie,
284 and uses the given functions for input and output. */
285extern FILE *fopencookie (void *__restrict __magic_cookie,
286 const char *__restrict __modes,
287 cookie_io_functions_t __io_funcs) __THROW __wur;
288#endif
289
290#if defined __USE_XOPEN2K8 || __GLIBC_USE (LIB_EXT2)
291/* Create a new stream that refers to a memory buffer. */
292extern FILE *fmemopen (void *__s, size_t __len, const char *__modes)
293 __THROW __wur;
294
295/* Open a stream that writes into a malloc'd buffer that is expanded as
296 necessary. *BUFLOC and *SIZELOC are updated with the buffer's location
297 and the number of characters written on fflush or fclose. */
298extern FILE *open_memstream (char **__bufloc, size_t *__sizeloc) __THROW __wur;
299#endif
300
301
302/* If BUF is NULL, make STREAM unbuffered.
303 Else make it use buffer BUF, of size BUFSIZ. */
304extern void setbuf (FILE *__restrict __stream, char *__restrict __buf) __THROW;
305/* Make STREAM use buffering mode MODE.
306 If BUF is not NULL, use N bytes of it for buffering;
307 else allocate an internal buffer N bytes long. */
308extern int setvbuf (FILE *__restrict __stream, char *__restrict __buf,
309 int __modes, size_t __n) __THROW;
310
311#ifdef __USE_MISC
312/* If BUF is NULL, make STREAM unbuffered.
313 Else make it use SIZE bytes of BUF for buffering. */
314extern void setbuffer (FILE *__restrict __stream, char *__restrict __buf,
315 size_t __size) __THROW;
316
317/* Make STREAM line-buffered. */
318extern void setlinebuf (FILE *__stream) __THROW;
319#endif
320
321
322/* Write formatted output to STREAM.
323
324 This function is a possible cancellation point and therefore not
325 marked with __THROW. */
326extern int fprintf (FILE *__restrict __stream,
327 const char *__restrict __format, ...);
328/* Write formatted output to stdout.
329
330 This function is a possible cancellation point and therefore not
331 marked with __THROW. */
332extern int printf (const char *__restrict __format, ...);
333/* Write formatted output to S. */
334extern int sprintf (char *__restrict __s,
335 const char *__restrict __format, ...) __THROWNL;
336
337/* Write formatted output to S from argument list ARG.
338
339 This function is a possible cancellation point and therefore not
340 marked with __THROW. */
341extern int vfprintf (FILE *__restrict __s, const char *__restrict __format,
342 __gnuc_va_list __arg);
343/* Write formatted output to stdout from argument list ARG.
344
345 This function is a possible cancellation point and therefore not
346 marked with __THROW. */
347extern int vprintf (const char *__restrict __format, __gnuc_va_list __arg);
348/* Write formatted output to S from argument list ARG. */
349extern int vsprintf (char *__restrict __s, const char *__restrict __format,
350 __gnuc_va_list __arg) __THROWNL;
351
352#if defined __USE_ISOC99 || defined __USE_UNIX98
353/* Maximum chars of output to write in MAXLEN. */
354extern int snprintf (char *__restrict __s, size_t __maxlen,
355 const char *__restrict __format, ...)
356 __THROWNL __attribute__ ((__format__ (__printf__, 3, 4)));
357
358extern int vsnprintf (char *__restrict __s, size_t __maxlen,
359 const char *__restrict __format, __gnuc_va_list __arg)
360 __THROWNL __attribute__ ((__format__ (__printf__, 3, 0)));
361#endif
362
363#if __GLIBC_USE (LIB_EXT2)
364/* Write formatted output to a string dynamically allocated with `malloc'.
365 Store the address of the string in *PTR. */
366extern int vasprintf (char **__restrict __ptr, const char *__restrict __f,
367 __gnuc_va_list __arg)
368 __THROWNL __attribute__ ((__format__ (__printf__, 2, 0))) __wur;
369extern int __asprintf (char **__restrict __ptr,
370 const char *__restrict __fmt, ...)
371 __THROWNL __attribute__ ((__format__ (__printf__, 2, 3))) __wur;
372extern int asprintf (char **__restrict __ptr,
373 const char *__restrict __fmt, ...)
374 __THROWNL __attribute__ ((__format__ (__printf__, 2, 3))) __wur;
375#endif
376
377#ifdef __USE_XOPEN2K8
378/* Write formatted output to a file descriptor. */
379extern int vdprintf (int __fd, const char *__restrict __fmt,
380 __gnuc_va_list __arg)
381 __attribute__ ((__format__ (__printf__, 2, 0)));
382extern int dprintf (int __fd, const char *__restrict __fmt, ...)
383 __attribute__ ((__format__ (__printf__, 2, 3)));
384#endif
385
386
387/* Read formatted input from STREAM.
388
389 This function is a possible cancellation point and therefore not
390 marked with __THROW. */
391extern int fscanf (FILE *__restrict __stream,
392 const char *__restrict __format, ...) __wur;
393/* Read formatted input from stdin.
394
395 This function is a possible cancellation point and therefore not
396 marked with __THROW. */
397extern int scanf (const char *__restrict __format, ...) __wur;
398/* Read formatted input from S. */
399extern int sscanf (const char *__restrict __s,
400 const char *__restrict __format, ...) __THROW;
401
402/* For historical reasons, the C99-compliant versions of the scanf
403 functions are at alternative names. When __LDBL_COMPAT is in
404 effect, this is handled in bits/stdio-ldbl.h. */
405#if !__GLIBC_USE (DEPRECATED_SCANF) && !defined __LDBL_COMPAT
406# ifdef __REDIRECT
407extern int __REDIRECT (fscanf, (FILE *__restrict __stream,
408 const char *__restrict __format, ...),
409 __isoc99_fscanf) __wur;
410extern int __REDIRECT (scanf, (const char *__restrict __format, ...),
411 __isoc99_scanf) __wur;
412extern int __REDIRECT_NTH (sscanf, (const char *__restrict __s,
413 const char *__restrict __format, ...),
414 __isoc99_sscanf);
415# else
416extern int __isoc99_fscanf (FILE *__restrict __stream,
417 const char *__restrict __format, ...) __wur;
418extern int __isoc99_scanf (const char *__restrict __format, ...) __wur;
419extern int __isoc99_sscanf (const char *__restrict __s,
420 const char *__restrict __format, ...) __THROW;
421# define fscanf __isoc99_fscanf
422# define scanf __isoc99_scanf
423# define sscanf __isoc99_sscanf
424# endif
425#endif
426
427#ifdef __USE_ISOC99
428/* Read formatted input from S into argument list ARG.
429
430 This function is a possible cancellation point and therefore not
431 marked with __THROW. */
432extern int vfscanf (FILE *__restrict __s, const char *__restrict __format,
433 __gnuc_va_list __arg)
434 __attribute__ ((__format__ (__scanf__, 2, 0))) __wur;
435
436/* Read formatted input from stdin into argument list ARG.
437
438 This function is a possible cancellation point and therefore not
439 marked with __THROW. */
440extern int vscanf (const char *__restrict __format, __gnuc_va_list __arg)
441 __attribute__ ((__format__ (__scanf__, 1, 0))) __wur;
442
443/* Read formatted input from S into argument list ARG. */
444extern int vsscanf (const char *__restrict __s,
445 const char *__restrict __format, __gnuc_va_list __arg)
446 __THROW __attribute__ ((__format__ (__scanf__, 2, 0)));
447
448/* Same redirection as above for the v*scanf family. */
449# if !__GLIBC_USE (DEPRECATED_SCANF)
450# if defined __REDIRECT && !defined __LDBL_COMPAT
451extern int __REDIRECT (vfscanf,
452 (FILE *__restrict __s,
453 const char *__restrict __format, __gnuc_va_list __arg),
454 __isoc99_vfscanf)
455 __attribute__ ((__format__ (__scanf__, 2, 0))) __wur;
456extern int __REDIRECT (vscanf, (const char *__restrict __format,
457 __gnuc_va_list __arg), __isoc99_vscanf)
458 __attribute__ ((__format__ (__scanf__, 1, 0))) __wur;
459extern int __REDIRECT_NTH (vsscanf,
460 (const char *__restrict __s,
461 const char *__restrict __format,
462 __gnuc_va_list __arg), __isoc99_vsscanf)
463 __attribute__ ((__format__ (__scanf__, 2, 0)));
464# elif !defined __REDIRECT
465extern int __isoc99_vfscanf (FILE *__restrict __s,
466 const char *__restrict __format,
467 __gnuc_va_list __arg) __wur;
468extern int __isoc99_vscanf (const char *__restrict __format,
469 __gnuc_va_list __arg) __wur;
470extern int __isoc99_vsscanf (const char *__restrict __s,
471 const char *__restrict __format,
472 __gnuc_va_list __arg) __THROW;
473# define vfscanf __isoc99_vfscanf
474# define vscanf __isoc99_vscanf
475# define vsscanf __isoc99_vsscanf
476# endif
477# endif
478#endif /* Use ISO C9x. */
479
480
481/* Read a character from STREAM.
482
483 These functions are possible cancellation points and therefore not
484 marked with __THROW. */
485extern int fgetc (FILE *__stream);
486extern int getc (FILE *__stream);
487
488/* Read a character from stdin.
489
490 This function is a possible cancellation point and therefore not
491 marked with __THROW. */
492extern int getchar (void);
493
494#ifdef __USE_POSIX199506
495/* These are defined in POSIX.1:1996.
496
497 These functions are possible cancellation points and therefore not
498 marked with __THROW. */
499extern int getc_unlocked (FILE *__stream);
500extern int getchar_unlocked (void);
501#endif /* Use POSIX. */
502
503#ifdef __USE_MISC
504/* Faster version when locking is not necessary.
505
506 This function is not part of POSIX and therefore no official
507 cancellation point. But due to similarity with an POSIX interface
508 or due to the implementation it is a cancellation point and
509 therefore not marked with __THROW. */
510extern int fgetc_unlocked (FILE *__stream);
511#endif /* Use MISC. */
512
513
514/* Write a character to STREAM.
515
516 These functions are possible cancellation points and therefore not
517 marked with __THROW.
518
519 These functions is a possible cancellation point and therefore not
520 marked with __THROW. */
521extern int fputc (int __c, FILE *__stream);
522extern int putc (int __c, FILE *__stream);
523
524/* Write a character to stdout.
525
526 This function is a possible cancellation point and therefore not
527 marked with __THROW. */
528extern int putchar (int __c);
529
530#ifdef __USE_MISC
531/* Faster version when locking is not necessary.
532
533 This function is not part of POSIX and therefore no official
534 cancellation point. But due to similarity with an POSIX interface
535 or due to the implementation it is a cancellation point and
536 therefore not marked with __THROW. */
537extern int fputc_unlocked (int __c, FILE *__stream);
538#endif /* Use MISC. */
539
540#ifdef __USE_POSIX199506
541/* These are defined in POSIX.1:1996.
542
543 These functions are possible cancellation points and therefore not
544 marked with __THROW. */
545extern int putc_unlocked (int __c, FILE *__stream);
546extern int putchar_unlocked (int __c);
547#endif /* Use POSIX. */
548
549
550#if defined __USE_MISC \
551 || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
552/* Get a word (int) from STREAM. */
553extern int getw (FILE *__stream);
554
555/* Write a word (int) to STREAM. */
556extern int putw (int __w, FILE *__stream);
557#endif
558
559
560/* Get a newline-terminated string of finite length from STREAM.
561
562 This function is a possible cancellation point and therefore not
563 marked with __THROW. */
564extern char *fgets (char *__restrict __s, int __n, FILE *__restrict __stream)
565 __wur;
566
567#if __GLIBC_USE (DEPRECATED_GETS)
568/* Get a newline-terminated string from stdin, removing the newline.
569
570 This function is impossible to use safely. It has been officially
571 removed from ISO C11 and ISO C++14, and we have also removed it
572 from the _GNU_SOURCE feature list. It remains available when
573 explicitly using an old ISO C, Unix, or POSIX standard.
574
575 This function is a possible cancellation point and therefore not
576 marked with __THROW. */
577extern char *gets (char *__s) __wur __attribute_deprecated__;
578#endif
579
580#ifdef __USE_GNU
581/* This function does the same as `fgets' but does not lock the stream.
582
583 This function is not part of POSIX and therefore no official
584 cancellation point. But due to similarity with an POSIX interface
585 or due to the implementation it is a cancellation point and
586 therefore not marked with __THROW. */
587extern char *fgets_unlocked (char *__restrict __s, int __n,
588 FILE *__restrict __stream) __wur;
589#endif
590
591
592#if defined __USE_XOPEN2K8 || __GLIBC_USE (LIB_EXT2)
593/* Read up to (and including) a DELIMITER from STREAM into *LINEPTR
594 (and null-terminate it). *LINEPTR is a pointer returned from malloc (or
595 NULL), pointing to *N characters of space. It is realloc'd as
596 necessary. Returns the number of characters read (not including the
597 null terminator), or -1 on error or EOF.
598
599 These functions are not part of POSIX and therefore no official
600 cancellation point. But due to similarity with an POSIX interface
601 or due to the implementation they are cancellation points and
602 therefore not marked with __THROW. */
603extern __ssize_t __getdelim (char **__restrict __lineptr,
604 size_t *__restrict __n, int __delimiter,
605 FILE *__restrict __stream) __wur;
606extern __ssize_t getdelim (char **__restrict __lineptr,
607 size_t *__restrict __n, int __delimiter,
608 FILE *__restrict __stream) __wur;
609
610/* Like `getdelim', but reads up to a newline.
611
612 This function is not part of POSIX and therefore no official
613 cancellation point. But due to similarity with an POSIX interface
614 or due to the implementation it is a cancellation point and
615 therefore not marked with __THROW. */
616extern __ssize_t getline (char **__restrict __lineptr,
617 size_t *__restrict __n,
618 FILE *__restrict __stream) __wur;
619#endif
620
621
622/* Write a string to STREAM.
623
624 This function is a possible cancellation point and therefore not
625 marked with __THROW. */
626extern int fputs (const char *__restrict __s, FILE *__restrict __stream);
627
628/* Write a string, followed by a newline, to stdout.
629
630 This function is a possible cancellation point and therefore not
631 marked with __THROW. */
632extern int puts (const char *__s);
633
634
635/* Push a character back onto the input buffer of STREAM.
636
637 This function is a possible cancellation point and therefore not
638 marked with __THROW. */
639extern int ungetc (int __c, FILE *__stream);
640
641
642/* Read chunks of generic data from STREAM.
643
644 This function is a possible cancellation point and therefore not
645 marked with __THROW. */
646extern size_t fread (void *__restrict __ptr, size_t __size,
647 size_t __n, FILE *__restrict __stream) __wur;
648/* Write chunks of generic data to STREAM.
649
650 This function is a possible cancellation point and therefore not
651 marked with __THROW. */
652extern size_t fwrite (const void *__restrict __ptr, size_t __size,
653 size_t __n, FILE *__restrict __s);
654
655#ifdef __USE_GNU
656/* This function does the same as `fputs' but does not lock the stream.
657
658 This function is not part of POSIX and therefore no official
659 cancellation point. But due to similarity with an POSIX interface
660 or due to the implementation it is a cancellation point and
661 therefore not marked with __THROW. */
662extern int fputs_unlocked (const char *__restrict __s,
663 FILE *__restrict __stream);
664#endif
665
666#ifdef __USE_MISC
667/* Faster versions when locking is not necessary.
668
669 These functions are not part of POSIX and therefore no official
670 cancellation point. But due to similarity with an POSIX interface
671 or due to the implementation they are cancellation points and
672 therefore not marked with __THROW. */
673extern size_t fread_unlocked (void *__restrict __ptr, size_t __size,
674 size_t __n, FILE *__restrict __stream) __wur;
675extern size_t fwrite_unlocked (const void *__restrict __ptr, size_t __size,
676 size_t __n, FILE *__restrict __stream);
677#endif
678
679
680/* Seek to a certain position on STREAM.
681
682 This function is a possible cancellation point and therefore not
683 marked with __THROW. */
684extern int fseek (FILE *__stream, long int __off, int __whence);
685/* Return the current position of STREAM.
686
687 This function is a possible cancellation point and therefore not
688 marked with __THROW. */
689extern long int ftell (FILE *__stream) __wur;
690/* Rewind to the beginning of STREAM.
691
692 This function is a possible cancellation point and therefore not
693 marked with __THROW. */
694extern void rewind (FILE *__stream);
695
696/* The Single Unix Specification, Version 2, specifies an alternative,
697 more adequate interface for the two functions above which deal with
698 file offset. `long int' is not the right type. These definitions
699 are originally defined in the Large File Support API. */
700
701#if defined __USE_LARGEFILE || defined __USE_XOPEN2K
702# ifndef __USE_FILE_OFFSET64
703/* Seek to a certain position on STREAM.
704
705 This function is a possible cancellation point and therefore not
706 marked with __THROW. */
707extern int fseeko (FILE *__stream, __off_t __off, int __whence);
708/* Return the current position of STREAM.
709
710 This function is a possible cancellation point and therefore not
711 marked with __THROW. */
712extern __off_t ftello (FILE *__stream) __wur;
713# else
714# ifdef __REDIRECT
715extern int __REDIRECT (fseeko,
716 (FILE *__stream, __off64_t __off, int __whence),
717 fseeko64);
718extern __off64_t __REDIRECT (ftello, (FILE *__stream), ftello64);
719# else
720# define fseeko fseeko64
721# define ftello ftello64
722# endif
723# endif
724#endif
725
726#ifndef __USE_FILE_OFFSET64
727/* Get STREAM's position.
728
729 This function is a possible cancellation point and therefore not
730 marked with __THROW. */
731extern int fgetpos (FILE *__restrict __stream, fpos_t *__restrict __pos);
732/* Set STREAM's position.
733
734 This function is a possible cancellation point and therefore not
735 marked with __THROW. */
736extern int fsetpos (FILE *__stream, const fpos_t *__pos);
737#else
738# ifdef __REDIRECT
739extern int __REDIRECT (fgetpos, (FILE *__restrict __stream,
740 fpos_t *__restrict __pos), fgetpos64);
741extern int __REDIRECT (fsetpos,
742 (FILE *__stream, const fpos_t *__pos), fsetpos64);
743# else
744# define fgetpos fgetpos64
745# define fsetpos fsetpos64
746# endif
747#endif
748
749#ifdef __USE_LARGEFILE64
750extern int fseeko64 (FILE *__stream, __off64_t __off, int __whence);
751extern __off64_t ftello64 (FILE *__stream) __wur;
752extern int fgetpos64 (FILE *__restrict __stream, fpos64_t *__restrict __pos);
753extern int fsetpos64 (FILE *__stream, const fpos64_t *__pos);
754#endif
755
756/* Clear the error and EOF indicators for STREAM. */
757extern void clearerr (FILE *__stream) __THROW;
758/* Return the EOF indicator for STREAM. */
759extern int feof (FILE *__stream) __THROW __wur;
760/* Return the error indicator for STREAM. */
761extern int ferror (FILE *__stream) __THROW __wur;
762
763#ifdef __USE_MISC
764/* Faster versions when locking is not required. */
765extern void clearerr_unlocked (FILE *__stream) __THROW;
766extern int feof_unlocked (FILE *__stream) __THROW __wur;
767extern int ferror_unlocked (FILE *__stream) __THROW __wur;
768#endif
769
770
771/* Print a message describing the meaning of the value of errno.
772
773 This function is a possible cancellation point and therefore not
774 marked with __THROW. */
775extern void perror (const char *__s);
776
777/* Provide the declarations for `sys_errlist' and `sys_nerr' if they
778 are available on this system. Even if available, these variables
779 should not be used directly. The `strerror' function provides
780 all the necessary functionality. */
781#include <bits/sys_errlist.h>
782
783
784#ifdef __USE_POSIX
785/* Return the system file descriptor for STREAM. */
786extern int fileno (FILE *__stream) __THROW __wur;
787#endif /* Use POSIX. */
788
789#ifdef __USE_MISC
790/* Faster version when locking is not required. */
791extern int fileno_unlocked (FILE *__stream) __THROW __wur;
792#endif
793
794
795#ifdef __USE_POSIX2
796/* Create a new stream connected to a pipe running the given command.
797
798 This function is a possible cancellation point and therefore not
799 marked with __THROW. */
800extern FILE *popen (const char *__command, const char *__modes) __wur;
801
802/* Close a stream opened by popen and return the status of its child.
803
804 This function is a possible cancellation point and therefore not
805 marked with __THROW. */
806extern int pclose (FILE *__stream);
807#endif
808
809
810#ifdef __USE_POSIX
811/* Return the name of the controlling terminal. */
812extern char *ctermid (char *__s) __THROW;
813#endif /* Use POSIX. */
814
815
816#if (defined __USE_XOPEN && !defined __USE_XOPEN2K) || defined __USE_GNU
817/* Return the name of the current user. */
818extern char *cuserid (char *__s);
819#endif /* Use X/Open, but not issue 6. */
820
821
822#ifdef __USE_GNU
823struct obstack; /* See <obstack.h>. */
824
825/* Write formatted output to an obstack. */
826extern int obstack_printf (struct obstack *__restrict __obstack,
827 const char *__restrict __format, ...)
828 __THROWNL __attribute__ ((__format__ (__printf__, 2, 3)));
829extern int obstack_vprintf (struct obstack *__restrict __obstack,
830 const char *__restrict __format,
831 __gnuc_va_list __args)
832 __THROWNL __attribute__ ((__format__ (__printf__, 2, 0)));
833#endif /* Use GNU. */
834
835
836#ifdef __USE_POSIX199506
837/* These are defined in POSIX.1:1996. */
838
839/* Acquire ownership of STREAM. */
840extern void flockfile (FILE *__stream) __THROW;
841
842/* Try to acquire ownership of STREAM but do not block if it is not
843 possible. */
844extern int ftrylockfile (FILE *__stream) __THROW __wur;
845
846/* Relinquish the ownership granted for STREAM. */
847extern void funlockfile (FILE *__stream) __THROW;
848#endif /* POSIX */
849
850#if defined __USE_XOPEN && !defined __USE_XOPEN2K && !defined __USE_GNU
851/* X/Open Issues 1-5 required getopt to be declared in this
852 header. It was removed in Issue 6. GNU follows Issue 6. */
853# include <bits/getopt_posix.h>
854#endif
855
856/* Slow-path routines used by the optimized inline functions in
857 bits/stdio.h. */
858extern int __uflow (FILE *);
859extern int __overflow (FILE *, int);
860
861/* If we are compiling with optimizing read this file. It contains
862 several optimizing inline functions and macros. */
863#ifdef __USE_EXTERN_INLINES
864# include <bits/stdio.h>
865#endif
866#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
867# include <bits/stdio2.h>
868#endif
869#ifdef __LDBL_COMPAT
870# include <bits/stdio-ldbl.h>
871#endif
872
873__END_DECLS
874
875#endif /* <stdio.h> included. */
libc/glibc-include/stdio_ext.h created+86
...@@ -0,0 +1,86 @@
1/* Functions to access FILE structure internals.
2 Copyright (C) 2000-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19/* This header contains the same definitions as the header of the same name
20 on Sun's Solaris OS. */
21
22#ifndef _STDIO_EXT_H
23#define _STDIO_EXT_H 1
24
25#include <stdio.h>
26
27enum
28{
29 /* Query current state of the locking status. */
30 FSETLOCKING_QUERY = 0,
31#define FSETLOCKING_QUERY FSETLOCKING_QUERY
32 /* The library protects all uses of the stream functions, except for
33 uses of the *_unlocked functions, by calls equivalent to flockfile(). */
34 FSETLOCKING_INTERNAL,
35#define FSETLOCKING_INTERNAL FSETLOCKING_INTERNAL
36 /* The user will take care of locking. */
37 FSETLOCKING_BYCALLER
38#define FSETLOCKING_BYCALLER FSETLOCKING_BYCALLER
39};
40
41
42__BEGIN_DECLS
43
44/* Return the size of the buffer of FP in bytes currently in use by
45 the given stream. */
46extern size_t __fbufsize (FILE *__fp) __THROW;
47
48
49/* Return non-zero value iff the stream FP is opened readonly, or if the
50 last operation on the stream was a read operation. */
51extern int __freading (FILE *__fp) __THROW;
52
53/* Return non-zero value iff the stream FP is opened write-only or
54 append-only, or if the last operation on the stream was a write
55 operation. */
56extern int __fwriting (FILE *__fp) __THROW;
57
58
59/* Return non-zero value iff stream FP is not opened write-only or
60 append-only. */
61extern int __freadable (FILE *__fp) __THROW;
62
63/* Return non-zero value iff stream FP is not opened read-only. */
64extern int __fwritable (FILE *__fp) __THROW;
65
66
67/* Return non-zero value iff the stream FP is line-buffered. */
68extern int __flbf (FILE *__fp) __THROW;
69
70
71/* Discard all pending buffered I/O on the stream FP. */
72extern void __fpurge (FILE *__fp) __THROW;
73
74/* Return amount of output in bytes pending on a stream FP. */
75extern size_t __fpending (FILE *__fp) __THROW;
76
77/* Flush all line-buffered files. */
78extern void _flushlbf (void);
79
80
81/* Set locking status of stream FP to TYPE. */
82extern int __fsetlocking (FILE *__fp, int __type) __THROW;
83
84__END_DECLS
85
86#endif /* stdio_ext.h */
libc/glibc-include/stdlib.h created+1022
...@@ -0,0 +1,1022 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/*
19 * ISO C99 Standard: 7.20 General utilities <stdlib.h>
20 */
21
22#ifndef _STDLIB_H
23
24#define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION
25#include <bits/libc-header-start.h>
26
27/* Get size_t, wchar_t and NULL from <stddef.h>. */
28#define __need_size_t
29#define __need_wchar_t
30#define __need_NULL
31#include <stddef.h>
32
33__BEGIN_DECLS
34
35#define _STDLIB_H 1
36
37#if (defined __USE_XOPEN || defined __USE_XOPEN2K8) && !defined _SYS_WAIT_H
38/* XPG requires a few symbols from <sys/wait.h> being defined. */
39# include <bits/waitflags.h>
40# include <bits/waitstatus.h>
41
42/* Define the macros <sys/wait.h> also would define this way. */
43# define WEXITSTATUS(status) __WEXITSTATUS (status)
44# define WTERMSIG(status) __WTERMSIG (status)
45# define WSTOPSIG(status) __WSTOPSIG (status)
46# define WIFEXITED(status) __WIFEXITED (status)
47# define WIFSIGNALED(status) __WIFSIGNALED (status)
48# define WIFSTOPPED(status) __WIFSTOPPED (status)
49# ifdef __WIFCONTINUED
50# define WIFCONTINUED(status) __WIFCONTINUED (status)
51# endif
52#endif /* X/Open or XPG7 and <sys/wait.h> not included. */
53
54/* _FloatN API tests for enablement. */
55#include <bits/floatn.h>
56
57/* Returned by `div'. */
58typedef struct
59 {
60 int quot; /* Quotient. */
61 int rem; /* Remainder. */
62 } div_t;
63
64/* Returned by `ldiv'. */
65#ifndef __ldiv_t_defined
66typedef struct
67 {
68 long int quot; /* Quotient. */
69 long int rem; /* Remainder. */
70 } ldiv_t;
71# define __ldiv_t_defined 1
72#endif
73
74#if defined __USE_ISOC99 && !defined __lldiv_t_defined
75/* Returned by `lldiv'. */
76__extension__ typedef struct
77 {
78 long long int quot; /* Quotient. */
79 long long int rem; /* Remainder. */
80 } lldiv_t;
81# define __lldiv_t_defined 1
82#endif
83
84
85/* The largest number rand will return (same as INT_MAX). */
86#define RAND_MAX 2147483647
87
88
89/* We define these the same for all machines.
90 Changes from this to the outside world should be done in `_exit'. */
91#define EXIT_FAILURE 1 /* Failing exit status. */
92#define EXIT_SUCCESS 0 /* Successful exit status. */
93
94
95/* Maximum length of a multibyte character in the current locale. */
96#define MB_CUR_MAX (__ctype_get_mb_cur_max ())
97extern size_t __ctype_get_mb_cur_max (void) __THROW __wur;
98
99
100/* Convert a string to a floating-point number. */
101extern double atof (const char *__nptr)
102 __THROW __attribute_pure__ __nonnull ((1)) __wur;
103/* Convert a string to an integer. */
104extern int atoi (const char *__nptr)
105 __THROW __attribute_pure__ __nonnull ((1)) __wur;
106/* Convert a string to a long integer. */
107extern long int atol (const char *__nptr)
108 __THROW __attribute_pure__ __nonnull ((1)) __wur;
109
110#ifdef __USE_ISOC99
111/* Convert a string to a long long integer. */
112__extension__ extern long long int atoll (const char *__nptr)
113 __THROW __attribute_pure__ __nonnull ((1)) __wur;
114#endif
115
116/* Convert a string to a floating-point number. */
117extern double strtod (const char *__restrict __nptr,
118 char **__restrict __endptr)
119 __THROW __nonnull ((1));
120
121#ifdef __USE_ISOC99
122/* Likewise for `float' and `long double' sizes of floating-point numbers. */
123extern float strtof (const char *__restrict __nptr,
124 char **__restrict __endptr) __THROW __nonnull ((1));
125
126extern long double strtold (const char *__restrict __nptr,
127 char **__restrict __endptr)
128 __THROW __nonnull ((1));
129#endif
130
131/* Likewise for '_FloatN' and '_FloatNx'. */
132
133#if __HAVE_FLOAT16 && __GLIBC_USE (IEC_60559_TYPES_EXT)
134extern _Float16 strtof16 (const char *__restrict __nptr,
135 char **__restrict __endptr)
136 __THROW __nonnull ((1));
137#endif
138
139#if __HAVE_FLOAT32 && __GLIBC_USE (IEC_60559_TYPES_EXT)
140extern _Float32 strtof32 (const char *__restrict __nptr,
141 char **__restrict __endptr)
142 __THROW __nonnull ((1));
143#endif
144
145#if __HAVE_FLOAT64 && __GLIBC_USE (IEC_60559_TYPES_EXT)
146extern _Float64 strtof64 (const char *__restrict __nptr,
147 char **__restrict __endptr)
148 __THROW __nonnull ((1));
149#endif
150
151#if __HAVE_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT)
152extern _Float128 strtof128 (const char *__restrict __nptr,
153 char **__restrict __endptr)
154 __THROW __nonnull ((1));
155#endif
156
157#if __HAVE_FLOAT32X && __GLIBC_USE (IEC_60559_TYPES_EXT)
158extern _Float32x strtof32x (const char *__restrict __nptr,
159 char **__restrict __endptr)
160 __THROW __nonnull ((1));
161#endif
162
163#if __HAVE_FLOAT64X && __GLIBC_USE (IEC_60559_TYPES_EXT)
164extern _Float64x strtof64x (const char *__restrict __nptr,
165 char **__restrict __endptr)
166 __THROW __nonnull ((1));
167#endif
168
169#if __HAVE_FLOAT128X && __GLIBC_USE (IEC_60559_TYPES_EXT)
170extern _Float128x strtof128x (const char *__restrict __nptr,
171 char **__restrict __endptr)
172 __THROW __nonnull ((1));
173#endif
174
175/* Convert a string to a long integer. */
176extern long int strtol (const char *__restrict __nptr,
177 char **__restrict __endptr, int __base)
178 __THROW __nonnull ((1));
179/* Convert a string to an unsigned long integer. */
180extern unsigned long int strtoul (const char *__restrict __nptr,
181 char **__restrict __endptr, int __base)
182 __THROW __nonnull ((1));
183
184#ifdef __USE_MISC
185/* Convert a string to a quadword integer. */
186__extension__
187extern long long int strtoq (const char *__restrict __nptr,
188 char **__restrict __endptr, int __base)
189 __THROW __nonnull ((1));
190/* Convert a string to an unsigned quadword integer. */
191__extension__
192extern unsigned long long int strtouq (const char *__restrict __nptr,
193 char **__restrict __endptr, int __base)
194 __THROW __nonnull ((1));
195#endif /* Use misc. */
196
197#ifdef __USE_ISOC99
198/* Convert a string to a quadword integer. */
199__extension__
200extern long long int strtoll (const char *__restrict __nptr,
201 char **__restrict __endptr, int __base)
202 __THROW __nonnull ((1));
203/* Convert a string to an unsigned quadword integer. */
204__extension__
205extern unsigned long long int strtoull (const char *__restrict __nptr,
206 char **__restrict __endptr, int __base)
207 __THROW __nonnull ((1));
208#endif /* ISO C99 or use MISC. */
209
210/* Convert a floating-point number to a string. */
211#if __GLIBC_USE (IEC_60559_BFP_EXT)
212extern int strfromd (char *__dest, size_t __size, const char *__format,
213 double __f)
214 __THROW __nonnull ((3));
215
216extern int strfromf (char *__dest, size_t __size, const char *__format,
217 float __f)
218 __THROW __nonnull ((3));
219
220extern int strfroml (char *__dest, size_t __size, const char *__format,
221 long double __f)
222 __THROW __nonnull ((3));
223#endif
224
225#if __HAVE_FLOAT16 && __GLIBC_USE (IEC_60559_TYPES_EXT)
226extern int strfromf16 (char *__dest, size_t __size, const char * __format,
227 _Float16 __f)
228 __THROW __nonnull ((3));
229#endif
230
231#if __HAVE_FLOAT32 && __GLIBC_USE (IEC_60559_TYPES_EXT)
232extern int strfromf32 (char *__dest, size_t __size, const char * __format,
233 _Float32 __f)
234 __THROW __nonnull ((3));
235#endif
236
237#if __HAVE_FLOAT64 && __GLIBC_USE (IEC_60559_TYPES_EXT)
238extern int strfromf64 (char *__dest, size_t __size, const char * __format,
239 _Float64 __f)
240 __THROW __nonnull ((3));
241#endif
242
243#if __HAVE_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT)
244extern int strfromf128 (char *__dest, size_t __size, const char * __format,
245 _Float128 __f)
246 __THROW __nonnull ((3));
247#endif
248
249#if __HAVE_FLOAT32X && __GLIBC_USE (IEC_60559_TYPES_EXT)
250extern int strfromf32x (char *__dest, size_t __size, const char * __format,
251 _Float32x __f)
252 __THROW __nonnull ((3));
253#endif
254
255#if __HAVE_FLOAT64X && __GLIBC_USE (IEC_60559_TYPES_EXT)
256extern int strfromf64x (char *__dest, size_t __size, const char * __format,
257 _Float64x __f)
258 __THROW __nonnull ((3));
259#endif
260
261#if __HAVE_FLOAT128X && __GLIBC_USE (IEC_60559_TYPES_EXT)
262extern int strfromf128x (char *__dest, size_t __size, const char * __format,
263 _Float128x __f)
264 __THROW __nonnull ((3));
265#endif
266
267
268#ifdef __USE_GNU
269/* Parallel versions of the functions above which take the locale to
270 use as an additional parameter. These are GNU extensions inspired
271 by the POSIX.1-2008 extended locale API. */
272# include <bits/types/locale_t.h>
273
274extern long int strtol_l (const char *__restrict __nptr,
275 char **__restrict __endptr, int __base,
276 locale_t __loc) __THROW __nonnull ((1, 4));
277
278extern unsigned long int strtoul_l (const char *__restrict __nptr,
279 char **__restrict __endptr,
280 int __base, locale_t __loc)
281 __THROW __nonnull ((1, 4));
282
283__extension__
284extern long long int strtoll_l (const char *__restrict __nptr,
285 char **__restrict __endptr, int __base,
286 locale_t __loc)
287 __THROW __nonnull ((1, 4));
288
289__extension__
290extern unsigned long long int strtoull_l (const char *__restrict __nptr,
291 char **__restrict __endptr,
292 int __base, locale_t __loc)
293 __THROW __nonnull ((1, 4));
294
295extern double strtod_l (const char *__restrict __nptr,
296 char **__restrict __endptr, locale_t __loc)
297 __THROW __nonnull ((1, 3));
298
299extern float strtof_l (const char *__restrict __nptr,
300 char **__restrict __endptr, locale_t __loc)
301 __THROW __nonnull ((1, 3));
302
303extern long double strtold_l (const char *__restrict __nptr,
304 char **__restrict __endptr,
305 locale_t __loc)
306 __THROW __nonnull ((1, 3));
307
308# if __HAVE_FLOAT16
309extern _Float16 strtof16_l (const char *__restrict __nptr,
310 char **__restrict __endptr,
311 locale_t __loc)
312 __THROW __nonnull ((1, 3));
313# endif
314
315# if __HAVE_FLOAT32
316extern _Float32 strtof32_l (const char *__restrict __nptr,
317 char **__restrict __endptr,
318 locale_t __loc)
319 __THROW __nonnull ((1, 3));
320# endif
321
322# if __HAVE_FLOAT64
323extern _Float64 strtof64_l (const char *__restrict __nptr,
324 char **__restrict __endptr,
325 locale_t __loc)
326 __THROW __nonnull ((1, 3));
327# endif
328
329# if __HAVE_FLOAT128
330extern _Float128 strtof128_l (const char *__restrict __nptr,
331 char **__restrict __endptr,
332 locale_t __loc)
333 __THROW __nonnull ((1, 3));
334# endif
335
336# if __HAVE_FLOAT32X
337extern _Float32x strtof32x_l (const char *__restrict __nptr,
338 char **__restrict __endptr,
339 locale_t __loc)
340 __THROW __nonnull ((1, 3));
341# endif
342
343# if __HAVE_FLOAT64X
344extern _Float64x strtof64x_l (const char *__restrict __nptr,
345 char **__restrict __endptr,
346 locale_t __loc)
347 __THROW __nonnull ((1, 3));
348# endif
349
350# if __HAVE_FLOAT128X
351extern _Float128x strtof128x_l (const char *__restrict __nptr,
352 char **__restrict __endptr,
353 locale_t __loc)
354 __THROW __nonnull ((1, 3));
355# endif
356#endif /* GNU */
357
358
359#ifdef __USE_EXTERN_INLINES
360__extern_inline int
361__NTH (atoi (const char *__nptr))
362{
363 return (int) strtol (__nptr, (char **) NULL, 10);
364}
365__extern_inline long int
366__NTH (atol (const char *__nptr))
367{
368 return strtol (__nptr, (char **) NULL, 10);
369}
370
371# ifdef __USE_ISOC99
372__extension__ __extern_inline long long int
373__NTH (atoll (const char *__nptr))
374{
375 return strtoll (__nptr, (char **) NULL, 10);
376}
377# endif
378#endif /* Optimizing and Inlining. */
379
380
381#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
382/* Convert N to base 64 using the digits "./0-9A-Za-z", least-significant
383 digit first. Returns a pointer to static storage overwritten by the
384 next call. */
385extern char *l64a (long int __n) __THROW __wur;
386
387/* Read a number from a string S in base 64 as above. */
388extern long int a64l (const char *__s)
389 __THROW __attribute_pure__ __nonnull ((1)) __wur;
390
391#endif /* Use misc || extended X/Open. */
392
393#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
394# include <sys/types.h> /* we need int32_t... */
395
396/* These are the functions that actually do things. The `random', `srandom',
397 `initstate' and `setstate' functions are those from BSD Unices.
398 The `rand' and `srand' functions are required by the ANSI standard.
399 We provide both interfaces to the same random number generator. */
400/* Return a random long integer between 0 and RAND_MAX inclusive. */
401extern long int random (void) __THROW;
402
403/* Seed the random number generator with the given number. */
404extern void srandom (unsigned int __seed) __THROW;
405
406/* Initialize the random number generator to use state buffer STATEBUF,
407 of length STATELEN, and seed it with SEED. Optimal lengths are 8, 16,
408 32, 64, 128 and 256, the bigger the better; values less than 8 will
409 cause an error and values greater than 256 will be rounded down. */
410extern char *initstate (unsigned int __seed, char *__statebuf,
411 size_t __statelen) __THROW __nonnull ((2));
412
413/* Switch the random number generator to state buffer STATEBUF,
414 which should have been previously initialized by `initstate'. */
415extern char *setstate (char *__statebuf) __THROW __nonnull ((1));
416
417
418# ifdef __USE_MISC
419/* Reentrant versions of the `random' family of functions.
420 These functions all use the following data structure to contain
421 state, rather than global state variables. */
422
423struct random_data
424 {
425 int32_t *fptr; /* Front pointer. */
426 int32_t *rptr; /* Rear pointer. */
427 int32_t *state; /* Array of state values. */
428 int rand_type; /* Type of random number generator. */
429 int rand_deg; /* Degree of random number generator. */
430 int rand_sep; /* Distance between front and rear. */
431 int32_t *end_ptr; /* Pointer behind state table. */
432 };
433
434extern int random_r (struct random_data *__restrict __buf,
435 int32_t *__restrict __result) __THROW __nonnull ((1, 2));
436
437extern int srandom_r (unsigned int __seed, struct random_data *__buf)
438 __THROW __nonnull ((2));
439
440extern int initstate_r (unsigned int __seed, char *__restrict __statebuf,
441 size_t __statelen,
442 struct random_data *__restrict __buf)
443 __THROW __nonnull ((2, 4));
444
445extern int setstate_r (char *__restrict __statebuf,
446 struct random_data *__restrict __buf)
447 __THROW __nonnull ((1, 2));
448# endif /* Use misc. */
449#endif /* Use extended X/Open || misc. */
450
451
452/* Return a random integer between 0 and RAND_MAX inclusive. */
453extern int rand (void) __THROW;
454/* Seed the random number generator with the given number. */
455extern void srand (unsigned int __seed) __THROW;
456
457#ifdef __USE_POSIX199506
458/* Reentrant interface according to POSIX.1. */
459extern int rand_r (unsigned int *__seed) __THROW;
460#endif
461
462
463#if defined __USE_MISC || defined __USE_XOPEN
464/* System V style 48-bit random number generator functions. */
465
466/* Return non-negative, double-precision floating-point value in [0.0,1.0). */
467extern double drand48 (void) __THROW;
468extern double erand48 (unsigned short int __xsubi[3]) __THROW __nonnull ((1));
469
470/* Return non-negative, long integer in [0,2^31). */
471extern long int lrand48 (void) __THROW;
472extern long int nrand48 (unsigned short int __xsubi[3])
473 __THROW __nonnull ((1));
474
475/* Return signed, long integers in [-2^31,2^31). */
476extern long int mrand48 (void) __THROW;
477extern long int jrand48 (unsigned short int __xsubi[3])
478 __THROW __nonnull ((1));
479
480/* Seed random number generator. */
481extern void srand48 (long int __seedval) __THROW;
482extern unsigned short int *seed48 (unsigned short int __seed16v[3])
483 __THROW __nonnull ((1));
484extern void lcong48 (unsigned short int __param[7]) __THROW __nonnull ((1));
485
486# ifdef __USE_MISC
487/* Data structure for communication with thread safe versions. This
488 type is to be regarded as opaque. It's only exported because users
489 have to allocate objects of this type. */
490struct drand48_data
491 {
492 unsigned short int __x[3]; /* Current state. */
493 unsigned short int __old_x[3]; /* Old state. */
494 unsigned short int __c; /* Additive const. in congruential formula. */
495 unsigned short int __init; /* Flag for initializing. */
496 __extension__ unsigned long long int __a; /* Factor in congruential
497 formula. */
498 };
499
500/* Return non-negative, double-precision floating-point value in [0.0,1.0). */
501extern int drand48_r (struct drand48_data *__restrict __buffer,
502 double *__restrict __result) __THROW __nonnull ((1, 2));
503extern int erand48_r (unsigned short int __xsubi[3],
504 struct drand48_data *__restrict __buffer,
505 double *__restrict __result) __THROW __nonnull ((1, 2));
506
507/* Return non-negative, long integer in [0,2^31). */
508extern int lrand48_r (struct drand48_data *__restrict __buffer,
509 long int *__restrict __result)
510 __THROW __nonnull ((1, 2));
511extern int nrand48_r (unsigned short int __xsubi[3],
512 struct drand48_data *__restrict __buffer,
513 long int *__restrict __result)
514 __THROW __nonnull ((1, 2));
515
516/* Return signed, long integers in [-2^31,2^31). */
517extern int mrand48_r (struct drand48_data *__restrict __buffer,
518 long int *__restrict __result)
519 __THROW __nonnull ((1, 2));
520extern int jrand48_r (unsigned short int __xsubi[3],
521 struct drand48_data *__restrict __buffer,
522 long int *__restrict __result)
523 __THROW __nonnull ((1, 2));
524
525/* Seed random number generator. */
526extern int srand48_r (long int __seedval, struct drand48_data *__buffer)
527 __THROW __nonnull ((2));
528
529extern int seed48_r (unsigned short int __seed16v[3],
530 struct drand48_data *__buffer) __THROW __nonnull ((1, 2));
531
532extern int lcong48_r (unsigned short int __param[7],
533 struct drand48_data *__buffer)
534 __THROW __nonnull ((1, 2));
535# endif /* Use misc. */
536#endif /* Use misc or X/Open. */
537
538/* Allocate SIZE bytes of memory. */
539extern void *malloc (size_t __size) __THROW __attribute_malloc__ __wur;
540/* Allocate NMEMB elements of SIZE bytes each, all initialized to 0. */
541extern void *calloc (size_t __nmemb, size_t __size)
542 __THROW __attribute_malloc__ __wur;
543
544/* Re-allocate the previously allocated block
545 in PTR, making the new block SIZE bytes long. */
546/* __attribute_malloc__ is not used, because if realloc returns
547 the same pointer that was passed to it, aliasing needs to be allowed
548 between objects pointed by the old and new pointers. */
549extern void *realloc (void *__ptr, size_t __size)
550 __THROW __attribute_warn_unused_result__;
551
552#ifdef __USE_MISC
553/* Re-allocate the previously allocated block in PTR, making the new
554 block large enough for NMEMB elements of SIZE bytes each. */
555/* __attribute_malloc__ is not used, because if reallocarray returns
556 the same pointer that was passed to it, aliasing needs to be allowed
557 between objects pointed by the old and new pointers. */
558extern void *reallocarray (void *__ptr, size_t __nmemb, size_t __size)
559 __THROW __attribute_warn_unused_result__;
560#endif
561
562/* Free a block allocated by `malloc', `realloc' or `calloc'. */
563extern void free (void *__ptr) __THROW;
564
565#ifdef __USE_MISC
566# include <alloca.h>
567#endif /* Use misc. */
568
569#if (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K) \
570 || defined __USE_MISC
571/* Allocate SIZE bytes on a page boundary. The storage cannot be freed. */
572extern void *valloc (size_t __size) __THROW __attribute_malloc__ __wur;
573#endif
574
575#ifdef __USE_XOPEN2K
576/* Allocate memory of SIZE bytes with an alignment of ALIGNMENT. */
577extern int posix_memalign (void **__memptr, size_t __alignment, size_t __size)
578 __THROW __nonnull ((1)) __wur;
579#endif
580
581#ifdef __USE_ISOC11
582/* ISO C variant of aligned allocation. */
583extern void *aligned_alloc (size_t __alignment, size_t __size)
584 __THROW __attribute_malloc__ __attribute_alloc_size__ ((2)) __wur;
585#endif
586
587/* Abort execution and generate a core-dump. */
588extern void abort (void) __THROW __attribute__ ((__noreturn__));
589
590
591/* Register a function to be called when `exit' is called. */
592extern int atexit (void (*__func) (void)) __THROW __nonnull ((1));
593
594#if defined __USE_ISOC11 || defined __USE_ISOCXX11
595/* Register a function to be called when `quick_exit' is called. */
596# ifdef __cplusplus
597extern "C++" int at_quick_exit (void (*__func) (void))
598 __THROW __asm ("at_quick_exit") __nonnull ((1));
599# else
600extern int at_quick_exit (void (*__func) (void)) __THROW __nonnull ((1));
601# endif
602#endif
603
604#ifdef __USE_MISC
605/* Register a function to be called with the status
606 given to `exit' and the given argument. */
607extern int on_exit (void (*__func) (int __status, void *__arg), void *__arg)
608 __THROW __nonnull ((1));
609#endif
610
611/* Call all functions registered with `atexit' and `on_exit',
612 in the reverse of the order in which they were registered,
613 perform stdio cleanup, and terminate program execution with STATUS. */
614extern void exit (int __status) __THROW __attribute__ ((__noreturn__));
615
616#if defined __USE_ISOC11 || defined __USE_ISOCXX11
617/* Call all functions registered with `at_quick_exit' in the reverse
618 of the order in which they were registered and terminate program
619 execution with STATUS. */
620extern void quick_exit (int __status) __THROW __attribute__ ((__noreturn__));
621#endif
622
623#ifdef __USE_ISOC99
624/* Terminate the program with STATUS without calling any of the
625 functions registered with `atexit' or `on_exit'. */
626extern void _Exit (int __status) __THROW __attribute__ ((__noreturn__));
627#endif
628
629
630/* Return the value of envariable NAME, or NULL if it doesn't exist. */
631extern char *getenv (const char *__name) __THROW __nonnull ((1)) __wur;
632
633#ifdef __USE_GNU
634/* This function is similar to the above but returns NULL if the
635 programs is running with SUID or SGID enabled. */
636extern char *secure_getenv (const char *__name)
637 __THROW __nonnull ((1)) __wur;
638#endif
639
640#if defined __USE_MISC || defined __USE_XOPEN
641/* The SVID says this is in <stdio.h>, but this seems a better place. */
642/* Put STRING, which is of the form "NAME=VALUE", in the environment.
643 If there is no `=', remove NAME from the environment. */
644extern int putenv (char *__string) __THROW __nonnull ((1));
645#endif
646
647#ifdef __USE_XOPEN2K
648/* Set NAME to VALUE in the environment.
649 If REPLACE is nonzero, overwrite an existing value. */
650extern int setenv (const char *__name, const char *__value, int __replace)
651 __THROW __nonnull ((2));
652
653/* Remove the variable NAME from the environment. */
654extern int unsetenv (const char *__name) __THROW __nonnull ((1));
655#endif
656
657#ifdef __USE_MISC
658/* The `clearenv' was planned to be added to POSIX.1 but probably
659 never made it. Nevertheless the POSIX.9 standard (POSIX bindings
660 for Fortran 77) requires this function. */
661extern int clearenv (void) __THROW;
662#endif
663
664
665#if defined __USE_MISC \
666 || (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8)
667/* Generate a unique temporary file name from TEMPLATE.
668 The last six characters of TEMPLATE must be "XXXXXX";
669 they are replaced with a string that makes the file name unique.
670 Always returns TEMPLATE, it's either a temporary file name or a null
671 string if it cannot get a unique file name. */
672extern char *mktemp (char *__template) __THROW __nonnull ((1));
673#endif
674
675#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
676/* Generate a unique temporary file name from TEMPLATE.
677 The last six characters of TEMPLATE must be "XXXXXX";
678 they are replaced with a string that makes the filename unique.
679 Returns a file descriptor open on the file for reading and writing,
680 or -1 if it cannot create a uniquely-named file.
681
682 This function is a possible cancellation point and therefore not
683 marked with __THROW. */
684# ifndef __USE_FILE_OFFSET64
685extern int mkstemp (char *__template) __nonnull ((1)) __wur;
686# else
687# ifdef __REDIRECT
688extern int __REDIRECT (mkstemp, (char *__template), mkstemp64)
689 __nonnull ((1)) __wur;
690# else
691# define mkstemp mkstemp64
692# endif
693# endif
694# ifdef __USE_LARGEFILE64
695extern int mkstemp64 (char *__template) __nonnull ((1)) __wur;
696# endif
697#endif
698
699#ifdef __USE_MISC
700/* Similar to mkstemp, but the template can have a suffix after the
701 XXXXXX. The length of the suffix is specified in the second
702 parameter.
703
704 This function is a possible cancellation point and therefore not
705 marked with __THROW. */
706# ifndef __USE_FILE_OFFSET64
707extern int mkstemps (char *__template, int __suffixlen) __nonnull ((1)) __wur;
708# else
709# ifdef __REDIRECT
710extern int __REDIRECT (mkstemps, (char *__template, int __suffixlen),
711 mkstemps64) __nonnull ((1)) __wur;
712# else
713# define mkstemps mkstemps64
714# endif
715# endif
716# ifdef __USE_LARGEFILE64
717extern int mkstemps64 (char *__template, int __suffixlen)
718 __nonnull ((1)) __wur;
719# endif
720#endif
721
722#ifdef __USE_XOPEN2K8
723/* Create a unique temporary directory from TEMPLATE.
724 The last six characters of TEMPLATE must be "XXXXXX";
725 they are replaced with a string that makes the directory name unique.
726 Returns TEMPLATE, or a null pointer if it cannot get a unique name.
727 The directory is created mode 700. */
728extern char *mkdtemp (char *__template) __THROW __nonnull ((1)) __wur;
729#endif
730
731#ifdef __USE_GNU
732/* Generate a unique temporary file name from TEMPLATE similar to
733 mkstemp. But allow the caller to pass additional flags which are
734 used in the open call to create the file..
735
736 This function is a possible cancellation point and therefore not
737 marked with __THROW. */
738# ifndef __USE_FILE_OFFSET64
739extern int mkostemp (char *__template, int __flags) __nonnull ((1)) __wur;
740# else
741# ifdef __REDIRECT
742extern int __REDIRECT (mkostemp, (char *__template, int __flags), mkostemp64)
743 __nonnull ((1)) __wur;
744# else
745# define mkostemp mkostemp64
746# endif
747# endif
748# ifdef __USE_LARGEFILE64
749extern int mkostemp64 (char *__template, int __flags) __nonnull ((1)) __wur;
750# endif
751
752/* Similar to mkostemp, but the template can have a suffix after the
753 XXXXXX. The length of the suffix is specified in the second
754 parameter.
755
756 This function is a possible cancellation point and therefore not
757 marked with __THROW. */
758# ifndef __USE_FILE_OFFSET64
759extern int mkostemps (char *__template, int __suffixlen, int __flags)
760 __nonnull ((1)) __wur;
761# else
762# ifdef __REDIRECT
763extern int __REDIRECT (mkostemps, (char *__template, int __suffixlen,
764 int __flags), mkostemps64)
765 __nonnull ((1)) __wur;
766# else
767# define mkostemps mkostemps64
768# endif
769# endif
770# ifdef __USE_LARGEFILE64
771extern int mkostemps64 (char *__template, int __suffixlen, int __flags)
772 __nonnull ((1)) __wur;
773# endif
774#endif
775
776
777/* Execute the given line as a shell command.
778
779 This function is a cancellation point and therefore not marked with
780 __THROW. */
781extern int system (const char *__command) __wur;
782
783
784#ifdef __USE_GNU
785/* Return a malloc'd string containing the canonical absolute name of the
786 existing named file. */
787extern char *canonicalize_file_name (const char *__name)
788 __THROW __nonnull ((1)) __wur;
789#endif
790
791#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
792/* Return the canonical absolute name of file NAME. If RESOLVED is
793 null, the result is malloc'd; otherwise, if the canonical name is
794 PATH_MAX chars or more, returns null with `errno' set to
795 ENAMETOOLONG; if the name fits in fewer than PATH_MAX chars,
796 returns the name in RESOLVED. */
797extern char *realpath (const char *__restrict __name,
798 char *__restrict __resolved) __THROW __wur;
799#endif
800
801
802/* Shorthand for type of comparison functions. */
803#ifndef __COMPAR_FN_T
804# define __COMPAR_FN_T
805typedef int (*__compar_fn_t) (const void *, const void *);
806
807# ifdef __USE_GNU
808typedef __compar_fn_t comparison_fn_t;
809# endif
810#endif
811#ifdef __USE_GNU
812typedef int (*__compar_d_fn_t) (const void *, const void *, void *);
813#endif
814
815/* Do a binary search for KEY in BASE, which consists of NMEMB elements
816 of SIZE bytes each, using COMPAR to perform the comparisons. */
817extern void *bsearch (const void *__key, const void *__base,
818 size_t __nmemb, size_t __size, __compar_fn_t __compar)
819 __nonnull ((1, 2, 5)) __wur;
820
821#ifdef __USE_EXTERN_INLINES
822# include <bits/stdlib-bsearch.h>
823#endif
824
825/* Sort NMEMB elements of BASE, of SIZE bytes each,
826 using COMPAR to perform the comparisons. */
827extern void qsort (void *__base, size_t __nmemb, size_t __size,
828 __compar_fn_t __compar) __nonnull ((1, 4));
829#ifdef __USE_GNU
830extern void qsort_r (void *__base, size_t __nmemb, size_t __size,
831 __compar_d_fn_t __compar, void *__arg)
832 __nonnull ((1, 4));
833#endif
834
835
836/* Return the absolute value of X. */
837extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
838extern long int labs (long int __x) __THROW __attribute__ ((__const__)) __wur;
839
840#ifdef __USE_ISOC99
841__extension__ extern long long int llabs (long long int __x)
842 __THROW __attribute__ ((__const__)) __wur;
843#endif
844
845
846/* Return the `div_t', `ldiv_t' or `lldiv_t' representation
847 of the value of NUMER over DENOM. */
848/* GCC may have built-ins for these someday. */
849extern div_t div (int __numer, int __denom)
850 __THROW __attribute__ ((__const__)) __wur;
851extern ldiv_t ldiv (long int __numer, long int __denom)
852 __THROW __attribute__ ((__const__)) __wur;
853
854#ifdef __USE_ISOC99
855__extension__ extern lldiv_t lldiv (long long int __numer,
856 long long int __denom)
857 __THROW __attribute__ ((__const__)) __wur;
858#endif
859
860
861#if (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8) \
862 || defined __USE_MISC
863/* Convert floating point numbers to strings. The returned values are
864 valid only until another call to the same function. */
865
866/* Convert VALUE to a string with NDIGIT digits and return a pointer to
867 this. Set *DECPT with the position of the decimal character and *SIGN
868 with the sign of the number. */
869extern char *ecvt (double __value, int __ndigit, int *__restrict __decpt,
870 int *__restrict __sign) __THROW __nonnull ((3, 4)) __wur;
871
872/* Convert VALUE to a string rounded to NDIGIT decimal digits. Set *DECPT
873 with the position of the decimal character and *SIGN with the sign of
874 the number. */
875extern char *fcvt (double __value, int __ndigit, int *__restrict __decpt,
876 int *__restrict __sign) __THROW __nonnull ((3, 4)) __wur;
877
878/* If possible convert VALUE to a string with NDIGIT significant digits.
879 Otherwise use exponential representation. The resulting string will
880 be written to BUF. */
881extern char *gcvt (double __value, int __ndigit, char *__buf)
882 __THROW __nonnull ((3)) __wur;
883#endif
884
885#ifdef __USE_MISC
886/* Long double versions of above functions. */
887extern char *qecvt (long double __value, int __ndigit,
888 int *__restrict __decpt, int *__restrict __sign)
889 __THROW __nonnull ((3, 4)) __wur;
890extern char *qfcvt (long double __value, int __ndigit,
891 int *__restrict __decpt, int *__restrict __sign)
892 __THROW __nonnull ((3, 4)) __wur;
893extern char *qgcvt (long double __value, int __ndigit, char *__buf)
894 __THROW __nonnull ((3)) __wur;
895
896
897/* Reentrant version of the functions above which provide their own
898 buffers. */
899extern int ecvt_r (double __value, int __ndigit, int *__restrict __decpt,
900 int *__restrict __sign, char *__restrict __buf,
901 size_t __len) __THROW __nonnull ((3, 4, 5));
902extern int fcvt_r (double __value, int __ndigit, int *__restrict __decpt,
903 int *__restrict __sign, char *__restrict __buf,
904 size_t __len) __THROW __nonnull ((3, 4, 5));
905
906extern int qecvt_r (long double __value, int __ndigit,
907 int *__restrict __decpt, int *__restrict __sign,
908 char *__restrict __buf, size_t __len)
909 __THROW __nonnull ((3, 4, 5));
910extern int qfcvt_r (long double __value, int __ndigit,
911 int *__restrict __decpt, int *__restrict __sign,
912 char *__restrict __buf, size_t __len)
913 __THROW __nonnull ((3, 4, 5));
914#endif /* misc */
915
916
917/* Return the length of the multibyte character
918 in S, which is no longer than N. */
919extern int mblen (const char *__s, size_t __n) __THROW;
920/* Return the length of the given multibyte character,
921 putting its `wchar_t' representation in *PWC. */
922extern int mbtowc (wchar_t *__restrict __pwc,
923 const char *__restrict __s, size_t __n) __THROW;
924/* Put the multibyte character represented
925 by WCHAR in S, returning its length. */
926extern int wctomb (char *__s, wchar_t __wchar) __THROW;
927
928
929/* Convert a multibyte string to a wide char string. */
930extern size_t mbstowcs (wchar_t *__restrict __pwcs,
931 const char *__restrict __s, size_t __n) __THROW;
932/* Convert a wide char string to multibyte string. */
933extern size_t wcstombs (char *__restrict __s,
934 const wchar_t *__restrict __pwcs, size_t __n)
935 __THROW;
936
937
938#ifdef __USE_MISC
939/* Determine whether the string value of RESPONSE matches the affirmation
940 or negative response expression as specified by the LC_MESSAGES category
941 in the program's current locale. Returns 1 if affirmative, 0 if
942 negative, and -1 if not matching. */
943extern int rpmatch (const char *__response) __THROW __nonnull ((1)) __wur;
944#endif
945
946
947#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
948/* Parse comma separated suboption from *OPTIONP and match against
949 strings in TOKENS. If found return index and set *VALUEP to
950 optional value introduced by an equal sign. If the suboption is
951 not part of TOKENS return in *VALUEP beginning of unknown
952 suboption. On exit *OPTIONP is set to the beginning of the next
953 token or at the terminating NUL character. */
954extern int getsubopt (char **__restrict __optionp,
955 char *const *__restrict __tokens,
956 char **__restrict __valuep)
957 __THROW __nonnull ((1, 2, 3)) __wur;
958#endif
959
960
961/* X/Open pseudo terminal handling. */
962
963#ifdef __USE_XOPEN2KXSI
964/* Return a master pseudo-terminal handle. */
965extern int posix_openpt (int __oflag) __wur;
966#endif
967
968#ifdef __USE_XOPEN_EXTENDED
969/* The next four functions all take a master pseudo-tty fd and
970 perform an operation on the associated slave: */
971
972/* Chown the slave to the calling user. */
973extern int grantpt (int __fd) __THROW;
974
975/* Release an internal lock so the slave can be opened.
976 Call after grantpt(). */
977extern int unlockpt (int __fd) __THROW;
978
979/* Return the pathname of the pseudo terminal slave associated with
980 the master FD is open on, or NULL on errors.
981 The returned storage is good until the next call to this function. */
982extern char *ptsname (int __fd) __THROW __wur;
983#endif
984
985#ifdef __USE_GNU
986/* Store at most BUFLEN characters of the pathname of the slave pseudo
987 terminal associated with the master FD is open on in BUF.
988 Return 0 on success, otherwise an error number. */
989extern int ptsname_r (int __fd, char *__buf, size_t __buflen)
990 __THROW __nonnull ((2));
991
992/* Open a master pseudo terminal and return its file descriptor. */
993extern int getpt (void);
994#endif
995
996#ifdef __USE_MISC
997/* Put the 1 minute, 5 minute and 15 minute load averages into the first
998 NELEM elements of LOADAVG. Return the number written (never more than
999 three, but may be less than NELEM), or -1 if an error occurred. */
1000extern int getloadavg (double __loadavg[], int __nelem)
1001 __THROW __nonnull ((1));
1002#endif
1003
1004#if defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K
1005/* Return the index into the active-logins file (utmp) for
1006 the controlling terminal. */
1007extern int ttyslot (void) __THROW;
1008#endif
1009
1010#include <bits/stdlib-float.h>
1011
1012/* Define some macros helping to catch buffer overflows. */
1013#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
1014# include <bits/stdlib.h>
1015#endif
1016#ifdef __LDBL_COMPAT
1017# include <bits/stdlib-ldbl.h>
1018#endif
1019
1020__END_DECLS
1021
1022#endif /* stdlib.h */
libc/glibc-include/string.h created+500
...@@ -0,0 +1,500 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/*
19 * ISO C99 Standard: 7.21 String handling <string.h>
20 */
21
22#ifndef _STRING_H
23#define _STRING_H 1
24
25#define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION
26#include <bits/libc-header-start.h>
27
28__BEGIN_DECLS
29
30/* Get size_t and NULL from <stddef.h>. */
31#define __need_size_t
32#define __need_NULL
33#include <stddef.h>
34
35/* Tell the caller that we provide correct C++ prototypes. */
36#if defined __cplusplus && __GNUC_PREREQ (4, 4)
37# define __CORRECT_ISO_CPP_STRING_H_PROTO
38#endif
39
40
41/* Copy N bytes of SRC to DEST. */
42extern void *memcpy (void *__restrict __dest, const void *__restrict __src,
43 size_t __n) __THROW __nonnull ((1, 2));
44/* Copy N bytes of SRC to DEST, guaranteeing
45 correct behavior for overlapping strings. */
46extern void *memmove (void *__dest, const void *__src, size_t __n)
47 __THROW __nonnull ((1, 2));
48
49/* Copy no more than N bytes of SRC to DEST, stopping when C is found.
50 Return the position in DEST one byte past where C was copied,
51 or NULL if C was not found in the first N bytes of SRC. */
52#if defined __USE_MISC || defined __USE_XOPEN
53extern void *memccpy (void *__restrict __dest, const void *__restrict __src,
54 int __c, size_t __n)
55 __THROW __nonnull ((1, 2));
56#endif /* Misc || X/Open. */
57
58
59/* Set N bytes of S to C. */
60extern void *memset (void *__s, int __c, size_t __n) __THROW __nonnull ((1));
61
62/* Compare N bytes of S1 and S2. */
63extern int memcmp (const void *__s1, const void *__s2, size_t __n)
64 __THROW __attribute_pure__ __nonnull ((1, 2));
65
66/* Search N bytes of S for C. */
67#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
68extern "C++"
69{
70extern void *memchr (void *__s, int __c, size_t __n)
71 __THROW __asm ("memchr") __attribute_pure__ __nonnull ((1));
72extern const void *memchr (const void *__s, int __c, size_t __n)
73 __THROW __asm ("memchr") __attribute_pure__ __nonnull ((1));
74
75# ifdef __OPTIMIZE__
76__extern_always_inline void *
77memchr (void *__s, int __c, size_t __n) __THROW
78{
79 return __builtin_memchr (__s, __c, __n);
80}
81
82__extern_always_inline const void *
83memchr (const void *__s, int __c, size_t __n) __THROW
84{
85 return __builtin_memchr (__s, __c, __n);
86}
87# endif
88}
89#else
90extern void *memchr (const void *__s, int __c, size_t __n)
91 __THROW __attribute_pure__ __nonnull ((1));
92#endif
93
94#ifdef __USE_GNU
95/* Search in S for C. This is similar to `memchr' but there is no
96 length limit. */
97# ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
98extern "C++" void *rawmemchr (void *__s, int __c)
99 __THROW __asm ("rawmemchr") __attribute_pure__ __nonnull ((1));
100extern "C++" const void *rawmemchr (const void *__s, int __c)
101 __THROW __asm ("rawmemchr") __attribute_pure__ __nonnull ((1));
102# else
103extern void *rawmemchr (const void *__s, int __c)
104 __THROW __attribute_pure__ __nonnull ((1));
105# endif
106
107/* Search N bytes of S for the final occurrence of C. */
108# ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
109extern "C++" void *memrchr (void *__s, int __c, size_t __n)
110 __THROW __asm ("memrchr") __attribute_pure__ __nonnull ((1));
111extern "C++" const void *memrchr (const void *__s, int __c, size_t __n)
112 __THROW __asm ("memrchr") __attribute_pure__ __nonnull ((1));
113# else
114extern void *memrchr (const void *__s, int __c, size_t __n)
115 __THROW __attribute_pure__ __nonnull ((1));
116# endif
117#endif
118
119
120/* Copy SRC to DEST. */
121extern char *strcpy (char *__restrict __dest, const char *__restrict __src)
122 __THROW __nonnull ((1, 2));
123/* Copy no more than N characters of SRC to DEST. */
124extern char *strncpy (char *__restrict __dest,
125 const char *__restrict __src, size_t __n)
126 __THROW __nonnull ((1, 2));
127
128/* Append SRC onto DEST. */
129extern char *strcat (char *__restrict __dest, const char *__restrict __src)
130 __THROW __nonnull ((1, 2));
131/* Append no more than N characters from SRC onto DEST. */
132extern char *strncat (char *__restrict __dest, const char *__restrict __src,
133 size_t __n) __THROW __nonnull ((1, 2));
134
135/* Compare S1 and S2. */
136extern int strcmp (const char *__s1, const char *__s2)
137 __THROW __attribute_pure__ __nonnull ((1, 2));
138/* Compare N characters of S1 and S2. */
139extern int strncmp (const char *__s1, const char *__s2, size_t __n)
140 __THROW __attribute_pure__ __nonnull ((1, 2));
141
142/* Compare the collated forms of S1 and S2. */
143extern int strcoll (const char *__s1, const char *__s2)
144 __THROW __attribute_pure__ __nonnull ((1, 2));
145/* Put a transformation of SRC into no more than N bytes of DEST. */
146extern size_t strxfrm (char *__restrict __dest,
147 const char *__restrict __src, size_t __n)
148 __THROW __nonnull ((2));
149
150#ifdef __USE_XOPEN2K8
151/* POSIX.1-2008 extended locale interface (see locale.h). */
152# include <bits/types/locale_t.h>
153
154/* Compare the collated forms of S1 and S2, using sorting rules from L. */
155extern int strcoll_l (const char *__s1, const char *__s2, locale_t __l)
156 __THROW __attribute_pure__ __nonnull ((1, 2, 3));
157/* Put a transformation of SRC into no more than N bytes of DEST,
158 using sorting rules from L. */
159extern size_t strxfrm_l (char *__dest, const char *__src, size_t __n,
160 locale_t __l) __THROW __nonnull ((2, 4));
161#endif
162
163#if (defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8 \
164 || __GLIBC_USE (LIB_EXT2))
165/* Duplicate S, returning an identical malloc'd string. */
166extern char *strdup (const char *__s)
167 __THROW __attribute_malloc__ __nonnull ((1));
168#endif
169
170/* Return a malloc'd copy of at most N bytes of STRING. The
171 resultant string is terminated even if no null terminator
172 appears before STRING[N]. */
173#if defined __USE_XOPEN2K8 || __GLIBC_USE (LIB_EXT2)
174extern char *strndup (const char *__string, size_t __n)
175 __THROW __attribute_malloc__ __nonnull ((1));
176#endif
177
178#if defined __USE_GNU && defined __GNUC__
179/* Duplicate S, returning an identical alloca'd string. */
180# define strdupa(s) \
181 (__extension__ \
182 ({ \
183 const char *__old = (s); \
184 size_t __len = strlen (__old) + 1; \
185 char *__new = (char *) __builtin_alloca (__len); \
186 (char *) memcpy (__new, __old, __len); \
187 }))
188
189/* Return an alloca'd copy of at most N bytes of string. */
190# define strndupa(s, n) \
191 (__extension__ \
192 ({ \
193 const char *__old = (s); \
194 size_t __len = strnlen (__old, (n)); \
195 char *__new = (char *) __builtin_alloca (__len + 1); \
196 __new[__len] = '\0'; \
197 (char *) memcpy (__new, __old, __len); \
198 }))
199#endif
200
201/* Find the first occurrence of C in S. */
202#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
203extern "C++"
204{
205extern char *strchr (char *__s, int __c)
206 __THROW __asm ("strchr") __attribute_pure__ __nonnull ((1));
207extern const char *strchr (const char *__s, int __c)
208 __THROW __asm ("strchr") __attribute_pure__ __nonnull ((1));
209
210# ifdef __OPTIMIZE__
211__extern_always_inline char *
212strchr (char *__s, int __c) __THROW
213{
214 return __builtin_strchr (__s, __c);
215}
216
217__extern_always_inline const char *
218strchr (const char *__s, int __c) __THROW
219{
220 return __builtin_strchr (__s, __c);
221}
222# endif
223}
224#else
225extern char *strchr (const char *__s, int __c)
226 __THROW __attribute_pure__ __nonnull ((1));
227#endif
228/* Find the last occurrence of C in S. */
229#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
230extern "C++"
231{
232extern char *strrchr (char *__s, int __c)
233 __THROW __asm ("strrchr") __attribute_pure__ __nonnull ((1));
234extern const char *strrchr (const char *__s, int __c)
235 __THROW __asm ("strrchr") __attribute_pure__ __nonnull ((1));
236
237# ifdef __OPTIMIZE__
238__extern_always_inline char *
239strrchr (char *__s, int __c) __THROW
240{
241 return __builtin_strrchr (__s, __c);
242}
243
244__extern_always_inline const char *
245strrchr (const char *__s, int __c) __THROW
246{
247 return __builtin_strrchr (__s, __c);
248}
249# endif
250}
251#else
252extern char *strrchr (const char *__s, int __c)
253 __THROW __attribute_pure__ __nonnull ((1));
254#endif
255
256#ifdef __USE_GNU
257/* This function is similar to `strchr'. But it returns a pointer to
258 the closing NUL byte in case C is not found in S. */
259# ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
260extern "C++" char *strchrnul (char *__s, int __c)
261 __THROW __asm ("strchrnul") __attribute_pure__ __nonnull ((1));
262extern "C++" const char *strchrnul (const char *__s, int __c)
263 __THROW __asm ("strchrnul") __attribute_pure__ __nonnull ((1));
264# else
265extern char *strchrnul (const char *__s, int __c)
266 __THROW __attribute_pure__ __nonnull ((1));
267# endif
268#endif
269
270/* Return the length of the initial segment of S which
271 consists entirely of characters not in REJECT. */
272extern size_t strcspn (const char *__s, const char *__reject)
273 __THROW __attribute_pure__ __nonnull ((1, 2));
274/* Return the length of the initial segment of S which
275 consists entirely of characters in ACCEPT. */
276extern size_t strspn (const char *__s, const char *__accept)
277 __THROW __attribute_pure__ __nonnull ((1, 2));
278/* Find the first occurrence in S of any character in ACCEPT. */
279#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
280extern "C++"
281{
282extern char *strpbrk (char *__s, const char *__accept)
283 __THROW __asm ("strpbrk") __attribute_pure__ __nonnull ((1, 2));
284extern const char *strpbrk (const char *__s, const char *__accept)
285 __THROW __asm ("strpbrk") __attribute_pure__ __nonnull ((1, 2));
286
287# ifdef __OPTIMIZE__
288__extern_always_inline char *
289strpbrk (char *__s, const char *__accept) __THROW
290{
291 return __builtin_strpbrk (__s, __accept);
292}
293
294__extern_always_inline const char *
295strpbrk (const char *__s, const char *__accept) __THROW
296{
297 return __builtin_strpbrk (__s, __accept);
298}
299# endif
300}
301#else
302extern char *strpbrk (const char *__s, const char *__accept)
303 __THROW __attribute_pure__ __nonnull ((1, 2));
304#endif
305/* Find the first occurrence of NEEDLE in HAYSTACK. */
306#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
307extern "C++"
308{
309extern char *strstr (char *__haystack, const char *__needle)
310 __THROW __asm ("strstr") __attribute_pure__ __nonnull ((1, 2));
311extern const char *strstr (const char *__haystack, const char *__needle)
312 __THROW __asm ("strstr") __attribute_pure__ __nonnull ((1, 2));
313
314# ifdef __OPTIMIZE__
315__extern_always_inline char *
316strstr (char *__haystack, const char *__needle) __THROW
317{
318 return __builtin_strstr (__haystack, __needle);
319}
320
321__extern_always_inline const char *
322strstr (const char *__haystack, const char *__needle) __THROW
323{
324 return __builtin_strstr (__haystack, __needle);
325}
326# endif
327}
328#else
329extern char *strstr (const char *__haystack, const char *__needle)
330 __THROW __attribute_pure__ __nonnull ((1, 2));
331#endif
332
333
334/* Divide S into tokens separated by characters in DELIM. */
335extern char *strtok (char *__restrict __s, const char *__restrict __delim)
336 __THROW __nonnull ((2));
337
338/* Divide S into tokens separated by characters in DELIM. Information
339 passed between calls are stored in SAVE_PTR. */
340extern char *__strtok_r (char *__restrict __s,
341 const char *__restrict __delim,
342 char **__restrict __save_ptr)
343 __THROW __nonnull ((2, 3));
344#ifdef __USE_POSIX
345extern char *strtok_r (char *__restrict __s, const char *__restrict __delim,
346 char **__restrict __save_ptr)
347 __THROW __nonnull ((2, 3));
348#endif
349
350#ifdef __USE_GNU
351/* Similar to `strstr' but this function ignores the case of both strings. */
352# ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
353extern "C++" char *strcasestr (char *__haystack, const char *__needle)
354 __THROW __asm ("strcasestr") __attribute_pure__ __nonnull ((1, 2));
355extern "C++" const char *strcasestr (const char *__haystack,
356 const char *__needle)
357 __THROW __asm ("strcasestr") __attribute_pure__ __nonnull ((1, 2));
358# else
359extern char *strcasestr (const char *__haystack, const char *__needle)
360 __THROW __attribute_pure__ __nonnull ((1, 2));
361# endif
362#endif
363
364#ifdef __USE_GNU
365/* Find the first occurrence of NEEDLE in HAYSTACK.
366 NEEDLE is NEEDLELEN bytes long;
367 HAYSTACK is HAYSTACKLEN bytes long. */
368extern void *memmem (const void *__haystack, size_t __haystacklen,
369 const void *__needle, size_t __needlelen)
370 __THROW __attribute_pure__ __nonnull ((1, 3));
371
372/* Copy N bytes of SRC to DEST, return pointer to bytes after the
373 last written byte. */
374extern void *__mempcpy (void *__restrict __dest,
375 const void *__restrict __src, size_t __n)
376 __THROW __nonnull ((1, 2));
377extern void *mempcpy (void *__restrict __dest,
378 const void *__restrict __src, size_t __n)
379 __THROW __nonnull ((1, 2));
380#endif
381
382
383/* Return the length of S. */
384extern size_t strlen (const char *__s)
385 __THROW __attribute_pure__ __nonnull ((1));
386
387#ifdef __USE_XOPEN2K8
388/* Find the length of STRING, but scan at most MAXLEN characters.
389 If no '\0' terminator is found in that many characters, return MAXLEN. */
390extern size_t strnlen (const char *__string, size_t __maxlen)
391 __THROW __attribute_pure__ __nonnull ((1));
392#endif
393
394
395/* Return a string describing the meaning of the `errno' code in ERRNUM. */
396extern char *strerror (int __errnum) __THROW;
397#ifdef __USE_XOPEN2K
398/* Reentrant version of `strerror'.
399 There are 2 flavors of `strerror_r', GNU which returns the string
400 and may or may not use the supplied temporary buffer and POSIX one
401 which fills the string into the buffer.
402 To use the POSIX version, -D_XOPEN_SOURCE=600 or -D_POSIX_C_SOURCE=200112L
403 without -D_GNU_SOURCE is needed, otherwise the GNU version is
404 preferred. */
405# if defined __USE_XOPEN2K && !defined __USE_GNU
406/* Fill BUF with a string describing the meaning of the `errno' code in
407 ERRNUM. */
408# ifdef __REDIRECT_NTH
409extern int __REDIRECT_NTH (strerror_r,
410 (int __errnum, char *__buf, size_t __buflen),
411 __xpg_strerror_r) __nonnull ((2));
412# else
413extern int __xpg_strerror_r (int __errnum, char *__buf, size_t __buflen)
414 __THROW __nonnull ((2));
415# define strerror_r __xpg_strerror_r
416# endif
417# else
418/* If a temporary buffer is required, at most BUFLEN bytes of BUF will be
419 used. */
420extern char *strerror_r (int __errnum, char *__buf, size_t __buflen)
421 __THROW __nonnull ((2)) __wur;
422# endif
423#endif
424
425#ifdef __USE_XOPEN2K8
426/* Translate error number to string according to the locale L. */
427extern char *strerror_l (int __errnum, locale_t __l) __THROW;
428#endif
429
430#ifdef __USE_MISC
431# include <strings.h>
432
433/* Set N bytes of S to 0. The compiler will not delete a call to this
434 function, even if S is dead after the call. */
435extern void explicit_bzero (void *__s, size_t __n) __THROW __nonnull ((1));
436
437/* Return the next DELIM-delimited token from *STRINGP,
438 terminating it with a '\0', and update *STRINGP to point past it. */
439extern char *strsep (char **__restrict __stringp,
440 const char *__restrict __delim)
441 __THROW __nonnull ((1, 2));
442#endif
443
444#ifdef __USE_XOPEN2K8
445/* Return a string describing the meaning of the signal number in SIG. */
446extern char *strsignal (int __sig) __THROW;
447
448/* Copy SRC to DEST, returning the address of the terminating '\0' in DEST. */
449extern char *__stpcpy (char *__restrict __dest, const char *__restrict __src)
450 __THROW __nonnull ((1, 2));
451extern char *stpcpy (char *__restrict __dest, const char *__restrict __src)
452 __THROW __nonnull ((1, 2));
453
454/* Copy no more than N characters of SRC to DEST, returning the address of
455 the last character written into DEST. */
456extern char *__stpncpy (char *__restrict __dest,
457 const char *__restrict __src, size_t __n)
458 __THROW __nonnull ((1, 2));
459extern char *stpncpy (char *__restrict __dest,
460 const char *__restrict __src, size_t __n)
461 __THROW __nonnull ((1, 2));
462#endif
463
464#ifdef __USE_GNU
465/* Compare S1 and S2 as strings holding name & indices/version numbers. */
466extern int strverscmp (const char *__s1, const char *__s2)
467 __THROW __attribute_pure__ __nonnull ((1, 2));
468
469/* Sautee STRING briskly. */
470extern char *strfry (char *__string) __THROW __nonnull ((1));
471
472/* Frobnicate N bytes of S. */
473extern void *memfrob (void *__s, size_t __n) __THROW __nonnull ((1));
474
475# ifndef basename
476/* Return the file name within directory of FILENAME. We don't
477 declare the function if the `basename' macro is available (defined
478 in <libgen.h>) which makes the XPG version of this function
479 available. */
480# ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
481extern "C++" char *basename (char *__filename)
482 __THROW __asm ("basename") __nonnull ((1));
483extern "C++" const char *basename (const char *__filename)
484 __THROW __asm ("basename") __nonnull ((1));
485# else
486extern char *basename (const char *__filename) __THROW __nonnull ((1));
487# endif
488# endif
489#endif
490
491#if __GNUC_PREREQ (3,4)
492# if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
493/* Functions with security checks. */
494# include <bits/string_fortified.h>
495# endif
496#endif
497
498__END_DECLS
499
500#endif /* string.h */
libc/glibc-include/strings.h created+148
...@@ -0,0 +1,148 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _STRINGS_H
19#define _STRINGS_H 1
20
21#include <features.h>
22#define __need_size_t
23#include <stddef.h>
24
25/* Tell the caller that we provide correct C++ prototypes. */
26#if defined __cplusplus && __GNUC_PREREQ (4, 4)
27# define __CORRECT_ISO_CPP_STRINGS_H_PROTO
28#endif
29
30__BEGIN_DECLS
31
32#if defined __USE_MISC || !defined __USE_XOPEN2K8
33/* Compare N bytes of S1 and S2 (same as memcmp). */
34extern int bcmp (const void *__s1, const void *__s2, size_t __n)
35 __THROW __attribute_pure__ __nonnull ((1, 2));
36
37/* Copy N bytes of SRC to DEST (like memmove, but args reversed). */
38extern void bcopy (const void *__src, void *__dest, size_t __n)
39 __THROW __nonnull ((1, 2));
40
41/* Set N bytes of S to 0. */
42extern void bzero (void *__s, size_t __n) __THROW __nonnull ((1));
43
44/* Find the first occurrence of C in S (same as strchr). */
45# ifdef __CORRECT_ISO_CPP_STRINGS_H_PROTO
46extern "C++"
47{
48extern char *index (char *__s, int __c)
49 __THROW __asm ("index") __attribute_pure__ __nonnull ((1));
50extern const char *index (const char *__s, int __c)
51 __THROW __asm ("index") __attribute_pure__ __nonnull ((1));
52
53# if defined __OPTIMIZE__
54__extern_always_inline char *
55index (char *__s, int __c) __THROW
56{
57 return __builtin_index (__s, __c);
58}
59
60__extern_always_inline const char *
61index (const char *__s, int __c) __THROW
62{
63 return __builtin_index (__s, __c);
64}
65# endif
66}
67# else
68extern char *index (const char *__s, int __c)
69 __THROW __attribute_pure__ __nonnull ((1));
70# endif
71
72/* Find the last occurrence of C in S (same as strrchr). */
73# ifdef __CORRECT_ISO_CPP_STRINGS_H_PROTO
74extern "C++"
75{
76extern char *rindex (char *__s, int __c)
77 __THROW __asm ("rindex") __attribute_pure__ __nonnull ((1));
78extern const char *rindex (const char *__s, int __c)
79 __THROW __asm ("rindex") __attribute_pure__ __nonnull ((1));
80
81# if defined __OPTIMIZE__
82__extern_always_inline char *
83rindex (char *__s, int __c) __THROW
84{
85 return __builtin_rindex (__s, __c);
86}
87
88__extern_always_inline const char *
89rindex (const char *__s, int __c) __THROW
90{
91 return __builtin_rindex (__s, __c);
92}
93# endif
94}
95# else
96extern char *rindex (const char *__s, int __c)
97 __THROW __attribute_pure__ __nonnull ((1));
98# endif
99#endif
100
101#if defined __USE_MISC || !defined __USE_XOPEN2K8 || defined __USE_XOPEN2K8XSI
102/* Return the position of the first bit set in I, or 0 if none are set.
103 The least-significant bit is position 1, the most-significant 32. */
104extern int ffs (int __i) __THROW __attribute_const__;
105#endif
106
107/* The following two functions are non-standard but necessary for non-32 bit
108 platforms. */
109# ifdef __USE_MISC
110extern int ffsl (long int __l) __THROW __attribute_const__;
111__extension__ extern int ffsll (long long int __ll)
112 __THROW __attribute_const__;
113# endif
114
115/* Compare S1 and S2, ignoring case. */
116extern int strcasecmp (const char *__s1, const char *__s2)
117 __THROW __attribute_pure__ __nonnull ((1, 2));
118
119/* Compare no more than N chars of S1 and S2, ignoring case. */
120extern int strncasecmp (const char *__s1, const char *__s2, size_t __n)
121 __THROW __attribute_pure__ __nonnull ((1, 2));
122
123#ifdef __USE_XOPEN2K8
124/* POSIX.1-2008 extended locale interface (see locale.h). */
125# include <bits/types/locale_t.h>
126
127/* Compare S1 and S2, ignoring case, using collation rules from LOC. */
128extern int strcasecmp_l (const char *__s1, const char *__s2, locale_t __loc)
129 __THROW __attribute_pure__ __nonnull ((1, 2, 3));
130
131/* Compare no more than N chars of S1 and S2, ignoring case, using
132 collation rules from LOC. */
133extern int strncasecmp_l (const char *__s1, const char *__s2,
134 size_t __n, locale_t __loc)
135 __THROW __attribute_pure__ __nonnull ((1, 2, 4));
136#endif
137
138__END_DECLS
139
140#if __GNUC_PREREQ (3,4) && __USE_FORTIFY_LEVEL > 0 \
141 && defined __fortify_function
142/* Functions with security checks. */
143# if defined __USE_MISC || !defined __USE_XOPEN2K8
144# include <bits/strings_fortified.h>
145# endif
146#endif
147
148#endif /* strings.h */
libc/glibc-include/stropts.h created+92
...@@ -0,0 +1,92 @@
1/* Copyright (C) 1998-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _STROPTS_H
19#define _STROPTS_H 1
20
21#include <features.h>
22#include <bits/types.h>
23#include <bits/xtitypes.h>
24
25#ifndef __gid_t_defined
26typedef __gid_t gid_t;
27# define __gid_t_defined
28#endif
29
30#ifndef __uid_t_defined
31typedef __uid_t uid_t;
32# define __uid_t_defined
33#endif
34
35typedef __t_scalar_t t_scalar_t;
36typedef __t_uscalar_t t_uscalar_t;
37
38/* Get system specific constants. */
39#include <bits/stropts.h>
40
41
42__BEGIN_DECLS
43
44/* Test whether FILDES is associated with a STREAM-based file. */
45extern int isastream (int __fildes) __THROW;
46
47/* Receive next message from a STREAMS file.
48
49 This function is a cancellation point and therefore not marked with
50 __THROW. */
51extern int getmsg (int __fildes, struct strbuf *__restrict __ctlptr,
52 struct strbuf *__restrict __dataptr,
53 int *__restrict __flagsp);
54
55/* Receive next message from a STREAMS file, with *FLAGSP allowing to
56 control which message.
57
58 This function is a cancellation point and therefore not marked with
59 __THROW. */
60extern int getpmsg (int __fildes, struct strbuf *__restrict __ctlptr,
61 struct strbuf *__restrict __dataptr,
62 int *__restrict __bandp, int *__restrict __flagsp);
63
64/* Perform the I/O control operation specified by REQUEST on FD.
65 One argument may follow; its presence and type depend on REQUEST.
66 Return value depends on REQUEST. Usually -1 indicates error. */
67extern int ioctl (int __fd, unsigned long int __request, ...) __THROW;
68
69/* Send a message on a STREAM.
70
71 This function is a cancellation point and therefore not marked with
72 __THROW. */
73extern int putmsg (int __fildes, const struct strbuf *__ctlptr,
74 const struct strbuf *__dataptr, int __flags);
75
76/* Send a message on a STREAM to the BAND.
77
78 This function is a cancellation point and therefore not marked with
79 __THROW. */
80extern int putpmsg (int __fildes, const struct strbuf *__ctlptr,
81 const struct strbuf *__dataptr, int __band, int __flags);
82
83/* Attach a STREAMS-based file descriptor FILDES to a file PATH in the
84 file system name space. */
85extern int fattach (int __fildes, const char *__path) __THROW;
86
87/* Detach a name PATH from a STREAMS-based file descriptor. */
88extern int fdetach (const char *__path) __THROW;
89
90__END_DECLS
91
92#endif /* stropts.h */
libc/glibc-include/sys/acct.h created+106
...@@ -0,0 +1,106 @@
1/* Copyright (C) 1996-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_ACCT_H
19#define _SYS_ACCT_H 1
20
21#include <sys/types.h>
22#include <stdint.h>
23#include <endian.h>
24#include <bits/types/time_t.h>
25
26__BEGIN_DECLS
27
28#define ACCT_COMM 16
29
30/*
31 comp_t is a 16-bit "floating" point number with a 3-bit base 8
32 exponent and a 13-bit fraction. See linux/kernel/acct.c for the
33 specific encoding system used.
34*/
35
36typedef uint16_t comp_t;
37
38struct acct
39{
40 char ac_flag; /* Flags. */
41 uint16_t ac_uid; /* Real user ID. */
42 uint16_t ac_gid; /* Real group ID. */
43 uint16_t ac_tty; /* Controlling terminal. */
44 uint32_t ac_btime; /* Beginning time. */
45 comp_t ac_utime; /* User time. */
46 comp_t ac_stime; /* System time. */
47 comp_t ac_etime; /* Elapsed time. */
48 comp_t ac_mem; /* Average memory usage. */
49 comp_t ac_io; /* Chars transferred. */
50 comp_t ac_rw; /* Blocks read or written. */
51 comp_t ac_minflt; /* Minor pagefaults. */
52 comp_t ac_majflt; /* Major pagefaults. */
53 comp_t ac_swaps; /* Number of swaps. */
54 uint32_t ac_exitcode; /* Process exitcode. */
55 char ac_comm[ACCT_COMM+1]; /* Command name. */
56 char ac_pad[10]; /* Padding bytes. */
57};
58
59
60struct acct_v3
61{
62 char ac_flag; /* Flags */
63 char ac_version; /* Always set to ACCT_VERSION */
64 uint16_t ac_tty; /* Control Terminal */
65 uint32_t ac_exitcode; /* Exitcode */
66 uint32_t ac_uid; /* Real User ID */
67 uint32_t ac_gid; /* Real Group ID */
68 uint32_t ac_pid; /* Process ID */
69 uint32_t ac_ppid; /* Parent Process ID */
70 uint32_t ac_btime; /* Process Creation Time */
71 float ac_etime; /* Elapsed Time */
72 comp_t ac_utime; /* User Time */
73 comp_t ac_stime; /* System Time */
74 comp_t ac_mem; /* Average Memory Usage */
75 comp_t ac_io; /* Chars Transferred */
76 comp_t ac_rw; /* Blocks Read or Written */
77 comp_t ac_minflt; /* Minor Pagefaults */
78 comp_t ac_majflt; /* Major Pagefaults */
79 comp_t ac_swaps; /* Number of Swaps */
80 char ac_comm[ACCT_COMM]; /* Command Name */
81};
82
83
84enum
85 {
86 AFORK = 0x01, /* Has executed fork, but no exec. */
87 ASU = 0x02, /* Used super-user privileges. */
88 ACORE = 0x08, /* Dumped core. */
89 AXSIG = 0x10 /* Killed by a signal. */
90 };
91
92#if __BYTE_ORDER == __BIG_ENDIAN
93# define ACCT_BYTEORDER 0x80 /* Accounting file is big endian. */
94#else
95# define ACCT_BYTEORDER 0x00 /* Accounting file is little endian. */
96#endif
97
98#define AHZ 100
99
100
101/* Switch process accounting on and off. */
102extern int acct (const char *__filename) __THROW;
103
104__END_DECLS
105
106#endif /* sys/acct.h */
libc/glibc-include/sys/auxv.h created+36
...@@ -0,0 +1,36 @@
1/* Access to the auxiliary vector.
2 Copyright (C) 2012-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SYS_AUXV_H
20#define _SYS_AUXV_H 1
21
22#include <elf.h>
23#include <sys/cdefs.h>
24#include <bits/hwcap.h>
25
26__BEGIN_DECLS
27
28/* Return the value associated with an Elf*_auxv_t type from the auxv list
29 passed to the program on startup. If TYPE was not present in the auxv
30 list, returns zero and sets errno to ENOENT. */
31extern unsigned long int getauxval (unsigned long int __type)
32 __THROW;
33
34__END_DECLS
35
36#endif /* sys/auxv.h */
libc/glibc-include/sys/bitypes.h created+3
...@@ -0,0 +1,3 @@
1/* The GNU <sys/types.h> defines all the necessary types. */
2
3#include <sys/types.h>
libc/glibc-include/sys/cdefs.h created+517
...@@ -0,0 +1,517 @@
1/* Copyright (C) 1992-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_CDEFS_H
19#define _SYS_CDEFS_H 1
20
21/* We are almost always included from features.h. */
22#ifndef _FEATURES_H
23# include <features.h>
24#endif
25
26/* The GNU libc does not support any K&R compilers or the traditional mode
27 of ISO C compilers anymore. Check for some of the combinations not
28 anymore supported. */
29#if defined __GNUC__ && !defined __STDC__
30# error "You need a ISO C conforming compiler to use the glibc headers"
31#endif
32
33/* Some user header file might have defined this before. */
34#undef __P
35#undef __PMT
36
37#ifdef __GNUC__
38
39/* All functions, except those with callbacks or those that
40 synchronize memory, are leaf functions. */
41# if __GNUC_PREREQ (4, 6) && !defined _LIBC
42# define __LEAF , __leaf__
43# define __LEAF_ATTR __attribute__ ((__leaf__))
44# else
45# define __LEAF
46# define __LEAF_ATTR
47# endif
48
49/* GCC can always grok prototypes. For C++ programs we add throw()
50 to help it optimize the function calls. But this works only with
51 gcc 2.8.x and egcs. For gcc 3.2 and up we even mark C functions
52 as non-throwing using a function attribute since programs can use
53 the -fexceptions options for C code as well. */
54# if !defined __cplusplus && __GNUC_PREREQ (3, 3)
55# define __THROW __attribute__ ((__nothrow__ __LEAF))
56# define __THROWNL __attribute__ ((__nothrow__))
57# define __NTH(fct) __attribute__ ((__nothrow__ __LEAF)) fct
58# define __NTHNL(fct) __attribute__ ((__nothrow__)) fct
59# else
60# if defined __cplusplus && __GNUC_PREREQ (2,8)
61# define __THROW throw ()
62# define __THROWNL throw ()
63# define __NTH(fct) __LEAF_ATTR fct throw ()
64# define __NTHNL(fct) fct throw ()
65# else
66# define __THROW
67# define __THROWNL
68# define __NTH(fct) fct
69# define __NTHNL(fct) fct
70# endif
71# endif
72
73#else /* Not GCC. */
74
75# if (defined __cplusplus \
76 || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L))
77# define __inline inline
78# else
79# define __inline /* No inline functions. */
80# endif
81
82# define __THROW
83# define __THROWNL
84# define __NTH(fct) fct
85
86#endif /* GCC. */
87
88/* Compilers that are not clang may object to
89 #if defined __clang__ && __has_extension(...)
90 even though they do not need to evaluate the right-hand side of the &&. */
91#if defined __clang__ && defined __has_extension
92# define __glibc_clang_has_extension(ext) __has_extension (ext)
93#else
94# define __glibc_clang_has_extension(ext) 0
95#endif
96
97/* These two macros are not used in glibc anymore. They are kept here
98 only because some other projects expect the macros to be defined. */
99#define __P(args) args
100#define __PMT(args) args
101
102/* For these things, GCC behaves the ANSI way normally,
103 and the non-ANSI way under -traditional. */
104
105#define __CONCAT(x,y) x ## y
106#define __STRING(x) #x
107
108/* This is not a typedef so `const __ptr_t' does the right thing. */
109#define __ptr_t void *
110
111
112/* C++ needs to know that types and declarations are C, not C++. */
113#ifdef __cplusplus
114# define __BEGIN_DECLS extern "C" {
115# define __END_DECLS }
116#else
117# define __BEGIN_DECLS
118# define __END_DECLS
119#endif
120
121
122/* Fortify support. */
123#define __bos(ptr) __builtin_object_size (ptr, __USE_FORTIFY_LEVEL > 1)
124#define __bos0(ptr) __builtin_object_size (ptr, 0)
125
126#if __GNUC_PREREQ (4,3)
127# define __warndecl(name, msg) \
128 extern void name (void) __attribute__((__warning__ (msg)))
129# define __warnattr(msg) __attribute__((__warning__ (msg)))
130# define __errordecl(name, msg) \
131 extern void name (void) __attribute__((__error__ (msg)))
132#else
133# define __warndecl(name, msg) extern void name (void)
134# define __warnattr(msg)
135# define __errordecl(name, msg) extern void name (void)
136#endif
137
138/* Support for flexible arrays.
139 Headers that should use flexible arrays only if they're "real"
140 (e.g. only if they won't affect sizeof()) should test
141 #if __glibc_c99_flexarr_available. */
142#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
143# define __flexarr []
144# define __glibc_c99_flexarr_available 1
145#elif __GNUC_PREREQ (2,97)
146/* GCC 2.97 supports C99 flexible array members as an extension,
147 even when in C89 mode or compiling C++ (any version). */
148# define __flexarr []
149# define __glibc_c99_flexarr_available 1
150#elif defined __GNUC__
151/* Pre-2.97 GCC did not support C99 flexible arrays but did have
152 an equivalent extension with slightly different notation. */
153# define __flexarr [0]
154# define __glibc_c99_flexarr_available 1
155#else
156/* Some other non-C99 compiler. Approximate with [1]. */
157# define __flexarr [1]
158# define __glibc_c99_flexarr_available 0
159#endif
160
161
162/* __asm__ ("xyz") is used throughout the headers to rename functions
163 at the assembly language level. This is wrapped by the __REDIRECT
164 macro, in order to support compilers that can do this some other
165 way. When compilers don't support asm-names at all, we have to do
166 preprocessor tricks instead (which don't have exactly the right
167 semantics, but it's the best we can do).
168
169 Example:
170 int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); */
171
172#if defined __GNUC__ && __GNUC__ >= 2
173
174# define __REDIRECT(name, proto, alias) name proto __asm__ (__ASMNAME (#alias))
175# ifdef __cplusplus
176# define __REDIRECT_NTH(name, proto, alias) \
177 name proto __THROW __asm__ (__ASMNAME (#alias))
178# define __REDIRECT_NTHNL(name, proto, alias) \
179 name proto __THROWNL __asm__ (__ASMNAME (#alias))
180# else
181# define __REDIRECT_NTH(name, proto, alias) \
182 name proto __asm__ (__ASMNAME (#alias)) __THROW
183# define __REDIRECT_NTHNL(name, proto, alias) \
184 name proto __asm__ (__ASMNAME (#alias)) __THROWNL
185# endif
186# define __ASMNAME(cname) __ASMNAME2 (__USER_LABEL_PREFIX__, cname)
187# define __ASMNAME2(prefix, cname) __STRING (prefix) cname
188
189/*
190#elif __SOME_OTHER_COMPILER__
191
192# define __REDIRECT(name, proto, alias) name proto; \
193 _Pragma("let " #name " = " #alias)
194*/
195#endif
196
197/* GCC has various useful declarations that can be made with the
198 `__attribute__' syntax. All of the ways we use this do fine if
199 they are omitted for compilers that don't understand it. */
200#if !defined __GNUC__ || __GNUC__ < 2
201# define __attribute__(xyz) /* Ignore */
202#endif
203
204/* At some point during the gcc 2.96 development the `malloc' attribute
205 for functions was introduced. We don't want to use it unconditionally
206 (although this would be possible) since it generates warnings. */
207#if __GNUC_PREREQ (2,96)
208# define __attribute_malloc__ __attribute__ ((__malloc__))
209#else
210# define __attribute_malloc__ /* Ignore */
211#endif
212
213/* Tell the compiler which arguments to an allocation function
214 indicate the size of the allocation. */
215#if __GNUC_PREREQ (4, 3)
216# define __attribute_alloc_size__(params) \
217 __attribute__ ((__alloc_size__ params))
218#else
219# define __attribute_alloc_size__(params) /* Ignore. */
220#endif
221
222/* At some point during the gcc 2.96 development the `pure' attribute
223 for functions was introduced. We don't want to use it unconditionally
224 (although this would be possible) since it generates warnings. */
225#if __GNUC_PREREQ (2,96)
226# define __attribute_pure__ __attribute__ ((__pure__))
227#else
228# define __attribute_pure__ /* Ignore */
229#endif
230
231/* This declaration tells the compiler that the value is constant. */
232#if __GNUC_PREREQ (2,5)
233# define __attribute_const__ __attribute__ ((__const__))
234#else
235# define __attribute_const__ /* Ignore */
236#endif
237
238/* At some point during the gcc 3.1 development the `used' attribute
239 for functions was introduced. We don't want to use it unconditionally
240 (although this would be possible) since it generates warnings. */
241#if __GNUC_PREREQ (3,1)
242# define __attribute_used__ __attribute__ ((__used__))
243# define __attribute_noinline__ __attribute__ ((__noinline__))
244#else
245# define __attribute_used__ __attribute__ ((__unused__))
246# define __attribute_noinline__ /* Ignore */
247#endif
248
249/* Since version 3.2, gcc allows marking deprecated functions. */
250#if __GNUC_PREREQ (3,2)
251# define __attribute_deprecated__ __attribute__ ((__deprecated__))
252#else
253# define __attribute_deprecated__ /* Ignore */
254#endif
255
256/* Since version 4.5, gcc also allows one to specify the message printed
257 when a deprecated function is used. clang claims to be gcc 4.2, but
258 may also support this feature. */
259#if __GNUC_PREREQ (4,5) || \
260 __glibc_clang_has_extension (__attribute_deprecated_with_message__)
261# define __attribute_deprecated_msg__(msg) \
262 __attribute__ ((__deprecated__ (msg)))
263#else
264# define __attribute_deprecated_msg__(msg) __attribute_deprecated__
265#endif
266
267/* At some point during the gcc 2.8 development the `format_arg' attribute
268 for functions was introduced. We don't want to use it unconditionally
269 (although this would be possible) since it generates warnings.
270 If several `format_arg' attributes are given for the same function, in
271 gcc-3.0 and older, all but the last one are ignored. In newer gccs,
272 all designated arguments are considered. */
273#if __GNUC_PREREQ (2,8)
274# define __attribute_format_arg__(x) __attribute__ ((__format_arg__ (x)))
275#else
276# define __attribute_format_arg__(x) /* Ignore */
277#endif
278
279/* At some point during the gcc 2.97 development the `strfmon' format
280 attribute for functions was introduced. We don't want to use it
281 unconditionally (although this would be possible) since it
282 generates warnings. */
283#if __GNUC_PREREQ (2,97)
284# define __attribute_format_strfmon__(a,b) \
285 __attribute__ ((__format__ (__strfmon__, a, b)))
286#else
287# define __attribute_format_strfmon__(a,b) /* Ignore */
288#endif
289
290/* The nonull function attribute allows to mark pointer parameters which
291 must not be NULL. */
292#if __GNUC_PREREQ (3,3)
293# define __nonnull(params) __attribute__ ((__nonnull__ params))
294#else
295# define __nonnull(params)
296#endif
297
298/* If fortification mode, we warn about unused results of certain
299 function calls which can lead to problems. */
300#if __GNUC_PREREQ (3,4)
301# define __attribute_warn_unused_result__ \
302 __attribute__ ((__warn_unused_result__))
303# if __USE_FORTIFY_LEVEL > 0
304# define __wur __attribute_warn_unused_result__
305# endif
306#else
307# define __attribute_warn_unused_result__ /* empty */
308#endif
309#ifndef __wur
310# define __wur /* Ignore */
311#endif
312
313/* Forces a function to be always inlined. */
314#if __GNUC_PREREQ (3,2)
315/* The Linux kernel defines __always_inline in stddef.h (283d7573), and
316 it conflicts with this definition. Therefore undefine it first to
317 allow either header to be included first. */
318# undef __always_inline
319# define __always_inline __inline __attribute__ ((__always_inline__))
320#else
321# undef __always_inline
322# define __always_inline __inline
323#endif
324
325/* Associate error messages with the source location of the call site rather
326 than with the source location inside the function. */
327#if __GNUC_PREREQ (4,3)
328# define __attribute_artificial__ __attribute__ ((__artificial__))
329#else
330# define __attribute_artificial__ /* Ignore */
331#endif
332
333/* GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99
334 inline semantics, unless -fgnu89-inline is used. Using __GNUC_STDC_INLINE__
335 or __GNUC_GNU_INLINE is not a good enough check for gcc because gcc versions
336 older than 4.3 may define these macros and still not guarantee GNU inlining
337 semantics.
338
339 clang++ identifies itself as gcc-4.2, but has support for GNU inlining
340 semantics, that can be checked for by using the __GNUC_STDC_INLINE_ and
341 __GNUC_GNU_INLINE__ macro definitions. */
342#if (!defined __cplusplus || __GNUC_PREREQ (4,3) \
343 || (defined __clang__ && (defined __GNUC_STDC_INLINE__ \
344 || defined __GNUC_GNU_INLINE__)))
345# if defined __GNUC_STDC_INLINE__ || defined __cplusplus
346# define __extern_inline extern __inline __attribute__ ((__gnu_inline__))
347# define __extern_always_inline \
348 extern __always_inline __attribute__ ((__gnu_inline__))
349# else
350# define __extern_inline extern __inline
351# define __extern_always_inline extern __always_inline
352# endif
353#endif
354
355#ifdef __extern_always_inline
356# define __fortify_function __extern_always_inline __attribute_artificial__
357#endif
358
359/* GCC 4.3 and above allow passing all anonymous arguments of an
360 __extern_always_inline function to some other vararg function. */
361#if __GNUC_PREREQ (4,3)
362# define __va_arg_pack() __builtin_va_arg_pack ()
363# define __va_arg_pack_len() __builtin_va_arg_pack_len ()
364#endif
365
366/* It is possible to compile containing GCC extensions even if GCC is
367 run in pedantic mode if the uses are carefully marked using the
368 `__extension__' keyword. But this is not generally available before
369 version 2.8. */
370#if !__GNUC_PREREQ (2,8)
371# define __extension__ /* Ignore */
372#endif
373
374/* __restrict is known in EGCS 1.2 and above. */
375#if !__GNUC_PREREQ (2,92)
376# if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
377# define __restrict restrict
378# else
379# define __restrict /* Ignore */
380# endif
381#endif
382
383/* ISO C99 also allows to declare arrays as non-overlapping. The syntax is
384 array_name[restrict]
385 GCC 3.1 supports this. */
386#if __GNUC_PREREQ (3,1) && !defined __GNUG__
387# define __restrict_arr __restrict
388#else
389# ifdef __GNUC__
390# define __restrict_arr /* Not supported in old GCC. */
391# else
392# if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
393# define __restrict_arr restrict
394# else
395/* Some other non-C99 compiler. */
396# define __restrict_arr /* Not supported. */
397# endif
398# endif
399#endif
400
401#if __GNUC__ >= 3
402# define __glibc_unlikely(cond) __builtin_expect ((cond), 0)
403# define __glibc_likely(cond) __builtin_expect ((cond), 1)
404#else
405# define __glibc_unlikely(cond) (cond)
406# define __glibc_likely(cond) (cond)
407#endif
408
409#ifdef __has_attribute
410# define __glibc_has_attribute(attr) __has_attribute (attr)
411#else
412# define __glibc_has_attribute(attr) 0
413#endif
414
415#if (!defined _Noreturn \
416 && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \
417 && !__GNUC_PREREQ (4,7))
418# if __GNUC_PREREQ (2,8)
419# define _Noreturn __attribute__ ((__noreturn__))
420# else
421# define _Noreturn
422# endif
423#endif
424
425#if __GNUC_PREREQ (8, 0)
426/* Describes a char array whose address can safely be passed as the first
427 argument to strncpy and strncat, as the char array is not necessarily
428 a NUL-terminated string. */
429# define __attribute_nonstring__ __attribute__ ((__nonstring__))
430#else
431# define __attribute_nonstring__
432#endif
433
434/* Undefine (also defined in libc-symbols.h). */
435#undef __attribute_copy__
436#if __GNUC_PREREQ (9, 0)
437/* Copies attributes from the declaration or type referenced by
438 the argument. */
439# define __attribute_copy__(arg) __attribute__ ((__copy__ (arg)))
440#else
441# define __attribute_copy__(arg)
442#endif
443
444#if (!defined _Static_assert && !defined __cplusplus \
445 && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \
446 && (!__GNUC_PREREQ (4, 6) || defined __STRICT_ANSI__))
447# define _Static_assert(expr, diagnostic) \
448 extern int (*__Static_assert_function (void)) \
449 [!!sizeof (struct { int __error_if_negative: (expr) ? 2 : -1; })]
450#endif
451
452#include <bits/wordsize.h>
453#include <bits/long-double.h>
454
455#if defined __LONG_DOUBLE_MATH_OPTIONAL && defined __NO_LONG_DOUBLE_MATH
456# define __LDBL_COMPAT 1
457# ifdef __REDIRECT
458# define __LDBL_REDIR1(name, proto, alias) __REDIRECT (name, proto, alias)
459# define __LDBL_REDIR(name, proto) \
460 __LDBL_REDIR1 (name, proto, __nldbl_##name)
461# define __LDBL_REDIR1_NTH(name, proto, alias) __REDIRECT_NTH (name, proto, alias)
462# define __LDBL_REDIR_NTH(name, proto) \
463 __LDBL_REDIR1_NTH (name, proto, __nldbl_##name)
464# define __LDBL_REDIR1_DECL(name, alias) \
465 extern __typeof (name) name __asm (__ASMNAME (#alias));
466# define __LDBL_REDIR_DECL(name) \
467 extern __typeof (name) name __asm (__ASMNAME ("__nldbl_" #name));
468# define __REDIRECT_LDBL(name, proto, alias) \
469 __LDBL_REDIR1 (name, proto, __nldbl_##alias)
470# define __REDIRECT_NTH_LDBL(name, proto, alias) \
471 __LDBL_REDIR1_NTH (name, proto, __nldbl_##alias)
472# endif
473#endif
474#if !defined __LDBL_COMPAT || !defined __REDIRECT
475# define __LDBL_REDIR1(name, proto, alias) name proto
476# define __LDBL_REDIR(name, proto) name proto
477# define __LDBL_REDIR1_NTH(name, proto, alias) name proto __THROW
478# define __LDBL_REDIR_NTH(name, proto) name proto __THROW
479# define __LDBL_REDIR_DECL(name)
480# ifdef __REDIRECT
481# define __REDIRECT_LDBL(name, proto, alias) __REDIRECT (name, proto, alias)
482# define __REDIRECT_NTH_LDBL(name, proto, alias) \
483 __REDIRECT_NTH (name, proto, alias)
484# endif
485#endif
486
487/* __glibc_macro_warning (MESSAGE) issues warning MESSAGE. This is
488 intended for use in preprocessor macros.
489
490 Note: MESSAGE must be a _single_ string; concatenation of string
491 literals is not supported. */
492#if __GNUC_PREREQ (4,8) || __glibc_clang_prereq (3,5)
493# define __glibc_macro_warning1(message) _Pragma (#message)
494# define __glibc_macro_warning(message) \
495 __glibc_macro_warning1 (GCC warning message)
496#else
497# define __glibc_macro_warning(msg)
498#endif
499
500/* Generic selection (ISO C11) is a C-only feature, available in GCC
501 since version 4.9. Previous versions do not provide generic
502 selection, even though they might set __STDC_VERSION__ to 201112L,
503 when in -std=c11 mode. Thus, we must check for !defined __GNUC__
504 when testing __STDC_VERSION__ for generic selection support.
505 On the other hand, Clang also defines __GNUC__, so a clang-specific
506 check is required to enable the use of generic selection. */
507#if !defined __cplusplus \
508 && (__GNUC_PREREQ (4, 9) \
509 || __glibc_clang_has_extension (c_generic_selections) \
510 || (!defined __GNUC__ && defined __STDC_VERSION__ \
511 && __STDC_VERSION__ >= 201112L))
512# define __HAVE_GENERIC_SELECTION 1
513#else
514# define __HAVE_GENERIC_SELECTION 0
515#endif
516
517#endif /* sys/cdefs.h */
libc/glibc-include/sys/debugreg.h created+88
...@@ -0,0 +1,88 @@
1/* Copyright (C) 2001-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_DEBUGREG_H
19#define _SYS_DEBUGREG_H 1
20
21/* Indicate the register numbers for a number of the specific
22 debug registers. Registers 0-3 contain the addresses we wish to trap on */
23#define DR_FIRSTADDR 0 /* u_debugreg[DR_FIRSTADDR] */
24#define DR_LASTADDR 3 /* u_debugreg[DR_LASTADDR] */
25
26#define DR_STATUS 6 /* u_debugreg[DR_STATUS] */
27#define DR_CONTROL 7 /* u_debugreg[DR_CONTROL] */
28
29/* Define a few things for the status register. We can use this to determine
30 which debugging register was responsible for the trap. The other bits
31 are either reserved or not of interest to us. */
32
33#define DR_TRAP0 (0x1) /* db0 */
34#define DR_TRAP1 (0x2) /* db1 */
35#define DR_TRAP2 (0x4) /* db2 */
36#define DR_TRAP3 (0x8) /* db3 */
37
38#define DR_STEP (0x4000) /* single-step */
39#define DR_SWITCH (0x8000) /* task switch */
40
41/* Now define a bunch of things for manipulating the control register.
42 The top two bytes of the control register consist of 4 fields of 4
43 bits - each field corresponds to one of the four debug registers,
44 and indicates what types of access we trap on, and how large the data
45 field is that we are looking at */
46
47#define DR_CONTROL_SHIFT 16 /* Skip this many bits in ctl register */
48#define DR_CONTROL_SIZE 4 /* 4 control bits per register */
49
50#define DR_RW_EXECUTE (0x0) /* Settings for the access types to trap on */
51#define DR_RW_WRITE (0x1)
52#define DR_RW_READ (0x3)
53
54#define DR_LEN_1 (0x0) /* Settings for data length to trap on */
55#define DR_LEN_2 (0x4)
56#define DR_LEN_4 (0xC)
57#ifdef __x86_64__
58# define DR_LEN_8 (0x8)
59#endif
60
61/* The low byte to the control register determine which registers are
62 enabled. There are 4 fields of two bits. One bit is "local", meaning
63 that the processor will reset the bit after a task switch and the other
64 is global meaning that we have to explicitly reset the bit. With linux,
65 you can use either one, since we explicitly zero the register when we enter
66 kernel mode. */
67
68#define DR_LOCAL_ENABLE_SHIFT 0 /* Extra shift to the local enable bit */
69#define DR_GLOBAL_ENABLE_SHIFT 1 /* Extra shift to the global enable bit */
70#define DR_ENABLE_SIZE 2 /* 2 enable bits per register */
71
72#define DR_LOCAL_ENABLE_MASK (0x55) /* Set local bits for all 4 regs */
73#define DR_GLOBAL_ENABLE_MASK (0xAA) /* Set global bits for all 4 regs */
74
75/* The second byte to the control register has a few special
76 things. */
77
78
79
80#ifdef __x86_64__
81# define DR_CONTROL_RESERVED (0xFFFFFFFF0000FC00ULL) /* Reserved */
82#else
83# define DR_CONTROL_RESERVED (0x00FC00U) /* Reserved */
84#endif
85#define DR_LOCAL_SLOWDOWN (0x100) /* Local slow the pipeline */
86#define DR_GLOBAL_SLOWDOWN (0x200) /* Global slow the pipeline */
87
88#endif /* sys/debugreg.h */
libc/glibc-include/sys/dir.h created+27
...@@ -0,0 +1,27 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_DIR_H
19#define _SYS_DIR_H 1
20
21#include <features.h>
22
23#include <dirent.h>
24
25#define direct dirent
26
27#endif /* sys/dir.h */
libc/glibc-include/sys/elf.h created+29
...@@ -0,0 +1,29 @@
1/* Copyright (C) 1998-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_ELF_H
19#define _SYS_ELF_H 1
20
21#ifdef __x86_64__
22# error This header is unsupported on x86-64.
23#else
24# warning "This header is obsolete; use <sys/procfs.h> instead."
25
26# include <sys/procfs.h>
27#endif
28
29#endif /* _SYS_ELF_H */
libc/glibc-include/sys/epoll.h created+138
...@@ -0,0 +1,138 @@
1/* Copyright (C) 2002-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_EPOLL_H
19#define _SYS_EPOLL_H 1
20
21#include <stdint.h>
22#include <sys/types.h>
23
24#include <bits/types/sigset_t.h>
25
26/* Get the platform-dependent flags. */
27#include <bits/epoll.h>
28
29#ifndef __EPOLL_PACKED
30# define __EPOLL_PACKED
31#endif
32
33
34enum EPOLL_EVENTS
35 {
36 EPOLLIN = 0x001,
37#define EPOLLIN EPOLLIN
38 EPOLLPRI = 0x002,
39#define EPOLLPRI EPOLLPRI
40 EPOLLOUT = 0x004,
41#define EPOLLOUT EPOLLOUT
42 EPOLLRDNORM = 0x040,
43#define EPOLLRDNORM EPOLLRDNORM
44 EPOLLRDBAND = 0x080,
45#define EPOLLRDBAND EPOLLRDBAND
46 EPOLLWRNORM = 0x100,
47#define EPOLLWRNORM EPOLLWRNORM
48 EPOLLWRBAND = 0x200,
49#define EPOLLWRBAND EPOLLWRBAND
50 EPOLLMSG = 0x400,
51#define EPOLLMSG EPOLLMSG
52 EPOLLERR = 0x008,
53#define EPOLLERR EPOLLERR
54 EPOLLHUP = 0x010,
55#define EPOLLHUP EPOLLHUP
56 EPOLLRDHUP = 0x2000,
57#define EPOLLRDHUP EPOLLRDHUP
58 EPOLLEXCLUSIVE = 1u << 28,
59#define EPOLLEXCLUSIVE EPOLLEXCLUSIVE
60 EPOLLWAKEUP = 1u << 29,
61#define EPOLLWAKEUP EPOLLWAKEUP
62 EPOLLONESHOT = 1u << 30,
63#define EPOLLONESHOT EPOLLONESHOT
64 EPOLLET = 1u << 31
65#define EPOLLET EPOLLET
66 };
67
68
69/* Valid opcodes ( "op" parameter ) to issue to epoll_ctl(). */
70#define EPOLL_CTL_ADD 1 /* Add a file descriptor to the interface. */
71#define EPOLL_CTL_DEL 2 /* Remove a file descriptor from the interface. */
72#define EPOLL_CTL_MOD 3 /* Change file descriptor epoll_event structure. */
73
74
75typedef union epoll_data
76{
77 void *ptr;
78 int fd;
79 uint32_t u32;
80 uint64_t u64;
81} epoll_data_t;
82
83struct epoll_event
84{
85 uint32_t events; /* Epoll events */
86 epoll_data_t data; /* User data variable */
87} __EPOLL_PACKED;
88
89
90__BEGIN_DECLS
91
92/* Creates an epoll instance. Returns an fd for the new instance.
93 The "size" parameter is a hint specifying the number of file
94 descriptors to be associated with the new instance. The fd
95 returned by epoll_create() should be closed with close(). */
96extern int epoll_create (int __size) __THROW;
97
98/* Same as epoll_create but with an FLAGS parameter. The unused SIZE
99 parameter has been dropped. */
100extern int epoll_create1 (int __flags) __THROW;
101
102
103/* Manipulate an epoll instance "epfd". Returns 0 in case of success,
104 -1 in case of error ( the "errno" variable will contain the
105 specific error code ) The "op" parameter is one of the EPOLL_CTL_*
106 constants defined above. The "fd" parameter is the target of the
107 operation. The "event" parameter describes which events the caller
108 is interested in and any associated user data. */
109extern int epoll_ctl (int __epfd, int __op, int __fd,
110 struct epoll_event *__event) __THROW;
111
112
113/* Wait for events on an epoll instance "epfd". Returns the number of
114 triggered events returned in "events" buffer. Or -1 in case of
115 error with the "errno" variable set to the specific error code. The
116 "events" parameter is a buffer that will contain triggered
117 events. The "maxevents" is the maximum number of events to be
118 returned ( usually size of "events" ). The "timeout" parameter
119 specifies the maximum wait time in milliseconds (-1 == infinite).
120
121 This function is a cancellation point and therefore not marked with
122 __THROW. */
123extern int epoll_wait (int __epfd, struct epoll_event *__events,
124 int __maxevents, int __timeout);
125
126
127/* Same as epoll_wait, but the thread's signal mask is temporarily
128 and atomically replaced with the one provided as parameter.
129
130 This function is a cancellation point and therefore not marked with
131 __THROW. */
132extern int epoll_pwait (int __epfd, struct epoll_event *__events,
133 int __maxevents, int __timeout,
134 const __sigset_t *__ss);
135
136__END_DECLS
137
138#endif /* sys/epoll.h */
libc/glibc-include/sys/errno.h created+1
...@@ -0,0 +1 @@
1#include <errno.h>
libc/glibc-include/sys/eventfd.h created+44
...@@ -0,0 +1,44 @@
1/* Copyright (C) 2007-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_EVENTFD_H
19#define _SYS_EVENTFD_H 1
20
21#include <stdint.h>
22
23/* Get the platform-dependent flags. */
24#include <bits/eventfd.h>
25
26/* Type for event counter. */
27typedef uint64_t eventfd_t;
28
29
30__BEGIN_DECLS
31
32/* Return file descriptor for generic event channel. Set initial
33 value to COUNT. */
34extern int eventfd (unsigned int __count, int __flags) __THROW;
35
36/* Read event counter and possibly wait for events. */
37extern int eventfd_read (int __fd, eventfd_t *__value);
38
39/* Increment event counter. */
40extern int eventfd_write (int __fd, eventfd_t __value);
41
42__END_DECLS
43
44#endif /* sys/eventfd.h */
libc/glibc-include/sys/fanotify.h created+38
...@@ -0,0 +1,38 @@
1/* Copyright (C) 2010-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_FANOTIFY_H
19#define _SYS_FANOTIFY_H 1
20
21#include <stdint.h>
22#include <linux/fanotify.h>
23
24
25__BEGIN_DECLS
26
27/* Create and initialize fanotify group. */
28extern int fanotify_init (unsigned int __flags, unsigned int __event_f_flags)
29 __THROW;
30
31/* Add, remove, or modify an fanotify mark on a filesystem object. */
32extern int fanotify_mark (int __fanotify_fd, unsigned int __flags,
33 uint64_t __mask, int __dfd, const char *__pathname)
34 __THROW;
35
36__END_DECLS
37
38#endif /* sys/fanotify.h */
libc/glibc-include/sys/fcntl.h created+1
...@@ -0,0 +1 @@
1#include <fcntl.h>
libc/glibc-include/sys/file.h created+55
...@@ -0,0 +1,55 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_FILE_H
19#define _SYS_FILE_H 1
20
21#include <features.h>
22
23#ifndef _FCNTL_H
24# include <fcntl.h>
25#endif
26
27__BEGIN_DECLS
28
29
30/* Alternate names for values for the WHENCE argument to `lseek'.
31 These are the same as SEEK_SET, SEEK_CUR, and SEEK_END, respectively. */
32#ifndef L_SET
33# define L_SET 0 /* Seek from beginning of file. */
34# define L_INCR 1 /* Seek from current position. */
35# define L_XTND 2 /* Seek from end of file. */
36#endif
37
38
39/* Operations for the `flock' call. */
40#define LOCK_SH 1 /* Shared lock. */
41#define LOCK_EX 2 /* Exclusive lock. */
42#define LOCK_UN 8 /* Unlock. */
43
44/* Can be OR'd in to one of the above. */
45#define LOCK_NB 4 /* Don't block when locking. */
46
47
48/* Apply or remove an advisory lock, according to OPERATION,
49 on the file FD refers to. */
50extern int flock (int __fd, int __operation) __THROW;
51
52
53__END_DECLS
54
55#endif /* sys/file.h */
libc/glibc-include/sys/fsuid.h created+35
...@@ -0,0 +1,35 @@
1/* Copyright (C) 1997-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_FSUID_H
19#define _SYS_FSUID_H 1
20
21#include <features.h>
22#include <sys/types.h>
23
24__BEGIN_DECLS
25
26/* Change uid used for file access control to UID, without affecting
27 other privileges (such as who can send signals at the process). */
28extern int setfsuid (__uid_t __uid) __THROW;
29
30/* Ditto for group id. */
31extern int setfsgid (__gid_t __gid) __THROW;
32
33__END_DECLS
34
35#endif /* fsuid.h */
libc/glibc-include/sys/gmon.h created+201
...@@ -0,0 +1,201 @@
1/*-
2 * Copyright (c) 1982, 1986, 1992, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 4. Neither the name of the University nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * @(#)gmon.h 8.2 (Berkeley) 1/4/94
30 */
31
32#ifndef _SYS_GMON_H
33#define _SYS_GMON_H 1
34
35#include <features.h>
36
37#include <sys/types.h>
38
39/*
40 * See gmon_out.h for gmon.out format.
41 */
42
43/* structure emitted by "gcc -a". This must match struct bb in
44 gcc/libgcc2.c. It is OK for gcc to declare a longer structure as
45 long as the members below are present. */
46struct __bb
47{
48 long zero_word;
49 const char *filename;
50 long *counts;
51 long ncounts;
52 struct __bb *next;
53 const unsigned long *addresses;
54};
55
56extern struct __bb *__bb_head;
57
58/*
59 * histogram counters are unsigned shorts (according to the kernel).
60 */
61#define HISTCOUNTER unsigned short
62
63/*
64 * fraction of text space to allocate for histogram counters here, 1/2
65 */
66#define HISTFRACTION 2
67
68/*
69 * Fraction of text space to allocate for from hash buckets.
70 * The value of HASHFRACTION is based on the minimum number of bytes
71 * of separation between two subroutine call points in the object code.
72 * Given MIN_SUBR_SEPARATION bytes of separation the value of
73 * HASHFRACTION is calculated as:
74 *
75 * HASHFRACTION = MIN_SUBR_SEPARATION / (2 * sizeof(short) - 1);
76 *
77 * For example, on the VAX, the shortest two call sequence is:
78 *
79 * calls $0,(r0)
80 * calls $0,(r0)
81 *
82 * which is separated by only three bytes, thus HASHFRACTION is
83 * calculated as:
84 *
85 * HASHFRACTION = 3 / (2 * 2 - 1) = 1
86 *
87 * Note that the division above rounds down, thus if MIN_SUBR_FRACTION
88 * is less than three, this algorithm will not work!
89 *
90 * In practice, however, call instructions are rarely at a minimal
91 * distance. Hence, we will define HASHFRACTION to be 2 across all
92 * architectures. This saves a reasonable amount of space for
93 * profiling data structures without (in practice) sacrificing
94 * any granularity.
95 */
96#define HASHFRACTION 2
97
98/*
99 * Percent of text space to allocate for tostructs.
100 * This is a heuristic; we will fail with a warning when profiling programs
101 * with a very large number of very small functions, but that's
102 * normally OK.
103 * 2 is probably still a good value for normal programs.
104 * Profiling a test case with 64000 small functions will work if
105 * you raise this value to 3 and link statically (which bloats the
106 * text size, thus raising the number of arcs expected by the heuristic).
107 */
108#define ARCDENSITY 3
109
110/*
111 * Always allocate at least this many tostructs. This
112 * hides the inadequacy of the ARCDENSITY heuristic, at least
113 * for small programs.
114 */
115#define MINARCS 50
116
117/*
118 * The type used to represent indices into gmonparam.tos[].
119 */
120#define ARCINDEX unsigned long
121
122/*
123 * Maximum number of arcs we want to allow.
124 * Used to be max representable value of ARCINDEX minus 2, but now
125 * that ARCINDEX is a long, that's too large; we don't really want
126 * to allow a 48 gigabyte table.
127 * The old value of 1<<16 wasn't high enough in practice for large C++
128 * programs; will 1<<20 be adequate for long? FIXME
129 */
130#define MAXARCS (1 << 20)
131
132struct tostruct {
133 unsigned long selfpc;
134 long count;
135 ARCINDEX link;
136};
137
138/*
139 * a raw arc, with pointers to the calling site and
140 * the called site and a count.
141 */
142struct rawarc {
143 unsigned long raw_frompc;
144 unsigned long raw_selfpc;
145 long raw_count;
146};
147
148/*
149 * general rounding functions.
150 */
151#define ROUNDDOWN(x,y) (((x)/(y))*(y))
152#define ROUNDUP(x,y) ((((x)+(y)-1)/(y))*(y))
153
154/*
155 * The profiling data structures are housed in this structure.
156 */
157struct gmonparam {
158 long int state;
159 unsigned short *kcount;
160 unsigned long kcountsize;
161 ARCINDEX *froms;
162 unsigned long fromssize;
163 struct tostruct *tos;
164 unsigned long tossize;
165 long tolimit;
166 unsigned long lowpc;
167 unsigned long highpc;
168 unsigned long textsize;
169 unsigned long hashfraction;
170 long log_hashfraction;
171};
172
173/*
174 * Possible states of profiling.
175 */
176#define GMON_PROF_ON 0
177#define GMON_PROF_BUSY 1
178#define GMON_PROF_ERROR 2
179#define GMON_PROF_OFF 3
180
181/*
182 * Sysctl definitions for extracting profiling information from the kernel.
183 */
184#define GPROF_STATE 0 /* int: profiling enabling variable */
185#define GPROF_COUNT 1 /* struct: profile tick count buffer */
186#define GPROF_FROMS 2 /* struct: from location hash bucket */
187#define GPROF_TOS 3 /* struct: destination/count structure */
188#define GPROF_GMONPARAM 4 /* struct: profiling parameters (see above) */
189
190__BEGIN_DECLS
191
192/* Set up data structures and start profiling. */
193extern void __monstartup (unsigned long __lowpc, unsigned long __highpc) __THROW;
194extern void monstartup (unsigned long __lowpc, unsigned long __highpc) __THROW;
195
196/* Clean up profiling and write out gmon.out. */
197extern void _mcleanup (void) __THROW;
198
199__END_DECLS
200
201#endif /* sys/gmon.h */
libc/glibc-include/sys/gmon_out.h created+79
...@@ -0,0 +1,79 @@
1/* Copyright (C) 1996-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by David Mosberger <davidm@cs.arizona.edu>.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19/* This file specifies the format of gmon.out files. It should have
20 as few external dependencies as possible as it is going to be included
21 in many different programs. That is, minimize the number of #include's.
22
23 A gmon.out file consists of a header (defined by gmon_hdr) followed by
24 a sequence of records. Each record starts with a one-byte tag
25 identifying the type of records, followed by records specific data. */
26
27#ifndef _SYS_GMON_OUT_H
28#define _SYS_GMON_OUT_H 1
29
30#include <features.h>
31
32#define GMON_MAGIC "gmon" /* magic cookie */
33#define GMON_VERSION 1 /* version number */
34
35/* For profiling shared object we need a new format. */
36#define GMON_SHOBJ_VERSION 0x1ffff
37
38__BEGIN_DECLS
39
40/*
41 * Raw header as it appears on file (without padding). This header
42 * always comes first in gmon.out and is then followed by a series
43 * records defined below.
44 */
45struct gmon_hdr
46 {
47 char cookie[4];
48 char version[4];
49 char spare[3 * 4];
50 };
51
52/* types of records in this file: */
53typedef enum
54 {
55 GMON_TAG_TIME_HIST = 0,
56 GMON_TAG_CG_ARC = 1,
57 GMON_TAG_BB_COUNT = 2
58 } GMON_Record_Tag;
59
60struct gmon_hist_hdr
61 {
62 char low_pc[sizeof (char *)]; /* base pc address of sample buffer */
63 char high_pc[sizeof (char *)]; /* max pc address of sampled buffer */
64 char hist_size[4]; /* size of sample buffer */
65 char prof_rate[4]; /* profiling clock rate */
66 char dimen[15]; /* phys. dim., usually "seconds" */
67 char dimen_abbrev; /* usually 's' for "seconds" */
68 };
69
70struct gmon_cg_arc_record
71 {
72 char from_pc[sizeof (char *)]; /* address within caller's body */
73 char self_pc[sizeof (char *)]; /* address within callee's body */
74 char count[4]; /* number of arc traversals */
75 };
76
77__END_DECLS
78
79#endif /* sys/gmon_out.h */
libc/glibc-include/sys/inotify.h created+100
...@@ -0,0 +1,100 @@
1/* Copyright (C) 2005-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_INOTIFY_H
19#define _SYS_INOTIFY_H 1
20
21#include <stdint.h>
22
23/* Get the platform-dependent flags. */
24#include <bits/inotify.h>
25
26
27/* Structure describing an inotify event. */
28struct inotify_event
29{
30 int wd; /* Watch descriptor. */
31 uint32_t mask; /* Watch mask. */
32 uint32_t cookie; /* Cookie to synchronize two events. */
33 uint32_t len; /* Length (including NULs) of name. */
34 char name __flexarr; /* Name. */
35};
36
37
38/* Supported events suitable for MASK parameter of INOTIFY_ADD_WATCH. */
39#define IN_ACCESS 0x00000001 /* File was accessed. */
40#define IN_MODIFY 0x00000002 /* File was modified. */
41#define IN_ATTRIB 0x00000004 /* Metadata changed. */
42#define IN_CLOSE_WRITE 0x00000008 /* Writtable file was closed. */
43#define IN_CLOSE_NOWRITE 0x00000010 /* Unwrittable file closed. */
44#define IN_CLOSE (IN_CLOSE_WRITE | IN_CLOSE_NOWRITE) /* Close. */
45#define IN_OPEN 0x00000020 /* File was opened. */
46#define IN_MOVED_FROM 0x00000040 /* File was moved from X. */
47#define IN_MOVED_TO 0x00000080 /* File was moved to Y. */
48#define IN_MOVE (IN_MOVED_FROM | IN_MOVED_TO) /* Moves. */
49#define IN_CREATE 0x00000100 /* Subfile was created. */
50#define IN_DELETE 0x00000200 /* Subfile was deleted. */
51#define IN_DELETE_SELF 0x00000400 /* Self was deleted. */
52#define IN_MOVE_SELF 0x00000800 /* Self was moved. */
53
54/* Events sent by the kernel. */
55#define IN_UNMOUNT 0x00002000 /* Backing fs was unmounted. */
56#define IN_Q_OVERFLOW 0x00004000 /* Event queued overflowed. */
57#define IN_IGNORED 0x00008000 /* File was ignored. */
58
59/* Helper events. */
60#define IN_CLOSE (IN_CLOSE_WRITE | IN_CLOSE_NOWRITE) /* Close. */
61#define IN_MOVE (IN_MOVED_FROM | IN_MOVED_TO) /* Moves. */
62
63/* Special flags. */
64#define IN_ONLYDIR 0x01000000 /* Only watch the path if it is a
65 directory. */
66#define IN_DONT_FOLLOW 0x02000000 /* Do not follow a sym link. */
67#define IN_EXCL_UNLINK 0x04000000 /* Exclude events on unlinked
68 objects. */
69#define IN_MASK_CREATE 0x10000000 /* Only create watches. */
70#define IN_MASK_ADD 0x20000000 /* Add to the mask of an already
71 existing watch. */
72#define IN_ISDIR 0x40000000 /* Event occurred against dir. */
73#define IN_ONESHOT 0x80000000 /* Only send event once. */
74
75/* All events which a program can wait on. */
76#define IN_ALL_EVENTS (IN_ACCESS | IN_MODIFY | IN_ATTRIB | IN_CLOSE_WRITE \
77 | IN_CLOSE_NOWRITE | IN_OPEN | IN_MOVED_FROM \
78 | IN_MOVED_TO | IN_CREATE | IN_DELETE \
79 | IN_DELETE_SELF | IN_MOVE_SELF)
80
81
82__BEGIN_DECLS
83
84/* Create and initialize inotify instance. */
85extern int inotify_init (void) __THROW;
86
87/* Create and initialize inotify instance. */
88extern int inotify_init1 (int __flags) __THROW;
89
90/* Add watch of object NAME to inotify instance FD. Notify about
91 events specified by MASK. */
92extern int inotify_add_watch (int __fd, const char *__name, uint32_t __mask)
93 __THROW;
94
95/* Remove the watch specified by WD from the inotify instance FD. */
96extern int inotify_rm_watch (int __fd, int __wd) __THROW;
97
98__END_DECLS
99
100#endif /* sys/inotify.h */
libc/glibc-include/sys/io.h created+183
...@@ -0,0 +1,183 @@
1/* Copyright (C) 1996-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_IO_H
19#define _SYS_IO_H 1
20
21#include <features.h>
22
23__BEGIN_DECLS
24
25/* If TURN_ON is TRUE, request for permission to do direct i/o on the
26 port numbers in the range [FROM,FROM+NUM-1]. Otherwise, turn I/O
27 permission off for that range. This call requires root privileges.
28
29 Portability note: not all Linux platforms support this call. Most
30 platforms based on the PC I/O architecture probably will, however.
31 E.g., Linux/Alpha for Alpha PCs supports this. */
32extern int ioperm (unsigned long int __from, unsigned long int __num,
33 int __turn_on) __THROW;
34
35/* Set the I/O privilege level to LEVEL. If LEVEL>3, permission to
36 access any I/O port is granted. This call requires root
37 privileges. */
38extern int iopl (int __level) __THROW;
39
40#if defined __GNUC__ && __GNUC__ >= 2
41
42static __inline unsigned char
43inb (unsigned short int __port)
44{
45 unsigned char _v;
46
47 __asm__ __volatile__ ("inb %w1,%0":"=a" (_v):"Nd" (__port));
48 return _v;
49}
50
51static __inline unsigned char
52inb_p (unsigned short int __port)
53{
54 unsigned char _v;
55
56 __asm__ __volatile__ ("inb %w1,%0\noutb %%al,$0x80":"=a" (_v):"Nd" (__port));
57 return _v;
58}
59
60static __inline unsigned short int
61inw (unsigned short int __port)
62{
63 unsigned short _v;
64
65 __asm__ __volatile__ ("inw %w1,%0":"=a" (_v):"Nd" (__port));
66 return _v;
67}
68
69static __inline unsigned short int
70inw_p (unsigned short int __port)
71{
72 unsigned short int _v;
73
74 __asm__ __volatile__ ("inw %w1,%0\noutb %%al,$0x80":"=a" (_v):"Nd" (__port));
75 return _v;
76}
77
78static __inline unsigned int
79inl (unsigned short int __port)
80{
81 unsigned int _v;
82
83 __asm__ __volatile__ ("inl %w1,%0":"=a" (_v):"Nd" (__port));
84 return _v;
85}
86
87static __inline unsigned int
88inl_p (unsigned short int __port)
89{
90 unsigned int _v;
91 __asm__ __volatile__ ("inl %w1,%0\noutb %%al,$0x80":"=a" (_v):"Nd" (__port));
92 return _v;
93}
94
95static __inline void
96outb (unsigned char __value, unsigned short int __port)
97{
98 __asm__ __volatile__ ("outb %b0,%w1": :"a" (__value), "Nd" (__port));
99}
100
101static __inline void
102outb_p (unsigned char __value, unsigned short int __port)
103{
104 __asm__ __volatile__ ("outb %b0,%w1\noutb %%al,$0x80": :"a" (__value),
105 "Nd" (__port));
106}
107
108static __inline void
109outw (unsigned short int __value, unsigned short int __port)
110{
111 __asm__ __volatile__ ("outw %w0,%w1": :"a" (__value), "Nd" (__port));
112
113}
114
115static __inline void
116outw_p (unsigned short int __value, unsigned short int __port)
117{
118 __asm__ __volatile__ ("outw %w0,%w1\noutb %%al,$0x80": :"a" (__value),
119 "Nd" (__port));
120}
121
122static __inline void
123outl (unsigned int __value, unsigned short int __port)
124{
125 __asm__ __volatile__ ("outl %0,%w1": :"a" (__value), "Nd" (__port));
126}
127
128static __inline void
129outl_p (unsigned int __value, unsigned short int __port)
130{
131 __asm__ __volatile__ ("outl %0,%w1\noutb %%al,$0x80": :"a" (__value),
132 "Nd" (__port));
133}
134
135static __inline void
136insb (unsigned short int __port, void *__addr, unsigned long int __count)
137{
138 __asm__ __volatile__ ("cld ; rep ; insb":"=D" (__addr), "=c" (__count)
139 :"d" (__port), "0" (__addr), "1" (__count));
140}
141
142static __inline void
143insw (unsigned short int __port, void *__addr, unsigned long int __count)
144{
145 __asm__ __volatile__ ("cld ; rep ; insw":"=D" (__addr), "=c" (__count)
146 :"d" (__port), "0" (__addr), "1" (__count));
147}
148
149static __inline void
150insl (unsigned short int __port, void *__addr, unsigned long int __count)
151{
152 __asm__ __volatile__ ("cld ; rep ; insl":"=D" (__addr), "=c" (__count)
153 :"d" (__port), "0" (__addr), "1" (__count));
154}
155
156static __inline void
157outsb (unsigned short int __port, const void *__addr,
158 unsigned long int __count)
159{
160 __asm__ __volatile__ ("cld ; rep ; outsb":"=S" (__addr), "=c" (__count)
161 :"d" (__port), "0" (__addr), "1" (__count));
162}
163
164static __inline void
165outsw (unsigned short int __port, const void *__addr,
166 unsigned long int __count)
167{
168 __asm__ __volatile__ ("cld ; rep ; outsw":"=S" (__addr), "=c" (__count)
169 :"d" (__port), "0" (__addr), "1" (__count));
170}
171
172static __inline void
173outsl (unsigned short int __port, const void *__addr,
174 unsigned long int __count)
175{
176 __asm__ __volatile__ ("cld ; rep ; outsl":"=S" (__addr), "=c" (__count)
177 :"d" (__port), "0" (__addr), "1" (__count));
178}
179
180#endif /* GNU C */
181
182__END_DECLS
183#endif /* _SYS_IO_H */
libc/glibc-include/sys/ioctl.h created+45
...@@ -0,0 +1,45 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_IOCTL_H
19#define _SYS_IOCTL_H 1
20
21#include <features.h>
22
23__BEGIN_DECLS
24
25/* Get the list of `ioctl' requests and related constants. */
26#include <bits/ioctls.h>
27
28/* Define some types used by `ioctl' requests. */
29#include <bits/ioctl-types.h>
30
31/* On a Unix system, the system <sys/ioctl.h> probably defines some of
32 the symbols we define in <sys/ttydefaults.h> (usually with the same
33 values). The code to generate <bits/ioctls.h> has omitted these
34 symbols to avoid the conflict, but a Unix program expects <sys/ioctl.h>
35 to define them, so we must include <sys/ttydefaults.h> here. */
36#include <sys/ttydefaults.h>
37
38/* Perform the I/O control operation specified by REQUEST on FD.
39 One argument may follow; its presence and type depend on REQUEST.
40 Return value depends on REQUEST. Usually -1 indicates error. */
41extern int ioctl (int __fd, unsigned long int __request, ...) __THROW;
42
43__END_DECLS
44
45#endif /* sys/ioctl.h */
libc/glibc-include/sys/ipc.h created+54
...@@ -0,0 +1,54 @@
1/* Copyright (C) 1995-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_IPC_H
19#define _SYS_IPC_H 1
20
21#include <features.h>
22
23/* Get system dependent definition of `struct ipc_perm' and more. */
24#include <bits/ipctypes.h>
25#include <bits/ipc.h>
26
27#ifndef __uid_t_defined
28typedef __uid_t uid_t;
29# define __uid_t_defined
30#endif
31
32#ifndef __gid_t_defined
33typedef __gid_t gid_t;
34# define __gid_t_defined
35#endif
36
37#ifndef __mode_t_defined
38typedef __mode_t mode_t;
39# define __mode_t_defined
40#endif
41
42#ifndef __key_t_defined
43typedef __key_t key_t;
44# define __key_t_defined
45#endif
46
47__BEGIN_DECLS
48
49/* Generates key for System V style IPC. */
50extern key_t ftok (const char *__pathname, int __proj_id) __THROW;
51
52__END_DECLS
53
54#endif /* sys/ipc.h */
libc/glibc-include/sys/kd.h created+34
...@@ -0,0 +1,34 @@
1/* Copyright (C) 1996-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_KD_H
19#define _SYS_KD_H 1
20
21/* Make sure the <linux/types.h> header is not loaded. */
22#ifndef _LINUX_TYPES_H
23# define _LINUX_TYPES_H 1
24# define __undef_LINUX_TYPES_H
25#endif
26
27#include <linux/kd.h>
28
29#ifdef __undef_LINUX_TYPES_H
30# undef _LINUX_TYPES_H
31# undef __undef_LINUX_TYPES_H
32#endif
33
34#endif /* sys/kd.h */
libc/glibc-include/sys/klog.h created+33
...@@ -0,0 +1,33 @@
1/* Copyright (C) 1996-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_KLOG_H
19
20#define _SYS_KLOG_H 1
21#include <features.h>
22
23__BEGIN_DECLS
24
25/* Control the kernel's logging facility. This corresponds exactly to
26 the kernel's syslog system call, but that name is easily confused
27 with the user-level syslog facility, which is something completely
28 different. */
29extern int klogctl (int __type, char *__bufp, int __len) __THROW;
30
31__END_DECLS
32
33#endif /* _SYS_KLOG_H */
libc/glibc-include/sys/mman.h created+151
...@@ -0,0 +1,151 @@
1/* Definitions for BSD-style memory management.
2 Copyright (C) 1994-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SYS_MMAN_H
20#define _SYS_MMAN_H 1
21
22#include <features.h>
23#include <bits/types.h>
24#define __need_size_t
25#include <stddef.h>
26
27#ifndef __off_t_defined
28# ifndef __USE_FILE_OFFSET64
29typedef __off_t off_t;
30# else
31typedef __off64_t off_t;
32# endif
33# define __off_t_defined
34#endif
35
36#ifndef __mode_t_defined
37typedef __mode_t mode_t;
38# define __mode_t_defined
39#endif
40
41#include <bits/mman.h>
42
43/* Return value of `mmap' in case of an error. */
44#define MAP_FAILED ((void *) -1)
45
46__BEGIN_DECLS
47/* Map addresses starting near ADDR and extending for LEN bytes. from
48 OFFSET into the file FD describes according to PROT and FLAGS. If ADDR
49 is nonzero, it is the desired mapping address. If the MAP_FIXED bit is
50 set in FLAGS, the mapping will be at ADDR exactly (which must be
51 page-aligned); otherwise the system chooses a convenient nearby address.
52 The return value is the actual mapping address chosen or MAP_FAILED
53 for errors (in which case `errno' is set). A successful `mmap' call
54 deallocates any previous mapping for the affected region. */
55
56#ifndef __USE_FILE_OFFSET64
57extern void *mmap (void *__addr, size_t __len, int __prot,
58 int __flags, int __fd, __off_t __offset) __THROW;
59#else
60# ifdef __REDIRECT_NTH
61extern void * __REDIRECT_NTH (mmap,
62 (void *__addr, size_t __len, int __prot,
63 int __flags, int __fd, __off64_t __offset),
64 mmap64);
65# else
66# define mmap mmap64
67# endif
68#endif
69#ifdef __USE_LARGEFILE64
70extern void *mmap64 (void *__addr, size_t __len, int __prot,
71 int __flags, int __fd, __off64_t __offset) __THROW;
72#endif
73
74/* Deallocate any mapping for the region starting at ADDR and extending LEN
75 bytes. Returns 0 if successful, -1 for errors (and sets errno). */
76extern int munmap (void *__addr, size_t __len) __THROW;
77
78/* Change the memory protection of the region starting at ADDR and
79 extending LEN bytes to PROT. Returns 0 if successful, -1 for errors
80 (and sets errno). */
81extern int mprotect (void *__addr, size_t __len, int __prot) __THROW;
82
83/* Synchronize the region starting at ADDR and extending LEN bytes with the
84 file it maps. Filesystem operations on a file being mapped are
85 unpredictable before this is done. Flags are from the MS_* set.
86
87 This function is a cancellation point and therefore not marked with
88 __THROW. */
89extern int msync (void *__addr, size_t __len, int __flags);
90
91#ifdef __USE_MISC
92/* Advise the system about particular usage patterns the program follows
93 for the region starting at ADDR and extending LEN bytes. */
94extern int madvise (void *__addr, size_t __len, int __advice) __THROW;
95#endif
96#ifdef __USE_XOPEN2K
97/* This is the POSIX name for this function. */
98extern int posix_madvise (void *__addr, size_t __len, int __advice) __THROW;
99#endif
100
101/* Guarantee all whole pages mapped by the range [ADDR,ADDR+LEN) to
102 be memory resident. */
103extern int mlock (const void *__addr, size_t __len) __THROW;
104
105/* Unlock whole pages previously mapped by the range [ADDR,ADDR+LEN). */
106extern int munlock (const void *__addr, size_t __len) __THROW;
107
108/* Cause all currently mapped pages of the process to be memory resident
109 until unlocked by a call to the `munlockall', until the process exits,
110 or until the process calls `execve'. */
111extern int mlockall (int __flags) __THROW;
112
113/* All currently mapped pages of the process' address space become
114 unlocked. */
115extern int munlockall (void) __THROW;
116
117#ifdef __USE_MISC
118/* mincore returns the memory residency status of the pages in the
119 current process's address space specified by [start, start + len).
120 The status is returned in a vector of bytes. The least significant
121 bit of each byte is 1 if the referenced page is in memory, otherwise
122 it is zero. */
123extern int mincore (void *__start, size_t __len, unsigned char *__vec)
124 __THROW;
125#endif
126
127#ifdef __USE_GNU
128/* Remap pages mapped by the range [ADDR,ADDR+OLD_LEN) to new length
129 NEW_LEN. If MREMAP_MAYMOVE is set in FLAGS the returned address
130 may differ from ADDR. If MREMAP_FIXED is set in FLAGS the function
131 takes another parameter which is a fixed address at which the block
132 resides after a successful call. */
133extern void *mremap (void *__addr, size_t __old_len, size_t __new_len,
134 int __flags, ...) __THROW;
135
136/* Remap arbitrary pages of a shared backing store within an existing
137 VMA. */
138extern int remap_file_pages (void *__start, size_t __size, int __prot,
139 size_t __pgoff, int __flags) __THROW;
140#endif
141
142
143/* Open shared memory segment. */
144extern int shm_open (const char *__name, int __oflag, mode_t __mode);
145
146/* Remove shared memory segment. */
147extern int shm_unlink (const char *__name);
148
149__END_DECLS
150
151#endif /* sys/mman.h */
libc/glibc-include/sys/mount.h created+150
...@@ -0,0 +1,150 @@
1/* Header file for mounting/unmount Linux filesystems.
2 Copyright (C) 1996-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19/* This is taken from /usr/include/linux/fs.h. */
20
21#ifndef _SYS_MOUNT_H
22#define _SYS_MOUNT_H 1
23
24#include <features.h>
25#include <sys/ioctl.h>
26
27#define BLOCK_SIZE 1024
28#define BLOCK_SIZE_BITS 10
29
30
31/* These are the fs-independent mount-flags: up to 16 flags are
32 supported */
33enum
34{
35 MS_RDONLY = 1, /* Mount read-only. */
36#define MS_RDONLY MS_RDONLY
37 MS_NOSUID = 2, /* Ignore suid and sgid bits. */
38#define MS_NOSUID MS_NOSUID
39 MS_NODEV = 4, /* Disallow access to device special files. */
40#define MS_NODEV MS_NODEV
41 MS_NOEXEC = 8, /* Disallow program execution. */
42#define MS_NOEXEC MS_NOEXEC
43 MS_SYNCHRONOUS = 16, /* Writes are synced at once. */
44#define MS_SYNCHRONOUS MS_SYNCHRONOUS
45 MS_REMOUNT = 32, /* Alter flags of a mounted FS. */
46#define MS_REMOUNT MS_REMOUNT
47 MS_MANDLOCK = 64, /* Allow mandatory locks on an FS. */
48#define MS_MANDLOCK MS_MANDLOCK
49 MS_DIRSYNC = 128, /* Directory modifications are synchronous. */
50#define MS_DIRSYNC MS_DIRSYNC
51 MS_NOATIME = 1024, /* Do not update access times. */
52#define MS_NOATIME MS_NOATIME
53 MS_NODIRATIME = 2048, /* Do not update directory access times. */
54#define MS_NODIRATIME MS_NODIRATIME
55 MS_BIND = 4096, /* Bind directory at different place. */
56#define MS_BIND MS_BIND
57 MS_MOVE = 8192,
58#define MS_MOVE MS_MOVE
59 MS_REC = 16384,
60#define MS_REC MS_REC
61 MS_SILENT = 32768,
62#define MS_SILENT MS_SILENT
63 MS_POSIXACL = 1 << 16, /* VFS does not apply the umask. */
64#define MS_POSIXACL MS_POSIXACL
65 MS_UNBINDABLE = 1 << 17, /* Change to unbindable. */
66#define MS_UNBINDABLE MS_UNBINDABLE
67 MS_PRIVATE = 1 << 18, /* Change to private. */
68#define MS_PRIVATE MS_PRIVATE
69 MS_SLAVE = 1 << 19, /* Change to slave. */
70#define MS_SLAVE MS_SLAVE
71 MS_SHARED = 1 << 20, /* Change to shared. */
72#define MS_SHARED MS_SHARED
73 MS_RELATIME = 1 << 21, /* Update atime relative to mtime/ctime. */
74#define MS_RELATIME MS_RELATIME
75 MS_KERNMOUNT = 1 << 22, /* This is a kern_mount call. */
76#define MS_KERNMOUNT MS_KERNMOUNT
77 MS_I_VERSION = 1 << 23, /* Update inode I_version field. */
78#define MS_I_VERSION MS_I_VERSION
79 MS_STRICTATIME = 1 << 24, /* Always perform atime updates. */
80#define MS_STRICTATIME MS_STRICTATIME
81 MS_LAZYTIME = 1 << 25, /* Update the on-disk [acm]times lazily. */
82#define MS_LAZYTIME MS_LAZYTIME
83 MS_ACTIVE = 1 << 30,
84#define MS_ACTIVE MS_ACTIVE
85 MS_NOUSER = 1 << 31
86#define MS_NOUSER MS_NOUSER
87};
88
89/* Flags that can be altered by MS_REMOUNT */
90#define MS_RMT_MASK (MS_RDONLY|MS_SYNCHRONOUS|MS_MANDLOCK|MS_I_VERSION \
91 |MS_LAZYTIME)
92
93
94/* Magic mount flag number. Has to be or-ed to the flag values. */
95
96#define MS_MGC_VAL 0xc0ed0000 /* Magic flag number to indicate "new" flags */
97#define MS_MGC_MSK 0xffff0000 /* Magic flag number mask */
98
99
100/* The read-only stuff doesn't really belong here, but any other place
101 is probably as bad and I don't want to create yet another include
102 file. */
103
104#define BLKROSET _IO(0x12, 93) /* Set device read-only (0 = read-write). */
105#define BLKROGET _IO(0x12, 94) /* Get read-only status (0 = read_write). */
106#define BLKRRPART _IO(0x12, 95) /* Re-read partition table. */
107#define BLKGETSIZE _IO(0x12, 96) /* Return device size. */
108#define BLKFLSBUF _IO(0x12, 97) /* Flush buffer cache. */
109#define BLKRASET _IO(0x12, 98) /* Set read ahead for block device. */
110#define BLKRAGET _IO(0x12, 99) /* Get current read ahead setting. */
111#define BLKFRASET _IO(0x12,100) /* Set filesystem read-ahead. */
112#define BLKFRAGET _IO(0x12,101) /* Get filesystem read-ahead. */
113#define BLKSECTSET _IO(0x12,102) /* Set max sectors per request. */
114#define BLKSECTGET _IO(0x12,103) /* Get max sectors per request. */
115#define BLKSSZGET _IO(0x12,104) /* Get block device sector size. */
116#define BLKBSZGET _IOR(0x12,112,size_t)
117#define BLKBSZSET _IOW(0x12,113,size_t)
118#define BLKGETSIZE64 _IOR(0x12,114,size_t) /* return device size. */
119
120
121/* Possible value for FLAGS parameter of `umount2'. */
122enum
123{
124 MNT_FORCE = 1, /* Force unmounting. */
125#define MNT_FORCE MNT_FORCE
126 MNT_DETACH = 2, /* Just detach from the tree. */
127#define MNT_DETACH MNT_DETACH
128 MNT_EXPIRE = 4, /* Mark for expiry. */
129#define MNT_EXPIRE MNT_EXPIRE
130 UMOUNT_NOFOLLOW = 8 /* Don't follow symlink on umount. */
131#define UMOUNT_NOFOLLOW UMOUNT_NOFOLLOW
132};
133
134
135__BEGIN_DECLS
136
137/* Mount a filesystem. */
138extern int mount (const char *__special_file, const char *__dir,
139 const char *__fstype, unsigned long int __rwflag,
140 const void *__data) __THROW;
141
142/* Unmount a filesystem. */
143extern int umount (const char *__special_file) __THROW;
144
145/* Unmount a filesystem. Force unmounting if FLAGS is set to MNT_FORCE. */
146extern int umount2 (const char *__special_file, int __flags) __THROW;
147
148__END_DECLS
149
150#endif /* _SYS_MOUNT_H */
libc/glibc-include/sys/msg.h created+82
...@@ -0,0 +1,82 @@
1/* Copyright (C) 1995-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_MSG_H
19#define _SYS_MSG_H
20
21#include <features.h>
22
23#define __need_size_t
24#include <stddef.h>
25
26/* Get common definition of System V style IPC. */
27#include <sys/ipc.h>
28
29/* Get system dependent definition of `struct msqid_ds' and more. */
30#include <bits/msq.h>
31
32/* Define types required by the standard. */
33#include <bits/types/time_t.h>
34
35#ifndef __pid_t_defined
36typedef __pid_t pid_t;
37# define __pid_t_defined
38#endif
39
40#ifndef __ssize_t_defined
41typedef __ssize_t ssize_t;
42# define __ssize_t_defined
43#endif
44
45/* The following System V style IPC functions implement a message queue
46 system. The definition is found in XPG2. */
47
48#ifdef __USE_GNU
49/* Template for struct to be used as argument for `msgsnd' and `msgrcv'. */
50struct msgbuf
51 {
52 __syscall_slong_t mtype; /* type of received/sent message */
53 char mtext[1]; /* text of the message */
54 };
55#endif
56
57
58__BEGIN_DECLS
59
60/* Message queue control operation. */
61extern int msgctl (int __msqid, int __cmd, struct msqid_ds *__buf) __THROW;
62
63/* Get messages queue. */
64extern int msgget (key_t __key, int __msgflg) __THROW;
65
66/* Receive message from message queue.
67
68 This function is a cancellation point and therefore not marked with
69 __THROW. */
70extern ssize_t msgrcv (int __msqid, void *__msgp, size_t __msgsz,
71 long int __msgtyp, int __msgflg);
72
73/* Send message to message queue.
74
75 This function is a cancellation point and therefore not marked with
76 __THROW. */
77extern int msgsnd (int __msqid, const void *__msgp, size_t __msgsz,
78 int __msgflg);
79
80__END_DECLS
81
82#endif /* sys/msg.h */
libc/glibc-include/sys/mtio.h created+276
...@@ -0,0 +1,276 @@
1/* Structures and definitions for magnetic tape I/O control commands.
2 Copyright (C) 1996-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19/* Written by H. Bergman <hennus@cybercomm.nl>. */
20
21#ifndef _SYS_MTIO_H
22#define _SYS_MTIO_H 1
23
24/* Get necessary definitions from system and kernel headers. */
25#include <sys/types.h>
26#include <sys/ioctl.h>
27
28
29/* Structure for MTIOCTOP - magnetic tape operation command. */
30struct mtop
31 {
32 short int mt_op; /* Operations defined below. */
33 int mt_count; /* How many of them. */
34 };
35#define _IOT_mtop /* Hurd ioctl type field. */ \
36 _IOT (_IOTS (short), 1, _IOTS (int), 1, 0, 0)
37
38/* Magnetic Tape operations [Not all operations supported by all drivers]. */
39#define MTRESET 0 /* +reset drive in case of problems. */
40#define MTFSF 1 /* Forward space over FileMark,
41 * position at first record of next file. */
42#define MTBSF 2 /* Backward space FileMark (position before FM). */
43#define MTFSR 3 /* Forward space record. */
44#define MTBSR 4 /* Backward space record. */
45#define MTWEOF 5 /* Write an end-of-file record (mark). */
46#define MTREW 6 /* Rewind. */
47#define MTOFFL 7 /* Rewind and put the drive offline (eject?). */
48#define MTNOP 8 /* No op, set status only (read with MTIOCGET). */
49#define MTRETEN 9 /* Retension tape. */
50#define MTBSFM 10 /* +backward space FileMark, position at FM. */
51#define MTFSFM 11 /* +forward space FileMark, position at FM. */
52#define MTEOM 12 /* Goto end of recorded media (for appending files).
53 MTEOM positions after the last FM, ready for
54 appending another file. */
55#define MTERASE 13 /* Erase tape -- be careful! */
56
57#define MTRAS1 14 /* Run self test 1 (nondestructive). */
58#define MTRAS2 15 /* Run self test 2 (destructive). */
59#define MTRAS3 16 /* Reserved for self test 3. */
60
61#define MTSETBLK 20 /* Set block length (SCSI). */
62#define MTSETDENSITY 21 /* Set tape density (SCSI). */
63#define MTSEEK 22 /* Seek to block (Tandberg, etc.). */
64#define MTTELL 23 /* Tell block (Tandberg, etc.). */
65#define MTSETDRVBUFFER 24 /* Set the drive buffering according to SCSI-2.
66 Ordinary buffered operation with code 1. */
67#define MTFSS 25 /* Space forward over setmarks. */
68#define MTBSS 26 /* Space backward over setmarks. */
69#define MTWSM 27 /* Write setmarks. */
70
71#define MTLOCK 28 /* Lock the drive door. */
72#define MTUNLOCK 29 /* Unlock the drive door. */
73#define MTLOAD 30 /* Execute the SCSI load command. */
74#define MTUNLOAD 31 /* Execute the SCSI unload command. */
75#define MTCOMPRESSION 32/* Control compression with SCSI mode page 15. */
76#define MTSETPART 33 /* Change the active tape partition. */
77#define MTMKPART 34 /* Format the tape with one or two partitions. */
78
79/* structure for MTIOCGET - mag tape get status command */
80
81struct mtget
82 {
83 long int mt_type; /* Type of magtape device. */
84 long int mt_resid; /* Residual count: (not sure)
85 number of bytes ignored, or
86 number of files not skipped, or
87 number of records not skipped. */
88 /* The following registers are device dependent. */
89 long int mt_dsreg; /* Status register. */
90 long int mt_gstat; /* Generic (device independent) status. */
91 long int mt_erreg; /* Error register. */
92 /* The next two fields are not always used. */
93 __daddr_t mt_fileno; /* Number of current file on tape. */
94 __daddr_t mt_blkno; /* Current block number. */
95 };
96#define _IOT_mtget /* Hurd ioctl type field. */ \
97 _IOT (_IOTS (long), 7, 0, 0, 0, 0)
98
99
100/* Constants for mt_type. Not all of these are supported, and
101 these are not all of the ones that are supported. */
102#define MT_ISUNKNOWN 0x01
103#define MT_ISQIC02 0x02 /* Generic QIC-02 tape streamer. */
104#define MT_ISWT5150 0x03 /* Wangtek 5150EQ, QIC-150, QIC-02. */
105#define MT_ISARCHIVE_5945L2 0x04 /* Archive 5945L-2, QIC-24, QIC-02?. */
106#define MT_ISCMSJ500 0x05 /* CMS Jumbo 500 (QIC-02?). */
107#define MT_ISTDC3610 0x06 /* Tandberg 6310, QIC-24. */
108#define MT_ISARCHIVE_VP60I 0x07 /* Archive VP60i, QIC-02. */
109#define MT_ISARCHIVE_2150L 0x08 /* Archive Viper 2150L. */
110#define MT_ISARCHIVE_2060L 0x09 /* Archive Viper 2060L. */
111#define MT_ISARCHIVESC499 0x0A /* Archive SC-499 QIC-36 controller. */
112#define MT_ISQIC02_ALL_FEATURES 0x0F /* Generic QIC-02 with all features. */
113#define MT_ISWT5099EEN24 0x11 /* Wangtek 5099-een24, 60MB, QIC-24. */
114#define MT_ISTEAC_MT2ST 0x12 /* Teac MT-2ST 155mb drive,
115 Teac DC-1 card (Wangtek type). */
116#define MT_ISEVEREX_FT40A 0x32 /* Everex FT40A (QIC-40). */
117#define MT_ISDDS1 0x51 /* DDS device without partitions. */
118#define MT_ISDDS2 0x52 /* DDS device with partitions. */
119#define MT_ISSCSI1 0x71 /* Generic ANSI SCSI-1 tape unit. */
120#define MT_ISSCSI2 0x72 /* Generic ANSI SCSI-2 tape unit. */
121
122/* QIC-40/80/3010/3020 ftape supported drives.
123 20bit vendor ID + 0x800000 (see vendors.h in ftape distribution). */
124#define MT_ISFTAPE_UNKNOWN 0x800000 /* obsolete */
125#define MT_ISFTAPE_FLAG 0x800000
126
127struct mt_tape_info
128 {
129 long int t_type; /* Device type id (mt_type). */
130 char *t_name; /* Descriptive name. */
131 };
132
133#define MT_TAPE_INFO \
134 { \
135 {MT_ISUNKNOWN, "Unknown type of tape device"}, \
136 {MT_ISQIC02, "Generic QIC-02 tape streamer"}, \
137 {MT_ISWT5150, "Wangtek 5150, QIC-150"}, \
138 {MT_ISARCHIVE_5945L2, "Archive 5945L-2"}, \
139 {MT_ISCMSJ500, "CMS Jumbo 500"}, \
140 {MT_ISTDC3610, "Tandberg TDC 3610, QIC-24"}, \
141 {MT_ISARCHIVE_VP60I, "Archive VP60i, QIC-02"}, \
142 {MT_ISARCHIVE_2150L, "Archive Viper 2150L"}, \
143 {MT_ISARCHIVE_2060L, "Archive Viper 2060L"}, \
144 {MT_ISARCHIVESC499, "Archive SC-499 QIC-36 controller"}, \
145 {MT_ISQIC02_ALL_FEATURES, "Generic QIC-02 tape, all features"}, \
146 {MT_ISWT5099EEN24, "Wangtek 5099-een24, 60MB"}, \
147 {MT_ISTEAC_MT2ST, "Teac MT-2ST 155mb data cassette drive"}, \
148 {MT_ISEVEREX_FT40A, "Everex FT40A, QIC-40"}, \
149 {MT_ISSCSI1, "Generic SCSI-1 tape"}, \
150 {MT_ISSCSI2, "Generic SCSI-2 tape"}, \
151 {0, NULL} \
152 }
153
154
155/* Structure for MTIOCPOS - mag tape get position command. */
156
157struct mtpos
158 {
159 long int mt_blkno; /* Current block number. */
160 };
161#define _IOT_mtpos /* Hurd ioctl type field. */ \
162 _IOT_SIMPLE (long)
163
164
165/* Structure for MTIOCGETCONFIG/MTIOCSETCONFIG primarily intended
166 as an interim solution for QIC-02 until DDI is fully implemented. */
167struct mtconfiginfo
168 {
169 long int mt_type; /* Drive type. */
170 long int ifc_type; /* Interface card type. */
171 unsigned short int irqnr; /* IRQ number to use. */
172 unsigned short int dmanr; /* DMA channel to use. */
173 unsigned short int port; /* IO port base address. */
174
175 unsigned long int debug; /* Debugging flags. */
176
177 unsigned have_dens:1;
178 unsigned have_bsf:1;
179 unsigned have_fsr:1;
180 unsigned have_bsr:1;
181 unsigned have_eod:1;
182 unsigned have_seek:1;
183 unsigned have_tell:1;
184 unsigned have_ras1:1;
185 unsigned have_ras2:1;
186 unsigned have_ras3:1;
187 unsigned have_qfa:1;
188
189 unsigned pad1:5;
190 char reserved[10];
191 };
192#define _IOT_mtconfiginfo /* Hurd ioctl type field. */ \
193 _IOT (_IOTS (long), 2, _IOTS (short), 3, _IOTS (long), 1) /* XXX wrong */
194
195
196/* Magnetic tape I/O control commands. */
197#define MTIOCTOP _IOW('m', 1, struct mtop) /* Do a mag tape op. */
198#define MTIOCGET _IOR('m', 2, struct mtget) /* Get tape status. */
199#define MTIOCPOS _IOR('m', 3, struct mtpos) /* Get tape position.*/
200
201/* The next two are used by the QIC-02 driver for runtime reconfiguration.
202 See tpqic02.h for struct mtconfiginfo. */
203#define MTIOCGETCONFIG _IOR('m', 4, struct mtconfiginfo) /* Get tape config.*/
204#define MTIOCSETCONFIG _IOW('m', 5, struct mtconfiginfo) /* Set tape config.*/
205
206/* Generic Mag Tape (device independent) status macros for examining
207 mt_gstat -- HP-UX compatible.
208 There is room for more generic status bits here, but I don't
209 know which of them are reserved. At least three or so should
210 be added to make this really useful. */
211#define GMT_EOF(x) ((x) & 0x80000000)
212#define GMT_BOT(x) ((x) & 0x40000000)
213#define GMT_EOT(x) ((x) & 0x20000000)
214#define GMT_SM(x) ((x) & 0x10000000) /* DDS setmark */
215#define GMT_EOD(x) ((x) & 0x08000000) /* DDS EOD */
216#define GMT_WR_PROT(x) ((x) & 0x04000000)
217/* #define GMT_ ? ((x) & 0x02000000) */
218#define GMT_ONLINE(x) ((x) & 0x01000000)
219#define GMT_D_6250(x) ((x) & 0x00800000)
220#define GMT_D_1600(x) ((x) & 0x00400000)
221#define GMT_D_800(x) ((x) & 0x00200000)
222/* #define GMT_ ? ((x) & 0x00100000) */
223/* #define GMT_ ? ((x) & 0x00080000) */
224#define GMT_DR_OPEN(x) ((x) & 0x00040000) /* Door open (no tape). */
225/* #define GMT_ ? ((x) & 0x00020000) */
226#define GMT_IM_REP_EN(x) ((x) & 0x00010000) /* Immediate report mode.*/
227/* 16 generic status bits unused. */
228
229
230/* SCSI-tape specific definitions. Bitfield shifts in the status */
231#define MT_ST_BLKSIZE_SHIFT 0
232#define MT_ST_BLKSIZE_MASK 0xffffff
233#define MT_ST_DENSITY_SHIFT 24
234#define MT_ST_DENSITY_MASK 0xff000000
235
236#define MT_ST_SOFTERR_SHIFT 0
237#define MT_ST_SOFTERR_MASK 0xffff
238
239/* Bitfields for the MTSETDRVBUFFER ioctl. */
240#define MT_ST_OPTIONS 0xf0000000
241#define MT_ST_BOOLEANS 0x10000000
242#define MT_ST_SETBOOLEANS 0x30000000
243#define MT_ST_CLEARBOOLEANS 0x40000000
244#define MT_ST_WRITE_THRESHOLD 0x20000000
245#define MT_ST_DEF_BLKSIZE 0x50000000
246#define MT_ST_DEF_OPTIONS 0x60000000
247
248#define MT_ST_BUFFER_WRITES 0x1
249#define MT_ST_ASYNC_WRITES 0x2
250#define MT_ST_READ_AHEAD 0x4
251#define MT_ST_DEBUGGING 0x8
252#define MT_ST_TWO_FM 0x10
253#define MT_ST_FAST_MTEOM 0x20
254#define MT_ST_AUTO_LOCK 0x40
255#define MT_ST_DEF_WRITES 0x80
256#define MT_ST_CAN_BSR 0x100
257#define MT_ST_NO_BLKLIMS 0x200
258#define MT_ST_CAN_PARTITIONS 0x400
259#define MT_ST_SCSI2LOGICAL 0x800
260
261/* The mode parameters to be controlled. Parameter chosen with bits 20-28. */
262#define MT_ST_CLEAR_DEFAULT 0xfffff
263#define MT_ST_DEF_DENSITY (MT_ST_DEF_OPTIONS | 0x100000)
264#define MT_ST_DEF_COMPRESSION (MT_ST_DEF_OPTIONS | 0x200000)
265#define MT_ST_DEF_DRVBUFFER (MT_ST_DEF_OPTIONS | 0x300000)
266
267/* The offset for the arguments for the special HP changer load command. */
268#define MT_ST_HPLOADER_OFFSET 10000
269
270
271/* Specify default tape device. */
272#ifndef DEFTAPE
273# define DEFTAPE "/dev/tape"
274#endif
275
276#endif /* mtio.h */
libc/glibc-include/sys/param.h created+106
...@@ -0,0 +1,106 @@
1/* Compatibility header for old-style Unix parameters and limits.
2 Copyright (C) 1995-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SYS_PARAM_H
20#define _SYS_PARAM_H 1
21
22#define __need_NULL
23#include <stddef.h>
24
25#include <sys/types.h>
26#include <limits.h>
27#include <endian.h> /* Define BYTE_ORDER et al. */
28#include <signal.h> /* Define NSIG. */
29
30/* This file defines some things in system-specific ways. */
31#include <bits/param.h>
32
33
34/* BSD names for some <limits.h> values. */
35
36#define NBBY CHAR_BIT
37
38#if !defined NGROUPS && defined NGROUPS_MAX
39# define NGROUPS NGROUPS_MAX
40#endif
41#if !defined MAXSYMLINKS && defined SYMLOOP_MAX
42# define MAXSYMLINKS SYMLOOP_MAX
43#endif
44#if !defined CANBSIZ && defined MAX_CANON
45# define CANBSIZ MAX_CANON
46#endif
47#if !defined MAXPATHLEN && defined PATH_MAX
48# define MAXPATHLEN PATH_MAX
49#endif
50#if !defined NOFILE && defined OPEN_MAX
51# define NOFILE OPEN_MAX
52#endif
53#if !defined MAXHOSTNAMELEN && defined HOST_NAME_MAX
54# define MAXHOSTNAMELEN HOST_NAME_MAX
55#endif
56#ifndef NCARGS
57# ifdef ARG_MAX
58# define NCARGS ARG_MAX
59# else
60/* ARG_MAX is unlimited, but we define NCARGS for BSD programs that want to
61 compare against some fixed limit. */
62# define NCARGS INT_MAX
63# endif
64#endif
65
66
67/* Magical constants. */
68#ifndef NOGROUP
69# define NOGROUP 65535 /* Marker for empty group set member. */
70#endif
71#ifndef NODEV
72# define NODEV ((dev_t) -1) /* Non-existent device. */
73#endif
74
75
76/* Unit of `st_blocks'. */
77#ifndef DEV_BSIZE
78# define DEV_BSIZE 512
79#endif
80
81
82/* Bit map related macros. */
83#define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY))
84#define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
85#define isset(a,i) ((a)[(i)/NBBY] & (1<<((i)%NBBY)))
86#define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
87
88/* Macros for counting and rounding. */
89#ifndef howmany
90# define howmany(x, y) (((x) + ((y) - 1)) / (y))
91#endif
92#ifdef __GNUC__
93# define roundup(x, y) (__builtin_constant_p (y) && powerof2 (y) \
94 ? (((x) + (y) - 1) & ~((y) - 1)) \
95 : ((((x) + ((y) - 1)) / (y)) * (y)))
96#else
97# define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
98#endif
99#define powerof2(x) ((((x) - 1) & (x)) == 0)
100
101/* Macros for min/max. */
102#define MIN(a,b) (((a)<(b))?(a):(b))
103#define MAX(a,b) (((a)>(b))?(a):(b))
104
105
106#endif /* sys/param.h */
libc/glibc-include/sys/pci.h created+24
...@@ -0,0 +1,24 @@
1/* Copyright (C) 1997-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_PCI_H
19#define _SYS_PCI_H 1
20
21/* We use the constants from the kernel. */
22#include <linux/pci.h>
23
24#endif /* sys/pci.h */
libc/glibc-include/sys/perm.h created+35
...@@ -0,0 +1,35 @@
1/* Copyright (C) 1996-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_PERM_H
19
20#define _SYS_PERM_H 1
21#include <features.h>
22
23__BEGIN_DECLS
24
25/* Set port input/output permissions. */
26extern int ioperm (unsigned long int __from, unsigned long int __num,
27 int __turn_on) __THROW;
28
29
30/* Change I/O privilege level. */
31extern int iopl (int __level) __THROW;
32
33__END_DECLS
34
35#endif /* _SYS_PERM_H */
libc/glibc-include/sys/personality.h created+80
...@@ -0,0 +1,80 @@
1/* Copyright (C) 2002-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/* Taken verbatim from Linux 2.6 (include/linux/personality.h). */
19
20#ifndef _SYS_PERSONALITY_H
21#define _SYS_PERSONALITY_H 1
22
23#include <features.h>
24
25/* Flags for bug emulation.
26 These occupy the top three bytes. */
27enum
28 {
29 UNAME26 = 0x0020000,
30 ADDR_NO_RANDOMIZE = 0x0040000,
31 FDPIC_FUNCPTRS = 0x0080000,
32 MMAP_PAGE_ZERO = 0x0100000,
33 ADDR_COMPAT_LAYOUT = 0x0200000,
34 READ_IMPLIES_EXEC = 0x0400000,
35 ADDR_LIMIT_32BIT = 0x0800000,
36 SHORT_INODE = 0x1000000,
37 WHOLE_SECONDS = 0x2000000,
38 STICKY_TIMEOUTS = 0x4000000,
39 ADDR_LIMIT_3GB = 0x8000000
40 };
41
42/* Personality types.
43
44 These go in the low byte. Avoid using the top bit, it will
45 conflict with error returns. */
46enum
47 {
48 PER_LINUX = 0x0000,
49 PER_LINUX_32BIT = 0x0000 | ADDR_LIMIT_32BIT,
50 PER_LINUX_FDPIC = 0x0000 | FDPIC_FUNCPTRS,
51 PER_SVR4 = 0x0001 | STICKY_TIMEOUTS | MMAP_PAGE_ZERO,
52 PER_SVR3 = 0x0002 | STICKY_TIMEOUTS | SHORT_INODE,
53 PER_SCOSVR3 = 0x0003 | STICKY_TIMEOUTS | WHOLE_SECONDS | SHORT_INODE,
54 PER_OSR5 = 0x0003 | STICKY_TIMEOUTS | WHOLE_SECONDS,
55 PER_WYSEV386 = 0x0004 | STICKY_TIMEOUTS | SHORT_INODE,
56 PER_ISCR4 = 0x0005 | STICKY_TIMEOUTS,
57 PER_BSD = 0x0006,
58 PER_SUNOS = 0x0006 | STICKY_TIMEOUTS,
59 PER_XENIX = 0x0007 | STICKY_TIMEOUTS | SHORT_INODE,
60 PER_LINUX32 = 0x0008,
61 PER_LINUX32_3GB = 0x0008 | ADDR_LIMIT_3GB,
62 PER_IRIX32 = 0x0009 | STICKY_TIMEOUTS, /* IRIX5 32-bit */
63 PER_IRIXN32 = 0x000a | STICKY_TIMEOUTS, /* IRIX6 new 32-bit */
64 PER_IRIX64 = 0x000b | STICKY_TIMEOUTS, /* IRIX6 64-bit */
65 PER_RISCOS = 0x000c,
66 PER_SOLARIS = 0x000d | STICKY_TIMEOUTS,
67 PER_UW7 = 0x000e | STICKY_TIMEOUTS | MMAP_PAGE_ZERO,
68 PER_OSF4 = 0x000f,
69 PER_HPUX = 0x0010,
70 PER_MASK = 0x00ff,
71 };
72
73__BEGIN_DECLS
74
75/* Set different ABIs (personalities). */
76extern int personality (unsigned long int __persona) __THROW;
77
78__END_DECLS
79
80#endif /* sys/personality.h */
libc/glibc-include/sys/poll.h created+76
...@@ -0,0 +1,76 @@
1/* Compatibility definitions for System V `poll' interface.
2 Copyright (C) 1994-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SYS_POLL_H
20#define _SYS_POLL_H 1
21
22#include <features.h>
23
24/* Get the platform dependent bits of `poll'. */
25#include <bits/poll.h>
26#ifdef __USE_GNU
27# include <bits/types/__sigset_t.h>
28# include <bits/types/struct_timespec.h>
29#endif
30
31
32/* Type used for the number of file descriptors. */
33typedef unsigned long int nfds_t;
34
35/* Data structure describing a polling request. */
36struct pollfd
37 {
38 int fd; /* File descriptor to poll. */
39 short int events; /* Types of events poller cares about. */
40 short int revents; /* Types of events that actually occurred. */
41 };
42
43
44__BEGIN_DECLS
45
46/* Poll the file descriptors described by the NFDS structures starting at
47 FDS. If TIMEOUT is nonzero and not -1, allow TIMEOUT milliseconds for
48 an event to occur; if TIMEOUT is -1, block until an event occurs.
49 Returns the number of file descriptors with events, zero if timed out,
50 or -1 for errors.
51
52 This function is a cancellation point and therefore not marked with
53 __THROW. */
54extern int poll (struct pollfd *__fds, nfds_t __nfds, int __timeout);
55
56#ifdef __USE_GNU
57/* Like poll, but before waiting the threads signal mask is replaced
58 with that specified in the fourth parameter. For better usability,
59 the timeout value is specified using a TIMESPEC object.
60
61 This function is a cancellation point and therefore not marked with
62 __THROW. */
63extern int ppoll (struct pollfd *__fds, nfds_t __nfds,
64 const struct timespec *__timeout,
65 const __sigset_t *__ss);
66#endif
67
68__END_DECLS
69
70
71/* Define some inlines helping to catch common problems. */
72#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
73# include <bits/poll2.h>
74#endif
75
76#endif /* sys/poll.h */
libc/glibc-include/sys/prctl.h created+31
...@@ -0,0 +1,31 @@
1/* Copyright (C) 1997-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_PRCTL_H
19#define _SYS_PRCTL_H 1
20
21#include <features.h>
22#include <linux/prctl.h> /* The magic values come from here */
23
24__BEGIN_DECLS
25
26/* Control process execution. */
27extern int prctl (int __option, ...) __THROW;
28
29__END_DECLS
30
31#endif /* sys/prctl.h */
libc/glibc-include/sys/procfs.h created+126
...@@ -0,0 +1,126 @@
1/* Definitions for core files and libthread_db. Generic Linux version.
2 Copyright (C) 1996-2019 Free Software Foundation, Inc.
3
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
19
20#ifndef _SYS_PROCFS_H
21#define _SYS_PROCFS_H 1
22
23/* This is somewhat modelled after the file of the same name on SVR4
24 systems. It provides a definition of the core file format for ELF
25 used on Linux. It doesn't have anything to do with the /proc file
26 system, even though Linux has one.
27
28 Anyway, the whole purpose of this file is for GDB and GDB only.
29 Don't read too much into it. Don't use it for anything other than
30 GDB unless you know what you are doing. */
31
32#include <features.h>
33#include <sys/time.h>
34#include <sys/types.h>
35#include <sys/user.h>
36
37/* bits/procfs.h, provided by each architecture, must define
38 elf_gregset_t, elf_fpregset_t and any other architecture-specific
39 types needed. */
40#include <bits/procfs.h>
41
42/* bits/procfs-id.h must define __pr_uid_t and __pr_gid_t, the types
43 of pr_uid and pr_gid. */
44#include <bits/procfs-id.h>
45
46__BEGIN_DECLS
47
48/* Signal info. */
49struct elf_siginfo
50 {
51 int si_signo; /* Signal number. */
52 int si_code; /* Extra code. */
53 int si_errno; /* Errno. */
54 };
55
56/* Definitions to generate Intel SVR4-like core files. These mostly
57 have the same names as the SVR4 types with "elf_" tacked on the
58 front to prevent clashes with Linux definitions, and the typedef
59 forms have been avoided. This is mostly like the SVR4 structure,
60 but more Linuxy, with things that Linux does not support and which
61 GDB doesn't really use excluded. */
62
63struct elf_prstatus
64 {
65 struct elf_siginfo pr_info; /* Info associated with signal. */
66 short int pr_cursig; /* Current signal. */
67 unsigned long int pr_sigpend; /* Set of pending signals. */
68 unsigned long int pr_sighold; /* Set of held signals. */
69 __pid_t pr_pid;
70 __pid_t pr_ppid;
71 __pid_t pr_pgrp;
72 __pid_t pr_sid;
73 struct timeval pr_utime; /* User time. */
74 struct timeval pr_stime; /* System time. */
75 struct timeval pr_cutime; /* Cumulative user time. */
76 struct timeval pr_cstime; /* Cumulative system time. */
77 elf_gregset_t pr_reg; /* GP registers. */
78 int pr_fpvalid; /* True if math copro being used. */
79 };
80
81
82#define ELF_PRARGSZ (80) /* Number of chars for args. */
83
84struct elf_prpsinfo
85 {
86 char pr_state; /* Numeric process state. */
87 char pr_sname; /* Char for pr_state. */
88 char pr_zomb; /* Zombie. */
89 char pr_nice; /* Nice val. */
90 unsigned long int pr_flag; /* Flags. */
91 __pr_uid_t pr_uid;
92 __pr_gid_t pr_gid;
93 int pr_pid, pr_ppid, pr_pgrp, pr_sid;
94 /* Lots missing */
95 char pr_fname[16]; /* Filename of executable. */
96 char pr_psargs[ELF_PRARGSZ]; /* Initial part of arg list. */
97 };
98
99/* The rest of this file provides the types for emulation of the
100 Solaris <proc_service.h> interfaces that should be implemented by
101 users of libthread_db. */
102
103/* Addresses. */
104typedef void *psaddr_t;
105
106#include <bits/procfs-prregset.h>
107
108/* Register sets. Linux has different names. */
109typedef __prgregset_t prgregset_t;
110typedef __prfpregset_t prfpregset_t;
111
112/* We don't have any differences between processes and threads,
113 therefore have only one PID type. */
114typedef __pid_t lwpid_t;
115
116/* Process status and info. In the end we do provide typedefs for them. */
117typedef struct elf_prstatus prstatus_t;
118typedef struct elf_prpsinfo prpsinfo_t;
119
120__END_DECLS
121
122/* On some architectures, provide other-ABI variants of the above
123 types. */
124#include <bits/procfs-extra.h>
125
126#endif /* sys/procfs.h. */
libc/glibc-include/sys/profil.h created+60
...@@ -0,0 +1,60 @@
1/* Copyright (C) 2001-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _PROFIL_H
19#define _PROFIL_H 1
20
21#include <features.h>
22
23#include <sys/time.h>
24#include <sys/types.h>
25
26/* This interface is intended to follow the sprofil() system calls as
27 described by the sprofil(2) man page of Irix v6.5, except that:
28
29 - there is no a priori limit on number of text sections
30 - pr_scale is declared as unsigned long (instead of "unsigned int")
31 - pr_size is declared as size_t (instead of "unsigned int")
32 - pr_off is declared as void * (instead of "__psunsigned_t")
33 - the overflow bin (pr_base==0, pr_scale==2) can appear anywhere
34 in the profp array
35 - PROF_FAST has no effect */
36
37struct prof
38 {
39 void *pr_base; /* buffer base */
40 size_t pr_size; /* buffer size */
41 size_t pr_off; /* pc offset */
42 unsigned long int pr_scale; /* pc scaling (fixed-point number) */
43 };
44
45enum
46 {
47 PROF_USHORT = 0, /* use 16-bit counters (default) */
48 PROF_UINT = 1 << 0, /* use 32-bit counters */
49 PROF_FAST = 1 << 1 /* profile faster than usual */
50 };
51
52
53__BEGIN_DECLS
54
55extern int sprofil (struct prof *__profp, int __profcnt,
56 struct timeval *__tvp, unsigned int __flags) __THROW;
57
58__END_DECLS
59
60#endif /* profil.h */
libc/glibc-include/sys/ptrace.h created+198
...@@ -0,0 +1,198 @@
1/* `ptrace' debugger support interface. Linux/x86 version.
2 Copyright (C) 1996-2019 Free Software Foundation, Inc.
3
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
19
20#ifndef _SYS_PTRACE_H
21#define _SYS_PTRACE_H 1
22
23#include <features.h>
24#include <bits/types.h>
25
26__BEGIN_DECLS
27
28/* Type of the REQUEST argument to `ptrace.' */
29enum __ptrace_request
30{
31 /* Indicate that the process making this request should be traced.
32 All signals received by this process can be intercepted by its
33 parent, and its parent can use the other `ptrace' requests. */
34 PTRACE_TRACEME = 0,
35#define PT_TRACE_ME PTRACE_TRACEME
36
37 /* Return the word in the process's text space at address ADDR. */
38 PTRACE_PEEKTEXT = 1,
39#define PT_READ_I PTRACE_PEEKTEXT
40
41 /* Return the word in the process's data space at address ADDR. */
42 PTRACE_PEEKDATA = 2,
43#define PT_READ_D PTRACE_PEEKDATA
44
45 /* Return the word in the process's user area at offset ADDR. */
46 PTRACE_PEEKUSER = 3,
47#define PT_READ_U PTRACE_PEEKUSER
48
49 /* Write the word DATA into the process's text space at address ADDR. */
50 PTRACE_POKETEXT = 4,
51#define PT_WRITE_I PTRACE_POKETEXT
52
53 /* Write the word DATA into the process's data space at address ADDR. */
54 PTRACE_POKEDATA = 5,
55#define PT_WRITE_D PTRACE_POKEDATA
56
57 /* Write the word DATA into the process's user area at offset ADDR. */
58 PTRACE_POKEUSER = 6,
59#define PT_WRITE_U PTRACE_POKEUSER
60
61 /* Continue the process. */
62 PTRACE_CONT = 7,
63#define PT_CONTINUE PTRACE_CONT
64
65 /* Kill the process. */
66 PTRACE_KILL = 8,
67#define PT_KILL PTRACE_KILL
68
69 /* Single step the process. */
70 PTRACE_SINGLESTEP = 9,
71#define PT_STEP PTRACE_SINGLESTEP
72
73 /* Get all general purpose registers used by a processes. */
74 PTRACE_GETREGS = 12,
75#define PT_GETREGS PTRACE_GETREGS
76
77 /* Set all general purpose registers used by a processes. */
78 PTRACE_SETREGS = 13,
79#define PT_SETREGS PTRACE_SETREGS
80
81 /* Get all floating point registers used by a processes. */
82 PTRACE_GETFPREGS = 14,
83#define PT_GETFPREGS PTRACE_GETFPREGS
84
85 /* Set all floating point registers used by a processes. */
86 PTRACE_SETFPREGS = 15,
87#define PT_SETFPREGS PTRACE_SETFPREGS
88
89 /* Attach to a process that is already running. */
90 PTRACE_ATTACH = 16,
91#define PT_ATTACH PTRACE_ATTACH
92
93 /* Detach from a process attached to with PTRACE_ATTACH. */
94 PTRACE_DETACH = 17,
95#define PT_DETACH PTRACE_DETACH
96
97 /* Get all extended floating point registers used by a processes. */
98 PTRACE_GETFPXREGS = 18,
99#define PT_GETFPXREGS PTRACE_GETFPXREGS
100
101 /* Set all extended floating point registers used by a processes. */
102 PTRACE_SETFPXREGS = 19,
103#define PT_SETFPXREGS PTRACE_SETFPXREGS
104
105 /* Continue and stop at the next entry to or return from syscall. */
106 PTRACE_SYSCALL = 24,
107#define PT_SYSCALL PTRACE_SYSCALL
108
109 /* Get a TLS entry in the GDT. */
110 PTRACE_GET_THREAD_AREA = 25,
111#define PT_GET_THREAD_AREA PTRACE_GET_THREAD_AREA
112
113 /* Change a TLS entry in the GDT. */
114 PTRACE_SET_THREAD_AREA = 26,
115#define PT_SET_THREAD_AREA PTRACE_SET_THREAD_AREA
116
117#ifdef __x86_64__
118 /* Access TLS data. */
119 PTRACE_ARCH_PRCTL = 30,
120# define PT_ARCH_PRCTL PTRACE_ARCH_PRCTL
121#endif
122
123 /* Continue and stop at the next syscall, it will not be executed. */
124 PTRACE_SYSEMU = 31,
125#define PT_SYSEMU PTRACE_SYSEMU
126
127 /* Single step the process, the next syscall will not be executed. */
128 PTRACE_SYSEMU_SINGLESTEP = 32,
129#define PT_SYSEMU_SINGLESTEP PTRACE_SYSEMU_SINGLESTEP
130
131 /* Execute process until next taken branch. */
132 PTRACE_SINGLEBLOCK = 33,
133#define PT_STEPBLOCK PTRACE_SINGLEBLOCK
134
135 /* Set ptrace filter options. */
136 PTRACE_SETOPTIONS = 0x4200,
137#define PT_SETOPTIONS PTRACE_SETOPTIONS
138
139 /* Get last ptrace message. */
140 PTRACE_GETEVENTMSG = 0x4201,
141#define PT_GETEVENTMSG PTRACE_GETEVENTMSG
142
143 /* Get siginfo for process. */
144 PTRACE_GETSIGINFO = 0x4202,
145#define PT_GETSIGINFO PTRACE_GETSIGINFO
146
147 /* Set new siginfo for process. */
148 PTRACE_SETSIGINFO = 0x4203,
149#define PT_SETSIGINFO PTRACE_SETSIGINFO
150
151 /* Get register content. */
152 PTRACE_GETREGSET = 0x4204,
153#define PTRACE_GETREGSET PTRACE_GETREGSET
154
155 /* Set register content. */
156 PTRACE_SETREGSET = 0x4205,
157#define PTRACE_SETREGSET PTRACE_SETREGSET
158
159 /* Like PTRACE_ATTACH, but do not force tracee to trap and do not affect
160 signal or group stop state. */
161 PTRACE_SEIZE = 0x4206,
162#define PTRACE_SEIZE PTRACE_SEIZE
163
164 /* Trap seized tracee. */
165 PTRACE_INTERRUPT = 0x4207,
166#define PTRACE_INTERRUPT PTRACE_INTERRUPT
167
168 /* Wait for next group event. */
169 PTRACE_LISTEN = 0x4208,
170#define PTRACE_LISTEN PTRACE_LISTEN
171
172 /* Retrieve siginfo_t structures without removing signals from a queue. */
173 PTRACE_PEEKSIGINFO = 0x4209,
174#define PTRACE_PEEKSIGINFO PTRACE_PEEKSIGINFO
175
176 /* Get the mask of blocked signals. */
177 PTRACE_GETSIGMASK = 0x420a,
178#define PTRACE_GETSIGMASK PTRACE_GETSIGMASK
179
180 /* Change the mask of blocked signals. */
181 PTRACE_SETSIGMASK = 0x420b,
182#define PTRACE_SETSIGMASK PTRACE_SETSIGMASK
183
184 /* Get seccomp BPF filters. */
185 PTRACE_SECCOMP_GET_FILTER = 0x420c,
186#define PTRACE_SECCOMP_GET_FILTER PTRACE_SECCOMP_GET_FILTER
187
188 /* Get seccomp BPF filter metadata. */
189 PTRACE_SECCOMP_GET_METADATA = 0x420d
190#define PTRACE_SECCOMP_GET_METADATA PTRACE_SECCOMP_GET_METADATA
191};
192
193
194#include <bits/ptrace-shared.h>
195
196__END_DECLS
197
198#endif /* _SYS_PTRACE_H */
libc/glibc-include/sys/queue.h created+574
...@@ -0,0 +1,574 @@
1/*
2 * Copyright (c) 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the University nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * @(#)queue.h 8.5 (Berkeley) 8/20/94
30 */
31
32#ifndef _SYS_QUEUE_H_
33#define _SYS_QUEUE_H_
34
35/*
36 * This file defines five types of data structures: singly-linked lists,
37 * lists, simple queues, tail queues, and circular queues.
38 *
39 * A singly-linked list is headed by a single forward pointer. The
40 * elements are singly linked for minimum space and pointer manipulation
41 * overhead at the expense of O(n) removal for arbitrary elements. New
42 * elements can be added to the list after an existing element or at the
43 * head of the list. Elements being removed from the head of the list
44 * should use the explicit macro for this purpose for optimum
45 * efficiency. A singly-linked list may only be traversed in the forward
46 * direction. Singly-linked lists are ideal for applications with large
47 * datasets and few or no removals or for implementing a LIFO queue.
48 *
49 * A list is headed by a single forward pointer (or an array of forward
50 * pointers for a hash table header). The elements are doubly linked
51 * so that an arbitrary element can be removed without a need to
52 * traverse the list. New elements can be added to the list before
53 * or after an existing element or at the head of the list. A list
54 * may only be traversed in the forward direction.
55 *
56 * A simple queue is headed by a pair of pointers, one the head of the
57 * list and the other to the tail of the list. The elements are singly
58 * linked to save space, so elements can only be removed from the
59 * head of the list. New elements can be added to the list after
60 * an existing element, at the head of the list, or at the end of the
61 * list. A simple queue may only be traversed in the forward direction.
62 *
63 * A tail queue is headed by a pair of pointers, one to the head of the
64 * list and the other to the tail of the list. The elements are doubly
65 * linked so that an arbitrary element can be removed without a need to
66 * traverse the list. New elements can be added to the list before or
67 * after an existing element, at the head of the list, or at the end of
68 * the list. A tail queue may be traversed in either direction.
69 *
70 * A circle queue is headed by a pair of pointers, one to the head of the
71 * list and the other to the tail of the list. The elements are doubly
72 * linked so that an arbitrary element can be removed without a need to
73 * traverse the list. New elements can be added to the list before or after
74 * an existing element, at the head of the list, or at the end of the list.
75 * A circle queue may be traversed in either direction, but has a more
76 * complex end of list detection.
77 *
78 * For details on the use of these macros, see the queue(3) manual page.
79 */
80
81/*
82 * List definitions.
83 */
84#define LIST_HEAD(name, type) \
85struct name { \
86 struct type *lh_first; /* first element */ \
87}
88
89#define LIST_HEAD_INITIALIZER(head) \
90 { NULL }
91
92#define LIST_ENTRY(type) \
93struct { \
94 struct type *le_next; /* next element */ \
95 struct type **le_prev; /* address of previous next element */ \
96}
97
98/*
99 * List functions.
100 */
101#define LIST_INIT(head) do { \
102 (head)->lh_first = NULL; \
103} while (/*CONSTCOND*/0)
104
105#define LIST_INSERT_AFTER(listelm, elm, field) do { \
106 if (((elm)->field.le_next = (listelm)->field.le_next) != NULL) \
107 (listelm)->field.le_next->field.le_prev = \
108 &(elm)->field.le_next; \
109 (listelm)->field.le_next = (elm); \
110 (elm)->field.le_prev = &(listelm)->field.le_next; \
111} while (/*CONSTCOND*/0)
112
113#define LIST_INSERT_BEFORE(listelm, elm, field) do { \
114 (elm)->field.le_prev = (listelm)->field.le_prev; \
115 (elm)->field.le_next = (listelm); \
116 *(listelm)->field.le_prev = (elm); \
117 (listelm)->field.le_prev = &(elm)->field.le_next; \
118} while (/*CONSTCOND*/0)
119
120#define LIST_INSERT_HEAD(head, elm, field) do { \
121 if (((elm)->field.le_next = (head)->lh_first) != NULL) \
122 (head)->lh_first->field.le_prev = &(elm)->field.le_next;\
123 (head)->lh_first = (elm); \
124 (elm)->field.le_prev = &(head)->lh_first; \
125} while (/*CONSTCOND*/0)
126
127#define LIST_REMOVE(elm, field) do { \
128 if ((elm)->field.le_next != NULL) \
129 (elm)->field.le_next->field.le_prev = \
130 (elm)->field.le_prev; \
131 *(elm)->field.le_prev = (elm)->field.le_next; \
132} while (/*CONSTCOND*/0)
133
134#define LIST_FOREACH(var, head, field) \
135 for ((var) = ((head)->lh_first); \
136 (var); \
137 (var) = ((var)->field.le_next))
138
139/*
140 * List access methods.
141 */
142#define LIST_EMPTY(head) ((head)->lh_first == NULL)
143#define LIST_FIRST(head) ((head)->lh_first)
144#define LIST_NEXT(elm, field) ((elm)->field.le_next)
145
146
147/*
148 * Singly-linked List definitions.
149 */
150#define SLIST_HEAD(name, type) \
151struct name { \
152 struct type *slh_first; /* first element */ \
153}
154
155#define SLIST_HEAD_INITIALIZER(head) \
156 { NULL }
157
158#define SLIST_ENTRY(type) \
159struct { \
160 struct type *sle_next; /* next element */ \
161}
162
163/*
164 * Singly-linked List functions.
165 */
166#define SLIST_INIT(head) do { \
167 (head)->slh_first = NULL; \
168} while (/*CONSTCOND*/0)
169
170#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \
171 (elm)->field.sle_next = (slistelm)->field.sle_next; \
172 (slistelm)->field.sle_next = (elm); \
173} while (/*CONSTCOND*/0)
174
175#define SLIST_INSERT_HEAD(head, elm, field) do { \
176 (elm)->field.sle_next = (head)->slh_first; \
177 (head)->slh_first = (elm); \
178} while (/*CONSTCOND*/0)
179
180#define SLIST_REMOVE_HEAD(head, field) do { \
181 (head)->slh_first = (head)->slh_first->field.sle_next; \
182} while (/*CONSTCOND*/0)
183
184#define SLIST_REMOVE(head, elm, type, field) do { \
185 if ((head)->slh_first == (elm)) { \
186 SLIST_REMOVE_HEAD((head), field); \
187 } \
188 else { \
189 struct type *curelm = (head)->slh_first; \
190 while(curelm->field.sle_next != (elm)) \
191 curelm = curelm->field.sle_next; \
192 curelm->field.sle_next = \
193 curelm->field.sle_next->field.sle_next; \
194 } \
195} while (/*CONSTCOND*/0)
196
197#define SLIST_FOREACH(var, head, field) \
198 for((var) = (head)->slh_first; (var); (var) = (var)->field.sle_next)
199
200/*
201 * Singly-linked List access methods.
202 */
203#define SLIST_EMPTY(head) ((head)->slh_first == NULL)
204#define SLIST_FIRST(head) ((head)->slh_first)
205#define SLIST_NEXT(elm, field) ((elm)->field.sle_next)
206
207
208/*
209 * Singly-linked Tail queue declarations.
210 */
211#define STAILQ_HEAD(name, type) \
212struct name { \
213 struct type *stqh_first; /* first element */ \
214 struct type **stqh_last; /* addr of last next element */ \
215}
216
217#define STAILQ_HEAD_INITIALIZER(head) \
218 { NULL, &(head).stqh_first }
219
220#define STAILQ_ENTRY(type) \
221struct { \
222 struct type *stqe_next; /* next element */ \
223}
224
225/*
226 * Singly-linked Tail queue functions.
227 */
228#define STAILQ_INIT(head) do { \
229 (head)->stqh_first = NULL; \
230 (head)->stqh_last = &(head)->stqh_first; \
231} while (/*CONSTCOND*/0)
232
233#define STAILQ_INSERT_HEAD(head, elm, field) do { \
234 if (((elm)->field.stqe_next = (head)->stqh_first) == NULL) \
235 (head)->stqh_last = &(elm)->field.stqe_next; \
236 (head)->stqh_first = (elm); \
237} while (/*CONSTCOND*/0)
238
239#define STAILQ_INSERT_TAIL(head, elm, field) do { \
240 (elm)->field.stqe_next = NULL; \
241 *(head)->stqh_last = (elm); \
242 (head)->stqh_last = &(elm)->field.stqe_next; \
243} while (/*CONSTCOND*/0)
244
245#define STAILQ_INSERT_AFTER(head, listelm, elm, field) do { \
246 if (((elm)->field.stqe_next = (listelm)->field.stqe_next) == NULL)\
247 (head)->stqh_last = &(elm)->field.stqe_next; \
248 (listelm)->field.stqe_next = (elm); \
249} while (/*CONSTCOND*/0)
250
251#define STAILQ_REMOVE_HEAD(head, field) do { \
252 if (((head)->stqh_first = (head)->stqh_first->field.stqe_next) == NULL) \
253 (head)->stqh_last = &(head)->stqh_first; \
254} while (/*CONSTCOND*/0)
255
256#define STAILQ_REMOVE(head, elm, type, field) do { \
257 if ((head)->stqh_first == (elm)) { \
258 STAILQ_REMOVE_HEAD((head), field); \
259 } else { \
260 struct type *curelm = (head)->stqh_first; \
261 while (curelm->field.stqe_next != (elm)) \
262 curelm = curelm->field.stqe_next; \
263 if ((curelm->field.stqe_next = \
264 curelm->field.stqe_next->field.stqe_next) == NULL) \
265 (head)->stqh_last = &(curelm)->field.stqe_next; \
266 } \
267} while (/*CONSTCOND*/0)
268
269#define STAILQ_FOREACH(var, head, field) \
270 for ((var) = ((head)->stqh_first); \
271 (var); \
272 (var) = ((var)->field.stqe_next))
273
274#define STAILQ_CONCAT(head1, head2) do { \
275 if (!STAILQ_EMPTY((head2))) { \
276 *(head1)->stqh_last = (head2)->stqh_first; \
277 (head1)->stqh_last = (head2)->stqh_last; \
278 STAILQ_INIT((head2)); \
279 } \
280} while (/*CONSTCOND*/0)
281
282/*
283 * Singly-linked Tail queue access methods.
284 */
285#define STAILQ_EMPTY(head) ((head)->stqh_first == NULL)
286#define STAILQ_FIRST(head) ((head)->stqh_first)
287#define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next)
288
289
290/*
291 * Simple queue definitions.
292 */
293#define SIMPLEQ_HEAD(name, type) \
294struct name { \
295 struct type *sqh_first; /* first element */ \
296 struct type **sqh_last; /* addr of last next element */ \
297}
298
299#define SIMPLEQ_HEAD_INITIALIZER(head) \
300 { NULL, &(head).sqh_first }
301
302#define SIMPLEQ_ENTRY(type) \
303struct { \
304 struct type *sqe_next; /* next element */ \
305}
306
307/*
308 * Simple queue functions.
309 */
310#define SIMPLEQ_INIT(head) do { \
311 (head)->sqh_first = NULL; \
312 (head)->sqh_last = &(head)->sqh_first; \
313} while (/*CONSTCOND*/0)
314
315#define SIMPLEQ_INSERT_HEAD(head, elm, field) do { \
316 if (((elm)->field.sqe_next = (head)->sqh_first) == NULL) \
317 (head)->sqh_last = &(elm)->field.sqe_next; \
318 (head)->sqh_first = (elm); \
319} while (/*CONSTCOND*/0)
320
321#define SIMPLEQ_INSERT_TAIL(head, elm, field) do { \
322 (elm)->field.sqe_next = NULL; \
323 *(head)->sqh_last = (elm); \
324 (head)->sqh_last = &(elm)->field.sqe_next; \
325} while (/*CONSTCOND*/0)
326
327#define SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do { \
328 if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL)\
329 (head)->sqh_last = &(elm)->field.sqe_next; \
330 (listelm)->field.sqe_next = (elm); \
331} while (/*CONSTCOND*/0)
332
333#define SIMPLEQ_REMOVE_HEAD(head, field) do { \
334 if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL) \
335 (head)->sqh_last = &(head)->sqh_first; \
336} while (/*CONSTCOND*/0)
337
338#define SIMPLEQ_REMOVE(head, elm, type, field) do { \
339 if ((head)->sqh_first == (elm)) { \
340 SIMPLEQ_REMOVE_HEAD((head), field); \
341 } else { \
342 struct type *curelm = (head)->sqh_first; \
343 while (curelm->field.sqe_next != (elm)) \
344 curelm = curelm->field.sqe_next; \
345 if ((curelm->field.sqe_next = \
346 curelm->field.sqe_next->field.sqe_next) == NULL) \
347 (head)->sqh_last = &(curelm)->field.sqe_next; \
348 } \
349} while (/*CONSTCOND*/0)
350
351#define SIMPLEQ_FOREACH(var, head, field) \
352 for ((var) = ((head)->sqh_first); \
353 (var); \
354 (var) = ((var)->field.sqe_next))
355
356/*
357 * Simple queue access methods.
358 */
359#define SIMPLEQ_EMPTY(head) ((head)->sqh_first == NULL)
360#define SIMPLEQ_FIRST(head) ((head)->sqh_first)
361#define SIMPLEQ_NEXT(elm, field) ((elm)->field.sqe_next)
362
363
364/*
365 * Tail queue definitions.
366 */
367#define _TAILQ_HEAD(name, type, qual) \
368struct name { \
369 qual type *tqh_first; /* first element */ \
370 qual type *qual *tqh_last; /* addr of last next element */ \
371}
372#define TAILQ_HEAD(name, type) _TAILQ_HEAD(name, struct type,)
373
374#define TAILQ_HEAD_INITIALIZER(head) \
375 { NULL, &(head).tqh_first }
376
377#define _TAILQ_ENTRY(type, qual) \
378struct { \
379 qual type *tqe_next; /* next element */ \
380 qual type *qual *tqe_prev; /* address of previous next element */\
381}
382#define TAILQ_ENTRY(type) _TAILQ_ENTRY(struct type,)
383
384/*
385 * Tail queue functions.
386 */
387#define TAILQ_INIT(head) do { \
388 (head)->tqh_first = NULL; \
389 (head)->tqh_last = &(head)->tqh_first; \
390} while (/*CONSTCOND*/0)
391
392#define TAILQ_INSERT_HEAD(head, elm, field) do { \
393 if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \
394 (head)->tqh_first->field.tqe_prev = \
395 &(elm)->field.tqe_next; \
396 else \
397 (head)->tqh_last = &(elm)->field.tqe_next; \
398 (head)->tqh_first = (elm); \
399 (elm)->field.tqe_prev = &(head)->tqh_first; \
400} while (/*CONSTCOND*/0)
401
402#define TAILQ_INSERT_TAIL(head, elm, field) do { \
403 (elm)->field.tqe_next = NULL; \
404 (elm)->field.tqe_prev = (head)->tqh_last; \
405 *(head)->tqh_last = (elm); \
406 (head)->tqh_last = &(elm)->field.tqe_next; \
407} while (/*CONSTCOND*/0)
408
409#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \
410 if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\
411 (elm)->field.tqe_next->field.tqe_prev = \
412 &(elm)->field.tqe_next; \
413 else \
414 (head)->tqh_last = &(elm)->field.tqe_next; \
415 (listelm)->field.tqe_next = (elm); \
416 (elm)->field.tqe_prev = &(listelm)->field.tqe_next; \
417} while (/*CONSTCOND*/0)
418
419#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \
420 (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \
421 (elm)->field.tqe_next = (listelm); \
422 *(listelm)->field.tqe_prev = (elm); \
423 (listelm)->field.tqe_prev = &(elm)->field.tqe_next; \
424} while (/*CONSTCOND*/0)
425
426#define TAILQ_REMOVE(head, elm, field) do { \
427 if (((elm)->field.tqe_next) != NULL) \
428 (elm)->field.tqe_next->field.tqe_prev = \
429 (elm)->field.tqe_prev; \
430 else \
431 (head)->tqh_last = (elm)->field.tqe_prev; \
432 *(elm)->field.tqe_prev = (elm)->field.tqe_next; \
433} while (/*CONSTCOND*/0)
434
435#define TAILQ_FOREACH(var, head, field) \
436 for ((var) = ((head)->tqh_first); \
437 (var); \
438 (var) = ((var)->field.tqe_next))
439
440#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \
441 for ((var) = (*(((struct headname *)((head)->tqh_last))->tqh_last)); \
442 (var); \
443 (var) = (*(((struct headname *)((var)->field.tqe_prev))->tqh_last)))
444
445#define TAILQ_CONCAT(head1, head2, field) do { \
446 if (!TAILQ_EMPTY(head2)) { \
447 *(head1)->tqh_last = (head2)->tqh_first; \
448 (head2)->tqh_first->field.tqe_prev = (head1)->tqh_last; \
449 (head1)->tqh_last = (head2)->tqh_last; \
450 TAILQ_INIT((head2)); \
451 } \
452} while (/*CONSTCOND*/0)
453
454/*
455 * Tail queue access methods.
456 */
457#define TAILQ_EMPTY(head) ((head)->tqh_first == NULL)
458#define TAILQ_FIRST(head) ((head)->tqh_first)
459#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
460
461#define TAILQ_LAST(head, headname) \
462 (*(((struct headname *)((head)->tqh_last))->tqh_last))
463#define TAILQ_PREV(elm, headname, field) \
464 (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
465
466
467/*
468 * Circular queue definitions.
469 */
470#define CIRCLEQ_HEAD(name, type) \
471struct name { \
472 struct type *cqh_first; /* first element */ \
473 struct type *cqh_last; /* last element */ \
474}
475
476#define CIRCLEQ_HEAD_INITIALIZER(head) \
477 { (void *)&head, (void *)&head }
478
479#define CIRCLEQ_ENTRY(type) \
480struct { \
481 struct type *cqe_next; /* next element */ \
482 struct type *cqe_prev; /* previous element */ \
483}
484
485/*
486 * Circular queue functions.
487 */
488#define CIRCLEQ_INIT(head) do { \
489 (head)->cqh_first = (void *)(head); \
490 (head)->cqh_last = (void *)(head); \
491} while (/*CONSTCOND*/0)
492
493#define CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) do { \
494 (elm)->field.cqe_next = (listelm)->field.cqe_next; \
495 (elm)->field.cqe_prev = (listelm); \
496 if ((listelm)->field.cqe_next == (void *)(head)) \
497 (head)->cqh_last = (elm); \
498 else \
499 (listelm)->field.cqe_next->field.cqe_prev = (elm); \
500 (listelm)->field.cqe_next = (elm); \
501} while (/*CONSTCOND*/0)
502
503#define CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) do { \
504 (elm)->field.cqe_next = (listelm); \
505 (elm)->field.cqe_prev = (listelm)->field.cqe_prev; \
506 if ((listelm)->field.cqe_prev == (void *)(head)) \
507 (head)->cqh_first = (elm); \
508 else \
509 (listelm)->field.cqe_prev->field.cqe_next = (elm); \
510 (listelm)->field.cqe_prev = (elm); \
511} while (/*CONSTCOND*/0)
512
513#define CIRCLEQ_INSERT_HEAD(head, elm, field) do { \
514 (elm)->field.cqe_next = (head)->cqh_first; \
515 (elm)->field.cqe_prev = (void *)(head); \
516 if ((head)->cqh_last == (void *)(head)) \
517 (head)->cqh_last = (elm); \
518 else \
519 (head)->cqh_first->field.cqe_prev = (elm); \
520 (head)->cqh_first = (elm); \
521} while (/*CONSTCOND*/0)
522
523#define CIRCLEQ_INSERT_TAIL(head, elm, field) do { \
524 (elm)->field.cqe_next = (void *)(head); \
525 (elm)->field.cqe_prev = (head)->cqh_last; \
526 if ((head)->cqh_first == (void *)(head)) \
527 (head)->cqh_first = (elm); \
528 else \
529 (head)->cqh_last->field.cqe_next = (elm); \
530 (head)->cqh_last = (elm); \
531} while (/*CONSTCOND*/0)
532
533#define CIRCLEQ_REMOVE(head, elm, field) do { \
534 if ((elm)->field.cqe_next == (void *)(head)) \
535 (head)->cqh_last = (elm)->field.cqe_prev; \
536 else \
537 (elm)->field.cqe_next->field.cqe_prev = \
538 (elm)->field.cqe_prev; \
539 if ((elm)->field.cqe_prev == (void *)(head)) \
540 (head)->cqh_first = (elm)->field.cqe_next; \
541 else \
542 (elm)->field.cqe_prev->field.cqe_next = \
543 (elm)->field.cqe_next; \
544} while (/*CONSTCOND*/0)
545
546#define CIRCLEQ_FOREACH(var, head, field) \
547 for ((var) = ((head)->cqh_first); \
548 (var) != (const void *)(head); \
549 (var) = ((var)->field.cqe_next))
550
551#define CIRCLEQ_FOREACH_REVERSE(var, head, field) \
552 for ((var) = ((head)->cqh_last); \
553 (var) != (const void *)(head); \
554 (var) = ((var)->field.cqe_prev))
555
556/*
557 * Circular queue access methods.
558 */
559#define CIRCLEQ_EMPTY(head) ((head)->cqh_first == (void *)(head))
560#define CIRCLEQ_FIRST(head) ((head)->cqh_first)
561#define CIRCLEQ_LAST(head) ((head)->cqh_last)
562#define CIRCLEQ_NEXT(elm, field) ((elm)->field.cqe_next)
563#define CIRCLEQ_PREV(elm, field) ((elm)->field.cqe_prev)
564
565#define CIRCLEQ_LOOP_NEXT(head, elm, field) \
566 (((elm)->field.cqe_next == (void *)(head)) \
567 ? ((head)->cqh_first) \
568 : (elm->field.cqe_next))
569#define CIRCLEQ_LOOP_PREV(head, elm, field) \
570 (((elm)->field.cqe_prev == (void *)(head)) \
571 ? ((head)->cqh_last) \
572 : (elm->field.cqe_prev))
573
574#endif /* sys/queue.h */
libc/glibc-include/sys/quota.h created+135
...@@ -0,0 +1,135 @@
1/* This just represents the non-kernel parts of <linux/quota.h>.
2 Copyright (C) 1998-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19/*
20 * Copyright (c) 1982, 1986 Regents of the University of California.
21 * All rights reserved.
22 *
23 * This code is derived from software contributed to Berkeley by
24 * Robert Elz at The University of Melbourne.
25 *
26 * Redistribution and use in source and binary forms, with or without
27 * modification, are permitted provided that the following conditions
28 * are met:
29 * 1. Redistributions of source code must retain the above copyright
30 * notice, this list of conditions and the following disclaimer.
31 * 2. Redistributions in binary form must reproduce the above copyright
32 * notice, this list of conditions and the following disclaimer in the
33 * documentation and/or other materials provided with the distribution.
34 * 4. Neither the name of the University nor the names of its contributors
35 * may be used to endorse or promote products derived from this software
36 * without specific prior written permission.
37 *
38 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
39 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
41 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
42 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
43 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
44 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
45 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
46 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
47 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
48 * SUCH DAMAGE.
49 */
50
51#ifndef _SYS_QUOTA_H
52#define _SYS_QUOTA_H 1
53
54#include <features.h>
55#include <sys/types.h>
56
57#include <linux/quota.h>
58
59/*
60 * Convert diskblocks to blocks and the other way around.
61 * currently only to fool the BSD source. :-)
62 */
63#define dbtob(num) ((num) << 10)
64#define btodb(num) ((num) >> 10)
65
66/*
67 * Convert count of filesystem blocks to diskquota blocks, meant for
68 * filesystems where i_blksize != 1024.
69 */
70#define fs_to_dq_blocks(num, blksize) (((num) * (blksize)) / 1024)
71
72/*
73 * Definitions for disk quotas imposed on the average user
74 * (big brother finally hits Linux).
75 *
76 * The following constants define the amount of time given a user
77 * before the soft limits are treated as hard limits (usually resulting
78 * in an allocation failure). The timer is started when the user crosses
79 * their soft limit, it is reset when they go below their soft limit.
80 */
81#define MAX_IQ_TIME 604800 /* (7*24*60*60) 1 week */
82#define MAX_DQ_TIME 604800 /* (7*24*60*60) 1 week */
83
84#define QUOTAFILENAME "quota"
85#define QUOTAGROUP "staff"
86
87#define NR_DQHASH 43 /* Just an arbitrary number any suggestions ? */
88#define NR_DQUOTS 256 /* Number of quotas active at one time */
89
90/* Old name for struct if_dqblk. */
91struct dqblk
92 {
93 __uint64_t dqb_bhardlimit; /* absolute limit on disk quota blocks alloc */
94 __uint64_t dqb_bsoftlimit; /* preferred limit on disk quota blocks */
95 __uint64_t dqb_curspace; /* current quota block count */
96 __uint64_t dqb_ihardlimit; /* maximum # allocated inodes */
97 __uint64_t dqb_isoftlimit; /* preferred inode limit */
98 __uint64_t dqb_curinodes; /* current # allocated inodes */
99 __uint64_t dqb_btime; /* time limit for excessive disk use */
100 __uint64_t dqb_itime; /* time limit for excessive files */
101 __uint32_t dqb_valid; /* bitmask of QIF_* constants */
102 };
103
104/*
105 * Shorthand notation.
106 */
107#define dq_bhardlimit dq_dqb.dqb_bhardlimit
108#define dq_bsoftlimit dq_dqb.dqb_bsoftlimit
109#define dq_curspace dq_dqb.dqb_curspace
110#define dq_valid dq_dqb.dqb_valid
111#define dq_ihardlimit dq_dqb.dqb_ihardlimit
112#define dq_isoftlimit dq_dqb.dqb_isoftlimit
113#define dq_curinodes dq_dqb.dqb_curinodes
114#define dq_btime dq_dqb.dqb_btime
115#define dq_itime dq_dqb.dqb_itime
116
117#define dqoff(UID) ((__loff_t)((UID) * sizeof (struct dqblk)))
118
119/* Old name for struct if_dqinfo. */
120struct dqinfo
121 {
122 __uint64_t dqi_bgrace;
123 __uint64_t dqi_igrace;
124 __uint32_t dqi_flags;
125 __uint32_t dqi_valid;
126 };
127
128__BEGIN_DECLS
129
130extern int quotactl (int __cmd, const char *__special, int __id,
131 __caddr_t __addr) __THROW;
132
133__END_DECLS
134
135#endif /* sys/quota.h */
libc/glibc-include/sys/random.h created+42
...@@ -0,0 +1,42 @@
1/* Interfaces for obtaining random bytes.
2 Copyright (C) 2016-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SYS_RANDOM_H
20#define _SYS_RANDOM_H 1
21
22#include <features.h>
23#include <sys/types.h>
24
25/* Flags for use with getrandom. */
26#define GRND_NONBLOCK 0x01
27#define GRND_RANDOM 0x02
28
29__BEGIN_DECLS
30
31/* Write LENGTH bytes of randomness starting at BUFFER. Return the
32 number of bytes written, or -1 on error. */
33ssize_t getrandom (void *__buffer, size_t __length,
34 unsigned int __flags) __wur;
35
36/* Write LENGTH bytes of randomness starting at BUFFER. Return 0 on
37 success or -1 on error. */
38int getentropy (void *__buffer, size_t __length) __wur;
39
40__END_DECLS
41
42#endif /* _SYS_RANDOM_H */
libc/glibc-include/sys/raw.h created+38
...@@ -0,0 +1,38 @@
1/* Copyright (C) 1999-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_RAW_H
19#define _SYS_RAW_H 1
20
21#include <stdint.h>
22#include <sys/ioctl.h>
23
24/* The major device number for raw devices. */
25#define RAW_MAJOR 162
26
27/* `ioctl' commands for raw devices. */
28#define RAW_SETBIND _IO(0xac, 0)
29#define RAW_GETBIND _IO(0xac, 1)
30
31struct raw_config_request
32{
33 int raw_minor;
34 uint64_t block_major;
35 uint64_t block_minor;
36};
37
38#endif /* sys/raw.h */
libc/glibc-include/sys/reboot.h created+54
...@@ -0,0 +1,54 @@
1/* Copyright (C) 1996-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/* This file should define RB_* macros to be used as flag
19 bits in the argument to the `reboot' system call. */
20
21#ifndef _SYS_REBOOT_H
22#define _SYS_REBOOT_H 1
23
24#include <features.h>
25
26/* Perform a hard reset now. */
27#define RB_AUTOBOOT 0x01234567
28
29/* Halt the system. */
30#define RB_HALT_SYSTEM 0xcdef0123
31
32/* Enable reboot using Ctrl-Alt-Delete keystroke. */
33#define RB_ENABLE_CAD 0x89abcdef
34
35/* Disable reboot using Ctrl-Alt-Delete keystroke. */
36#define RB_DISABLE_CAD 0
37
38/* Stop system and switch power off if possible. */
39#define RB_POWER_OFF 0x4321fedc
40
41/* Suspend system using software suspend. */
42#define RB_SW_SUSPEND 0xd000fce2
43
44/* Reboot system into new kernel. */
45#define RB_KEXEC 0x45584543
46
47__BEGIN_DECLS
48
49/* Reboot or halt the system. */
50extern int reboot (int __howto) __THROW;
51
52__END_DECLS
53
54#endif /* _SYS_REBOOT_H */
libc/glibc-include/sys/reg.h created+77
...@@ -0,0 +1,77 @@
1/* Copyright (C) 2001-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_REG_H
19#define _SYS_REG_H 1
20
21
22#ifdef __x86_64__
23/* Index into an array of 8 byte longs returned from ptrace for
24 location of the users' stored general purpose registers. */
25
26# define R15 0
27# define R14 1
28# define R13 2
29# define R12 3
30# define RBP 4
31# define RBX 5
32# define R11 6
33# define R10 7
34# define R9 8
35# define R8 9
36# define RAX 10
37# define RCX 11
38# define RDX 12
39# define RSI 13
40# define RDI 14
41# define ORIG_RAX 15
42# define RIP 16
43# define CS 17
44# define EFLAGS 18
45# define RSP 19
46# define SS 20
47# define FS_BASE 21
48# define GS_BASE 22
49# define DS 23
50# define ES 24
51# define FS 25
52# define GS 26
53#else
54
55/* Index into an array of 4 byte integers returned from ptrace for
56 * location of the users' stored general purpose registers. */
57
58# define EBX 0
59# define ECX 1
60# define EDX 2
61# define ESI 3
62# define EDI 4
63# define EBP 5
64# define EAX 6
65# define DS 7
66# define ES 8
67# define FS 9
68# define GS 10
69# define ORIG_EAX 11
70# define EIP 12
71# define CS 13
72# define EFL 14
73# define UESP 15
74# define SS 16
75#endif
76
77#endif
libc/glibc-include/sys/resource.h created+102
...@@ -0,0 +1,102 @@
1/* Copyright (C) 1992-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_RESOURCE_H
19#define _SYS_RESOURCE_H 1
20
21#include <features.h>
22
23/* Get the system-dependent definitions of structures and bit values. */
24#include <bits/resource.h>
25
26#ifndef __id_t_defined
27typedef __id_t id_t;
28# define __id_t_defined
29#endif
30
31__BEGIN_DECLS
32
33/* The X/Open standard defines that all the functions below must use
34 `int' as the type for the first argument. When we are compiling with
35 GNU extensions we change this slightly to provide better error
36 checking. */
37#if defined __USE_GNU && !defined __cplusplus
38typedef enum __rlimit_resource __rlimit_resource_t;
39typedef enum __rusage_who __rusage_who_t;
40typedef enum __priority_which __priority_which_t;
41#else
42typedef int __rlimit_resource_t;
43typedef int __rusage_who_t;
44typedef int __priority_which_t;
45#endif
46
47/* Put the soft and hard limits for RESOURCE in *RLIMITS.
48 Returns 0 if successful, -1 if not (and sets errno). */
49#ifndef __USE_FILE_OFFSET64
50extern int getrlimit (__rlimit_resource_t __resource,
51 struct rlimit *__rlimits) __THROW;
52#else
53# ifdef __REDIRECT_NTH
54extern int __REDIRECT_NTH (getrlimit, (__rlimit_resource_t __resource,
55 struct rlimit *__rlimits), getrlimit64);
56# else
57# define getrlimit getrlimit64
58# endif
59#endif
60#ifdef __USE_LARGEFILE64
61extern int getrlimit64 (__rlimit_resource_t __resource,
62 struct rlimit64 *__rlimits) __THROW;
63#endif
64
65/* Set the soft and hard limits for RESOURCE to *RLIMITS.
66 Only the super-user can increase hard limits.
67 Return 0 if successful, -1 if not (and sets errno). */
68#ifndef __USE_FILE_OFFSET64
69extern int setrlimit (__rlimit_resource_t __resource,
70 const struct rlimit *__rlimits) __THROW;
71#else
72# ifdef __REDIRECT_NTH
73extern int __REDIRECT_NTH (setrlimit, (__rlimit_resource_t __resource,
74 const struct rlimit *__rlimits),
75 setrlimit64);
76# else
77# define setrlimit setrlimit64
78# endif
79#endif
80#ifdef __USE_LARGEFILE64
81extern int setrlimit64 (__rlimit_resource_t __resource,
82 const struct rlimit64 *__rlimits) __THROW;
83#endif
84
85/* Return resource usage information on process indicated by WHO
86 and put it in *USAGE. Returns 0 for success, -1 for failure. */
87extern int getrusage (__rusage_who_t __who, struct rusage *__usage) __THROW;
88
89/* Return the highest priority of any process specified by WHICH and WHO
90 (see above); if WHO is zero, the current process, process group, or user
91 (as specified by WHO) is used. A lower priority number means higher
92 priority. Priorities range from PRIO_MIN to PRIO_MAX (above). */
93extern int getpriority (__priority_which_t __which, id_t __who) __THROW;
94
95/* Set the priority of all processes specified by WHICH and WHO (see above)
96 to PRIO. Returns 0 on success, -1 on errors. */
97extern int setpriority (__priority_which_t __which, id_t __who, int __prio)
98 __THROW;
99
100__END_DECLS
101
102#endif /* sys/resource.h */
libc/glibc-include/sys/select.h created+128
...@@ -0,0 +1,128 @@
1/* `fd_set' type and related macros, and `select'/`pselect' declarations.
2 Copyright (C) 1996-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19/* POSIX 1003.1g: 6.2 Select from File Descriptor Sets <sys/select.h> */
20
21#ifndef _SYS_SELECT_H
22#define _SYS_SELECT_H 1
23
24#include <features.h>
25
26/* Get definition of needed basic types. */
27#include <bits/types.h>
28
29/* Get __FD_* definitions. */
30#include <bits/select.h>
31
32/* Get sigset_t. */
33#include <bits/types/sigset_t.h>
34
35/* Get definition of timer specification structures. */
36#include <bits/types/time_t.h>
37#include <bits/types/struct_timeval.h>
38#ifdef __USE_XOPEN2K
39# include <bits/types/struct_timespec.h>
40#endif
41
42#ifndef __suseconds_t_defined
43typedef __suseconds_t suseconds_t;
44# define __suseconds_t_defined
45#endif
46
47
48/* The fd_set member is required to be an array of longs. */
49typedef long int __fd_mask;
50
51/* Some versions of <linux/posix_types.h> define this macros. */
52#undef __NFDBITS
53/* It's easier to assume 8-bit bytes than to get CHAR_BIT. */
54#define __NFDBITS (8 * (int) sizeof (__fd_mask))
55#define __FD_ELT(d) ((d) / __NFDBITS)
56#define __FD_MASK(d) ((__fd_mask) (1UL << ((d) % __NFDBITS)))
57
58/* fd_set for select and pselect. */
59typedef struct
60 {
61 /* XPG4.2 requires this member name. Otherwise avoid the name
62 from the global namespace. */
63#ifdef __USE_XOPEN
64 __fd_mask fds_bits[__FD_SETSIZE / __NFDBITS];
65# define __FDS_BITS(set) ((set)->fds_bits)
66#else
67 __fd_mask __fds_bits[__FD_SETSIZE / __NFDBITS];
68# define __FDS_BITS(set) ((set)->__fds_bits)
69#endif
70 } fd_set;
71
72/* Maximum number of file descriptors in `fd_set'. */
73#define FD_SETSIZE __FD_SETSIZE
74
75#ifdef __USE_MISC
76/* Sometimes the fd_set member is assumed to have this type. */
77typedef __fd_mask fd_mask;
78
79/* Number of bits per word of `fd_set' (some code assumes this is 32). */
80# define NFDBITS __NFDBITS
81#endif
82
83
84/* Access macros for `fd_set'. */
85#define FD_SET(fd, fdsetp) __FD_SET (fd, fdsetp)
86#define FD_CLR(fd, fdsetp) __FD_CLR (fd, fdsetp)
87#define FD_ISSET(fd, fdsetp) __FD_ISSET (fd, fdsetp)
88#define FD_ZERO(fdsetp) __FD_ZERO (fdsetp)
89
90
91__BEGIN_DECLS
92
93/* Check the first NFDS descriptors each in READFDS (if not NULL) for read
94 readiness, in WRITEFDS (if not NULL) for write readiness, and in EXCEPTFDS
95 (if not NULL) for exceptional conditions. If TIMEOUT is not NULL, time out
96 after waiting the interval specified therein. Returns the number of ready
97 descriptors, or -1 for errors.
98
99 This function is a cancellation point and therefore not marked with
100 __THROW. */
101extern int select (int __nfds, fd_set *__restrict __readfds,
102 fd_set *__restrict __writefds,
103 fd_set *__restrict __exceptfds,
104 struct timeval *__restrict __timeout);
105
106#ifdef __USE_XOPEN2K
107/* Same as above only that the TIMEOUT value is given with higher
108 resolution and a sigmask which is been set temporarily. This version
109 should be used.
110
111 This function is a cancellation point and therefore not marked with
112 __THROW. */
113extern int pselect (int __nfds, fd_set *__restrict __readfds,
114 fd_set *__restrict __writefds,
115 fd_set *__restrict __exceptfds,
116 const struct timespec *__restrict __timeout,
117 const __sigset_t *__restrict __sigmask);
118#endif
119
120
121/* Define some inlines helping to catch common problems. */
122#if __USE_FORTIFY_LEVEL > 0 && defined __GNUC__
123# include <bits/select2.h>
124#endif
125
126__END_DECLS
127
128#endif /* sys/select.h */
libc/glibc-include/sys/sem.h created+67
...@@ -0,0 +1,67 @@
1/* Copyright (C) 1995-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_SEM_H
19#define _SYS_SEM_H 1
20
21#include <features.h>
22
23#define __need_size_t
24#include <stddef.h>
25
26/* Get common definition of System V style IPC. */
27#include <sys/ipc.h>
28
29/* Get system dependent definition of `struct semid_ds' and more. */
30#include <bits/sem.h>
31
32#ifdef __USE_GNU
33# include <bits/types/struct_timespec.h>
34#endif
35
36/* The following System V style IPC functions implement a semaphore
37 handling. The definition is found in XPG2. */
38
39/* Structure used for argument to `semop' to describe operations. */
40struct sembuf
41{
42 unsigned short int sem_num; /* semaphore number */
43 short int sem_op; /* semaphore operation */
44 short int sem_flg; /* operation flag */
45};
46
47
48__BEGIN_DECLS
49
50/* Semaphore control operation. */
51extern int semctl (int __semid, int __semnum, int __cmd, ...) __THROW;
52
53/* Get semaphore. */
54extern int semget (key_t __key, int __nsems, int __semflg) __THROW;
55
56/* Operate on semaphore. */
57extern int semop (int __semid, struct sembuf *__sops, size_t __nsops) __THROW;
58
59#ifdef __USE_GNU
60/* Operate on semaphore with timeout. */
61extern int semtimedop (int __semid, struct sembuf *__sops, size_t __nsops,
62 const struct timespec *__timeout) __THROW;
63#endif
64
65__END_DECLS
66
67#endif /* sys/sem.h */
libc/glibc-include/sys/sendfile.h created+51
...@@ -0,0 +1,51 @@
1/* sendfile -- copy data directly from one file descriptor to another
2 Copyright (C) 1998-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SYS_SENDFILE_H
20#define _SYS_SENDFILE_H 1
21
22#include <features.h>
23#include <sys/types.h>
24
25__BEGIN_DECLS
26
27/* Send up to COUNT bytes from file associated with IN_FD starting at
28 *OFFSET to descriptor OUT_FD. Set *OFFSET to the IN_FD's file position
29 following the read bytes. If OFFSET is a null pointer, use the normal
30 file position instead. Return the number of written bytes, or -1 in
31 case of error. */
32#ifndef __USE_FILE_OFFSET64
33extern ssize_t sendfile (int __out_fd, int __in_fd, off_t *__offset,
34 size_t __count) __THROW;
35#else
36# ifdef __REDIRECT_NTH
37extern ssize_t __REDIRECT_NTH (sendfile,
38 (int __out_fd, int __in_fd, __off64_t *__offset,
39 size_t __count), sendfile64);
40# else
41# define sendfile sendfile64
42# endif
43#endif
44#ifdef __USE_LARGEFILE64
45extern ssize_t sendfile64 (int __out_fd, int __in_fd, __off64_t *__offset,
46 size_t __count) __THROW;
47#endif
48
49__END_DECLS
50
51#endif /* sys/sendfile.h */
libc/glibc-include/sys/shm.h created+63
...@@ -0,0 +1,63 @@
1/* Copyright (C) 1995-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_SHM_H
19#define _SYS_SHM_H 1
20
21#include <features.h>
22
23#define __need_size_t
24#include <stddef.h>
25
26/* Get common definition of System V style IPC. */
27#include <sys/ipc.h>
28
29/* Get system dependent definition of `struct shmid_ds' and more. */
30#include <bits/shm.h>
31
32/* Define types required by the standard. */
33#include <bits/types/time_t.h>
34
35#ifdef __USE_XOPEN
36# ifndef __pid_t_defined
37typedef __pid_t pid_t;
38# define __pid_t_defined
39# endif
40#endif /* X/Open */
41
42
43__BEGIN_DECLS
44
45/* The following System V style IPC functions implement a shared memory
46 facility. The definition is found in XPG4.2. */
47
48/* Shared memory control operation. */
49extern int shmctl (int __shmid, int __cmd, struct shmid_ds *__buf) __THROW;
50
51/* Get shared memory segment. */
52extern int shmget (key_t __key, size_t __size, int __shmflg) __THROW;
53
54/* Attach shared memory segment. */
55extern void *shmat (int __shmid, const void *__shmaddr, int __shmflg)
56 __THROW;
57
58/* Detach shared memory segment. */
59extern int shmdt (const void *__shmaddr) __THROW;
60
61__END_DECLS
62
63#endif /* sys/shm.h */
libc/glibc-include/sys/signal.h created+1
...@@ -0,0 +1 @@
1#include <signal.h>
libc/glibc-include/sys/signalfd.h created+62
...@@ -0,0 +1,62 @@
1/* Copyright (C) 2007-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_SIGNALFD_H
19#define _SYS_SIGNALFD_H 1
20
21#include <stdint.h>
22#include <bits/types/sigset_t.h>
23
24/* Get the platform-dependent flags. */
25#include <bits/signalfd.h>
26
27struct signalfd_siginfo
28{
29 uint32_t ssi_signo;
30 int32_t ssi_errno;
31 int32_t ssi_code;
32 uint32_t ssi_pid;
33 uint32_t ssi_uid;
34 int32_t ssi_fd;
35 uint32_t ssi_tid;
36 uint32_t ssi_band;
37 uint32_t ssi_overrun;
38 uint32_t ssi_trapno;
39 int32_t ssi_status;
40 int32_t ssi_int;
41 uint64_t ssi_ptr;
42 uint64_t ssi_utime;
43 uint64_t ssi_stime;
44 uint64_t ssi_addr;
45 uint16_t ssi_addr_lsb;
46 uint16_t __pad2;
47 int32_t ssi_syscall;
48 uint64_t ssi_call_addr;
49 uint32_t ssi_arch;
50 uint8_t __pad[28];
51};
52
53__BEGIN_DECLS
54
55/* Request notification for delivery of signals in MASK to be
56 performed using descriptor FD.*/
57extern int signalfd (int __fd, const sigset_t *__mask, int __flags)
58 __THROW __nonnull ((2));
59
60__END_DECLS
61
62#endif /* sys/signalfd.h */
libc/glibc-include/sys/socket.h created+274
...@@ -0,0 +1,274 @@
1/* Declarations of socket constants, types, and functions.
2 Copyright (C) 1991-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SYS_SOCKET_H
20#define _SYS_SOCKET_H 1
21
22#include <features.h>
23
24__BEGIN_DECLS
25
26#include <bits/types/struct_iovec.h>
27#define __need_size_t
28#include <stddef.h>
29
30/* This operating system-specific header file defines the SOCK_*, PF_*,
31 AF_*, MSG_*, SOL_*, and SO_* constants, and the `struct sockaddr',
32 `struct msghdr', and `struct linger' types. */
33#include <bits/socket.h>
34
35#ifdef __USE_MISC
36# include <bits/types/struct_osockaddr.h>
37#endif
38
39/* The following constants should be used for the second parameter of
40 `shutdown'. */
41enum
42{
43 SHUT_RD = 0, /* No more receptions. */
44#define SHUT_RD SHUT_RD
45 SHUT_WR, /* No more transmissions. */
46#define SHUT_WR SHUT_WR
47 SHUT_RDWR /* No more receptions or transmissions. */
48#define SHUT_RDWR SHUT_RDWR
49};
50
51/* This is the type we use for generic socket address arguments.
52
53 With GCC 2.7 and later, the funky union causes redeclarations or
54 uses with any of the listed types to be allowed without complaint.
55 G++ 2.7 does not support transparent unions so there we want the
56 old-style declaration, too. */
57#if defined __cplusplus || !__GNUC_PREREQ (2, 7) || !defined __USE_GNU
58# define __SOCKADDR_ARG struct sockaddr *__restrict
59# define __CONST_SOCKADDR_ARG const struct sockaddr *
60#else
61/* Add more `struct sockaddr_AF' types here as necessary.
62 These are all the ones I found on NetBSD and Linux. */
63# define __SOCKADDR_ALLTYPES \
64 __SOCKADDR_ONETYPE (sockaddr) \
65 __SOCKADDR_ONETYPE (sockaddr_at) \
66 __SOCKADDR_ONETYPE (sockaddr_ax25) \
67 __SOCKADDR_ONETYPE (sockaddr_dl) \
68 __SOCKADDR_ONETYPE (sockaddr_eon) \
69 __SOCKADDR_ONETYPE (sockaddr_in) \
70 __SOCKADDR_ONETYPE (sockaddr_in6) \
71 __SOCKADDR_ONETYPE (sockaddr_inarp) \
72 __SOCKADDR_ONETYPE (sockaddr_ipx) \
73 __SOCKADDR_ONETYPE (sockaddr_iso) \
74 __SOCKADDR_ONETYPE (sockaddr_ns) \
75 __SOCKADDR_ONETYPE (sockaddr_un) \
76 __SOCKADDR_ONETYPE (sockaddr_x25)
77
78# define __SOCKADDR_ONETYPE(type) struct type *__restrict __##type##__;
79typedef union { __SOCKADDR_ALLTYPES
80 } __SOCKADDR_ARG __attribute__ ((__transparent_union__));
81# undef __SOCKADDR_ONETYPE
82# define __SOCKADDR_ONETYPE(type) const struct type *__restrict __##type##__;
83typedef union { __SOCKADDR_ALLTYPES
84 } __CONST_SOCKADDR_ARG __attribute__ ((__transparent_union__));
85# undef __SOCKADDR_ONETYPE
86#endif
87
88#ifdef __USE_GNU
89/* For `recvmmsg' and `sendmmsg'. */
90struct mmsghdr
91 {
92 struct msghdr msg_hdr; /* Actual message header. */
93 unsigned int msg_len; /* Number of received or sent bytes for the
94 entry. */
95 };
96#endif
97
98
99/* Create a new socket of type TYPE in domain DOMAIN, using
100 protocol PROTOCOL. If PROTOCOL is zero, one is chosen automatically.
101 Returns a file descriptor for the new socket, or -1 for errors. */
102extern int socket (int __domain, int __type, int __protocol) __THROW;
103
104/* Create two new sockets, of type TYPE in domain DOMAIN and using
105 protocol PROTOCOL, which are connected to each other, and put file
106 descriptors for them in FDS[0] and FDS[1]. If PROTOCOL is zero,
107 one will be chosen automatically. Returns 0 on success, -1 for errors. */
108extern int socketpair (int __domain, int __type, int __protocol,
109 int __fds[2]) __THROW;
110
111/* Give the socket FD the local address ADDR (which is LEN bytes long). */
112extern int bind (int __fd, __CONST_SOCKADDR_ARG __addr, socklen_t __len)
113 __THROW;
114
115/* Put the local address of FD into *ADDR and its length in *LEN. */
116extern int getsockname (int __fd, __SOCKADDR_ARG __addr,
117 socklen_t *__restrict __len) __THROW;
118
119/* Open a connection on socket FD to peer at ADDR (which LEN bytes long).
120 For connectionless socket types, just set the default address to send to
121 and the only address from which to accept transmissions.
122 Return 0 on success, -1 for errors.
123
124 This function is a cancellation point and therefore not marked with
125 __THROW. */
126extern int connect (int __fd, __CONST_SOCKADDR_ARG __addr, socklen_t __len);
127
128/* Put the address of the peer connected to socket FD into *ADDR
129 (which is *LEN bytes long), and its actual length into *LEN. */
130extern int getpeername (int __fd, __SOCKADDR_ARG __addr,
131 socklen_t *__restrict __len) __THROW;
132
133
134/* Send N bytes of BUF to socket FD. Returns the number sent or -1.
135
136 This function is a cancellation point and therefore not marked with
137 __THROW. */
138extern ssize_t send (int __fd, const void *__buf, size_t __n, int __flags);
139
140/* Read N bytes into BUF from socket FD.
141 Returns the number read or -1 for errors.
142
143 This function is a cancellation point and therefore not marked with
144 __THROW. */
145extern ssize_t recv (int __fd, void *__buf, size_t __n, int __flags);
146
147/* Send N bytes of BUF on socket FD to peer at address ADDR (which is
148 ADDR_LEN bytes long). Returns the number sent, or -1 for errors.
149
150 This function is a cancellation point and therefore not marked with
151 __THROW. */
152extern ssize_t sendto (int __fd, const void *__buf, size_t __n,
153 int __flags, __CONST_SOCKADDR_ARG __addr,
154 socklen_t __addr_len);
155
156/* Read N bytes into BUF through socket FD.
157 If ADDR is not NULL, fill in *ADDR_LEN bytes of it with tha address of
158 the sender, and store the actual size of the address in *ADDR_LEN.
159 Returns the number of bytes read or -1 for errors.
160
161 This function is a cancellation point and therefore not marked with
162 __THROW. */
163extern ssize_t recvfrom (int __fd, void *__restrict __buf, size_t __n,
164 int __flags, __SOCKADDR_ARG __addr,
165 socklen_t *__restrict __addr_len);
166
167
168/* Send a message described MESSAGE on socket FD.
169 Returns the number of bytes sent, or -1 for errors.
170
171 This function is a cancellation point and therefore not marked with
172 __THROW. */
173extern ssize_t sendmsg (int __fd, const struct msghdr *__message,
174 int __flags);
175
176#ifdef __USE_GNU
177/* Send a VLEN messages as described by VMESSAGES to socket FD.
178 Returns the number of datagrams successfully written or -1 for errors.
179
180 This function is a cancellation point and therefore not marked with
181 __THROW. */
182extern int sendmmsg (int __fd, struct mmsghdr *__vmessages,
183 unsigned int __vlen, int __flags);
184#endif
185
186/* Receive a message as described by MESSAGE from socket FD.
187 Returns the number of bytes read or -1 for errors.
188
189 This function is a cancellation point and therefore not marked with
190 __THROW. */
191extern ssize_t recvmsg (int __fd, struct msghdr *__message, int __flags);
192
193#ifdef __USE_GNU
194/* Receive up to VLEN messages as described by VMESSAGES from socket FD.
195 Returns the number of messages received or -1 for errors.
196
197 This function is a cancellation point and therefore not marked with
198 __THROW. */
199extern int recvmmsg (int __fd, struct mmsghdr *__vmessages,
200 unsigned int __vlen, int __flags,
201 struct timespec *__tmo);
202#endif
203
204
205/* Put the current value for socket FD's option OPTNAME at protocol level LEVEL
206 into OPTVAL (which is *OPTLEN bytes long), and set *OPTLEN to the value's
207 actual length. Returns 0 on success, -1 for errors. */
208extern int getsockopt (int __fd, int __level, int __optname,
209 void *__restrict __optval,
210 socklen_t *__restrict __optlen) __THROW;
211
212/* Set socket FD's option OPTNAME at protocol level LEVEL
213 to *OPTVAL (which is OPTLEN bytes long).
214 Returns 0 on success, -1 for errors. */
215extern int setsockopt (int __fd, int __level, int __optname,
216 const void *__optval, socklen_t __optlen) __THROW;
217
218
219/* Prepare to accept connections on socket FD.
220 N connection requests will be queued before further requests are refused.
221 Returns 0 on success, -1 for errors. */
222extern int listen (int __fd, int __n) __THROW;
223
224/* Await a connection on socket FD.
225 When a connection arrives, open a new socket to communicate with it,
226 set *ADDR (which is *ADDR_LEN bytes long) to the address of the connecting
227 peer and *ADDR_LEN to the address's actual length, and return the
228 new socket's descriptor, or -1 for errors.
229
230 This function is a cancellation point and therefore not marked with
231 __THROW. */
232extern int accept (int __fd, __SOCKADDR_ARG __addr,
233 socklen_t *__restrict __addr_len);
234
235#ifdef __USE_GNU
236/* Similar to 'accept' but takes an additional parameter to specify flags.
237
238 This function is a cancellation point and therefore not marked with
239 __THROW. */
240extern int accept4 (int __fd, __SOCKADDR_ARG __addr,
241 socklen_t *__restrict __addr_len, int __flags);
242#endif
243
244/* Shut down all or part of the connection open on socket FD.
245 HOW determines what to shut down:
246 SHUT_RD = No more receptions;
247 SHUT_WR = No more transmissions;
248 SHUT_RDWR = No more receptions or transmissions.
249 Returns 0 on success, -1 for errors. */
250extern int shutdown (int __fd, int __how) __THROW;
251
252
253#ifdef __USE_XOPEN2K
254/* Determine whether socket is at a out-of-band mark. */
255extern int sockatmark (int __fd) __THROW;
256#endif
257
258
259#ifdef __USE_MISC
260/* FDTYPE is S_IFSOCK or another S_IF* macro defined in <sys/stat.h>;
261 returns 1 if FD is open on an object of the indicated type, 0 if not,
262 or -1 for errors (setting errno). */
263extern int isfdtype (int __fd, int __fdtype) __THROW;
264#endif
265
266
267/* Define some macros helping to catch buffer overflows. */
268#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
269# include <bits/socket2.h>
270#endif
271
272__END_DECLS
273
274#endif /* sys/socket.h */
libc/glibc-include/sys/socketvar.h created+3
...@@ -0,0 +1,3 @@
1/* This header is used on many systems but for GNU we have everything
2 already defined in the standard header. */
3#include <sys/socket.h>
libc/glibc-include/sys/soundcard.h created+1
...@@ -0,0 +1 @@
1#include <linux/soundcard.h>
libc/glibc-include/sys/stat.h created+537
...@@ -0,0 +1,537 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/*
19 * POSIX Standard: 5.6 File Characteristics <sys/stat.h>
20 */
21
22#ifndef _SYS_STAT_H
23#define _SYS_STAT_H 1
24
25#include <features.h>
26
27#include <bits/types.h> /* For __mode_t and __dev_t. */
28
29#ifdef __USE_XOPEN2K8
30# include <bits/types/struct_timespec.h>
31#endif
32
33#if defined __USE_XOPEN || defined __USE_XOPEN2K
34/* The Single Unix specification says that some more types are
35 available here. */
36
37# include <bits/types/time_t.h>
38
39# ifndef __dev_t_defined
40typedef __dev_t dev_t;
41# define __dev_t_defined
42# endif
43
44# ifndef __gid_t_defined
45typedef __gid_t gid_t;
46# define __gid_t_defined
47# endif
48
49# ifndef __ino_t_defined
50# ifndef __USE_FILE_OFFSET64
51typedef __ino_t ino_t;
52# else
53typedef __ino64_t ino_t;
54# endif
55# define __ino_t_defined
56# endif
57
58# ifndef __mode_t_defined
59typedef __mode_t mode_t;
60# define __mode_t_defined
61# endif
62
63# ifndef __nlink_t_defined
64typedef __nlink_t nlink_t;
65# define __nlink_t_defined
66# endif
67
68# ifndef __off_t_defined
69# ifndef __USE_FILE_OFFSET64
70typedef __off_t off_t;
71# else
72typedef __off64_t off_t;
73# endif
74# define __off_t_defined
75# endif
76
77# ifndef __uid_t_defined
78typedef __uid_t uid_t;
79# define __uid_t_defined
80# endif
81#endif /* X/Open */
82
83#ifdef __USE_UNIX98
84# ifndef __blkcnt_t_defined
85# ifndef __USE_FILE_OFFSET64
86typedef __blkcnt_t blkcnt_t;
87# else
88typedef __blkcnt64_t blkcnt_t;
89# endif
90# define __blkcnt_t_defined
91# endif
92
93# ifndef __blksize_t_defined
94typedef __blksize_t blksize_t;
95# define __blksize_t_defined
96# endif
97#endif /* Unix98 */
98
99__BEGIN_DECLS
100
101#include <bits/stat.h>
102
103#if defined __USE_MISC || defined __USE_XOPEN
104# define S_IFMT __S_IFMT
105# define S_IFDIR __S_IFDIR
106# define S_IFCHR __S_IFCHR
107# define S_IFBLK __S_IFBLK
108# define S_IFREG __S_IFREG
109# ifdef __S_IFIFO
110# define S_IFIFO __S_IFIFO
111# endif
112# ifdef __S_IFLNK
113# define S_IFLNK __S_IFLNK
114# endif
115# if (defined __USE_MISC || defined __USE_XOPEN_EXTENDED) \
116 && defined __S_IFSOCK
117# define S_IFSOCK __S_IFSOCK
118# endif
119#endif
120
121/* Test macros for file types. */
122
123#define __S_ISTYPE(mode, mask) (((mode) & __S_IFMT) == (mask))
124
125#define S_ISDIR(mode) __S_ISTYPE((mode), __S_IFDIR)
126#define S_ISCHR(mode) __S_ISTYPE((mode), __S_IFCHR)
127#define S_ISBLK(mode) __S_ISTYPE((mode), __S_IFBLK)
128#define S_ISREG(mode) __S_ISTYPE((mode), __S_IFREG)
129#ifdef __S_IFIFO
130# define S_ISFIFO(mode) __S_ISTYPE((mode), __S_IFIFO)
131#endif
132#ifdef __S_IFLNK
133# define S_ISLNK(mode) __S_ISTYPE((mode), __S_IFLNK)
134#endif
135
136#if defined __USE_MISC && !defined __S_IFLNK
137# define S_ISLNK(mode) 0
138#endif
139
140#if (defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K) \
141 && defined __S_IFSOCK
142# define S_ISSOCK(mode) __S_ISTYPE((mode), __S_IFSOCK)
143#elif defined __USE_XOPEN2K
144# define S_ISSOCK(mode) 0
145#endif
146
147/* These are from POSIX.1b. If the objects are not implemented using separate
148 distinct file types, the macros always will evaluate to zero. Unlike the
149 other S_* macros the following three take a pointer to a `struct stat'
150 object as the argument. */
151#ifdef __USE_POSIX199309
152# define S_TYPEISMQ(buf) __S_TYPEISMQ(buf)
153# define S_TYPEISSEM(buf) __S_TYPEISSEM(buf)
154# define S_TYPEISSHM(buf) __S_TYPEISSHM(buf)
155#endif
156
157
158/* Protection bits. */
159
160#define S_ISUID __S_ISUID /* Set user ID on execution. */
161#define S_ISGID __S_ISGID /* Set group ID on execution. */
162
163#if defined __USE_MISC || defined __USE_XOPEN
164/* Save swapped text after use (sticky bit). This is pretty well obsolete. */
165# define S_ISVTX __S_ISVTX
166#endif
167
168#define S_IRUSR __S_IREAD /* Read by owner. */
169#define S_IWUSR __S_IWRITE /* Write by owner. */
170#define S_IXUSR __S_IEXEC /* Execute by owner. */
171/* Read, write, and execute by owner. */
172#define S_IRWXU (__S_IREAD|__S_IWRITE|__S_IEXEC)
173
174#ifdef __USE_MISC
175# define S_IREAD S_IRUSR
176# define S_IWRITE S_IWUSR
177# define S_IEXEC S_IXUSR
178#endif
179
180#define S_IRGRP (S_IRUSR >> 3) /* Read by group. */
181#define S_IWGRP (S_IWUSR >> 3) /* Write by group. */
182#define S_IXGRP (S_IXUSR >> 3) /* Execute by group. */
183/* Read, write, and execute by group. */
184#define S_IRWXG (S_IRWXU >> 3)
185
186#define S_IROTH (S_IRGRP >> 3) /* Read by others. */
187#define S_IWOTH (S_IWGRP >> 3) /* Write by others. */
188#define S_IXOTH (S_IXGRP >> 3) /* Execute by others. */
189/* Read, write, and execute by others. */
190#define S_IRWXO (S_IRWXG >> 3)
191
192
193#ifdef __USE_MISC
194/* Macros for common mode bit masks. */
195# define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */
196# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)/* 07777 */
197# define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)/* 0666*/
198
199# define S_BLKSIZE 512 /* Block size for `st_blocks'. */
200#endif
201
202
203#ifndef __USE_FILE_OFFSET64
204/* Get file attributes for FILE and put them in BUF. */
205extern int stat (const char *__restrict __file,
206 struct stat *__restrict __buf) __THROW __nonnull ((1, 2));
207
208/* Get file attributes for the file, device, pipe, or socket
209 that file descriptor FD is open on and put them in BUF. */
210extern int fstat (int __fd, struct stat *__buf) __THROW __nonnull ((2));
211#else
212# ifdef __REDIRECT_NTH
213extern int __REDIRECT_NTH (stat, (const char *__restrict __file,
214 struct stat *__restrict __buf), stat64)
215 __nonnull ((1, 2));
216extern int __REDIRECT_NTH (fstat, (int __fd, struct stat *__buf), fstat64)
217 __nonnull ((2));
218# else
219# define stat stat64
220# define fstat fstat64
221# endif
222#endif
223#ifdef __USE_LARGEFILE64
224extern int stat64 (const char *__restrict __file,
225 struct stat64 *__restrict __buf) __THROW __nonnull ((1, 2));
226extern int fstat64 (int __fd, struct stat64 *__buf) __THROW __nonnull ((2));
227#endif
228
229#ifdef __USE_ATFILE
230/* Similar to stat, get the attributes for FILE and put them in BUF.
231 Relative path names are interpreted relative to FD unless FD is
232 AT_FDCWD. */
233# ifndef __USE_FILE_OFFSET64
234extern int fstatat (int __fd, const char *__restrict __file,
235 struct stat *__restrict __buf, int __flag)
236 __THROW __nonnull ((2, 3));
237# else
238# ifdef __REDIRECT_NTH
239extern int __REDIRECT_NTH (fstatat, (int __fd, const char *__restrict __file,
240 struct stat *__restrict __buf,
241 int __flag),
242 fstatat64) __nonnull ((2, 3));
243# else
244# define fstatat fstatat64
245# endif
246# endif
247
248# ifdef __USE_LARGEFILE64
249extern int fstatat64 (int __fd, const char *__restrict __file,
250 struct stat64 *__restrict __buf, int __flag)
251 __THROW __nonnull ((2, 3));
252# endif
253#endif
254
255#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K
256# ifndef __USE_FILE_OFFSET64
257/* Get file attributes about FILE and put them in BUF.
258 If FILE is a symbolic link, do not follow it. */
259extern int lstat (const char *__restrict __file,
260 struct stat *__restrict __buf) __THROW __nonnull ((1, 2));
261# else
262# ifdef __REDIRECT_NTH
263extern int __REDIRECT_NTH (lstat,
264 (const char *__restrict __file,
265 struct stat *__restrict __buf), lstat64)
266 __nonnull ((1, 2));
267# else
268# define lstat lstat64
269# endif
270# endif
271# ifdef __USE_LARGEFILE64
272extern int lstat64 (const char *__restrict __file,
273 struct stat64 *__restrict __buf)
274 __THROW __nonnull ((1, 2));
275# endif
276#endif
277
278/* Set file access permissions for FILE to MODE.
279 If FILE is a symbolic link, this affects its target instead. */
280extern int chmod (const char *__file, __mode_t __mode)
281 __THROW __nonnull ((1));
282
283#ifdef __USE_MISC
284/* Set file access permissions for FILE to MODE.
285 If FILE is a symbolic link, this affects the link itself
286 rather than its target. */
287extern int lchmod (const char *__file, __mode_t __mode)
288 __THROW __nonnull ((1));
289#endif
290
291/* Set file access permissions of the file FD is open on to MODE. */
292#if defined __USE_POSIX199309 || defined __USE_XOPEN_EXTENDED
293extern int fchmod (int __fd, __mode_t __mode) __THROW;
294#endif
295
296#ifdef __USE_ATFILE
297/* Set file access permissions of FILE relative to
298 the directory FD is open on. */
299extern int fchmodat (int __fd, const char *__file, __mode_t __mode,
300 int __flag)
301 __THROW __nonnull ((2)) __wur;
302#endif /* Use ATFILE. */
303
304
305
306/* Set the file creation mask of the current process to MASK,
307 and return the old creation mask. */
308extern __mode_t umask (__mode_t __mask) __THROW;
309
310#ifdef __USE_GNU
311/* Get the current `umask' value without changing it.
312 This function is only available under the GNU Hurd. */
313extern __mode_t getumask (void) __THROW;
314#endif
315
316/* Create a new directory named PATH, with permission bits MODE. */
317extern int mkdir (const char *__path, __mode_t __mode)
318 __THROW __nonnull ((1));
319
320#ifdef __USE_ATFILE
321/* Like mkdir, create a new directory with permission bits MODE. But
322 interpret relative PATH names relative to the directory associated
323 with FD. */
324extern int mkdirat (int __fd, const char *__path, __mode_t __mode)
325 __THROW __nonnull ((2));
326#endif
327
328/* Create a device file named PATH, with permission and special bits MODE
329 and device number DEV (which can be constructed from major and minor
330 device numbers with the `makedev' macro above). */
331#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
332extern int mknod (const char *__path, __mode_t __mode, __dev_t __dev)
333 __THROW __nonnull ((1));
334
335# ifdef __USE_ATFILE
336/* Like mknod, create a new device file with permission bits MODE and
337 device number DEV. But interpret relative PATH names relative to
338 the directory associated with FD. */
339extern int mknodat (int __fd, const char *__path, __mode_t __mode,
340 __dev_t __dev) __THROW __nonnull ((2));
341# endif
342#endif
343
344
345/* Create a new FIFO named PATH, with permission bits MODE. */
346extern int mkfifo (const char *__path, __mode_t __mode)
347 __THROW __nonnull ((1));
348
349#ifdef __USE_ATFILE
350/* Like mkfifo, create a new FIFO with permission bits MODE. But
351 interpret relative PATH names relative to the directory associated
352 with FD. */
353extern int mkfifoat (int __fd, const char *__path, __mode_t __mode)
354 __THROW __nonnull ((2));
355#endif
356
357#ifdef __USE_ATFILE
358/* Set file access and modification times relative to directory file
359 descriptor. */
360extern int utimensat (int __fd, const char *__path,
361 const struct timespec __times[2],
362 int __flags)
363 __THROW __nonnull ((2));
364#endif
365
366#ifdef __USE_XOPEN2K8
367/* Set file access and modification times of the file associated with FD. */
368extern int futimens (int __fd, const struct timespec __times[2]) __THROW;
369#endif
370
371/* To allow the `struct stat' structure and the file type `mode_t'
372 bits to vary without changing shared library major version number,
373 the `stat' family of functions and `mknod' are in fact inline
374 wrappers around calls to `xstat', `fxstat', `lxstat', and `xmknod',
375 which all take a leading version-number argument designating the
376 data structure and bits used. <bits/stat.h> defines _STAT_VER with
377 the version number corresponding to `struct stat' as defined in
378 that file; and _MKNOD_VER with the version number corresponding to
379 the S_IF* macros defined therein. It is arranged that when not
380 inlined these function are always statically linked; that way a
381 dynamically-linked executable always encodes the version number
382 corresponding to the data structures it uses, so the `x' functions
383 in the shared library can adapt without needing to recompile all
384 callers. */
385
386#ifndef _STAT_VER
387# define _STAT_VER 0
388#endif
389#ifndef _MKNOD_VER
390# define _MKNOD_VER 0
391#endif
392
393/* Wrappers for stat and mknod system calls. */
394#ifndef __USE_FILE_OFFSET64
395extern int __fxstat (int __ver, int __fildes, struct stat *__stat_buf)
396 __THROW __nonnull ((3));
397extern int __xstat (int __ver, const char *__filename,
398 struct stat *__stat_buf) __THROW __nonnull ((2, 3));
399extern int __lxstat (int __ver, const char *__filename,
400 struct stat *__stat_buf) __THROW __nonnull ((2, 3));
401extern int __fxstatat (int __ver, int __fildes, const char *__filename,
402 struct stat *__stat_buf, int __flag)
403 __THROW __nonnull ((3, 4));
404#else
405# ifdef __REDIRECT_NTH
406extern int __REDIRECT_NTH (__fxstat, (int __ver, int __fildes,
407 struct stat *__stat_buf), __fxstat64)
408 __nonnull ((3));
409extern int __REDIRECT_NTH (__xstat, (int __ver, const char *__filename,
410 struct stat *__stat_buf), __xstat64)
411 __nonnull ((2, 3));
412extern int __REDIRECT_NTH (__lxstat, (int __ver, const char *__filename,
413 struct stat *__stat_buf), __lxstat64)
414 __nonnull ((2, 3));
415extern int __REDIRECT_NTH (__fxstatat, (int __ver, int __fildes,
416 const char *__filename,
417 struct stat *__stat_buf, int __flag),
418 __fxstatat64) __nonnull ((3, 4));
419
420# else
421# define __fxstat __fxstat64
422# define __xstat __xstat64
423# define __lxstat __lxstat64
424# endif
425#endif
426
427#ifdef __USE_LARGEFILE64
428extern int __fxstat64 (int __ver, int __fildes, struct stat64 *__stat_buf)
429 __THROW __nonnull ((3));
430extern int __xstat64 (int __ver, const char *__filename,
431 struct stat64 *__stat_buf) __THROW __nonnull ((2, 3));
432extern int __lxstat64 (int __ver, const char *__filename,
433 struct stat64 *__stat_buf) __THROW __nonnull ((2, 3));
434extern int __fxstatat64 (int __ver, int __fildes, const char *__filename,
435 struct stat64 *__stat_buf, int __flag)
436 __THROW __nonnull ((3, 4));
437#endif
438extern int __xmknod (int __ver, const char *__path, __mode_t __mode,
439 __dev_t *__dev) __THROW __nonnull ((2, 4));
440
441extern int __xmknodat (int __ver, int __fd, const char *__path,
442 __mode_t __mode, __dev_t *__dev)
443 __THROW __nonnull ((3, 5));
444
445#ifdef __USE_GNU
446# include <bits/statx.h>
447#endif
448
449#ifdef __USE_EXTERN_INLINES
450/* Inlined versions of the real stat and mknod functions. */
451
452__extern_inline int
453__NTH (stat (const char *__path, struct stat *__statbuf))
454{
455 return __xstat (_STAT_VER, __path, __statbuf);
456}
457
458# if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
459__extern_inline int
460__NTH (lstat (const char *__path, struct stat *__statbuf))
461{
462 return __lxstat (_STAT_VER, __path, __statbuf);
463}
464# endif
465
466__extern_inline int
467__NTH (fstat (int __fd, struct stat *__statbuf))
468{
469 return __fxstat (_STAT_VER, __fd, __statbuf);
470}
471
472# ifdef __USE_ATFILE
473__extern_inline int
474__NTH (fstatat (int __fd, const char *__filename, struct stat *__statbuf,
475 int __flag))
476{
477 return __fxstatat (_STAT_VER, __fd, __filename, __statbuf, __flag);
478}
479# endif
480
481# ifdef __USE_MISC
482__extern_inline int
483__NTH (mknod (const char *__path, __mode_t __mode, __dev_t __dev))
484{
485 return __xmknod (_MKNOD_VER, __path, __mode, &__dev);
486}
487# endif
488
489# ifdef __USE_ATFILE
490__extern_inline int
491__NTH (mknodat (int __fd, const char *__path, __mode_t __mode,
492 __dev_t __dev))
493{
494 return __xmknodat (_MKNOD_VER, __fd, __path, __mode, &__dev);
495}
496# endif
497
498# if defined __USE_LARGEFILE64 \
499 && (! defined __USE_FILE_OFFSET64 \
500 || (defined __REDIRECT_NTH && defined __OPTIMIZE__))
501__extern_inline int
502__NTH (stat64 (const char *__path, struct stat64 *__statbuf))
503{
504 return __xstat64 (_STAT_VER, __path, __statbuf);
505}
506
507# if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
508__extern_inline int
509__NTH (lstat64 (const char *__path, struct stat64 *__statbuf))
510{
511 return __lxstat64 (_STAT_VER, __path, __statbuf);
512}
513# endif
514
515__extern_inline int
516__NTH (fstat64 (int __fd, struct stat64 *__statbuf))
517{
518 return __fxstat64 (_STAT_VER, __fd, __statbuf);
519}
520
521# ifdef __USE_ATFILE
522__extern_inline int
523__NTH (fstatat64 (int __fd, const char *__filename, struct stat64 *__statbuf,
524 int __flag))
525{
526 return __fxstatat64 (_STAT_VER, __fd, __filename, __statbuf, __flag);
527}
528# endif
529
530# endif
531
532#endif
533
534__END_DECLS
535
536
537#endif /* sys/stat.h */
libc/glibc-include/sys/statfs.h created+67
...@@ -0,0 +1,67 @@
1/* Definitions for getting information about a filesystem.
2 Copyright (C) 1996-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SYS_STATFS_H
20#define _SYS_STATFS_H 1
21
22#include <features.h>
23
24/* Get the system-specific definition of `struct statfs'. */
25#include <bits/statfs.h>
26
27__BEGIN_DECLS
28
29/* Return information about the filesystem on which FILE resides. */
30#ifndef __USE_FILE_OFFSET64
31extern int statfs (const char *__file, struct statfs *__buf)
32 __THROW __nonnull ((1, 2));
33#else
34# ifdef __REDIRECT_NTH
35extern int __REDIRECT_NTH (statfs,
36 (const char *__file, struct statfs *__buf),
37 statfs64) __nonnull ((1, 2));
38# else
39# define statfs statfs64
40# endif
41#endif
42#ifdef __USE_LARGEFILE64
43extern int statfs64 (const char *__file, struct statfs64 *__buf)
44 __THROW __nonnull ((1, 2));
45#endif
46
47/* Return information about the filesystem containing the file FILDES
48 refers to. */
49#ifndef __USE_FILE_OFFSET64
50extern int fstatfs (int __fildes, struct statfs *__buf)
51 __THROW __nonnull ((2));
52#else
53# ifdef __REDIRECT_NTH
54extern int __REDIRECT_NTH (fstatfs, (int __fildes, struct statfs *__buf),
55 fstatfs64) __nonnull ((2));
56# else
57# define fstatfs fstatfs64
58# endif
59#endif
60#ifdef __USE_LARGEFILE64
61extern int fstatfs64 (int __fildes, struct statfs64 *__buf)
62 __THROW __nonnull ((2));
63#endif
64
65__END_DECLS
66
67#endif /* sys/statfs.h */
libc/glibc-include/sys/statvfs.h created+90
...@@ -0,0 +1,90 @@
1/* Definitions for getting information about a filesystem.
2 Copyright (C) 1998-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SYS_STATVFS_H
20#define _SYS_STATVFS_H 1
21
22#include <features.h>
23
24/* Get the system-specific definition of `struct statfs'. */
25#include <bits/statvfs.h>
26
27#ifndef __USE_FILE_OFFSET64
28# ifndef __fsblkcnt_t_defined
29typedef __fsblkcnt_t fsblkcnt_t; /* Type to count file system blocks. */
30# define __fsblkcnt_t_defined
31# endif
32# ifndef __fsfilcnt_t_defined
33typedef __fsfilcnt_t fsfilcnt_t; /* Type to count file system inodes. */
34# define __fsfilcnt_t_defined
35# endif
36#else
37# ifndef __fsblkcnt_t_defined
38typedef __fsblkcnt64_t fsblkcnt_t; /* Type to count file system blocks. */
39# define __fsblkcnt_t_defined
40# endif
41# ifndef __fsfilcnt_t_defined
42typedef __fsfilcnt64_t fsfilcnt_t; /* Type to count file system inodes. */
43# define __fsfilcnt_t_defined
44# endif
45#endif
46
47__BEGIN_DECLS
48
49/* Return information about the filesystem on which FILE resides. */
50#ifndef __USE_FILE_OFFSET64
51extern int statvfs (const char *__restrict __file,
52 struct statvfs *__restrict __buf)
53 __THROW __nonnull ((1, 2));
54#else
55# ifdef __REDIRECT_NTH
56extern int __REDIRECT_NTH (statvfs,
57 (const char *__restrict __file,
58 struct statvfs *__restrict __buf), statvfs64)
59 __nonnull ((1, 2));
60# else
61# define statvfs statvfs64
62# endif
63#endif
64#ifdef __USE_LARGEFILE64
65extern int statvfs64 (const char *__restrict __file,
66 struct statvfs64 *__restrict __buf)
67 __THROW __nonnull ((1, 2));
68#endif
69
70/* Return information about the filesystem containing the file FILDES
71 refers to. */
72#ifndef __USE_FILE_OFFSET64
73extern int fstatvfs (int __fildes, struct statvfs *__buf)
74 __THROW __nonnull ((2));
75#else
76# ifdef __REDIRECT_NTH
77extern int __REDIRECT_NTH (fstatvfs, (int __fildes, struct statvfs *__buf),
78 fstatvfs64) __nonnull ((2));
79# else
80# define fstatvfs fstatvfs64
81# endif
82#endif
83#ifdef __USE_LARGEFILE64
84extern int fstatvfs64 (int __fildes, struct statvfs64 *__buf)
85 __THROW __nonnull ((2));
86#endif
87
88__END_DECLS
89
90#endif /* sys/statvfs.h */
libc/glibc-include/sys/stropts.h created+1
...@@ -0,0 +1 @@
1#include <stropts.h>
libc/glibc-include/sys/swap.h created+43
...@@ -0,0 +1,43 @@
1/* Calls to enable and disable swapping on specified locations. Linux version.
2 Copyright (C) 1996-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SYS_SWAP_H
20
21#define _SYS_SWAP_H 1
22#include <features.h>
23
24/* The swap priority is encoded as:
25 (prio << SWAP_FLAG_PRIO_SHIFT) & SWAP_FLAG_PRIO_MASK
26*/
27#define SWAP_FLAG_PREFER 0x8000 /* Set if swap priority is specified. */
28#define SWAP_FLAG_PRIO_MASK 0x7fff
29#define SWAP_FLAG_PRIO_SHIFT 0
30#define SWAP_FLAG_DISCARD 0x10000 /* Discard swap cluster after use. */
31
32__BEGIN_DECLS
33
34/* Make the block special device PATH available to the system for swapping.
35 This call is restricted to the super-user. */
36extern int swapon (const char *__path, int __flags) __THROW;
37
38/* Stop using block special device PATH for swapping. */
39extern int swapoff (const char *__path) __THROW;
40
41__END_DECLS
42
43#endif /* _SYS_SWAP_H */
libc/glibc-include/sys/syscall.h created+34
...@@ -0,0 +1,34 @@
1/* Copyright (C) 1995-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYSCALL_H
19#define _SYSCALL_H 1
20
21/* This file should list the numbers of the system calls the system knows.
22 But instead of duplicating this we use the information available
23 from the kernel sources. */
24#include <asm/unistd.h>
25
26#ifndef _LIBC
27/* The Linux kernel header file defines macros `__NR_<name>', but some
28 programs expect the traditional form `SYS_<name>'. So in building libc
29 we scan the kernel's list and produce <bits/syscall.h> with macros for
30 all the `SYS_' names. */
31# include <bits/syscall.h>
32#endif
33
34#endif
libc/glibc-include/sys/sysctl.h created+73
...@@ -0,0 +1,73 @@
1/* Copyright (C) 1996-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_SYSCTL_H
19#define _SYS_SYSCTL_H 1
20
21#include <features.h>
22#define __need_size_t
23#include <stddef.h>
24/* Prevent more kernel headers than necessary to be included. */
25#ifndef _LINUX_KERNEL_H
26# define _LINUX_KERNEL_H 1
27# define __undef_LINUX_KERNEL_H
28#endif
29#ifndef _LINUX_TYPES_H
30# define _LINUX_TYPES_H 1
31# define __undef_LINUX_TYPES_H
32#endif
33#ifndef _LINUX_LIST_H
34# define _LINUX_LIST_H 1
35# define __undef_LINUX_LIST_H
36#endif
37#ifndef __LINUX_COMPILER_H
38# define __LINUX_COMPILER_H 1
39# define __user
40# define __undef__LINUX_COMPILER_H
41#endif
42
43#include <linux/sysctl.h>
44
45#ifdef __undef_LINUX_KERNEL_H
46# undef _LINUX_KERNEL_H
47# undef __undef_LINUX_KERNEL_H
48#endif
49#ifdef __undef_LINUX_TYPES_H
50# undef _LINUX_TYPES_H
51# undef __undef_LINUX_TYPES_H
52#endif
53#ifdef __undef_LINUX_LIST_H
54# undef _LINUX_LIST_H
55# undef __undef_LINUX_LIST_H
56#endif
57#ifdef __undef__LINUX_COMPILER_H
58# undef __LINUX_COMPILER_H
59# undef __user
60# undef __undef__LINUX_COMPILER_H
61#endif
62
63#include <bits/sysctl.h>
64
65__BEGIN_DECLS
66
67/* Read or write system parameters. */
68extern int sysctl (int *__name, int __nlen, void *__oldval,
69 size_t *__oldlenp, void *__newval, size_t __newlen) __THROW;
70
71__END_DECLS
72
73#endif /* _SYS_SYSCTL_H */
libc/glibc-include/sys/sysinfo.h created+47
...@@ -0,0 +1,47 @@
1/* Copyright (C) 1996-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_SYSINFO_H
19#define _SYS_SYSINFO_H 1
20
21#include <features.h>
22
23/* Get sysinfo structure from kernel header. */
24#include <linux/kernel.h>
25
26__BEGIN_DECLS
27
28/* Returns information on overall system statistics. */
29extern int sysinfo (struct sysinfo *__info) __THROW;
30
31
32/* Return number of configured processors. */
33extern int get_nprocs_conf (void) __THROW;
34
35/* Return number of available processors. */
36extern int get_nprocs (void) __THROW;
37
38
39/* Return number of physical pages of memory in the system. */
40extern long int get_phys_pages (void) __THROW;
41
42/* Return number of available physical pages of memory in the system. */
43extern long int get_avphys_pages (void) __THROW;
44
45__END_DECLS
46
47#endif /* sys/sysinfo.h */
libc/glibc-include/sys/syslog.h created+215
...@@ -0,0 +1,215 @@
1/*
2 * Copyright (c) 1982, 1986, 1988, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 4. Neither the name of the University nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * @(#)syslog.h 8.1 (Berkeley) 6/2/93
30 */
31
32#ifndef _SYS_SYSLOG_H
33#define _SYS_SYSLOG_H 1
34
35#include <features.h>
36#define __need___va_list
37#include <stdarg.h>
38
39/* This file defines _PATH_LOG. */
40#include <bits/syslog-path.h>
41
42/*
43 * priorities/facilities are encoded into a single 32-bit quantity, where the
44 * bottom 3 bits are the priority (0-7) and the top 28 bits are the facility
45 * (0-big number). Both the priorities and the facilities map roughly
46 * one-to-one to strings in the syslogd(8) source code. This mapping is
47 * included in this file.
48 *
49 * priorities (these are ordered)
50 */
51#define LOG_EMERG 0 /* system is unusable */
52#define LOG_ALERT 1 /* action must be taken immediately */
53#define LOG_CRIT 2 /* critical conditions */
54#define LOG_ERR 3 /* error conditions */
55#define LOG_WARNING 4 /* warning conditions */
56#define LOG_NOTICE 5 /* normal but significant condition */
57#define LOG_INFO 6 /* informational */
58#define LOG_DEBUG 7 /* debug-level messages */
59
60#define LOG_PRIMASK 0x07 /* mask to extract priority part (internal) */
61 /* extract priority */
62#define LOG_PRI(p) ((p) & LOG_PRIMASK)
63#define LOG_MAKEPRI(fac, pri) ((fac) | (pri))
64
65#ifdef SYSLOG_NAMES
66#define INTERNAL_NOPRI 0x10 /* the "no priority" priority */
67 /* mark "facility" */
68#define INTERNAL_MARK LOG_MAKEPRI(LOG_NFACILITIES << 3, 0)
69typedef struct _code {
70 char *c_name;
71 int c_val;
72} CODE;
73
74CODE prioritynames[] =
75 {
76 { "alert", LOG_ALERT },
77 { "crit", LOG_CRIT },
78 { "debug", LOG_DEBUG },
79 { "emerg", LOG_EMERG },
80 { "err", LOG_ERR },
81 { "error", LOG_ERR }, /* DEPRECATED */
82 { "info", LOG_INFO },
83 { "none", INTERNAL_NOPRI }, /* INTERNAL */
84 { "notice", LOG_NOTICE },
85 { "panic", LOG_EMERG }, /* DEPRECATED */
86 { "warn", LOG_WARNING }, /* DEPRECATED */
87 { "warning", LOG_WARNING },
88 { NULL, -1 }
89 };
90#endif
91
92/* facility codes */
93#define LOG_KERN (0<<3) /* kernel messages */
94#define LOG_USER (1<<3) /* random user-level messages */
95#define LOG_MAIL (2<<3) /* mail system */
96#define LOG_DAEMON (3<<3) /* system daemons */
97#define LOG_AUTH (4<<3) /* security/authorization messages */
98#define LOG_SYSLOG (5<<3) /* messages generated internally by syslogd */
99#define LOG_LPR (6<<3) /* line printer subsystem */
100#define LOG_NEWS (7<<3) /* network news subsystem */
101#define LOG_UUCP (8<<3) /* UUCP subsystem */
102#define LOG_CRON (9<<3) /* clock daemon */
103#define LOG_AUTHPRIV (10<<3) /* security/authorization messages (private) */
104#define LOG_FTP (11<<3) /* ftp daemon */
105
106 /* other codes through 15 reserved for system use */
107#define LOG_LOCAL0 (16<<3) /* reserved for local use */
108#define LOG_LOCAL1 (17<<3) /* reserved for local use */
109#define LOG_LOCAL2 (18<<3) /* reserved for local use */
110#define LOG_LOCAL3 (19<<3) /* reserved for local use */
111#define LOG_LOCAL4 (20<<3) /* reserved for local use */
112#define LOG_LOCAL5 (21<<3) /* reserved for local use */
113#define LOG_LOCAL6 (22<<3) /* reserved for local use */
114#define LOG_LOCAL7 (23<<3) /* reserved for local use */
115
116#define LOG_NFACILITIES 24 /* current number of facilities */
117#define LOG_FACMASK 0x03f8 /* mask to extract facility part */
118 /* facility of pri */
119#define LOG_FAC(p) (((p) & LOG_FACMASK) >> 3)
120
121#ifdef SYSLOG_NAMES
122CODE facilitynames[] =
123 {
124 { "auth", LOG_AUTH },
125 { "authpriv", LOG_AUTHPRIV },
126 { "cron", LOG_CRON },
127 { "daemon", LOG_DAEMON },
128 { "ftp", LOG_FTP },
129 { "kern", LOG_KERN },
130 { "lpr", LOG_LPR },
131 { "mail", LOG_MAIL },
132 { "mark", INTERNAL_MARK }, /* INTERNAL */
133 { "news", LOG_NEWS },
134 { "security", LOG_AUTH }, /* DEPRECATED */
135 { "syslog", LOG_SYSLOG },
136 { "user", LOG_USER },
137 { "uucp", LOG_UUCP },
138 { "local0", LOG_LOCAL0 },
139 { "local1", LOG_LOCAL1 },
140 { "local2", LOG_LOCAL2 },
141 { "local3", LOG_LOCAL3 },
142 { "local4", LOG_LOCAL4 },
143 { "local5", LOG_LOCAL5 },
144 { "local6", LOG_LOCAL6 },
145 { "local7", LOG_LOCAL7 },
146 { NULL, -1 }
147 };
148#endif
149
150/*
151 * arguments to setlogmask.
152 */
153#define LOG_MASK(pri) (1 << (pri)) /* mask for one priority */
154#define LOG_UPTO(pri) ((1 << ((pri)+1)) - 1) /* all priorities through pri */
155
156/*
157 * Option flags for openlog.
158 *
159 * LOG_ODELAY no longer does anything.
160 * LOG_NDELAY is the inverse of what it used to be.
161 */
162#define LOG_PID 0x01 /* log the pid with each message */
163#define LOG_CONS 0x02 /* log on the console if errors in sending */
164#define LOG_ODELAY 0x04 /* delay open until first syslog() (default) */
165#define LOG_NDELAY 0x08 /* don't delay open */
166#define LOG_NOWAIT 0x10 /* don't wait for console forks: DEPRECATED */
167#define LOG_PERROR 0x20 /* log to stderr as well */
168
169__BEGIN_DECLS
170
171/* Close descriptor used to write to system logger.
172
173 This function is a possible cancellation point and therefore not
174 marked with __THROW. */
175extern void closelog (void);
176
177/* Open connection to system logger.
178
179 This function is a possible cancellation point and therefore not
180 marked with __THROW. */
181extern void openlog (const char *__ident, int __option, int __facility);
182
183/* Set the log mask level. */
184extern int setlogmask (int __mask) __THROW;
185
186/* Generate a log message using FMT string and option arguments.
187
188 This function is a possible cancellation point and therefore not
189 marked with __THROW. */
190extern void syslog (int __pri, const char *__fmt, ...)
191 __attribute__ ((__format__ (__printf__, 2, 3)));
192
193#ifdef __USE_MISC
194/* Generate a log message using FMT and using arguments pointed to by AP.
195
196 This function is not part of POSIX and therefore no official
197 cancellation point. But due to similarity with an POSIX interface
198 or due to the implementation it is a cancellation point and
199 therefore not marked with __THROW. */
200extern void vsyslog (int __pri, const char *__fmt, __gnuc_va_list __ap)
201 __attribute__ ((__format__ (__printf__, 2, 0)));
202#endif
203
204
205/* Define some macros helping to catch buffer overflows. */
206#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
207# include <bits/syslog.h>
208#endif
209#ifdef __LDBL_COMPAT
210# include <bits/syslog-ldbl.h>
211#endif
212
213__END_DECLS
214
215#endif /* sys/syslog.h */
libc/glibc-include/sys/sysmacros.h created+64
...@@ -0,0 +1,64 @@
1/* Definitions of macros to access `dev_t' values.
2 Copyright (C) 1996-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SYS_SYSMACROS_H
20#define _SYS_SYSMACROS_H 1
21
22#include <features.h>
23#include <bits/types.h>
24#include <bits/sysmacros.h>
25
26#define __SYSMACROS_DECL_TEMPL(rtype, name, proto) \
27 extern rtype gnu_dev_##name proto __THROW __attribute_const__;
28
29#define __SYSMACROS_IMPL_TEMPL(rtype, name, proto) \
30 __extension__ __extern_inline __attribute_const__ rtype \
31 __NTH (gnu_dev_##name proto)
32
33__BEGIN_DECLS
34
35__SYSMACROS_DECLARE_MAJOR (__SYSMACROS_DECL_TEMPL)
36__SYSMACROS_DECLARE_MINOR (__SYSMACROS_DECL_TEMPL)
37__SYSMACROS_DECLARE_MAKEDEV (__SYSMACROS_DECL_TEMPL)
38
39#ifdef __USE_EXTERN_INLINES
40
41__SYSMACROS_DEFINE_MAJOR (__SYSMACROS_IMPL_TEMPL)
42__SYSMACROS_DEFINE_MINOR (__SYSMACROS_IMPL_TEMPL)
43__SYSMACROS_DEFINE_MAKEDEV (__SYSMACROS_IMPL_TEMPL)
44
45#endif
46
47__END_DECLS
48
49#ifndef __SYSMACROS_NEED_IMPLEMENTATION
50# undef __SYSMACROS_DECL_TEMPL
51# undef __SYSMACROS_IMPL_TEMPL
52# undef __SYSMACROS_DECLARE_MAJOR
53# undef __SYSMACROS_DECLARE_MINOR
54# undef __SYSMACROS_DECLARE_MAKEDEV
55# undef __SYSMACROS_DEFINE_MAJOR
56# undef __SYSMACROS_DEFINE_MINOR
57# undef __SYSMACROS_DEFINE_MAKEDEV
58#endif
59
60#define major(dev) gnu_dev_major (dev)
61#define minor(dev) gnu_dev_minor (dev)
62#define makedev(maj, min) gnu_dev_makedev (maj, min)
63
64#endif /* sys/sysmacros.h */
libc/glibc-include/sys/termios.h created+4
...@@ -0,0 +1,4 @@
1#ifndef _SYS_TERMIOS_H
2#define _SYS_TERMIOS_H
3#include <termios.h>
4#endif
libc/glibc-include/sys/time.h created+188
...@@ -0,0 +1,188 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_TIME_H
19#define _SYS_TIME_H 1
20
21#include <features.h>
22
23#include <bits/types.h>
24#include <bits/types/time_t.h>
25#include <bits/types/struct_timeval.h>
26
27#ifndef __suseconds_t_defined
28typedef __suseconds_t suseconds_t;
29# define __suseconds_t_defined
30#endif
31
32#include <sys/select.h>
33
34__BEGIN_DECLS
35
36#ifdef __USE_GNU
37/* Macros for converting between `struct timeval' and `struct timespec'. */
38# define TIMEVAL_TO_TIMESPEC(tv, ts) { \
39 (ts)->tv_sec = (tv)->tv_sec; \
40 (ts)->tv_nsec = (tv)->tv_usec * 1000; \
41}
42# define TIMESPEC_TO_TIMEVAL(tv, ts) { \
43 (tv)->tv_sec = (ts)->tv_sec; \
44 (tv)->tv_usec = (ts)->tv_nsec / 1000; \
45}
46#endif
47
48
49#ifdef __USE_MISC
50/* Structure crudely representing a timezone.
51 This is obsolete and should never be used. */
52struct timezone
53 {
54 int tz_minuteswest; /* Minutes west of GMT. */
55 int tz_dsttime; /* Nonzero if DST is ever in effect. */
56 };
57
58typedef struct timezone *__restrict __timezone_ptr_t;
59#else
60typedef void *__restrict __timezone_ptr_t;
61#endif
62
63/* Get the current time of day and timezone information,
64 putting it into *TV and *TZ. If TZ is NULL, *TZ is not filled.
65 Returns 0 on success, -1 on errors.
66 NOTE: This form of timezone information is obsolete.
67 Use the functions and variables declared in <time.h> instead. */
68extern int gettimeofday (struct timeval *__restrict __tv,
69 __timezone_ptr_t __tz) __THROW __nonnull ((1));
70
71#ifdef __USE_MISC
72/* Set the current time of day and timezone information.
73 This call is restricted to the super-user. */
74extern int settimeofday (const struct timeval *__tv,
75 const struct timezone *__tz)
76 __THROW;
77
78/* Adjust the current time of day by the amount in DELTA.
79 If OLDDELTA is not NULL, it is filled in with the amount
80 of time adjustment remaining to be done from the last `adjtime' call.
81 This call is restricted to the super-user. */
82extern int adjtime (const struct timeval *__delta,
83 struct timeval *__olddelta) __THROW;
84#endif
85
86
87/* Values for the first argument to `getitimer' and `setitimer'. */
88enum __itimer_which
89 {
90 /* Timers run in real time. */
91 ITIMER_REAL = 0,
92#define ITIMER_REAL ITIMER_REAL
93 /* Timers run only when the process is executing. */
94 ITIMER_VIRTUAL = 1,
95#define ITIMER_VIRTUAL ITIMER_VIRTUAL
96 /* Timers run when the process is executing and when
97 the system is executing on behalf of the process. */
98 ITIMER_PROF = 2
99#define ITIMER_PROF ITIMER_PROF
100 };
101
102/* Type of the second argument to `getitimer' and
103 the second and third arguments `setitimer'. */
104struct itimerval
105 {
106 /* Value to put into `it_value' when the timer expires. */
107 struct timeval it_interval;
108 /* Time to the next timer expiration. */
109 struct timeval it_value;
110 };
111
112#if defined __USE_GNU && !defined __cplusplus
113/* Use the nicer parameter type only in GNU mode and not for C++ since the
114 strict C++ rules prevent the automatic promotion. */
115typedef enum __itimer_which __itimer_which_t;
116#else
117typedef int __itimer_which_t;
118#endif
119
120/* Set *VALUE to the current setting of timer WHICH.
121 Return 0 on success, -1 on errors. */
122extern int getitimer (__itimer_which_t __which,
123 struct itimerval *__value) __THROW;
124
125/* Set the timer WHICH to *NEW. If OLD is not NULL,
126 set *OLD to the old value of timer WHICH.
127 Returns 0 on success, -1 on errors. */
128extern int setitimer (__itimer_which_t __which,
129 const struct itimerval *__restrict __new,
130 struct itimerval *__restrict __old) __THROW;
131
132/* Change the access time of FILE to TVP[0] and the modification time of
133 FILE to TVP[1]. If TVP is a null pointer, use the current time instead.
134 Returns 0 on success, -1 on errors. */
135extern int utimes (const char *__file, const struct timeval __tvp[2])
136 __THROW __nonnull ((1));
137
138#ifdef __USE_MISC
139/* Same as `utimes', but does not follow symbolic links. */
140extern int lutimes (const char *__file, const struct timeval __tvp[2])
141 __THROW __nonnull ((1));
142
143/* Same as `utimes', but takes an open file descriptor instead of a name. */
144extern int futimes (int __fd, const struct timeval __tvp[2]) __THROW;
145#endif
146
147#ifdef __USE_GNU
148/* Change the access time of FILE relative to FD to TVP[0] and the
149 modification time of FILE to TVP[1]. If TVP is a null pointer, use
150 the current time instead. Returns 0 on success, -1 on errors. */
151extern int futimesat (int __fd, const char *__file,
152 const struct timeval __tvp[2]) __THROW;
153#endif
154
155
156#ifdef __USE_MISC
157/* Convenience macros for operations on timevals.
158 NOTE: `timercmp' does not work for >= or <=. */
159# define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
160# define timerclear(tvp) ((tvp)->tv_sec = (tvp)->tv_usec = 0)
161# define timercmp(a, b, CMP) \
162 (((a)->tv_sec == (b)->tv_sec) ? \
163 ((a)->tv_usec CMP (b)->tv_usec) : \
164 ((a)->tv_sec CMP (b)->tv_sec))
165# define timeradd(a, b, result) \
166 do { \
167 (result)->tv_sec = (a)->tv_sec + (b)->tv_sec; \
168 (result)->tv_usec = (a)->tv_usec + (b)->tv_usec; \
169 if ((result)->tv_usec >= 1000000) \
170 { \
171 ++(result)->tv_sec; \
172 (result)->tv_usec -= 1000000; \
173 } \
174 } while (0)
175# define timersub(a, b, result) \
176 do { \
177 (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
178 (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
179 if ((result)->tv_usec < 0) { \
180 --(result)->tv_sec; \
181 (result)->tv_usec += 1000000; \
182 } \
183 } while (0)
184#endif /* Misc. */
185
186__END_DECLS
187
188#endif /* sys/time.h */
libc/glibc-include/sys/timeb.h created+43
...@@ -0,0 +1,43 @@
1/* Copyright (C) 1994-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_TIMEB_H
19#define _SYS_TIMEB_H 1
20
21#include <features.h>
22
23#include <bits/types/time_t.h>
24
25__BEGIN_DECLS
26
27/* Structure returned by the `ftime' function. */
28
29struct timeb
30 {
31 time_t time; /* Seconds since epoch, as from `time'. */
32 unsigned short int millitm; /* Additional milliseconds. */
33 short int timezone; /* Minutes west of GMT. */
34 short int dstflag; /* Nonzero if Daylight Savings Time used. */
35 };
36
37/* Fill in TIMEBUF with information about the current time. */
38
39extern int ftime (struct timeb *__timebuf);
40
41__END_DECLS
42
43#endif /* sys/timeb.h */
libc/glibc-include/sys/timerfd.h created+55
...@@ -0,0 +1,55 @@
1/* Copyright (C) 2008-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_TIMERFD_H
19#define _SYS_TIMERFD_H 1
20
21#include <time.h>
22#include <bits/types/struct_itimerspec.h>
23
24/* Get the platform-dependent flags. */
25#include <bits/timerfd.h>
26
27
28/* Bits to be set in the FLAGS parameter of `timerfd_settime'. */
29enum
30 {
31 TFD_TIMER_ABSTIME = 1 << 0,
32#define TFD_TIMER_ABSTIME TFD_TIMER_ABSTIME
33 TFD_TIMER_CANCEL_ON_SET = 1 << 1
34#define TFD_TIMER_CANCEL_ON_SET TFD_TIMER_CANCEL_ON_SET
35 };
36
37
38__BEGIN_DECLS
39
40/* Return file descriptor for new interval timer source. */
41extern int timerfd_create (__clockid_t __clock_id, int __flags) __THROW;
42
43/* Set next expiration time of interval timer source UFD to UTMR. If
44 FLAGS has the TFD_TIMER_ABSTIME flag set the timeout value is
45 absolute. Optionally return the old expiration time in OTMR. */
46extern int timerfd_settime (int __ufd, int __flags,
47 const struct itimerspec *__utmr,
48 struct itimerspec *__otmr) __THROW;
49
50/* Return the next expiration time of UFD. */
51extern int timerfd_gettime (int __ufd, struct itimerspec *__otmr) __THROW;
52
53__END_DECLS
54
55#endif /* sys/timerfd.h */
libc/glibc-include/sys/times.h created+50
...@@ -0,0 +1,50 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/*
19 * POSIX Standard: 4.5.2 Process Times <sys/times.h>
20 */
21
22#ifndef _SYS_TIMES_H
23#define _SYS_TIMES_H 1
24
25#include <features.h>
26
27#include <bits/types/clock_t.h>
28
29__BEGIN_DECLS
30
31/* Structure describing CPU time used by a process and its children. */
32struct tms
33 {
34 clock_t tms_utime; /* User CPU time. */
35 clock_t tms_stime; /* System CPU time. */
36
37 clock_t tms_cutime; /* User CPU time of dead children. */
38 clock_t tms_cstime; /* System CPU time of dead children. */
39 };
40
41
42/* Store the CPU time used by this process and all its
43 dead children (and their dead children) in BUFFER.
44 Return the elapsed real time, or (clock_t) -1 for errors.
45 All times are in CLK_TCKths of a second. */
46extern clock_t times (struct tms *__buffer) __THROW;
47
48__END_DECLS
49
50#endif /* sys/times.h */
libc/glibc-include/sys/timex.h created+71
...@@ -0,0 +1,71 @@
1/* Copyright (C) 1995-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_TIMEX_H
19#define _SYS_TIMEX_H 1
20
21#include <features.h>
22#include <sys/time.h>
23
24/* These definitions from linux/timex.h as of 2.6.30. */
25
26#include <bits/timex.h>
27
28#define NTP_API 4 /* NTP API version */
29
30struct ntptimeval
31{
32 struct timeval time; /* current time (ro) */
33 long int maxerror; /* maximum error (us) (ro) */
34 long int esterror; /* estimated error (us) (ro) */
35 long int tai; /* TAI offset (ro) */
36
37 long int __glibc_reserved1;
38 long int __glibc_reserved2;
39 long int __glibc_reserved3;
40 long int __glibc_reserved4;
41};
42
43/* Clock states (time_state) */
44#define TIME_OK 0 /* clock synchronized, no leap second */
45#define TIME_INS 1 /* insert leap second */
46#define TIME_DEL 2 /* delete leap second */
47#define TIME_OOP 3 /* leap second in progress */
48#define TIME_WAIT 4 /* leap second has occurred */
49#define TIME_ERROR 5 /* clock not synchronized */
50#define TIME_BAD TIME_ERROR /* bw compat */
51
52/* Maximum time constant of the PLL. */
53#define MAXTC 6
54
55__BEGIN_DECLS
56
57extern int __adjtimex (struct timex *__ntx) __THROW;
58extern int adjtimex (struct timex *__ntx) __THROW;
59
60#ifdef __REDIRECT_NTH
61extern int __REDIRECT_NTH (ntp_gettime, (struct ntptimeval *__ntv),
62 ntp_gettimex);
63#else
64extern int ntp_gettimex (struct ntptimeval *__ntv) __THROW;
65# define ntp_gettime ntp_gettimex
66#endif
67extern int ntp_adjtime (struct timex *__tntx) __THROW;
68
69__END_DECLS
70
71#endif /* sys/timex.h */
libc/glibc-include/sys/ttychars.h created+61
...@@ -0,0 +1,61 @@
1/*-
2 * Copyright (c) 1982, 1986, 1990, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 4. Neither the name of the University nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * @(#)ttychars.h 8.2 (Berkeley) 1/4/94
30 */
31
32/*
33 * 4.3 COMPATIBILITY FILE
34 *
35 * User visible structures and constants related to terminal handling.
36 */
37#ifndef _SYS_TTYCHARS_H
38#define _SYS_TTYCHARS_H 1
39
40struct ttychars {
41 char tc_erase; /* erase last character */
42 char tc_kill; /* erase entire line */
43 char tc_intrc; /* interrupt */
44 char tc_quitc; /* quit */
45 char tc_startc; /* start output */
46 char tc_stopc; /* stop output */
47 char tc_eofc; /* end-of-file */
48 char tc_brkc; /* input delimiter (like nl) */
49 char tc_suspc; /* stop process signal */
50 char tc_dsuspc; /* delayed stop process signal */
51 char tc_rprntc; /* reprint line */
52 char tc_flushc; /* flush output (toggles) */
53 char tc_werasc; /* word erase */
54 char tc_lnextc; /* literal next character */
55};
56
57#ifdef __USE_OLD_TTY
58#include <sys/ttydefaults.h> /* to pick up character defaults */
59#endif
60
61#endif /* sys/ttychars.h */
libc/glibc-include/sys/ttydefaults.h created+100
...@@ -0,0 +1,100 @@
1/*-
2 * Copyright (c) 1982, 1986, 1993
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 4. Neither the name of the University nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 *
34 * @(#)ttydefaults.h 8.4 (Berkeley) 1/21/94
35 */
36
37/*
38 * System wide defaults for terminal state. Linux version.
39 */
40#ifndef _SYS_TTYDEFAULTS_H_
41#define _SYS_TTYDEFAULTS_H_
42
43/*
44 * Defaults on "first" open.
45 */
46#define TTYDEF_IFLAG (BRKINT | ISTRIP | ICRNL | IMAXBEL | IXON | IXANY)
47#define TTYDEF_OFLAG (OPOST | ONLCR | XTABS)
48#define TTYDEF_LFLAG (ECHO | ICANON | ISIG | IEXTEN | ECHOE|ECHOKE|ECHOCTL)
49#define TTYDEF_CFLAG (CREAD | CS7 | PARENB | HUPCL)
50#define TTYDEF_SPEED (B9600)
51
52/*
53 * Control Character Defaults
54 */
55#define CTRL(x) (x&037)
56#define CEOF CTRL('d')
57#ifdef _POSIX_VDISABLE
58# define CEOL _POSIX_VDISABLE
59#else
60# define CEOL '\0' /* XXX avoid _POSIX_VDISABLE */
61#endif
62#define CERASE 0177
63#define CINTR CTRL('c')
64#ifdef _POSIX_VDISABLE
65# define CSTATUS _POSIX_VDISABLE
66#else
67# define CSTATUS '\0' /* XXX avoid _POSIX_VDISABLE */
68#endif
69#define CKILL CTRL('u')
70#define CMIN 1
71#define CQUIT 034 /* FS, ^\ */
72#define CSUSP CTRL('z')
73#define CTIME 0
74#define CDSUSP CTRL('y')
75#define CSTART CTRL('q')
76#define CSTOP CTRL('s')
77#define CLNEXT CTRL('v')
78#define CDISCARD CTRL('o')
79#define CWERASE CTRL('w')
80#define CREPRINT CTRL('r')
81#define CEOT CEOF
82/* compat */
83#define CBRK CEOL
84#define CRPRNT CREPRINT
85#define CFLUSH CDISCARD
86
87/* PROTECTED INCLUSION ENDS HERE */
88#endif /* !_SYS_TTYDEFAULTS_H_ */
89
90/*
91 * #define TTYDEFCHARS to include an array of default control characters.
92 */
93#ifdef TTYDEFCHARS
94cc_t ttydefchars[NCCS] = {
95 CEOF, CEOL, CEOL, CERASE, CWERASE, CKILL, CREPRINT,
96 _POSIX_VDISABLE, CINTR, CQUIT, CSUSP, CDSUSP, CSTART, CSTOP, CLNEXT,
97 CDISCARD, CMIN, CTIME, CSTATUS, _POSIX_VDISABLE
98};
99#undef TTYDEFCHARS
100#endif
libc/glibc-include/sys/types.h created+249
...@@ -0,0 +1,249 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/*
19 * POSIX Standard: 2.6 Primitive System Data Types <sys/types.h>
20 */
21
22#ifndef _SYS_TYPES_H
23#define _SYS_TYPES_H 1
24
25#include <features.h>
26
27__BEGIN_DECLS
28
29#include <bits/types.h>
30
31#ifdef __USE_MISC
32# ifndef __u_char_defined
33typedef __u_char u_char;
34typedef __u_short u_short;
35typedef __u_int u_int;
36typedef __u_long u_long;
37typedef __quad_t quad_t;
38typedef __u_quad_t u_quad_t;
39typedef __fsid_t fsid_t;
40# define __u_char_defined
41# endif
42typedef __loff_t loff_t;
43#endif
44
45#ifndef __ino_t_defined
46# ifndef __USE_FILE_OFFSET64
47typedef __ino_t ino_t;
48# else
49typedef __ino64_t ino_t;
50# endif
51# define __ino_t_defined
52#endif
53#if defined __USE_LARGEFILE64 && !defined __ino64_t_defined
54typedef __ino64_t ino64_t;
55# define __ino64_t_defined
56#endif
57
58#ifndef __dev_t_defined
59typedef __dev_t dev_t;
60# define __dev_t_defined
61#endif
62
63#ifndef __gid_t_defined
64typedef __gid_t gid_t;
65# define __gid_t_defined
66#endif
67
68#ifndef __mode_t_defined
69typedef __mode_t mode_t;
70# define __mode_t_defined
71#endif
72
73#ifndef __nlink_t_defined
74typedef __nlink_t nlink_t;
75# define __nlink_t_defined
76#endif
77
78#ifndef __uid_t_defined
79typedef __uid_t uid_t;
80# define __uid_t_defined
81#endif
82
83#ifndef __off_t_defined
84# ifndef __USE_FILE_OFFSET64
85typedef __off_t off_t;
86# else
87typedef __off64_t off_t;
88# endif
89# define __off_t_defined
90#endif
91#if defined __USE_LARGEFILE64 && !defined __off64_t_defined
92typedef __off64_t off64_t;
93# define __off64_t_defined
94#endif
95
96#ifndef __pid_t_defined
97typedef __pid_t pid_t;
98# define __pid_t_defined
99#endif
100
101#if (defined __USE_XOPEN || defined __USE_XOPEN2K8) \
102 && !defined __id_t_defined
103typedef __id_t id_t;
104# define __id_t_defined
105#endif
106
107#ifndef __ssize_t_defined
108typedef __ssize_t ssize_t;
109# define __ssize_t_defined
110#endif
111
112#ifdef __USE_MISC
113# ifndef __daddr_t_defined
114typedef __daddr_t daddr_t;
115typedef __caddr_t caddr_t;
116# define __daddr_t_defined
117# endif
118#endif
119
120#if (defined __USE_MISC || defined __USE_XOPEN) && !defined __key_t_defined
121typedef __key_t key_t;
122# define __key_t_defined
123#endif
124
125#if defined __USE_XOPEN || defined __USE_XOPEN2K8
126# include <bits/types/clock_t.h>
127#endif
128#include <bits/types/clockid_t.h>
129#include <bits/types/time_t.h>
130#include <bits/types/timer_t.h>
131
132#ifdef __USE_XOPEN
133# ifndef __useconds_t_defined
134typedef __useconds_t useconds_t;
135# define __useconds_t_defined
136# endif
137# ifndef __suseconds_t_defined
138typedef __suseconds_t suseconds_t;
139# define __suseconds_t_defined
140# endif
141#endif
142
143#define __need_size_t
144#include <stddef.h>
145
146#ifdef __USE_MISC
147/* Old compatibility names for C types. */
148typedef unsigned long int ulong;
149typedef unsigned short int ushort;
150typedef unsigned int uint;
151#endif
152
153/* These size-specific names are used by some of the inet code. */
154
155#include <bits/stdint-intn.h>
156
157#if !__GNUC_PREREQ (2, 7)
158
159/* These were defined by ISO C without the first `_'. */
160typedef unsigned char u_int8_t;
161typedef unsigned short int u_int16_t;
162typedef unsigned int u_int32_t;
163# if __WORDSIZE == 64
164typedef unsigned long int u_int64_t;
165# else
166__extension__ typedef unsigned long long int u_int64_t;
167# endif
168
169typedef int register_t;
170
171#else
172
173/* For GCC 2.7 and later, we can use specific type-size attributes. */
174# define __u_intN_t(N, MODE) \
175 typedef unsigned int u_int##N##_t __attribute__ ((__mode__ (MODE)))
176
177__u_intN_t (8, __QI__);
178__u_intN_t (16, __HI__);
179__u_intN_t (32, __SI__);
180__u_intN_t (64, __DI__);
181
182typedef int register_t __attribute__ ((__mode__ (__word__)));
183
184
185/* Some code from BIND tests this macro to see if the types above are
186 defined. */
187#endif
188#define __BIT_TYPES_DEFINED__ 1
189
190
191#ifdef __USE_MISC
192/* In BSD <sys/types.h> is expected to define BYTE_ORDER. */
193# include <endian.h>
194
195/* It also defines `fd_set' and the FD_* macros for `select'. */
196# include <sys/select.h>
197#endif /* Use misc. */
198
199
200#if (defined __USE_UNIX98 || defined __USE_XOPEN2K8) \
201 && !defined __blksize_t_defined
202typedef __blksize_t blksize_t;
203# define __blksize_t_defined
204#endif
205
206/* Types from the Large File Support interface. */
207#ifndef __USE_FILE_OFFSET64
208# ifndef __blkcnt_t_defined
209typedef __blkcnt_t blkcnt_t; /* Type to count number of disk blocks. */
210# define __blkcnt_t_defined
211# endif
212# ifndef __fsblkcnt_t_defined
213typedef __fsblkcnt_t fsblkcnt_t; /* Type to count file system blocks. */
214# define __fsblkcnt_t_defined
215# endif
216# ifndef __fsfilcnt_t_defined
217typedef __fsfilcnt_t fsfilcnt_t; /* Type to count file system inodes. */
218# define __fsfilcnt_t_defined
219# endif
220#else
221# ifndef __blkcnt_t_defined
222typedef __blkcnt64_t blkcnt_t; /* Type to count number of disk blocks. */
223# define __blkcnt_t_defined
224# endif
225# ifndef __fsblkcnt_t_defined
226typedef __fsblkcnt64_t fsblkcnt_t; /* Type to count file system blocks. */
227# define __fsblkcnt_t_defined
228# endif
229# ifndef __fsfilcnt_t_defined
230typedef __fsfilcnt64_t fsfilcnt_t; /* Type to count file system inodes. */
231# define __fsfilcnt_t_defined
232# endif
233#endif
234
235#ifdef __USE_LARGEFILE64
236typedef __blkcnt64_t blkcnt64_t; /* Type to count number of disk blocks. */
237typedef __fsblkcnt64_t fsblkcnt64_t; /* Type to count file system blocks. */
238typedef __fsfilcnt64_t fsfilcnt64_t; /* Type to count file system inodes. */
239#endif
240
241
242/* Now add the thread types. */
243#if defined __USE_POSIX199506 || defined __USE_UNIX98
244# include <bits/pthreadtypes.h>
245#endif
246
247__END_DECLS
248
249#endif /* sys/types.h */
libc/glibc-include/sys/ucontext.h created+262
...@@ -0,0 +1,262 @@
1/* Copyright (C) 2001-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_UCONTEXT_H
19#define _SYS_UCONTEXT_H 1
20
21#include <features.h>
22
23#include <bits/types.h>
24#include <bits/types/sigset_t.h>
25#include <bits/types/stack_t.h>
26
27
28#ifdef __USE_MISC
29# define __ctx(fld) fld
30#else
31# define __ctx(fld) __ ## fld
32#endif
33
34#ifdef __x86_64__
35
36/* Type for general register. */
37__extension__ typedef long long int greg_t;
38
39/* Number of general registers. */
40#define __NGREG 23
41#ifdef __USE_MISC
42# define NGREG __NGREG
43#endif
44
45/* Container for all general registers. */
46typedef greg_t gregset_t[__NGREG];
47
48#ifdef __USE_GNU
49/* Number of each register in the `gregset_t' array. */
50enum
51{
52 REG_R8 = 0,
53# define REG_R8 REG_R8
54 REG_R9,
55# define REG_R9 REG_R9
56 REG_R10,
57# define REG_R10 REG_R10
58 REG_R11,
59# define REG_R11 REG_R11
60 REG_R12,
61# define REG_R12 REG_R12
62 REG_R13,
63# define REG_R13 REG_R13
64 REG_R14,
65# define REG_R14 REG_R14
66 REG_R15,
67# define REG_R15 REG_R15
68 REG_RDI,
69# define REG_RDI REG_RDI
70 REG_RSI,
71# define REG_RSI REG_RSI
72 REG_RBP,
73# define REG_RBP REG_RBP
74 REG_RBX,
75# define REG_RBX REG_RBX
76 REG_RDX,
77# define REG_RDX REG_RDX
78 REG_RAX,
79# define REG_RAX REG_RAX
80 REG_RCX,
81# define REG_RCX REG_RCX
82 REG_RSP,
83# define REG_RSP REG_RSP
84 REG_RIP,
85# define REG_RIP REG_RIP
86 REG_EFL,
87# define REG_EFL REG_EFL
88 REG_CSGSFS, /* Actually short cs, gs, fs, __pad0. */
89# define REG_CSGSFS REG_CSGSFS
90 REG_ERR,
91# define REG_ERR REG_ERR
92 REG_TRAPNO,
93# define REG_TRAPNO REG_TRAPNO
94 REG_OLDMASK,
95# define REG_OLDMASK REG_OLDMASK
96 REG_CR2
97# define REG_CR2 REG_CR2
98};
99#endif
100
101struct _libc_fpxreg
102{
103 unsigned short int __ctx(significand)[4];
104 unsigned short int __ctx(exponent);
105 unsigned short int __glibc_reserved1[3];
106};
107
108struct _libc_xmmreg
109{
110 __uint32_t __ctx(element)[4];
111};
112
113struct _libc_fpstate
114{
115 /* 64-bit FXSAVE format. */
116 __uint16_t __ctx(cwd);
117 __uint16_t __ctx(swd);
118 __uint16_t __ctx(ftw);
119 __uint16_t __ctx(fop);
120 __uint64_t __ctx(rip);
121 __uint64_t __ctx(rdp);
122 __uint32_t __ctx(mxcsr);
123 __uint32_t __ctx(mxcr_mask);
124 struct _libc_fpxreg _st[8];
125 struct _libc_xmmreg _xmm[16];
126 __uint32_t __glibc_reserved1[24];
127};
128
129/* Structure to describe FPU registers. */
130typedef struct _libc_fpstate *fpregset_t;
131
132/* Context to describe whole processor state. */
133typedef struct
134 {
135 gregset_t __ctx(gregs);
136 /* Note that fpregs is a pointer. */
137 fpregset_t __ctx(fpregs);
138 __extension__ unsigned long long __reserved1 [8];
139} mcontext_t;
140
141/* Userlevel context. */
142typedef struct ucontext_t
143 {
144 unsigned long int __ctx(uc_flags);
145 struct ucontext_t *uc_link;
146 stack_t uc_stack;
147 mcontext_t uc_mcontext;
148 sigset_t uc_sigmask;
149 struct _libc_fpstate __fpregs_mem;
150 __extension__ unsigned long long int __ssp[4];
151 } ucontext_t;
152
153#else /* !__x86_64__ */
154
155/* Type for general register. */
156typedef int greg_t;
157
158/* Number of general registers. */
159#define __NGREG 19
160#ifdef __USE_MISC
161# define NGREG __NGREG
162#endif
163
164/* Container for all general registers. */
165typedef greg_t gregset_t[__NGREG];
166
167#ifdef __USE_GNU
168/* Number of each register is the `gregset_t' array. */
169enum
170{
171 REG_GS = 0,
172# define REG_GS REG_GS
173 REG_FS,
174# define REG_FS REG_FS
175 REG_ES,
176# define REG_ES REG_ES
177 REG_DS,
178# define REG_DS REG_DS
179 REG_EDI,
180# define REG_EDI REG_EDI
181 REG_ESI,
182# define REG_ESI REG_ESI
183 REG_EBP,
184# define REG_EBP REG_EBP
185 REG_ESP,
186# define REG_ESP REG_ESP
187 REG_EBX,
188# define REG_EBX REG_EBX
189 REG_EDX,
190# define REG_EDX REG_EDX
191 REG_ECX,
192# define REG_ECX REG_ECX
193 REG_EAX,
194# define REG_EAX REG_EAX
195 REG_TRAPNO,
196# define REG_TRAPNO REG_TRAPNO
197 REG_ERR,
198# define REG_ERR REG_ERR
199 REG_EIP,
200# define REG_EIP REG_EIP
201 REG_CS,
202# define REG_CS REG_CS
203 REG_EFL,
204# define REG_EFL REG_EFL
205 REG_UESP,
206# define REG_UESP REG_UESP
207 REG_SS
208# define REG_SS REG_SS
209};
210#endif
211
212/* Definitions taken from the kernel headers. */
213struct _libc_fpreg
214{
215 unsigned short int __ctx(significand)[4];
216 unsigned short int __ctx(exponent);
217};
218
219struct _libc_fpstate
220{
221 unsigned long int __ctx(cw);
222 unsigned long int __ctx(sw);
223 unsigned long int __ctx(tag);
224 unsigned long int __ctx(ipoff);
225 unsigned long int __ctx(cssel);
226 unsigned long int __ctx(dataoff);
227 unsigned long int __ctx(datasel);
228 struct _libc_fpreg _st[8];
229 unsigned long int __ctx(status);
230};
231
232/* Structure to describe FPU registers. */
233typedef struct _libc_fpstate *fpregset_t;
234
235/* Context to describe whole processor state. */
236typedef struct
237 {
238 gregset_t __ctx(gregs);
239 /* Due to Linux's history we have to use a pointer here. The SysV/i386
240 ABI requires a struct with the values. */
241 fpregset_t __ctx(fpregs);
242 unsigned long int __ctx(oldmask);
243 unsigned long int __ctx(cr2);
244 } mcontext_t;
245
246/* Userlevel context. */
247typedef struct ucontext_t
248 {
249 unsigned long int __ctx(uc_flags);
250 struct ucontext_t *uc_link;
251 stack_t uc_stack;
252 mcontext_t uc_mcontext;
253 sigset_t uc_sigmask;
254 struct _libc_fpstate __fpregs_mem;
255 unsigned long int __ssp[4];
256 } ucontext_t;
257
258#endif /* !__x86_64__ */
259
260#undef __ctx
261
262#endif /* sys/ucontext.h */
libc/glibc-include/sys/uio.h created+171
...@@ -0,0 +1,171 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_UIO_H
19#define _SYS_UIO_H 1
20
21#include <features.h>
22#include <sys/types.h>
23#include <bits/types/struct_iovec.h>
24#include <bits/uio_lim.h>
25#ifdef __IOV_MAX
26# define UIO_MAXIOV __IOV_MAX
27#else
28# undef UIO_MAXIOV
29#endif
30
31__BEGIN_DECLS
32
33/* Read data from file descriptor FD, and put the result in the
34 buffers described by IOVEC, which is a vector of COUNT 'struct iovec's.
35 The buffers are filled in the order specified.
36 Operates just like 'read' (see <unistd.h>) except that data are
37 put in IOVEC instead of a contiguous buffer.
38
39 This function is a cancellation point and therefore not marked with
40 __THROW. */
41extern ssize_t readv (int __fd, const struct iovec *__iovec, int __count)
42 __wur;
43
44/* Write data pointed by the buffers described by IOVEC, which
45 is a vector of COUNT 'struct iovec's, to file descriptor FD.
46 The data is written in the order specified.
47 Operates just like 'write' (see <unistd.h>) except that the data
48 are taken from IOVEC instead of a contiguous buffer.
49
50 This function is a cancellation point and therefore not marked with
51 __THROW. */
52extern ssize_t writev (int __fd, const struct iovec *__iovec, int __count)
53 __wur;
54
55
56#ifdef __USE_MISC
57# ifndef __USE_FILE_OFFSET64
58/* Read data from file descriptor FD at the given position OFFSET
59 without change the file pointer, and put the result in the buffers
60 described by IOVEC, which is a vector of COUNT 'struct iovec's.
61 The buffers are filled in the order specified. Operates just like
62 'pread' (see <unistd.h>) except that data are put in IOVEC instead
63 of a contiguous buffer.
64
65 This function is a cancellation point and therefore not marked with
66 __THROW. */
67extern ssize_t preadv (int __fd, const struct iovec *__iovec, int __count,
68 __off_t __offset) __wur;
69
70/* Write data pointed by the buffers described by IOVEC, which is a
71 vector of COUNT 'struct iovec's, to file descriptor FD at the given
72 position OFFSET without change the file pointer. The data is
73 written in the order specified. Operates just like 'pwrite' (see
74 <unistd.h>) except that the data are taken from IOVEC instead of a
75 contiguous buffer.
76
77 This function is a cancellation point and therefore not marked with
78 __THROW. */
79extern ssize_t pwritev (int __fd, const struct iovec *__iovec, int __count,
80 __off_t __offset) __wur;
81
82# else
83# ifdef __REDIRECT
84extern ssize_t __REDIRECT (preadv, (int __fd, const struct iovec *__iovec,
85 int __count, __off64_t __offset),
86 preadv64) __wur;
87extern ssize_t __REDIRECT (pwritev, (int __fd, const struct iovec *__iovec,
88 int __count, __off64_t __offset),
89 pwritev64) __wur;
90# else
91# define preadv preadv64
92# define pwritev pwritev64
93# endif
94# endif
95
96# ifdef __USE_LARGEFILE64
97/* Read data from file descriptor FD at the given position OFFSET
98 without change the file pointer, and put the result in the buffers
99 described by IOVEC, which is a vector of COUNT 'struct iovec's.
100 The buffers are filled in the order specified. Operates just like
101 'pread' (see <unistd.h>) except that data are put in IOVEC instead
102 of a contiguous buffer.
103
104 This function is a cancellation point and therefore not marked with
105 __THROW. */
106extern ssize_t preadv64 (int __fd, const struct iovec *__iovec, int __count,
107 __off64_t __offset) __wur;
108
109/* Write data pointed by the buffers described by IOVEC, which is a
110 vector of COUNT 'struct iovec's, to file descriptor FD at the given
111 position OFFSET without change the file pointer. The data is
112 written in the order specified. Operates just like 'pwrite' (see
113 <unistd.h>) except that the data are taken from IOVEC instead of a
114 contiguous buffer.
115
116 This function is a cancellation point and therefore not marked with
117 __THROW. */
118extern ssize_t pwritev64 (int __fd, const struct iovec *__iovec, int __count,
119 __off64_t __offset) __wur;
120# endif
121#endif /* Use misc. */
122
123
124#ifdef __USE_GNU
125# ifndef __USE_FILE_OFFSET64
126/* Same as preadv but with an additional flag argumenti defined at uio.h. */
127extern ssize_t preadv2 (int __fp, const struct iovec *__iovec, int __count,
128 __off_t __offset, int ___flags) __wur;
129
130/* Same as preadv but with an additional flag argument defined at uio.h. */
131extern ssize_t pwritev2 (int __fd, const struct iovec *__iodev, int __count,
132 __off_t __offset, int __flags) __wur;
133
134# else
135# ifdef __REDIRECT
136extern ssize_t __REDIRECT (pwritev2, (int __fd, const struct iovec *__iovec,
137 int __count, __off64_t __offset,
138 int __flags),
139 pwritev64v2) __wur;
140extern ssize_t __REDIRECT (preadv2, (int __fd, const struct iovec *__iovec,
141 int __count, __off64_t __offset,
142 int __flags),
143 preadv64v2) __wur;
144# else
145# define preadv2 preadv64v2
146# define pwritev2 pwritev64v2
147# endif
148# endif
149
150# ifdef __USE_LARGEFILE64
151/* Same as preadv but with an additional flag argumenti defined at uio.h. */
152extern ssize_t preadv64v2 (int __fp, const struct iovec *__iovec,
153 int __count, __off64_t __offset,
154 int ___flags) __wur;
155
156/* Same as preadv but with an additional flag argument defined at uio.h. */
157extern ssize_t pwritev64v2 (int __fd, const struct iovec *__iodev,
158 int __count, __off64_t __offset,
159 int __flags) __wur;
160# endif
161#endif /* Use GNU. */
162
163__END_DECLS
164
165/* Some operating systems provide system-specific extensions to this
166 header. */
167#ifdef __USE_GNU
168# include <bits/uio-ext.h>
169#endif
170
171#endif /* sys/uio.h */
libc/glibc-include/sys/un.h created+46
...@@ -0,0 +1,46 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_UN_H
19#define _SYS_UN_H 1
20
21#include <sys/cdefs.h>
22
23/* Get the definition of the macro to define the common sockaddr members. */
24#include <bits/sockaddr.h>
25
26__BEGIN_DECLS
27
28/* Structure describing the address of an AF_LOCAL (aka AF_UNIX) socket. */
29struct sockaddr_un
30 {
31 __SOCKADDR_COMMON (sun_);
32 char sun_path[108]; /* Path name. */
33 };
34
35
36#ifdef __USE_MISC
37# include <string.h> /* For prototype of `strlen'. */
38
39/* Evaluate to actual length of the `sockaddr_un' structure. */
40# define SUN_LEN(ptr) ((size_t) (((struct sockaddr_un *) 0)->sun_path) \
41 + strlen ((ptr)->sun_path))
42#endif
43
44__END_DECLS
45
46#endif /* sys/un.h */
libc/glibc-include/sys/unistd.h created+1
...@@ -0,0 +1 @@
1#include <unistd.h>
libc/glibc-include/sys/user.h created+180
...@@ -0,0 +1,180 @@
1/* Copyright (C) 2001-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_USER_H
19#define _SYS_USER_H 1
20
21/* The whole purpose of this file is for GDB and GDB only. Don't read
22 too much into it. Don't use it for anything other than GDB unless
23 you know what you are doing. */
24
25#ifdef __x86_64__
26
27struct user_fpregs_struct
28{
29 unsigned short int cwd;
30 unsigned short int swd;
31 unsigned short int ftw;
32 unsigned short int fop;
33 __extension__ unsigned long long int rip;
34 __extension__ unsigned long long int rdp;
35 unsigned int mxcsr;
36 unsigned int mxcr_mask;
37 unsigned int st_space[32]; /* 8*16 bytes for each FP-reg = 128 bytes */
38 unsigned int xmm_space[64]; /* 16*16 bytes for each XMM-reg = 256 bytes */
39 unsigned int padding[24];
40};
41
42struct user_regs_struct
43{
44 __extension__ unsigned long long int r15;
45 __extension__ unsigned long long int r14;
46 __extension__ unsigned long long int r13;
47 __extension__ unsigned long long int r12;
48 __extension__ unsigned long long int rbp;
49 __extension__ unsigned long long int rbx;
50 __extension__ unsigned long long int r11;
51 __extension__ unsigned long long int r10;
52 __extension__ unsigned long long int r9;
53 __extension__ unsigned long long int r8;
54 __extension__ unsigned long long int rax;
55 __extension__ unsigned long long int rcx;
56 __extension__ unsigned long long int rdx;
57 __extension__ unsigned long long int rsi;
58 __extension__ unsigned long long int rdi;
59 __extension__ unsigned long long int orig_rax;
60 __extension__ unsigned long long int rip;
61 __extension__ unsigned long long int cs;
62 __extension__ unsigned long long int eflags;
63 __extension__ unsigned long long int rsp;
64 __extension__ unsigned long long int ss;
65 __extension__ unsigned long long int fs_base;
66 __extension__ unsigned long long int gs_base;
67 __extension__ unsigned long long int ds;
68 __extension__ unsigned long long int es;
69 __extension__ unsigned long long int fs;
70 __extension__ unsigned long long int gs;
71};
72
73struct user
74{
75 struct user_regs_struct regs;
76 int u_fpvalid;
77 struct user_fpregs_struct i387;
78 __extension__ unsigned long long int u_tsize;
79 __extension__ unsigned long long int u_dsize;
80 __extension__ unsigned long long int u_ssize;
81 __extension__ unsigned long long int start_code;
82 __extension__ unsigned long long int start_stack;
83 __extension__ long long int signal;
84 int reserved;
85 __extension__ union
86 {
87 struct user_regs_struct* u_ar0;
88 __extension__ unsigned long long int __u_ar0_word;
89 };
90 __extension__ union
91 {
92 struct user_fpregs_struct* u_fpstate;
93 __extension__ unsigned long long int __u_fpstate_word;
94 };
95 __extension__ unsigned long long int magic;
96 char u_comm [32];
97 __extension__ unsigned long long int u_debugreg [8];
98};
99
100#else
101/* These are the 32-bit x86 structures. */
102struct user_fpregs_struct
103{
104 long int cwd;
105 long int swd;
106 long int twd;
107 long int fip;
108 long int fcs;
109 long int foo;
110 long int fos;
111 long int st_space [20];
112};
113
114struct user_fpxregs_struct
115{
116 unsigned short int cwd;
117 unsigned short int swd;
118 unsigned short int twd;
119 unsigned short int fop;
120 long int fip;
121 long int fcs;
122 long int foo;
123 long int fos;
124 long int mxcsr;
125 long int reserved;
126 long int st_space[32]; /* 8*16 bytes for each FP-reg = 128 bytes */
127 long int xmm_space[32]; /* 8*16 bytes for each XMM-reg = 128 bytes */
128 long int padding[56];
129};
130
131struct user_regs_struct
132{
133 long int ebx;
134 long int ecx;
135 long int edx;
136 long int esi;
137 long int edi;
138 long int ebp;
139 long int eax;
140 long int xds;
141 long int xes;
142 long int xfs;
143 long int xgs;
144 long int orig_eax;
145 long int eip;
146 long int xcs;
147 long int eflags;
148 long int esp;
149 long int xss;
150};
151
152struct user
153{
154 struct user_regs_struct regs;
155 int u_fpvalid;
156 struct user_fpregs_struct i387;
157 unsigned long int u_tsize;
158 unsigned long int u_dsize;
159 unsigned long int u_ssize;
160 unsigned long int start_code;
161 unsigned long int start_stack;
162 long int signal;
163 int reserved;
164 struct user_regs_struct* u_ar0;
165 struct user_fpregs_struct* u_fpstate;
166 unsigned long int magic;
167 char u_comm [32];
168 int u_debugreg [8];
169};
170#endif /* __x86_64__ */
171
172#define PAGE_SHIFT 12
173#define PAGE_SIZE (1UL << PAGE_SHIFT)
174#define PAGE_MASK (~(PAGE_SIZE-1))
175#define NBPG PAGE_SIZE
176#define UPAGES 1
177#define HOST_TEXT_START_ADDR (u.start_code)
178#define HOST_STACK_END_ADDR (u.start_stack + u.u_ssize * NBPG)
179
180#endif /* _SYS_USER_H */
libc/glibc-include/sys/utsname.h created+86
...@@ -0,0 +1,86 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/*
19 * POSIX Standard: 4.4 System Identification <sys/utsname.h>
20 */
21
22#ifndef _SYS_UTSNAME_H
23#define _SYS_UTSNAME_H 1
24
25#include <features.h>
26
27__BEGIN_DECLS
28
29#include <bits/utsname.h>
30
31#ifndef _UTSNAME_SYSNAME_LENGTH
32# define _UTSNAME_SYSNAME_LENGTH _UTSNAME_LENGTH
33#endif
34#ifndef _UTSNAME_NODENAME_LENGTH
35# define _UTSNAME_NODENAME_LENGTH _UTSNAME_LENGTH
36#endif
37#ifndef _UTSNAME_RELEASE_LENGTH
38# define _UTSNAME_RELEASE_LENGTH _UTSNAME_LENGTH
39#endif
40#ifndef _UTSNAME_VERSION_LENGTH
41# define _UTSNAME_VERSION_LENGTH _UTSNAME_LENGTH
42#endif
43#ifndef _UTSNAME_MACHINE_LENGTH
44# define _UTSNAME_MACHINE_LENGTH _UTSNAME_LENGTH
45#endif
46
47/* Structure describing the system and machine. */
48struct utsname
49 {
50 /* Name of the implementation of the operating system. */
51 char sysname[_UTSNAME_SYSNAME_LENGTH];
52
53 /* Name of this node on the network. */
54 char nodename[_UTSNAME_NODENAME_LENGTH];
55
56 /* Current release level of this implementation. */
57 char release[_UTSNAME_RELEASE_LENGTH];
58 /* Current version level of this release. */
59 char version[_UTSNAME_VERSION_LENGTH];
60
61 /* Name of the hardware type the system is running on. */
62 char machine[_UTSNAME_MACHINE_LENGTH];
63
64#if _UTSNAME_DOMAIN_LENGTH - 0
65 /* Name of the domain of this node on the network. */
66# ifdef __USE_GNU
67 char domainname[_UTSNAME_DOMAIN_LENGTH];
68# else
69 char __domainname[_UTSNAME_DOMAIN_LENGTH];
70# endif
71#endif
72 };
73
74#ifdef __USE_MISC
75/* Note that SVID assumes all members have the same size. */
76# define SYS_NMLN _UTSNAME_LENGTH
77#endif
78
79
80/* Put information about the system in NAME. */
81extern int uname (struct utsname *__name) __THROW;
82
83
84__END_DECLS
85
86#endif /* sys/utsname.h */
libc/glibc-include/sys/vfs.h created+4
...@@ -0,0 +1,4 @@
1/* Other systems declare `struct statfs' et al in <sys/vfs.h>,
2 so we have this file to be compatible with programs expecting it. */
3
4#include <sys/statfs.h>
libc/glibc-include/sys/vlimit.h created+67
...@@ -0,0 +1,67 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_VLIMIT_H
19#define _SYS_VLIMIT_H 1
20
21#include <features.h>
22
23__BEGIN_DECLS
24
25/* This interface is obsolete, and is superseded by <sys/resource.h>. */
26
27/* Kinds of resource limit. */
28enum __vlimit_resource
29{
30 /* Setting this non-zero makes it impossible to raise limits.
31 Only the super-use can set it to zero.
32
33 This is not implemented in recent versions of BSD, nor by
34 the GNU C library. */
35 LIM_NORAISE,
36
37 /* CPU time available for each process (seconds). */
38 LIM_CPU,
39
40 /* Largest file which can be created (bytes). */
41 LIM_FSIZE,
42
43 /* Maximum size of the data segment (bytes). */
44 LIM_DATA,
45
46 /* Maximum size of the stack segment (bytes). */
47 LIM_STACK,
48
49 /* Largest core file that will be created (bytes). */
50 LIM_CORE,
51
52 /* Resident set size (bytes). */
53 LIM_MAXRSS
54};
55
56/* This means no limit. */
57#define INFINITY 0x7fffffff
58
59
60/* Set the soft limit for RESOURCE to be VALUE.
61 Returns 0 for success, -1 for failure. */
62extern int vlimit (enum __vlimit_resource __resource, int __value) __THROW;
63
64
65__END_DECLS
66
67#endif /* sys/vlimit.h */
libc/glibc-include/sys/vm86.h created+38
...@@ -0,0 +1,38 @@
1/* Copyright (C) 1996-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_VM86_H
19
20#define _SYS_VM86_H 1
21#include <features.h>
22
23#ifdef __x86_64__
24# error This header is unsupported on x86-64.
25#else
26/* Get constants and data types from kernel header file. */
27# include <asm/vm86.h>
28
29__BEGIN_DECLS
30
31/* Enter virtual 8086 mode. */
32extern int vm86 (unsigned long int __subfunction,
33 struct vm86plus_struct *__info) __THROW;
34
35__END_DECLS
36# endif
37
38#endif /* _SYS_VM86_H */
libc/glibc-include/sys/vt.h created+1
...@@ -0,0 +1 @@
1#include <linux/vt.h>
libc/glibc-include/sys/vtimes.h created+68
...@@ -0,0 +1,68 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_VTIMES_H
19#define _SYS_VTIMES_H 1
20
21#include <features.h>
22
23__BEGIN_DECLS
24
25/* This interface is obsolete; use `getrusage' instead. */
26
27/* Granularity of the `vm_utime' and `vm_stime' fields of a `struct vtimes'.
28 (This is the frequency of the machine's power supply, in Hz.) */
29#define VTIMES_UNITS_PER_SECOND 60
30
31struct vtimes
32{
33 /* User time used in units of 1/VTIMES_UNITS_PER_SECOND seconds. */
34 int vm_utime;
35 /* System time used in units of 1/VTIMES_UNITS_PER_SECOND seconds. */
36 int vm_stime;
37
38 /* Amount of data and stack memory used (kilobyte-seconds). */
39 unsigned int vm_idsrss;
40 /* Amount of text memory used (kilobyte-seconds). */
41 unsigned int vm_ixrss;
42 /* Maximum resident set size (text, data, and stack) (kilobytes). */
43 int vm_maxrss;
44
45 /* Number of hard page faults (i.e. those that required I/O). */
46 int vm_majflt;
47 /* Number of soft page faults (i.e. those serviced by reclaiming
48 a page from the list of pages awaiting reallocation. */
49 int vm_minflt;
50
51 /* Number of times a process was swapped out of physical memory. */
52 int vm_nswap;
53
54 /* Number of input operations via the file system. Note: This
55 and `ru_oublock' do not include operations with the cache. */
56 int vm_inblk;
57 /* Number of output operations via the file system. */
58 int vm_oublk;
59};
60
61/* If CURRENT is not NULL, write statistics for the current process into
62 *CURRENT. If CHILD is not NULL, write statistics for all terminated child
63 processes into *CHILD. Returns 0 for success, -1 for failure. */
64extern int vtimes (struct vtimes * __current, struct vtimes * __child) __THROW;
65
66__END_DECLS
67
68#endif /* sys/vtimes.h */
libc/glibc-include/sys/wait.h created+160
...@@ -0,0 +1,160 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/*
19 * POSIX Standard: 3.2.1 Wait for Process Termination <sys/wait.h>
20 */
21
22#ifndef _SYS_WAIT_H
23#define _SYS_WAIT_H 1
24
25#include <features.h>
26
27__BEGIN_DECLS
28
29#include <bits/types.h>
30#ifndef __pid_t_defined
31typedef __pid_t pid_t;
32# define __pid_t_defined
33#endif
34
35#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
36# include <signal.h>
37#endif
38
39#if defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8
40/* Some older standards require the contents of struct rusage to be
41 defined here. */
42# include <bits/types/struct_rusage.h>
43#endif
44
45/* These macros could also be defined in <stdlib.h>. */
46#if !defined _STDLIB_H || (!defined __USE_XOPEN && !defined __USE_XOPEN2K8)
47/* This will define the `W*' macros for the flag
48 bits to `waitpid', `wait3', and `wait4'. */
49# include <bits/waitflags.h>
50
51/* This will define all the `__W*' macros. */
52# include <bits/waitstatus.h>
53
54# define WEXITSTATUS(status) __WEXITSTATUS (status)
55# define WTERMSIG(status) __WTERMSIG (status)
56# define WSTOPSIG(status) __WSTOPSIG (status)
57# define WIFEXITED(status) __WIFEXITED (status)
58# define WIFSIGNALED(status) __WIFSIGNALED (status)
59# define WIFSTOPPED(status) __WIFSTOPPED (status)
60# ifdef __WIFCONTINUED
61# define WIFCONTINUED(status) __WIFCONTINUED (status)
62# endif
63#endif /* <stdlib.h> not included. */
64
65#ifdef __USE_MISC
66# define WCOREFLAG __WCOREFLAG
67# define WCOREDUMP(status) __WCOREDUMP (status)
68# define W_EXITCODE(ret, sig) __W_EXITCODE (ret, sig)
69# define W_STOPCODE(sig) __W_STOPCODE (sig)
70#endif
71
72/* The following values are used by the `waitid' function. */
73#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
74typedef enum
75{
76 P_ALL, /* Wait for any child. */
77 P_PID, /* Wait for specified process. */
78 P_PGID /* Wait for members of process group. */
79} idtype_t;
80#endif
81
82
83/* Wait for a child to die. When one does, put its status in *STAT_LOC
84 and return its process ID. For errors, return (pid_t) -1.
85
86 This function is a cancellation point and therefore not marked with
87 __THROW. */
88extern __pid_t wait (int *__stat_loc);
89
90#ifdef __USE_MISC
91/* Special values for the PID argument to `waitpid' and `wait4'. */
92# define WAIT_ANY (-1) /* Any process. */
93# define WAIT_MYPGRP 0 /* Any process in my process group. */
94#endif
95
96/* Wait for a child matching PID to die.
97 If PID is greater than 0, match any process whose process ID is PID.
98 If PID is (pid_t) -1, match any process.
99 If PID is (pid_t) 0, match any process with the
100 same process group as the current process.
101 If PID is less than -1, match any process whose
102 process group is the absolute value of PID.
103 If the WNOHANG bit is set in OPTIONS, and that child
104 is not already dead, return (pid_t) 0. If successful,
105 return PID and store the dead child's status in STAT_LOC.
106 Return (pid_t) -1 for errors. If the WUNTRACED bit is
107 set in OPTIONS, return status for stopped children; otherwise don't.
108
109 This function is a cancellation point and therefore not marked with
110 __THROW. */
111extern __pid_t waitpid (__pid_t __pid, int *__stat_loc, int __options);
112
113#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
114# ifndef __id_t_defined
115typedef __id_t id_t;
116# define __id_t_defined
117# endif
118
119# include <bits/types/siginfo_t.h>
120
121/* Wait for a childing matching IDTYPE and ID to change the status and
122 place appropriate information in *INFOP.
123 If IDTYPE is P_PID, match any process whose process ID is ID.
124 If IDTYPE is P_PGID, match any process whose process group is ID.
125 If IDTYPE is P_ALL, match any process.
126 If the WNOHANG bit is set in OPTIONS, and that child
127 is not already dead, clear *INFOP and return 0. If successful, store
128 exit code and status in *INFOP.
129
130 This function is a cancellation point and therefore not marked with
131 __THROW. */
132extern int waitid (idtype_t __idtype, __id_t __id, siginfo_t *__infop,
133 int __options);
134#endif
135
136#if defined __USE_MISC \
137 || (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K)
138/* This being here makes the prototypes valid whether or not
139 we have already included <sys/resource.h> to define `struct rusage'. */
140struct rusage;
141
142/* Wait for a child to exit. When one does, put its status in *STAT_LOC and
143 return its process ID. For errors return (pid_t) -1. If USAGE is not
144 nil, store information about the child's resource usage there. If the
145 WUNTRACED bit is set in OPTIONS, return status for stopped children;
146 otherwise don't. */
147extern __pid_t wait3 (int *__stat_loc, int __options,
148 struct rusage * __usage) __THROWNL;
149#endif
150
151#ifdef __USE_MISC
152/* PID is like waitpid. Other args are like wait3. */
153extern __pid_t wait4 (__pid_t __pid, int *__stat_loc, int __options,
154 struct rusage *__usage) __THROWNL;
155#endif /* Use misc. */
156
157
158__END_DECLS
159
160#endif /* sys/wait.h */
libc/glibc-include/sys/xattr.h created+105
...@@ -0,0 +1,105 @@
1/* Copyright (C) 2002-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_XATTR_H
19#define _SYS_XATTR_H 1
20
21#include <features.h>
22#include <sys/types.h>
23
24
25__BEGIN_DECLS
26
27/* The following constants should be used for the fifth parameter of
28 `*setxattr'. */
29#ifndef __USE_KERNEL_XATTR_DEFS
30enum
31{
32 XATTR_CREATE = 1, /* set value, fail if attr already exists. */
33#define XATTR_CREATE XATTR_CREATE
34 XATTR_REPLACE = 2 /* set value, fail if attr does not exist. */
35#define XATTR_REPLACE XATTR_REPLACE
36};
37#endif
38
39/* Set the attribute NAME of the file pointed to by PATH to VALUE (which
40 is SIZE bytes long). Return 0 on success, -1 for errors. */
41extern int setxattr (const char *__path, const char *__name,
42 const void *__value, size_t __size, int __flags)
43 __THROW;
44
45/* Set the attribute NAME of the file pointed to by PATH to VALUE (which is
46 SIZE bytes long), not following symlinks for the last pathname component.
47 Return 0 on success, -1 for errors. */
48extern int lsetxattr (const char *__path, const char *__name,
49 const void *__value, size_t __size, int __flags)
50 __THROW;
51
52/* Set the attribute NAME of the file descriptor FD to VALUE (which is SIZE
53 bytes long). Return 0 on success, -1 for errors. */
54extern int fsetxattr (int __fd, const char *__name, const void *__value,
55 size_t __size, int __flags) __THROW;
56
57/* Get the attribute NAME of the file pointed to by PATH to VALUE (which is
58 SIZE bytes long). Return 0 on success, -1 for errors. */
59extern ssize_t getxattr (const char *__path, const char *__name,
60 void *__value, size_t __size) __THROW;
61
62/* Get the attribute NAME of the file pointed to by PATH to VALUE (which is
63 SIZE bytes long), not following symlinks for the last pathname component.
64 Return 0 on success, -1 for errors. */
65extern ssize_t lgetxattr (const char *__path, const char *__name,
66 void *__value, size_t __size) __THROW;
67
68/* Get the attribute NAME of the file descriptor FD to VALUE (which is SIZE
69 bytes long). Return 0 on success, -1 for errors. */
70extern ssize_t fgetxattr (int __fd, const char *__name, void *__value,
71 size_t __size) __THROW;
72
73/* List attributes of the file pointed to by PATH into the user-supplied
74 buffer LIST (which is SIZE bytes big). Return 0 on success, -1 for
75 errors. */
76extern ssize_t listxattr (const char *__path, char *__list, size_t __size)
77 __THROW;
78
79/* List attributes of the file pointed to by PATH into the user-supplied
80 buffer LIST (which is SIZE bytes big), not following symlinks for the
81 last pathname component. Return 0 on success, -1 for errors. */
82extern ssize_t llistxattr (const char *__path, char *__list, size_t __size)
83 __THROW;
84
85/* List attributes of the file descriptor FD into the user-supplied buffer
86 LIST (which is SIZE bytes big). Return 0 on success, -1 for errors. */
87extern ssize_t flistxattr (int __fd, char *__list, size_t __size)
88 __THROW;
89
90/* Remove the attribute NAME from the file pointed to by PATH. Return 0
91 on success, -1 for errors. */
92extern int removexattr (const char *__path, const char *__name) __THROW;
93
94/* Remove the attribute NAME from the file pointed to by PATH, not
95 following symlinks for the last pathname component. Return 0 on
96 success, -1 for errors. */
97extern int lremovexattr (const char *__path, const char *__name) __THROW;
98
99/* Remove the attribute NAME from the file descriptor FD. Return 0 on
100 success, -1 for errors. */
101extern int fremovexattr (int __fd, const char *__name) __THROW;
102
103__END_DECLS
104
105#endif /* sys/xattr.h */
libc/glibc-include/syscall.h created+1
...@@ -0,0 +1 @@
1#include <sys/syscall.h>
libc/glibc-include/sysexits.h created+114
...@@ -0,0 +1,114 @@
1/*
2 * Copyright (c) 1987, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 4. Neither the name of the University nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * @(#)sysexits.h 8.1 (Berkeley) 6/2/93
30 */
31
32#ifndef _SYSEXITS_H
33#define _SYSEXITS_H 1
34
35/*
36 * SYSEXITS.H -- Exit status codes for system programs.
37 *
38 * This include file attempts to categorize possible error
39 * exit statuses for system programs, notably delivermail
40 * and the Berkeley network.
41 *
42 * Error numbers begin at EX__BASE to reduce the possibility of
43 * clashing with other exit statuses that random programs may
44 * already return. The meaning of the codes is approximately
45 * as follows:
46 *
47 * EX_USAGE -- The command was used incorrectly, e.g., with
48 * the wrong number of arguments, a bad flag, a bad
49 * syntax in a parameter, or whatever.
50 * EX_DATAERR -- The input data was incorrect in some way.
51 * This should only be used for user's data & not
52 * system files.
53 * EX_NOINPUT -- An input file (not a system file) did not
54 * exist or was not readable. This could also include
55 * errors like "No message" to a mailer (if it cared
56 * to catch it).
57 * EX_NOUSER -- The user specified did not exist. This might
58 * be used for mail addresses or remote logins.
59 * EX_NOHOST -- The host specified did not exist. This is used
60 * in mail addresses or network requests.
61 * EX_UNAVAILABLE -- A service is unavailable. This can occur
62 * if a support program or file does not exist. This
63 * can also be used as a catchall message when something
64 * you wanted to do doesn't work, but you don't know
65 * why.
66 * EX_SOFTWARE -- An internal software error has been detected.
67 * This should be limited to non-operating system related
68 * errors as possible.
69 * EX_OSERR -- An operating system error has been detected.
70 * This is intended to be used for such things as "cannot
71 * fork", "cannot create pipe", or the like. It includes
72 * things like getuid returning a user that does not
73 * exist in the passwd file.
74 * EX_OSFILE -- Some system file (e.g., /etc/passwd, /etc/utmp,
75 * etc.) does not exist, cannot be opened, or has some
76 * sort of error (e.g., syntax error).
77 * EX_CANTCREAT -- A (user specified) output file cannot be
78 * created.
79 * EX_IOERR -- An error occurred while doing I/O on some file.
80 * EX_TEMPFAIL -- temporary failure, indicating something that
81 * is not really an error. In sendmail, this means
82 * that a mailer (e.g.) could not create a connection,
83 * and the request should be reattempted later.
84 * EX_PROTOCOL -- the remote system returned something that
85 * was "not possible" during a protocol exchange.
86 * EX_NOPERM -- You did not have sufficient permission to
87 * perform the operation. This is not intended for
88 * file system problems, which should use NOINPUT or
89 * CANTCREAT, but rather for higher level permissions.
90 */
91
92#define EX_OK 0 /* successful termination */
93
94#define EX__BASE 64 /* base value for error messages */
95
96#define EX_USAGE 64 /* command line usage error */
97#define EX_DATAERR 65 /* data format error */
98#define EX_NOINPUT 66 /* cannot open input */
99#define EX_NOUSER 67 /* addressee unknown */
100#define EX_NOHOST 68 /* host name unknown */
101#define EX_UNAVAILABLE 69 /* service unavailable */
102#define EX_SOFTWARE 70 /* internal software error */
103#define EX_OSERR 71 /* system error (e.g., can't fork) */
104#define EX_OSFILE 72 /* critical OS file missing */
105#define EX_CANTCREAT 73 /* can't create (user) output file */
106#define EX_IOERR 74 /* input/output error */
107#define EX_TEMPFAIL 75 /* temp failure; user is invited to retry */
108#define EX_PROTOCOL 76 /* remote error in protocol */
109#define EX_NOPERM 77 /* permission denied */
110#define EX_CONFIG 78 /* configuration error */
111
112#define EX__MAX 78 /* maximum listed value */
113
114#endif /* sysexits.h */
libc/glibc-include/syslog.h created+1
...@@ -0,0 +1 @@
1#include <sys/syslog.h>
libc/glibc-include/tar.h created+112
...@@ -0,0 +1,112 @@
1/* Extended tar format from POSIX.1.
2 Copyright (C) 1992-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Written by David J. MacKenzie.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
19
20#ifndef _TAR_H
21#define _TAR_H 1
22
23#include <features.h>
24
25
26/* A tar archive consists of 512-byte blocks.
27 Each file in the archive has a header block followed by 0+ data blocks.
28 Two blocks of NUL bytes indicate the end of the archive. */
29
30/* The fields of header blocks:
31 All strings are stored as ISO 646 (approximately ASCII) strings.
32
33 Fields are numeric unless otherwise noted below; numbers are ISO 646
34 representations of octal numbers, with leading zeros as needed.
35
36 linkname is only valid when typeflag==LNKTYPE. It doesn't use prefix;
37 files that are links to pathnames >100 chars long can not be stored
38 in a tar archive.
39
40 If typeflag=={LNKTYPE,SYMTYPE,DIRTYPE} then size must be 0.
41
42 devmajor and devminor are only valid for typeflag=={BLKTYPE,CHRTYPE}.
43
44 chksum contains the sum of all 512 bytes in the header block,
45 treating each byte as an 8-bit unsigned value and treating the
46 8 bytes of chksum as blank characters.
47
48 uname and gname are used in preference to uid and gid, if those
49 names exist locally.
50
51 Field Name Byte Offset Length in Bytes Field Type
52 name 0 100 NUL-terminated if NUL fits
53 mode 100 8
54 uid 108 8
55 gid 116 8
56 size 124 12
57 mtime 136 12
58 chksum 148 8
59 typeflag 156 1 see below
60 linkname 157 100 NUL-terminated if NUL fits
61 magic 257 6 must be TMAGIC (NUL term.)
62 version 263 2 must be TVERSION
63 uname 265 32 NUL-terminated
64 gname 297 32 NUL-terminated
65 devmajor 329 8
66 devminor 337 8
67 prefix 345 155 NUL-terminated if NUL fits
68
69 If the first character of prefix is '\0', the file name is name;
70 otherwise, it is prefix/name. Files whose pathnames don't fit in that
71 length can not be stored in a tar archive. */
72
73/* The bits in mode: */
74#define TSUID 04000
75#define TSGID 02000
76#if defined __USE_XOPEN || !defined __USE_XOPEN2K
77# define TSVTX 01000
78#endif
79#define TUREAD 00400
80#define TUWRITE 00200
81#define TUEXEC 00100
82#define TGREAD 00040
83#define TGWRITE 00020
84#define TGEXEC 00010
85#define TOREAD 00004
86#define TOWRITE 00002
87#define TOEXEC 00001
88
89/* The values for typeflag:
90 Values 'A'-'Z' are reserved for custom implementations.
91 All other values are reserved for future POSIX.1 revisions. */
92
93#define REGTYPE '0' /* Regular file (preferred code). */
94#define AREGTYPE '\0' /* Regular file (alternate code). */
95#define LNKTYPE '1' /* Hard link. */
96#define SYMTYPE '2' /* Symbolic link (hard if not supported). */
97#define CHRTYPE '3' /* Character special. */
98#define BLKTYPE '4' /* Block special. */
99#define DIRTYPE '5' /* Directory. */
100#define FIFOTYPE '6' /* Named pipe. */
101#define CONTTYPE '7' /* Contiguous file */
102 /* (regular file if not supported). */
103
104/* Contents of magic field and its length. */
105#define TMAGIC "ustar"
106#define TMAGLEN 6
107
108/* Contents of the version field and its length. */
109#define TVERSION "00"
110#define TVERSLEN 2
111
112#endif /* tar.h */
libc/glibc-include/termio.h created+6
...@@ -0,0 +1,6 @@
1/* Compatible <termio.h> for old `struct termio' ioctl interface.
2 This is obsolete; use the POSIX.1 `struct termios' interface
3 defined in <termios.h> instead. */
4
5#include <termios.h>
6#include <sys/ioctl.h>
libc/glibc-include/termios.h created+109
...@@ -0,0 +1,109 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/*
19 * POSIX Standard: 7.1-2 General Terminal Interface <termios.h>
20 */
21
22#ifndef _TERMIOS_H
23#define _TERMIOS_H 1
24
25#include <features.h>
26#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
27/* We need `pid_t'. */
28# include <bits/types.h>
29# ifndef __pid_t_defined
30typedef __pid_t pid_t;
31# define __pid_t_defined
32# endif
33#endif
34
35__BEGIN_DECLS
36
37/* Get the system-dependent definitions of `struct termios', `tcflag_t',
38 `cc_t', `speed_t', and all the macros specifying the flag bits. */
39#include <bits/termios.h>
40
41#ifdef __USE_MISC
42/* Compare a character C to a value VAL from the `c_cc' array in a
43 `struct termios'. If VAL is _POSIX_VDISABLE, no character can match it. */
44# define CCEQ(val, c) ((c) == (val) && (val) != _POSIX_VDISABLE)
45#endif
46
47/* Return the output baud rate stored in *TERMIOS_P. */
48extern speed_t cfgetospeed (const struct termios *__termios_p) __THROW;
49
50/* Return the input baud rate stored in *TERMIOS_P. */
51extern speed_t cfgetispeed (const struct termios *__termios_p) __THROW;
52
53/* Set the output baud rate stored in *TERMIOS_P to SPEED. */
54extern int cfsetospeed (struct termios *__termios_p, speed_t __speed) __THROW;
55
56/* Set the input baud rate stored in *TERMIOS_P to SPEED. */
57extern int cfsetispeed (struct termios *__termios_p, speed_t __speed) __THROW;
58
59#ifdef __USE_MISC
60/* Set both the input and output baud rates in *TERMIOS_OP to SPEED. */
61extern int cfsetspeed (struct termios *__termios_p, speed_t __speed) __THROW;
62#endif
63
64
65/* Put the state of FD into *TERMIOS_P. */
66extern int tcgetattr (int __fd, struct termios *__termios_p) __THROW;
67
68/* Set the state of FD to *TERMIOS_P.
69 Values for OPTIONAL_ACTIONS (TCSA*) are in <bits/termios.h>. */
70extern int tcsetattr (int __fd, int __optional_actions,
71 const struct termios *__termios_p) __THROW;
72
73
74#ifdef __USE_MISC
75/* Set *TERMIOS_P to indicate raw mode. */
76extern void cfmakeraw (struct termios *__termios_p) __THROW;
77#endif
78
79/* Send zero bits on FD. */
80extern int tcsendbreak (int __fd, int __duration) __THROW;
81
82/* Wait for pending output to be written on FD.
83
84 This function is a cancellation point and therefore not marked with
85 __THROW. */
86extern int tcdrain (int __fd);
87
88/* Flush pending data on FD.
89 Values for QUEUE_SELECTOR (TC{I,O,IO}FLUSH) are in <bits/termios.h>. */
90extern int tcflush (int __fd, int __queue_selector) __THROW;
91
92/* Suspend or restart transmission on FD.
93 Values for ACTION (TC[IO]{OFF,ON}) are in <bits/termios.h>. */
94extern int tcflow (int __fd, int __action) __THROW;
95
96
97#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
98/* Get process group ID for session leader for controlling terminal FD. */
99extern __pid_t tcgetsid (int __fd) __THROW;
100#endif
101
102
103#ifdef __USE_MISC
104# include <sys/ttydefaults.h>
105#endif
106
107__END_DECLS
108
109#endif /* termios.h */
libc/glibc-include/tgmath.h created+764
...@@ -0,0 +1,764 @@
1/* Copyright (C) 1997-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/*
19 * ISO C99 Standard: 7.22 Type-generic math <tgmath.h>
20 */
21
22#ifndef _TGMATH_H
23#define _TGMATH_H 1
24
25#define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION
26#include <bits/libc-header-start.h>
27
28/* Include the needed headers. */
29#include <bits/floatn.h>
30#include <math.h>
31#include <complex.h>
32
33
34/* There are two variant implementations of type-generic macros in
35 this file: one for GCC 8 and later, using __builtin_tgmath and
36 where each macro expands each of its arguments only once, and one
37 for older GCC, using other compiler extensions but with macros
38 expanding their arguments many times (so resulting in exponential
39 blowup of the size of expansions when calls to such macros are
40 nested inside arguments to such macros). */
41
42#define __HAVE_BUILTIN_TGMATH __GNUC_PREREQ (8, 0)
43
44#if __GNUC_PREREQ (2, 7)
45
46# if __HAVE_BUILTIN_TGMATH
47
48# if __HAVE_FLOAT16 && __GLIBC_USE (IEC_60559_TYPES_EXT)
49# define __TG_F16_ARG(X) X ## f16,
50# else
51# define __TG_F16_ARG(X)
52# endif
53# if __HAVE_FLOAT32 && __GLIBC_USE (IEC_60559_TYPES_EXT)
54# define __TG_F32_ARG(X) X ## f32,
55# else
56# define __TG_F32_ARG(X)
57# endif
58# if __HAVE_FLOAT64 && __GLIBC_USE (IEC_60559_TYPES_EXT)
59# define __TG_F64_ARG(X) X ## f64,
60# else
61# define __TG_F64_ARG(X)
62# endif
63# if __HAVE_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT)
64# define __TG_F128_ARG(X) X ## f128,
65# else
66# define __TG_F128_ARG(X)
67# endif
68# if __HAVE_FLOAT32X && __GLIBC_USE (IEC_60559_TYPES_EXT)
69# define __TG_F32X_ARG(X) X ## f32x,
70# else
71# define __TG_F32X_ARG(X)
72# endif
73# if __HAVE_FLOAT64X && __GLIBC_USE (IEC_60559_TYPES_EXT)
74# define __TG_F64X_ARG(X) X ## f64x,
75# else
76# define __TG_F64X_ARG(X)
77# endif
78# if __HAVE_FLOAT128X && __GLIBC_USE (IEC_60559_TYPES_EXT)
79# define __TG_F128X_ARG(X) X ## f128x,
80# else
81# define __TG_F128X_ARG(X)
82# endif
83
84# define __TGMATH_FUNCS(X) X ## f, X, X ## l, \
85 __TG_F16_ARG (X) __TG_F32_ARG (X) __TG_F64_ARG (X) __TG_F128_ARG (X) \
86 __TG_F32X_ARG (X) __TG_F64X_ARG (X) __TG_F128X_ARG (X)
87# define __TGMATH_RCFUNCS(F, C) __TGMATH_FUNCS (F) __TGMATH_FUNCS (C)
88# define __TGMATH_1(F, X) __builtin_tgmath (__TGMATH_FUNCS (F) (X))
89# define __TGMATH_2(F, X, Y) __builtin_tgmath (__TGMATH_FUNCS (F) (X), (Y))
90# define __TGMATH_2STD(F, X, Y) __builtin_tgmath (F ## f, F, F ## l, (X), (Y))
91# define __TGMATH_3(F, X, Y, Z) __builtin_tgmath (__TGMATH_FUNCS (F) \
92 (X), (Y), (Z))
93# define __TGMATH_1C(F, C, X) __builtin_tgmath (__TGMATH_RCFUNCS (F, C) (X))
94# define __TGMATH_2C(F, C, X, Y) __builtin_tgmath (__TGMATH_RCFUNCS (F, C) \
95 (X), (Y))
96
97# else /* !__HAVE_BUILTIN_TGMATH. */
98
99# ifdef __NO_LONG_DOUBLE_MATH
100# define __tgml(fct) fct
101# else
102# define __tgml(fct) fct ## l
103# endif
104
105/* __floating_type expands to 1 if TYPE is a floating type (including
106 complex floating types), 0 if TYPE is an integer type (including
107 complex integer types). __real_integer_type expands to 1 if TYPE
108 is a real integer type. __complex_integer_type expands to 1 if
109 TYPE is a complex integer type. All these macros expand to integer
110 constant expressions. All these macros can assume their argument
111 has an arithmetic type (not vector, decimal floating-point or
112 fixed-point), valid to pass to tgmath.h macros. */
113# if __GNUC_PREREQ (3, 1)
114/* __builtin_classify_type expands to an integer constant expression
115 in GCC 3.1 and later. Default conversions applied to the argument
116 of __builtin_classify_type mean it always returns 1 for real
117 integer types rather than ever returning different values for
118 character, boolean or enumerated types. */
119# define __floating_type(type) \
120 (__builtin_classify_type (__real__ ((type) 0)) == 8)
121# define __real_integer_type(type) \
122 (__builtin_classify_type ((type) 0) == 1)
123# define __complex_integer_type(type) \
124 (__builtin_classify_type ((type) 0) == 9 \
125 && __builtin_classify_type (__real__ ((type) 0)) == 1)
126# else
127/* GCC versions predating __builtin_classify_type are also looser on
128 what counts as an integer constant expression. */
129# define __floating_type(type) (((type) 1.25) != 1)
130# define __real_integer_type(type) (((type) (1.25 + _Complex_I)) == 1)
131# define __complex_integer_type(type) \
132 (((type) (1.25 + _Complex_I)) == (1 + _Complex_I))
133# endif
134
135/* Whether an expression (of arithmetic type) has a real type. */
136# define __expr_is_real(E) (__builtin_classify_type (E) != 9)
137
138/* The tgmath real type for T, where E is 0 if T is an integer type
139 and 1 for a floating type. If T has a complex type, it is
140 unspecified whether the return type is real or complex (but it has
141 the correct corresponding real type). */
142# define __tgmath_real_type_sub(T, E) \
143 __typeof__ (*(0 ? (__typeof__ (0 ? (double *) 0 : (void *) (E))) 0 \
144 : (__typeof__ (0 ? (T *) 0 : (void *) (!(E)))) 0))
145
146/* The tgmath real type of EXPR. */
147# define __tgmath_real_type(expr) \
148 __tgmath_real_type_sub (__typeof__ ((__typeof__ (+(expr))) 0), \
149 __floating_type (__typeof__ (+(expr))))
150
151/* The tgmath complex type for T, where E1 is 1 if T has a floating
152 type and 0 otherwise, E2 is 1 if T has a real integer type and 0
153 otherwise, and E3 is 1 if T has a complex type and 0 otherwise. */
154# define __tgmath_complex_type_sub(T, E1, E2, E3) \
155 __typeof__ (*(0 \
156 ? (__typeof__ (0 ? (T *) 0 : (void *) (!(E1)))) 0 \
157 : (__typeof__ (0 \
158 ? (__typeof__ (0 \
159 ? (double *) 0 \
160 : (void *) (!(E2)))) 0 \
161 : (__typeof__ (0 \
162 ? (_Complex double *) 0 \
163 : (void *) (!(E3)))) 0)) 0))
164
165/* The tgmath complex type of EXPR. */
166# define __tgmath_complex_type(expr) \
167 __tgmath_complex_type_sub (__typeof__ ((__typeof__ (+(expr))) 0), \
168 __floating_type (__typeof__ (+(expr))), \
169 __real_integer_type (__typeof__ (+(expr))), \
170 __complex_integer_type (__typeof__ (+(expr))))
171
172# if (__HAVE_DISTINCT_FLOAT16 \
173 || __HAVE_DISTINCT_FLOAT32 \
174 || __HAVE_DISTINCT_FLOAT64 \
175 || __HAVE_DISTINCT_FLOAT32X \
176 || __HAVE_DISTINCT_FLOAT64X \
177 || __HAVE_DISTINCT_FLOAT128X)
178# error "Unsupported _FloatN or _FloatNx types for <tgmath.h>."
179# endif
180
181/* Expand to text that checks if ARG_COMB has type _Float128, and if
182 so calls the appropriately suffixed FCT (which may include a cast),
183 or FCT and CFCT for complex functions, with arguments ARG_CALL. */
184# if __HAVE_DISTINCT_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT)
185# if (!__HAVE_FLOAT64X \
186 || __HAVE_FLOAT64X_LONG_DOUBLE \
187 || !__HAVE_FLOATN_NOT_TYPEDEF)
188# define __TGMATH_F128(arg_comb, fct, arg_call) \
189 __builtin_types_compatible_p (__typeof (+(arg_comb)), _Float128) \
190 ? fct ## f128 arg_call :
191# define __TGMATH_CF128(arg_comb, fct, cfct, arg_call) \
192 __builtin_types_compatible_p (__typeof (+__real__ (arg_comb)), _Float128) \
193 ? (__expr_is_real (arg_comb) \
194 ? fct ## f128 arg_call \
195 : cfct ## f128 arg_call) :
196# else
197/* _Float64x is a distinct type at the C language level, which must be
198 handled like _Float128. */
199# define __TGMATH_F128(arg_comb, fct, arg_call) \
200 (__builtin_types_compatible_p (__typeof (+(arg_comb)), _Float128) \
201 || __builtin_types_compatible_p (__typeof (+(arg_comb)), _Float64x)) \
202 ? fct ## f128 arg_call :
203# define __TGMATH_CF128(arg_comb, fct, cfct, arg_call) \
204 (__builtin_types_compatible_p (__typeof (+__real__ (arg_comb)), _Float128) \
205 || __builtin_types_compatible_p (__typeof (+__real__ (arg_comb)), \
206 _Float64x)) \
207 ? (__expr_is_real (arg_comb) \
208 ? fct ## f128 arg_call \
209 : cfct ## f128 arg_call) :
210# endif
211# else
212# define __TGMATH_F128(arg_comb, fct, arg_call) /* Nothing. */
213# define __TGMATH_CF128(arg_comb, fct, cfct, arg_call) /* Nothing. */
214# endif
215
216# endif /* !__HAVE_BUILTIN_TGMATH. */
217
218/* We have two kinds of generic macros: to support functions which are
219 only defined on real valued parameters and those which are defined
220 for complex functions as well. */
221# if __HAVE_BUILTIN_TGMATH
222
223# define __TGMATH_UNARY_REAL_ONLY(Val, Fct) __TGMATH_1 (Fct, (Val))
224# define __TGMATH_UNARY_REAL_RET_ONLY(Val, Fct) __TGMATH_1 (Fct, (Val))
225# define __TGMATH_BINARY_FIRST_REAL_ONLY(Val1, Val2, Fct) \
226 __TGMATH_2 (Fct, (Val1), (Val2))
227# define __TGMATH_BINARY_FIRST_REAL_STD_ONLY(Val1, Val2, Fct) \
228 __TGMATH_2STD (Fct, (Val1), (Val2))
229# define __TGMATH_BINARY_REAL_ONLY(Val1, Val2, Fct) \
230 __TGMATH_2 (Fct, (Val1), (Val2))
231# define __TGMATH_BINARY_REAL_STD_ONLY(Val1, Val2, Fct) \
232 __TGMATH_2STD (Fct, (Val1), (Val2))
233# define __TGMATH_BINARY_REAL_RET_ONLY(Val1, Val2, Fct) \
234 __TGMATH_2 (Fct, (Val1), (Val2))
235# define __TGMATH_TERNARY_FIRST_SECOND_REAL_ONLY(Val1, Val2, Val3, Fct) \
236 __TGMATH_3 (Fct, (Val1), (Val2), (Val3))
237# define __TGMATH_TERNARY_REAL_ONLY(Val1, Val2, Val3, Fct) \
238 __TGMATH_3 (Fct, (Val1), (Val2), (Val3))
239# define __TGMATH_TERNARY_FIRST_REAL_RET_ONLY(Val1, Val2, Val3, Fct) \
240 __TGMATH_3 (Fct, (Val1), (Val2), (Val3))
241# define __TGMATH_UNARY_REAL_IMAG(Val, Fct, Cfct) \
242 __TGMATH_1C (Fct, Cfct, (Val))
243# define __TGMATH_UNARY_IMAG(Val, Cfct) __TGMATH_1 (Cfct, (Val))
244# define __TGMATH_UNARY_REAL_IMAG_RET_REAL(Val, Fct, Cfct) \
245 __TGMATH_1C (Fct, Cfct, (Val))
246# define __TGMATH_UNARY_REAL_IMAG_RET_REAL_SAME(Val, Cfct) \
247 __TGMATH_1 (Cfct, (Val))
248# define __TGMATH_BINARY_REAL_IMAG(Val1, Val2, Fct, Cfct) \
249 __TGMATH_2C (Fct, Cfct, (Val1), (Val2))
250
251# else /* !__HAVE_BUILTIN_TGMATH. */
252
253# define __TGMATH_UNARY_REAL_ONLY(Val, Fct) \
254 (__extension__ ((sizeof (+(Val)) == sizeof (double) \
255 || __builtin_classify_type (Val) != 8) \
256 ? (__tgmath_real_type (Val)) Fct (Val) \
257 : (sizeof (+(Val)) == sizeof (float)) \
258 ? (__tgmath_real_type (Val)) Fct##f (Val) \
259 : __TGMATH_F128 ((Val), (__tgmath_real_type (Val)) Fct, \
260 (Val)) \
261 (__tgmath_real_type (Val)) __tgml(Fct) (Val)))
262
263# define __TGMATH_UNARY_REAL_RET_ONLY(Val, Fct) \
264 (__extension__ ((sizeof (+(Val)) == sizeof (double) \
265 || __builtin_classify_type (Val) != 8) \
266 ? Fct (Val) \
267 : (sizeof (+(Val)) == sizeof (float)) \
268 ? Fct##f (Val) \
269 : __TGMATH_F128 ((Val), Fct, (Val)) \
270 __tgml(Fct) (Val)))
271
272# define __TGMATH_BINARY_FIRST_REAL_ONLY(Val1, Val2, Fct) \
273 (__extension__ ((sizeof (+(Val1)) == sizeof (double) \
274 || __builtin_classify_type (Val1) != 8) \
275 ? (__tgmath_real_type (Val1)) Fct (Val1, Val2) \
276 : (sizeof (+(Val1)) == sizeof (float)) \
277 ? (__tgmath_real_type (Val1)) Fct##f (Val1, Val2) \
278 : __TGMATH_F128 ((Val1), (__tgmath_real_type (Val1)) Fct, \
279 (Val1, Val2)) \
280 (__tgmath_real_type (Val1)) __tgml(Fct) (Val1, Val2)))
281
282# define __TGMATH_BINARY_FIRST_REAL_STD_ONLY(Val1, Val2, Fct) \
283 (__extension__ ((sizeof (+(Val1)) == sizeof (double) \
284 || __builtin_classify_type (Val1) != 8) \
285 ? (__tgmath_real_type (Val1)) Fct (Val1, Val2) \
286 : (sizeof (+(Val1)) == sizeof (float)) \
287 ? (__tgmath_real_type (Val1)) Fct##f (Val1, Val2) \
288 : (__tgmath_real_type (Val1)) __tgml(Fct) (Val1, Val2)))
289
290# define __TGMATH_BINARY_REAL_ONLY(Val1, Val2, Fct) \
291 (__extension__ ((sizeof ((Val1) + (Val2)) > sizeof (double) \
292 && __builtin_classify_type ((Val1) + (Val2)) == 8) \
293 ? __TGMATH_F128 ((Val1) + (Val2), \
294 (__typeof \
295 ((__tgmath_real_type (Val1)) 0 \
296 + (__tgmath_real_type (Val2)) 0)) Fct, \
297 (Val1, Val2)) \
298 (__typeof ((__tgmath_real_type (Val1)) 0 \
299 + (__tgmath_real_type (Val2)) 0)) \
300 __tgml(Fct) (Val1, Val2) \
301 : (sizeof (+(Val1)) == sizeof (double) \
302 || sizeof (+(Val2)) == sizeof (double) \
303 || __builtin_classify_type (Val1) != 8 \
304 || __builtin_classify_type (Val2) != 8) \
305 ? (__typeof ((__tgmath_real_type (Val1)) 0 \
306 + (__tgmath_real_type (Val2)) 0)) \
307 Fct (Val1, Val2) \
308 : (__typeof ((__tgmath_real_type (Val1)) 0 \
309 + (__tgmath_real_type (Val2)) 0)) \
310 Fct##f (Val1, Val2)))
311
312# define __TGMATH_BINARY_REAL_STD_ONLY(Val1, Val2, Fct) \
313 (__extension__ ((sizeof ((Val1) + (Val2)) > sizeof (double) \
314 && __builtin_classify_type ((Val1) + (Val2)) == 8) \
315 ? (__typeof ((__tgmath_real_type (Val1)) 0 \
316 + (__tgmath_real_type (Val2)) 0)) \
317 __tgml(Fct) (Val1, Val2) \
318 : (sizeof (+(Val1)) == sizeof (double) \
319 || sizeof (+(Val2)) == sizeof (double) \
320 || __builtin_classify_type (Val1) != 8 \
321 || __builtin_classify_type (Val2) != 8) \
322 ? (__typeof ((__tgmath_real_type (Val1)) 0 \
323 + (__tgmath_real_type (Val2)) 0)) \
324 Fct (Val1, Val2) \
325 : (__typeof ((__tgmath_real_type (Val1)) 0 \
326 + (__tgmath_real_type (Val2)) 0)) \
327 Fct##f (Val1, Val2)))
328
329# define __TGMATH_BINARY_REAL_RET_ONLY(Val1, Val2, Fct) \
330 (__extension__ ((sizeof ((Val1) + (Val2)) > sizeof (double) \
331 && __builtin_classify_type ((Val1) + (Val2)) == 8) \
332 ? __TGMATH_F128 ((Val1) + (Val2), Fct, (Val1, Val2)) \
333 __tgml(Fct) (Val1, Val2) \
334 : (sizeof (+(Val1)) == sizeof (double) \
335 || sizeof (+(Val2)) == sizeof (double) \
336 || __builtin_classify_type (Val1) != 8 \
337 || __builtin_classify_type (Val2) != 8) \
338 ? Fct (Val1, Val2) \
339 : Fct##f (Val1, Val2)))
340
341# define __TGMATH_TERNARY_FIRST_SECOND_REAL_ONLY(Val1, Val2, Val3, Fct) \
342 (__extension__ ((sizeof ((Val1) + (Val2)) > sizeof (double) \
343 && __builtin_classify_type ((Val1) + (Val2)) == 8) \
344 ? __TGMATH_F128 ((Val1) + (Val2), \
345 (__typeof \
346 ((__tgmath_real_type (Val1)) 0 \
347 + (__tgmath_real_type (Val2)) 0)) Fct, \
348 (Val1, Val2, Val3)) \
349 (__typeof ((__tgmath_real_type (Val1)) 0 \
350 + (__tgmath_real_type (Val2)) 0)) \
351 __tgml(Fct) (Val1, Val2, Val3) \
352 : (sizeof (+(Val1)) == sizeof (double) \
353 || sizeof (+(Val2)) == sizeof (double) \
354 || __builtin_classify_type (Val1) != 8 \
355 || __builtin_classify_type (Val2) != 8) \
356 ? (__typeof ((__tgmath_real_type (Val1)) 0 \
357 + (__tgmath_real_type (Val2)) 0)) \
358 Fct (Val1, Val2, Val3) \
359 : (__typeof ((__tgmath_real_type (Val1)) 0 \
360 + (__tgmath_real_type (Val2)) 0)) \
361 Fct##f (Val1, Val2, Val3)))
362
363# define __TGMATH_TERNARY_REAL_ONLY(Val1, Val2, Val3, Fct) \
364 (__extension__ ((sizeof ((Val1) + (Val2) + (Val3)) > sizeof (double) \
365 && __builtin_classify_type ((Val1) + (Val2) + (Val3)) \
366 == 8) \
367 ? __TGMATH_F128 ((Val1) + (Val2) + (Val3), \
368 (__typeof \
369 ((__tgmath_real_type (Val1)) 0 \
370 + (__tgmath_real_type (Val2)) 0 \
371 + (__tgmath_real_type (Val3)) 0)) Fct, \
372 (Val1, Val2, Val3)) \
373 (__typeof ((__tgmath_real_type (Val1)) 0 \
374 + (__tgmath_real_type (Val2)) 0 \
375 + (__tgmath_real_type (Val3)) 0)) \
376 __tgml(Fct) (Val1, Val2, Val3) \
377 : (sizeof (+(Val1)) == sizeof (double) \
378 || sizeof (+(Val2)) == sizeof (double) \
379 || sizeof (+(Val3)) == sizeof (double) \
380 || __builtin_classify_type (Val1) != 8 \
381 || __builtin_classify_type (Val2) != 8 \
382 || __builtin_classify_type (Val3) != 8) \
383 ? (__typeof ((__tgmath_real_type (Val1)) 0 \
384 + (__tgmath_real_type (Val2)) 0 \
385 + (__tgmath_real_type (Val3)) 0)) \
386 Fct (Val1, Val2, Val3) \
387 : (__typeof ((__tgmath_real_type (Val1)) 0 \
388 + (__tgmath_real_type (Val2)) 0 \
389 + (__tgmath_real_type (Val3)) 0)) \
390 Fct##f (Val1, Val2, Val3)))
391
392# define __TGMATH_TERNARY_FIRST_REAL_RET_ONLY(Val1, Val2, Val3, Fct) \
393 (__extension__ ((sizeof (+(Val1)) == sizeof (double) \
394 || __builtin_classify_type (Val1) != 8) \
395 ? Fct (Val1, Val2, Val3) \
396 : (sizeof (+(Val1)) == sizeof (float)) \
397 ? Fct##f (Val1, Val2, Val3) \
398 : __TGMATH_F128 ((Val1), Fct, (Val1, Val2, Val3)) \
399 __tgml(Fct) (Val1, Val2, Val3)))
400
401/* XXX This definition has to be changed as soon as the compiler understands
402 the imaginary keyword. */
403# define __TGMATH_UNARY_REAL_IMAG(Val, Fct, Cfct) \
404 (__extension__ ((sizeof (+__real__ (Val)) == sizeof (double) \
405 || __builtin_classify_type (__real__ (Val)) != 8) \
406 ? (__expr_is_real (Val) \
407 ? (__tgmath_complex_type (Val)) Fct (Val) \
408 : (__tgmath_complex_type (Val)) Cfct (Val)) \
409 : (sizeof (+__real__ (Val)) == sizeof (float)) \
410 ? (__expr_is_real (Val) \
411 ? (__tgmath_complex_type (Val)) Fct##f (Val) \
412 : (__tgmath_complex_type (Val)) Cfct##f (Val)) \
413 : __TGMATH_CF128 ((Val), \
414 (__tgmath_complex_type (Val)) Fct, \
415 (__tgmath_complex_type (Val)) Cfct, \
416 (Val)) \
417 (__expr_is_real (Val) \
418 ? (__tgmath_complex_type (Val)) __tgml(Fct) (Val) \
419 : (__tgmath_complex_type (Val)) __tgml(Cfct) (Val))))
420
421# define __TGMATH_UNARY_IMAG(Val, Cfct) \
422 (__extension__ ((sizeof (+__real__ (Val)) == sizeof (double) \
423 || __builtin_classify_type (__real__ (Val)) != 8) \
424 ? (__typeof__ ((__tgmath_real_type (Val)) 0 \
425 + _Complex_I)) Cfct (Val) \
426 : (sizeof (+__real__ (Val)) == sizeof (float)) \
427 ? (__typeof__ ((__tgmath_real_type (Val)) 0 \
428 + _Complex_I)) Cfct##f (Val) \
429 : __TGMATH_F128 (__real__ (Val), \
430 (__typeof__ \
431 ((__tgmath_real_type (Val)) 0 \
432 + _Complex_I)) Cfct, (Val)) \
433 (__typeof__ ((__tgmath_real_type (Val)) 0 \
434 + _Complex_I)) __tgml(Cfct) (Val)))
435
436/* XXX This definition has to be changed as soon as the compiler understands
437 the imaginary keyword. */
438# define __TGMATH_UNARY_REAL_IMAG_RET_REAL(Val, Fct, Cfct) \
439 (__extension__ ((sizeof (+__real__ (Val)) == sizeof (double) \
440 || __builtin_classify_type (__real__ (Val)) != 8) \
441 ? (__expr_is_real (Val) \
442 ? (__typeof__ (__real__ (__tgmath_real_type (Val)) 0))\
443 Fct (Val) \
444 : (__typeof__ (__real__ (__tgmath_real_type (Val)) 0))\
445 Cfct (Val)) \
446 : (sizeof (+__real__ (Val)) == sizeof (float)) \
447 ? (__expr_is_real (Val) \
448 ? (__typeof__ (__real__ (__tgmath_real_type (Val)) 0))\
449 Fct##f (Val) \
450 : (__typeof__ (__real__ (__tgmath_real_type (Val)) 0))\
451 Cfct##f (Val)) \
452 : __TGMATH_CF128 ((Val), \
453 (__typeof__ \
454 (__real__ \
455 (__tgmath_real_type (Val)) 0)) Fct, \
456 (__typeof__ \
457 (__real__ \
458 (__tgmath_real_type (Val)) 0)) Cfct, \
459 (Val)) \
460 (__expr_is_real (Val) \
461 ? (__typeof__ (__real__ (__tgmath_real_type (Val)) 0)) \
462 __tgml(Fct) (Val) \
463 : (__typeof__ (__real__ (__tgmath_real_type (Val)) 0)) \
464 __tgml(Cfct) (Val))))
465# define __TGMATH_UNARY_REAL_IMAG_RET_REAL_SAME(Val, Cfct) \
466 __TGMATH_UNARY_REAL_IMAG_RET_REAL ((Val), Cfct, Cfct)
467
468/* XXX This definition has to be changed as soon as the compiler understands
469 the imaginary keyword. */
470# define __TGMATH_BINARY_REAL_IMAG(Val1, Val2, Fct, Cfct) \
471 (__extension__ ((sizeof (__real__ (Val1) \
472 + __real__ (Val2)) > sizeof (double) \
473 && __builtin_classify_type (__real__ (Val1) \
474 + __real__ (Val2)) == 8) \
475 ? __TGMATH_CF128 ((Val1) + (Val2), \
476 (__typeof \
477 ((__tgmath_complex_type (Val1)) 0 \
478 + (__tgmath_complex_type (Val2)) 0)) \
479 Fct, \
480 (__typeof \
481 ((__tgmath_complex_type (Val1)) 0 \
482 + (__tgmath_complex_type (Val2)) 0)) \
483 Cfct, \
484 (Val1, Val2)) \
485 (__expr_is_real ((Val1) + (Val2)) \
486 ? (__typeof ((__tgmath_complex_type (Val1)) 0 \
487 + (__tgmath_complex_type (Val2)) 0)) \
488 __tgml(Fct) (Val1, Val2) \
489 : (__typeof ((__tgmath_complex_type (Val1)) 0 \
490 + (__tgmath_complex_type (Val2)) 0)) \
491 __tgml(Cfct) (Val1, Val2)) \
492 : (sizeof (+__real__ (Val1)) == sizeof (double) \
493 || sizeof (+__real__ (Val2)) == sizeof (double) \
494 || __builtin_classify_type (__real__ (Val1)) != 8 \
495 || __builtin_classify_type (__real__ (Val2)) != 8) \
496 ? (__expr_is_real ((Val1) + (Val2)) \
497 ? (__typeof ((__tgmath_complex_type (Val1)) 0 \
498 + (__tgmath_complex_type (Val2)) 0)) \
499 Fct (Val1, Val2) \
500 : (__typeof ((__tgmath_complex_type (Val1)) 0 \
501 + (__tgmath_complex_type (Val2)) 0)) \
502 Cfct (Val1, Val2)) \
503 : (__expr_is_real ((Val1) + (Val2)) \
504 ? (__typeof ((__tgmath_complex_type (Val1)) 0 \
505 + (__tgmath_complex_type (Val2)) 0)) \
506 Fct##f (Val1, Val2) \
507 : (__typeof ((__tgmath_complex_type (Val1)) 0 \
508 + (__tgmath_complex_type (Val2)) 0)) \
509 Cfct##f (Val1, Val2))))
510# endif /* !__HAVE_BUILTIN_TGMATH. */
511#else
512# error "Unsupported compiler; you cannot use <tgmath.h>"
513#endif
514
515
516/* Unary functions defined for real and complex values. */
517
518
519/* Trigonometric functions. */
520
521/* Arc cosine of X. */
522#define acos(Val) __TGMATH_UNARY_REAL_IMAG (Val, acos, cacos)
523/* Arc sine of X. */
524#define asin(Val) __TGMATH_UNARY_REAL_IMAG (Val, asin, casin)
525/* Arc tangent of X. */
526#define atan(Val) __TGMATH_UNARY_REAL_IMAG (Val, atan, catan)
527/* Arc tangent of Y/X. */
528#define atan2(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, atan2)
529
530/* Cosine of X. */
531#define cos(Val) __TGMATH_UNARY_REAL_IMAG (Val, cos, ccos)
532/* Sine of X. */
533#define sin(Val) __TGMATH_UNARY_REAL_IMAG (Val, sin, csin)
534/* Tangent of X. */
535#define tan(Val) __TGMATH_UNARY_REAL_IMAG (Val, tan, ctan)
536
537
538/* Hyperbolic functions. */
539
540/* Hyperbolic arc cosine of X. */
541#define acosh(Val) __TGMATH_UNARY_REAL_IMAG (Val, acosh, cacosh)
542/* Hyperbolic arc sine of X. */
543#define asinh(Val) __TGMATH_UNARY_REAL_IMAG (Val, asinh, casinh)
544/* Hyperbolic arc tangent of X. */
545#define atanh(Val) __TGMATH_UNARY_REAL_IMAG (Val, atanh, catanh)
546
547/* Hyperbolic cosine of X. */
548#define cosh(Val) __TGMATH_UNARY_REAL_IMAG (Val, cosh, ccosh)
549/* Hyperbolic sine of X. */
550#define sinh(Val) __TGMATH_UNARY_REAL_IMAG (Val, sinh, csinh)
551/* Hyperbolic tangent of X. */
552#define tanh(Val) __TGMATH_UNARY_REAL_IMAG (Val, tanh, ctanh)
553
554
555/* Exponential and logarithmic functions. */
556
557/* Exponential function of X. */
558#define exp(Val) __TGMATH_UNARY_REAL_IMAG (Val, exp, cexp)
559
560/* Break VALUE into a normalized fraction and an integral power of 2. */
561#define frexp(Val1, Val2) __TGMATH_BINARY_FIRST_REAL_ONLY (Val1, Val2, frexp)
562
563/* X times (two to the EXP power). */
564#define ldexp(Val1, Val2) __TGMATH_BINARY_FIRST_REAL_ONLY (Val1, Val2, ldexp)
565
566/* Natural logarithm of X. */
567#define log(Val) __TGMATH_UNARY_REAL_IMAG (Val, log, clog)
568
569/* Base-ten logarithm of X. */
570#ifdef __USE_GNU
571# define log10(Val) __TGMATH_UNARY_REAL_IMAG (Val, log10, clog10)
572#else
573# define log10(Val) __TGMATH_UNARY_REAL_ONLY (Val, log10)
574#endif
575
576/* Return exp(X) - 1. */
577#define expm1(Val) __TGMATH_UNARY_REAL_ONLY (Val, expm1)
578
579/* Return log(1 + X). */
580#define log1p(Val) __TGMATH_UNARY_REAL_ONLY (Val, log1p)
581
582/* Return the base 2 signed integral exponent of X. */
583#define logb(Val) __TGMATH_UNARY_REAL_ONLY (Val, logb)
584
585/* Compute base-2 exponential of X. */
586#define exp2(Val) __TGMATH_UNARY_REAL_ONLY (Val, exp2)
587
588/* Compute base-2 logarithm of X. */
589#define log2(Val) __TGMATH_UNARY_REAL_ONLY (Val, log2)
590
591
592/* Power functions. */
593
594/* Return X to the Y power. */
595#define pow(Val1, Val2) __TGMATH_BINARY_REAL_IMAG (Val1, Val2, pow, cpow)
596
597/* Return the square root of X. */
598#define sqrt(Val) __TGMATH_UNARY_REAL_IMAG (Val, sqrt, csqrt)
599
600/* Return `sqrt(X*X + Y*Y)'. */
601#define hypot(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, hypot)
602
603/* Return the cube root of X. */
604#define cbrt(Val) __TGMATH_UNARY_REAL_ONLY (Val, cbrt)
605
606
607/* Nearest integer, absolute value, and remainder functions. */
608
609/* Smallest integral value not less than X. */
610#define ceil(Val) __TGMATH_UNARY_REAL_ONLY (Val, ceil)
611
612/* Absolute value of X. */
613#define fabs(Val) __TGMATH_UNARY_REAL_IMAG_RET_REAL (Val, fabs, cabs)
614
615/* Largest integer not greater than X. */
616#define floor(Val) __TGMATH_UNARY_REAL_ONLY (Val, floor)
617
618/* Floating-point modulo remainder of X/Y. */
619#define fmod(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, fmod)
620
621/* Round X to integral valuein floating-point format using current
622 rounding direction, but do not raise inexact exception. */
623#define nearbyint(Val) __TGMATH_UNARY_REAL_ONLY (Val, nearbyint)
624
625/* Round X to nearest integral value, rounding halfway cases away from
626 zero. */
627#define round(Val) __TGMATH_UNARY_REAL_ONLY (Val, round)
628
629/* Round X to the integral value in floating-point format nearest but
630 not larger in magnitude. */
631#define trunc(Val) __TGMATH_UNARY_REAL_ONLY (Val, trunc)
632
633/* Compute remainder of X and Y and put in *QUO a value with sign of x/y
634 and magnitude congruent `mod 2^n' to the magnitude of the integral
635 quotient x/y, with n >= 3. */
636#define remquo(Val1, Val2, Val3) \
637 __TGMATH_TERNARY_FIRST_SECOND_REAL_ONLY (Val1, Val2, Val3, remquo)
638
639/* Round X to nearest integral value according to current rounding
640 direction. */
641#define lrint(Val) __TGMATH_UNARY_REAL_RET_ONLY (Val, lrint)
642#define llrint(Val) __TGMATH_UNARY_REAL_RET_ONLY (Val, llrint)
643
644/* Round X to nearest integral value, rounding halfway cases away from
645 zero. */
646#define lround(Val) __TGMATH_UNARY_REAL_RET_ONLY (Val, lround)
647#define llround(Val) __TGMATH_UNARY_REAL_RET_ONLY (Val, llround)
648
649
650/* Return X with its signed changed to Y's. */
651#define copysign(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, copysign)
652
653/* Error and gamma functions. */
654#define erf(Val) __TGMATH_UNARY_REAL_ONLY (Val, erf)
655#define erfc(Val) __TGMATH_UNARY_REAL_ONLY (Val, erfc)
656#define tgamma(Val) __TGMATH_UNARY_REAL_ONLY (Val, tgamma)
657#define lgamma(Val) __TGMATH_UNARY_REAL_ONLY (Val, lgamma)
658
659
660/* Return the integer nearest X in the direction of the
661 prevailing rounding mode. */
662#define rint(Val) __TGMATH_UNARY_REAL_ONLY (Val, rint)
663
664#if __GLIBC_USE (IEC_60559_BFP_EXT)
665/* Return X - epsilon. */
666# define nextdown(Val) __TGMATH_UNARY_REAL_ONLY (Val, nextdown)
667/* Return X + epsilon. */
668# define nextup(Val) __TGMATH_UNARY_REAL_ONLY (Val, nextup)
669#endif
670
671/* Return X + epsilon if X < Y, X - epsilon if X > Y. */
672#define nextafter(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, nextafter)
673#define nexttoward(Val1, Val2) \
674 __TGMATH_BINARY_FIRST_REAL_STD_ONLY (Val1, Val2, nexttoward)
675
676/* Return the remainder of integer divison X / Y with infinite precision. */
677#define remainder(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, remainder)
678
679/* Return X times (2 to the Nth power). */
680#ifdef __USE_MISC
681# define scalb(Val1, Val2) __TGMATH_BINARY_REAL_STD_ONLY (Val1, Val2, scalb)
682#endif
683
684/* Return X times (2 to the Nth power). */
685#define scalbn(Val1, Val2) __TGMATH_BINARY_FIRST_REAL_ONLY (Val1, Val2, scalbn)
686
687/* Return X times (2 to the Nth power). */
688#define scalbln(Val1, Val2) \
689 __TGMATH_BINARY_FIRST_REAL_ONLY (Val1, Val2, scalbln)
690
691/* Return the binary exponent of X, which must be nonzero. */
692#define ilogb(Val) __TGMATH_UNARY_REAL_RET_ONLY (Val, ilogb)
693
694
695/* Return positive difference between X and Y. */
696#define fdim(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, fdim)
697
698/* Return maximum numeric value from X and Y. */
699#define fmax(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, fmax)
700
701/* Return minimum numeric value from X and Y. */
702#define fmin(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, fmin)
703
704
705/* Multiply-add function computed as a ternary operation. */
706#define fma(Val1, Val2, Val3) \
707 __TGMATH_TERNARY_REAL_ONLY (Val1, Val2, Val3, fma)
708
709#if __GLIBC_USE (IEC_60559_BFP_EXT)
710/* Round X to nearest integer value, rounding halfway cases to even. */
711# define roundeven(Val) __TGMATH_UNARY_REAL_ONLY (Val, roundeven)
712
713# define fromfp(Val1, Val2, Val3) \
714 __TGMATH_TERNARY_FIRST_REAL_RET_ONLY (Val1, Val2, Val3, fromfp)
715
716# define ufromfp(Val1, Val2, Val3) \
717 __TGMATH_TERNARY_FIRST_REAL_RET_ONLY (Val1, Val2, Val3, ufromfp)
718
719# define fromfpx(Val1, Val2, Val3) \
720 __TGMATH_TERNARY_FIRST_REAL_RET_ONLY (Val1, Val2, Val3, fromfpx)
721
722# define ufromfpx(Val1, Val2, Val3) \
723 __TGMATH_TERNARY_FIRST_REAL_RET_ONLY (Val1, Val2, Val3, ufromfpx)
724
725/* Like ilogb, but returning long int. */
726# define llogb(Val) __TGMATH_UNARY_REAL_RET_ONLY (Val, llogb)
727
728/* Return value with maximum magnitude. */
729# define fmaxmag(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, fmaxmag)
730
731/* Return value with minimum magnitude. */
732# define fminmag(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, fminmag)
733
734/* Total order operation. */
735# define totalorder(Val1, Val2) \
736 __TGMATH_BINARY_REAL_RET_ONLY (Val1, Val2, totalorder)
737
738/* Total order operation on absolute values. */
739# define totalordermag(Val1, Val2) \
740 __TGMATH_BINARY_REAL_RET_ONLY (Val1, Val2, totalordermag)
741#endif
742
743
744/* Absolute value, conjugates, and projection. */
745
746/* Argument value of Z. */
747#define carg(Val) __TGMATH_UNARY_REAL_IMAG_RET_REAL_SAME (Val, carg)
748
749/* Complex conjugate of Z. */
750#define conj(Val) __TGMATH_UNARY_IMAG (Val, conj)
751
752/* Projection of Z onto the Riemann sphere. */
753#define cproj(Val) __TGMATH_UNARY_IMAG (Val, cproj)
754
755
756/* Decomposing complex values. */
757
758/* Imaginary part of Z. */
759#define cimag(Val) __TGMATH_UNARY_REAL_IMAG_RET_REAL_SAME (Val, cimag)
760
761/* Real part of Z. */
762#define creal(Val) __TGMATH_UNARY_REAL_IMAG_RET_REAL_SAME (Val, creal)
763
764#endif /* tgmath.h */
libc/glibc-include/thread_db.h created+458
...@@ -0,0 +1,458 @@
1/* thread_db.h -- interface to libthread_db.so library for debugging -lpthread
2 Copyright (C) 1999-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _THREAD_DB_H
20#define _THREAD_DB_H 1
21
22/* This is the debugger interface for the NPTL library. It is
23 modelled closely after the interface with same names in Solaris
24 with the goal to share the same code in the debugger. */
25#include <pthread.h>
26#include <stdint.h>
27#include <sys/types.h>
28#include <sys/procfs.h>
29
30
31/* Error codes of the library. */
32typedef enum
33{
34 TD_OK, /* No error. */
35 TD_ERR, /* No further specified error. */
36 TD_NOTHR, /* No matching thread found. */
37 TD_NOSV, /* No matching synchronization handle found. */
38 TD_NOLWP, /* No matching light-weighted process found. */
39 TD_BADPH, /* Invalid process handle. */
40 TD_BADTH, /* Invalid thread handle. */
41 TD_BADSH, /* Invalid synchronization handle. */
42 TD_BADTA, /* Invalid thread agent. */
43 TD_BADKEY, /* Invalid key. */
44 TD_NOMSG, /* No event available. */
45 TD_NOFPREGS, /* No floating-point register content available. */
46 TD_NOLIBTHREAD, /* Application not linked with thread library. */
47 TD_NOEVENT, /* Requested event is not supported. */
48 TD_NOCAPAB, /* Capability not available. */
49 TD_DBERR, /* Internal debug library error. */
50 TD_NOAPLIC, /* Operation is not applicable. */
51 TD_NOTSD, /* No thread-specific data available. */
52 TD_MALLOC, /* Out of memory. */
53 TD_PARTIALREG, /* Not entire register set was read or written. */
54 TD_NOXREGS, /* X register set not available for given thread. */
55 TD_TLSDEFER, /* Thread has not yet allocated TLS for given module. */
56 TD_NOTALLOC = TD_TLSDEFER,
57 TD_VERSION, /* Version if libpthread and libthread_db do not match. */
58 TD_NOTLS /* There is no TLS segment in the given module. */
59} td_err_e;
60
61
62/* Possible thread states. TD_THR_ANY_STATE is a pseudo-state used to
63 select threads regardless of state in td_ta_thr_iter(). */
64typedef enum
65{
66 TD_THR_ANY_STATE,
67 TD_THR_UNKNOWN,
68 TD_THR_STOPPED,
69 TD_THR_RUN,
70 TD_THR_ACTIVE,
71 TD_THR_ZOMBIE,
72 TD_THR_SLEEP,
73 TD_THR_STOPPED_ASLEEP
74} td_thr_state_e;
75
76/* Thread type: user or system. TD_THR_ANY_TYPE is a pseudo-type used
77 to select threads regardless of type in td_ta_thr_iter(). */
78typedef enum
79{
80 TD_THR_ANY_TYPE,
81 TD_THR_USER,
82 TD_THR_SYSTEM
83} td_thr_type_e;
84
85
86/* Types of the debugging library. */
87
88/* Handle for a process. This type is opaque. */
89typedef struct td_thragent td_thragent_t;
90
91/* The actual thread handle type. This is also opaque. */
92typedef struct td_thrhandle
93{
94 td_thragent_t *th_ta_p;
95 psaddr_t th_unique;
96} td_thrhandle_t;
97
98
99/* Forward declaration of a type defined by and for the dynamic linker. */
100struct link_map;
101
102
103/* Flags for `td_ta_thr_iter'. */
104#define TD_THR_ANY_USER_FLAGS 0xffffffff
105#define TD_THR_LOWEST_PRIORITY -20
106#define TD_SIGNO_MASK NULL
107
108
109#define TD_EVENTSIZE 2
110#define BT_UISHIFT 5 /* log base 2 of BT_NBIPUI, to extract word index */
111#define BT_NBIPUI (1 << BT_UISHIFT) /* n bits per unsigned int */
112#define BT_UIMASK (BT_NBIPUI - 1) /* to extract bit index */
113
114/* Bitmask of enabled events. */
115typedef struct td_thr_events
116{
117 uint32_t event_bits[TD_EVENTSIZE];
118} td_thr_events_t;
119
120/* Event set manipulation macros. */
121#define __td_eventmask(n) \
122 (UINT32_C (1) << (((n) - 1) & BT_UIMASK))
123#define __td_eventword(n) \
124 ((UINT32_C ((n) - 1)) >> BT_UISHIFT)
125
126#define td_event_emptyset(setp) \
127 do { \
128 int __i; \
129 for (__i = TD_EVENTSIZE; __i > 0; --__i) \
130 (setp)->event_bits[__i - 1] = 0; \
131 } while (0)
132
133#define td_event_fillset(setp) \
134 do { \
135 int __i; \
136 for (__i = TD_EVENTSIZE; __i > 0; --__i) \
137 (setp)->event_bits[__i - 1] = UINT32_C (0xffffffff); \
138 } while (0)
139
140#define td_event_addset(setp, n) \
141 (((setp)->event_bits[__td_eventword (n)]) |= __td_eventmask (n))
142#define td_event_delset(setp, n) \
143 (((setp)->event_bits[__td_eventword (n)]) &= ~__td_eventmask (n))
144#define td_eventismember(setp, n) \
145 (__td_eventmask (n) & ((setp)->event_bits[__td_eventword (n)]))
146#if TD_EVENTSIZE == 2
147# define td_eventisempty(setp) \
148 (!((setp)->event_bits[0]) && !((setp)->event_bits[1]))
149#else
150# error "td_eventisempty must be changed to match TD_EVENTSIZE"
151#endif
152
153/* Events reportable by the thread implementation. */
154typedef enum
155{
156 TD_ALL_EVENTS, /* Pseudo-event number. */
157 TD_EVENT_NONE = TD_ALL_EVENTS, /* Depends on context. */
158 TD_READY, /* Is executable now. */
159 TD_SLEEP, /* Blocked in a synchronization obj. */
160 TD_SWITCHTO, /* Now assigned to a process. */
161 TD_SWITCHFROM, /* Not anymore assigned to a process. */
162 TD_LOCK_TRY, /* Trying to get an unavailable lock. */
163 TD_CATCHSIG, /* Signal posted to the thread. */
164 TD_IDLE, /* Process getting idle. */
165 TD_CREATE, /* New thread created. */
166 TD_DEATH, /* Thread terminated. */
167 TD_PREEMPT, /* Preempted. */
168 TD_PRI_INHERIT, /* Inherited elevated priority. */
169 TD_REAP, /* Reaped. */
170 TD_CONCURRENCY, /* Number of processes changing. */
171 TD_TIMEOUT, /* Conditional variable wait timed out. */
172 TD_MIN_EVENT_NUM = TD_READY,
173 TD_MAX_EVENT_NUM = TD_TIMEOUT,
174 TD_EVENTS_ENABLE = 31 /* Event reporting enabled. */
175} td_event_e;
176
177/* Values representing the different ways events are reported. */
178typedef enum
179{
180 NOTIFY_BPT, /* User must insert breakpoint at u.bptaddr. */
181 NOTIFY_AUTOBPT, /* Breakpoint at u.bptaddr is automatically
182 inserted. */
183 NOTIFY_SYSCALL /* System call u.syscallno will be invoked. */
184} td_notify_e;
185
186/* Description how event type is reported. */
187typedef struct td_notify
188{
189 td_notify_e type; /* Way the event is reported. */
190 union
191 {
192 psaddr_t bptaddr; /* Address of breakpoint. */
193 int syscallno; /* Number of system call used. */
194 } u;
195} td_notify_t;
196
197/* Structure used to report event. */
198typedef struct td_event_msg
199{
200 td_event_e event; /* Event type being reported. */
201 const td_thrhandle_t *th_p; /* Thread reporting the event. */
202 union
203 {
204# if 0
205 td_synchandle_t *sh; /* Handle of synchronization object. */
206#endif
207 uintptr_t data; /* Event specific data. */
208 } msg;
209} td_event_msg_t;
210
211/* Structure containing event data available in each thread structure. */
212typedef struct
213{
214 td_thr_events_t eventmask; /* Mask of enabled events. */
215 td_event_e eventnum; /* Number of last event. */
216 void *eventdata; /* Data associated with event. */
217} td_eventbuf_t;
218
219
220/* Gathered statistics about the process. */
221typedef struct td_ta_stats
222{
223 int nthreads; /* Total number of threads in use. */
224 int r_concurrency; /* Concurrency level requested by user. */
225 int nrunnable_num; /* Average runnable threads, numerator. */
226 int nrunnable_den; /* Average runnable threads, denominator. */
227 int a_concurrency_num; /* Achieved concurrency level, numerator. */
228 int a_concurrency_den; /* Achieved concurrency level, denominator. */
229 int nlwps_num; /* Average number of processes in use,
230 numerator. */
231 int nlwps_den; /* Average number of processes in use,
232 denominator. */
233 int nidle_num; /* Average number of idling processes,
234 numerator. */
235 int nidle_den; /* Average number of idling processes,
236 denominator. */
237} td_ta_stats_t;
238
239
240/* Since Sun's library is based on Solaris threads we have to define a few
241 types to map them to POSIX threads. */
242typedef pthread_t thread_t;
243typedef pthread_key_t thread_key_t;
244
245
246/* Callback for iteration over threads. */
247typedef int td_thr_iter_f (const td_thrhandle_t *, void *);
248
249/* Callback for iteration over thread local data. */
250typedef int td_key_iter_f (thread_key_t, void (*) (void *), void *);
251
252
253
254/* Forward declaration. This has to be defined by the user. */
255struct ps_prochandle;
256
257
258/* Information about the thread. */
259typedef struct td_thrinfo
260{
261 td_thragent_t *ti_ta_p; /* Process handle. */
262 unsigned int ti_user_flags; /* Unused. */
263 thread_t ti_tid; /* Thread ID returned by
264 pthread_create(). */
265 char *ti_tls; /* Pointer to thread-local data. */
266 psaddr_t ti_startfunc; /* Start function passed to
267 pthread_create(). */
268 psaddr_t ti_stkbase; /* Base of thread's stack. */
269 long int ti_stksize; /* Size of thread's stack. */
270 psaddr_t ti_ro_area; /* Unused. */
271 int ti_ro_size; /* Unused. */
272 td_thr_state_e ti_state; /* Thread state. */
273 unsigned char ti_db_suspended; /* Nonzero if suspended by debugger. */
274 td_thr_type_e ti_type; /* Type of the thread (system vs
275 user thread). */
276 intptr_t ti_pc; /* Unused. */
277 intptr_t ti_sp; /* Unused. */
278 short int ti_flags; /* Unused. */
279 int ti_pri; /* Thread priority. */
280 lwpid_t ti_lid; /* Kernel PID for this thread. */
281 sigset_t ti_sigmask; /* Signal mask. */
282 unsigned char ti_traceme; /* Nonzero if event reporting
283 enabled. */
284 unsigned char ti_preemptflag; /* Unused. */
285 unsigned char ti_pirecflag; /* Unused. */
286 sigset_t ti_pending; /* Set of pending signals. */
287 td_thr_events_t ti_events; /* Set of enabled events. */
288} td_thrinfo_t;
289
290
291
292/* Prototypes for exported library functions. */
293
294/* Initialize the thread debug support library. */
295extern td_err_e td_init (void);
296
297/* Historical relict. Should not be used anymore. */
298extern td_err_e td_log (void);
299
300/* Return list of symbols the library can request. */
301extern const char **td_symbol_list (void);
302
303/* Generate new thread debug library handle for process PS. */
304extern td_err_e td_ta_new (struct ps_prochandle *__ps, td_thragent_t **__ta);
305
306/* Free resources allocated for TA. */
307extern td_err_e td_ta_delete (td_thragent_t *__ta);
308
309/* Get number of currently running threads in process associated with TA. */
310extern td_err_e td_ta_get_nthreads (const td_thragent_t *__ta, int *__np);
311
312/* Return process handle passed in `td_ta_new' for process associated with
313 TA. */
314extern td_err_e td_ta_get_ph (const td_thragent_t *__ta,
315 struct ps_prochandle **__ph);
316
317/* Map thread library handle PT to thread debug library handle for process
318 associated with TA and store result in *TH. */
319extern td_err_e td_ta_map_id2thr (const td_thragent_t *__ta, pthread_t __pt,
320 td_thrhandle_t *__th);
321
322/* Map process ID LWPID to thread debug library handle for process
323 associated with TA and store result in *TH. */
324extern td_err_e td_ta_map_lwp2thr (const td_thragent_t *__ta, lwpid_t __lwpid,
325 td_thrhandle_t *__th);
326
327
328/* Call for each thread in a process associated with TA the callback function
329 CALLBACK. */
330extern td_err_e td_ta_thr_iter (const td_thragent_t *__ta,
331 td_thr_iter_f *__callback, void *__cbdata_p,
332 td_thr_state_e __state, int __ti_pri,
333 sigset_t *__ti_sigmask_p,
334 unsigned int __ti_user_flags);
335
336/* Call for each defined thread local data entry the callback function KI. */
337extern td_err_e td_ta_tsd_iter (const td_thragent_t *__ta, td_key_iter_f *__ki,
338 void *__p);
339
340
341/* Get event address for EVENT. */
342extern td_err_e td_ta_event_addr (const td_thragent_t *__ta,
343 td_event_e __event, td_notify_t *__ptr);
344
345/* Enable EVENT in global mask. */
346extern td_err_e td_ta_set_event (const td_thragent_t *__ta,
347 td_thr_events_t *__event);
348
349/* Disable EVENT in global mask. */
350extern td_err_e td_ta_clear_event (const td_thragent_t *__ta,
351 td_thr_events_t *__event);
352
353/* Return information about last event. */
354extern td_err_e td_ta_event_getmsg (const td_thragent_t *__ta,
355 td_event_msg_t *__msg);
356
357
358/* Set suggested concurrency level for process associated with TA. */
359extern td_err_e td_ta_setconcurrency (const td_thragent_t *__ta, int __level);
360
361
362/* Enable collecting statistics for process associated with TA. */
363extern td_err_e td_ta_enable_stats (const td_thragent_t *__ta, int __enable);
364
365/* Reset statistics. */
366extern td_err_e td_ta_reset_stats (const td_thragent_t *__ta);
367
368/* Retrieve statistics from process associated with TA. */
369extern td_err_e td_ta_get_stats (const td_thragent_t *__ta,
370 td_ta_stats_t *__statsp);
371
372
373/* Validate that TH is a thread handle. */
374extern td_err_e td_thr_validate (const td_thrhandle_t *__th);
375
376/* Return information about thread TH. */
377extern td_err_e td_thr_get_info (const td_thrhandle_t *__th,
378 td_thrinfo_t *__infop);
379
380/* Retrieve floating-point register contents of process running thread TH. */
381extern td_err_e td_thr_getfpregs (const td_thrhandle_t *__th,
382 prfpregset_t *__regset);
383
384/* Retrieve general register contents of process running thread TH. */
385extern td_err_e td_thr_getgregs (const td_thrhandle_t *__th,
386 prgregset_t __gregs);
387
388/* Retrieve extended register contents of process running thread TH. */
389extern td_err_e td_thr_getxregs (const td_thrhandle_t *__th, void *__xregs);
390
391/* Get size of extended register set of process running thread TH. */
392extern td_err_e td_thr_getxregsize (const td_thrhandle_t *__th, int *__sizep);
393
394/* Set floating-point register contents of process running thread TH. */
395extern td_err_e td_thr_setfpregs (const td_thrhandle_t *__th,
396 const prfpregset_t *__fpregs);
397
398/* Set general register contents of process running thread TH. */
399extern td_err_e td_thr_setgregs (const td_thrhandle_t *__th,
400 prgregset_t __gregs);
401
402/* Set extended register contents of process running thread TH. */
403extern td_err_e td_thr_setxregs (const td_thrhandle_t *__th,
404 const void *__addr);
405
406
407/* Get address of the given module's TLS storage area for the given thread. */
408extern td_err_e td_thr_tlsbase (const td_thrhandle_t *__th,
409 unsigned long int __modid,
410 psaddr_t *__base);
411
412/* Get address of thread local variable. */
413extern td_err_e td_thr_tls_get_addr (const td_thrhandle_t *__th,
414 psaddr_t __map_address, size_t __offset,
415 psaddr_t *__address);
416
417
418/* Enable reporting for EVENT for thread TH. */
419extern td_err_e td_thr_event_enable (const td_thrhandle_t *__th, int __event);
420
421/* Enable EVENT for thread TH. */
422extern td_err_e td_thr_set_event (const td_thrhandle_t *__th,
423 td_thr_events_t *__event);
424
425/* Disable EVENT for thread TH. */
426extern td_err_e td_thr_clear_event (const td_thrhandle_t *__th,
427 td_thr_events_t *__event);
428
429/* Get event message for thread TH. */
430extern td_err_e td_thr_event_getmsg (const td_thrhandle_t *__th,
431 td_event_msg_t *__msg);
432
433
434/* Set priority of thread TH. */
435extern td_err_e td_thr_setprio (const td_thrhandle_t *__th, int __prio);
436
437
438/* Set pending signals for thread TH. */
439extern td_err_e td_thr_setsigpending (const td_thrhandle_t *__th,
440 unsigned char __n, const sigset_t *__ss);
441
442/* Set signal mask for thread TH. */
443extern td_err_e td_thr_sigsetmask (const td_thrhandle_t *__th,
444 const sigset_t *__ss);
445
446
447/* Return thread local data associated with key TK in thread TH. */
448extern td_err_e td_thr_tsd (const td_thrhandle_t *__th,
449 const thread_key_t __tk, void **__data);
450
451
452/* Suspend execution of thread TH. */
453extern td_err_e td_thr_dbsuspend (const td_thrhandle_t *__th);
454
455/* Resume execution of thread TH. */
456extern td_err_e td_thr_dbresume (const td_thrhandle_t *__th);
457
458#endif /* thread_db.h */
libc/glibc-include/threads.h created+207
...@@ -0,0 +1,207 @@
1/* ISO C11 Standard: 7.26 - Thread support library <threads.h>.
2 Copyright (C) 2018-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _THREADS_H
20#define _THREADS_H 1
21
22#include <features.h>
23#include <time.h>
24
25__BEGIN_DECLS
26
27#include <bits/pthreadtypes-arch.h>
28#include <bits/types/struct_timespec.h>
29
30#ifndef __cplusplus
31# define thread_local _Thread_local
32#endif
33
34#define TSS_DTOR_ITERATIONS 4
35typedef unsigned int tss_t;
36typedef void (*tss_dtor_t) (void*);
37
38typedef unsigned long int thrd_t;
39typedef int (*thrd_start_t) (void*);
40
41/* Exit and error codes. */
42enum
43{
44 thrd_success = 0,
45 thrd_busy = 1,
46 thrd_error = 2,
47 thrd_nomem = 3,
48 thrd_timedout = 4
49};
50
51/* Mutex types. */
52enum
53{
54 mtx_plain = 0,
55 mtx_recursive = 1,
56 mtx_timed = 2
57};
58
59typedef struct
60{
61 int __data __ONCE_ALIGNMENT;
62} once_flag;
63#define ONCE_FLAG_INIT { 0 }
64
65typedef union
66{
67 char __size[__SIZEOF_PTHREAD_MUTEX_T];
68 long int __align __LOCK_ALIGNMENT;
69} mtx_t;
70
71typedef union
72{
73 char __size[__SIZEOF_PTHREAD_COND_T];
74 __extension__ long long int __align __LOCK_ALIGNMENT;
75} cnd_t;
76
77/* Threads functions. */
78
79/* Create a new thread executing the function __FUNC. Arguments for __FUNC
80 are passed through __ARG. If succesful, __THR is set to new thread
81 identifier. */
82extern int thrd_create (thrd_t *__thr, thrd_start_t __func, void *__arg);
83
84/* Check if __LHS and __RHS point to the same thread. */
85extern int thrd_equal (thrd_t __lhs, thrd_t __rhs);
86
87/* Return current thread identifier. */
88extern thrd_t thrd_current (void);
89
90/* Block current thread execution for at least the time pointed by
91 __TIME_POINT. The current thread may resume if receives a signal. In
92 that case, if __REMAINING is not NULL, the remaining time is stored in
93 the object pointed by it. */
94extern int thrd_sleep (const struct timespec *__time_point,
95 struct timespec *__remaining);
96
97/* Terminate current thread execution, cleaning up any thread local
98 storage and freeing resources. Returns the value specified in __RES. */
99extern void thrd_exit (int __res) __attribute__ ((__noreturn__));
100
101/* Detach the thread identified by __THR from the current environment
102 (it does not allow join or wait for it). */
103extern int thrd_detach (thrd_t __thr);
104
105/* Block current thread until execution of __THR is complete. In case that
106 __RES is not NULL, will store the return value of __THR when exiting. */
107extern int thrd_join (thrd_t __thr, int *__res);
108
109/* Stop current thread execution and call the scheduler to decide which
110 thread should execute next. The current thread may be selected by the
111 scheduler to keep running. */
112extern void thrd_yield (void);
113
114#ifdef __USE_EXTERN_INLINES
115/* Optimizations. */
116__extern_inline int
117thrd_equal (thrd_t __thread1, thrd_t __thread2)
118{
119 return __thread1 == __thread2;
120}
121#endif
122
123
124/* Mutex functions. */
125
126/* Creates a new mutex object with type __TYPE. If successful the new
127 object is pointed by __MUTEX. */
128extern int mtx_init (mtx_t *__mutex, int __type);
129
130/* Block the current thread until the mutex pointed to by __MUTEX is
131 unlocked. In that case current thread will not be blocked. */
132extern int mtx_lock (mtx_t *__mutex);
133
134/* Block the current thread until the mutex pointed by __MUTEX is unlocked
135 or time pointed by __TIME_POINT is reached. In case the mutex is unlock,
136 the current thread will not be blocked. */
137extern int mtx_timedlock (mtx_t *__restrict __mutex,
138 const struct timespec *__restrict __time_point);
139
140/* Try to lock the mutex pointed by __MUTEX without blocking. If the mutex
141 is free the current threads takes control of it, otherwise it returns
142 immediately. */
143extern int mtx_trylock (mtx_t *__mutex);
144
145/* Unlock the mutex pointed by __MUTEX. It may potentially awake other
146 threads waiting on this mutex. */
147extern int mtx_unlock (mtx_t *__mutex);
148
149/* Destroy the mutex object pointed by __MUTEX. */
150extern void mtx_destroy (mtx_t *__mutex);
151
152
153/* Call function __FUNC exactly once, even if invoked from several threads.
154 All calls must be made with the same __FLAGS object. */
155extern void call_once (once_flag *__flag, void (*__func)(void));
156
157
158/* Condition variable functions. */
159
160/* Initialize new condition variable pointed by __COND. */
161extern int cnd_init (cnd_t *__cond);
162
163/* Unblock one thread that currently waits on condition variable pointed
164 by __COND. */
165extern int cnd_signal (cnd_t *__cond);
166
167/* Unblock all threads currently waiting on condition variable pointed by
168 __COND. */
169extern int cnd_broadcast (cnd_t *__cond);
170
171/* Block current thread on the condition variable pointed by __COND. */
172extern int cnd_wait (cnd_t *__cond, mtx_t *__mutex);
173
174/* Block current thread on the condition variable until condition variable
175 pointed by __COND is signaled or time pointed by __TIME_POINT is
176 reached. */
177extern int cnd_timedwait (cnd_t *__restrict __cond,
178 mtx_t *__restrict __mutex,
179 const struct timespec *__restrict __time_point);
180
181/* Destroy condition variable pointed by __cond and free all of its
182 resources. */
183extern void cnd_destroy (cnd_t *__COND);
184
185
186/* Thread specific storage functions. */
187
188/* Create new thread-specific storage key and stores it in the object pointed
189 by __TSS_ID. If __DESTRUCTOR is not NULL, the function will be called when
190 the thread terminates. */
191extern int tss_create (tss_t *__tss_id, tss_dtor_t __destructor);
192
193/* Return the value held in thread-specific storage for the current thread
194 identified by __TSS_ID. */
195extern void *tss_get (tss_t __tss_id);
196
197/* Sets the value of the thread-specific storage identified by __TSS_ID for
198 the current thread to __VAL. */
199extern int tss_set (tss_t __tss_id, void *__val);
200
201/* Destroys the thread-specific storage identified by __TSS_ID. The
202 destructor is not called until thrd_exit is called. */
203extern void tss_delete (tss_t __tss_id);
204
205__END_DECLS
206
207#endif /* _THREADS_H */
libc/glibc-include/time.h created+309
...@@ -0,0 +1,309 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/*
19 * ISO C99 Standard: 7.23 Date and time <time.h>
20 */
21
22#ifndef _TIME_H
23#define _TIME_H 1
24
25#include <features.h>
26
27#define __need_size_t
28#define __need_NULL
29#include <stddef.h>
30
31/* This defines CLOCKS_PER_SEC, which is the number of processor clock
32 ticks per second, and possibly a number of other constants. */
33#include <bits/time.h>
34
35/* Many of the typedefs and structs whose official home is this header
36 may also need to be defined by other headers. */
37#include <bits/types/clock_t.h>
38#include <bits/types/time_t.h>
39#include <bits/types/struct_tm.h>
40
41#if defined __USE_POSIX199309 || defined __USE_ISOC11
42# include <bits/types/struct_timespec.h>
43#endif
44
45#ifdef __USE_POSIX199309
46# include <bits/types/clockid_t.h>
47# include <bits/types/timer_t.h>
48# include <bits/types/struct_itimerspec.h>
49struct sigevent;
50#endif
51
52#ifdef __USE_XOPEN2K
53# ifndef __pid_t_defined
54typedef __pid_t pid_t;
55# define __pid_t_defined
56# endif
57#endif
58
59#ifdef __USE_XOPEN2K8
60# include <bits/types/locale_t.h>
61#endif
62
63#ifdef __USE_ISOC11
64/* Time base values for timespec_get. */
65# define TIME_UTC 1
66#endif
67
68__BEGIN_DECLS
69
70/* Time used by the program so far (user time + system time).
71 The result / CLOCKS_PER_SEC is program time in seconds. */
72extern clock_t clock (void) __THROW;
73
74/* Return the current time and put it in *TIMER if TIMER is not NULL. */
75extern time_t time (time_t *__timer) __THROW;
76
77/* Return the difference between TIME1 and TIME0. */
78extern double difftime (time_t __time1, time_t __time0)
79 __THROW __attribute__ ((__const__));
80
81/* Return the `time_t' representation of TP and normalize TP. */
82extern time_t mktime (struct tm *__tp) __THROW;
83
84
85/* Format TP into S according to FORMAT.
86 Write no more than MAXSIZE characters and return the number
87 of characters written, or 0 if it would exceed MAXSIZE. */
88extern size_t strftime (char *__restrict __s, size_t __maxsize,
89 const char *__restrict __format,
90 const struct tm *__restrict __tp) __THROW;
91
92#ifdef __USE_XOPEN
93/* Parse S according to FORMAT and store binary time information in TP.
94 The return value is a pointer to the first unparsed character in S. */
95extern char *strptime (const char *__restrict __s,
96 const char *__restrict __fmt, struct tm *__tp)
97 __THROW;
98#endif
99
100#ifdef __USE_XOPEN2K8
101/* Similar to the two functions above but take the information from
102 the provided locale and not the global locale. */
103
104extern size_t strftime_l (char *__restrict __s, size_t __maxsize,
105 const char *__restrict __format,
106 const struct tm *__restrict __tp,
107 locale_t __loc) __THROW;
108#endif
109
110#ifdef __USE_GNU
111extern char *strptime_l (const char *__restrict __s,
112 const char *__restrict __fmt, struct tm *__tp,
113 locale_t __loc) __THROW;
114#endif
115
116
117/* Return the `struct tm' representation of *TIMER
118 in Universal Coordinated Time (aka Greenwich Mean Time). */
119extern struct tm *gmtime (const time_t *__timer) __THROW;
120
121/* Return the `struct tm' representation
122 of *TIMER in the local timezone. */
123extern struct tm *localtime (const time_t *__timer) __THROW;
124
125#ifdef __USE_POSIX
126/* Return the `struct tm' representation of *TIMER in UTC,
127 using *TP to store the result. */
128extern struct tm *gmtime_r (const time_t *__restrict __timer,
129 struct tm *__restrict __tp) __THROW;
130
131/* Return the `struct tm' representation of *TIMER in local time,
132 using *TP to store the result. */
133extern struct tm *localtime_r (const time_t *__restrict __timer,
134 struct tm *__restrict __tp) __THROW;
135#endif /* POSIX */
136
137/* Return a string of the form "Day Mon dd hh:mm:ss yyyy\n"
138 that is the representation of TP in this format. */
139extern char *asctime (const struct tm *__tp) __THROW;
140
141/* Equivalent to `asctime (localtime (timer))'. */
142extern char *ctime (const time_t *__timer) __THROW;
143
144#ifdef __USE_POSIX
145/* Reentrant versions of the above functions. */
146
147/* Return in BUF a string of the form "Day Mon dd hh:mm:ss yyyy\n"
148 that is the representation of TP in this format. */
149extern char *asctime_r (const struct tm *__restrict __tp,
150 char *__restrict __buf) __THROW;
151
152/* Equivalent to `asctime_r (localtime_r (timer, *TMP*), buf)'. */
153extern char *ctime_r (const time_t *__restrict __timer,
154 char *__restrict __buf) __THROW;
155#endif /* POSIX */
156
157
158/* Defined in localtime.c. */
159extern char *__tzname[2]; /* Current timezone names. */
160extern int __daylight; /* If daylight-saving time is ever in use. */
161extern long int __timezone; /* Seconds west of UTC. */
162
163
164#ifdef __USE_POSIX
165/* Same as above. */
166extern char *tzname[2];
167
168/* Set time conversion information from the TZ environment variable.
169 If TZ is not defined, a locale-dependent default is used. */
170extern void tzset (void) __THROW;
171#endif
172
173#if defined __USE_MISC || defined __USE_XOPEN
174extern int daylight;
175extern long int timezone;
176#endif
177
178#ifdef __USE_MISC
179/* Set the system time to *WHEN.
180 This call is restricted to the superuser. */
181extern int stime (const time_t *__when) __THROW;
182#endif
183
184
185/* Nonzero if YEAR is a leap year (every 4 years,
186 except every 100th isn't, and every 400th is). */
187#define __isleap(year) \
188 ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0))
189
190
191#ifdef __USE_MISC
192/* Miscellaneous functions many Unices inherited from the public domain
193 localtime package. These are included only for compatibility. */
194
195/* Like `mktime', but for TP represents Universal Time, not local time. */
196extern time_t timegm (struct tm *__tp) __THROW;
197
198/* Another name for `mktime'. */
199extern time_t timelocal (struct tm *__tp) __THROW;
200
201/* Return the number of days in YEAR. */
202extern int dysize (int __year) __THROW __attribute__ ((__const__));
203#endif
204
205
206#ifdef __USE_POSIX199309
207/* Pause execution for a number of nanoseconds.
208
209 This function is a cancellation point and therefore not marked with
210 __THROW. */
211extern int nanosleep (const struct timespec *__requested_time,
212 struct timespec *__remaining);
213
214
215/* Get resolution of clock CLOCK_ID. */
216extern int clock_getres (clockid_t __clock_id, struct timespec *__res) __THROW;
217
218/* Get current value of clock CLOCK_ID and store it in TP. */
219extern int clock_gettime (clockid_t __clock_id, struct timespec *__tp) __THROW;
220
221/* Set clock CLOCK_ID to value TP. */
222extern int clock_settime (clockid_t __clock_id, const struct timespec *__tp)
223 __THROW;
224
225# ifdef __USE_XOPEN2K
226/* High-resolution sleep with the specified clock.
227
228 This function is a cancellation point and therefore not marked with
229 __THROW. */
230extern int clock_nanosleep (clockid_t __clock_id, int __flags,
231 const struct timespec *__req,
232 struct timespec *__rem);
233
234/* Return clock ID for CPU-time clock. */
235extern int clock_getcpuclockid (pid_t __pid, clockid_t *__clock_id) __THROW;
236# endif
237
238
239/* Create new per-process timer using CLOCK_ID. */
240extern int timer_create (clockid_t __clock_id,
241 struct sigevent *__restrict __evp,
242 timer_t *__restrict __timerid) __THROW;
243
244/* Delete timer TIMERID. */
245extern int timer_delete (timer_t __timerid) __THROW;
246
247/* Set timer TIMERID to VALUE, returning old value in OVALUE. */
248extern int timer_settime (timer_t __timerid, int __flags,
249 const struct itimerspec *__restrict __value,
250 struct itimerspec *__restrict __ovalue) __THROW;
251
252/* Get current value of timer TIMERID and store it in VALUE. */
253extern int timer_gettime (timer_t __timerid, struct itimerspec *__value)
254 __THROW;
255
256/* Get expiration overrun for timer TIMERID. */
257extern int timer_getoverrun (timer_t __timerid) __THROW;
258#endif
259
260
261#ifdef __USE_ISOC11
262/* Set TS to calendar time based in time base BASE. */
263extern int timespec_get (struct timespec *__ts, int __base)
264 __THROW __nonnull ((1));
265#endif
266
267
268#ifdef __USE_XOPEN_EXTENDED
269/* Set to one of the following values to indicate an error.
270 1 the DATEMSK environment variable is null or undefined,
271 2 the template file cannot be opened for reading,
272 3 failed to get file status information,
273 4 the template file is not a regular file,
274 5 an error is encountered while reading the template file,
275 6 memory allication failed (not enough memory available),
276 7 there is no line in the template that matches the input,
277 8 invalid input specification Example: February 31 or a time is
278 specified that can not be represented in a time_t (representing
279 the time in seconds since 00:00:00 UTC, January 1, 1970) */
280extern int getdate_err;
281
282/* Parse the given string as a date specification and return a value
283 representing the value. The templates from the file identified by
284 the environment variable DATEMSK are used. In case of an error
285 `getdate_err' is set.
286
287 This function is a possible cancellation point and therefore not
288 marked with __THROW. */
289extern struct tm *getdate (const char *__string);
290#endif
291
292#ifdef __USE_GNU
293/* Since `getdate' is not reentrant because of the use of `getdate_err'
294 and the static buffer to return the result in, we provide a thread-safe
295 variant. The functionality is the same. The result is returned in
296 the buffer pointed to by RESBUFP and in case of an error the return
297 value is != 0 with the same values as given above for `getdate_err'.
298
299 This function is not part of POSIX and therefore no official
300 cancellation point. But due to similarity with an POSIX interface
301 or due to the implementation it is a cancellation point and
302 therefore not marked with __THROW. */
303extern int getdate_r (const char *__restrict __string,
304 struct tm *__restrict __resbufp);
305#endif
306
307__END_DECLS
308
309#endif /* time.h. */
libc/glibc-include/ttyent.h created+65
...@@ -0,0 +1,65 @@
1/*
2 * Copyright (c) 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 4. Neither the name of the University nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * @(#)ttyent.h 8.1 (Berkeley) 6/2/93
30 */
31
32#ifndef _TTYENT_H
33#define _TTYENT_H 1
34
35#include <features.h>
36
37#define _PATH_TTYS "/etc/ttys"
38
39#define _TTYS_OFF "off"
40#define _TTYS_ON "on"
41#define _TTYS_SECURE "secure"
42#define _TTYS_WINDOW "window"
43
44struct ttyent {
45 char *ty_name; /* terminal device name */
46 char *ty_getty; /* command to execute, usually getty */
47 char *ty_type; /* terminal type for termcap */
48#define TTY_ON 0x01 /* enable logins (start ty_getty program) */
49#define TTY_SECURE 0x02 /* allow uid of 0 to login */
50 int ty_status; /* status flags */
51 char *ty_window; /* command to start up window manager */
52 char *ty_comment; /* comment field */
53};
54
55
56__BEGIN_DECLS
57
58extern struct ttyent *getttyent (void) __THROW;
59extern struct ttyent *getttynam (const char *__tty) __THROW;
60extern int setttyent (void) __THROW;
61extern int endttyent (void) __THROW;
62
63__END_DECLS
64
65#endif /* ttyent.h */
libc/glibc-include/uchar.h created+67
...@@ -0,0 +1,67 @@
1/* Copyright (C) 2011-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/*
19 * ISO C11 Standard: 7.28
20 * Unicode utilities <uchar.h>
21 */
22
23#ifndef _UCHAR_H
24#define _UCHAR_H 1
25
26#include <features.h>
27
28#define __need_size_t
29#include <stddef.h>
30
31#include <bits/types.h>
32#include <bits/types/mbstate_t.h>
33
34#ifndef __USE_ISOCXX11
35/* Define the 16-bit and 32-bit character types. */
36typedef __uint_least16_t char16_t;
37typedef __uint_least32_t char32_t;
38#endif
39
40
41__BEGIN_DECLS
42
43/* Write char16_t representation of multibyte character pointed
44 to by S to PC16. */
45extern size_t mbrtoc16 (char16_t *__restrict __pc16,
46 const char *__restrict __s, size_t __n,
47 mbstate_t *__restrict __p) __THROW;
48
49/* Write multibyte representation of char16_t C16 to S. */
50extern size_t c16rtomb (char *__restrict __s, char16_t __c16,
51 mbstate_t *__restrict __ps) __THROW;
52
53
54
55/* Write char32_t representation of multibyte character pointed
56 to by S to PC32. */
57extern size_t mbrtoc32 (char32_t *__restrict __pc32,
58 const char *__restrict __s, size_t __n,
59 mbstate_t *__restrict __p) __THROW;
60
61/* Write multibyte representation of char32_t C32 to S. */
62extern size_t c32rtomb (char *__restrict __s, char32_t __c32,
63 mbstate_t *__restrict __ps) __THROW;
64
65__END_DECLS
66
67#endif /* uchar.h */
libc/glibc-include/ucontext.h created+56
...@@ -0,0 +1,56 @@
1/* Copyright (C) 1997-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/* System V ABI compliant user-level context switching support. */
19
20#ifndef _UCONTEXT_H
21#define _UCONTEXT_H 1
22
23#include <features.h>
24
25/* Get definition of __INDIRECT_RETURN. */
26#include <bits/indirect-return.h>
27
28/* Get machine dependent definition of data structures. */
29#include <sys/ucontext.h>
30
31__BEGIN_DECLS
32
33/* Get user context and store it in variable pointed to by UCP. */
34extern int getcontext (ucontext_t *__ucp) __THROWNL;
35
36/* Set user context from information of variable pointed to by UCP. */
37extern int setcontext (const ucontext_t *__ucp) __THROWNL;
38
39/* Save current context in context variable pointed to by OUCP and set
40 context from variable pointed to by UCP. */
41extern int swapcontext (ucontext_t *__restrict __oucp,
42 const ucontext_t *__restrict __ucp)
43 __THROWNL __INDIRECT_RETURN;
44
45/* Manipulate user context UCP to continue with calling functions FUNC
46 and the ARGC-1 parameters following ARGC when the context is used
47 the next time in `setcontext' or `swapcontext'.
48
49 We cannot say anything about the parameters FUNC takes; `void'
50 is as good as any other choice. */
51extern void makecontext (ucontext_t *__ucp, void (*__func) (void),
52 int __argc, ...) __THROW;
53
54__END_DECLS
55
56#endif /* ucontext.h */
libc/glibc-include/ulimit.h created+47
...@@ -0,0 +1,47 @@
1/* Copyright (C) 1997-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _ULIMIT_H
19#define _ULIMIT_H 1
20
21#include <features.h>
22
23/* Constants used as the first parameter for `ulimit'. They denote limits
24 which can be set or retrieved using this function. */
25enum
26{
27 UL_GETFSIZE = 1, /* Return limit on the size of a file,
28 in units of 512 bytes. */
29#define UL_GETFSIZE UL_GETFSIZE
30 UL_SETFSIZE, /* Set limit on the size of a file to
31 second argument. */
32#define UL_SETFSIZE UL_SETFSIZE
33 __UL_GETMAXBRK, /* Return the maximum possible address
34 of the data segment. */
35 __UL_GETOPENMAX /* Return the maximum number of files
36 that the calling process can open.*/
37};
38
39
40__BEGIN_DECLS
41
42/* Control process limits according to CMD. */
43extern long int ulimit (int __cmd, ...) __THROW;
44
45__END_DECLS
46
47#endif /* ulimit.h */
libc/glibc-include/unistd.h created+1171
...@@ -0,0 +1,1171 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/*
19 * POSIX Standard: 2.10 Symbolic Constants <unistd.h>
20 */
21
22#ifndef _UNISTD_H
23#define _UNISTD_H 1
24
25#include <features.h>
26
27__BEGIN_DECLS
28
29/* These may be used to determine what facilities are present at compile time.
30 Their values can be obtained at run time from `sysconf'. */
31
32#ifdef __USE_XOPEN2K8
33/* POSIX Standard approved as ISO/IEC 9945-1 as of September 2008. */
34# define _POSIX_VERSION 200809L
35#elif defined __USE_XOPEN2K
36/* POSIX Standard approved as ISO/IEC 9945-1 as of December 2001. */
37# define _POSIX_VERSION 200112L
38#elif defined __USE_POSIX199506
39/* POSIX Standard approved as ISO/IEC 9945-1 as of June 1995. */
40# define _POSIX_VERSION 199506L
41#elif defined __USE_POSIX199309
42/* POSIX Standard approved as ISO/IEC 9945-1 as of September 1993. */
43# define _POSIX_VERSION 199309L
44#else
45/* POSIX Standard approved as ISO/IEC 9945-1 as of September 1990. */
46# define _POSIX_VERSION 199009L
47#endif
48
49/* These are not #ifdef __USE_POSIX2 because they are
50 in the theoretically application-owned namespace. */
51
52#ifdef __USE_XOPEN2K8
53# define __POSIX2_THIS_VERSION 200809L
54/* The utilities on GNU systems also correspond to this version. */
55#elif defined __USE_XOPEN2K
56/* The utilities on GNU systems also correspond to this version. */
57# define __POSIX2_THIS_VERSION 200112L
58#elif defined __USE_POSIX199506
59/* The utilities on GNU systems also correspond to this version. */
60# define __POSIX2_THIS_VERSION 199506L
61#else
62/* The utilities on GNU systems also correspond to this version. */
63# define __POSIX2_THIS_VERSION 199209L
64#endif
65
66/* The utilities on GNU systems also correspond to this version. */
67#define _POSIX2_VERSION __POSIX2_THIS_VERSION
68
69/* This symbol was required until the 2001 edition of POSIX. */
70#define _POSIX2_C_VERSION __POSIX2_THIS_VERSION
71
72/* If defined, the implementation supports the
73 C Language Bindings Option. */
74#define _POSIX2_C_BIND __POSIX2_THIS_VERSION
75
76/* If defined, the implementation supports the
77 C Language Development Utilities Option. */
78#define _POSIX2_C_DEV __POSIX2_THIS_VERSION
79
80/* If defined, the implementation supports the
81 Software Development Utilities Option. */
82#define _POSIX2_SW_DEV __POSIX2_THIS_VERSION
83
84/* If defined, the implementation supports the
85 creation of locales with the localedef utility. */
86#define _POSIX2_LOCALEDEF __POSIX2_THIS_VERSION
87
88/* X/Open version number to which the library conforms. It is selectable. */
89#ifdef __USE_XOPEN2K8
90# define _XOPEN_VERSION 700
91#elif defined __USE_XOPEN2K
92# define _XOPEN_VERSION 600
93#elif defined __USE_UNIX98
94# define _XOPEN_VERSION 500
95#else
96# define _XOPEN_VERSION 4
97#endif
98
99/* Commands and utilities from XPG4 are available. */
100#define _XOPEN_XCU_VERSION 4
101
102/* We are compatible with the old published standards as well. */
103#define _XOPEN_XPG2 1
104#define _XOPEN_XPG3 1
105#define _XOPEN_XPG4 1
106
107/* The X/Open Unix extensions are available. */
108#define _XOPEN_UNIX 1
109
110/* The enhanced internationalization capabilities according to XPG4.2
111 are present. */
112#define _XOPEN_ENH_I18N 1
113
114/* The legacy interfaces are also available. */
115#define _XOPEN_LEGACY 1
116
117
118/* Get values of POSIX options:
119
120 If these symbols are defined, the corresponding features are
121 always available. If not, they may be available sometimes.
122 The current values can be obtained with `sysconf'.
123
124 _POSIX_JOB_CONTROL Job control is supported.
125 _POSIX_SAVED_IDS Processes have a saved set-user-ID
126 and a saved set-group-ID.
127 _POSIX_REALTIME_SIGNALS Real-time, queued signals are supported.
128 _POSIX_PRIORITY_SCHEDULING Priority scheduling is supported.
129 _POSIX_TIMERS POSIX.4 clocks and timers are supported.
130 _POSIX_ASYNCHRONOUS_IO Asynchronous I/O is supported.
131 _POSIX_PRIORITIZED_IO Prioritized asynchronous I/O is supported.
132 _POSIX_SYNCHRONIZED_IO Synchronizing file data is supported.
133 _POSIX_FSYNC The fsync function is present.
134 _POSIX_MAPPED_FILES Mapping of files to memory is supported.
135 _POSIX_MEMLOCK Locking of all memory is supported.
136 _POSIX_MEMLOCK_RANGE Locking of ranges of memory is supported.
137 _POSIX_MEMORY_PROTECTION Setting of memory protections is supported.
138 _POSIX_MESSAGE_PASSING POSIX.4 message queues are supported.
139 _POSIX_SEMAPHORES POSIX.4 counting semaphores are supported.
140 _POSIX_SHARED_MEMORY_OBJECTS POSIX.4 shared memory objects are supported.
141 _POSIX_THREADS POSIX.1c pthreads are supported.
142 _POSIX_THREAD_ATTR_STACKADDR Thread stack address attribute option supported.
143 _POSIX_THREAD_ATTR_STACKSIZE Thread stack size attribute option supported.
144 _POSIX_THREAD_SAFE_FUNCTIONS Thread-safe functions are supported.
145 _POSIX_THREAD_PRIORITY_SCHEDULING
146 POSIX.1c thread execution scheduling supported.
147 _POSIX_THREAD_PRIO_INHERIT Thread priority inheritance option supported.
148 _POSIX_THREAD_PRIO_PROTECT Thread priority protection option supported.
149 _POSIX_THREAD_PROCESS_SHARED Process-shared synchronization supported.
150 _POSIX_PII Protocol-independent interfaces are supported.
151 _POSIX_PII_XTI XTI protocol-indep. interfaces are supported.
152 _POSIX_PII_SOCKET Socket protocol-indep. interfaces are supported.
153 _POSIX_PII_INTERNET Internet family of protocols supported.
154 _POSIX_PII_INTERNET_STREAM Connection-mode Internet protocol supported.
155 _POSIX_PII_INTERNET_DGRAM Connectionless Internet protocol supported.
156 _POSIX_PII_OSI ISO/OSI family of protocols supported.
157 _POSIX_PII_OSI_COTS Connection-mode ISO/OSI service supported.
158 _POSIX_PII_OSI_CLTS Connectionless ISO/OSI service supported.
159 _POSIX_POLL Implementation supports `poll' function.
160 _POSIX_SELECT Implementation supports `select' and `pselect'.
161
162 _XOPEN_REALTIME X/Open realtime support is available.
163 _XOPEN_REALTIME_THREADS X/Open realtime thread support is available.
164 _XOPEN_SHM Shared memory interface according to XPG4.2.
165
166 _XBS5_ILP32_OFF32 Implementation provides environment with 32-bit
167 int, long, pointer, and off_t types.
168 _XBS5_ILP32_OFFBIG Implementation provides environment with 32-bit
169 int, long, and pointer and off_t with at least
170 64 bits.
171 _XBS5_LP64_OFF64 Implementation provides environment with 32-bit
172 int, and 64-bit long, pointer, and off_t types.
173 _XBS5_LPBIG_OFFBIG Implementation provides environment with at
174 least 32 bits int and long, pointer, and off_t
175 with at least 64 bits.
176
177 If any of these symbols is defined as -1, the corresponding option is not
178 true for any file. If any is defined as other than -1, the corresponding
179 option is true for all files. If a symbol is not defined at all, the value
180 for a specific file can be obtained from `pathconf' and `fpathconf'.
181
182 _POSIX_CHOWN_RESTRICTED Only the super user can use `chown' to change
183 the owner of a file. `chown' can only be used
184 to change the group ID of a file to a group of
185 which the calling process is a member.
186 _POSIX_NO_TRUNC Pathname components longer than
187 NAME_MAX generate an error.
188 _POSIX_VDISABLE If defined, if the value of an element of the
189 `c_cc' member of `struct termios' is
190 _POSIX_VDISABLE, no character will have the
191 effect associated with that element.
192 _POSIX_SYNC_IO Synchronous I/O may be performed.
193 _POSIX_ASYNC_IO Asynchronous I/O may be performed.
194 _POSIX_PRIO_IO Prioritized Asynchronous I/O may be performed.
195
196 Support for the Large File Support interface is not generally available.
197 If it is available the following constants are defined to one.
198 _LFS64_LARGEFILE Low-level I/O supports large files.
199 _LFS64_STDIO Standard I/O supports large files.
200 */
201
202#include <bits/posix_opt.h>
203
204/* Get the environment definitions from Unix98. */
205#if defined __USE_UNIX98 || defined __USE_XOPEN2K
206# include <bits/environments.h>
207#endif
208
209/* Standard file descriptors. */
210#define STDIN_FILENO 0 /* Standard input. */
211#define STDOUT_FILENO 1 /* Standard output. */
212#define STDERR_FILENO 2 /* Standard error output. */
213
214
215/* All functions that are not declared anywhere else. */
216
217#include <bits/types.h>
218
219#ifndef __ssize_t_defined
220typedef __ssize_t ssize_t;
221# define __ssize_t_defined
222#endif
223
224#define __need_size_t
225#define __need_NULL
226#include <stddef.h>
227
228#if defined __USE_XOPEN || defined __USE_XOPEN2K
229/* The Single Unix specification says that some more types are
230 available here. */
231# ifndef __gid_t_defined
232typedef __gid_t gid_t;
233# define __gid_t_defined
234# endif
235
236# ifndef __uid_t_defined
237typedef __uid_t uid_t;
238# define __uid_t_defined
239# endif
240
241# ifndef __off_t_defined
242# ifndef __USE_FILE_OFFSET64
243typedef __off_t off_t;
244# else
245typedef __off64_t off_t;
246# endif
247# define __off_t_defined
248# endif
249# if defined __USE_LARGEFILE64 && !defined __off64_t_defined
250typedef __off64_t off64_t;
251# define __off64_t_defined
252# endif
253
254# ifndef __useconds_t_defined
255typedef __useconds_t useconds_t;
256# define __useconds_t_defined
257# endif
258
259# ifndef __pid_t_defined
260typedef __pid_t pid_t;
261# define __pid_t_defined
262# endif
263#endif /* X/Open */
264
265#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K
266# ifndef __intptr_t_defined
267typedef __intptr_t intptr_t;
268# define __intptr_t_defined
269# endif
270#endif
271
272#if defined __USE_MISC || defined __USE_XOPEN
273# ifndef __socklen_t_defined
274typedef __socklen_t socklen_t;
275# define __socklen_t_defined
276# endif
277#endif
278
279/* Values for the second argument to access.
280 These may be OR'd together. */
281#define R_OK 4 /* Test for read permission. */
282#define W_OK 2 /* Test for write permission. */
283#define X_OK 1 /* Test for execute permission. */
284#define F_OK 0 /* Test for existence. */
285
286/* Test for access to NAME using the real UID and real GID. */
287extern int access (const char *__name, int __type) __THROW __nonnull ((1));
288
289#ifdef __USE_GNU
290/* Test for access to NAME using the effective UID and GID
291 (as normal file operations use). */
292extern int euidaccess (const char *__name, int __type)
293 __THROW __nonnull ((1));
294
295/* An alias for `euidaccess', used by some other systems. */
296extern int eaccess (const char *__name, int __type)
297 __THROW __nonnull ((1));
298#endif
299
300#ifdef __USE_ATFILE
301/* Test for access to FILE relative to the directory FD is open on.
302 If AT_EACCESS is set in FLAG, then use effective IDs like `eaccess',
303 otherwise use real IDs like `access'. */
304extern int faccessat (int __fd, const char *__file, int __type, int __flag)
305 __THROW __nonnull ((2)) __wur;
306#endif /* Use GNU. */
307
308
309/* Values for the WHENCE argument to lseek. */
310#ifndef _STDIO_H /* <stdio.h> has the same definitions. */
311# define SEEK_SET 0 /* Seek from beginning of file. */
312# define SEEK_CUR 1 /* Seek from current position. */
313# define SEEK_END 2 /* Seek from end of file. */
314# ifdef __USE_GNU
315# define SEEK_DATA 3 /* Seek to next data. */
316# define SEEK_HOLE 4 /* Seek to next hole. */
317# endif
318#endif
319
320#if defined __USE_MISC && !defined L_SET
321/* Old BSD names for the same constants; just for compatibility. */
322# define L_SET SEEK_SET
323# define L_INCR SEEK_CUR
324# define L_XTND SEEK_END
325#endif
326
327
328/* Move FD's file position to OFFSET bytes from the
329 beginning of the file (if WHENCE is SEEK_SET),
330 the current position (if WHENCE is SEEK_CUR),
331 or the end of the file (if WHENCE is SEEK_END).
332 Return the new file position. */
333#ifndef __USE_FILE_OFFSET64
334extern __off_t lseek (int __fd, __off_t __offset, int __whence) __THROW;
335#else
336# ifdef __REDIRECT_NTH
337extern __off64_t __REDIRECT_NTH (lseek,
338 (int __fd, __off64_t __offset, int __whence),
339 lseek64);
340# else
341# define lseek lseek64
342# endif
343#endif
344#ifdef __USE_LARGEFILE64
345extern __off64_t lseek64 (int __fd, __off64_t __offset, int __whence)
346 __THROW;
347#endif
348
349/* Close the file descriptor FD.
350
351 This function is a cancellation point and therefore not marked with
352 __THROW. */
353extern int close (int __fd);
354
355/* Read NBYTES into BUF from FD. Return the
356 number read, -1 for errors or 0 for EOF.
357
358 This function is a cancellation point and therefore not marked with
359 __THROW. */
360extern ssize_t read (int __fd, void *__buf, size_t __nbytes) __wur;
361
362/* Write N bytes of BUF to FD. Return the number written, or -1.
363
364 This function is a cancellation point and therefore not marked with
365 __THROW. */
366extern ssize_t write (int __fd, const void *__buf, size_t __n) __wur;
367
368#if defined __USE_UNIX98 || defined __USE_XOPEN2K8
369# ifndef __USE_FILE_OFFSET64
370/* Read NBYTES into BUF from FD at the given position OFFSET without
371 changing the file pointer. Return the number read, -1 for errors
372 or 0 for EOF.
373
374 This function is a cancellation point and therefore not marked with
375 __THROW. */
376extern ssize_t pread (int __fd, void *__buf, size_t __nbytes,
377 __off_t __offset) __wur;
378
379/* Write N bytes of BUF to FD at the given position OFFSET without
380 changing the file pointer. Return the number written, or -1.
381
382 This function is a cancellation point and therefore not marked with
383 __THROW. */
384extern ssize_t pwrite (int __fd, const void *__buf, size_t __n,
385 __off_t __offset) __wur;
386# else
387# ifdef __REDIRECT
388extern ssize_t __REDIRECT (pread, (int __fd, void *__buf, size_t __nbytes,
389 __off64_t __offset),
390 pread64) __wur;
391extern ssize_t __REDIRECT (pwrite, (int __fd, const void *__buf,
392 size_t __nbytes, __off64_t __offset),
393 pwrite64) __wur;
394# else
395# define pread pread64
396# define pwrite pwrite64
397# endif
398# endif
399
400# ifdef __USE_LARGEFILE64
401/* Read NBYTES into BUF from FD at the given position OFFSET without
402 changing the file pointer. Return the number read, -1 for errors
403 or 0 for EOF. */
404extern ssize_t pread64 (int __fd, void *__buf, size_t __nbytes,
405 __off64_t __offset) __wur;
406/* Write N bytes of BUF to FD at the given position OFFSET without
407 changing the file pointer. Return the number written, or -1. */
408extern ssize_t pwrite64 (int __fd, const void *__buf, size_t __n,
409 __off64_t __offset) __wur;
410# endif
411#endif
412
413/* Create a one-way communication channel (pipe).
414 If successful, two file descriptors are stored in PIPEDES;
415 bytes written on PIPEDES[1] can be read from PIPEDES[0].
416 Returns 0 if successful, -1 if not. */
417extern int pipe (int __pipedes[2]) __THROW __wur;
418
419#ifdef __USE_GNU
420/* Same as pipe but apply flags passed in FLAGS to the new file
421 descriptors. */
422extern int pipe2 (int __pipedes[2], int __flags) __THROW __wur;
423#endif
424
425/* Schedule an alarm. In SECONDS seconds, the process will get a SIGALRM.
426 If SECONDS is zero, any currently scheduled alarm will be cancelled.
427 The function returns the number of seconds remaining until the last
428 alarm scheduled would have signaled, or zero if there wasn't one.
429 There is no return value to indicate an error, but you can set `errno'
430 to 0 and check its value after calling `alarm', and this might tell you.
431 The signal may come late due to processor scheduling. */
432extern unsigned int alarm (unsigned int __seconds) __THROW;
433
434/* Make the process sleep for SECONDS seconds, or until a signal arrives
435 and is not ignored. The function returns the number of seconds less
436 than SECONDS which it actually slept (thus zero if it slept the full time).
437 If a signal handler does a `longjmp' or modifies the handling of the
438 SIGALRM signal while inside `sleep' call, the handling of the SIGALRM
439 signal afterwards is undefined. There is no return value to indicate
440 error, but if `sleep' returns SECONDS, it probably didn't work.
441
442 This function is a cancellation point and therefore not marked with
443 __THROW. */
444extern unsigned int sleep (unsigned int __seconds);
445
446#if (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8) \
447 || defined __USE_MISC
448/* Set an alarm to go off (generating a SIGALRM signal) in VALUE
449 microseconds. If INTERVAL is nonzero, when the alarm goes off, the
450 timer is reset to go off every INTERVAL microseconds thereafter.
451 Returns the number of microseconds remaining before the alarm. */
452extern __useconds_t ualarm (__useconds_t __value, __useconds_t __interval)
453 __THROW;
454
455/* Sleep USECONDS microseconds, or until a signal arrives that is not blocked
456 or ignored.
457
458 This function is a cancellation point and therefore not marked with
459 __THROW. */
460extern int usleep (__useconds_t __useconds);
461#endif
462
463
464/* Suspend the process until a signal arrives.
465 This always returns -1 and sets `errno' to EINTR.
466
467 This function is a cancellation point and therefore not marked with
468 __THROW. */
469extern int pause (void);
470
471
472/* Change the owner and group of FILE. */
473extern int chown (const char *__file, __uid_t __owner, __gid_t __group)
474 __THROW __nonnull ((1)) __wur;
475
476#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
477/* Change the owner and group of the file that FD is open on. */
478extern int fchown (int __fd, __uid_t __owner, __gid_t __group) __THROW __wur;
479
480
481/* Change owner and group of FILE, if it is a symbolic
482 link the ownership of the symbolic link is changed. */
483extern int lchown (const char *__file, __uid_t __owner, __gid_t __group)
484 __THROW __nonnull ((1)) __wur;
485
486#endif /* Use X/Open Unix. */
487
488#ifdef __USE_ATFILE
489/* Change the owner and group of FILE relative to the directory FD is open
490 on. */
491extern int fchownat (int __fd, const char *__file, __uid_t __owner,
492 __gid_t __group, int __flag)
493 __THROW __nonnull ((2)) __wur;
494#endif /* Use GNU. */
495
496/* Change the process's working directory to PATH. */
497extern int chdir (const char *__path) __THROW __nonnull ((1)) __wur;
498
499#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
500/* Change the process's working directory to the one FD is open on. */
501extern int fchdir (int __fd) __THROW __wur;
502#endif
503
504/* Get the pathname of the current working directory,
505 and put it in SIZE bytes of BUF. Returns NULL if the
506 directory couldn't be determined or SIZE was too small.
507 If successful, returns BUF. In GNU, if BUF is NULL,
508 an array is allocated with `malloc'; the array is SIZE
509 bytes long, unless SIZE == 0, in which case it is as
510 big as necessary. */
511extern char *getcwd (char *__buf, size_t __size) __THROW __wur;
512
513#ifdef __USE_GNU
514/* Return a malloc'd string containing the current directory name.
515 If the environment variable `PWD' is set, and its value is correct,
516 that value is used. */
517extern char *get_current_dir_name (void) __THROW;
518#endif
519
520#if (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8) \
521 || defined __USE_MISC
522/* Put the absolute pathname of the current working directory in BUF.
523 If successful, return BUF. If not, put an error message in
524 BUF and return NULL. BUF should be at least PATH_MAX bytes long. */
525extern char *getwd (char *__buf)
526 __THROW __nonnull ((1)) __attribute_deprecated__ __wur;
527#endif
528
529
530/* Duplicate FD, returning a new file descriptor on the same file. */
531extern int dup (int __fd) __THROW __wur;
532
533/* Duplicate FD to FD2, closing FD2 and making it open on the same file. */
534extern int dup2 (int __fd, int __fd2) __THROW;
535
536#ifdef __USE_GNU
537/* Duplicate FD to FD2, closing FD2 and making it open on the same
538 file while setting flags according to FLAGS. */
539extern int dup3 (int __fd, int __fd2, int __flags) __THROW;
540#endif
541
542/* NULL-terminated array of "NAME=VALUE" environment variables. */
543extern char **__environ;
544#ifdef __USE_GNU
545extern char **environ;
546#endif
547
548
549/* Replace the current process, executing PATH with arguments ARGV and
550 environment ENVP. ARGV and ENVP are terminated by NULL pointers. */
551extern int execve (const char *__path, char *const __argv[],
552 char *const __envp[]) __THROW __nonnull ((1, 2));
553
554#ifdef __USE_XOPEN2K8
555/* Execute the file FD refers to, overlaying the running program image.
556 ARGV and ENVP are passed to the new program, as for `execve'. */
557extern int fexecve (int __fd, char *const __argv[], char *const __envp[])
558 __THROW __nonnull ((2));
559#endif
560
561
562/* Execute PATH with arguments ARGV and environment from `environ'. */
563extern int execv (const char *__path, char *const __argv[])
564 __THROW __nonnull ((1, 2));
565
566/* Execute PATH with all arguments after PATH until a NULL pointer,
567 and the argument after that for environment. */
568extern int execle (const char *__path, const char *__arg, ...)
569 __THROW __nonnull ((1, 2));
570
571/* Execute PATH with all arguments after PATH until
572 a NULL pointer and environment from `environ'. */
573extern int execl (const char *__path, const char *__arg, ...)
574 __THROW __nonnull ((1, 2));
575
576/* Execute FILE, searching in the `PATH' environment variable if it contains
577 no slashes, with arguments ARGV and environment from `environ'. */
578extern int execvp (const char *__file, char *const __argv[])
579 __THROW __nonnull ((1, 2));
580
581/* Execute FILE, searching in the `PATH' environment variable if
582 it contains no slashes, with all arguments after FILE until a
583 NULL pointer and environment from `environ'. */
584extern int execlp (const char *__file, const char *__arg, ...)
585 __THROW __nonnull ((1, 2));
586
587#ifdef __USE_GNU
588/* Execute FILE, searching in the `PATH' environment variable if it contains
589 no slashes, with arguments ARGV and environment from `environ'. */
590extern int execvpe (const char *__file, char *const __argv[],
591 char *const __envp[])
592 __THROW __nonnull ((1, 2));
593#endif
594
595
596#if defined __USE_MISC || defined __USE_XOPEN
597/* Add INC to priority of the current process. */
598extern int nice (int __inc) __THROW __wur;
599#endif
600
601
602/* Terminate program execution with the low-order 8 bits of STATUS. */
603extern void _exit (int __status) __attribute__ ((__noreturn__));
604
605
606/* Get the `_PC_*' symbols for the NAME argument to `pathconf' and `fpathconf';
607 the `_SC_*' symbols for the NAME argument to `sysconf';
608 and the `_CS_*' symbols for the NAME argument to `confstr'. */
609#include <bits/confname.h>
610
611/* Get file-specific configuration information about PATH. */
612extern long int pathconf (const char *__path, int __name)
613 __THROW __nonnull ((1));
614
615/* Get file-specific configuration about descriptor FD. */
616extern long int fpathconf (int __fd, int __name) __THROW;
617
618/* Get the value of the system variable NAME. */
619extern long int sysconf (int __name) __THROW;
620
621#ifdef __USE_POSIX2
622/* Get the value of the string-valued system variable NAME. */
623extern size_t confstr (int __name, char *__buf, size_t __len) __THROW;
624#endif
625
626
627/* Get the process ID of the calling process. */
628extern __pid_t getpid (void) __THROW;
629
630/* Get the process ID of the calling process's parent. */
631extern __pid_t getppid (void) __THROW;
632
633/* Get the process group ID of the calling process. */
634extern __pid_t getpgrp (void) __THROW;
635
636/* Get the process group ID of process PID. */
637extern __pid_t __getpgid (__pid_t __pid) __THROW;
638#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
639extern __pid_t getpgid (__pid_t __pid) __THROW;
640#endif
641
642
643/* Set the process group ID of the process matching PID to PGID.
644 If PID is zero, the current process's process group ID is set.
645 If PGID is zero, the process ID of the process is used. */
646extern int setpgid (__pid_t __pid, __pid_t __pgid) __THROW;
647
648#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
649/* Both System V and BSD have `setpgrp' functions, but with different
650 calling conventions. The BSD function is the same as POSIX.1 `setpgid'
651 (above). The System V function takes no arguments and puts the calling
652 process in its on group like `setpgid (0, 0)'.
653
654 New programs should always use `setpgid' instead.
655
656 GNU provides the POSIX.1 function. */
657
658/* Set the process group ID of the calling process to its own PID.
659 This is exactly the same as `setpgid (0, 0)'. */
660extern int setpgrp (void) __THROW;
661
662#endif /* Use misc or X/Open. */
663
664/* Create a new session with the calling process as its leader.
665 The process group IDs of the session and the calling process
666 are set to the process ID of the calling process, which is returned. */
667extern __pid_t setsid (void) __THROW;
668
669#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
670/* Return the session ID of the given process. */
671extern __pid_t getsid (__pid_t __pid) __THROW;
672#endif
673
674/* Get the real user ID of the calling process. */
675extern __uid_t getuid (void) __THROW;
676
677/* Get the effective user ID of the calling process. */
678extern __uid_t geteuid (void) __THROW;
679
680/* Get the real group ID of the calling process. */
681extern __gid_t getgid (void) __THROW;
682
683/* Get the effective group ID of the calling process. */
684extern __gid_t getegid (void) __THROW;
685
686/* If SIZE is zero, return the number of supplementary groups
687 the calling process is in. Otherwise, fill in the group IDs
688 of its supplementary groups in LIST and return the number written. */
689extern int getgroups (int __size, __gid_t __list[]) __THROW __wur;
690
691#ifdef __USE_GNU
692/* Return nonzero iff the calling process is in group GID. */
693extern int group_member (__gid_t __gid) __THROW;
694#endif
695
696/* Set the user ID of the calling process to UID.
697 If the calling process is the super-user, set the real
698 and effective user IDs, and the saved set-user-ID to UID;
699 if not, the effective user ID is set to UID. */
700extern int setuid (__uid_t __uid) __THROW __wur;
701
702#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
703/* Set the real user ID of the calling process to RUID,
704 and the effective user ID of the calling process to EUID. */
705extern int setreuid (__uid_t __ruid, __uid_t __euid) __THROW __wur;
706#endif
707
708#ifdef __USE_XOPEN2K
709/* Set the effective user ID of the calling process to UID. */
710extern int seteuid (__uid_t __uid) __THROW __wur;
711#endif /* Use POSIX.1-2001. */
712
713/* Set the group ID of the calling process to GID.
714 If the calling process is the super-user, set the real
715 and effective group IDs, and the saved set-group-ID to GID;
716 if not, the effective group ID is set to GID. */
717extern int setgid (__gid_t __gid) __THROW __wur;
718
719#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
720/* Set the real group ID of the calling process to RGID,
721 and the effective group ID of the calling process to EGID. */
722extern int setregid (__gid_t __rgid, __gid_t __egid) __THROW __wur;
723#endif
724
725#ifdef __USE_XOPEN2K
726/* Set the effective group ID of the calling process to GID. */
727extern int setegid (__gid_t __gid) __THROW __wur;
728#endif /* Use POSIX.1-2001. */
729
730#ifdef __USE_GNU
731/* Fetch the real user ID, effective user ID, and saved-set user ID,
732 of the calling process. */
733extern int getresuid (__uid_t *__ruid, __uid_t *__euid, __uid_t *__suid)
734 __THROW;
735
736/* Fetch the real group ID, effective group ID, and saved-set group ID,
737 of the calling process. */
738extern int getresgid (__gid_t *__rgid, __gid_t *__egid, __gid_t *__sgid)
739 __THROW;
740
741/* Set the real user ID, effective user ID, and saved-set user ID,
742 of the calling process to RUID, EUID, and SUID, respectively. */
743extern int setresuid (__uid_t __ruid, __uid_t __euid, __uid_t __suid)
744 __THROW __wur;
745
746/* Set the real group ID, effective group ID, and saved-set group ID,
747 of the calling process to RGID, EGID, and SGID, respectively. */
748extern int setresgid (__gid_t __rgid, __gid_t __egid, __gid_t __sgid)
749 __THROW __wur;
750#endif
751
752
753/* Clone the calling process, creating an exact copy.
754 Return -1 for errors, 0 to the new process,
755 and the process ID of the new process to the old process. */
756extern __pid_t fork (void) __THROWNL;
757
758#if (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8) \
759 || defined __USE_MISC
760/* Clone the calling process, but without copying the whole address space.
761 The calling process is suspended until the new process exits or is
762 replaced by a call to `execve'. Return -1 for errors, 0 to the new process,
763 and the process ID of the new process to the old process. */
764extern __pid_t vfork (void) __THROW;
765#endif /* Use misc or XPG < 7. */
766
767
768/* Return the pathname of the terminal FD is open on, or NULL on errors.
769 The returned storage is good only until the next call to this function. */
770extern char *ttyname (int __fd) __THROW;
771
772/* Store at most BUFLEN characters of the pathname of the terminal FD is
773 open on in BUF. Return 0 on success, otherwise an error number. */
774extern int ttyname_r (int __fd, char *__buf, size_t __buflen)
775 __THROW __nonnull ((2)) __wur;
776
777/* Return 1 if FD is a valid descriptor associated
778 with a terminal, zero if not. */
779extern int isatty (int __fd) __THROW;
780
781#ifdef __USE_MISC
782/* Return the index into the active-logins file (utmp) for
783 the controlling terminal. */
784extern int ttyslot (void) __THROW;
785#endif
786
787
788/* Make a link to FROM named TO. */
789extern int link (const char *__from, const char *__to)
790 __THROW __nonnull ((1, 2)) __wur;
791
792#ifdef __USE_ATFILE
793/* Like link but relative paths in TO and FROM are interpreted relative
794 to FROMFD and TOFD respectively. */
795extern int linkat (int __fromfd, const char *__from, int __tofd,
796 const char *__to, int __flags)
797 __THROW __nonnull ((2, 4)) __wur;
798#endif
799
800#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K
801/* Make a symbolic link to FROM named TO. */
802extern int symlink (const char *__from, const char *__to)
803 __THROW __nonnull ((1, 2)) __wur;
804
805/* Read the contents of the symbolic link PATH into no more than
806 LEN bytes of BUF. The contents are not null-terminated.
807 Returns the number of characters read, or -1 for errors. */
808extern ssize_t readlink (const char *__restrict __path,
809 char *__restrict __buf, size_t __len)
810 __THROW __nonnull ((1, 2)) __wur;
811#endif /* Use POSIX.1-2001. */
812
813#ifdef __USE_ATFILE
814/* Like symlink but a relative path in TO is interpreted relative to TOFD. */
815extern int symlinkat (const char *__from, int __tofd,
816 const char *__to) __THROW __nonnull ((1, 3)) __wur;
817
818/* Like readlink but a relative PATH is interpreted relative to FD. */
819extern ssize_t readlinkat (int __fd, const char *__restrict __path,
820 char *__restrict __buf, size_t __len)
821 __THROW __nonnull ((2, 3)) __wur;
822#endif
823
824/* Remove the link NAME. */
825extern int unlink (const char *__name) __THROW __nonnull ((1));
826
827#ifdef __USE_ATFILE
828/* Remove the link NAME relative to FD. */
829extern int unlinkat (int __fd, const char *__name, int __flag)
830 __THROW __nonnull ((2));
831#endif
832
833/* Remove the directory PATH. */
834extern int rmdir (const char *__path) __THROW __nonnull ((1));
835
836
837/* Return the foreground process group ID of FD. */
838extern __pid_t tcgetpgrp (int __fd) __THROW;
839
840/* Set the foreground process group ID of FD set PGRP_ID. */
841extern int tcsetpgrp (int __fd, __pid_t __pgrp_id) __THROW;
842
843
844/* Return the login name of the user.
845
846 This function is a possible cancellation point and therefore not
847 marked with __THROW. */
848extern char *getlogin (void);
849#ifdef __USE_POSIX199506
850/* Return at most NAME_LEN characters of the login name of the user in NAME.
851 If it cannot be determined or some other error occurred, return the error
852 code. Otherwise return 0.
853
854 This function is a possible cancellation point and therefore not
855 marked with __THROW. */
856extern int getlogin_r (char *__name, size_t __name_len) __nonnull ((1));
857#endif
858
859#ifdef __USE_MISC
860/* Set the login name returned by `getlogin'. */
861extern int setlogin (const char *__name) __THROW __nonnull ((1));
862#endif
863
864
865#ifdef __USE_POSIX2
866/* Get definitions and prototypes for functions to process the
867 arguments in ARGV (ARGC of them, minus the program name) for
868 options given in OPTS. */
869# include <bits/getopt_posix.h>
870#endif
871
872
873#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K
874/* Put the name of the current host in no more than LEN bytes of NAME.
875 The result is null-terminated if LEN is large enough for the full
876 name and the terminator. */
877extern int gethostname (char *__name, size_t __len) __THROW __nonnull ((1));
878#endif
879
880
881#if defined __USE_MISC
882/* Set the name of the current host to NAME, which is LEN bytes long.
883 This call is restricted to the super-user. */
884extern int sethostname (const char *__name, size_t __len)
885 __THROW __nonnull ((1)) __wur;
886
887/* Set the current machine's Internet number to ID.
888 This call is restricted to the super-user. */
889extern int sethostid (long int __id) __THROW __wur;
890
891
892/* Get and set the NIS (aka YP) domain name, if any.
893 Called just like `gethostname' and `sethostname'.
894 The NIS domain name is usually the empty string when not using NIS. */
895extern int getdomainname (char *__name, size_t __len)
896 __THROW __nonnull ((1)) __wur;
897extern int setdomainname (const char *__name, size_t __len)
898 __THROW __nonnull ((1)) __wur;
899
900
901/* Revoke access permissions to all processes currently communicating
902 with the control terminal, and then send a SIGHUP signal to the process
903 group of the control terminal. */
904extern int vhangup (void) __THROW;
905
906/* Revoke the access of all descriptors currently open on FILE. */
907extern int revoke (const char *__file) __THROW __nonnull ((1)) __wur;
908
909
910/* Enable statistical profiling, writing samples of the PC into at most
911 SIZE bytes of SAMPLE_BUFFER; every processor clock tick while profiling
912 is enabled, the system examines the user PC and increments
913 SAMPLE_BUFFER[((PC - OFFSET) / 2) * SCALE / 65536]. If SCALE is zero,
914 disable profiling. Returns zero on success, -1 on error. */
915extern int profil (unsigned short int *__sample_buffer, size_t __size,
916 size_t __offset, unsigned int __scale)
917 __THROW __nonnull ((1));
918
919
920/* Turn accounting on if NAME is an existing file. The system will then write
921 a record for each process as it terminates, to this file. If NAME is NULL,
922 turn accounting off. This call is restricted to the super-user. */
923extern int acct (const char *__name) __THROW;
924
925
926/* Successive calls return the shells listed in `/etc/shells'. */
927extern char *getusershell (void) __THROW;
928extern void endusershell (void) __THROW; /* Discard cached info. */
929extern void setusershell (void) __THROW; /* Rewind and re-read the file. */
930
931
932/* Put the program in the background, and dissociate from the controlling
933 terminal. If NOCHDIR is zero, do `chdir ("/")'. If NOCLOSE is zero,
934 redirects stdin, stdout, and stderr to /dev/null. */
935extern int daemon (int __nochdir, int __noclose) __THROW __wur;
936#endif /* Use misc. */
937
938
939#if defined __USE_MISC || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
940/* Make PATH be the root directory (the starting point for absolute paths).
941 This call is restricted to the super-user. */
942extern int chroot (const char *__path) __THROW __nonnull ((1)) __wur;
943
944/* Prompt with PROMPT and read a string from the terminal without echoing.
945 Uses /dev/tty if possible; otherwise stderr and stdin. */
946extern char *getpass (const char *__prompt) __nonnull ((1));
947#endif /* Use misc || X/Open. */
948
949
950/* Make all changes done to FD actually appear on disk.
951
952 This function is a cancellation point and therefore not marked with
953 __THROW. */
954extern int fsync (int __fd);
955
956
957#ifdef __USE_GNU
958/* Make all changes done to all files on the file system associated
959 with FD actually appear on disk. */
960extern int syncfs (int __fd) __THROW;
961#endif
962
963
964#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
965
966/* Return identifier for the current host. */
967extern long int gethostid (void);
968
969/* Make all changes done to all files actually appear on disk. */
970extern void sync (void) __THROW;
971
972
973# if defined __USE_MISC || !defined __USE_XOPEN2K
974/* Return the number of bytes in a page. This is the system's page size,
975 which is not necessarily the same as the hardware page size. */
976extern int getpagesize (void) __THROW __attribute__ ((__const__));
977
978
979/* Return the maximum number of file descriptors
980 the current process could possibly have. */
981extern int getdtablesize (void) __THROW;
982# endif
983
984#endif /* Use misc || X/Open Unix. */
985
986
987#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
988
989/* Truncate FILE to LENGTH bytes. */
990# ifndef __USE_FILE_OFFSET64
991extern int truncate (const char *__file, __off_t __length)
992 __THROW __nonnull ((1)) __wur;
993# else
994# ifdef __REDIRECT_NTH
995extern int __REDIRECT_NTH (truncate,
996 (const char *__file, __off64_t __length),
997 truncate64) __nonnull ((1)) __wur;
998# else
999# define truncate truncate64
1000# endif
1001# endif
1002# ifdef __USE_LARGEFILE64
1003extern int truncate64 (const char *__file, __off64_t __length)
1004 __THROW __nonnull ((1)) __wur;
1005# endif
1006
1007#endif /* Use X/Open Unix || POSIX 2008. */
1008
1009#if defined __USE_POSIX199309 \
1010 || defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K
1011
1012/* Truncate the file FD is open on to LENGTH bytes. */
1013# ifndef __USE_FILE_OFFSET64
1014extern int ftruncate (int __fd, __off_t __length) __THROW __wur;
1015# else
1016# ifdef __REDIRECT_NTH
1017extern int __REDIRECT_NTH (ftruncate, (int __fd, __off64_t __length),
1018 ftruncate64) __wur;
1019# else
1020# define ftruncate ftruncate64
1021# endif
1022# endif
1023# ifdef __USE_LARGEFILE64
1024extern int ftruncate64 (int __fd, __off64_t __length) __THROW __wur;
1025# endif
1026
1027#endif /* Use POSIX.1b || X/Open Unix || XPG6. */
1028
1029
1030#if (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K) \
1031 || defined __USE_MISC
1032
1033/* Set the end of accessible data space (aka "the break") to ADDR.
1034 Returns zero on success and -1 for errors (with errno set). */
1035extern int brk (void *__addr) __THROW __wur;
1036
1037/* Increase or decrease the end of accessible data space by DELTA bytes.
1038 If successful, returns the address the previous end of data space
1039 (i.e. the beginning of the new space, if DELTA > 0);
1040 returns (void *) -1 for errors (with errno set). */
1041extern void *sbrk (intptr_t __delta) __THROW;
1042#endif
1043
1044
1045#ifdef __USE_MISC
1046/* Invoke `system call' number SYSNO, passing it the remaining arguments.
1047 This is completely system-dependent, and not often useful.
1048
1049 In Unix, `syscall' sets `errno' for all errors and most calls return -1
1050 for errors; in many systems you cannot pass arguments or get return
1051 values for all system calls (`pipe', `fork', and `getppid' typically
1052 among them).
1053
1054 In Mach, all system calls take normal arguments and always return an
1055 error code (zero for success). */
1056extern long int syscall (long int __sysno, ...) __THROW;
1057
1058#endif /* Use misc. */
1059
1060
1061#if (defined __USE_MISC || defined __USE_XOPEN_EXTENDED) && !defined F_LOCK
1062/* NOTE: These declarations also appear in <fcntl.h>; be sure to keep both
1063 files consistent. Some systems have them there and some here, and some
1064 software depends on the macros being defined without including both. */
1065
1066/* `lockf' is a simpler interface to the locking facilities of `fcntl'.
1067 LEN is always relative to the current file position.
1068 The CMD argument is one of the following.
1069
1070 This function is a cancellation point and therefore not marked with
1071 __THROW. */
1072
1073# define F_ULOCK 0 /* Unlock a previously locked region. */
1074# define F_LOCK 1 /* Lock a region for exclusive use. */
1075# define F_TLOCK 2 /* Test and lock a region for exclusive use. */
1076# define F_TEST 3 /* Test a region for other processes locks. */
1077
1078# ifndef __USE_FILE_OFFSET64
1079extern int lockf (int __fd, int __cmd, __off_t __len) __wur;
1080# else
1081# ifdef __REDIRECT
1082extern int __REDIRECT (lockf, (int __fd, int __cmd, __off64_t __len),
1083 lockf64) __wur;
1084# else
1085# define lockf lockf64
1086# endif
1087# endif
1088# ifdef __USE_LARGEFILE64
1089extern int lockf64 (int __fd, int __cmd, __off64_t __len) __wur;
1090# endif
1091#endif /* Use misc and F_LOCK not already defined. */
1092
1093
1094#ifdef __USE_GNU
1095
1096/* Evaluate EXPRESSION, and repeat as long as it returns -1 with `errno'
1097 set to EINTR. */
1098
1099# define TEMP_FAILURE_RETRY(expression) \
1100 (__extension__ \
1101 ({ long int __result; \
1102 do __result = (long int) (expression); \
1103 while (__result == -1L && errno == EINTR); \
1104 __result; }))
1105
1106/* Copy LENGTH bytes from INFD to OUTFD. */
1107ssize_t copy_file_range (int __infd, __off64_t *__pinoff,
1108 int __outfd, __off64_t *__poutoff,
1109 size_t __length, unsigned int __flags);
1110#endif /* __USE_GNU */
1111
1112#if defined __USE_POSIX199309 || defined __USE_UNIX98
1113/* Synchronize at least the data part of a file with the underlying
1114 media. */
1115extern int fdatasync (int __fildes);
1116#endif /* Use POSIX199309 */
1117
1118#ifdef __USE_MISC
1119/* One-way hash PHRASE, returning a string suitable for storage in the
1120 user database. SALT selects the one-way function to use, and
1121 ensures that no two users' hashes are the same, even if they use
1122 the same passphrase. The return value points to static storage
1123 which will be overwritten by the next call to crypt. */
1124extern char *crypt (const char *__key, const char *__salt)
1125 __THROW __nonnull ((1, 2));
1126#endif
1127
1128#ifdef __USE_XOPEN
1129/* Swab pairs bytes in the first N bytes of the area pointed to by
1130 FROM and copy the result to TO. The value of TO must not be in the
1131 range [FROM - N + 1, FROM - 1]. If N is odd the first byte in FROM
1132 is without partner. */
1133extern void swab (const void *__restrict __from, void *__restrict __to,
1134 ssize_t __n) __THROW __nonnull ((1, 2));
1135#endif
1136
1137
1138/* Prior to Issue 6, the Single Unix Specification required these
1139 prototypes to appear in this header. They are also found in
1140 <stdio.h>. */
1141#if defined __USE_XOPEN && !defined __USE_XOPEN2K
1142/* Return the name of the controlling terminal. */
1143extern char *ctermid (char *__s) __THROW;
1144
1145/* Return the name of the current user. */
1146extern char *cuserid (char *__s);
1147#endif
1148
1149
1150/* Unix98 requires this function to be declared here. In other
1151 standards it is in <pthread.h>. */
1152#if defined __USE_UNIX98 && !defined __USE_XOPEN2K
1153extern int pthread_atfork (void (*__prepare) (void),
1154 void (*__parent) (void),
1155 void (*__child) (void)) __THROW;
1156#endif
1157
1158#ifdef __USE_MISC
1159/* Write LENGTH bytes of randomness starting at BUFFER. Return 0 on
1160 success or -1 on error. */
1161int getentropy (void *__buffer, size_t __length) __wur;
1162#endif
1163
1164/* Define some macros helping to catch buffer overflows. */
1165#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
1166# include <bits/unistd.h>
1167#endif
1168
1169__END_DECLS
1170
1171#endif /* unistd.h */
libc/glibc-include/utime.h created+50
...@@ -0,0 +1,50 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/*
19 * POSIX Standard: 5.6.6 Set File Access and Modification Times <utime.h>
20 */
21
22#ifndef _UTIME_H
23#define _UTIME_H 1
24
25#include <features.h>
26
27__BEGIN_DECLS
28
29#include <bits/types.h>
30
31#if defined __USE_XOPEN || defined __USE_XOPEN2K
32# include <bits/types/time_t.h>
33#endif
34
35/* Structure describing file times. */
36struct utimbuf
37 {
38 __time_t actime; /* Access time. */
39 __time_t modtime; /* Modification time. */
40 };
41
42/* Set the access and modification times of FILE to those given in
43 *FILE_TIMES. If FILE_TIMES is NULL, set them to the current time. */
44extern int utime (const char *__file,
45 const struct utimbuf *__file_times)
46 __THROW __nonnull ((1));
47
48__END_DECLS
49
50#endif /* utime.h */
libc/glibc-include/utmp.h created+96
...@@ -0,0 +1,96 @@
1/* Copyright (C) 1993-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _UTMP_H
19#define _UTMP_H 1
20
21#include <features.h>
22
23#include <sys/types.h>
24
25
26__BEGIN_DECLS
27
28/* Get system dependent values and data structures. */
29#include <bits/utmp.h>
30
31/* Compatibility names for the strings of the canonical file names. */
32#define UTMP_FILE _PATH_UTMP
33#define UTMP_FILENAME _PATH_UTMP
34#define WTMP_FILE _PATH_WTMP
35#define WTMP_FILENAME _PATH_WTMP
36
37
38
39/* Make FD be the controlling terminal, stdin, stdout, and stderr;
40 then close FD. Returns 0 on success, nonzero on error. */
41extern int login_tty (int __fd) __THROW;
42
43
44/* Write the given entry into utmp and wtmp. */
45extern void login (const struct utmp *__entry) __THROW;
46
47/* Write the utmp entry to say the user on UT_LINE has logged out. */
48extern int logout (const char *__ut_line) __THROW;
49
50/* Append to wtmp an entry for the current time and the given info. */
51extern void logwtmp (const char *__ut_line, const char *__ut_name,
52 const char *__ut_host) __THROW;
53
54/* Append entry UTMP to the wtmp-like file WTMP_FILE. */
55extern void updwtmp (const char *__wtmp_file, const struct utmp *__utmp)
56 __THROW;
57
58/* Change name of the utmp file to be examined. */
59extern int utmpname (const char *__file) __THROW;
60
61/* Read next entry from a utmp-like file. */
62extern struct utmp *getutent (void) __THROW;
63
64/* Reset the input stream to the beginning of the file. */
65extern void setutent (void) __THROW;
66
67/* Close the current open file. */
68extern void endutent (void) __THROW;
69
70/* Search forward from the current point in the utmp file until the
71 next entry with a ut_type matching ID->ut_type. */
72extern struct utmp *getutid (const struct utmp *__id) __THROW;
73
74/* Search forward from the current point in the utmp file until the
75 next entry with a ut_line matching LINE->ut_line. */
76extern struct utmp *getutline (const struct utmp *__line) __THROW;
77
78/* Write out entry pointed to by UTMP_PTR into the utmp file. */
79extern struct utmp *pututline (const struct utmp *__utmp_ptr) __THROW;
80
81
82#ifdef __USE_MISC
83/* Reentrant versions of the file for handling utmp files. */
84extern int getutent_r (struct utmp *__buffer, struct utmp **__result) __THROW;
85
86extern int getutid_r (const struct utmp *__id, struct utmp *__buffer,
87 struct utmp **__result) __THROW;
88
89extern int getutline_r (const struct utmp *__line,
90 struct utmp *__buffer, struct utmp **__result) __THROW;
91
92#endif /* Use misc. */
93
94__END_DECLS
95
96#endif /* utmp.h */
libc/glibc-include/utmpx.h created+125
...@@ -0,0 +1,125 @@
1/* Copyright (C) 1997-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _UTMPX_H
19#define _UTMPX_H 1
20
21#include <features.h>
22#include <sys/time.h>
23
24/* Required according to Unix98. */
25#ifndef __pid_t_defined
26typedef __pid_t pid_t;
27# define __pid_t_defined
28#endif
29
30/* Get system dependent values and data structures. */
31#include <bits/utmpx.h>
32
33#ifdef __USE_GNU
34/* Compatibility names for the strings of the canonical file names. */
35# define UTMPX_FILE _PATH_UTMPX
36# define UTMPX_FILENAME _PATH_UTMPX
37# define WTMPX_FILE _PATH_WTMPX
38# define WTMPX_FILENAME _PATH_WTMPX
39#endif
40
41/* For the getutmp{,x} functions we need the `struct utmp'. */
42#ifdef __USE_GNU
43struct utmp;
44#endif
45
46
47__BEGIN_DECLS
48
49/* Open user accounting database.
50
51 This function is a possible cancellation point and therefore not
52 marked with __THROW. */
53extern void setutxent (void);
54
55/* Close user accounting database.
56
57 This function is a possible cancellation point and therefore not
58 marked with __THROW. */
59extern void endutxent (void);
60
61/* Get the next entry from the user accounting database.
62
63 This function is a possible cancellation point and therefore not
64 marked with __THROW. */
65extern struct utmpx *getutxent (void);
66
67/* Get the user accounting database entry corresponding to ID.
68
69 This function is a possible cancellation point and therefore not
70 marked with __THROW. */
71extern struct utmpx *getutxid (const struct utmpx *__id);
72
73/* Get the user accounting database entry corresponding to LINE.
74
75 This function is a possible cancellation point and therefore not
76 marked with __THROW. */
77extern struct utmpx *getutxline (const struct utmpx *__line);
78
79/* Write the entry UTMPX into the user accounting database.
80
81 This function is a possible cancellation point and therefore not
82 marked with __THROW. */
83extern struct utmpx *pututxline (const struct utmpx *__utmpx);
84
85
86#ifdef __USE_GNU
87/* Change name of the utmpx file to be examined.
88
89 This function is not part of POSIX and therefore no official
90 cancellation point. But due to similarity with an POSIX interface
91 or due to the implementation it is a cancellation point and
92 therefore not marked with __THROW. */
93extern int utmpxname (const char *__file);
94
95/* Append entry UTMP to the wtmpx-like file WTMPX_FILE.
96
97 This function is not part of POSIX and therefore no official
98 cancellation point. But due to similarity with an POSIX interface
99 or due to the implementation it is a cancellation point and
100 therefore not marked with __THROW. */
101extern void updwtmpx (const char *__wtmpx_file,
102 const struct utmpx *__utmpx);
103
104
105/* Copy the information in UTMPX to UTMP.
106
107 This function is not part of POSIX and therefore no official
108 cancellation point. But due to similarity with an POSIX interface
109 or due to the implementation it is a cancellation point and
110 therefore not marked with __THROW. */
111extern void getutmp (const struct utmpx *__utmpx,
112 struct utmp *__utmp);
113
114/* Copy the information in UTMP to UTMPX.
115
116 This function is not part of POSIX and therefore no official
117 cancellation point. But due to similarity with an POSIX interface
118 or due to the implementation it is a cancellation point and
119 therefore not marked with __THROW. */
120extern void getutmpx (const struct utmp *__utmp, struct utmpx *__utmpx);
121#endif
122
123__END_DECLS
124
125#endif /* utmpx.h */
libc/glibc-include/values.h created+68
...@@ -0,0 +1,68 @@
1/* Old compatibility names for <limits.h> and <float.h> constants.
2 Copyright (C) 1995-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19/* This interface is obsolete. New programs should use
20 <limits.h> and/or <float.h> instead of <values.h>. */
21
22#ifndef _VALUES_H
23#define _VALUES_H 1
24
25#include <features.h>
26
27#include <limits.h>
28
29#define _TYPEBITS(type) (sizeof (type) * CHAR_BIT)
30
31#define CHARBITS _TYPEBITS (char)
32#define SHORTBITS _TYPEBITS (short int)
33#define INTBITS _TYPEBITS (int)
34#define LONGBITS _TYPEBITS (long int)
35#define PTRBITS _TYPEBITS (char *)
36#define DOUBLEBITS _TYPEBITS (double)
37#define FLOATBITS _TYPEBITS (float)
38
39#define MINSHORT SHRT_MIN
40#define MININT INT_MIN
41#define MINLONG LONG_MIN
42
43#define MAXSHORT SHRT_MAX
44#define MAXINT INT_MAX
45#define MAXLONG LONG_MAX
46
47#define HIBITS MINSHORT
48#define HIBITL MINLONG
49
50
51#include <float.h>
52
53#define MAXDOUBLE DBL_MAX
54#define MAXFLOAT FLT_MAX
55#define MINDOUBLE DBL_MIN
56#define MINFLOAT FLT_MIN
57#define DMINEXP DBL_MIN_EXP
58#define FMINEXP FLT_MIN_EXP
59#define DMAXEXP DBL_MAX_EXP
60#define FMAXEXP FLT_MAX_EXP
61
62
63#ifdef __USE_MISC
64/* Some systems define this name instead of CHAR_BIT or CHARBITS. */
65# define BITSPERBYTE CHAR_BIT
66#endif
67
68#endif /* values.h */
libc/glibc-include/wait.h created+1
...@@ -0,0 +1 @@
1#include <sys/wait.h>
libc/glibc-include/wchar.h created+857
...@@ -0,0 +1,857 @@
1/* Copyright (C) 1995-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/*
19 * ISO C99 Standard: 7.24
20 * Extended multibyte and wide character utilities <wchar.h>
21 */
22
23#ifndef _WCHAR_H
24#define _WCHAR_H 1
25
26#define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION
27#include <bits/libc-header-start.h>
28
29/* Gather machine dependent type support. */
30#include <bits/floatn.h>
31
32#define __need_size_t
33#define __need_wchar_t
34#define __need_NULL
35#include <stddef.h>
36
37#define __need___va_list
38#include <stdarg.h>
39
40#include <bits/wchar.h>
41#include <bits/types/wint_t.h>
42#include <bits/types/mbstate_t.h>
43#include <bits/types/__FILE.h>
44
45#if defined __USE_UNIX98 || defined __USE_XOPEN2K
46# include <bits/types/FILE.h>
47#endif
48#ifdef __USE_XOPEN2K8
49# include <bits/types/locale_t.h>
50#endif
51
52/* Tell the caller that we provide correct C++ prototypes. */
53#if defined __cplusplus && __GNUC_PREREQ (4, 4)
54# define __CORRECT_ISO_CPP_WCHAR_H_PROTO
55#endif
56
57#ifndef WCHAR_MIN
58/* These constants might also be defined in <inttypes.h>. */
59# define WCHAR_MIN __WCHAR_MIN
60# define WCHAR_MAX __WCHAR_MAX
61#endif
62
63#ifndef WEOF
64# define WEOF (0xffffffffu)
65#endif
66
67/* All versions of XPG prior to the publication of ISO C99 required
68 the bulk of <wctype.h>'s declarations to appear in this header
69 (because <wctype.h> did not exist prior to C99). In POSIX.1-2001
70 those declarations were marked as XSI extensions; in -2008 they
71 were additionally marked as obsolescent. _GNU_SOURCE mode
72 anticipates the removal of these declarations in the next revision
73 of POSIX. */
74#if (defined __USE_XOPEN && !defined __USE_GNU \
75 && !(defined __USE_XOPEN2K && !defined __USE_XOPEN2KXSI))
76# include <bits/wctype-wchar.h>
77#endif
78
79__BEGIN_DECLS
80
81/* This incomplete type is defined in <time.h> but needed here because
82 of `wcsftime'. */
83struct tm;
84
85
86/* Copy SRC to DEST. */
87extern wchar_t *wcscpy (wchar_t *__restrict __dest,
88 const wchar_t *__restrict __src)
89 __THROW __nonnull ((1, 2));
90
91/* Copy no more than N wide-characters of SRC to DEST. */
92extern wchar_t *wcsncpy (wchar_t *__restrict __dest,
93 const wchar_t *__restrict __src, size_t __n)
94 __THROW __nonnull ((1, 2));
95
96/* Append SRC onto DEST. */
97extern wchar_t *wcscat (wchar_t *__restrict __dest,
98 const wchar_t *__restrict __src)
99 __THROW __nonnull ((1, 2));
100/* Append no more than N wide-characters of SRC onto DEST. */
101extern wchar_t *wcsncat (wchar_t *__restrict __dest,
102 const wchar_t *__restrict __src, size_t __n)
103 __THROW __nonnull ((1, 2));
104
105/* Compare S1 and S2. */
106extern int wcscmp (const wchar_t *__s1, const wchar_t *__s2)
107 __THROW __attribute_pure__ __nonnull ((1, 2));
108/* Compare N wide-characters of S1 and S2. */
109extern int wcsncmp (const wchar_t *__s1, const wchar_t *__s2, size_t __n)
110 __THROW __attribute_pure__ __nonnull ((1, 2));
111
112#ifdef __USE_XOPEN2K8
113/* Compare S1 and S2, ignoring case. */
114extern int wcscasecmp (const wchar_t *__s1, const wchar_t *__s2) __THROW;
115
116/* Compare no more than N chars of S1 and S2, ignoring case. */
117extern int wcsncasecmp (const wchar_t *__s1, const wchar_t *__s2,
118 size_t __n) __THROW;
119
120/* Similar to the two functions above but take the information from
121 the provided locale and not the global locale. */
122extern int wcscasecmp_l (const wchar_t *__s1, const wchar_t *__s2,
123 locale_t __loc) __THROW;
124
125extern int wcsncasecmp_l (const wchar_t *__s1, const wchar_t *__s2,
126 size_t __n, locale_t __loc) __THROW;
127#endif
128
129/* Compare S1 and S2, both interpreted as appropriate to the
130 LC_COLLATE category of the current locale. */
131extern int wcscoll (const wchar_t *__s1, const wchar_t *__s2) __THROW;
132/* Transform S2 into array pointed to by S1 such that if wcscmp is
133 applied to two transformed strings the result is the as applying
134 `wcscoll' to the original strings. */
135extern size_t wcsxfrm (wchar_t *__restrict __s1,
136 const wchar_t *__restrict __s2, size_t __n) __THROW;
137
138#ifdef __USE_XOPEN2K8
139/* Similar to the two functions above but take the information from
140 the provided locale and not the global locale. */
141
142/* Compare S1 and S2, both interpreted as appropriate to the
143 LC_COLLATE category of the given locale. */
144extern int wcscoll_l (const wchar_t *__s1, const wchar_t *__s2,
145 locale_t __loc) __THROW;
146
147/* Transform S2 into array pointed to by S1 such that if wcscmp is
148 applied to two transformed strings the result is the as applying
149 `wcscoll' to the original strings. */
150extern size_t wcsxfrm_l (wchar_t *__s1, const wchar_t *__s2,
151 size_t __n, locale_t __loc) __THROW;
152
153/* Duplicate S, returning an identical malloc'd string. */
154extern wchar_t *wcsdup (const wchar_t *__s) __THROW __attribute_malloc__;
155#endif
156
157/* Find the first occurrence of WC in WCS. */
158#ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO
159extern "C++" wchar_t *wcschr (wchar_t *__wcs, wchar_t __wc)
160 __THROW __asm ("wcschr") __attribute_pure__;
161extern "C++" const wchar_t *wcschr (const wchar_t *__wcs, wchar_t __wc)
162 __THROW __asm ("wcschr") __attribute_pure__;
163#else
164extern wchar_t *wcschr (const wchar_t *__wcs, wchar_t __wc)
165 __THROW __attribute_pure__;
166#endif
167/* Find the last occurrence of WC in WCS. */
168#ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO
169extern "C++" wchar_t *wcsrchr (wchar_t *__wcs, wchar_t __wc)
170 __THROW __asm ("wcsrchr") __attribute_pure__;
171extern "C++" const wchar_t *wcsrchr (const wchar_t *__wcs, wchar_t __wc)
172 __THROW __asm ("wcsrchr") __attribute_pure__;
173#else
174extern wchar_t *wcsrchr (const wchar_t *__wcs, wchar_t __wc)
175 __THROW __attribute_pure__;
176#endif
177
178#ifdef __USE_GNU
179/* This function is similar to `wcschr'. But it returns a pointer to
180 the closing NUL wide character in case C is not found in S. */
181extern wchar_t *wcschrnul (const wchar_t *__s, wchar_t __wc)
182 __THROW __attribute_pure__;
183#endif
184
185/* Return the length of the initial segmet of WCS which
186 consists entirely of wide characters not in REJECT. */
187extern size_t wcscspn (const wchar_t *__wcs, const wchar_t *__reject)
188 __THROW __attribute_pure__;
189/* Return the length of the initial segmet of WCS which
190 consists entirely of wide characters in ACCEPT. */
191extern size_t wcsspn (const wchar_t *__wcs, const wchar_t *__accept)
192 __THROW __attribute_pure__;
193/* Find the first occurrence in WCS of any character in ACCEPT. */
194#ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO
195extern "C++" wchar_t *wcspbrk (wchar_t *__wcs, const wchar_t *__accept)
196 __THROW __asm ("wcspbrk") __attribute_pure__;
197extern "C++" const wchar_t *wcspbrk (const wchar_t *__wcs,
198 const wchar_t *__accept)
199 __THROW __asm ("wcspbrk") __attribute_pure__;
200#else
201extern wchar_t *wcspbrk (const wchar_t *__wcs, const wchar_t *__accept)
202 __THROW __attribute_pure__;
203#endif
204/* Find the first occurrence of NEEDLE in HAYSTACK. */
205#ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO
206extern "C++" wchar_t *wcsstr (wchar_t *__haystack, const wchar_t *__needle)
207 __THROW __asm ("wcsstr") __attribute_pure__;
208extern "C++" const wchar_t *wcsstr (const wchar_t *__haystack,
209 const wchar_t *__needle)
210 __THROW __asm ("wcsstr") __attribute_pure__;
211#else
212extern wchar_t *wcsstr (const wchar_t *__haystack, const wchar_t *__needle)
213 __THROW __attribute_pure__;
214#endif
215
216/* Divide WCS into tokens separated by characters in DELIM. */
217extern wchar_t *wcstok (wchar_t *__restrict __s,
218 const wchar_t *__restrict __delim,
219 wchar_t **__restrict __ptr) __THROW;
220
221/* Return the number of wide characters in S. */
222extern size_t wcslen (const wchar_t *__s) __THROW __attribute_pure__;
223
224#ifdef __USE_XOPEN
225/* Another name for `wcsstr' from XPG4. */
226# ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO
227extern "C++" wchar_t *wcswcs (wchar_t *__haystack, const wchar_t *__needle)
228 __THROW __asm ("wcswcs") __attribute_pure__;
229extern "C++" const wchar_t *wcswcs (const wchar_t *__haystack,
230 const wchar_t *__needle)
231 __THROW __asm ("wcswcs") __attribute_pure__;
232# else
233extern wchar_t *wcswcs (const wchar_t *__haystack, const wchar_t *__needle)
234 __THROW __attribute_pure__;
235# endif
236#endif
237
238#ifdef __USE_XOPEN2K8
239/* Return the number of wide characters in S, but at most MAXLEN. */
240extern size_t wcsnlen (const wchar_t *__s, size_t __maxlen)
241 __THROW __attribute_pure__;
242#endif
243
244
245/* Search N wide characters of S for C. */
246#ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO
247extern "C++" wchar_t *wmemchr (wchar_t *__s, wchar_t __c, size_t __n)
248 __THROW __asm ("wmemchr") __attribute_pure__;
249extern "C++" const wchar_t *wmemchr (const wchar_t *__s, wchar_t __c,
250 size_t __n)
251 __THROW __asm ("wmemchr") __attribute_pure__;
252#else
253extern wchar_t *wmemchr (const wchar_t *__s, wchar_t __c, size_t __n)
254 __THROW __attribute_pure__;
255#endif
256
257/* Compare N wide characters of S1 and S2. */
258extern int wmemcmp (const wchar_t *__s1, const wchar_t *__s2, size_t __n)
259 __THROW __attribute_pure__;
260
261/* Copy N wide characters of SRC to DEST. */
262extern wchar_t *wmemcpy (wchar_t *__restrict __s1,
263 const wchar_t *__restrict __s2, size_t __n) __THROW;
264
265/* Copy N wide characters of SRC to DEST, guaranteeing
266 correct behavior for overlapping strings. */
267extern wchar_t *wmemmove (wchar_t *__s1, const wchar_t *__s2, size_t __n)
268 __THROW;
269
270/* Set N wide characters of S to C. */
271extern wchar_t *wmemset (wchar_t *__s, wchar_t __c, size_t __n) __THROW;
272
273#ifdef __USE_GNU
274/* Copy N wide characters of SRC to DEST and return pointer to following
275 wide character. */
276extern wchar_t *wmempcpy (wchar_t *__restrict __s1,
277 const wchar_t *__restrict __s2, size_t __n)
278 __THROW;
279#endif
280
281
282/* Determine whether C constitutes a valid (one-byte) multibyte
283 character. */
284extern wint_t btowc (int __c) __THROW;
285
286/* Determine whether C corresponds to a member of the extended
287 character set whose multibyte representation is a single byte. */
288extern int wctob (wint_t __c) __THROW;
289
290/* Determine whether PS points to an object representing the initial
291 state. */
292extern int mbsinit (const mbstate_t *__ps) __THROW __attribute_pure__;
293
294/* Write wide character representation of multibyte character pointed
295 to by S to PWC. */
296extern size_t mbrtowc (wchar_t *__restrict __pwc,
297 const char *__restrict __s, size_t __n,
298 mbstate_t *__restrict __p) __THROW;
299
300/* Write multibyte representation of wide character WC to S. */
301extern size_t wcrtomb (char *__restrict __s, wchar_t __wc,
302 mbstate_t *__restrict __ps) __THROW;
303
304/* Return number of bytes in multibyte character pointed to by S. */
305extern size_t __mbrlen (const char *__restrict __s, size_t __n,
306 mbstate_t *__restrict __ps) __THROW;
307extern size_t mbrlen (const char *__restrict __s, size_t __n,
308 mbstate_t *__restrict __ps) __THROW;
309
310#ifdef __USE_EXTERN_INLINES
311/* Define inline function as optimization. */
312
313/* We can use the BTOWC and WCTOB optimizations since we know that all
314 locales must use ASCII encoding for the values in the ASCII range
315 and because the wchar_t encoding is always ISO 10646. */
316extern wint_t __btowc_alias (int __c) __asm ("btowc");
317__extern_inline wint_t
318__NTH (btowc (int __c))
319{ return (__builtin_constant_p (__c) && __c >= '\0' && __c <= '\x7f'
320 ? (wint_t) __c : __btowc_alias (__c)); }
321
322extern int __wctob_alias (wint_t __c) __asm ("wctob");
323__extern_inline int
324__NTH (wctob (wint_t __wc))
325{ return (__builtin_constant_p (__wc) && __wc >= L'\0' && __wc <= L'\x7f'
326 ? (int) __wc : __wctob_alias (__wc)); }
327
328__extern_inline size_t
329__NTH (mbrlen (const char *__restrict __s, size_t __n,
330 mbstate_t *__restrict __ps))
331{ return (__ps != NULL
332 ? mbrtowc (NULL, __s, __n, __ps) : __mbrlen (__s, __n, NULL)); }
333#endif
334
335/* Write wide character representation of multibyte character string
336 SRC to DST. */
337extern size_t mbsrtowcs (wchar_t *__restrict __dst,
338 const char **__restrict __src, size_t __len,
339 mbstate_t *__restrict __ps) __THROW;
340
341/* Write multibyte character representation of wide character string
342 SRC to DST. */
343extern size_t wcsrtombs (char *__restrict __dst,
344 const wchar_t **__restrict __src, size_t __len,
345 mbstate_t *__restrict __ps) __THROW;
346
347
348#ifdef __USE_XOPEN2K8
349/* Write wide character representation of at most NMC bytes of the
350 multibyte character string SRC to DST. */
351extern size_t mbsnrtowcs (wchar_t *__restrict __dst,
352 const char **__restrict __src, size_t __nmc,
353 size_t __len, mbstate_t *__restrict __ps) __THROW;
354
355/* Write multibyte character representation of at most NWC characters
356 from the wide character string SRC to DST. */
357extern size_t wcsnrtombs (char *__restrict __dst,
358 const wchar_t **__restrict __src,
359 size_t __nwc, size_t __len,
360 mbstate_t *__restrict __ps) __THROW;
361#endif /* use POSIX 2008 */
362
363
364/* The following functions are extensions found in X/Open CAE. */
365#ifdef __USE_XOPEN
366/* Determine number of column positions required for C. */
367extern int wcwidth (wchar_t __c) __THROW;
368
369/* Determine number of column positions required for first N wide
370 characters (or fewer if S ends before this) in S. */
371extern int wcswidth (const wchar_t *__s, size_t __n) __THROW;
372#endif /* Use X/Open. */
373
374
375/* Convert initial portion of the wide string NPTR to `double'
376 representation. */
377extern double wcstod (const wchar_t *__restrict __nptr,
378 wchar_t **__restrict __endptr) __THROW;
379
380#ifdef __USE_ISOC99
381/* Likewise for `float' and `long double' sizes of floating-point numbers. */
382extern float wcstof (const wchar_t *__restrict __nptr,
383 wchar_t **__restrict __endptr) __THROW;
384extern long double wcstold (const wchar_t *__restrict __nptr,
385 wchar_t **__restrict __endptr) __THROW;
386#endif /* C99 */
387
388/* Likewise for `_FloatN' and `_FloatNx' when support is enabled. */
389
390#if __HAVE_FLOAT16 && defined __USE_GNU
391extern _Float16 wcstof16 (const wchar_t *__restrict __nptr,
392 wchar_t **__restrict __endptr) __THROW;
393#endif
394
395#if __HAVE_FLOAT32 && defined __USE_GNU
396extern _Float32 wcstof32 (const wchar_t *__restrict __nptr,
397 wchar_t **__restrict __endptr) __THROW;
398#endif
399
400#if __HAVE_FLOAT64 && defined __USE_GNU
401extern _Float64 wcstof64 (const wchar_t *__restrict __nptr,
402 wchar_t **__restrict __endptr) __THROW;
403#endif
404
405#if __HAVE_FLOAT128 && defined __USE_GNU
406extern _Float128 wcstof128 (const wchar_t *__restrict __nptr,
407 wchar_t **__restrict __endptr) __THROW;
408#endif
409
410#if __HAVE_FLOAT32X && defined __USE_GNU
411extern _Float32x wcstof32x (const wchar_t *__restrict __nptr,
412 wchar_t **__restrict __endptr) __THROW;
413#endif
414
415#if __HAVE_FLOAT64X && defined __USE_GNU
416extern _Float64x wcstof64x (const wchar_t *__restrict __nptr,
417 wchar_t **__restrict __endptr) __THROW;
418#endif
419
420#if __HAVE_FLOAT128X && defined __USE_GNU
421extern _Float128x wcstof128x (const wchar_t *__restrict __nptr,
422 wchar_t **__restrict __endptr) __THROW;
423#endif
424
425
426/* Convert initial portion of wide string NPTR to `long int'
427 representation. */
428extern long int wcstol (const wchar_t *__restrict __nptr,
429 wchar_t **__restrict __endptr, int __base) __THROW;
430
431/* Convert initial portion of wide string NPTR to `unsigned long int'
432 representation. */
433extern unsigned long int wcstoul (const wchar_t *__restrict __nptr,
434 wchar_t **__restrict __endptr, int __base)
435 __THROW;
436
437#ifdef __USE_ISOC99
438/* Convert initial portion of wide string NPTR to `long long int'
439 representation. */
440__extension__
441extern long long int wcstoll (const wchar_t *__restrict __nptr,
442 wchar_t **__restrict __endptr, int __base)
443 __THROW;
444
445/* Convert initial portion of wide string NPTR to `unsigned long long int'
446 representation. */
447__extension__
448extern unsigned long long int wcstoull (const wchar_t *__restrict __nptr,
449 wchar_t **__restrict __endptr,
450 int __base) __THROW;
451#endif /* ISO C99. */
452
453#ifdef __USE_GNU
454/* Convert initial portion of wide string NPTR to `long long int'
455 representation. */
456__extension__
457extern long long int wcstoq (const wchar_t *__restrict __nptr,
458 wchar_t **__restrict __endptr, int __base)
459 __THROW;
460
461/* Convert initial portion of wide string NPTR to `unsigned long long int'
462 representation. */
463__extension__
464extern unsigned long long int wcstouq (const wchar_t *__restrict __nptr,
465 wchar_t **__restrict __endptr,
466 int __base) __THROW;
467#endif /* Use GNU. */
468
469#ifdef __USE_GNU
470/* Parallel versions of the functions above which take the locale to
471 use as an additional parameter. These are GNU extensions inspired
472 by the POSIX.1-2008 extended locale API. */
473extern long int wcstol_l (const wchar_t *__restrict __nptr,
474 wchar_t **__restrict __endptr, int __base,
475 locale_t __loc) __THROW;
476
477extern unsigned long int wcstoul_l (const wchar_t *__restrict __nptr,
478 wchar_t **__restrict __endptr,
479 int __base, locale_t __loc) __THROW;
480
481__extension__
482extern long long int wcstoll_l (const wchar_t *__restrict __nptr,
483 wchar_t **__restrict __endptr,
484 int __base, locale_t __loc) __THROW;
485
486__extension__
487extern unsigned long long int wcstoull_l (const wchar_t *__restrict __nptr,
488 wchar_t **__restrict __endptr,
489 int __base, locale_t __loc)
490 __THROW;
491
492extern double wcstod_l (const wchar_t *__restrict __nptr,
493 wchar_t **__restrict __endptr, locale_t __loc)
494 __THROW;
495
496extern float wcstof_l (const wchar_t *__restrict __nptr,
497 wchar_t **__restrict __endptr, locale_t __loc)
498 __THROW;
499
500extern long double wcstold_l (const wchar_t *__restrict __nptr,
501 wchar_t **__restrict __endptr,
502 locale_t __loc) __THROW;
503
504# if __HAVE_FLOAT16
505extern _Float16 wcstof16_l (const wchar_t *__restrict __nptr,
506 wchar_t **__restrict __endptr,
507 locale_t __loc) __THROW;
508# endif
509
510# if __HAVE_FLOAT32
511extern _Float32 wcstof32_l (const wchar_t *__restrict __nptr,
512 wchar_t **__restrict __endptr,
513 locale_t __loc) __THROW;
514# endif
515
516# if __HAVE_FLOAT64
517extern _Float64 wcstof64_l (const wchar_t *__restrict __nptr,
518 wchar_t **__restrict __endptr,
519 locale_t __loc) __THROW;
520# endif
521
522# if __HAVE_FLOAT128
523extern _Float128 wcstof128_l (const wchar_t *__restrict __nptr,
524 wchar_t **__restrict __endptr,
525 locale_t __loc) __THROW;
526# endif
527
528# if __HAVE_FLOAT32X
529extern _Float32x wcstof32x_l (const wchar_t *__restrict __nptr,
530 wchar_t **__restrict __endptr,
531 locale_t __loc) __THROW;
532# endif
533
534# if __HAVE_FLOAT64X
535extern _Float64x wcstof64x_l (const wchar_t *__restrict __nptr,
536 wchar_t **__restrict __endptr,
537 locale_t __loc) __THROW;
538# endif
539
540# if __HAVE_FLOAT128X
541extern _Float128x wcstof128x_l (const wchar_t *__restrict __nptr,
542 wchar_t **__restrict __endptr,
543 locale_t __loc) __THROW;
544# endif
545#endif /* use GNU */
546
547
548#ifdef __USE_XOPEN2K8
549/* Copy SRC to DEST, returning the address of the terminating L'\0' in
550 DEST. */
551extern wchar_t *wcpcpy (wchar_t *__restrict __dest,
552 const wchar_t *__restrict __src) __THROW;
553
554/* Copy no more than N characters of SRC to DEST, returning the address of
555 the last character written into DEST. */
556extern wchar_t *wcpncpy (wchar_t *__restrict __dest,
557 const wchar_t *__restrict __src, size_t __n)
558 __THROW;
559#endif
560
561
562/* Wide character I/O functions. */
563
564#if defined __USE_XOPEN2K8 || __GLIBC_USE (LIB_EXT2)
565/* Like OPEN_MEMSTREAM, but the stream is wide oriented and produces
566 a wide character string. */
567extern __FILE *open_wmemstream (wchar_t **__bufloc, size_t *__sizeloc) __THROW;
568#endif
569
570#if defined __USE_ISOC95 || defined __USE_UNIX98
571
572/* Select orientation for stream. */
573extern int fwide (__FILE *__fp, int __mode) __THROW;
574
575
576/* Write formatted output to STREAM.
577
578 This function is a possible cancellation point and therefore not
579 marked with __THROW. */
580extern int fwprintf (__FILE *__restrict __stream,
581 const wchar_t *__restrict __format, ...)
582 /* __attribute__ ((__format__ (__wprintf__, 2, 3))) */;
583/* Write formatted output to stdout.
584
585 This function is a possible cancellation point and therefore not
586 marked with __THROW. */
587extern int wprintf (const wchar_t *__restrict __format, ...)
588 /* __attribute__ ((__format__ (__wprintf__, 1, 2))) */;
589/* Write formatted output of at most N characters to S. */
590extern int swprintf (wchar_t *__restrict __s, size_t __n,
591 const wchar_t *__restrict __format, ...)
592 __THROW /* __attribute__ ((__format__ (__wprintf__, 3, 4))) */;
593
594/* Write formatted output to S from argument list ARG.
595
596 This function is a possible cancellation point and therefore not
597 marked with __THROW. */
598extern int vfwprintf (__FILE *__restrict __s,
599 const wchar_t *__restrict __format,
600 __gnuc_va_list __arg)
601 /* __attribute__ ((__format__ (__wprintf__, 2, 0))) */;
602/* Write formatted output to stdout from argument list ARG.
603
604 This function is a possible cancellation point and therefore not
605 marked with __THROW. */
606extern int vwprintf (const wchar_t *__restrict __format,
607 __gnuc_va_list __arg)
608 /* __attribute__ ((__format__ (__wprintf__, 1, 0))) */;
609/* Write formatted output of at most N character to S from argument
610 list ARG. */
611extern int vswprintf (wchar_t *__restrict __s, size_t __n,
612 const wchar_t *__restrict __format,
613 __gnuc_va_list __arg)
614 __THROW /* __attribute__ ((__format__ (__wprintf__, 3, 0))) */;
615
616
617/* Read formatted input from STREAM.
618
619 This function is a possible cancellation point and therefore not
620 marked with __THROW. */
621extern int fwscanf (__FILE *__restrict __stream,
622 const wchar_t *__restrict __format, ...)
623 /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */;
624/* Read formatted input from stdin.
625
626 This function is a possible cancellation point and therefore not
627 marked with __THROW. */
628extern int wscanf (const wchar_t *__restrict __format, ...)
629 /* __attribute__ ((__format__ (__wscanf__, 1, 2))) */;
630/* Read formatted input from S. */
631extern int swscanf (const wchar_t *__restrict __s,
632 const wchar_t *__restrict __format, ...)
633 __THROW /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */;
634
635/* For historical reasons, the C99-compliant versions of the scanf
636 functions are at alternative names. When __LDBL_COMPAT is in
637 effect, this is handled in bits/wchar-ldbl.h. */
638#if !__GLIBC_USE (DEPRECATED_SCANF) && !defined __LDBL_COMPAT
639# ifdef __REDIRECT
640extern int __REDIRECT (fwscanf, (__FILE *__restrict __stream,
641 const wchar_t *__restrict __format, ...),
642 __isoc99_fwscanf)
643 /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */;
644extern int __REDIRECT (wscanf, (const wchar_t *__restrict __format, ...),
645 __isoc99_wscanf)
646 /* __attribute__ ((__format__ (__wscanf__, 1, 2))) */;
647extern int __REDIRECT_NTH (swscanf, (const wchar_t *__restrict __s,
648 const wchar_t *__restrict __format,
649 ...), __isoc99_swscanf)
650 /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */;
651# else
652extern int __isoc99_fwscanf (__FILE *__restrict __stream,
653 const wchar_t *__restrict __format, ...);
654extern int __isoc99_wscanf (const wchar_t *__restrict __format, ...);
655extern int __isoc99_swscanf (const wchar_t *__restrict __s,
656 const wchar_t *__restrict __format, ...)
657 __THROW;
658# define fwscanf __isoc99_fwscanf
659# define wscanf __isoc99_wscanf
660# define swscanf __isoc99_swscanf
661# endif
662# endif
663
664#endif /* Use ISO C95, C99 and Unix98. */
665
666#ifdef __USE_ISOC99
667/* Read formatted input from S into argument list ARG.
668
669 This function is a possible cancellation point and therefore not
670 marked with __THROW. */
671extern int vfwscanf (__FILE *__restrict __s,
672 const wchar_t *__restrict __format,
673 __gnuc_va_list __arg)
674 /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */;
675/* Read formatted input from stdin into argument list ARG.
676
677 This function is a possible cancellation point and therefore not
678 marked with __THROW. */
679extern int vwscanf (const wchar_t *__restrict __format,
680 __gnuc_va_list __arg)
681 /* __attribute__ ((__format__ (__wscanf__, 1, 0))) */;
682/* Read formatted input from S into argument list ARG. */
683extern int vswscanf (const wchar_t *__restrict __s,
684 const wchar_t *__restrict __format,
685 __gnuc_va_list __arg)
686 __THROW /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */;
687
688# if !defined __USE_GNU \
689 && (!defined __LDBL_COMPAT || !defined __REDIRECT) \
690 && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)
691# ifdef __REDIRECT
692extern int __REDIRECT (vfwscanf, (__FILE *__restrict __s,
693 const wchar_t *__restrict __format,
694 __gnuc_va_list __arg), __isoc99_vfwscanf)
695 /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */;
696extern int __REDIRECT (vwscanf, (const wchar_t *__restrict __format,
697 __gnuc_va_list __arg), __isoc99_vwscanf)
698 /* __attribute__ ((__format__ (__wscanf__, 1, 0))) */;
699extern int __REDIRECT_NTH (vswscanf, (const wchar_t *__restrict __s,
700 const wchar_t *__restrict __format,
701 __gnuc_va_list __arg), __isoc99_vswscanf)
702 /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */;
703# else
704extern int __isoc99_vfwscanf (__FILE *__restrict __s,
705 const wchar_t *__restrict __format,
706 __gnuc_va_list __arg);
707extern int __isoc99_vwscanf (const wchar_t *__restrict __format,
708 __gnuc_va_list __arg);
709extern int __isoc99_vswscanf (const wchar_t *__restrict __s,
710 const wchar_t *__restrict __format,
711 __gnuc_va_list __arg) __THROW;
712# define vfwscanf __isoc99_vfwscanf
713# define vwscanf __isoc99_vwscanf
714# define vswscanf __isoc99_vswscanf
715# endif
716# endif
717
718#endif /* Use ISO C99. */
719
720
721/* Read a character from STREAM.
722
723 These functions are possible cancellation points and therefore not
724 marked with __THROW. */
725extern wint_t fgetwc (__FILE *__stream);
726extern wint_t getwc (__FILE *__stream);
727
728/* Read a character from stdin.
729
730 This function is a possible cancellation point and therefore not
731 marked with __THROW. */
732extern wint_t getwchar (void);
733
734
735/* Write a character to STREAM.
736
737 These functions are possible cancellation points and therefore not
738 marked with __THROW. */
739extern wint_t fputwc (wchar_t __wc, __FILE *__stream);
740extern wint_t putwc (wchar_t __wc, __FILE *__stream);
741
742/* Write a character to stdout.
743
744 This function is a possible cancellation point and therefore not
745 marked with __THROW. */
746extern wint_t putwchar (wchar_t __wc);
747
748
749/* Get a newline-terminated wide character string of finite length
750 from STREAM.
751
752 This function is a possible cancellation point and therefore not
753 marked with __THROW. */
754extern wchar_t *fgetws (wchar_t *__restrict __ws, int __n,
755 __FILE *__restrict __stream);
756
757/* Write a string to STREAM.
758
759 This function is a possible cancellation point and therefore not
760 marked with __THROW. */
761extern int fputws (const wchar_t *__restrict __ws,
762 __FILE *__restrict __stream);
763
764
765/* Push a character back onto the input buffer of STREAM.
766
767 This function is a possible cancellation point and therefore not
768 marked with __THROW. */
769extern wint_t ungetwc (wint_t __wc, __FILE *__stream);
770
771
772#ifdef __USE_GNU
773/* These are defined to be equivalent to the `char' functions defined
774 in POSIX.1:1996.
775
776 These functions are not part of POSIX and therefore no official
777 cancellation point. But due to similarity with an POSIX interface
778 or due to the implementation they are cancellation points and
779 therefore not marked with __THROW. */
780extern wint_t getwc_unlocked (__FILE *__stream);
781extern wint_t getwchar_unlocked (void);
782
783/* This is the wide character version of a GNU extension.
784
785 This function is not part of POSIX and therefore no official
786 cancellation point. But due to similarity with an POSIX interface
787 or due to the implementation it is a cancellation point and
788 therefore not marked with __THROW. */
789extern wint_t fgetwc_unlocked (__FILE *__stream);
790
791/* Faster version when locking is not necessary.
792
793 This function is not part of POSIX and therefore no official
794 cancellation point. But due to similarity with an POSIX interface
795 or due to the implementation it is a cancellation point and
796 therefore not marked with __THROW. */
797extern wint_t fputwc_unlocked (wchar_t __wc, __FILE *__stream);
798
799/* These are defined to be equivalent to the `char' functions defined
800 in POSIX.1:1996.
801
802 These functions are not part of POSIX and therefore no official
803 cancellation point. But due to similarity with an POSIX interface
804 or due to the implementation they are cancellation points and
805 therefore not marked with __THROW. */
806extern wint_t putwc_unlocked (wchar_t __wc, __FILE *__stream);
807extern wint_t putwchar_unlocked (wchar_t __wc);
808
809
810/* This function does the same as `fgetws' but does not lock the stream.
811
812 This function is not part of POSIX and therefore no official
813 cancellation point. But due to similarity with an POSIX interface
814 or due to the implementation it is a cancellation point and
815 therefore not marked with __THROW. */
816extern wchar_t *fgetws_unlocked (wchar_t *__restrict __ws, int __n,
817 __FILE *__restrict __stream);
818
819/* This function does the same as `fputws' but does not lock the stream.
820
821 This function is not part of POSIX and therefore no official
822 cancellation point. But due to similarity with an POSIX interface
823 or due to the implementation it is a cancellation point and
824 therefore not marked with __THROW. */
825extern int fputws_unlocked (const wchar_t *__restrict __ws,
826 __FILE *__restrict __stream);
827#endif
828
829
830/* Format TP into S according to FORMAT.
831 Write no more than MAXSIZE wide characters and return the number
832 of wide characters written, or 0 if it would exceed MAXSIZE. */
833extern size_t wcsftime (wchar_t *__restrict __s, size_t __maxsize,
834 const wchar_t *__restrict __format,
835 const struct tm *__restrict __tp) __THROW;
836
837# ifdef __USE_GNU
838/* Similar to `wcsftime' but takes the information from
839 the provided locale and not the global locale. */
840extern size_t wcsftime_l (wchar_t *__restrict __s, size_t __maxsize,
841 const wchar_t *__restrict __format,
842 const struct tm *__restrict __tp,
843 locale_t __loc) __THROW;
844# endif
845
846/* Define some macros helping to catch buffer overflows. */
847#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
848# include <bits/wchar2.h>
849#endif
850
851#ifdef __LDBL_COMPAT
852# include <bits/wchar-ldbl.h>
853#endif
854
855__END_DECLS
856
857#endif /* wchar.h */
libc/glibc-include/wctype.h created+148
...@@ -0,0 +1,148 @@
1/* Copyright (C) 1996-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/*
19 * ISO C99 Standard: 7.25
20 * Wide character classification and mapping utilities <wctype.h>
21 */
22
23#ifndef _WCTYPE_H
24#define _WCTYPE_H 1
25
26#include <features.h>
27#include <bits/types.h>
28#include <bits/types/wint_t.h>
29
30/* Constant expression of type `wint_t' whose value does not correspond
31 to any member of the extended character set. */
32#ifndef WEOF
33# define WEOF (0xffffffffu)
34#endif
35
36/* Some definitions from this header also appear in <wchar.h> in
37 Unix98 mode. */
38#include <bits/wctype-wchar.h>
39
40/*
41 * Extensible wide-character mapping functions: 7.15.3.2.
42 */
43
44__BEGIN_DECLS
45
46/* Scalar type that can hold values which represent locale-specific
47 character mappings. */
48typedef const __int32_t *wctrans_t;
49
50/* Construct value that describes a mapping between wide characters
51 identified by the string argument PROPERTY. */
52extern wctrans_t wctrans (const char *__property) __THROW;
53
54/* Map the wide character WC using the mapping described by DESC. */
55extern wint_t towctrans (wint_t __wc, wctrans_t __desc) __THROW;
56
57# ifdef __USE_XOPEN2K8
58/* POSIX.1-2008 extended locale interface (see locale.h). */
59# include <bits/types/locale_t.h>
60
61/* Test for any wide character for which `iswalpha' or `iswdigit' is
62 true. */
63extern int iswalnum_l (wint_t __wc, locale_t __locale) __THROW;
64
65/* Test for any wide character for which `iswupper' or 'iswlower' is
66 true, or any wide character that is one of a locale-specific set of
67 wide-characters for which none of `iswcntrl', `iswdigit',
68 `iswpunct', or `iswspace' is true. */
69extern int iswalpha_l (wint_t __wc, locale_t __locale) __THROW;
70
71/* Test for any control wide character. */
72extern int iswcntrl_l (wint_t __wc, locale_t __locale) __THROW;
73
74/* Test for any wide character that corresponds to a decimal-digit
75 character. */
76extern int iswdigit_l (wint_t __wc, locale_t __locale) __THROW;
77
78/* Test for any wide character for which `iswprint' is true and
79 `iswspace' is false. */
80extern int iswgraph_l (wint_t __wc, locale_t __locale) __THROW;
81
82/* Test for any wide character that corresponds to a lowercase letter
83 or is one of a locale-specific set of wide characters for which
84 none of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */
85extern int iswlower_l (wint_t __wc, locale_t __locale) __THROW;
86
87/* Test for any printing wide character. */
88extern int iswprint_l (wint_t __wc, locale_t __locale) __THROW;
89
90/* Test for any printing wide character that is one of a
91 locale-specific et of wide characters for which neither `iswspace'
92 nor `iswalnum' is true. */
93extern int iswpunct_l (wint_t __wc, locale_t __locale) __THROW;
94
95/* Test for any wide character that corresponds to a locale-specific
96 set of wide characters for which none of `iswalnum', `iswgraph', or
97 `iswpunct' is true. */
98extern int iswspace_l (wint_t __wc, locale_t __locale) __THROW;
99
100/* Test for any wide character that corresponds to an uppercase letter
101 or is one of a locale-specific set of wide character for which none
102 of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */
103extern int iswupper_l (wint_t __wc, locale_t __locale) __THROW;
104
105/* Test for any wide character that corresponds to a hexadecimal-digit
106 character equivalent to that performed be the functions described
107 in the previous subclause. */
108extern int iswxdigit_l (wint_t __wc, locale_t __locale) __THROW;
109
110/* Test for any wide character that corresponds to a standard blank
111 wide character or a locale-specific set of wide characters for
112 which `iswalnum' is false. */
113extern int iswblank_l (wint_t __wc, locale_t __locale) __THROW;
114
115/* Construct value that describes a class of wide characters identified
116 by the string argument PROPERTY. */
117extern wctype_t wctype_l (const char *__property, locale_t __locale)
118 __THROW;
119
120/* Determine whether the wide-character WC has the property described by
121 DESC. */
122extern int iswctype_l (wint_t __wc, wctype_t __desc, locale_t __locale)
123 __THROW;
124
125/*
126 * Wide-character case-mapping functions.
127 */
128
129/* Converts an uppercase letter to the corresponding lowercase letter. */
130extern wint_t towlower_l (wint_t __wc, locale_t __locale) __THROW;
131
132/* Converts an lowercase letter to the corresponding uppercase letter. */
133extern wint_t towupper_l (wint_t __wc, locale_t __locale) __THROW;
134
135/* Construct value that describes a mapping between wide characters
136 identified by the string argument PROPERTY. */
137extern wctrans_t wctrans_l (const char *__property, locale_t __locale)
138 __THROW;
139
140/* Map the wide character WC using the mapping described by DESC. */
141extern wint_t towctrans_l (wint_t __wc, wctrans_t __desc,
142 locale_t __locale) __THROW;
143
144# endif /* Use POSIX 2008. */
145
146__END_DECLS
147
148#endif /* wctype.h */
libc/glibc-include/wordexp.h created+70
...@@ -0,0 +1,70 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _WORDEXP_H
19#define _WORDEXP_H 1
20
21#include <features.h>
22#define __need_size_t
23#include <stddef.h>
24
25__BEGIN_DECLS
26
27/* Bits set in the FLAGS argument to `wordexp'. */
28enum
29 {
30 WRDE_DOOFFS = (1 << 0), /* Insert PWORDEXP->we_offs NULLs. */
31 WRDE_APPEND = (1 << 1), /* Append to results of a previous call. */
32 WRDE_NOCMD = (1 << 2), /* Don't do command substitution. */
33 WRDE_REUSE = (1 << 3), /* Reuse storage in PWORDEXP. */
34 WRDE_SHOWERR = (1 << 4), /* Don't redirect stderr to /dev/null. */
35 WRDE_UNDEF = (1 << 5), /* Error for expanding undefined variables. */
36 __WRDE_FLAGS = (WRDE_DOOFFS | WRDE_APPEND | WRDE_NOCMD |
37 WRDE_REUSE | WRDE_SHOWERR | WRDE_UNDEF)
38 };
39
40/* Structure describing a word-expansion run. */
41typedef struct
42 {
43 size_t we_wordc; /* Count of words matched. */
44 char **we_wordv; /* List of expanded words. */
45 size_t we_offs; /* Slots to reserve in `we_wordv'. */
46 } wordexp_t;
47
48/* Possible nonzero return values from `wordexp'. */
49enum
50 {
51#ifdef __USE_XOPEN
52 WRDE_NOSYS = -1, /* Never used since we support `wordexp'. */
53#endif
54 WRDE_NOSPACE = 1, /* Ran out of memory. */
55 WRDE_BADCHAR, /* A metachar appears in the wrong place. */
56 WRDE_BADVAL, /* Undefined var reference with WRDE_UNDEF. */
57 WRDE_CMDSUB, /* Command substitution with WRDE_NOCMD. */
58 WRDE_SYNTAX /* Shell syntax error. */
59 };
60
61/* Do word expansion of WORDS into PWORDEXP. */
62extern int wordexp (const char *__restrict __words,
63 wordexp_t *__restrict __pwordexp, int __flags);
64
65/* Free the storage allocated by a `wordexp' call. */
66extern void wordfree (wordexp_t *__wordexp) __THROW;
67
68__END_DECLS
69
70#endif /* wordexp.h */
libc/glibc/bits/byteswap.h created+79
...@@ -0,0 +1,79 @@
1/* Macros and inline functions to swap the order of bytes in integer values.
2 Copyright (C) 1997-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#if !defined _BYTESWAP_H && !defined _NETINET_IN_H && !defined _ENDIAN_H
20# error "Never use <bits/byteswap.h> directly; include <byteswap.h> instead."
21#endif
22
23#ifndef _BITS_BYTESWAP_H
24#define _BITS_BYTESWAP_H 1
25
26#include <features.h>
27#include <bits/types.h>
28
29/* Swap bytes in 16-bit value. */
30#define __bswap_constant_16(x) \
31 ((__uint16_t) ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8)))
32
33static __inline __uint16_t
34__bswap_16 (__uint16_t __bsx)
35{
36#if __GNUC_PREREQ (4, 8)
37 return __builtin_bswap16 (__bsx);
38#else
39 return __bswap_constant_16 (__bsx);
40#endif
41}
42
43/* Swap bytes in 32-bit value. */
44#define __bswap_constant_32(x) \
45 ((((x) & 0xff000000u) >> 24) | (((x) & 0x00ff0000u) >> 8) \
46 | (((x) & 0x0000ff00u) << 8) | (((x) & 0x000000ffu) << 24))
47
48static __inline __uint32_t
49__bswap_32 (__uint32_t __bsx)
50{
51#if __GNUC_PREREQ (4, 3)
52 return __builtin_bswap32 (__bsx);
53#else
54 return __bswap_constant_32 (__bsx);
55#endif
56}
57
58/* Swap bytes in 64-bit value. */
59#define __bswap_constant_64(x) \
60 ((((x) & 0xff00000000000000ull) >> 56) \
61 | (((x) & 0x00ff000000000000ull) >> 40) \
62 | (((x) & 0x0000ff0000000000ull) >> 24) \
63 | (((x) & 0x000000ff00000000ull) >> 8) \
64 | (((x) & 0x00000000ff000000ull) << 8) \
65 | (((x) & 0x0000000000ff0000ull) << 24) \
66 | (((x) & 0x000000000000ff00ull) << 40) \
67 | (((x) & 0x00000000000000ffull) << 56))
68
69__extension__ static __inline __uint64_t
70__bswap_64 (__uint64_t __bsx)
71{
72#if __GNUC_PREREQ (4, 3)
73 return __builtin_bswap64 (__bsx);
74#else
75 return __bswap_constant_64 (__bsx);
76#endif
77}
78
79#endif /* _BITS_BYTESWAP_H */
libc/glibc/bits/endian.h created+13
...@@ -0,0 +1,13 @@
1/* This file should define __BYTE_ORDER as appropriate for the machine
2 in question. See string/endian.h for how to define it.
3
4 If only the stub bits/endian.h applies to a particular configuration,
5 bytesex.h is generated by running a program on the host machine.
6 So if cross-compiling to a machine with a different byte order,
7 the bits/endian.h file for that machine must exist. */
8
9#ifndef _ENDIAN_H
10# error "Never use <bits/endian.h> directly; include <endian.h> instead."
11#endif
12
13#error Machine byte order unknown.
libc/glibc/bits/floatn-common.h created+329
...@@ -0,0 +1,329 @@
1/* Macros to control TS 18661-3 glibc features where the same
2 definitions are appropriate for all platforms.
3 Copyright (C) 2017-2019 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
19
20#ifndef _BITS_FLOATN_COMMON_H
21#define _BITS_FLOATN_COMMON_H
22
23#include <features.h>
24#include <bits/long-double.h>
25
26/* This header should be included at the bottom of each bits/floatn.h.
27 It defines the following macros for each _FloatN and _FloatNx type,
28 where the same definitions, or definitions based only on the macros
29 in bits/floatn.h, are appropriate for all glibc configurations. */
30
31/* Defined to 1 if the current compiler invocation provides a
32 floating-point type with the right format for this type, and this
33 glibc includes corresponding *fN or *fNx interfaces for it. */
34#define __HAVE_FLOAT16 0
35#define __HAVE_FLOAT32 1
36#define __HAVE_FLOAT64 1
37#define __HAVE_FLOAT32X 1
38#define __HAVE_FLOAT128X 0
39
40/* Defined to 1 if the corresponding __HAVE_<type> macro is 1 and the
41 type is the first with its format in the sequence of (the default
42 choices for) float, double, long double, _Float16, _Float32,
43 _Float64, _Float128, _Float32x, _Float64x, _Float128x for this
44 glibc; that is, if functions present once per floating-point format
45 rather than once per type are present for this type.
46
47 All configurations supported by glibc have _Float32 the same format
48 as float, _Float64 and _Float32x the same format as double, the
49 _Float64x the same format as either long double or _Float128. No
50 configurations support _Float128x or, as of GCC 7, have compiler
51 support for a type meeting the requirements for _Float128x. */
52#define __HAVE_DISTINCT_FLOAT16 __HAVE_FLOAT16
53#define __HAVE_DISTINCT_FLOAT32 0
54#define __HAVE_DISTINCT_FLOAT64 0
55#define __HAVE_DISTINCT_FLOAT32X 0
56#define __HAVE_DISTINCT_FLOAT64X 0
57#define __HAVE_DISTINCT_FLOAT128X __HAVE_FLOAT128X
58
59/* Defined to 1 if the corresponding _FloatN type is not binary compatible
60 with the corresponding ISO C type in the current compilation unit as
61 opposed to __HAVE_DISTINCT_FLOATN, which indicates the default types built
62 in glibc. */
63#define __HAVE_FLOAT128_UNLIKE_LDBL (__HAVE_DISTINCT_FLOAT128 \
64 && __LDBL_MANT_DIG__ != 113)
65
66/* Defined to 1 if any _FloatN or _FloatNx types that are not
67 ABI-distinct are however distinct types at the C language level (so
68 for the purposes of __builtin_types_compatible_p and _Generic). */
69#if __GNUC_PREREQ (7, 0) && !defined __cplusplus
70# define __HAVE_FLOATN_NOT_TYPEDEF 1
71#else
72# define __HAVE_FLOATN_NOT_TYPEDEF 0
73#endif
74
75#ifndef __ASSEMBLER__
76
77/* Defined to concatenate the literal suffix to be used with _FloatN
78 or _FloatNx types, if __HAVE_<type> is 1. The corresponding
79 literal suffixes exist since GCC 7, for C only. */
80# if __HAVE_FLOAT16
81# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
82/* No corresponding suffix available for this type. */
83# define __f16(x) ((_Float16) x##f)
84# else
85# define __f16(x) x##f16
86# endif
87# endif
88
89# if __HAVE_FLOAT32
90# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
91# define __f32(x) x##f
92# else
93# define __f32(x) x##f32
94# endif
95# endif
96
97# if __HAVE_FLOAT64
98# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
99# ifdef __NO_LONG_DOUBLE_MATH
100# define __f64(x) x##l
101# else
102# define __f64(x) x
103# endif
104# else
105# define __f64(x) x##f64
106# endif
107# endif
108
109# if __HAVE_FLOAT32X
110# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
111# define __f32x(x) x
112# else
113# define __f32x(x) x##f32x
114# endif
115# endif
116
117# if __HAVE_FLOAT64X
118# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
119# if __HAVE_FLOAT64X_LONG_DOUBLE
120# define __f64x(x) x##l
121# else
122# define __f64x(x) __f128 (x)
123# endif
124# else
125# define __f64x(x) x##f64x
126# endif
127# endif
128
129# if __HAVE_FLOAT128X
130# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
131# error "_Float128X supported but no constant suffix"
132# else
133# define __f128x(x) x##f128x
134# endif
135# endif
136
137/* Defined to a complex type if __HAVE_<type> is 1. */
138# if __HAVE_FLOAT16
139# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
140typedef _Complex float __cfloat16 __attribute__ ((__mode__ (__HC__)));
141# define __CFLOAT16 __cfloat16
142# else
143# define __CFLOAT16 _Complex _Float16
144# endif
145# endif
146
147# if __HAVE_FLOAT32
148# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
149# define __CFLOAT32 _Complex float
150# else
151# define __CFLOAT32 _Complex _Float32
152# endif
153# endif
154
155# if __HAVE_FLOAT64
156# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
157# ifdef __NO_LONG_DOUBLE_MATH
158# define __CFLOAT64 _Complex long double
159# else
160# define __CFLOAT64 _Complex double
161# endif
162# else
163# define __CFLOAT64 _Complex _Float64
164# endif
165# endif
166
167# if __HAVE_FLOAT32X
168# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
169# define __CFLOAT32X _Complex double
170# else
171# define __CFLOAT32X _Complex _Float32x
172# endif
173# endif
174
175# if __HAVE_FLOAT64X
176# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
177# if __HAVE_FLOAT64X_LONG_DOUBLE
178# define __CFLOAT64X _Complex long double
179# else
180# define __CFLOAT64X __CFLOAT128
181# endif
182# else
183# define __CFLOAT64X _Complex _Float64x
184# endif
185# endif
186
187# if __HAVE_FLOAT128X
188# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
189# error "_Float128X supported but no complex type"
190# else
191# define __CFLOAT128X _Complex _Float128x
192# endif
193# endif
194
195/* The remaining of this file provides support for older compilers. */
196# if __HAVE_FLOAT16
197
198# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
199typedef float _Float16 __attribute__ ((__mode__ (__HF__)));
200# endif
201
202# if !__GNUC_PREREQ (7, 0)
203# define __builtin_huge_valf16() ((_Float16) __builtin_huge_val ())
204# define __builtin_inff16() ((_Float16) __builtin_inf ())
205# define __builtin_nanf16(x) ((_Float16) __builtin_nan (x))
206# define __builtin_nansf16(x) ((_Float16) __builtin_nans (x))
207# endif
208
209# endif
210
211# if __HAVE_FLOAT32
212
213# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
214typedef float _Float32;
215# endif
216
217# if !__GNUC_PREREQ (7, 0)
218# define __builtin_huge_valf32() (__builtin_huge_valf ())
219# define __builtin_inff32() (__builtin_inff ())
220# define __builtin_nanf32(x) (__builtin_nanf (x))
221# define __builtin_nansf32(x) (__builtin_nansf (x))
222# endif
223
224# endif
225
226# if __HAVE_FLOAT64
227
228/* If double, long double and _Float64 all have the same set of
229 values, TS 18661-3 requires the usual arithmetic conversions on
230 long double and _Float64 to produce _Float64. For this to be the
231 case when building with a compiler without a distinct _Float64
232 type, _Float64 must be a typedef for long double, not for
233 double. */
234
235# ifdef __NO_LONG_DOUBLE_MATH
236
237# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
238typedef long double _Float64;
239# endif
240
241# if !__GNUC_PREREQ (7, 0)
242# define __builtin_huge_valf64() (__builtin_huge_vall ())
243# define __builtin_inff64() (__builtin_infl ())
244# define __builtin_nanf64(x) (__builtin_nanl (x))
245# define __builtin_nansf64(x) (__builtin_nansl (x))
246# endif
247
248# else
249
250# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
251typedef double _Float64;
252# endif
253
254# if !__GNUC_PREREQ (7, 0)
255# define __builtin_huge_valf64() (__builtin_huge_val ())
256# define __builtin_inff64() (__builtin_inf ())
257# define __builtin_nanf64(x) (__builtin_nan (x))
258# define __builtin_nansf64(x) (__builtin_nans (x))
259# endif
260
261# endif
262
263# endif
264
265# if __HAVE_FLOAT32X
266
267# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
268typedef double _Float32x;
269# endif
270
271# if !__GNUC_PREREQ (7, 0)
272# define __builtin_huge_valf32x() (__builtin_huge_val ())
273# define __builtin_inff32x() (__builtin_inf ())
274# define __builtin_nanf32x(x) (__builtin_nan (x))
275# define __builtin_nansf32x(x) (__builtin_nans (x))
276# endif
277
278# endif
279
280# if __HAVE_FLOAT64X
281
282# if __HAVE_FLOAT64X_LONG_DOUBLE
283
284# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
285typedef long double _Float64x;
286# endif
287
288# if !__GNUC_PREREQ (7, 0)
289# define __builtin_huge_valf64x() (__builtin_huge_vall ())
290# define __builtin_inff64x() (__builtin_infl ())
291# define __builtin_nanf64x(x) (__builtin_nanl (x))
292# define __builtin_nansf64x(x) (__builtin_nansl (x))
293# endif
294
295# else
296
297# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
298typedef _Float128 _Float64x;
299# endif
300
301# if !__GNUC_PREREQ (7, 0)
302# define __builtin_huge_valf64x() (__builtin_huge_valf128 ())
303# define __builtin_inff64x() (__builtin_inff128 ())
304# define __builtin_nanf64x(x) (__builtin_nanf128 (x))
305# define __builtin_nansf64x(x) (__builtin_nansf128 (x))
306# endif
307
308# endif
309
310# endif
311
312# if __HAVE_FLOAT128X
313
314# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
315# error "_Float128x supported but no type"
316# endif
317
318# if !__GNUC_PREREQ (7, 0)
319# define __builtin_huge_valf128x() ((_Float128x) __builtin_huge_val ())
320# define __builtin_inff128x() ((_Float128x) __builtin_inf ())
321# define __builtin_nanf128x(x) ((_Float128x) __builtin_nan (x))
322# define __builtin_nansf128x(x) ((_Float128x) __builtin_nans (x))
323# endif
324
325# endif
326
327#endif /* !__ASSEMBLER__. */
328
329#endif /* _BITS_FLOATN_COMMON_H */
libc/glibc/bits/libc-header-start.h created+70
...@@ -0,0 +1,70 @@
1/* Handle feature test macros at the start of a header.
2 Copyright (C) 2016-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19/* This header is internal to glibc and should not be included outside
20 of glibc headers. Headers including it must define
21 __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION first. This header
22 cannot have multiple include guards because ISO C feature test
23 macros depend on the definition of the macro when an affected
24 header is included, not when the first system header is
25 included. */
26
27#ifndef __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION
28# error "Never include <bits/libc-header-start.h> directly."
29#endif
30
31#undef __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION
32
33#include <features.h>
34
35/* ISO/IEC TR 24731-2:2010 defines the __STDC_WANT_LIB_EXT2__
36 macro. */
37#undef __GLIBC_USE_LIB_EXT2
38#if (defined __USE_GNU \
39 || (defined __STDC_WANT_LIB_EXT2__ && __STDC_WANT_LIB_EXT2__ > 0))
40# define __GLIBC_USE_LIB_EXT2 1
41#else
42# define __GLIBC_USE_LIB_EXT2 0
43#endif
44
45/* ISO/IEC TS 18661-1:2014 defines the __STDC_WANT_IEC_60559_BFP_EXT__
46 macro. */
47#undef __GLIBC_USE_IEC_60559_BFP_EXT
48#if defined __USE_GNU || defined __STDC_WANT_IEC_60559_BFP_EXT__
49# define __GLIBC_USE_IEC_60559_BFP_EXT 1
50#else
51# define __GLIBC_USE_IEC_60559_BFP_EXT 0
52#endif
53
54/* ISO/IEC TS 18661-4:2015 defines the
55 __STDC_WANT_IEC_60559_FUNCS_EXT__ macro. */
56#undef __GLIBC_USE_IEC_60559_FUNCS_EXT
57#if defined __USE_GNU || defined __STDC_WANT_IEC_60559_FUNCS_EXT__
58# define __GLIBC_USE_IEC_60559_FUNCS_EXT 1
59#else
60# define __GLIBC_USE_IEC_60559_FUNCS_EXT 0
61#endif
62
63/* ISO/IEC TS 18661-3:2015 defines the
64 __STDC_WANT_IEC_60559_TYPES_EXT__ macro. */
65#undef __GLIBC_USE_IEC_60559_TYPES_EXT
66#if defined __USE_GNU || defined __STDC_WANT_IEC_60559_TYPES_EXT__
67# define __GLIBC_USE_IEC_60559_TYPES_EXT 1
68#else
69# define __GLIBC_USE_IEC_60559_TYPES_EXT 0
70#endif
libc/glibc/bits/long-double.h created+39
...@@ -0,0 +1,39 @@
1/* Properties of long double type.
2 Copyright (C) 2016-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19/* This header is included by <sys/cdefs.h>.
20
21 If long double is ABI-compatible with double, it should define
22 __NO_LONG_DOUBLE_MATH to 1; otherwise, it should leave
23 __NO_LONG_DOUBLE_MATH undefined.
24
25 If this build of the GNU C Library supports both long double
26 ABI-compatible with double and some other long double format not
27 ABI-compatible with double, it should define
28 __LONG_DOUBLE_MATH_OPTIONAL to 1; otherwise, it should leave
29 __LONG_DOUBLE_MATH_OPTIONAL undefined.
30
31 If __NO_LONG_DOUBLE_MATH is already defined, this header must not
32 define anything; this is needed to work with the definition of
33 __NO_LONG_DOUBLE_MATH in nldbl-compat.h. */
34
35/* In the default version of this header, long double is
36 ABI-compatible with double. */
37#ifndef __NO_LONG_DOUBLE_MATH
38# define __NO_LONG_DOUBLE_MATH 1
39#endif
libc/glibc/bits/param.h created+33
...@@ -0,0 +1,33 @@
1/* Old-style Unix parameters and limits. Stub version.
2 Copyright (C) 1995-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SYS_PARAM_H
20# error "Never use <bits/param.h> directly; include <sys/param.h> instead."
21#endif
22
23/* This header is expected to define a few particular macros.
24
25 The traditional BSD macros that correspond directly to POSIX <limits.h>
26 macros don't need to be defined here if <bits/local_lim.h> defines the
27 POSIX limit macro, as the common <sys/param.h> code will define each
28 traditional name to its POSIX name if available.
29
30 This file should define at least:
31
32 EXEC_PAGESIZE
33*/
libc/glibc/bits/pthreadtypes.h created+1
...@@ -0,0 +1 @@
1/* No thread support. */
libc/glibc/bits/sched.h created+34
...@@ -0,0 +1,34 @@
1/* Definitions of constants and data structure for POSIX 1003.1b-1993
2 scheduling interface.
3 Copyright (C) 1996-2019 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
19
20#ifndef _BITS_SCHED_H
21#define _BITS_SCHED_H 1
22
23#ifndef _SCHED_H
24# error "Never include <bits/sched.h> directly; use <sched.h> instead."
25#endif
26
27/* Scheduling algorithms. */
28#define SCHED_OTHER 0
29#define SCHED_FIFO 1
30#define SCHED_RR 2
31
32#include <bits/types/struct_sched_param.h>
33
34#endif /* bits/sched.h */
libc/glibc/bits/select.h created+37
...@@ -0,0 +1,37 @@
1/* Copyright (C) 1997-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_SELECT_H
19# error "Never use <bits/select.h> directly; include <sys/select.h> instead."
20#endif
21
22
23/* We don't use `memset' because this would require a prototype and
24 the array isn't too big. */
25#define __FD_ZERO(s) \
26 do { \
27 unsigned int __i; \
28 fd_set *__arr = (s); \
29 for (__i = 0; __i < sizeof (fd_set) / sizeof (__fd_mask); ++__i) \
30 __FDS_BITS (__arr)[__i] = 0; \
31 } while (0)
32#define __FD_SET(d, s) \
33 ((void) (__FDS_BITS (s)[__FD_ELT(d)] |= __FD_MASK(d)))
34#define __FD_CLR(d, s) \
35 ((void) (__FDS_BITS (s)[__FD_ELT(d)] &= ~__FD_MASK(d)))
36#define __FD_ISSET(d, s) \
37 ((__FDS_BITS (s)[__FD_ELT (d)] & __FD_MASK (d)) != 0)
libc/glibc/bits/setjmp.h created+7
...@@ -0,0 +1,7 @@
1/* Define the machine-dependent type `jmp_buf'. Stub version. */
2
3#ifndef _SETJMP_H
4# error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead."
5#endif
6
7typedef int __jmp_buf[1];
libc/glibc/bits/signum-generic.h created+102
...@@ -0,0 +1,102 @@
1/* Signal number constants. Generic template.
2 Copyright (C) 1991-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_SIGNUM_GENERIC_H
20#define _BITS_SIGNUM_GENERIC_H 1
21
22#ifndef _SIGNAL_H
23#error "Never include <bits/signum-generic.h> directly; use <signal.h> instead."
24#endif
25
26/* Fake signal functions. */
27
28#define SIG_ERR ((__sighandler_t) -1) /* Error return. */
29#define SIG_DFL ((__sighandler_t) 0) /* Default action. */
30#define SIG_IGN ((__sighandler_t) 1) /* Ignore signal. */
31
32#ifdef __USE_XOPEN
33# define SIG_HOLD ((__sighandler_t) 2) /* Add signal to hold mask. */
34#endif
35
36/* We define here all the signal names listed in POSIX (1003.1-2008);
37 as of 1003.1-2013, no additional signals have been added by POSIX.
38 We also define here signal names that historically exist in every
39 real-world POSIX variant (e.g. SIGWINCH).
40
41 Signals in the 1-15 range are defined with their historical numbers.
42 For other signals, we use the BSD numbers.
43 There are two unallocated signal numbers in the 1-31 range: 7 and 29.
44 Signal number 0 is reserved for use as kill(pid, 0), to test whether
45 a process exists without sending it a signal. */
46
47/* ISO C99 signals. */
48#define SIGINT 2 /* Interactive attention signal. */
49#define SIGILL 4 /* Illegal instruction. */
50#define SIGABRT 6 /* Abnormal termination. */
51#define SIGFPE 8 /* Erroneous arithmetic operation. */
52#define SIGSEGV 11 /* Invalid access to storage. */
53#define SIGTERM 15 /* Termination request. */
54
55/* Historical signals specified by POSIX. */
56#define SIGHUP 1 /* Hangup. */
57#define SIGQUIT 3 /* Quit. */
58#define SIGTRAP 5 /* Trace/breakpoint trap. */
59#define SIGKILL 9 /* Killed. */
60#define SIGBUS 10 /* Bus error. */
61#define SIGSYS 12 /* Bad system call. */
62#define SIGPIPE 13 /* Broken pipe. */
63#define SIGALRM 14 /* Alarm clock. */
64
65/* New(er) POSIX signals (1003.1-2008, 1003.1-2013). */
66#define SIGURG 16 /* Urgent data is available at a socket. */
67#define SIGSTOP 17 /* Stop, unblockable. */
68#define SIGTSTP 18 /* Keyboard stop. */
69#define SIGCONT 19 /* Continue. */
70#define SIGCHLD 20 /* Child terminated or stopped. */
71#define SIGTTIN 21 /* Background read from control terminal. */
72#define SIGTTOU 22 /* Background write to control terminal. */
73#define SIGPOLL 23 /* Pollable event occurred (System V). */
74#define SIGXCPU 24 /* CPU time limit exceeded. */
75#define SIGXFSZ 25 /* File size limit exceeded. */
76#define SIGVTALRM 26 /* Virtual timer expired. */
77#define SIGPROF 27 /* Profiling timer expired. */
78#define SIGUSR1 30 /* User-defined signal 1. */
79#define SIGUSR2 31 /* User-defined signal 2. */
80
81/* Nonstandard signals found in all modern POSIX systems
82 (including both BSD and Linux). */
83#define SIGWINCH 28 /* Window size change (4.3 BSD, Sun). */
84
85/* Archaic names for compatibility. */
86#define SIGIO SIGPOLL /* I/O now possible (4.2 BSD). */
87#define SIGIOT SIGABRT /* IOT instruction, abort() on a PDP-11. */
88#define SIGCLD SIGCHLD /* Old System V name */
89
90/* Not all systems support real-time signals. bits/signum.h indicates
91 that they are supported by overriding __SIGRTMAX to a value greater
92 than __SIGRTMIN. These constants give the kernel-level hard limits,
93 but some real-time signals may be used internally by glibc. Do not
94 use these constants in application code; use SIGRTMIN and SIGRTMAX
95 (defined in signal.h) instead. */
96#define __SIGRTMIN 32
97#define __SIGRTMAX __SIGRTMIN
98
99/* Biggest signal number + 1 (including real-time signals). */
100#define _NSIG (__SIGRTMAX + 1)
101
102#endif /* bits/signum-generic.h. */
libc/glibc/bits/signum.h created+32
...@@ -0,0 +1,32 @@
1/* Signal number constants. Generic version.
2 Copyright (C) 2017-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_SIGNUM_H
20#define _BITS_SIGNUM_H 1
21
22#ifndef _SIGNAL_H
23#error "Never include <bits/signum.h> directly; use <signal.h> instead."
24#endif
25
26#include <bits/signum-generic.h>
27
28/* This operating system does not need to override any of the generic
29 signal number assignments in bits/signum-generic.h, nor to add any
30 additional signal constants. */
31
32#endif /* bits/signum.h. */
libc/glibc/bits/stat.h created+103
...@@ -0,0 +1,103 @@
1/* Copyright (C) 1992-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#if !defined _SYS_STAT_H && !defined _FCNTL_H
19# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
20#endif
21
22#ifndef _BITS_STAT_H
23#define _BITS_STAT_H 1
24
25/* This structure needs to be defined in accordance with the
26 implementation of __stat, __fstat, and __lstat. */
27
28#include <bits/types.h>
29
30/* Structure describing file characteristics. */
31struct stat
32 {
33 /* These are the members that POSIX.1 requires. */
34
35 __mode_t st_mode; /* File mode. */
36#ifndef __USE_FILE_OFFSET64
37 __ino_t st_ino; /* File serial number. */
38#else
39 __ino64_t st_ino; /* File serial number. */
40#endif
41 __dev_t st_dev; /* Device containing the file. */
42 __nlink_t st_nlink; /* Link count. */
43
44 __uid_t st_uid; /* User ID of the file's owner. */
45 __gid_t st_gid; /* Group ID of the file's group. */
46#ifndef __USE_FILE_OFFSET64
47 __off_t st_size; /* Size of file, in bytes. */
48#else
49 __off64_t st_size; /* Size of file, in bytes. */
50#endif
51
52 __time_t st_atime; /* Time of last access. */
53 __time_t st_mtime; /* Time of last modification. */
54 __time_t st_ctime; /* Time of last status change. */
55
56 /* This should be defined if there is a `st_blksize' member. */
57#undef _STATBUF_ST_BLKSIZE
58 };
59
60/* Encoding of the file mode. These are the standard Unix values,
61 but POSIX.1 does not specify what values should be used. */
62
63#define __S_IFMT 0170000 /* These bits determine file type. */
64
65/* File types. */
66#define __S_IFDIR 0040000 /* Directory. */
67#define __S_IFCHR 0020000 /* Character device. */
68#define __S_IFBLK 0060000 /* Block device. */
69#define __S_IFREG 0100000 /* Regular file. */
70#define __S_IFIFO 0010000 /* FIFO. */
71
72/* POSIX.1b objects. */
73#define __S_TYPEISMQ(buf) 0
74#define __S_TYPEISSEM(buf) 0
75#define __S_TYPEISSHM(buf) 0
76
77/* Protection bits. */
78
79#define __S_ISUID 04000 /* Set user ID on execution. */
80#define __S_ISGID 02000 /* Set group ID on execution. */
81#define __S_IREAD 0400 /* Read by owner. */
82#define __S_IWRITE 0200 /* Write by owner. */
83#define __S_IEXEC 0100 /* Execute by owner. */
84
85#ifdef __USE_LARGEFILE64
86struct stat64
87 {
88 __mode_t st_mode; /* File mode. */
89 __ino64_t st_ino; /* File serial number. */
90 __dev_t st_dev; /* Device. */
91 __nlink_t st_nlink; /* Link count. */
92
93 __uid_t st_uid; /* User ID of the file's owner. */
94 __gid_t st_gid; /* Group ID of the file's group.*/
95 __off64_t st_size; /* Size of file, in bytes. */
96
97 __time_t st_atime; /* Time of last access. */
98 __time_t st_mtime; /* Time of last modification. */
99 __time_t st_ctime; /* Time of last status change. */
100 };
101#endif
102
103#endif /* bits/stat.h */
libc/glibc/bits/stdint-intn.h created+29
...@@ -0,0 +1,29 @@
1/* Define intN_t types.
2 Copyright (C) 2017-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_STDINT_INTN_H
20#define _BITS_STDINT_INTN_H 1
21
22#include <bits/types.h>
23
24typedef __int8_t int8_t;
25typedef __int16_t int16_t;
26typedef __int32_t int32_t;
27typedef __int64_t int64_t;
28
29#endif /* bits/stdint-intn.h */
libc/glibc/bits/stdlib-bsearch.h created+43
...@@ -0,0 +1,43 @@
1/* Perform binary search - inline version.
2 Copyright (C) 1991-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19__extern_inline void *
20bsearch (const void *__key, const void *__base, size_t __nmemb, size_t __size,
21 __compar_fn_t __compar)
22{
23 size_t __l, __u, __idx;
24 const void *__p;
25 int __comparison;
26
27 __l = 0;
28 __u = __nmemb;
29 while (__l < __u)
30 {
31 __idx = (__l + __u) / 2;
32 __p = (void *) (((const char *) __base) + (__idx * __size));
33 __comparison = (*__compar) (__key, __p);
34 if (__comparison < 0)
35 __u = __idx;
36 else if (__comparison > 0)
37 __l = __idx + 1;
38 else
39 return (void *) __p;
40 }
41
42 return NULL;
43}
libc/glibc/bits/time.h created+64
...@@ -0,0 +1,64 @@
1/* System-dependent timing definitions. Generic version.
2 Copyright (C) 1996-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19/*
20 * Never include this file directly; use <time.h> instead.
21 */
22
23#ifndef _BITS_TIME_H
24#define _BITS_TIME_H 1
25
26#include <bits/types.h>
27
28/* ISO/IEC 9899:1999 7.23.1: Components of time
29 The macro `CLOCKS_PER_SEC' is an expression with type `clock_t' that is
30 the number per second of the value returned by the `clock' function. */
31/* CAE XSH, Issue 4, Version 2: <time.h>
32 The value of CLOCKS_PER_SEC is required to be 1 million on all
33 XSI-conformant systems. */
34#define CLOCKS_PER_SEC ((__clock_t) 1000000)
35
36#if (!defined __STRICT_ANSI__ || defined __USE_POSIX) \
37 && !defined __USE_XOPEN2K
38/* Even though CLOCKS_PER_SEC has such a strange value CLK_TCK
39 presents the real value for clock ticks per second for the system. */
40extern long int __sysconf (int);
41# define CLK_TCK ((__clock_t) __sysconf (2)) /* 2 is _SC_CLK_TCK */
42#endif
43
44#ifdef __USE_POSIX199309
45/* Identifier for system-wide realtime clock. */
46# define CLOCK_REALTIME 0
47/* Monotonic system-wide clock. */
48# define CLOCK_MONOTONIC 1
49/* High-resolution timer from the CPU. */
50# define CLOCK_PROCESS_CPUTIME_ID 2
51/* Thread-specific CPU-time clock. */
52# define CLOCK_THREAD_CPUTIME_ID 3
53/* Monotonic system-wide clock, not adjusted for frequency scaling. */
54# define CLOCK_MONOTONIC_RAW 4
55/* Identifier for system-wide realtime clock, updated only on ticks. */
56# define CLOCK_REALTIME_COARSE 5
57/* Monotonic system-wide clock, updated only on ticks. */
58# define CLOCK_MONOTONIC_COARSE 6
59
60/* Flag to indicate time is absolute. */
61# define TIMER_ABSTIME 1
62#endif
63
64#endif /* bits/time.h */
libc/glibc/bits/time64.h created+36
...@@ -0,0 +1,36 @@
1/* bits/time64.h -- underlying types for __time64_t. Generic version.
2 Copyright (C) 2018-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_TYPES_H
20# error "Never include <bits/time64.h> directly; use <sys/types.h> instead."
21#endif
22
23#ifndef _BITS_TIME64_H
24#define _BITS_TIME64_H 1
25
26/* Define __TIME64_T_TYPE so that it is always a 64-bit type. */
27
28#if __TIMESIZE == 64
29/* If we already have 64-bit time type then use it. */
30# define __TIME64_T_TYPE __TIME_T_TYPE
31#else
32/* Define a 64-bit time type alongsize the 32-bit one. */
33# define __TIME64_T_TYPE __SQUAD_TYPE
34#endif
35
36#endif /* bits/time64.h */
libc/glibc/bits/timesize.h created+22
...@@ -0,0 +1,22 @@
1/* Bit size of the time_t type at glibc build time, general case.
2 Copyright (C) 2018-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#include <bits/wordsize.h>
20
21/* Size in bits of the 'time_t' type of the default ABI. */
22#define __TIMESIZE __WORDSIZE
libc/glibc/bits/types/__sigset_t.h created+7
...@@ -0,0 +1,7 @@
1#ifndef ____sigset_t_defined
2#define ____sigset_t_defined 1
3
4/* A `sigset_t' has a bit for each signal. */
5typedef unsigned long int __sigset_t;
6
7#endif
libc/glibc/bits/types/struct_sched_param.h created+28
...@@ -0,0 +1,28 @@
1/* Sched parameter structure. Generic version.
2 Copyright (C) 1996-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_TYPES_STRUCT_SCHED_PARAM
20#define _BITS_TYPES_STRUCT_SCHED_PARAM 1
21
22/* Data structure to describe a process' schedulability. */
23struct sched_param
24{
25 int sched_priority;
26};
27
28#endif /* bits/types/struct_sched_param.h */
libc/glibc/bits/typesizes.h created+83
...@@ -0,0 +1,83 @@
1/* bits/typesizes.h -- underlying types for *_t. Generic version.
2 Copyright (C) 2002-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_TYPES_H
20# error "Never include <bits/typesizes.h> directly; use <sys/types.h> instead."
21#endif
22
23#ifndef _BITS_TYPESIZES_H
24#define _BITS_TYPESIZES_H 1
25
26/* See <bits/types.h> for the meaning of these macros. This file exists so
27 that <bits/types.h> need not vary across different GNU platforms. */
28
29#define __DEV_T_TYPE __UQUAD_TYPE
30#define __UID_T_TYPE __U32_TYPE
31#define __GID_T_TYPE __U32_TYPE
32#define __INO_T_TYPE __ULONGWORD_TYPE
33#define __INO64_T_TYPE __UQUAD_TYPE
34#define __MODE_T_TYPE __U32_TYPE
35#define __NLINK_T_TYPE __UWORD_TYPE
36#define __OFF_T_TYPE __SLONGWORD_TYPE
37#define __OFF64_T_TYPE __SQUAD_TYPE
38#define __PID_T_TYPE __S32_TYPE
39#define __RLIM_T_TYPE __ULONGWORD_TYPE
40#define __RLIM64_T_TYPE __UQUAD_TYPE
41#define __BLKCNT_T_TYPE __SLONGWORD_TYPE
42#define __BLKCNT64_T_TYPE __SQUAD_TYPE
43#define __FSBLKCNT_T_TYPE __ULONGWORD_TYPE
44#define __FSBLKCNT64_T_TYPE __UQUAD_TYPE
45#define __FSFILCNT_T_TYPE __ULONGWORD_TYPE
46#define __FSFILCNT64_T_TYPE __UQUAD_TYPE
47#define __FSWORD_T_TYPE __SWORD_TYPE
48#define __ID_T_TYPE __U32_TYPE
49#define __CLOCK_T_TYPE __SLONGWORD_TYPE
50#define __TIME_T_TYPE __SLONGWORD_TYPE
51#define __USECONDS_T_TYPE __U32_TYPE
52#define __SUSECONDS_T_TYPE __SLONGWORD_TYPE
53#define __DADDR_T_TYPE __S32_TYPE
54#define __KEY_T_TYPE __S32_TYPE
55#define __CLOCKID_T_TYPE __S32_TYPE
56#define __TIMER_T_TYPE void *
57#define __BLKSIZE_T_TYPE __SLONGWORD_TYPE
58#define __FSID_T_TYPE struct { int __val[2]; }
59#define __SSIZE_T_TYPE __SWORD_TYPE
60#define __SYSCALL_SLONG_TYPE __SLONGWORD_TYPE
61#define __SYSCALL_ULONG_TYPE __ULONGWORD_TYPE
62#define __CPU_MASK_TYPE __ULONGWORD_TYPE
63
64#ifdef __LP64__
65/* Tell the libc code that off_t and off64_t are actually the same type
66 for all ABI purposes, even if possibly expressed as different base types
67 for C type-checking purposes. */
68# define __OFF_T_MATCHES_OFF64_T 1
69
70/* Same for ino_t and ino64_t. */
71# define __INO_T_MATCHES_INO64_T 1
72
73/* And for rlim_t and rlim64_t. */
74# define __RLIM_T_MATCHES_RLIM64_T 1
75#else
76# define __RLIM_T_MATCHES_RLIM64_T 0
77#endif
78
79/* Number of descriptors that can fit in an `fd_set'. */
80#define __FD_SETSIZE 1024
81
82
83#endif /* bits/typesizes.h */
libc/glibc/bits/uintn-identity.h created+50
...@@ -0,0 +1,50 @@
1/* Inline functions to return unsigned integer values unchanged.
2 Copyright (C) 2017-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#if !defined _NETINET_IN_H && !defined _ENDIAN_H
20# error "Never use <bits/uintn-identity.h> directly; include <netinet/in.h> or <endian.h> instead."
21#endif
22
23#ifndef _BITS_UINTN_IDENTITY_H
24#define _BITS_UINTN_IDENTITY_H 1
25
26#include <bits/types.h>
27
28/* These inline functions are to ensure the appropriate type
29 conversions and associated diagnostics from macros that convert to
30 a given endianness. */
31
32static __inline __uint16_t
33__uint16_identity (__uint16_t __x)
34{
35 return __x;
36}
37
38static __inline __uint32_t
39__uint32_identity (__uint32_t __x)
40{
41 return __x;
42}
43
44static __inline __uint64_t
45__uint64_identity (__uint64_t __x)
46{
47 return __x;
48}
49
50#endif /* _BITS_UINTN_IDENTITY_H. */
libc/glibc/bits/waitflags.h created+26
...@@ -0,0 +1,26 @@
1/* Definitions of flag bits for `waitpid' et al.
2 Copyright (C) 1992-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#if !defined _SYS_WAIT_H && !defined _STDLIB_H
20# error "Never include <bits/waitflags.h> directly; use <sys/wait.h> instead."
21#endif
22
23
24/* Bits in the third argument to `waitpid'. */
25#define WNOHANG 1 /* Don't block waiting. */
26#define WUNTRACED 2 /* Report status of stopped children. */
libc/glibc/bits/waitstatus.h created+59
...@@ -0,0 +1,59 @@
1/* Definitions of status bits for `wait' et al.
2 Copyright (C) 1992-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#if !defined _SYS_WAIT_H && !defined _STDLIB_H
20# error "Never include <bits/waitstatus.h> directly; use <sys/wait.h> instead."
21#endif
22
23
24/* Everything extant so far uses these same bits. */
25
26
27/* If WIFEXITED(STATUS), the low-order 8 bits of the status. */
28#define __WEXITSTATUS(status) (((status) & 0xff00) >> 8)
29
30/* If WIFSIGNALED(STATUS), the terminating signal. */
31#define __WTERMSIG(status) ((status) & 0x7f)
32
33/* If WIFSTOPPED(STATUS), the signal that stopped the child. */
34#define __WSTOPSIG(status) __WEXITSTATUS(status)
35
36/* Nonzero if STATUS indicates normal termination. */
37#define __WIFEXITED(status) (__WTERMSIG(status) == 0)
38
39/* Nonzero if STATUS indicates termination by a signal. */
40#define __WIFSIGNALED(status) \
41 (((signed char) (((status) & 0x7f) + 1) >> 1) > 0)
42
43/* Nonzero if STATUS indicates the child is stopped. */
44#define __WIFSTOPPED(status) (((status) & 0xff) == 0x7f)
45
46/* Nonzero if STATUS indicates the child continued after a stop. We only
47 define this if <bits/waitflags.h> provides the WCONTINUED flag bit. */
48#ifdef WCONTINUED
49# define __WIFCONTINUED(status) ((status) == __W_CONTINUED)
50#endif
51
52/* Nonzero if STATUS indicates the child dumped core. */
53#define __WCOREDUMP(status) ((status) & __WCOREFLAG)
54
55/* Macros for constructing status values. */
56#define __W_EXITCODE(ret, sig) ((ret) << 8 | (sig))
57#define __W_STOPCODE(sig) ((sig) << 8 | 0x7f)
58#define __W_CONTINUED 0xffff
59#define __WCOREFLAG 0x80
libc/glibc/csu/abi-note.S created+72
...@@ -0,0 +1,72 @@
1/* Special .init and .fini section support.
2 Copyright (C) 1997-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 The GNU C Library is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 Lesser General Public License for more details.
23
24 You should have received a copy of the GNU Lesser General Public
25 License along with the GNU C Library; if not, see
26 <http://www.gnu.org/licenses/>. */
27
28/* Define an ELF note identifying the operating-system ABI that the
29 executable was created for. The ELF note information identifies a
30 particular OS or coordinated development effort within which the
31 ELF header's e_machine value plus (for dynamically linked programs)
32 the PT_INTERP dynamic linker name and DT_NEEDED shared library
33 names fully identify the runtime environment required by an
34 executable.
35
36 The general format of ELF notes is as follows.
37 Offsets and lengths are bytes or (parenthetical references) to the
38 values in other fields.
39
40offset length contents
410 4 length of name
424 4 length of data
438 4 note type
4412 (0) vendor name
45 - null-terminated ASCII string, padded to 4-byte alignment
4612+(0) (4) note data,
47
48 The GNU project and cooperating development efforts (including the
49 Linux community) use note type 1 and a vendor name string of "GNU"
50 for a note descriptor that indicates ABI requirements. The note data
51 is four 32-bit words. The first of these is an operating system
52 number (0=Linux, 1=Hurd, 2=Solaris, ...) and the remaining three
53 identify the earliest release of that OS that supports this ABI.
54 See abi-tags (top level) for details. */
55
56#include <config.h>
57#include <abi-tag.h> /* OS-specific ABI tag value */
58
59/* The linker (GNU ld 2.8 and later) recognizes an allocated section whose
60 name begins with `.note' and creates a PT_NOTE program header entry
61 pointing at it. */
62
63 .section ".note.ABI-tag", "a"
64 .p2align 2
65 .long 1f - 0f /* name length */
66 .long 3f - 2f /* data length */
67 .long 1 /* note type */
680: .asciz "GNU" /* vendor name */
691: .p2align 2
702: .long __ABI_TAG_OS /* note data: the ABI tag */
71 .long __ABI_TAG_VERSION
723: .p2align 2 /* pad out section */
libc/glibc/csu/abi-tag.h created+4
...@@ -0,0 +1,4 @@
1#define __ABI_TAG_OS 0
2#ifndef __ABI_TAG_VERSION
3# define __ABI_TAG_VERSION 2,0,0
4#endif
libc/glibc/csu/elf-init.c created+106
...@@ -0,0 +1,106 @@
1/* Startup support for ELF initializers/finalizers in the main executable.
2 Copyright (C) 2002-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library; if not, see
34 <http://www.gnu.org/licenses/>. */
35
36#include <stddef.h>
37
38
39/* These magic symbols are provided by the linker. */
40extern void (*__preinit_array_start []) (int, char **, char **)
41 attribute_hidden;
42extern void (*__preinit_array_end []) (int, char **, char **)
43 attribute_hidden;
44extern void (*__init_array_start []) (int, char **, char **)
45 attribute_hidden;
46extern void (*__init_array_end []) (int, char **, char **)
47 attribute_hidden;
48extern void (*__fini_array_start []) (void) attribute_hidden;
49extern void (*__fini_array_end []) (void) attribute_hidden;
50
51
52#ifndef NO_INITFINI
53/* These function symbols are provided for the .init/.fini section entry
54 points automagically by the linker. */
55extern void _init (void);
56extern void _fini (void);
57#endif
58
59
60/* These functions are passed to __libc_start_main by the startup code.
61 These get statically linked into each program. For dynamically linked
62 programs, this module will come from libc_nonshared.a and differs from
63 the libc.a module in that it doesn't call the preinit array. */
64
65
66void
67__libc_csu_init (int argc, char **argv, char **envp)
68{
69 /* For dynamically linked executables the preinit array is executed by
70 the dynamic linker (before initializing any shared object). */
71
72#ifndef LIBC_NONSHARED
73 /* For static executables, preinit happens right before init. */
74 {
75 const size_t size = __preinit_array_end - __preinit_array_start;
76 size_t i;
77 for (i = 0; i < size; i++)
78 (*__preinit_array_start [i]) (argc, argv, envp);
79 }
80#endif
81
82#ifndef NO_INITFINI
83 _init ();
84#endif
85
86 const size_t size = __init_array_end - __init_array_start;
87 for (size_t i = 0; i < size; i++)
88 (*__init_array_start [i]) (argc, argv, envp);
89}
90
91/* This function should not be used anymore. We run the executable's
92 destructor now just like any other. We cannot remove the function,
93 though. */
94void
95__libc_csu_fini (void)
96{
97#ifndef LIBC_NONSHARED
98 size_t i = __fini_array_end - __fini_array_start;
99 while (i-- > 0)
100 (*__fini_array_start [i]) ();
101
102# ifndef NO_INITFINI
103 _fini ();
104# endif
105#endif
106}
libc/glibc/csu/init.c created+23
...@@ -0,0 +1,23 @@
1/* Special startup support.
2 Copyright (C) 1997-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19/* Vestigial libio version number. Some code in libio checks whether
20 this symbol exists in the executable, but nothing looks at its
21 value anymore; the value it was historically set to has been
22 preserved out of an abundance of caution. */
23const int _IO_stdin_used = 0x20001;
libc/glibc/debug/stack_chk_fail_local.c created+46
...@@ -0,0 +1,46 @@
1/* Copyright (C) 2005-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 In addition to the permissions in the GNU Lesser General Public
10 License, the Free Software Foundation gives you unlimited
11 permission to link the compiled version of this file with other
12 programs, and to distribute those programs without any restriction
13 coming from the use of this file. (The GNU Lesser General Public
14 License restrictions do apply in other respects; for example, they
15 cover modification of the file, and distribution when not linked
16 into another program.)
17
18 Note that people who make modified versions of this file are not
19 obligated to grant this special exception for their modified
20 versions; it is their choice whether to do so. The GNU Lesser
21 General Public License gives permission to release a modified
22 version without this exception; this exception also makes it
23 possible to release a modified version which carries forward this
24 exception.
25
26 The GNU C Library is distributed in the hope that it will be useful,
27 but WITHOUT ANY WARRANTY; without even the implied warranty of
28 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
29 Lesser General Public License for more details.
30
31 You should have received a copy of the GNU Lesser General Public
32 License along with the GNU C Library; if not, see
33 <http://www.gnu.org/licenses/>. */
34
35#include <sys/cdefs.h>
36
37extern void __stack_chk_fail (void) __attribute__ ((noreturn));
38
39/* On some architectures, this helps needless PIC pointer setup
40 that would be needed just for the __stack_chk_fail call. */
41
42void __attribute__ ((noreturn)) attribute_hidden
43__stack_chk_fail_local (void)
44{
45 __stack_chk_fail ();
46}
libc/glibc/debug/warning-nop.c created+70
...@@ -0,0 +1,70 @@
1/* Dummy nop functions to elicit link-time warnings.
2 Copyright (C) 2005-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library; if not, see
34 <http://www.gnu.org/licenses/>. */
35
36#include <sys/cdefs.h>
37
38static void
39__attribute__ ((used))
40nop (void)
41{
42}
43
44/* Don't insert any other #include's before this #undef! */
45
46#undef __warndecl
47#define __warndecl(name, msg) \
48 extern void name (void) __attribute__ ((alias ("nop"))) attribute_hidden; \
49 link_warning (name, msg)
50
51#undef __USE_FORTIFY_LEVEL
52#define __USE_FORTIFY_LEVEL 99
53
54/* Following here we need an #include for each public header file
55 that uses __warndecl. */
56
57/* Define away to avoid warnings with compilers that do not have these
58 builtins. */
59#define __builtin___memcpy_chk(dest, src, len, bos) NULL
60#define __builtin___memmove_chk(dest, src, len, bos) NULL
61#define __builtin___mempcpy_chk(dest, src, len, bos) NULL
62#define __builtin___memset_chk(dest, ch, len, bos) NULL
63#define __builtin___stpcpy_chk(dest, src, bos) NULL
64#define __builtin___strcat_chk(dest, src, bos) NULL
65#define __builtin___strcpy_chk(dest, src, bos) NULL
66#define __builtin___strncat_chk(dest, src, len, bos) NULL
67#define __builtin___strncpy_chk(dest, src, len, bos) NULL
68#define __builtin_object_size(bos, level) 0
69
70#include <string.h>
libc/glibc/elf/elf.h created+4001
...@@ -0,0 +1,4001 @@
1/* This file defines standard ELF types, structures, and macros.
2 Copyright (C) 1995-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _ELF_H
20#define _ELF_H 1
21
22#include <features.h>
23
24__BEGIN_DECLS
25
26/* Standard ELF types. */
27
28#include <stdint.h>
29
30/* Type for a 16-bit quantity. */
31typedef uint16_t Elf32_Half;
32typedef uint16_t Elf64_Half;
33
34/* Types for signed and unsigned 32-bit quantities. */
35typedef uint32_t Elf32_Word;
36typedef int32_t Elf32_Sword;
37typedef uint32_t Elf64_Word;
38typedef int32_t Elf64_Sword;
39
40/* Types for signed and unsigned 64-bit quantities. */
41typedef uint64_t Elf32_Xword;
42typedef int64_t Elf32_Sxword;
43typedef uint64_t Elf64_Xword;
44typedef int64_t Elf64_Sxword;
45
46/* Type of addresses. */
47typedef uint32_t Elf32_Addr;
48typedef uint64_t Elf64_Addr;
49
50/* Type of file offsets. */
51typedef uint32_t Elf32_Off;
52typedef uint64_t Elf64_Off;
53
54/* Type for section indices, which are 16-bit quantities. */
55typedef uint16_t Elf32_Section;
56typedef uint16_t Elf64_Section;
57
58/* Type for version symbol information. */
59typedef Elf32_Half Elf32_Versym;
60typedef Elf64_Half Elf64_Versym;
61
62
63/* The ELF file header. This appears at the start of every ELF file. */
64
65#define EI_NIDENT (16)
66
67typedef struct
68{
69 unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */
70 Elf32_Half e_type; /* Object file type */
71 Elf32_Half e_machine; /* Architecture */
72 Elf32_Word e_version; /* Object file version */
73 Elf32_Addr e_entry; /* Entry point virtual address */
74 Elf32_Off e_phoff; /* Program header table file offset */
75 Elf32_Off e_shoff; /* Section header table file offset */
76 Elf32_Word e_flags; /* Processor-specific flags */
77 Elf32_Half e_ehsize; /* ELF header size in bytes */
78 Elf32_Half e_phentsize; /* Program header table entry size */
79 Elf32_Half e_phnum; /* Program header table entry count */
80 Elf32_Half e_shentsize; /* Section header table entry size */
81 Elf32_Half e_shnum; /* Section header table entry count */
82 Elf32_Half e_shstrndx; /* Section header string table index */
83} Elf32_Ehdr;
84
85typedef struct
86{
87 unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */
88 Elf64_Half e_type; /* Object file type */
89 Elf64_Half e_machine; /* Architecture */
90 Elf64_Word e_version; /* Object file version */
91 Elf64_Addr e_entry; /* Entry point virtual address */
92 Elf64_Off e_phoff; /* Program header table file offset */
93 Elf64_Off e_shoff; /* Section header table file offset */
94 Elf64_Word e_flags; /* Processor-specific flags */
95 Elf64_Half e_ehsize; /* ELF header size in bytes */
96 Elf64_Half e_phentsize; /* Program header table entry size */
97 Elf64_Half e_phnum; /* Program header table entry count */
98 Elf64_Half e_shentsize; /* Section header table entry size */
99 Elf64_Half e_shnum; /* Section header table entry count */
100 Elf64_Half e_shstrndx; /* Section header string table index */
101} Elf64_Ehdr;
102
103/* Fields in the e_ident array. The EI_* macros are indices into the
104 array. The macros under each EI_* macro are the values the byte
105 may have. */
106
107#define EI_MAG0 0 /* File identification byte 0 index */
108#define ELFMAG0 0x7f /* Magic number byte 0 */
109
110#define EI_MAG1 1 /* File identification byte 1 index */
111#define ELFMAG1 'E' /* Magic number byte 1 */
112
113#define EI_MAG2 2 /* File identification byte 2 index */
114#define ELFMAG2 'L' /* Magic number byte 2 */
115
116#define EI_MAG3 3 /* File identification byte 3 index */
117#define ELFMAG3 'F' /* Magic number byte 3 */
118
119/* Conglomeration of the identification bytes, for easy testing as a word. */
120#define ELFMAG "\177ELF"
121#define SELFMAG 4
122
123#define EI_CLASS 4 /* File class byte index */
124#define ELFCLASSNONE 0 /* Invalid class */
125#define ELFCLASS32 1 /* 32-bit objects */
126#define ELFCLASS64 2 /* 64-bit objects */
127#define ELFCLASSNUM 3
128
129#define EI_DATA 5 /* Data encoding byte index */
130#define ELFDATANONE 0 /* Invalid data encoding */
131#define ELFDATA2LSB 1 /* 2's complement, little endian */
132#define ELFDATA2MSB 2 /* 2's complement, big endian */
133#define ELFDATANUM 3
134
135#define EI_VERSION 6 /* File version byte index */
136 /* Value must be EV_CURRENT */
137
138#define EI_OSABI 7 /* OS ABI identification */
139#define ELFOSABI_NONE 0 /* UNIX System V ABI */
140#define ELFOSABI_SYSV 0 /* Alias. */
141#define ELFOSABI_HPUX 1 /* HP-UX */
142#define ELFOSABI_NETBSD 2 /* NetBSD. */
143#define ELFOSABI_GNU 3 /* Object uses GNU ELF extensions. */
144#define ELFOSABI_LINUX ELFOSABI_GNU /* Compatibility alias. */
145#define ELFOSABI_SOLARIS 6 /* Sun Solaris. */
146#define ELFOSABI_AIX 7 /* IBM AIX. */
147#define ELFOSABI_IRIX 8 /* SGI Irix. */
148#define ELFOSABI_FREEBSD 9 /* FreeBSD. */
149#define ELFOSABI_TRU64 10 /* Compaq TRU64 UNIX. */
150#define ELFOSABI_MODESTO 11 /* Novell Modesto. */
151#define ELFOSABI_OPENBSD 12 /* OpenBSD. */
152#define ELFOSABI_ARM_AEABI 64 /* ARM EABI */
153#define ELFOSABI_ARM 97 /* ARM */
154#define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */
155
156#define EI_ABIVERSION 8 /* ABI version */
157
158#define EI_PAD 9 /* Byte index of padding bytes */
159
160/* Legal values for e_type (object file type). */
161
162#define ET_NONE 0 /* No file type */
163#define ET_REL 1 /* Relocatable file */
164#define ET_EXEC 2 /* Executable file */
165#define ET_DYN 3 /* Shared object file */
166#define ET_CORE 4 /* Core file */
167#define ET_NUM 5 /* Number of defined types */
168#define ET_LOOS 0xfe00 /* OS-specific range start */
169#define ET_HIOS 0xfeff /* OS-specific range end */
170#define ET_LOPROC 0xff00 /* Processor-specific range start */
171#define ET_HIPROC 0xffff /* Processor-specific range end */
172
173/* Legal values for e_machine (architecture). */
174
175#define EM_NONE 0 /* No machine */
176#define EM_M32 1 /* AT&T WE 32100 */
177#define EM_SPARC 2 /* SUN SPARC */
178#define EM_386 3 /* Intel 80386 */
179#define EM_68K 4 /* Motorola m68k family */
180#define EM_88K 5 /* Motorola m88k family */
181#define EM_IAMCU 6 /* Intel MCU */
182#define EM_860 7 /* Intel 80860 */
183#define EM_MIPS 8 /* MIPS R3000 big-endian */
184#define EM_S370 9 /* IBM System/370 */
185#define EM_MIPS_RS3_LE 10 /* MIPS R3000 little-endian */
186 /* reserved 11-14 */
187#define EM_PARISC 15 /* HPPA */
188 /* reserved 16 */
189#define EM_VPP500 17 /* Fujitsu VPP500 */
190#define EM_SPARC32PLUS 18 /* Sun's "v8plus" */
191#define EM_960 19 /* Intel 80960 */
192#define EM_PPC 20 /* PowerPC */
193#define EM_PPC64 21 /* PowerPC 64-bit */
194#define EM_S390 22 /* IBM S390 */
195#define EM_SPU 23 /* IBM SPU/SPC */
196 /* reserved 24-35 */
197#define EM_V800 36 /* NEC V800 series */
198#define EM_FR20 37 /* Fujitsu FR20 */
199#define EM_RH32 38 /* TRW RH-32 */
200#define EM_RCE 39 /* Motorola RCE */
201#define EM_ARM 40 /* ARM */
202#define EM_FAKE_ALPHA 41 /* Digital Alpha */
203#define EM_SH 42 /* Hitachi SH */
204#define EM_SPARCV9 43 /* SPARC v9 64-bit */
205#define EM_TRICORE 44 /* Siemens Tricore */
206#define EM_ARC 45 /* Argonaut RISC Core */
207#define EM_H8_300 46 /* Hitachi H8/300 */
208#define EM_H8_300H 47 /* Hitachi H8/300H */
209#define EM_H8S 48 /* Hitachi H8S */
210#define EM_H8_500 49 /* Hitachi H8/500 */
211#define EM_IA_64 50 /* Intel Merced */
212#define EM_MIPS_X 51 /* Stanford MIPS-X */
213#define EM_COLDFIRE 52 /* Motorola Coldfire */
214#define EM_68HC12 53 /* Motorola M68HC12 */
215#define EM_MMA 54 /* Fujitsu MMA Multimedia Accelerator */
216#define EM_PCP 55 /* Siemens PCP */
217#define EM_NCPU 56 /* Sony nCPU embeeded RISC */
218#define EM_NDR1 57 /* Denso NDR1 microprocessor */
219#define EM_STARCORE 58 /* Motorola Start*Core processor */
220#define EM_ME16 59 /* Toyota ME16 processor */
221#define EM_ST100 60 /* STMicroelectronic ST100 processor */
222#define EM_TINYJ 61 /* Advanced Logic Corp. Tinyj emb.fam */
223#define EM_X86_64 62 /* AMD x86-64 architecture */
224#define EM_PDSP 63 /* Sony DSP Processor */
225#define EM_PDP10 64 /* Digital PDP-10 */
226#define EM_PDP11 65 /* Digital PDP-11 */
227#define EM_FX66 66 /* Siemens FX66 microcontroller */
228#define EM_ST9PLUS 67 /* STMicroelectronics ST9+ 8/16 mc */
229#define EM_ST7 68 /* STmicroelectronics ST7 8 bit mc */
230#define EM_68HC16 69 /* Motorola MC68HC16 microcontroller */
231#define EM_68HC11 70 /* Motorola MC68HC11 microcontroller */
232#define EM_68HC08 71 /* Motorola MC68HC08 microcontroller */
233#define EM_68HC05 72 /* Motorola MC68HC05 microcontroller */
234#define EM_SVX 73 /* Silicon Graphics SVx */
235#define EM_ST19 74 /* STMicroelectronics ST19 8 bit mc */
236#define EM_VAX 75 /* Digital VAX */
237#define EM_CRIS 76 /* Axis Communications 32-bit emb.proc */
238#define EM_JAVELIN 77 /* Infineon Technologies 32-bit emb.proc */
239#define EM_FIREPATH 78 /* Element 14 64-bit DSP Processor */
240#define EM_ZSP 79 /* LSI Logic 16-bit DSP Processor */
241#define EM_MMIX 80 /* Donald Knuth's educational 64-bit proc */
242#define EM_HUANY 81 /* Harvard University machine-independent object files */
243#define EM_PRISM 82 /* SiTera Prism */
244#define EM_AVR 83 /* Atmel AVR 8-bit microcontroller */
245#define EM_FR30 84 /* Fujitsu FR30 */
246#define EM_D10V 85 /* Mitsubishi D10V */
247#define EM_D30V 86 /* Mitsubishi D30V */
248#define EM_V850 87 /* NEC v850 */
249#define EM_M32R 88 /* Mitsubishi M32R */
250#define EM_MN10300 89 /* Matsushita MN10300 */
251#define EM_MN10200 90 /* Matsushita MN10200 */
252#define EM_PJ 91 /* picoJava */
253#define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor */
254#define EM_ARC_COMPACT 93 /* ARC International ARCompact */
255#define EM_XTENSA 94 /* Tensilica Xtensa Architecture */
256#define EM_VIDEOCORE 95 /* Alphamosaic VideoCore */
257#define EM_TMM_GPP 96 /* Thompson Multimedia General Purpose Proc */
258#define EM_NS32K 97 /* National Semi. 32000 */
259#define EM_TPC 98 /* Tenor Network TPC */
260#define EM_SNP1K 99 /* Trebia SNP 1000 */
261#define EM_ST200 100 /* STMicroelectronics ST200 */
262#define EM_IP2K 101 /* Ubicom IP2xxx */
263#define EM_MAX 102 /* MAX processor */
264#define EM_CR 103 /* National Semi. CompactRISC */
265#define EM_F2MC16 104 /* Fujitsu F2MC16 */
266#define EM_MSP430 105 /* Texas Instruments msp430 */
267#define EM_BLACKFIN 106 /* Analog Devices Blackfin DSP */
268#define EM_SE_C33 107 /* Seiko Epson S1C33 family */
269#define EM_SEP 108 /* Sharp embedded microprocessor */
270#define EM_ARCA 109 /* Arca RISC */
271#define EM_UNICORE 110 /* PKU-Unity & MPRC Peking Uni. mc series */
272#define EM_EXCESS 111 /* eXcess configurable cpu */
273#define EM_DXP 112 /* Icera Semi. Deep Execution Processor */
274#define EM_ALTERA_NIOS2 113 /* Altera Nios II */
275#define EM_CRX 114 /* National Semi. CompactRISC CRX */
276#define EM_XGATE 115 /* Motorola XGATE */
277#define EM_C166 116 /* Infineon C16x/XC16x */
278#define EM_M16C 117 /* Renesas M16C */
279#define EM_DSPIC30F 118 /* Microchip Technology dsPIC30F */
280#define EM_CE 119 /* Freescale Communication Engine RISC */
281#define EM_M32C 120 /* Renesas M32C */
282 /* reserved 121-130 */
283#define EM_TSK3000 131 /* Altium TSK3000 */
284#define EM_RS08 132 /* Freescale RS08 */
285#define EM_SHARC 133 /* Analog Devices SHARC family */
286#define EM_ECOG2 134 /* Cyan Technology eCOG2 */
287#define EM_SCORE7 135 /* Sunplus S+core7 RISC */
288#define EM_DSP24 136 /* New Japan Radio (NJR) 24-bit DSP */
289#define EM_VIDEOCORE3 137 /* Broadcom VideoCore III */
290#define EM_LATTICEMICO32 138 /* RISC for Lattice FPGA */
291#define EM_SE_C17 139 /* Seiko Epson C17 */
292#define EM_TI_C6000 140 /* Texas Instruments TMS320C6000 DSP */
293#define EM_TI_C2000 141 /* Texas Instruments TMS320C2000 DSP */
294#define EM_TI_C5500 142 /* Texas Instruments TMS320C55x DSP */
295#define EM_TI_ARP32 143 /* Texas Instruments App. Specific RISC */
296#define EM_TI_PRU 144 /* Texas Instruments Prog. Realtime Unit */
297 /* reserved 145-159 */
298#define EM_MMDSP_PLUS 160 /* STMicroelectronics 64bit VLIW DSP */
299#define EM_CYPRESS_M8C 161 /* Cypress M8C */
300#define EM_R32C 162 /* Renesas R32C */
301#define EM_TRIMEDIA 163 /* NXP Semi. TriMedia */
302#define EM_QDSP6 164 /* QUALCOMM DSP6 */
303#define EM_8051 165 /* Intel 8051 and variants */
304#define EM_STXP7X 166 /* STMicroelectronics STxP7x */
305#define EM_NDS32 167 /* Andes Tech. compact code emb. RISC */
306#define EM_ECOG1X 168 /* Cyan Technology eCOG1X */
307#define EM_MAXQ30 169 /* Dallas Semi. MAXQ30 mc */
308#define EM_XIMO16 170 /* New Japan Radio (NJR) 16-bit DSP */
309#define EM_MANIK 171 /* M2000 Reconfigurable RISC */
310#define EM_CRAYNV2 172 /* Cray NV2 vector architecture */
311#define EM_RX 173 /* Renesas RX */
312#define EM_METAG 174 /* Imagination Tech. META */
313#define EM_MCST_ELBRUS 175 /* MCST Elbrus */
314#define EM_ECOG16 176 /* Cyan Technology eCOG16 */
315#define EM_CR16 177 /* National Semi. CompactRISC CR16 */
316#define EM_ETPU 178 /* Freescale Extended Time Processing Unit */
317#define EM_SLE9X 179 /* Infineon Tech. SLE9X */
318#define EM_L10M 180 /* Intel L10M */
319#define EM_K10M 181 /* Intel K10M */
320 /* reserved 182 */
321#define EM_AARCH64 183 /* ARM AARCH64 */
322 /* reserved 184 */
323#define EM_AVR32 185 /* Amtel 32-bit microprocessor */
324#define EM_STM8 186 /* STMicroelectronics STM8 */
325#define EM_TILE64 187 /* Tileta TILE64 */
326#define EM_TILEPRO 188 /* Tilera TILEPro */
327#define EM_MICROBLAZE 189 /* Xilinx MicroBlaze */
328#define EM_CUDA 190 /* NVIDIA CUDA */
329#define EM_TILEGX 191 /* Tilera TILE-Gx */
330#define EM_CLOUDSHIELD 192 /* CloudShield */
331#define EM_COREA_1ST 193 /* KIPO-KAIST Core-A 1st gen. */
332#define EM_COREA_2ND 194 /* KIPO-KAIST Core-A 2nd gen. */
333#define EM_ARC_COMPACT2 195 /* Synopsys ARCompact V2 */
334#define EM_OPEN8 196 /* Open8 RISC */
335#define EM_RL78 197 /* Renesas RL78 */
336#define EM_VIDEOCORE5 198 /* Broadcom VideoCore V */
337#define EM_78KOR 199 /* Renesas 78KOR */
338#define EM_56800EX 200 /* Freescale 56800EX DSC */
339#define EM_BA1 201 /* Beyond BA1 */
340#define EM_BA2 202 /* Beyond BA2 */
341#define EM_XCORE 203 /* XMOS xCORE */
342#define EM_MCHP_PIC 204 /* Microchip 8-bit PIC(r) */
343 /* reserved 205-209 */
344#define EM_KM32 210 /* KM211 KM32 */
345#define EM_KMX32 211 /* KM211 KMX32 */
346#define EM_EMX16 212 /* KM211 KMX16 */
347#define EM_EMX8 213 /* KM211 KMX8 */
348#define EM_KVARC 214 /* KM211 KVARC */
349#define EM_CDP 215 /* Paneve CDP */
350#define EM_COGE 216 /* Cognitive Smart Memory Processor */
351#define EM_COOL 217 /* Bluechip CoolEngine */
352#define EM_NORC 218 /* Nanoradio Optimized RISC */
353#define EM_CSR_KALIMBA 219 /* CSR Kalimba */
354#define EM_Z80 220 /* Zilog Z80 */
355#define EM_VISIUM 221 /* Controls and Data Services VISIUMcore */
356#define EM_FT32 222 /* FTDI Chip FT32 */
357#define EM_MOXIE 223 /* Moxie processor */
358#define EM_AMDGPU 224 /* AMD GPU */
359 /* reserved 225-242 */
360#define EM_RISCV 243 /* RISC-V */
361
362#define EM_BPF 247 /* Linux BPF -- in-kernel virtual machine */
363#define EM_CSKY 252 /* C_SKY */
364
365#define EM_NUM 253
366
367/* Old spellings/synonyms. */
368
369#define EM_ARC_A5 EM_ARC_COMPACT
370
371/* If it is necessary to assign new unofficial EM_* values, please
372 pick large random numbers (0x8523, 0xa7f2, etc.) to minimize the
373 chances of collision with official or non-GNU unofficial values. */
374
375#define EM_ALPHA 0x9026
376
377/* Legal values for e_version (version). */
378
379#define EV_NONE 0 /* Invalid ELF version */
380#define EV_CURRENT 1 /* Current version */
381#define EV_NUM 2
382
383/* Section header. */
384
385typedef struct
386{
387 Elf32_Word sh_name; /* Section name (string tbl index) */
388 Elf32_Word sh_type; /* Section type */
389 Elf32_Word sh_flags; /* Section flags */
390 Elf32_Addr sh_addr; /* Section virtual addr at execution */
391 Elf32_Off sh_offset; /* Section file offset */
392 Elf32_Word sh_size; /* Section size in bytes */
393 Elf32_Word sh_link; /* Link to another section */
394 Elf32_Word sh_info; /* Additional section information */
395 Elf32_Word sh_addralign; /* Section alignment */
396 Elf32_Word sh_entsize; /* Entry size if section holds table */
397} Elf32_Shdr;
398
399typedef struct
400{
401 Elf64_Word sh_name; /* Section name (string tbl index) */
402 Elf64_Word sh_type; /* Section type */
403 Elf64_Xword sh_flags; /* Section flags */
404 Elf64_Addr sh_addr; /* Section virtual addr at execution */
405 Elf64_Off sh_offset; /* Section file offset */
406 Elf64_Xword sh_size; /* Section size in bytes */
407 Elf64_Word sh_link; /* Link to another section */
408 Elf64_Word sh_info; /* Additional section information */
409 Elf64_Xword sh_addralign; /* Section alignment */
410 Elf64_Xword sh_entsize; /* Entry size if section holds table */
411} Elf64_Shdr;
412
413/* Special section indices. */
414
415#define SHN_UNDEF 0 /* Undefined section */
416#define SHN_LORESERVE 0xff00 /* Start of reserved indices */
417#define SHN_LOPROC 0xff00 /* Start of processor-specific */
418#define SHN_BEFORE 0xff00 /* Order section before all others
419 (Solaris). */
420#define SHN_AFTER 0xff01 /* Order section after all others
421 (Solaris). */
422#define SHN_HIPROC 0xff1f /* End of processor-specific */
423#define SHN_LOOS 0xff20 /* Start of OS-specific */
424#define SHN_HIOS 0xff3f /* End of OS-specific */
425#define SHN_ABS 0xfff1 /* Associated symbol is absolute */
426#define SHN_COMMON 0xfff2 /* Associated symbol is common */
427#define SHN_XINDEX 0xffff /* Index is in extra table. */
428#define SHN_HIRESERVE 0xffff /* End of reserved indices */
429
430/* Legal values for sh_type (section type). */
431
432#define SHT_NULL 0 /* Section header table entry unused */
433#define SHT_PROGBITS 1 /* Program data */
434#define SHT_SYMTAB 2 /* Symbol table */
435#define SHT_STRTAB 3 /* String table */
436#define SHT_RELA 4 /* Relocation entries with addends */
437#define SHT_HASH 5 /* Symbol hash table */
438#define SHT_DYNAMIC 6 /* Dynamic linking information */
439#define SHT_NOTE 7 /* Notes */
440#define SHT_NOBITS 8 /* Program space with no data (bss) */
441#define SHT_REL 9 /* Relocation entries, no addends */
442#define SHT_SHLIB 10 /* Reserved */
443#define SHT_DYNSYM 11 /* Dynamic linker symbol table */
444#define SHT_INIT_ARRAY 14 /* Array of constructors */
445#define SHT_FINI_ARRAY 15 /* Array of destructors */
446#define SHT_PREINIT_ARRAY 16 /* Array of pre-constructors */
447#define SHT_GROUP 17 /* Section group */
448#define SHT_SYMTAB_SHNDX 18 /* Extended section indeces */
449#define SHT_NUM 19 /* Number of defined types. */
450#define SHT_LOOS 0x60000000 /* Start OS-specific. */
451#define SHT_GNU_ATTRIBUTES 0x6ffffff5 /* Object attributes. */
452#define SHT_GNU_HASH 0x6ffffff6 /* GNU-style hash table. */
453#define SHT_GNU_LIBLIST 0x6ffffff7 /* Prelink library list */
454#define SHT_CHECKSUM 0x6ffffff8 /* Checksum for DSO content. */
455#define SHT_LOSUNW 0x6ffffffa /* Sun-specific low bound. */
456#define SHT_SUNW_move 0x6ffffffa
457#define SHT_SUNW_COMDAT 0x6ffffffb
458#define SHT_SUNW_syminfo 0x6ffffffc
459#define SHT_GNU_verdef 0x6ffffffd /* Version definition section. */
460#define SHT_GNU_verneed 0x6ffffffe /* Version needs section. */
461#define SHT_GNU_versym 0x6fffffff /* Version symbol table. */
462#define SHT_HISUNW 0x6fffffff /* Sun-specific high bound. */
463#define SHT_HIOS 0x6fffffff /* End OS-specific type */
464#define SHT_LOPROC 0x70000000 /* Start of processor-specific */
465#define SHT_HIPROC 0x7fffffff /* End of processor-specific */
466#define SHT_LOUSER 0x80000000 /* Start of application-specific */
467#define SHT_HIUSER 0x8fffffff /* End of application-specific */
468
469/* Legal values for sh_flags (section flags). */
470
471#define SHF_WRITE (1 << 0) /* Writable */
472#define SHF_ALLOC (1 << 1) /* Occupies memory during execution */
473#define SHF_EXECINSTR (1 << 2) /* Executable */
474#define SHF_MERGE (1 << 4) /* Might be merged */
475#define SHF_STRINGS (1 << 5) /* Contains nul-terminated strings */
476#define SHF_INFO_LINK (1 << 6) /* `sh_info' contains SHT index */
477#define SHF_LINK_ORDER (1 << 7) /* Preserve order after combining */
478#define SHF_OS_NONCONFORMING (1 << 8) /* Non-standard OS specific handling
479 required */
480#define SHF_GROUP (1 << 9) /* Section is member of a group. */
481#define SHF_TLS (1 << 10) /* Section hold thread-local data. */
482#define SHF_COMPRESSED (1 << 11) /* Section with compressed data. */
483#define SHF_MASKOS 0x0ff00000 /* OS-specific. */
484#define SHF_MASKPROC 0xf0000000 /* Processor-specific */
485#define SHF_ORDERED (1 << 30) /* Special ordering requirement
486 (Solaris). */
487#define SHF_EXCLUDE (1U << 31) /* Section is excluded unless
488 referenced or allocated (Solaris).*/
489
490/* Section compression header. Used when SHF_COMPRESSED is set. */
491
492typedef struct
493{
494 Elf32_Word ch_type; /* Compression format. */
495 Elf32_Word ch_size; /* Uncompressed data size. */
496 Elf32_Word ch_addralign; /* Uncompressed data alignment. */
497} Elf32_Chdr;
498
499typedef struct
500{
501 Elf64_Word ch_type; /* Compression format. */
502 Elf64_Word ch_reserved;
503 Elf64_Xword ch_size; /* Uncompressed data size. */
504 Elf64_Xword ch_addralign; /* Uncompressed data alignment. */
505} Elf64_Chdr;
506
507/* Legal values for ch_type (compression algorithm). */
508#define ELFCOMPRESS_ZLIB 1 /* ZLIB/DEFLATE algorithm. */
509#define ELFCOMPRESS_LOOS 0x60000000 /* Start of OS-specific. */
510#define ELFCOMPRESS_HIOS 0x6fffffff /* End of OS-specific. */
511#define ELFCOMPRESS_LOPROC 0x70000000 /* Start of processor-specific. */
512#define ELFCOMPRESS_HIPROC 0x7fffffff /* End of processor-specific. */
513
514/* Section group handling. */
515#define GRP_COMDAT 0x1 /* Mark group as COMDAT. */
516
517/* Symbol table entry. */
518
519typedef struct
520{
521 Elf32_Word st_name; /* Symbol name (string tbl index) */
522 Elf32_Addr st_value; /* Symbol value */
523 Elf32_Word st_size; /* Symbol size */
524 unsigned char st_info; /* Symbol type and binding */
525 unsigned char st_other; /* Symbol visibility */
526 Elf32_Section st_shndx; /* Section index */
527} Elf32_Sym;
528
529typedef struct
530{
531 Elf64_Word st_name; /* Symbol name (string tbl index) */
532 unsigned char st_info; /* Symbol type and binding */
533 unsigned char st_other; /* Symbol visibility */
534 Elf64_Section st_shndx; /* Section index */
535 Elf64_Addr st_value; /* Symbol value */
536 Elf64_Xword st_size; /* Symbol size */
537} Elf64_Sym;
538
539/* The syminfo section if available contains additional information about
540 every dynamic symbol. */
541
542typedef struct
543{
544 Elf32_Half si_boundto; /* Direct bindings, symbol bound to */
545 Elf32_Half si_flags; /* Per symbol flags */
546} Elf32_Syminfo;
547
548typedef struct
549{
550 Elf64_Half si_boundto; /* Direct bindings, symbol bound to */
551 Elf64_Half si_flags; /* Per symbol flags */
552} Elf64_Syminfo;
553
554/* Possible values for si_boundto. */
555#define SYMINFO_BT_SELF 0xffff /* Symbol bound to self */
556#define SYMINFO_BT_PARENT 0xfffe /* Symbol bound to parent */
557#define SYMINFO_BT_LOWRESERVE 0xff00 /* Beginning of reserved entries */
558
559/* Possible bitmasks for si_flags. */
560#define SYMINFO_FLG_DIRECT 0x0001 /* Direct bound symbol */
561#define SYMINFO_FLG_PASSTHRU 0x0002 /* Pass-thru symbol for translator */
562#define SYMINFO_FLG_COPY 0x0004 /* Symbol is a copy-reloc */
563#define SYMINFO_FLG_LAZYLOAD 0x0008 /* Symbol bound to object to be lazy
564 loaded */
565/* Syminfo version values. */
566#define SYMINFO_NONE 0
567#define SYMINFO_CURRENT 1
568#define SYMINFO_NUM 2
569
570
571/* How to extract and insert information held in the st_info field. */
572
573#define ELF32_ST_BIND(val) (((unsigned char) (val)) >> 4)
574#define ELF32_ST_TYPE(val) ((val) & 0xf)
575#define ELF32_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf))
576
577/* Both Elf32_Sym and Elf64_Sym use the same one-byte st_info field. */
578#define ELF64_ST_BIND(val) ELF32_ST_BIND (val)
579#define ELF64_ST_TYPE(val) ELF32_ST_TYPE (val)
580#define ELF64_ST_INFO(bind, type) ELF32_ST_INFO ((bind), (type))
581
582/* Legal values for ST_BIND subfield of st_info (symbol binding). */
583
584#define STB_LOCAL 0 /* Local symbol */
585#define STB_GLOBAL 1 /* Global symbol */
586#define STB_WEAK 2 /* Weak symbol */
587#define STB_NUM 3 /* Number of defined types. */
588#define STB_LOOS 10 /* Start of OS-specific */
589#define STB_GNU_UNIQUE 10 /* Unique symbol. */
590#define STB_HIOS 12 /* End of OS-specific */
591#define STB_LOPROC 13 /* Start of processor-specific */
592#define STB_HIPROC 15 /* End of processor-specific */
593
594/* Legal values for ST_TYPE subfield of st_info (symbol type). */
595
596#define STT_NOTYPE 0 /* Symbol type is unspecified */
597#define STT_OBJECT 1 /* Symbol is a data object */
598#define STT_FUNC 2 /* Symbol is a code object */
599#define STT_SECTION 3 /* Symbol associated with a section */
600#define STT_FILE 4 /* Symbol's name is file name */
601#define STT_COMMON 5 /* Symbol is a common data object */
602#define STT_TLS 6 /* Symbol is thread-local data object*/
603#define STT_NUM 7 /* Number of defined types. */
604#define STT_LOOS 10 /* Start of OS-specific */
605#define STT_GNU_IFUNC 10 /* Symbol is indirect code object */
606#define STT_HIOS 12 /* End of OS-specific */
607#define STT_LOPROC 13 /* Start of processor-specific */
608#define STT_HIPROC 15 /* End of processor-specific */
609
610
611/* Symbol table indices are found in the hash buckets and chain table
612 of a symbol hash table section. This special index value indicates
613 the end of a chain, meaning no further symbols are found in that bucket. */
614
615#define STN_UNDEF 0 /* End of a chain. */
616
617
618/* How to extract and insert information held in the st_other field. */
619
620#define ELF32_ST_VISIBILITY(o) ((o) & 0x03)
621
622/* For ELF64 the definitions are the same. */
623#define ELF64_ST_VISIBILITY(o) ELF32_ST_VISIBILITY (o)
624
625/* Symbol visibility specification encoded in the st_other field. */
626#define STV_DEFAULT 0 /* Default symbol visibility rules */
627#define STV_INTERNAL 1 /* Processor specific hidden class */
628#define STV_HIDDEN 2 /* Sym unavailable in other modules */
629#define STV_PROTECTED 3 /* Not preemptible, not exported */
630
631
632/* Relocation table entry without addend (in section of type SHT_REL). */
633
634typedef struct
635{
636 Elf32_Addr r_offset; /* Address */
637 Elf32_Word r_info; /* Relocation type and symbol index */
638} Elf32_Rel;
639
640/* I have seen two different definitions of the Elf64_Rel and
641 Elf64_Rela structures, so we'll leave them out until Novell (or
642 whoever) gets their act together. */
643/* The following, at least, is used on Sparc v9, MIPS, and Alpha. */
644
645typedef struct
646{
647 Elf64_Addr r_offset; /* Address */
648 Elf64_Xword r_info; /* Relocation type and symbol index */
649} Elf64_Rel;
650
651/* Relocation table entry with addend (in section of type SHT_RELA). */
652
653typedef struct
654{
655 Elf32_Addr r_offset; /* Address */
656 Elf32_Word r_info; /* Relocation type and symbol index */
657 Elf32_Sword r_addend; /* Addend */
658} Elf32_Rela;
659
660typedef struct
661{
662 Elf64_Addr r_offset; /* Address */
663 Elf64_Xword r_info; /* Relocation type and symbol index */
664 Elf64_Sxword r_addend; /* Addend */
665} Elf64_Rela;
666
667/* How to extract and insert information held in the r_info field. */
668
669#define ELF32_R_SYM(val) ((val) >> 8)
670#define ELF32_R_TYPE(val) ((val) & 0xff)
671#define ELF32_R_INFO(sym, type) (((sym) << 8) + ((type) & 0xff))
672
673#define ELF64_R_SYM(i) ((i) >> 32)
674#define ELF64_R_TYPE(i) ((i) & 0xffffffff)
675#define ELF64_R_INFO(sym,type) ((((Elf64_Xword) (sym)) << 32) + (type))
676
677/* Program segment header. */
678
679typedef struct
680{
681 Elf32_Word p_type; /* Segment type */
682 Elf32_Off p_offset; /* Segment file offset */
683 Elf32_Addr p_vaddr; /* Segment virtual address */
684 Elf32_Addr p_paddr; /* Segment physical address */
685 Elf32_Word p_filesz; /* Segment size in file */
686 Elf32_Word p_memsz; /* Segment size in memory */
687 Elf32_Word p_flags; /* Segment flags */
688 Elf32_Word p_align; /* Segment alignment */
689} Elf32_Phdr;
690
691typedef struct
692{
693 Elf64_Word p_type; /* Segment type */
694 Elf64_Word p_flags; /* Segment flags */
695 Elf64_Off p_offset; /* Segment file offset */
696 Elf64_Addr p_vaddr; /* Segment virtual address */
697 Elf64_Addr p_paddr; /* Segment physical address */
698 Elf64_Xword p_filesz; /* Segment size in file */
699 Elf64_Xword p_memsz; /* Segment size in memory */
700 Elf64_Xword p_align; /* Segment alignment */
701} Elf64_Phdr;
702
703/* Special value for e_phnum. This indicates that the real number of
704 program headers is too large to fit into e_phnum. Instead the real
705 value is in the field sh_info of section 0. */
706
707#define PN_XNUM 0xffff
708
709/* Legal values for p_type (segment type). */
710
711#define PT_NULL 0 /* Program header table entry unused */
712#define PT_LOAD 1 /* Loadable program segment */
713#define PT_DYNAMIC 2 /* Dynamic linking information */
714#define PT_INTERP 3 /* Program interpreter */
715#define PT_NOTE 4 /* Auxiliary information */
716#define PT_SHLIB 5 /* Reserved */
717#define PT_PHDR 6 /* Entry for header table itself */
718#define PT_TLS 7 /* Thread-local storage segment */
719#define PT_NUM 8 /* Number of defined types */
720#define PT_LOOS 0x60000000 /* Start of OS-specific */
721#define PT_GNU_EH_FRAME 0x6474e550 /* GCC .eh_frame_hdr segment */
722#define PT_GNU_STACK 0x6474e551 /* Indicates stack executability */
723#define PT_GNU_RELRO 0x6474e552 /* Read-only after relocation */
724#define PT_LOSUNW 0x6ffffffa
725#define PT_SUNWBSS 0x6ffffffa /* Sun Specific segment */
726#define PT_SUNWSTACK 0x6ffffffb /* Stack segment */
727#define PT_HISUNW 0x6fffffff
728#define PT_HIOS 0x6fffffff /* End of OS-specific */
729#define PT_LOPROC 0x70000000 /* Start of processor-specific */
730#define PT_HIPROC 0x7fffffff /* End of processor-specific */
731
732/* Legal values for p_flags (segment flags). */
733
734#define PF_X (1 << 0) /* Segment is executable */
735#define PF_W (1 << 1) /* Segment is writable */
736#define PF_R (1 << 2) /* Segment is readable */
737#define PF_MASKOS 0x0ff00000 /* OS-specific */
738#define PF_MASKPROC 0xf0000000 /* Processor-specific */
739
740/* Legal values for note segment descriptor types for core files. */
741
742#define NT_PRSTATUS 1 /* Contains copy of prstatus struct */
743#define NT_PRFPREG 2 /* Contains copy of fpregset
744 struct. */
745#define NT_FPREGSET 2 /* Contains copy of fpregset struct */
746#define NT_PRPSINFO 3 /* Contains copy of prpsinfo struct */
747#define NT_PRXREG 4 /* Contains copy of prxregset struct */
748#define NT_TASKSTRUCT 4 /* Contains copy of task structure */
749#define NT_PLATFORM 5 /* String from sysinfo(SI_PLATFORM) */
750#define NT_AUXV 6 /* Contains copy of auxv array */
751#define NT_GWINDOWS 7 /* Contains copy of gwindows struct */
752#define NT_ASRS 8 /* Contains copy of asrset struct */
753#define NT_PSTATUS 10 /* Contains copy of pstatus struct */
754#define NT_PSINFO 13 /* Contains copy of psinfo struct */
755#define NT_PRCRED 14 /* Contains copy of prcred struct */
756#define NT_UTSNAME 15 /* Contains copy of utsname struct */
757#define NT_LWPSTATUS 16 /* Contains copy of lwpstatus struct */
758#define NT_LWPSINFO 17 /* Contains copy of lwpinfo struct */
759#define NT_PRFPXREG 20 /* Contains copy of fprxregset struct */
760#define NT_SIGINFO 0x53494749 /* Contains copy of siginfo_t,
761 size might increase */
762#define NT_FILE 0x46494c45 /* Contains information about mapped
763 files */
764#define NT_PRXFPREG 0x46e62b7f /* Contains copy of user_fxsr_struct */
765#define NT_PPC_VMX 0x100 /* PowerPC Altivec/VMX registers */
766#define NT_PPC_SPE 0x101 /* PowerPC SPE/EVR registers */
767#define NT_PPC_VSX 0x102 /* PowerPC VSX registers */
768#define NT_PPC_TAR 0x103 /* Target Address Register */
769#define NT_PPC_PPR 0x104 /* Program Priority Register */
770#define NT_PPC_DSCR 0x105 /* Data Stream Control Register */
771#define NT_PPC_EBB 0x106 /* Event Based Branch Registers */
772#define NT_PPC_PMU 0x107 /* Performance Monitor Registers */
773#define NT_PPC_TM_CGPR 0x108 /* TM checkpointed GPR Registers */
774#define NT_PPC_TM_CFPR 0x109 /* TM checkpointed FPR Registers */
775#define NT_PPC_TM_CVMX 0x10a /* TM checkpointed VMX Registers */
776#define NT_PPC_TM_CVSX 0x10b /* TM checkpointed VSX Registers */
777#define NT_PPC_TM_SPR 0x10c /* TM Special Purpose Registers */
778#define NT_PPC_TM_CTAR 0x10d /* TM checkpointed Target Address
779 Register */
780#define NT_PPC_TM_CPPR 0x10e /* TM checkpointed Program Priority
781 Register */
782#define NT_PPC_TM_CDSCR 0x10f /* TM checkpointed Data Stream Control
783 Register */
784#define NT_PPC_PKEY 0x110 /* Memory Protection Keys
785 registers. */
786#define NT_386_TLS 0x200 /* i386 TLS slots (struct user_desc) */
787#define NT_386_IOPERM 0x201 /* x86 io permission bitmap (1=deny) */
788#define NT_X86_XSTATE 0x202 /* x86 extended state using xsave */
789#define NT_S390_HIGH_GPRS 0x300 /* s390 upper register halves */
790#define NT_S390_TIMER 0x301 /* s390 timer register */
791#define NT_S390_TODCMP 0x302 /* s390 TOD clock comparator register */
792#define NT_S390_TODPREG 0x303 /* s390 TOD programmable register */
793#define NT_S390_CTRS 0x304 /* s390 control registers */
794#define NT_S390_PREFIX 0x305 /* s390 prefix register */
795#define NT_S390_LAST_BREAK 0x306 /* s390 breaking event address */
796#define NT_S390_SYSTEM_CALL 0x307 /* s390 system call restart data */
797#define NT_S390_TDB 0x308 /* s390 transaction diagnostic block */
798#define NT_S390_VXRS_LOW 0x309 /* s390 vector registers 0-15
799 upper half. */
800#define NT_S390_VXRS_HIGH 0x30a /* s390 vector registers 16-31. */
801#define NT_S390_GS_CB 0x30b /* s390 guarded storage registers. */
802#define NT_S390_GS_BC 0x30c /* s390 guarded storage
803 broadcast control block. */
804#define NT_S390_RI_CB 0x30d /* s390 runtime instrumentation. */
805#define NT_ARM_VFP 0x400 /* ARM VFP/NEON registers */
806#define NT_ARM_TLS 0x401 /* ARM TLS register */
807#define NT_ARM_HW_BREAK 0x402 /* ARM hardware breakpoint registers */
808#define NT_ARM_HW_WATCH 0x403 /* ARM hardware watchpoint registers */
809#define NT_ARM_SYSTEM_CALL 0x404 /* ARM system call number */
810#define NT_ARM_SVE 0x405 /* ARM Scalable Vector Extension
811 registers */
812#define NT_VMCOREDD 0x700 /* Vmcore Device Dump Note. */
813#define NT_MIPS_DSP 0x800 /* MIPS DSP ASE registers. */
814#define NT_MIPS_FP_MODE 0x801 /* MIPS floating-point mode. */
815
816/* Legal values for the note segment descriptor types for object files. */
817
818#define NT_VERSION 1 /* Contains a version string. */
819
820
821/* Dynamic section entry. */
822
823typedef struct
824{
825 Elf32_Sword d_tag; /* Dynamic entry type */
826 union
827 {
828 Elf32_Word d_val; /* Integer value */
829 Elf32_Addr d_ptr; /* Address value */
830 } d_un;
831} Elf32_Dyn;
832
833typedef struct
834{
835 Elf64_Sxword d_tag; /* Dynamic entry type */
836 union
837 {
838 Elf64_Xword d_val; /* Integer value */
839 Elf64_Addr d_ptr; /* Address value */
840 } d_un;
841} Elf64_Dyn;
842
843/* Legal values for d_tag (dynamic entry type). */
844
845#define DT_NULL 0 /* Marks end of dynamic section */
846#define DT_NEEDED 1 /* Name of needed library */
847#define DT_PLTRELSZ 2 /* Size in bytes of PLT relocs */
848#define DT_PLTGOT 3 /* Processor defined value */
849#define DT_HASH 4 /* Address of symbol hash table */
850#define DT_STRTAB 5 /* Address of string table */
851#define DT_SYMTAB 6 /* Address of symbol table */
852#define DT_RELA 7 /* Address of Rela relocs */
853#define DT_RELASZ 8 /* Total size of Rela relocs */
854#define DT_RELAENT 9 /* Size of one Rela reloc */
855#define DT_STRSZ 10 /* Size of string table */
856#define DT_SYMENT 11 /* Size of one symbol table entry */
857#define DT_INIT 12 /* Address of init function */
858#define DT_FINI 13 /* Address of termination function */
859#define DT_SONAME 14 /* Name of shared object */
860#define DT_RPATH 15 /* Library search path (deprecated) */
861#define DT_SYMBOLIC 16 /* Start symbol search here */
862#define DT_REL 17 /* Address of Rel relocs */
863#define DT_RELSZ 18 /* Total size of Rel relocs */
864#define DT_RELENT 19 /* Size of one Rel reloc */
865#define DT_PLTREL 20 /* Type of reloc in PLT */
866#define DT_DEBUG 21 /* For debugging; unspecified */
867#define DT_TEXTREL 22 /* Reloc might modify .text */
868#define DT_JMPREL 23 /* Address of PLT relocs */
869#define DT_BIND_NOW 24 /* Process relocations of object */
870#define DT_INIT_ARRAY 25 /* Array with addresses of init fct */
871#define DT_FINI_ARRAY 26 /* Array with addresses of fini fct */
872#define DT_INIT_ARRAYSZ 27 /* Size in bytes of DT_INIT_ARRAY */
873#define DT_FINI_ARRAYSZ 28 /* Size in bytes of DT_FINI_ARRAY */
874#define DT_RUNPATH 29 /* Library search path */
875#define DT_FLAGS 30 /* Flags for the object being loaded */
876#define DT_ENCODING 32 /* Start of encoded range */
877#define DT_PREINIT_ARRAY 32 /* Array with addresses of preinit fct*/
878#define DT_PREINIT_ARRAYSZ 33 /* size in bytes of DT_PREINIT_ARRAY */
879#define DT_SYMTAB_SHNDX 34 /* Address of SYMTAB_SHNDX section */
880#define DT_NUM 35 /* Number used */
881#define DT_LOOS 0x6000000d /* Start of OS-specific */
882#define DT_HIOS 0x6ffff000 /* End of OS-specific */
883#define DT_LOPROC 0x70000000 /* Start of processor-specific */
884#define DT_HIPROC 0x7fffffff /* End of processor-specific */
885#define DT_PROCNUM DT_MIPS_NUM /* Most used by any processor */
886
887/* DT_* entries which fall between DT_VALRNGHI & DT_VALRNGLO use the
888 Dyn.d_un.d_val field of the Elf*_Dyn structure. This follows Sun's
889 approach. */
890#define DT_VALRNGLO 0x6ffffd00
891#define DT_GNU_PRELINKED 0x6ffffdf5 /* Prelinking timestamp */
892#define DT_GNU_CONFLICTSZ 0x6ffffdf6 /* Size of conflict section */
893#define DT_GNU_LIBLISTSZ 0x6ffffdf7 /* Size of library list */
894#define DT_CHECKSUM 0x6ffffdf8
895#define DT_PLTPADSZ 0x6ffffdf9
896#define DT_MOVEENT 0x6ffffdfa
897#define DT_MOVESZ 0x6ffffdfb
898#define DT_FEATURE_1 0x6ffffdfc /* Feature selection (DTF_*). */
899#define DT_POSFLAG_1 0x6ffffdfd /* Flags for DT_* entries, effecting
900 the following DT_* entry. */
901#define DT_SYMINSZ 0x6ffffdfe /* Size of syminfo table (in bytes) */
902#define DT_SYMINENT 0x6ffffdff /* Entry size of syminfo */
903#define DT_VALRNGHI 0x6ffffdff
904#define DT_VALTAGIDX(tag) (DT_VALRNGHI - (tag)) /* Reverse order! */
905#define DT_VALNUM 12
906
907/* DT_* entries which fall between DT_ADDRRNGHI & DT_ADDRRNGLO use the
908 Dyn.d_un.d_ptr field of the Elf*_Dyn structure.
909
910 If any adjustment is made to the ELF object after it has been
911 built these entries will need to be adjusted. */
912#define DT_ADDRRNGLO 0x6ffffe00
913#define DT_GNU_HASH 0x6ffffef5 /* GNU-style hash table. */
914#define DT_TLSDESC_PLT 0x6ffffef6
915#define DT_TLSDESC_GOT 0x6ffffef7
916#define DT_GNU_CONFLICT 0x6ffffef8 /* Start of conflict section */
917#define DT_GNU_LIBLIST 0x6ffffef9 /* Library list */
918#define DT_CONFIG 0x6ffffefa /* Configuration information. */
919#define DT_DEPAUDIT 0x6ffffefb /* Dependency auditing. */
920#define DT_AUDIT 0x6ffffefc /* Object auditing. */
921#define DT_PLTPAD 0x6ffffefd /* PLT padding. */
922#define DT_MOVETAB 0x6ffffefe /* Move table. */
923#define DT_SYMINFO 0x6ffffeff /* Syminfo table. */
924#define DT_ADDRRNGHI 0x6ffffeff
925#define DT_ADDRTAGIDX(tag) (DT_ADDRRNGHI - (tag)) /* Reverse order! */
926#define DT_ADDRNUM 11
927
928/* The versioning entry types. The next are defined as part of the
929 GNU extension. */
930#define DT_VERSYM 0x6ffffff0
931
932#define DT_RELACOUNT 0x6ffffff9
933#define DT_RELCOUNT 0x6ffffffa
934
935/* These were chosen by Sun. */
936#define DT_FLAGS_1 0x6ffffffb /* State flags, see DF_1_* below. */
937#define DT_VERDEF 0x6ffffffc /* Address of version definition
938 table */
939#define DT_VERDEFNUM 0x6ffffffd /* Number of version definitions */
940#define DT_VERNEED 0x6ffffffe /* Address of table with needed
941 versions */
942#define DT_VERNEEDNUM 0x6fffffff /* Number of needed versions */
943#define DT_VERSIONTAGIDX(tag) (DT_VERNEEDNUM - (tag)) /* Reverse order! */
944#define DT_VERSIONTAGNUM 16
945
946/* Sun added these machine-independent extensions in the "processor-specific"
947 range. Be compatible. */
948#define DT_AUXILIARY 0x7ffffffd /* Shared object to load before self */
949#define DT_FILTER 0x7fffffff /* Shared object to get values from */
950#define DT_EXTRATAGIDX(tag) ((Elf32_Word)-((Elf32_Sword) (tag) <<1>>1)-1)
951#define DT_EXTRANUM 3
952
953/* Values of `d_un.d_val' in the DT_FLAGS entry. */
954#define DF_ORIGIN 0x00000001 /* Object may use DF_ORIGIN */
955#define DF_SYMBOLIC 0x00000002 /* Symbol resolutions starts here */
956#define DF_TEXTREL 0x00000004 /* Object contains text relocations */
957#define DF_BIND_NOW 0x00000008 /* No lazy binding for this object */
958#define DF_STATIC_TLS 0x00000010 /* Module uses the static TLS model */
959
960/* State flags selectable in the `d_un.d_val' element of the DT_FLAGS_1
961 entry in the dynamic section. */
962#define DF_1_NOW 0x00000001 /* Set RTLD_NOW for this object. */
963#define DF_1_GLOBAL 0x00000002 /* Set RTLD_GLOBAL for this object. */
964#define DF_1_GROUP 0x00000004 /* Set RTLD_GROUP for this object. */
965#define DF_1_NODELETE 0x00000008 /* Set RTLD_NODELETE for this object.*/
966#define DF_1_LOADFLTR 0x00000010 /* Trigger filtee loading at runtime.*/
967#define DF_1_INITFIRST 0x00000020 /* Set RTLD_INITFIRST for this object*/
968#define DF_1_NOOPEN 0x00000040 /* Set RTLD_NOOPEN for this object. */
969#define DF_1_ORIGIN 0x00000080 /* $ORIGIN must be handled. */
970#define DF_1_DIRECT 0x00000100 /* Direct binding enabled. */
971#define DF_1_TRANS 0x00000200
972#define DF_1_INTERPOSE 0x00000400 /* Object is used to interpose. */
973#define DF_1_NODEFLIB 0x00000800 /* Ignore default lib search path. */
974#define DF_1_NODUMP 0x00001000 /* Object can't be dldump'ed. */
975#define DF_1_CONFALT 0x00002000 /* Configuration alternative created.*/
976#define DF_1_ENDFILTEE 0x00004000 /* Filtee terminates filters search. */
977#define DF_1_DISPRELDNE 0x00008000 /* Disp reloc applied at build time. */
978#define DF_1_DISPRELPND 0x00010000 /* Disp reloc applied at run-time. */
979#define DF_1_NODIRECT 0x00020000 /* Object has no-direct binding. */
980#define DF_1_IGNMULDEF 0x00040000
981#define DF_1_NOKSYMS 0x00080000
982#define DF_1_NOHDR 0x00100000
983#define DF_1_EDITED 0x00200000 /* Object is modified after built. */
984#define DF_1_NORELOC 0x00400000
985#define DF_1_SYMINTPOSE 0x00800000 /* Object has individual interposers. */
986#define DF_1_GLOBAUDIT 0x01000000 /* Global auditing required. */
987#define DF_1_SINGLETON 0x02000000 /* Singleton symbols are used. */
988#define DF_1_STUB 0x04000000
989#define DF_1_PIE 0x08000000
990
991/* Flags for the feature selection in DT_FEATURE_1. */
992#define DTF_1_PARINIT 0x00000001
993#define DTF_1_CONFEXP 0x00000002
994
995/* Flags in the DT_POSFLAG_1 entry effecting only the next DT_* entry. */
996#define DF_P1_LAZYLOAD 0x00000001 /* Lazyload following object. */
997#define DF_P1_GROUPPERM 0x00000002 /* Symbols from next object are not
998 generally available. */
999
1000/* Version definition sections. */
1001
1002typedef struct
1003{
1004 Elf32_Half vd_version; /* Version revision */
1005 Elf32_Half vd_flags; /* Version information */
1006 Elf32_Half vd_ndx; /* Version Index */
1007 Elf32_Half vd_cnt; /* Number of associated aux entries */
1008 Elf32_Word vd_hash; /* Version name hash value */
1009 Elf32_Word vd_aux; /* Offset in bytes to verdaux array */
1010 Elf32_Word vd_next; /* Offset in bytes to next verdef
1011 entry */
1012} Elf32_Verdef;
1013
1014typedef struct
1015{
1016 Elf64_Half vd_version; /* Version revision */
1017 Elf64_Half vd_flags; /* Version information */
1018 Elf64_Half vd_ndx; /* Version Index */
1019 Elf64_Half vd_cnt; /* Number of associated aux entries */
1020 Elf64_Word vd_hash; /* Version name hash value */
1021 Elf64_Word vd_aux; /* Offset in bytes to verdaux array */
1022 Elf64_Word vd_next; /* Offset in bytes to next verdef
1023 entry */
1024} Elf64_Verdef;
1025
1026
1027/* Legal values for vd_version (version revision). */
1028#define VER_DEF_NONE 0 /* No version */
1029#define VER_DEF_CURRENT 1 /* Current version */
1030#define VER_DEF_NUM 2 /* Given version number */
1031
1032/* Legal values for vd_flags (version information flags). */
1033#define VER_FLG_BASE 0x1 /* Version definition of file itself */
1034#define VER_FLG_WEAK 0x2 /* Weak version identifier */
1035
1036/* Versym symbol index values. */
1037#define VER_NDX_LOCAL 0 /* Symbol is local. */
1038#define VER_NDX_GLOBAL 1 /* Symbol is global. */
1039#define VER_NDX_LORESERVE 0xff00 /* Beginning of reserved entries. */
1040#define VER_NDX_ELIMINATE 0xff01 /* Symbol is to be eliminated. */
1041
1042/* Auxialiary version information. */
1043
1044typedef struct
1045{
1046 Elf32_Word vda_name; /* Version or dependency names */
1047 Elf32_Word vda_next; /* Offset in bytes to next verdaux
1048 entry */
1049} Elf32_Verdaux;
1050
1051typedef struct
1052{
1053 Elf64_Word vda_name; /* Version or dependency names */
1054 Elf64_Word vda_next; /* Offset in bytes to next verdaux
1055 entry */
1056} Elf64_Verdaux;
1057
1058
1059/* Version dependency section. */
1060
1061typedef struct
1062{
1063 Elf32_Half vn_version; /* Version of structure */
1064 Elf32_Half vn_cnt; /* Number of associated aux entries */
1065 Elf32_Word vn_file; /* Offset of filename for this
1066 dependency */
1067 Elf32_Word vn_aux; /* Offset in bytes to vernaux array */
1068 Elf32_Word vn_next; /* Offset in bytes to next verneed
1069 entry */
1070} Elf32_Verneed;
1071
1072typedef struct
1073{
1074 Elf64_Half vn_version; /* Version of structure */
1075 Elf64_Half vn_cnt; /* Number of associated aux entries */
1076 Elf64_Word vn_file; /* Offset of filename for this
1077 dependency */
1078 Elf64_Word vn_aux; /* Offset in bytes to vernaux array */
1079 Elf64_Word vn_next; /* Offset in bytes to next verneed
1080 entry */
1081} Elf64_Verneed;
1082
1083
1084/* Legal values for vn_version (version revision). */
1085#define VER_NEED_NONE 0 /* No version */
1086#define VER_NEED_CURRENT 1 /* Current version */
1087#define VER_NEED_NUM 2 /* Given version number */
1088
1089/* Auxiliary needed version information. */
1090
1091typedef struct
1092{
1093 Elf32_Word vna_hash; /* Hash value of dependency name */
1094 Elf32_Half vna_flags; /* Dependency specific information */
1095 Elf32_Half vna_other; /* Unused */
1096 Elf32_Word vna_name; /* Dependency name string offset */
1097 Elf32_Word vna_next; /* Offset in bytes to next vernaux
1098 entry */
1099} Elf32_Vernaux;
1100
1101typedef struct
1102{
1103 Elf64_Word vna_hash; /* Hash value of dependency name */
1104 Elf64_Half vna_flags; /* Dependency specific information */
1105 Elf64_Half vna_other; /* Unused */
1106 Elf64_Word vna_name; /* Dependency name string offset */
1107 Elf64_Word vna_next; /* Offset in bytes to next vernaux
1108 entry */
1109} Elf64_Vernaux;
1110
1111
1112/* Legal values for vna_flags. */
1113#define VER_FLG_WEAK 0x2 /* Weak version identifier */
1114
1115
1116/* Auxiliary vector. */
1117
1118/* This vector is normally only used by the program interpreter. The
1119 usual definition in an ABI supplement uses the name auxv_t. The
1120 vector is not usually defined in a standard <elf.h> file, but it
1121 can't hurt. We rename it to avoid conflicts. The sizes of these
1122 types are an arrangement between the exec server and the program
1123 interpreter, so we don't fully specify them here. */
1124
1125typedef struct
1126{
1127 uint32_t a_type; /* Entry type */
1128 union
1129 {
1130 uint32_t a_val; /* Integer value */
1131 /* We use to have pointer elements added here. We cannot do that,
1132 though, since it does not work when using 32-bit definitions
1133 on 64-bit platforms and vice versa. */
1134 } a_un;
1135} Elf32_auxv_t;
1136
1137typedef struct
1138{
1139 uint64_t a_type; /* Entry type */
1140 union
1141 {
1142 uint64_t a_val; /* Integer value */
1143 /* We use to have pointer elements added here. We cannot do that,
1144 though, since it does not work when using 32-bit definitions
1145 on 64-bit platforms and vice versa. */
1146 } a_un;
1147} Elf64_auxv_t;
1148
1149/* Legal values for a_type (entry type). */
1150
1151#define AT_NULL 0 /* End of vector */
1152#define AT_IGNORE 1 /* Entry should be ignored */
1153#define AT_EXECFD 2 /* File descriptor of program */
1154#define AT_PHDR 3 /* Program headers for program */
1155#define AT_PHENT 4 /* Size of program header entry */
1156#define AT_PHNUM 5 /* Number of program headers */
1157#define AT_PAGESZ 6 /* System page size */
1158#define AT_BASE 7 /* Base address of interpreter */
1159#define AT_FLAGS 8 /* Flags */
1160#define AT_ENTRY 9 /* Entry point of program */
1161#define AT_NOTELF 10 /* Program is not ELF */
1162#define AT_UID 11 /* Real uid */
1163#define AT_EUID 12 /* Effective uid */
1164#define AT_GID 13 /* Real gid */
1165#define AT_EGID 14 /* Effective gid */
1166#define AT_CLKTCK 17 /* Frequency of times() */
1167
1168/* Some more special a_type values describing the hardware. */
1169#define AT_PLATFORM 15 /* String identifying platform. */
1170#define AT_HWCAP 16 /* Machine-dependent hints about
1171 processor capabilities. */
1172
1173/* This entry gives some information about the FPU initialization
1174 performed by the kernel. */
1175#define AT_FPUCW 18 /* Used FPU control word. */
1176
1177/* Cache block sizes. */
1178#define AT_DCACHEBSIZE 19 /* Data cache block size. */
1179#define AT_ICACHEBSIZE 20 /* Instruction cache block size. */
1180#define AT_UCACHEBSIZE 21 /* Unified cache block size. */
1181
1182/* A special ignored value for PPC, used by the kernel to control the
1183 interpretation of the AUXV. Must be > 16. */
1184#define AT_IGNOREPPC 22 /* Entry should be ignored. */
1185
1186#define AT_SECURE 23 /* Boolean, was exec setuid-like? */
1187
1188#define AT_BASE_PLATFORM 24 /* String identifying real platforms.*/
1189
1190#define AT_RANDOM 25 /* Address of 16 random bytes. */
1191
1192#define AT_HWCAP2 26 /* More machine-dependent hints about
1193 processor capabilities. */
1194
1195#define AT_EXECFN 31 /* Filename of executable. */
1196
1197/* Pointer to the global system page used for system calls and other
1198 nice things. */
1199#define AT_SYSINFO 32
1200#define AT_SYSINFO_EHDR 33
1201
1202/* Shapes of the caches. Bits 0-3 contains associativity; bits 4-7 contains
1203 log2 of line size; mask those to get cache size. */
1204#define AT_L1I_CACHESHAPE 34
1205#define AT_L1D_CACHESHAPE 35
1206#define AT_L2_CACHESHAPE 36
1207#define AT_L3_CACHESHAPE 37
1208
1209/* Shapes of the caches, with more room to describe them.
1210 *GEOMETRY are comprised of cache line size in bytes in the bottom 16 bits
1211 and the cache associativity in the next 16 bits. */
1212#define AT_L1I_CACHESIZE 40
1213#define AT_L1I_CACHEGEOMETRY 41
1214#define AT_L1D_CACHESIZE 42
1215#define AT_L1D_CACHEGEOMETRY 43
1216#define AT_L2_CACHESIZE 44
1217#define AT_L2_CACHEGEOMETRY 45
1218#define AT_L3_CACHESIZE 46
1219#define AT_L3_CACHEGEOMETRY 47
1220
1221#define AT_MINSIGSTKSZ 51 /* Stack needed for signal delivery
1222 (AArch64). */
1223
1224/* Note section contents. Each entry in the note section begins with
1225 a header of a fixed form. */
1226
1227typedef struct
1228{
1229 Elf32_Word n_namesz; /* Length of the note's name. */
1230 Elf32_Word n_descsz; /* Length of the note's descriptor. */
1231 Elf32_Word n_type; /* Type of the note. */
1232} Elf32_Nhdr;
1233
1234typedef struct
1235{
1236 Elf64_Word n_namesz; /* Length of the note's name. */
1237 Elf64_Word n_descsz; /* Length of the note's descriptor. */
1238 Elf64_Word n_type; /* Type of the note. */
1239} Elf64_Nhdr;
1240
1241/* Known names of notes. */
1242
1243/* Solaris entries in the note section have this name. */
1244#define ELF_NOTE_SOLARIS "SUNW Solaris"
1245
1246/* Note entries for GNU systems have this name. */
1247#define ELF_NOTE_GNU "GNU"
1248
1249
1250/* Defined types of notes for Solaris. */
1251
1252/* Value of descriptor (one word) is desired pagesize for the binary. */
1253#define ELF_NOTE_PAGESIZE_HINT 1
1254
1255
1256/* Defined note types for GNU systems. */
1257
1258/* ABI information. The descriptor consists of words:
1259 word 0: OS descriptor
1260 word 1: major version of the ABI
1261 word 2: minor version of the ABI
1262 word 3: subminor version of the ABI
1263*/
1264#define NT_GNU_ABI_TAG 1
1265#define ELF_NOTE_ABI NT_GNU_ABI_TAG /* Old name. */
1266
1267/* Known OSes. These values can appear in word 0 of an
1268 NT_GNU_ABI_TAG note section entry. */
1269#define ELF_NOTE_OS_LINUX 0
1270#define ELF_NOTE_OS_GNU 1
1271#define ELF_NOTE_OS_SOLARIS2 2
1272#define ELF_NOTE_OS_FREEBSD 3
1273
1274/* Synthetic hwcap information. The descriptor begins with two words:
1275 word 0: number of entries
1276 word 1: bitmask of enabled entries
1277 Then follow variable-length entries, one byte followed by a
1278 '\0'-terminated hwcap name string. The byte gives the bit
1279 number to test if enabled, (1U << bit) & bitmask. */
1280#define NT_GNU_HWCAP 2
1281
1282/* Build ID bits as generated by ld --build-id.
1283 The descriptor consists of any nonzero number of bytes. */
1284#define NT_GNU_BUILD_ID 3
1285
1286/* Version note generated by GNU gold containing a version string. */
1287#define NT_GNU_GOLD_VERSION 4
1288
1289/* Program property. */
1290#define NT_GNU_PROPERTY_TYPE_0 5
1291
1292/* Note section name of program property. */
1293#define NOTE_GNU_PROPERTY_SECTION_NAME ".note.gnu.property"
1294
1295/* Values used in GNU .note.gnu.property notes (NT_GNU_PROPERTY_TYPE_0). */
1296
1297/* Stack size. */
1298#define GNU_PROPERTY_STACK_SIZE 1
1299/* No copy relocation on protected data symbol. */
1300#define GNU_PROPERTY_NO_COPY_ON_PROTECTED 2
1301
1302/* Processor-specific semantics, lo */
1303#define GNU_PROPERTY_LOPROC 0xc0000000
1304/* Processor-specific semantics, hi */
1305#define GNU_PROPERTY_HIPROC 0xdfffffff
1306/* Application-specific semantics, lo */
1307#define GNU_PROPERTY_LOUSER 0xe0000000
1308/* Application-specific semantics, hi */
1309#define GNU_PROPERTY_HIUSER 0xffffffff
1310
1311/* The x86 instruction sets indicated by the corresponding bits are
1312 used in program. Their support in the hardware is optional. */
1313#define GNU_PROPERTY_X86_ISA_1_USED 0xc0000000
1314/* The x86 instruction sets indicated by the corresponding bits are
1315 used in program and they must be supported by the hardware. */
1316#define GNU_PROPERTY_X86_ISA_1_NEEDED 0xc0000001
1317/* X86 processor-specific features used in program. */
1318#define GNU_PROPERTY_X86_FEATURE_1_AND 0xc0000002
1319
1320#define GNU_PROPERTY_X86_ISA_1_486 (1U << 0)
1321#define GNU_PROPERTY_X86_ISA_1_586 (1U << 1)
1322#define GNU_PROPERTY_X86_ISA_1_686 (1U << 2)
1323#define GNU_PROPERTY_X86_ISA_1_SSE (1U << 3)
1324#define GNU_PROPERTY_X86_ISA_1_SSE2 (1U << 4)
1325#define GNU_PROPERTY_X86_ISA_1_SSE3 (1U << 5)
1326#define GNU_PROPERTY_X86_ISA_1_SSSE3 (1U << 6)
1327#define GNU_PROPERTY_X86_ISA_1_SSE4_1 (1U << 7)
1328#define GNU_PROPERTY_X86_ISA_1_SSE4_2 (1U << 8)
1329#define GNU_PROPERTY_X86_ISA_1_AVX (1U << 9)
1330#define GNU_PROPERTY_X86_ISA_1_AVX2 (1U << 10)
1331#define GNU_PROPERTY_X86_ISA_1_AVX512F (1U << 11)
1332#define GNU_PROPERTY_X86_ISA_1_AVX512CD (1U << 12)
1333#define GNU_PROPERTY_X86_ISA_1_AVX512ER (1U << 13)
1334#define GNU_PROPERTY_X86_ISA_1_AVX512PF (1U << 14)
1335#define GNU_PROPERTY_X86_ISA_1_AVX512VL (1U << 15)
1336#define GNU_PROPERTY_X86_ISA_1_AVX512DQ (1U << 16)
1337#define GNU_PROPERTY_X86_ISA_1_AVX512BW (1U << 17)
1338
1339/* This indicates that all executable sections are compatible with
1340 IBT. */
1341#define GNU_PROPERTY_X86_FEATURE_1_IBT (1U << 0)
1342/* This indicates that all executable sections are compatible with
1343 SHSTK. */
1344#define GNU_PROPERTY_X86_FEATURE_1_SHSTK (1U << 1)
1345
1346/* Move records. */
1347typedef struct
1348{
1349 Elf32_Xword m_value; /* Symbol value. */
1350 Elf32_Word m_info; /* Size and index. */
1351 Elf32_Word m_poffset; /* Symbol offset. */
1352 Elf32_Half m_repeat; /* Repeat count. */
1353 Elf32_Half m_stride; /* Stride info. */
1354} Elf32_Move;
1355
1356typedef struct
1357{
1358 Elf64_Xword m_value; /* Symbol value. */
1359 Elf64_Xword m_info; /* Size and index. */
1360 Elf64_Xword m_poffset; /* Symbol offset. */
1361 Elf64_Half m_repeat; /* Repeat count. */
1362 Elf64_Half m_stride; /* Stride info. */
1363} Elf64_Move;
1364
1365/* Macro to construct move records. */
1366#define ELF32_M_SYM(info) ((info) >> 8)
1367#define ELF32_M_SIZE(info) ((unsigned char) (info))
1368#define ELF32_M_INFO(sym, size) (((sym) << 8) + (unsigned char) (size))
1369
1370#define ELF64_M_SYM(info) ELF32_M_SYM (info)
1371#define ELF64_M_SIZE(info) ELF32_M_SIZE (info)
1372#define ELF64_M_INFO(sym, size) ELF32_M_INFO (sym, size)
1373
1374
1375/* Motorola 68k specific definitions. */
1376
1377/* Values for Elf32_Ehdr.e_flags. */
1378#define EF_CPU32 0x00810000
1379
1380/* m68k relocs. */
1381
1382#define R_68K_NONE 0 /* No reloc */
1383#define R_68K_32 1 /* Direct 32 bit */
1384#define R_68K_16 2 /* Direct 16 bit */
1385#define R_68K_8 3 /* Direct 8 bit */
1386#define R_68K_PC32 4 /* PC relative 32 bit */
1387#define R_68K_PC16 5 /* PC relative 16 bit */
1388#define R_68K_PC8 6 /* PC relative 8 bit */
1389#define R_68K_GOT32 7 /* 32 bit PC relative GOT entry */
1390#define R_68K_GOT16 8 /* 16 bit PC relative GOT entry */
1391#define R_68K_GOT8 9 /* 8 bit PC relative GOT entry */
1392#define R_68K_GOT32O 10 /* 32 bit GOT offset */
1393#define R_68K_GOT16O 11 /* 16 bit GOT offset */
1394#define R_68K_GOT8O 12 /* 8 bit GOT offset */
1395#define R_68K_PLT32 13 /* 32 bit PC relative PLT address */
1396#define R_68K_PLT16 14 /* 16 bit PC relative PLT address */
1397#define R_68K_PLT8 15 /* 8 bit PC relative PLT address */
1398#define R_68K_PLT32O 16 /* 32 bit PLT offset */
1399#define R_68K_PLT16O 17 /* 16 bit PLT offset */
1400#define R_68K_PLT8O 18 /* 8 bit PLT offset */
1401#define R_68K_COPY 19 /* Copy symbol at runtime */
1402#define R_68K_GLOB_DAT 20 /* Create GOT entry */
1403#define R_68K_JMP_SLOT 21 /* Create PLT entry */
1404#define R_68K_RELATIVE 22 /* Adjust by program base */
1405#define R_68K_TLS_GD32 25 /* 32 bit GOT offset for GD */
1406#define R_68K_TLS_GD16 26 /* 16 bit GOT offset for GD */
1407#define R_68K_TLS_GD8 27 /* 8 bit GOT offset for GD */
1408#define R_68K_TLS_LDM32 28 /* 32 bit GOT offset for LDM */
1409#define R_68K_TLS_LDM16 29 /* 16 bit GOT offset for LDM */
1410#define R_68K_TLS_LDM8 30 /* 8 bit GOT offset for LDM */
1411#define R_68K_TLS_LDO32 31 /* 32 bit module-relative offset */
1412#define R_68K_TLS_LDO16 32 /* 16 bit module-relative offset */
1413#define R_68K_TLS_LDO8 33 /* 8 bit module-relative offset */
1414#define R_68K_TLS_IE32 34 /* 32 bit GOT offset for IE */
1415#define R_68K_TLS_IE16 35 /* 16 bit GOT offset for IE */
1416#define R_68K_TLS_IE8 36 /* 8 bit GOT offset for IE */
1417#define R_68K_TLS_LE32 37 /* 32 bit offset relative to
1418 static TLS block */
1419#define R_68K_TLS_LE16 38 /* 16 bit offset relative to
1420 static TLS block */
1421#define R_68K_TLS_LE8 39 /* 8 bit offset relative to
1422 static TLS block */
1423#define R_68K_TLS_DTPMOD32 40 /* 32 bit module number */
1424#define R_68K_TLS_DTPREL32 41 /* 32 bit module-relative offset */
1425#define R_68K_TLS_TPREL32 42 /* 32 bit TP-relative offset */
1426/* Keep this the last entry. */
1427#define R_68K_NUM 43
1428
1429/* Intel 80386 specific definitions. */
1430
1431/* i386 relocs. */
1432
1433#define R_386_NONE 0 /* No reloc */
1434#define R_386_32 1 /* Direct 32 bit */
1435#define R_386_PC32 2 /* PC relative 32 bit */
1436#define R_386_GOT32 3 /* 32 bit GOT entry */
1437#define R_386_PLT32 4 /* 32 bit PLT address */
1438#define R_386_COPY 5 /* Copy symbol at runtime */
1439#define R_386_GLOB_DAT 6 /* Create GOT entry */
1440#define R_386_JMP_SLOT 7 /* Create PLT entry */
1441#define R_386_RELATIVE 8 /* Adjust by program base */
1442#define R_386_GOTOFF 9 /* 32 bit offset to GOT */
1443#define R_386_GOTPC 10 /* 32 bit PC relative offset to GOT */
1444#define R_386_32PLT 11
1445#define R_386_TLS_TPOFF 14 /* Offset in static TLS block */
1446#define R_386_TLS_IE 15 /* Address of GOT entry for static TLS
1447 block offset */
1448#define R_386_TLS_GOTIE 16 /* GOT entry for static TLS block
1449 offset */
1450#define R_386_TLS_LE 17 /* Offset relative to static TLS
1451 block */
1452#define R_386_TLS_GD 18 /* Direct 32 bit for GNU version of
1453 general dynamic thread local data */
1454#define R_386_TLS_LDM 19 /* Direct 32 bit for GNU version of
1455 local dynamic thread local data
1456 in LE code */
1457#define R_386_16 20
1458#define R_386_PC16 21
1459#define R_386_8 22
1460#define R_386_PC8 23
1461#define R_386_TLS_GD_32 24 /* Direct 32 bit for general dynamic
1462 thread local data */
1463#define R_386_TLS_GD_PUSH 25 /* Tag for pushl in GD TLS code */
1464#define R_386_TLS_GD_CALL 26 /* Relocation for call to
1465 __tls_get_addr() */
1466#define R_386_TLS_GD_POP 27 /* Tag for popl in GD TLS code */
1467#define R_386_TLS_LDM_32 28 /* Direct 32 bit for local dynamic
1468 thread local data in LE code */
1469#define R_386_TLS_LDM_PUSH 29 /* Tag for pushl in LDM TLS code */
1470#define R_386_TLS_LDM_CALL 30 /* Relocation for call to
1471 __tls_get_addr() in LDM code */
1472#define R_386_TLS_LDM_POP 31 /* Tag for popl in LDM TLS code */
1473#define R_386_TLS_LDO_32 32 /* Offset relative to TLS block */
1474#define R_386_TLS_IE_32 33 /* GOT entry for negated static TLS
1475 block offset */
1476#define R_386_TLS_LE_32 34 /* Negated offset relative to static
1477 TLS block */
1478#define R_386_TLS_DTPMOD32 35 /* ID of module containing symbol */
1479#define R_386_TLS_DTPOFF32 36 /* Offset in TLS block */
1480#define R_386_TLS_TPOFF32 37 /* Negated offset in static TLS block */
1481#define R_386_SIZE32 38 /* 32-bit symbol size */
1482#define R_386_TLS_GOTDESC 39 /* GOT offset for TLS descriptor. */
1483#define R_386_TLS_DESC_CALL 40 /* Marker of call through TLS
1484 descriptor for
1485 relaxation. */
1486#define R_386_TLS_DESC 41 /* TLS descriptor containing
1487 pointer to code and to
1488 argument, returning the TLS
1489 offset for the symbol. */
1490#define R_386_IRELATIVE 42 /* Adjust indirectly by program base */
1491#define R_386_GOT32X 43 /* Load from 32 bit GOT entry,
1492 relaxable. */
1493/* Keep this the last entry. */
1494#define R_386_NUM 44
1495
1496/* SUN SPARC specific definitions. */
1497
1498/* Legal values for ST_TYPE subfield of st_info (symbol type). */
1499
1500#define STT_SPARC_REGISTER 13 /* Global register reserved to app. */
1501
1502/* Values for Elf64_Ehdr.e_flags. */
1503
1504#define EF_SPARCV9_MM 3
1505#define EF_SPARCV9_TSO 0
1506#define EF_SPARCV9_PSO 1
1507#define EF_SPARCV9_RMO 2
1508#define EF_SPARC_LEDATA 0x800000 /* little endian data */
1509#define EF_SPARC_EXT_MASK 0xFFFF00
1510#define EF_SPARC_32PLUS 0x000100 /* generic V8+ features */
1511#define EF_SPARC_SUN_US1 0x000200 /* Sun UltraSPARC1 extensions */
1512#define EF_SPARC_HAL_R1 0x000400 /* HAL R1 extensions */
1513#define EF_SPARC_SUN_US3 0x000800 /* Sun UltraSPARCIII extensions */
1514
1515/* SPARC relocs. */
1516
1517#define R_SPARC_NONE 0 /* No reloc */
1518#define R_SPARC_8 1 /* Direct 8 bit */
1519#define R_SPARC_16 2 /* Direct 16 bit */
1520#define R_SPARC_32 3 /* Direct 32 bit */
1521#define R_SPARC_DISP8 4 /* PC relative 8 bit */
1522#define R_SPARC_DISP16 5 /* PC relative 16 bit */
1523#define R_SPARC_DISP32 6 /* PC relative 32 bit */
1524#define R_SPARC_WDISP30 7 /* PC relative 30 bit shifted */
1525#define R_SPARC_WDISP22 8 /* PC relative 22 bit shifted */
1526#define R_SPARC_HI22 9 /* High 22 bit */
1527#define R_SPARC_22 10 /* Direct 22 bit */
1528#define R_SPARC_13 11 /* Direct 13 bit */
1529#define R_SPARC_LO10 12 /* Truncated 10 bit */
1530#define R_SPARC_GOT10 13 /* Truncated 10 bit GOT entry */
1531#define R_SPARC_GOT13 14 /* 13 bit GOT entry */
1532#define R_SPARC_GOT22 15 /* 22 bit GOT entry shifted */
1533#define R_SPARC_PC10 16 /* PC relative 10 bit truncated */
1534#define R_SPARC_PC22 17 /* PC relative 22 bit shifted */
1535#define R_SPARC_WPLT30 18 /* 30 bit PC relative PLT address */
1536#define R_SPARC_COPY 19 /* Copy symbol at runtime */
1537#define R_SPARC_GLOB_DAT 20 /* Create GOT entry */
1538#define R_SPARC_JMP_SLOT 21 /* Create PLT entry */
1539#define R_SPARC_RELATIVE 22 /* Adjust by program base */
1540#define R_SPARC_UA32 23 /* Direct 32 bit unaligned */
1541
1542/* Additional Sparc64 relocs. */
1543
1544#define R_SPARC_PLT32 24 /* Direct 32 bit ref to PLT entry */
1545#define R_SPARC_HIPLT22 25 /* High 22 bit PLT entry */
1546#define R_SPARC_LOPLT10 26 /* Truncated 10 bit PLT entry */
1547#define R_SPARC_PCPLT32 27 /* PC rel 32 bit ref to PLT entry */
1548#define R_SPARC_PCPLT22 28 /* PC rel high 22 bit PLT entry */
1549#define R_SPARC_PCPLT10 29 /* PC rel trunc 10 bit PLT entry */
1550#define R_SPARC_10 30 /* Direct 10 bit */
1551#define R_SPARC_11 31 /* Direct 11 bit */
1552#define R_SPARC_64 32 /* Direct 64 bit */
1553#define R_SPARC_OLO10 33 /* 10bit with secondary 13bit addend */
1554#define R_SPARC_HH22 34 /* Top 22 bits of direct 64 bit */
1555#define R_SPARC_HM10 35 /* High middle 10 bits of ... */
1556#define R_SPARC_LM22 36 /* Low middle 22 bits of ... */
1557#define R_SPARC_PC_HH22 37 /* Top 22 bits of pc rel 64 bit */
1558#define R_SPARC_PC_HM10 38 /* High middle 10 bit of ... */
1559#define R_SPARC_PC_LM22 39 /* Low miggle 22 bits of ... */
1560#define R_SPARC_WDISP16 40 /* PC relative 16 bit shifted */
1561#define R_SPARC_WDISP19 41 /* PC relative 19 bit shifted */
1562#define R_SPARC_GLOB_JMP 42 /* was part of v9 ABI but was removed */
1563#define R_SPARC_7 43 /* Direct 7 bit */
1564#define R_SPARC_5 44 /* Direct 5 bit */
1565#define R_SPARC_6 45 /* Direct 6 bit */
1566#define R_SPARC_DISP64 46 /* PC relative 64 bit */
1567#define R_SPARC_PLT64 47 /* Direct 64 bit ref to PLT entry */
1568#define R_SPARC_HIX22 48 /* High 22 bit complemented */
1569#define R_SPARC_LOX10 49 /* Truncated 11 bit complemented */
1570#define R_SPARC_H44 50 /* Direct high 12 of 44 bit */
1571#define R_SPARC_M44 51 /* Direct mid 22 of 44 bit */
1572#define R_SPARC_L44 52 /* Direct low 10 of 44 bit */
1573#define R_SPARC_REGISTER 53 /* Global register usage */
1574#define R_SPARC_UA64 54 /* Direct 64 bit unaligned */
1575#define R_SPARC_UA16 55 /* Direct 16 bit unaligned */
1576#define R_SPARC_TLS_GD_HI22 56
1577#define R_SPARC_TLS_GD_LO10 57
1578#define R_SPARC_TLS_GD_ADD 58
1579#define R_SPARC_TLS_GD_CALL 59
1580#define R_SPARC_TLS_LDM_HI22 60
1581#define R_SPARC_TLS_LDM_LO10 61
1582#define R_SPARC_TLS_LDM_ADD 62
1583#define R_SPARC_TLS_LDM_CALL 63
1584#define R_SPARC_TLS_LDO_HIX22 64
1585#define R_SPARC_TLS_LDO_LOX10 65
1586#define R_SPARC_TLS_LDO_ADD 66
1587#define R_SPARC_TLS_IE_HI22 67
1588#define R_SPARC_TLS_IE_LO10 68
1589#define R_SPARC_TLS_IE_LD 69
1590#define R_SPARC_TLS_IE_LDX 70
1591#define R_SPARC_TLS_IE_ADD 71
1592#define R_SPARC_TLS_LE_HIX22 72
1593#define R_SPARC_TLS_LE_LOX10 73
1594#define R_SPARC_TLS_DTPMOD32 74
1595#define R_SPARC_TLS_DTPMOD64 75
1596#define R_SPARC_TLS_DTPOFF32 76
1597#define R_SPARC_TLS_DTPOFF64 77
1598#define R_SPARC_TLS_TPOFF32 78
1599#define R_SPARC_TLS_TPOFF64 79
1600#define R_SPARC_GOTDATA_HIX22 80
1601#define R_SPARC_GOTDATA_LOX10 81
1602#define R_SPARC_GOTDATA_OP_HIX22 82
1603#define R_SPARC_GOTDATA_OP_LOX10 83
1604#define R_SPARC_GOTDATA_OP 84
1605#define R_SPARC_H34 85
1606#define R_SPARC_SIZE32 86
1607#define R_SPARC_SIZE64 87
1608#define R_SPARC_WDISP10 88
1609#define R_SPARC_JMP_IREL 248
1610#define R_SPARC_IRELATIVE 249
1611#define R_SPARC_GNU_VTINHERIT 250
1612#define R_SPARC_GNU_VTENTRY 251
1613#define R_SPARC_REV32 252
1614/* Keep this the last entry. */
1615#define R_SPARC_NUM 253
1616
1617/* For Sparc64, legal values for d_tag of Elf64_Dyn. */
1618
1619#define DT_SPARC_REGISTER 0x70000001
1620#define DT_SPARC_NUM 2
1621
1622/* MIPS R3000 specific definitions. */
1623
1624/* Legal values for e_flags field of Elf32_Ehdr. */
1625
1626#define EF_MIPS_NOREORDER 1 /* A .noreorder directive was used. */
1627#define EF_MIPS_PIC 2 /* Contains PIC code. */
1628#define EF_MIPS_CPIC 4 /* Uses PIC calling sequence. */
1629#define EF_MIPS_XGOT 8
1630#define EF_MIPS_64BIT_WHIRL 16
1631#define EF_MIPS_ABI2 32
1632#define EF_MIPS_ABI_ON32 64
1633#define EF_MIPS_FP64 512 /* Uses FP64 (12 callee-saved). */
1634#define EF_MIPS_NAN2008 1024 /* Uses IEEE 754-2008 NaN encoding. */
1635#define EF_MIPS_ARCH 0xf0000000 /* MIPS architecture level. */
1636
1637/* Legal values for MIPS architecture level. */
1638
1639#define EF_MIPS_ARCH_1 0x00000000 /* -mips1 code. */
1640#define EF_MIPS_ARCH_2 0x10000000 /* -mips2 code. */
1641#define EF_MIPS_ARCH_3 0x20000000 /* -mips3 code. */
1642#define EF_MIPS_ARCH_4 0x30000000 /* -mips4 code. */
1643#define EF_MIPS_ARCH_5 0x40000000 /* -mips5 code. */
1644#define EF_MIPS_ARCH_32 0x50000000 /* MIPS32 code. */
1645#define EF_MIPS_ARCH_64 0x60000000 /* MIPS64 code. */
1646#define EF_MIPS_ARCH_32R2 0x70000000 /* MIPS32r2 code. */
1647#define EF_MIPS_ARCH_64R2 0x80000000 /* MIPS64r2 code. */
1648
1649/* The following are unofficial names and should not be used. */
1650
1651#define E_MIPS_ARCH_1 EF_MIPS_ARCH_1
1652#define E_MIPS_ARCH_2 EF_MIPS_ARCH_2
1653#define E_MIPS_ARCH_3 EF_MIPS_ARCH_3
1654#define E_MIPS_ARCH_4 EF_MIPS_ARCH_4
1655#define E_MIPS_ARCH_5 EF_MIPS_ARCH_5
1656#define E_MIPS_ARCH_32 EF_MIPS_ARCH_32
1657#define E_MIPS_ARCH_64 EF_MIPS_ARCH_64
1658
1659/* Special section indices. */
1660
1661#define SHN_MIPS_ACOMMON 0xff00 /* Allocated common symbols. */
1662#define SHN_MIPS_TEXT 0xff01 /* Allocated test symbols. */
1663#define SHN_MIPS_DATA 0xff02 /* Allocated data symbols. */
1664#define SHN_MIPS_SCOMMON 0xff03 /* Small common symbols. */
1665#define SHN_MIPS_SUNDEFINED 0xff04 /* Small undefined symbols. */
1666
1667/* Legal values for sh_type field of Elf32_Shdr. */
1668
1669#define SHT_MIPS_LIBLIST 0x70000000 /* Shared objects used in link. */
1670#define SHT_MIPS_MSYM 0x70000001
1671#define SHT_MIPS_CONFLICT 0x70000002 /* Conflicting symbols. */
1672#define SHT_MIPS_GPTAB 0x70000003 /* Global data area sizes. */
1673#define SHT_MIPS_UCODE 0x70000004 /* Reserved for SGI/MIPS compilers */
1674#define SHT_MIPS_DEBUG 0x70000005 /* MIPS ECOFF debugging info. */
1675#define SHT_MIPS_REGINFO 0x70000006 /* Register usage information. */
1676#define SHT_MIPS_PACKAGE 0x70000007
1677#define SHT_MIPS_PACKSYM 0x70000008
1678#define SHT_MIPS_RELD 0x70000009
1679#define SHT_MIPS_IFACE 0x7000000b
1680#define SHT_MIPS_CONTENT 0x7000000c
1681#define SHT_MIPS_OPTIONS 0x7000000d /* Miscellaneous options. */
1682#define SHT_MIPS_SHDR 0x70000010
1683#define SHT_MIPS_FDESC 0x70000011
1684#define SHT_MIPS_EXTSYM 0x70000012
1685#define SHT_MIPS_DENSE 0x70000013
1686#define SHT_MIPS_PDESC 0x70000014
1687#define SHT_MIPS_LOCSYM 0x70000015
1688#define SHT_MIPS_AUXSYM 0x70000016
1689#define SHT_MIPS_OPTSYM 0x70000017
1690#define SHT_MIPS_LOCSTR 0x70000018
1691#define SHT_MIPS_LINE 0x70000019
1692#define SHT_MIPS_RFDESC 0x7000001a
1693#define SHT_MIPS_DELTASYM 0x7000001b
1694#define SHT_MIPS_DELTAINST 0x7000001c
1695#define SHT_MIPS_DELTACLASS 0x7000001d
1696#define SHT_MIPS_DWARF 0x7000001e /* DWARF debugging information. */
1697#define SHT_MIPS_DELTADECL 0x7000001f
1698#define SHT_MIPS_SYMBOL_LIB 0x70000020
1699#define SHT_MIPS_EVENTS 0x70000021 /* Event section. */
1700#define SHT_MIPS_TRANSLATE 0x70000022
1701#define SHT_MIPS_PIXIE 0x70000023
1702#define SHT_MIPS_XLATE 0x70000024
1703#define SHT_MIPS_XLATE_DEBUG 0x70000025
1704#define SHT_MIPS_WHIRL 0x70000026
1705#define SHT_MIPS_EH_REGION 0x70000027
1706#define SHT_MIPS_XLATE_OLD 0x70000028
1707#define SHT_MIPS_PDR_EXCEPTION 0x70000029
1708
1709/* Legal values for sh_flags field of Elf32_Shdr. */
1710
1711#define SHF_MIPS_GPREL 0x10000000 /* Must be in global data area. */
1712#define SHF_MIPS_MERGE 0x20000000
1713#define SHF_MIPS_ADDR 0x40000000
1714#define SHF_MIPS_STRINGS 0x80000000
1715#define SHF_MIPS_NOSTRIP 0x08000000
1716#define SHF_MIPS_LOCAL 0x04000000
1717#define SHF_MIPS_NAMES 0x02000000
1718#define SHF_MIPS_NODUPE 0x01000000
1719
1720
1721/* Symbol tables. */
1722
1723/* MIPS specific values for `st_other'. */
1724#define STO_MIPS_DEFAULT 0x0
1725#define STO_MIPS_INTERNAL 0x1
1726#define STO_MIPS_HIDDEN 0x2
1727#define STO_MIPS_PROTECTED 0x3
1728#define STO_MIPS_PLT 0x8
1729#define STO_MIPS_SC_ALIGN_UNUSED 0xff
1730
1731/* MIPS specific values for `st_info'. */
1732#define STB_MIPS_SPLIT_COMMON 13
1733
1734/* Entries found in sections of type SHT_MIPS_GPTAB. */
1735
1736typedef union
1737{
1738 struct
1739 {
1740 Elf32_Word gt_current_g_value; /* -G value used for compilation. */
1741 Elf32_Word gt_unused; /* Not used. */
1742 } gt_header; /* First entry in section. */
1743 struct
1744 {
1745 Elf32_Word gt_g_value; /* If this value were used for -G. */
1746 Elf32_Word gt_bytes; /* This many bytes would be used. */
1747 } gt_entry; /* Subsequent entries in section. */
1748} Elf32_gptab;
1749
1750/* Entry found in sections of type SHT_MIPS_REGINFO. */
1751
1752typedef struct
1753{
1754 Elf32_Word ri_gprmask; /* General registers used. */
1755 Elf32_Word ri_cprmask[4]; /* Coprocessor registers used. */
1756 Elf32_Sword ri_gp_value; /* $gp register value. */
1757} Elf32_RegInfo;
1758
1759/* Entries found in sections of type SHT_MIPS_OPTIONS. */
1760
1761typedef struct
1762{
1763 unsigned char kind; /* Determines interpretation of the
1764 variable part of descriptor. */
1765 unsigned char size; /* Size of descriptor, including header. */
1766 Elf32_Section section; /* Section header index of section affected,
1767 0 for global options. */
1768 Elf32_Word info; /* Kind-specific information. */
1769} Elf_Options;
1770
1771/* Values for `kind' field in Elf_Options. */
1772
1773#define ODK_NULL 0 /* Undefined. */
1774#define ODK_REGINFO 1 /* Register usage information. */
1775#define ODK_EXCEPTIONS 2 /* Exception processing options. */
1776#define ODK_PAD 3 /* Section padding options. */
1777#define ODK_HWPATCH 4 /* Hardware workarounds performed */
1778#define ODK_FILL 5 /* record the fill value used by the linker. */
1779#define ODK_TAGS 6 /* reserve space for desktop tools to write. */
1780#define ODK_HWAND 7 /* HW workarounds. 'AND' bits when merging. */
1781#define ODK_HWOR 8 /* HW workarounds. 'OR' bits when merging. */
1782
1783/* Values for `info' in Elf_Options for ODK_EXCEPTIONS entries. */
1784
1785#define OEX_FPU_MIN 0x1f /* FPE's which MUST be enabled. */
1786#define OEX_FPU_MAX 0x1f00 /* FPE's which MAY be enabled. */
1787#define OEX_PAGE0 0x10000 /* page zero must be mapped. */
1788#define OEX_SMM 0x20000 /* Force sequential memory mode? */
1789#define OEX_FPDBUG 0x40000 /* Force floating point debug mode? */
1790#define OEX_PRECISEFP OEX_FPDBUG
1791#define OEX_DISMISS 0x80000 /* Dismiss invalid address faults? */
1792
1793#define OEX_FPU_INVAL 0x10
1794#define OEX_FPU_DIV0 0x08
1795#define OEX_FPU_OFLO 0x04
1796#define OEX_FPU_UFLO 0x02
1797#define OEX_FPU_INEX 0x01
1798
1799/* Masks for `info' in Elf_Options for an ODK_HWPATCH entry. */
1800
1801#define OHW_R4KEOP 0x1 /* R4000 end-of-page patch. */
1802#define OHW_R8KPFETCH 0x2 /* may need R8000 prefetch patch. */
1803#define OHW_R5KEOP 0x4 /* R5000 end-of-page patch. */
1804#define OHW_R5KCVTL 0x8 /* R5000 cvt.[ds].l bug. clean=1. */
1805
1806#define OPAD_PREFIX 0x1
1807#define OPAD_POSTFIX 0x2
1808#define OPAD_SYMBOL 0x4
1809
1810/* Entry found in `.options' section. */
1811
1812typedef struct
1813{
1814 Elf32_Word hwp_flags1; /* Extra flags. */
1815 Elf32_Word hwp_flags2; /* Extra flags. */
1816} Elf_Options_Hw;
1817
1818/* Masks for `info' in ElfOptions for ODK_HWAND and ODK_HWOR entries. */
1819
1820#define OHWA0_R4KEOP_CHECKED 0x00000001
1821#define OHWA1_R4KEOP_CLEAN 0x00000002
1822
1823/* MIPS relocs. */
1824
1825#define R_MIPS_NONE 0 /* No reloc */
1826#define R_MIPS_16 1 /* Direct 16 bit */
1827#define R_MIPS_32 2 /* Direct 32 bit */
1828#define R_MIPS_REL32 3 /* PC relative 32 bit */
1829#define R_MIPS_26 4 /* Direct 26 bit shifted */
1830#define R_MIPS_HI16 5 /* High 16 bit */
1831#define R_MIPS_LO16 6 /* Low 16 bit */
1832#define R_MIPS_GPREL16 7 /* GP relative 16 bit */
1833#define R_MIPS_LITERAL 8 /* 16 bit literal entry */
1834#define R_MIPS_GOT16 9 /* 16 bit GOT entry */
1835#define R_MIPS_PC16 10 /* PC relative 16 bit */
1836#define R_MIPS_CALL16 11 /* 16 bit GOT entry for function */
1837#define R_MIPS_GPREL32 12 /* GP relative 32 bit */
1838
1839#define R_MIPS_SHIFT5 16
1840#define R_MIPS_SHIFT6 17
1841#define R_MIPS_64 18
1842#define R_MIPS_GOT_DISP 19
1843#define R_MIPS_GOT_PAGE 20
1844#define R_MIPS_GOT_OFST 21
1845#define R_MIPS_GOT_HI16 22
1846#define R_MIPS_GOT_LO16 23
1847#define R_MIPS_SUB 24
1848#define R_MIPS_INSERT_A 25
1849#define R_MIPS_INSERT_B 26
1850#define R_MIPS_DELETE 27
1851#define R_MIPS_HIGHER 28
1852#define R_MIPS_HIGHEST 29
1853#define R_MIPS_CALL_HI16 30
1854#define R_MIPS_CALL_LO16 31
1855#define R_MIPS_SCN_DISP 32
1856#define R_MIPS_REL16 33
1857#define R_MIPS_ADD_IMMEDIATE 34
1858#define R_MIPS_PJUMP 35
1859#define R_MIPS_RELGOT 36
1860#define R_MIPS_JALR 37
1861#define R_MIPS_TLS_DTPMOD32 38 /* Module number 32 bit */
1862#define R_MIPS_TLS_DTPREL32 39 /* Module-relative offset 32 bit */
1863#define R_MIPS_TLS_DTPMOD64 40 /* Module number 64 bit */
1864#define R_MIPS_TLS_DTPREL64 41 /* Module-relative offset 64 bit */
1865#define R_MIPS_TLS_GD 42 /* 16 bit GOT offset for GD */
1866#define R_MIPS_TLS_LDM 43 /* 16 bit GOT offset for LDM */
1867#define R_MIPS_TLS_DTPREL_HI16 44 /* Module-relative offset, high 16 bits */
1868#define R_MIPS_TLS_DTPREL_LO16 45 /* Module-relative offset, low 16 bits */
1869#define R_MIPS_TLS_GOTTPREL 46 /* 16 bit GOT offset for IE */
1870#define R_MIPS_TLS_TPREL32 47 /* TP-relative offset, 32 bit */
1871#define R_MIPS_TLS_TPREL64 48 /* TP-relative offset, 64 bit */
1872#define R_MIPS_TLS_TPREL_HI16 49 /* TP-relative offset, high 16 bits */
1873#define R_MIPS_TLS_TPREL_LO16 50 /* TP-relative offset, low 16 bits */
1874#define R_MIPS_GLOB_DAT 51
1875#define R_MIPS_COPY 126
1876#define R_MIPS_JUMP_SLOT 127
1877/* Keep this the last entry. */
1878#define R_MIPS_NUM 128
1879
1880/* Legal values for p_type field of Elf32_Phdr. */
1881
1882#define PT_MIPS_REGINFO 0x70000000 /* Register usage information. */
1883#define PT_MIPS_RTPROC 0x70000001 /* Runtime procedure table. */
1884#define PT_MIPS_OPTIONS 0x70000002
1885#define PT_MIPS_ABIFLAGS 0x70000003 /* FP mode requirement. */
1886
1887/* Special program header types. */
1888
1889#define PF_MIPS_LOCAL 0x10000000
1890
1891/* Legal values for d_tag field of Elf32_Dyn. */
1892
1893#define DT_MIPS_RLD_VERSION 0x70000001 /* Runtime linker interface version */
1894#define DT_MIPS_TIME_STAMP 0x70000002 /* Timestamp */
1895#define DT_MIPS_ICHECKSUM 0x70000003 /* Checksum */
1896#define DT_MIPS_IVERSION 0x70000004 /* Version string (string tbl index) */
1897#define DT_MIPS_FLAGS 0x70000005 /* Flags */
1898#define DT_MIPS_BASE_ADDRESS 0x70000006 /* Base address */
1899#define DT_MIPS_MSYM 0x70000007
1900#define DT_MIPS_CONFLICT 0x70000008 /* Address of CONFLICT section */
1901#define DT_MIPS_LIBLIST 0x70000009 /* Address of LIBLIST section */
1902#define DT_MIPS_LOCAL_GOTNO 0x7000000a /* Number of local GOT entries */
1903#define DT_MIPS_CONFLICTNO 0x7000000b /* Number of CONFLICT entries */
1904#define DT_MIPS_LIBLISTNO 0x70000010 /* Number of LIBLIST entries */
1905#define DT_MIPS_SYMTABNO 0x70000011 /* Number of DYNSYM entries */
1906#define DT_MIPS_UNREFEXTNO 0x70000012 /* First external DYNSYM */
1907#define DT_MIPS_GOTSYM 0x70000013 /* First GOT entry in DYNSYM */
1908#define DT_MIPS_HIPAGENO 0x70000014 /* Number of GOT page table entries */
1909#define DT_MIPS_RLD_MAP 0x70000016 /* Address of run time loader map. */
1910#define DT_MIPS_DELTA_CLASS 0x70000017 /* Delta C++ class definition. */
1911#define DT_MIPS_DELTA_CLASS_NO 0x70000018 /* Number of entries in
1912 DT_MIPS_DELTA_CLASS. */
1913#define DT_MIPS_DELTA_INSTANCE 0x70000019 /* Delta C++ class instances. */
1914#define DT_MIPS_DELTA_INSTANCE_NO 0x7000001a /* Number of entries in
1915 DT_MIPS_DELTA_INSTANCE. */
1916#define DT_MIPS_DELTA_RELOC 0x7000001b /* Delta relocations. */
1917#define DT_MIPS_DELTA_RELOC_NO 0x7000001c /* Number of entries in
1918 DT_MIPS_DELTA_RELOC. */
1919#define DT_MIPS_DELTA_SYM 0x7000001d /* Delta symbols that Delta
1920 relocations refer to. */
1921#define DT_MIPS_DELTA_SYM_NO 0x7000001e /* Number of entries in
1922 DT_MIPS_DELTA_SYM. */
1923#define DT_MIPS_DELTA_CLASSSYM 0x70000020 /* Delta symbols that hold the
1924 class declaration. */
1925#define DT_MIPS_DELTA_CLASSSYM_NO 0x70000021 /* Number of entries in
1926 DT_MIPS_DELTA_CLASSSYM. */
1927#define DT_MIPS_CXX_FLAGS 0x70000022 /* Flags indicating for C++ flavor. */
1928#define DT_MIPS_PIXIE_INIT 0x70000023
1929#define DT_MIPS_SYMBOL_LIB 0x70000024
1930#define DT_MIPS_LOCALPAGE_GOTIDX 0x70000025
1931#define DT_MIPS_LOCAL_GOTIDX 0x70000026
1932#define DT_MIPS_HIDDEN_GOTIDX 0x70000027
1933#define DT_MIPS_PROTECTED_GOTIDX 0x70000028
1934#define DT_MIPS_OPTIONS 0x70000029 /* Address of .options. */
1935#define DT_MIPS_INTERFACE 0x7000002a /* Address of .interface. */
1936#define DT_MIPS_DYNSTR_ALIGN 0x7000002b
1937#define DT_MIPS_INTERFACE_SIZE 0x7000002c /* Size of the .interface section. */
1938#define DT_MIPS_RLD_TEXT_RESOLVE_ADDR 0x7000002d /* Address of rld_text_rsolve
1939 function stored in GOT. */
1940#define DT_MIPS_PERF_SUFFIX 0x7000002e /* Default suffix of dso to be added
1941 by rld on dlopen() calls. */
1942#define DT_MIPS_COMPACT_SIZE 0x7000002f /* (O32)Size of compact rel section. */
1943#define DT_MIPS_GP_VALUE 0x70000030 /* GP value for aux GOTs. */
1944#define DT_MIPS_AUX_DYNAMIC 0x70000031 /* Address of aux .dynamic. */
1945/* The address of .got.plt in an executable using the new non-PIC ABI. */
1946#define DT_MIPS_PLTGOT 0x70000032
1947/* The base of the PLT in an executable using the new non-PIC ABI if that
1948 PLT is writable. For a non-writable PLT, this is omitted or has a zero
1949 value. */
1950#define DT_MIPS_RWPLT 0x70000034
1951/* An alternative description of the classic MIPS RLD_MAP that is usable
1952 in a PIE as it stores a relative offset from the address of the tag
1953 rather than an absolute address. */
1954#define DT_MIPS_RLD_MAP_REL 0x70000035
1955#define DT_MIPS_NUM 0x36
1956
1957/* Legal values for DT_MIPS_FLAGS Elf32_Dyn entry. */
1958
1959#define RHF_NONE 0 /* No flags */
1960#define RHF_QUICKSTART (1 << 0) /* Use quickstart */
1961#define RHF_NOTPOT (1 << 1) /* Hash size not power of 2 */
1962#define RHF_NO_LIBRARY_REPLACEMENT (1 << 2) /* Ignore LD_LIBRARY_PATH */
1963#define RHF_NO_MOVE (1 << 3)
1964#define RHF_SGI_ONLY (1 << 4)
1965#define RHF_GUARANTEE_INIT (1 << 5)
1966#define RHF_DELTA_C_PLUS_PLUS (1 << 6)
1967#define RHF_GUARANTEE_START_INIT (1 << 7)
1968#define RHF_PIXIE (1 << 8)
1969#define RHF_DEFAULT_DELAY_LOAD (1 << 9)
1970#define RHF_REQUICKSTART (1 << 10)
1971#define RHF_REQUICKSTARTED (1 << 11)
1972#define RHF_CORD (1 << 12)
1973#define RHF_NO_UNRES_UNDEF (1 << 13)
1974#define RHF_RLD_ORDER_SAFE (1 << 14)
1975
1976/* Entries found in sections of type SHT_MIPS_LIBLIST. */
1977
1978typedef struct
1979{
1980 Elf32_Word l_name; /* Name (string table index) */
1981 Elf32_Word l_time_stamp; /* Timestamp */
1982 Elf32_Word l_checksum; /* Checksum */
1983 Elf32_Word l_version; /* Interface version */
1984 Elf32_Word l_flags; /* Flags */
1985} Elf32_Lib;
1986
1987typedef struct
1988{
1989 Elf64_Word l_name; /* Name (string table index) */
1990 Elf64_Word l_time_stamp; /* Timestamp */
1991 Elf64_Word l_checksum; /* Checksum */
1992 Elf64_Word l_version; /* Interface version */
1993 Elf64_Word l_flags; /* Flags */
1994} Elf64_Lib;
1995
1996
1997/* Legal values for l_flags. */
1998
1999#define LL_NONE 0
2000#define LL_EXACT_MATCH (1 << 0) /* Require exact match */
2001#define LL_IGNORE_INT_VER (1 << 1) /* Ignore interface version */
2002#define LL_REQUIRE_MINOR (1 << 2)
2003#define LL_EXPORTS (1 << 3)
2004#define LL_DELAY_LOAD (1 << 4)
2005#define LL_DELTA (1 << 5)
2006
2007/* Entries found in sections of type SHT_MIPS_CONFLICT. */
2008
2009typedef Elf32_Addr Elf32_Conflict;
2010
2011typedef struct
2012{
2013 /* Version of flags structure. */
2014 Elf32_Half version;
2015 /* The level of the ISA: 1-5, 32, 64. */
2016 unsigned char isa_level;
2017 /* The revision of ISA: 0 for MIPS V and below, 1-n otherwise. */
2018 unsigned char isa_rev;
2019 /* The size of general purpose registers. */
2020 unsigned char gpr_size;
2021 /* The size of co-processor 1 registers. */
2022 unsigned char cpr1_size;
2023 /* The size of co-processor 2 registers. */
2024 unsigned char cpr2_size;
2025 /* The floating-point ABI. */
2026 unsigned char fp_abi;
2027 /* Processor-specific extension. */
2028 Elf32_Word isa_ext;
2029 /* Mask of ASEs used. */
2030 Elf32_Word ases;
2031 /* Mask of general flags. */
2032 Elf32_Word flags1;
2033 Elf32_Word flags2;
2034} Elf_MIPS_ABIFlags_v0;
2035
2036/* Values for the register size bytes of an abi flags structure. */
2037
2038#define MIPS_AFL_REG_NONE 0x00 /* No registers. */
2039#define MIPS_AFL_REG_32 0x01 /* 32-bit registers. */
2040#define MIPS_AFL_REG_64 0x02 /* 64-bit registers. */
2041#define MIPS_AFL_REG_128 0x03 /* 128-bit registers. */
2042
2043/* Masks for the ases word of an ABI flags structure. */
2044
2045#define MIPS_AFL_ASE_DSP 0x00000001 /* DSP ASE. */
2046#define MIPS_AFL_ASE_DSPR2 0x00000002 /* DSP R2 ASE. */
2047#define MIPS_AFL_ASE_EVA 0x00000004 /* Enhanced VA Scheme. */
2048#define MIPS_AFL_ASE_MCU 0x00000008 /* MCU (MicroController) ASE. */
2049#define MIPS_AFL_ASE_MDMX 0x00000010 /* MDMX ASE. */
2050#define MIPS_AFL_ASE_MIPS3D 0x00000020 /* MIPS-3D ASE. */
2051#define MIPS_AFL_ASE_MT 0x00000040 /* MT ASE. */
2052#define MIPS_AFL_ASE_SMARTMIPS 0x00000080 /* SmartMIPS ASE. */
2053#define MIPS_AFL_ASE_VIRT 0x00000100 /* VZ ASE. */
2054#define MIPS_AFL_ASE_MSA 0x00000200 /* MSA ASE. */
2055#define MIPS_AFL_ASE_MIPS16 0x00000400 /* MIPS16 ASE. */
2056#define MIPS_AFL_ASE_MICROMIPS 0x00000800 /* MICROMIPS ASE. */
2057#define MIPS_AFL_ASE_XPA 0x00001000 /* XPA ASE. */
2058#define MIPS_AFL_ASE_MASK 0x00001fff /* All ASEs. */
2059
2060/* Values for the isa_ext word of an ABI flags structure. */
2061
2062#define MIPS_AFL_EXT_XLR 1 /* RMI Xlr instruction. */
2063#define MIPS_AFL_EXT_OCTEON2 2 /* Cavium Networks Octeon2. */
2064#define MIPS_AFL_EXT_OCTEONP 3 /* Cavium Networks OcteonP. */
2065#define MIPS_AFL_EXT_LOONGSON_3A 4 /* Loongson 3A. */
2066#define MIPS_AFL_EXT_OCTEON 5 /* Cavium Networks Octeon. */
2067#define MIPS_AFL_EXT_5900 6 /* MIPS R5900 instruction. */
2068#define MIPS_AFL_EXT_4650 7 /* MIPS R4650 instruction. */
2069#define MIPS_AFL_EXT_4010 8 /* LSI R4010 instruction. */
2070#define MIPS_AFL_EXT_4100 9 /* NEC VR4100 instruction. */
2071#define MIPS_AFL_EXT_3900 10 /* Toshiba R3900 instruction. */
2072#define MIPS_AFL_EXT_10000 11 /* MIPS R10000 instruction. */
2073#define MIPS_AFL_EXT_SB1 12 /* Broadcom SB-1 instruction. */
2074#define MIPS_AFL_EXT_4111 13 /* NEC VR4111/VR4181 instruction. */
2075#define MIPS_AFL_EXT_4120 14 /* NEC VR4120 instruction. */
2076#define MIPS_AFL_EXT_5400 15 /* NEC VR5400 instruction. */
2077#define MIPS_AFL_EXT_5500 16 /* NEC VR5500 instruction. */
2078#define MIPS_AFL_EXT_LOONGSON_2E 17 /* ST Microelectronics Loongson 2E. */
2079#define MIPS_AFL_EXT_LOONGSON_2F 18 /* ST Microelectronics Loongson 2F. */
2080
2081/* Masks for the flags1 word of an ABI flags structure. */
2082#define MIPS_AFL_FLAGS1_ODDSPREG 1 /* Uses odd single-precision registers. */
2083
2084/* Object attribute values. */
2085enum
2086{
2087 /* Not tagged or not using any ABIs affected by the differences. */
2088 Val_GNU_MIPS_ABI_FP_ANY = 0,
2089 /* Using hard-float -mdouble-float. */
2090 Val_GNU_MIPS_ABI_FP_DOUBLE = 1,
2091 /* Using hard-float -msingle-float. */
2092 Val_GNU_MIPS_ABI_FP_SINGLE = 2,
2093 /* Using soft-float. */
2094 Val_GNU_MIPS_ABI_FP_SOFT = 3,
2095 /* Using -mips32r2 -mfp64. */
2096 Val_GNU_MIPS_ABI_FP_OLD_64 = 4,
2097 /* Using -mfpxx. */
2098 Val_GNU_MIPS_ABI_FP_XX = 5,
2099 /* Using -mips32r2 -mfp64. */
2100 Val_GNU_MIPS_ABI_FP_64 = 6,
2101 /* Using -mips32r2 -mfp64 -mno-odd-spreg. */
2102 Val_GNU_MIPS_ABI_FP_64A = 7,
2103 /* Maximum allocated FP ABI value. */
2104 Val_GNU_MIPS_ABI_FP_MAX = 7
2105};
2106
2107/* HPPA specific definitions. */
2108
2109/* Legal values for e_flags field of Elf32_Ehdr. */
2110
2111#define EF_PARISC_TRAPNIL 0x00010000 /* Trap nil pointer dereference. */
2112#define EF_PARISC_EXT 0x00020000 /* Program uses arch. extensions. */
2113#define EF_PARISC_LSB 0x00040000 /* Program expects little endian. */
2114#define EF_PARISC_WIDE 0x00080000 /* Program expects wide mode. */
2115#define EF_PARISC_NO_KABP 0x00100000 /* No kernel assisted branch
2116 prediction. */
2117#define EF_PARISC_LAZYSWAP 0x00400000 /* Allow lazy swapping. */
2118#define EF_PARISC_ARCH 0x0000ffff /* Architecture version. */
2119
2120/* Defined values for `e_flags & EF_PARISC_ARCH' are: */
2121
2122#define EFA_PARISC_1_0 0x020b /* PA-RISC 1.0 big-endian. */
2123#define EFA_PARISC_1_1 0x0210 /* PA-RISC 1.1 big-endian. */
2124#define EFA_PARISC_2_0 0x0214 /* PA-RISC 2.0 big-endian. */
2125
2126/* Additional section indeces. */
2127
2128#define SHN_PARISC_ANSI_COMMON 0xff00 /* Section for tenatively declared
2129 symbols in ANSI C. */
2130#define SHN_PARISC_HUGE_COMMON 0xff01 /* Common blocks in huge model. */
2131
2132/* Legal values for sh_type field of Elf32_Shdr. */
2133
2134#define SHT_PARISC_EXT 0x70000000 /* Contains product specific ext. */
2135#define SHT_PARISC_UNWIND 0x70000001 /* Unwind information. */
2136#define SHT_PARISC_DOC 0x70000002 /* Debug info for optimized code. */
2137
2138/* Legal values for sh_flags field of Elf32_Shdr. */
2139
2140#define SHF_PARISC_SHORT 0x20000000 /* Section with short addressing. */
2141#define SHF_PARISC_HUGE 0x40000000 /* Section far from gp. */
2142#define SHF_PARISC_SBP 0x80000000 /* Static branch prediction code. */
2143
2144/* Legal values for ST_TYPE subfield of st_info (symbol type). */
2145
2146#define STT_PARISC_MILLICODE 13 /* Millicode function entry point. */
2147
2148#define STT_HP_OPAQUE (STT_LOOS + 0x1)
2149#define STT_HP_STUB (STT_LOOS + 0x2)
2150
2151/* HPPA relocs. */
2152
2153#define R_PARISC_NONE 0 /* No reloc. */
2154#define R_PARISC_DIR32 1 /* Direct 32-bit reference. */
2155#define R_PARISC_DIR21L 2 /* Left 21 bits of eff. address. */
2156#define R_PARISC_DIR17R 3 /* Right 17 bits of eff. address. */
2157#define R_PARISC_DIR17F 4 /* 17 bits of eff. address. */
2158#define R_PARISC_DIR14R 6 /* Right 14 bits of eff. address. */
2159#define R_PARISC_PCREL32 9 /* 32-bit rel. address. */
2160#define R_PARISC_PCREL21L 10 /* Left 21 bits of rel. address. */
2161#define R_PARISC_PCREL17R 11 /* Right 17 bits of rel. address. */
2162#define R_PARISC_PCREL17F 12 /* 17 bits of rel. address. */
2163#define R_PARISC_PCREL14R 14 /* Right 14 bits of rel. address. */
2164#define R_PARISC_DPREL21L 18 /* Left 21 bits of rel. address. */
2165#define R_PARISC_DPREL14R 22 /* Right 14 bits of rel. address. */
2166#define R_PARISC_GPREL21L 26 /* GP-relative, left 21 bits. */
2167#define R_PARISC_GPREL14R 30 /* GP-relative, right 14 bits. */
2168#define R_PARISC_LTOFF21L 34 /* LT-relative, left 21 bits. */
2169#define R_PARISC_LTOFF14R 38 /* LT-relative, right 14 bits. */
2170#define R_PARISC_SECREL32 41 /* 32 bits section rel. address. */
2171#define R_PARISC_SEGBASE 48 /* No relocation, set segment base. */
2172#define R_PARISC_SEGREL32 49 /* 32 bits segment rel. address. */
2173#define R_PARISC_PLTOFF21L 50 /* PLT rel. address, left 21 bits. */
2174#define R_PARISC_PLTOFF14R 54 /* PLT rel. address, right 14 bits. */
2175#define R_PARISC_LTOFF_FPTR32 57 /* 32 bits LT-rel. function pointer. */
2176#define R_PARISC_LTOFF_FPTR21L 58 /* LT-rel. fct ptr, left 21 bits. */
2177#define R_PARISC_LTOFF_FPTR14R 62 /* LT-rel. fct ptr, right 14 bits. */
2178#define R_PARISC_FPTR64 64 /* 64 bits function address. */
2179#define R_PARISC_PLABEL32 65 /* 32 bits function address. */
2180#define R_PARISC_PLABEL21L 66 /* Left 21 bits of fdesc address. */
2181#define R_PARISC_PLABEL14R 70 /* Right 14 bits of fdesc address. */
2182#define R_PARISC_PCREL64 72 /* 64 bits PC-rel. address. */
2183#define R_PARISC_PCREL22F 74 /* 22 bits PC-rel. address. */
2184#define R_PARISC_PCREL14WR 75 /* PC-rel. address, right 14 bits. */
2185#define R_PARISC_PCREL14DR 76 /* PC rel. address, right 14 bits. */
2186#define R_PARISC_PCREL16F 77 /* 16 bits PC-rel. address. */
2187#define R_PARISC_PCREL16WF 78 /* 16 bits PC-rel. address. */
2188#define R_PARISC_PCREL16DF 79 /* 16 bits PC-rel. address. */
2189#define R_PARISC_DIR64 80 /* 64 bits of eff. address. */
2190#define R_PARISC_DIR14WR 83 /* 14 bits of eff. address. */
2191#define R_PARISC_DIR14DR 84 /* 14 bits of eff. address. */
2192#define R_PARISC_DIR16F 85 /* 16 bits of eff. address. */
2193#define R_PARISC_DIR16WF 86 /* 16 bits of eff. address. */
2194#define R_PARISC_DIR16DF 87 /* 16 bits of eff. address. */
2195#define R_PARISC_GPREL64 88 /* 64 bits of GP-rel. address. */
2196#define R_PARISC_GPREL14WR 91 /* GP-rel. address, right 14 bits. */
2197#define R_PARISC_GPREL14DR 92 /* GP-rel. address, right 14 bits. */
2198#define R_PARISC_GPREL16F 93 /* 16 bits GP-rel. address. */
2199#define R_PARISC_GPREL16WF 94 /* 16 bits GP-rel. address. */
2200#define R_PARISC_GPREL16DF 95 /* 16 bits GP-rel. address. */
2201#define R_PARISC_LTOFF64 96 /* 64 bits LT-rel. address. */
2202#define R_PARISC_LTOFF14WR 99 /* LT-rel. address, right 14 bits. */
2203#define R_PARISC_LTOFF14DR 100 /* LT-rel. address, right 14 bits. */
2204#define R_PARISC_LTOFF16F 101 /* 16 bits LT-rel. address. */
2205#define R_PARISC_LTOFF16WF 102 /* 16 bits LT-rel. address. */
2206#define R_PARISC_LTOFF16DF 103 /* 16 bits LT-rel. address. */
2207#define R_PARISC_SECREL64 104 /* 64 bits section rel. address. */
2208#define R_PARISC_SEGREL64 112 /* 64 bits segment rel. address. */
2209#define R_PARISC_PLTOFF14WR 115 /* PLT-rel. address, right 14 bits. */
2210#define R_PARISC_PLTOFF14DR 116 /* PLT-rel. address, right 14 bits. */
2211#define R_PARISC_PLTOFF16F 117 /* 16 bits LT-rel. address. */
2212#define R_PARISC_PLTOFF16WF 118 /* 16 bits PLT-rel. address. */
2213#define R_PARISC_PLTOFF16DF 119 /* 16 bits PLT-rel. address. */
2214#define R_PARISC_LTOFF_FPTR64 120 /* 64 bits LT-rel. function ptr. */
2215#define R_PARISC_LTOFF_FPTR14WR 123 /* LT-rel. fct. ptr., right 14 bits. */
2216#define R_PARISC_LTOFF_FPTR14DR 124 /* LT-rel. fct. ptr., right 14 bits. */
2217#define R_PARISC_LTOFF_FPTR16F 125 /* 16 bits LT-rel. function ptr. */
2218#define R_PARISC_LTOFF_FPTR16WF 126 /* 16 bits LT-rel. function ptr. */
2219#define R_PARISC_LTOFF_FPTR16DF 127 /* 16 bits LT-rel. function ptr. */
2220#define R_PARISC_LORESERVE 128
2221#define R_PARISC_COPY 128 /* Copy relocation. */
2222#define R_PARISC_IPLT 129 /* Dynamic reloc, imported PLT */
2223#define R_PARISC_EPLT 130 /* Dynamic reloc, exported PLT */
2224#define R_PARISC_TPREL32 153 /* 32 bits TP-rel. address. */
2225#define R_PARISC_TPREL21L 154 /* TP-rel. address, left 21 bits. */
2226#define R_PARISC_TPREL14R 158 /* TP-rel. address, right 14 bits. */
2227#define R_PARISC_LTOFF_TP21L 162 /* LT-TP-rel. address, left 21 bits. */
2228#define R_PARISC_LTOFF_TP14R 166 /* LT-TP-rel. address, right 14 bits.*/
2229#define R_PARISC_LTOFF_TP14F 167 /* 14 bits LT-TP-rel. address. */
2230#define R_PARISC_TPREL64 216 /* 64 bits TP-rel. address. */
2231#define R_PARISC_TPREL14WR 219 /* TP-rel. address, right 14 bits. */
2232#define R_PARISC_TPREL14DR 220 /* TP-rel. address, right 14 bits. */
2233#define R_PARISC_TPREL16F 221 /* 16 bits TP-rel. address. */
2234#define R_PARISC_TPREL16WF 222 /* 16 bits TP-rel. address. */
2235#define R_PARISC_TPREL16DF 223 /* 16 bits TP-rel. address. */
2236#define R_PARISC_LTOFF_TP64 224 /* 64 bits LT-TP-rel. address. */
2237#define R_PARISC_LTOFF_TP14WR 227 /* LT-TP-rel. address, right 14 bits.*/
2238#define R_PARISC_LTOFF_TP14DR 228 /* LT-TP-rel. address, right 14 bits.*/
2239#define R_PARISC_LTOFF_TP16F 229 /* 16 bits LT-TP-rel. address. */
2240#define R_PARISC_LTOFF_TP16WF 230 /* 16 bits LT-TP-rel. address. */
2241#define R_PARISC_LTOFF_TP16DF 231 /* 16 bits LT-TP-rel. address. */
2242#define R_PARISC_GNU_VTENTRY 232
2243#define R_PARISC_GNU_VTINHERIT 233
2244#define R_PARISC_TLS_GD21L 234 /* GD 21-bit left. */
2245#define R_PARISC_TLS_GD14R 235 /* GD 14-bit right. */
2246#define R_PARISC_TLS_GDCALL 236 /* GD call to __t_g_a. */
2247#define R_PARISC_TLS_LDM21L 237 /* LD module 21-bit left. */
2248#define R_PARISC_TLS_LDM14R 238 /* LD module 14-bit right. */
2249#define R_PARISC_TLS_LDMCALL 239 /* LD module call to __t_g_a. */
2250#define R_PARISC_TLS_LDO21L 240 /* LD offset 21-bit left. */
2251#define R_PARISC_TLS_LDO14R 241 /* LD offset 14-bit right. */
2252#define R_PARISC_TLS_DTPMOD32 242 /* DTP module 32-bit. */
2253#define R_PARISC_TLS_DTPMOD64 243 /* DTP module 64-bit. */
2254#define R_PARISC_TLS_DTPOFF32 244 /* DTP offset 32-bit. */
2255#define R_PARISC_TLS_DTPOFF64 245 /* DTP offset 32-bit. */
2256#define R_PARISC_TLS_LE21L R_PARISC_TPREL21L
2257#define R_PARISC_TLS_LE14R R_PARISC_TPREL14R
2258#define R_PARISC_TLS_IE21L R_PARISC_LTOFF_TP21L
2259#define R_PARISC_TLS_IE14R R_PARISC_LTOFF_TP14R
2260#define R_PARISC_TLS_TPREL32 R_PARISC_TPREL32
2261#define R_PARISC_TLS_TPREL64 R_PARISC_TPREL64
2262#define R_PARISC_HIRESERVE 255
2263
2264/* Legal values for p_type field of Elf32_Phdr/Elf64_Phdr. */
2265
2266#define PT_HP_TLS (PT_LOOS + 0x0)
2267#define PT_HP_CORE_NONE (PT_LOOS + 0x1)
2268#define PT_HP_CORE_VERSION (PT_LOOS + 0x2)
2269#define PT_HP_CORE_KERNEL (PT_LOOS + 0x3)
2270#define PT_HP_CORE_COMM (PT_LOOS + 0x4)
2271#define PT_HP_CORE_PROC (PT_LOOS + 0x5)
2272#define PT_HP_CORE_LOADABLE (PT_LOOS + 0x6)
2273#define PT_HP_CORE_STACK (PT_LOOS + 0x7)
2274#define PT_HP_CORE_SHM (PT_LOOS + 0x8)
2275#define PT_HP_CORE_MMF (PT_LOOS + 0x9)
2276#define PT_HP_PARALLEL (PT_LOOS + 0x10)
2277#define PT_HP_FASTBIND (PT_LOOS + 0x11)
2278#define PT_HP_OPT_ANNOT (PT_LOOS + 0x12)
2279#define PT_HP_HSL_ANNOT (PT_LOOS + 0x13)
2280#define PT_HP_STACK (PT_LOOS + 0x14)
2281
2282#define PT_PARISC_ARCHEXT 0x70000000
2283#define PT_PARISC_UNWIND 0x70000001
2284
2285/* Legal values for p_flags field of Elf32_Phdr/Elf64_Phdr. */
2286
2287#define PF_PARISC_SBP 0x08000000
2288
2289#define PF_HP_PAGE_SIZE 0x00100000
2290#define PF_HP_FAR_SHARED 0x00200000
2291#define PF_HP_NEAR_SHARED 0x00400000
2292#define PF_HP_CODE 0x01000000
2293#define PF_HP_MODIFY 0x02000000
2294#define PF_HP_LAZYSWAP 0x04000000
2295#define PF_HP_SBP 0x08000000
2296
2297
2298/* Alpha specific definitions. */
2299
2300/* Legal values for e_flags field of Elf64_Ehdr. */
2301
2302#define EF_ALPHA_32BIT 1 /* All addresses must be < 2GB. */
2303#define EF_ALPHA_CANRELAX 2 /* Relocations for relaxing exist. */
2304
2305/* Legal values for sh_type field of Elf64_Shdr. */
2306
2307/* These two are primerily concerned with ECOFF debugging info. */
2308#define SHT_ALPHA_DEBUG 0x70000001
2309#define SHT_ALPHA_REGINFO 0x70000002
2310
2311/* Legal values for sh_flags field of Elf64_Shdr. */
2312
2313#define SHF_ALPHA_GPREL 0x10000000
2314
2315/* Legal values for st_other field of Elf64_Sym. */
2316#define STO_ALPHA_NOPV 0x80 /* No PV required. */
2317#define STO_ALPHA_STD_GPLOAD 0x88 /* PV only used for initial ldgp. */
2318
2319/* Alpha relocs. */
2320
2321#define R_ALPHA_NONE 0 /* No reloc */
2322#define R_ALPHA_REFLONG 1 /* Direct 32 bit */
2323#define R_ALPHA_REFQUAD 2 /* Direct 64 bit */
2324#define R_ALPHA_GPREL32 3 /* GP relative 32 bit */
2325#define R_ALPHA_LITERAL 4 /* GP relative 16 bit w/optimization */
2326#define R_ALPHA_LITUSE 5 /* Optimization hint for LITERAL */
2327#define R_ALPHA_GPDISP 6 /* Add displacement to GP */
2328#define R_ALPHA_BRADDR 7 /* PC+4 relative 23 bit shifted */
2329#define R_ALPHA_HINT 8 /* PC+4 relative 16 bit shifted */
2330#define R_ALPHA_SREL16 9 /* PC relative 16 bit */
2331#define R_ALPHA_SREL32 10 /* PC relative 32 bit */
2332#define R_ALPHA_SREL64 11 /* PC relative 64 bit */
2333#define R_ALPHA_GPRELHIGH 17 /* GP relative 32 bit, high 16 bits */
2334#define R_ALPHA_GPRELLOW 18 /* GP relative 32 bit, low 16 bits */
2335#define R_ALPHA_GPREL16 19 /* GP relative 16 bit */
2336#define R_ALPHA_COPY 24 /* Copy symbol at runtime */
2337#define R_ALPHA_GLOB_DAT 25 /* Create GOT entry */
2338#define R_ALPHA_JMP_SLOT 26 /* Create PLT entry */
2339#define R_ALPHA_RELATIVE 27 /* Adjust by program base */
2340#define R_ALPHA_TLS_GD_HI 28
2341#define R_ALPHA_TLSGD 29
2342#define R_ALPHA_TLS_LDM 30
2343#define R_ALPHA_DTPMOD64 31
2344#define R_ALPHA_GOTDTPREL 32
2345#define R_ALPHA_DTPREL64 33
2346#define R_ALPHA_DTPRELHI 34
2347#define R_ALPHA_DTPRELLO 35
2348#define R_ALPHA_DTPREL16 36
2349#define R_ALPHA_GOTTPREL 37
2350#define R_ALPHA_TPREL64 38
2351#define R_ALPHA_TPRELHI 39
2352#define R_ALPHA_TPRELLO 40
2353#define R_ALPHA_TPREL16 41
2354/* Keep this the last entry. */
2355#define R_ALPHA_NUM 46
2356
2357/* Magic values of the LITUSE relocation addend. */
2358#define LITUSE_ALPHA_ADDR 0
2359#define LITUSE_ALPHA_BASE 1
2360#define LITUSE_ALPHA_BYTOFF 2
2361#define LITUSE_ALPHA_JSR 3
2362#define LITUSE_ALPHA_TLS_GD 4
2363#define LITUSE_ALPHA_TLS_LDM 5
2364
2365/* Legal values for d_tag of Elf64_Dyn. */
2366#define DT_ALPHA_PLTRO (DT_LOPROC + 0)
2367#define DT_ALPHA_NUM 1
2368
2369/* PowerPC specific declarations */
2370
2371/* Values for Elf32/64_Ehdr.e_flags. */
2372#define EF_PPC_EMB 0x80000000 /* PowerPC embedded flag */
2373
2374/* Cygnus local bits below */
2375#define EF_PPC_RELOCATABLE 0x00010000 /* PowerPC -mrelocatable flag*/
2376#define EF_PPC_RELOCATABLE_LIB 0x00008000 /* PowerPC -mrelocatable-lib
2377 flag */
2378
2379/* PowerPC relocations defined by the ABIs */
2380#define R_PPC_NONE 0
2381#define R_PPC_ADDR32 1 /* 32bit absolute address */
2382#define R_PPC_ADDR24 2 /* 26bit address, 2 bits ignored. */
2383#define R_PPC_ADDR16 3 /* 16bit absolute address */
2384#define R_PPC_ADDR16_LO 4 /* lower 16bit of absolute address */
2385#define R_PPC_ADDR16_HI 5 /* high 16bit of absolute address */
2386#define R_PPC_ADDR16_HA 6 /* adjusted high 16bit */
2387#define R_PPC_ADDR14 7 /* 16bit address, 2 bits ignored */
2388#define R_PPC_ADDR14_BRTAKEN 8
2389#define R_PPC_ADDR14_BRNTAKEN 9
2390#define R_PPC_REL24 10 /* PC relative 26 bit */
2391#define R_PPC_REL14 11 /* PC relative 16 bit */
2392#define R_PPC_REL14_BRTAKEN 12
2393#define R_PPC_REL14_BRNTAKEN 13
2394#define R_PPC_GOT16 14
2395#define R_PPC_GOT16_LO 15
2396#define R_PPC_GOT16_HI 16
2397#define R_PPC_GOT16_HA 17
2398#define R_PPC_PLTREL24 18
2399#define R_PPC_COPY 19
2400#define R_PPC_GLOB_DAT 20
2401#define R_PPC_JMP_SLOT 21
2402#define R_PPC_RELATIVE 22
2403#define R_PPC_LOCAL24PC 23
2404#define R_PPC_UADDR32 24
2405#define R_PPC_UADDR16 25
2406#define R_PPC_REL32 26
2407#define R_PPC_PLT32 27
2408#define R_PPC_PLTREL32 28
2409#define R_PPC_PLT16_LO 29
2410#define R_PPC_PLT16_HI 30
2411#define R_PPC_PLT16_HA 31
2412#define R_PPC_SDAREL16 32
2413#define R_PPC_SECTOFF 33
2414#define R_PPC_SECTOFF_LO 34
2415#define R_PPC_SECTOFF_HI 35
2416#define R_PPC_SECTOFF_HA 36
2417
2418/* PowerPC relocations defined for the TLS access ABI. */
2419#define R_PPC_TLS 67 /* none (sym+add)@tls */
2420#define R_PPC_DTPMOD32 68 /* word32 (sym+add)@dtpmod */
2421#define R_PPC_TPREL16 69 /* half16* (sym+add)@tprel */
2422#define R_PPC_TPREL16_LO 70 /* half16 (sym+add)@tprel@l */
2423#define R_PPC_TPREL16_HI 71 /* half16 (sym+add)@tprel@h */
2424#define R_PPC_TPREL16_HA 72 /* half16 (sym+add)@tprel@ha */
2425#define R_PPC_TPREL32 73 /* word32 (sym+add)@tprel */
2426#define R_PPC_DTPREL16 74 /* half16* (sym+add)@dtprel */
2427#define R_PPC_DTPREL16_LO 75 /* half16 (sym+add)@dtprel@l */
2428#define R_PPC_DTPREL16_HI 76 /* half16 (sym+add)@dtprel@h */
2429#define R_PPC_DTPREL16_HA 77 /* half16 (sym+add)@dtprel@ha */
2430#define R_PPC_DTPREL32 78 /* word32 (sym+add)@dtprel */
2431#define R_PPC_GOT_TLSGD16 79 /* half16* (sym+add)@got@tlsgd */
2432#define R_PPC_GOT_TLSGD16_LO 80 /* half16 (sym+add)@got@tlsgd@l */
2433#define R_PPC_GOT_TLSGD16_HI 81 /* half16 (sym+add)@got@tlsgd@h */
2434#define R_PPC_GOT_TLSGD16_HA 82 /* half16 (sym+add)@got@tlsgd@ha */
2435#define R_PPC_GOT_TLSLD16 83 /* half16* (sym+add)@got@tlsld */
2436#define R_PPC_GOT_TLSLD16_LO 84 /* half16 (sym+add)@got@tlsld@l */
2437#define R_PPC_GOT_TLSLD16_HI 85 /* half16 (sym+add)@got@tlsld@h */
2438#define R_PPC_GOT_TLSLD16_HA 86 /* half16 (sym+add)@got@tlsld@ha */
2439#define R_PPC_GOT_TPREL16 87 /* half16* (sym+add)@got@tprel */
2440#define R_PPC_GOT_TPREL16_LO 88 /* half16 (sym+add)@got@tprel@l */
2441#define R_PPC_GOT_TPREL16_HI 89 /* half16 (sym+add)@got@tprel@h */
2442#define R_PPC_GOT_TPREL16_HA 90 /* half16 (sym+add)@got@tprel@ha */
2443#define R_PPC_GOT_DTPREL16 91 /* half16* (sym+add)@got@dtprel */
2444#define R_PPC_GOT_DTPREL16_LO 92 /* half16* (sym+add)@got@dtprel@l */
2445#define R_PPC_GOT_DTPREL16_HI 93 /* half16* (sym+add)@got@dtprel@h */
2446#define R_PPC_GOT_DTPREL16_HA 94 /* half16* (sym+add)@got@dtprel@ha */
2447#define R_PPC_TLSGD 95 /* none (sym+add)@tlsgd */
2448#define R_PPC_TLSLD 96 /* none (sym+add)@tlsld */
2449
2450/* The remaining relocs are from the Embedded ELF ABI, and are not
2451 in the SVR4 ELF ABI. */
2452#define R_PPC_EMB_NADDR32 101
2453#define R_PPC_EMB_NADDR16 102
2454#define R_PPC_EMB_NADDR16_LO 103
2455#define R_PPC_EMB_NADDR16_HI 104
2456#define R_PPC_EMB_NADDR16_HA 105
2457#define R_PPC_EMB_SDAI16 106
2458#define R_PPC_EMB_SDA2I16 107
2459#define R_PPC_EMB_SDA2REL 108
2460#define R_PPC_EMB_SDA21 109 /* 16 bit offset in SDA */
2461#define R_PPC_EMB_MRKREF 110
2462#define R_PPC_EMB_RELSEC16 111
2463#define R_PPC_EMB_RELST_LO 112
2464#define R_PPC_EMB_RELST_HI 113
2465#define R_PPC_EMB_RELST_HA 114
2466#define R_PPC_EMB_BIT_FLD 115
2467#define R_PPC_EMB_RELSDA 116 /* 16 bit relative offset in SDA */
2468
2469/* Diab tool relocations. */
2470#define R_PPC_DIAB_SDA21_LO 180 /* like EMB_SDA21, but lower 16 bit */
2471#define R_PPC_DIAB_SDA21_HI 181 /* like EMB_SDA21, but high 16 bit */
2472#define R_PPC_DIAB_SDA21_HA 182 /* like EMB_SDA21, adjusted high 16 */
2473#define R_PPC_DIAB_RELSDA_LO 183 /* like EMB_RELSDA, but lower 16 bit */
2474#define R_PPC_DIAB_RELSDA_HI 184 /* like EMB_RELSDA, but high 16 bit */
2475#define R_PPC_DIAB_RELSDA_HA 185 /* like EMB_RELSDA, adjusted high 16 */
2476
2477/* GNU extension to support local ifunc. */
2478#define R_PPC_IRELATIVE 248
2479
2480/* GNU relocs used in PIC code sequences. */
2481#define R_PPC_REL16 249 /* half16 (sym+add-.) */
2482#define R_PPC_REL16_LO 250 /* half16 (sym+add-.)@l */
2483#define R_PPC_REL16_HI 251 /* half16 (sym+add-.)@h */
2484#define R_PPC_REL16_HA 252 /* half16 (sym+add-.)@ha */
2485
2486/* This is a phony reloc to handle any old fashioned TOC16 references
2487 that may still be in object files. */
2488#define R_PPC_TOC16 255
2489
2490/* PowerPC specific values for the Dyn d_tag field. */
2491#define DT_PPC_GOT (DT_LOPROC + 0)
2492#define DT_PPC_OPT (DT_LOPROC + 1)
2493#define DT_PPC_NUM 2
2494
2495/* PowerPC specific values for the DT_PPC_OPT Dyn entry. */
2496#define PPC_OPT_TLS 1
2497
2498/* PowerPC64 relocations defined by the ABIs */
2499#define R_PPC64_NONE R_PPC_NONE
2500#define R_PPC64_ADDR32 R_PPC_ADDR32 /* 32bit absolute address */
2501#define R_PPC64_ADDR24 R_PPC_ADDR24 /* 26bit address, word aligned */
2502#define R_PPC64_ADDR16 R_PPC_ADDR16 /* 16bit absolute address */
2503#define R_PPC64_ADDR16_LO R_PPC_ADDR16_LO /* lower 16bits of address */
2504#define R_PPC64_ADDR16_HI R_PPC_ADDR16_HI /* high 16bits of address. */
2505#define R_PPC64_ADDR16_HA R_PPC_ADDR16_HA /* adjusted high 16bits. */
2506#define R_PPC64_ADDR14 R_PPC_ADDR14 /* 16bit address, word aligned */
2507#define R_PPC64_ADDR14_BRTAKEN R_PPC_ADDR14_BRTAKEN
2508#define R_PPC64_ADDR14_BRNTAKEN R_PPC_ADDR14_BRNTAKEN
2509#define R_PPC64_REL24 R_PPC_REL24 /* PC-rel. 26 bit, word aligned */
2510#define R_PPC64_REL14 R_PPC_REL14 /* PC relative 16 bit */
2511#define R_PPC64_REL14_BRTAKEN R_PPC_REL14_BRTAKEN
2512#define R_PPC64_REL14_BRNTAKEN R_PPC_REL14_BRNTAKEN
2513#define R_PPC64_GOT16 R_PPC_GOT16
2514#define R_PPC64_GOT16_LO R_PPC_GOT16_LO
2515#define R_PPC64_GOT16_HI R_PPC_GOT16_HI
2516#define R_PPC64_GOT16_HA R_PPC_GOT16_HA
2517
2518#define R_PPC64_COPY R_PPC_COPY
2519#define R_PPC64_GLOB_DAT R_PPC_GLOB_DAT
2520#define R_PPC64_JMP_SLOT R_PPC_JMP_SLOT
2521#define R_PPC64_RELATIVE R_PPC_RELATIVE
2522
2523#define R_PPC64_UADDR32 R_PPC_UADDR32
2524#define R_PPC64_UADDR16 R_PPC_UADDR16
2525#define R_PPC64_REL32 R_PPC_REL32
2526#define R_PPC64_PLT32 R_PPC_PLT32
2527#define R_PPC64_PLTREL32 R_PPC_PLTREL32
2528#define R_PPC64_PLT16_LO R_PPC_PLT16_LO
2529#define R_PPC64_PLT16_HI R_PPC_PLT16_HI
2530#define R_PPC64_PLT16_HA R_PPC_PLT16_HA
2531
2532#define R_PPC64_SECTOFF R_PPC_SECTOFF
2533#define R_PPC64_SECTOFF_LO R_PPC_SECTOFF_LO
2534#define R_PPC64_SECTOFF_HI R_PPC_SECTOFF_HI
2535#define R_PPC64_SECTOFF_HA R_PPC_SECTOFF_HA
2536#define R_PPC64_ADDR30 37 /* word30 (S + A - P) >> 2 */
2537#define R_PPC64_ADDR64 38 /* doubleword64 S + A */
2538#define R_PPC64_ADDR16_HIGHER 39 /* half16 #higher(S + A) */
2539#define R_PPC64_ADDR16_HIGHERA 40 /* half16 #highera(S + A) */
2540#define R_PPC64_ADDR16_HIGHEST 41 /* half16 #highest(S + A) */
2541#define R_PPC64_ADDR16_HIGHESTA 42 /* half16 #highesta(S + A) */
2542#define R_PPC64_UADDR64 43 /* doubleword64 S + A */
2543#define R_PPC64_REL64 44 /* doubleword64 S + A - P */
2544#define R_PPC64_PLT64 45 /* doubleword64 L + A */
2545#define R_PPC64_PLTREL64 46 /* doubleword64 L + A - P */
2546#define R_PPC64_TOC16 47 /* half16* S + A - .TOC */
2547#define R_PPC64_TOC16_LO 48 /* half16 #lo(S + A - .TOC.) */
2548#define R_PPC64_TOC16_HI 49 /* half16 #hi(S + A - .TOC.) */
2549#define R_PPC64_TOC16_HA 50 /* half16 #ha(S + A - .TOC.) */
2550#define R_PPC64_TOC 51 /* doubleword64 .TOC */
2551#define R_PPC64_PLTGOT16 52 /* half16* M + A */
2552#define R_PPC64_PLTGOT16_LO 53 /* half16 #lo(M + A) */
2553#define R_PPC64_PLTGOT16_HI 54 /* half16 #hi(M + A) */
2554#define R_PPC64_PLTGOT16_HA 55 /* half16 #ha(M + A) */
2555
2556#define R_PPC64_ADDR16_DS 56 /* half16ds* (S + A) >> 2 */
2557#define R_PPC64_ADDR16_LO_DS 57 /* half16ds #lo(S + A) >> 2 */
2558#define R_PPC64_GOT16_DS 58 /* half16ds* (G + A) >> 2 */
2559#define R_PPC64_GOT16_LO_DS 59 /* half16ds #lo(G + A) >> 2 */
2560#define R_PPC64_PLT16_LO_DS 60 /* half16ds #lo(L + A) >> 2 */
2561#define R_PPC64_SECTOFF_DS 61 /* half16ds* (R + A) >> 2 */
2562#define R_PPC64_SECTOFF_LO_DS 62 /* half16ds #lo(R + A) >> 2 */
2563#define R_PPC64_TOC16_DS 63 /* half16ds* (S + A - .TOC.) >> 2 */
2564#define R_PPC64_TOC16_LO_DS 64 /* half16ds #lo(S + A - .TOC.) >> 2 */
2565#define R_PPC64_PLTGOT16_DS 65 /* half16ds* (M + A) >> 2 */
2566#define R_PPC64_PLTGOT16_LO_DS 66 /* half16ds #lo(M + A) >> 2 */
2567
2568/* PowerPC64 relocations defined for the TLS access ABI. */
2569#define R_PPC64_TLS 67 /* none (sym+add)@tls */
2570#define R_PPC64_DTPMOD64 68 /* doubleword64 (sym+add)@dtpmod */
2571#define R_PPC64_TPREL16 69 /* half16* (sym+add)@tprel */
2572#define R_PPC64_TPREL16_LO 70 /* half16 (sym+add)@tprel@l */
2573#define R_PPC64_TPREL16_HI 71 /* half16 (sym+add)@tprel@h */
2574#define R_PPC64_TPREL16_HA 72 /* half16 (sym+add)@tprel@ha */
2575#define R_PPC64_TPREL64 73 /* doubleword64 (sym+add)@tprel */
2576#define R_PPC64_DTPREL16 74 /* half16* (sym+add)@dtprel */
2577#define R_PPC64_DTPREL16_LO 75 /* half16 (sym+add)@dtprel@l */
2578#define R_PPC64_DTPREL16_HI 76 /* half16 (sym+add)@dtprel@h */
2579#define R_PPC64_DTPREL16_HA 77 /* half16 (sym+add)@dtprel@ha */
2580#define R_PPC64_DTPREL64 78 /* doubleword64 (sym+add)@dtprel */
2581#define R_PPC64_GOT_TLSGD16 79 /* half16* (sym+add)@got@tlsgd */
2582#define R_PPC64_GOT_TLSGD16_LO 80 /* half16 (sym+add)@got@tlsgd@l */
2583#define R_PPC64_GOT_TLSGD16_HI 81 /* half16 (sym+add)@got@tlsgd@h */
2584#define R_PPC64_GOT_TLSGD16_HA 82 /* half16 (sym+add)@got@tlsgd@ha */
2585#define R_PPC64_GOT_TLSLD16 83 /* half16* (sym+add)@got@tlsld */
2586#define R_PPC64_GOT_TLSLD16_LO 84 /* half16 (sym+add)@got@tlsld@l */
2587#define R_PPC64_GOT_TLSLD16_HI 85 /* half16 (sym+add)@got@tlsld@h */
2588#define R_PPC64_GOT_TLSLD16_HA 86 /* half16 (sym+add)@got@tlsld@ha */
2589#define R_PPC64_GOT_TPREL16_DS 87 /* half16ds* (sym+add)@got@tprel */
2590#define R_PPC64_GOT_TPREL16_LO_DS 88 /* half16ds (sym+add)@got@tprel@l */
2591#define R_PPC64_GOT_TPREL16_HI 89 /* half16 (sym+add)@got@tprel@h */
2592#define R_PPC64_GOT_TPREL16_HA 90 /* half16 (sym+add)@got@tprel@ha */
2593#define R_PPC64_GOT_DTPREL16_DS 91 /* half16ds* (sym+add)@got@dtprel */
2594#define R_PPC64_GOT_DTPREL16_LO_DS 92 /* half16ds (sym+add)@got@dtprel@l */
2595#define R_PPC64_GOT_DTPREL16_HI 93 /* half16 (sym+add)@got@dtprel@h */
2596#define R_PPC64_GOT_DTPREL16_HA 94 /* half16 (sym+add)@got@dtprel@ha */
2597#define R_PPC64_TPREL16_DS 95 /* half16ds* (sym+add)@tprel */
2598#define R_PPC64_TPREL16_LO_DS 96 /* half16ds (sym+add)@tprel@l */
2599#define R_PPC64_TPREL16_HIGHER 97 /* half16 (sym+add)@tprel@higher */
2600#define R_PPC64_TPREL16_HIGHERA 98 /* half16 (sym+add)@tprel@highera */
2601#define R_PPC64_TPREL16_HIGHEST 99 /* half16 (sym+add)@tprel@highest */
2602#define R_PPC64_TPREL16_HIGHESTA 100 /* half16 (sym+add)@tprel@highesta */
2603#define R_PPC64_DTPREL16_DS 101 /* half16ds* (sym+add)@dtprel */
2604#define R_PPC64_DTPREL16_LO_DS 102 /* half16ds (sym+add)@dtprel@l */
2605#define R_PPC64_DTPREL16_HIGHER 103 /* half16 (sym+add)@dtprel@higher */
2606#define R_PPC64_DTPREL16_HIGHERA 104 /* half16 (sym+add)@dtprel@highera */
2607#define R_PPC64_DTPREL16_HIGHEST 105 /* half16 (sym+add)@dtprel@highest */
2608#define R_PPC64_DTPREL16_HIGHESTA 106 /* half16 (sym+add)@dtprel@highesta */
2609#define R_PPC64_TLSGD 107 /* none (sym+add)@tlsgd */
2610#define R_PPC64_TLSLD 108 /* none (sym+add)@tlsld */
2611#define R_PPC64_TOCSAVE 109 /* none */
2612
2613/* Added when HA and HI relocs were changed to report overflows. */
2614#define R_PPC64_ADDR16_HIGH 110
2615#define R_PPC64_ADDR16_HIGHA 111
2616#define R_PPC64_TPREL16_HIGH 112
2617#define R_PPC64_TPREL16_HIGHA 113
2618#define R_PPC64_DTPREL16_HIGH 114
2619#define R_PPC64_DTPREL16_HIGHA 115
2620
2621/* GNU extension to support local ifunc. */
2622#define R_PPC64_JMP_IREL 247
2623#define R_PPC64_IRELATIVE 248
2624#define R_PPC64_REL16 249 /* half16 (sym+add-.) */
2625#define R_PPC64_REL16_LO 250 /* half16 (sym+add-.)@l */
2626#define R_PPC64_REL16_HI 251 /* half16 (sym+add-.)@h */
2627#define R_PPC64_REL16_HA 252 /* half16 (sym+add-.)@ha */
2628
2629/* e_flags bits specifying ABI.
2630 1 for original function descriptor using ABI,
2631 2 for revised ABI without function descriptors,
2632 0 for unspecified or not using any features affected by the differences. */
2633#define EF_PPC64_ABI 3
2634
2635/* PowerPC64 specific values for the Dyn d_tag field. */
2636#define DT_PPC64_GLINK (DT_LOPROC + 0)
2637#define DT_PPC64_OPD (DT_LOPROC + 1)
2638#define DT_PPC64_OPDSZ (DT_LOPROC + 2)
2639#define DT_PPC64_OPT (DT_LOPROC + 3)
2640#define DT_PPC64_NUM 4
2641
2642/* PowerPC64 specific bits in the DT_PPC64_OPT Dyn entry. */
2643#define PPC64_OPT_TLS 1
2644#define PPC64_OPT_MULTI_TOC 2
2645#define PPC64_OPT_LOCALENTRY 4
2646
2647/* PowerPC64 specific values for the Elf64_Sym st_other field. */
2648#define STO_PPC64_LOCAL_BIT 5
2649#define STO_PPC64_LOCAL_MASK (7 << STO_PPC64_LOCAL_BIT)
2650#define PPC64_LOCAL_ENTRY_OFFSET(other) \
2651 (((1 << (((other) & STO_PPC64_LOCAL_MASK) >> STO_PPC64_LOCAL_BIT)) >> 2) << 2)
2652
2653
2654/* ARM specific declarations */
2655
2656/* Processor specific flags for the ELF header e_flags field. */
2657#define EF_ARM_RELEXEC 0x01
2658#define EF_ARM_HASENTRY 0x02
2659#define EF_ARM_INTERWORK 0x04
2660#define EF_ARM_APCS_26 0x08
2661#define EF_ARM_APCS_FLOAT 0x10
2662#define EF_ARM_PIC 0x20
2663#define EF_ARM_ALIGN8 0x40 /* 8-bit structure alignment is in use */
2664#define EF_ARM_NEW_ABI 0x80
2665#define EF_ARM_OLD_ABI 0x100
2666#define EF_ARM_SOFT_FLOAT 0x200
2667#define EF_ARM_VFP_FLOAT 0x400
2668#define EF_ARM_MAVERICK_FLOAT 0x800
2669
2670#define EF_ARM_ABI_FLOAT_SOFT 0x200 /* NB conflicts with EF_ARM_SOFT_FLOAT */
2671#define EF_ARM_ABI_FLOAT_HARD 0x400 /* NB conflicts with EF_ARM_VFP_FLOAT */
2672
2673
2674/* Other constants defined in the ARM ELF spec. version B-01. */
2675/* NB. These conflict with values defined above. */
2676#define EF_ARM_SYMSARESORTED 0x04
2677#define EF_ARM_DYNSYMSUSESEGIDX 0x08
2678#define EF_ARM_MAPSYMSFIRST 0x10
2679#define EF_ARM_EABIMASK 0XFF000000
2680
2681/* Constants defined in AAELF. */
2682#define EF_ARM_BE8 0x00800000
2683#define EF_ARM_LE8 0x00400000
2684
2685#define EF_ARM_EABI_VERSION(flags) ((flags) & EF_ARM_EABIMASK)
2686#define EF_ARM_EABI_UNKNOWN 0x00000000
2687#define EF_ARM_EABI_VER1 0x01000000
2688#define EF_ARM_EABI_VER2 0x02000000
2689#define EF_ARM_EABI_VER3 0x03000000
2690#define EF_ARM_EABI_VER4 0x04000000
2691#define EF_ARM_EABI_VER5 0x05000000
2692
2693/* Additional symbol types for Thumb. */
2694#define STT_ARM_TFUNC STT_LOPROC /* A Thumb function. */
2695#define STT_ARM_16BIT STT_HIPROC /* A Thumb label. */
2696
2697/* ARM-specific values for sh_flags */
2698#define SHF_ARM_ENTRYSECT 0x10000000 /* Section contains an entry point */
2699#define SHF_ARM_COMDEF 0x80000000 /* Section may be multiply defined
2700 in the input to a link step. */
2701
2702/* ARM-specific program header flags */
2703#define PF_ARM_SB 0x10000000 /* Segment contains the location
2704 addressed by the static base. */
2705#define PF_ARM_PI 0x20000000 /* Position-independent segment. */
2706#define PF_ARM_ABS 0x40000000 /* Absolute segment. */
2707
2708/* Processor specific values for the Phdr p_type field. */
2709#define PT_ARM_EXIDX (PT_LOPROC + 1) /* ARM unwind segment. */
2710
2711/* Processor specific values for the Shdr sh_type field. */
2712#define SHT_ARM_EXIDX (SHT_LOPROC + 1) /* ARM unwind section. */
2713#define SHT_ARM_PREEMPTMAP (SHT_LOPROC + 2) /* Preemption details. */
2714#define SHT_ARM_ATTRIBUTES (SHT_LOPROC + 3) /* ARM attributes section. */
2715
2716
2717/* AArch64 relocs. */
2718
2719#define R_AARCH64_NONE 0 /* No relocation. */
2720
2721/* ILP32 AArch64 relocs. */
2722#define R_AARCH64_P32_ABS32 1 /* Direct 32 bit. */
2723#define R_AARCH64_P32_COPY 180 /* Copy symbol at runtime. */
2724#define R_AARCH64_P32_GLOB_DAT 181 /* Create GOT entry. */
2725#define R_AARCH64_P32_JUMP_SLOT 182 /* Create PLT entry. */
2726#define R_AARCH64_P32_RELATIVE 183 /* Adjust by program base. */
2727#define R_AARCH64_P32_TLS_DTPMOD 184 /* Module number, 32 bit. */
2728#define R_AARCH64_P32_TLS_DTPREL 185 /* Module-relative offset, 32 bit. */
2729#define R_AARCH64_P32_TLS_TPREL 186 /* TP-relative offset, 32 bit. */
2730#define R_AARCH64_P32_TLSDESC 187 /* TLS Descriptor. */
2731#define R_AARCH64_P32_IRELATIVE 188 /* STT_GNU_IFUNC relocation. */
2732
2733/* LP64 AArch64 relocs. */
2734#define R_AARCH64_ABS64 257 /* Direct 64 bit. */
2735#define R_AARCH64_ABS32 258 /* Direct 32 bit. */
2736#define R_AARCH64_ABS16 259 /* Direct 16-bit. */
2737#define R_AARCH64_PREL64 260 /* PC-relative 64-bit. */
2738#define R_AARCH64_PREL32 261 /* PC-relative 32-bit. */
2739#define R_AARCH64_PREL16 262 /* PC-relative 16-bit. */
2740#define R_AARCH64_MOVW_UABS_G0 263 /* Dir. MOVZ imm. from bits 15:0. */
2741#define R_AARCH64_MOVW_UABS_G0_NC 264 /* Likewise for MOVK; no check. */
2742#define R_AARCH64_MOVW_UABS_G1 265 /* Dir. MOVZ imm. from bits 31:16. */
2743#define R_AARCH64_MOVW_UABS_G1_NC 266 /* Likewise for MOVK; no check. */
2744#define R_AARCH64_MOVW_UABS_G2 267 /* Dir. MOVZ imm. from bits 47:32. */
2745#define R_AARCH64_MOVW_UABS_G2_NC 268 /* Likewise for MOVK; no check. */
2746#define R_AARCH64_MOVW_UABS_G3 269 /* Dir. MOV{K,Z} imm. from 63:48. */
2747#define R_AARCH64_MOVW_SABS_G0 270 /* Dir. MOV{N,Z} imm. from 15:0. */
2748#define R_AARCH64_MOVW_SABS_G1 271 /* Dir. MOV{N,Z} imm. from 31:16. */
2749#define R_AARCH64_MOVW_SABS_G2 272 /* Dir. MOV{N,Z} imm. from 47:32. */
2750#define R_AARCH64_LD_PREL_LO19 273 /* PC-rel. LD imm. from bits 20:2. */
2751#define R_AARCH64_ADR_PREL_LO21 274 /* PC-rel. ADR imm. from bits 20:0. */
2752#define R_AARCH64_ADR_PREL_PG_HI21 275 /* Page-rel. ADRP imm. from 32:12. */
2753#define R_AARCH64_ADR_PREL_PG_HI21_NC 276 /* Likewise; no overflow check. */
2754#define R_AARCH64_ADD_ABS_LO12_NC 277 /* Dir. ADD imm. from bits 11:0. */
2755#define R_AARCH64_LDST8_ABS_LO12_NC 278 /* Likewise for LD/ST; no check. */
2756#define R_AARCH64_TSTBR14 279 /* PC-rel. TBZ/TBNZ imm. from 15:2. */
2757#define R_AARCH64_CONDBR19 280 /* PC-rel. cond. br. imm. from 20:2. */
2758#define R_AARCH64_JUMP26 282 /* PC-rel. B imm. from bits 27:2. */
2759#define R_AARCH64_CALL26 283 /* Likewise for CALL. */
2760#define R_AARCH64_LDST16_ABS_LO12_NC 284 /* Dir. ADD imm. from bits 11:1. */
2761#define R_AARCH64_LDST32_ABS_LO12_NC 285 /* Likewise for bits 11:2. */
2762#define R_AARCH64_LDST64_ABS_LO12_NC 286 /* Likewise for bits 11:3. */
2763#define R_AARCH64_MOVW_PREL_G0 287 /* PC-rel. MOV{N,Z} imm. from 15:0. */
2764#define R_AARCH64_MOVW_PREL_G0_NC 288 /* Likewise for MOVK; no check. */
2765#define R_AARCH64_MOVW_PREL_G1 289 /* PC-rel. MOV{N,Z} imm. from 31:16. */
2766#define R_AARCH64_MOVW_PREL_G1_NC 290 /* Likewise for MOVK; no check. */
2767#define R_AARCH64_MOVW_PREL_G2 291 /* PC-rel. MOV{N,Z} imm. from 47:32. */
2768#define R_AARCH64_MOVW_PREL_G2_NC 292 /* Likewise for MOVK; no check. */
2769#define R_AARCH64_MOVW_PREL_G3 293 /* PC-rel. MOV{N,Z} imm. from 63:48. */
2770#define R_AARCH64_LDST128_ABS_LO12_NC 299 /* Dir. ADD imm. from bits 11:4. */
2771#define R_AARCH64_MOVW_GOTOFF_G0 300 /* GOT-rel. off. MOV{N,Z} imm. 15:0. */
2772#define R_AARCH64_MOVW_GOTOFF_G0_NC 301 /* Likewise for MOVK; no check. */
2773#define R_AARCH64_MOVW_GOTOFF_G1 302 /* GOT-rel. o. MOV{N,Z} imm. 31:16. */
2774#define R_AARCH64_MOVW_GOTOFF_G1_NC 303 /* Likewise for MOVK; no check. */
2775#define R_AARCH64_MOVW_GOTOFF_G2 304 /* GOT-rel. o. MOV{N,Z} imm. 47:32. */
2776#define R_AARCH64_MOVW_GOTOFF_G2_NC 305 /* Likewise for MOVK; no check. */
2777#define R_AARCH64_MOVW_GOTOFF_G3 306 /* GOT-rel. o. MOV{N,Z} imm. 63:48. */
2778#define R_AARCH64_GOTREL64 307 /* GOT-relative 64-bit. */
2779#define R_AARCH64_GOTREL32 308 /* GOT-relative 32-bit. */
2780#define R_AARCH64_GOT_LD_PREL19 309 /* PC-rel. GOT off. load imm. 20:2. */
2781#define R_AARCH64_LD64_GOTOFF_LO15 310 /* GOT-rel. off. LD/ST imm. 14:3. */
2782#define R_AARCH64_ADR_GOT_PAGE 311 /* P-page-rel. GOT off. ADRP 32:12. */
2783#define R_AARCH64_LD64_GOT_LO12_NC 312 /* Dir. GOT off. LD/ST imm. 11:3. */
2784#define R_AARCH64_LD64_GOTPAGE_LO15 313 /* GOT-page-rel. GOT off. LD/ST 14:3 */
2785#define R_AARCH64_TLSGD_ADR_PREL21 512 /* PC-relative ADR imm. 20:0. */
2786#define R_AARCH64_TLSGD_ADR_PAGE21 513 /* page-rel. ADRP imm. 32:12. */
2787#define R_AARCH64_TLSGD_ADD_LO12_NC 514 /* direct ADD imm. from 11:0. */
2788#define R_AARCH64_TLSGD_MOVW_G1 515 /* GOT-rel. MOV{N,Z} 31:16. */
2789#define R_AARCH64_TLSGD_MOVW_G0_NC 516 /* GOT-rel. MOVK imm. 15:0. */
2790#define R_AARCH64_TLSLD_ADR_PREL21 517 /* Like 512; local dynamic model. */
2791#define R_AARCH64_TLSLD_ADR_PAGE21 518 /* Like 513; local dynamic model. */
2792#define R_AARCH64_TLSLD_ADD_LO12_NC 519 /* Like 514; local dynamic model. */
2793#define R_AARCH64_TLSLD_MOVW_G1 520 /* Like 515; local dynamic model. */
2794#define R_AARCH64_TLSLD_MOVW_G0_NC 521 /* Like 516; local dynamic model. */
2795#define R_AARCH64_TLSLD_LD_PREL19 522 /* TLS PC-rel. load imm. 20:2. */
2796#define R_AARCH64_TLSLD_MOVW_DTPREL_G2 523 /* TLS DTP-rel. MOV{N,Z} 47:32. */
2797#define R_AARCH64_TLSLD_MOVW_DTPREL_G1 524 /* TLS DTP-rel. MOV{N,Z} 31:16. */
2798#define R_AARCH64_TLSLD_MOVW_DTPREL_G1_NC 525 /* Likewise; MOVK; no check. */
2799#define R_AARCH64_TLSLD_MOVW_DTPREL_G0 526 /* TLS DTP-rel. MOV{N,Z} 15:0. */
2800#define R_AARCH64_TLSLD_MOVW_DTPREL_G0_NC 527 /* Likewise; MOVK; no check. */
2801#define R_AARCH64_TLSLD_ADD_DTPREL_HI12 528 /* DTP-rel. ADD imm. from 23:12. */
2802#define R_AARCH64_TLSLD_ADD_DTPREL_LO12 529 /* DTP-rel. ADD imm. from 11:0. */
2803#define R_AARCH64_TLSLD_ADD_DTPREL_LO12_NC 530 /* Likewise; no ovfl. check. */
2804#define R_AARCH64_TLSLD_LDST8_DTPREL_LO12 531 /* DTP-rel. LD/ST imm. 11:0. */
2805#define R_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC 532 /* Likewise; no check. */
2806#define R_AARCH64_TLSLD_LDST16_DTPREL_LO12 533 /* DTP-rel. LD/ST imm. 11:1. */
2807#define R_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC 534 /* Likewise; no check. */
2808#define R_AARCH64_TLSLD_LDST32_DTPREL_LO12 535 /* DTP-rel. LD/ST imm. 11:2. */
2809#define R_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC 536 /* Likewise; no check. */
2810#define R_AARCH64_TLSLD_LDST64_DTPREL_LO12 537 /* DTP-rel. LD/ST imm. 11:3. */
2811#define R_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC 538 /* Likewise; no check. */
2812#define R_AARCH64_TLSIE_MOVW_GOTTPREL_G1 539 /* GOT-rel. MOV{N,Z} 31:16. */
2813#define R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC 540 /* GOT-rel. MOVK 15:0. */
2814#define R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21 541 /* Page-rel. ADRP 32:12. */
2815#define R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC 542 /* Direct LD off. 11:3. */
2816#define R_AARCH64_TLSIE_LD_GOTTPREL_PREL19 543 /* PC-rel. load imm. 20:2. */
2817#define R_AARCH64_TLSLE_MOVW_TPREL_G2 544 /* TLS TP-rel. MOV{N,Z} 47:32. */
2818#define R_AARCH64_TLSLE_MOVW_TPREL_G1 545 /* TLS TP-rel. MOV{N,Z} 31:16. */
2819#define R_AARCH64_TLSLE_MOVW_TPREL_G1_NC 546 /* Likewise; MOVK; no check. */
2820#define R_AARCH64_TLSLE_MOVW_TPREL_G0 547 /* TLS TP-rel. MOV{N,Z} 15:0. */
2821#define R_AARCH64_TLSLE_MOVW_TPREL_G0_NC 548 /* Likewise; MOVK; no check. */
2822#define R_AARCH64_TLSLE_ADD_TPREL_HI12 549 /* TP-rel. ADD imm. 23:12. */
2823#define R_AARCH64_TLSLE_ADD_TPREL_LO12 550 /* TP-rel. ADD imm. 11:0. */
2824#define R_AARCH64_TLSLE_ADD_TPREL_LO12_NC 551 /* Likewise; no ovfl. check. */
2825#define R_AARCH64_TLSLE_LDST8_TPREL_LO12 552 /* TP-rel. LD/ST off. 11:0. */
2826#define R_AARCH64_TLSLE_LDST8_TPREL_LO12_NC 553 /* Likewise; no ovfl. check. */
2827#define R_AARCH64_TLSLE_LDST16_TPREL_LO12 554 /* TP-rel. LD/ST off. 11:1. */
2828#define R_AARCH64_TLSLE_LDST16_TPREL_LO12_NC 555 /* Likewise; no check. */
2829#define R_AARCH64_TLSLE_LDST32_TPREL_LO12 556 /* TP-rel. LD/ST off. 11:2. */
2830#define R_AARCH64_TLSLE_LDST32_TPREL_LO12_NC 557 /* Likewise; no check. */
2831#define R_AARCH64_TLSLE_LDST64_TPREL_LO12 558 /* TP-rel. LD/ST off. 11:3. */
2832#define R_AARCH64_TLSLE_LDST64_TPREL_LO12_NC 559 /* Likewise; no check. */
2833#define R_AARCH64_TLSDESC_LD_PREL19 560 /* PC-rel. load immediate 20:2. */
2834#define R_AARCH64_TLSDESC_ADR_PREL21 561 /* PC-rel. ADR immediate 20:0. */
2835#define R_AARCH64_TLSDESC_ADR_PAGE21 562 /* Page-rel. ADRP imm. 32:12. */
2836#define R_AARCH64_TLSDESC_LD64_LO12 563 /* Direct LD off. from 11:3. */
2837#define R_AARCH64_TLSDESC_ADD_LO12 564 /* Direct ADD imm. from 11:0. */
2838#define R_AARCH64_TLSDESC_OFF_G1 565 /* GOT-rel. MOV{N,Z} imm. 31:16. */
2839#define R_AARCH64_TLSDESC_OFF_G0_NC 566 /* GOT-rel. MOVK imm. 15:0; no ck. */
2840#define R_AARCH64_TLSDESC_LDR 567 /* Relax LDR. */
2841#define R_AARCH64_TLSDESC_ADD 568 /* Relax ADD. */
2842#define R_AARCH64_TLSDESC_CALL 569 /* Relax BLR. */
2843#define R_AARCH64_TLSLE_LDST128_TPREL_LO12 570 /* TP-rel. LD/ST off. 11:4. */
2844#define R_AARCH64_TLSLE_LDST128_TPREL_LO12_NC 571 /* Likewise; no check. */
2845#define R_AARCH64_TLSLD_LDST128_DTPREL_LO12 572 /* DTP-rel. LD/ST imm. 11:4. */
2846#define R_AARCH64_TLSLD_LDST128_DTPREL_LO12_NC 573 /* Likewise; no check. */
2847#define R_AARCH64_COPY 1024 /* Copy symbol at runtime. */
2848#define R_AARCH64_GLOB_DAT 1025 /* Create GOT entry. */
2849#define R_AARCH64_JUMP_SLOT 1026 /* Create PLT entry. */
2850#define R_AARCH64_RELATIVE 1027 /* Adjust by program base. */
2851#define R_AARCH64_TLS_DTPMOD 1028 /* Module number, 64 bit. */
2852#define R_AARCH64_TLS_DTPREL 1029 /* Module-relative offset, 64 bit. */
2853#define R_AARCH64_TLS_TPREL 1030 /* TP-relative offset, 64 bit. */
2854#define R_AARCH64_TLSDESC 1031 /* TLS Descriptor. */
2855#define R_AARCH64_IRELATIVE 1032 /* STT_GNU_IFUNC relocation. */
2856
2857/* ARM relocs. */
2858
2859#define R_ARM_NONE 0 /* No reloc */
2860#define R_ARM_PC24 1 /* Deprecated PC relative 26
2861 bit branch. */
2862#define R_ARM_ABS32 2 /* Direct 32 bit */
2863#define R_ARM_REL32 3 /* PC relative 32 bit */
2864#define R_ARM_PC13 4
2865#define R_ARM_ABS16 5 /* Direct 16 bit */
2866#define R_ARM_ABS12 6 /* Direct 12 bit */
2867#define R_ARM_THM_ABS5 7 /* Direct & 0x7C (LDR, STR). */
2868#define R_ARM_ABS8 8 /* Direct 8 bit */
2869#define R_ARM_SBREL32 9
2870#define R_ARM_THM_PC22 10 /* PC relative 24 bit (Thumb32 BL). */
2871#define R_ARM_THM_PC8 11 /* PC relative & 0x3FC
2872 (Thumb16 LDR, ADD, ADR). */
2873#define R_ARM_AMP_VCALL9 12
2874#define R_ARM_SWI24 13 /* Obsolete static relocation. */
2875#define R_ARM_TLS_DESC 13 /* Dynamic relocation. */
2876#define R_ARM_THM_SWI8 14 /* Reserved. */
2877#define R_ARM_XPC25 15 /* Reserved. */
2878#define R_ARM_THM_XPC22 16 /* Reserved. */
2879#define R_ARM_TLS_DTPMOD32 17 /* ID of module containing symbol */
2880#define R_ARM_TLS_DTPOFF32 18 /* Offset in TLS block */
2881#define R_ARM_TLS_TPOFF32 19 /* Offset in static TLS block */
2882#define R_ARM_COPY 20 /* Copy symbol at runtime */
2883#define R_ARM_GLOB_DAT 21 /* Create GOT entry */
2884#define R_ARM_JUMP_SLOT 22 /* Create PLT entry */
2885#define R_ARM_RELATIVE 23 /* Adjust by program base */
2886#define R_ARM_GOTOFF 24 /* 32 bit offset to GOT */
2887#define R_ARM_GOTPC 25 /* 32 bit PC relative offset to GOT */
2888#define R_ARM_GOT32 26 /* 32 bit GOT entry */
2889#define R_ARM_PLT32 27 /* Deprecated, 32 bit PLT address. */
2890#define R_ARM_CALL 28 /* PC relative 24 bit (BL, BLX). */
2891#define R_ARM_JUMP24 29 /* PC relative 24 bit
2892 (B, BL<cond>). */
2893#define R_ARM_THM_JUMP24 30 /* PC relative 24 bit (Thumb32 B.W). */
2894#define R_ARM_BASE_ABS 31 /* Adjust by program base. */
2895#define R_ARM_ALU_PCREL_7_0 32 /* Obsolete. */
2896#define R_ARM_ALU_PCREL_15_8 33 /* Obsolete. */
2897#define R_ARM_ALU_PCREL_23_15 34 /* Obsolete. */
2898#define R_ARM_LDR_SBREL_11_0 35 /* Deprecated, prog. base relative. */
2899#define R_ARM_ALU_SBREL_19_12 36 /* Deprecated, prog. base relative. */
2900#define R_ARM_ALU_SBREL_27_20 37 /* Deprecated, prog. base relative. */
2901#define R_ARM_TARGET1 38
2902#define R_ARM_SBREL31 39 /* Program base relative. */
2903#define R_ARM_V4BX 40
2904#define R_ARM_TARGET2 41
2905#define R_ARM_PREL31 42 /* 32 bit PC relative. */
2906#define R_ARM_MOVW_ABS_NC 43 /* Direct 16-bit (MOVW). */
2907#define R_ARM_MOVT_ABS 44 /* Direct high 16-bit (MOVT). */
2908#define R_ARM_MOVW_PREL_NC 45 /* PC relative 16-bit (MOVW). */
2909#define R_ARM_MOVT_PREL 46 /* PC relative (MOVT). */
2910#define R_ARM_THM_MOVW_ABS_NC 47 /* Direct 16 bit (Thumb32 MOVW). */
2911#define R_ARM_THM_MOVT_ABS 48 /* Direct high 16 bit
2912 (Thumb32 MOVT). */
2913#define R_ARM_THM_MOVW_PREL_NC 49 /* PC relative 16 bit
2914 (Thumb32 MOVW). */
2915#define R_ARM_THM_MOVT_PREL 50 /* PC relative high 16 bit
2916 (Thumb32 MOVT). */
2917#define R_ARM_THM_JUMP19 51 /* PC relative 20 bit
2918 (Thumb32 B<cond>.W). */
2919#define R_ARM_THM_JUMP6 52 /* PC relative X & 0x7E
2920 (Thumb16 CBZ, CBNZ). */
2921#define R_ARM_THM_ALU_PREL_11_0 53 /* PC relative 12 bit
2922 (Thumb32 ADR.W). */
2923#define R_ARM_THM_PC12 54 /* PC relative 12 bit
2924 (Thumb32 LDR{D,SB,H,SH}). */
2925#define R_ARM_ABS32_NOI 55 /* Direct 32-bit. */
2926#define R_ARM_REL32_NOI 56 /* PC relative 32-bit. */
2927#define R_ARM_ALU_PC_G0_NC 57 /* PC relative (ADD, SUB). */
2928#define R_ARM_ALU_PC_G0 58 /* PC relative (ADD, SUB). */
2929#define R_ARM_ALU_PC_G1_NC 59 /* PC relative (ADD, SUB). */
2930#define R_ARM_ALU_PC_G1 60 /* PC relative (ADD, SUB). */
2931#define R_ARM_ALU_PC_G2 61 /* PC relative (ADD, SUB). */
2932#define R_ARM_LDR_PC_G1 62 /* PC relative (LDR,STR,LDRB,STRB). */
2933#define R_ARM_LDR_PC_G2 63 /* PC relative (LDR,STR,LDRB,STRB). */
2934#define R_ARM_LDRS_PC_G0 64 /* PC relative (STR{D,H},
2935 LDR{D,SB,H,SH}). */
2936#define R_ARM_LDRS_PC_G1 65 /* PC relative (STR{D,H},
2937 LDR{D,SB,H,SH}). */
2938#define R_ARM_LDRS_PC_G2 66 /* PC relative (STR{D,H},
2939 LDR{D,SB,H,SH}). */
2940#define R_ARM_LDC_PC_G0 67 /* PC relative (LDC, STC). */
2941#define R_ARM_LDC_PC_G1 68 /* PC relative (LDC, STC). */
2942#define R_ARM_LDC_PC_G2 69 /* PC relative (LDC, STC). */
2943#define R_ARM_ALU_SB_G0_NC 70 /* Program base relative (ADD,SUB). */
2944#define R_ARM_ALU_SB_G0 71 /* Program base relative (ADD,SUB). */
2945#define R_ARM_ALU_SB_G1_NC 72 /* Program base relative (ADD,SUB). */
2946#define R_ARM_ALU_SB_G1 73 /* Program base relative (ADD,SUB). */
2947#define R_ARM_ALU_SB_G2 74 /* Program base relative (ADD,SUB). */
2948#define R_ARM_LDR_SB_G0 75 /* Program base relative (LDR,
2949 STR, LDRB, STRB). */
2950#define R_ARM_LDR_SB_G1 76 /* Program base relative
2951 (LDR, STR, LDRB, STRB). */
2952#define R_ARM_LDR_SB_G2 77 /* Program base relative
2953 (LDR, STR, LDRB, STRB). */
2954#define R_ARM_LDRS_SB_G0 78 /* Program base relative
2955 (LDR, STR, LDRB, STRB). */
2956#define R_ARM_LDRS_SB_G1 79 /* Program base relative
2957 (LDR, STR, LDRB, STRB). */
2958#define R_ARM_LDRS_SB_G2 80 /* Program base relative
2959 (LDR, STR, LDRB, STRB). */
2960#define R_ARM_LDC_SB_G0 81 /* Program base relative (LDC,STC). */
2961#define R_ARM_LDC_SB_G1 82 /* Program base relative (LDC,STC). */
2962#define R_ARM_LDC_SB_G2 83 /* Program base relative (LDC,STC). */
2963#define R_ARM_MOVW_BREL_NC 84 /* Program base relative 16
2964 bit (MOVW). */
2965#define R_ARM_MOVT_BREL 85 /* Program base relative high
2966 16 bit (MOVT). */
2967#define R_ARM_MOVW_BREL 86 /* Program base relative 16
2968 bit (MOVW). */
2969#define R_ARM_THM_MOVW_BREL_NC 87 /* Program base relative 16
2970 bit (Thumb32 MOVW). */
2971#define R_ARM_THM_MOVT_BREL 88 /* Program base relative high
2972 16 bit (Thumb32 MOVT). */
2973#define R_ARM_THM_MOVW_BREL 89 /* Program base relative 16
2974 bit (Thumb32 MOVW). */
2975#define R_ARM_TLS_GOTDESC 90
2976#define R_ARM_TLS_CALL 91
2977#define R_ARM_TLS_DESCSEQ 92 /* TLS relaxation. */
2978#define R_ARM_THM_TLS_CALL 93
2979#define R_ARM_PLT32_ABS 94
2980#define R_ARM_GOT_ABS 95 /* GOT entry. */
2981#define R_ARM_GOT_PREL 96 /* PC relative GOT entry. */
2982#define R_ARM_GOT_BREL12 97 /* GOT entry relative to GOT
2983 origin (LDR). */
2984#define R_ARM_GOTOFF12 98 /* 12 bit, GOT entry relative
2985 to GOT origin (LDR, STR). */
2986#define R_ARM_GOTRELAX 99
2987#define R_ARM_GNU_VTENTRY 100
2988#define R_ARM_GNU_VTINHERIT 101
2989#define R_ARM_THM_PC11 102 /* PC relative & 0xFFE (Thumb16 B). */
2990#define R_ARM_THM_PC9 103 /* PC relative & 0x1FE
2991 (Thumb16 B/B<cond>). */
2992#define R_ARM_TLS_GD32 104 /* PC-rel 32 bit for global dynamic
2993 thread local data */
2994#define R_ARM_TLS_LDM32 105 /* PC-rel 32 bit for local dynamic
2995 thread local data */
2996#define R_ARM_TLS_LDO32 106 /* 32 bit offset relative to TLS
2997 block */
2998#define R_ARM_TLS_IE32 107 /* PC-rel 32 bit for GOT entry of
2999 static TLS block offset */
3000#define R_ARM_TLS_LE32 108 /* 32 bit offset relative to static
3001 TLS block */
3002#define R_ARM_TLS_LDO12 109 /* 12 bit relative to TLS
3003 block (LDR, STR). */
3004#define R_ARM_TLS_LE12 110 /* 12 bit relative to static
3005 TLS block (LDR, STR). */
3006#define R_ARM_TLS_IE12GP 111 /* 12 bit GOT entry relative
3007 to GOT origin (LDR). */
3008#define R_ARM_ME_TOO 128 /* Obsolete. */
3009#define R_ARM_THM_TLS_DESCSEQ 129
3010#define R_ARM_THM_TLS_DESCSEQ16 129
3011#define R_ARM_THM_TLS_DESCSEQ32 130
3012#define R_ARM_THM_GOT_BREL12 131 /* GOT entry relative to GOT
3013 origin, 12 bit (Thumb32 LDR). */
3014#define R_ARM_IRELATIVE 160
3015#define R_ARM_RXPC25 249
3016#define R_ARM_RSBREL32 250
3017#define R_ARM_THM_RPC22 251
3018#define R_ARM_RREL32 252
3019#define R_ARM_RABS22 253
3020#define R_ARM_RPC24 254
3021#define R_ARM_RBASE 255
3022/* Keep this the last entry. */
3023#define R_ARM_NUM 256
3024
3025/* csky */
3026#define R_CKCORE_NONE 0 /* no reloc */
3027#define R_CKCORE_ADDR32 1 /* direct 32 bit (S + A) */
3028#define R_CKCORE_PCRELIMM8BY4 2 /* disp ((S + A - P) >> 2) & 0xff */
3029#define R_CKCORE_PCRELIMM11BY2 3 /* disp ((S + A - P) >> 1) & 0x7ff */
3030#define R_CKCORE_PCREL32 5 /* 32-bit rel (S + A - P) */
3031#define R_CKCORE_PCRELJSR_IMM11BY2 6 /* disp ((S + A - P) >>1) & 0x7ff */
3032#define R_CKCORE_RELATIVE 9 /* 32 bit adjust program base(B + A)*/
3033#define R_CKCORE_COPY 10 /* 32 bit adjust by program base */
3034#define R_CKCORE_GLOB_DAT 11 /* off between got and sym (S) */
3035#define R_CKCORE_JUMP_SLOT 12 /* PLT entry (S) */
3036#define R_CKCORE_GOTOFF 13 /* offset to GOT (S + A - GOT) */
3037#define R_CKCORE_GOTPC 14 /* PC offset to GOT (GOT + A - P) */
3038#define R_CKCORE_GOT32 15 /* 32 bit GOT entry (G) */
3039#define R_CKCORE_PLT32 16 /* 32 bit PLT entry (G) */
3040#define R_CKCORE_ADDRGOT 17 /* GOT entry in GLOB_DAT (GOT + G) */
3041#define R_CKCORE_ADDRPLT 18 /* PLT entry in GLOB_DAT (GOT + G) */
3042#define R_CKCORE_PCREL_IMM26BY2 19 /* ((S + A - P) >> 1) & 0x3ffffff */
3043#define R_CKCORE_PCREL_IMM16BY2 20 /* disp ((S + A - P) >> 1) & 0xffff */
3044#define R_CKCORE_PCREL_IMM16BY4 21 /* disp ((S + A - P) >> 2) & 0xffff */
3045#define R_CKCORE_PCREL_IMM10BY2 22 /* disp ((S + A - P) >> 1) & 0x3ff */
3046#define R_CKCORE_PCREL_IMM10BY4 23 /* disp ((S + A - P) >> 2) & 0x3ff */
3047#define R_CKCORE_ADDR_HI16 24 /* high & low 16 bit ADDR */
3048 /* ((S + A) >> 16) & 0xffff */
3049#define R_CKCORE_ADDR_LO16 25 /* (S + A) & 0xffff */
3050#define R_CKCORE_GOTPC_HI16 26 /* high & low 16 bit GOTPC */
3051 /* ((GOT + A - P) >> 16) & 0xffff */
3052#define R_CKCORE_GOTPC_LO16 27 /* (GOT + A - P) & 0xffff */
3053#define R_CKCORE_GOTOFF_HI16 28 /* high & low 16 bit GOTOFF */
3054 /* ((S + A - GOT) >> 16) & 0xffff */
3055#define R_CKCORE_GOTOFF_LO16 29 /* (S + A - GOT) & 0xffff */
3056#define R_CKCORE_GOT12 30 /* 12 bit disp GOT entry (G) */
3057#define R_CKCORE_GOT_HI16 31 /* high & low 16 bit GOT */
3058 /* (G >> 16) & 0xffff */
3059#define R_CKCORE_GOT_LO16 32 /* (G & 0xffff) */
3060#define R_CKCORE_PLT12 33 /* 12 bit disp PLT entry (G) */
3061#define R_CKCORE_PLT_HI16 34 /* high & low 16 bit PLT */
3062 /* (G >> 16) & 0xffff */
3063#define R_CKCORE_PLT_LO16 35 /* G & 0xffff */
3064#define R_CKCORE_ADDRGOT_HI16 36 /* high & low 16 bit ADDRGOT */
3065 /* (GOT + G * 4) & 0xffff */
3066#define R_CKCORE_ADDRGOT_LO16 37 /* (GOT + G * 4) & 0xffff */
3067#define R_CKCORE_ADDRPLT_HI16 38 /* high & low 16 bit ADDRPLT */
3068 /* ((GOT + G * 4) >> 16) & 0xFFFF */
3069#define R_CKCORE_ADDRPLT_LO16 39 /* (GOT+G*4) & 0xffff */
3070#define R_CKCORE_PCREL_JSR_IMM26BY2 40 /* disp ((S+A-P) >>1) & x3ffffff */
3071#define R_CKCORE_TOFFSET_LO16 41 /* (S+A-BTEXT) & 0xffff */
3072#define R_CKCORE_DOFFSET_LO16 42 /* (S+A-BTEXT) & 0xffff */
3073#define R_CKCORE_PCREL_IMM18BY2 43 /* disp ((S+A-P) >>1) & 0x3ffff */
3074#define R_CKCORE_DOFFSET_IMM18 44 /* disp (S+A-BDATA) & 0x3ffff */
3075#define R_CKCORE_DOFFSET_IMM18BY2 45 /* disp ((S+A-BDATA)>>1) & 0x3ffff */
3076#define R_CKCORE_DOFFSET_IMM18BY4 46 /* disp ((S+A-BDATA)>>2) & 0x3ffff */
3077#define R_CKCORE_GOT_IMM18BY4 48 /* disp (G >> 2) */
3078#define R_CKCORE_PLT_IMM18BY4 49 /* disp (G >> 2) */
3079#define R_CKCORE_PCREL_IMM7BY4 50 /* disp ((S+A-P) >>2) & 0x7f */
3080#define R_CKCORE_TLS_LE32 51 /* 32 bit offset to TLS block */
3081#define R_CKCORE_TLS_IE32 52
3082#define R_CKCORE_TLS_GD32 53
3083#define R_CKCORE_TLS_LDM32 54
3084#define R_CKCORE_TLS_LDO32 55
3085#define R_CKCORE_TLS_DTPMOD32 56
3086#define R_CKCORE_TLS_DTPOFF32 57
3087#define R_CKCORE_TLS_TPOFF32 58
3088
3089/* IA-64 specific declarations. */
3090
3091/* Processor specific flags for the Ehdr e_flags field. */
3092#define EF_IA_64_MASKOS 0x0000000f /* os-specific flags */
3093#define EF_IA_64_ABI64 0x00000010 /* 64-bit ABI */
3094#define EF_IA_64_ARCH 0xff000000 /* arch. version mask */
3095
3096/* Processor specific values for the Phdr p_type field. */
3097#define PT_IA_64_ARCHEXT (PT_LOPROC + 0) /* arch extension bits */
3098#define PT_IA_64_UNWIND (PT_LOPROC + 1) /* ia64 unwind bits */
3099#define PT_IA_64_HP_OPT_ANOT (PT_LOOS + 0x12)
3100#define PT_IA_64_HP_HSL_ANOT (PT_LOOS + 0x13)
3101#define PT_IA_64_HP_STACK (PT_LOOS + 0x14)
3102
3103/* Processor specific flags for the Phdr p_flags field. */
3104#define PF_IA_64_NORECOV 0x80000000 /* spec insns w/o recovery */
3105
3106/* Processor specific values for the Shdr sh_type field. */
3107#define SHT_IA_64_EXT (SHT_LOPROC + 0) /* extension bits */
3108#define SHT_IA_64_UNWIND (SHT_LOPROC + 1) /* unwind bits */
3109
3110/* Processor specific flags for the Shdr sh_flags field. */
3111#define SHF_IA_64_SHORT 0x10000000 /* section near gp */
3112#define SHF_IA_64_NORECOV 0x20000000 /* spec insns w/o recovery */
3113
3114/* Processor specific values for the Dyn d_tag field. */
3115#define DT_IA_64_PLT_RESERVE (DT_LOPROC + 0)
3116#define DT_IA_64_NUM 1
3117
3118/* IA-64 relocations. */
3119#define R_IA64_NONE 0x00 /* none */
3120#define R_IA64_IMM14 0x21 /* symbol + addend, add imm14 */
3121#define R_IA64_IMM22 0x22 /* symbol + addend, add imm22 */
3122#define R_IA64_IMM64 0x23 /* symbol + addend, mov imm64 */
3123#define R_IA64_DIR32MSB 0x24 /* symbol + addend, data4 MSB */
3124#define R_IA64_DIR32LSB 0x25 /* symbol + addend, data4 LSB */
3125#define R_IA64_DIR64MSB 0x26 /* symbol + addend, data8 MSB */
3126#define R_IA64_DIR64LSB 0x27 /* symbol + addend, data8 LSB */
3127#define R_IA64_GPREL22 0x2a /* @gprel(sym + add), add imm22 */
3128#define R_IA64_GPREL64I 0x2b /* @gprel(sym + add), mov imm64 */
3129#define R_IA64_GPREL32MSB 0x2c /* @gprel(sym + add), data4 MSB */
3130#define R_IA64_GPREL32LSB 0x2d /* @gprel(sym + add), data4 LSB */
3131#define R_IA64_GPREL64MSB 0x2e /* @gprel(sym + add), data8 MSB */
3132#define R_IA64_GPREL64LSB 0x2f /* @gprel(sym + add), data8 LSB */
3133#define R_IA64_LTOFF22 0x32 /* @ltoff(sym + add), add imm22 */
3134#define R_IA64_LTOFF64I 0x33 /* @ltoff(sym + add), mov imm64 */
3135#define R_IA64_PLTOFF22 0x3a /* @pltoff(sym + add), add imm22 */
3136#define R_IA64_PLTOFF64I 0x3b /* @pltoff(sym + add), mov imm64 */
3137#define R_IA64_PLTOFF64MSB 0x3e /* @pltoff(sym + add), data8 MSB */
3138#define R_IA64_PLTOFF64LSB 0x3f /* @pltoff(sym + add), data8 LSB */
3139#define R_IA64_FPTR64I 0x43 /* @fptr(sym + add), mov imm64 */
3140#define R_IA64_FPTR32MSB 0x44 /* @fptr(sym + add), data4 MSB */
3141#define R_IA64_FPTR32LSB 0x45 /* @fptr(sym + add), data4 LSB */
3142#define R_IA64_FPTR64MSB 0x46 /* @fptr(sym + add), data8 MSB */
3143#define R_IA64_FPTR64LSB 0x47 /* @fptr(sym + add), data8 LSB */
3144#define R_IA64_PCREL60B 0x48 /* @pcrel(sym + add), brl */
3145#define R_IA64_PCREL21B 0x49 /* @pcrel(sym + add), ptb, call */
3146#define R_IA64_PCREL21M 0x4a /* @pcrel(sym + add), chk.s */
3147#define R_IA64_PCREL21F 0x4b /* @pcrel(sym + add), fchkf */
3148#define R_IA64_PCREL32MSB 0x4c /* @pcrel(sym + add), data4 MSB */
3149#define R_IA64_PCREL32LSB 0x4d /* @pcrel(sym + add), data4 LSB */
3150#define R_IA64_PCREL64MSB 0x4e /* @pcrel(sym + add), data8 MSB */
3151#define R_IA64_PCREL64LSB 0x4f /* @pcrel(sym + add), data8 LSB */
3152#define R_IA64_LTOFF_FPTR22 0x52 /* @ltoff(@fptr(s+a)), imm22 */
3153#define R_IA64_LTOFF_FPTR64I 0x53 /* @ltoff(@fptr(s+a)), imm64 */
3154#define R_IA64_LTOFF_FPTR32MSB 0x54 /* @ltoff(@fptr(s+a)), data4 MSB */
3155#define R_IA64_LTOFF_FPTR32LSB 0x55 /* @ltoff(@fptr(s+a)), data4 LSB */
3156#define R_IA64_LTOFF_FPTR64MSB 0x56 /* @ltoff(@fptr(s+a)), data8 MSB */
3157#define R_IA64_LTOFF_FPTR64LSB 0x57 /* @ltoff(@fptr(s+a)), data8 LSB */
3158#define R_IA64_SEGREL32MSB 0x5c /* @segrel(sym + add), data4 MSB */
3159#define R_IA64_SEGREL32LSB 0x5d /* @segrel(sym + add), data4 LSB */
3160#define R_IA64_SEGREL64MSB 0x5e /* @segrel(sym + add), data8 MSB */
3161#define R_IA64_SEGREL64LSB 0x5f /* @segrel(sym + add), data8 LSB */
3162#define R_IA64_SECREL32MSB 0x64 /* @secrel(sym + add), data4 MSB */
3163#define R_IA64_SECREL32LSB 0x65 /* @secrel(sym + add), data4 LSB */
3164#define R_IA64_SECREL64MSB 0x66 /* @secrel(sym + add), data8 MSB */
3165#define R_IA64_SECREL64LSB 0x67 /* @secrel(sym + add), data8 LSB */
3166#define R_IA64_REL32MSB 0x6c /* data 4 + REL */
3167#define R_IA64_REL32LSB 0x6d /* data 4 + REL */
3168#define R_IA64_REL64MSB 0x6e /* data 8 + REL */
3169#define R_IA64_REL64LSB 0x6f /* data 8 + REL */
3170#define R_IA64_LTV32MSB 0x74 /* symbol + addend, data4 MSB */
3171#define R_IA64_LTV32LSB 0x75 /* symbol + addend, data4 LSB */
3172#define R_IA64_LTV64MSB 0x76 /* symbol + addend, data8 MSB */
3173#define R_IA64_LTV64LSB 0x77 /* symbol + addend, data8 LSB */
3174#define R_IA64_PCREL21BI 0x79 /* @pcrel(sym + add), 21bit inst */
3175#define R_IA64_PCREL22 0x7a /* @pcrel(sym + add), 22bit inst */
3176#define R_IA64_PCREL64I 0x7b /* @pcrel(sym + add), 64bit inst */
3177#define R_IA64_IPLTMSB 0x80 /* dynamic reloc, imported PLT, MSB */
3178#define R_IA64_IPLTLSB 0x81 /* dynamic reloc, imported PLT, LSB */
3179#define R_IA64_COPY 0x84 /* copy relocation */
3180#define R_IA64_SUB 0x85 /* Addend and symbol difference */
3181#define R_IA64_LTOFF22X 0x86 /* LTOFF22, relaxable. */
3182#define R_IA64_LDXMOV 0x87 /* Use of LTOFF22X. */
3183#define R_IA64_TPREL14 0x91 /* @tprel(sym + add), imm14 */
3184#define R_IA64_TPREL22 0x92 /* @tprel(sym + add), imm22 */
3185#define R_IA64_TPREL64I 0x93 /* @tprel(sym + add), imm64 */
3186#define R_IA64_TPREL64MSB 0x96 /* @tprel(sym + add), data8 MSB */
3187#define R_IA64_TPREL64LSB 0x97 /* @tprel(sym + add), data8 LSB */
3188#define R_IA64_LTOFF_TPREL22 0x9a /* @ltoff(@tprel(s+a)), imm2 */
3189#define R_IA64_DTPMOD64MSB 0xa6 /* @dtpmod(sym + add), data8 MSB */
3190#define R_IA64_DTPMOD64LSB 0xa7 /* @dtpmod(sym + add), data8 LSB */
3191#define R_IA64_LTOFF_DTPMOD22 0xaa /* @ltoff(@dtpmod(sym + add)), imm22 */
3192#define R_IA64_DTPREL14 0xb1 /* @dtprel(sym + add), imm14 */
3193#define R_IA64_DTPREL22 0xb2 /* @dtprel(sym + add), imm22 */
3194#define R_IA64_DTPREL64I 0xb3 /* @dtprel(sym + add), imm64 */
3195#define R_IA64_DTPREL32MSB 0xb4 /* @dtprel(sym + add), data4 MSB */
3196#define R_IA64_DTPREL32LSB 0xb5 /* @dtprel(sym + add), data4 LSB */
3197#define R_IA64_DTPREL64MSB 0xb6 /* @dtprel(sym + add), data8 MSB */
3198#define R_IA64_DTPREL64LSB 0xb7 /* @dtprel(sym + add), data8 LSB */
3199#define R_IA64_LTOFF_DTPREL22 0xba /* @ltoff(@dtprel(s+a)), imm22 */
3200
3201/* SH specific declarations */
3202
3203/* Processor specific flags for the ELF header e_flags field. */
3204#define EF_SH_MACH_MASK 0x1f
3205#define EF_SH_UNKNOWN 0x0
3206#define EF_SH1 0x1
3207#define EF_SH2 0x2
3208#define EF_SH3 0x3
3209#define EF_SH_DSP 0x4
3210#define EF_SH3_DSP 0x5
3211#define EF_SH4AL_DSP 0x6
3212#define EF_SH3E 0x8
3213#define EF_SH4 0x9
3214#define EF_SH2E 0xb
3215#define EF_SH4A 0xc
3216#define EF_SH2A 0xd
3217#define EF_SH4_NOFPU 0x10
3218#define EF_SH4A_NOFPU 0x11
3219#define EF_SH4_NOMMU_NOFPU 0x12
3220#define EF_SH2A_NOFPU 0x13
3221#define EF_SH3_NOMMU 0x14
3222#define EF_SH2A_SH4_NOFPU 0x15
3223#define EF_SH2A_SH3_NOFPU 0x16
3224#define EF_SH2A_SH4 0x17
3225#define EF_SH2A_SH3E 0x18
3226
3227/* SH relocs. */
3228#define R_SH_NONE 0
3229#define R_SH_DIR32 1
3230#define R_SH_REL32 2
3231#define R_SH_DIR8WPN 3
3232#define R_SH_IND12W 4
3233#define R_SH_DIR8WPL 5
3234#define R_SH_DIR8WPZ 6
3235#define R_SH_DIR8BP 7
3236#define R_SH_DIR8W 8
3237#define R_SH_DIR8L 9
3238#define R_SH_SWITCH16 25
3239#define R_SH_SWITCH32 26
3240#define R_SH_USES 27
3241#define R_SH_COUNT 28
3242#define R_SH_ALIGN 29
3243#define R_SH_CODE 30
3244#define R_SH_DATA 31
3245#define R_SH_LABEL 32
3246#define R_SH_SWITCH8 33
3247#define R_SH_GNU_VTINHERIT 34
3248#define R_SH_GNU_VTENTRY 35
3249#define R_SH_TLS_GD_32 144
3250#define R_SH_TLS_LD_32 145
3251#define R_SH_TLS_LDO_32 146
3252#define R_SH_TLS_IE_32 147
3253#define R_SH_TLS_LE_32 148
3254#define R_SH_TLS_DTPMOD32 149
3255#define R_SH_TLS_DTPOFF32 150
3256#define R_SH_TLS_TPOFF32 151
3257#define R_SH_GOT32 160
3258#define R_SH_PLT32 161
3259#define R_SH_COPY 162
3260#define R_SH_GLOB_DAT 163
3261#define R_SH_JMP_SLOT 164
3262#define R_SH_RELATIVE 165
3263#define R_SH_GOTOFF 166
3264#define R_SH_GOTPC 167
3265/* Keep this the last entry. */
3266#define R_SH_NUM 256
3267
3268/* S/390 specific definitions. */
3269
3270/* Valid values for the e_flags field. */
3271
3272#define EF_S390_HIGH_GPRS 0x00000001 /* High GPRs kernel facility needed. */
3273
3274/* Additional s390 relocs */
3275
3276#define R_390_NONE 0 /* No reloc. */
3277#define R_390_8 1 /* Direct 8 bit. */
3278#define R_390_12 2 /* Direct 12 bit. */
3279#define R_390_16 3 /* Direct 16 bit. */
3280#define R_390_32 4 /* Direct 32 bit. */
3281#define R_390_PC32 5 /* PC relative 32 bit. */
3282#define R_390_GOT12 6 /* 12 bit GOT offset. */
3283#define R_390_GOT32 7 /* 32 bit GOT offset. */
3284#define R_390_PLT32 8 /* 32 bit PC relative PLT address. */
3285#define R_390_COPY 9 /* Copy symbol at runtime. */
3286#define R_390_GLOB_DAT 10 /* Create GOT entry. */
3287#define R_390_JMP_SLOT 11 /* Create PLT entry. */
3288#define R_390_RELATIVE 12 /* Adjust by program base. */
3289#define R_390_GOTOFF32 13 /* 32 bit offset to GOT. */
3290#define R_390_GOTPC 14 /* 32 bit PC relative offset to GOT. */
3291#define R_390_GOT16 15 /* 16 bit GOT offset. */
3292#define R_390_PC16 16 /* PC relative 16 bit. */
3293#define R_390_PC16DBL 17 /* PC relative 16 bit shifted by 1. */
3294#define R_390_PLT16DBL 18 /* 16 bit PC rel. PLT shifted by 1. */
3295#define R_390_PC32DBL 19 /* PC relative 32 bit shifted by 1. */
3296#define R_390_PLT32DBL 20 /* 32 bit PC rel. PLT shifted by 1. */
3297#define R_390_GOTPCDBL 21 /* 32 bit PC rel. GOT shifted by 1. */
3298#define R_390_64 22 /* Direct 64 bit. */
3299#define R_390_PC64 23 /* PC relative 64 bit. */
3300#define R_390_GOT64 24 /* 64 bit GOT offset. */
3301#define R_390_PLT64 25 /* 64 bit PC relative PLT address. */
3302#define R_390_GOTENT 26 /* 32 bit PC rel. to GOT entry >> 1. */
3303#define R_390_GOTOFF16 27 /* 16 bit offset to GOT. */
3304#define R_390_GOTOFF64 28 /* 64 bit offset to GOT. */
3305#define R_390_GOTPLT12 29 /* 12 bit offset to jump slot. */
3306#define R_390_GOTPLT16 30 /* 16 bit offset to jump slot. */
3307#define R_390_GOTPLT32 31 /* 32 bit offset to jump slot. */
3308#define R_390_GOTPLT64 32 /* 64 bit offset to jump slot. */
3309#define R_390_GOTPLTENT 33 /* 32 bit rel. offset to jump slot. */
3310#define R_390_PLTOFF16 34 /* 16 bit offset from GOT to PLT. */
3311#define R_390_PLTOFF32 35 /* 32 bit offset from GOT to PLT. */
3312#define R_390_PLTOFF64 36 /* 16 bit offset from GOT to PLT. */
3313#define R_390_TLS_LOAD 37 /* Tag for load insn in TLS code. */
3314#define R_390_TLS_GDCALL 38 /* Tag for function call in general
3315 dynamic TLS code. */
3316#define R_390_TLS_LDCALL 39 /* Tag for function call in local
3317 dynamic TLS code. */
3318#define R_390_TLS_GD32 40 /* Direct 32 bit for general dynamic
3319 thread local data. */
3320#define R_390_TLS_GD64 41 /* Direct 64 bit for general dynamic
3321 thread local data. */
3322#define R_390_TLS_GOTIE12 42 /* 12 bit GOT offset for static TLS
3323 block offset. */
3324#define R_390_TLS_GOTIE32 43 /* 32 bit GOT offset for static TLS
3325 block offset. */
3326#define R_390_TLS_GOTIE64 44 /* 64 bit GOT offset for static TLS
3327 block offset. */
3328#define R_390_TLS_LDM32 45 /* Direct 32 bit for local dynamic
3329 thread local data in LE code. */
3330#define R_390_TLS_LDM64 46 /* Direct 64 bit for local dynamic
3331 thread local data in LE code. */
3332#define R_390_TLS_IE32 47 /* 32 bit address of GOT entry for
3333 negated static TLS block offset. */
3334#define R_390_TLS_IE64 48 /* 64 bit address of GOT entry for
3335 negated static TLS block offset. */
3336#define R_390_TLS_IEENT 49 /* 32 bit rel. offset to GOT entry for
3337 negated static TLS block offset. */
3338#define R_390_TLS_LE32 50 /* 32 bit negated offset relative to
3339 static TLS block. */
3340#define R_390_TLS_LE64 51 /* 64 bit negated offset relative to
3341 static TLS block. */
3342#define R_390_TLS_LDO32 52 /* 32 bit offset relative to TLS
3343 block. */
3344#define R_390_TLS_LDO64 53 /* 64 bit offset relative to TLS
3345 block. */
3346#define R_390_TLS_DTPMOD 54 /* ID of module containing symbol. */
3347#define R_390_TLS_DTPOFF 55 /* Offset in TLS block. */
3348#define R_390_TLS_TPOFF 56 /* Negated offset in static TLS
3349 block. */
3350#define R_390_20 57 /* Direct 20 bit. */
3351#define R_390_GOT20 58 /* 20 bit GOT offset. */
3352#define R_390_GOTPLT20 59 /* 20 bit offset to jump slot. */
3353#define R_390_TLS_GOTIE20 60 /* 20 bit GOT offset for static TLS
3354 block offset. */
3355#define R_390_IRELATIVE 61 /* STT_GNU_IFUNC relocation. */
3356/* Keep this the last entry. */
3357#define R_390_NUM 62
3358
3359
3360/* CRIS relocations. */
3361#define R_CRIS_NONE 0
3362#define R_CRIS_8 1
3363#define R_CRIS_16 2
3364#define R_CRIS_32 3
3365#define R_CRIS_8_PCREL 4
3366#define R_CRIS_16_PCREL 5
3367#define R_CRIS_32_PCREL 6
3368#define R_CRIS_GNU_VTINHERIT 7
3369#define R_CRIS_GNU_VTENTRY 8
3370#define R_CRIS_COPY 9
3371#define R_CRIS_GLOB_DAT 10
3372#define R_CRIS_JUMP_SLOT 11
3373#define R_CRIS_RELATIVE 12
3374#define R_CRIS_16_GOT 13
3375#define R_CRIS_32_GOT 14
3376#define R_CRIS_16_GOTPLT 15
3377#define R_CRIS_32_GOTPLT 16
3378#define R_CRIS_32_GOTREL 17
3379#define R_CRIS_32_PLT_GOTREL 18
3380#define R_CRIS_32_PLT_PCREL 19
3381
3382#define R_CRIS_NUM 20
3383
3384
3385/* AMD x86-64 relocations. */
3386#define R_X86_64_NONE 0 /* No reloc */
3387#define R_X86_64_64 1 /* Direct 64 bit */
3388#define R_X86_64_PC32 2 /* PC relative 32 bit signed */
3389#define R_X86_64_GOT32 3 /* 32 bit GOT entry */
3390#define R_X86_64_PLT32 4 /* 32 bit PLT address */
3391#define R_X86_64_COPY 5 /* Copy symbol at runtime */
3392#define R_X86_64_GLOB_DAT 6 /* Create GOT entry */
3393#define R_X86_64_JUMP_SLOT 7 /* Create PLT entry */
3394#define R_X86_64_RELATIVE 8 /* Adjust by program base */
3395#define R_X86_64_GOTPCREL 9 /* 32 bit signed PC relative
3396 offset to GOT */
3397#define R_X86_64_32 10 /* Direct 32 bit zero extended */
3398#define R_X86_64_32S 11 /* Direct 32 bit sign extended */
3399#define R_X86_64_16 12 /* Direct 16 bit zero extended */
3400#define R_X86_64_PC16 13 /* 16 bit sign extended pc relative */
3401#define R_X86_64_8 14 /* Direct 8 bit sign extended */
3402#define R_X86_64_PC8 15 /* 8 bit sign extended pc relative */
3403#define R_X86_64_DTPMOD64 16 /* ID of module containing symbol */
3404#define R_X86_64_DTPOFF64 17 /* Offset in module's TLS block */
3405#define R_X86_64_TPOFF64 18 /* Offset in initial TLS block */
3406#define R_X86_64_TLSGD 19 /* 32 bit signed PC relative offset
3407 to two GOT entries for GD symbol */
3408#define R_X86_64_TLSLD 20 /* 32 bit signed PC relative offset
3409 to two GOT entries for LD symbol */
3410#define R_X86_64_DTPOFF32 21 /* Offset in TLS block */
3411#define R_X86_64_GOTTPOFF 22 /* 32 bit signed PC relative offset
3412 to GOT entry for IE symbol */
3413#define R_X86_64_TPOFF32 23 /* Offset in initial TLS block */
3414#define R_X86_64_PC64 24 /* PC relative 64 bit */
3415#define R_X86_64_GOTOFF64 25 /* 64 bit offset to GOT */
3416#define R_X86_64_GOTPC32 26 /* 32 bit signed pc relative
3417 offset to GOT */
3418#define R_X86_64_GOT64 27 /* 64-bit GOT entry offset */
3419#define R_X86_64_GOTPCREL64 28 /* 64-bit PC relative offset
3420 to GOT entry */
3421#define R_X86_64_GOTPC64 29 /* 64-bit PC relative offset to GOT */
3422#define R_X86_64_GOTPLT64 30 /* like GOT64, says PLT entry needed */
3423#define R_X86_64_PLTOFF64 31 /* 64-bit GOT relative offset
3424 to PLT entry */
3425#define R_X86_64_SIZE32 32 /* Size of symbol plus 32-bit addend */
3426#define R_X86_64_SIZE64 33 /* Size of symbol plus 64-bit addend */
3427#define R_X86_64_GOTPC32_TLSDESC 34 /* GOT offset for TLS descriptor. */
3428#define R_X86_64_TLSDESC_CALL 35 /* Marker for call through TLS
3429 descriptor. */
3430#define R_X86_64_TLSDESC 36 /* TLS descriptor. */
3431#define R_X86_64_IRELATIVE 37 /* Adjust indirectly by program base */
3432#define R_X86_64_RELATIVE64 38 /* 64-bit adjust by program base */
3433 /* 39 Reserved was R_X86_64_PC32_BND */
3434 /* 40 Reserved was R_X86_64_PLT32_BND */
3435#define R_X86_64_GOTPCRELX 41 /* Load from 32 bit signed pc relative
3436 offset to GOT entry without REX
3437 prefix, relaxable. */
3438#define R_X86_64_REX_GOTPCRELX 42 /* Load from 32 bit signed pc relative
3439 offset to GOT entry with REX prefix,
3440 relaxable. */
3441#define R_X86_64_NUM 43
3442
3443/* x86-64 sh_type values. */
3444#define SHT_X86_64_UNWIND 0x70000001 /* Unwind information. */
3445
3446
3447/* AM33 relocations. */
3448#define R_MN10300_NONE 0 /* No reloc. */
3449#define R_MN10300_32 1 /* Direct 32 bit. */
3450#define R_MN10300_16 2 /* Direct 16 bit. */
3451#define R_MN10300_8 3 /* Direct 8 bit. */
3452#define R_MN10300_PCREL32 4 /* PC-relative 32-bit. */
3453#define R_MN10300_PCREL16 5 /* PC-relative 16-bit signed. */
3454#define R_MN10300_PCREL8 6 /* PC-relative 8-bit signed. */
3455#define R_MN10300_GNU_VTINHERIT 7 /* Ancient C++ vtable garbage... */
3456#define R_MN10300_GNU_VTENTRY 8 /* ... collection annotation. */
3457#define R_MN10300_24 9 /* Direct 24 bit. */
3458#define R_MN10300_GOTPC32 10 /* 32-bit PCrel offset to GOT. */
3459#define R_MN10300_GOTPC16 11 /* 16-bit PCrel offset to GOT. */
3460#define R_MN10300_GOTOFF32 12 /* 32-bit offset from GOT. */
3461#define R_MN10300_GOTOFF24 13 /* 24-bit offset from GOT. */
3462#define R_MN10300_GOTOFF16 14 /* 16-bit offset from GOT. */
3463#define R_MN10300_PLT32 15 /* 32-bit PCrel to PLT entry. */
3464#define R_MN10300_PLT16 16 /* 16-bit PCrel to PLT entry. */
3465#define R_MN10300_GOT32 17 /* 32-bit offset to GOT entry. */
3466#define R_MN10300_GOT24 18 /* 24-bit offset to GOT entry. */
3467#define R_MN10300_GOT16 19 /* 16-bit offset to GOT entry. */
3468#define R_MN10300_COPY 20 /* Copy symbol at runtime. */
3469#define R_MN10300_GLOB_DAT 21 /* Create GOT entry. */
3470#define R_MN10300_JMP_SLOT 22 /* Create PLT entry. */
3471#define R_MN10300_RELATIVE 23 /* Adjust by program base. */
3472#define R_MN10300_TLS_GD 24 /* 32-bit offset for global dynamic. */
3473#define R_MN10300_TLS_LD 25 /* 32-bit offset for local dynamic. */
3474#define R_MN10300_TLS_LDO 26 /* Module-relative offset. */
3475#define R_MN10300_TLS_GOTIE 27 /* GOT offset for static TLS block
3476 offset. */
3477#define R_MN10300_TLS_IE 28 /* GOT address for static TLS block
3478 offset. */
3479#define R_MN10300_TLS_LE 29 /* Offset relative to static TLS
3480 block. */
3481#define R_MN10300_TLS_DTPMOD 30 /* ID of module containing symbol. */
3482#define R_MN10300_TLS_DTPOFF 31 /* Offset in module TLS block. */
3483#define R_MN10300_TLS_TPOFF 32 /* Offset in static TLS block. */
3484#define R_MN10300_SYM_DIFF 33 /* Adjustment for next reloc as needed
3485 by linker relaxation. */
3486#define R_MN10300_ALIGN 34 /* Alignment requirement for linker
3487 relaxation. */
3488#define R_MN10300_NUM 35
3489
3490
3491/* M32R relocs. */
3492#define R_M32R_NONE 0 /* No reloc. */
3493#define R_M32R_16 1 /* Direct 16 bit. */
3494#define R_M32R_32 2 /* Direct 32 bit. */
3495#define R_M32R_24 3 /* Direct 24 bit. */
3496#define R_M32R_10_PCREL 4 /* PC relative 10 bit shifted. */
3497#define R_M32R_18_PCREL 5 /* PC relative 18 bit shifted. */
3498#define R_M32R_26_PCREL 6 /* PC relative 26 bit shifted. */
3499#define R_M32R_HI16_ULO 7 /* High 16 bit with unsigned low. */
3500#define R_M32R_HI16_SLO 8 /* High 16 bit with signed low. */
3501#define R_M32R_LO16 9 /* Low 16 bit. */
3502#define R_M32R_SDA16 10 /* 16 bit offset in SDA. */
3503#define R_M32R_GNU_VTINHERIT 11
3504#define R_M32R_GNU_VTENTRY 12
3505/* M32R relocs use SHT_RELA. */
3506#define R_M32R_16_RELA 33 /* Direct 16 bit. */
3507#define R_M32R_32_RELA 34 /* Direct 32 bit. */
3508#define R_M32R_24_RELA 35 /* Direct 24 bit. */
3509#define R_M32R_10_PCREL_RELA 36 /* PC relative 10 bit shifted. */
3510#define R_M32R_18_PCREL_RELA 37 /* PC relative 18 bit shifted. */
3511#define R_M32R_26_PCREL_RELA 38 /* PC relative 26 bit shifted. */
3512#define R_M32R_HI16_ULO_RELA 39 /* High 16 bit with unsigned low */
3513#define R_M32R_HI16_SLO_RELA 40 /* High 16 bit with signed low */
3514#define R_M32R_LO16_RELA 41 /* Low 16 bit */
3515#define R_M32R_SDA16_RELA 42 /* 16 bit offset in SDA */
3516#define R_M32R_RELA_GNU_VTINHERIT 43
3517#define R_M32R_RELA_GNU_VTENTRY 44
3518#define R_M32R_REL32 45 /* PC relative 32 bit. */
3519
3520#define R_M32R_GOT24 48 /* 24 bit GOT entry */
3521#define R_M32R_26_PLTREL 49 /* 26 bit PC relative to PLT shifted */
3522#define R_M32R_COPY 50 /* Copy symbol at runtime */
3523#define R_M32R_GLOB_DAT 51 /* Create GOT entry */
3524#define R_M32R_JMP_SLOT 52 /* Create PLT entry */
3525#define R_M32R_RELATIVE 53 /* Adjust by program base */
3526#define R_M32R_GOTOFF 54 /* 24 bit offset to GOT */
3527#define R_M32R_GOTPC24 55 /* 24 bit PC relative offset to GOT */
3528#define R_M32R_GOT16_HI_ULO 56 /* High 16 bit GOT entry with unsigned
3529 low */
3530#define R_M32R_GOT16_HI_SLO 57 /* High 16 bit GOT entry with signed
3531 low */
3532#define R_M32R_GOT16_LO 58 /* Low 16 bit GOT entry */
3533#define R_M32R_GOTPC_HI_ULO 59 /* High 16 bit PC relative offset to
3534 GOT with unsigned low */
3535#define R_M32R_GOTPC_HI_SLO 60 /* High 16 bit PC relative offset to
3536 GOT with signed low */
3537#define R_M32R_GOTPC_LO 61 /* Low 16 bit PC relative offset to
3538 GOT */
3539#define R_M32R_GOTOFF_HI_ULO 62 /* High 16 bit offset to GOT
3540 with unsigned low */
3541#define R_M32R_GOTOFF_HI_SLO 63 /* High 16 bit offset to GOT
3542 with signed low */
3543#define R_M32R_GOTOFF_LO 64 /* Low 16 bit offset to GOT */
3544#define R_M32R_NUM 256 /* Keep this the last entry. */
3545
3546/* MicroBlaze relocations */
3547#define R_MICROBLAZE_NONE 0 /* No reloc. */
3548#define R_MICROBLAZE_32 1 /* Direct 32 bit. */
3549#define R_MICROBLAZE_32_PCREL 2 /* PC relative 32 bit. */
3550#define R_MICROBLAZE_64_PCREL 3 /* PC relative 64 bit. */
3551#define R_MICROBLAZE_32_PCREL_LO 4 /* Low 16 bits of PCREL32. */
3552#define R_MICROBLAZE_64 5 /* Direct 64 bit. */
3553#define R_MICROBLAZE_32_LO 6 /* Low 16 bit. */
3554#define R_MICROBLAZE_SRO32 7 /* Read-only small data area. */
3555#define R_MICROBLAZE_SRW32 8 /* Read-write small data area. */
3556#define R_MICROBLAZE_64_NONE 9 /* No reloc. */
3557#define R_MICROBLAZE_32_SYM_OP_SYM 10 /* Symbol Op Symbol relocation. */
3558#define R_MICROBLAZE_GNU_VTINHERIT 11 /* GNU C++ vtable hierarchy. */
3559#define R_MICROBLAZE_GNU_VTENTRY 12 /* GNU C++ vtable member usage. */
3560#define R_MICROBLAZE_GOTPC_64 13 /* PC-relative GOT offset. */
3561#define R_MICROBLAZE_GOT_64 14 /* GOT entry offset. */
3562#define R_MICROBLAZE_PLT_64 15 /* PLT offset (PC-relative). */
3563#define R_MICROBLAZE_REL 16 /* Adjust by program base. */
3564#define R_MICROBLAZE_JUMP_SLOT 17 /* Create PLT entry. */
3565#define R_MICROBLAZE_GLOB_DAT 18 /* Create GOT entry. */
3566#define R_MICROBLAZE_GOTOFF_64 19 /* 64 bit offset to GOT. */
3567#define R_MICROBLAZE_GOTOFF_32 20 /* 32 bit offset to GOT. */
3568#define R_MICROBLAZE_COPY 21 /* Runtime copy. */
3569#define R_MICROBLAZE_TLS 22 /* TLS Reloc. */
3570#define R_MICROBLAZE_TLSGD 23 /* TLS General Dynamic. */
3571#define R_MICROBLAZE_TLSLD 24 /* TLS Local Dynamic. */
3572#define R_MICROBLAZE_TLSDTPMOD32 25 /* TLS Module ID. */
3573#define R_MICROBLAZE_TLSDTPREL32 26 /* TLS Offset Within TLS Block. */
3574#define R_MICROBLAZE_TLSDTPREL64 27 /* TLS Offset Within TLS Block. */
3575#define R_MICROBLAZE_TLSGOTTPREL32 28 /* TLS Offset From Thread Pointer. */
3576#define R_MICROBLAZE_TLSTPREL32 29 /* TLS Offset From Thread Pointer. */
3577
3578/* Legal values for d_tag (dynamic entry type). */
3579#define DT_NIOS2_GP 0x70000002 /* Address of _gp. */
3580
3581/* Nios II relocations. */
3582#define R_NIOS2_NONE 0 /* No reloc. */
3583#define R_NIOS2_S16 1 /* Direct signed 16 bit. */
3584#define R_NIOS2_U16 2 /* Direct unsigned 16 bit. */
3585#define R_NIOS2_PCREL16 3 /* PC relative 16 bit. */
3586#define R_NIOS2_CALL26 4 /* Direct call. */
3587#define R_NIOS2_IMM5 5 /* 5 bit constant expression. */
3588#define R_NIOS2_CACHE_OPX 6 /* 5 bit expression, shift 22. */
3589#define R_NIOS2_IMM6 7 /* 6 bit constant expression. */
3590#define R_NIOS2_IMM8 8 /* 8 bit constant expression. */
3591#define R_NIOS2_HI16 9 /* High 16 bit. */
3592#define R_NIOS2_LO16 10 /* Low 16 bit. */
3593#define R_NIOS2_HIADJ16 11 /* High 16 bit, adjusted. */
3594#define R_NIOS2_BFD_RELOC_32 12 /* 32 bit symbol value + addend. */
3595#define R_NIOS2_BFD_RELOC_16 13 /* 16 bit symbol value + addend. */
3596#define R_NIOS2_BFD_RELOC_8 14 /* 8 bit symbol value + addend. */
3597#define R_NIOS2_GPREL 15 /* 16 bit GP pointer offset. */
3598#define R_NIOS2_GNU_VTINHERIT 16 /* GNU C++ vtable hierarchy. */
3599#define R_NIOS2_GNU_VTENTRY 17 /* GNU C++ vtable member usage. */
3600#define R_NIOS2_UJMP 18 /* Unconditional branch. */
3601#define R_NIOS2_CJMP 19 /* Conditional branch. */
3602#define R_NIOS2_CALLR 20 /* Indirect call through register. */
3603#define R_NIOS2_ALIGN 21 /* Alignment requirement for
3604 linker relaxation. */
3605#define R_NIOS2_GOT16 22 /* 16 bit GOT entry. */
3606#define R_NIOS2_CALL16 23 /* 16 bit GOT entry for function. */
3607#define R_NIOS2_GOTOFF_LO 24 /* %lo of offset to GOT pointer. */
3608#define R_NIOS2_GOTOFF_HA 25 /* %hiadj of offset to GOT pointer. */
3609#define R_NIOS2_PCREL_LO 26 /* %lo of PC relative offset. */
3610#define R_NIOS2_PCREL_HA 27 /* %hiadj of PC relative offset. */
3611#define R_NIOS2_TLS_GD16 28 /* 16 bit GOT offset for TLS GD. */
3612#define R_NIOS2_TLS_LDM16 29 /* 16 bit GOT offset for TLS LDM. */
3613#define R_NIOS2_TLS_LDO16 30 /* 16 bit module relative offset. */
3614#define R_NIOS2_TLS_IE16 31 /* 16 bit GOT offset for TLS IE. */
3615#define R_NIOS2_TLS_LE16 32 /* 16 bit LE TP-relative offset. */
3616#define R_NIOS2_TLS_DTPMOD 33 /* Module number. */
3617#define R_NIOS2_TLS_DTPREL 34 /* Module-relative offset. */
3618#define R_NIOS2_TLS_TPREL 35 /* TP-relative offset. */
3619#define R_NIOS2_COPY 36 /* Copy symbol at runtime. */
3620#define R_NIOS2_GLOB_DAT 37 /* Create GOT entry. */
3621#define R_NIOS2_JUMP_SLOT 38 /* Create PLT entry. */
3622#define R_NIOS2_RELATIVE 39 /* Adjust by program base. */
3623#define R_NIOS2_GOTOFF 40 /* 16 bit offset to GOT pointer. */
3624#define R_NIOS2_CALL26_NOAT 41 /* Direct call in .noat section. */
3625#define R_NIOS2_GOT_LO 42 /* %lo() of GOT entry. */
3626#define R_NIOS2_GOT_HA 43 /* %hiadj() of GOT entry. */
3627#define R_NIOS2_CALL_LO 44 /* %lo() of function GOT entry. */
3628#define R_NIOS2_CALL_HA 45 /* %hiadj() of function GOT entry. */
3629
3630/* TILEPro relocations. */
3631#define R_TILEPRO_NONE 0 /* No reloc */
3632#define R_TILEPRO_32 1 /* Direct 32 bit */
3633#define R_TILEPRO_16 2 /* Direct 16 bit */
3634#define R_TILEPRO_8 3 /* Direct 8 bit */
3635#define R_TILEPRO_32_PCREL 4 /* PC relative 32 bit */
3636#define R_TILEPRO_16_PCREL 5 /* PC relative 16 bit */
3637#define R_TILEPRO_8_PCREL 6 /* PC relative 8 bit */
3638#define R_TILEPRO_LO16 7 /* Low 16 bit */
3639#define R_TILEPRO_HI16 8 /* High 16 bit */
3640#define R_TILEPRO_HA16 9 /* High 16 bit, adjusted */
3641#define R_TILEPRO_COPY 10 /* Copy relocation */
3642#define R_TILEPRO_GLOB_DAT 11 /* Create GOT entry */
3643#define R_TILEPRO_JMP_SLOT 12 /* Create PLT entry */
3644#define R_TILEPRO_RELATIVE 13 /* Adjust by program base */
3645#define R_TILEPRO_BROFF_X1 14 /* X1 pipe branch offset */
3646#define R_TILEPRO_JOFFLONG_X1 15 /* X1 pipe jump offset */
3647#define R_TILEPRO_JOFFLONG_X1_PLT 16 /* X1 pipe jump offset to PLT */
3648#define R_TILEPRO_IMM8_X0 17 /* X0 pipe 8-bit */
3649#define R_TILEPRO_IMM8_Y0 18 /* Y0 pipe 8-bit */
3650#define R_TILEPRO_IMM8_X1 19 /* X1 pipe 8-bit */
3651#define R_TILEPRO_IMM8_Y1 20 /* Y1 pipe 8-bit */
3652#define R_TILEPRO_MT_IMM15_X1 21 /* X1 pipe mtspr */
3653#define R_TILEPRO_MF_IMM15_X1 22 /* X1 pipe mfspr */
3654#define R_TILEPRO_IMM16_X0 23 /* X0 pipe 16-bit */
3655#define R_TILEPRO_IMM16_X1 24 /* X1 pipe 16-bit */
3656#define R_TILEPRO_IMM16_X0_LO 25 /* X0 pipe low 16-bit */
3657#define R_TILEPRO_IMM16_X1_LO 26 /* X1 pipe low 16-bit */
3658#define R_TILEPRO_IMM16_X0_HI 27 /* X0 pipe high 16-bit */
3659#define R_TILEPRO_IMM16_X1_HI 28 /* X1 pipe high 16-bit */
3660#define R_TILEPRO_IMM16_X0_HA 29 /* X0 pipe high 16-bit, adjusted */
3661#define R_TILEPRO_IMM16_X1_HA 30 /* X1 pipe high 16-bit, adjusted */
3662#define R_TILEPRO_IMM16_X0_PCREL 31 /* X0 pipe PC relative 16 bit */
3663#define R_TILEPRO_IMM16_X1_PCREL 32 /* X1 pipe PC relative 16 bit */
3664#define R_TILEPRO_IMM16_X0_LO_PCREL 33 /* X0 pipe PC relative low 16 bit */
3665#define R_TILEPRO_IMM16_X1_LO_PCREL 34 /* X1 pipe PC relative low 16 bit */
3666#define R_TILEPRO_IMM16_X0_HI_PCREL 35 /* X0 pipe PC relative high 16 bit */
3667#define R_TILEPRO_IMM16_X1_HI_PCREL 36 /* X1 pipe PC relative high 16 bit */
3668#define R_TILEPRO_IMM16_X0_HA_PCREL 37 /* X0 pipe PC relative ha() 16 bit */
3669#define R_TILEPRO_IMM16_X1_HA_PCREL 38 /* X1 pipe PC relative ha() 16 bit */
3670#define R_TILEPRO_IMM16_X0_GOT 39 /* X0 pipe 16-bit GOT offset */
3671#define R_TILEPRO_IMM16_X1_GOT 40 /* X1 pipe 16-bit GOT offset */
3672#define R_TILEPRO_IMM16_X0_GOT_LO 41 /* X0 pipe low 16-bit GOT offset */
3673#define R_TILEPRO_IMM16_X1_GOT_LO 42 /* X1 pipe low 16-bit GOT offset */
3674#define R_TILEPRO_IMM16_X0_GOT_HI 43 /* X0 pipe high 16-bit GOT offset */
3675#define R_TILEPRO_IMM16_X1_GOT_HI 44 /* X1 pipe high 16-bit GOT offset */
3676#define R_TILEPRO_IMM16_X0_GOT_HA 45 /* X0 pipe ha() 16-bit GOT offset */
3677#define R_TILEPRO_IMM16_X1_GOT_HA 46 /* X1 pipe ha() 16-bit GOT offset */
3678#define R_TILEPRO_MMSTART_X0 47 /* X0 pipe mm "start" */
3679#define R_TILEPRO_MMEND_X0 48 /* X0 pipe mm "end" */
3680#define R_TILEPRO_MMSTART_X1 49 /* X1 pipe mm "start" */
3681#define R_TILEPRO_MMEND_X1 50 /* X1 pipe mm "end" */
3682#define R_TILEPRO_SHAMT_X0 51 /* X0 pipe shift amount */
3683#define R_TILEPRO_SHAMT_X1 52 /* X1 pipe shift amount */
3684#define R_TILEPRO_SHAMT_Y0 53 /* Y0 pipe shift amount */
3685#define R_TILEPRO_SHAMT_Y1 54 /* Y1 pipe shift amount */
3686#define R_TILEPRO_DEST_IMM8_X1 55 /* X1 pipe destination 8-bit */
3687/* Relocs 56-59 are currently not defined. */
3688#define R_TILEPRO_TLS_GD_CALL 60 /* "jal" for TLS GD */
3689#define R_TILEPRO_IMM8_X0_TLS_GD_ADD 61 /* X0 pipe "addi" for TLS GD */
3690#define R_TILEPRO_IMM8_X1_TLS_GD_ADD 62 /* X1 pipe "addi" for TLS GD */
3691#define R_TILEPRO_IMM8_Y0_TLS_GD_ADD 63 /* Y0 pipe "addi" for TLS GD */
3692#define R_TILEPRO_IMM8_Y1_TLS_GD_ADD 64 /* Y1 pipe "addi" for TLS GD */
3693#define R_TILEPRO_TLS_IE_LOAD 65 /* "lw_tls" for TLS IE */
3694#define R_TILEPRO_IMM16_X0_TLS_GD 66 /* X0 pipe 16-bit TLS GD offset */
3695#define R_TILEPRO_IMM16_X1_TLS_GD 67 /* X1 pipe 16-bit TLS GD offset */
3696#define R_TILEPRO_IMM16_X0_TLS_GD_LO 68 /* X0 pipe low 16-bit TLS GD offset */
3697#define R_TILEPRO_IMM16_X1_TLS_GD_LO 69 /* X1 pipe low 16-bit TLS GD offset */
3698#define R_TILEPRO_IMM16_X0_TLS_GD_HI 70 /* X0 pipe high 16-bit TLS GD offset */
3699#define R_TILEPRO_IMM16_X1_TLS_GD_HI 71 /* X1 pipe high 16-bit TLS GD offset */
3700#define R_TILEPRO_IMM16_X0_TLS_GD_HA 72 /* X0 pipe ha() 16-bit TLS GD offset */
3701#define R_TILEPRO_IMM16_X1_TLS_GD_HA 73 /* X1 pipe ha() 16-bit TLS GD offset */
3702#define R_TILEPRO_IMM16_X0_TLS_IE 74 /* X0 pipe 16-bit TLS IE offset */
3703#define R_TILEPRO_IMM16_X1_TLS_IE 75 /* X1 pipe 16-bit TLS IE offset */
3704#define R_TILEPRO_IMM16_X0_TLS_IE_LO 76 /* X0 pipe low 16-bit TLS IE offset */
3705#define R_TILEPRO_IMM16_X1_TLS_IE_LO 77 /* X1 pipe low 16-bit TLS IE offset */
3706#define R_TILEPRO_IMM16_X0_TLS_IE_HI 78 /* X0 pipe high 16-bit TLS IE offset */
3707#define R_TILEPRO_IMM16_X1_TLS_IE_HI 79 /* X1 pipe high 16-bit TLS IE offset */
3708#define R_TILEPRO_IMM16_X0_TLS_IE_HA 80 /* X0 pipe ha() 16-bit TLS IE offset */
3709#define R_TILEPRO_IMM16_X1_TLS_IE_HA 81 /* X1 pipe ha() 16-bit TLS IE offset */
3710#define R_TILEPRO_TLS_DTPMOD32 82 /* ID of module containing symbol */
3711#define R_TILEPRO_TLS_DTPOFF32 83 /* Offset in TLS block */
3712#define R_TILEPRO_TLS_TPOFF32 84 /* Offset in static TLS block */
3713#define R_TILEPRO_IMM16_X0_TLS_LE 85 /* X0 pipe 16-bit TLS LE offset */
3714#define R_TILEPRO_IMM16_X1_TLS_LE 86 /* X1 pipe 16-bit TLS LE offset */
3715#define R_TILEPRO_IMM16_X0_TLS_LE_LO 87 /* X0 pipe low 16-bit TLS LE offset */
3716#define R_TILEPRO_IMM16_X1_TLS_LE_LO 88 /* X1 pipe low 16-bit TLS LE offset */
3717#define R_TILEPRO_IMM16_X0_TLS_LE_HI 89 /* X0 pipe high 16-bit TLS LE offset */
3718#define R_TILEPRO_IMM16_X1_TLS_LE_HI 90 /* X1 pipe high 16-bit TLS LE offset */
3719#define R_TILEPRO_IMM16_X0_TLS_LE_HA 91 /* X0 pipe ha() 16-bit TLS LE offset */
3720#define R_TILEPRO_IMM16_X1_TLS_LE_HA 92 /* X1 pipe ha() 16-bit TLS LE offset */
3721
3722#define R_TILEPRO_GNU_VTINHERIT 128 /* GNU C++ vtable hierarchy */
3723#define R_TILEPRO_GNU_VTENTRY 129 /* GNU C++ vtable member usage */
3724
3725#define R_TILEPRO_NUM 130
3726
3727
3728/* TILE-Gx relocations. */
3729#define R_TILEGX_NONE 0 /* No reloc */
3730#define R_TILEGX_64 1 /* Direct 64 bit */
3731#define R_TILEGX_32 2 /* Direct 32 bit */
3732#define R_TILEGX_16 3 /* Direct 16 bit */
3733#define R_TILEGX_8 4 /* Direct 8 bit */
3734#define R_TILEGX_64_PCREL 5 /* PC relative 64 bit */
3735#define R_TILEGX_32_PCREL 6 /* PC relative 32 bit */
3736#define R_TILEGX_16_PCREL 7 /* PC relative 16 bit */
3737#define R_TILEGX_8_PCREL 8 /* PC relative 8 bit */
3738#define R_TILEGX_HW0 9 /* hword 0 16-bit */
3739#define R_TILEGX_HW1 10 /* hword 1 16-bit */
3740#define R_TILEGX_HW2 11 /* hword 2 16-bit */
3741#define R_TILEGX_HW3 12 /* hword 3 16-bit */
3742#define R_TILEGX_HW0_LAST 13 /* last hword 0 16-bit */
3743#define R_TILEGX_HW1_LAST 14 /* last hword 1 16-bit */
3744#define R_TILEGX_HW2_LAST 15 /* last hword 2 16-bit */
3745#define R_TILEGX_COPY 16 /* Copy relocation */
3746#define R_TILEGX_GLOB_DAT 17 /* Create GOT entry */
3747#define R_TILEGX_JMP_SLOT 18 /* Create PLT entry */
3748#define R_TILEGX_RELATIVE 19 /* Adjust by program base */
3749#define R_TILEGX_BROFF_X1 20 /* X1 pipe branch offset */
3750#define R_TILEGX_JUMPOFF_X1 21 /* X1 pipe jump offset */
3751#define R_TILEGX_JUMPOFF_X1_PLT 22 /* X1 pipe jump offset to PLT */
3752#define R_TILEGX_IMM8_X0 23 /* X0 pipe 8-bit */
3753#define R_TILEGX_IMM8_Y0 24 /* Y0 pipe 8-bit */
3754#define R_TILEGX_IMM8_X1 25 /* X1 pipe 8-bit */
3755#define R_TILEGX_IMM8_Y1 26 /* Y1 pipe 8-bit */
3756#define R_TILEGX_DEST_IMM8_X1 27 /* X1 pipe destination 8-bit */
3757#define R_TILEGX_MT_IMM14_X1 28 /* X1 pipe mtspr */
3758#define R_TILEGX_MF_IMM14_X1 29 /* X1 pipe mfspr */
3759#define R_TILEGX_MMSTART_X0 30 /* X0 pipe mm "start" */
3760#define R_TILEGX_MMEND_X0 31 /* X0 pipe mm "end" */
3761#define R_TILEGX_SHAMT_X0 32 /* X0 pipe shift amount */
3762#define R_TILEGX_SHAMT_X1 33 /* X1 pipe shift amount */
3763#define R_TILEGX_SHAMT_Y0 34 /* Y0 pipe shift amount */
3764#define R_TILEGX_SHAMT_Y1 35 /* Y1 pipe shift amount */
3765#define R_TILEGX_IMM16_X0_HW0 36 /* X0 pipe hword 0 */
3766#define R_TILEGX_IMM16_X1_HW0 37 /* X1 pipe hword 0 */
3767#define R_TILEGX_IMM16_X0_HW1 38 /* X0 pipe hword 1 */
3768#define R_TILEGX_IMM16_X1_HW1 39 /* X1 pipe hword 1 */
3769#define R_TILEGX_IMM16_X0_HW2 40 /* X0 pipe hword 2 */
3770#define R_TILEGX_IMM16_X1_HW2 41 /* X1 pipe hword 2 */
3771#define R_TILEGX_IMM16_X0_HW3 42 /* X0 pipe hword 3 */
3772#define R_TILEGX_IMM16_X1_HW3 43 /* X1 pipe hword 3 */
3773#define R_TILEGX_IMM16_X0_HW0_LAST 44 /* X0 pipe last hword 0 */
3774#define R_TILEGX_IMM16_X1_HW0_LAST 45 /* X1 pipe last hword 0 */
3775#define R_TILEGX_IMM16_X0_HW1_LAST 46 /* X0 pipe last hword 1 */
3776#define R_TILEGX_IMM16_X1_HW1_LAST 47 /* X1 pipe last hword 1 */
3777#define R_TILEGX_IMM16_X0_HW2_LAST 48 /* X0 pipe last hword 2 */
3778#define R_TILEGX_IMM16_X1_HW2_LAST 49 /* X1 pipe last hword 2 */
3779#define R_TILEGX_IMM16_X0_HW0_PCREL 50 /* X0 pipe PC relative hword 0 */
3780#define R_TILEGX_IMM16_X1_HW0_PCREL 51 /* X1 pipe PC relative hword 0 */
3781#define R_TILEGX_IMM16_X0_HW1_PCREL 52 /* X0 pipe PC relative hword 1 */
3782#define R_TILEGX_IMM16_X1_HW1_PCREL 53 /* X1 pipe PC relative hword 1 */
3783#define R_TILEGX_IMM16_X0_HW2_PCREL 54 /* X0 pipe PC relative hword 2 */
3784#define R_TILEGX_IMM16_X1_HW2_PCREL 55 /* X1 pipe PC relative hword 2 */
3785#define R_TILEGX_IMM16_X0_HW3_PCREL 56 /* X0 pipe PC relative hword 3 */
3786#define R_TILEGX_IMM16_X1_HW3_PCREL 57 /* X1 pipe PC relative hword 3 */
3787#define R_TILEGX_IMM16_X0_HW0_LAST_PCREL 58 /* X0 pipe PC-rel last hword 0 */
3788#define R_TILEGX_IMM16_X1_HW0_LAST_PCREL 59 /* X1 pipe PC-rel last hword 0 */
3789#define R_TILEGX_IMM16_X0_HW1_LAST_PCREL 60 /* X0 pipe PC-rel last hword 1 */
3790#define R_TILEGX_IMM16_X1_HW1_LAST_PCREL 61 /* X1 pipe PC-rel last hword 1 */
3791#define R_TILEGX_IMM16_X0_HW2_LAST_PCREL 62 /* X0 pipe PC-rel last hword 2 */
3792#define R_TILEGX_IMM16_X1_HW2_LAST_PCREL 63 /* X1 pipe PC-rel last hword 2 */
3793#define R_TILEGX_IMM16_X0_HW0_GOT 64 /* X0 pipe hword 0 GOT offset */
3794#define R_TILEGX_IMM16_X1_HW0_GOT 65 /* X1 pipe hword 0 GOT offset */
3795#define R_TILEGX_IMM16_X0_HW0_PLT_PCREL 66 /* X0 pipe PC-rel PLT hword 0 */
3796#define R_TILEGX_IMM16_X1_HW0_PLT_PCREL 67 /* X1 pipe PC-rel PLT hword 0 */
3797#define R_TILEGX_IMM16_X0_HW1_PLT_PCREL 68 /* X0 pipe PC-rel PLT hword 1 */
3798#define R_TILEGX_IMM16_X1_HW1_PLT_PCREL 69 /* X1 pipe PC-rel PLT hword 1 */
3799#define R_TILEGX_IMM16_X0_HW2_PLT_PCREL 70 /* X0 pipe PC-rel PLT hword 2 */
3800#define R_TILEGX_IMM16_X1_HW2_PLT_PCREL 71 /* X1 pipe PC-rel PLT hword 2 */
3801#define R_TILEGX_IMM16_X0_HW0_LAST_GOT 72 /* X0 pipe last hword 0 GOT offset */
3802#define R_TILEGX_IMM16_X1_HW0_LAST_GOT 73 /* X1 pipe last hword 0 GOT offset */
3803#define R_TILEGX_IMM16_X0_HW1_LAST_GOT 74 /* X0 pipe last hword 1 GOT offset */
3804#define R_TILEGX_IMM16_X1_HW1_LAST_GOT 75 /* X1 pipe last hword 1 GOT offset */
3805#define R_TILEGX_IMM16_X0_HW3_PLT_PCREL 76 /* X0 pipe PC-rel PLT hword 3 */
3806#define R_TILEGX_IMM16_X1_HW3_PLT_PCREL 77 /* X1 pipe PC-rel PLT hword 3 */
3807#define R_TILEGX_IMM16_X0_HW0_TLS_GD 78 /* X0 pipe hword 0 TLS GD offset */
3808#define R_TILEGX_IMM16_X1_HW0_TLS_GD 79 /* X1 pipe hword 0 TLS GD offset */
3809#define R_TILEGX_IMM16_X0_HW0_TLS_LE 80 /* X0 pipe hword 0 TLS LE offset */
3810#define R_TILEGX_IMM16_X1_HW0_TLS_LE 81 /* X1 pipe hword 0 TLS LE offset */
3811#define R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE 82 /* X0 pipe last hword 0 LE off */
3812#define R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE 83 /* X1 pipe last hword 0 LE off */
3813#define R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE 84 /* X0 pipe last hword 1 LE off */
3814#define R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE 85 /* X1 pipe last hword 1 LE off */
3815#define R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD 86 /* X0 pipe last hword 0 GD off */
3816#define R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD 87 /* X1 pipe last hword 0 GD off */
3817#define R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD 88 /* X0 pipe last hword 1 GD off */
3818#define R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD 89 /* X1 pipe last hword 1 GD off */
3819/* Relocs 90-91 are currently not defined. */
3820#define R_TILEGX_IMM16_X0_HW0_TLS_IE 92 /* X0 pipe hword 0 TLS IE offset */
3821#define R_TILEGX_IMM16_X1_HW0_TLS_IE 93 /* X1 pipe hword 0 TLS IE offset */
3822#define R_TILEGX_IMM16_X0_HW0_LAST_PLT_PCREL 94 /* X0 pipe PC-rel PLT last hword 0 */
3823#define R_TILEGX_IMM16_X1_HW0_LAST_PLT_PCREL 95 /* X1 pipe PC-rel PLT last hword 0 */
3824#define R_TILEGX_IMM16_X0_HW1_LAST_PLT_PCREL 96 /* X0 pipe PC-rel PLT last hword 1 */
3825#define R_TILEGX_IMM16_X1_HW1_LAST_PLT_PCREL 97 /* X1 pipe PC-rel PLT last hword 1 */
3826#define R_TILEGX_IMM16_X0_HW2_LAST_PLT_PCREL 98 /* X0 pipe PC-rel PLT last hword 2 */
3827#define R_TILEGX_IMM16_X1_HW2_LAST_PLT_PCREL 99 /* X1 pipe PC-rel PLT last hword 2 */
3828#define R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE 100 /* X0 pipe last hword 0 IE off */
3829#define R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE 101 /* X1 pipe last hword 0 IE off */
3830#define R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE 102 /* X0 pipe last hword 1 IE off */
3831#define R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE 103 /* X1 pipe last hword 1 IE off */
3832/* Relocs 104-105 are currently not defined. */
3833#define R_TILEGX_TLS_DTPMOD64 106 /* 64-bit ID of symbol's module */
3834#define R_TILEGX_TLS_DTPOFF64 107 /* 64-bit offset in TLS block */
3835#define R_TILEGX_TLS_TPOFF64 108 /* 64-bit offset in static TLS block */
3836#define R_TILEGX_TLS_DTPMOD32 109 /* 32-bit ID of symbol's module */
3837#define R_TILEGX_TLS_DTPOFF32 110 /* 32-bit offset in TLS block */
3838#define R_TILEGX_TLS_TPOFF32 111 /* 32-bit offset in static TLS block */
3839#define R_TILEGX_TLS_GD_CALL 112 /* "jal" for TLS GD */
3840#define R_TILEGX_IMM8_X0_TLS_GD_ADD 113 /* X0 pipe "addi" for TLS GD */
3841#define R_TILEGX_IMM8_X1_TLS_GD_ADD 114 /* X1 pipe "addi" for TLS GD */
3842#define R_TILEGX_IMM8_Y0_TLS_GD_ADD 115 /* Y0 pipe "addi" for TLS GD */
3843#define R_TILEGX_IMM8_Y1_TLS_GD_ADD 116 /* Y1 pipe "addi" for TLS GD */
3844#define R_TILEGX_TLS_IE_LOAD 117 /* "ld_tls" for TLS IE */
3845#define R_TILEGX_IMM8_X0_TLS_ADD 118 /* X0 pipe "addi" for TLS GD/IE */
3846#define R_TILEGX_IMM8_X1_TLS_ADD 119 /* X1 pipe "addi" for TLS GD/IE */
3847#define R_TILEGX_IMM8_Y0_TLS_ADD 120 /* Y0 pipe "addi" for TLS GD/IE */
3848#define R_TILEGX_IMM8_Y1_TLS_ADD 121 /* Y1 pipe "addi" for TLS GD/IE */
3849
3850#define R_TILEGX_GNU_VTINHERIT 128 /* GNU C++ vtable hierarchy */
3851#define R_TILEGX_GNU_VTENTRY 129 /* GNU C++ vtable member usage */
3852
3853#define R_TILEGX_NUM 130
3854
3855/* RISC-V ELF Flags */
3856#define EF_RISCV_RVC 0x0001
3857#define EF_RISCV_FLOAT_ABI 0x0006
3858#define EF_RISCV_FLOAT_ABI_SOFT 0x0000
3859#define EF_RISCV_FLOAT_ABI_SINGLE 0x0002
3860#define EF_RISCV_FLOAT_ABI_DOUBLE 0x0004
3861#define EF_RISCV_FLOAT_ABI_QUAD 0x0006
3862
3863/* RISC-V relocations. */
3864#define R_RISCV_NONE 0
3865#define R_RISCV_32 1
3866#define R_RISCV_64 2
3867#define R_RISCV_RELATIVE 3
3868#define R_RISCV_COPY 4
3869#define R_RISCV_JUMP_SLOT 5
3870#define R_RISCV_TLS_DTPMOD32 6
3871#define R_RISCV_TLS_DTPMOD64 7
3872#define R_RISCV_TLS_DTPREL32 8
3873#define R_RISCV_TLS_DTPREL64 9
3874#define R_RISCV_TLS_TPREL32 10
3875#define R_RISCV_TLS_TPREL64 11
3876#define R_RISCV_BRANCH 16
3877#define R_RISCV_JAL 17
3878#define R_RISCV_CALL 18
3879#define R_RISCV_CALL_PLT 19
3880#define R_RISCV_GOT_HI20 20
3881#define R_RISCV_TLS_GOT_HI20 21
3882#define R_RISCV_TLS_GD_HI20 22
3883#define R_RISCV_PCREL_HI20 23
3884#define R_RISCV_PCREL_LO12_I 24
3885#define R_RISCV_PCREL_LO12_S 25
3886#define R_RISCV_HI20 26
3887#define R_RISCV_LO12_I 27
3888#define R_RISCV_LO12_S 28
3889#define R_RISCV_TPREL_HI20 29
3890#define R_RISCV_TPREL_LO12_I 30
3891#define R_RISCV_TPREL_LO12_S 31
3892#define R_RISCV_TPREL_ADD 32
3893#define R_RISCV_ADD8 33
3894#define R_RISCV_ADD16 34
3895#define R_RISCV_ADD32 35
3896#define R_RISCV_ADD64 36
3897#define R_RISCV_SUB8 37
3898#define R_RISCV_SUB16 38
3899#define R_RISCV_SUB32 39
3900#define R_RISCV_SUB64 40
3901#define R_RISCV_GNU_VTINHERIT 41
3902#define R_RISCV_GNU_VTENTRY 42
3903#define R_RISCV_ALIGN 43
3904#define R_RISCV_RVC_BRANCH 44
3905#define R_RISCV_RVC_JUMP 45
3906#define R_RISCV_RVC_LUI 46
3907#define R_RISCV_GPREL_I 47
3908#define R_RISCV_GPREL_S 48
3909#define R_RISCV_TPREL_I 49
3910#define R_RISCV_TPREL_S 50
3911#define R_RISCV_RELAX 51
3912#define R_RISCV_SUB6 52
3913#define R_RISCV_SET6 53
3914#define R_RISCV_SET8 54
3915#define R_RISCV_SET16 55
3916#define R_RISCV_SET32 56
3917#define R_RISCV_32_PCREL 57
3918
3919#define R_RISCV_NUM 58
3920
3921/* BPF specific declarations. */
3922
3923#define R_BPF_NONE 0 /* No reloc */
3924#define R_BPF_64_64 1
3925#define R_BPF_64_32 10
3926
3927/* Imagination Meta specific relocations. */
3928
3929#define R_METAG_HIADDR16 0
3930#define R_METAG_LOADDR16 1
3931#define R_METAG_ADDR32 2 /* 32bit absolute address */
3932#define R_METAG_NONE 3 /* No reloc */
3933#define R_METAG_RELBRANCH 4
3934#define R_METAG_GETSETOFF 5
3935
3936/* Backward compatability */
3937#define R_METAG_REG32OP1 6
3938#define R_METAG_REG32OP2 7
3939#define R_METAG_REG32OP3 8
3940#define R_METAG_REG16OP1 9
3941#define R_METAG_REG16OP2 10
3942#define R_METAG_REG16OP3 11
3943#define R_METAG_REG32OP4 12
3944
3945#define R_METAG_HIOG 13
3946#define R_METAG_LOOG 14
3947
3948#define R_METAG_REL8 15
3949#define R_METAG_REL16 16
3950
3951/* GNU */
3952#define R_METAG_GNU_VTINHERIT 30
3953#define R_METAG_GNU_VTENTRY 31
3954
3955/* PIC relocations */
3956#define R_METAG_HI16_GOTOFF 32
3957#define R_METAG_LO16_GOTOFF 33
3958#define R_METAG_GETSET_GOTOFF 34
3959#define R_METAG_GETSET_GOT 35
3960#define R_METAG_HI16_GOTPC 36
3961#define R_METAG_LO16_GOTPC 37
3962#define R_METAG_HI16_PLT 38
3963#define R_METAG_LO16_PLT 39
3964#define R_METAG_RELBRANCH_PLT 40
3965#define R_METAG_GOTOFF 41
3966#define R_METAG_PLT 42
3967#define R_METAG_COPY 43
3968#define R_METAG_JMP_SLOT 44
3969#define R_METAG_RELATIVE 45
3970#define R_METAG_GLOB_DAT 46
3971
3972/* TLS relocations */
3973#define R_METAG_TLS_GD 47
3974#define R_METAG_TLS_LDM 48
3975#define R_METAG_TLS_LDO_HI16 49
3976#define R_METAG_TLS_LDO_LO16 50
3977#define R_METAG_TLS_LDO 51
3978#define R_METAG_TLS_IE 52
3979#define R_METAG_TLS_IENONPIC 53
3980#define R_METAG_TLS_IENONPIC_HI16 54
3981#define R_METAG_TLS_IENONPIC_LO16 55
3982#define R_METAG_TLS_TPOFF 56
3983#define R_METAG_TLS_DTPMOD 57
3984#define R_METAG_TLS_DTPOFF 58
3985#define R_METAG_TLS_LE 59
3986#define R_METAG_TLS_LE_HI16 60
3987#define R_METAG_TLS_LE_LO16 61
3988
3989/* NDS32 relocations. */
3990#define R_NDS32_NONE 0
3991#define R_NDS32_32_RELA 20
3992#define R_NDS32_COPY 39
3993#define R_NDS32_GLOB_DAT 40
3994#define R_NDS32_JMP_SLOT 41
3995#define R_NDS32_RELATIVE 42
3996#define R_NDS32_TLS_TPOFF 102
3997#define R_NDS32_TLS_DESC 119
3998
3999__END_DECLS
4000
4001#endif /* elf.h */
libc/glibc/include/alloca.h created+40
...@@ -0,0 +1,40 @@
1#ifndef _ALLOCA_H
2
3#include <stdlib/alloca.h>
4
5# ifndef _ISOMAC
6
7#include <stackinfo.h>
8
9#undef __alloca
10
11/* Now define the internal interfaces. */
12extern void *__alloca (size_t __size);
13
14#ifdef __GNUC__
15# define __alloca(size) __builtin_alloca (size)
16#endif /* GCC. */
17
18extern int __libc_use_alloca (size_t size) __attribute__ ((const));
19extern int __libc_alloca_cutoff (size_t size) __attribute__ ((const));
20libc_hidden_proto (__libc_alloca_cutoff)
21
22#define __MAX_ALLOCA_CUTOFF 65536
23
24#include <allocalim.h>
25
26#if defined stackinfo_get_sp && defined stackinfo_sub_sp
27# define alloca_account(size, avar) \
28 ({ void *old__ = stackinfo_get_sp (); \
29 void *m__ = __alloca (size); \
30 avar += stackinfo_sub_sp (old__); \
31 m__; })
32#else
33# define alloca_account(size, avar) \
34 ({ size_t s__ = (size); \
35 avar += s__; \
36 __alloca (s__); })
37#endif
38
39# endif /* !_ISOMAC */
40#endif
libc/glibc/include/bits/cpu-set.h created+1
...@@ -0,0 +1 @@
1#include <posix/bits/cpu-set.h>
libc/glibc/include/bits/statx.h created+1
...@@ -0,0 +1 @@
1#include <io/bits/statx.h>
libc/glibc/include/bits/stdlib-float.h created+8
...@@ -0,0 +1,8 @@
1/* No floating-point inline functions in rtld and for the conform tests. */
2#ifdef _ISOMAC
3# include <stdlib/bits/stdlib-float.h>
4#else
5# if !IS_IN (rtld)
6# include <stdlib/bits/stdlib-float.h>
7# endif
8#endif
libc/glibc/include/bits/types.h created+1
...@@ -0,0 +1 @@
1#include <posix/bits/types.h>
libc/glibc/include/bits/types/__locale_t.h created+1
...@@ -0,0 +1 @@
1#include <locale/bits/types/__locale_t.h>
libc/glibc/include/bits/types/clock_t.h created+1
...@@ -0,0 +1 @@
1#include <time/bits/types/clock_t.h>
libc/glibc/include/bits/types/clockid_t.h created+1
...@@ -0,0 +1 @@
1#include <time/bits/types/clockid_t.h>
libc/glibc/include/bits/types/locale_t.h created+1
...@@ -0,0 +1 @@
1#include <locale/bits/types/locale_t.h>
libc/glibc/include/bits/types/sig_atomic_t.h created+1
...@@ -0,0 +1 @@
1#include <signal/bits/types/sig_atomic_t.h>
libc/glibc/include/bits/types/sigset_t.h created+1
...@@ -0,0 +1 @@
1#include <signal/bits/types/sigset_t.h>
libc/glibc/include/bits/types/struct_itimerspec.h created+1
...@@ -0,0 +1 @@
1#include <time/bits/types/struct_itimerspec.h>
libc/glibc/include/bits/types/struct_timespec.h created+1
...@@ -0,0 +1 @@
1#include <time/bits/types/struct_timespec.h>
libc/glibc/include/bits/types/struct_timeval.h created+1
...@@ -0,0 +1 @@
1#include <time/bits/types/struct_timeval.h>
libc/glibc/include/bits/types/struct_tm.h created+1
...@@ -0,0 +1 @@
1#include <time/bits/types/struct_tm.h>
libc/glibc/include/bits/types/time_t.h created+1
...@@ -0,0 +1 @@
1#include <time/bits/types/time_t.h>
libc/glibc/include/bits/types/timer_t.h created+1
...@@ -0,0 +1 @@
1#include <time/bits/types/timer_t.h>
libc/glibc/include/config.h created
libc/glibc/include/dso_handle.h created+3
...@@ -0,0 +1,3 @@
1/* __dso_handle is always defined by either crtbegin.o from GCC or our
2 dso_handle.c. */
3extern void *__dso_handle __attribute__ ((__visibility__ ("hidden")));
libc/glibc/include/elf.h created+29
...@@ -0,0 +1,29 @@
1#ifndef _ELF_H
2#include <elf/elf.h>
3
4#ifndef _ISOMAC
5
6# include <libc-pointer-arith.h>
7
8/* Compute the offset of the note descriptor from size of note entry's
9 owner string and note alignment. */
10# define ELF_NOTE_DESC_OFFSET(namesz, align) \
11 ALIGN_UP (sizeof (ElfW(Nhdr)) + (namesz), (align))
12
13/* Compute the offset of the next note entry from size of note entry's
14 owner string, size of the note descriptor and note alignment. */
15# define ELF_NOTE_NEXT_OFFSET(namesz, descsz, align) \
16 ALIGN_UP (ELF_NOTE_DESC_OFFSET ((namesz), (align)) + (descsz), (align))
17
18/* Some information which is not meant for the public and therefore not
19 in <elf.h>. */
20# include <dl-dtprocnum.h>
21# ifdef DT_1_SUPPORTED_MASK
22# error DT_1_SUPPORTED_MASK is defined!
23# endif
24# define DT_1_SUPPORTED_MASK \
25 (DF_1_NOW | DF_1_NODELETE | DF_1_INITFIRST | DF_1_NOOPEN \
26 | DF_1_ORIGIN | DF_1_NODEFLIB)
27
28#endif /* !_ISOMAC */
29#endif /* elf.h */
libc/glibc/include/endian.h created+17
...@@ -0,0 +1,17 @@
1#include <string/endian.h>
2
3#if defined _LIBC && !defined _ISOMAC
4# if __FLOAT_WORD_ORDER == __BIG_ENDIAN
5# define BIG_ENDI 1
6# undef LITTLE_ENDI
7# define HIGH_HALF 0
8# define LOW_HALF 1
9# else
10# if __FLOAT_WORD_ORDER == __LITTLE_ENDIAN
11# undef BIG_ENDI
12# define LITTLE_ENDI 1
13# define HIGH_HALF 1
14# define LOW_HALF 0
15# endif
16# endif
17#endif
libc/glibc/include/features.h created+477
...@@ -0,0 +1,477 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _FEATURES_H
19#define _FEATURES_H 1
20
21/* These are defined by the user (or the compiler)
22 to specify the desired environment:
23
24 __STRICT_ANSI__ ISO Standard C.
25 _ISOC99_SOURCE Extensions to ISO C89 from ISO C99.
26 _ISOC11_SOURCE Extensions to ISO C99 from ISO C11.
27 __STDC_WANT_LIB_EXT2__
28 Extensions to ISO C99 from TR 27431-2:2010.
29 __STDC_WANT_IEC_60559_BFP_EXT__
30 Extensions to ISO C11 from TS 18661-1:2014.
31 __STDC_WANT_IEC_60559_FUNCS_EXT__
32 Extensions to ISO C11 from TS 18661-4:2015.
33 __STDC_WANT_IEC_60559_TYPES_EXT__
34 Extensions to ISO C11 from TS 18661-3:2015.
35
36 _POSIX_SOURCE IEEE Std 1003.1.
37 _POSIX_C_SOURCE If ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2;
38 if >=199309L, add IEEE Std 1003.1b-1993;
39 if >=199506L, add IEEE Std 1003.1c-1995;
40 if >=200112L, all of IEEE 1003.1-2004
41 if >=200809L, all of IEEE 1003.1-2008
42 _XOPEN_SOURCE Includes POSIX and XPG things. Set to 500 if
43 Single Unix conformance is wanted, to 600 for the
44 sixth revision, to 700 for the seventh revision.
45 _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions.
46 _LARGEFILE_SOURCE Some more functions for correct standard I/O.
47 _LARGEFILE64_SOURCE Additional functionality from LFS for large files.
48 _FILE_OFFSET_BITS=N Select default filesystem interface.
49 _ATFILE_SOURCE Additional *at interfaces.
50 _GNU_SOURCE All of the above, plus GNU extensions.
51 _DEFAULT_SOURCE The default set of features (taking precedence over
52 __STRICT_ANSI__).
53
54 _FORTIFY_SOURCE Add security hardening to many library functions.
55 Set to 1 or 2; 2 performs stricter checks than 1.
56
57 _REENTRANT, _THREAD_SAFE
58 Obsolete; equivalent to _POSIX_C_SOURCE=199506L.
59
60 The `-ansi' switch to the GNU C compiler, and standards conformance
61 options such as `-std=c99', define __STRICT_ANSI__. If none of
62 these are defined, or if _DEFAULT_SOURCE is defined, the default is
63 to have _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to
64 200809L, as well as enabling miscellaneous functions from BSD and
65 SVID. If more than one of these are defined, they accumulate. For
66 example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE together
67 give you ISO C, 1003.1, and 1003.2, but nothing else.
68
69 These are defined by this file and are used by the
70 header files to decide what to declare or define:
71
72 __GLIBC_USE (F) Define things from feature set F. This is defined
73 to 1 or 0; the subsequent macros are either defined
74 or undefined, and those tests should be moved to
75 __GLIBC_USE.
76 __USE_ISOC11 Define ISO C11 things.
77 __USE_ISOC99 Define ISO C99 things.
78 __USE_ISOC95 Define ISO C90 AMD1 (C95) things.
79 __USE_ISOCXX11 Define ISO C++11 things.
80 __USE_POSIX Define IEEE Std 1003.1 things.
81 __USE_POSIX2 Define IEEE Std 1003.2 things.
82 __USE_POSIX199309 Define IEEE Std 1003.1, and .1b things.
83 __USE_POSIX199506 Define IEEE Std 1003.1, .1b, .1c and .1i things.
84 __USE_XOPEN Define XPG things.
85 __USE_XOPEN_EXTENDED Define X/Open Unix things.
86 __USE_UNIX98 Define Single Unix V2 things.
87 __USE_XOPEN2K Define XPG6 things.
88 __USE_XOPEN2KXSI Define XPG6 XSI things.
89 __USE_XOPEN2K8 Define XPG7 things.
90 __USE_XOPEN2K8XSI Define XPG7 XSI things.
91 __USE_LARGEFILE Define correct standard I/O things.
92 __USE_LARGEFILE64 Define LFS things with separate names.
93 __USE_FILE_OFFSET64 Define 64bit interface as default.
94 __USE_MISC Define things from 4.3BSD or System V Unix.
95 __USE_ATFILE Define *at interfaces and AT_* constants for them.
96 __USE_GNU Define GNU extensions.
97 __USE_FORTIFY_LEVEL Additional security measures used, according to level.
98
99 The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are
100 defined by this file unconditionally. `__GNU_LIBRARY__' is provided
101 only for compatibility. All new code should use the other symbols
102 to test for features.
103
104 All macros listed above as possibly being defined by this file are
105 explicitly undefined if they are not explicitly defined.
106 Feature-test macros that are not defined by the user or compiler
107 but are implied by the other feature-test macros defined (or by the
108 lack of any definitions) are defined by the file.
109
110 ISO C feature test macros depend on the definition of the macro
111 when an affected header is included, not when the first system
112 header is included, and so they are handled in
113 <bits/libc-header-start.h>, which does not have a multiple include
114 guard. Feature test macros that can be handled from the first
115 system header included are handled here. */
116
117
118/* Undefine everything, so we get a clean slate. */
119#undef __USE_ISOC11
120#undef __USE_ISOC99
121#undef __USE_ISOC95
122#undef __USE_ISOCXX11
123#undef __USE_POSIX
124#undef __USE_POSIX2
125#undef __USE_POSIX199309
126#undef __USE_POSIX199506
127#undef __USE_XOPEN
128#undef __USE_XOPEN_EXTENDED
129#undef __USE_UNIX98
130#undef __USE_XOPEN2K
131#undef __USE_XOPEN2KXSI
132#undef __USE_XOPEN2K8
133#undef __USE_XOPEN2K8XSI
134#undef __USE_LARGEFILE
135#undef __USE_LARGEFILE64
136#undef __USE_FILE_OFFSET64
137#undef __USE_MISC
138#undef __USE_ATFILE
139#undef __USE_GNU
140#undef __USE_FORTIFY_LEVEL
141#undef __KERNEL_STRICT_NAMES
142#undef __GLIBC_USE_DEPRECATED_GETS
143#undef __GLIBC_USE_DEPRECATED_SCANF
144
145/* Suppress kernel-name space pollution unless user expressedly asks
146 for it. */
147#ifndef _LOOSE_KERNEL_NAMES
148# define __KERNEL_STRICT_NAMES
149#endif
150
151/* Convenience macro to test the version of gcc.
152 Use like this:
153 #if __GNUC_PREREQ (2,8)
154 ... code requiring gcc 2.8 or later ...
155 #endif
156 Note: only works for GCC 2.0 and later, because __GNUC_MINOR__ was
157 added in 2.0. */
158#if defined __GNUC__ && defined __GNUC_MINOR__
159# define __GNUC_PREREQ(maj, min) \
160 ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
161#else
162# define __GNUC_PREREQ(maj, min) 0
163#endif
164
165/* Similarly for clang. Features added to GCC after version 4.2 may
166 or may not also be available in clang, and clang's definitions of
167 __GNUC(_MINOR)__ are fixed at 4 and 2 respectively. Not all such
168 features can be queried via __has_extension/__has_feature. */
169#if defined __clang_major__ && defined __clang_minor__
170# define __glibc_clang_prereq(maj, min) \
171 ((__clang_major__ << 16) + __clang_minor__ >= ((maj) << 16) + (min))
172#else
173# define __glibc_clang_prereq(maj, min) 0
174#endif
175
176/* Whether to use feature set F. */
177#define __GLIBC_USE(F) __GLIBC_USE_ ## F
178
179/* _BSD_SOURCE and _SVID_SOURCE are deprecated aliases for
180 _DEFAULT_SOURCE. If _DEFAULT_SOURCE is present we do not
181 issue a warning; the expectation is that the source is being
182 transitioned to use the new macro. */
183#if (defined _BSD_SOURCE || defined _SVID_SOURCE) \
184 && !defined _DEFAULT_SOURCE
185# warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE"
186# undef _DEFAULT_SOURCE
187# define _DEFAULT_SOURCE 1
188#endif
189
190/* If _GNU_SOURCE was defined by the user, turn on all the other features. */
191#ifdef _GNU_SOURCE
192# undef _ISOC95_SOURCE
193# define _ISOC95_SOURCE 1
194# undef _ISOC99_SOURCE
195# define _ISOC99_SOURCE 1
196# undef _ISOC11_SOURCE
197# define _ISOC11_SOURCE 1
198# undef _POSIX_SOURCE
199# define _POSIX_SOURCE 1
200# undef _POSIX_C_SOURCE
201# define _POSIX_C_SOURCE 200809L
202# undef _XOPEN_SOURCE
203# define _XOPEN_SOURCE 700
204# undef _XOPEN_SOURCE_EXTENDED
205# define _XOPEN_SOURCE_EXTENDED 1
206# undef _LARGEFILE64_SOURCE
207# define _LARGEFILE64_SOURCE 1
208# undef _DEFAULT_SOURCE
209# define _DEFAULT_SOURCE 1
210# undef _ATFILE_SOURCE
211# define _ATFILE_SOURCE 1
212#endif
213
214/* If nothing (other than _GNU_SOURCE and _DEFAULT_SOURCE) is defined,
215 define _DEFAULT_SOURCE. */
216#if (defined _DEFAULT_SOURCE \
217 || (!defined __STRICT_ANSI__ \
218 && !defined _ISOC99_SOURCE && !defined _ISOC11_SOURCE \
219 && !defined _POSIX_SOURCE && !defined _POSIX_C_SOURCE \
220 && !defined _XOPEN_SOURCE))
221# undef _DEFAULT_SOURCE
222# define _DEFAULT_SOURCE 1
223#endif
224
225/* This is to enable the ISO C11 extension. */
226#if (defined _ISOC11_SOURCE \
227 || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 201112L))
228# define __USE_ISOC11 1
229#endif
230
231/* This is to enable the ISO C99 extension. */
232#if (defined _ISOC99_SOURCE || defined _ISOC11_SOURCE \
233 || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L))
234# define __USE_ISOC99 1
235#endif
236
237/* This is to enable the ISO C90 Amendment 1:1995 extension. */
238#if (defined _ISOC99_SOURCE || defined _ISOC11_SOURCE \
239 || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199409L))
240# define __USE_ISOC95 1
241#endif
242
243#ifdef __cplusplus
244/* This is to enable compatibility for ISO C++17. */
245# if __cplusplus >= 201703L
246# define __USE_ISOC11 1
247# endif
248/* This is to enable compatibility for ISO C++11.
249 Check the temporary macro for now, too. */
250# if __cplusplus >= 201103L || defined __GXX_EXPERIMENTAL_CXX0X__
251# define __USE_ISOCXX11 1
252# define __USE_ISOC99 1
253# endif
254#endif
255
256/* If none of the ANSI/POSIX macros are defined, or if _DEFAULT_SOURCE
257 is defined, use POSIX.1-2008 (or another version depending on
258 _XOPEN_SOURCE). */
259#ifdef _DEFAULT_SOURCE
260# if !defined _POSIX_SOURCE && !defined _POSIX_C_SOURCE
261# define __USE_POSIX_IMPLICITLY 1
262# endif
263# undef _POSIX_SOURCE
264# define _POSIX_SOURCE 1
265# undef _POSIX_C_SOURCE
266# define _POSIX_C_SOURCE 200809L
267#endif
268
269#if ((!defined __STRICT_ANSI__ \
270 || (defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) >= 500)) \
271 && !defined _POSIX_SOURCE && !defined _POSIX_C_SOURCE)
272# define _POSIX_SOURCE 1
273# if defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) < 500
274# define _POSIX_C_SOURCE 2
275# elif defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) < 600
276# define _POSIX_C_SOURCE 199506L
277# elif defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) < 700
278# define _POSIX_C_SOURCE 200112L
279# else
280# define _POSIX_C_SOURCE 200809L
281# endif
282# define __USE_POSIX_IMPLICITLY 1
283#endif
284
285/* Some C libraries once required _REENTRANT and/or _THREAD_SAFE to be
286 defined in all multithreaded code. GNU libc has not required this
287 for many years. We now treat them as compatibility synonyms for
288 _POSIX_C_SOURCE=199506L, which is the earliest level of POSIX with
289 comprehensive support for multithreaded code. Using them never
290 lowers the selected level of POSIX conformance, only raises it. */
291#if ((!defined _POSIX_C_SOURCE || (_POSIX_C_SOURCE - 0) < 199506L) \
292 && (defined _REENTRANT || defined _THREAD_SAFE))
293# define _POSIX_SOURCE 1
294# undef _POSIX_C_SOURCE
295# define _POSIX_C_SOURCE 199506L
296#endif
297
298#if (defined _POSIX_SOURCE \
299 || (defined _POSIX_C_SOURCE && _POSIX_C_SOURCE >= 1) \
300 || defined _XOPEN_SOURCE)
301# define __USE_POSIX 1
302#endif
303
304#if defined _POSIX_C_SOURCE && _POSIX_C_SOURCE >= 2 || defined _XOPEN_SOURCE
305# define __USE_POSIX2 1
306#endif
307
308#if defined _POSIX_C_SOURCE && (_POSIX_C_SOURCE - 0) >= 199309L
309# define __USE_POSIX199309 1
310#endif
311
312#if defined _POSIX_C_SOURCE && (_POSIX_C_SOURCE - 0) >= 199506L
313# define __USE_POSIX199506 1
314#endif
315
316#if defined _POSIX_C_SOURCE && (_POSIX_C_SOURCE - 0) >= 200112L
317# define __USE_XOPEN2K 1
318# undef __USE_ISOC95
319# define __USE_ISOC95 1
320# undef __USE_ISOC99
321# define __USE_ISOC99 1
322#endif
323
324#if defined _POSIX_C_SOURCE && (_POSIX_C_SOURCE - 0) >= 200809L
325# define __USE_XOPEN2K8 1
326# undef _ATFILE_SOURCE
327# define _ATFILE_SOURCE 1
328#endif
329
330#ifdef _XOPEN_SOURCE
331# define __USE_XOPEN 1
332# if (_XOPEN_SOURCE - 0) >= 500
333# define __USE_XOPEN_EXTENDED 1
334# define __USE_UNIX98 1
335# undef _LARGEFILE_SOURCE
336# define _LARGEFILE_SOURCE 1
337# if (_XOPEN_SOURCE - 0) >= 600
338# if (_XOPEN_SOURCE - 0) >= 700
339# define __USE_XOPEN2K8 1
340# define __USE_XOPEN2K8XSI 1
341# endif
342# define __USE_XOPEN2K 1
343# define __USE_XOPEN2KXSI 1
344# undef __USE_ISOC95
345# define __USE_ISOC95 1
346# undef __USE_ISOC99
347# define __USE_ISOC99 1
348# endif
349# else
350# ifdef _XOPEN_SOURCE_EXTENDED
351# define __USE_XOPEN_EXTENDED 1
352# endif
353# endif
354#endif
355
356#ifdef _LARGEFILE_SOURCE
357# define __USE_LARGEFILE 1
358#endif
359
360#ifdef _LARGEFILE64_SOURCE
361# define __USE_LARGEFILE64 1
362#endif
363
364#if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS == 64
365# define __USE_FILE_OFFSET64 1
366#endif
367
368#if defined _DEFAULT_SOURCE
369# define __USE_MISC 1
370#endif
371
372#ifdef _ATFILE_SOURCE
373# define __USE_ATFILE 1
374#endif
375
376#ifdef _GNU_SOURCE
377# define __USE_GNU 1
378#endif
379
380#if defined _FORTIFY_SOURCE && _FORTIFY_SOURCE > 0
381# if !defined __OPTIMIZE__ || __OPTIMIZE__ <= 0
382# warning _FORTIFY_SOURCE requires compiling with optimization (-O)
383# elif !__GNUC_PREREQ (4, 1)
384# warning _FORTIFY_SOURCE requires GCC 4.1 or later
385# elif _FORTIFY_SOURCE > 1
386# define __USE_FORTIFY_LEVEL 2
387# else
388# define __USE_FORTIFY_LEVEL 1
389# endif
390#endif
391#ifndef __USE_FORTIFY_LEVEL
392# define __USE_FORTIFY_LEVEL 0
393#endif
394
395/* The function 'gets' existed in C89, but is impossible to use
396 safely. It has been removed from ISO C11 and ISO C++14. Note: for
397 compatibility with various implementations of <cstdio>, this test
398 must consider only the value of __cplusplus when compiling C++. */
399#if defined __cplusplus ? __cplusplus >= 201402L : defined __USE_ISOC11
400# define __GLIBC_USE_DEPRECATED_GETS 0
401#else
402# define __GLIBC_USE_DEPRECATED_GETS 1
403#endif
404
405/* GNU formerly extended the scanf functions with modified format
406 specifiers %as, %aS, and %a[...] that allocate a buffer for the
407 input using malloc. This extension conflicts with ISO C99, which
408 defines %a as a standalone format specifier that reads a floating-
409 point number; moreover, POSIX.1-2008 provides the same feature
410 using the modifier letter 'm' instead (%ms, %mS, %m[...]).
411
412 We now follow C99 unless GNU extensions are active and the compiler
413 is specifically in C89 or C++98 mode (strict or not). For
414 instance, with GCC, -std=gnu11 will have C99-compliant scanf with
415 or without -D_GNU_SOURCE, but -std=c89 -D_GNU_SOURCE will have the
416 old extension. */
417#if defined __USE_GNU && \
418 (defined __cplusplus \
419 ? (__cplusplus < 201103L && !defined __GXX_EXPERIMENTAL_CXX0X__) \
420 : (!defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L))
421# define __GLIBC_USE_DEPRECATED_SCANF 1
422#else
423# define __GLIBC_USE_DEPRECATED_SCANF 0
424#endif
425
426/* Get definitions of __STDC_* predefined macros, if the compiler has
427 not preincluded this header automatically. */
428#include <stdc-predef.h>
429
430/* This macro indicates that the installed library is the GNU C Library.
431 For historic reasons the value now is 6 and this will stay from now
432 on. The use of this variable is deprecated. Use __GLIBC__ and
433 __GLIBC_MINOR__ now (see below) when you want to test for a specific
434 GNU C library version and use the values in <gnu/lib-names.h> to get
435 the sonames of the shared libraries. */
436#undef __GNU_LIBRARY__
437#define __GNU_LIBRARY__ 6
438
439/* Major and minor version number of the GNU C library package. Use
440 these macros to test for features in specific releases. */
441#define __GLIBC__ 2
442#define __GLIBC_MINOR__ 29
443
444#define __GLIBC_PREREQ(maj, min) \
445 ((__GLIBC__ << 16) + __GLIBC_MINOR__ >= ((maj) << 16) + (min))
446
447/* This is here only because every header file already includes this one. */
448#ifndef __ASSEMBLER__
449# ifndef _SYS_CDEFS_H
450# include <sys/cdefs.h>
451# endif
452
453/* If we don't have __REDIRECT, prototypes will be missing if
454 __USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. */
455# if defined __USE_FILE_OFFSET64 && !defined __REDIRECT
456# define __USE_LARGEFILE 1
457# define __USE_LARGEFILE64 1
458# endif
459
460#endif /* !ASSEMBLER */
461
462/* Decide whether we can define 'extern inline' functions in headers. */
463#if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \
464 && !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__ \
465 && defined __extern_inline
466# define __USE_EXTERN_INLINES 1
467#endif
468
469
470/* This is here only because every header file already includes this one.
471 Get the definitions of all the appropriate `__stub_FUNCTION' symbols.
472 <gnu/stubs.h> contains `#define __stub_FUNCTION' when FUNCTION is a stub
473 that will always return failure (and set errno to ENOSYS). */
474#include <gnu/stubs.h>
475
476
477#endif /* features.h */
libc/glibc/include/gnu/stubs.h created+2
...@@ -0,0 +1,2 @@
1/* This is a placeholder used only while compiling libc.
2 The installed gnu/stubs.h file is created by make install. */
libc/glibc/include/libc-modules.h created+44
...@@ -0,0 +1,44 @@
1/* AUTOGENERATED BY gen-libc-modules.awk, DO NOT EDIT. */
2
3#define MODULE_iconvprogs 1
4#define MODULE_iconvdata 2
5#define MODULE_ldconfig 3
6#define MODULE_lddlibc4 4
7#define MODULE_libmemusage 5
8#define MODULE_libSegFault 6
9#define MODULE_libpcprofile 7
10#define MODULE_librpcsvc 8
11#define MODULE_locale_programs 9
12#define MODULE_memusagestat 10
13#define MODULE_nonlib 11
14#define MODULE_nscd 12
15#define MODULE_extramodules 13
16#define MODULE_libnldbl 14
17#define MODULE_libsupport 15
18#define MODULE_testsuite 16
19#define MODULE_LIBS_BEGIN 17
20#define MODULE_rtld 18
21#define MODULE_libc 19
22#define MODULE_libnss_nis 20
23#define MODULE_libBrokenLocale 21
24#define MODULE_libpthread 22
25#define MODULE_libthread_db 23
26#define MODULE_libnss_nisplus 24
27#define MODULE_libcrypt 25
28#define MODULE_libdl 26
29#define MODULE_libgcc_s 27
30#define MODULE_libnss_test1 28
31#define MODULE_libnsl 29
32#define MODULE_libutil 30
33#define MODULE_libnss_ldap 31
34#define MODULE_libnss_test2 32
35#define MODULE_libnss_dns 33
36#define MODULE_libnss_compat 34
37#define MODULE_libmvec 35
38#define MODULE_libresolv 36
39#define MODULE_libnss_db 37
40#define MODULE_libm 38
41#define MODULE_libnss_files 39
42#define MODULE_librt 40
43#define MODULE_libnss_hesiod 41
44#define MODULE_libanl 42
libc/glibc/include/libc-pointer-arith.h created+60
...@@ -0,0 +1,60 @@
1/* Helper macros for pointer arithmetic.
2 Copyright (C) 2012-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _LIBC_POINTER_ARITH_H
20#define _LIBC_POINTER_ARITH_H 1
21
22#include <stdint.h>
23
24/* 1 if 'type' is a pointer type, 0 otherwise. */
25# define __pointer_type(type) (__builtin_classify_type ((type) 0) == 5)
26
27/* intptr_t if P is true, or T if P is false. */
28# define __integer_if_pointer_type_sub(T, P) \
29 __typeof__ (*(0 ? (__typeof__ (0 ? (T *) 0 : (void *) (P))) 0 \
30 : (__typeof__ (0 ? (intptr_t *) 0 : (void *) (!(P)))) 0))
31
32/* intptr_t if EXPR has a pointer type, or the type of EXPR otherwise. */
33# define __integer_if_pointer_type(expr) \
34 __integer_if_pointer_type_sub(__typeof__ ((__typeof__ (expr)) 0), \
35 __pointer_type (__typeof__ (expr)))
36
37/* Cast an integer or a pointer VAL to integer with proper type. */
38# define cast_to_integer(val) ((__integer_if_pointer_type (val)) (val))
39
40/* Align a value by rounding down to closest size.
41 e.g. Using size of 4096, we get this behavior:
42 {4095, 4096, 4097} = {0, 4096, 4096}. */
43#define ALIGN_DOWN(base, size) ((base) & -((__typeof__ (base)) (size)))
44
45/* Align a value by rounding up to closest size.
46 e.g. Using size of 4096, we get this behavior:
47 {4095, 4096, 4097} = {4096, 4096, 8192}.
48
49 Note: The size argument has side effects (expanded multiple times). */
50#define ALIGN_UP(base, size) ALIGN_DOWN ((base) + (size) - 1, (size))
51
52/* Same as ALIGN_DOWN(), but automatically casts when base is a pointer. */
53#define PTR_ALIGN_DOWN(base, size) \
54 ((__typeof__ (base)) ALIGN_DOWN ((uintptr_t) (base), (size)))
55
56/* Same as ALIGN_UP(), but automatically casts when base is a pointer. */
57#define PTR_ALIGN_UP(base, size) \
58 ((__typeof__ (base)) ALIGN_UP ((uintptr_t) (base), (size)))
59
60#endif
libc/glibc/include/libc-symbols.h created+1087
...@@ -0,0 +1,1087 @@
1/* Support macros for making weak and strong aliases for symbols,
2 and for using symbol sets and linker warnings with GNU ld.
3 Copyright (C) 1995-2019 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
19
20#ifndef _LIBC_SYMBOLS_H
21#define _LIBC_SYMBOLS_H 1
22
23/* This file is included implicitly in the compilation of every source file,
24 using -include. It includes config.h. */
25
26/* Enable declarations of GNU extensions, since we are compiling them. */
27#define _GNU_SOURCE 1
28
29#ifdef MODULE_NAME
30
31/* Use `#if IS_IN (module)` to detect what component is being compiled. */
32#define PASTE_NAME1(a,b) a##b
33#define PASTE_NAME(a,b) PASTE_NAME1 (a,b)
34#define IN_MODULE PASTE_NAME (MODULE_, MODULE_NAME)
35#define IS_IN(lib) (IN_MODULE == MODULE_##lib)
36
37/* True if the current module is a versioned library. Versioned
38 library names culled from shlib-versions files are assigned a
39 MODULE_* value greater than MODULE_LIBS_BEGIN. */
40#define IS_IN_LIB (IN_MODULE > MODULE_LIBS_BEGIN)
41
42/* The testsuite, and some other ancillary code, should be compiled against
43 as close an approximation to the installed headers as possible.
44 Defining this symbol disables most internal-use-only declarations
45 provided by this header, and all those provided by other internal
46 wrapper headers. */
47#if IS_IN (testsuite) || defined IS_IN_build || defined __cplusplus
48# define _ISOMAC 1
49#endif
50
51#else
52/* The generation process for a few files created very early in the
53 build (notably libc-modules.h itself) involves preprocessing this
54 header without defining MODULE_NAME. Under these conditions,
55 internal declarations (especially from config.h) must be visible,
56 but IS_IN should always evaluate as false. */
57# define IS_IN(lib) 0
58# define IS_IN_LIB 0
59# define IN_MODULE (-1)
60#endif
61
62#ifndef _ISOMAC
63
64/* This is defined for the compilation of all C library code. features.h
65 tests this to avoid inclusion of stubs.h while compiling the library,
66 before stubs.h has been generated. Some library code that is shared
67 with other packages also tests this symbol to see if it is being
68 compiled as part of the C library. We must define this before including
69 config.h, because it makes some definitions conditional on whether libc
70 itself is being compiled, or just some generator program. */
71#define _LIBC 1
72
73/* Some files must be compiled with optimization on. */
74#if !defined __ASSEMBLER__ && !defined __OPTIMIZE__
75# error "glibc cannot be compiled without optimization"
76#endif
77
78/* -ffast-math cannot be applied to the C library, as it alters the ABI.
79 Some test components that use -ffast-math are currently not part of
80 IS_IN (testsuite) for technical reasons, so we have a secondary override. */
81#if defined __FAST_MATH__ && !defined TEST_FAST_MATH
82# error "glibc must not be compiled with -ffast-math"
83#endif
84
85#include <config.h>
86
87/* When PIC is defined and SHARED isn't defined, we are building PIE
88 by default. */
89#if defined PIC && !defined SHARED
90# define BUILD_PIE_DEFAULT 1
91#else
92# define BUILD_PIE_DEFAULT 0
93#endif
94
95/* Define this for the benefit of portable GNU code that wants to check it.
96 Code that checks with #if will not #include <config.h> again, since we've
97 already done it (and this file is implicitly included in every compile,
98 via -include). Code that checks with #ifdef will #include <config.h>,
99 but that file should always be idempotent (i.e., it's just #define/#undef
100 and nothing else anywhere should be changing the macro state it touches),
101 so it's harmless. */
102#define HAVE_CONFIG_H 0
103
104/* Define these macros for the benefit of portable GNU code that wants to check
105 them. Of course, STDC_HEADERS is never false when building libc! */
106#define STDC_HEADERS 1
107#define HAVE_MBSTATE_T 1
108#define HAVE_MBSRTOWCS 1
109#define HAVE_LIBINTL_H 1
110#define HAVE_WCTYPE_H 1
111#define HAVE_ISWCTYPE 1
112#define ENABLE_NLS 1
113
114/* The symbols in all the user (non-_) macros are C symbols. */
115
116#ifndef __SYMBOL_PREFIX
117# define __SYMBOL_PREFIX
118#endif
119
120#ifndef C_SYMBOL_NAME
121# define C_SYMBOL_NAME(name) name
122#endif
123
124#ifndef ASM_LINE_SEP
125# define ASM_LINE_SEP ;
126#endif
127
128#ifndef __attribute_copy__
129/* Provide an empty definition when cdefs.h is not included. */
130# define __attribute_copy__(arg)
131#endif
132
133#ifndef __ASSEMBLER__
134/* GCC understands weak symbols and aliases; use its interface where
135 possible, instead of embedded assembly language. */
136
137/* Define ALIASNAME as a strong alias for NAME. */
138# define strong_alias(name, aliasname) _strong_alias(name, aliasname)
139# define _strong_alias(name, aliasname) \
140 extern __typeof (name) aliasname __attribute__ ((alias (#name))) \
141 __attribute_copy__ (name);
142
143/* This comes between the return type and function name in
144 a function definition to make that definition weak. */
145# define weak_function __attribute__ ((weak))
146# define weak_const_function __attribute__ ((weak, __const__))
147
148/* Define ALIASNAME as a weak alias for NAME.
149 If weak aliases are not available, this defines a strong alias. */
150# define weak_alias(name, aliasname) _weak_alias (name, aliasname)
151# define _weak_alias(name, aliasname) \
152 extern __typeof (name) aliasname __attribute__ ((weak, alias (#name))) \
153 __attribute_copy__ (name);
154
155/* Same as WEAK_ALIAS, but mark symbol as hidden. */
156# define weak_hidden_alias(name, aliasname) \
157 _weak_hidden_alias (name, aliasname)
158# define _weak_hidden_alias(name, aliasname) \
159 extern __typeof (name) aliasname \
160 __attribute__ ((weak, alias (#name), __visibility__ ("hidden"))) \
161 __attribute_copy__ (name);
162
163/* Declare SYMBOL as weak undefined symbol (resolved to 0 if not defined). */
164# define weak_extern(symbol) _weak_extern (weak symbol)
165# define _weak_extern(expr) _Pragma (#expr)
166
167/* In shared builds, the expression call_function_static_weak
168 (FUNCTION-SYMBOL, ARGUMENTS) invokes FUNCTION-SYMBOL (an
169 identifier) unconditionally, with the (potentially empty) argument
170 list ARGUMENTS. In static builds, if FUNCTION-SYMBOL has a
171 definition, the function is invoked as before; if FUNCTION-SYMBOL
172 is NULL, no call is performed. */
173# ifdef SHARED
174# define call_function_static_weak(func, ...) func (__VA_ARGS__)
175# else /* !SHARED */
176# define call_function_static_weak(func, ...) \
177 ({ \
178 extern __typeof__ (func) func weak_function; \
179 (func != NULL ? func (__VA_ARGS__) : (void)0); \
180 })
181# endif
182
183#else /* __ASSEMBLER__ */
184
185# ifdef HAVE_ASM_SET_DIRECTIVE
186# define strong_alias(original, alias) \
187 .globl C_SYMBOL_NAME (alias) ASM_LINE_SEP \
188 .set C_SYMBOL_NAME (alias),C_SYMBOL_NAME (original)
189# define strong_data_alias(original, alias) strong_alias(original, alias)
190# else
191# define strong_alias(original, alias) \
192 .globl C_SYMBOL_NAME (alias) ASM_LINE_SEP \
193 C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original)
194# define strong_data_alias(original, alias) strong_alias(original, alias)
195# endif
196
197# define weak_alias(original, alias) \
198 .weak C_SYMBOL_NAME (alias) ASM_LINE_SEP \
199 C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original)
200
201# define weak_extern(symbol) \
202 .weak C_SYMBOL_NAME (symbol)
203
204#endif /* __ASSEMBLER__ */
205
206/* Determine the return address. */
207#define RETURN_ADDRESS(nr) \
208 __builtin_extract_return_addr (__builtin_return_address (nr))
209
210/* When a reference to SYMBOL is encountered, the linker will emit a
211 warning message MSG. */
212/* We want the .gnu.warning.SYMBOL section to be unallocated. */
213#define __make_section_unallocated(section_string) \
214 asm (".section " section_string "\n\t.previous");
215
216/* Tacking on "\n\t#" to the section name makes gcc put it's bogus
217 section attributes on what looks like a comment to the assembler. */
218#ifdef HAVE_SECTION_QUOTES
219# define __sec_comment "\"\n\t#\""
220#else
221# define __sec_comment "\n\t#"
222#endif
223#define link_warning(symbol, msg) \
224 __make_section_unallocated (".gnu.warning." #symbol) \
225 static const char __evoke_link_warning_##symbol[] \
226 __attribute__ ((used, section (".gnu.warning." #symbol __sec_comment))) \
227 = msg;
228
229/* A canned warning for sysdeps/stub functions. */
230#define stub_warning(name) \
231 __make_section_unallocated (".gnu.glibc-stub." #name) \
232 link_warning (name, #name " is not implemented and will always fail")
233
234/* Warning for linking functions calling dlopen into static binaries. */
235#ifdef SHARED
236#define static_link_warning(name)
237#else
238#define static_link_warning(name) static_link_warning1(name)
239#define static_link_warning1(name) \
240 link_warning(name, "Using '" #name "' in statically linked applications \
241requires at runtime the shared libraries from the glibc version used \
242for linking")
243#endif
244
245/* Resource Freeing Hooks:
246
247 Normally a process exits and the OS cleans up any allocated
248 memory. However, when tooling like mtrace or valgrind is monitoring
249 the process we need to free all resources that are part of the
250 process in order to provide the consistency required to track
251 memory leaks.
252
253 A single public API exists and is __libc_freeres(), and this is used
254 by applications like valgrind to freee resouces.
255
256 There are 3 cases:
257
258 (a) __libc_freeres
259
260 In this case all you need to do is define the freeing routine:
261
262 foo.c:
263 libfoo_freeres_fn (foo_freeres)
264 {
265 complex_free (mem);
266 }
267
268 This ensures the function is called at the right point to free
269 resources.
270
271 (b) __libc_freeres_ptr
272
273 The framework for (a) iterates over the list of pointers-to-free
274 in (b) and frees them.
275
276 foo.c:
277 libc_freeres_ptr (static char *foo_buffer);
278
279 Freeing these resources alaways happens last and is equivalent
280 to registering a function that does 'free (foo_buffer)'.
281
282 (c) Explicit lists of free routines to call or objects to free.
283
284 It is the intended goal to remove (a) and (b) which have some
285 non-determinism based on link order, and instead use explicit
286 lists of functions and frees to resolve cleanup ordering issues
287 and make it easy to debug and maintain.
288
289 As of today the following subsystems use (c):
290
291 Per-thread cleanup:
292 * malloc/thread-freeres.c
293
294 libdl cleanup:
295 * dlfcn/dlfreeres.c
296
297 libpthread cleanup:
298 * nptl/nptlfreeres.c
299
300 So if you need any shutdown routines to run you should add them
301 directly to the appropriate subsystem's shutdown list. */
302
303/* Resource pointers to free in libc.so. */
304#define libc_freeres_ptr(decl) \
305 __make_section_unallocated ("__libc_freeres_ptrs, \"aw\", %nobits") \
306 decl __attribute__ ((section ("__libc_freeres_ptrs" __sec_comment)))
307
308/* Resource freeing functions from libc.so go in this section. */
309#define __libc_freeres_fn_section \
310 __attribute__ ((section ("__libc_freeres_fn")))
311
312/* Resource freeing functions for libc.so. */
313#define libc_freeres_fn(name) \
314 static void name (void) __attribute_used__ __libc_freeres_fn_section; \
315 text_set_element (__libc_subfreeres, name); \
316 static void name (void)
317
318/* Declare SYMBOL to be TYPE (`function' or `object') of SIZE bytes
319 alias to ORIGINAL, when the assembler supports such declarations
320 (such as in ELF).
321 This is only necessary when defining something in assembly, or playing
322 funny alias games where the size should be other than what the compiler
323 thinks it is. */
324#define declare_symbol_alias(symbol, original, type, size) \
325 declare_symbol_alias_1 (symbol, original, type, size)
326#ifdef __ASSEMBLER__
327# define declare_symbol_alias_1(symbol, original, type, size) \
328 strong_alias (original, symbol); \
329 .type C_SYMBOL_NAME (symbol), %##type; \
330 .size C_SYMBOL_NAME (symbol), size
331#else /* Not __ASSEMBLER__. */
332# define declare_symbol_alias_1(symbol, original, type, size) \
333 asm (".globl " __SYMBOL_PREFIX #symbol \
334 "\n\t" declare_symbol_alias_1_alias (symbol, original) \
335 "\n\t.type " __SYMBOL_PREFIX #symbol ", " \
336 "%" #type \
337 "\n\t.size " __SYMBOL_PREFIX #symbol ", " #size);
338# ifdef HAVE_ASM_SET_DIRECTIVE
339# define declare_symbol_alias_1_alias(symbol, original) \
340 ".set " __SYMBOL_PREFIX #symbol ", " __SYMBOL_PREFIX #original
341# else
342# define declare_symbol_alias_1_alias(symbol, original) \
343 __SYMBOL_PREFIX #symbol " = " __SYMBOL_PREFIX #original
344# endif /* HAVE_ASM_SET_DIRECTIVE */
345#endif /* __ASSEMBLER__ */
346
347
348/*
349
350*/
351
352/* Symbol set support macros. */
353
354/* Make SYMBOL, which is in the text segment, an element of SET. */
355#define text_set_element(set, symbol) _elf_set_element(set, symbol)
356/* Make SYMBOL, which is in the data segment, an element of SET. */
357#define data_set_element(set, symbol) _elf_set_element(set, symbol)
358/* Make SYMBOL, which is in the bss segment, an element of SET. */
359#define bss_set_element(set, symbol) _elf_set_element(set, symbol)
360
361/* These are all done the same way in ELF.
362 There is a new section created for each set. */
363#ifdef SHARED
364/* When building a shared library, make the set section writable,
365 because it will need to be relocated at run time anyway. */
366# define _elf_set_element(set, symbol) \
367 static const void *__elf_set_##set##_element_##symbol##__ \
368 __attribute__ ((used, section (#set))) = &(symbol)
369#else
370# define _elf_set_element(set, symbol) \
371 static const void *const __elf_set_##set##_element_##symbol##__ \
372 __attribute__ ((used, section (#set))) = &(symbol)
373#endif
374
375/* Define SET as a symbol set. This may be required (it is in a.out) to
376 be able to use the set's contents. */
377#define symbol_set_define(set) symbol_set_declare(set)
378
379/* Declare SET for use in this module, if defined in another module.
380 In a shared library, this is always local to that shared object.
381 For static linking, the set might be wholly absent and so we use
382 weak references. */
383#define symbol_set_declare(set) \
384 extern char const __start_##set[] __symbol_set_attribute; \
385 extern char const __stop_##set[] __symbol_set_attribute;
386#ifdef SHARED
387# define __symbol_set_attribute attribute_hidden
388#else
389# define __symbol_set_attribute __attribute__ ((weak))
390#endif
391
392/* Return a pointer (void *const *) to the first element of SET. */
393#define symbol_set_first_element(set) ((void *const *) (&__start_##set))
394
395/* Return true iff PTR (a void *const *) has been incremented
396 past the last element in SET. */
397#define symbol_set_end_p(set, ptr) ((ptr) >= (void *const *) &__stop_##set)
398
399/* Use symbol_version_reference to specify the version a symbol
400 reference should link to. Use symbol_version or
401 default_symbol_version for the definition of a versioned symbol.
402 The difference is that the latter is a no-op in non-shared
403 builds. */
404#ifdef __ASSEMBLER__
405# define symbol_version_reference(real, name, version) \
406 .symver real, name##@##version
407#else /* !__ASSEMBLER__ */
408# define symbol_version_reference(real, name, version) \
409 __asm__ (".symver " #real "," #name "@" #version)
410#endif
411
412#ifdef SHARED
413# define symbol_version(real, name, version) \
414 symbol_version_reference(real, name, version)
415# define default_symbol_version(real, name, version) \
416 _default_symbol_version(real, name, version)
417# ifdef __ASSEMBLER__
418# define _default_symbol_version(real, name, version) \
419 .symver real, name##@##@##version
420# else
421# define _default_symbol_version(real, name, version) \
422 __asm__ (".symver " #real "," #name "@@" #version)
423# endif
424#else
425# define symbol_version(real, name, version)
426# define default_symbol_version(real, name, version) \
427 strong_alias(real, name)
428#endif
429
430#if defined SHARED || defined LIBC_NONSHARED \
431 || (BUILD_PIE_DEFAULT && IS_IN (libc))
432# define attribute_hidden __attribute__ ((visibility ("hidden")))
433#else
434# define attribute_hidden
435#endif
436
437#define attribute_tls_model_ie __attribute__ ((tls_model ("initial-exec")))
438
439#define attribute_relro __attribute__ ((section (".data.rel.ro")))
440
441
442/* Used to disable stack protection in sensitive places, like ifunc
443 resolvers and early static TLS init. */
444#ifdef HAVE_CC_NO_STACK_PROTECTOR
445# define inhibit_stack_protector \
446 __attribute__ ((__optimize__ ("-fno-stack-protector")))
447#else
448# define inhibit_stack_protector
449#endif
450
451/* The following macros are used for PLT bypassing within libc.so
452 (and if needed other libraries similarly).
453 First of all, you need to have the function prototyped somewhere,
454 say in foo/foo.h:
455
456 int foo (int __bar);
457
458 If calls to foo within libc.so should always go to foo defined in libc.so,
459 then in include/foo.h you add:
460
461 libc_hidden_proto (foo)
462
463 line and after the foo function definition:
464
465 int foo (int __bar)
466 {
467 return __bar;
468 }
469 libc_hidden_def (foo)
470
471 or
472
473 int foo (int __bar)
474 {
475 return __bar;
476 }
477 libc_hidden_weak (foo)
478
479 Similarly for global data. If references to foo within libc.so should
480 always go to foo defined in libc.so, then in include/foo.h you add:
481
482 libc_hidden_proto (foo)
483
484 line and after foo's definition:
485
486 int foo = INITIAL_FOO_VALUE;
487 libc_hidden_data_def (foo)
488
489 or
490
491 int foo = INITIAL_FOO_VALUE;
492 libc_hidden_data_weak (foo)
493
494 If foo is normally just an alias (strong or weak) to some other function,
495 you should use the normal strong_alias first, then add libc_hidden_def
496 or libc_hidden_weak:
497
498 int baz (int __bar)
499 {
500 return __bar;
501 }
502 strong_alias (baz, foo)
503 libc_hidden_weak (foo)
504
505 If the function should be internal to multiple objects, say ld.so and
506 libc.so, the best way is to use:
507
508 #if IS_IN (libc) || IS_IN (rtld)
509 hidden_proto (foo)
510 #endif
511
512 in include/foo.h and the normal macros at all function definitions
513 depending on what DSO they belong to.
514
515 If versioned_symbol macro is used to define foo,
516 libc_hidden_ver macro should be used, as in:
517
518 int __real_foo (int __bar)
519 {
520 return __bar;
521 }
522 versioned_symbol (libc, __real_foo, foo, GLIBC_2_1);
523 libc_hidden_ver (__real_foo, foo) */
524
525#if defined SHARED && !defined NO_HIDDEN
526# ifndef __ASSEMBLER__
527# define __hidden_proto_hiddenattr(attrs...) \
528 __attribute__ ((visibility ("hidden"), ##attrs))
529# define hidden_proto(name, attrs...) \
530 __hidden_proto (name, , __GI_##name, ##attrs)
531# define hidden_tls_proto(name, attrs...) \
532 __hidden_proto (name, __thread, __GI_##name, ##attrs)
533# define __hidden_proto(name, thread, internal, attrs...) \
534 extern thread __typeof (name) name __asm__ (__hidden_asmname (#internal)) \
535 __hidden_proto_hiddenattr (attrs);
536# define __hidden_asmname(name) \
537 __hidden_asmname1 (__USER_LABEL_PREFIX__, name)
538# define __hidden_asmname1(prefix, name) __hidden_asmname2(prefix, name)
539# define __hidden_asmname2(prefix, name) #prefix name
540# define __hidden_ver1(local, internal, name) \
541 __hidden_ver2 (, local, internal, name)
542# define __hidden_ver2(thread, local, internal, name) \
543 extern thread __typeof (name) __EI_##name \
544 __asm__(__hidden_asmname (#internal)); \
545 extern thread __typeof (name) __EI_##name \
546 __attribute__((alias (__hidden_asmname (#local)))) \
547 __attribute_copy__ (name)
548# define hidden_ver(local, name) __hidden_ver1(local, __GI_##name, name);
549# define hidden_data_ver(local, name) hidden_ver(local, name)
550# define hidden_def(name) __hidden_ver1(__GI_##name, name, name);
551# define hidden_data_def(name) hidden_def(name)
552# define hidden_tls_def(name) \
553 __hidden_ver2 (__thread, __GI_##name, name, name);
554# define hidden_weak(name) \
555 __hidden_ver1(__GI_##name, name, name) __attribute__((weak));
556# define hidden_data_weak(name) hidden_weak(name)
557# define hidden_nolink(name, lib, version) \
558 __hidden_nolink1 (__GI_##name, __EI_##name, name, VERSION_##lib##_##version)
559# define __hidden_nolink1(local, internal, name, version) \
560 __hidden_nolink2 (local, internal, name, version)
561# define __hidden_nolink2(local, internal, name, version) \
562 extern __typeof (name) internal __attribute__ ((alias (#local))) \
563 __attribute_copy__ (name); \
564 __hidden_nolink3 (local, internal, #name "@" #version)
565# define __hidden_nolink3(local, internal, vername) \
566 __asm__ (".symver " #internal ", " vername);
567# else
568/* For assembly, we need to do the opposite of what we do in C:
569 in assembly gcc __REDIRECT stuff is not in place, so functions
570 are defined by its normal name and we need to create the
571 __GI_* alias to it, in C __REDIRECT causes the function definition
572 to use __GI_* name and we need to add alias to the real name.
573 There is no reason to use hidden_weak over hidden_def in assembly,
574 but we provide it for consistency with the C usage.
575 hidden_proto doesn't make sense for assembly but the equivalent
576 is to call via the HIDDEN_JUMPTARGET macro instead of JUMPTARGET. */
577# define hidden_def(name) strong_alias (name, __GI_##name)
578# define hidden_weak(name) hidden_def (name)
579# define hidden_ver(local, name) strong_alias (local, __GI_##name)
580# define hidden_data_def(name) strong_data_alias (name, __GI_##name)
581# define hidden_tls_def(name) hidden_data_def (name)
582# define hidden_data_weak(name) hidden_data_def (name)
583# define hidden_data_ver(local, name) strong_data_alias (local, __GI_##name)
584# define HIDDEN_JUMPTARGET(name) __GI_##name
585# endif
586#else
587# ifndef __ASSEMBLER__
588# if !defined SHARED && IS_IN (libc) && !defined LIBC_NONSHARED \
589 && (!defined PIC || !defined NO_HIDDEN_EXTERN_FUNC_IN_PIE) \
590 && !defined NO_HIDDEN
591# define __hidden_proto_hiddenattr(attrs...) \
592 __attribute__ ((visibility ("hidden"), ##attrs))
593# define hidden_proto(name, attrs...) \
594 __hidden_proto (name, , name, ##attrs)
595# define hidden_tls_proto(name, attrs...) \
596 __hidden_proto (name, __thread, name, ##attrs)
597# define __hidden_proto(name, thread, internal, attrs...) \
598 extern thread __typeof (name) name __hidden_proto_hiddenattr (attrs);
599# else
600# define hidden_proto(name, attrs...)
601# define hidden_tls_proto(name, attrs...)
602# endif
603# else
604# define HIDDEN_JUMPTARGET(name) JUMPTARGET(name)
605# endif /* Not __ASSEMBLER__ */
606# define hidden_weak(name)
607# define hidden_def(name)
608# define hidden_ver(local, name)
609# define hidden_data_weak(name)
610# define hidden_data_def(name)
611# define hidden_tls_def(name)
612# define hidden_data_ver(local, name)
613# define hidden_nolink(name, lib, version)
614#endif
615
616#if IS_IN (libc)
617# define libc_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
618# define libc_hidden_tls_proto(name, attrs...) hidden_tls_proto (name, ##attrs)
619# define libc_hidden_def(name) hidden_def (name)
620# define libc_hidden_weak(name) hidden_weak (name)
621# ifdef LINK_OBSOLETE_RPC
622 /* libc_hidden_nolink_sunrpc should only get used in sunrpc code. */
623# define libc_hidden_nolink_sunrpc(name, version) hidden_def (name)
624# else
625# define libc_hidden_nolink_sunrpc(name, version) hidden_nolink (name, libc, version)
626# endif
627# define libc_hidden_ver(local, name) hidden_ver (local, name)
628# define libc_hidden_data_def(name) hidden_data_def (name)
629# define libc_hidden_tls_def(name) hidden_tls_def (name)
630# define libc_hidden_data_weak(name) hidden_data_weak (name)
631# define libc_hidden_data_ver(local, name) hidden_data_ver (local, name)
632#else
633# define libc_hidden_proto(name, attrs...)
634# define libc_hidden_tls_proto(name, attrs...)
635# define libc_hidden_def(name)
636# define libc_hidden_weak(name)
637# define libc_hidden_ver(local, name)
638# define libc_hidden_data_def(name)
639# define libc_hidden_tls_def(name)
640# define libc_hidden_data_weak(name)
641# define libc_hidden_data_ver(local, name)
642#endif
643
644#if IS_IN (rtld) && !defined NO_RTLD_HIDDEN
645# define rtld_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
646# define rtld_hidden_tls_proto(name, attrs...) hidden_tls_proto (name, ##attrs)
647# define rtld_hidden_def(name) hidden_def (name)
648# define rtld_hidden_weak(name) hidden_weak (name)
649# define rtld_hidden_ver(local, name) hidden_ver (local, name)
650# define rtld_hidden_data_def(name) hidden_data_def (name)
651# define rtld_hidden_tls_def(name) hidden_tls_def (name)
652# define rtld_hidden_data_weak(name) hidden_data_weak (name)
653# define rtld_hidden_data_ver(local, name) hidden_data_ver (local, name)
654#else
655# define rtld_hidden_proto(name, attrs...)
656# define rtld_hidden_tls_proto(name, attrs...)
657# define rtld_hidden_def(name)
658# define rtld_hidden_weak(name)
659# define rtld_hidden_ver(local, name)
660# define rtld_hidden_data_def(name)
661# define rtld_hidden_tls_def(name)
662# define rtld_hidden_data_weak(name)
663# define rtld_hidden_data_ver(local, name)
664#endif
665
666#if IS_IN (libm)
667# define libm_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
668# define libm_hidden_tls_proto(name, attrs...) hidden_tls_proto (name, ##attrs)
669# define libm_hidden_def(name) hidden_def (name)
670# define libm_hidden_weak(name) hidden_weak (name)
671# define libm_hidden_ver(local, name) hidden_ver (local, name)
672# define libm_hidden_data_def(name) hidden_data_def (name)
673# define libm_hidden_tls_def(name) hidden_tls_def (name)
674# define libm_hidden_data_weak(name) hidden_data_weak (name)
675# define libm_hidden_data_ver(local, name) hidden_data_ver (local, name)
676#else
677# define libm_hidden_proto(name, attrs...)
678# define libm_hidden_tls_proto(name, attrs...)
679# define libm_hidden_def(name)
680# define libm_hidden_weak(name)
681# define libm_hidden_ver(local, name)
682# define libm_hidden_data_def(name)
683# define libm_hidden_tls_def(name)
684# define libm_hidden_data_weak(name)
685# define libm_hidden_data_ver(local, name)
686#endif
687
688#if IS_IN (libmvec)
689# define libmvec_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
690# define libmvec_hidden_tls_proto(name, attrs...) hidden_tls_proto (name, ##attrs)
691# define libmvec_hidden_def(name) hidden_def (name)
692# define libmvec_hidden_weak(name) hidden_weak (name)
693# define libmvec_hidden_ver(local, name) hidden_ver (local, name)
694# define libmvec_hidden_data_def(name) hidden_data_def (name)
695# define libmvec_hidden_tls_def(name) hidden_tls_def (name)
696# define libmvec_hidden_data_weak(name) hidden_data_weak (name)
697# define libmvec_hidden_data_ver(local, name) hidden_data_ver (local, name)
698#else
699# define libmvec_hidden_proto(name, attrs...)
700# define libmvec_hidden_tls_proto(name, attrs...)
701# define libmvec_hidden_def(name)
702# define libmvec_hidden_weak(name)
703# define libmvec_hidden_ver(local, name)
704# define libmvec_hidden_data_def(name)
705# define libmvec_hidden_tls_def(name)
706# define libmvec_hidden_data_weak(name)
707# define libmvec_hidden_data_ver(local, name)
708#endif
709
710#if IS_IN (libresolv)
711# define libresolv_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
712# define libresolv_hidden_tls_proto(name, attrs...) \
713 hidden_tls_proto (name, ##attrs)
714# define libresolv_hidden_def(name) hidden_def (name)
715# define libresolv_hidden_weak(name) hidden_weak (name)
716# define libresolv_hidden_ver(local, name) hidden_ver (local, name)
717# define libresolv_hidden_data_def(name) hidden_data_def (name)
718# define libresolv_hidden_tls_def(name) hidden_tls_def (name)
719# define libresolv_hidden_data_weak(name) hidden_data_weak (name)
720# define libresolv_hidden_data_ver(local, name) hidden_data_ver (local, name)
721#else
722# define libresolv_hidden_proto(name, attrs...)
723# define libresolv_hidden_tls_proto(name, attrs...)
724# define libresolv_hidden_def(name)
725# define libresolv_hidden_weak(name)
726# define libresolv_hidden_ver(local, name)
727# define libresolv_hidden_data_def(name)
728# define libresolv_hidden_tls_def(name)
729# define libresolv_hidden_data_weak(name)
730# define libresolv_hidden_data_ver(local, name)
731#endif
732
733#if IS_IN (librt)
734# define librt_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
735# define librt_hidden_tls_proto(name, attrs...) \
736 hidden_tls_proto (name, ##attrs)
737# define librt_hidden_def(name) hidden_def (name)
738# define librt_hidden_weak(name) hidden_weak (name)
739# define librt_hidden_ver(local, name) hidden_ver (local, name)
740# define librt_hidden_data_def(name) hidden_data_def (name)
741# define librt_hidden_tls_def(name) hidden_tls_def (name)
742# define librt_hidden_data_weak(name) hidden_data_weak (name)
743# define librt_hidden_data_ver(local, name) hidden_data_ver (local, name)
744#else
745# define librt_hidden_proto(name, attrs...)
746# define librt_hidden_tls_proto(name, attrs...)
747# define librt_hidden_def(name)
748# define librt_hidden_weak(name)
749# define librt_hidden_ver(local, name)
750# define librt_hidden_data_def(name)
751# define librt_hidden_tls_def(name)
752# define librt_hidden_data_weak(name)
753# define librt_hidden_data_ver(local, name)
754#endif
755
756#if IS_IN (libdl)
757# define libdl_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
758# define libdl_hidden_tls_proto(name, attrs...) \
759 hidden_tls_proto (name, ##attrs)
760# define libdl_hidden_def(name) hidden_def (name)
761# define libdl_hidden_weak(name) hidden_weak (name)
762# define libdl_hidden_ver(local, name) hidden_ver (local, name)
763# define libdl_hidden_data_def(name) hidden_data_def (name)
764# define libdl_hidden_tls_def(name) hidden_tls_def (name)
765# define libdl_hidden_data_weak(name) hidden_data_weak (name)
766# define libdl_hidden_data_ver(local, name) hidden_data_ver (local, name)
767#else
768# define libdl_hidden_proto(name, attrs...)
769# define libdl_hidden_tls_proto(name, attrs...)
770# define libdl_hidden_def(name)
771# define libdl_hidden_weak(name)
772# define libdl_hidden_ver(local, name)
773# define libdl_hidden_data_def(name)
774# define libdl_hidden_tls_def(name)
775# define libdl_hidden_data_weak(name)
776# define libdl_hidden_data_ver(local, name)
777#endif
778
779#if IS_IN (libnss_files)
780# define libnss_files_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
781# define libnss_files_hidden_tls_proto(name, attrs...) \
782 hidden_tls_proto (name, ##attrs)
783# define libnss_files_hidden_def(name) hidden_def (name)
784# define libnss_files_hidden_weak(name) hidden_weak (name)
785# define libnss_files_hidden_ver(local, name) hidden_ver (local, name)
786# define libnss_files_hidden_data_def(name) hidden_data_def (name)
787# define libnss_files_hidden_tls_def(name) hidden_tls_def (name)
788# define libnss_files_hidden_data_weak(name) hidden_data_weak (name)
789# define libnss_files_hidden_data_ver(local, name) hidden_data_ver(local, name)
790#else
791# define libnss_files_hidden_proto(name, attrs...)
792# define libnss_files_hidden_tls_proto(name, attrs...)
793# define libnss_files_hidden_def(name)
794# define libnss_files_hidden_weak(name)
795# define libnss_files_hidden_ver(local, name)
796# define libnss_files_hidden_data_def(name)
797# define libnss_files_hidden_tls_def(name)
798# define libnss_files_hidden_data_weak(name)
799# define libnss_files_hidden_data_ver(local, name)
800#endif
801
802#if IS_IN (libnsl)
803# define libnsl_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
804# define libnsl_hidden_tls_proto(name, attrs...) \
805 hidden_tls_proto (name, ##attrs)
806# ifdef LINK_OBSOLETE_NSL
807 /* libnsl_hidden_nolink should only get used in libnsl code. */
808# define libnsl_hidden_nolink_def(name, version) libnsl_hidden_def (name)
809# else
810# define libnsl_hidden_nolink_def(name, version) hidden_nolink (name, libnsl, version)
811# endif
812# define libnsl_hidden_def(name) hidden_def (name)
813# define libnsl_hidden_weak(name) hidden_weak (name)
814# define libnsl_hidden_ver(local, name) hidden_ver (local, name)
815# define libnsl_hidden_data_def(name) hidden_data_def (name)
816# define libnsl_hidden_tls_def(name) hidden_tls_def (name)
817# define libnsl_hidden_data_weak(name) hidden_data_weak (name)
818# define libnsl_hidden_data_ver(local, name) hidden_data_ver (local, name)
819#else
820# define libnsl_hidden_proto(name, attrs...)
821# define libnsl_hidden_tls_proto(name, attrs...)
822# define libnsl_hidden_def(name)
823# define libnsl_hidden_weak(name)
824# define libnsl_hidden_ver(local, name)
825# define libnsl_hidden_data_def(name)
826# define libnsl_hidden_tls_def(name)
827# define libnsl_hidden_data_weak(name)
828# define libnsl_hidden_data_ver(local, name)
829#endif
830
831#if IS_IN (libnss_nisplus)
832# define libnss_nisplus_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
833# define libnss_nisplus_hidden_tls_proto(name, attrs...) \
834 hidden_tls_proto (name, ##attrs)
835# define libnss_nisplus_hidden_def(name) hidden_def (name)
836# define libnss_nisplus_hidden_weak(name) hidden_weak (name)
837# define libnss_nisplus_hidden_ver(local, name) hidden_ver (local, name)
838# define libnss_nisplus_hidden_data_def(name) hidden_data_def (name)
839# define libnss_nisplus_hidden_tls_def(name) hidden_tls_def (name)
840# define libnss_nisplus_hidden_data_weak(name) hidden_data_weak (name)
841# define libnss_nisplus_hidden_data_ver(local, name) hidden_data_ver (local, name)
842#else
843# define libnss_nisplus_hidden_proto(name, attrs...)
844# define libnss_nisplus_hidden_tls_proto(name, attrs...)
845# define libnss_nisplus_hidden_def(name)
846# define libnss_nisplus_hidden_weak(name)
847# define libnss_nisplus_hidden_ver(local, name)
848# define libnss_nisplus_hidden_data_def(name)
849# define libnss_nisplus_hidden_tls_def(name)
850# define libnss_nisplus_hidden_data_weak(name)
851# define libnss_nisplus_hidden_data_ver(local, name)
852#endif
853
854#define libc_hidden_builtin_proto(name, attrs...) libc_hidden_proto (name, ##attrs)
855#define libc_hidden_builtin_def(name) libc_hidden_def (name)
856#define libc_hidden_builtin_weak(name) libc_hidden_weak (name)
857#define libc_hidden_builtin_ver(local, name) libc_hidden_ver (local, name)
858#ifdef __ASSEMBLER__
859# define HIDDEN_BUILTIN_JUMPTARGET(name) HIDDEN_JUMPTARGET(name)
860#endif
861
862#if IS_IN (libutil)
863# define libutil_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
864# define libutil_hidden_tls_proto(name, attrs...) \
865 hidden_tls_proto (name, ##attrs)
866# define libutil_hidden_def(name) hidden_def (name)
867# define libutil_hidden_weak(name) hidden_weak (name)
868# define libutil_hidden_ver(local, name) hidden_ver (local, name)
869# define libutil_hidden_data_def(name) hidden_data_def (name)
870# define libutil_hidden_tls_def(name) hidden_tls_def (name)
871# define libutil_hidden_data_weak(name) hidden_data_weak (name)
872# define libutil_hidden_data_ver(local, name) hidden_data_ver (local, name)
873#else
874# define libutil_hidden_proto(name, attrs...)
875# define libutil_hidden_tls_proto(name, attrs...)
876# define libutil_hidden_def(name)
877# define libutil_hidden_weak(name)
878# define libutil_hidden_ver(local, name)
879# define libutil_hidden_data_def(name)
880# define libutil_hidden_tls_def(name)
881# define libutil_hidden_data_weak(name)
882# define libutil_hidden_data_ver(local, name)
883#endif
884
885/* Get some dirty hacks. */
886#include <symbol-hacks.h>
887
888/* Move compatibility symbols out of the way by placing them all in a
889 special section. */
890#ifndef __ASSEMBLER__
891# define attribute_compat_text_section \
892 __attribute__ ((section (".text.compat")))
893# define attribute_compat_data_section \
894 __attribute__ ((section (".data.compat")))
895#else
896# define compat_text_section .section ".text.compat", "ax";
897# define compat_data_section .section ".data.compat", "aw";
898#endif
899
900/* Helper / base macros for indirect function symbols. */
901#define __ifunc_resolver(type_name, name, expr, arg, init, classifier) \
902 classifier inhibit_stack_protector \
903 __typeof (type_name) *name##_ifunc (arg) \
904 { \
905 init (); \
906 __typeof (type_name) *res = expr; \
907 return res; \
908 }
909
910#ifdef HAVE_GCC_IFUNC
911# define __ifunc(type_name, name, expr, arg, init) \
912 extern __typeof (type_name) name __attribute__ \
913 ((ifunc (#name "_ifunc"))); \
914 __ifunc_resolver (type_name, name, expr, arg, init, static)
915
916# define __ifunc_hidden(type_name, name, expr, arg, init) \
917 __ifunc (type_name, name, expr, arg, init)
918#else
919/* Gcc does not support __attribute__ ((ifunc (...))). Use the old behaviour
920 as fallback. But keep in mind that the debug information for the ifunc
921 resolver functions is not correct. It contains the ifunc'ed function as
922 DW_AT_linkage_name. E.g. lldb uses this field and an inferior function
923 call of the ifunc'ed function will fail due to "no matching function for
924 call to ..." because the ifunc'ed function and the resolver function have
925 different signatures. (Gcc support is disabled at least on a ppc64le
926 Ubuntu 14.04 system.) */
927
928# define __ifunc(type_name, name, expr, arg, init) \
929 extern __typeof (type_name) name; \
930 __typeof (type_name) *name##_ifunc (arg) __asm__ (#name); \
931 __ifunc_resolver (type_name, name, expr, arg, init,) \
932 __asm__ (".type " #name ", %gnu_indirect_function");
933
934# define __ifunc_hidden(type_name, name, expr, arg, init) \
935 extern __typeof (type_name) __libc_##name; \
936 __ifunc (type_name, __libc_##name, expr, arg, init) \
937 strong_alias (__libc_##name, name);
938#endif /* !HAVE_GCC_IFUNC */
939
940/* The following macros are used for indirect function symbols in libc.so.
941 First of all, you need to have the function prototyped somewhere,
942 say in foo.h:
943
944 int foo (int __bar);
945
946 If you have an implementation for foo which e.g. uses a special hardware
947 feature which isn't available on all machines where this libc.so will be
948 used but decideable if available at runtime e.g. via hwcaps, you can provide
949 two or multiple implementations of foo:
950
951 int __foo_default (int __bar)
952 {
953 return __bar;
954 }
955
956 int __foo_special (int __bar)
957 {
958 return __bar;
959 }
960
961 If your function foo has no libc_hidden_proto (foo) defined for PLT
962 bypassing, you can use:
963
964 #define INIT_ARCH() unsigned long int hwcap = __GLRO(dl_hwcap);
965
966 libc_ifunc (foo, (hwcap & HWCAP_SPECIAL) ? __foo_special : __foo_default);
967
968 This will define a resolver function for foo which returns __foo_special or
969 __foo_default depending on your specified expression. Please note that you
970 have to define a macro function INIT_ARCH before using libc_ifunc macro as
971 it is called by the resolver function before evaluating the specified
972 expression. In this example it is used to prepare the hwcap variable.
973 The resolver function is assigned to an ifunc'ed symbol foo. Calls to foo
974 from inside or outside of libc.so will be indirected by a PLT call.
975
976 If your function foo has a libc_hidden_proto (foo) defined for PLT bypassing
977 and calls to foo within libc.so should always go to one specific
978 implementation of foo e.g. __foo_default then you have to add:
979
980 __hidden_ver1 (__foo_default, __GI_foo, __foo_default);
981
982 or a tweaked definition of libc_hidden_def macro after the __foo_default
983 function definition. Calls to foo within libc.so will always go directly to
984 __foo_default. Calls to foo from outside libc.so will be indirected by a
985 PLT call to ifunc'ed symbol foo which you have to define in a separate
986 compile unit:
987
988 #define foo __redirect_foo
989 #include <foo.h>
990 #undef foo
991
992 extern __typeof (__redirect_foo) __foo_default attribute_hidden;
993 extern __typeof (__redirect_foo) __foo_special attribute_hidden;
994
995 libc_ifunc_redirected (__redirect_foo, foo,
996 (hwcap & HWCAP_SPECIAL)
997 ? __foo_special
998 : __foo_default);
999
1000 This will define the ifunc'ed symbol foo like above. The redirection of foo
1001 in header file is needed to omit an additional defintion of __GI_foo which
1002 would end in a linker error while linking libc.so. You have to specify
1003 __redirect_foo as first parameter which is used within libc_ifunc_redirected
1004 macro in conjunction with typeof to define the ifunc'ed symbol foo.
1005
1006 If your function foo has a libc_hidden_proto (foo) defined and calls to foo
1007 within or from outside libc.so should go via ifunc'ed symbol, then you have
1008 to use:
1009
1010 libc_ifunc_hidden (foo, foo,
1011 (hwcap & HWCAP_SPECIAL)
1012 ? __foo_special
1013 : __foo_default);
1014 libc_hidden_def (foo)
1015
1016 The first parameter foo of libc_ifunc_hidden macro is used in the same way
1017 as for libc_ifunc_redirected macro. */
1018
1019#define libc_ifunc(name, expr) __ifunc (name, name, expr, void, INIT_ARCH)
1020
1021#define libc_ifunc_redirected(redirected_name, name, expr) \
1022 __ifunc (redirected_name, name, expr, void, INIT_ARCH)
1023
1024#define libc_ifunc_hidden(redirected_name, name, expr) \
1025 __ifunc_hidden (redirected_name, name, expr, void, INIT_ARCH)
1026
1027/* The body of the function is supposed to use __get_cpu_features
1028 which will, if necessary, initialize the data first. */
1029#define libm_ifunc_init()
1030#define libm_ifunc(name, expr) \
1031 __ifunc (name, name, expr, void, libm_ifunc_init)
1032
1033/* Add the compiler optimization to inhibit loop transformation to library
1034 calls. This is used to avoid recursive calls in memset and memmove
1035 default implementations. */
1036#ifdef HAVE_CC_INHIBIT_LOOP_TO_LIBCALL
1037# define inhibit_loop_to_libcall \
1038 __attribute__ ((__optimize__ ("-fno-tree-loop-distribute-patterns")))
1039#else
1040# define inhibit_loop_to_libcall
1041#endif
1042
1043/* These macros facilitate sharing source files with gnulib.
1044
1045 They are here instead of sys/cdefs.h because they should not be
1046 used in public header files.
1047
1048 Their definitions should be kept consistent with the definitions in
1049 gnulib-common.m4, but it is not necessary to cater to old non-GCC
1050 compilers, since they will only be used while building glibc itself.
1051 (Note that _GNUC_PREREQ cannot be used in this file.) */
1052
1053/* Define as a marker that can be attached to declarations that might not
1054 be used. This helps to reduce warnings, such as from
1055 GCC -Wunused-parameter. */
1056#if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
1057# define _GL_UNUSED __attribute__ ((__unused__))
1058#else
1059# define _GL_UNUSED
1060#endif
1061
1062/* gcc supports the "unused" attribute on possibly unused labels, and
1063 g++ has since version 4.5. Note to support C++ as well as C,
1064 _GL_UNUSED_LABEL should be used with a trailing ; */
1065#if !defined __cplusplus || __GNUC__ > 4 \
1066 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
1067# define _GL_UNUSED_LABEL _GL_UNUSED
1068#else
1069# define _GL_UNUSED_LABEL
1070#endif
1071
1072/* The __pure__ attribute was added in gcc 2.96. */
1073#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
1074# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
1075#else
1076# define _GL_ATTRIBUTE_PURE /* empty */
1077#endif
1078
1079/* The __const__ attribute was added in gcc 2.95. */
1080#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)
1081# define _GL_ATTRIBUTE_CONST __attribute__ ((__const__))
1082#else
1083# define _GL_ATTRIBUTE_CONST /* empty */
1084#endif
1085
1086#endif /* !_ISOMAC */
1087#endif /* libc-symbols.h */
libc/glibc/include/pthread.h created+16
...@@ -0,0 +1,16 @@
1#include_next <pthread.h>
2
3#ifndef _ISOMAC
4/* Prototypes repeated instead of using __typeof because pthread.h is
5 included in C++ tests, and declaring functions with __typeof and
6 __THROW doesn't work for C++. */
7extern int __pthread_barrier_init (pthread_barrier_t *__restrict __barrier,
8 const pthread_barrierattr_t *__restrict
9 __attr, unsigned int __count)
10 __THROW __nonnull ((1));
11extern int __pthread_barrier_wait (pthread_barrier_t *__barrier)
12 __THROWNL __nonnull ((1));
13
14/* This function is called to initialize the pthread library. */
15extern void __pthread_initialize (void) __attribute__ ((weak));
16#endif
libc/glibc/include/sched.h created+34
...@@ -0,0 +1,34 @@
1#ifndef _SCHED_H
2#include <posix/sched.h>
3
4#ifndef _ISOMAC
5/* Now define the internal interfaces. */
6extern int __sched_setparam (__pid_t __pid,
7 const struct sched_param *__param);
8libc_hidden_proto (__sched_setparam)
9extern int __sched_getparam (__pid_t __pid, struct sched_param *__param);
10extern int __sched_setscheduler (__pid_t __pid, int __policy,
11 const struct sched_param *__param);
12libc_hidden_proto (__sched_setscheduler)
13extern int __sched_getscheduler (__pid_t __pid);
14extern int __sched_yield (void);
15libc_hidden_proto (__sched_yield)
16extern int __sched_get_priority_max (int __algorithm);
17libc_hidden_proto (__sched_get_priority_max)
18extern int __sched_get_priority_min (int __algorithm);
19libc_hidden_proto (__sched_get_priority_min)
20extern int __sched_rr_get_interval (__pid_t __pid, struct timespec *__t);
21
22/* These are Linux specific. */
23extern int __clone (int (*__fn) (void *__arg), void *__child_stack,
24 int __flags, void *__arg, ...);
25libc_hidden_proto (__clone)
26extern int __clone2 (int (*__fn) (void *__arg), void *__child_stack_base,
27 size_t __child_stack_size, int __flags, void *__arg, ...);
28libc_hidden_proto (__clone2)
29/* NB: Can't use "__typeof__ (getcpu)" since getcpu is Linux specific
30 and Hurd doesn't have it. */
31extern int __getcpu (unsigned int *, unsigned int *);
32libc_hidden_proto (__getcpu)
33#endif
34#endif
libc/glibc/include/setjmp.h created+69
...@@ -0,0 +1,69 @@
1#ifndef _SETJMP_H
2#include <setjmp/setjmp.h>
3
4#ifndef _ISOMAC
5/* Now define the internal interfaces. */
6
7/* Internal machine-dependent function to restore context sans signal mask. */
8extern void __longjmp (__jmp_buf __env, int __val)
9 __attribute__ ((__noreturn__)) attribute_hidden;
10
11extern void ____longjmp_chk (__jmp_buf __env, int __val)
12 __attribute__ ((__noreturn__)) attribute_hidden;
13
14/* Internal function to possibly save the current mask of blocked signals
15 in ENV, and always set the flag saying whether or not it was saved.
16 This is used by the machine-dependent definition of `__sigsetjmp'.
17 Always returns zero, for convenience. */
18extern int __sigjmp_save (jmp_buf __env, int __savemask);
19
20extern void _longjmp_unwind (jmp_buf env, int val);
21
22extern void __libc_siglongjmp (sigjmp_buf env, int val)
23 __attribute__ ((noreturn));
24extern void __libc_longjmp (sigjmp_buf env, int val)
25 __attribute__ ((noreturn));
26
27libc_hidden_proto (_setjmp)
28libc_hidden_proto (__sigsetjmp)
29
30# if IS_IN (rtld) && !defined NO_RTLD_HIDDEN
31extern __typeof (__sigsetjmp) __sigsetjmp attribute_hidden;
32# endif
33
34/* Check jmp_buf sizes, alignments and offsets. */
35# include <stddef.h>
36# include <jmp_buf-macros.h>
37
38# define STR_HELPER(x) #x
39# define STR(x) STR_HELPER(x)
40
41# define TEST_SIZE(type, size) \
42 _Static_assert (sizeof (type) == size, \
43 "size of " #type " != " \
44 STR (size))
45# define TEST_ALIGN(type, align) \
46 _Static_assert (__alignof__ (type) == align , \
47 "align of " #type " != " \
48 STR (align))
49# define TEST_OFFSET(type, member, offset) \
50 _Static_assert (offsetof (type, member) == offset, \
51 "offset of " #member " field of " #type " != " \
52 STR (offset))
53
54/* Check if jmp_buf have the expected sizes. */
55TEST_SIZE (jmp_buf, JMP_BUF_SIZE);
56TEST_SIZE (sigjmp_buf, SIGJMP_BUF_SIZE);
57
58/* Check if jmp_buf have the expected alignments. */
59TEST_ALIGN (jmp_buf, JMP_BUF_ALIGN);
60TEST_ALIGN (sigjmp_buf, SIGJMP_BUF_ALIGN);
61
62/* Check if internal fields in jmp_buf have the expected offsets. */
63TEST_OFFSET (struct __jmp_buf_tag, __mask_was_saved,
64 MASK_WAS_SAVED_OFFSET);
65TEST_OFFSET (struct __jmp_buf_tag, __saved_mask,
66 SAVED_MASK_OFFSET);
67#endif
68
69#endif
libc/glibc/include/signal.h created+63
...@@ -0,0 +1,63 @@
1#ifndef _SIGNAL_H
2# include <signal/signal.h>
3
4# ifndef _ISOMAC
5libc_hidden_proto (sigemptyset)
6libc_hidden_proto (sigfillset)
7libc_hidden_proto (sigaddset)
8libc_hidden_proto (sigdelset)
9libc_hidden_proto (sigismember)
10extern int __sigpause (int sig_or_mask, int is_sig);
11libc_hidden_proto (__sigpause)
12libc_hidden_proto (raise)
13libc_hidden_proto (__libc_current_sigrtmin)
14libc_hidden_proto (__libc_current_sigrtmax)
15libc_hidden_proto (_sys_siglist)
16
17/* Now define the internal interfaces. */
18extern __sighandler_t __bsd_signal (int __sig, __sighandler_t __handler);
19extern int __kill (__pid_t __pid, int __sig);
20libc_hidden_proto (__kill)
21extern int __sigaction (int __sig, const struct sigaction *__restrict __act,
22 struct sigaction *__restrict __oact);
23libc_hidden_proto (__sigaction)
24extern int __sigblock (int __mask);
25libc_hidden_proto (__sigblock)
26extern int __sigsetmask (int __mask);
27extern int __sigprocmask (int __how,
28 const sigset_t *__set, sigset_t *__oset);
29libc_hidden_proto (__sigprocmask)
30extern int __sigsuspend (const sigset_t *__set);
31libc_hidden_proto (__sigsuspend)
32extern int __sigwait (const sigset_t *__set, int *__sig);
33libc_hidden_proto (__sigwait)
34extern int __sigwaitinfo (const sigset_t *__set, siginfo_t *__info);
35libc_hidden_proto (__sigwaitinfo)
36extern int __sigtimedwait (const sigset_t *__set, siginfo_t *__info,
37 const struct timespec *__timeout);
38libc_hidden_proto (__sigtimedwait)
39extern int __sigqueue (__pid_t __pid, int __sig,
40 const union sigval __val);
41#ifdef __USE_MISC
42extern int __sigreturn (struct sigcontext *__scp);
43#endif
44extern int __sigaltstack (const stack_t *__ss,
45 stack_t *__oss);
46libc_hidden_proto (__sigaltstack)
47extern int __libc_sigaction (int sig, const struct sigaction *act,
48 struct sigaction *oact);
49libc_hidden_proto (__libc_sigaction)
50
51extern int __default_sigpause (int mask);
52extern int __xpg_sigpause (int sig);
53
54/* Allocate real-time signal with highest/lowest available priority. */
55extern int __libc_allocate_rtsig (int __high);
56
57# if IS_IN (rtld) && !defined NO_RTLD_HIDDEN
58extern __typeof (__sigaction) __sigaction attribute_hidden;
59extern __typeof (__libc_sigaction) __libc_sigaction attribute_hidden;
60# endif
61
62# endif /* _ISOMAC */
63#endif /* signal.h */
libc/glibc/include/stackinfo.h created+42
...@@ -0,0 +1,42 @@
1/* Details about the machine's stack: wrapper header.
2 Copyright (C) 2014-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _INCLUDE_STACKINFO_H
20#define _INCLUDE_STACKINFO_H 1
21
22/* A sysdeps/.../stackinfo.h file defines details for the CPU.
23 It is obliged to define either _STACK_GROWS_DOWN or _STACK_GROWS_UP. */
24#include_next <stackinfo.h>
25
26#if defined _STACK_GROWS_DOWN && _STACK_GROWS_DOWN
27# ifdef _STACK_GROWS_UP
28# error "stackinfo.h should not define both!"
29# else
30# define _STACK_GROWS_UP 0
31# endif
32#elif defined _STACK_GROWS_UP && _STACK_GROWS_UP
33# ifdef _STACK_GROWS_DOWN
34# error "stackinfo.h should not define both!"
35# else
36# define _STACK_GROWS_DOWN 0
37# endif
38#else
39# error "stackinfo.h must define _STACK_GROWS_UP or _STACK_GROWS_DOWN!"
40#endif
41
42#endif /* include/stackinfo.h */
libc/glibc/include/stap-probe.h created+77
...@@ -0,0 +1,77 @@
1/* Macros for defining Systemtap <sys/sdt.h> static probe points.
2 Copyright (C) 2012-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _STAP_PROBE_H
20#define _STAP_PROBE_H 1
21
22#ifdef USE_STAP_PROBE
23
24# include <sys/sdt.h>
25
26/* Our code uses one macro LIBC_PROBE (name, n, arg1, ..., argn).
27
28 Without USE_STAP_PROBE, that does nothing but evaluates all
29 its arguments (to prevent bit rot, unlike e.g. assert).
30
31 Systemtap's header defines the macros STAP_PROBE (provider, name) and
32 STAP_PROBEn (provider, name, arg1, ..., argn). For "provider" we paste
33 in MODULE_NAME (libc, libpthread, etc.) automagically.
34
35 The format of the arg parameters is discussed here:
36
37 https://sourceware.org/systemtap/wiki/UserSpaceProbeImplementation
38
39 The precise details of how register names are specified is
40 architecture specific and can be found in the gdb and SystemTap
41 source code. */
42
43# define LIBC_PROBE(name, n, ...) \
44 LIBC_PROBE_1 (MODULE_NAME, name, n, ## __VA_ARGS__)
45
46# define LIBC_PROBE_1(lib, name, n, ...) \
47 STAP_PROBE##n (lib, name, ## __VA_ARGS__)
48
49# define STAP_PROBE0 STAP_PROBE
50
51# define LIBC_PROBE_ASM(name, template) \
52 STAP_PROBE_ASM (MODULE_NAME, name, template)
53
54# define LIBC_PROBE_ASM_OPERANDS STAP_PROBE_ASM_OPERANDS
55
56#else /* Not USE_STAP_PROBE. */
57
58# ifndef __ASSEMBLER__
59/* Evaluate all the arguments and verify that N matches their number. */
60# define LIBC_PROBE(name, n, ...) STAP_PROBE##n (__VA_ARGS__)
61
62# define STAP_PROBE0()
63# define STAP_PROBE1(a1)
64# define STAP_PROBE2(a1, a2)
65# define STAP_PROBE3(a1, a2, a3)
66# define STAP_PROBE4(a1, a2, a3, a4)
67
68# else
69# define LIBC_PROBE(name, n, ...) /* Nothing. */
70# endif
71
72# define LIBC_PROBE_ASM(name, template) /* Nothing. */
73# define LIBC_PROBE_ASM_OPERANDS(n, ...) /* Nothing. */
74
75#endif /* USE_STAP_PROBE. */
76
77#endif /* stap-probe.h */
libc/glibc/include/stdc-predef.h created+60
...@@ -0,0 +1,60 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _STDC_PREDEF_H
19#define _STDC_PREDEF_H 1
20
21/* This header is separate from features.h so that the compiler can
22 include it implicitly at the start of every compilation. It must
23 not itself include <features.h> or any other header that includes
24 <features.h> because the implicit include comes before any feature
25 test macros that may be defined in a source file before it first
26 explicitly includes a system header. GCC knows the name of this
27 header in order to preinclude it. */
28
29/* glibc's intent is to support the IEC 559 math functionality, real
30 and complex. If the GCC (4.9 and later) predefined macros
31 specifying compiler intent are available, use them to determine
32 whether the overall intent is to support these features; otherwise,
33 presume an older compiler has intent to support these features and
34 define these macros by default. */
35
36#ifdef __GCC_IEC_559
37# if __GCC_IEC_559 > 0
38# define __STDC_IEC_559__ 1
39# endif
40#else
41# define __STDC_IEC_559__ 1
42#endif
43
44#ifdef __GCC_IEC_559_COMPLEX
45# if __GCC_IEC_559_COMPLEX > 0
46# define __STDC_IEC_559_COMPLEX__ 1
47# endif
48#else
49# define __STDC_IEC_559_COMPLEX__ 1
50#endif
51
52/* wchar_t uses Unicode 10.0.0. Version 10.0 of the Unicode Standard is
53 synchronized with ISO/IEC 10646:2017, fifth edition, plus
54 the following additions from Amendment 1 to the fifth edition:
55 - 56 emoji characters
56 - 285 hentaigana
57 - 3 additional Zanabazar Square characters */
58#define __STDC_ISO_10646__ 201706L
59
60#endif
libc/glibc/include/stdlib.h created+306
...@@ -0,0 +1,306 @@
1#ifndef _STDLIB_H
2
3#ifndef _ISOMAC
4# include <stddef.h>
5#endif
6#include <stdlib/stdlib.h>
7
8/* Now define the internal interfaces. */
9#if !defined _ISOMAC
10# include <sys/stat.h>
11
12extern __typeof (strtol_l) __strtol_l;
13extern __typeof (strtoul_l) __strtoul_l;
14extern __typeof (strtoll_l) __strtoll_l;
15extern __typeof (strtoull_l) __strtoull_l;
16extern __typeof (strtod_l) __strtod_l;
17extern __typeof (strtof_l) __strtof_l;
18extern __typeof (strtold_l) __strtold_l;
19libc_hidden_proto (__strtol_l)
20libc_hidden_proto (__strtoul_l)
21libc_hidden_proto (__strtoll_l)
22libc_hidden_proto (__strtoull_l)
23libc_hidden_proto (__strtod_l)
24libc_hidden_proto (__strtof_l)
25libc_hidden_proto (__strtold_l)
26
27libc_hidden_proto (exit)
28libc_hidden_proto (abort)
29libc_hidden_proto (getenv)
30extern __typeof (secure_getenv) __libc_secure_getenv;
31libc_hidden_proto (__libc_secure_getenv)
32libc_hidden_proto (bsearch)
33libc_hidden_proto (qsort)
34extern __typeof (qsort_r) __qsort_r;
35libc_hidden_proto (__qsort_r)
36libc_hidden_proto (lrand48_r)
37libc_hidden_proto (wctomb)
38
39extern long int __random (void) attribute_hidden;
40extern void __srandom (unsigned int __seed);
41extern char *__initstate (unsigned int __seed, char *__statebuf,
42 size_t __statelen);
43extern char *__setstate (char *__statebuf);
44extern int __random_r (struct random_data *__buf, int32_t *__result)
45 attribute_hidden;
46extern int __srandom_r (unsigned int __seed, struct random_data *__buf)
47 attribute_hidden;
48extern int __initstate_r (unsigned int __seed, char *__statebuf,
49 size_t __statelen, struct random_data *__buf)
50 attribute_hidden;
51extern int __setstate_r (char *__statebuf, struct random_data *__buf)
52 attribute_hidden;
53extern int __rand_r (unsigned int *__seed);
54extern int __erand48_r (unsigned short int __xsubi[3],
55 struct drand48_data *__buffer, double *__result)
56 attribute_hidden;
57extern int __nrand48_r (unsigned short int __xsubi[3],
58 struct drand48_data *__buffer,
59 long int *__result) attribute_hidden;
60extern int __jrand48_r (unsigned short int __xsubi[3],
61 struct drand48_data *__buffer,
62 long int *__result) attribute_hidden;
63extern int __srand48_r (long int __seedval,
64 struct drand48_data *__buffer) attribute_hidden;
65extern int __seed48_r (unsigned short int __seed16v[3],
66 struct drand48_data *__buffer) attribute_hidden;
67extern int __lcong48_r (unsigned short int __param[7],
68 struct drand48_data *__buffer) attribute_hidden;
69
70/* Internal function to compute next state of the generator. */
71extern int __drand48_iterate (unsigned short int __xsubi[3],
72 struct drand48_data *__buffer)
73 attribute_hidden;
74
75/* Global state for non-reentrant functions. Defined in drand48-iter.c. */
76extern struct drand48_data __libc_drand48_data attribute_hidden;
77
78extern int __setenv (const char *__name, const char *__value, int __replace)
79 attribute_hidden;
80extern int __unsetenv (const char *__name) attribute_hidden;
81extern int __clearenv (void) attribute_hidden;
82extern char *__mktemp (char *__template) __THROW __nonnull ((1));
83extern char *__canonicalize_file_name (const char *__name);
84extern char *__realpath (const char *__name, char *__resolved);
85libc_hidden_proto (__realpath)
86extern int __ptsname_r (int __fd, char *__buf, size_t __buflen)
87 attribute_hidden;
88# ifndef _ISOMAC
89extern int __ptsname_internal (int fd, char *buf, size_t buflen,
90 struct stat64 *stp) attribute_hidden;
91# endif
92extern int __getpt (void);
93extern int __posix_openpt (int __oflag) attribute_hidden;
94
95extern int __add_to_environ (const char *name, const char *value,
96 const char *combines, int replace)
97 attribute_hidden;
98extern void _quicksort (void *const pbase, size_t total_elems,
99 size_t size, __compar_d_fn_t cmp, void *arg);
100
101extern int __on_exit (void (*__func) (int __status, void *__arg), void *__arg);
102
103extern int __cxa_atexit (void (*func) (void *), void *arg, void *d);
104libc_hidden_proto (__cxa_atexit);
105
106extern int __cxa_thread_atexit_impl (void (*func) (void *), void *arg,
107 void *d);
108extern void __call_tls_dtors (void)
109#ifndef SHARED
110 __attribute__ ((weak))
111#endif
112 ;
113libc_hidden_proto (__call_tls_dtors)
114
115extern void __cxa_finalize (void *d);
116
117extern int __posix_memalign (void **memptr, size_t alignment, size_t size);
118
119extern void *__libc_memalign (size_t alignment, size_t size)
120 __attribute_malloc__;
121
122extern void *__libc_reallocarray (void *__ptr, size_t __nmemb, size_t __size)
123 __THROW __attribute_warn_unused_result__;
124libc_hidden_proto (__libc_reallocarray)
125
126extern int __libc_system (const char *line);
127
128
129extern double __strtod_internal (const char *__restrict __nptr,
130 char **__restrict __endptr, int __group)
131 __THROW __nonnull ((1)) __wur;
132extern float __strtof_internal (const char *__restrict __nptr,
133 char **__restrict __endptr, int __group)
134 __THROW __nonnull ((1)) __wur;
135extern long double __strtold_internal (const char *__restrict __nptr,
136 char **__restrict __endptr,
137 int __group)
138 __THROW __nonnull ((1)) __wur;
139extern long int __strtol_internal (const char *__restrict __nptr,
140 char **__restrict __endptr,
141 int __base, int __group)
142 __THROW __nonnull ((1)) __wur;
143extern unsigned long int __strtoul_internal (const char *__restrict __nptr,
144 char **__restrict __endptr,
145 int __base, int __group)
146 __THROW __nonnull ((1)) __wur;
147__extension__
148extern long long int __strtoll_internal (const char *__restrict __nptr,
149 char **__restrict __endptr,
150 int __base, int __group)
151 __THROW __nonnull ((1)) __wur;
152__extension__
153extern unsigned long long int __strtoull_internal (const char *
154 __restrict __nptr,
155 char **__restrict __endptr,
156 int __base, int __group)
157 __THROW __nonnull ((1)) __wur;
158libc_hidden_proto (__strtof_internal)
159libc_hidden_proto (__strtod_internal)
160libc_hidden_proto (__strtold_internal)
161libc_hidden_proto (__strtol_internal)
162libc_hidden_proto (__strtoll_internal)
163libc_hidden_proto (__strtoul_internal)
164libc_hidden_proto (__strtoull_internal)
165
166extern double ____strtod_l_internal (const char *__restrict __nptr,
167 char **__restrict __endptr, int __group,
168 locale_t __loc);
169extern float ____strtof_l_internal (const char *__restrict __nptr,
170 char **__restrict __endptr, int __group,
171 locale_t __loc);
172extern long double ____strtold_l_internal (const char *__restrict __nptr,
173 char **__restrict __endptr,
174 int __group, locale_t __loc);
175extern long int ____strtol_l_internal (const char *__restrict __nptr,
176 char **__restrict __endptr,
177 int __base, int __group,
178 locale_t __loc);
179extern unsigned long int ____strtoul_l_internal (const char *
180 __restrict __nptr,
181 char **__restrict __endptr,
182 int __base, int __group,
183 locale_t __loc);
184__extension__
185extern long long int ____strtoll_l_internal (const char *__restrict __nptr,
186 char **__restrict __endptr,
187 int __base, int __group,
188 locale_t __loc);
189__extension__
190extern unsigned long long int ____strtoull_l_internal (const char *
191 __restrict __nptr,
192 char **
193 __restrict __endptr,
194 int __base, int __group,
195 locale_t __loc);
196
197libc_hidden_proto (____strtof_l_internal)
198libc_hidden_proto (____strtod_l_internal)
199libc_hidden_proto (____strtold_l_internal)
200libc_hidden_proto (____strtol_l_internal)
201libc_hidden_proto (____strtoll_l_internal)
202libc_hidden_proto (____strtoul_l_internal)
203libc_hidden_proto (____strtoull_l_internal)
204
205libc_hidden_proto (strtof)
206libc_hidden_proto (strtod)
207libc_hidden_proto (strtold)
208libc_hidden_proto (strtol)
209libc_hidden_proto (strtoll)
210libc_hidden_proto (strtoul)
211libc_hidden_proto (strtoull)
212
213libc_hidden_proto (atoi)
214
215extern float __strtof_nan (const char *, char **, char);
216extern double __strtod_nan (const char *, char **, char);
217extern long double __strtold_nan (const char *, char **, char);
218extern float __wcstof_nan (const wchar_t *, wchar_t **, wchar_t);
219extern double __wcstod_nan (const wchar_t *, wchar_t **, wchar_t);
220extern long double __wcstold_nan (const wchar_t *, wchar_t **, wchar_t);
221
222libc_hidden_proto (__strtof_nan)
223libc_hidden_proto (__strtod_nan)
224libc_hidden_proto (__strtold_nan)
225libc_hidden_proto (__wcstof_nan)
226libc_hidden_proto (__wcstod_nan)
227libc_hidden_proto (__wcstold_nan)
228
229/* Enable _FloatN bits as needed. */
230#include <bits/floatn.h>
231
232#if __HAVE_DISTINCT_FLOAT128
233extern __typeof (strtof128_l) __strtof128_l;
234
235libc_hidden_proto (__strtof128_l)
236libc_hidden_proto (strtof128)
237
238extern _Float128 __strtof128_nan (const char *, char **, char);
239extern _Float128 __wcstof128_nan (const wchar_t *, wchar_t **, wchar_t);
240
241libc_hidden_proto (__strtof128_nan)
242libc_hidden_proto (__wcstof128_nan)
243
244extern _Float128 __strtof128_internal (const char *__restrict __nptr,
245 char **__restrict __endptr,
246 int __group);
247libc_hidden_proto (__strtof128_internal)
248
249extern _Float128 ____strtof128_l_internal (const char *__restrict __nptr,
250 char **__restrict __endptr,
251 int __group, locale_t __loc);
252
253libc_hidden_proto (____strtof128_l_internal)
254#endif
255
256extern char *__ecvt (double __value, int __ndigit, int *__restrict __decpt,
257 int *__restrict __sign);
258extern char *__fcvt (double __value, int __ndigit, int *__restrict __decpt,
259 int *__restrict __sign);
260extern char *__gcvt (double __value, int __ndigit, char *__buf);
261extern int __ecvt_r (double __value, int __ndigit, int *__restrict __decpt,
262 int *__restrict __sign, char *__restrict __buf,
263 size_t __len);
264libc_hidden_proto (__ecvt_r)
265extern int __fcvt_r (double __value, int __ndigit, int *__restrict __decpt,
266 int *__restrict __sign, char *__restrict __buf,
267 size_t __len);
268libc_hidden_proto (__fcvt_r)
269extern char *__qecvt (long double __value, int __ndigit,
270 int *__restrict __decpt, int *__restrict __sign);
271extern char *__qfcvt (long double __value, int __ndigit,
272 int *__restrict __decpt, int *__restrict __sign);
273extern char *__qgcvt (long double __value, int __ndigit, char *__buf);
274extern int __qecvt_r (long double __value, int __ndigit,
275 int *__restrict __decpt, int *__restrict __sign,
276 char *__restrict __buf, size_t __len);
277libc_hidden_proto (__qecvt_r)
278extern int __qfcvt_r (long double __value, int __ndigit,
279 int *__restrict __decpt, int *__restrict __sign,
280 char *__restrict __buf, size_t __len);
281libc_hidden_proto (__qfcvt_r)
282
283# if IS_IN (libc)
284# undef MB_CUR_MAX
285# define MB_CUR_MAX (_NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_MB_CUR_MAX))
286# endif
287
288extern void *__default_morecore (ptrdiff_t) __THROW;
289libc_hidden_proto (__default_morecore)
290
291struct abort_msg_s
292{
293 unsigned int size;
294 char msg[0];
295};
296extern struct abort_msg_s *__abort_msg;
297libc_hidden_proto (__abort_msg)
298
299# if IS_IN (rtld) && !defined NO_RTLD_HIDDEN
300extern __typeof (unsetenv) unsetenv attribute_hidden;
301extern __typeof (__strtoul_internal) __strtoul_internal attribute_hidden;
302# endif
303
304#endif
305
306#endif /* include/stdlib.h */
libc/glibc/include/sys/cdefs.h created+18
...@@ -0,0 +1,18 @@
1#ifndef _SYS_CDEFS_H
2
3#include <misc/sys/cdefs.h>
4
5#ifndef _ISOMAC
6/* The compiler will optimize based on the knowledge the parameter is
7 not NULL. This will omit tests. A robust implementation cannot allow
8 this so when compiling glibc itself we ignore this attribute. */
9# undef __nonnull
10# define __nonnull(params)
11
12extern void __chk_fail (void) __attribute__ ((__noreturn__));
13libc_hidden_proto (__chk_fail)
14rtld_hidden_proto (__chk_fail)
15
16#endif
17
18#endif
libc/glibc/include/sys/param.h created+1
...@@ -0,0 +1 @@
1#include <misc/sys/param.h>
libc/glibc/include/sys/select.h created+18
...@@ -0,0 +1,18 @@
1#ifndef _SYS_SELECT_H
2#include <misc/sys/select.h>
3
4#ifndef _ISOMAC
5/* Now define the internal interfaces. */
6extern int __pselect (int __nfds, fd_set *__readfds,
7 fd_set *__writefds, fd_set *__exceptfds,
8 const struct timespec *__timeout,
9 const __sigset_t *__sigmask);
10
11extern int __select (int __nfds, fd_set *__restrict __readfds,
12 fd_set *__restrict __writefds,
13 fd_set *__restrict __exceptfds,
14 struct timeval *__restrict __timeout);
15libc_hidden_proto (__select)
16
17#endif
18#endif
libc/glibc/include/sys/signal.h created+1
...@@ -0,0 +1 @@
1#include <signal/sys/signal.h>
libc/glibc/include/sys/stat.h created+64
...@@ -0,0 +1,64 @@
1#ifndef _SYS_STAT_H
2#include <io/sys/stat.h>
3
4#ifndef _ISOMAC
5/* Now define the internal interfaces. */
6extern int __stat (const char *__file, struct stat *__buf);
7extern int __fstat (int __fd, struct stat *__buf);
8extern int __lstat (const char *__file, struct stat *__buf);
9extern int __chmod (const char *__file, __mode_t __mode);
10libc_hidden_proto (__chmod)
11extern int __fchmod (int __fd, __mode_t __mode);
12extern __mode_t __umask (__mode_t __mask);
13extern int __mkdir (const char *__path, __mode_t __mode);
14libc_hidden_proto (__mkdir)
15extern int __mknod (const char *__path,
16 __mode_t __mode, __dev_t __dev);
17#if IS_IN (libc) || (IS_IN (rtld) && !defined NO_RTLD_HIDDEN)
18hidden_proto (__fxstat)
19hidden_proto (__fxstat64)
20hidden_proto (__lxstat)
21hidden_proto (__lxstat64)
22hidden_proto (__xstat)
23hidden_proto (__xstat64)
24#endif
25extern __inline__ int __stat (const char *__path, struct stat *__statbuf)
26{
27 return __xstat (_STAT_VER, __path, __statbuf);
28}
29libc_hidden_proto (__xmknod)
30extern __inline__ int __mknod (const char *__path, __mode_t __mode,
31 __dev_t __dev)
32{
33 return __xmknod (_MKNOD_VER, __path, __mode, &__dev);
34}
35libc_hidden_proto (__xmknodat)
36
37libc_hidden_proto (__fxstatat)
38libc_hidden_proto (__fxstatat64)
39
40# if IS_IN (rtld) && !defined NO_RTLD_HIDDEN
41extern __typeof (__fxstatat64) __fxstatat64 attribute_hidden;
42# endif
43
44/* The `stat', `fstat', `lstat' functions have to be handled special since
45 even while not compiling the library with optimization calls to these
46 functions in the shared library must reference the `xstat' etc functions.
47 We have to use macros but we cannot define them in the normal headers
48 since on user level we must use real functions. */
49#define stat(fname, buf) __xstat (_STAT_VER, fname, buf)
50#define lstat(fname, buf) __lxstat (_STAT_VER, fname, buf)
51#define __lstat(fname, buf) __lxstat (_STAT_VER, fname, buf)
52#define lstat64(fname, buf) __lxstat64 (_STAT_VER, fname, buf)
53#define __lstat64(fname, buf) __lxstat64 (_STAT_VER, fname, buf)
54#define stat64(fname, buf) __xstat64 (_STAT_VER, fname, buf)
55#define fstat64(fd, buf) __fxstat64 (_STAT_VER, fd, buf)
56#define __fstat64(fd, buf) __fxstat64 (_STAT_VER, fd, buf)
57#define fstat(fd, buf) __fxstat (_STAT_VER, fd, buf)
58#define __fstat(fd, buf) __fxstat (_STAT_VER, fd, buf)
59#define __fstatat(dfd, fname, buf, flag) \
60 __fxstatat (_STAT_VER, dfd, fname, buf, flag)
61#define __fstatat64(dfd, fname, buf, flag) \
62 __fxstatat64 (_STAT_VER, dfd, fname, buf, flag)
63#endif
64#endif
libc/glibc/include/sys/time.h created+43
...@@ -0,0 +1,43 @@
1/* Time function internal interfaces.
2 Copyright (C) 1997-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SYS_TIME_H
20# include <time/sys/time.h>
21
22# ifndef _ISOMAC
23extern int __gettimeofday (struct timeval *__tv,
24 struct timezone *__tz);
25libc_hidden_proto (__gettimeofday)
26libc_hidden_proto (gettimeofday)
27extern int __settimeofday (const struct timeval *__tv,
28 const struct timezone *__tz)
29 attribute_hidden;
30extern int __adjtime (const struct timeval *__delta,
31 struct timeval *__olddelta);
32extern int __getitimer (enum __itimer_which __which,
33 struct itimerval *__value);
34extern int __setitimer (enum __itimer_which __which,
35 const struct itimerval *__restrict __new,
36 struct itimerval *__restrict __old)
37 attribute_hidden;
38extern int __utimes (const char *__file, const struct timeval __tvp[2])
39 attribute_hidden;
40extern int __futimes (int fd, const struct timeval tvp[2]) attribute_hidden;
41
42# endif
43#endif
libc/glibc/include/sys/types.h created+1
...@@ -0,0 +1 @@
1#include <posix/sys/types.h>
libc/glibc/include/time.h created+159
...@@ -0,0 +1,159 @@
1#ifndef _TIME_H
2#include <time/time.h>
3
4#ifndef _ISOMAC
5# include <bits/types/locale_t.h>
6
7extern __typeof (strftime_l) __strftime_l;
8libc_hidden_proto (__strftime_l)
9extern __typeof (strptime_l) __strptime_l;
10
11libc_hidden_proto (time)
12libc_hidden_proto (asctime)
13libc_hidden_proto (mktime)
14libc_hidden_proto (timelocal)
15libc_hidden_proto (localtime)
16libc_hidden_proto (strftime)
17libc_hidden_proto (strptime)
18
19extern __typeof (clock_getres) __clock_getres;
20extern __typeof (clock_gettime) __clock_gettime;
21libc_hidden_proto (__clock_gettime)
22extern __typeof (clock_settime) __clock_settime;
23extern __typeof (clock_nanosleep) __clock_nanosleep;
24extern __typeof (clock_getcpuclockid) __clock_getcpuclockid;
25
26/* Now define the internal interfaces. */
27struct tm;
28
29/* Defined in mktime.c. */
30extern const unsigned short int __mon_yday[2][13] attribute_hidden;
31
32/* Defined in localtime.c. */
33extern struct tm _tmbuf attribute_hidden;
34
35/* Defined in tzset.c. */
36extern char *__tzstring (const char *string) attribute_hidden;
37
38extern int __use_tzfile attribute_hidden;
39
40extern void __tzfile_read (const char *file, size_t extra,
41 char **extrap) attribute_hidden;
42extern void __tzfile_compute (__time64_t timer, int use_localtime,
43 long int *leap_correct, int *leap_hit,
44 struct tm *tp) attribute_hidden;
45extern void __tzfile_default (const char *std, const char *dst,
46 long int stdoff, long int dstoff)
47 attribute_hidden;
48extern void __tzset_parse_tz (const char *tz) attribute_hidden;
49extern void __tz_compute (__time64_t timer, struct tm *tm, int use_localtime)
50 __THROW attribute_hidden;
51
52/* Subroutine of `mktime'. Return the `time_t' representation of TP and
53 normalize TP, given that a `struct tm *' maps to a `time_t' as performed
54 by FUNC. Record next guess for localtime-gmtime offset in *OFFSET. */
55extern time_t __mktime_internal (struct tm *__tp,
56 struct tm *(*__func) (const time_t *,
57 struct tm *),
58 long int *__offset) attribute_hidden;
59
60#if __TIMESIZE == 64
61# define __ctime64 ctime
62#else
63extern char *__ctime64 (const __time64_t *__timer) __THROW;
64libc_hidden_proto (__ctime64);
65#endif
66
67#if __TIMESIZE == 64
68# define __ctime64_r ctime_r
69#else
70extern char *__ctime64_r (const __time64_t *__restrict __timer,
71 char *__restrict __buf) __THROW;
72libc_hidden_proto (__ctime64_r);
73#endif
74
75#if __TIMESIZE == 64
76# define __localtime64 localtime
77#else
78extern struct tm *__localtime64 (const __time64_t *__timer);
79libc_hidden_proto (__localtime64)
80#endif
81
82extern struct tm *__localtime_r (const time_t *__timer,
83 struct tm *__tp) attribute_hidden;
84
85#if __TIMESIZE == 64
86# define __localtime64_r __localtime_r
87#else
88extern struct tm *__localtime64_r (const __time64_t *__timer,
89 struct tm *__tp);
90libc_hidden_proto (__localtime64_r)
91#endif
92
93extern struct tm *__gmtime_r (const time_t *__restrict __timer,
94 struct tm *__restrict __tp);
95libc_hidden_proto (__gmtime_r)
96
97#if __TIMESIZE == 64
98# define __gmtime64 gmtime
99#else
100extern struct tm *__gmtime64 (const __time64_t *__timer);
101libc_hidden_proto (__gmtime64)
102#endif
103
104#if __TIMESIZE == 64
105# define __gmtime64_r __gmtime_r
106#else
107extern struct tm *__gmtime64_r (const __time64_t *__restrict __timer,
108 struct tm *__restrict __tp);
109libc_hidden_proto (__gmtime64_r);
110#endif
111
112/* Compute the `struct tm' representation of T,
113 offset OFFSET seconds east of UTC,
114 and store year, yday, mon, mday, wday, hour, min, sec into *TP.
115 Return nonzero if successful. */
116extern int __offtime (__time64_t __timer,
117 long int __offset,
118 struct tm *__tp) attribute_hidden;
119
120extern char *__asctime_r (const struct tm *__tp, char *__buf)
121 attribute_hidden;
122extern void __tzset (void) attribute_hidden;
123
124/* Prototype for the internal function to get information based on TZ. */
125extern struct tm *__tz_convert (__time64_t timer, int use_localtime,
126 struct tm *tp) attribute_hidden;
127
128extern int __nanosleep (const struct timespec *__requested_time,
129 struct timespec *__remaining);
130hidden_proto (__nanosleep)
131extern int __getdate_r (const char *__string, struct tm *__resbufp)
132 attribute_hidden;
133
134
135/* Determine CLK_TCK value. */
136extern int __getclktck (void) attribute_hidden;
137
138
139/* strptime support. */
140extern char * __strptime_internal (const char *rp, const char *fmt,
141 struct tm *tm, void *statep,
142 locale_t locparam) attribute_hidden;
143
144#if __TIMESIZE == 64
145# define __difftime64 __difftime
146#else
147extern double __difftime64 (__time64_t time1, __time64_t time0);
148libc_hidden_proto (__difftime64)
149#endif
150
151extern double __difftime (time_t time1, time_t time0);
152
153
154/* Use in the clock_* functions. Size of the field representing the
155 actual clock ID. */
156#define CLOCK_IDFIELD_SIZE 3
157
158#endif
159#endif
libc/glibc/io/bits/statx.h created+91
...@@ -0,0 +1,91 @@
1/* statx-related definitions and declarations.
2 Copyright (C) 2018-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19/* This interface is based on <linux/stat.h> in Linux. */
20
21#ifndef _SYS_STAT_H
22# error Never include <bits/stat.x.h> directly, include <sys/stat.h> instead.
23#endif
24
25struct statx_timestamp
26{
27 __int64_t tv_sec;
28 __uint32_t tv_nsec;
29 __int32_t __statx_timestamp_pad1[1];
30};
31
32/* Warning: The kernel may add additional fields to this struct in the
33 future. Only use this struct for calling the statx function, not
34 for storing data. (Expansion will be controlled by the mask
35 argument of the statx function.) */
36struct statx
37{
38 __uint32_t stx_mask;
39 __uint32_t stx_blksize;
40 __uint64_t stx_attributes;
41 __uint32_t stx_nlink;
42 __uint32_t stx_uid;
43 __uint32_t stx_gid;
44 __uint16_t stx_mode;
45 __uint16_t __statx_pad1[1];
46 __uint64_t stx_ino;
47 __uint64_t stx_size;
48 __uint64_t stx_blocks;
49 __uint64_t stx_attributes_mask;
50 struct statx_timestamp stx_atime;
51 struct statx_timestamp stx_btime;
52 struct statx_timestamp stx_ctime;
53 struct statx_timestamp stx_mtime;
54 __uint32_t stx_rdev_major;
55 __uint32_t stx_rdev_minor;
56 __uint32_t stx_dev_major;
57 __uint32_t stx_dev_minor;
58 __uint64_t __statx_pad2[14];
59};
60
61#define STATX_TYPE 0x0001U
62#define STATX_MODE 0x0002U
63#define STATX_NLINK 0x0004U
64#define STATX_UID 0x0008U
65#define STATX_GID 0x0010U
66#define STATX_ATIME 0x0020U
67#define STATX_MTIME 0x0040U
68#define STATX_CTIME 0x0080U
69#define STATX_INO 0x0100U
70#define STATX_SIZE 0x0200U
71#define STATX_BLOCKS 0x0400U
72#define STATX_BASIC_STATS 0x07ffU
73#define STATX_ALL 0x0fffU
74#define STATX_BTIME 0x0800U
75#define STATX__RESERVED 0x80000000U
76
77#define STATX_ATTR_COMPRESSED 0x0004
78#define STATX_ATTR_IMMUTABLE 0x0010
79#define STATX_ATTR_APPEND 0x0020
80#define STATX_ATTR_NODUMP 0x0040
81#define STATX_ATTR_ENCRYPTED 0x0800
82#define STATX_ATTR_AUTOMOUNT 0x1000
83
84__BEGIN_DECLS
85
86/* Fill *BUF with information about PATH in DIRFD. */
87int statx (int __dirfd, const char *__restrict __path, int __flags,
88 unsigned int __mask, struct statx *__restrict __buf)
89 __THROW __nonnull ((2, 5));
90
91__END_DECLS
libc/glibc/io/fstat.c created+55
...@@ -0,0 +1,55 @@
1/* Copyright (C) 1996-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 In addition to the permissions in the GNU Lesser General Public
10 License, the Free Software Foundation gives you unlimited
11 permission to link the compiled version of this file with other
12 programs, and to distribute those programs without any restriction
13 coming from the use of this file. (The GNU Lesser General Public
14 License restrictions do apply in other respects; for example, they
15 cover modification of the file, and distribution when not linked
16 into another program.)
17
18 Note that people who make modified versions of this file are not
19 obligated to grant this special exception for their modified
20 versions; it is their choice whether to do so. The GNU Lesser
21 General Public License gives permission to release a modified
22 version without this exception; this exception also makes it
23 possible to release a modified version which carries forward this
24 exception.
25
26 The GNU C Library is distributed in the hope that it will be useful,
27 but WITHOUT ANY WARRANTY; without even the implied warranty of
28 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
29 Lesser General Public License for more details.
30
31 You should have received a copy of the GNU Lesser General Public
32 License along with the GNU C Library; if not, see
33 <http://www.gnu.org/licenses/>. */
34
35#include <sys/stat.h>
36
37/* This definition is only used if inlining fails for this function; see
38 the last page of <sys/stat.h>. The real work is done by the `x'
39 function which is passed a version number argument. We arrange in the
40 makefile that when not inlined this function is always statically
41 linked; that way a dynamically-linked executable always encodes the
42 version number corresponding to the data structures it uses, so the `x'
43 functions in the shared library can adapt without needing to recompile
44 all callers. */
45
46#undef fstat
47#undef __fstat
48int
49attribute_hidden
50__fstat (int fd, struct stat *buf)
51{
52 return __fxstat (_STAT_VER, fd, buf);
53}
54
55weak_hidden_alias (__fstat, fstat)
libc/glibc/io/fstat64.c created+52
...@@ -0,0 +1,52 @@
1/* Copyright (C) 1996-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 In addition to the permissions in the GNU Lesser General Public
10 License, the Free Software Foundation gives you unlimited
11 permission to link the compiled version of this file with other
12 programs, and to distribute those programs without any restriction
13 coming from the use of this file. (The GNU Lesser General Public
14 License restrictions do apply in other respects; for example, they
15 cover modification of the file, and distribution when not linked
16 into another program.)
17
18 Note that people who make modified versions of this file are not
19 obligated to grant this special exception for their modified
20 versions; it is their choice whether to do so. The GNU Lesser
21 General Public License gives permission to release a modified
22 version without this exception; this exception also makes it
23 possible to release a modified version which carries forward this
24 exception.
25
26 The GNU C Library is distributed in the hope that it will be useful,
27 but WITHOUT ANY WARRANTY; without even the implied warranty of
28 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
29 Lesser General Public License for more details.
30
31 You should have received a copy of the GNU Lesser General Public
32 License along with the GNU C Library; if not, see
33 <http://www.gnu.org/licenses/>. */
34
35#include <sys/stat.h>
36
37/* This definition is only used if inlining fails for this function; see
38 the last page of <sys/stat.h>. The real work is done by the `x'
39 function which is passed a version number argument. We arrange in the
40 makefile that when not inlined this function is always statically
41 linked; that way a dynamically-linked executable always encodes the
42 version number corresponding to the data structures it uses, so the `x'
43 functions in the shared library can adapt without needing to recompile
44 all callers. */
45
46#undef fstat64
47int
48attribute_hidden
49fstat64 (int fd, struct stat64 *buf)
50{
51 return __fxstat64 (_STAT_VER, fd, buf);
52}
libc/glibc/io/fstatat.c created+52
...@@ -0,0 +1,52 @@
1/* Copyright (C) 2005-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 In addition to the permissions in the GNU Lesser General Public
10 License, the Free Software Foundation gives you unlimited
11 permission to link the compiled version of this file with other
12 programs, and to distribute those programs without any restriction
13 coming from the use of this file. (The GNU Lesser General Public
14 License restrictions do apply in other respects; for example, they
15 cover modification of the file, and distribution when not linked
16 into another program.)
17
18 Note that people who make modified versions of this file are not
19 obligated to grant this special exception for their modified
20 versions; it is their choice whether to do so. The GNU Lesser
21 General Public License gives permission to release a modified
22 version without this exception; this exception also makes it
23 possible to release a modified version which carries forward this
24 exception.
25
26 The GNU C Library is distributed in the hope that it will be useful,
27 but WITHOUT ANY WARRANTY; without even the implied warranty of
28 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
29 Lesser General Public License for more details.
30
31 You should have received a copy of the GNU Lesser General Public
32 License along with the GNU C Library; if not, see
33 <http://www.gnu.org/licenses/>. */
34
35#include <sys/stat.h>
36
37/* This definition is only used if inlining fails for this function; see
38 the last page of <sys/stat.h>. The real work is done by the `x'
39 function which is passed a version number argument. We arrange in the
40 makefile that when not inlined this function is always statically
41 linked; that way a dynamically-linked executable always encodes the
42 version number corresponding to the data structures it uses, so the `x'
43 functions in the shared library can adapt without needing to recompile
44 all callers. */
45
46#undef fstatat
47int
48attribute_hidden
49fstatat (int fd, const char *file, struct stat *buf, int flag)
50{
51 return __fxstatat (_STAT_VER, fd, file, buf, flag);
52}
libc/glibc/io/fstatat64.c created+52
...@@ -0,0 +1,52 @@
1/* Copyright (C) 2005-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 In addition to the permissions in the GNU Lesser General Public
10 License, the Free Software Foundation gives you unlimited
11 permission to link the compiled version of this file with other
12 programs, and to distribute those programs without any restriction
13 coming from the use of this file. (The GNU Lesser General Public
14 License restrictions do apply in other respects; for example, they
15 cover modification of the file, and distribution when not linked
16 into another program.)
17
18 Note that people who make modified versions of this file are not
19 obligated to grant this special exception for their modified
20 versions; it is their choice whether to do so. The GNU Lesser
21 General Public License gives permission to release a modified
22 version without this exception; this exception also makes it
23 possible to release a modified version which carries forward this
24 exception.
25
26 The GNU C Library is distributed in the hope that it will be useful,
27 but WITHOUT ANY WARRANTY; without even the implied warranty of
28 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
29 Lesser General Public License for more details.
30
31 You should have received a copy of the GNU Lesser General Public
32 License along with the GNU C Library; if not, see
33 <http://www.gnu.org/licenses/>. */
34
35#include <sys/stat.h>
36
37/* This definition is only used if inlining fails for this function; see
38 the last page of <sys/stat.h>. The real work is done by the `x'
39 function which is passed a version number argument. We arrange in the
40 makefile that when not inlined this function is always statically
41 linked; that way a dynamically-linked executable always encodes the
42 version number corresponding to the data structures it uses, so the `x'
43 functions in the shared library can adapt without needing to recompile
44 all callers. */
45
46#undef fstatat64
47int
48attribute_hidden
49fstatat64 (int fd, const char *file, struct stat64 *buf, int flag)
50{
51 return __fxstatat64 (_STAT_VER, fd, file, buf, flag);
52}
libc/glibc/io/lstat.c created+55
...@@ -0,0 +1,55 @@
1/* Copyright (C) 1996-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 In addition to the permissions in the GNU Lesser General Public
10 License, the Free Software Foundation gives you unlimited
11 permission to link the compiled version of this file with other
12 programs, and to distribute those programs without any restriction
13 coming from the use of this file. (The GNU Lesser General Public
14 License restrictions do apply in other respects; for example, they
15 cover modification of the file, and distribution when not linked
16 into another program.)
17
18 Note that people who make modified versions of this file are not
19 obligated to grant this special exception for their modified
20 versions; it is their choice whether to do so. The GNU Lesser
21 General Public License gives permission to release a modified
22 version without this exception; this exception also makes it
23 possible to release a modified version which carries forward this
24 exception.
25
26 The GNU C Library is distributed in the hope that it will be useful,
27 but WITHOUT ANY WARRANTY; without even the implied warranty of
28 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
29 Lesser General Public License for more details.
30
31 You should have received a copy of the GNU Lesser General Public
32 License along with the GNU C Library; if not, see
33 <http://www.gnu.org/licenses/>. */
34
35#include <sys/stat.h>
36
37/* This definition is only used if inlining fails for this function; see
38 the last page of <sys/stat.h>. The real work is done by the `x'
39 function which is passed a version number argument. We arrange in the
40 makefile that when not inlined this function is always statically
41 linked; that way a dynamically-linked executable always encodes the
42 version number corresponding to the data structures it uses, so the `x'
43 functions in the shared library can adapt without needing to recompile
44 all callers. */
45
46#undef lstat
47#undef __lstat
48int
49attribute_hidden
50__lstat (const char *file, struct stat *buf)
51{
52 return __lxstat (_STAT_VER, file, buf);
53}
54
55weak_hidden_alias (__lstat, lstat)
libc/glibc/io/lstat64.c created+52
...@@ -0,0 +1,52 @@
1/* Copyright (C) 1996-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 In addition to the permissions in the GNU Lesser General Public
10 License, the Free Software Foundation gives you unlimited
11 permission to link the compiled version of this file with other
12 programs, and to distribute those programs without any restriction
13 coming from the use of this file. (The GNU Lesser General Public
14 License restrictions do apply in other respects; for example, they
15 cover modification of the file, and distribution when not linked
16 into another program.)
17
18 Note that people who make modified versions of this file are not
19 obligated to grant this special exception for their modified
20 versions; it is their choice whether to do so. The GNU Lesser
21 General Public License gives permission to release a modified
22 version without this exception; this exception also makes it
23 possible to release a modified version which carries forward this
24 exception.
25
26 The GNU C Library is distributed in the hope that it will be useful,
27 but WITHOUT ANY WARRANTY; without even the implied warranty of
28 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
29 Lesser General Public License for more details.
30
31 You should have received a copy of the GNU Lesser General Public
32 License along with the GNU C Library; if not, see
33 <http://www.gnu.org/licenses/>. */
34
35#include <sys/stat.h>
36
37/* This definition is only used if inlining fails for this function; see
38 the last page of <sys/stat.h>. The real work is done by the `x'
39 function which is passed a version number argument. We arrange in the
40 makefile that when not inlined this function is always statically
41 linked; that way a dynamically-linked executable always encodes the
42 version number corresponding to the data structures it uses, so the `x'
43 functions in the shared library can adapt without needing to recompile
44 all callers. */
45
46#undef lstat64
47int
48attribute_hidden
49lstat64 (const char *file, struct stat64 *buf)
50{
51 return __lxstat64 (_STAT_VER, file, buf);
52}
libc/glibc/io/mknod.c created+55
...@@ -0,0 +1,55 @@
1/* Copyright (C) 1995-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 In addition to the permissions in the GNU Lesser General Public
10 License, the Free Software Foundation gives you unlimited
11 permission to link the compiled version of this file with other
12 programs, and to distribute those programs without any restriction
13 coming from the use of this file. (The GNU Lesser General Public
14 License restrictions do apply in other respects; for example, they
15 cover modification of the file, and distribution when not linked
16 into another program.)
17
18 Note that people who make modified versions of this file are not
19 obligated to grant this special exception for their modified
20 versions; it is their choice whether to do so. The GNU Lesser
21 General Public License gives permission to release a modified
22 version without this exception; this exception also makes it
23 possible to release a modified version which carries forward this
24 exception.
25
26 The GNU C Library is distributed in the hope that it will be useful,
27 but WITHOUT ANY WARRANTY; without even the implied warranty of
28 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
29 Lesser General Public License for more details.
30
31 You should have received a copy of the GNU Lesser General Public
32 License along with the GNU C Library; if not, see
33 <http://www.gnu.org/licenses/>. */
34
35
36#include <sys/types.h>
37#include <sys/stat.h>
38
39/* This definition is only used if inlining fails for this function; see
40 the last page of <sys/stat.h>. The real work is done by the `x'
41 function which is passed a version number argument. We arrange in the
42 makefile that when not inlined this function is always statically
43 linked; that way a dynamically-linked executable always encodes the
44 version number corresponding to the data structures it uses, so the `x'
45 functions in the shared library can adapt without needing to recompile
46 all callers. */
47
48int
49attribute_hidden
50__mknod (const char *path, mode_t mode, dev_t dev)
51{
52 return __xmknod (_MKNOD_VER, path, mode, &dev);
53}
54
55weak_hidden_alias (__mknod, mknod)
libc/glibc/io/mknodat.c created+53
...@@ -0,0 +1,53 @@
1/* Copyright (C) 1995-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 In addition to the permissions in the GNU Lesser General Public
10 License, the Free Software Foundation gives you unlimited
11 permission to link the compiled version of this file with other
12 programs, and to distribute those programs without any restriction
13 coming from the use of this file. (The GNU Lesser General Public
14 License restrictions do apply in other respects; for example, they
15 cover modification of the file, and distribution when not linked
16 into another program.)
17
18 Note that people who make modified versions of this file are not
19 obligated to grant this special exception for their modified
20 versions; it is their choice whether to do so. The GNU Lesser
21 General Public License gives permission to release a modified
22 version without this exception; this exception also makes it
23 possible to release a modified version which carries forward this
24 exception.
25
26 The GNU C Library is distributed in the hope that it will be useful,
27 but WITHOUT ANY WARRANTY; without even the implied warranty of
28 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
29 Lesser General Public License for more details.
30
31 You should have received a copy of the GNU Lesser General Public
32 License along with the GNU C Library; if not, see
33 <http://www.gnu.org/licenses/>. */
34
35
36#include <sys/types.h>
37#include <sys/stat.h>
38
39/* This definition is only used if inlining fails for this function; see
40 the last page of <sys/stat.h>. The real work is done by the `x'
41 function which is passed a version number argument. We arrange in the
42 makefile that when not inlined this function is always statically
43 linked; that way a dynamically-linked executable always encodes the
44 version number corresponding to the data structures it uses, so the `x'
45 functions in the shared library can adapt without needing to recompile
46 all callers. */
47
48int
49attribute_hidden
50mknodat (int fd, const char *path, mode_t mode, dev_t dev)
51{
52 return __xmknodat (_MKNOD_VER, fd, path, mode, &dev);
53}
libc/glibc/io/stat.c created+54
...@@ -0,0 +1,54 @@
1/* Copyright (C) 1996-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 In addition to the permissions in the GNU Lesser General Public
10 License, the Free Software Foundation gives you unlimited
11 permission to link the compiled version of this file with other
12 programs, and to distribute those programs without any restriction
13 coming from the use of this file. (The GNU Lesser General Public
14 License restrictions do apply in other respects; for example, they
15 cover modification of the file, and distribution when not linked
16 into another program.)
17
18 Note that people who make modified versions of this file are not
19 obligated to grant this special exception for their modified
20 versions; it is their choice whether to do so. The GNU Lesser
21 General Public License gives permission to release a modified
22 version without this exception; this exception also makes it
23 possible to release a modified version which carries forward this
24 exception.
25
26 The GNU C Library is distributed in the hope that it will be useful,
27 but WITHOUT ANY WARRANTY; without even the implied warranty of
28 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
29 Lesser General Public License for more details.
30
31 You should have received a copy of the GNU Lesser General Public
32 License along with the GNU C Library; if not, see
33 <http://www.gnu.org/licenses/>. */
34
35#include <sys/stat.h>
36
37/* This definition is only used if inlining fails for this function; see
38 the last page of <sys/stat.h>. The real work is done by the `x'
39 function which is passed a version number argument. We arrange in the
40 makefile that when not inlined this function is always statically
41 linked; that way a dynamically-linked executable always encodes the
42 version number corresponding to the data structures it uses, so the `x'
43 functions in the shared library can adapt without needing to recompile
44 all callers. */
45
46#undef stat
47int
48attribute_hidden
49__stat (const char *file, struct stat *buf)
50{
51 return __xstat (_STAT_VER, file, buf);
52}
53
54weak_hidden_alias (__stat, stat)
libc/glibc/io/stat64.c created+52
...@@ -0,0 +1,52 @@
1/* Copyright (C) 1996-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 In addition to the permissions in the GNU Lesser General Public
10 License, the Free Software Foundation gives you unlimited
11 permission to link the compiled version of this file with other
12 programs, and to distribute those programs without any restriction
13 coming from the use of this file. (The GNU Lesser General Public
14 License restrictions do apply in other respects; for example, they
15 cover modification of the file, and distribution when not linked
16 into another program.)
17
18 Note that people who make modified versions of this file are not
19 obligated to grant this special exception for their modified
20 versions; it is their choice whether to do so. The GNU Lesser
21 General Public License gives permission to release a modified
22 version without this exception; this exception also makes it
23 possible to release a modified version which carries forward this
24 exception.
25
26 The GNU C Library is distributed in the hope that it will be useful,
27 but WITHOUT ANY WARRANTY; without even the implied warranty of
28 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
29 Lesser General Public License for more details.
30
31 You should have received a copy of the GNU Lesser General Public
32 License along with the GNU C Library; if not, see
33 <http://www.gnu.org/licenses/>. */
34
35#include <sys/stat.h>
36
37/* This definition is only used if inlining fails for this function; see
38 the last page of <sys/stat.h>. The real work is done by the `x'
39 function which is passed a version number argument. We arrange in the
40 makefile that when not inlined this function is always statically
41 linked; that way a dynamically-linked executable always encodes the
42 version number corresponding to the data structures it uses, so the `x'
43 functions in the shared library can adapt without needing to recompile
44 all callers. */
45
46#undef stat64
47int
48attribute_hidden
49stat64 (const char *file, struct stat64 *buf)
50{
51 return __xstat64 (_STAT_VER, file, buf);
52}
libc/glibc/io/sys/stat.h created+537
...@@ -0,0 +1,537 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/*
19 * POSIX Standard: 5.6 File Characteristics <sys/stat.h>
20 */
21
22#ifndef _SYS_STAT_H
23#define _SYS_STAT_H 1
24
25#include <features.h>
26
27#include <bits/types.h> /* For __mode_t and __dev_t. */
28
29#ifdef __USE_XOPEN2K8
30# include <bits/types/struct_timespec.h>
31#endif
32
33#if defined __USE_XOPEN || defined __USE_XOPEN2K
34/* The Single Unix specification says that some more types are
35 available here. */
36
37# include <bits/types/time_t.h>
38
39# ifndef __dev_t_defined
40typedef __dev_t dev_t;
41# define __dev_t_defined
42# endif
43
44# ifndef __gid_t_defined
45typedef __gid_t gid_t;
46# define __gid_t_defined
47# endif
48
49# ifndef __ino_t_defined
50# ifndef __USE_FILE_OFFSET64
51typedef __ino_t ino_t;
52# else
53typedef __ino64_t ino_t;
54# endif
55# define __ino_t_defined
56# endif
57
58# ifndef __mode_t_defined
59typedef __mode_t mode_t;
60# define __mode_t_defined
61# endif
62
63# ifndef __nlink_t_defined
64typedef __nlink_t nlink_t;
65# define __nlink_t_defined
66# endif
67
68# ifndef __off_t_defined
69# ifndef __USE_FILE_OFFSET64
70typedef __off_t off_t;
71# else
72typedef __off64_t off_t;
73# endif
74# define __off_t_defined
75# endif
76
77# ifndef __uid_t_defined
78typedef __uid_t uid_t;
79# define __uid_t_defined
80# endif
81#endif /* X/Open */
82
83#ifdef __USE_UNIX98
84# ifndef __blkcnt_t_defined
85# ifndef __USE_FILE_OFFSET64
86typedef __blkcnt_t blkcnt_t;
87# else
88typedef __blkcnt64_t blkcnt_t;
89# endif
90# define __blkcnt_t_defined
91# endif
92
93# ifndef __blksize_t_defined
94typedef __blksize_t blksize_t;
95# define __blksize_t_defined
96# endif
97#endif /* Unix98 */
98
99__BEGIN_DECLS
100
101#include <bits/stat.h>
102
103#if defined __USE_MISC || defined __USE_XOPEN
104# define S_IFMT __S_IFMT
105# define S_IFDIR __S_IFDIR
106# define S_IFCHR __S_IFCHR
107# define S_IFBLK __S_IFBLK
108# define S_IFREG __S_IFREG
109# ifdef __S_IFIFO
110# define S_IFIFO __S_IFIFO
111# endif
112# ifdef __S_IFLNK
113# define S_IFLNK __S_IFLNK
114# endif
115# if (defined __USE_MISC || defined __USE_XOPEN_EXTENDED) \
116 && defined __S_IFSOCK
117# define S_IFSOCK __S_IFSOCK
118# endif
119#endif
120
121/* Test macros for file types. */
122
123#define __S_ISTYPE(mode, mask) (((mode) & __S_IFMT) == (mask))
124
125#define S_ISDIR(mode) __S_ISTYPE((mode), __S_IFDIR)
126#define S_ISCHR(mode) __S_ISTYPE((mode), __S_IFCHR)
127#define S_ISBLK(mode) __S_ISTYPE((mode), __S_IFBLK)
128#define S_ISREG(mode) __S_ISTYPE((mode), __S_IFREG)
129#ifdef __S_IFIFO
130# define S_ISFIFO(mode) __S_ISTYPE((mode), __S_IFIFO)
131#endif
132#ifdef __S_IFLNK
133# define S_ISLNK(mode) __S_ISTYPE((mode), __S_IFLNK)
134#endif
135
136#if defined __USE_MISC && !defined __S_IFLNK
137# define S_ISLNK(mode) 0
138#endif
139
140#if (defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K) \
141 && defined __S_IFSOCK
142# define S_ISSOCK(mode) __S_ISTYPE((mode), __S_IFSOCK)
143#elif defined __USE_XOPEN2K
144# define S_ISSOCK(mode) 0
145#endif
146
147/* These are from POSIX.1b. If the objects are not implemented using separate
148 distinct file types, the macros always will evaluate to zero. Unlike the
149 other S_* macros the following three take a pointer to a `struct stat'
150 object as the argument. */
151#ifdef __USE_POSIX199309
152# define S_TYPEISMQ(buf) __S_TYPEISMQ(buf)
153# define S_TYPEISSEM(buf) __S_TYPEISSEM(buf)
154# define S_TYPEISSHM(buf) __S_TYPEISSHM(buf)
155#endif
156
157
158/* Protection bits. */
159
160#define S_ISUID __S_ISUID /* Set user ID on execution. */
161#define S_ISGID __S_ISGID /* Set group ID on execution. */
162
163#if defined __USE_MISC || defined __USE_XOPEN
164/* Save swapped text after use (sticky bit). This is pretty well obsolete. */
165# define S_ISVTX __S_ISVTX
166#endif
167
168#define S_IRUSR __S_IREAD /* Read by owner. */
169#define S_IWUSR __S_IWRITE /* Write by owner. */
170#define S_IXUSR __S_IEXEC /* Execute by owner. */
171/* Read, write, and execute by owner. */
172#define S_IRWXU (__S_IREAD|__S_IWRITE|__S_IEXEC)
173
174#ifdef __USE_MISC
175# define S_IREAD S_IRUSR
176# define S_IWRITE S_IWUSR
177# define S_IEXEC S_IXUSR
178#endif
179
180#define S_IRGRP (S_IRUSR >> 3) /* Read by group. */
181#define S_IWGRP (S_IWUSR >> 3) /* Write by group. */
182#define S_IXGRP (S_IXUSR >> 3) /* Execute by group. */
183/* Read, write, and execute by group. */
184#define S_IRWXG (S_IRWXU >> 3)
185
186#define S_IROTH (S_IRGRP >> 3) /* Read by others. */
187#define S_IWOTH (S_IWGRP >> 3) /* Write by others. */
188#define S_IXOTH (S_IXGRP >> 3) /* Execute by others. */
189/* Read, write, and execute by others. */
190#define S_IRWXO (S_IRWXG >> 3)
191
192
193#ifdef __USE_MISC
194/* Macros for common mode bit masks. */
195# define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */
196# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)/* 07777 */
197# define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)/* 0666*/
198
199# define S_BLKSIZE 512 /* Block size for `st_blocks'. */
200#endif
201
202
203#ifndef __USE_FILE_OFFSET64
204/* Get file attributes for FILE and put them in BUF. */
205extern int stat (const char *__restrict __file,
206 struct stat *__restrict __buf) __THROW __nonnull ((1, 2));
207
208/* Get file attributes for the file, device, pipe, or socket
209 that file descriptor FD is open on and put them in BUF. */
210extern int fstat (int __fd, struct stat *__buf) __THROW __nonnull ((2));
211#else
212# ifdef __REDIRECT_NTH
213extern int __REDIRECT_NTH (stat, (const char *__restrict __file,
214 struct stat *__restrict __buf), stat64)
215 __nonnull ((1, 2));
216extern int __REDIRECT_NTH (fstat, (int __fd, struct stat *__buf), fstat64)
217 __nonnull ((2));
218# else
219# define stat stat64
220# define fstat fstat64
221# endif
222#endif
223#ifdef __USE_LARGEFILE64
224extern int stat64 (const char *__restrict __file,
225 struct stat64 *__restrict __buf) __THROW __nonnull ((1, 2));
226extern int fstat64 (int __fd, struct stat64 *__buf) __THROW __nonnull ((2));
227#endif
228
229#ifdef __USE_ATFILE
230/* Similar to stat, get the attributes for FILE and put them in BUF.
231 Relative path names are interpreted relative to FD unless FD is
232 AT_FDCWD. */
233# ifndef __USE_FILE_OFFSET64
234extern int fstatat (int __fd, const char *__restrict __file,
235 struct stat *__restrict __buf, int __flag)
236 __THROW __nonnull ((2, 3));
237# else
238# ifdef __REDIRECT_NTH
239extern int __REDIRECT_NTH (fstatat, (int __fd, const char *__restrict __file,
240 struct stat *__restrict __buf,
241 int __flag),
242 fstatat64) __nonnull ((2, 3));
243# else
244# define fstatat fstatat64
245# endif
246# endif
247
248# ifdef __USE_LARGEFILE64
249extern int fstatat64 (int __fd, const char *__restrict __file,
250 struct stat64 *__restrict __buf, int __flag)
251 __THROW __nonnull ((2, 3));
252# endif
253#endif
254
255#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K
256# ifndef __USE_FILE_OFFSET64
257/* Get file attributes about FILE and put them in BUF.
258 If FILE is a symbolic link, do not follow it. */
259extern int lstat (const char *__restrict __file,
260 struct stat *__restrict __buf) __THROW __nonnull ((1, 2));
261# else
262# ifdef __REDIRECT_NTH
263extern int __REDIRECT_NTH (lstat,
264 (const char *__restrict __file,
265 struct stat *__restrict __buf), lstat64)
266 __nonnull ((1, 2));
267# else
268# define lstat lstat64
269# endif
270# endif
271# ifdef __USE_LARGEFILE64
272extern int lstat64 (const char *__restrict __file,
273 struct stat64 *__restrict __buf)
274 __THROW __nonnull ((1, 2));
275# endif
276#endif
277
278/* Set file access permissions for FILE to MODE.
279 If FILE is a symbolic link, this affects its target instead. */
280extern int chmod (const char *__file, __mode_t __mode)
281 __THROW __nonnull ((1));
282
283#ifdef __USE_MISC
284/* Set file access permissions for FILE to MODE.
285 If FILE is a symbolic link, this affects the link itself
286 rather than its target. */
287extern int lchmod (const char *__file, __mode_t __mode)
288 __THROW __nonnull ((1));
289#endif
290
291/* Set file access permissions of the file FD is open on to MODE. */
292#if defined __USE_POSIX199309 || defined __USE_XOPEN_EXTENDED
293extern int fchmod (int __fd, __mode_t __mode) __THROW;
294#endif
295
296#ifdef __USE_ATFILE
297/* Set file access permissions of FILE relative to
298 the directory FD is open on. */
299extern int fchmodat (int __fd, const char *__file, __mode_t __mode,
300 int __flag)
301 __THROW __nonnull ((2)) __wur;
302#endif /* Use ATFILE. */
303
304
305
306/* Set the file creation mask of the current process to MASK,
307 and return the old creation mask. */
308extern __mode_t umask (__mode_t __mask) __THROW;
309
310#ifdef __USE_GNU
311/* Get the current `umask' value without changing it.
312 This function is only available under the GNU Hurd. */
313extern __mode_t getumask (void) __THROW;
314#endif
315
316/* Create a new directory named PATH, with permission bits MODE. */
317extern int mkdir (const char *__path, __mode_t __mode)
318 __THROW __nonnull ((1));
319
320#ifdef __USE_ATFILE
321/* Like mkdir, create a new directory with permission bits MODE. But
322 interpret relative PATH names relative to the directory associated
323 with FD. */
324extern int mkdirat (int __fd, const char *__path, __mode_t __mode)
325 __THROW __nonnull ((2));
326#endif
327
328/* Create a device file named PATH, with permission and special bits MODE
329 and device number DEV (which can be constructed from major and minor
330 device numbers with the `makedev' macro above). */
331#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
332extern int mknod (const char *__path, __mode_t __mode, __dev_t __dev)
333 __THROW __nonnull ((1));
334
335# ifdef __USE_ATFILE
336/* Like mknod, create a new device file with permission bits MODE and
337 device number DEV. But interpret relative PATH names relative to
338 the directory associated with FD. */
339extern int mknodat (int __fd, const char *__path, __mode_t __mode,
340 __dev_t __dev) __THROW __nonnull ((2));
341# endif
342#endif
343
344
345/* Create a new FIFO named PATH, with permission bits MODE. */
346extern int mkfifo (const char *__path, __mode_t __mode)
347 __THROW __nonnull ((1));
348
349#ifdef __USE_ATFILE
350/* Like mkfifo, create a new FIFO with permission bits MODE. But
351 interpret relative PATH names relative to the directory associated
352 with FD. */
353extern int mkfifoat (int __fd, const char *__path, __mode_t __mode)
354 __THROW __nonnull ((2));
355#endif
356
357#ifdef __USE_ATFILE
358/* Set file access and modification times relative to directory file
359 descriptor. */
360extern int utimensat (int __fd, const char *__path,
361 const struct timespec __times[2],
362 int __flags)
363 __THROW __nonnull ((2));
364#endif
365
366#ifdef __USE_XOPEN2K8
367/* Set file access and modification times of the file associated with FD. */
368extern int futimens (int __fd, const struct timespec __times[2]) __THROW;
369#endif
370
371/* To allow the `struct stat' structure and the file type `mode_t'
372 bits to vary without changing shared library major version number,
373 the `stat' family of functions and `mknod' are in fact inline
374 wrappers around calls to `xstat', `fxstat', `lxstat', and `xmknod',
375 which all take a leading version-number argument designating the
376 data structure and bits used. <bits/stat.h> defines _STAT_VER with
377 the version number corresponding to `struct stat' as defined in
378 that file; and _MKNOD_VER with the version number corresponding to
379 the S_IF* macros defined therein. It is arranged that when not
380 inlined these function are always statically linked; that way a
381 dynamically-linked executable always encodes the version number
382 corresponding to the data structures it uses, so the `x' functions
383 in the shared library can adapt without needing to recompile all
384 callers. */
385
386#ifndef _STAT_VER
387# define _STAT_VER 0
388#endif
389#ifndef _MKNOD_VER
390# define _MKNOD_VER 0
391#endif
392
393/* Wrappers for stat and mknod system calls. */
394#ifndef __USE_FILE_OFFSET64
395extern int __fxstat (int __ver, int __fildes, struct stat *__stat_buf)
396 __THROW __nonnull ((3));
397extern int __xstat (int __ver, const char *__filename,
398 struct stat *__stat_buf) __THROW __nonnull ((2, 3));
399extern int __lxstat (int __ver, const char *__filename,
400 struct stat *__stat_buf) __THROW __nonnull ((2, 3));
401extern int __fxstatat (int __ver, int __fildes, const char *__filename,
402 struct stat *__stat_buf, int __flag)
403 __THROW __nonnull ((3, 4));
404#else
405# ifdef __REDIRECT_NTH
406extern int __REDIRECT_NTH (__fxstat, (int __ver, int __fildes,
407 struct stat *__stat_buf), __fxstat64)
408 __nonnull ((3));
409extern int __REDIRECT_NTH (__xstat, (int __ver, const char *__filename,
410 struct stat *__stat_buf), __xstat64)
411 __nonnull ((2, 3));
412extern int __REDIRECT_NTH (__lxstat, (int __ver, const char *__filename,
413 struct stat *__stat_buf), __lxstat64)
414 __nonnull ((2, 3));
415extern int __REDIRECT_NTH (__fxstatat, (int __ver, int __fildes,
416 const char *__filename,
417 struct stat *__stat_buf, int __flag),
418 __fxstatat64) __nonnull ((3, 4));
419
420# else
421# define __fxstat __fxstat64
422# define __xstat __xstat64
423# define __lxstat __lxstat64
424# endif
425#endif
426
427#ifdef __USE_LARGEFILE64
428extern int __fxstat64 (int __ver, int __fildes, struct stat64 *__stat_buf)
429 __THROW __nonnull ((3));
430extern int __xstat64 (int __ver, const char *__filename,
431 struct stat64 *__stat_buf) __THROW __nonnull ((2, 3));
432extern int __lxstat64 (int __ver, const char *__filename,
433 struct stat64 *__stat_buf) __THROW __nonnull ((2, 3));
434extern int __fxstatat64 (int __ver, int __fildes, const char *__filename,
435 struct stat64 *__stat_buf, int __flag)
436 __THROW __nonnull ((3, 4));
437#endif
438extern int __xmknod (int __ver, const char *__path, __mode_t __mode,
439 __dev_t *__dev) __THROW __nonnull ((2, 4));
440
441extern int __xmknodat (int __ver, int __fd, const char *__path,
442 __mode_t __mode, __dev_t *__dev)
443 __THROW __nonnull ((3, 5));
444
445#ifdef __USE_GNU
446# include <bits/statx.h>
447#endif
448
449#ifdef __USE_EXTERN_INLINES
450/* Inlined versions of the real stat and mknod functions. */
451
452__extern_inline int
453__NTH (stat (const char *__path, struct stat *__statbuf))
454{
455 return __xstat (_STAT_VER, __path, __statbuf);
456}
457
458# if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
459__extern_inline int
460__NTH (lstat (const char *__path, struct stat *__statbuf))
461{
462 return __lxstat (_STAT_VER, __path, __statbuf);
463}
464# endif
465
466__extern_inline int
467__NTH (fstat (int __fd, struct stat *__statbuf))
468{
469 return __fxstat (_STAT_VER, __fd, __statbuf);
470}
471
472# ifdef __USE_ATFILE
473__extern_inline int
474__NTH (fstatat (int __fd, const char *__filename, struct stat *__statbuf,
475 int __flag))
476{
477 return __fxstatat (_STAT_VER, __fd, __filename, __statbuf, __flag);
478}
479# endif
480
481# ifdef __USE_MISC
482__extern_inline int
483__NTH (mknod (const char *__path, __mode_t __mode, __dev_t __dev))
484{
485 return __xmknod (_MKNOD_VER, __path, __mode, &__dev);
486}
487# endif
488
489# ifdef __USE_ATFILE
490__extern_inline int
491__NTH (mknodat (int __fd, const char *__path, __mode_t __mode,
492 __dev_t __dev))
493{
494 return __xmknodat (_MKNOD_VER, __fd, __path, __mode, &__dev);
495}
496# endif
497
498# if defined __USE_LARGEFILE64 \
499 && (! defined __USE_FILE_OFFSET64 \
500 || (defined __REDIRECT_NTH && defined __OPTIMIZE__))
501__extern_inline int
502__NTH (stat64 (const char *__path, struct stat64 *__statbuf))
503{
504 return __xstat64 (_STAT_VER, __path, __statbuf);
505}
506
507# if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
508__extern_inline int
509__NTH (lstat64 (const char *__path, struct stat64 *__statbuf))
510{
511 return __lxstat64 (_STAT_VER, __path, __statbuf);
512}
513# endif
514
515__extern_inline int
516__NTH (fstat64 (int __fd, struct stat64 *__statbuf))
517{
518 return __fxstat64 (_STAT_VER, __fd, __statbuf);
519}
520
521# ifdef __USE_ATFILE
522__extern_inline int
523__NTH (fstatat64 (int __fd, const char *__filename, struct stat64 *__statbuf,
524 int __flag))
525{
526 return __fxstatat64 (_STAT_VER, __fd, __filename, __statbuf, __flag);
527}
528# endif
529
530# endif
531
532#endif
533
534__END_DECLS
535
536
537#endif /* sys/stat.h */
libc/glibc/locale/bits/types/__locale_t.h created+44
...@@ -0,0 +1,44 @@
1/* Definition of struct __locale_struct and __locale_t.
2 Copyright (C) 1997-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
19
20#ifndef _BITS_TYPES___LOCALE_T_H
21#define _BITS_TYPES___LOCALE_T_H 1
22
23/* POSIX.1-2008: the locale_t type, representing a locale context
24 (implementation-namespace version). This type should be treated
25 as opaque by applications; some details are exposed for the sake of
26 efficiency in e.g. ctype functions. */
27
28struct __locale_struct
29{
30 /* Note: LC_ALL is not a valid index into this array. */
31 struct __locale_data *__locales[13]; /* 13 = __LC_LAST. */
32
33 /* To increase the speed of this solution we add some special members. */
34 const unsigned short int *__ctype_b;
35 const int *__ctype_tolower;
36 const int *__ctype_toupper;
37
38 /* Note: LC_ALL is not a valid index into this array. */
39 const char *__names[13];
40};
41
42typedef struct __locale_struct *__locale_t;
43
44#endif /* bits/types/__locale_t.h */
libc/glibc/locale/bits/types/locale_t.h created+26
...@@ -0,0 +1,26 @@
1/* Definition of locale_t.
2 Copyright (C) 2017-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_TYPES_LOCALE_T_H
20#define _BITS_TYPES_LOCALE_T_H 1
21
22#include <bits/types/__locale_t.h>
23
24typedef __locale_t locale_t;
25
26#endif /* bits/types/locale_t.h */
libc/glibc/misc/sys/cdefs.h created+517
...@@ -0,0 +1,517 @@
1/* Copyright (C) 1992-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_CDEFS_H
19#define _SYS_CDEFS_H 1
20
21/* We are almost always included from features.h. */
22#ifndef _FEATURES_H
23# include <features.h>
24#endif
25
26/* The GNU libc does not support any K&R compilers or the traditional mode
27 of ISO C compilers anymore. Check for some of the combinations not
28 anymore supported. */
29#if defined __GNUC__ && !defined __STDC__
30# error "You need a ISO C conforming compiler to use the glibc headers"
31#endif
32
33/* Some user header file might have defined this before. */
34#undef __P
35#undef __PMT
36
37#ifdef __GNUC__
38
39/* All functions, except those with callbacks or those that
40 synchronize memory, are leaf functions. */
41# if __GNUC_PREREQ (4, 6) && !defined _LIBC
42# define __LEAF , __leaf__
43# define __LEAF_ATTR __attribute__ ((__leaf__))
44# else
45# define __LEAF
46# define __LEAF_ATTR
47# endif
48
49/* GCC can always grok prototypes. For C++ programs we add throw()
50 to help it optimize the function calls. But this works only with
51 gcc 2.8.x and egcs. For gcc 3.2 and up we even mark C functions
52 as non-throwing using a function attribute since programs can use
53 the -fexceptions options for C code as well. */
54# if !defined __cplusplus && __GNUC_PREREQ (3, 3)
55# define __THROW __attribute__ ((__nothrow__ __LEAF))
56# define __THROWNL __attribute__ ((__nothrow__))
57# define __NTH(fct) __attribute__ ((__nothrow__ __LEAF)) fct
58# define __NTHNL(fct) __attribute__ ((__nothrow__)) fct
59# else
60# if defined __cplusplus && __GNUC_PREREQ (2,8)
61# define __THROW throw ()
62# define __THROWNL throw ()
63# define __NTH(fct) __LEAF_ATTR fct throw ()
64# define __NTHNL(fct) fct throw ()
65# else
66# define __THROW
67# define __THROWNL
68# define __NTH(fct) fct
69# define __NTHNL(fct) fct
70# endif
71# endif
72
73#else /* Not GCC. */
74
75# if (defined __cplusplus \
76 || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L))
77# define __inline inline
78# else
79# define __inline /* No inline functions. */
80# endif
81
82# define __THROW
83# define __THROWNL
84# define __NTH(fct) fct
85
86#endif /* GCC. */
87
88/* Compilers that are not clang may object to
89 #if defined __clang__ && __has_extension(...)
90 even though they do not need to evaluate the right-hand side of the &&. */
91#if defined __clang__ && defined __has_extension
92# define __glibc_clang_has_extension(ext) __has_extension (ext)
93#else
94# define __glibc_clang_has_extension(ext) 0
95#endif
96
97/* These two macros are not used in glibc anymore. They are kept here
98 only because some other projects expect the macros to be defined. */
99#define __P(args) args
100#define __PMT(args) args
101
102/* For these things, GCC behaves the ANSI way normally,
103 and the non-ANSI way under -traditional. */
104
105#define __CONCAT(x,y) x ## y
106#define __STRING(x) #x
107
108/* This is not a typedef so `const __ptr_t' does the right thing. */
109#define __ptr_t void *
110
111
112/* C++ needs to know that types and declarations are C, not C++. */
113#ifdef __cplusplus
114# define __BEGIN_DECLS extern "C" {
115# define __END_DECLS }
116#else
117# define __BEGIN_DECLS
118# define __END_DECLS
119#endif
120
121
122/* Fortify support. */
123#define __bos(ptr) __builtin_object_size (ptr, __USE_FORTIFY_LEVEL > 1)
124#define __bos0(ptr) __builtin_object_size (ptr, 0)
125
126#if __GNUC_PREREQ (4,3)
127# define __warndecl(name, msg) \
128 extern void name (void) __attribute__((__warning__ (msg)))
129# define __warnattr(msg) __attribute__((__warning__ (msg)))
130# define __errordecl(name, msg) \
131 extern void name (void) __attribute__((__error__ (msg)))
132#else
133# define __warndecl(name, msg) extern void name (void)
134# define __warnattr(msg)
135# define __errordecl(name, msg) extern void name (void)
136#endif
137
138/* Support for flexible arrays.
139 Headers that should use flexible arrays only if they're "real"
140 (e.g. only if they won't affect sizeof()) should test
141 #if __glibc_c99_flexarr_available. */
142#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
143# define __flexarr []
144# define __glibc_c99_flexarr_available 1
145#elif __GNUC_PREREQ (2,97)
146/* GCC 2.97 supports C99 flexible array members as an extension,
147 even when in C89 mode or compiling C++ (any version). */
148# define __flexarr []
149# define __glibc_c99_flexarr_available 1
150#elif defined __GNUC__
151/* Pre-2.97 GCC did not support C99 flexible arrays but did have
152 an equivalent extension with slightly different notation. */
153# define __flexarr [0]
154# define __glibc_c99_flexarr_available 1
155#else
156/* Some other non-C99 compiler. Approximate with [1]. */
157# define __flexarr [1]
158# define __glibc_c99_flexarr_available 0
159#endif
160
161
162/* __asm__ ("xyz") is used throughout the headers to rename functions
163 at the assembly language level. This is wrapped by the __REDIRECT
164 macro, in order to support compilers that can do this some other
165 way. When compilers don't support asm-names at all, we have to do
166 preprocessor tricks instead (which don't have exactly the right
167 semantics, but it's the best we can do).
168
169 Example:
170 int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); */
171
172#if defined __GNUC__ && __GNUC__ >= 2
173
174# define __REDIRECT(name, proto, alias) name proto __asm__ (__ASMNAME (#alias))
175# ifdef __cplusplus
176# define __REDIRECT_NTH(name, proto, alias) \
177 name proto __THROW __asm__ (__ASMNAME (#alias))
178# define __REDIRECT_NTHNL(name, proto, alias) \
179 name proto __THROWNL __asm__ (__ASMNAME (#alias))
180# else
181# define __REDIRECT_NTH(name, proto, alias) \
182 name proto __asm__ (__ASMNAME (#alias)) __THROW
183# define __REDIRECT_NTHNL(name, proto, alias) \
184 name proto __asm__ (__ASMNAME (#alias)) __THROWNL
185# endif
186# define __ASMNAME(cname) __ASMNAME2 (__USER_LABEL_PREFIX__, cname)
187# define __ASMNAME2(prefix, cname) __STRING (prefix) cname
188
189/*
190#elif __SOME_OTHER_COMPILER__
191
192# define __REDIRECT(name, proto, alias) name proto; \
193 _Pragma("let " #name " = " #alias)
194*/
195#endif
196
197/* GCC has various useful declarations that can be made with the
198 `__attribute__' syntax. All of the ways we use this do fine if
199 they are omitted for compilers that don't understand it. */
200#if !defined __GNUC__ || __GNUC__ < 2
201# define __attribute__(xyz) /* Ignore */
202#endif
203
204/* At some point during the gcc 2.96 development the `malloc' attribute
205 for functions was introduced. We don't want to use it unconditionally
206 (although this would be possible) since it generates warnings. */
207#if __GNUC_PREREQ (2,96)
208# define __attribute_malloc__ __attribute__ ((__malloc__))
209#else
210# define __attribute_malloc__ /* Ignore */
211#endif
212
213/* Tell the compiler which arguments to an allocation function
214 indicate the size of the allocation. */
215#if __GNUC_PREREQ (4, 3)
216# define __attribute_alloc_size__(params) \
217 __attribute__ ((__alloc_size__ params))
218#else
219# define __attribute_alloc_size__(params) /* Ignore. */
220#endif
221
222/* At some point during the gcc 2.96 development the `pure' attribute
223 for functions was introduced. We don't want to use it unconditionally
224 (although this would be possible) since it generates warnings. */
225#if __GNUC_PREREQ (2,96)
226# define __attribute_pure__ __attribute__ ((__pure__))
227#else
228# define __attribute_pure__ /* Ignore */
229#endif
230
231/* This declaration tells the compiler that the value is constant. */
232#if __GNUC_PREREQ (2,5)
233# define __attribute_const__ __attribute__ ((__const__))
234#else
235# define __attribute_const__ /* Ignore */
236#endif
237
238/* At some point during the gcc 3.1 development the `used' attribute
239 for functions was introduced. We don't want to use it unconditionally
240 (although this would be possible) since it generates warnings. */
241#if __GNUC_PREREQ (3,1)
242# define __attribute_used__ __attribute__ ((__used__))
243# define __attribute_noinline__ __attribute__ ((__noinline__))
244#else
245# define __attribute_used__ __attribute__ ((__unused__))
246# define __attribute_noinline__ /* Ignore */
247#endif
248
249/* Since version 3.2, gcc allows marking deprecated functions. */
250#if __GNUC_PREREQ (3,2)
251# define __attribute_deprecated__ __attribute__ ((__deprecated__))
252#else
253# define __attribute_deprecated__ /* Ignore */
254#endif
255
256/* Since version 4.5, gcc also allows one to specify the message printed
257 when a deprecated function is used. clang claims to be gcc 4.2, but
258 may also support this feature. */
259#if __GNUC_PREREQ (4,5) || \
260 __glibc_clang_has_extension (__attribute_deprecated_with_message__)
261# define __attribute_deprecated_msg__(msg) \
262 __attribute__ ((__deprecated__ (msg)))
263#else
264# define __attribute_deprecated_msg__(msg) __attribute_deprecated__
265#endif
266
267/* At some point during the gcc 2.8 development the `format_arg' attribute
268 for functions was introduced. We don't want to use it unconditionally
269 (although this would be possible) since it generates warnings.
270 If several `format_arg' attributes are given for the same function, in
271 gcc-3.0 and older, all but the last one are ignored. In newer gccs,
272 all designated arguments are considered. */
273#if __GNUC_PREREQ (2,8)
274# define __attribute_format_arg__(x) __attribute__ ((__format_arg__ (x)))
275#else
276# define __attribute_format_arg__(x) /* Ignore */
277#endif
278
279/* At some point during the gcc 2.97 development the `strfmon' format
280 attribute for functions was introduced. We don't want to use it
281 unconditionally (although this would be possible) since it
282 generates warnings. */
283#if __GNUC_PREREQ (2,97)
284# define __attribute_format_strfmon__(a,b) \
285 __attribute__ ((__format__ (__strfmon__, a, b)))
286#else
287# define __attribute_format_strfmon__(a,b) /* Ignore */
288#endif
289
290/* The nonull function attribute allows to mark pointer parameters which
291 must not be NULL. */
292#if __GNUC_PREREQ (3,3)
293# define __nonnull(params) __attribute__ ((__nonnull__ params))
294#else
295# define __nonnull(params)
296#endif
297
298/* If fortification mode, we warn about unused results of certain
299 function calls which can lead to problems. */
300#if __GNUC_PREREQ (3,4)
301# define __attribute_warn_unused_result__ \
302 __attribute__ ((__warn_unused_result__))
303# if __USE_FORTIFY_LEVEL > 0
304# define __wur __attribute_warn_unused_result__
305# endif
306#else
307# define __attribute_warn_unused_result__ /* empty */
308#endif
309#ifndef __wur
310# define __wur /* Ignore */
311#endif
312
313/* Forces a function to be always inlined. */
314#if __GNUC_PREREQ (3,2)
315/* The Linux kernel defines __always_inline in stddef.h (283d7573), and
316 it conflicts with this definition. Therefore undefine it first to
317 allow either header to be included first. */
318# undef __always_inline
319# define __always_inline __inline __attribute__ ((__always_inline__))
320#else
321# undef __always_inline
322# define __always_inline __inline
323#endif
324
325/* Associate error messages with the source location of the call site rather
326 than with the source location inside the function. */
327#if __GNUC_PREREQ (4,3)
328# define __attribute_artificial__ __attribute__ ((__artificial__))
329#else
330# define __attribute_artificial__ /* Ignore */
331#endif
332
333/* GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99
334 inline semantics, unless -fgnu89-inline is used. Using __GNUC_STDC_INLINE__
335 or __GNUC_GNU_INLINE is not a good enough check for gcc because gcc versions
336 older than 4.3 may define these macros and still not guarantee GNU inlining
337 semantics.
338
339 clang++ identifies itself as gcc-4.2, but has support for GNU inlining
340 semantics, that can be checked for by using the __GNUC_STDC_INLINE_ and
341 __GNUC_GNU_INLINE__ macro definitions. */
342#if (!defined __cplusplus || __GNUC_PREREQ (4,3) \
343 || (defined __clang__ && (defined __GNUC_STDC_INLINE__ \
344 || defined __GNUC_GNU_INLINE__)))
345# if defined __GNUC_STDC_INLINE__ || defined __cplusplus
346# define __extern_inline extern __inline __attribute__ ((__gnu_inline__))
347# define __extern_always_inline \
348 extern __always_inline __attribute__ ((__gnu_inline__))
349# else
350# define __extern_inline extern __inline
351# define __extern_always_inline extern __always_inline
352# endif
353#endif
354
355#ifdef __extern_always_inline
356# define __fortify_function __extern_always_inline __attribute_artificial__
357#endif
358
359/* GCC 4.3 and above allow passing all anonymous arguments of an
360 __extern_always_inline function to some other vararg function. */
361#if __GNUC_PREREQ (4,3)
362# define __va_arg_pack() __builtin_va_arg_pack ()
363# define __va_arg_pack_len() __builtin_va_arg_pack_len ()
364#endif
365
366/* It is possible to compile containing GCC extensions even if GCC is
367 run in pedantic mode if the uses are carefully marked using the
368 `__extension__' keyword. But this is not generally available before
369 version 2.8. */
370#if !__GNUC_PREREQ (2,8)
371# define __extension__ /* Ignore */
372#endif
373
374/* __restrict is known in EGCS 1.2 and above. */
375#if !__GNUC_PREREQ (2,92)
376# if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
377# define __restrict restrict
378# else
379# define __restrict /* Ignore */
380# endif
381#endif
382
383/* ISO C99 also allows to declare arrays as non-overlapping. The syntax is
384 array_name[restrict]
385 GCC 3.1 supports this. */
386#if __GNUC_PREREQ (3,1) && !defined __GNUG__
387# define __restrict_arr __restrict
388#else
389# ifdef __GNUC__
390# define __restrict_arr /* Not supported in old GCC. */
391# else
392# if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
393# define __restrict_arr restrict
394# else
395/* Some other non-C99 compiler. */
396# define __restrict_arr /* Not supported. */
397# endif
398# endif
399#endif
400
401#if __GNUC__ >= 3
402# define __glibc_unlikely(cond) __builtin_expect ((cond), 0)
403# define __glibc_likely(cond) __builtin_expect ((cond), 1)
404#else
405# define __glibc_unlikely(cond) (cond)
406# define __glibc_likely(cond) (cond)
407#endif
408
409#ifdef __has_attribute
410# define __glibc_has_attribute(attr) __has_attribute (attr)
411#else
412# define __glibc_has_attribute(attr) 0
413#endif
414
415#if (!defined _Noreturn \
416 && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \
417 && !__GNUC_PREREQ (4,7))
418# if __GNUC_PREREQ (2,8)
419# define _Noreturn __attribute__ ((__noreturn__))
420# else
421# define _Noreturn
422# endif
423#endif
424
425#if __GNUC_PREREQ (8, 0)
426/* Describes a char array whose address can safely be passed as the first
427 argument to strncpy and strncat, as the char array is not necessarily
428 a NUL-terminated string. */
429# define __attribute_nonstring__ __attribute__ ((__nonstring__))
430#else
431# define __attribute_nonstring__
432#endif
433
434/* Undefine (also defined in libc-symbols.h). */
435#undef __attribute_copy__
436#if __GNUC_PREREQ (9, 0)
437/* Copies attributes from the declaration or type referenced by
438 the argument. */
439# define __attribute_copy__(arg) __attribute__ ((__copy__ (arg)))
440#else
441# define __attribute_copy__(arg)
442#endif
443
444#if (!defined _Static_assert && !defined __cplusplus \
445 && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \
446 && (!__GNUC_PREREQ (4, 6) || defined __STRICT_ANSI__))
447# define _Static_assert(expr, diagnostic) \
448 extern int (*__Static_assert_function (void)) \
449 [!!sizeof (struct { int __error_if_negative: (expr) ? 2 : -1; })]
450#endif
451
452#include <bits/wordsize.h>
453#include <bits/long-double.h>
454
455#if defined __LONG_DOUBLE_MATH_OPTIONAL && defined __NO_LONG_DOUBLE_MATH
456# define __LDBL_COMPAT 1
457# ifdef __REDIRECT
458# define __LDBL_REDIR1(name, proto, alias) __REDIRECT (name, proto, alias)
459# define __LDBL_REDIR(name, proto) \
460 __LDBL_REDIR1 (name, proto, __nldbl_##name)
461# define __LDBL_REDIR1_NTH(name, proto, alias) __REDIRECT_NTH (name, proto, alias)
462# define __LDBL_REDIR_NTH(name, proto) \
463 __LDBL_REDIR1_NTH (name, proto, __nldbl_##name)
464# define __LDBL_REDIR1_DECL(name, alias) \
465 extern __typeof (name) name __asm (__ASMNAME (#alias));
466# define __LDBL_REDIR_DECL(name) \
467 extern __typeof (name) name __asm (__ASMNAME ("__nldbl_" #name));
468# define __REDIRECT_LDBL(name, proto, alias) \
469 __LDBL_REDIR1 (name, proto, __nldbl_##alias)
470# define __REDIRECT_NTH_LDBL(name, proto, alias) \
471 __LDBL_REDIR1_NTH (name, proto, __nldbl_##alias)
472# endif
473#endif
474#if !defined __LDBL_COMPAT || !defined __REDIRECT
475# define __LDBL_REDIR1(name, proto, alias) name proto
476# define __LDBL_REDIR(name, proto) name proto
477# define __LDBL_REDIR1_NTH(name, proto, alias) name proto __THROW
478# define __LDBL_REDIR_NTH(name, proto) name proto __THROW
479# define __LDBL_REDIR_DECL(name)
480# ifdef __REDIRECT
481# define __REDIRECT_LDBL(name, proto, alias) __REDIRECT (name, proto, alias)
482# define __REDIRECT_NTH_LDBL(name, proto, alias) \
483 __REDIRECT_NTH (name, proto, alias)
484# endif
485#endif
486
487/* __glibc_macro_warning (MESSAGE) issues warning MESSAGE. This is
488 intended for use in preprocessor macros.
489
490 Note: MESSAGE must be a _single_ string; concatenation of string
491 literals is not supported. */
492#if __GNUC_PREREQ (4,8) || __glibc_clang_prereq (3,5)
493# define __glibc_macro_warning1(message) _Pragma (#message)
494# define __glibc_macro_warning(message) \
495 __glibc_macro_warning1 (GCC warning message)
496#else
497# define __glibc_macro_warning(msg)
498#endif
499
500/* Generic selection (ISO C11) is a C-only feature, available in GCC
501 since version 4.9. Previous versions do not provide generic
502 selection, even though they might set __STDC_VERSION__ to 201112L,
503 when in -std=c11 mode. Thus, we must check for !defined __GNUC__
504 when testing __STDC_VERSION__ for generic selection support.
505 On the other hand, Clang also defines __GNUC__, so a clang-specific
506 check is required to enable the use of generic selection. */
507#if !defined __cplusplus \
508 && (__GNUC_PREREQ (4, 9) \
509 || __glibc_clang_has_extension (c_generic_selections) \
510 || (!defined __GNUC__ && defined __STDC_VERSION__ \
511 && __STDC_VERSION__ >= 201112L))
512# define __HAVE_GENERIC_SELECTION 1
513#else
514# define __HAVE_GENERIC_SELECTION 0
515#endif
516
517#endif /* sys/cdefs.h */
libc/glibc/misc/sys/param.h created+106
...@@ -0,0 +1,106 @@
1/* Compatibility header for old-style Unix parameters and limits.
2 Copyright (C) 1995-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SYS_PARAM_H
20#define _SYS_PARAM_H 1
21
22#define __need_NULL
23#include <stddef.h>
24
25#include <sys/types.h>
26#include <limits.h>
27#include <endian.h> /* Define BYTE_ORDER et al. */
28#include <signal.h> /* Define NSIG. */
29
30/* This file defines some things in system-specific ways. */
31#include <bits/param.h>
32
33
34/* BSD names for some <limits.h> values. */
35
36#define NBBY CHAR_BIT
37
38#if !defined NGROUPS && defined NGROUPS_MAX
39# define NGROUPS NGROUPS_MAX
40#endif
41#if !defined MAXSYMLINKS && defined SYMLOOP_MAX
42# define MAXSYMLINKS SYMLOOP_MAX
43#endif
44#if !defined CANBSIZ && defined MAX_CANON
45# define CANBSIZ MAX_CANON
46#endif
47#if !defined MAXPATHLEN && defined PATH_MAX
48# define MAXPATHLEN PATH_MAX
49#endif
50#if !defined NOFILE && defined OPEN_MAX
51# define NOFILE OPEN_MAX
52#endif
53#if !defined MAXHOSTNAMELEN && defined HOST_NAME_MAX
54# define MAXHOSTNAMELEN HOST_NAME_MAX
55#endif
56#ifndef NCARGS
57# ifdef ARG_MAX
58# define NCARGS ARG_MAX
59# else
60/* ARG_MAX is unlimited, but we define NCARGS for BSD programs that want to
61 compare against some fixed limit. */
62# define NCARGS INT_MAX
63# endif
64#endif
65
66
67/* Magical constants. */
68#ifndef NOGROUP
69# define NOGROUP 65535 /* Marker for empty group set member. */
70#endif
71#ifndef NODEV
72# define NODEV ((dev_t) -1) /* Non-existent device. */
73#endif
74
75
76/* Unit of `st_blocks'. */
77#ifndef DEV_BSIZE
78# define DEV_BSIZE 512
79#endif
80
81
82/* Bit map related macros. */
83#define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY))
84#define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
85#define isset(a,i) ((a)[(i)/NBBY] & (1<<((i)%NBBY)))
86#define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
87
88/* Macros for counting and rounding. */
89#ifndef howmany
90# define howmany(x, y) (((x) + ((y) - 1)) / (y))
91#endif
92#ifdef __GNUC__
93# define roundup(x, y) (__builtin_constant_p (y) && powerof2 (y) \
94 ? (((x) + (y) - 1) & ~((y) - 1)) \
95 : ((((x) + ((y) - 1)) / (y)) * (y)))
96#else
97# define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
98#endif
99#define powerof2(x) ((((x) - 1) & (x)) == 0)
100
101/* Macros for min/max. */
102#define MIN(a,b) (((a)<(b))?(a):(b))
103#define MAX(a,b) (((a)>(b))?(a):(b))
104
105
106#endif /* sys/param.h */
libc/glibc/misc/sys/select.h created+128
...@@ -0,0 +1,128 @@
1/* `fd_set' type and related macros, and `select'/`pselect' declarations.
2 Copyright (C) 1996-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19/* POSIX 1003.1g: 6.2 Select from File Descriptor Sets <sys/select.h> */
20
21#ifndef _SYS_SELECT_H
22#define _SYS_SELECT_H 1
23
24#include <features.h>
25
26/* Get definition of needed basic types. */
27#include <bits/types.h>
28
29/* Get __FD_* definitions. */
30#include <bits/select.h>
31
32/* Get sigset_t. */
33#include <bits/types/sigset_t.h>
34
35/* Get definition of timer specification structures. */
36#include <bits/types/time_t.h>
37#include <bits/types/struct_timeval.h>
38#ifdef __USE_XOPEN2K
39# include <bits/types/struct_timespec.h>
40#endif
41
42#ifndef __suseconds_t_defined
43typedef __suseconds_t suseconds_t;
44# define __suseconds_t_defined
45#endif
46
47
48/* The fd_set member is required to be an array of longs. */
49typedef long int __fd_mask;
50
51/* Some versions of <linux/posix_types.h> define this macros. */
52#undef __NFDBITS
53/* It's easier to assume 8-bit bytes than to get CHAR_BIT. */
54#define __NFDBITS (8 * (int) sizeof (__fd_mask))
55#define __FD_ELT(d) ((d) / __NFDBITS)
56#define __FD_MASK(d) ((__fd_mask) (1UL << ((d) % __NFDBITS)))
57
58/* fd_set for select and pselect. */
59typedef struct
60 {
61 /* XPG4.2 requires this member name. Otherwise avoid the name
62 from the global namespace. */
63#ifdef __USE_XOPEN
64 __fd_mask fds_bits[__FD_SETSIZE / __NFDBITS];
65# define __FDS_BITS(set) ((set)->fds_bits)
66#else
67 __fd_mask __fds_bits[__FD_SETSIZE / __NFDBITS];
68# define __FDS_BITS(set) ((set)->__fds_bits)
69#endif
70 } fd_set;
71
72/* Maximum number of file descriptors in `fd_set'. */
73#define FD_SETSIZE __FD_SETSIZE
74
75#ifdef __USE_MISC
76/* Sometimes the fd_set member is assumed to have this type. */
77typedef __fd_mask fd_mask;
78
79/* Number of bits per word of `fd_set' (some code assumes this is 32). */
80# define NFDBITS __NFDBITS
81#endif
82
83
84/* Access macros for `fd_set'. */
85#define FD_SET(fd, fdsetp) __FD_SET (fd, fdsetp)
86#define FD_CLR(fd, fdsetp) __FD_CLR (fd, fdsetp)
87#define FD_ISSET(fd, fdsetp) __FD_ISSET (fd, fdsetp)
88#define FD_ZERO(fdsetp) __FD_ZERO (fdsetp)
89
90
91__BEGIN_DECLS
92
93/* Check the first NFDS descriptors each in READFDS (if not NULL) for read
94 readiness, in WRITEFDS (if not NULL) for write readiness, and in EXCEPTFDS
95 (if not NULL) for exceptional conditions. If TIMEOUT is not NULL, time out
96 after waiting the interval specified therein. Returns the number of ready
97 descriptors, or -1 for errors.
98
99 This function is a cancellation point and therefore not marked with
100 __THROW. */
101extern int select (int __nfds, fd_set *__restrict __readfds,
102 fd_set *__restrict __writefds,
103 fd_set *__restrict __exceptfds,
104 struct timeval *__restrict __timeout);
105
106#ifdef __USE_XOPEN2K
107/* Same as above only that the TIMEOUT value is given with higher
108 resolution and a sigmask which is been set temporarily. This version
109 should be used.
110
111 This function is a cancellation point and therefore not marked with
112 __THROW. */
113extern int pselect (int __nfds, fd_set *__restrict __readfds,
114 fd_set *__restrict __writefds,
115 fd_set *__restrict __exceptfds,
116 const struct timespec *__restrict __timeout,
117 const __sigset_t *__restrict __sigmask);
118#endif
119
120
121/* Define some inlines helping to catch common problems. */
122#if __USE_FORTIFY_LEVEL > 0 && defined __GNUC__
123# include <bits/select2.h>
124#endif
125
126__END_DECLS
127
128#endif /* sys/select.h */
libc/glibc/nptl/pthread_atfork.c created+57
...@@ -0,0 +1,57 @@
1/* Copyright (C) 2002-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library; if not, see
34 <http://www.gnu.org/licenses/>. */
35
36#include "pthreadP.h"
37#include <fork.h>
38#include <dso_handle.h>
39
40
41/* Hide the symbol so that no definition but the one locally in the
42 executable or DSO is used. */
43int
44#ifndef __pthread_atfork
45/* Don't mark the compatibility function as hidden. */
46attribute_hidden
47#endif
48__pthread_atfork (void (*prepare) (void), void (*parent) (void),
49 void (*child) (void))
50{
51 return __register_atfork (prepare, parent, child, __dso_handle);
52}
53#ifndef __pthread_atfork
54extern int pthread_atfork (void (*prepare) (void), void (*parent) (void),
55 void (*child) (void)) attribute_hidden;
56weak_alias (__pthread_atfork, pthread_atfork)
57#endif
libc/glibc/posix/bits/cpu-set.h created+124
...@@ -0,0 +1,124 @@
1/* Definition of the cpu_set_t structure used by the POSIX 1003.1b-1993
2 scheduling interface.
3 Copyright (C) 1996-2019 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
19
20#ifndef _BITS_CPU_SET_H
21#define _BITS_CPU_SET_H 1
22
23#ifndef _SCHED_H
24# error "Never include <bits/cpu-set.h> directly; use <sched.h> instead."
25#endif
26
27/* Size definition for CPU sets. */
28#define __CPU_SETSIZE 1024
29#define __NCPUBITS (8 * sizeof (__cpu_mask))
30
31/* Type for array elements in 'cpu_set_t'. */
32typedef __CPU_MASK_TYPE __cpu_mask;
33
34/* Basic access functions. */
35#define __CPUELT(cpu) ((cpu) / __NCPUBITS)
36#define __CPUMASK(cpu) ((__cpu_mask) 1 << ((cpu) % __NCPUBITS))
37
38/* Data structure to describe CPU mask. */
39typedef struct
40{
41 __cpu_mask __bits[__CPU_SETSIZE / __NCPUBITS];
42} cpu_set_t;
43
44/* Access functions for CPU masks. */
45#if __GNUC_PREREQ (2, 91)
46# define __CPU_ZERO_S(setsize, cpusetp) \
47 do __builtin_memset (cpusetp, '\0', setsize); while (0)
48#else
49# define __CPU_ZERO_S(setsize, cpusetp) \
50 do { \
51 size_t __i; \
52 size_t __imax = (setsize) / sizeof (__cpu_mask); \
53 __cpu_mask *__bits = (cpusetp)->__bits; \
54 for (__i = 0; __i < __imax; ++__i) \
55 __bits[__i] = 0; \
56 } while (0)
57#endif
58#define __CPU_SET_S(cpu, setsize, cpusetp) \
59 (__extension__ \
60 ({ size_t __cpu = (cpu); \
61 __cpu / 8 < (setsize) \
62 ? (((__cpu_mask *) ((cpusetp)->__bits))[__CPUELT (__cpu)] \
63 |= __CPUMASK (__cpu)) \
64 : 0; }))
65#define __CPU_CLR_S(cpu, setsize, cpusetp) \
66 (__extension__ \
67 ({ size_t __cpu = (cpu); \
68 __cpu / 8 < (setsize) \
69 ? (((__cpu_mask *) ((cpusetp)->__bits))[__CPUELT (__cpu)] \
70 &= ~__CPUMASK (__cpu)) \
71 : 0; }))
72#define __CPU_ISSET_S(cpu, setsize, cpusetp) \
73 (__extension__ \
74 ({ size_t __cpu = (cpu); \
75 __cpu / 8 < (setsize) \
76 ? ((((const __cpu_mask *) ((cpusetp)->__bits))[__CPUELT (__cpu)] \
77 & __CPUMASK (__cpu))) != 0 \
78 : 0; }))
79
80#define __CPU_COUNT_S(setsize, cpusetp) \
81 __sched_cpucount (setsize, cpusetp)
82
83#if __GNUC_PREREQ (2, 91)
84# define __CPU_EQUAL_S(setsize, cpusetp1, cpusetp2) \
85 (__builtin_memcmp (cpusetp1, cpusetp2, setsize) == 0)
86#else
87# define __CPU_EQUAL_S(setsize, cpusetp1, cpusetp2) \
88 (__extension__ \
89 ({ const __cpu_mask *__arr1 = (cpusetp1)->__bits; \
90 const __cpu_mask *__arr2 = (cpusetp2)->__bits; \
91 size_t __imax = (setsize) / sizeof (__cpu_mask); \
92 size_t __i; \
93 for (__i = 0; __i < __imax; ++__i) \
94 if (__arr1[__i] != __arr2[__i]) \
95 break; \
96 __i == __imax; }))
97#endif
98
99#define __CPU_OP_S(setsize, destset, srcset1, srcset2, op) \
100 (__extension__ \
101 ({ cpu_set_t *__dest = (destset); \
102 const __cpu_mask *__arr1 = (srcset1)->__bits; \
103 const __cpu_mask *__arr2 = (srcset2)->__bits; \
104 size_t __imax = (setsize) / sizeof (__cpu_mask); \
105 size_t __i; \
106 for (__i = 0; __i < __imax; ++__i) \
107 ((__cpu_mask *) __dest->__bits)[__i] = __arr1[__i] op __arr2[__i]; \
108 __dest; }))
109
110#define __CPU_ALLOC_SIZE(count) \
111 ((((count) + __NCPUBITS - 1) / __NCPUBITS) * sizeof (__cpu_mask))
112#define __CPU_ALLOC(count) __sched_cpualloc (count)
113#define __CPU_FREE(cpuset) __sched_cpufree (cpuset)
114
115__BEGIN_DECLS
116
117extern int __sched_cpucount (size_t __setsize, const cpu_set_t *__setp)
118 __THROW;
119extern cpu_set_t *__sched_cpualloc (size_t __count) __THROW __wur;
120extern void __sched_cpufree (cpu_set_t *__set) __THROW;
121
122__END_DECLS
123
124#endif /* bits/cpu-set.h */
libc/glibc/posix/bits/types.h created+224
...@@ -0,0 +1,224 @@
1/* bits/types.h -- definitions of __*_t types underlying *_t types.
2 Copyright (C) 2002-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19/*
20 * Never include this file directly; use <sys/types.h> instead.
21 */
22
23#ifndef _BITS_TYPES_H
24#define _BITS_TYPES_H 1
25
26#include <features.h>
27#include <bits/wordsize.h>
28#include <bits/timesize.h>
29
30/* Convenience types. */
31typedef unsigned char __u_char;
32typedef unsigned short int __u_short;
33typedef unsigned int __u_int;
34typedef unsigned long int __u_long;
35
36/* Fixed-size types, underlying types depend on word size and compiler. */
37typedef signed char __int8_t;
38typedef unsigned char __uint8_t;
39typedef signed short int __int16_t;
40typedef unsigned short int __uint16_t;
41typedef signed int __int32_t;
42typedef unsigned int __uint32_t;
43#if __WORDSIZE == 64
44typedef signed long int __int64_t;
45typedef unsigned long int __uint64_t;
46#else
47__extension__ typedef signed long long int __int64_t;
48__extension__ typedef unsigned long long int __uint64_t;
49#endif
50
51/* Smallest types with at least a given width. */
52typedef __int8_t __int_least8_t;
53typedef __uint8_t __uint_least8_t;
54typedef __int16_t __int_least16_t;
55typedef __uint16_t __uint_least16_t;
56typedef __int32_t __int_least32_t;
57typedef __uint32_t __uint_least32_t;
58typedef __int64_t __int_least64_t;
59typedef __uint64_t __uint_least64_t;
60
61/* quad_t is also 64 bits. */
62#if __WORDSIZE == 64
63typedef long int __quad_t;
64typedef unsigned long int __u_quad_t;
65#else
66__extension__ typedef long long int __quad_t;
67__extension__ typedef unsigned long long int __u_quad_t;
68#endif
69
70/* Largest integral types. */
71#if __WORDSIZE == 64
72typedef long int __intmax_t;
73typedef unsigned long int __uintmax_t;
74#else
75__extension__ typedef long long int __intmax_t;
76__extension__ typedef unsigned long long int __uintmax_t;
77#endif
78
79
80/* The machine-dependent file <bits/typesizes.h> defines __*_T_TYPE
81 macros for each of the OS types we define below. The definitions
82 of those macros must use the following macros for underlying types.
83 We define __S<SIZE>_TYPE and __U<SIZE>_TYPE for the signed and unsigned
84 variants of each of the following integer types on this machine.
85
86 16 -- "natural" 16-bit type (always short)
87 32 -- "natural" 32-bit type (always int)
88 64 -- "natural" 64-bit type (long or long long)
89 LONG32 -- 32-bit type, traditionally long
90 QUAD -- 64-bit type, always long long
91 WORD -- natural type of __WORDSIZE bits (int or long)
92 LONGWORD -- type of __WORDSIZE bits, traditionally long
93
94 We distinguish WORD/LONGWORD, 32/LONG32, and 64/QUAD so that the
95 conventional uses of `long' or `long long' type modifiers match the
96 types we define, even when a less-adorned type would be the same size.
97 This matters for (somewhat) portably writing printf/scanf formats for
98 these types, where using the appropriate l or ll format modifiers can
99 make the typedefs and the formats match up across all GNU platforms. If
100 we used `long' when it's 64 bits where `long long' is expected, then the
101 compiler would warn about the formats not matching the argument types,
102 and the programmer changing them to shut up the compiler would break the
103 program's portability.
104
105 Here we assume what is presently the case in all the GCC configurations
106 we support: long long is always 64 bits, long is always word/address size,
107 and int is always 32 bits. */
108
109#define __S16_TYPE short int
110#define __U16_TYPE unsigned short int
111#define __S32_TYPE int
112#define __U32_TYPE unsigned int
113#define __SLONGWORD_TYPE long int
114#define __ULONGWORD_TYPE unsigned long int
115#if __WORDSIZE == 32
116# define __SQUAD_TYPE __quad_t
117# define __UQUAD_TYPE __u_quad_t
118# define __SWORD_TYPE int
119# define __UWORD_TYPE unsigned int
120# define __SLONG32_TYPE long int
121# define __ULONG32_TYPE unsigned long int
122# define __S64_TYPE __quad_t
123# define __U64_TYPE __u_quad_t
124/* We want __extension__ before typedef's that use nonstandard base types
125 such as `long long' in C89 mode. */
126# define __STD_TYPE __extension__ typedef
127#elif __WORDSIZE == 64
128# define __SQUAD_TYPE long int
129# define __UQUAD_TYPE unsigned long int
130# define __SWORD_TYPE long int
131# define __UWORD_TYPE unsigned long int
132# define __SLONG32_TYPE int
133# define __ULONG32_TYPE unsigned int
134# define __S64_TYPE long int
135# define __U64_TYPE unsigned long int
136/* No need to mark the typedef with __extension__. */
137# define __STD_TYPE typedef
138#else
139# error
140#endif
141#include <bits/typesizes.h> /* Defines __*_T_TYPE macros. */
142#include <bits/time64.h> /* Defines __TIME*_T_TYPE macros. */
143
144
145__STD_TYPE __DEV_T_TYPE __dev_t; /* Type of device numbers. */
146__STD_TYPE __UID_T_TYPE __uid_t; /* Type of user identifications. */
147__STD_TYPE __GID_T_TYPE __gid_t; /* Type of group identifications. */
148__STD_TYPE __INO_T_TYPE __ino_t; /* Type of file serial numbers. */
149__STD_TYPE __INO64_T_TYPE __ino64_t; /* Type of file serial numbers (LFS).*/
150__STD_TYPE __MODE_T_TYPE __mode_t; /* Type of file attribute bitmasks. */
151__STD_TYPE __NLINK_T_TYPE __nlink_t; /* Type of file link counts. */
152__STD_TYPE __OFF_T_TYPE __off_t; /* Type of file sizes and offsets. */
153__STD_TYPE __OFF64_T_TYPE __off64_t; /* Type of file sizes and offsets (LFS). */
154__STD_TYPE __PID_T_TYPE __pid_t; /* Type of process identifications. */
155__STD_TYPE __FSID_T_TYPE __fsid_t; /* Type of file system IDs. */
156__STD_TYPE __CLOCK_T_TYPE __clock_t; /* Type of CPU usage counts. */
157__STD_TYPE __RLIM_T_TYPE __rlim_t; /* Type for resource measurement. */
158__STD_TYPE __RLIM64_T_TYPE __rlim64_t; /* Type for resource measurement (LFS). */
159__STD_TYPE __ID_T_TYPE __id_t; /* General type for IDs. */
160__STD_TYPE __TIME_T_TYPE __time_t; /* Seconds since the Epoch. */
161__STD_TYPE __USECONDS_T_TYPE __useconds_t; /* Count of microseconds. */
162__STD_TYPE __SUSECONDS_T_TYPE __suseconds_t; /* Signed count of microseconds. */
163
164__STD_TYPE __DADDR_T_TYPE __daddr_t; /* The type of a disk address. */
165__STD_TYPE __KEY_T_TYPE __key_t; /* Type of an IPC key. */
166
167/* Clock ID used in clock and timer functions. */
168__STD_TYPE __CLOCKID_T_TYPE __clockid_t;
169
170/* Timer ID returned by `timer_create'. */
171__STD_TYPE __TIMER_T_TYPE __timer_t;
172
173/* Type to represent block size. */
174__STD_TYPE __BLKSIZE_T_TYPE __blksize_t;
175
176/* Types from the Large File Support interface. */
177
178/* Type to count number of disk blocks. */
179__STD_TYPE __BLKCNT_T_TYPE __blkcnt_t;
180__STD_TYPE __BLKCNT64_T_TYPE __blkcnt64_t;
181
182/* Type to count file system blocks. */
183__STD_TYPE __FSBLKCNT_T_TYPE __fsblkcnt_t;
184__STD_TYPE __FSBLKCNT64_T_TYPE __fsblkcnt64_t;
185
186/* Type to count file system nodes. */
187__STD_TYPE __FSFILCNT_T_TYPE __fsfilcnt_t;
188__STD_TYPE __FSFILCNT64_T_TYPE __fsfilcnt64_t;
189
190/* Type of miscellaneous file system fields. */
191__STD_TYPE __FSWORD_T_TYPE __fsword_t;
192
193__STD_TYPE __SSIZE_T_TYPE __ssize_t; /* Type of a byte count, or error. */
194
195/* Signed long type used in system calls. */
196__STD_TYPE __SYSCALL_SLONG_TYPE __syscall_slong_t;
197/* Unsigned long type used in system calls. */
198__STD_TYPE __SYSCALL_ULONG_TYPE __syscall_ulong_t;
199
200/* These few don't really vary by system, they always correspond
201 to one of the other defined types. */
202typedef __off64_t __loff_t; /* Type of file sizes and offsets (LFS). */
203typedef char *__caddr_t;
204
205/* Duplicates info from stdint.h but this is used in unistd.h. */
206__STD_TYPE __SWORD_TYPE __intptr_t;
207
208/* Duplicate info from sys/socket.h. */
209__STD_TYPE __U32_TYPE __socklen_t;
210
211/* C99: An integer type that can be accessed as an atomic entity,
212 even in the presence of asynchronous interrupts.
213 It is not currently necessary for this to be machine-specific. */
214typedef int __sig_atomic_t;
215
216#if __TIMESIZE == 64
217# define __time64_t __time_t
218#else
219__STD_TYPE __TIME64_T_TYPE __time64_t; /* Seconds since the Epoch. */
220#endif
221
222#undef __STD_TYPE
223
224#endif /* bits/types.h */
libc/glibc/posix/sched.h created+131
...@@ -0,0 +1,131 @@
1/* Definitions for POSIX 1003.1b-1993 (aka POSIX.4) scheduling interface.
2 Copyright (C) 1996-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SCHED_H
20#define _SCHED_H 1
21
22#include <features.h>
23
24/* Get type definitions. */
25#include <bits/types.h>
26
27#define __need_size_t
28#define __need_NULL
29#include <stddef.h>
30
31#include <bits/types/time_t.h>
32#include <bits/types/struct_timespec.h>
33#ifndef __USE_XOPEN2K
34# include <time.h>
35#endif
36
37#ifndef __pid_t_defined
38typedef __pid_t pid_t;
39# define __pid_t_defined
40#endif
41
42/* Get system specific constant and data structure definitions. */
43#include <bits/sched.h>
44#include <bits/cpu-set.h>
45
46/* Backward compatibility. */
47#define sched_priority sched_priority
48#define __sched_priority sched_priority
49
50
51__BEGIN_DECLS
52
53/* Set scheduling parameters for a process. */
54extern int sched_setparam (__pid_t __pid, const struct sched_param *__param)
55 __THROW;
56
57/* Retrieve scheduling parameters for a particular process. */
58extern int sched_getparam (__pid_t __pid, struct sched_param *__param) __THROW;
59
60/* Set scheduling algorithm and/or parameters for a process. */
61extern int sched_setscheduler (__pid_t __pid, int __policy,
62 const struct sched_param *__param) __THROW;
63
64/* Retrieve scheduling algorithm for a particular purpose. */
65extern int sched_getscheduler (__pid_t __pid) __THROW;
66
67/* Yield the processor. */
68extern int sched_yield (void) __THROW;
69
70/* Get maximum priority value for a scheduler. */
71extern int sched_get_priority_max (int __algorithm) __THROW;
72
73/* Get minimum priority value for a scheduler. */
74extern int sched_get_priority_min (int __algorithm) __THROW;
75
76/* Get the SCHED_RR interval for the named process. */
77extern int sched_rr_get_interval (__pid_t __pid, struct timespec *__t) __THROW;
78
79
80#ifdef __USE_GNU
81/* Access macros for `cpu_set'. */
82# define CPU_SETSIZE __CPU_SETSIZE
83# define CPU_SET(cpu, cpusetp) __CPU_SET_S (cpu, sizeof (cpu_set_t), cpusetp)
84# define CPU_CLR(cpu, cpusetp) __CPU_CLR_S (cpu, sizeof (cpu_set_t), cpusetp)
85# define CPU_ISSET(cpu, cpusetp) __CPU_ISSET_S (cpu, sizeof (cpu_set_t), \
86 cpusetp)
87# define CPU_ZERO(cpusetp) __CPU_ZERO_S (sizeof (cpu_set_t), cpusetp)
88# define CPU_COUNT(cpusetp) __CPU_COUNT_S (sizeof (cpu_set_t), cpusetp)
89
90# define CPU_SET_S(cpu, setsize, cpusetp) __CPU_SET_S (cpu, setsize, cpusetp)
91# define CPU_CLR_S(cpu, setsize, cpusetp) __CPU_CLR_S (cpu, setsize, cpusetp)
92# define CPU_ISSET_S(cpu, setsize, cpusetp) __CPU_ISSET_S (cpu, setsize, \
93 cpusetp)
94# define CPU_ZERO_S(setsize, cpusetp) __CPU_ZERO_S (setsize, cpusetp)
95# define CPU_COUNT_S(setsize, cpusetp) __CPU_COUNT_S (setsize, cpusetp)
96
97# define CPU_EQUAL(cpusetp1, cpusetp2) \
98 __CPU_EQUAL_S (sizeof (cpu_set_t), cpusetp1, cpusetp2)
99# define CPU_EQUAL_S(setsize, cpusetp1, cpusetp2) \
100 __CPU_EQUAL_S (setsize, cpusetp1, cpusetp2)
101
102# define CPU_AND(destset, srcset1, srcset2) \
103 __CPU_OP_S (sizeof (cpu_set_t), destset, srcset1, srcset2, &)
104# define CPU_OR(destset, srcset1, srcset2) \
105 __CPU_OP_S (sizeof (cpu_set_t), destset, srcset1, srcset2, |)
106# define CPU_XOR(destset, srcset1, srcset2) \
107 __CPU_OP_S (sizeof (cpu_set_t), destset, srcset1, srcset2, ^)
108# define CPU_AND_S(setsize, destset, srcset1, srcset2) \
109 __CPU_OP_S (setsize, destset, srcset1, srcset2, &)
110# define CPU_OR_S(setsize, destset, srcset1, srcset2) \
111 __CPU_OP_S (setsize, destset, srcset1, srcset2, |)
112# define CPU_XOR_S(setsize, destset, srcset1, srcset2) \
113 __CPU_OP_S (setsize, destset, srcset1, srcset2, ^)
114
115# define CPU_ALLOC_SIZE(count) __CPU_ALLOC_SIZE (count)
116# define CPU_ALLOC(count) __CPU_ALLOC (count)
117# define CPU_FREE(cpuset) __CPU_FREE (cpuset)
118
119
120/* Set the CPU affinity for a task */
121extern int sched_setaffinity (__pid_t __pid, size_t __cpusetsize,
122 const cpu_set_t *__cpuset) __THROW;
123
124/* Get the CPU affinity for a task */
125extern int sched_getaffinity (__pid_t __pid, size_t __cpusetsize,
126 cpu_set_t *__cpuset) __THROW;
127#endif
128
129__END_DECLS
130
131#endif /* sched.h */
libc/glibc/posix/sys/types.h created+249
...@@ -0,0 +1,249 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/*
19 * POSIX Standard: 2.6 Primitive System Data Types <sys/types.h>
20 */
21
22#ifndef _SYS_TYPES_H
23#define _SYS_TYPES_H 1
24
25#include <features.h>
26
27__BEGIN_DECLS
28
29#include <bits/types.h>
30
31#ifdef __USE_MISC
32# ifndef __u_char_defined
33typedef __u_char u_char;
34typedef __u_short u_short;
35typedef __u_int u_int;
36typedef __u_long u_long;
37typedef __quad_t quad_t;
38typedef __u_quad_t u_quad_t;
39typedef __fsid_t fsid_t;
40# define __u_char_defined
41# endif
42typedef __loff_t loff_t;
43#endif
44
45#ifndef __ino_t_defined
46# ifndef __USE_FILE_OFFSET64
47typedef __ino_t ino_t;
48# else
49typedef __ino64_t ino_t;
50# endif
51# define __ino_t_defined
52#endif
53#if defined __USE_LARGEFILE64 && !defined __ino64_t_defined
54typedef __ino64_t ino64_t;
55# define __ino64_t_defined
56#endif
57
58#ifndef __dev_t_defined
59typedef __dev_t dev_t;
60# define __dev_t_defined
61#endif
62
63#ifndef __gid_t_defined
64typedef __gid_t gid_t;
65# define __gid_t_defined
66#endif
67
68#ifndef __mode_t_defined
69typedef __mode_t mode_t;
70# define __mode_t_defined
71#endif
72
73#ifndef __nlink_t_defined
74typedef __nlink_t nlink_t;
75# define __nlink_t_defined
76#endif
77
78#ifndef __uid_t_defined
79typedef __uid_t uid_t;
80# define __uid_t_defined
81#endif
82
83#ifndef __off_t_defined
84# ifndef __USE_FILE_OFFSET64
85typedef __off_t off_t;
86# else
87typedef __off64_t off_t;
88# endif
89# define __off_t_defined
90#endif
91#if defined __USE_LARGEFILE64 && !defined __off64_t_defined
92typedef __off64_t off64_t;
93# define __off64_t_defined
94#endif
95
96#ifndef __pid_t_defined
97typedef __pid_t pid_t;
98# define __pid_t_defined
99#endif
100
101#if (defined __USE_XOPEN || defined __USE_XOPEN2K8) \
102 && !defined __id_t_defined
103typedef __id_t id_t;
104# define __id_t_defined
105#endif
106
107#ifndef __ssize_t_defined
108typedef __ssize_t ssize_t;
109# define __ssize_t_defined
110#endif
111
112#ifdef __USE_MISC
113# ifndef __daddr_t_defined
114typedef __daddr_t daddr_t;
115typedef __caddr_t caddr_t;
116# define __daddr_t_defined
117# endif
118#endif
119
120#if (defined __USE_MISC || defined __USE_XOPEN) && !defined __key_t_defined
121typedef __key_t key_t;
122# define __key_t_defined
123#endif
124
125#if defined __USE_XOPEN || defined __USE_XOPEN2K8
126# include <bits/types/clock_t.h>
127#endif
128#include <bits/types/clockid_t.h>
129#include <bits/types/time_t.h>
130#include <bits/types/timer_t.h>
131
132#ifdef __USE_XOPEN
133# ifndef __useconds_t_defined
134typedef __useconds_t useconds_t;
135# define __useconds_t_defined
136# endif
137# ifndef __suseconds_t_defined
138typedef __suseconds_t suseconds_t;
139# define __suseconds_t_defined
140# endif
141#endif
142
143#define __need_size_t
144#include <stddef.h>
145
146#ifdef __USE_MISC
147/* Old compatibility names for C types. */
148typedef unsigned long int ulong;
149typedef unsigned short int ushort;
150typedef unsigned int uint;
151#endif
152
153/* These size-specific names are used by some of the inet code. */
154
155#include <bits/stdint-intn.h>
156
157#if !__GNUC_PREREQ (2, 7)
158
159/* These were defined by ISO C without the first `_'. */
160typedef unsigned char u_int8_t;
161typedef unsigned short int u_int16_t;
162typedef unsigned int u_int32_t;
163# if __WORDSIZE == 64
164typedef unsigned long int u_int64_t;
165# else
166__extension__ typedef unsigned long long int u_int64_t;
167# endif
168
169typedef int register_t;
170
171#else
172
173/* For GCC 2.7 and later, we can use specific type-size attributes. */
174# define __u_intN_t(N, MODE) \
175 typedef unsigned int u_int##N##_t __attribute__ ((__mode__ (MODE)))
176
177__u_intN_t (8, __QI__);
178__u_intN_t (16, __HI__);
179__u_intN_t (32, __SI__);
180__u_intN_t (64, __DI__);
181
182typedef int register_t __attribute__ ((__mode__ (__word__)));
183
184
185/* Some code from BIND tests this macro to see if the types above are
186 defined. */
187#endif
188#define __BIT_TYPES_DEFINED__ 1
189
190
191#ifdef __USE_MISC
192/* In BSD <sys/types.h> is expected to define BYTE_ORDER. */
193# include <endian.h>
194
195/* It also defines `fd_set' and the FD_* macros for `select'. */
196# include <sys/select.h>
197#endif /* Use misc. */
198
199
200#if (defined __USE_UNIX98 || defined __USE_XOPEN2K8) \
201 && !defined __blksize_t_defined
202typedef __blksize_t blksize_t;
203# define __blksize_t_defined
204#endif
205
206/* Types from the Large File Support interface. */
207#ifndef __USE_FILE_OFFSET64
208# ifndef __blkcnt_t_defined
209typedef __blkcnt_t blkcnt_t; /* Type to count number of disk blocks. */
210# define __blkcnt_t_defined
211# endif
212# ifndef __fsblkcnt_t_defined
213typedef __fsblkcnt_t fsblkcnt_t; /* Type to count file system blocks. */
214# define __fsblkcnt_t_defined
215# endif
216# ifndef __fsfilcnt_t_defined
217typedef __fsfilcnt_t fsfilcnt_t; /* Type to count file system inodes. */
218# define __fsfilcnt_t_defined
219# endif
220#else
221# ifndef __blkcnt_t_defined
222typedef __blkcnt64_t blkcnt_t; /* Type to count number of disk blocks. */
223# define __blkcnt_t_defined
224# endif
225# ifndef __fsblkcnt_t_defined
226typedef __fsblkcnt64_t fsblkcnt_t; /* Type to count file system blocks. */
227# define __fsblkcnt_t_defined
228# endif
229# ifndef __fsfilcnt_t_defined
230typedef __fsfilcnt64_t fsfilcnt_t; /* Type to count file system inodes. */
231# define __fsfilcnt_t_defined
232# endif
233#endif
234
235#ifdef __USE_LARGEFILE64
236typedef __blkcnt64_t blkcnt64_t; /* Type to count number of disk blocks. */
237typedef __fsblkcnt64_t fsblkcnt64_t; /* Type to count file system blocks. */
238typedef __fsfilcnt64_t fsfilcnt64_t; /* Type to count file system inodes. */
239#endif
240
241
242/* Now add the thread types. */
243#if defined __USE_POSIX199506 || defined __USE_UNIX98
244# include <bits/pthreadtypes.h>
245#endif
246
247__END_DECLS
248
249#endif /* sys/types.h */
libc/glibc/setjmp/setjmp.h created+105
...@@ -0,0 +1,105 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/*
19 * ISO C99 Standard: 7.13 Nonlocal jumps <setjmp.h>
20 */
21
22#ifndef _SETJMP_H
23#define _SETJMP_H 1
24
25#include <features.h>
26
27__BEGIN_DECLS
28
29#include <bits/setjmp.h> /* Get `__jmp_buf'. */
30#include <bits/types/__sigset_t.h>
31
32/* Calling environment, plus possibly a saved signal mask. */
33struct __jmp_buf_tag
34 {
35 /* NOTE: The machine-dependent definitions of `__sigsetjmp'
36 assume that a `jmp_buf' begins with a `__jmp_buf' and that
37 `__mask_was_saved' follows it. Do not move these members
38 or add others before it. */
39 __jmp_buf __jmpbuf; /* Calling environment. */
40 int __mask_was_saved; /* Saved the signal mask? */
41 __sigset_t __saved_mask; /* Saved signal mask. */
42 };
43
44
45typedef struct __jmp_buf_tag jmp_buf[1];
46
47/* Store the calling environment in ENV, also saving the signal mask.
48 Return 0. */
49extern int setjmp (jmp_buf __env) __THROWNL;
50
51/* Store the calling environment in ENV, also saving the
52 signal mask if SAVEMASK is nonzero. Return 0.
53 This is the internal name for `sigsetjmp'. */
54extern int __sigsetjmp (struct __jmp_buf_tag __env[1], int __savemask) __THROWNL;
55
56/* Store the calling environment in ENV, not saving the signal mask.
57 Return 0. */
58extern int _setjmp (struct __jmp_buf_tag __env[1]) __THROWNL;
59
60/* Do not save the signal mask. This is equivalent to the `_setjmp'
61 BSD function. */
62#define setjmp(env) _setjmp (env)
63
64
65/* Jump to the environment saved in ENV, making the
66 `setjmp' call there return VAL, or 1 if VAL is 0. */
67extern void longjmp (struct __jmp_buf_tag __env[1], int __val)
68 __THROWNL __attribute__ ((__noreturn__));
69
70#if defined __USE_MISC || defined __USE_XOPEN
71/* Same. Usually `_longjmp' is used with `_setjmp', which does not save
72 the signal mask. But it is how ENV was saved that determines whether
73 `longjmp' restores the mask; `_longjmp' is just an alias. */
74extern void _longjmp (struct __jmp_buf_tag __env[1], int __val)
75 __THROWNL __attribute__ ((__noreturn__));
76#endif
77
78
79#ifdef __USE_POSIX
80/* Use the same type for `jmp_buf' and `sigjmp_buf'.
81 The `__mask_was_saved' flag determines whether
82 or not `longjmp' will restore the signal mask. */
83typedef struct __jmp_buf_tag sigjmp_buf[1];
84
85/* Store the calling environment in ENV, also saving the
86 signal mask if SAVEMASK is nonzero. Return 0. */
87# define sigsetjmp(env, savemask) __sigsetjmp (env, savemask)
88
89/* Jump to the environment saved in ENV, making the
90 sigsetjmp call there return VAL, or 1 if VAL is 0.
91 Restore the signal mask if that sigsetjmp call saved it.
92 This is just an alias `longjmp'. */
93extern void siglongjmp (sigjmp_buf __env, int __val)
94 __THROWNL __attribute__ ((__noreturn__));
95#endif /* Use POSIX. */
96
97
98/* Define helper functions to catch unsafe code. */
99#if __USE_FORTIFY_LEVEL > 0
100# include <bits/setjmp2.h>
101#endif
102
103__END_DECLS
104
105#endif /* setjmp.h */
libc/glibc/signal/bits/types/sig_atomic_t.h created+10
...@@ -0,0 +1,10 @@
1#ifndef __sig_atomic_t_defined
2#define __sig_atomic_t_defined 1
3
4#include <bits/types.h>
5
6/* An integral type that can be modified atomically, without the
7 possibility of a signal arriving in the middle of the operation. */
8typedef __sig_atomic_t sig_atomic_t;
9
10#endif
libc/glibc/signal/bits/types/sigset_t.h created+9
...@@ -0,0 +1,9 @@
1#ifndef __sigset_t_defined
2#define __sigset_t_defined 1
3
4#include <bits/types/__sigset_t.h>
5
6/* A set of signals to be blocked, unblocked, or waited for. */
7typedef __sigset_t sigset_t;
8
9#endif
libc/glibc/signal/signal.h created+375
...@@ -0,0 +1,375 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/*
19 * ISO C99 Standard: 7.14 Signal handling <signal.h>
20 */
21
22#ifndef _SIGNAL_H
23#define _SIGNAL_H
24
25#include <features.h>
26
27__BEGIN_DECLS
28
29#include <bits/types.h>
30#include <bits/signum.h>
31
32#include <bits/types/sig_atomic_t.h>
33
34#if defined __USE_POSIX
35#include <bits/types/sigset_t.h>
36#endif
37
38#if defined __USE_XOPEN || defined __USE_XOPEN2K
39# ifndef __pid_t_defined
40typedef __pid_t pid_t;
41# define __pid_t_defined
42#endif
43#ifdef __USE_XOPEN
44# endif
45# ifndef __uid_t_defined
46typedef __uid_t uid_t;
47# define __uid_t_defined
48# endif
49#endif /* Unix98 */
50
51#ifdef __USE_POSIX199309
52/* We need `struct timespec' later on. */
53# include <bits/types/struct_timespec.h>
54#endif
55
56#if defined __USE_POSIX199309 || defined __USE_XOPEN_EXTENDED
57# include <bits/types/siginfo_t.h>
58# include <bits/siginfo-consts.h>
59#endif
60
61#ifdef __USE_MISC
62# include <bits/types/sigval_t.h>
63#endif
64
65#ifdef __USE_POSIX199309
66# include <bits/types/sigevent_t.h>
67# include <bits/sigevent-consts.h>
68#endif
69
70
71/* Type of a signal handler. */
72typedef void (*__sighandler_t) (int);
73
74/* The X/Open definition of `signal' specifies the SVID semantic. Use
75 the additional function `sysv_signal' when X/Open compatibility is
76 requested. */
77extern __sighandler_t __sysv_signal (int __sig, __sighandler_t __handler)
78 __THROW;
79#ifdef __USE_GNU
80extern __sighandler_t sysv_signal (int __sig, __sighandler_t __handler)
81 __THROW;
82#endif
83
84/* Set the handler for the signal SIG to HANDLER, returning the old
85 handler, or SIG_ERR on error.
86 By default `signal' has the BSD semantic. */
87#ifdef __USE_MISC
88extern __sighandler_t signal (int __sig, __sighandler_t __handler)
89 __THROW;
90#else
91/* Make sure the used `signal' implementation is the SVID version. */
92# ifdef __REDIRECT_NTH
93extern __sighandler_t __REDIRECT_NTH (signal,
94 (int __sig, __sighandler_t __handler),
95 __sysv_signal);
96# else
97# define signal __sysv_signal
98# endif
99#endif
100
101#if defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8
102/* The X/Open definition of `signal' conflicts with the BSD version.
103 So they defined another function `bsd_signal'. */
104extern __sighandler_t bsd_signal (int __sig, __sighandler_t __handler)
105 __THROW;
106#endif
107
108/* Send signal SIG to process number PID. If PID is zero,
109 send SIG to all processes in the current process's process group.
110 If PID is < -1, send SIG to all processes in process group - PID. */
111#ifdef __USE_POSIX
112extern int kill (__pid_t __pid, int __sig) __THROW;
113#endif /* Use POSIX. */
114
115#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
116/* Send SIG to all processes in process group PGRP.
117 If PGRP is zero, send SIG to all processes in
118 the current process's process group. */
119extern int killpg (__pid_t __pgrp, int __sig) __THROW;
120#endif /* Use misc || X/Open Unix. */
121
122/* Raise signal SIG, i.e., send SIG to yourself. */
123extern int raise (int __sig) __THROW;
124
125#ifdef __USE_MISC
126/* SVID names for the same things. */
127extern __sighandler_t ssignal (int __sig, __sighandler_t __handler)
128 __THROW;
129extern int gsignal (int __sig) __THROW;
130#endif /* Use misc. */
131
132#ifdef __USE_XOPEN2K8
133/* Print a message describing the meaning of the given signal number. */
134extern void psignal (int __sig, const char *__s);
135
136/* Print a message describing the meaning of the given signal information. */
137extern void psiginfo (const siginfo_t *__pinfo, const char *__s);
138#endif /* POSIX 2008. */
139
140
141
142/* The `sigpause' function in X/Open defines the argument as the
143 signal number. This requires redirecting to another function
144 because the default version in glibc uses an old BSD interface.
145
146 This function is a cancellation point and therefore not marked with
147 __THROW. */
148
149#ifdef __USE_XOPEN_EXTENDED
150# ifdef __GNUC__
151extern int sigpause (int __sig) __asm__ ("__xpg_sigpause");
152# else
153extern int __sigpause (int __sig_or_mask, int __is_sig);
154/* Remove a signal from the signal mask and suspend the process. */
155# define sigpause(sig) __sigpause ((sig), 1)
156# endif
157#endif
158
159
160#ifdef __USE_MISC
161/* None of the following functions should be used anymore. They are here
162 only for compatibility. A single word (`int') is not guaranteed to be
163 enough to hold a complete signal mask and therefore these functions
164 simply do not work in many situations. Use `sigprocmask' instead. */
165
166/* Compute mask for signal SIG. */
167# define sigmask(sig) ((int)(1u << ((sig) - 1)))
168
169/* Block signals in MASK, returning the old mask. */
170extern int sigblock (int __mask) __THROW __attribute_deprecated__;
171
172/* Set the mask of blocked signals to MASK, returning the old mask. */
173extern int sigsetmask (int __mask) __THROW __attribute_deprecated__;
174
175/* Return currently selected signal mask. */
176extern int siggetmask (void) __THROW __attribute_deprecated__;
177#endif /* Use misc. */
178
179
180#ifdef __USE_MISC
181# define NSIG _NSIG
182#endif
183
184#ifdef __USE_GNU
185typedef __sighandler_t sighandler_t;
186#endif
187
188/* 4.4 BSD uses the name `sig_t' for this. */
189#ifdef __USE_MISC
190typedef __sighandler_t sig_t;
191#endif
192
193#ifdef __USE_POSIX
194
195/* Clear all signals from SET. */
196extern int sigemptyset (sigset_t *__set) __THROW __nonnull ((1));
197
198/* Set all signals in SET. */
199extern int sigfillset (sigset_t *__set) __THROW __nonnull ((1));
200
201/* Add SIGNO to SET. */
202extern int sigaddset (sigset_t *__set, int __signo) __THROW __nonnull ((1));
203
204/* Remove SIGNO from SET. */
205extern int sigdelset (sigset_t *__set, int __signo) __THROW __nonnull ((1));
206
207/* Return 1 if SIGNO is in SET, 0 if not. */
208extern int sigismember (const sigset_t *__set, int __signo)
209 __THROW __nonnull ((1));
210
211# ifdef __USE_GNU
212/* Return non-empty value is SET is not empty. */
213extern int sigisemptyset (const sigset_t *__set) __THROW __nonnull ((1));
214
215/* Build new signal set by combining the two inputs set using logical AND. */
216extern int sigandset (sigset_t *__set, const sigset_t *__left,
217 const sigset_t *__right) __THROW __nonnull ((1, 2, 3));
218
219/* Build new signal set by combining the two inputs set using logical OR. */
220extern int sigorset (sigset_t *__set, const sigset_t *__left,
221 const sigset_t *__right) __THROW __nonnull ((1, 2, 3));
222# endif /* GNU */
223
224/* Get the system-specific definitions of `struct sigaction'
225 and the `SA_*' and `SIG_*'. constants. */
226# include <bits/sigaction.h>
227
228/* Get and/or change the set of blocked signals. */
229extern int sigprocmask (int __how, const sigset_t *__restrict __set,
230 sigset_t *__restrict __oset) __THROW;
231
232/* Change the set of blocked signals to SET,
233 wait until a signal arrives, and restore the set of blocked signals.
234
235 This function is a cancellation point and therefore not marked with
236 __THROW. */
237extern int sigsuspend (const sigset_t *__set) __nonnull ((1));
238
239/* Get and/or set the action for signal SIG. */
240extern int sigaction (int __sig, const struct sigaction *__restrict __act,
241 struct sigaction *__restrict __oact) __THROW;
242
243/* Put in SET all signals that are blocked and waiting to be delivered. */
244extern int sigpending (sigset_t *__set) __THROW __nonnull ((1));
245
246
247# ifdef __USE_POSIX199506
248/* Select any of pending signals from SET or wait for any to arrive.
249
250 This function is a cancellation point and therefore not marked with
251 __THROW. */
252extern int sigwait (const sigset_t *__restrict __set, int *__restrict __sig)
253 __nonnull ((1, 2));
254# endif /* Use POSIX 1995. */
255
256# ifdef __USE_POSIX199309
257/* Select any of pending signals from SET and place information in INFO.
258
259 This function is a cancellation point and therefore not marked with
260 __THROW. */
261extern int sigwaitinfo (const sigset_t *__restrict __set,
262 siginfo_t *__restrict __info) __nonnull ((1));
263
264/* Select any of pending signals from SET and place information in INFO.
265 Wait the time specified by TIMEOUT if no signal is pending.
266
267 This function is a cancellation point and therefore not marked with
268 __THROW. */
269extern int sigtimedwait (const sigset_t *__restrict __set,
270 siginfo_t *__restrict __info,
271 const struct timespec *__restrict __timeout)
272 __nonnull ((1));
273
274/* Send signal SIG to the process PID. Associate data in VAL with the
275 signal. */
276extern int sigqueue (__pid_t __pid, int __sig, const union sigval __val)
277 __THROW;
278# endif /* Use POSIX 199306. */
279
280#endif /* Use POSIX. */
281
282#ifdef __USE_MISC
283
284/* Names of the signals. This variable exists only for compatibility.
285 Use `strsignal' instead (see <string.h>). */
286extern const char *const _sys_siglist[_NSIG];
287extern const char *const sys_siglist[_NSIG];
288
289
290/* Get machine-dependent `struct sigcontext' and signal subcodes. */
291# include <bits/sigcontext.h>
292
293/* Restore the state saved in SCP. */
294extern int sigreturn (struct sigcontext *__scp) __THROW;
295
296#endif /* Use misc. */
297
298
299#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
300# define __need_size_t
301# include <stddef.h>
302
303# include <bits/types/stack_t.h>
304# if defined __USE_XOPEN || defined __USE_XOPEN2K8
305/* This will define `ucontext_t' and `mcontext_t'. */
306# include <sys/ucontext.h>
307# endif
308#endif /* Use POSIX.1-2008 or X/Open Unix. */
309
310#if defined __USE_XOPEN_EXTENDED || defined __USE_MISC
311/* If INTERRUPT is nonzero, make signal SIG interrupt system calls
312 (causing them to fail with EINTR); if INTERRUPT is zero, make system
313 calls be restarted after signal SIG. */
314extern int siginterrupt (int __sig, int __interrupt) __THROW;
315
316# include <bits/sigstack.h>
317# include <bits/ss_flags.h>
318
319/* Alternate signal handler stack interface.
320 This interface should always be preferred over `sigstack'. */
321extern int sigaltstack (const stack_t *__restrict __ss,
322 stack_t *__restrict __oss) __THROW;
323#endif /* __USE_XOPEN_EXTENDED || __USE_MISC */
324
325#if ((defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8) \
326 || defined __USE_MISC)
327# include <bits/types/struct_sigstack.h>
328#endif
329
330#if ((defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K) \
331 || defined __USE_MISC)
332/* Run signals handlers on the stack specified by SS (if not NULL).
333 If OSS is not NULL, it is filled in with the old signal stack status.
334 This interface is obsolete and on many platform not implemented. */
335extern int sigstack (struct sigstack *__ss, struct sigstack *__oss)
336 __THROW __attribute_deprecated__;
337#endif
338
339#ifdef __USE_XOPEN_EXTENDED
340/* Simplified interface for signal management. */
341
342/* Add SIG to the calling process' signal mask. */
343extern int sighold (int __sig) __THROW;
344
345/* Remove SIG from the calling process' signal mask. */
346extern int sigrelse (int __sig) __THROW;
347
348/* Set the disposition of SIG to SIG_IGN. */
349extern int sigignore (int __sig) __THROW;
350
351/* Set the disposition of SIG. */
352extern __sighandler_t sigset (int __sig, __sighandler_t __disp) __THROW;
353#endif
354
355#if defined __USE_POSIX199506 || defined __USE_UNIX98
356/* Some of the functions for handling signals in threaded programs must
357 be defined here. */
358# include <bits/pthreadtypes.h>
359# include <bits/sigthread.h>
360#endif /* use Unix98 */
361
362/* The following functions are used internally in the C library and in
363 other code which need deep insights. */
364
365/* Return number of available real-time signal with highest priority. */
366extern int __libc_current_sigrtmin (void) __THROW;
367/* Return number of available real-time signal with lowest priority. */
368extern int __libc_current_sigrtmax (void) __THROW;
369
370#define SIGRTMIN (__libc_current_sigrtmin ())
371#define SIGRTMAX (__libc_current_sigrtmax ())
372
373__END_DECLS
374
375#endif /* not signal.h */
libc/glibc/signal/sys/signal.h created+1
...@@ -0,0 +1 @@
1#include <signal.h>
libc/glibc/stdlib/alloca.h created+40
...@@ -0,0 +1,40 @@
1/* Copyright (C) 1992-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _ALLOCA_H
19#define _ALLOCA_H 1
20
21#include <features.h>
22
23#define __need_size_t
24#include <stddef.h>
25
26__BEGIN_DECLS
27
28/* Remove any previous definitions. */
29#undef alloca
30
31/* Allocate a block that will be freed when the calling function exits. */
32extern void *alloca (size_t __size) __THROW;
33
34#ifdef __GNUC__
35# define alloca(size) __builtin_alloca (size)
36#endif /* GCC. */
37
38__END_DECLS
39
40#endif /* alloca.h */
libc/glibc/stdlib/at_quick_exit.c created+46
...@@ -0,0 +1,46 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 In addition to the permissions in the GNU Lesser General Public
10 License, the Free Software Foundation gives you unlimited
11 permission to link the compiled version of this file with other
12 programs, and to distribute those programs without any restriction
13 coming from the use of this file. (The GNU Lesser General Public
14 License restrictions do apply in other respects; for example, they
15 cover modification of the file, and distribution when not linked
16 into another program.)
17
18 Note that people who make modified versions of this file are not
19 obligated to grant this special exception for their modified
20 versions; it is their choice whether to do so. The GNU Lesser
21 General Public License gives permission to release a modified
22 version without this exception; this exception also makes it
23 possible to release a modified version which carries forward this
24 exception.
25
26 The GNU C Library is distributed in the hope that it will be useful,
27 but WITHOUT ANY WARRANTY; without even the implied warranty of
28 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
29 Lesser General Public License for more details.
30
31 You should have received a copy of the GNU Lesser General Public
32 License along with the GNU C Library; if not, see
33 <http://www.gnu.org/licenses/>. */
34
35#include <stdlib.h>
36#include <dso_handle.h>
37#include "exit.h"
38
39
40/* Register FUNC to be executed by `quick_exit'. */
41int
42attribute_hidden
43at_quick_exit (void (*func) (void))
44{
45 return __cxa_at_quick_exit ((void (*) (void *)) func, __dso_handle);
46}
libc/glibc/stdlib/atexit.c created+47
...@@ -0,0 +1,47 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 In addition to the permissions in the GNU Lesser General Public
10 License, the Free Software Foundation gives you unlimited
11 permission to link the compiled version of this file with other
12 programs, and to distribute those programs without any restriction
13 coming from the use of this file. (The GNU Lesser General Public
14 License restrictions do apply in other respects; for example, they
15 cover modification of the file, and distribution when not linked
16 into another program.)
17
18 Note that people who make modified versions of this file are not
19 obligated to grant this special exception for their modified
20 versions; it is their choice whether to do so. The GNU Lesser
21 General Public License gives permission to release a modified
22 version without this exception; this exception also makes it
23 possible to release a modified version which carries forward this
24 exception.
25
26 The GNU C Library is distributed in the hope that it will be useful,
27 but WITHOUT ANY WARRANTY; without even the implied warranty of
28 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
29 Lesser General Public License for more details.
30
31 You should have received a copy of the GNU Lesser General Public
32 License along with the GNU C Library; if not, see
33 <http://www.gnu.org/licenses/>. */
34
35#include <stdlib.h>
36#include <dso_handle.h>
37#include "exit.h"
38
39/* Register FUNC to be executed by `exit'. */
40int
41#ifndef atexit
42attribute_hidden
43#endif
44atexit (void (*func) (void))
45{
46 return __cxa_atexit ((void (*) (void *)) func, NULL, __dso_handle);
47}
libc/glibc/stdlib/bits/stdlib-float.h created+29
...@@ -0,0 +1,29 @@
1/* Floating-point inline functions for stdlib.h.
2 Copyright (C) 2012-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _STDLIB_H
20# error "Never use <bits/stdlib-float.h> directly; include <stdlib.h> instead."
21#endif
22
23#ifdef __USE_EXTERN_INLINES
24__extern_inline double
25__NTH (atof (const char *__nptr))
26{
27 return strtod (__nptr, (char **) NULL);
28}
29#endif /* Optimizing and Inlining. */
libc/glibc/stdlib/exit.h created+94
...@@ -0,0 +1,94 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _EXIT_H
19#define _EXIT_H 1
20
21#include <stdbool.h>
22#include <stdint.h>
23#include <libc-lock.h>
24
25enum
26{
27 ef_free, /* `ef_free' MUST be zero! */
28 ef_us,
29 ef_on,
30 ef_at,
31 ef_cxa
32};
33
34struct exit_function
35 {
36 /* `flavour' should be of type of the `enum' above but since we need
37 this element in an atomic operation we have to use `long int'. */
38 long int flavor;
39 union
40 {
41 void (*at) (void);
42 struct
43 {
44 void (*fn) (int status, void *arg);
45 void *arg;
46 } on;
47 struct
48 {
49 void (*fn) (void *arg, int status);
50 void *arg;
51 void *dso_handle;
52 } cxa;
53 } func;
54 };
55struct exit_function_list
56 {
57 struct exit_function_list *next;
58 size_t idx;
59 struct exit_function fns[32];
60 };
61
62extern struct exit_function_list *__exit_funcs attribute_hidden;
63extern struct exit_function_list *__quick_exit_funcs attribute_hidden;
64extern uint64_t __new_exitfn_called attribute_hidden;
65
66/* True once all registered atexit/at_quick_exit/onexit handlers have been
67 called */
68extern bool __exit_funcs_done attribute_hidden;
69
70/* This lock protects __exit_funcs, __quick_exit_funcs, __exit_funcs_done
71 and __new_exitfn_called globals against simultaneous access from
72 atexit/on_exit/at_quick_exit in multiple threads, and also from
73 simultaneous access while another thread is in the middle of calling
74 exit handlers. See BZ#14333. Note: for lists, the entire list, and
75 each associated entry in the list, is protected for all access by this
76 lock. */
77__libc_lock_define (extern, __exit_funcs_lock);
78
79
80extern struct exit_function *__new_exitfn (struct exit_function_list **listp)
81 attribute_hidden;
82
83extern void __run_exit_handlers (int status,
84 struct exit_function_list **listp,
85 bool run_list_atexit, bool run_dtors)
86 attribute_hidden __attribute__ ((__noreturn__));
87
88extern int __internal_atexit (void (*func) (void *), void *arg, void *d,
89 struct exit_function_list **listp)
90 attribute_hidden;
91extern int __cxa_at_quick_exit (void (*func) (void *), void *d);
92
93
94#endif /* exit.h */
libc/glibc/stdlib/stdlib.h created+1022
...@@ -0,0 +1,1022 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/*
19 * ISO C99 Standard: 7.20 General utilities <stdlib.h>
20 */
21
22#ifndef _STDLIB_H
23
24#define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION
25#include <bits/libc-header-start.h>
26
27/* Get size_t, wchar_t and NULL from <stddef.h>. */
28#define __need_size_t
29#define __need_wchar_t
30#define __need_NULL
31#include <stddef.h>
32
33__BEGIN_DECLS
34
35#define _STDLIB_H 1
36
37#if (defined __USE_XOPEN || defined __USE_XOPEN2K8) && !defined _SYS_WAIT_H
38/* XPG requires a few symbols from <sys/wait.h> being defined. */
39# include <bits/waitflags.h>
40# include <bits/waitstatus.h>
41
42/* Define the macros <sys/wait.h> also would define this way. */
43# define WEXITSTATUS(status) __WEXITSTATUS (status)
44# define WTERMSIG(status) __WTERMSIG (status)
45# define WSTOPSIG(status) __WSTOPSIG (status)
46# define WIFEXITED(status) __WIFEXITED (status)
47# define WIFSIGNALED(status) __WIFSIGNALED (status)
48# define WIFSTOPPED(status) __WIFSTOPPED (status)
49# ifdef __WIFCONTINUED
50# define WIFCONTINUED(status) __WIFCONTINUED (status)
51# endif
52#endif /* X/Open or XPG7 and <sys/wait.h> not included. */
53
54/* _FloatN API tests for enablement. */
55#include <bits/floatn.h>
56
57/* Returned by `div'. */
58typedef struct
59 {
60 int quot; /* Quotient. */
61 int rem; /* Remainder. */
62 } div_t;
63
64/* Returned by `ldiv'. */
65#ifndef __ldiv_t_defined
66typedef struct
67 {
68 long int quot; /* Quotient. */
69 long int rem; /* Remainder. */
70 } ldiv_t;
71# define __ldiv_t_defined 1
72#endif
73
74#if defined __USE_ISOC99 && !defined __lldiv_t_defined
75/* Returned by `lldiv'. */
76__extension__ typedef struct
77 {
78 long long int quot; /* Quotient. */
79 long long int rem; /* Remainder. */
80 } lldiv_t;
81# define __lldiv_t_defined 1
82#endif
83
84
85/* The largest number rand will return (same as INT_MAX). */
86#define RAND_MAX 2147483647
87
88
89/* We define these the same for all machines.
90 Changes from this to the outside world should be done in `_exit'. */
91#define EXIT_FAILURE 1 /* Failing exit status. */
92#define EXIT_SUCCESS 0 /* Successful exit status. */
93
94
95/* Maximum length of a multibyte character in the current locale. */
96#define MB_CUR_MAX (__ctype_get_mb_cur_max ())
97extern size_t __ctype_get_mb_cur_max (void) __THROW __wur;
98
99
100/* Convert a string to a floating-point number. */
101extern double atof (const char *__nptr)
102 __THROW __attribute_pure__ __nonnull ((1)) __wur;
103/* Convert a string to an integer. */
104extern int atoi (const char *__nptr)
105 __THROW __attribute_pure__ __nonnull ((1)) __wur;
106/* Convert a string to a long integer. */
107extern long int atol (const char *__nptr)
108 __THROW __attribute_pure__ __nonnull ((1)) __wur;
109
110#ifdef __USE_ISOC99
111/* Convert a string to a long long integer. */
112__extension__ extern long long int atoll (const char *__nptr)
113 __THROW __attribute_pure__ __nonnull ((1)) __wur;
114#endif
115
116/* Convert a string to a floating-point number. */
117extern double strtod (const char *__restrict __nptr,
118 char **__restrict __endptr)
119 __THROW __nonnull ((1));
120
121#ifdef __USE_ISOC99
122/* Likewise for `float' and `long double' sizes of floating-point numbers. */
123extern float strtof (const char *__restrict __nptr,
124 char **__restrict __endptr) __THROW __nonnull ((1));
125
126extern long double strtold (const char *__restrict __nptr,
127 char **__restrict __endptr)
128 __THROW __nonnull ((1));
129#endif
130
131/* Likewise for '_FloatN' and '_FloatNx'. */
132
133#if __HAVE_FLOAT16 && __GLIBC_USE (IEC_60559_TYPES_EXT)
134extern _Float16 strtof16 (const char *__restrict __nptr,
135 char **__restrict __endptr)
136 __THROW __nonnull ((1));
137#endif
138
139#if __HAVE_FLOAT32 && __GLIBC_USE (IEC_60559_TYPES_EXT)
140extern _Float32 strtof32 (const char *__restrict __nptr,
141 char **__restrict __endptr)
142 __THROW __nonnull ((1));
143#endif
144
145#if __HAVE_FLOAT64 && __GLIBC_USE (IEC_60559_TYPES_EXT)
146extern _Float64 strtof64 (const char *__restrict __nptr,
147 char **__restrict __endptr)
148 __THROW __nonnull ((1));
149#endif
150
151#if __HAVE_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT)
152extern _Float128 strtof128 (const char *__restrict __nptr,
153 char **__restrict __endptr)
154 __THROW __nonnull ((1));
155#endif
156
157#if __HAVE_FLOAT32X && __GLIBC_USE (IEC_60559_TYPES_EXT)
158extern _Float32x strtof32x (const char *__restrict __nptr,
159 char **__restrict __endptr)
160 __THROW __nonnull ((1));
161#endif
162
163#if __HAVE_FLOAT64X && __GLIBC_USE (IEC_60559_TYPES_EXT)
164extern _Float64x strtof64x (const char *__restrict __nptr,
165 char **__restrict __endptr)
166 __THROW __nonnull ((1));
167#endif
168
169#if __HAVE_FLOAT128X && __GLIBC_USE (IEC_60559_TYPES_EXT)
170extern _Float128x strtof128x (const char *__restrict __nptr,
171 char **__restrict __endptr)
172 __THROW __nonnull ((1));
173#endif
174
175/* Convert a string to a long integer. */
176extern long int strtol (const char *__restrict __nptr,
177 char **__restrict __endptr, int __base)
178 __THROW __nonnull ((1));
179/* Convert a string to an unsigned long integer. */
180extern unsigned long int strtoul (const char *__restrict __nptr,
181 char **__restrict __endptr, int __base)
182 __THROW __nonnull ((1));
183
184#ifdef __USE_MISC
185/* Convert a string to a quadword integer. */
186__extension__
187extern long long int strtoq (const char *__restrict __nptr,
188 char **__restrict __endptr, int __base)
189 __THROW __nonnull ((1));
190/* Convert a string to an unsigned quadword integer. */
191__extension__
192extern unsigned long long int strtouq (const char *__restrict __nptr,
193 char **__restrict __endptr, int __base)
194 __THROW __nonnull ((1));
195#endif /* Use misc. */
196
197#ifdef __USE_ISOC99
198/* Convert a string to a quadword integer. */
199__extension__
200extern long long int strtoll (const char *__restrict __nptr,
201 char **__restrict __endptr, int __base)
202 __THROW __nonnull ((1));
203/* Convert a string to an unsigned quadword integer. */
204__extension__
205extern unsigned long long int strtoull (const char *__restrict __nptr,
206 char **__restrict __endptr, int __base)
207 __THROW __nonnull ((1));
208#endif /* ISO C99 or use MISC. */
209
210/* Convert a floating-point number to a string. */
211#if __GLIBC_USE (IEC_60559_BFP_EXT)
212extern int strfromd (char *__dest, size_t __size, const char *__format,
213 double __f)
214 __THROW __nonnull ((3));
215
216extern int strfromf (char *__dest, size_t __size, const char *__format,
217 float __f)
218 __THROW __nonnull ((3));
219
220extern int strfroml (char *__dest, size_t __size, const char *__format,
221 long double __f)
222 __THROW __nonnull ((3));
223#endif
224
225#if __HAVE_FLOAT16 && __GLIBC_USE (IEC_60559_TYPES_EXT)
226extern int strfromf16 (char *__dest, size_t __size, const char * __format,
227 _Float16 __f)
228 __THROW __nonnull ((3));
229#endif
230
231#if __HAVE_FLOAT32 && __GLIBC_USE (IEC_60559_TYPES_EXT)
232extern int strfromf32 (char *__dest, size_t __size, const char * __format,
233 _Float32 __f)
234 __THROW __nonnull ((3));
235#endif
236
237#if __HAVE_FLOAT64 && __GLIBC_USE (IEC_60559_TYPES_EXT)
238extern int strfromf64 (char *__dest, size_t __size, const char * __format,
239 _Float64 __f)
240 __THROW __nonnull ((3));
241#endif
242
243#if __HAVE_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT)
244extern int strfromf128 (char *__dest, size_t __size, const char * __format,
245 _Float128 __f)
246 __THROW __nonnull ((3));
247#endif
248
249#if __HAVE_FLOAT32X && __GLIBC_USE (IEC_60559_TYPES_EXT)
250extern int strfromf32x (char *__dest, size_t __size, const char * __format,
251 _Float32x __f)
252 __THROW __nonnull ((3));
253#endif
254
255#if __HAVE_FLOAT64X && __GLIBC_USE (IEC_60559_TYPES_EXT)
256extern int strfromf64x (char *__dest, size_t __size, const char * __format,
257 _Float64x __f)
258 __THROW __nonnull ((3));
259#endif
260
261#if __HAVE_FLOAT128X && __GLIBC_USE (IEC_60559_TYPES_EXT)
262extern int strfromf128x (char *__dest, size_t __size, const char * __format,
263 _Float128x __f)
264 __THROW __nonnull ((3));
265#endif
266
267
268#ifdef __USE_GNU
269/* Parallel versions of the functions above which take the locale to
270 use as an additional parameter. These are GNU extensions inspired
271 by the POSIX.1-2008 extended locale API. */
272# include <bits/types/locale_t.h>
273
274extern long int strtol_l (const char *__restrict __nptr,
275 char **__restrict __endptr, int __base,
276 locale_t __loc) __THROW __nonnull ((1, 4));
277
278extern unsigned long int strtoul_l (const char *__restrict __nptr,
279 char **__restrict __endptr,
280 int __base, locale_t __loc)
281 __THROW __nonnull ((1, 4));
282
283__extension__
284extern long long int strtoll_l (const char *__restrict __nptr,
285 char **__restrict __endptr, int __base,
286 locale_t __loc)
287 __THROW __nonnull ((1, 4));
288
289__extension__
290extern unsigned long long int strtoull_l (const char *__restrict __nptr,
291 char **__restrict __endptr,
292 int __base, locale_t __loc)
293 __THROW __nonnull ((1, 4));
294
295extern double strtod_l (const char *__restrict __nptr,
296 char **__restrict __endptr, locale_t __loc)
297 __THROW __nonnull ((1, 3));
298
299extern float strtof_l (const char *__restrict __nptr,
300 char **__restrict __endptr, locale_t __loc)
301 __THROW __nonnull ((1, 3));
302
303extern long double strtold_l (const char *__restrict __nptr,
304 char **__restrict __endptr,
305 locale_t __loc)
306 __THROW __nonnull ((1, 3));
307
308# if __HAVE_FLOAT16
309extern _Float16 strtof16_l (const char *__restrict __nptr,
310 char **__restrict __endptr,
311 locale_t __loc)
312 __THROW __nonnull ((1, 3));
313# endif
314
315# if __HAVE_FLOAT32
316extern _Float32 strtof32_l (const char *__restrict __nptr,
317 char **__restrict __endptr,
318 locale_t __loc)
319 __THROW __nonnull ((1, 3));
320# endif
321
322# if __HAVE_FLOAT64
323extern _Float64 strtof64_l (const char *__restrict __nptr,
324 char **__restrict __endptr,
325 locale_t __loc)
326 __THROW __nonnull ((1, 3));
327# endif
328
329# if __HAVE_FLOAT128
330extern _Float128 strtof128_l (const char *__restrict __nptr,
331 char **__restrict __endptr,
332 locale_t __loc)
333 __THROW __nonnull ((1, 3));
334# endif
335
336# if __HAVE_FLOAT32X
337extern _Float32x strtof32x_l (const char *__restrict __nptr,
338 char **__restrict __endptr,
339 locale_t __loc)
340 __THROW __nonnull ((1, 3));
341# endif
342
343# if __HAVE_FLOAT64X
344extern _Float64x strtof64x_l (const char *__restrict __nptr,
345 char **__restrict __endptr,
346 locale_t __loc)
347 __THROW __nonnull ((1, 3));
348# endif
349
350# if __HAVE_FLOAT128X
351extern _Float128x strtof128x_l (const char *__restrict __nptr,
352 char **__restrict __endptr,
353 locale_t __loc)
354 __THROW __nonnull ((1, 3));
355# endif
356#endif /* GNU */
357
358
359#ifdef __USE_EXTERN_INLINES
360__extern_inline int
361__NTH (atoi (const char *__nptr))
362{
363 return (int) strtol (__nptr, (char **) NULL, 10);
364}
365__extern_inline long int
366__NTH (atol (const char *__nptr))
367{
368 return strtol (__nptr, (char **) NULL, 10);
369}
370
371# ifdef __USE_ISOC99
372__extension__ __extern_inline long long int
373__NTH (atoll (const char *__nptr))
374{
375 return strtoll (__nptr, (char **) NULL, 10);
376}
377# endif
378#endif /* Optimizing and Inlining. */
379
380
381#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
382/* Convert N to base 64 using the digits "./0-9A-Za-z", least-significant
383 digit first. Returns a pointer to static storage overwritten by the
384 next call. */
385extern char *l64a (long int __n) __THROW __wur;
386
387/* Read a number from a string S in base 64 as above. */
388extern long int a64l (const char *__s)
389 __THROW __attribute_pure__ __nonnull ((1)) __wur;
390
391#endif /* Use misc || extended X/Open. */
392
393#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
394# include <sys/types.h> /* we need int32_t... */
395
396/* These are the functions that actually do things. The `random', `srandom',
397 `initstate' and `setstate' functions are those from BSD Unices.
398 The `rand' and `srand' functions are required by the ANSI standard.
399 We provide both interfaces to the same random number generator. */
400/* Return a random long integer between 0 and RAND_MAX inclusive. */
401extern long int random (void) __THROW;
402
403/* Seed the random number generator with the given number. */
404extern void srandom (unsigned int __seed) __THROW;
405
406/* Initialize the random number generator to use state buffer STATEBUF,
407 of length STATELEN, and seed it with SEED. Optimal lengths are 8, 16,
408 32, 64, 128 and 256, the bigger the better; values less than 8 will
409 cause an error and values greater than 256 will be rounded down. */
410extern char *initstate (unsigned int __seed, char *__statebuf,
411 size_t __statelen) __THROW __nonnull ((2));
412
413/* Switch the random number generator to state buffer STATEBUF,
414 which should have been previously initialized by `initstate'. */
415extern char *setstate (char *__statebuf) __THROW __nonnull ((1));
416
417
418# ifdef __USE_MISC
419/* Reentrant versions of the `random' family of functions.
420 These functions all use the following data structure to contain
421 state, rather than global state variables. */
422
423struct random_data
424 {
425 int32_t *fptr; /* Front pointer. */
426 int32_t *rptr; /* Rear pointer. */
427 int32_t *state; /* Array of state values. */
428 int rand_type; /* Type of random number generator. */
429 int rand_deg; /* Degree of random number generator. */
430 int rand_sep; /* Distance between front and rear. */
431 int32_t *end_ptr; /* Pointer behind state table. */
432 };
433
434extern int random_r (struct random_data *__restrict __buf,
435 int32_t *__restrict __result) __THROW __nonnull ((1, 2));
436
437extern int srandom_r (unsigned int __seed, struct random_data *__buf)
438 __THROW __nonnull ((2));
439
440extern int initstate_r (unsigned int __seed, char *__restrict __statebuf,
441 size_t __statelen,
442 struct random_data *__restrict __buf)
443 __THROW __nonnull ((2, 4));
444
445extern int setstate_r (char *__restrict __statebuf,
446 struct random_data *__restrict __buf)
447 __THROW __nonnull ((1, 2));
448# endif /* Use misc. */
449#endif /* Use extended X/Open || misc. */
450
451
452/* Return a random integer between 0 and RAND_MAX inclusive. */
453extern int rand (void) __THROW;
454/* Seed the random number generator with the given number. */
455extern void srand (unsigned int __seed) __THROW;
456
457#ifdef __USE_POSIX199506
458/* Reentrant interface according to POSIX.1. */
459extern int rand_r (unsigned int *__seed) __THROW;
460#endif
461
462
463#if defined __USE_MISC || defined __USE_XOPEN
464/* System V style 48-bit random number generator functions. */
465
466/* Return non-negative, double-precision floating-point value in [0.0,1.0). */
467extern double drand48 (void) __THROW;
468extern double erand48 (unsigned short int __xsubi[3]) __THROW __nonnull ((1));
469
470/* Return non-negative, long integer in [0,2^31). */
471extern long int lrand48 (void) __THROW;
472extern long int nrand48 (unsigned short int __xsubi[3])
473 __THROW __nonnull ((1));
474
475/* Return signed, long integers in [-2^31,2^31). */
476extern long int mrand48 (void) __THROW;
477extern long int jrand48 (unsigned short int __xsubi[3])
478 __THROW __nonnull ((1));
479
480/* Seed random number generator. */
481extern void srand48 (long int __seedval) __THROW;
482extern unsigned short int *seed48 (unsigned short int __seed16v[3])
483 __THROW __nonnull ((1));
484extern void lcong48 (unsigned short int __param[7]) __THROW __nonnull ((1));
485
486# ifdef __USE_MISC
487/* Data structure for communication with thread safe versions. This
488 type is to be regarded as opaque. It's only exported because users
489 have to allocate objects of this type. */
490struct drand48_data
491 {
492 unsigned short int __x[3]; /* Current state. */
493 unsigned short int __old_x[3]; /* Old state. */
494 unsigned short int __c; /* Additive const. in congruential formula. */
495 unsigned short int __init; /* Flag for initializing. */
496 __extension__ unsigned long long int __a; /* Factor in congruential
497 formula. */
498 };
499
500/* Return non-negative, double-precision floating-point value in [0.0,1.0). */
501extern int drand48_r (struct drand48_data *__restrict __buffer,
502 double *__restrict __result) __THROW __nonnull ((1, 2));
503extern int erand48_r (unsigned short int __xsubi[3],
504 struct drand48_data *__restrict __buffer,
505 double *__restrict __result) __THROW __nonnull ((1, 2));
506
507/* Return non-negative, long integer in [0,2^31). */
508extern int lrand48_r (struct drand48_data *__restrict __buffer,
509 long int *__restrict __result)
510 __THROW __nonnull ((1, 2));
511extern int nrand48_r (unsigned short int __xsubi[3],
512 struct drand48_data *__restrict __buffer,
513 long int *__restrict __result)
514 __THROW __nonnull ((1, 2));
515
516/* Return signed, long integers in [-2^31,2^31). */
517extern int mrand48_r (struct drand48_data *__restrict __buffer,
518 long int *__restrict __result)
519 __THROW __nonnull ((1, 2));
520extern int jrand48_r (unsigned short int __xsubi[3],
521 struct drand48_data *__restrict __buffer,
522 long int *__restrict __result)
523 __THROW __nonnull ((1, 2));
524
525/* Seed random number generator. */
526extern int srand48_r (long int __seedval, struct drand48_data *__buffer)
527 __THROW __nonnull ((2));
528
529extern int seed48_r (unsigned short int __seed16v[3],
530 struct drand48_data *__buffer) __THROW __nonnull ((1, 2));
531
532extern int lcong48_r (unsigned short int __param[7],
533 struct drand48_data *__buffer)
534 __THROW __nonnull ((1, 2));
535# endif /* Use misc. */
536#endif /* Use misc or X/Open. */
537
538/* Allocate SIZE bytes of memory. */
539extern void *malloc (size_t __size) __THROW __attribute_malloc__ __wur;
540/* Allocate NMEMB elements of SIZE bytes each, all initialized to 0. */
541extern void *calloc (size_t __nmemb, size_t __size)
542 __THROW __attribute_malloc__ __wur;
543
544/* Re-allocate the previously allocated block
545 in PTR, making the new block SIZE bytes long. */
546/* __attribute_malloc__ is not used, because if realloc returns
547 the same pointer that was passed to it, aliasing needs to be allowed
548 between objects pointed by the old and new pointers. */
549extern void *realloc (void *__ptr, size_t __size)
550 __THROW __attribute_warn_unused_result__;
551
552#ifdef __USE_MISC
553/* Re-allocate the previously allocated block in PTR, making the new
554 block large enough for NMEMB elements of SIZE bytes each. */
555/* __attribute_malloc__ is not used, because if reallocarray returns
556 the same pointer that was passed to it, aliasing needs to be allowed
557 between objects pointed by the old and new pointers. */
558extern void *reallocarray (void *__ptr, size_t __nmemb, size_t __size)
559 __THROW __attribute_warn_unused_result__;
560#endif
561
562/* Free a block allocated by `malloc', `realloc' or `calloc'. */
563extern void free (void *__ptr) __THROW;
564
565#ifdef __USE_MISC
566# include <alloca.h>
567#endif /* Use misc. */
568
569#if (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K) \
570 || defined __USE_MISC
571/* Allocate SIZE bytes on a page boundary. The storage cannot be freed. */
572extern void *valloc (size_t __size) __THROW __attribute_malloc__ __wur;
573#endif
574
575#ifdef __USE_XOPEN2K
576/* Allocate memory of SIZE bytes with an alignment of ALIGNMENT. */
577extern int posix_memalign (void **__memptr, size_t __alignment, size_t __size)
578 __THROW __nonnull ((1)) __wur;
579#endif
580
581#ifdef __USE_ISOC11
582/* ISO C variant of aligned allocation. */
583extern void *aligned_alloc (size_t __alignment, size_t __size)
584 __THROW __attribute_malloc__ __attribute_alloc_size__ ((2)) __wur;
585#endif
586
587/* Abort execution and generate a core-dump. */
588extern void abort (void) __THROW __attribute__ ((__noreturn__));
589
590
591/* Register a function to be called when `exit' is called. */
592extern int atexit (void (*__func) (void)) __THROW __nonnull ((1));
593
594#if defined __USE_ISOC11 || defined __USE_ISOCXX11
595/* Register a function to be called when `quick_exit' is called. */
596# ifdef __cplusplus
597extern "C++" int at_quick_exit (void (*__func) (void))
598 __THROW __asm ("at_quick_exit") __nonnull ((1));
599# else
600extern int at_quick_exit (void (*__func) (void)) __THROW __nonnull ((1));
601# endif
602#endif
603
604#ifdef __USE_MISC
605/* Register a function to be called with the status
606 given to `exit' and the given argument. */
607extern int on_exit (void (*__func) (int __status, void *__arg), void *__arg)
608 __THROW __nonnull ((1));
609#endif
610
611/* Call all functions registered with `atexit' and `on_exit',
612 in the reverse of the order in which they were registered,
613 perform stdio cleanup, and terminate program execution with STATUS. */
614extern void exit (int __status) __THROW __attribute__ ((__noreturn__));
615
616#if defined __USE_ISOC11 || defined __USE_ISOCXX11
617/* Call all functions registered with `at_quick_exit' in the reverse
618 of the order in which they were registered and terminate program
619 execution with STATUS. */
620extern void quick_exit (int __status) __THROW __attribute__ ((__noreturn__));
621#endif
622
623#ifdef __USE_ISOC99
624/* Terminate the program with STATUS without calling any of the
625 functions registered with `atexit' or `on_exit'. */
626extern void _Exit (int __status) __THROW __attribute__ ((__noreturn__));
627#endif
628
629
630/* Return the value of envariable NAME, or NULL if it doesn't exist. */
631extern char *getenv (const char *__name) __THROW __nonnull ((1)) __wur;
632
633#ifdef __USE_GNU
634/* This function is similar to the above but returns NULL if the
635 programs is running with SUID or SGID enabled. */
636extern char *secure_getenv (const char *__name)
637 __THROW __nonnull ((1)) __wur;
638#endif
639
640#if defined __USE_MISC || defined __USE_XOPEN
641/* The SVID says this is in <stdio.h>, but this seems a better place. */
642/* Put STRING, which is of the form "NAME=VALUE", in the environment.
643 If there is no `=', remove NAME from the environment. */
644extern int putenv (char *__string) __THROW __nonnull ((1));
645#endif
646
647#ifdef __USE_XOPEN2K
648/* Set NAME to VALUE in the environment.
649 If REPLACE is nonzero, overwrite an existing value. */
650extern int setenv (const char *__name, const char *__value, int __replace)
651 __THROW __nonnull ((2));
652
653/* Remove the variable NAME from the environment. */
654extern int unsetenv (const char *__name) __THROW __nonnull ((1));
655#endif
656
657#ifdef __USE_MISC
658/* The `clearenv' was planned to be added to POSIX.1 but probably
659 never made it. Nevertheless the POSIX.9 standard (POSIX bindings
660 for Fortran 77) requires this function. */
661extern int clearenv (void) __THROW;
662#endif
663
664
665#if defined __USE_MISC \
666 || (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8)
667/* Generate a unique temporary file name from TEMPLATE.
668 The last six characters of TEMPLATE must be "XXXXXX";
669 they are replaced with a string that makes the file name unique.
670 Always returns TEMPLATE, it's either a temporary file name or a null
671 string if it cannot get a unique file name. */
672extern char *mktemp (char *__template) __THROW __nonnull ((1));
673#endif
674
675#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
676/* Generate a unique temporary file name from TEMPLATE.
677 The last six characters of TEMPLATE must be "XXXXXX";
678 they are replaced with a string that makes the filename unique.
679 Returns a file descriptor open on the file for reading and writing,
680 or -1 if it cannot create a uniquely-named file.
681
682 This function is a possible cancellation point and therefore not
683 marked with __THROW. */
684# ifndef __USE_FILE_OFFSET64
685extern int mkstemp (char *__template) __nonnull ((1)) __wur;
686# else
687# ifdef __REDIRECT
688extern int __REDIRECT (mkstemp, (char *__template), mkstemp64)
689 __nonnull ((1)) __wur;
690# else
691# define mkstemp mkstemp64
692# endif
693# endif
694# ifdef __USE_LARGEFILE64
695extern int mkstemp64 (char *__template) __nonnull ((1)) __wur;
696# endif
697#endif
698
699#ifdef __USE_MISC
700/* Similar to mkstemp, but the template can have a suffix after the
701 XXXXXX. The length of the suffix is specified in the second
702 parameter.
703
704 This function is a possible cancellation point and therefore not
705 marked with __THROW. */
706# ifndef __USE_FILE_OFFSET64
707extern int mkstemps (char *__template, int __suffixlen) __nonnull ((1)) __wur;
708# else
709# ifdef __REDIRECT
710extern int __REDIRECT (mkstemps, (char *__template, int __suffixlen),
711 mkstemps64) __nonnull ((1)) __wur;
712# else
713# define mkstemps mkstemps64
714# endif
715# endif
716# ifdef __USE_LARGEFILE64
717extern int mkstemps64 (char *__template, int __suffixlen)
718 __nonnull ((1)) __wur;
719# endif
720#endif
721
722#ifdef __USE_XOPEN2K8
723/* Create a unique temporary directory from TEMPLATE.
724 The last six characters of TEMPLATE must be "XXXXXX";
725 they are replaced with a string that makes the directory name unique.
726 Returns TEMPLATE, or a null pointer if it cannot get a unique name.
727 The directory is created mode 700. */
728extern char *mkdtemp (char *__template) __THROW __nonnull ((1)) __wur;
729#endif
730
731#ifdef __USE_GNU
732/* Generate a unique temporary file name from TEMPLATE similar to
733 mkstemp. But allow the caller to pass additional flags which are
734 used in the open call to create the file..
735
736 This function is a possible cancellation point and therefore not
737 marked with __THROW. */
738# ifndef __USE_FILE_OFFSET64
739extern int mkostemp (char *__template, int __flags) __nonnull ((1)) __wur;
740# else
741# ifdef __REDIRECT
742extern int __REDIRECT (mkostemp, (char *__template, int __flags), mkostemp64)
743 __nonnull ((1)) __wur;
744# else
745# define mkostemp mkostemp64
746# endif
747# endif
748# ifdef __USE_LARGEFILE64
749extern int mkostemp64 (char *__template, int __flags) __nonnull ((1)) __wur;
750# endif
751
752/* Similar to mkostemp, but the template can have a suffix after the
753 XXXXXX. The length of the suffix is specified in the second
754 parameter.
755
756 This function is a possible cancellation point and therefore not
757 marked with __THROW. */
758# ifndef __USE_FILE_OFFSET64
759extern int mkostemps (char *__template, int __suffixlen, int __flags)
760 __nonnull ((1)) __wur;
761# else
762# ifdef __REDIRECT
763extern int __REDIRECT (mkostemps, (char *__template, int __suffixlen,
764 int __flags), mkostemps64)
765 __nonnull ((1)) __wur;
766# else
767# define mkostemps mkostemps64
768# endif
769# endif
770# ifdef __USE_LARGEFILE64
771extern int mkostemps64 (char *__template, int __suffixlen, int __flags)
772 __nonnull ((1)) __wur;
773# endif
774#endif
775
776
777/* Execute the given line as a shell command.
778
779 This function is a cancellation point and therefore not marked with
780 __THROW. */
781extern int system (const char *__command) __wur;
782
783
784#ifdef __USE_GNU
785/* Return a malloc'd string containing the canonical absolute name of the
786 existing named file. */
787extern char *canonicalize_file_name (const char *__name)
788 __THROW __nonnull ((1)) __wur;
789#endif
790
791#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
792/* Return the canonical absolute name of file NAME. If RESOLVED is
793 null, the result is malloc'd; otherwise, if the canonical name is
794 PATH_MAX chars or more, returns null with `errno' set to
795 ENAMETOOLONG; if the name fits in fewer than PATH_MAX chars,
796 returns the name in RESOLVED. */
797extern char *realpath (const char *__restrict __name,
798 char *__restrict __resolved) __THROW __wur;
799#endif
800
801
802/* Shorthand for type of comparison functions. */
803#ifndef __COMPAR_FN_T
804# define __COMPAR_FN_T
805typedef int (*__compar_fn_t) (const void *, const void *);
806
807# ifdef __USE_GNU
808typedef __compar_fn_t comparison_fn_t;
809# endif
810#endif
811#ifdef __USE_GNU
812typedef int (*__compar_d_fn_t) (const void *, const void *, void *);
813#endif
814
815/* Do a binary search for KEY in BASE, which consists of NMEMB elements
816 of SIZE bytes each, using COMPAR to perform the comparisons. */
817extern void *bsearch (const void *__key, const void *__base,
818 size_t __nmemb, size_t __size, __compar_fn_t __compar)
819 __nonnull ((1, 2, 5)) __wur;
820
821#ifdef __USE_EXTERN_INLINES
822# include <bits/stdlib-bsearch.h>
823#endif
824
825/* Sort NMEMB elements of BASE, of SIZE bytes each,
826 using COMPAR to perform the comparisons. */
827extern void qsort (void *__base, size_t __nmemb, size_t __size,
828 __compar_fn_t __compar) __nonnull ((1, 4));
829#ifdef __USE_GNU
830extern void qsort_r (void *__base, size_t __nmemb, size_t __size,
831 __compar_d_fn_t __compar, void *__arg)
832 __nonnull ((1, 4));
833#endif
834
835
836/* Return the absolute value of X. */
837extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
838extern long int labs (long int __x) __THROW __attribute__ ((__const__)) __wur;
839
840#ifdef __USE_ISOC99
841__extension__ extern long long int llabs (long long int __x)
842 __THROW __attribute__ ((__const__)) __wur;
843#endif
844
845
846/* Return the `div_t', `ldiv_t' or `lldiv_t' representation
847 of the value of NUMER over DENOM. */
848/* GCC may have built-ins for these someday. */
849extern div_t div (int __numer, int __denom)
850 __THROW __attribute__ ((__const__)) __wur;
851extern ldiv_t ldiv (long int __numer, long int __denom)
852 __THROW __attribute__ ((__const__)) __wur;
853
854#ifdef __USE_ISOC99
855__extension__ extern lldiv_t lldiv (long long int __numer,
856 long long int __denom)
857 __THROW __attribute__ ((__const__)) __wur;
858#endif
859
860
861#if (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8) \
862 || defined __USE_MISC
863/* Convert floating point numbers to strings. The returned values are
864 valid only until another call to the same function. */
865
866/* Convert VALUE to a string with NDIGIT digits and return a pointer to
867 this. Set *DECPT with the position of the decimal character and *SIGN
868 with the sign of the number. */
869extern char *ecvt (double __value, int __ndigit, int *__restrict __decpt,
870 int *__restrict __sign) __THROW __nonnull ((3, 4)) __wur;
871
872/* Convert VALUE to a string rounded to NDIGIT decimal digits. Set *DECPT
873 with the position of the decimal character and *SIGN with the sign of
874 the number. */
875extern char *fcvt (double __value, int __ndigit, int *__restrict __decpt,
876 int *__restrict __sign) __THROW __nonnull ((3, 4)) __wur;
877
878/* If possible convert VALUE to a string with NDIGIT significant digits.
879 Otherwise use exponential representation. The resulting string will
880 be written to BUF. */
881extern char *gcvt (double __value, int __ndigit, char *__buf)
882 __THROW __nonnull ((3)) __wur;
883#endif
884
885#ifdef __USE_MISC
886/* Long double versions of above functions. */
887extern char *qecvt (long double __value, int __ndigit,
888 int *__restrict __decpt, int *__restrict __sign)
889 __THROW __nonnull ((3, 4)) __wur;
890extern char *qfcvt (long double __value, int __ndigit,
891 int *__restrict __decpt, int *__restrict __sign)
892 __THROW __nonnull ((3, 4)) __wur;
893extern char *qgcvt (long double __value, int __ndigit, char *__buf)
894 __THROW __nonnull ((3)) __wur;
895
896
897/* Reentrant version of the functions above which provide their own
898 buffers. */
899extern int ecvt_r (double __value, int __ndigit, int *__restrict __decpt,
900 int *__restrict __sign, char *__restrict __buf,
901 size_t __len) __THROW __nonnull ((3, 4, 5));
902extern int fcvt_r (double __value, int __ndigit, int *__restrict __decpt,
903 int *__restrict __sign, char *__restrict __buf,
904 size_t __len) __THROW __nonnull ((3, 4, 5));
905
906extern int qecvt_r (long double __value, int __ndigit,
907 int *__restrict __decpt, int *__restrict __sign,
908 char *__restrict __buf, size_t __len)
909 __THROW __nonnull ((3, 4, 5));
910extern int qfcvt_r (long double __value, int __ndigit,
911 int *__restrict __decpt, int *__restrict __sign,
912 char *__restrict __buf, size_t __len)
913 __THROW __nonnull ((3, 4, 5));
914#endif /* misc */
915
916
917/* Return the length of the multibyte character
918 in S, which is no longer than N. */
919extern int mblen (const char *__s, size_t __n) __THROW;
920/* Return the length of the given multibyte character,
921 putting its `wchar_t' representation in *PWC. */
922extern int mbtowc (wchar_t *__restrict __pwc,
923 const char *__restrict __s, size_t __n) __THROW;
924/* Put the multibyte character represented
925 by WCHAR in S, returning its length. */
926extern int wctomb (char *__s, wchar_t __wchar) __THROW;
927
928
929/* Convert a multibyte string to a wide char string. */
930extern size_t mbstowcs (wchar_t *__restrict __pwcs,
931 const char *__restrict __s, size_t __n) __THROW;
932/* Convert a wide char string to multibyte string. */
933extern size_t wcstombs (char *__restrict __s,
934 const wchar_t *__restrict __pwcs, size_t __n)
935 __THROW;
936
937
938#ifdef __USE_MISC
939/* Determine whether the string value of RESPONSE matches the affirmation
940 or negative response expression as specified by the LC_MESSAGES category
941 in the program's current locale. Returns 1 if affirmative, 0 if
942 negative, and -1 if not matching. */
943extern int rpmatch (const char *__response) __THROW __nonnull ((1)) __wur;
944#endif
945
946
947#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
948/* Parse comma separated suboption from *OPTIONP and match against
949 strings in TOKENS. If found return index and set *VALUEP to
950 optional value introduced by an equal sign. If the suboption is
951 not part of TOKENS return in *VALUEP beginning of unknown
952 suboption. On exit *OPTIONP is set to the beginning of the next
953 token or at the terminating NUL character. */
954extern int getsubopt (char **__restrict __optionp,
955 char *const *__restrict __tokens,
956 char **__restrict __valuep)
957 __THROW __nonnull ((1, 2, 3)) __wur;
958#endif
959
960
961/* X/Open pseudo terminal handling. */
962
963#ifdef __USE_XOPEN2KXSI
964/* Return a master pseudo-terminal handle. */
965extern int posix_openpt (int __oflag) __wur;
966#endif
967
968#ifdef __USE_XOPEN_EXTENDED
969/* The next four functions all take a master pseudo-tty fd and
970 perform an operation on the associated slave: */
971
972/* Chown the slave to the calling user. */
973extern int grantpt (int __fd) __THROW;
974
975/* Release an internal lock so the slave can be opened.
976 Call after grantpt(). */
977extern int unlockpt (int __fd) __THROW;
978
979/* Return the pathname of the pseudo terminal slave associated with
980 the master FD is open on, or NULL on errors.
981 The returned storage is good until the next call to this function. */
982extern char *ptsname (int __fd) __THROW __wur;
983#endif
984
985#ifdef __USE_GNU
986/* Store at most BUFLEN characters of the pathname of the slave pseudo
987 terminal associated with the master FD is open on in BUF.
988 Return 0 on success, otherwise an error number. */
989extern int ptsname_r (int __fd, char *__buf, size_t __buflen)
990 __THROW __nonnull ((2));
991
992/* Open a master pseudo terminal and return its file descriptor. */
993extern int getpt (void);
994#endif
995
996#ifdef __USE_MISC
997/* Put the 1 minute, 5 minute and 15 minute load averages into the first
998 NELEM elements of LOADAVG. Return the number written (never more than
999 three, but may be less than NELEM), or -1 if an error occurred. */
1000extern int getloadavg (double __loadavg[], int __nelem)
1001 __THROW __nonnull ((1));
1002#endif
1003
1004#if defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K
1005/* Return the index into the active-logins file (utmp) for
1006 the controlling terminal. */
1007extern int ttyslot (void) __THROW;
1008#endif
1009
1010#include <bits/stdlib-float.h>
1011
1012/* Define some macros helping to catch buffer overflows. */
1013#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
1014# include <bits/stdlib.h>
1015#endif
1016#ifdef __LDBL_COMPAT
1017# include <bits/stdlib-ldbl.h>
1018#endif
1019
1020__END_DECLS
1021
1022#endif /* stdlib.h */
libc/glibc/string/endian.h created+97
...@@ -0,0 +1,97 @@
1/* Copyright (C) 1992-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _ENDIAN_H
19#define _ENDIAN_H 1
20
21#include <features.h>
22
23/* Definitions for byte order, according to significance of bytes,
24 from low addresses to high addresses. The value is what you get by
25 putting '4' in the most significant byte, '3' in the second most
26 significant byte, '2' in the second least significant byte, and '1'
27 in the least significant byte, and then writing down one digit for
28 each byte, starting with the byte at the lowest address at the left,
29 and proceeding to the byte with the highest address at the right. */
30
31#define __LITTLE_ENDIAN 1234
32#define __BIG_ENDIAN 4321
33#define __PDP_ENDIAN 3412
34
35/* This file defines `__BYTE_ORDER' for the particular machine. */
36#include <bits/endian.h>
37
38/* Some machines may need to use a different endianness for floating point
39 values. */
40#ifndef __FLOAT_WORD_ORDER
41# define __FLOAT_WORD_ORDER __BYTE_ORDER
42#endif
43
44#ifdef __USE_MISC
45# define LITTLE_ENDIAN __LITTLE_ENDIAN
46# define BIG_ENDIAN __BIG_ENDIAN
47# define PDP_ENDIAN __PDP_ENDIAN
48# define BYTE_ORDER __BYTE_ORDER
49#endif
50
51#if __BYTE_ORDER == __LITTLE_ENDIAN
52# define __LONG_LONG_PAIR(HI, LO) LO, HI
53#elif __BYTE_ORDER == __BIG_ENDIAN
54# define __LONG_LONG_PAIR(HI, LO) HI, LO
55#endif
56
57
58#if defined __USE_MISC && !defined __ASSEMBLER__
59/* Conversion interfaces. */
60# include <bits/byteswap.h>
61# include <bits/uintn-identity.h>
62
63# if __BYTE_ORDER == __LITTLE_ENDIAN
64# define htobe16(x) __bswap_16 (x)
65# define htole16(x) __uint16_identity (x)
66# define be16toh(x) __bswap_16 (x)
67# define le16toh(x) __uint16_identity (x)
68
69# define htobe32(x) __bswap_32 (x)
70# define htole32(x) __uint32_identity (x)
71# define be32toh(x) __bswap_32 (x)
72# define le32toh(x) __uint32_identity (x)
73
74# define htobe64(x) __bswap_64 (x)
75# define htole64(x) __uint64_identity (x)
76# define be64toh(x) __bswap_64 (x)
77# define le64toh(x) __uint64_identity (x)
78
79# else
80# define htobe16(x) __uint16_identity (x)
81# define htole16(x) __bswap_16 (x)
82# define be16toh(x) __uint16_identity (x)
83# define le16toh(x) __bswap_16 (x)
84
85# define htobe32(x) __uint32_identity (x)
86# define htole32(x) __bswap_32 (x)
87# define be32toh(x) __uint32_identity (x)
88# define le32toh(x) __bswap_32 (x)
89
90# define htobe64(x) __uint64_identity (x)
91# define htole64(x) __bswap_64 (x)
92# define be64toh(x) __uint64_identity (x)
93# define le64toh(x) __bswap_64 (x)
94# endif
95#endif
96
97#endif /* endian.h */
libc/glibc/sysdeps/generic/allocalim.h created+4
...@@ -0,0 +1,4 @@
1extern inline int __libc_use_alloca (size_t size)
2{
3 return size <= __MAX_ALLOCA_CUTOFF;
4}
libc/glibc/sysdeps/generic/dl-dtprocnum.h created+21
...@@ -0,0 +1,21 @@
1/* Configuration of lookup functions.
2 Copyright (C) 2000-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19/* Number of extra dynamic section entries for this architecture. By
20 default there are none. */
21#define DT_THISPROCNUM 0
libc/glibc/sysdeps/generic/dwarf2.h created+590
...@@ -0,0 +1,590 @@
1/* Declarations and definitions of codes relating to the DWARF2 symbolic
2 debugging information format.
3 Copyright (C) 1992-2019 Free Software Foundation, Inc.
4 Contributed by Gary Funck (gary@intrepid.com). Derived from the
5 DWARF 1 implementation written by Ron Guilmette (rfg@monkeys.com).
6
7 This file is part of the GNU C Library.
8
9 The GNU C Library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Lesser General Public
11 License as published by the Free Software Foundation; either
12 version 2.1 of the License, or (at your option) any later version.
13
14 The GNU C Library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public
20 License along with the GNU C Library; if not, see
21 <http://www.gnu.org/licenses/>. */
22
23#ifndef _DWARF2_H
24#define _DWARF2_H 1
25
26/* This file is derived from the DWARF specification (a public document)
27 Revision 2.0.0 (July 27, 1993) developed by the UNIX International
28 Programming Languages Special Interest Group (UI/PLSIG) and distributed
29 by UNIX International. Copies of this specification are available from
30 UNIX International, 20 Waterview Boulevard, Parsippany, NJ, 07054. */
31
32/* This file is shared between GCC and GDB, and should not contain
33 prototypes. */
34
35#ifndef __ASSEMBLER__
36/* Tag names and codes. */
37
38enum dwarf_tag
39 {
40 DW_TAG_padding = 0x00,
41 DW_TAG_array_type = 0x01,
42 DW_TAG_class_type = 0x02,
43 DW_TAG_entry_point = 0x03,
44 DW_TAG_enumeration_type = 0x04,
45 DW_TAG_formal_parameter = 0x05,
46 DW_TAG_imported_declaration = 0x08,
47 DW_TAG_label = 0x0a,
48 DW_TAG_lexical_block = 0x0b,
49 DW_TAG_member = 0x0d,
50 DW_TAG_pointer_type = 0x0f,
51 DW_TAG_reference_type = 0x10,
52 DW_TAG_compile_unit = 0x11,
53 DW_TAG_string_type = 0x12,
54 DW_TAG_structure_type = 0x13,
55 DW_TAG_subroutine_type = 0x15,
56 DW_TAG_typedef = 0x16,
57 DW_TAG_union_type = 0x17,
58 DW_TAG_unspecified_parameters = 0x18,
59 DW_TAG_variant = 0x19,
60 DW_TAG_common_block = 0x1a,
61 DW_TAG_common_inclusion = 0x1b,
62 DW_TAG_inheritance = 0x1c,
63 DW_TAG_inlined_subroutine = 0x1d,
64 DW_TAG_module = 0x1e,
65 DW_TAG_ptr_to_member_type = 0x1f,
66 DW_TAG_set_type = 0x20,
67 DW_TAG_subrange_type = 0x21,
68 DW_TAG_with_stmt = 0x22,
69 DW_TAG_access_declaration = 0x23,
70 DW_TAG_base_type = 0x24,
71 DW_TAG_catch_block = 0x25,
72 DW_TAG_const_type = 0x26,
73 DW_TAG_constant = 0x27,
74 DW_TAG_enumerator = 0x28,
75 DW_TAG_file_type = 0x29,
76 DW_TAG_friend = 0x2a,
77 DW_TAG_namelist = 0x2b,
78 DW_TAG_namelist_item = 0x2c,
79 DW_TAG_packed_type = 0x2d,
80 DW_TAG_subprogram = 0x2e,
81 DW_TAG_template_type_param = 0x2f,
82 DW_TAG_template_value_param = 0x30,
83 DW_TAG_thrown_type = 0x31,
84 DW_TAG_try_block = 0x32,
85 DW_TAG_variant_part = 0x33,
86 DW_TAG_variable = 0x34,
87 DW_TAG_volatile_type = 0x35,
88 /* SGI/MIPS Extensions */
89 DW_TAG_MIPS_loop = 0x4081,
90 /* GNU extensions */
91 DW_TAG_format_label = 0x4101, /* for FORTRAN 77 and Fortran 90 */
92 DW_TAG_function_template = 0x4102, /* for C++ */
93 DW_TAG_class_template = 0x4103, /* for C++ */
94 DW_TAG_GNU_BINCL = 0x4104,
95 DW_TAG_GNU_EINCL = 0x4105
96 };
97
98#define DW_TAG_lo_user 0x4080
99#define DW_TAG_hi_user 0xffff
100
101/* flag that tells whether entry has a child or not */
102#define DW_children_no 0
103#define DW_children_yes 1
104
105/* Form names and codes. */
106enum dwarf_form
107 {
108 DW_FORM_addr = 0x01,
109 DW_FORM_block2 = 0x03,
110 DW_FORM_block4 = 0x04,
111 DW_FORM_data2 = 0x05,
112 DW_FORM_data4 = 0x06,
113 DW_FORM_data8 = 0x07,
114 DW_FORM_string = 0x08,
115 DW_FORM_block = 0x09,
116 DW_FORM_block1 = 0x0a,
117 DW_FORM_data1 = 0x0b,
118 DW_FORM_flag = 0x0c,
119 DW_FORM_sdata = 0x0d,
120 DW_FORM_strp = 0x0e,
121 DW_FORM_udata = 0x0f,
122 DW_FORM_ref_addr = 0x10,
123 DW_FORM_ref1 = 0x11,
124 DW_FORM_ref2 = 0x12,
125 DW_FORM_ref4 = 0x13,
126 DW_FORM_ref8 = 0x14,
127 DW_FORM_ref_udata = 0x15,
128 DW_FORM_indirect = 0x16
129 };
130
131/* Attribute names and codes. */
132
133enum dwarf_attribute
134 {
135 DW_AT_sibling = 0x01,
136 DW_AT_location = 0x02,
137 DW_AT_name = 0x03,
138 DW_AT_ordering = 0x09,
139 DW_AT_subscr_data = 0x0a,
140 DW_AT_byte_size = 0x0b,
141 DW_AT_bit_offset = 0x0c,
142 DW_AT_bit_size = 0x0d,
143 DW_AT_element_list = 0x0f,
144 DW_AT_stmt_list = 0x10,
145 DW_AT_low_pc = 0x11,
146 DW_AT_high_pc = 0x12,
147 DW_AT_language = 0x13,
148 DW_AT_member = 0x14,
149 DW_AT_discr = 0x15,
150 DW_AT_discr_value = 0x16,
151 DW_AT_visibility = 0x17,
152 DW_AT_import = 0x18,
153 DW_AT_string_length = 0x19,
154 DW_AT_common_reference = 0x1a,
155 DW_AT_comp_dir = 0x1b,
156 DW_AT_const_value = 0x1c,
157 DW_AT_containing_type = 0x1d,
158 DW_AT_default_value = 0x1e,
159 DW_AT_inline = 0x20,
160 DW_AT_is_optional = 0x21,
161 DW_AT_lower_bound = 0x22,
162 DW_AT_producer = 0x25,
163 DW_AT_prototyped = 0x27,
164 DW_AT_return_addr = 0x2a,
165 DW_AT_start_scope = 0x2c,
166 DW_AT_stride_size = 0x2e,
167 DW_AT_upper_bound = 0x2f,
168 DW_AT_abstract_origin = 0x31,
169 DW_AT_accessibility = 0x32,
170 DW_AT_address_class = 0x33,
171 DW_AT_artificial = 0x34,
172 DW_AT_base_types = 0x35,
173 DW_AT_calling_convention = 0x36,
174 DW_AT_count = 0x37,
175 DW_AT_data_member_location = 0x38,
176 DW_AT_decl_column = 0x39,
177 DW_AT_decl_file = 0x3a,
178 DW_AT_decl_line = 0x3b,
179 DW_AT_declaration = 0x3c,
180 DW_AT_discr_list = 0x3d,
181 DW_AT_encoding = 0x3e,
182 DW_AT_external = 0x3f,
183 DW_AT_frame_base = 0x40,
184 DW_AT_friend = 0x41,
185 DW_AT_identifier_case = 0x42,
186 DW_AT_macro_info = 0x43,
187 DW_AT_namelist_items = 0x44,
188 DW_AT_priority = 0x45,
189 DW_AT_segment = 0x46,
190 DW_AT_specification = 0x47,
191 DW_AT_static_link = 0x48,
192 DW_AT_type = 0x49,
193 DW_AT_use_location = 0x4a,
194 DW_AT_variable_parameter = 0x4b,
195 DW_AT_virtuality = 0x4c,
196 DW_AT_vtable_elem_location = 0x4d,
197 /* SGI/MIPS Extensions */
198 DW_AT_MIPS_fde = 0x2001,
199 DW_AT_MIPS_loop_begin = 0x2002,
200 DW_AT_MIPS_tail_loop_begin = 0x2003,
201 DW_AT_MIPS_epilog_begin = 0x2004,
202 DW_AT_MIPS_loop_unroll_factor = 0x2005,
203 DW_AT_MIPS_software_pipeline_depth = 0x2006,
204 DW_AT_MIPS_linkage_name = 0x2007,
205 DW_AT_MIPS_stride = 0x2008,
206 DW_AT_MIPS_abstract_name = 0x2009,
207 DW_AT_MIPS_clone_origin = 0x200a,
208 DW_AT_MIPS_has_inlines = 0x200b,
209 /* GNU extensions. */
210 DW_AT_sf_names = 0x2101,
211 DW_AT_src_info = 0x2102,
212 DW_AT_mac_info = 0x2103,
213 DW_AT_src_coords = 0x2104,
214 DW_AT_body_begin = 0x2105,
215 DW_AT_body_end = 0x2106
216 };
217
218#define DW_AT_lo_user 0x2000 /* implementation-defined range start */
219#define DW_AT_hi_user 0x3ff0 /* implementation-defined range end */
220
221/* Location atom names and codes. */
222
223enum dwarf_location_atom
224 {
225 DW_OP_addr = 0x03,
226 DW_OP_deref = 0x06,
227 DW_OP_const1u = 0x08,
228 DW_OP_const1s = 0x09,
229 DW_OP_const2u = 0x0a,
230 DW_OP_const2s = 0x0b,
231 DW_OP_const4u = 0x0c,
232 DW_OP_const4s = 0x0d,
233 DW_OP_const8u = 0x0e,
234 DW_OP_const8s = 0x0f,
235 DW_OP_constu = 0x10,
236 DW_OP_consts = 0x11,
237 DW_OP_dup = 0x12,
238 DW_OP_drop = 0x13,
239 DW_OP_over = 0x14,
240 DW_OP_pick = 0x15,
241 DW_OP_swap = 0x16,
242 DW_OP_rot = 0x17,
243 DW_OP_xderef = 0x18,
244 DW_OP_abs = 0x19,
245 DW_OP_and = 0x1a,
246 DW_OP_div = 0x1b,
247 DW_OP_minus = 0x1c,
248 DW_OP_mod = 0x1d,
249 DW_OP_mul = 0x1e,
250 DW_OP_neg = 0x1f,
251 DW_OP_not = 0x20,
252 DW_OP_or = 0x21,
253 DW_OP_plus = 0x22,
254 DW_OP_plus_uconst = 0x23,
255 DW_OP_shl = 0x24,
256 DW_OP_shr = 0x25,
257 DW_OP_shra = 0x26,
258 DW_OP_xor = 0x27,
259 DW_OP_bra = 0x28,
260 DW_OP_eq = 0x29,
261 DW_OP_ge = 0x2a,
262 DW_OP_gt = 0x2b,
263 DW_OP_le = 0x2c,
264 DW_OP_lt = 0x2d,
265 DW_OP_ne = 0x2e,
266 DW_OP_skip = 0x2f,
267 DW_OP_lit0 = 0x30,
268 DW_OP_lit1 = 0x31,
269 DW_OP_lit2 = 0x32,
270 DW_OP_lit3 = 0x33,
271 DW_OP_lit4 = 0x34,
272 DW_OP_lit5 = 0x35,
273 DW_OP_lit6 = 0x36,
274 DW_OP_lit7 = 0x37,
275 DW_OP_lit8 = 0x38,
276 DW_OP_lit9 = 0x39,
277 DW_OP_lit10 = 0x3a,
278 DW_OP_lit11 = 0x3b,
279 DW_OP_lit12 = 0x3c,
280 DW_OP_lit13 = 0x3d,
281 DW_OP_lit14 = 0x3e,
282 DW_OP_lit15 = 0x3f,
283 DW_OP_lit16 = 0x40,
284 DW_OP_lit17 = 0x41,
285 DW_OP_lit18 = 0x42,
286 DW_OP_lit19 = 0x43,
287 DW_OP_lit20 = 0x44,
288 DW_OP_lit21 = 0x45,
289 DW_OP_lit22 = 0x46,
290 DW_OP_lit23 = 0x47,
291 DW_OP_lit24 = 0x48,
292 DW_OP_lit25 = 0x49,
293 DW_OP_lit26 = 0x4a,
294 DW_OP_lit27 = 0x4b,
295 DW_OP_lit28 = 0x4c,
296 DW_OP_lit29 = 0x4d,
297 DW_OP_lit30 = 0x4e,
298 DW_OP_lit31 = 0x4f,
299 DW_OP_reg0 = 0x50,
300 DW_OP_reg1 = 0x51,
301 DW_OP_reg2 = 0x52,
302 DW_OP_reg3 = 0x53,
303 DW_OP_reg4 = 0x54,
304 DW_OP_reg5 = 0x55,
305 DW_OP_reg6 = 0x56,
306 DW_OP_reg7 = 0x57,
307 DW_OP_reg8 = 0x58,
308 DW_OP_reg9 = 0x59,
309 DW_OP_reg10 = 0x5a,
310 DW_OP_reg11 = 0x5b,
311 DW_OP_reg12 = 0x5c,
312 DW_OP_reg13 = 0x5d,
313 DW_OP_reg14 = 0x5e,
314 DW_OP_reg15 = 0x5f,
315 DW_OP_reg16 = 0x60,
316 DW_OP_reg17 = 0x61,
317 DW_OP_reg18 = 0x62,
318 DW_OP_reg19 = 0x63,
319 DW_OP_reg20 = 0x64,
320 DW_OP_reg21 = 0x65,
321 DW_OP_reg22 = 0x66,
322 DW_OP_reg23 = 0x67,
323 DW_OP_reg24 = 0x68,
324 DW_OP_reg25 = 0x69,
325 DW_OP_reg26 = 0x6a,
326 DW_OP_reg27 = 0x6b,
327 DW_OP_reg28 = 0x6c,
328 DW_OP_reg29 = 0x6d,
329 DW_OP_reg30 = 0x6e,
330 DW_OP_reg31 = 0x6f,
331 DW_OP_breg0 = 0x70,
332 DW_OP_breg1 = 0x71,
333 DW_OP_breg2 = 0x72,
334 DW_OP_breg3 = 0x73,
335 DW_OP_breg4 = 0x74,
336 DW_OP_breg5 = 0x75,
337 DW_OP_breg6 = 0x76,
338 DW_OP_breg7 = 0x77,
339 DW_OP_breg8 = 0x78,
340 DW_OP_breg9 = 0x79,
341 DW_OP_breg10 = 0x7a,
342 DW_OP_breg11 = 0x7b,
343 DW_OP_breg12 = 0x7c,
344 DW_OP_breg13 = 0x7d,
345 DW_OP_breg14 = 0x7e,
346 DW_OP_breg15 = 0x7f,
347 DW_OP_breg16 = 0x80,
348 DW_OP_breg17 = 0x81,
349 DW_OP_breg18 = 0x82,
350 DW_OP_breg19 = 0x83,
351 DW_OP_breg20 = 0x84,
352 DW_OP_breg21 = 0x85,
353 DW_OP_breg22 = 0x86,
354 DW_OP_breg23 = 0x87,
355 DW_OP_breg24 = 0x88,
356 DW_OP_breg25 = 0x89,
357 DW_OP_breg26 = 0x8a,
358 DW_OP_breg27 = 0x8b,
359 DW_OP_breg28 = 0x8c,
360 DW_OP_breg29 = 0x8d,
361 DW_OP_breg30 = 0x8e,
362 DW_OP_breg31 = 0x8f,
363 DW_OP_regx = 0x90,
364 DW_OP_fbreg = 0x91,
365 DW_OP_bregx = 0x92,
366 DW_OP_piece = 0x93,
367 DW_OP_deref_size = 0x94,
368 DW_OP_xderef_size = 0x95,
369 DW_OP_nop = 0x96
370 };
371
372#define DW_OP_lo_user 0x80 /* implementation-defined range start */
373#define DW_OP_hi_user 0xff /* implementation-defined range end */
374
375/* Type encodings. */
376
377enum dwarf_type
378 {
379 DW_ATE_void = 0x0,
380 DW_ATE_address = 0x1,
381 DW_ATE_boolean = 0x2,
382 DW_ATE_complex_float = 0x3,
383 DW_ATE_float = 0x4,
384 DW_ATE_signed = 0x5,
385 DW_ATE_signed_char = 0x6,
386 DW_ATE_unsigned = 0x7,
387 DW_ATE_unsigned_char = 0x8
388 };
389
390#define DW_ATE_lo_user 0x80
391#define DW_ATE_hi_user 0xff
392
393/* Array ordering names and codes. */
394enum dwarf_array_dim_ordering
395 {
396 DW_ORD_row_major = 0,
397 DW_ORD_col_major = 1
398 };
399
400/* access attribute */
401enum dwarf_access_attribute
402 {
403 DW_ACCESS_public = 1,
404 DW_ACCESS_protected = 2,
405 DW_ACCESS_private = 3
406 };
407
408/* visibility */
409enum dwarf_visibility_attribute
410 {
411 DW_VIS_local = 1,
412 DW_VIS_exported = 2,
413 DW_VIS_qualified = 3
414 };
415
416/* virtuality */
417enum dwarf_virtuality_attribute
418 {
419 DW_VIRTUALITY_none = 0,
420 DW_VIRTUALITY_virtual = 1,
421 DW_VIRTUALITY_pure_virtual = 2
422 };
423
424/* case sensitivity */
425enum dwarf_id_case
426 {
427 DW_ID_case_sensitive = 0,
428 DW_ID_up_case = 1,
429 DW_ID_down_case = 2,
430 DW_ID_case_insensitive = 3
431 };
432
433/* calling convention */
434enum dwarf_calling_convention
435 {
436 DW_CC_normal = 0x1,
437 DW_CC_program = 0x2,
438 DW_CC_nocall = 0x3
439 };
440
441#define DW_CC_lo_user 0x40
442#define DW_CC_hi_user 0xff
443
444/* inline attribute */
445enum dwarf_inline_attribute
446 {
447 DW_INL_not_inlined = 0,
448 DW_INL_inlined = 1,
449 DW_INL_declared_not_inlined = 2,
450 DW_INL_declared_inlined = 3
451 };
452
453/* discriminant lists */
454enum dwarf_discrim_list
455 {
456 DW_DSC_label = 0,
457 DW_DSC_range = 1
458 };
459
460/* line number opcodes */
461enum dwarf_line_number_ops
462 {
463 DW_LNS_extended_op = 0,
464 DW_LNS_copy = 1,
465 DW_LNS_advance_pc = 2,
466 DW_LNS_advance_line = 3,
467 DW_LNS_set_file = 4,
468 DW_LNS_set_column = 5,
469 DW_LNS_negate_stmt = 6,
470 DW_LNS_set_basic_block = 7,
471 DW_LNS_const_add_pc = 8,
472 DW_LNS_fixed_advance_pc = 9
473 };
474
475/* line number extended opcodes */
476enum dwarf_line_number_x_ops
477 {
478 DW_LNE_end_sequence = 1,
479 DW_LNE_set_address = 2,
480 DW_LNE_define_file = 3
481 };
482
483/* call frame information */
484enum dwarf_call_frame_info
485 {
486 DW_CFA_advance_loc = 0x40,
487 DW_CFA_offset = 0x80,
488 DW_CFA_restore = 0xc0,
489 DW_CFA_nop = 0x00,
490 DW_CFA_set_loc = 0x01,
491 DW_CFA_advance_loc1 = 0x02,
492 DW_CFA_advance_loc2 = 0x03,
493 DW_CFA_advance_loc4 = 0x04,
494 DW_CFA_offset_extended = 0x05,
495 DW_CFA_restore_extended = 0x06,
496 DW_CFA_undefined = 0x07,
497 DW_CFA_same_value = 0x08,
498 DW_CFA_register = 0x09,
499 DW_CFA_remember_state = 0x0a,
500 DW_CFA_restore_state = 0x0b,
501 DW_CFA_def_cfa = 0x0c,
502 DW_CFA_def_cfa_register = 0x0d,
503 DW_CFA_def_cfa_offset = 0x0e,
504 DW_CFA_def_cfa_expression = 0x0f,
505 DW_CFA_expression = 0x10,
506 /* Dwarf 2.1 */
507 DW_CFA_offset_extended_sf = 0x11,
508 DW_CFA_def_cfa_sf = 0x12,
509 DW_CFA_def_cfa_offset_sf = 0x13,
510
511 /* SGI/MIPS specific */
512 DW_CFA_MIPS_advance_loc8 = 0x1d,
513
514 /* GNU extensions */
515 DW_CFA_GNU_window_save = 0x2d,
516 DW_CFA_GNU_args_size = 0x2e,
517 DW_CFA_GNU_negative_offset_extended = 0x2f
518 };
519
520#define DW_CIE_ID 0xffffffff
521#define DW_CIE_VERSION 1
522
523#define DW_CFA_extended 0
524#define DW_CFA_low_user 0x1c
525#define DW_CFA_high_user 0x3f
526
527#define DW_CHILDREN_no 0x00
528#define DW_CHILDREN_yes 0x01
529
530#define DW_ADDR_none 0
531
532/* Source language names and codes. */
533
534enum dwarf_source_language
535 {
536 DW_LANG_C89 = 0x0001,
537 DW_LANG_C = 0x0002,
538 DW_LANG_Ada83 = 0x0003,
539 DW_LANG_C_plus_plus = 0x0004,
540 DW_LANG_Cobol74 = 0x0005,
541 DW_LANG_Cobol85 = 0x0006,
542 DW_LANG_Fortran77 = 0x0007,
543 DW_LANG_Fortran90 = 0x0008,
544 DW_LANG_Pascal83 = 0x0009,
545 DW_LANG_Modula2 = 0x000a,
546 DW_LANG_Java = 0x000b,
547 DW_LANG_Mips_Assembler = 0x8001
548 };
549
550
551#define DW_LANG_lo_user 0x8000 /* implementation-defined range start */
552#define DW_LANG_hi_user 0xffff /* implementation-defined range start */
553
554/* Names and codes for macro information. */
555
556enum dwarf_macinfo_record_type
557 {
558 DW_MACINFO_define = 1,
559 DW_MACINFO_undef = 2,
560 DW_MACINFO_start_file = 3,
561 DW_MACINFO_end_file = 4,
562 DW_MACINFO_vendor_ext = 255
563 };
564
565#endif /* !ASSEMBLER */
566
567/* @@@ For use with GNU frame unwind information. */
568
569#define DW_EH_PE_absptr 0x00
570#define DW_EH_PE_omit 0xff
571
572#define DW_EH_PE_uleb128 0x01
573#define DW_EH_PE_udata2 0x02
574#define DW_EH_PE_udata4 0x03
575#define DW_EH_PE_udata8 0x04
576#define DW_EH_PE_sleb128 0x09
577#define DW_EH_PE_sdata2 0x0A
578#define DW_EH_PE_sdata4 0x0B
579#define DW_EH_PE_sdata8 0x0C
580#define DW_EH_PE_signed 0x08
581
582#define DW_EH_PE_pcrel 0x10
583#define DW_EH_PE_textrel 0x20
584#define DW_EH_PE_datarel 0x30
585#define DW_EH_PE_funcrel 0x40
586#define DW_EH_PE_aligned 0x50
587
588#define DW_EH_PE_indirect 0x80
589
590#endif /* dwarf2.h */
libc/glibc/sysdeps/generic/libc-lock.h created+140
...@@ -0,0 +1,140 @@
1/* libc-internal interface for mutex locks. Stub version.
2 Copyright (C) 1996-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _LIBC_LOCK_H
20#define _LIBC_LOCK_H 1
21
22
23/* Define a lock variable NAME with storage class CLASS. The lock must be
24 initialized with __libc_lock_init before it can be used (or define it
25 with __libc_lock_define_initialized, below). Use `extern' for CLASS to
26 declare a lock defined in another module. In public structure
27 definitions you must use a pointer to the lock structure (i.e., NAME
28 begins with a `*'), because its storage size will not be known outside
29 of libc. */
30#define __libc_lock_define(CLASS,NAME)
31#define __libc_lock_define_recursive(CLASS,NAME)
32#define __rtld_lock_define_recursive(CLASS,NAME)
33#define __libc_rwlock_define(CLASS,NAME)
34
35/* Define an initialized lock variable NAME with storage class CLASS. */
36#define __libc_lock_define_initialized(CLASS,NAME)
37#define __libc_rwlock_define_initialized(CLASS,NAME)
38
39/* Define an initialized recursive lock variable NAME with storage
40 class CLASS. */
41#define __libc_lock_define_initialized_recursive(CLASS,NAME)
42#define __rtld_lock_define_initialized_recursive(CLASS,NAME)
43
44/* Initialize the named lock variable, leaving it in a consistent, unlocked
45 state. */
46#define __libc_lock_init(NAME)
47#define __rtld_lock_initialize(NAME)
48#define __libc_rwlock_init(NAME)
49
50/* Same as last but this time we initialize a recursive mutex. */
51#define __libc_lock_init_recursive(NAME)
52
53/* Finalize the named lock variable, which must be locked. It cannot be
54 used again until __libc_lock_init is called again on it. This must be
55 called on a lock variable before the containing storage is reused. */
56#define __libc_lock_fini(NAME)
57#define __libc_rwlock_fini(NAME)
58
59/* Finalize recursive named lock. */
60#define __libc_lock_fini_recursive(NAME)
61
62/* Lock the named lock variable. */
63#define __libc_lock_lock(NAME)
64#define __libc_rwlock_rdlock(NAME)
65#define __libc_rwlock_wrlock(NAME)
66
67/* Lock the recursive named lock variable. */
68#define __libc_lock_lock_recursive(NAME)
69#define __rtld_lock_lock_recursive(NAME)
70
71/* Try to lock the named lock variable. */
72#define __libc_lock_trylock(NAME) 0
73#define __libc_rwlock_tryrdlock(NAME) 0
74#define __libc_rwlock_trywrlock(NAME) 0
75
76/* Try to lock the recursive named lock variable. */
77#define __libc_lock_trylock_recursive(NAME) 0
78
79/* Unlock the named lock variable. */
80#define __libc_lock_unlock(NAME)
81#define __libc_rwlock_unlock(NAME)
82
83/* Unlock the recursive named lock variable. */
84#define __libc_lock_unlock_recursive(NAME)
85#define __rtld_lock_unlock_recursive(NAME)
86
87
88/* Define once control variable. */
89#define __libc_once_define(CLASS, NAME) CLASS int NAME = 0
90
91/* Call handler iff the first call. */
92#define __libc_once(ONCE_CONTROL, INIT_FUNCTION) \
93 do { \
94 if ((ONCE_CONTROL) == 0) { \
95 INIT_FUNCTION (); \
96 (ONCE_CONTROL) = 1; \
97 } \
98 } while (0)
99
100/* Get once control variable. */
101#define __libc_once_get(ONCE_CONTROL) \
102 ((ONCE_CONTROL) == 1)
103
104/* Start a critical region with a cleanup function */
105#define __libc_cleanup_region_start(DOIT, FCT, ARG) \
106{ \
107 typeof (***(FCT)) *__save_FCT = (DOIT) ? (FCT) : 0; \
108 typeof (ARG) __save_ARG = ARG; \
109 /* close brace is in __libc_cleanup_region_end below. */
110
111/* End a critical region started with __libc_cleanup_region_start. */
112#define __libc_cleanup_region_end(DOIT) \
113 if ((DOIT) && __save_FCT != 0) \
114 (*__save_FCT)(__save_ARG); \
115}
116
117/* Sometimes we have to exit the block in the middle. */
118#define __libc_cleanup_end(DOIT) \
119 if ((DOIT) && __save_FCT != 0) \
120 (*__save_FCT)(__save_ARG); \
121
122#define __libc_cleanup_push(fct, arg) __libc_cleanup_region_start (1, fct, arg)
123#define __libc_cleanup_pop(execute) __libc_cleanup_region_end (execute)
124
125/* We need portable names for some of the functions. */
126#define __libc_mutex_unlock
127
128/* Type for key of thread specific data. */
129typedef int __libc_key_t;
130
131/* Create key for thread specific data. */
132#define __libc_key_create(KEY,DEST) ((void) (KEY), (void) (DEST), -1)
133
134/* Set thread-specific data associated with KEY to VAL. */
135#define __libc_setspecific(KEY,VAL) ((void) (KEY), (void) (VAL))
136
137/* Get thread-specific data associated with KEY. */
138#define __libc_getspecific(KEY) ((void) (KEY), (void *) 0)
139
140#endif /* libc-lock.h */
libc/glibc/sysdeps/generic/stackinfo.h created+20
...@@ -0,0 +1,20 @@
1/* Copyright (C) 1999-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/* This file contains a bit of information about the stack allocation
19 of the processor. Since there is no general truth we can't say
20 anything here. */
libc/glibc/sysdeps/generic/symbol-hacks.h created+19
...@@ -0,0 +1,19 @@
1/* Some compiler optimizations may transform loops into memset/memmove
2 calls and without proper declaration it may generate PLT calls. */
3#if !defined __ASSEMBLER__ && IS_IN (libc) && defined SHARED
4asm ("memmove = __GI_memmove");
5asm ("memset = __GI_memset");
6asm ("memcpy = __GI_memcpy");
7
8/* Some targets do not use __stack_chk_fail_local. In libc.so,
9 redirect __stack_chk_fail to a hidden reference
10 __stack_chk_fail_local, to avoid the PLT reference.
11 __stack_chk_fail itself is a global symbol, exported from libc.so,
12 and cannot be made hidden. */
13
14# if IS_IN (libc) && defined SHARED && \
15 defined STACK_PROTECTOR_LEVEL && STACK_PROTECTOR_LEVEL > 0
16asm (".hidden __stack_chk_fail_local\n"
17 "__stack_chk_fail = __stack_chk_fail_local");
18# endif
19#endif
libc/glibc/sysdeps/generic/sysdep.h created+97
...@@ -0,0 +1,97 @@
1/* Generic asm macros used on many machines.
2 Copyright (C) 1991-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef C_LABEL
20
21/* Define a macro we can use to construct the asm name for a C symbol. */
22# define C_LABEL(name) name##:
23
24#endif
25
26#ifdef __ASSEMBLER__
27/* Mark the end of function named SYM. This is used on some platforms
28 to generate correct debugging information. */
29# ifndef END
30# define END(sym)
31# endif
32
33# ifndef JUMPTARGET
34# define JUMPTARGET(sym) sym
35# endif
36#endif
37
38/* Makros to generate eh_frame unwind information. */
39#ifdef __ASSEMBLER__
40# define cfi_startproc .cfi_startproc
41# define cfi_endproc .cfi_endproc
42# define cfi_def_cfa(reg, off) .cfi_def_cfa reg, off
43# define cfi_def_cfa_register(reg) .cfi_def_cfa_register reg
44# define cfi_def_cfa_offset(off) .cfi_def_cfa_offset off
45# define cfi_adjust_cfa_offset(off) .cfi_adjust_cfa_offset off
46# define cfi_offset(reg, off) .cfi_offset reg, off
47# define cfi_rel_offset(reg, off) .cfi_rel_offset reg, off
48# define cfi_register(r1, r2) .cfi_register r1, r2
49# define cfi_return_column(reg) .cfi_return_column reg
50# define cfi_restore(reg) .cfi_restore reg
51# define cfi_same_value(reg) .cfi_same_value reg
52# define cfi_undefined(reg) .cfi_undefined reg
53# define cfi_remember_state .cfi_remember_state
54# define cfi_restore_state .cfi_restore_state
55# define cfi_window_save .cfi_window_save
56# define cfi_personality(enc, exp) .cfi_personality enc, exp
57# define cfi_lsda(enc, exp) .cfi_lsda enc, exp
58
59#else /* ! ASSEMBLER */
60
61# define CFI_STRINGIFY(Name) CFI_STRINGIFY2 (Name)
62# define CFI_STRINGIFY2(Name) #Name
63# define CFI_STARTPROC ".cfi_startproc"
64# define CFI_ENDPROC ".cfi_endproc"
65# define CFI_DEF_CFA(reg, off) \
66 ".cfi_def_cfa " CFI_STRINGIFY(reg) "," CFI_STRINGIFY(off)
67# define CFI_DEF_CFA_REGISTER(reg) \
68 ".cfi_def_cfa_register " CFI_STRINGIFY(reg)
69# define CFI_DEF_CFA_OFFSET(off) \
70 ".cfi_def_cfa_offset " CFI_STRINGIFY(off)
71# define CFI_ADJUST_CFA_OFFSET(off) \
72 ".cfi_adjust_cfa_offset " CFI_STRINGIFY(off)
73# define CFI_OFFSET(reg, off) \
74 ".cfi_offset " CFI_STRINGIFY(reg) "," CFI_STRINGIFY(off)
75# define CFI_REL_OFFSET(reg, off) \
76 ".cfi_rel_offset " CFI_STRINGIFY(reg) "," CFI_STRINGIFY(off)
77# define CFI_REGISTER(r1, r2) \
78 ".cfi_register " CFI_STRINGIFY(r1) "," CFI_STRINGIFY(r2)
79# define CFI_RETURN_COLUMN(reg) \
80 ".cfi_return_column " CFI_STRINGIFY(reg)
81# define CFI_RESTORE(reg) \
82 ".cfi_restore " CFI_STRINGIFY(reg)
83# define CFI_UNDEFINED(reg) \
84 ".cfi_undefined " CFI_STRINGIFY(reg)
85# define CFI_REMEMBER_STATE \
86 ".cfi_remember_state"
87# define CFI_RESTORE_STATE \
88 ".cfi_restore_state"
89# define CFI_WINDOW_SAVE \
90 ".cfi_window_save"
91# define CFI_PERSONALITY(enc, exp) \
92 ".cfi_personality " CFI_STRINGIFY(enc) "," CFI_STRINGIFY(exp)
93# define CFI_LSDA(enc, exp) \
94 ".cfi_lsda " CFI_STRINGIFY(enc) "," CFI_STRINGIFY(exp)
95#endif
96
97#include "dwarf2.h"
libc/glibc/sysdeps/nptl/bits/pthreadtypes.h created+121
...@@ -0,0 +1,121 @@
1/* Declaration of common pthread types for all architectures.
2 Copyright (C) 2017-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_PTHREADTYPES_COMMON_H
20# define _BITS_PTHREADTYPES_COMMON_H 1
21
22/* For internal mutex and condition variable definitions. */
23#include <bits/thread-shared-types.h>
24
25/* Thread identifiers. The structure of the attribute type is not
26 exposed on purpose. */
27typedef unsigned long int pthread_t;
28
29
30/* Data structures for mutex handling. The structure of the attribute
31 type is not exposed on purpose. */
32typedef union
33{
34 char __size[__SIZEOF_PTHREAD_MUTEXATTR_T];
35 int __align;
36} pthread_mutexattr_t;
37
38
39/* Data structure for condition variable handling. The structure of
40 the attribute type is not exposed on purpose. */
41typedef union
42{
43 char __size[__SIZEOF_PTHREAD_CONDATTR_T];
44 int __align;
45} pthread_condattr_t;
46
47
48/* Keys for thread-specific data */
49typedef unsigned int pthread_key_t;
50
51
52/* Once-only execution */
53typedef int __ONCE_ALIGNMENT pthread_once_t;
54
55
56union pthread_attr_t
57{
58 char __size[__SIZEOF_PTHREAD_ATTR_T];
59 long int __align;
60};
61#ifndef __have_pthread_attr_t
62typedef union pthread_attr_t pthread_attr_t;
63# define __have_pthread_attr_t 1
64#endif
65
66
67typedef union
68{
69 struct __pthread_mutex_s __data;
70 char __size[__SIZEOF_PTHREAD_MUTEX_T];
71 long int __align;
72} pthread_mutex_t;
73
74
75typedef union
76{
77 struct __pthread_cond_s __data;
78 char __size[__SIZEOF_PTHREAD_COND_T];
79 __extension__ long long int __align;
80} pthread_cond_t;
81
82
83#if defined __USE_UNIX98 || defined __USE_XOPEN2K
84/* Data structure for reader-writer lock variable handling. The
85 structure of the attribute type is deliberately not exposed. */
86typedef union
87{
88 struct __pthread_rwlock_arch_t __data;
89 char __size[__SIZEOF_PTHREAD_RWLOCK_T];
90 long int __align;
91} pthread_rwlock_t;
92
93typedef union
94{
95 char __size[__SIZEOF_PTHREAD_RWLOCKATTR_T];
96 long int __align;
97} pthread_rwlockattr_t;
98#endif
99
100
101#ifdef __USE_XOPEN2K
102/* POSIX spinlock data type. */
103typedef volatile int pthread_spinlock_t;
104
105
106/* POSIX barriers data type. The structure of the type is
107 deliberately not exposed. */
108typedef union
109{
110 char __size[__SIZEOF_PTHREAD_BARRIER_T];
111 long int __align;
112} pthread_barrier_t;
113
114typedef union
115{
116 char __size[__SIZEOF_PTHREAD_BARRIERATTR_T];
117 int __align;
118} pthread_barrierattr_t;
119#endif
120
121#endif
libc/glibc/sysdeps/nptl/bits/thread-shared-types.h created+198
...@@ -0,0 +1,198 @@
1/* Common threading primitives definitions for both POSIX and C11.
2 Copyright (C) 2017-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _THREAD_SHARED_TYPES_H
20#define _THREAD_SHARED_TYPES_H 1
21
22/* Arch-specific definitions. Each architecture must define the following
23 macros to define the expected sizes of pthread data types:
24
25 __SIZEOF_PTHREAD_ATTR_T - size of pthread_attr_t.
26 __SIZEOF_PTHREAD_MUTEX_T - size of pthread_mutex_t.
27 __SIZEOF_PTHREAD_MUTEXATTR_T - size of pthread_mutexattr_t.
28 __SIZEOF_PTHREAD_COND_T - size of pthread_cond_t.
29 __SIZEOF_PTHREAD_CONDATTR_T - size of pthread_condattr_t.
30 __SIZEOF_PTHREAD_RWLOCK_T - size of pthread_rwlock_t.
31 __SIZEOF_PTHREAD_RWLOCKATTR_T - size of pthread_rwlockattr_t.
32 __SIZEOF_PTHREAD_BARRIER_T - size of pthread_barrier_t.
33 __SIZEOF_PTHREAD_BARRIERATTR_T - size of pthread_barrierattr_t.
34
35 Also, the following macros must be define for internal pthread_mutex_t
36 struct definitions (struct __pthread_mutex_s):
37
38 __PTHREAD_COMPAT_PADDING_MID - any additional members after 'kind'
39 and before '__spin' (for 64 bits) or
40 '__nusers' (for 32 bits).
41 __PTHREAD_COMPAT_PADDING_END - any additional members at the end of
42 the internal structure.
43 __PTHREAD_MUTEX_LOCK_ELISION - 1 if the architecture supports lock
44 elision or 0 otherwise.
45 __PTHREAD_MUTEX_NUSERS_AFTER_KIND - control where to put __nusers. The
46 preferred value for new architectures
47 is 0.
48 __PTHREAD_MUTEX_USE_UNION - control whether internal __spins and
49 __list will be place inside a union for
50 linuxthreads compatibility.
51 The preferred value for new architectures
52 is 0.
53
54 For a new port the preferred values for the required defines are:
55
56 #define __PTHREAD_COMPAT_PADDING_MID
57 #define __PTHREAD_COMPAT_PADDING_END
58 #define __PTHREAD_MUTEX_LOCK_ELISION 0
59 #define __PTHREAD_MUTEX_NUSERS_AFTER_KIND 0
60 #define __PTHREAD_MUTEX_USE_UNION 0
61
62 __PTHREAD_MUTEX_LOCK_ELISION can be set to 1 if the hardware plans to
63 eventually support lock elision using transactional memory.
64
65 The additional macro defines any constraint for the lock alignment
66 inside the thread structures:
67
68 __LOCK_ALIGNMENT - for internal lock/futex usage.
69
70 Same idea but for the once locking primitive:
71
72 __ONCE_ALIGNMENT - for pthread_once_t/once_flag definition.
73
74 And finally the internal pthread_rwlock_t (struct __pthread_rwlock_arch_t)
75 must be defined.
76 */
77#include <bits/pthreadtypes-arch.h>
78
79/* Common definition of pthread_mutex_t. */
80
81#if !__PTHREAD_MUTEX_USE_UNION
82typedef struct __pthread_internal_list
83{
84 struct __pthread_internal_list *__prev;
85 struct __pthread_internal_list *__next;
86} __pthread_list_t;
87#else
88typedef struct __pthread_internal_slist
89{
90 struct __pthread_internal_slist *__next;
91} __pthread_slist_t;
92#endif
93
94/* Lock elision support. */
95#if __PTHREAD_MUTEX_LOCK_ELISION
96# if !__PTHREAD_MUTEX_USE_UNION
97# define __PTHREAD_SPINS_DATA \
98 short __spins; \
99 short __elision
100# define __PTHREAD_SPINS 0, 0
101# else
102# define __PTHREAD_SPINS_DATA \
103 struct \
104 { \
105 short __espins; \
106 short __eelision; \
107 } __elision_data
108# define __PTHREAD_SPINS { 0, 0 }
109# define __spins __elision_data.__espins
110# define __elision __elision_data.__eelision
111# endif
112#else
113# define __PTHREAD_SPINS_DATA int __spins
114/* Mutex __spins initializer used by PTHREAD_MUTEX_INITIALIZER. */
115# define __PTHREAD_SPINS 0
116#endif
117
118struct __pthread_mutex_s
119{
120 int __lock __LOCK_ALIGNMENT;
121 unsigned int __count;
122 int __owner;
123#if !__PTHREAD_MUTEX_NUSERS_AFTER_KIND
124 unsigned int __nusers;
125#endif
126 /* KIND must stay at this position in the structure to maintain
127 binary compatibility with static initializers.
128
129 Concurrency notes:
130 The __kind of a mutex is initialized either by the static
131 PTHREAD_MUTEX_INITIALIZER or by a call to pthread_mutex_init.
132
133 After a mutex has been initialized, the __kind of a mutex is usually not
134 changed. BUT it can be set to -1 in pthread_mutex_destroy or elision can
135 be enabled. This is done concurrently in the pthread_mutex_*lock functions
136 by using the macro FORCE_ELISION. This macro is only defined for
137 architectures which supports lock elision.
138
139 For elision, there are the flags PTHREAD_MUTEX_ELISION_NP and
140 PTHREAD_MUTEX_NO_ELISION_NP which can be set in addition to the already set
141 type of a mutex.
142 Before a mutex is initialized, only PTHREAD_MUTEX_NO_ELISION_NP can be set
143 with pthread_mutexattr_settype.
144 After a mutex has been initialized, the functions pthread_mutex_*lock can
145 enable elision - if the mutex-type and the machine supports it - by setting
146 the flag PTHREAD_MUTEX_ELISION_NP. This is done concurrently. Afterwards
147 the lock / unlock functions are using specific elision code-paths. */
148 int __kind;
149 __PTHREAD_COMPAT_PADDING_MID
150#if __PTHREAD_MUTEX_NUSERS_AFTER_KIND
151 unsigned int __nusers;
152#endif
153#if !__PTHREAD_MUTEX_USE_UNION
154 __PTHREAD_SPINS_DATA;
155 __pthread_list_t __list;
156# define __PTHREAD_MUTEX_HAVE_PREV 1
157#else
158 __extension__ union
159 {
160 __PTHREAD_SPINS_DATA;
161 __pthread_slist_t __list;
162 };
163# define __PTHREAD_MUTEX_HAVE_PREV 0
164#endif
165 __PTHREAD_COMPAT_PADDING_END
166};
167
168
169/* Common definition of pthread_cond_t. */
170
171struct __pthread_cond_s
172{
173 __extension__ union
174 {
175 __extension__ unsigned long long int __wseq;
176 struct
177 {
178 unsigned int __low;
179 unsigned int __high;
180 } __wseq32;
181 };
182 __extension__ union
183 {
184 __extension__ unsigned long long int __g1_start;
185 struct
186 {
187 unsigned int __low;
188 unsigned int __high;
189 } __g1_start32;
190 };
191 unsigned int __g_refs[2] __LOCK_ALIGNMENT;
192 unsigned int __g_size[2];
193 unsigned int __g1_orig_size;
194 unsigned int __wrefs;
195 unsigned int __g_signals[2];
196};
197
198#endif /* _THREAD_SHARED_TYPES_H */
libc/glibc/sysdeps/nptl/libc-lock.h created+187
...@@ -0,0 +1,187 @@
1/* libc-internal interface for mutex locks. NPTL version.
2 Copyright (C) 1996-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If
17 not, see <http://www.gnu.org/licenses/>. */
18
19#ifndef _LIBC_LOCK_H
20#define _LIBC_LOCK_H 1
21
22#include <pthread.h>
23#define __need_NULL
24#include <stddef.h>
25
26
27/* Mutex type. */
28#if defined _LIBC || defined _IO_MTSAFE_IO
29# if (!IS_IN (libc) && !IS_IN (libpthread)) || !defined _LIBC
30typedef struct { pthread_mutex_t mutex; } __libc_lock_recursive_t;
31# else
32typedef struct { int lock; int cnt; void *owner; } __libc_lock_recursive_t;
33# endif
34#else
35typedef struct __libc_lock_recursive_opaque__ __libc_lock_recursive_t;
36#endif
37
38/* Define a lock variable NAME with storage class CLASS. The lock must be
39 initialized with __libc_lock_init before it can be used (or define it
40 with __libc_lock_define_initialized, below). Use `extern' for CLASS to
41 declare a lock defined in another module. In public structure
42 definitions you must use a pointer to the lock structure (i.e., NAME
43 begins with a `*'), because its storage size will not be known outside
44 of libc. */
45#define __libc_lock_define_recursive(CLASS,NAME) \
46 CLASS __libc_lock_recursive_t NAME;
47
48/* Define an initialized recursive lock variable NAME with storage
49 class CLASS. */
50#if defined _LIBC && (IS_IN (libc) || IS_IN (libpthread))
51# define __libc_lock_define_initialized_recursive(CLASS, NAME) \
52 CLASS __libc_lock_recursive_t NAME = _LIBC_LOCK_RECURSIVE_INITIALIZER;
53# define _LIBC_LOCK_RECURSIVE_INITIALIZER \
54 { LLL_LOCK_INITIALIZER, 0, NULL }
55#else
56# define __libc_lock_define_initialized_recursive(CLASS,NAME) \
57 CLASS __libc_lock_recursive_t NAME = _LIBC_LOCK_RECURSIVE_INITIALIZER;
58# define _LIBC_LOCK_RECURSIVE_INITIALIZER \
59 {PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP}
60#endif
61
62/* Initialize a recursive mutex. */
63#if defined _LIBC && (IS_IN (libc) || IS_IN (libpthread))
64# define __libc_lock_init_recursive(NAME) \
65 ((void) ((NAME) = (__libc_lock_recursive_t) _LIBC_LOCK_RECURSIVE_INITIALIZER))
66#else
67# define __libc_lock_init_recursive(NAME) \
68 do { \
69 if (__pthread_mutex_init != NULL) \
70 { \
71 pthread_mutexattr_t __attr; \
72 __pthread_mutexattr_init (&__attr); \
73 __pthread_mutexattr_settype (&__attr, PTHREAD_MUTEX_RECURSIVE_NP); \
74 __pthread_mutex_init (&(NAME).mutex, &__attr); \
75 __pthread_mutexattr_destroy (&__attr); \
76 } \
77 } while (0)
78#endif
79
80/* Finalize recursive named lock. */
81#if defined _LIBC && (IS_IN (libc) || IS_IN (libpthread))
82# define __libc_lock_fini_recursive(NAME) ((void) 0)
83#else
84# define __libc_lock_fini_recursive(NAME) \
85 __libc_maybe_call (__pthread_mutex_destroy, (&(NAME).mutex), 0)
86#endif
87
88/* Lock the recursive named lock variable. */
89#if defined _LIBC && (IS_IN (libc) || IS_IN (libpthread))
90# define __libc_lock_lock_recursive(NAME) \
91 do { \
92 void *self = THREAD_SELF; \
93 if ((NAME).owner != self) \
94 { \
95 lll_lock ((NAME).lock, LLL_PRIVATE); \
96 (NAME).owner = self; \
97 } \
98 ++(NAME).cnt; \
99 } while (0)
100#else
101# define __libc_lock_lock_recursive(NAME) \
102 __libc_maybe_call (__pthread_mutex_lock, (&(NAME).mutex), 0)
103#endif
104
105/* Try to lock the recursive named lock variable. */
106#if defined _LIBC && (IS_IN (libc) || IS_IN (libpthread))
107# define __libc_lock_trylock_recursive(NAME) \
108 ({ \
109 int result = 0; \
110 void *self = THREAD_SELF; \
111 if ((NAME).owner != self) \
112 { \
113 if (lll_trylock ((NAME).lock) == 0) \
114 { \
115 (NAME).owner = self; \
116 (NAME).cnt = 1; \
117 } \
118 else \
119 result = EBUSY; \
120 } \
121 else \
122 ++(NAME).cnt; \
123 result; \
124 })
125#else
126# define __libc_lock_trylock_recursive(NAME) \
127 __libc_maybe_call (__pthread_mutex_trylock, (&(NAME).mutex), 0)
128#endif
129
130/* Unlock the recursive named lock variable. */
131#if defined _LIBC && (IS_IN (libc) || IS_IN (libpthread))
132/* We do no error checking here. */
133# define __libc_lock_unlock_recursive(NAME) \
134 do { \
135 if (--(NAME).cnt == 0) \
136 { \
137 (NAME).owner = NULL; \
138 lll_unlock ((NAME).lock, LLL_PRIVATE); \
139 } \
140 } while (0)
141#else
142# define __libc_lock_unlock_recursive(NAME) \
143 __libc_maybe_call (__pthread_mutex_unlock, (&(NAME).mutex), 0)
144#endif
145
146/* Note that for I/O cleanup handling we are using the old-style
147 cancel handling. It does not have to be integrated with C++ since
148 no C++ code is called in the middle. The old-style handling is
149 faster and the support is not going away. */
150extern void _pthread_cleanup_push_defer (struct _pthread_cleanup_buffer *buffer,
151 void (*routine) (void *), void *arg);
152extern void _pthread_cleanup_pop_restore (struct _pthread_cleanup_buffer *buffer,
153 int execute);
154
155/* Start critical region with cleanup. */
156#define __libc_cleanup_region_start(DOIT, FCT, ARG) \
157 { struct _pthread_cleanup_buffer _buffer; \
158 int _avail; \
159 if (DOIT) { \
160 _avail = PTFAVAIL (_pthread_cleanup_push_defer); \
161 if (_avail) { \
162 __libc_ptf_call_always (_pthread_cleanup_push_defer, (&_buffer, FCT, \
163 ARG)); \
164 } else { \
165 _buffer.__routine = (FCT); \
166 _buffer.__arg = (ARG); \
167 } \
168 } else { \
169 _avail = 0; \
170 }
171
172/* End critical region with cleanup. */
173#define __libc_cleanup_region_end(DOIT) \
174 if (_avail) { \
175 __libc_ptf_call_always (_pthread_cleanup_pop_restore, (&_buffer, DOIT));\
176 } else if (DOIT) \
177 _buffer.__routine (_buffer.__arg); \
178 }
179
180
181/* Hide the definitions which are only supposed to be used inside libc in
182 a separate file. This file is not present in the installation! */
183#ifdef _LIBC
184# include "libc-lockP.h"
185#endif
186
187#endif /* libc-lock.h */
libc/glibc/sysdeps/nptl/libc-lockP.h created+436
...@@ -0,0 +1,436 @@
1/* Private libc-internal interface for mutex locks. NPTL version.
2 Copyright (C) 1996-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If
17 not, see <http://www.gnu.org/licenses/>. */
18
19#ifndef _LIBC_LOCKP_H
20#define _LIBC_LOCKP_H 1
21
22#include <pthread.h>
23#define __need_NULL
24#include <stddef.h>
25
26
27/* Fortunately Linux now has a mean to do locking which is realtime
28 safe without the aid of the thread library. We also need no fancy
29 options like error checking mutexes etc. We only need simple
30 locks, maybe recursive. This can be easily and cheaply implemented
31 using futexes. We will use them everywhere except in ld.so since
32 ld.so might be used on old kernels with a different libc.so. */
33#include <lowlevellock.h>
34#include <tls.h>
35#include <pthread-functions.h>
36
37#if IS_IN (libpthread)
38/* This gets us the declarations of the __pthread_* internal names,
39 and hidden_proto for them. */
40# include <nptl/pthreadP.h>
41#endif
42
43/* Mutex type. */
44#if !IS_IN (libc) && !IS_IN (libpthread)
45typedef pthread_mutex_t __libc_lock_t;
46#else
47typedef int __libc_lock_t;
48#endif
49typedef struct { pthread_mutex_t mutex; } __rtld_lock_recursive_t;
50typedef pthread_rwlock_t __libc_rwlock_t;
51
52/* Type for key to thread-specific data. */
53typedef pthread_key_t __libc_key_t;
54
55/* Define a lock variable NAME with storage class CLASS. The lock must be
56 initialized with __libc_lock_init before it can be used (or define it
57 with __libc_lock_define_initialized, below). Use `extern' for CLASS to
58 declare a lock defined in another module. In public structure
59 definitions you must use a pointer to the lock structure (i.e., NAME
60 begins with a `*'), because its storage size will not be known outside
61 of libc. */
62#define __libc_lock_define(CLASS,NAME) \
63 CLASS __libc_lock_t NAME;
64#define __libc_rwlock_define(CLASS,NAME) \
65 CLASS __libc_rwlock_t NAME;
66#define __rtld_lock_define_recursive(CLASS,NAME) \
67 CLASS __rtld_lock_recursive_t NAME;
68
69/* Define an initialized lock variable NAME with storage class CLASS.
70
71 For the C library we take a deeper look at the initializer. For
72 this implementation all fields are initialized to zero. Therefore
73 we don't initialize the variable which allows putting it into the
74 BSS section. (Except on PA-RISC and other odd architectures, where
75 initialized locks must be set to one due to the lack of normal
76 atomic operations.) */
77
78#define _LIBC_LOCK_INITIALIZER LLL_LOCK_INITIALIZER
79#if IS_IN (libc) || IS_IN (libpthread)
80# if LLL_LOCK_INITIALIZER == 0
81# define __libc_lock_define_initialized(CLASS,NAME) \
82 CLASS __libc_lock_t NAME;
83# else
84# define __libc_lock_define_initialized(CLASS,NAME) \
85 CLASS __libc_lock_t NAME = LLL_LOCK_INITIALIZER;
86# endif
87#else
88# define __libc_lock_define_initialized(CLASS,NAME) \
89 CLASS __libc_lock_t NAME;
90#endif
91
92#define __libc_rwlock_define_initialized(CLASS,NAME) \
93 CLASS __libc_rwlock_t NAME = PTHREAD_RWLOCK_INITIALIZER;
94
95#define __rtld_lock_define_initialized_recursive(CLASS,NAME) \
96 CLASS __rtld_lock_recursive_t NAME = _RTLD_LOCK_RECURSIVE_INITIALIZER;
97#define _RTLD_LOCK_RECURSIVE_INITIALIZER \
98 {PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP}
99
100#define __rtld_lock_initialize(NAME) \
101 (void) ((NAME) = (__rtld_lock_recursive_t) _RTLD_LOCK_RECURSIVE_INITIALIZER)
102
103/* If we check for a weakly referenced symbol and then perform a
104 normal jump to it te code generated for some platforms in case of
105 PIC is unnecessarily slow. What would happen is that the function
106 is first referenced as data and then it is called indirectly
107 through the PLT. We can make this a direct jump. */
108#ifdef __PIC__
109# define __libc_maybe_call(FUNC, ARGS, ELSE) \
110 (__extension__ ({ __typeof (FUNC) *_fn = (FUNC); \
111 _fn != NULL ? (*_fn) ARGS : ELSE; }))
112#else
113# define __libc_maybe_call(FUNC, ARGS, ELSE) \
114 (FUNC != NULL ? FUNC ARGS : ELSE)
115#endif
116
117/* Call thread functions through the function pointer table. */
118#if defined SHARED && IS_IN (libc)
119# define PTFAVAIL(NAME) __libc_pthread_functions_init
120# define __libc_ptf_call(FUNC, ARGS, ELSE) \
121 (__libc_pthread_functions_init ? PTHFCT_CALL (ptr_##FUNC, ARGS) : ELSE)
122# define __libc_ptf_call_always(FUNC, ARGS) \
123 PTHFCT_CALL (ptr_##FUNC, ARGS)
124#elif IS_IN (libpthread)
125# define PTFAVAIL(NAME) 1
126# define __libc_ptf_call(FUNC, ARGS, ELSE) \
127 FUNC ARGS
128# define __libc_ptf_call_always(FUNC, ARGS) \
129 FUNC ARGS
130#else
131# define PTFAVAIL(NAME) (NAME != NULL)
132# define __libc_ptf_call(FUNC, ARGS, ELSE) \
133 __libc_maybe_call (FUNC, ARGS, ELSE)
134# define __libc_ptf_call_always(FUNC, ARGS) \
135 FUNC ARGS
136#endif
137
138
139/* Initialize the named lock variable, leaving it in a consistent, unlocked
140 state. */
141#if IS_IN (libc) || IS_IN (libpthread)
142# define __libc_lock_init(NAME) \
143 ((void) ((NAME) = LLL_LOCK_INITIALIZER))
144#else
145# define __libc_lock_init(NAME) \
146 __libc_maybe_call (__pthread_mutex_init, (&(NAME), NULL), 0)
147#endif
148#if defined SHARED && IS_IN (libc)
149/* ((NAME) = (__libc_rwlock_t) PTHREAD_RWLOCK_INITIALIZER) is inefficient. */
150# define __libc_rwlock_init(NAME) \
151 ((void) __builtin_memset (&(NAME), '\0', sizeof (NAME)))
152#else
153# define __libc_rwlock_init(NAME) \
154 __libc_maybe_call (__pthread_rwlock_init, (&(NAME), NULL), 0)
155#endif
156
157/* Finalize the named lock variable, which must be locked. It cannot be
158 used again until __libc_lock_init is called again on it. This must be
159 called on a lock variable before the containing storage is reused. */
160#if IS_IN (libc) || IS_IN (libpthread)
161# define __libc_lock_fini(NAME) ((void) 0)
162#else
163# define __libc_lock_fini(NAME) \
164 __libc_maybe_call (__pthread_mutex_destroy, (&(NAME)), 0)
165#endif
166#if defined SHARED && IS_IN (libc)
167# define __libc_rwlock_fini(NAME) ((void) 0)
168#else
169# define __libc_rwlock_fini(NAME) \
170 __libc_maybe_call (__pthread_rwlock_destroy, (&(NAME)), 0)
171#endif
172
173/* Lock the named lock variable. */
174#if IS_IN (libc) || IS_IN (libpthread)
175# ifndef __libc_lock_lock
176# define __libc_lock_lock(NAME) \
177 ({ lll_lock (NAME, LLL_PRIVATE); 0; })
178# endif
179#else
180# undef __libc_lock_lock
181# define __libc_lock_lock(NAME) \
182 __libc_maybe_call (__pthread_mutex_lock, (&(NAME)), 0)
183#endif
184#define __libc_rwlock_rdlock(NAME) \
185 __libc_ptf_call (__pthread_rwlock_rdlock, (&(NAME)), 0)
186#define __libc_rwlock_wrlock(NAME) \
187 __libc_ptf_call (__pthread_rwlock_wrlock, (&(NAME)), 0)
188
189/* Try to lock the named lock variable. */
190#if IS_IN (libc) || IS_IN (libpthread)
191# ifndef __libc_lock_trylock
192# define __libc_lock_trylock(NAME) \
193 lll_trylock (NAME)
194# endif
195#else
196# undef __libc_lock_trylock
197# define __libc_lock_trylock(NAME) \
198 __libc_maybe_call (__pthread_mutex_trylock, (&(NAME)), 0)
199#endif
200#define __libc_rwlock_tryrdlock(NAME) \
201 __libc_maybe_call (__pthread_rwlock_tryrdlock, (&(NAME)), 0)
202#define __libc_rwlock_trywrlock(NAME) \
203 __libc_maybe_call (__pthread_rwlock_trywrlock, (&(NAME)), 0)
204
205#define __rtld_lock_trylock_recursive(NAME) \
206 __libc_maybe_call (__pthread_mutex_trylock, (&(NAME).mutex), 0)
207
208/* Unlock the named lock variable. */
209#if IS_IN (libc) || IS_IN (libpthread)
210# define __libc_lock_unlock(NAME) \
211 lll_unlock (NAME, LLL_PRIVATE)
212#else
213# define __libc_lock_unlock(NAME) \
214 __libc_maybe_call (__pthread_mutex_unlock, (&(NAME)), 0)
215#endif
216#define __libc_rwlock_unlock(NAME) \
217 __libc_ptf_call (__pthread_rwlock_unlock, (&(NAME)), 0)
218
219#ifdef SHARED
220# define __rtld_lock_default_lock_recursive(lock) \
221 ++((pthread_mutex_t *)(lock))->__data.__count;
222
223# define __rtld_lock_default_unlock_recursive(lock) \
224 --((pthread_mutex_t *)(lock))->__data.__count;
225
226# define __rtld_lock_lock_recursive(NAME) \
227 GL(dl_rtld_lock_recursive) (&(NAME).mutex)
228
229# define __rtld_lock_unlock_recursive(NAME) \
230 GL(dl_rtld_unlock_recursive) (&(NAME).mutex)
231#else
232# define __rtld_lock_lock_recursive(NAME) \
233 __libc_maybe_call (__pthread_mutex_lock, (&(NAME).mutex), 0)
234
235# define __rtld_lock_unlock_recursive(NAME) \
236 __libc_maybe_call (__pthread_mutex_unlock, (&(NAME).mutex), 0)
237#endif
238
239/* Define once control variable. */
240#if PTHREAD_ONCE_INIT == 0
241/* Special case for static variables where we can avoid the initialization
242 if it is zero. */
243# define __libc_once_define(CLASS, NAME) \
244 CLASS pthread_once_t NAME
245#else
246# define __libc_once_define(CLASS, NAME) \
247 CLASS pthread_once_t NAME = PTHREAD_ONCE_INIT
248#endif
249
250/* Call handler iff the first call. */
251#define __libc_once(ONCE_CONTROL, INIT_FUNCTION) \
252 do { \
253 if (PTFAVAIL (__pthread_once)) \
254 __libc_ptf_call_always (__pthread_once, (&(ONCE_CONTROL), \
255 INIT_FUNCTION)); \
256 else if ((ONCE_CONTROL) == PTHREAD_ONCE_INIT) { \
257 INIT_FUNCTION (); \
258 (ONCE_CONTROL) |= 2; \
259 } \
260 } while (0)
261
262/* Get once control variable. */
263#define __libc_once_get(ONCE_CONTROL) ((ONCE_CONTROL) != PTHREAD_ONCE_INIT)
264
265/* Note that for I/O cleanup handling we are using the old-style
266 cancel handling. It does not have to be integrated with C++ snce
267 no C++ code is called in the middle. The old-style handling is
268 faster and the support is not going away. */
269extern void _pthread_cleanup_push (struct _pthread_cleanup_buffer *buffer,
270 void (*routine) (void *), void *arg);
271extern void _pthread_cleanup_pop (struct _pthread_cleanup_buffer *buffer,
272 int execute);
273extern void _pthread_cleanup_push_defer (struct _pthread_cleanup_buffer *buffer,
274 void (*routine) (void *), void *arg);
275extern void _pthread_cleanup_pop_restore (struct _pthread_cleanup_buffer *buffer,
276 int execute);
277
278/* Sometimes we have to exit the block in the middle. */
279#define __libc_cleanup_end(DOIT) \
280 if (_avail) { \
281 __libc_ptf_call_always (_pthread_cleanup_pop_restore, (&_buffer, DOIT));\
282 } else if (DOIT) \
283 _buffer.__routine (_buffer.__arg)
284
285
286/* Normal cleanup handling, based on C cleanup attribute. */
287__extern_inline void
288__libc_cleanup_routine (struct __pthread_cleanup_frame *f)
289{
290 if (f->__do_it)
291 f->__cancel_routine (f->__cancel_arg);
292}
293
294#define __libc_cleanup_push(fct, arg) \
295 do { \
296 struct __pthread_cleanup_frame __clframe \
297 __attribute__ ((__cleanup__ (__libc_cleanup_routine))) \
298 = { .__cancel_routine = (fct), .__cancel_arg = (arg), \
299 .__do_it = 1 };
300
301#define __libc_cleanup_pop(execute) \
302 __clframe.__do_it = (execute); \
303 } while (0)
304
305
306/* Create thread-specific key. */
307#define __libc_key_create(KEY, DESTRUCTOR) \
308 __libc_ptf_call (__pthread_key_create, (KEY, DESTRUCTOR), 1)
309
310/* Get thread-specific data. */
311#define __libc_getspecific(KEY) \
312 __libc_ptf_call (__pthread_getspecific, (KEY), NULL)
313
314/* Set thread-specific data. */
315#define __libc_setspecific(KEY, VALUE) \
316 __libc_ptf_call (__pthread_setspecific, (KEY, VALUE), 0)
317
318
319/* Register handlers to execute before and after `fork'. Note that the
320 last parameter is NULL. The handlers registered by the libc are
321 never removed so this is OK. */
322extern int __register_atfork (void (*__prepare) (void),
323 void (*__parent) (void),
324 void (*__child) (void),
325 void *__dso_handle);
326
327/* Functions that are used by this file and are internal to the GNU C
328 library. */
329
330extern int __pthread_mutex_init (pthread_mutex_t *__mutex,
331 const pthread_mutexattr_t *__mutex_attr);
332
333extern int __pthread_mutex_destroy (pthread_mutex_t *__mutex);
334
335extern int __pthread_mutex_trylock (pthread_mutex_t *__mutex);
336
337extern int __pthread_mutex_lock (pthread_mutex_t *__mutex);
338
339extern int __pthread_mutex_unlock (pthread_mutex_t *__mutex);
340
341extern int __pthread_mutexattr_init (pthread_mutexattr_t *__attr);
342
343extern int __pthread_mutexattr_destroy (pthread_mutexattr_t *__attr);
344
345extern int __pthread_mutexattr_settype (pthread_mutexattr_t *__attr,
346 int __kind);
347
348extern int __pthread_rwlock_init (pthread_rwlock_t *__rwlock,
349 const pthread_rwlockattr_t *__attr);
350
351extern int __pthread_rwlock_destroy (pthread_rwlock_t *__rwlock);
352
353extern int __pthread_rwlock_rdlock (pthread_rwlock_t *__rwlock);
354
355extern int __pthread_rwlock_tryrdlock (pthread_rwlock_t *__rwlock);
356
357extern int __pthread_rwlock_wrlock (pthread_rwlock_t *__rwlock);
358
359extern int __pthread_rwlock_trywrlock (pthread_rwlock_t *__rwlock);
360
361extern int __pthread_rwlock_unlock (pthread_rwlock_t *__rwlock);
362
363extern int __pthread_key_create (pthread_key_t *__key,
364 void (*__destr_function) (void *));
365
366extern int __pthread_setspecific (pthread_key_t __key,
367 const void *__pointer);
368
369extern void *__pthread_getspecific (pthread_key_t __key);
370
371extern int __pthread_once (pthread_once_t *__once_control,
372 void (*__init_routine) (void));
373
374extern int __pthread_atfork (void (*__prepare) (void),
375 void (*__parent) (void),
376 void (*__child) (void));
377
378extern int __pthread_setcancelstate (int state, int *oldstate);
379
380
381/* Make the pthread functions weak so that we can elide them from
382 single-threaded processes. */
383#ifndef __NO_WEAK_PTHREAD_ALIASES
384# ifdef weak_extern
385weak_extern (__pthread_mutex_init)
386weak_extern (__pthread_mutex_destroy)
387weak_extern (__pthread_mutex_lock)
388weak_extern (__pthread_mutex_trylock)
389weak_extern (__pthread_mutex_unlock)
390weak_extern (__pthread_mutexattr_init)
391weak_extern (__pthread_mutexattr_destroy)
392weak_extern (__pthread_mutexattr_settype)
393weak_extern (__pthread_rwlock_init)
394weak_extern (__pthread_rwlock_destroy)
395weak_extern (__pthread_rwlock_rdlock)
396weak_extern (__pthread_rwlock_tryrdlock)
397weak_extern (__pthread_rwlock_wrlock)
398weak_extern (__pthread_rwlock_trywrlock)
399weak_extern (__pthread_rwlock_unlock)
400weak_extern (__pthread_key_create)
401weak_extern (__pthread_setspecific)
402weak_extern (__pthread_getspecific)
403weak_extern (__pthread_once)
404weak_extern (__pthread_initialize)
405weak_extern (__pthread_atfork)
406weak_extern (__pthread_setcancelstate)
407weak_extern (_pthread_cleanup_push_defer)
408weak_extern (_pthread_cleanup_pop_restore)
409# else
410# pragma weak __pthread_mutex_init
411# pragma weak __pthread_mutex_destroy
412# pragma weak __pthread_mutex_lock
413# pragma weak __pthread_mutex_trylock
414# pragma weak __pthread_mutex_unlock
415# pragma weak __pthread_mutexattr_init
416# pragma weak __pthread_mutexattr_destroy
417# pragma weak __pthread_mutexattr_settype
418# pragma weak __pthread_rwlock_destroy
419# pragma weak __pthread_rwlock_rdlock
420# pragma weak __pthread_rwlock_tryrdlock
421# pragma weak __pthread_rwlock_wrlock
422# pragma weak __pthread_rwlock_trywrlock
423# pragma weak __pthread_rwlock_unlock
424# pragma weak __pthread_key_create
425# pragma weak __pthread_setspecific
426# pragma weak __pthread_getspecific
427# pragma weak __pthread_once
428# pragma weak __pthread_initialize
429# pragma weak __pthread_atfork
430# pragma weak __pthread_setcancelstate
431# pragma weak _pthread_cleanup_push_defer
432# pragma weak _pthread_cleanup_pop_restore
433# endif
434#endif
435
436#endif /* libc-lockP.h */
libc/glibc/sysdeps/nptl/lowlevellock.h created+204
...@@ -0,0 +1,204 @@
1/* Low-level lock implementation. Generic futex-based version.
2 Copyright (C) 2005-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _LOWLEVELLOCK_H
20#define _LOWLEVELLOCK_H 1
21
22#include <atomic.h>
23#include <lowlevellock-futex.h>
24
25/* Low-level locks use a combination of atomic operations (to acquire and
26 release lock ownership) and futex operations (to block until the state
27 of a lock changes). A lock can be in one of three states:
28 0: not acquired,
29 1: acquired with no waiters; no other threads are blocked or about to block
30 for changes to the lock state,
31 >1: acquired, possibly with waiters; there may be other threads blocked or
32 about to block for changes to the lock state.
33
34 We expect that the common case is an uncontended lock, so we just need
35 to transition the lock between states 0 and 1; releasing the lock does
36 not need to wake any other blocked threads. If the lock is contended
37 and a thread decides to block using a futex operation, then this thread
38 needs to first change the state to >1; if this state is observed during
39 lock release, the releasing thread will wake one of the potentially
40 blocked threads.
41
42 Much of this code takes a 'private' parameter. This may be:
43 LLL_PRIVATE: lock only shared within a process
44 LLL_SHARED: lock may be shared across processes.
45
46 Condition variables contain an optimization for broadcasts that requeues
47 waiting threads on a lock's futex. Therefore, there is a special
48 variant of the locks (whose name contains "cond") that makes sure to
49 always set the lock state to >1 and not just 1.
50
51 Robust locks set the lock to the id of the owner. This allows detection
52 of the case where the owner exits without releasing the lock. Flags are
53 OR'd with the owner id to record additional information about lock state.
54 Therefore the states of robust locks are:
55 0: not acquired
56 id: acquired (by user identified by id & FUTEX_TID_MASK)
57
58 The following flags may be set in the robust lock value:
59 FUTEX_WAITERS - possibly has waiters
60 FUTEX_OWNER_DIED - owning user has exited without releasing the futex. */
61
62
63/* If LOCK is 0 (not acquired), set to 1 (acquired with no waiters) and return
64 0. Otherwise leave lock unchanged and return non-zero to indicate that the
65 lock was not acquired. */
66#define lll_trylock(lock) \
67 __glibc_unlikely (atomic_compare_and_exchange_bool_acq (&(lock), 1, 0))
68
69/* If LOCK is 0 (not acquired), set to 2 (acquired, possibly with waiters) and
70 return 0. Otherwise leave lock unchanged and return non-zero to indicate
71 that the lock was not acquired. */
72#define lll_cond_trylock(lock) \
73 __glibc_unlikely (atomic_compare_and_exchange_bool_acq (&(lock), 2, 0))
74
75extern void __lll_lock_wait_private (int *futex) attribute_hidden;
76extern void __lll_lock_wait (int *futex, int private) attribute_hidden;
77
78/* This is an expression rather than a statement even though its value is
79 void, so that it can be used in a comma expression or as an expression
80 that's cast to void. */
81/* The inner conditional compiles to a call to __lll_lock_wait_private if
82 private is known at compile time to be LLL_PRIVATE, and to a call to
83 __lll_lock_wait otherwise. */
84/* If FUTEX is 0 (not acquired), set to 1 (acquired with no waiters) and
85 return. Otherwise, ensure that it is >1 (acquired, possibly with waiters)
86 and then block until we acquire the lock, at which point FUTEX will still be
87 >1. The lock is always acquired on return. */
88#define __lll_lock(futex, private) \
89 ((void) \
90 ({ \
91 int *__futex = (futex); \
92 if (__glibc_unlikely \
93 (atomic_compare_and_exchange_bool_acq (__futex, 1, 0))) \
94 { \
95 if (__builtin_constant_p (private) && (private) == LLL_PRIVATE) \
96 __lll_lock_wait_private (__futex); \
97 else \
98 __lll_lock_wait (__futex, private); \
99 } \
100 }))
101#define lll_lock(futex, private) \
102 __lll_lock (&(futex), private)
103
104
105/* This is an expression rather than a statement even though its value is
106 void, so that it can be used in a comma expression or as an expression
107 that's cast to void. */
108/* Unconditionally set FUTEX to 2 (acquired, possibly with waiters). If FUTEX
109 was 0 (not acquired) then return. Otherwise, block until the lock is
110 acquired, at which point FUTEX is 2 (acquired, possibly with waiters). The
111 lock is always acquired on return. */
112#define __lll_cond_lock(futex, private) \
113 ((void) \
114 ({ \
115 int *__futex = (futex); \
116 if (__glibc_unlikely (atomic_exchange_acq (__futex, 2) != 0)) \
117 __lll_lock_wait (__futex, private); \
118 }))
119#define lll_cond_lock(futex, private) __lll_cond_lock (&(futex), private)
120
121
122extern int __lll_timedlock_wait (int *futex, const struct timespec *,
123 int private) attribute_hidden;
124
125
126/* As __lll_lock, but with a timeout. If the timeout occurs then return
127 ETIMEDOUT. If ABSTIME is invalid, return EINVAL. */
128#define __lll_timedlock(futex, abstime, private) \
129 ({ \
130 int *__futex = (futex); \
131 int __val = 0; \
132 \
133 if (__glibc_unlikely \
134 (atomic_compare_and_exchange_bool_acq (__futex, 1, 0))) \
135 __val = __lll_timedlock_wait (__futex, abstime, private); \
136 __val; \
137 })
138#define lll_timedlock(futex, abstime, private) \
139 __lll_timedlock (&(futex), abstime, private)
140
141
142/* This is an expression rather than a statement even though its value is
143 void, so that it can be used in a comma expression or as an expression
144 that's cast to void. */
145/* Unconditionally set FUTEX to 0 (not acquired), releasing the lock. If FUTEX
146 was >1 (acquired, possibly with waiters), then wake any waiters. The waiter
147 that acquires the lock will set FUTEX to >1.
148 Evaluate PRIVATE before releasing the lock so that we do not violate the
149 mutex destruction requirements. Specifically, we need to ensure that
150 another thread can destroy the mutex (and reuse its memory) once it
151 acquires the lock and when there will be no further lock acquisitions;
152 thus, we must not access the lock after releasing it, or those accesses
153 could be concurrent with mutex destruction or reuse of the memory. */
154#define __lll_unlock(futex, private) \
155 ((void) \
156 ({ \
157 int *__futex = (futex); \
158 int __private = (private); \
159 int __oldval = atomic_exchange_rel (__futex, 0); \
160 if (__glibc_unlikely (__oldval > 1)) \
161 lll_futex_wake (__futex, 1, __private); \
162 }))
163#define lll_unlock(futex, private) \
164 __lll_unlock (&(futex), private)
165
166
167#define lll_islocked(futex) \
168 ((futex) != LLL_LOCK_INITIALIZER)
169
170
171/* Our internal lock implementation is identical to the binary-compatible
172 mutex implementation. */
173
174/* Initializers for lock. */
175#define LLL_LOCK_INITIALIZER (0)
176#define LLL_LOCK_INITIALIZER_LOCKED (1)
177
178extern int __lll_timedwait_tid (int *, const struct timespec *)
179 attribute_hidden;
180
181/* The kernel notifies a process which uses CLONE_CHILD_CLEARTID via futex
182 wake-up when the clone terminates. The memory location contains the
183 thread ID while the clone is running and is reset to zero by the kernel
184 afterwards. The kernel up to version 3.16.3 does not use the private futex
185 operations for futex wake-up when the clone terminates.
186 If ABSTIME is not NULL, is used a timeout for futex call. If the timeout
187 occurs then return ETIMEOUT, if ABSTIME is invalid, return EINVAL.
188 The futex operation are issues with cancellable versions. */
189#define lll_wait_tid(tid, abstime) \
190 ({ \
191 int __res = 0; \
192 __typeof (tid) __tid; \
193 if (abstime != NULL) \
194 __res = __lll_timedwait_tid (&(tid), (abstime)); \
195 else \
196 /* We need acquire MO here so that we synchronize with the \
197 kernel's store to 0 when the clone terminates. (see above) */ \
198 while ((__tid = atomic_load_acquire (&(tid))) != 0) \
199 lll_futex_wait_cancel (&(tid), __tid, LLL_SHARED); \
200 __res; \
201 })
202
203
204#endif /* lowlevellock.h */
libc/glibc/sysdeps/nptl/pthread.h created+1162
...@@ -0,0 +1,1162 @@
1/* Copyright (C) 2002-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _PTHREAD_H
19#define _PTHREAD_H 1
20
21#include <features.h>
22#include <endian.h>
23#include <sched.h>
24#include <time.h>
25
26#include <bits/pthreadtypes.h>
27#include <bits/setjmp.h>
28#include <bits/wordsize.h>
29#include <bits/types/struct_timespec.h>
30
31
32/* Detach state. */
33enum
34{
35 PTHREAD_CREATE_JOINABLE,
36#define PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_JOINABLE
37 PTHREAD_CREATE_DETACHED
38#define PTHREAD_CREATE_DETACHED PTHREAD_CREATE_DETACHED
39};
40
41
42/* Mutex types. */
43enum
44{
45 PTHREAD_MUTEX_TIMED_NP,
46 PTHREAD_MUTEX_RECURSIVE_NP,
47 PTHREAD_MUTEX_ERRORCHECK_NP,
48 PTHREAD_MUTEX_ADAPTIVE_NP
49#if defined __USE_UNIX98 || defined __USE_XOPEN2K8
50 ,
51 PTHREAD_MUTEX_NORMAL = PTHREAD_MUTEX_TIMED_NP,
52 PTHREAD_MUTEX_RECURSIVE = PTHREAD_MUTEX_RECURSIVE_NP,
53 PTHREAD_MUTEX_ERRORCHECK = PTHREAD_MUTEX_ERRORCHECK_NP,
54 PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_NORMAL
55#endif
56#ifdef __USE_GNU
57 /* For compatibility. */
58 , PTHREAD_MUTEX_FAST_NP = PTHREAD_MUTEX_TIMED_NP
59#endif
60};
61
62
63#ifdef __USE_XOPEN2K
64/* Robust mutex or not flags. */
65enum
66{
67 PTHREAD_MUTEX_STALLED,
68 PTHREAD_MUTEX_STALLED_NP = PTHREAD_MUTEX_STALLED,
69 PTHREAD_MUTEX_ROBUST,
70 PTHREAD_MUTEX_ROBUST_NP = PTHREAD_MUTEX_ROBUST
71};
72#endif
73
74
75#if defined __USE_POSIX199506 || defined __USE_UNIX98
76/* Mutex protocols. */
77enum
78{
79 PTHREAD_PRIO_NONE,
80 PTHREAD_PRIO_INHERIT,
81 PTHREAD_PRIO_PROTECT
82};
83#endif
84
85
86#if __PTHREAD_MUTEX_HAVE_PREV
87# define PTHREAD_MUTEX_INITIALIZER \
88 { { 0, 0, 0, 0, 0, __PTHREAD_SPINS, { 0, 0 } } }
89# ifdef __USE_GNU
90# define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \
91 { { 0, 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP, __PTHREAD_SPINS, { 0, 0 } } }
92# define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \
93 { { 0, 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP, __PTHREAD_SPINS, { 0, 0 } } }
94# define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \
95 { { 0, 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP, __PTHREAD_SPINS, { 0, 0 } } }
96
97# endif
98#else
99# define PTHREAD_MUTEX_INITIALIZER \
100 { { 0, 0, 0, 0, 0, { __PTHREAD_SPINS } } }
101# ifdef __USE_GNU
102# define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \
103 { { 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP, 0, { __PTHREAD_SPINS } } }
104# define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \
105 { { 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP, 0, { __PTHREAD_SPINS } } }
106# define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \
107 { { 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP, 0, { __PTHREAD_SPINS } } }
108
109# endif
110#endif
111
112
113/* Read-write lock types. */
114#if defined __USE_UNIX98 || defined __USE_XOPEN2K
115enum
116{
117 PTHREAD_RWLOCK_PREFER_READER_NP,
118 PTHREAD_RWLOCK_PREFER_WRITER_NP,
119 PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP,
120 PTHREAD_RWLOCK_DEFAULT_NP = PTHREAD_RWLOCK_PREFER_READER_NP
121};
122
123/* Define __PTHREAD_RWLOCK_INT_FLAGS_SHARED to 1 if pthread_rwlock_t
124 has the shared field. All 64-bit architectures have the shared field
125 in pthread_rwlock_t. */
126#ifndef __PTHREAD_RWLOCK_INT_FLAGS_SHARED
127# if __WORDSIZE == 64
128# define __PTHREAD_RWLOCK_INT_FLAGS_SHARED 1
129# endif
130#endif
131
132/* Read-write lock initializers. */
133# define PTHREAD_RWLOCK_INITIALIZER \
134 { { 0, 0, 0, 0, 0, 0, 0, 0, __PTHREAD_RWLOCK_ELISION_EXTRA, 0, 0 } }
135# ifdef __USE_GNU
136# ifdef __PTHREAD_RWLOCK_INT_FLAGS_SHARED
137# define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \
138 { { 0, 0, 0, 0, 0, 0, 0, 0, __PTHREAD_RWLOCK_ELISION_EXTRA, 0, \
139 PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
140# else
141# if __BYTE_ORDER == __LITTLE_ENDIAN
142# define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \
143 { { 0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP, \
144 0, __PTHREAD_RWLOCK_ELISION_EXTRA, 0, 0 } }
145# else
146# define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \
147 { { 0, 0, 0, 0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP,\
148 0 } }
149# endif
150# endif
151# endif
152#endif /* Unix98 or XOpen2K */
153
154
155/* Scheduler inheritance. */
156enum
157{
158 PTHREAD_INHERIT_SCHED,
159#define PTHREAD_INHERIT_SCHED PTHREAD_INHERIT_SCHED
160 PTHREAD_EXPLICIT_SCHED
161#define PTHREAD_EXPLICIT_SCHED PTHREAD_EXPLICIT_SCHED
162};
163
164
165/* Scope handling. */
166enum
167{
168 PTHREAD_SCOPE_SYSTEM,
169#define PTHREAD_SCOPE_SYSTEM PTHREAD_SCOPE_SYSTEM
170 PTHREAD_SCOPE_PROCESS
171#define PTHREAD_SCOPE_PROCESS PTHREAD_SCOPE_PROCESS
172};
173
174
175/* Process shared or private flag. */
176enum
177{
178 PTHREAD_PROCESS_PRIVATE,
179#define PTHREAD_PROCESS_PRIVATE PTHREAD_PROCESS_PRIVATE
180 PTHREAD_PROCESS_SHARED
181#define PTHREAD_PROCESS_SHARED PTHREAD_PROCESS_SHARED
182};
183
184
185
186/* Conditional variable handling. */
187#define PTHREAD_COND_INITIALIZER { { {0}, {0}, {0, 0}, {0, 0}, 0, 0, {0, 0} } }
188
189
190/* Cleanup buffers */
191struct _pthread_cleanup_buffer
192{
193 void (*__routine) (void *); /* Function to call. */
194 void *__arg; /* Its argument. */
195 int __canceltype; /* Saved cancellation type. */
196 struct _pthread_cleanup_buffer *__prev; /* Chaining of cleanup functions. */
197};
198
199/* Cancellation */
200enum
201{
202 PTHREAD_CANCEL_ENABLE,
203#define PTHREAD_CANCEL_ENABLE PTHREAD_CANCEL_ENABLE
204 PTHREAD_CANCEL_DISABLE
205#define PTHREAD_CANCEL_DISABLE PTHREAD_CANCEL_DISABLE
206};
207enum
208{
209 PTHREAD_CANCEL_DEFERRED,
210#define PTHREAD_CANCEL_DEFERRED PTHREAD_CANCEL_DEFERRED
211 PTHREAD_CANCEL_ASYNCHRONOUS
212#define PTHREAD_CANCEL_ASYNCHRONOUS PTHREAD_CANCEL_ASYNCHRONOUS
213};
214#define PTHREAD_CANCELED ((void *) -1)
215
216
217/* Single execution handling. */
218#define PTHREAD_ONCE_INIT 0
219
220
221#ifdef __USE_XOPEN2K
222/* Value returned by 'pthread_barrier_wait' for one of the threads after
223 the required number of threads have called this function.
224 -1 is distinct from 0 and all errno constants */
225# define PTHREAD_BARRIER_SERIAL_THREAD -1
226#endif
227
228
229__BEGIN_DECLS
230
231/* Create a new thread, starting with execution of START-ROUTINE
232 getting passed ARG. Creation attributed come from ATTR. The new
233 handle is stored in *NEWTHREAD. */
234extern int pthread_create (pthread_t *__restrict __newthread,
235 const pthread_attr_t *__restrict __attr,
236 void *(*__start_routine) (void *),
237 void *__restrict __arg) __THROWNL __nonnull ((1, 3));
238
239/* Terminate calling thread.
240
241 The registered cleanup handlers are called via exception handling
242 so we cannot mark this function with __THROW.*/
243extern void pthread_exit (void *__retval) __attribute__ ((__noreturn__));
244
245/* Make calling thread wait for termination of the thread TH. The
246 exit status of the thread is stored in *THREAD_RETURN, if THREAD_RETURN
247 is not NULL.
248
249 This function is a cancellation point and therefore not marked with
250 __THROW. */
251extern int pthread_join (pthread_t __th, void **__thread_return);
252
253#ifdef __USE_GNU
254/* Check whether thread TH has terminated. If yes return the status of
255 the thread in *THREAD_RETURN, if THREAD_RETURN is not NULL. */
256extern int pthread_tryjoin_np (pthread_t __th, void **__thread_return) __THROW;
257
258/* Make calling thread wait for termination of the thread TH, but only
259 until TIMEOUT. The exit status of the thread is stored in
260 *THREAD_RETURN, if THREAD_RETURN is not NULL.
261
262 This function is a cancellation point and therefore not marked with
263 __THROW. */
264extern int pthread_timedjoin_np (pthread_t __th, void **__thread_return,
265 const struct timespec *__abstime);
266#endif
267
268/* Indicate that the thread TH is never to be joined with PTHREAD_JOIN.
269 The resources of TH will therefore be freed immediately when it
270 terminates, instead of waiting for another thread to perform PTHREAD_JOIN
271 on it. */
272extern int pthread_detach (pthread_t __th) __THROW;
273
274
275/* Obtain the identifier of the current thread. */
276extern pthread_t pthread_self (void) __THROW __attribute__ ((__const__));
277
278/* Compare two thread identifiers. */
279extern int pthread_equal (pthread_t __thread1, pthread_t __thread2)
280 __THROW __attribute__ ((__const__));
281
282
283/* Thread attribute handling. */
284
285/* Initialize thread attribute *ATTR with default attributes
286 (detachstate is PTHREAD_JOINABLE, scheduling policy is SCHED_OTHER,
287 no user-provided stack). */
288extern int pthread_attr_init (pthread_attr_t *__attr) __THROW __nonnull ((1));
289
290/* Destroy thread attribute *ATTR. */
291extern int pthread_attr_destroy (pthread_attr_t *__attr)
292 __THROW __nonnull ((1));
293
294/* Get detach state attribute. */
295extern int pthread_attr_getdetachstate (const pthread_attr_t *__attr,
296 int *__detachstate)
297 __THROW __nonnull ((1, 2));
298
299/* Set detach state attribute. */
300extern int pthread_attr_setdetachstate (pthread_attr_t *__attr,
301 int __detachstate)
302 __THROW __nonnull ((1));
303
304
305/* Get the size of the guard area created for stack overflow protection. */
306extern int pthread_attr_getguardsize (const pthread_attr_t *__attr,
307 size_t *__guardsize)
308 __THROW __nonnull ((1, 2));
309
310/* Set the size of the guard area created for stack overflow protection. */
311extern int pthread_attr_setguardsize (pthread_attr_t *__attr,
312 size_t __guardsize)
313 __THROW __nonnull ((1));
314
315
316/* Return in *PARAM the scheduling parameters of *ATTR. */
317extern int pthread_attr_getschedparam (const pthread_attr_t *__restrict __attr,
318 struct sched_param *__restrict __param)
319 __THROW __nonnull ((1, 2));
320
321/* Set scheduling parameters (priority, etc) in *ATTR according to PARAM. */
322extern int pthread_attr_setschedparam (pthread_attr_t *__restrict __attr,
323 const struct sched_param *__restrict
324 __param) __THROW __nonnull ((1, 2));
325
326/* Return in *POLICY the scheduling policy of *ATTR. */
327extern int pthread_attr_getschedpolicy (const pthread_attr_t *__restrict
328 __attr, int *__restrict __policy)
329 __THROW __nonnull ((1, 2));
330
331/* Set scheduling policy in *ATTR according to POLICY. */
332extern int pthread_attr_setschedpolicy (pthread_attr_t *__attr, int __policy)
333 __THROW __nonnull ((1));
334
335/* Return in *INHERIT the scheduling inheritance mode of *ATTR. */
336extern int pthread_attr_getinheritsched (const pthread_attr_t *__restrict
337 __attr, int *__restrict __inherit)
338 __THROW __nonnull ((1, 2));
339
340/* Set scheduling inheritance mode in *ATTR according to INHERIT. */
341extern int pthread_attr_setinheritsched (pthread_attr_t *__attr,
342 int __inherit)
343 __THROW __nonnull ((1));
344
345
346/* Return in *SCOPE the scheduling contention scope of *ATTR. */
347extern int pthread_attr_getscope (const pthread_attr_t *__restrict __attr,
348 int *__restrict __scope)
349 __THROW __nonnull ((1, 2));
350
351/* Set scheduling contention scope in *ATTR according to SCOPE. */
352extern int pthread_attr_setscope (pthread_attr_t *__attr, int __scope)
353 __THROW __nonnull ((1));
354
355/* Return the previously set address for the stack. */
356extern int pthread_attr_getstackaddr (const pthread_attr_t *__restrict
357 __attr, void **__restrict __stackaddr)
358 __THROW __nonnull ((1, 2)) __attribute_deprecated__;
359
360/* Set the starting address of the stack of the thread to be created.
361 Depending on whether the stack grows up or down the value must either
362 be higher or lower than all the address in the memory block. The
363 minimal size of the block must be PTHREAD_STACK_MIN. */
364extern int pthread_attr_setstackaddr (pthread_attr_t *__attr,
365 void *__stackaddr)
366 __THROW __nonnull ((1)) __attribute_deprecated__;
367
368/* Return the currently used minimal stack size. */
369extern int pthread_attr_getstacksize (const pthread_attr_t *__restrict
370 __attr, size_t *__restrict __stacksize)
371 __THROW __nonnull ((1, 2));
372
373/* Add information about the minimum stack size needed for the thread
374 to be started. This size must never be less than PTHREAD_STACK_MIN
375 and must also not exceed the system limits. */
376extern int pthread_attr_setstacksize (pthread_attr_t *__attr,
377 size_t __stacksize)
378 __THROW __nonnull ((1));
379
380#ifdef __USE_XOPEN2K
381/* Return the previously set address for the stack. */
382extern int pthread_attr_getstack (const pthread_attr_t *__restrict __attr,
383 void **__restrict __stackaddr,
384 size_t *__restrict __stacksize)
385 __THROW __nonnull ((1, 2, 3));
386
387/* The following two interfaces are intended to replace the last two. They
388 require setting the address as well as the size since only setting the
389 address will make the implementation on some architectures impossible. */
390extern int pthread_attr_setstack (pthread_attr_t *__attr, void *__stackaddr,
391 size_t __stacksize) __THROW __nonnull ((1));
392#endif
393
394#ifdef __USE_GNU
395/* Thread created with attribute ATTR will be limited to run only on
396 the processors represented in CPUSET. */
397extern int pthread_attr_setaffinity_np (pthread_attr_t *__attr,
398 size_t __cpusetsize,
399 const cpu_set_t *__cpuset)
400 __THROW __nonnull ((1, 3));
401
402/* Get bit set in CPUSET representing the processors threads created with
403 ATTR can run on. */
404extern int pthread_attr_getaffinity_np (const pthread_attr_t *__attr,
405 size_t __cpusetsize,
406 cpu_set_t *__cpuset)
407 __THROW __nonnull ((1, 3));
408
409/* Get the default attributes used by pthread_create in this process. */
410extern int pthread_getattr_default_np (pthread_attr_t *__attr)
411 __THROW __nonnull ((1));
412
413/* Set the default attributes to be used by pthread_create in this
414 process. */
415extern int pthread_setattr_default_np (const pthread_attr_t *__attr)
416 __THROW __nonnull ((1));
417
418/* Initialize thread attribute *ATTR with attributes corresponding to the
419 already running thread TH. It shall be called on uninitialized ATTR
420 and destroyed with pthread_attr_destroy when no longer needed. */
421extern int pthread_getattr_np (pthread_t __th, pthread_attr_t *__attr)
422 __THROW __nonnull ((2));
423#endif
424
425
426/* Functions for scheduling control. */
427
428/* Set the scheduling parameters for TARGET_THREAD according to POLICY
429 and *PARAM. */
430extern int pthread_setschedparam (pthread_t __target_thread, int __policy,
431 const struct sched_param *__param)
432 __THROW __nonnull ((3));
433
434/* Return in *POLICY and *PARAM the scheduling parameters for TARGET_THREAD. */
435extern int pthread_getschedparam (pthread_t __target_thread,
436 int *__restrict __policy,
437 struct sched_param *__restrict __param)
438 __THROW __nonnull ((2, 3));
439
440/* Set the scheduling priority for TARGET_THREAD. */
441extern int pthread_setschedprio (pthread_t __target_thread, int __prio)
442 __THROW;
443
444
445#ifdef __USE_GNU
446/* Get thread name visible in the kernel and its interfaces. */
447extern int pthread_getname_np (pthread_t __target_thread, char *__buf,
448 size_t __buflen)
449 __THROW __nonnull ((2));
450
451/* Set thread name visible in the kernel and its interfaces. */
452extern int pthread_setname_np (pthread_t __target_thread, const char *__name)
453 __THROW __nonnull ((2));
454#endif
455
456
457#ifdef __USE_UNIX98
458/* Determine level of concurrency. */
459extern int pthread_getconcurrency (void) __THROW;
460
461/* Set new concurrency level to LEVEL. */
462extern int pthread_setconcurrency (int __level) __THROW;
463#endif
464
465#ifdef __USE_GNU
466/* Yield the processor to another thread or process.
467 This function is similar to the POSIX `sched_yield' function but
468 might be differently implemented in the case of a m-on-n thread
469 implementation. */
470extern int pthread_yield (void) __THROW;
471
472
473/* Limit specified thread TH to run only on the processors represented
474 in CPUSET. */
475extern int pthread_setaffinity_np (pthread_t __th, size_t __cpusetsize,
476 const cpu_set_t *__cpuset)
477 __THROW __nonnull ((3));
478
479/* Get bit set in CPUSET representing the processors TH can run on. */
480extern int pthread_getaffinity_np (pthread_t __th, size_t __cpusetsize,
481 cpu_set_t *__cpuset)
482 __THROW __nonnull ((3));
483#endif
484
485
486/* Functions for handling initialization. */
487
488/* Guarantee that the initialization function INIT_ROUTINE will be called
489 only once, even if pthread_once is executed several times with the
490 same ONCE_CONTROL argument. ONCE_CONTROL must point to a static or
491 extern variable initialized to PTHREAD_ONCE_INIT.
492
493 The initialization functions might throw exception which is why
494 this function is not marked with __THROW. */
495extern int pthread_once (pthread_once_t *__once_control,
496 void (*__init_routine) (void)) __nonnull ((1, 2));
497
498
499/* Functions for handling cancellation.
500
501 Note that these functions are explicitly not marked to not throw an
502 exception in C++ code. If cancellation is implemented by unwinding
503 this is necessary to have the compiler generate the unwind information. */
504
505/* Set cancelability state of current thread to STATE, returning old
506 state in *OLDSTATE if OLDSTATE is not NULL. */
507extern int pthread_setcancelstate (int __state, int *__oldstate);
508
509/* Set cancellation state of current thread to TYPE, returning the old
510 type in *OLDTYPE if OLDTYPE is not NULL. */
511extern int pthread_setcanceltype (int __type, int *__oldtype);
512
513/* Cancel THREAD immediately or at the next possibility. */
514extern int pthread_cancel (pthread_t __th);
515
516/* Test for pending cancellation for the current thread and terminate
517 the thread as per pthread_exit(PTHREAD_CANCELED) if it has been
518 cancelled. */
519extern void pthread_testcancel (void);
520
521
522/* Cancellation handling with integration into exception handling. */
523
524typedef struct
525{
526 struct
527 {
528 __jmp_buf __cancel_jmp_buf;
529 int __mask_was_saved;
530 } __cancel_jmp_buf[1];
531 void *__pad[4];
532} __pthread_unwind_buf_t __attribute__ ((__aligned__));
533
534/* No special attributes by default. */
535#ifndef __cleanup_fct_attribute
536# define __cleanup_fct_attribute
537#endif
538
539
540/* Structure to hold the cleanup handler information. */
541struct __pthread_cleanup_frame
542{
543 void (*__cancel_routine) (void *);
544 void *__cancel_arg;
545 int __do_it;
546 int __cancel_type;
547};
548
549#if defined __GNUC__ && defined __EXCEPTIONS
550# ifdef __cplusplus
551/* Class to handle cancellation handler invocation. */
552class __pthread_cleanup_class
553{
554 void (*__cancel_routine) (void *);
555 void *__cancel_arg;
556 int __do_it;
557 int __cancel_type;
558
559 public:
560 __pthread_cleanup_class (void (*__fct) (void *), void *__arg)
561 : __cancel_routine (__fct), __cancel_arg (__arg), __do_it (1) { }
562 ~__pthread_cleanup_class () { if (__do_it) __cancel_routine (__cancel_arg); }
563 void __setdoit (int __newval) { __do_it = __newval; }
564 void __defer () { pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED,
565 &__cancel_type); }
566 void __restore () const { pthread_setcanceltype (__cancel_type, 0); }
567};
568
569/* Install a cleanup handler: ROUTINE will be called with arguments ARG
570 when the thread is canceled or calls pthread_exit. ROUTINE will also
571 be called with arguments ARG when the matching pthread_cleanup_pop
572 is executed with non-zero EXECUTE argument.
573
574 pthread_cleanup_push and pthread_cleanup_pop are macros and must always
575 be used in matching pairs at the same nesting level of braces. */
576# define pthread_cleanup_push(routine, arg) \
577 do { \
578 __pthread_cleanup_class __clframe (routine, arg)
579
580/* Remove a cleanup handler installed by the matching pthread_cleanup_push.
581 If EXECUTE is non-zero, the handler function is called. */
582# define pthread_cleanup_pop(execute) \
583 __clframe.__setdoit (execute); \
584 } while (0)
585
586# ifdef __USE_GNU
587/* Install a cleanup handler as pthread_cleanup_push does, but also
588 saves the current cancellation type and sets it to deferred
589 cancellation. */
590# define pthread_cleanup_push_defer_np(routine, arg) \
591 do { \
592 __pthread_cleanup_class __clframe (routine, arg); \
593 __clframe.__defer ()
594
595/* Remove a cleanup handler as pthread_cleanup_pop does, but also
596 restores the cancellation type that was in effect when the matching
597 pthread_cleanup_push_defer was called. */
598# define pthread_cleanup_pop_restore_np(execute) \
599 __clframe.__restore (); \
600 __clframe.__setdoit (execute); \
601 } while (0)
602# endif
603# else
604/* Function called to call the cleanup handler. As an extern inline
605 function the compiler is free to decide inlining the change when
606 needed or fall back on the copy which must exist somewhere
607 else. */
608__extern_inline void
609__pthread_cleanup_routine (struct __pthread_cleanup_frame *__frame)
610{
611 if (__frame->__do_it)
612 __frame->__cancel_routine (__frame->__cancel_arg);
613}
614
615/* Install a cleanup handler: ROUTINE will be called with arguments ARG
616 when the thread is canceled or calls pthread_exit. ROUTINE will also
617 be called with arguments ARG when the matching pthread_cleanup_pop
618 is executed with non-zero EXECUTE argument.
619
620 pthread_cleanup_push and pthread_cleanup_pop are macros and must always
621 be used in matching pairs at the same nesting level of braces. */
622# define pthread_cleanup_push(routine, arg) \
623 do { \
624 struct __pthread_cleanup_frame __clframe \
625 __attribute__ ((__cleanup__ (__pthread_cleanup_routine))) \
626 = { .__cancel_routine = (routine), .__cancel_arg = (arg), \
627 .__do_it = 1 };
628
629/* Remove a cleanup handler installed by the matching pthread_cleanup_push.
630 If EXECUTE is non-zero, the handler function is called. */
631# define pthread_cleanup_pop(execute) \
632 __clframe.__do_it = (execute); \
633 } while (0)
634
635# ifdef __USE_GNU
636/* Install a cleanup handler as pthread_cleanup_push does, but also
637 saves the current cancellation type and sets it to deferred
638 cancellation. */
639# define pthread_cleanup_push_defer_np(routine, arg) \
640 do { \
641 struct __pthread_cleanup_frame __clframe \
642 __attribute__ ((__cleanup__ (__pthread_cleanup_routine))) \
643 = { .__cancel_routine = (routine), .__cancel_arg = (arg), \
644 .__do_it = 1 }; \
645 (void) pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, \
646 &__clframe.__cancel_type)
647
648/* Remove a cleanup handler as pthread_cleanup_pop does, but also
649 restores the cancellation type that was in effect when the matching
650 pthread_cleanup_push_defer was called. */
651# define pthread_cleanup_pop_restore_np(execute) \
652 (void) pthread_setcanceltype (__clframe.__cancel_type, NULL); \
653 __clframe.__do_it = (execute); \
654 } while (0)
655# endif
656# endif
657#else
658/* Install a cleanup handler: ROUTINE will be called with arguments ARG
659 when the thread is canceled or calls pthread_exit. ROUTINE will also
660 be called with arguments ARG when the matching pthread_cleanup_pop
661 is executed with non-zero EXECUTE argument.
662
663 pthread_cleanup_push and pthread_cleanup_pop are macros and must always
664 be used in matching pairs at the same nesting level of braces. */
665# define pthread_cleanup_push(routine, arg) \
666 do { \
667 __pthread_unwind_buf_t __cancel_buf; \
668 void (*__cancel_routine) (void *) = (routine); \
669 void *__cancel_arg = (arg); \
670 int __not_first_call = __sigsetjmp ((struct __jmp_buf_tag *) (void *) \
671 __cancel_buf.__cancel_jmp_buf, 0); \
672 if (__glibc_unlikely (__not_first_call)) \
673 { \
674 __cancel_routine (__cancel_arg); \
675 __pthread_unwind_next (&__cancel_buf); \
676 /* NOTREACHED */ \
677 } \
678 \
679 __pthread_register_cancel (&__cancel_buf); \
680 do {
681extern void __pthread_register_cancel (__pthread_unwind_buf_t *__buf)
682 __cleanup_fct_attribute;
683
684/* Remove a cleanup handler installed by the matching pthread_cleanup_push.
685 If EXECUTE is non-zero, the handler function is called. */
686# define pthread_cleanup_pop(execute) \
687 do { } while (0);/* Empty to allow label before pthread_cleanup_pop. */\
688 } while (0); \
689 __pthread_unregister_cancel (&__cancel_buf); \
690 if (execute) \
691 __cancel_routine (__cancel_arg); \
692 } while (0)
693extern void __pthread_unregister_cancel (__pthread_unwind_buf_t *__buf)
694 __cleanup_fct_attribute;
695
696# ifdef __USE_GNU
697/* Install a cleanup handler as pthread_cleanup_push does, but also
698 saves the current cancellation type and sets it to deferred
699 cancellation. */
700# define pthread_cleanup_push_defer_np(routine, arg) \
701 do { \
702 __pthread_unwind_buf_t __cancel_buf; \
703 void (*__cancel_routine) (void *) = (routine); \
704 void *__cancel_arg = (arg); \
705 int __not_first_call = __sigsetjmp ((struct __jmp_buf_tag *) (void *) \
706 __cancel_buf.__cancel_jmp_buf, 0); \
707 if (__glibc_unlikely (__not_first_call)) \
708 { \
709 __cancel_routine (__cancel_arg); \
710 __pthread_unwind_next (&__cancel_buf); \
711 /* NOTREACHED */ \
712 } \
713 \
714 __pthread_register_cancel_defer (&__cancel_buf); \
715 do {
716extern void __pthread_register_cancel_defer (__pthread_unwind_buf_t *__buf)
717 __cleanup_fct_attribute;
718
719/* Remove a cleanup handler as pthread_cleanup_pop does, but also
720 restores the cancellation type that was in effect when the matching
721 pthread_cleanup_push_defer was called. */
722# define pthread_cleanup_pop_restore_np(execute) \
723 do { } while (0);/* Empty to allow label before pthread_cleanup_pop. */\
724 } while (0); \
725 __pthread_unregister_cancel_restore (&__cancel_buf); \
726 if (execute) \
727 __cancel_routine (__cancel_arg); \
728 } while (0)
729extern void __pthread_unregister_cancel_restore (__pthread_unwind_buf_t *__buf)
730 __cleanup_fct_attribute;
731# endif
732
733/* Internal interface to initiate cleanup. */
734extern void __pthread_unwind_next (__pthread_unwind_buf_t *__buf)
735 __cleanup_fct_attribute __attribute__ ((__noreturn__))
736# ifndef SHARED
737 __attribute__ ((__weak__))
738# endif
739 ;
740#endif
741
742/* Function used in the macros. */
743struct __jmp_buf_tag;
744extern int __sigsetjmp (struct __jmp_buf_tag *__env, int __savemask) __THROWNL;
745
746
747/* Mutex handling. */
748
749/* Initialize a mutex. */
750extern int pthread_mutex_init (pthread_mutex_t *__mutex,
751 const pthread_mutexattr_t *__mutexattr)
752 __THROW __nonnull ((1));
753
754/* Destroy a mutex. */
755extern int pthread_mutex_destroy (pthread_mutex_t *__mutex)
756 __THROW __nonnull ((1));
757
758/* Try locking a mutex. */
759extern int pthread_mutex_trylock (pthread_mutex_t *__mutex)
760 __THROWNL __nonnull ((1));
761
762/* Lock a mutex. */
763extern int pthread_mutex_lock (pthread_mutex_t *__mutex)
764 __THROWNL __nonnull ((1));
765
766#ifdef __USE_XOPEN2K
767/* Wait until lock becomes available, or specified time passes. */
768extern int pthread_mutex_timedlock (pthread_mutex_t *__restrict __mutex,
769 const struct timespec *__restrict
770 __abstime) __THROWNL __nonnull ((1, 2));
771#endif
772
773/* Unlock a mutex. */
774extern int pthread_mutex_unlock (pthread_mutex_t *__mutex)
775 __THROWNL __nonnull ((1));
776
777
778/* Get the priority ceiling of MUTEX. */
779extern int pthread_mutex_getprioceiling (const pthread_mutex_t *
780 __restrict __mutex,
781 int *__restrict __prioceiling)
782 __THROW __nonnull ((1, 2));
783
784/* Set the priority ceiling of MUTEX to PRIOCEILING, return old
785 priority ceiling value in *OLD_CEILING. */
786extern int pthread_mutex_setprioceiling (pthread_mutex_t *__restrict __mutex,
787 int __prioceiling,
788 int *__restrict __old_ceiling)
789 __THROW __nonnull ((1, 3));
790
791
792#ifdef __USE_XOPEN2K8
793/* Declare the state protected by MUTEX as consistent. */
794extern int pthread_mutex_consistent (pthread_mutex_t *__mutex)
795 __THROW __nonnull ((1));
796# ifdef __USE_GNU
797extern int pthread_mutex_consistent_np (pthread_mutex_t *__mutex)
798 __THROW __nonnull ((1));
799# endif
800#endif
801
802
803/* Functions for handling mutex attributes. */
804
805/* Initialize mutex attribute object ATTR with default attributes
806 (kind is PTHREAD_MUTEX_TIMED_NP). */
807extern int pthread_mutexattr_init (pthread_mutexattr_t *__attr)
808 __THROW __nonnull ((1));
809
810/* Destroy mutex attribute object ATTR. */
811extern int pthread_mutexattr_destroy (pthread_mutexattr_t *__attr)
812 __THROW __nonnull ((1));
813
814/* Get the process-shared flag of the mutex attribute ATTR. */
815extern int pthread_mutexattr_getpshared (const pthread_mutexattr_t *
816 __restrict __attr,
817 int *__restrict __pshared)
818 __THROW __nonnull ((1, 2));
819
820/* Set the process-shared flag of the mutex attribute ATTR. */
821extern int pthread_mutexattr_setpshared (pthread_mutexattr_t *__attr,
822 int __pshared)
823 __THROW __nonnull ((1));
824
825#if defined __USE_UNIX98 || defined __USE_XOPEN2K8
826/* Return in *KIND the mutex kind attribute in *ATTR. */
827extern int pthread_mutexattr_gettype (const pthread_mutexattr_t *__restrict
828 __attr, int *__restrict __kind)
829 __THROW __nonnull ((1, 2));
830
831/* Set the mutex kind attribute in *ATTR to KIND (either PTHREAD_MUTEX_NORMAL,
832 PTHREAD_MUTEX_RECURSIVE, PTHREAD_MUTEX_ERRORCHECK, or
833 PTHREAD_MUTEX_DEFAULT). */
834extern int pthread_mutexattr_settype (pthread_mutexattr_t *__attr, int __kind)
835 __THROW __nonnull ((1));
836#endif
837
838/* Return in *PROTOCOL the mutex protocol attribute in *ATTR. */
839extern int pthread_mutexattr_getprotocol (const pthread_mutexattr_t *
840 __restrict __attr,
841 int *__restrict __protocol)
842 __THROW __nonnull ((1, 2));
843
844/* Set the mutex protocol attribute in *ATTR to PROTOCOL (either
845 PTHREAD_PRIO_NONE, PTHREAD_PRIO_INHERIT, or PTHREAD_PRIO_PROTECT). */
846extern int pthread_mutexattr_setprotocol (pthread_mutexattr_t *__attr,
847 int __protocol)
848 __THROW __nonnull ((1));
849
850/* Return in *PRIOCEILING the mutex prioceiling attribute in *ATTR. */
851extern int pthread_mutexattr_getprioceiling (const pthread_mutexattr_t *
852 __restrict __attr,
853 int *__restrict __prioceiling)
854 __THROW __nonnull ((1, 2));
855
856/* Set the mutex prioceiling attribute in *ATTR to PRIOCEILING. */
857extern int pthread_mutexattr_setprioceiling (pthread_mutexattr_t *__attr,
858 int __prioceiling)
859 __THROW __nonnull ((1));
860
861#ifdef __USE_XOPEN2K
862/* Get the robustness flag of the mutex attribute ATTR. */
863extern int pthread_mutexattr_getrobust (const pthread_mutexattr_t *__attr,
864 int *__robustness)
865 __THROW __nonnull ((1, 2));
866# ifdef __USE_GNU
867extern int pthread_mutexattr_getrobust_np (const pthread_mutexattr_t *__attr,
868 int *__robustness)
869 __THROW __nonnull ((1, 2));
870# endif
871
872/* Set the robustness flag of the mutex attribute ATTR. */
873extern int pthread_mutexattr_setrobust (pthread_mutexattr_t *__attr,
874 int __robustness)
875 __THROW __nonnull ((1));
876# ifdef __USE_GNU
877extern int pthread_mutexattr_setrobust_np (pthread_mutexattr_t *__attr,
878 int __robustness)
879 __THROW __nonnull ((1));
880# endif
881#endif
882
883
884#if defined __USE_UNIX98 || defined __USE_XOPEN2K
885/* Functions for handling read-write locks. */
886
887/* Initialize read-write lock RWLOCK using attributes ATTR, or use
888 the default values if later is NULL. */
889extern int pthread_rwlock_init (pthread_rwlock_t *__restrict __rwlock,
890 const pthread_rwlockattr_t *__restrict
891 __attr) __THROW __nonnull ((1));
892
893/* Destroy read-write lock RWLOCK. */
894extern int pthread_rwlock_destroy (pthread_rwlock_t *__rwlock)
895 __THROW __nonnull ((1));
896
897/* Acquire read lock for RWLOCK. */
898extern int pthread_rwlock_rdlock (pthread_rwlock_t *__rwlock)
899 __THROWNL __nonnull ((1));
900
901/* Try to acquire read lock for RWLOCK. */
902extern int pthread_rwlock_tryrdlock (pthread_rwlock_t *__rwlock)
903 __THROWNL __nonnull ((1));
904
905# ifdef __USE_XOPEN2K
906/* Try to acquire read lock for RWLOCK or return after specfied time. */
907extern int pthread_rwlock_timedrdlock (pthread_rwlock_t *__restrict __rwlock,
908 const struct timespec *__restrict
909 __abstime) __THROWNL __nonnull ((1, 2));
910# endif
911
912/* Acquire write lock for RWLOCK. */
913extern int pthread_rwlock_wrlock (pthread_rwlock_t *__rwlock)
914 __THROWNL __nonnull ((1));
915
916/* Try to acquire write lock for RWLOCK. */
917extern int pthread_rwlock_trywrlock (pthread_rwlock_t *__rwlock)
918 __THROWNL __nonnull ((1));
919
920# ifdef __USE_XOPEN2K
921/* Try to acquire write lock for RWLOCK or return after specfied time. */
922extern int pthread_rwlock_timedwrlock (pthread_rwlock_t *__restrict __rwlock,
923 const struct timespec *__restrict
924 __abstime) __THROWNL __nonnull ((1, 2));
925# endif
926
927/* Unlock RWLOCK. */
928extern int pthread_rwlock_unlock (pthread_rwlock_t *__rwlock)
929 __THROWNL __nonnull ((1));
930
931
932/* Functions for handling read-write lock attributes. */
933
934/* Initialize attribute object ATTR with default values. */
935extern int pthread_rwlockattr_init (pthread_rwlockattr_t *__attr)
936 __THROW __nonnull ((1));
937
938/* Destroy attribute object ATTR. */
939extern int pthread_rwlockattr_destroy (pthread_rwlockattr_t *__attr)
940 __THROW __nonnull ((1));
941
942/* Return current setting of process-shared attribute of ATTR in PSHARED. */
943extern int pthread_rwlockattr_getpshared (const pthread_rwlockattr_t *
944 __restrict __attr,
945 int *__restrict __pshared)
946 __THROW __nonnull ((1, 2));
947
948/* Set process-shared attribute of ATTR to PSHARED. */
949extern int pthread_rwlockattr_setpshared (pthread_rwlockattr_t *__attr,
950 int __pshared)
951 __THROW __nonnull ((1));
952
953/* Return current setting of reader/writer preference. */
954extern int pthread_rwlockattr_getkind_np (const pthread_rwlockattr_t *
955 __restrict __attr,
956 int *__restrict __pref)
957 __THROW __nonnull ((1, 2));
958
959/* Set reader/write preference. */
960extern int pthread_rwlockattr_setkind_np (pthread_rwlockattr_t *__attr,
961 int __pref) __THROW __nonnull ((1));
962#endif
963
964
965/* Functions for handling conditional variables. */
966
967/* Initialize condition variable COND using attributes ATTR, or use
968 the default values if later is NULL. */
969extern int pthread_cond_init (pthread_cond_t *__restrict __cond,
970 const pthread_condattr_t *__restrict __cond_attr)
971 __THROW __nonnull ((1));
972
973/* Destroy condition variable COND. */
974extern int pthread_cond_destroy (pthread_cond_t *__cond)
975 __THROW __nonnull ((1));
976
977/* Wake up one thread waiting for condition variable COND. */
978extern int pthread_cond_signal (pthread_cond_t *__cond)
979 __THROWNL __nonnull ((1));
980
981/* Wake up all threads waiting for condition variables COND. */
982extern int pthread_cond_broadcast (pthread_cond_t *__cond)
983 __THROWNL __nonnull ((1));
984
985/* Wait for condition variable COND to be signaled or broadcast.
986 MUTEX is assumed to be locked before.
987
988 This function is a cancellation point and therefore not marked with
989 __THROW. */
990extern int pthread_cond_wait (pthread_cond_t *__restrict __cond,
991 pthread_mutex_t *__restrict __mutex)
992 __nonnull ((1, 2));
993
994/* Wait for condition variable COND to be signaled or broadcast until
995 ABSTIME. MUTEX is assumed to be locked before. ABSTIME is an
996 absolute time specification; zero is the beginning of the epoch
997 (00:00:00 GMT, January 1, 1970).
998
999 This function is a cancellation point and therefore not marked with
1000 __THROW. */
1001extern int pthread_cond_timedwait (pthread_cond_t *__restrict __cond,
1002 pthread_mutex_t *__restrict __mutex,
1003 const struct timespec *__restrict __abstime)
1004 __nonnull ((1, 2, 3));
1005
1006/* Functions for handling condition variable attributes. */
1007
1008/* Initialize condition variable attribute ATTR. */
1009extern int pthread_condattr_init (pthread_condattr_t *__attr)
1010 __THROW __nonnull ((1));
1011
1012/* Destroy condition variable attribute ATTR. */
1013extern int pthread_condattr_destroy (pthread_condattr_t *__attr)
1014 __THROW __nonnull ((1));
1015
1016/* Get the process-shared flag of the condition variable attribute ATTR. */
1017extern int pthread_condattr_getpshared (const pthread_condattr_t *
1018 __restrict __attr,
1019 int *__restrict __pshared)
1020 __THROW __nonnull ((1, 2));
1021
1022/* Set the process-shared flag of the condition variable attribute ATTR. */
1023extern int pthread_condattr_setpshared (pthread_condattr_t *__attr,
1024 int __pshared) __THROW __nonnull ((1));
1025
1026#ifdef __USE_XOPEN2K
1027/* Get the clock selected for the condition variable attribute ATTR. */
1028extern int pthread_condattr_getclock (const pthread_condattr_t *
1029 __restrict __attr,
1030 __clockid_t *__restrict __clock_id)
1031 __THROW __nonnull ((1, 2));
1032
1033/* Set the clock selected for the condition variable attribute ATTR. */
1034extern int pthread_condattr_setclock (pthread_condattr_t *__attr,
1035 __clockid_t __clock_id)
1036 __THROW __nonnull ((1));
1037#endif
1038
1039
1040#ifdef __USE_XOPEN2K
1041/* Functions to handle spinlocks. */
1042
1043/* Initialize the spinlock LOCK. If PSHARED is nonzero the spinlock can
1044 be shared between different processes. */
1045extern int pthread_spin_init (pthread_spinlock_t *__lock, int __pshared)
1046 __THROW __nonnull ((1));
1047
1048/* Destroy the spinlock LOCK. */
1049extern int pthread_spin_destroy (pthread_spinlock_t *__lock)
1050 __THROW __nonnull ((1));
1051
1052/* Wait until spinlock LOCK is retrieved. */
1053extern int pthread_spin_lock (pthread_spinlock_t *__lock)
1054 __THROWNL __nonnull ((1));
1055
1056/* Try to lock spinlock LOCK. */
1057extern int pthread_spin_trylock (pthread_spinlock_t *__lock)
1058 __THROWNL __nonnull ((1));
1059
1060/* Release spinlock LOCK. */
1061extern int pthread_spin_unlock (pthread_spinlock_t *__lock)
1062 __THROWNL __nonnull ((1));
1063
1064
1065/* Functions to handle barriers. */
1066
1067/* Initialize BARRIER with the attributes in ATTR. The barrier is
1068 opened when COUNT waiters arrived. */
1069extern int pthread_barrier_init (pthread_barrier_t *__restrict __barrier,
1070 const pthread_barrierattr_t *__restrict
1071 __attr, unsigned int __count)
1072 __THROW __nonnull ((1));
1073
1074/* Destroy a previously dynamically initialized barrier BARRIER. */
1075extern int pthread_barrier_destroy (pthread_barrier_t *__barrier)
1076 __THROW __nonnull ((1));
1077
1078/* Wait on barrier BARRIER. */
1079extern int pthread_barrier_wait (pthread_barrier_t *__barrier)
1080 __THROWNL __nonnull ((1));
1081
1082
1083/* Initialize barrier attribute ATTR. */
1084extern int pthread_barrierattr_init (pthread_barrierattr_t *__attr)
1085 __THROW __nonnull ((1));
1086
1087/* Destroy previously dynamically initialized barrier attribute ATTR. */
1088extern int pthread_barrierattr_destroy (pthread_barrierattr_t *__attr)
1089 __THROW __nonnull ((1));
1090
1091/* Get the process-shared flag of the barrier attribute ATTR. */
1092extern int pthread_barrierattr_getpshared (const pthread_barrierattr_t *
1093 __restrict __attr,
1094 int *__restrict __pshared)
1095 __THROW __nonnull ((1, 2));
1096
1097/* Set the process-shared flag of the barrier attribute ATTR. */
1098extern int pthread_barrierattr_setpshared (pthread_barrierattr_t *__attr,
1099 int __pshared)
1100 __THROW __nonnull ((1));
1101#endif
1102
1103
1104/* Functions for handling thread-specific data. */
1105
1106/* Create a key value identifying a location in the thread-specific
1107 data area. Each thread maintains a distinct thread-specific data
1108 area. DESTR_FUNCTION, if non-NULL, is called with the value
1109 associated to that key when the key is destroyed.
1110 DESTR_FUNCTION is not called if the value associated is NULL when
1111 the key is destroyed. */
1112extern int pthread_key_create (pthread_key_t *__key,
1113 void (*__destr_function) (void *))
1114 __THROW __nonnull ((1));
1115
1116/* Destroy KEY. */
1117extern int pthread_key_delete (pthread_key_t __key) __THROW;
1118
1119/* Return current value of the thread-specific data slot identified by KEY. */
1120extern void *pthread_getspecific (pthread_key_t __key) __THROW;
1121
1122/* Store POINTER in the thread-specific data slot identified by KEY. */
1123extern int pthread_setspecific (pthread_key_t __key,
1124 const void *__pointer) __THROW ;
1125
1126
1127#ifdef __USE_XOPEN2K
1128/* Get ID of CPU-time clock for thread THREAD_ID. */
1129extern int pthread_getcpuclockid (pthread_t __thread_id,
1130 __clockid_t *__clock_id)
1131 __THROW __nonnull ((2));
1132#endif
1133
1134
1135/* Install handlers to be called when a new process is created with FORK.
1136 The PREPARE handler is called in the parent process just before performing
1137 FORK. The PARENT handler is called in the parent process just after FORK.
1138 The CHILD handler is called in the child process. Each of the three
1139 handlers can be NULL, meaning that no handler needs to be called at that
1140 point.
1141 PTHREAD_ATFORK can be called several times, in which case the PREPARE
1142 handlers are called in LIFO order (last added with PTHREAD_ATFORK,
1143 first called before FORK), and the PARENT and CHILD handlers are called
1144 in FIFO (first added, first called). */
1145
1146extern int pthread_atfork (void (*__prepare) (void),
1147 void (*__parent) (void),
1148 void (*__child) (void)) __THROW;
1149
1150
1151#ifdef __USE_EXTERN_INLINES
1152/* Optimizations. */
1153__extern_inline int
1154__NTH (pthread_equal (pthread_t __thread1, pthread_t __thread2))
1155{
1156 return __thread1 == __thread2;
1157}
1158#endif
1159
1160__END_DECLS
1161
1162#endif /* pthread.h */
libc/glibc/sysdeps/pthread/allocalim.h created+32
...@@ -0,0 +1,32 @@
1/* Determine whether block of given size can be allocated on the stack or not.
2 Copyright (C) 2002-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If
17 not, see <http://www.gnu.org/licenses/>. */
18
19#include <alloca.h>
20#include <limits.h>
21
22
23extern __always_inline
24int
25__libc_use_alloca (size_t size)
26{
27 return (__glibc_likely (__libc_alloca_cutoff (size))
28#ifdef PTHREAD_STACK_MIN
29 || __glibc_likely (size <= PTHREAD_STACK_MIN / 4)
30#endif
31 );
32}
libc/glibc/sysdeps/unix/sysv/linux/bits/param.h created+42
...@@ -0,0 +1,42 @@
1/* Old-style Unix parameters and limits. Linux version.
2 Copyright (C) 1995-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SYS_PARAM_H
20# error "Never use <bits/param.h> directly; include <sys/param.h> instead."
21#endif
22
23#ifndef ARG_MAX
24# define __undef_ARG_MAX
25#endif
26
27#include <linux/limits.h>
28#include <linux/param.h>
29
30/* The kernel headers define ARG_MAX. The value is wrong, though. */
31#ifdef __undef_ARG_MAX
32# undef ARG_MAX
33# undef __undef_ARG_MAX
34#endif
35
36#define MAXSYMLINKS 20
37
38/* The following are not really correct but it is a value we used for a
39 long time and which seems to be usable. People should not use NOFILE
40 and NCARGS anyway. */
41#define NOFILE 256
42#define NCARGS 131072
libc/glibc/sysdeps/unix/sysv/linux/bits/sched.h created+98
...@@ -0,0 +1,98 @@
1/* Definitions of constants and data structure for POSIX 1003.1b-1993
2 scheduling interface.
3 Copyright (C) 1996-2019 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
19
20#ifndef _BITS_SCHED_H
21#define _BITS_SCHED_H 1
22
23#ifndef _SCHED_H
24# error "Never include <bits/sched.h> directly; use <sched.h> instead."
25#endif
26
27/* Scheduling algorithms. */
28#define SCHED_OTHER 0
29#define SCHED_FIFO 1
30#define SCHED_RR 2
31#ifdef __USE_GNU
32# define SCHED_BATCH 3
33# define SCHED_ISO 4
34# define SCHED_IDLE 5
35# define SCHED_DEADLINE 6
36
37# define SCHED_RESET_ON_FORK 0x40000000
38#endif
39
40#ifdef __USE_GNU
41/* Cloning flags. */
42# define CSIGNAL 0x000000ff /* Signal mask to be sent at exit. */
43# define CLONE_VM 0x00000100 /* Set if VM shared between processes. */
44# define CLONE_FS 0x00000200 /* Set if fs info shared between processes. */
45# define CLONE_FILES 0x00000400 /* Set if open files shared between processes. */
46# define CLONE_SIGHAND 0x00000800 /* Set if signal handlers shared. */
47# define CLONE_PTRACE 0x00002000 /* Set if tracing continues on the child. */
48# define CLONE_VFORK 0x00004000 /* Set if the parent wants the child to
49 wake it up on mm_release. */
50# define CLONE_PARENT 0x00008000 /* Set if we want to have the same
51 parent as the cloner. */
52# define CLONE_THREAD 0x00010000 /* Set to add to same thread group. */
53# define CLONE_NEWNS 0x00020000 /* Set to create new namespace. */
54# define CLONE_SYSVSEM 0x00040000 /* Set to shared SVID SEM_UNDO semantics. */
55# define CLONE_SETTLS 0x00080000 /* Set TLS info. */
56# define CLONE_PARENT_SETTID 0x00100000 /* Store TID in userlevel buffer
57 before MM copy. */
58# define CLONE_CHILD_CLEARTID 0x00200000 /* Register exit futex and memory
59 location to clear. */
60# define CLONE_DETACHED 0x00400000 /* Create clone detached. */
61# define CLONE_UNTRACED 0x00800000 /* Set if the tracing process can't
62 force CLONE_PTRACE on this clone. */
63# define CLONE_CHILD_SETTID 0x01000000 /* Store TID in userlevel buffer in
64 the child. */
65# define CLONE_NEWCGROUP 0x02000000 /* New cgroup namespace. */
66# define CLONE_NEWUTS 0x04000000 /* New utsname group. */
67# define CLONE_NEWIPC 0x08000000 /* New ipcs. */
68# define CLONE_NEWUSER 0x10000000 /* New user namespace. */
69# define CLONE_NEWPID 0x20000000 /* New pid namespace. */
70# define CLONE_NEWNET 0x40000000 /* New network namespace. */
71# define CLONE_IO 0x80000000 /* Clone I/O context. */
72#endif
73
74#include <bits/types/struct_sched_param.h>
75
76__BEGIN_DECLS
77
78#ifdef __USE_GNU
79/* Clone current process. */
80extern int clone (int (*__fn) (void *__arg), void *__child_stack,
81 int __flags, void *__arg, ...) __THROW;
82
83/* Unshare the specified resources. */
84extern int unshare (int __flags) __THROW;
85
86/* Get index of currently used CPU. */
87extern int sched_getcpu (void) __THROW;
88
89/* Get currently used CPU and NUMA node. */
90extern int getcpu (unsigned int *, unsigned int *) __THROW;
91
92/* Switch process to namespace of type NSTYPE indicated by FD. */
93extern int setns (int __fd, int __nstype) __THROW;
94#endif
95
96__END_DECLS
97
98#endif /* bits/sched.h */
libc/glibc/sysdeps/unix/sysv/linux/bits/signum.h created+58
...@@ -0,0 +1,58 @@
1/* Signal number definitions. Linux version.
2 Copyright (C) 1995-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_SIGNUM_H
20#define _BITS_SIGNUM_H 1
21
22#ifndef _SIGNAL_H
23#error "Never include <bits/signum.h> directly; use <signal.h> instead."
24#endif
25
26#include <bits/signum-generic.h>
27
28/* Adjustments and additions to the signal number constants for
29 most Linux systems. */
30
31#define SIGSTKFLT 16 /* Stack fault (obsolete). */
32#define SIGPWR 30 /* Power failure imminent. */
33
34#undef SIGBUS
35#define SIGBUS 7
36#undef SIGUSR1
37#define SIGUSR1 10
38#undef SIGUSR2
39#define SIGUSR2 12
40#undef SIGCHLD
41#define SIGCHLD 17
42#undef SIGCONT
43#define SIGCONT 18
44#undef SIGSTOP
45#define SIGSTOP 19
46#undef SIGTSTP
47#define SIGTSTP 20
48#undef SIGURG
49#define SIGURG 23
50#undef SIGPOLL
51#define SIGPOLL 29
52#undef SIGSYS
53#define SIGSYS 31
54
55#undef __SIGRTMAX
56#define __SIGRTMAX 64
57
58#endif /* <signal.h> included. */
libc/glibc/sysdeps/unix/sysv/linux/bits/time.h created+83
...@@ -0,0 +1,83 @@
1/* System-dependent timing definitions. Linux version.
2 Copyright (C) 1996-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19/*
20 * Never include this file directly; use <time.h> instead.
21 */
22
23#ifndef _BITS_TIME_H
24#define _BITS_TIME_H 1
25
26#include <bits/types.h>
27
28/* ISO/IEC 9899:1999 7.23.1: Components of time
29 The macro `CLOCKS_PER_SEC' is an expression with type `clock_t' that is
30 the number per second of the value returned by the `clock' function. */
31/* CAE XSH, Issue 4, Version 2: <time.h>
32 The value of CLOCKS_PER_SEC is required to be 1 million on all
33 XSI-conformant systems. */
34#define CLOCKS_PER_SEC ((__clock_t) 1000000)
35
36#if (!defined __STRICT_ANSI__ || defined __USE_POSIX) \
37 && !defined __USE_XOPEN2K
38/* Even though CLOCKS_PER_SEC has such a strange value CLK_TCK
39 presents the real value for clock ticks per second for the system. */
40extern long int __sysconf (int);
41# define CLK_TCK ((__clock_t) __sysconf (2)) /* 2 is _SC_CLK_TCK */
42#endif
43
44#ifdef __USE_POSIX199309
45/* Identifier for system-wide realtime clock. */
46# define CLOCK_REALTIME 0
47/* Monotonic system-wide clock. */
48# define CLOCK_MONOTONIC 1
49/* High-resolution timer from the CPU. */
50# define CLOCK_PROCESS_CPUTIME_ID 2
51/* Thread-specific CPU-time clock. */
52# define CLOCK_THREAD_CPUTIME_ID 3
53/* Monotonic system-wide clock, not adjusted for frequency scaling. */
54# define CLOCK_MONOTONIC_RAW 4
55/* Identifier for system-wide realtime clock, updated only on ticks. */
56# define CLOCK_REALTIME_COARSE 5
57/* Monotonic system-wide clock, updated only on ticks. */
58# define CLOCK_MONOTONIC_COARSE 6
59/* Monotonic system-wide clock that includes time spent in suspension. */
60# define CLOCK_BOOTTIME 7
61/* Like CLOCK_REALTIME but also wakes suspended system. */
62# define CLOCK_REALTIME_ALARM 8
63/* Like CLOCK_BOOTTIME but also wakes suspended system. */
64# define CLOCK_BOOTTIME_ALARM 9
65/* Like CLOCK_REALTIME but in International Atomic Time. */
66# define CLOCK_TAI 11
67
68/* Flag to indicate time is absolute. */
69# define TIMER_ABSTIME 1
70#endif
71
72#ifdef __USE_GNU
73# include <bits/timex.h>
74
75__BEGIN_DECLS
76
77/* Tune a POSIX clock. */
78extern int clock_adjtime (__clockid_t __clock_id, struct timex *__utx) __THROW;
79
80__END_DECLS
81#endif /* use GNU */
82
83#endif /* bits/time.h */
libc/glibc/sysdeps/unix/sysv/linux/bits/timex.h created+110
...@@ -0,0 +1,110 @@
1/* Copyright (C) 1995-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _BITS_TIMEX_H
19#define _BITS_TIMEX_H 1
20
21#include <bits/types.h>
22#include <bits/types/struct_timeval.h>
23
24/* These definitions from linux/timex.h as of 3.18. */
25
26struct timex
27{
28 unsigned int modes; /* mode selector */
29 __syscall_slong_t offset; /* time offset (usec) */
30 __syscall_slong_t freq; /* frequency offset (scaled ppm) */
31 __syscall_slong_t maxerror; /* maximum error (usec) */
32 __syscall_slong_t esterror; /* estimated error (usec) */
33 int status; /* clock command/status */
34 __syscall_slong_t constant; /* pll time constant */
35 __syscall_slong_t precision; /* clock precision (usec) (ro) */
36 __syscall_slong_t tolerance; /* clock frequency tolerance (ppm) (ro) */
37 struct timeval time; /* (read only, except for ADJ_SETOFFSET) */
38 __syscall_slong_t tick; /* (modified) usecs between clock ticks */
39 __syscall_slong_t ppsfreq; /* pps frequency (scaled ppm) (ro) */
40 __syscall_slong_t jitter; /* pps jitter (us) (ro) */
41 int shift; /* interval duration (s) (shift) (ro) */
42 __syscall_slong_t stabil; /* pps stability (scaled ppm) (ro) */
43 __syscall_slong_t jitcnt; /* jitter limit exceeded (ro) */
44 __syscall_slong_t calcnt; /* calibration intervals (ro) */
45 __syscall_slong_t errcnt; /* calibration errors (ro) */
46 __syscall_slong_t stbcnt; /* stability limit exceeded (ro) */
47
48 int tai; /* TAI offset (ro) */
49
50 /* ??? */
51 int :32; int :32; int :32; int :32;
52 int :32; int :32; int :32; int :32;
53 int :32; int :32; int :32;
54};
55
56/* Mode codes (timex.mode) */
57#define ADJ_OFFSET 0x0001 /* time offset */
58#define ADJ_FREQUENCY 0x0002 /* frequency offset */
59#define ADJ_MAXERROR 0x0004 /* maximum time error */
60#define ADJ_ESTERROR 0x0008 /* estimated time error */
61#define ADJ_STATUS 0x0010 /* clock status */
62#define ADJ_TIMECONST 0x0020 /* pll time constant */
63#define ADJ_TAI 0x0080 /* set TAI offset */
64#define ADJ_SETOFFSET 0x0100 /* add 'time' to current time */
65#define ADJ_MICRO 0x1000 /* select microsecond resolution */
66#define ADJ_NANO 0x2000 /* select nanosecond resolution */
67#define ADJ_TICK 0x4000 /* tick value */
68#define ADJ_OFFSET_SINGLESHOT 0x8001 /* old-fashioned adjtime */
69#define ADJ_OFFSET_SS_READ 0xa001 /* read-only adjtime */
70
71/* xntp 3.4 compatibility names */
72#define MOD_OFFSET ADJ_OFFSET
73#define MOD_FREQUENCY ADJ_FREQUENCY
74#define MOD_MAXERROR ADJ_MAXERROR
75#define MOD_ESTERROR ADJ_ESTERROR
76#define MOD_STATUS ADJ_STATUS
77#define MOD_TIMECONST ADJ_TIMECONST
78#define MOD_CLKB ADJ_TICK
79#define MOD_CLKA ADJ_OFFSET_SINGLESHOT /* 0x8000 in original */
80#define MOD_TAI ADJ_TAI
81#define MOD_MICRO ADJ_MICRO
82#define MOD_NANO ADJ_NANO
83
84
85/* Status codes (timex.status) */
86#define STA_PLL 0x0001 /* enable PLL updates (rw) */
87#define STA_PPSFREQ 0x0002 /* enable PPS freq discipline (rw) */
88#define STA_PPSTIME 0x0004 /* enable PPS time discipline (rw) */
89#define STA_FLL 0x0008 /* select frequency-lock mode (rw) */
90
91#define STA_INS 0x0010 /* insert leap (rw) */
92#define STA_DEL 0x0020 /* delete leap (rw) */
93#define STA_UNSYNC 0x0040 /* clock unsynchronized (rw) */
94#define STA_FREQHOLD 0x0080 /* hold frequency (rw) */
95
96#define STA_PPSSIGNAL 0x0100 /* PPS signal present (ro) */
97#define STA_PPSJITTER 0x0200 /* PPS signal jitter exceeded (ro) */
98#define STA_PPSWANDER 0x0400 /* PPS signal wander exceeded (ro) */
99#define STA_PPSERROR 0x0800 /* PPS signal calibration error (ro) */
100
101#define STA_CLOCKERR 0x1000 /* clock hardware fault (ro) */
102#define STA_NANO 0x2000 /* resolution (0 = us, 1 = ns) (ro) */
103#define STA_MODE 0x4000 /* mode (0 = PLL, 1 = FLL) (ro) */
104#define STA_CLK 0x8000 /* clock source (0 = A, 1 = B) (ro) */
105
106/* Read-only bits */
107#define STA_RONLY (STA_PPSSIGNAL | STA_PPSJITTER | STA_PPSWANDER | \
108 STA_PPSERROR | STA_CLOCKERR | STA_NANO | STA_MODE | STA_CLK)
109
110#endif /* bits/timex.h */
libc/glibc/sysdeps/unix/sysv/linux/include/sys/timex.h created+29
...@@ -0,0 +1,29 @@
1/* Internal declarations for sys/timex.h.
2 Copyright (C) 2014-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _INCLUDE_SYS_TIMEX_H
20#define _INCLUDE_SYS_TIMEX_H 1
21
22#include_next <sys/timex.h>
23
24# ifndef _ISOMAC
25
26libc_hidden_proto (__adjtimex)
27
28# endif /* _ISOMAC */
29#endif /* sys/timex.h */
libc/glibc/sysdeps/unix/sysv/linux/sys/timex.h created+71
...@@ -0,0 +1,71 @@
1/* Copyright (C) 1995-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_TIMEX_H
19#define _SYS_TIMEX_H 1
20
21#include <features.h>
22#include <sys/time.h>
23
24/* These definitions from linux/timex.h as of 2.6.30. */
25
26#include <bits/timex.h>
27
28#define NTP_API 4 /* NTP API version */
29
30struct ntptimeval
31{
32 struct timeval time; /* current time (ro) */
33 long int maxerror; /* maximum error (us) (ro) */
34 long int esterror; /* estimated error (us) (ro) */
35 long int tai; /* TAI offset (ro) */
36
37 long int __glibc_reserved1;
38 long int __glibc_reserved2;
39 long int __glibc_reserved3;
40 long int __glibc_reserved4;
41};
42
43/* Clock states (time_state) */
44#define TIME_OK 0 /* clock synchronized, no leap second */
45#define TIME_INS 1 /* insert leap second */
46#define TIME_DEL 2 /* delete leap second */
47#define TIME_OOP 3 /* leap second in progress */
48#define TIME_WAIT 4 /* leap second has occurred */
49#define TIME_ERROR 5 /* clock not synchronized */
50#define TIME_BAD TIME_ERROR /* bw compat */
51
52/* Maximum time constant of the PLL. */
53#define MAXTC 6
54
55__BEGIN_DECLS
56
57extern int __adjtimex (struct timex *__ntx) __THROW;
58extern int adjtimex (struct timex *__ntx) __THROW;
59
60#ifdef __REDIRECT_NTH
61extern int __REDIRECT_NTH (ntp_gettime, (struct ntptimeval *__ntv),
62 ntp_gettimex);
63#else
64extern int ntp_gettimex (struct ntptimeval *__ntv) __THROW;
65# define ntp_gettime ntp_gettimex
66#endif
67extern int ntp_adjtime (struct timex *__tntx) __THROW;
68
69__END_DECLS
70
71#endif /* sys/timex.h */
libc/glibc/sysdeps/unix/sysv/linux/x86/bits/stat.h created+210
...@@ -0,0 +1,210 @@
1/* Copyright (C) 1999-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#if !defined _SYS_STAT_H && !defined _FCNTL_H
19# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
20#endif
21
22#ifndef _BITS_STAT_H
23#define _BITS_STAT_H 1
24
25/* Versions of the `struct stat' data structure. */
26#ifndef __x86_64__
27# define _STAT_VER_LINUX_OLD 1
28# define _STAT_VER_KERNEL 1
29# define _STAT_VER_SVR4 2
30# define _STAT_VER_LINUX 3
31
32/* i386 versions of the `xmknod' interface. */
33# define _MKNOD_VER_LINUX 1
34# define _MKNOD_VER_SVR4 2
35# define _MKNOD_VER _MKNOD_VER_LINUX /* The bits defined below. */
36#else
37# define _STAT_VER_KERNEL 0
38# define _STAT_VER_LINUX 1
39
40/* x86-64 versions of the `xmknod' interface. */
41# define _MKNOD_VER_LINUX 0
42#endif
43
44#define _STAT_VER _STAT_VER_LINUX
45
46struct stat
47 {
48 __dev_t st_dev; /* Device. */
49#ifndef __x86_64__
50 unsigned short int __pad1;
51#endif
52#if defined __x86_64__ || !defined __USE_FILE_OFFSET64
53 __ino_t st_ino; /* File serial number. */
54#else
55 __ino_t __st_ino; /* 32bit file serial number. */
56#endif
57#ifndef __x86_64__
58 __mode_t st_mode; /* File mode. */
59 __nlink_t st_nlink; /* Link count. */
60#else
61 __nlink_t st_nlink; /* Link count. */
62 __mode_t st_mode; /* File mode. */
63#endif
64 __uid_t st_uid; /* User ID of the file's owner. */
65 __gid_t st_gid; /* Group ID of the file's group.*/
66#ifdef __x86_64__
67 int __pad0;
68#endif
69 __dev_t st_rdev; /* Device number, if device. */
70#ifndef __x86_64__
71 unsigned short int __pad2;
72#endif
73#if defined __x86_64__ || !defined __USE_FILE_OFFSET64
74 __off_t st_size; /* Size of file, in bytes. */
75#else
76 __off64_t st_size; /* Size of file, in bytes. */
77#endif
78 __blksize_t st_blksize; /* Optimal block size for I/O. */
79#if defined __x86_64__ || !defined __USE_FILE_OFFSET64
80 __blkcnt_t st_blocks; /* Number 512-byte blocks allocated. */
81#else
82 __blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
83#endif
84#ifdef __USE_XOPEN2K8
85 /* Nanosecond resolution timestamps are stored in a format
86 equivalent to 'struct timespec'. This is the type used
87 whenever possible but the Unix namespace rules do not allow the
88 identifier 'timespec' to appear in the <sys/stat.h> header.
89 Therefore we have to handle the use of this header in strictly
90 standard-compliant sources special. */
91 struct timespec st_atim; /* Time of last access. */
92 struct timespec st_mtim; /* Time of last modification. */
93 struct timespec st_ctim; /* Time of last status change. */
94# define st_atime st_atim.tv_sec /* Backward compatibility. */
95# define st_mtime st_mtim.tv_sec
96# define st_ctime st_ctim.tv_sec
97#else
98 __time_t st_atime; /* Time of last access. */
99 __syscall_ulong_t st_atimensec; /* Nscecs of last access. */
100 __time_t st_mtime; /* Time of last modification. */
101 __syscall_ulong_t st_mtimensec; /* Nsecs of last modification. */
102 __time_t st_ctime; /* Time of last status change. */
103 __syscall_ulong_t st_ctimensec; /* Nsecs of last status change. */
104#endif
105#ifdef __x86_64__
106 __syscall_slong_t __glibc_reserved[3];
107#else
108# ifndef __USE_FILE_OFFSET64
109 unsigned long int __glibc_reserved4;
110 unsigned long int __glibc_reserved5;
111# else
112 __ino64_t st_ino; /* File serial number. */
113# endif
114#endif
115 };
116
117#ifdef __USE_LARGEFILE64
118/* Note stat64 has the same shape as stat for x86-64. */
119struct stat64
120 {
121 __dev_t st_dev; /* Device. */
122# ifdef __x86_64__
123 __ino64_t st_ino; /* File serial number. */
124 __nlink_t st_nlink; /* Link count. */
125 __mode_t st_mode; /* File mode. */
126# else
127 unsigned int __pad1;
128 __ino_t __st_ino; /* 32bit file serial number. */
129 __mode_t st_mode; /* File mode. */
130 __nlink_t st_nlink; /* Link count. */
131# endif
132 __uid_t st_uid; /* User ID of the file's owner. */
133 __gid_t st_gid; /* Group ID of the file's group.*/
134# ifdef __x86_64__
135 int __pad0;
136 __dev_t st_rdev; /* Device number, if device. */
137 __off_t st_size; /* Size of file, in bytes. */
138# else
139 __dev_t st_rdev; /* Device number, if device. */
140 unsigned int __pad2;
141 __off64_t st_size; /* Size of file, in bytes. */
142# endif
143 __blksize_t st_blksize; /* Optimal block size for I/O. */
144 __blkcnt64_t st_blocks; /* Nr. 512-byte blocks allocated. */
145# ifdef __USE_XOPEN2K8
146 /* Nanosecond resolution timestamps are stored in a format
147 equivalent to 'struct timespec'. This is the type used
148 whenever possible but the Unix namespace rules do not allow the
149 identifier 'timespec' to appear in the <sys/stat.h> header.
150 Therefore we have to handle the use of this header in strictly
151 standard-compliant sources special. */
152 struct timespec st_atim; /* Time of last access. */
153 struct timespec st_mtim; /* Time of last modification. */
154 struct timespec st_ctim; /* Time of last status change. */
155# else
156 __time_t st_atime; /* Time of last access. */
157 __syscall_ulong_t st_atimensec; /* Nscecs of last access. */
158 __time_t st_mtime; /* Time of last modification. */
159 __syscall_ulong_t st_mtimensec; /* Nsecs of last modification. */
160 __time_t st_ctime; /* Time of last status change. */
161 __syscall_ulong_t st_ctimensec; /* Nsecs of last status change. */
162# endif
163# ifdef __x86_64__
164 __syscall_slong_t __glibc_reserved[3];
165# else
166 __ino64_t st_ino; /* File serial number. */
167# endif
168 };
169#endif
170
171/* Tell code we have these members. */
172#define _STATBUF_ST_BLKSIZE
173#define _STATBUF_ST_RDEV
174/* Nanosecond resolution time values are supported. */
175#define _STATBUF_ST_NSEC
176
177/* Encoding of the file mode. */
178
179#define __S_IFMT 0170000 /* These bits determine file type. */
180
181/* File types. */
182#define __S_IFDIR 0040000 /* Directory. */
183#define __S_IFCHR 0020000 /* Character device. */
184#define __S_IFBLK 0060000 /* Block device. */
185#define __S_IFREG 0100000 /* Regular file. */
186#define __S_IFIFO 0010000 /* FIFO. */
187#define __S_IFLNK 0120000 /* Symbolic link. */
188#define __S_IFSOCK 0140000 /* Socket. */
189
190/* POSIX.1b objects. Note that these macros always evaluate to zero. But
191 they do it by enforcing the correct use of the macros. */
192#define __S_TYPEISMQ(buf) ((buf)->st_mode - (buf)->st_mode)
193#define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode)
194#define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode)
195
196/* Protection bits. */
197
198#define __S_ISUID 04000 /* Set user ID on execution. */
199#define __S_ISGID 02000 /* Set group ID on execution. */
200#define __S_ISVTX 01000 /* Save swapped text after use (sticky). */
201#define __S_IREAD 0400 /* Read by owner. */
202#define __S_IWRITE 0200 /* Write by owner. */
203#define __S_IEXEC 0100 /* Execute by owner. */
204
205#ifdef __USE_ATFILE
206# define UTIME_NOW ((1l << 30) - 1l)
207# define UTIME_OMIT ((1l << 30) - 2l)
208#endif
209
210#endif /* bits/stat.h */
libc/glibc/sysdeps/unix/sysv/linux/x86/bits/typesizes.h created+95
...@@ -0,0 +1,95 @@
1/* bits/typesizes.h -- underlying types for *_t. Linux/x86-64 version.
2 Copyright (C) 2012-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_TYPES_H
20# error "Never include <bits/typesizes.h> directly; use <sys/types.h> instead."
21#endif
22
23#ifndef _BITS_TYPESIZES_H
24#define _BITS_TYPESIZES_H 1
25
26/* See <bits/types.h> for the meaning of these macros. This file exists so
27 that <bits/types.h> need not vary across different GNU platforms. */
28
29/* X32 kernel interface is 64-bit. */
30#if defined __x86_64__ && defined __ILP32__
31# define __SYSCALL_SLONG_TYPE __SQUAD_TYPE
32# define __SYSCALL_ULONG_TYPE __UQUAD_TYPE
33#else
34# define __SYSCALL_SLONG_TYPE __SLONGWORD_TYPE
35# define __SYSCALL_ULONG_TYPE __ULONGWORD_TYPE
36#endif
37
38#define __DEV_T_TYPE __UQUAD_TYPE
39#define __UID_T_TYPE __U32_TYPE
40#define __GID_T_TYPE __U32_TYPE
41#define __INO_T_TYPE __SYSCALL_ULONG_TYPE
42#define __INO64_T_TYPE __UQUAD_TYPE
43#define __MODE_T_TYPE __U32_TYPE
44#ifdef __x86_64__
45# define __NLINK_T_TYPE __SYSCALL_ULONG_TYPE
46# define __FSWORD_T_TYPE __SYSCALL_SLONG_TYPE
47#else
48# define __NLINK_T_TYPE __UWORD_TYPE
49# define __FSWORD_T_TYPE __SWORD_TYPE
50#endif
51#define __OFF_T_TYPE __SYSCALL_SLONG_TYPE
52#define __OFF64_T_TYPE __SQUAD_TYPE
53#define __PID_T_TYPE __S32_TYPE
54#define __RLIM_T_TYPE __SYSCALL_ULONG_TYPE
55#define __RLIM64_T_TYPE __UQUAD_TYPE
56#define __BLKCNT_T_TYPE __SYSCALL_SLONG_TYPE
57#define __BLKCNT64_T_TYPE __SQUAD_TYPE
58#define __FSBLKCNT_T_TYPE __SYSCALL_ULONG_TYPE
59#define __FSBLKCNT64_T_TYPE __UQUAD_TYPE
60#define __FSFILCNT_T_TYPE __SYSCALL_ULONG_TYPE
61#define __FSFILCNT64_T_TYPE __UQUAD_TYPE
62#define __ID_T_TYPE __U32_TYPE
63#define __CLOCK_T_TYPE __SYSCALL_SLONG_TYPE
64#define __TIME_T_TYPE __SYSCALL_SLONG_TYPE
65#define __USECONDS_T_TYPE __U32_TYPE
66#define __SUSECONDS_T_TYPE __SYSCALL_SLONG_TYPE
67#define __DADDR_T_TYPE __S32_TYPE
68#define __KEY_T_TYPE __S32_TYPE
69#define __CLOCKID_T_TYPE __S32_TYPE
70#define __TIMER_T_TYPE void *
71#define __BLKSIZE_T_TYPE __SYSCALL_SLONG_TYPE
72#define __FSID_T_TYPE struct { int __val[2]; }
73#define __SSIZE_T_TYPE __SWORD_TYPE
74#define __CPU_MASK_TYPE __SYSCALL_ULONG_TYPE
75
76#ifdef __x86_64__
77/* Tell the libc code that off_t and off64_t are actually the same type
78 for all ABI purposes, even if possibly expressed as different base types
79 for C type-checking purposes. */
80# define __OFF_T_MATCHES_OFF64_T 1
81
82/* Same for ino_t and ino64_t. */
83# define __INO_T_MATCHES_INO64_T 1
84
85/* And for __rlim_t and __rlim64_t. */
86# define __RLIM_T_MATCHES_RLIM64_T 1
87#else
88# define __RLIM_T_MATCHES_RLIM64_T 0
89#endif
90
91/* Number of descriptors that can fit in an `fd_set'. */
92#define __FD_SETSIZE 1024
93
94
95#endif /* bits/typesizes.h */
libc/glibc/sysdeps/unix/sysv/linux/x86/sys/elf.h created+29
...@@ -0,0 +1,29 @@
1/* Copyright (C) 1998-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_ELF_H
19#define _SYS_ELF_H 1
20
21#ifdef __x86_64__
22# error This header is unsupported on x86-64.
23#else
24# warning "This header is obsolete; use <sys/procfs.h> instead."
25
26# include <sys/procfs.h>
27#endif
28
29#endif /* _SYS_ELF_H */
libc/glibc/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h created+270
...@@ -0,0 +1,270 @@
1/* Copyright (C) 2002-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _LOWLEVELLOCK_H
20#define _LOWLEVELLOCK_H 1
21
22#include <stap-probe.h>
23
24#ifndef __ASSEMBLER__
25# include <time.h>
26# include <sys/param.h>
27# include <bits/pthreadtypes.h>
28# include <kernel-features.h>
29
30# ifndef LOCK_INSTR
31# ifdef UP
32# define LOCK_INSTR /* nothing */
33# else
34# define LOCK_INSTR "lock;"
35# endif
36# endif
37#else
38# ifndef LOCK
39# ifdef UP
40# define LOCK
41# else
42# define LOCK lock
43# endif
44# endif
45#endif
46
47#include <lowlevellock-futex.h>
48
49/* XXX Remove when no assembler code uses futexes anymore. */
50#define SYS_futex __NR_futex
51
52#ifndef __ASSEMBLER__
53
54/* Initializer for lock. */
55#define LLL_LOCK_INITIALIZER (0)
56#define LLL_LOCK_INITIALIZER_LOCKED (1)
57#define LLL_LOCK_INITIALIZER_WAITERS (2)
58
59
60/* NB: in the lll_trylock macro we simply return the value in %eax
61 after the cmpxchg instruction. In case the operation succeded this
62 value is zero. In case the operation failed, the cmpxchg instruction
63 has loaded the current value of the memory work which is guaranteed
64 to be nonzero. */
65#if !IS_IN (libc) || defined UP
66# define __lll_trylock_asm LOCK_INSTR "cmpxchgl %2, %1"
67#else
68# define __lll_trylock_asm "cmpl $0, __libc_multiple_threads(%%rip)\n\t" \
69 "je 0f\n\t" \
70 "lock; cmpxchgl %2, %1\n\t" \
71 "jmp 1f\n\t" \
72 "0:\tcmpxchgl %2, %1\n\t" \
73 "1:"
74#endif
75
76#define lll_trylock(futex) \
77 ({ int ret; \
78 __asm __volatile (__lll_trylock_asm \
79 : "=a" (ret), "=m" (futex) \
80 : "r" (LLL_LOCK_INITIALIZER_LOCKED), "m" (futex), \
81 "0" (LLL_LOCK_INITIALIZER) \
82 : "memory"); \
83 ret; })
84
85#define lll_cond_trylock(futex) \
86 ({ int ret; \
87 __asm __volatile (LOCK_INSTR "cmpxchgl %2, %1" \
88 : "=a" (ret), "=m" (futex) \
89 : "r" (LLL_LOCK_INITIALIZER_WAITERS), \
90 "m" (futex), "0" (LLL_LOCK_INITIALIZER) \
91 : "memory"); \
92 ret; })
93
94#if !IS_IN (libc) || defined UP
95# define __lll_lock_asm_start LOCK_INSTR "cmpxchgl %4, %2\n\t" \
96 "jz 24f\n\t"
97#else
98# define __lll_lock_asm_start "cmpl $0, __libc_multiple_threads(%%rip)\n\t" \
99 "je 0f\n\t" \
100 "lock; cmpxchgl %4, %2\n\t" \
101 "jnz 1f\n\t" \
102 "jmp 24f\n" \
103 "0:\tcmpxchgl %4, %2\n\t" \
104 "jz 24f\n\t"
105#endif
106
107#define lll_lock(futex, private) \
108 (void) \
109 ({ int ignore1, ignore2, ignore3; \
110 if (__builtin_constant_p (private) && (private) == LLL_PRIVATE) \
111 __asm __volatile (__lll_lock_asm_start \
112 "1:\tlea %2, %%" RDI_LP "\n" \
113 "2:\tsub $128, %%" RSP_LP "\n" \
114 ".cfi_adjust_cfa_offset 128\n" \
115 "3:\tcallq __lll_lock_wait_private\n" \
116 "4:\tadd $128, %%" RSP_LP "\n" \
117 ".cfi_adjust_cfa_offset -128\n" \
118 "24:" \
119 : "=S" (ignore1), "=&D" (ignore2), "=m" (futex), \
120 "=a" (ignore3) \
121 : "0" (1), "m" (futex), "3" (0) \
122 : "cx", "r11", "cc", "memory"); \
123 else \
124 __asm __volatile (__lll_lock_asm_start \
125 "1:\tlea %2, %%" RDI_LP "\n" \
126 "2:\tsub $128, %%" RSP_LP "\n" \
127 ".cfi_adjust_cfa_offset 128\n" \
128 "3:\tcallq __lll_lock_wait\n" \
129 "4:\tadd $128, %%" RSP_LP "\n" \
130 ".cfi_adjust_cfa_offset -128\n" \
131 "24:" \
132 : "=S" (ignore1), "=D" (ignore2), "=m" (futex), \
133 "=a" (ignore3) \
134 : "1" (1), "m" (futex), "3" (0), "0" (private) \
135 : "cx", "r11", "cc", "memory"); \
136 }) \
137
138#define lll_cond_lock(futex, private) \
139 (void) \
140 ({ int ignore1, ignore2, ignore3; \
141 __asm __volatile (LOCK_INSTR "cmpxchgl %4, %2\n\t" \
142 "jz 24f\n" \
143 "1:\tlea %2, %%" RDI_LP "\n" \
144 "2:\tsub $128, %%" RSP_LP "\n" \
145 ".cfi_adjust_cfa_offset 128\n" \
146 "3:\tcallq __lll_lock_wait\n" \
147 "4:\tadd $128, %%" RSP_LP "\n" \
148 ".cfi_adjust_cfa_offset -128\n" \
149 "24:" \
150 : "=S" (ignore1), "=D" (ignore2), "=m" (futex), \
151 "=a" (ignore3) \
152 : "1" (2), "m" (futex), "3" (0), "0" (private) \
153 : "cx", "r11", "cc", "memory"); \
154 })
155
156#define lll_timedlock(futex, timeout, private) \
157 ({ int result, ignore1, ignore2, ignore3; \
158 __asm __volatile (LOCK_INSTR "cmpxchgl %1, %4\n\t" \
159 "jz 24f\n" \
160 "1:\tlea %4, %%" RDI_LP "\n" \
161 "0:\tmov %8, %%" RDX_LP "\n" \
162 "2:\tsub $128, %%" RSP_LP "\n" \
163 ".cfi_adjust_cfa_offset 128\n" \
164 "3:\tcallq __lll_timedlock_wait\n" \
165 "4:\tadd $128, %%" RSP_LP "\n" \
166 ".cfi_adjust_cfa_offset -128\n" \
167 "24:" \
168 : "=a" (result), "=D" (ignore1), "=S" (ignore2), \
169 "=&d" (ignore3), "=m" (futex) \
170 : "0" (0), "1" (1), "m" (futex), "m" (timeout), \
171 "2" (private) \
172 : "memory", "cx", "cc", "r10", "r11"); \
173 result; })
174
175extern int __lll_timedlock_elision (int *futex, short *adapt_count,
176 const struct timespec *timeout,
177 int private) attribute_hidden;
178
179#define lll_timedlock_elision(futex, adapt_count, timeout, private) \
180 __lll_timedlock_elision(&(futex), &(adapt_count), timeout, private)
181
182#if !IS_IN (libc) || defined UP
183# define __lll_unlock_asm_start LOCK_INSTR "decl %0\n\t" \
184 "je 24f\n\t"
185#else
186# define __lll_unlock_asm_start "cmpl $0, __libc_multiple_threads(%%rip)\n\t" \
187 "je 0f\n\t" \
188 "lock; decl %0\n\t" \
189 "jne 1f\n\t" \
190 "jmp 24f\n\t" \
191 "0:\tdecl %0\n\t" \
192 "je 24f\n\t"
193#endif
194
195#define lll_unlock(futex, private) \
196 (void) \
197 ({ int ignore; \
198 if (__builtin_constant_p (private) && (private) == LLL_PRIVATE) \
199 __asm __volatile (__lll_unlock_asm_start \
200 "1:\tlea %0, %%" RDI_LP "\n" \
201 "2:\tsub $128, %%" RSP_LP "\n" \
202 ".cfi_adjust_cfa_offset 128\n" \
203 "3:\tcallq __lll_unlock_wake_private\n" \
204 "4:\tadd $128, %%" RSP_LP "\n" \
205 ".cfi_adjust_cfa_offset -128\n" \
206 "24:" \
207 : "=m" (futex), "=&D" (ignore) \
208 : "m" (futex) \
209 : "ax", "cx", "r11", "cc", "memory"); \
210 else \
211 __asm __volatile (__lll_unlock_asm_start \
212 "1:\tlea %0, %%" RDI_LP "\n" \
213 "2:\tsub $128, %%" RSP_LP "\n" \
214 ".cfi_adjust_cfa_offset 128\n" \
215 "3:\tcallq __lll_unlock_wake\n" \
216 "4:\tadd $128, %%" RSP_LP "\n" \
217 ".cfi_adjust_cfa_offset -128\n" \
218 "24:" \
219 : "=m" (futex), "=&D" (ignore) \
220 : "m" (futex), "S" (private) \
221 : "ax", "cx", "r11", "cc", "memory"); \
222 })
223
224#define lll_islocked(futex) \
225 (futex != LLL_LOCK_INITIALIZER)
226
227extern int __lll_timedwait_tid (int *, const struct timespec *)
228 attribute_hidden;
229
230/* The kernel notifies a process which uses CLONE_CHILD_CLEARTID via futex
231 wake-up when the clone terminates. The memory location contains the
232 thread ID while the clone is running and is reset to zero by the kernel
233 afterwards. The kernel up to version 3.16.3 does not use the private futex
234 operations for futex wake-up when the clone terminates.
235 If ABSTIME is not NULL, is used a timeout for futex call. If the timeout
236 occurs then return ETIMEOUT, if ABSTIME is invalid, return EINVAL.
237 The futex operation are issues with cancellable versions. */
238#define lll_wait_tid(tid, abstime) \
239 ({ \
240 int __res = 0; \
241 __typeof (tid) __tid; \
242 if (abstime != NULL) \
243 __res = __lll_timedwait_tid (&(tid), (abstime)); \
244 else \
245 /* We need acquire MO here so that we synchronize with the \
246 kernel's store to 0 when the clone terminates. (see above) */ \
247 while ((__tid = atomic_load_acquire (&(tid))) != 0) \
248 lll_futex_wait_cancel (&(tid), __tid, LLL_SHARED); \
249 __res; \
250 })
251
252extern int __lll_lock_elision (int *futex, short *adapt_count, int private)
253 attribute_hidden;
254
255extern int __lll_unlock_elision (int *lock, int private)
256 attribute_hidden;
257
258extern int __lll_trylock_elision (int *lock, short *adapt_count)
259 attribute_hidden;
260
261#define lll_lock_elision(futex, adapt_count, private) \
262 __lll_lock_elision (&(futex), &(adapt_count), private)
263#define lll_unlock_elision(futex, adapt_count, private) \
264 __lll_unlock_elision (&(futex), private)
265#define lll_trylock_elision(futex, adapt_count) \
266 __lll_trylock_elision (&(futex), &(adapt_count))
267
268#endif /* !__ASSEMBLER__ */
269
270#endif /* lowlevellock.h */
libc/glibc/sysdeps/x86/bits/endian.h created+7
...@@ -0,0 +1,7 @@
1/* i386/x86_64 are little-endian. */
2
3#ifndef _ENDIAN_H
4# error "Never use <bits/endian.h> directly; include <endian.h> instead."
5#endif
6
7#define __BYTE_ORDER __LITTLE_ENDIAN
libc/glibc/sysdeps/x86/bits/floatn.h created+121
...@@ -0,0 +1,121 @@
1/* Macros to control TS 18661-3 glibc features on x86.
2 Copyright (C) 2017-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_FLOATN_H
20#define _BITS_FLOATN_H
21
22#include <features.h>
23
24/* Defined to 1 if the current compiler invocation provides a
25 floating-point type with the IEEE 754 binary128 format, and this
26 glibc includes corresponding *f128 interfaces for it. The required
27 libgcc support was added some time after the basic compiler
28 support, for x86_64 and x86. */
29#if (defined __x86_64__ \
30 ? __GNUC_PREREQ (4, 3) \
31 : (defined __GNU__ ? __GNUC_PREREQ (4, 5) : __GNUC_PREREQ (4, 4)))
32# define __HAVE_FLOAT128 1
33#else
34# define __HAVE_FLOAT128 0
35#endif
36
37/* Defined to 1 if __HAVE_FLOAT128 is 1 and the type is ABI-distinct
38 from the default float, double and long double types in this glibc. */
39#if __HAVE_FLOAT128
40# define __HAVE_DISTINCT_FLOAT128 1
41#else
42# define __HAVE_DISTINCT_FLOAT128 0
43#endif
44
45/* Defined to 1 if the current compiler invocation provides a
46 floating-point type with the right format for _Float64x, and this
47 glibc includes corresponding *f64x interfaces for it. */
48#define __HAVE_FLOAT64X 1
49
50/* Defined to 1 if __HAVE_FLOAT64X is 1 and _Float64x has the format
51 of long double. Otherwise, if __HAVE_FLOAT64X is 1, _Float64x has
52 the format of _Float128, which must be different from that of long
53 double. */
54#define __HAVE_FLOAT64X_LONG_DOUBLE 1
55
56#ifndef __ASSEMBLER__
57
58/* Defined to concatenate the literal suffix to be used with _Float128
59 types, if __HAVE_FLOAT128 is 1. */
60# if __HAVE_FLOAT128
61# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
62/* The literal suffix f128 exists only since GCC 7.0. */
63# define __f128(x) x##q
64# else
65# define __f128(x) x##f128
66# endif
67# endif
68
69/* Defined to a complex binary128 type if __HAVE_FLOAT128 is 1. */
70# if __HAVE_FLOAT128
71# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
72/* Add a typedef for older GCC compilers which don't natively support
73 _Complex _Float128. */
74typedef _Complex float __cfloat128 __attribute__ ((__mode__ (__TC__)));
75# define __CFLOAT128 __cfloat128
76# else
77# define __CFLOAT128 _Complex _Float128
78# endif
79# endif
80
81/* The remaining of this file provides support for older compilers. */
82# if __HAVE_FLOAT128
83
84/* The type _Float128 exists only since GCC 7.0. */
85# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
86typedef __float128 _Float128;
87# endif
88
89/* __builtin_huge_valf128 doesn't exist before GCC 7.0. */
90# if !__GNUC_PREREQ (7, 0)
91# define __builtin_huge_valf128() ((_Float128) __builtin_huge_val ())
92# endif
93
94/* Older GCC has only a subset of built-in functions for _Float128 on
95 x86, and __builtin_infq is not usable in static initializers.
96 Converting a narrower sNaN to _Float128 produces a quiet NaN, so
97 attempts to use _Float128 sNaNs will not work properly with older
98 compilers. */
99# if !__GNUC_PREREQ (7, 0)
100# define __builtin_copysignf128 __builtin_copysignq
101# define __builtin_fabsf128 __builtin_fabsq
102# define __builtin_inff128() ((_Float128) __builtin_inf ())
103# define __builtin_nanf128(x) ((_Float128) __builtin_nan (x))
104# define __builtin_nansf128(x) ((_Float128) __builtin_nans (x))
105# endif
106
107/* In math/math.h, __MATH_TG will expand signbit to __builtin_signbit*,
108 e.g.: __builtin_signbitf128, before GCC 6. However, there has never
109 been a __builtin_signbitf128 in GCC and the type-generic builtin is
110 only available since GCC 6. */
111# if !__GNUC_PREREQ (6, 0)
112# define __builtin_signbitf128 __signbitf128
113# endif
114
115# endif
116
117#endif /* !__ASSEMBLER__. */
118
119#include <bits/floatn-common.h>
120
121#endif /* _BITS_FLOATN_H */
libc/glibc/sysdeps/x86/bits/select.h created+63
...@@ -0,0 +1,63 @@
1/* Copyright (C) 1997-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_SELECT_H
19# error "Never use <bits/select.h> directly; include <sys/select.h> instead."
20#endif
21
22#include <bits/wordsize.h>
23
24
25#if defined __GNUC__ && __GNUC__ >= 2
26
27# if __WORDSIZE == 64
28# define __FD_ZERO_STOS "stosq"
29# else
30# define __FD_ZERO_STOS "stosl"
31# endif
32
33# define __FD_ZERO(fdsp) \
34 do { \
35 int __d0, __d1; \
36 __asm__ __volatile__ ("cld; rep; " __FD_ZERO_STOS \
37 : "=c" (__d0), "=D" (__d1) \
38 : "a" (0), "0" (sizeof (fd_set) \
39 / sizeof (__fd_mask)), \
40 "1" (&__FDS_BITS (fdsp)[0]) \
41 : "memory"); \
42 } while (0)
43
44#else /* ! GNU CC */
45
46/* We don't use `memset' because this would require a prototype and
47 the array isn't too big. */
48# define __FD_ZERO(set) \
49 do { \
50 unsigned int __i; \
51 fd_set *__arr = (set); \
52 for (__i = 0; __i < sizeof (fd_set) / sizeof (__fd_mask); ++__i) \
53 __FDS_BITS (__arr)[__i] = 0; \
54 } while (0)
55
56#endif /* GNU CC */
57
58#define __FD_SET(d, set) \
59 ((void) (__FDS_BITS (set)[__FD_ELT (d)] |= __FD_MASK (d)))
60#define __FD_CLR(d, set) \
61 ((void) (__FDS_BITS (set)[__FD_ELT (d)] &= ~__FD_MASK (d)))
62#define __FD_ISSET(d, set) \
63 ((__FDS_BITS (set)[__FD_ELT (d)] & __FD_MASK (d)) != 0)
libc/glibc/sysdeps/x86/bits/setjmp.h created+40
...@@ -0,0 +1,40 @@
1/* Copyright (C) 2001-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/* Define the machine-dependent type `jmp_buf'. x86-64 version. */
19#ifndef _BITS_SETJMP_H
20#define _BITS_SETJMP_H 1
21
22#if !defined _SETJMP_H && !defined _PTHREAD_H
23# error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead."
24#endif
25
26#include <bits/wordsize.h>
27
28#ifndef _ASM
29
30# if __WORDSIZE == 64
31typedef long int __jmp_buf[8];
32# elif defined __x86_64__
33__extension__ typedef long long int __jmp_buf[8];
34# else
35typedef int __jmp_buf[6];
36# endif
37
38#endif
39
40#endif /* bits/setjmp.h */
libc/glibc/sysdeps/x86/bits/wordsize.h created+17
...@@ -0,0 +1,17 @@
1/* Determine the wordsize from the preprocessor defines. */
2
3#if defined __x86_64__ && !defined __ILP32__
4# define __WORDSIZE 64
5#else
6# define __WORDSIZE 32
7#define __WORDSIZE32_SIZE_ULONG 0
8#define __WORDSIZE32_PTRDIFF_LONG 0
9#endif
10
11#ifdef __x86_64__
12# define __WORDSIZE_TIME64_COMPAT32 1
13/* Both x86-64 and x32 use the 64-bit system call interface. */
14# define __SYSCALL_WORDSIZE 64
15#else
16# define __WORDSIZE_TIME64_COMPAT32 0
17#endif
libc/glibc/sysdeps/x86/nptl/bits/pthreadtypes-arch.h created+106
...@@ -0,0 +1,106 @@
1/* Copyright (C) 2002-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _BITS_PTHREADTYPES_ARCH_H
19#define _BITS_PTHREADTYPES_ARCH_H 1
20
21#include <bits/wordsize.h>
22
23#ifdef __x86_64__
24# if __WORDSIZE == 64
25# define __SIZEOF_PTHREAD_MUTEX_T 40
26# define __SIZEOF_PTHREAD_ATTR_T 56
27# define __SIZEOF_PTHREAD_MUTEX_T 40
28# define __SIZEOF_PTHREAD_RWLOCK_T 56
29# define __SIZEOF_PTHREAD_BARRIER_T 32
30# else
31# define __SIZEOF_PTHREAD_MUTEX_T 32
32# define __SIZEOF_PTHREAD_ATTR_T 32
33# define __SIZEOF_PTHREAD_MUTEX_T 32
34# define __SIZEOF_PTHREAD_RWLOCK_T 44
35# define __SIZEOF_PTHREAD_BARRIER_T 20
36# endif
37#else
38# define __SIZEOF_PTHREAD_MUTEX_T 24
39# define __SIZEOF_PTHREAD_ATTR_T 36
40# define __SIZEOF_PTHREAD_MUTEX_T 24
41# define __SIZEOF_PTHREAD_RWLOCK_T 32
42# define __SIZEOF_PTHREAD_BARRIER_T 20
43#endif
44#define __SIZEOF_PTHREAD_MUTEXATTR_T 4
45#define __SIZEOF_PTHREAD_COND_T 48
46#define __SIZEOF_PTHREAD_CONDATTR_T 4
47#define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
48#define __SIZEOF_PTHREAD_BARRIERATTR_T 4
49
50/* Definitions for internal mutex struct. */
51#define __PTHREAD_COMPAT_PADDING_MID
52#define __PTHREAD_COMPAT_PADDING_END
53#define __PTHREAD_MUTEX_LOCK_ELISION 1
54#ifdef __x86_64__
55# define __PTHREAD_MUTEX_NUSERS_AFTER_KIND 0
56# define __PTHREAD_MUTEX_USE_UNION 0
57#else
58# define __PTHREAD_MUTEX_NUSERS_AFTER_KIND 1
59# define __PTHREAD_MUTEX_USE_UNION 1
60#endif
61
62#define __LOCK_ALIGNMENT
63#define __ONCE_ALIGNMENT
64
65struct __pthread_rwlock_arch_t
66{
67 unsigned int __readers;
68 unsigned int __writers;
69 unsigned int __wrphase_futex;
70 unsigned int __writers_futex;
71 unsigned int __pad3;
72 unsigned int __pad4;
73#ifdef __x86_64__
74 int __cur_writer;
75 int __shared;
76 signed char __rwelision;
77# ifdef __ILP32__
78 unsigned char __pad1[3];
79# define __PTHREAD_RWLOCK_ELISION_EXTRA 0, { 0, 0, 0 }
80# else
81 unsigned char __pad1[7];
82# define __PTHREAD_RWLOCK_ELISION_EXTRA 0, { 0, 0, 0, 0, 0, 0, 0 }
83# endif
84 unsigned long int __pad2;
85 /* FLAGS must stay at this position in the structure to maintain
86 binary compatibility. */
87 unsigned int __flags;
88# define __PTHREAD_RWLOCK_INT_FLAGS_SHARED 1
89#else
90 /* FLAGS must stay at this position in the structure to maintain
91 binary compatibility. */
92 unsigned char __flags;
93 unsigned char __shared;
94 signed char __rwelision;
95# define __PTHREAD_RWLOCK_ELISION_EXTRA 0
96 unsigned char __pad2;
97 int __cur_writer;
98#endif
99};
100
101#ifndef __x86_64__
102/* Extra attributes for the cleanup functions. */
103# define __cleanup_fct_attribute __attribute__ ((__regparm__ (1)))
104#endif
105
106#endif /* bits/pthreadtypes.h */
libc/glibc/sysdeps/x86/sysdep.h created+113
...@@ -0,0 +1,113 @@
1/* Assembler macros for x86.
2 Copyright (C) 2017-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _X86_SYSDEP_H
20#define _X86_SYSDEP_H 1
21
22#include <sysdeps/generic/sysdep.h>
23
24/* __CET__ is defined by GCC with Control-Flow Protection values:
25
26enum cf_protection_level
27{
28 CF_NONE = 0,
29 CF_BRANCH = 1 << 0,
30 CF_RETURN = 1 << 1,
31 CF_FULL = CF_BRANCH | CF_RETURN,
32 CF_SET = 1 << 2
33};
34*/
35
36/* Set if CF_BRANCH (IBT) is enabled. */
37#define X86_FEATURE_1_IBT (1U << 0)
38/* Set if CF_RETURN (SHSTK) is enabled. */
39#define X86_FEATURE_1_SHSTK (1U << 1)
40
41#ifdef __CET__
42# define CET_ENABLED 1
43# define IBT_ENABLED (__CET__ & X86_FEATURE_1_IBT)
44# define SHSTK_ENABLED (__CET__ & X86_FEATURE_1_SHSTK)
45#else
46# define CET_ENABLED 0
47# define IBT_ENABLED 0
48# define SHSTK_ENABLED 0
49#endif
50
51/* Offset for fxsave/xsave area used by _dl_runtime_resolve. Also need
52 space to preserve RCX, RDX, RSI, RDI, R8, R9 and RAX. It must be
53 aligned to 16 bytes for fxsave and 64 bytes for xsave. */
54#define STATE_SAVE_OFFSET (8 * 7 + 8)
55
56/* Save SSE, AVX, AVX512, mask and bound registers. */
57#define STATE_SAVE_MASK \
58 ((1 << 1) | (1 << 2) | (1 << 3) | (1 << 5) | (1 << 6) | (1 << 7))
59
60#ifdef __ASSEMBLER__
61
62/* Syntactic details of assembler. */
63
64#ifdef _CET_ENDBR
65# define _CET_NOTRACK notrack
66#else
67# define _CET_ENDBR
68# define _CET_NOTRACK
69#endif
70
71/* ELF uses byte-counts for .align, most others use log2 of count of bytes. */
72#define ALIGNARG(log2) 1<<log2
73#define ASM_SIZE_DIRECTIVE(name) .size name,.-name;
74
75/* Define an entry point visible from C. */
76#define ENTRY(name) \
77 .globl C_SYMBOL_NAME(name); \
78 .type C_SYMBOL_NAME(name),@function; \
79 .align ALIGNARG(4); \
80 C_LABEL(name) \
81 cfi_startproc; \
82 _CET_ENDBR; \
83 CALL_MCOUNT
84
85#undef END
86#define END(name) \
87 cfi_endproc; \
88 ASM_SIZE_DIRECTIVE(name)
89
90#define ENTRY_CHK(name) ENTRY (name)
91#define END_CHK(name) END (name)
92
93/* Since C identifiers are not normally prefixed with an underscore
94 on this system, the asm identifier `syscall_error' intrudes on the
95 C name space. Make sure we use an innocuous name. */
96#define syscall_error __syscall_error
97#define mcount _mcount
98
99#undef PSEUDO_END
100#define PSEUDO_END(name) \
101 END (name)
102
103/* Local label name for asm code. */
104#ifndef L
105/* ELF-like local names start with `.L'. */
106# define L(name) .L##name
107#endif
108
109#define atom_text_section .section ".text.atom", "ax"
110
111#endif /* __ASSEMBLER__ */
112
113#endif /* _X86_SYSDEP_H */
libc/glibc/sysdeps/x86_64/crti.S created+84
...@@ -0,0 +1,84 @@
1/* Special .init and .fini section support for x86-64.
2 Copyright (C) 2012-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library; if not, see
34 <http://www.gnu.org/licenses/>. */
35
36/* crti.S puts a function prologue at the beginning of the .init and
37 .fini sections and defines global symbols for those addresses, so
38 they can be called as functions. The symbols _init and _fini are
39 magic and cause the linker to emit DT_INIT and DT_FINI. */
40
41#include <libc-symbols.h>
42#include <sysdep.h>
43
44#ifndef PREINIT_FUNCTION
45# define PREINIT_FUNCTION __gmon_start__
46#endif
47
48#ifndef PREINIT_FUNCTION_WEAK
49# define PREINIT_FUNCTION_WEAK 1
50#endif
51
52#if PREINIT_FUNCTION_WEAK
53 weak_extern (PREINIT_FUNCTION)
54#else
55 .hidden PREINIT_FUNCTION
56#endif
57
58 .section .init,"ax",@progbits
59 .p2align 2
60 .globl _init
61 .hidden _init
62 .type _init, @function
63_init:
64 _CET_ENDBR
65 /* Maintain 16-byte stack alignment for called functions. */
66 subq $8, %rsp
67#if PREINIT_FUNCTION_WEAK
68 movq PREINIT_FUNCTION@GOTPCREL(%rip), %rax
69 testq %rax, %rax
70 je .Lno_weak_fn
71 call *%rax
72.Lno_weak_fn:
73#else
74 call PREINIT_FUNCTION
75#endif
76
77 .section .fini,"ax",@progbits
78 .p2align 2
79 .globl _fini
80 .hidden _fini
81 .type _fini, @function
82_fini:
83 _CET_ENDBR
84 subq $8, %rsp
libc/glibc/sysdeps/x86_64/crtn.S created+45
...@@ -0,0 +1,45 @@
1/* Special .init and .fini section support for x86-64.
2 Copyright (C) 2012-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library; if not, see
34 <http://www.gnu.org/licenses/>. */
35
36/* crtn.S puts function epilogues in the .init and .fini sections
37 corresponding to the prologues in crti.S. */
38
39 .section .init,"ax",@progbits
40 addq $8, %rsp
41 ret
42
43 .section .fini,"ax",@progbits
44 addq $8, %rsp
45 ret
libc/glibc/sysdeps/x86_64/stackinfo.h created+43
...@@ -0,0 +1,43 @@
1/* Copyright (C) 2001-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/* This file contains a bit of information about the stack allocation
19 of the processor. */
20
21#ifndef _STACKINFO_H
22#define _STACKINFO_H 1
23
24#include <elf.h>
25
26/* On x86_64 the stack grows down. */
27#define _STACK_GROWS_DOWN 1
28
29/* Default to an executable stack. PF_X can be overridden if PT_GNU_STACK is
30 * present, but it is presumed absent. */
31#define DEFAULT_STACK_PERMS (PF_R|PF_W|PF_X)
32
33/* Access to the stack pointer. The macros are used in alloca_account
34 for which they need to act as barriers as well, hence the additional
35 (unnecessary) parameters. */
36#define stackinfo_get_sp() \
37 ({ void *p__; asm volatile ("mov %%" RSP_LP ", %0" : "=r" (p__)); p__; })
38#define stackinfo_sub_sp(ptr) \
39 ({ ptrdiff_t d__; \
40 asm volatile ("sub %%" RSP_LP " , %0" : "=r" (d__) : "0" (ptr)); \
41 d__; })
42
43#endif /* stackinfo.h */
libc/glibc/sysdeps/x86_64/start.S created+131
...@@ -0,0 +1,131 @@
1/* Startup code compliant to the ELF x86-64 ABI.
2 Copyright (C) 2001-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Andreas Jaeger <aj@suse.de>, 2001.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 In addition to the permissions in the GNU Lesser General Public
12 License, the Free Software Foundation gives you unlimited
13 permission to link the compiled version of this file with other
14 programs, and to distribute those programs without any restriction
15 coming from the use of this file. (The GNU Lesser General Public
16 License restrictions do apply in other respects; for example, they
17 cover modification of the file, and distribution when not linked
18 into another program.)
19
20 Note that people who make modified versions of this file are not
21 obligated to grant this special exception for their modified
22 versions; it is their choice whether to do so. The GNU Lesser
23 General Public License gives permission to release a modified
24 version without this exception; this exception also makes it
25 possible to release a modified version which carries forward this
26 exception.
27
28 The GNU C Library is distributed in the hope that it will be useful,
29 but WITHOUT ANY WARRANTY; without even the implied warranty of
30 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
31 Lesser General Public License for more details.
32
33 You should have received a copy of the GNU Lesser General Public
34 License along with the GNU C Library; if not, see
35 <http://www.gnu.org/licenses/>. */
36
37/* This is the canonical entry point, usually the first thing in the text
38 segment. The SVR4/i386 ABI (pages 3-31, 3-32) says that when the entry
39 point runs, most registers' values are unspecified, except for:
40
41 %rdx Contains a function pointer to be registered with `atexit'.
42 This is how the dynamic linker arranges to have DT_FINI
43 functions called for shared libraries that have been loaded
44 before this code runs.
45
46 %rsp The stack contains the arguments and environment:
47 0(%rsp) argc
48 LP_SIZE(%rsp) argv[0]
49 ...
50 (LP_SIZE*argc)(%rsp) NULL
51 (LP_SIZE*(argc+1))(%rsp) envp[0]
52 ...
53 NULL
54*/
55
56#include <sysdep.h>
57
58ENTRY (_start)
59 /* Clearing frame pointer is insufficient, use CFI. */
60 cfi_undefined (rip)
61 /* Clear the frame pointer. The ABI suggests this be done, to mark
62 the outermost frame obviously. */
63 xorl %ebp, %ebp
64
65 /* Extract the arguments as encoded on the stack and set up
66 the arguments for __libc_start_main (int (*main) (int, char **, char **),
67 int argc, char *argv,
68 void (*init) (void), void (*fini) (void),
69 void (*rtld_fini) (void), void *stack_end).
70 The arguments are passed via registers and on the stack:
71 main: %rdi
72 argc: %rsi
73 argv: %rdx
74 init: %rcx
75 fini: %r8
76 rtld_fini: %r9
77 stack_end: stack. */
78
79 mov %RDX_LP, %R9_LP /* Address of the shared library termination
80 function. */
81#ifdef __ILP32__
82 mov (%rsp), %esi /* Simulate popping 4-byte argument count. */
83 add $4, %esp
84#else
85 popq %rsi /* Pop the argument count. */
86#endif
87 /* argv starts just at the current stack top. */
88 mov %RSP_LP, %RDX_LP
89 /* Align the stack to a 16 byte boundary to follow the ABI. */
90 and $~15, %RSP_LP
91
92 /* Push garbage because we push 8 more bytes. */
93 pushq %rax
94
95 /* Provide the highest stack address to the user code (for stacks
96 which grow downwards). */
97 pushq %rsp
98
99#ifdef PIC
100 /* Pass address of our own entry points to .fini and .init. */
101 mov __libc_csu_fini@GOTPCREL(%rip), %R8_LP
102 mov __libc_csu_init@GOTPCREL(%rip), %RCX_LP
103
104 mov main@GOTPCREL(%rip), %RDI_LP
105#else
106 /* Pass address of our own entry points to .fini and .init. */
107 mov $__libc_csu_fini, %R8_LP
108 mov $__libc_csu_init, %RCX_LP
109
110 mov $main, %RDI_LP
111#endif
112
113 /* Call the user's main function, and exit with its value.
114 But let the libc call main. Since __libc_start_main in
115 libc.so is called very early, lazy binding isn't relevant
116 here. Use indirect branch via GOT to avoid extra branch
117 to PLT slot. In case of static executable, ld in binutils
118 2.26 or above can convert indirect branch into direct
119 branch. */
120 call *__libc_start_main@GOTPCREL(%rip)
121
122 hlt /* Crash if somehow `exit' does return. */
123END (_start)
124
125/* Define a symbol for the first piece of initialized data. */
126 .data
127 .globl __data_start
128__data_start:
129 .long 0
130 .weak data_start
131 data_start = __data_start
libc/glibc/sysdeps/x86_64/sysdep.h created+129
...@@ -0,0 +1,129 @@
1/* Assembler macros for x86-64.
2 Copyright (C) 2001-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _X86_64_SYSDEP_H
20#define _X86_64_SYSDEP_H 1
21
22#include <sysdeps/x86/sysdep.h>
23
24#ifdef __ASSEMBLER__
25
26/* Syntactic details of assembler. */
27
28/* This macro is for setting proper CFI with DW_CFA_expression describing
29 the register as saved relative to %rsp instead of relative to the CFA.
30 Expression is DW_OP_drop, DW_OP_breg7 (%rsp is register 7), sleb128 offset
31 from %rsp. */
32#define cfi_offset_rel_rsp(regn, off) .cfi_escape 0x10, regn, 0x4, 0x13, \
33 0x77, off & 0x7F | 0x80, off >> 7
34
35/* If compiled for profiling, call `mcount' at the start of each function. */
36#ifdef PROF
37/* The mcount code relies on a normal frame pointer being on the stack
38 to locate our caller, so push one just for its benefit. */
39#define CALL_MCOUNT \
40 pushq %rbp; \
41 cfi_adjust_cfa_offset(8); \
42 movq %rsp, %rbp; \
43 cfi_def_cfa_register(%rbp); \
44 call JUMPTARGET(mcount); \
45 popq %rbp; \
46 cfi_def_cfa(rsp,8);
47#else
48#define CALL_MCOUNT /* Do nothing. */
49#endif
50
51#define PSEUDO(name, syscall_name, args) \
52lose: \
53 jmp JUMPTARGET(syscall_error) \
54 .globl syscall_error; \
55 ENTRY (name) \
56 DO_CALL (syscall_name, args); \
57 jb lose
58
59#undef JUMPTARGET
60#ifdef SHARED
61# ifdef BIND_NOW
62# define JUMPTARGET(name) *name##@GOTPCREL(%rip)
63# else
64# define JUMPTARGET(name) name##@PLT
65# endif
66#else
67/* For static archives, branch to target directly. */
68# define JUMPTARGET(name) name
69#endif
70
71/* Long and pointer size in bytes. */
72#define LP_SIZE 8
73
74/* Instruction to operate on long and pointer. */
75#define LP_OP(insn) insn##q
76
77/* Assembler address directive. */
78#define ASM_ADDR .quad
79
80/* Registers to hold long and pointer. */
81#define RAX_LP rax
82#define RBP_LP rbp
83#define RBX_LP rbx
84#define RCX_LP rcx
85#define RDI_LP rdi
86#define RDX_LP rdx
87#define RSI_LP rsi
88#define RSP_LP rsp
89#define R8_LP r8
90#define R9_LP r9
91#define R10_LP r10
92#define R11_LP r11
93#define R12_LP r12
94#define R13_LP r13
95#define R14_LP r14
96#define R15_LP r15
97
98#else /* __ASSEMBLER__ */
99
100/* Long and pointer size in bytes. */
101#define LP_SIZE "8"
102
103/* Instruction to operate on long and pointer. */
104#define LP_OP(insn) #insn "q"
105
106/* Assembler address directive. */
107#define ASM_ADDR ".quad"
108
109/* Registers to hold long and pointer. */
110#define RAX_LP "rax"
111#define RBP_LP "rbp"
112#define RBX_LP "rbx"
113#define RCX_LP "rcx"
114#define RDI_LP "rdi"
115#define RDX_LP "rdx"
116#define RSI_LP "rsi"
117#define RSP_LP "rsp"
118#define R8_LP "r8"
119#define R9_LP "r9"
120#define R10_LP "r10"
121#define R11_LP "r11"
122#define R12_LP "r12"
123#define R13_LP "r13"
124#define R14_LP "r14"
125#define R15_LP "r15"
126
127#endif /* __ASSEMBLER__ */
128
129#endif /* _X86_64_SYSDEP_H */
libc/glibc/time/bits/types/clock_t.h created+9
...@@ -0,0 +1,9 @@
1#ifndef __clock_t_defined
2#define __clock_t_defined 1
3
4#include <bits/types.h>
5
6/* Returned by `clock'. */
7typedef __clock_t clock_t;
8
9#endif
libc/glibc/time/bits/types/clockid_t.h created+9
...@@ -0,0 +1,9 @@
1#ifndef __clockid_t_defined
2#define __clockid_t_defined 1
3
4#include <bits/types.h>
5
6/* Clock ID used in clock and timer functions. */
7typedef __clockid_t clockid_t;
8
9#endif
libc/glibc/time/bits/types/struct_itimerspec.h created+14
...@@ -0,0 +1,14 @@
1#ifndef __itimerspec_defined
2#define __itimerspec_defined 1
3
4#include <bits/types.h>
5#include <bits/types/struct_timespec.h>
6
7/* POSIX.1b structure for timer start values and intervals. */
8struct itimerspec
9 {
10 struct timespec it_interval;
11 struct timespec it_value;
12 };
13
14#endif
libc/glibc/time/bits/types/struct_timespec.h created+15
...@@ -0,0 +1,15 @@
1/* NB: Include guard matches what <linux/time.h> uses. */
2#ifndef _STRUCT_TIMESPEC
3#define _STRUCT_TIMESPEC 1
4
5#include <bits/types.h>
6
7/* POSIX.1b structure for a time value. This is like a `struct timeval' but
8 has nanoseconds instead of microseconds. */
9struct timespec
10{
11 __time_t tv_sec; /* Seconds. */
12 __syscall_slong_t tv_nsec; /* Nanoseconds. */
13};
14
15#endif
libc/glibc/time/bits/types/struct_timeval.h created+13
...@@ -0,0 +1,13 @@
1#ifndef __timeval_defined
2#define __timeval_defined 1
3
4#include <bits/types.h>
5
6/* A time value that is accurate to the nearest
7 microsecond but also has a range of years. */
8struct timeval
9{
10 __time_t tv_sec; /* Seconds. */
11 __suseconds_t tv_usec; /* Microseconds. */
12};
13#endif
libc/glibc/time/bits/types/struct_tm.h created+28
...@@ -0,0 +1,28 @@
1#ifndef __struct_tm_defined
2#define __struct_tm_defined 1
3
4#include <bits/types.h>
5
6/* ISO C `broken-down time' structure. */
7struct tm
8{
9 int tm_sec; /* Seconds. [0-60] (1 leap second) */
10 int tm_min; /* Minutes. [0-59] */
11 int tm_hour; /* Hours. [0-23] */
12 int tm_mday; /* Day. [1-31] */
13 int tm_mon; /* Month. [0-11] */
14 int tm_year; /* Year - 1900. */
15 int tm_wday; /* Day of week. [0-6] */
16 int tm_yday; /* Days in year.[0-365] */
17 int tm_isdst; /* DST. [-1/0/1]*/
18
19# ifdef __USE_MISC
20 long int tm_gmtoff; /* Seconds east of UTC. */
21 const char *tm_zone; /* Timezone abbreviation. */
22# else
23 long int __tm_gmtoff; /* Seconds east of UTC. */
24 const char *__tm_zone; /* Timezone abbreviation. */
25# endif
26};
27
28#endif
libc/glibc/time/bits/types/time_t.h created+9
...@@ -0,0 +1,9 @@
1#ifndef __time_t_defined
2#define __time_t_defined 1
3
4#include <bits/types.h>
5
6/* Returned by `time'. */
7typedef __time_t time_t;
8
9#endif
libc/glibc/time/bits/types/timer_t.h created+9
...@@ -0,0 +1,9 @@
1#ifndef __timer_t_defined
2#define __timer_t_defined 1
3
4#include <bits/types.h>
5
6/* Timer ID returned by `timer_create'. */
7typedef __timer_t timer_t;
8
9#endif
libc/glibc/time/sys/time.h created+188
...@@ -0,0 +1,188 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_TIME_H
19#define _SYS_TIME_H 1
20
21#include <features.h>
22
23#include <bits/types.h>
24#include <bits/types/time_t.h>
25#include <bits/types/struct_timeval.h>
26
27#ifndef __suseconds_t_defined
28typedef __suseconds_t suseconds_t;
29# define __suseconds_t_defined
30#endif
31
32#include <sys/select.h>
33
34__BEGIN_DECLS
35
36#ifdef __USE_GNU
37/* Macros for converting between `struct timeval' and `struct timespec'. */
38# define TIMEVAL_TO_TIMESPEC(tv, ts) { \
39 (ts)->tv_sec = (tv)->tv_sec; \
40 (ts)->tv_nsec = (tv)->tv_usec * 1000; \
41}
42# define TIMESPEC_TO_TIMEVAL(tv, ts) { \
43 (tv)->tv_sec = (ts)->tv_sec; \
44 (tv)->tv_usec = (ts)->tv_nsec / 1000; \
45}
46#endif
47
48
49#ifdef __USE_MISC
50/* Structure crudely representing a timezone.
51 This is obsolete and should never be used. */
52struct timezone
53 {
54 int tz_minuteswest; /* Minutes west of GMT. */
55 int tz_dsttime; /* Nonzero if DST is ever in effect. */
56 };
57
58typedef struct timezone *__restrict __timezone_ptr_t;
59#else
60typedef void *__restrict __timezone_ptr_t;
61#endif
62
63/* Get the current time of day and timezone information,
64 putting it into *TV and *TZ. If TZ is NULL, *TZ is not filled.
65 Returns 0 on success, -1 on errors.
66 NOTE: This form of timezone information is obsolete.
67 Use the functions and variables declared in <time.h> instead. */
68extern int gettimeofday (struct timeval *__restrict __tv,
69 __timezone_ptr_t __tz) __THROW __nonnull ((1));
70
71#ifdef __USE_MISC
72/* Set the current time of day and timezone information.
73 This call is restricted to the super-user. */
74extern int settimeofday (const struct timeval *__tv,
75 const struct timezone *__tz)
76 __THROW;
77
78/* Adjust the current time of day by the amount in DELTA.
79 If OLDDELTA is not NULL, it is filled in with the amount
80 of time adjustment remaining to be done from the last `adjtime' call.
81 This call is restricted to the super-user. */
82extern int adjtime (const struct timeval *__delta,
83 struct timeval *__olddelta) __THROW;
84#endif
85
86
87/* Values for the first argument to `getitimer' and `setitimer'. */
88enum __itimer_which
89 {
90 /* Timers run in real time. */
91 ITIMER_REAL = 0,
92#define ITIMER_REAL ITIMER_REAL
93 /* Timers run only when the process is executing. */
94 ITIMER_VIRTUAL = 1,
95#define ITIMER_VIRTUAL ITIMER_VIRTUAL
96 /* Timers run when the process is executing and when
97 the system is executing on behalf of the process. */
98 ITIMER_PROF = 2
99#define ITIMER_PROF ITIMER_PROF
100 };
101
102/* Type of the second argument to `getitimer' and
103 the second and third arguments `setitimer'. */
104struct itimerval
105 {
106 /* Value to put into `it_value' when the timer expires. */
107 struct timeval it_interval;
108 /* Time to the next timer expiration. */
109 struct timeval it_value;
110 };
111
112#if defined __USE_GNU && !defined __cplusplus
113/* Use the nicer parameter type only in GNU mode and not for C++ since the
114 strict C++ rules prevent the automatic promotion. */
115typedef enum __itimer_which __itimer_which_t;
116#else
117typedef int __itimer_which_t;
118#endif
119
120/* Set *VALUE to the current setting of timer WHICH.
121 Return 0 on success, -1 on errors. */
122extern int getitimer (__itimer_which_t __which,
123 struct itimerval *__value) __THROW;
124
125/* Set the timer WHICH to *NEW. If OLD is not NULL,
126 set *OLD to the old value of timer WHICH.
127 Returns 0 on success, -1 on errors. */
128extern int setitimer (__itimer_which_t __which,
129 const struct itimerval *__restrict __new,
130 struct itimerval *__restrict __old) __THROW;
131
132/* Change the access time of FILE to TVP[0] and the modification time of
133 FILE to TVP[1]. If TVP is a null pointer, use the current time instead.
134 Returns 0 on success, -1 on errors. */
135extern int utimes (const char *__file, const struct timeval __tvp[2])
136 __THROW __nonnull ((1));
137
138#ifdef __USE_MISC
139/* Same as `utimes', but does not follow symbolic links. */
140extern int lutimes (const char *__file, const struct timeval __tvp[2])
141 __THROW __nonnull ((1));
142
143/* Same as `utimes', but takes an open file descriptor instead of a name. */
144extern int futimes (int __fd, const struct timeval __tvp[2]) __THROW;
145#endif
146
147#ifdef __USE_GNU
148/* Change the access time of FILE relative to FD to TVP[0] and the
149 modification time of FILE to TVP[1]. If TVP is a null pointer, use
150 the current time instead. Returns 0 on success, -1 on errors. */
151extern int futimesat (int __fd, const char *__file,
152 const struct timeval __tvp[2]) __THROW;
153#endif
154
155
156#ifdef __USE_MISC
157/* Convenience macros for operations on timevals.
158 NOTE: `timercmp' does not work for >= or <=. */
159# define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
160# define timerclear(tvp) ((tvp)->tv_sec = (tvp)->tv_usec = 0)
161# define timercmp(a, b, CMP) \
162 (((a)->tv_sec == (b)->tv_sec) ? \
163 ((a)->tv_usec CMP (b)->tv_usec) : \
164 ((a)->tv_sec CMP (b)->tv_sec))
165# define timeradd(a, b, result) \
166 do { \
167 (result)->tv_sec = (a)->tv_sec + (b)->tv_sec; \
168 (result)->tv_usec = (a)->tv_usec + (b)->tv_usec; \
169 if ((result)->tv_usec >= 1000000) \
170 { \
171 ++(result)->tv_sec; \
172 (result)->tv_usec -= 1000000; \
173 } \
174 } while (0)
175# define timersub(a, b, result) \
176 do { \
177 (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
178 (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
179 if ((result)->tv_usec < 0) { \
180 --(result)->tv_sec; \
181 (result)->tv_usec += 1000000; \
182 } \
183 } while (0)
184#endif /* Misc. */
185
186__END_DECLS
187
188#endif /* sys/time.h */
libc/glibc/time/time.h created+309
...@@ -0,0 +1,309 @@
1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/*
19 * ISO C99 Standard: 7.23 Date and time <time.h>
20 */
21
22#ifndef _TIME_H
23#define _TIME_H 1
24
25#include <features.h>
26
27#define __need_size_t
28#define __need_NULL
29#include <stddef.h>
30
31/* This defines CLOCKS_PER_SEC, which is the number of processor clock
32 ticks per second, and possibly a number of other constants. */
33#include <bits/time.h>
34
35/* Many of the typedefs and structs whose official home is this header
36 may also need to be defined by other headers. */
37#include <bits/types/clock_t.h>
38#include <bits/types/time_t.h>
39#include <bits/types/struct_tm.h>
40
41#if defined __USE_POSIX199309 || defined __USE_ISOC11
42# include <bits/types/struct_timespec.h>
43#endif
44
45#ifdef __USE_POSIX199309
46# include <bits/types/clockid_t.h>
47# include <bits/types/timer_t.h>
48# include <bits/types/struct_itimerspec.h>
49struct sigevent;
50#endif
51
52#ifdef __USE_XOPEN2K
53# ifndef __pid_t_defined
54typedef __pid_t pid_t;
55# define __pid_t_defined
56# endif
57#endif
58
59#ifdef __USE_XOPEN2K8
60# include <bits/types/locale_t.h>
61#endif
62
63#ifdef __USE_ISOC11
64/* Time base values for timespec_get. */
65# define TIME_UTC 1
66#endif
67
68__BEGIN_DECLS
69
70/* Time used by the program so far (user time + system time).
71 The result / CLOCKS_PER_SEC is program time in seconds. */
72extern clock_t clock (void) __THROW;
73
74/* Return the current time and put it in *TIMER if TIMER is not NULL. */
75extern time_t time (time_t *__timer) __THROW;
76
77/* Return the difference between TIME1 and TIME0. */
78extern double difftime (time_t __time1, time_t __time0)
79 __THROW __attribute__ ((__const__));
80
81/* Return the `time_t' representation of TP and normalize TP. */
82extern time_t mktime (struct tm *__tp) __THROW;
83
84
85/* Format TP into S according to FORMAT.
86 Write no more than MAXSIZE characters and return the number
87 of characters written, or 0 if it would exceed MAXSIZE. */
88extern size_t strftime (char *__restrict __s, size_t __maxsize,
89 const char *__restrict __format,
90 const struct tm *__restrict __tp) __THROW;
91
92#ifdef __USE_XOPEN
93/* Parse S according to FORMAT and store binary time information in TP.
94 The return value is a pointer to the first unparsed character in S. */
95extern char *strptime (const char *__restrict __s,
96 const char *__restrict __fmt, struct tm *__tp)
97 __THROW;
98#endif
99
100#ifdef __USE_XOPEN2K8
101/* Similar to the two functions above but take the information from
102 the provided locale and not the global locale. */
103
104extern size_t strftime_l (char *__restrict __s, size_t __maxsize,
105 const char *__restrict __format,
106 const struct tm *__restrict __tp,
107 locale_t __loc) __THROW;
108#endif
109
110#ifdef __USE_GNU
111extern char *strptime_l (const char *__restrict __s,
112 const char *__restrict __fmt, struct tm *__tp,
113 locale_t __loc) __THROW;
114#endif
115
116
117/* Return the `struct tm' representation of *TIMER
118 in Universal Coordinated Time (aka Greenwich Mean Time). */
119extern struct tm *gmtime (const time_t *__timer) __THROW;
120
121/* Return the `struct tm' representation
122 of *TIMER in the local timezone. */
123extern struct tm *localtime (const time_t *__timer) __THROW;
124
125#ifdef __USE_POSIX
126/* Return the `struct tm' representation of *TIMER in UTC,
127 using *TP to store the result. */
128extern struct tm *gmtime_r (const time_t *__restrict __timer,
129 struct tm *__restrict __tp) __THROW;
130
131/* Return the `struct tm' representation of *TIMER in local time,
132 using *TP to store the result. */
133extern struct tm *localtime_r (const time_t *__restrict __timer,
134 struct tm *__restrict __tp) __THROW;
135#endif /* POSIX */
136
137/* Return a string of the form "Day Mon dd hh:mm:ss yyyy\n"
138 that is the representation of TP in this format. */
139extern char *asctime (const struct tm *__tp) __THROW;
140
141/* Equivalent to `asctime (localtime (timer))'. */
142extern char *ctime (const time_t *__timer) __THROW;
143
144#ifdef __USE_POSIX
145/* Reentrant versions of the above functions. */
146
147/* Return in BUF a string of the form "Day Mon dd hh:mm:ss yyyy\n"
148 that is the representation of TP in this format. */
149extern char *asctime_r (const struct tm *__restrict __tp,
150 char *__restrict __buf) __THROW;
151
152/* Equivalent to `asctime_r (localtime_r (timer, *TMP*), buf)'. */
153extern char *ctime_r (const time_t *__restrict __timer,
154 char *__restrict __buf) __THROW;
155#endif /* POSIX */
156
157
158/* Defined in localtime.c. */
159extern char *__tzname[2]; /* Current timezone names. */
160extern int __daylight; /* If daylight-saving time is ever in use. */
161extern long int __timezone; /* Seconds west of UTC. */
162
163
164#ifdef __USE_POSIX
165/* Same as above. */
166extern char *tzname[2];
167
168/* Set time conversion information from the TZ environment variable.
169 If TZ is not defined, a locale-dependent default is used. */
170extern void tzset (void) __THROW;
171#endif
172
173#if defined __USE_MISC || defined __USE_XOPEN
174extern int daylight;
175extern long int timezone;
176#endif
177
178#ifdef __USE_MISC
179/* Set the system time to *WHEN.
180 This call is restricted to the superuser. */
181extern int stime (const time_t *__when) __THROW;
182#endif
183
184
185/* Nonzero if YEAR is a leap year (every 4 years,
186 except every 100th isn't, and every 400th is). */
187#define __isleap(year) \
188 ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0))
189
190
191#ifdef __USE_MISC
192/* Miscellaneous functions many Unices inherited from the public domain
193 localtime package. These are included only for compatibility. */
194
195/* Like `mktime', but for TP represents Universal Time, not local time. */
196extern time_t timegm (struct tm *__tp) __THROW;
197
198/* Another name for `mktime'. */
199extern time_t timelocal (struct tm *__tp) __THROW;
200
201/* Return the number of days in YEAR. */
202extern int dysize (int __year) __THROW __attribute__ ((__const__));
203#endif
204
205
206#ifdef __USE_POSIX199309
207/* Pause execution for a number of nanoseconds.
208
209 This function is a cancellation point and therefore not marked with
210 __THROW. */
211extern int nanosleep (const struct timespec *__requested_time,
212 struct timespec *__remaining);
213
214
215/* Get resolution of clock CLOCK_ID. */
216extern int clock_getres (clockid_t __clock_id, struct timespec *__res) __THROW;
217
218/* Get current value of clock CLOCK_ID and store it in TP. */
219extern int clock_gettime (clockid_t __clock_id, struct timespec *__tp) __THROW;
220
221/* Set clock CLOCK_ID to value TP. */
222extern int clock_settime (clockid_t __clock_id, const struct timespec *__tp)
223 __THROW;
224
225# ifdef __USE_XOPEN2K
226/* High-resolution sleep with the specified clock.
227
228 This function is a cancellation point and therefore not marked with
229 __THROW. */
230extern int clock_nanosleep (clockid_t __clock_id, int __flags,
231 const struct timespec *__req,
232 struct timespec *__rem);
233
234/* Return clock ID for CPU-time clock. */
235extern int clock_getcpuclockid (pid_t __pid, clockid_t *__clock_id) __THROW;
236# endif
237
238
239/* Create new per-process timer using CLOCK_ID. */
240extern int timer_create (clockid_t __clock_id,
241 struct sigevent *__restrict __evp,
242 timer_t *__restrict __timerid) __THROW;
243
244/* Delete timer TIMERID. */
245extern int timer_delete (timer_t __timerid) __THROW;
246
247/* Set timer TIMERID to VALUE, returning old value in OVALUE. */
248extern int timer_settime (timer_t __timerid, int __flags,
249 const struct itimerspec *__restrict __value,
250 struct itimerspec *__restrict __ovalue) __THROW;
251
252/* Get current value of timer TIMERID and store it in VALUE. */
253extern int timer_gettime (timer_t __timerid, struct itimerspec *__value)
254 __THROW;
255
256/* Get expiration overrun for timer TIMERID. */
257extern int timer_getoverrun (timer_t __timerid) __THROW;
258#endif
259
260
261#ifdef __USE_ISOC11
262/* Set TS to calendar time based in time base BASE. */
263extern int timespec_get (struct timespec *__ts, int __base)
264 __THROW __nonnull ((1));
265#endif
266
267
268#ifdef __USE_XOPEN_EXTENDED
269/* Set to one of the following values to indicate an error.
270 1 the DATEMSK environment variable is null or undefined,
271 2 the template file cannot be opened for reading,
272 3 failed to get file status information,
273 4 the template file is not a regular file,
274 5 an error is encountered while reading the template file,
275 6 memory allication failed (not enough memory available),
276 7 there is no line in the template that matches the input,
277 8 invalid input specification Example: February 31 or a time is
278 specified that can not be represented in a time_t (representing
279 the time in seconds since 00:00:00 UTC, January 1, 1970) */
280extern int getdate_err;
281
282/* Parse the given string as a date specification and return a value
283 representing the value. The templates from the file identified by
284 the environment variable DATEMSK are used. In case of an error
285 `getdate_err' is set.
286
287 This function is a possible cancellation point and therefore not
288 marked with __THROW. */
289extern struct tm *getdate (const char *__string);
290#endif
291
292#ifdef __USE_GNU
293/* Since `getdate' is not reentrant because of the use of `getdate_err'
294 and the static buffer to return the result in, we provide a thread-safe
295 variant. The functionality is the same. The result is returned in
296 the buffer pointed to by RESBUFP and in case of an error the return
297 value is != 0 with the same values as given above for `getdate_err'.
298
299 This function is not part of POSIX and therefore no official
300 cancellation point. But due to similarity with an POSIX interface
301 or due to the implementation it is a cancellation point and
302 therefore not marked with __THROW. */
303extern int getdate_r (const char *__restrict __string,
304 struct tm *__restrict __resbufp);
305#endif
306
307__END_DECLS
308
309#endif /* time.h. */
libc/symbols.zig created+1974
...@@ -0,0 +1,1974 @@
1const builtin = @import("builtin");
2pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn {
3 unreachable;
4}
5
6export fn _Exit() void {}
7export fn _IO_adjust_column() void {}
8export fn _IO_adjust_wcolumn() void {}
9export fn _IO_default_doallocate() void {}
10export fn _IO_default_finish() void {}
11export fn _IO_default_pbackfail() void {}
12export fn _IO_default_uflow() void {}
13export fn _IO_default_xsgetn() void {}
14export fn _IO_default_xsputn() void {}
15export fn _IO_doallocbuf() void {}
16export fn _IO_enable_locks() void {}
17export fn _IO_feof() void {}
18export fn _IO_ferror() void {}
19export fn _IO_fflush() void {}
20export fn _IO_fgets() void {}
21export fn _IO_file_close() void {}
22export fn _IO_file_doallocate() void {}
23export fn _IO_file_open() void {}
24export fn _IO_file_read() void {}
25export fn _IO_file_seek() void {}
26export fn _IO_file_stat() void {}
27export fn _IO_flockfile() void {}
28export fn _IO_flush_all() void {}
29export fn _IO_flush_all_linebuffered() void {}
30export fn _IO_fprintf() void {}
31export fn _IO_fputs() void {}
32export fn _IO_fread() void {}
33export fn _IO_free_backup_area() void {}
34export fn _IO_free_wbackup_area() void {}
35export fn _IO_ftell() void {}
36export fn _IO_ftrylockfile() void {}
37export fn _IO_funlockfile() void {}
38export fn _IO_fwrite() void {}
39export fn _IO_getc() void {}
40export fn _IO_getline() void {}
41export fn _IO_getline_info() void {}
42export fn _IO_gets() void {}
43export fn _IO_init() void {}
44export fn _IO_init_marker() void {}
45export fn _IO_init_wmarker() void {}
46export fn _IO_iter_begin() void {}
47export fn _IO_iter_end() void {}
48export fn _IO_iter_file() void {}
49export fn _IO_iter_next() void {}
50export fn _IO_least_wmarker() void {}
51export fn _IO_link_in() void {}
52export fn _IO_list_lock() void {}
53export fn _IO_list_resetlock() void {}
54export fn _IO_list_unlock() void {}
55export fn _IO_marker_delta() void {}
56export fn _IO_marker_difference() void {}
57export fn _IO_padn() void {}
58export fn _IO_peekc_locked() void {}
59export fn _IO_printf() void {}
60export fn _IO_putc() void {}
61export fn _IO_puts() void {}
62export fn _IO_remove_marker() void {}
63export fn _IO_seekmark() void {}
64export fn _IO_seekoff() void {}
65export fn _IO_seekpos() void {}
66export fn _IO_seekwmark() void {}
67export fn _IO_setb() void {}
68export fn _IO_setbuffer() void {}
69export fn _IO_setvbuf() void {}
70export fn _IO_sgetn() void {}
71export fn _IO_sprintf() void {}
72export fn _IO_sputbackc() void {}
73export fn _IO_sputbackwc() void {}
74export fn _IO_sscanf() void {}
75export fn _IO_str_init_readonly() void {}
76export fn _IO_str_init_static() void {}
77export fn _IO_str_overflow() void {}
78export fn _IO_str_pbackfail() void {}
79export fn _IO_str_seekoff() void {}
80export fn _IO_str_underflow() void {}
81export fn _IO_sungetc() void {}
82export fn _IO_sungetwc() void {}
83export fn _IO_switch_to_get_mode() void {}
84export fn _IO_switch_to_main_wget_area() void {}
85export fn _IO_switch_to_wbackup_area() void {}
86export fn _IO_switch_to_wget_mode() void {}
87export fn _IO_un_link() void {}
88export fn _IO_ungetc() void {}
89export fn _IO_unsave_markers() void {}
90export fn _IO_unsave_wmarkers() void {}
91export fn _IO_vfprintf() void {}
92export fn _IO_vsprintf() void {}
93export fn _IO_wdefault_doallocate() void {}
94export fn _IO_wdefault_finish() void {}
95export fn _IO_wdefault_pbackfail() void {}
96export fn _IO_wdefault_uflow() void {}
97export fn _IO_wdefault_xsgetn() void {}
98export fn _IO_wdefault_xsputn() void {}
99export fn _IO_wdo_write() void {}
100export fn _IO_wdoallocbuf() void {}
101export fn _IO_wfile_overflow() void {}
102export fn _IO_wfile_seekoff() void {}
103export fn _IO_wfile_sync() void {}
104export fn _IO_wfile_underflow() void {}
105export fn _IO_wfile_xsputn() void {}
106export fn _IO_wmarker_delta() void {}
107export fn _IO_wsetb() void {}
108export fn __GI___gettimeofday() void {}
109export fn __GI___mempcpy() void {}
110export fn __GI___rawmemchr() void {}
111export fn __GI___stpcpy() void {}
112export fn __GI___stpncpy() void {}
113export fn __GI___strcasecmp() void {}
114export fn __GI___strcasecmp_l() void {}
115export fn __GI___strncasecmp_l() void {}
116export fn __GI___strncat() void {}
117export fn __GI___strnlen() void {}
118export fn __GI___wcschr() void {}
119export fn __GI___wcscmp() void {}
120export fn __GI___wmemchr() void {}
121export fn __GI___wmemset() void {}
122export fn __GI_gettimeofday() void {}
123export fn __GI_memchr() void {}
124export fn __GI_memcmp() void {}
125export fn __GI_memcpy() void {}
126export fn __GI_memmove() void {}
127export fn __GI_mempcpy() void {}
128export fn __GI_memset() void {}
129export fn __GI_stpcpy() void {}
130export fn __GI_strcat() void {}
131export fn __GI_strchr() void {}
132export fn __GI_strcmp() void {}
133export fn __GI_strcpy() void {}
134export fn __GI_strcspn() void {}
135export fn __GI_strlen() void {}
136export fn __GI_strncmp() void {}
137export fn __GI_strncpy() void {}
138export fn __GI_strnlen() void {}
139export fn __GI_strpbrk() void {}
140export fn __GI_strrchr() void {}
141export fn __GI_strspn() void {}
142export fn __GI_time() void {}
143export fn __GI_wcschr() void {}
144export fn __GI_wmemchr() void {}
145export fn __GI_wmemset() void {}
146export fn __adjtimex() void {}
147export fn __arch_prctl() void {}
148export fn __argz_count() void {}
149export fn __argz_next() void {}
150export fn __argz_stringify() void {}
151export fn __asprintf() void {}
152export fn __asprintf_chk() void {}
153export fn __assert() void {}
154export fn __assert_fail() void {}
155export fn __assert_perror_fail() void {}
156export fn __backtrace() void {}
157export fn __backtrace_symbols() void {}
158export fn __backtrace_symbols_fd() void {}
159export fn __bsd_getpgrp() void {}
160export fn __bzero() void {}
161export fn __call_tls_dtors() void {}
162export fn __chk_fail() void {}
163export fn __clock_getcpuclockid() void {}
164export fn __clock_getres() void {}
165export fn __clock_gettime() void {}
166export fn __clock_nanosleep() void {}
167export fn __clock_settime() void {}
168export fn __clone() void {}
169export fn __close() void {}
170export fn __close_nocancel() void {}
171export fn __cmsg_nxthdr() void {}
172export fn __confstr_chk() void {}
173export fn __connect() void {}
174export fn __copy_grp() void {}
175export fn __ctype_b_loc() void {}
176export fn __ctype_get_mb_cur_max() void {}
177export fn __ctype_init() void {}
178export fn __ctype_tolower_loc() void {}
179export fn __ctype_toupper_loc() void {}
180export fn __cxa_at_quick_exit() void {}
181export fn __cxa_atexit() void {}
182export fn __cxa_finalize() void {}
183export fn __cxa_thread_atexit_impl() void {}
184export fn __cyg_profile_func_enter() void {}
185export fn __cyg_profile_func_exit() void {}
186export fn __dcgettext() void {}
187export fn __default_morecore() void {}
188export fn __dgettext() void {}
189export fn __dprintf_chk() void {}
190export fn __dup2() void {}
191export fn __duplocale() void {}
192export fn __endmntent() void {}
193export fn __errno_location() void {}
194export fn __explicit_bzero_chk() void {}
195export fn __fbufsize() void {}
196export fn __fcntl() void {}
197export fn __fdelt_chk() void {}
198export fn __fdelt_warn() void {}
199export fn __fentry__() void {}
200export fn __ffs() void {}
201export fn __fgets_chk() void {}
202export fn __fgets_unlocked_chk() void {}
203export fn __fgetws_chk() void {}
204export fn __fgetws_unlocked_chk() void {}
205export fn __finite() void {}
206export fn __finitef() void {}
207export fn __finitel() void {}
208export fn __flbf() void {}
209export fn __fork() void {}
210export fn __fortify_fail() void {}
211export fn __fpending() void {}
212export fn __fprintf_chk() void {}
213export fn __fpurge() void {}
214export fn __fread_chk() void {}
215export fn __fread_unlocked_chk() void {}
216export fn __freadable() void {}
217export fn __freading() void {}
218export fn __freelocale() void {}
219export fn __fseeko64() void {}
220export fn __fsetlocking() void {}
221export fn __ftello64() void {}
222export fn __fwprintf_chk() void {}
223export fn __fwritable() void {}
224export fn __fwriting() void {}
225export fn __fxstat() void {}
226export fn __fxstat64() void {}
227export fn __fxstatat() void {}
228export fn __fxstatat64() void {}
229export fn __gai_sigqueue() void {}
230export fn __gconv_get_alias_db() void {}
231export fn __gconv_get_cache() void {}
232export fn __gconv_get_modules_db() void {}
233export fn __gconv_transliterate() void {}
234export fn __getauxval() void {}
235export fn __getcwd_chk() void {}
236export fn __getdelim() void {}
237export fn __getdomainname_chk() void {}
238export fn __getgroups_chk() void {}
239export fn __gethostname_chk() void {}
240export fn __getlogin_r_chk() void {}
241export fn __getmntent_r() void {}
242export fn __getpagesize() void {}
243export fn __getpgid() void {}
244export fn __getpid() void {}
245export fn __getrlimit() void {}
246export fn __gets_chk() void {}
247export fn __gettimeofday() void {}
248export fn __getwd_chk() void {}
249export fn __gmtime_r() void {}
250export fn __h_errno_location() void {}
251export fn __idna_from_dns_encoding() void {}
252export fn __idna_to_dns_encoding() void {}
253export fn __inet6_scopeid_pton() void {}
254export fn __inet_aton_exact() void {}
255export fn __inet_pton_length() void {}
256export fn __internal_endnetgrent() void {}
257export fn __internal_getnetgrent_r() void {}
258export fn __internal_setnetgrent() void {}
259export fn __isalnum_l() void {}
260export fn __isalpha_l() void {}
261export fn __isascii_l() void {}
262export fn __isblank_l() void {}
263export fn __iscntrl_l() void {}
264export fn __isctype() void {}
265export fn __isdigit_l() void {}
266export fn __isgraph_l() void {}
267export fn __isinf() void {}
268export fn __isinff() void {}
269export fn __isinfl() void {}
270export fn __islower_l() void {}
271export fn __isnan() void {}
272export fn __isnanf() void {}
273export fn __isnanl() void {}
274export fn __isoc99_fscanf() void {}
275export fn __isoc99_fwscanf() void {}
276export fn __isoc99_scanf() void {}
277export fn __isoc99_sscanf() void {}
278export fn __isoc99_swscanf() void {}
279export fn __isoc99_vfscanf() void {}
280export fn __isoc99_vfwscanf() void {}
281export fn __isoc99_vscanf() void {}
282export fn __isoc99_vsscanf() void {}
283export fn __isoc99_vswscanf() void {}
284export fn __isoc99_vwscanf() void {}
285export fn __isoc99_wscanf() void {}
286export fn __isprint_l() void {}
287export fn __ispunct_l() void {}
288export fn __isspace_l() void {}
289export fn __isupper_l() void {}
290export fn __iswalnum_l() void {}
291export fn __iswalpha_l() void {}
292export fn __iswblank_l() void {}
293export fn __iswcntrl_l() void {}
294export fn __iswctype() void {}
295export fn __iswctype_l() void {}
296export fn __iswdigit_l() void {}
297export fn __iswgraph_l() void {}
298export fn __iswlower_l() void {}
299export fn __iswprint_l() void {}
300export fn __iswpunct_l() void {}
301export fn __iswspace_l() void {}
302export fn __iswupper_l() void {}
303export fn __iswxdigit_l() void {}
304export fn __isxdigit_l() void {}
305export fn __ivaliduser() void {}
306export fn __libc_alloc_buffer_alloc_array() void {}
307export fn __libc_alloc_buffer_allocate() void {}
308export fn __libc_alloc_buffer_copy_bytes() void {}
309export fn __libc_alloc_buffer_copy_string() void {}
310export fn __libc_alloc_buffer_create_failure() void {}
311export fn __libc_alloca_cutoff() void {}
312export fn __libc_allocate_once_slow() void {}
313export fn __libc_allocate_rtsig() void {}
314export fn __libc_allocate_rtsig_private() void {}
315export fn __libc_calloc() void {}
316export fn __libc_current_sigrtmax() void {}
317export fn __libc_current_sigrtmax_private() void {}
318export fn __libc_current_sigrtmin() void {}
319export fn __libc_current_sigrtmin_private() void {}
320export fn __libc_dlclose() void {}
321export fn __libc_dlopen_mode() void {}
322export fn __libc_dlsym() void {}
323export fn __libc_dlvsym() void {}
324export fn __libc_dynarray_at_failure() void {}
325export fn __libc_dynarray_emplace_enlarge() void {}
326export fn __libc_dynarray_finalize() void {}
327export fn __libc_dynarray_resize() void {}
328export fn __libc_dynarray_resize_clear() void {}
329export fn __libc_fatal() void {}
330export fn __libc_fcntl64() void {}
331export fn __libc_fork() void {}
332export fn __libc_free() void {}
333export fn __libc_freeres() void {}
334export fn __libc_ifunc_impl_list() void {}
335export fn __libc_init_first() void {}
336export fn __libc_longjmp() void {}
337export fn __libc_mallinfo() void {}
338export fn __libc_malloc() void {}
339export fn __libc_mallopt() void {}
340export fn __libc_memalign() void {}
341export fn __libc_memmove() void {}
342export fn __libc_msgrcv() void {}
343export fn __libc_msgsnd() void {}
344export fn __libc_pread() void {}
345export fn __libc_pthread_init() void {}
346export fn __libc_pvalloc() void {}
347export fn __libc_pwrite() void {}
348export fn __libc_readline_unlocked() void {}
349export fn __libc_realloc() void {}
350export fn __libc_reallocarray() void {}
351export fn __libc_sa_len() void {}
352export fn __libc_scratch_buffer_grow() void {}
353export fn __libc_scratch_buffer_grow_preserve() void {}
354export fn __libc_scratch_buffer_set_array_size() void {}
355export fn __libc_secure_getenv() void {}
356export fn __libc_siglongjmp() void {}
357export fn __libc_start_main() void {}
358export fn __libc_strstr() void {}
359export fn __libc_system() void {}
360export fn __libc_thread_freeres() void {}
361export fn __libc_valloc() void {}
362export fn __libc_vfork() void {}
363export fn __longjmp_chk() void {}
364export fn __lseek() void {}
365export fn __lxstat() void {}
366export fn __lxstat64() void {}
367export fn __madvise() void {}
368export fn __mbrlen() void {}
369export fn __mbrtowc() void {}
370export fn __mbsnrtowcs_chk() void {}
371export fn __mbsrtowcs_chk() void {}
372export fn __mbstowcs_chk() void {}
373export fn __memchr() void {}
374export fn __memcpy_chk() void {}
375export fn __memmove_chk() void {}
376export fn __mempcpy() void {}
377export fn __mempcpy_chk() void {}
378export fn __memrchr() void {}
379export fn __memset_chk() void {}
380export fn __merge_grp() void {}
381export fn __mktemp() void {}
382export fn __mmap() void {}
383export fn __monstartup() void {}
384export fn __mprotect() void {}
385export fn __munmap() void {}
386export fn __nanosleep() void {}
387export fn __nanosleep_nocancel() void {}
388export fn __netlink_assert_response() void {}
389export fn __new_memcpy() void {}
390export fn __newlocale() void {}
391export fn __nl_langinfo_l() void {}
392export fn __nss_configure_lookup() void {}
393export fn __nss_database_lookup() void {}
394export fn __nss_disable_nscd() void {}
395export fn __nss_group_lookup2() void {}
396export fn __nss_hash() void {}
397export fn __nss_hostname_digits_dots() void {}
398export fn __nss_hosts_lookup2() void {}
399export fn __nss_lookup() void {}
400export fn __nss_lookup_function() void {}
401export fn __nss_next() void {}
402export fn __nss_next2() void {}
403export fn __nss_passwd_lookup2() void {}
404export fn __nss_services_lookup2() void {}
405export fn __obstack_printf_chk() void {}
406export fn __obstack_vprintf_chk() void {}
407export fn __open() void {}
408export fn __open64() void {}
409export fn __open64_2() void {}
410export fn __open64_nocancel() void {}
411export fn __open_2() void {}
412export fn __open_catalog() void {}
413export fn __open_nocancel() void {}
414export fn __openat64_2() void {}
415export fn __openat_2() void {}
416export fn __overflow() void {}
417export fn __pause_nocancel() void {}
418export fn __pipe() void {}
419export fn __poll() void {}
420export fn __poll_chk() void {}
421export fn __posix_getopt() void {}
422export fn __ppoll_chk() void {}
423export fn __pread64() void {}
424export fn __pread64_chk() void {}
425export fn __pread_chk() void {}
426export fn __printf_chk() void {}
427export fn __printf_fp() void {}
428export fn __profile_frequency() void {}
429export fn __ptsname_r_chk() void {}
430export fn __pwrite64() void {}
431export fn __rawmemchr() void {}
432export fn __read() void {}
433export fn __read_chk() void {}
434export fn __read_nocancel() void {}
435export fn __readlink_chk() void {}
436export fn __readlinkat_chk() void {}
437export fn __realpath_chk() void {}
438export fn __recv() void {}
439export fn __recv_chk() void {}
440export fn __recvfrom_chk() void {}
441export fn __register_atfork() void {}
442export fn __res_iclose() void {}
443export fn __res_init() void {}
444export fn __res_nclose() void {}
445export fn __res_ninit() void {}
446export fn __res_randomid() void {}
447export fn __res_state() void {}
448export fn __resolv_context_get() void {}
449export fn __resolv_context_get_override() void {}
450export fn __resolv_context_get_preinit() void {}
451export fn __resolv_context_put() void {}
452export fn __sbrk() void {}
453export fn __sched_cpualloc() void {}
454export fn __sched_cpucount() void {}
455export fn __sched_cpufree() void {}
456export fn __sched_get_priority_max() void {}
457export fn __sched_get_priority_min() void {}
458export fn __sched_getparam() void {}
459export fn __sched_getscheduler() void {}
460export fn __sched_setscheduler() void {}
461export fn __sched_yield() void {}
462export fn __select() void {}
463export fn __send() void {}
464export fn __sendmmsg() void {}
465export fn __setmntent() void {}
466export fn __setpgid() void {}
467export fn __sigaction() void {}
468export fn __signbit() void {}
469export fn __signbitf() void {}
470export fn __signbitl() void {}
471export fn __sigpause() void {}
472export fn __sigsetjmp() void {}
473export fn __sigsuspend() void {}
474export fn __sigtimedwait() void {}
475export fn __snprintf() void {}
476export fn __snprintf_chk() void {}
477export fn __socket() void {}
478export fn __sprintf_chk() void {}
479export fn __stack_chk_fail() void {}
480export fn __statfs() void {}
481export fn __stpcpy() void {}
482export fn __stpcpy_chk() void {}
483export fn __stpncpy() void {}
484export fn __stpncpy_chk() void {}
485export fn __strcasecmp() void {}
486export fn __strcasecmp_l() void {}
487export fn __strcasestr() void {}
488export fn __strcat_chk() void {}
489export fn __strchrnul() void {}
490export fn __strcoll_l() void {}
491export fn __strcpy_chk() void {}
492export fn __strdup() void {}
493export fn __strerror_r() void {}
494export fn __strfmon_l() void {}
495export fn __strftime_l() void {}
496export fn __strncasecmp() void {}
497export fn __strncasecmp_l() void {}
498export fn __strncat_chk() void {}
499export fn __strncpy_chk() void {}
500export fn __strndup() void {}
501export fn __strnlen() void {}
502export fn __strsep_g() void {}
503export fn __strtod_internal() void {}
504export fn __strtod_l() void {}
505export fn __strtod_nan() void {}
506export fn __strtof128_internal() void {}
507export fn __strtof128_nan() void {}
508export fn __strtof_internal() void {}
509export fn __strtof_l() void {}
510export fn __strtof_nan() void {}
511export fn __strtok_r() void {}
512export fn __strtol_internal() void {}
513export fn __strtol_l() void {}
514export fn __strtold_internal() void {}
515export fn __strtold_l() void {}
516export fn __strtold_nan() void {}
517export fn __strtoll_internal() void {}
518export fn __strtoll_l() void {}
519export fn __strtoul_internal() void {}
520export fn __strtoul_l() void {}
521export fn __strtoull_internal() void {}
522export fn __strtoull_l() void {}
523export fn __strverscmp() void {}
524export fn __strxfrm_l() void {}
525export fn __swprintf_chk() void {}
526export fn __sysconf() void {}
527export fn __sysctl() void {}
528export fn __syslog_chk() void {}
529export fn __sysv_signal() void {}
530export fn __tdelete() void {}
531export fn __tfind() void {}
532export fn __toascii_l() void {}
533export fn __tolower_l() void {}
534export fn __toupper_l() void {}
535export fn __towctrans() void {}
536export fn __towctrans_l() void {}
537export fn __towlower_l() void {}
538export fn __towupper_l() void {}
539export fn __tsearch() void {}
540export fn __ttyname_r_chk() void {}
541export fn __twalk() void {}
542export fn __uflow() void {}
543export fn __underflow() void {}
544export fn __uselocale() void {}
545export fn __vasprintf_chk() void {}
546export fn __vdprintf_chk() void {}
547export fn __vfork() void {}
548export fn __vfprintf_chk() void {}
549export fn __vfscanf() void {}
550export fn __vfwprintf_chk() void {}
551export fn __vprintf_chk() void {}
552export fn __vsnprintf() void {}
553export fn __vsnprintf_chk() void {}
554export fn __vsprintf_chk() void {}
555export fn __vsscanf() void {}
556export fn __vswprintf_chk() void {}
557export fn __vsyslog_chk() void {}
558export fn __vwprintf_chk() void {}
559export fn __wait() void {}
560export fn __waitpid() void {}
561export fn __wcpcpy_chk() void {}
562export fn __wcpncpy_chk() void {}
563export fn __wcrtomb_chk() void {}
564export fn __wcscasecmp_l() void {}
565export fn __wcscat_chk() void {}
566export fn __wcschr() void {}
567export fn __wcscmp() void {}
568export fn __wcscoll_l() void {}
569export fn __wcscpy_chk() void {}
570export fn __wcsftime_l() void {}
571export fn __wcslen() void {}
572export fn __wcsncasecmp_l() void {}
573export fn __wcsncat_chk() void {}
574export fn __wcsncpy_chk() void {}
575export fn __wcsnlen() void {}
576export fn __wcsnrtombs_chk() void {}
577export fn __wcsrtombs_chk() void {}
578export fn __wcstod_internal() void {}
579export fn __wcstod_l() void {}
580export fn __wcstof128_internal() void {}
581export fn __wcstof_internal() void {}
582export fn __wcstof_l() void {}
583export fn __wcstol_internal() void {}
584export fn __wcstol_l() void {}
585export fn __wcstold_internal() void {}
586export fn __wcstold_l() void {}
587export fn __wcstoll_internal() void {}
588export fn __wcstoll_l() void {}
589export fn __wcstombs_chk() void {}
590export fn __wcstoul_internal() void {}
591export fn __wcstoul_l() void {}
592export fn __wcstoull_internal() void {}
593export fn __wcstoull_l() void {}
594export fn __wcsxfrm_l() void {}
595export fn __wctomb_chk() void {}
596export fn __wctrans_l() void {}
597export fn __wctype_l() void {}
598export fn __wmemchr() void {}
599export fn __wmemcpy_chk() void {}
600export fn __wmemmove_chk() void {}
601export fn __wmempcpy_chk() void {}
602export fn __wmemset() void {}
603export fn __wmemset_chk() void {}
604export fn __woverflow() void {}
605export fn __wprintf_chk() void {}
606export fn __write() void {}
607export fn __write_nocancel() void {}
608export fn __wuflow() void {}
609export fn __wunderflow() void {}
610export fn __xmknod() void {}
611export fn __xmknodat() void {}
612export fn __xpg_basename() void {}
613export fn __xpg_sigpause() void {}
614export fn __xpg_strerror_r() void {}
615export fn __xstat() void {}
616export fn __xstat64() void {}
617export fn _dl_addr() void {}
618export fn _dl_catch_error() void {}
619export fn _dl_catch_exception() void {}
620export fn _dl_mcount_wrapper() void {}
621export fn _dl_mcount_wrapper_check() void {}
622export fn _dl_signal_error() void {}
623export fn _dl_signal_exception() void {}
624export fn _dl_sym() void {}
625export fn _dl_vsym() void {}
626export fn _exit() void {}
627export fn _flushlbf() void {}
628export fn _longjmp() void {}
629export fn _mcleanup() void {}
630export fn _mcount() void {}
631export fn _nss_files_parse_grent() void {}
632export fn _nss_files_parse_pwent() void {}
633export fn _nss_files_parse_sgent() void {}
634export fn _nss_files_parse_spent() void {}
635export fn _obstack_allocated_p() void {}
636export fn _obstack_begin() void {}
637export fn _obstack_begin_1() void {}
638export fn _obstack_free() void {}
639export fn _obstack_memory_used() void {}
640export fn _obstack_newchunk() void {}
641export fn _setjmp() void {}
642export fn _tolower() void {}
643export fn _toupper() void {}
644export fn a64l() void {}
645export fn abort() void {}
646export fn abs() void {}
647export fn accept() void {}
648export fn accept4() void {}
649export fn access() void {}
650export fn acct() void {}
651export fn addmntent() void {}
652export fn addseverity() void {}
653export fn adjtime() void {}
654export fn adjtimex() void {}
655export fn alarm() void {}
656export fn aligned_alloc() void {}
657export fn alphasort() void {}
658export fn alphasort64() void {}
659export fn arch_prctl() void {}
660export fn argp_error() void {}
661export fn argp_failure() void {}
662export fn argp_help() void {}
663export fn argp_parse() void {}
664export fn argp_state_help() void {}
665export fn argp_usage() void {}
666export fn argz_add() void {}
667export fn argz_add_sep() void {}
668export fn argz_append() void {}
669export fn argz_count() void {}
670export fn argz_create() void {}
671export fn argz_create_sep() void {}
672export fn argz_delete() void {}
673export fn argz_extract() void {}
674export fn argz_insert() void {}
675export fn argz_next() void {}
676export fn argz_replace() void {}
677export fn argz_stringify() void {}
678export fn asctime() void {}
679export fn asctime_r() void {}
680export fn asprintf() void {}
681export fn atof() void {}
682export fn atoi() void {}
683export fn atol() void {}
684export fn atoll() void {}
685export fn backtrace() void {}
686export fn backtrace_symbols() void {}
687export fn backtrace_symbols_fd() void {}
688export fn basename() void {}
689export fn bcmp() void {}
690export fn bcopy() void {}
691export fn bind() void {}
692export fn bind_textdomain_codeset() void {}
693export fn bindresvport() void {}
694export fn bindtextdomain() void {}
695export fn brk() void {}
696export fn bsd_signal() void {}
697export fn bsearch() void {}
698export fn btowc() void {}
699export fn bzero() void {}
700export fn c16rtomb() void {}
701export fn c32rtomb() void {}
702export fn calloc() void {}
703export fn canonicalize_file_name() void {}
704export fn capget() void {}
705export fn capset() void {}
706export fn catclose() void {}
707export fn catgets() void {}
708export fn catopen() void {}
709export fn cfgetispeed() void {}
710export fn cfgetospeed() void {}
711export fn cfmakeraw() void {}
712export fn cfsetispeed() void {}
713export fn cfsetospeed() void {}
714export fn cfsetspeed() void {}
715export fn chdir() void {}
716export fn chflags() void {}
717export fn chmod() void {}
718export fn chown() void {}
719export fn chroot() void {}
720export fn clearenv() void {}
721export fn clearerr() void {}
722export fn clearerr_unlocked() void {}
723export fn clnt_sperrno() void {}
724export fn clock() void {}
725export fn clock_adjtime() void {}
726export fn clock_getcpuclockid() void {}
727export fn clock_getres() void {}
728export fn clock_gettime() void {}
729export fn clock_nanosleep() void {}
730export fn clock_settime() void {}
731export fn clone() void {}
732export fn close() void {}
733export fn closedir() void {}
734export fn closelog() void {}
735export fn confstr() void {}
736export fn connect() void {}
737export fn copy_file_range() void {}
738export fn copysign() void {}
739export fn copysignf() void {}
740export fn copysignl() void {}
741export fn creat() void {}
742export fn creat64() void {}
743export fn ctermid() void {}
744export fn ctime() void {}
745export fn ctime_r() void {}
746export fn cuserid() void {}
747export fn daemon() void {}
748export fn dcgettext() void {}
749export fn dcngettext() void {}
750export fn delete_module() void {}
751export fn dgettext() void {}
752export fn difftime() void {}
753export fn dirfd() void {}
754export fn dirname() void {}
755export fn div() void {}
756export fn dl_iterate_phdr() void {}
757export fn dngettext() void {}
758export fn dprintf() void {}
759export fn drand48() void {}
760export fn drand48_r() void {}
761export fn dup() void {}
762export fn dup2() void {}
763export fn dup3() void {}
764export fn duplocale() void {}
765export fn dysize() void {}
766export fn eaccess() void {}
767export fn ecvt() void {}
768export fn ecvt_r() void {}
769export fn endaliasent() void {}
770export fn endfsent() void {}
771export fn endgrent() void {}
772export fn endhostent() void {}
773export fn endmntent() void {}
774export fn endnetent() void {}
775export fn endnetgrent() void {}
776export fn endprotoent() void {}
777export fn endpwent() void {}
778export fn endrpcent() void {}
779export fn endservent() void {}
780export fn endsgent() void {}
781export fn endspent() void {}
782export fn endttyent() void {}
783export fn endusershell() void {}
784export fn endutent() void {}
785export fn endutxent() void {}
786export fn envz_add() void {}
787export fn envz_entry() void {}
788export fn envz_get() void {}
789export fn envz_merge() void {}
790export fn envz_remove() void {}
791export fn envz_strip() void {}
792export fn epoll_create() void {}
793export fn epoll_create1() void {}
794export fn epoll_ctl() void {}
795export fn epoll_pwait() void {}
796export fn epoll_wait() void {}
797export fn erand48() void {}
798export fn erand48_r() void {}
799export fn err() void {}
800export fn @"error"() void {}
801export fn error_at_line() void {}
802export fn errx() void {}
803export fn ether_aton() void {}
804export fn ether_aton_r() void {}
805export fn ether_hostton() void {}
806export fn ether_line() void {}
807export fn ether_ntoa() void {}
808export fn ether_ntoa_r() void {}
809export fn ether_ntohost() void {}
810export fn euidaccess() void {}
811export fn eventfd() void {}
812export fn eventfd_read() void {}
813export fn eventfd_write() void {}
814export fn execl() void {}
815export fn execle() void {}
816export fn execlp() void {}
817export fn execv() void {}
818export fn execve() void {}
819export fn execvp() void {}
820export fn execvpe() void {}
821export fn exit() void {}
822export fn explicit_bzero() void {}
823export fn faccessat() void {}
824export fn fallocate() void {}
825export fn fallocate64() void {}
826export fn fanotify_init() void {}
827export fn fanotify_mark() void {}
828export fn fattach() void {}
829export fn fchdir() void {}
830export fn fchflags() void {}
831export fn fchmod() void {}
832export fn fchmodat() void {}
833export fn fchown() void {}
834export fn fchownat() void {}
835export fn fcloseall() void {}
836export fn fcntl() void {}
837export fn fcntl64() void {}
838export fn fcvt() void {}
839export fn fcvt_r() void {}
840export fn fdatasync() void {}
841export fn fdetach() void {}
842export fn fdopendir() void {}
843export fn feof() void {}
844export fn feof_unlocked() void {}
845export fn ferror() void {}
846export fn ferror_unlocked() void {}
847export fn fexecve() void {}
848export fn fflush() void {}
849export fn fflush_unlocked() void {}
850export fn ffs() void {}
851export fn ffsl() void {}
852export fn ffsll() void {}
853export fn fgetc() void {}
854export fn fgetc_unlocked() void {}
855export fn fgetgrent() void {}
856export fn fgetgrent_r() void {}
857export fn fgetpwent() void {}
858export fn fgetpwent_r() void {}
859export fn fgets() void {}
860export fn fgets_unlocked() void {}
861export fn fgetsgent() void {}
862export fn fgetsgent_r() void {}
863export fn fgetspent() void {}
864export fn fgetspent_r() void {}
865export fn fgetwc() void {}
866export fn fgetwc_unlocked() void {}
867export fn fgetws() void {}
868export fn fgetws_unlocked() void {}
869export fn fgetxattr() void {}
870export fn fileno() void {}
871export fn fileno_unlocked() void {}
872export fn finite() void {}
873export fn finitef() void {}
874export fn finitel() void {}
875export fn flistxattr() void {}
876export fn flock() void {}
877export fn flockfile() void {}
878export fn fmtmsg() void {}
879export fn fopen64() void {}
880export fn fork() void {}
881export fn fpathconf() void {}
882export fn fprintf() void {}
883export fn fputc() void {}
884export fn fputc_unlocked() void {}
885export fn fputs() void {}
886export fn fputs_unlocked() void {}
887export fn fputwc() void {}
888export fn fputwc_unlocked() void {}
889export fn fputws() void {}
890export fn fputws_unlocked() void {}
891export fn fread() void {}
892export fn fread_unlocked() void {}
893export fn free() void {}
894export fn freeaddrinfo() void {}
895export fn freeifaddrs() void {}
896export fn freelocale() void {}
897export fn fremovexattr() void {}
898export fn freopen() void {}
899export fn freopen64() void {}
900export fn frexp() void {}
901export fn frexpf() void {}
902export fn frexpl() void {}
903export fn fscanf() void {}
904export fn fseek() void {}
905export fn fseeko() void {}
906export fn fseeko64() void {}
907export fn fsetxattr() void {}
908export fn fstatfs() void {}
909export fn fstatfs64() void {}
910export fn fstatvfs() void {}
911export fn fstatvfs64() void {}
912export fn fsync() void {}
913export fn ftell() void {}
914export fn ftello() void {}
915export fn ftello64() void {}
916export fn ftime() void {}
917export fn ftok() void {}
918export fn ftruncate() void {}
919export fn ftruncate64() void {}
920export fn ftrylockfile() void {}
921export fn fts64_children() void {}
922export fn fts64_close() void {}
923export fn fts64_open() void {}
924export fn fts64_read() void {}
925export fn fts64_set() void {}
926export fn fts_children() void {}
927export fn fts_close() void {}
928export fn fts_open() void {}
929export fn fts_read() void {}
930export fn fts_set() void {}
931export fn ftw() void {}
932export fn ftw64() void {}
933export fn funlockfile() void {}
934export fn futimens() void {}
935export fn futimes() void {}
936export fn futimesat() void {}
937export fn fwide() void {}
938export fn fwprintf() void {}
939export fn fwrite() void {}
940export fn fwrite_unlocked() void {}
941export fn fwscanf() void {}
942export fn gai_strerror() void {}
943export fn gcvt() void {}
944export fn get_avphys_pages() void {}
945export fn get_current_dir_name() void {}
946export fn get_nprocs() void {}
947export fn get_nprocs_conf() void {}
948export fn get_phys_pages() void {}
949export fn getaddrinfo() void {}
950export fn getaliasbyname() void {}
951export fn getaliasent() void {}
952export fn getauxval() void {}
953export fn getc() void {}
954export fn getc_unlocked() void {}
955export fn getchar() void {}
956export fn getchar_unlocked() void {}
957export fn getcontext() void {}
958export fn getcpu() void {}
959export fn getcwd() void {}
960export fn getdate() void {}
961export fn getdate_r() void {}
962export fn getdelim() void {}
963export fn getdirentries() void {}
964export fn getdirentries64() void {}
965export fn getdomainname() void {}
966export fn getdtablesize() void {}
967export fn getegid() void {}
968export fn getentropy() void {}
969export fn getenv() void {}
970export fn geteuid() void {}
971export fn getfsent() void {}
972export fn getfsfile() void {}
973export fn getfsspec() void {}
974export fn getgid() void {}
975export fn getgrent() void {}
976export fn getgrgid() void {}
977export fn getgrnam() void {}
978export fn getgrouplist() void {}
979export fn getgroups() void {}
980export fn gethostbyaddr() void {}
981export fn gethostbyname() void {}
982export fn gethostbyname2() void {}
983export fn gethostent() void {}
984export fn gethostid() void {}
985export fn gethostname() void {}
986export fn getifaddrs() void {}
987export fn getipv4sourcefilter() void {}
988export fn getitimer() void {}
989export fn getline() void {}
990export fn getloadavg() void {}
991export fn getlogin() void {}
992export fn getlogin_r() void {}
993export fn getmntent() void {}
994export fn getmntent_r() void {}
995export fn getmsg() void {}
996export fn getnameinfo() void {}
997export fn getnetbyaddr() void {}
998export fn getnetbyname() void {}
999export fn getnetent() void {}
1000export fn getnetgrent() void {}
1001export fn getnetgrent_r() void {}
1002export fn getopt() void {}
1003export fn getopt_long() void {}
1004export fn getopt_long_only() void {}
1005export fn getpagesize() void {}
1006export fn getpass() void {}
1007export fn getpeername() void {}
1008export fn getpgid() void {}
1009export fn getpgrp() void {}
1010export fn getpid() void {}
1011export fn getpmsg() void {}
1012export fn getppid() void {}
1013export fn getpriority() void {}
1014export fn getprotobyname() void {}
1015export fn getprotobynumber() void {}
1016export fn getprotoent() void {}
1017export fn getpt() void {}
1018export fn getpw() void {}
1019export fn getpwent() void {}
1020export fn getpwnam() void {}
1021export fn getpwuid() void {}
1022export fn getrandom() void {}
1023export fn getresgid() void {}
1024export fn getresuid() void {}
1025export fn getrlimit() void {}
1026export fn getrlimit64() void {}
1027export fn getrpcbyname() void {}
1028export fn getrpcbynumber() void {}
1029export fn getrpcent() void {}
1030export fn getrpcport() void {}
1031export fn getrusage() void {}
1032export fn gets() void {}
1033export fn getservbyname() void {}
1034export fn getservbyport() void {}
1035export fn getservent() void {}
1036export fn getsgent() void {}
1037export fn getsgent_r() void {}
1038export fn getsgnam() void {}
1039export fn getsgnam_r() void {}
1040export fn getsid() void {}
1041export fn getsockname() void {}
1042export fn getsockopt() void {}
1043export fn getsourcefilter() void {}
1044export fn getspent() void {}
1045export fn getspnam() void {}
1046export fn getsubopt() void {}
1047export fn gettext() void {}
1048export fn gettimeofday() void {}
1049export fn getttyent() void {}
1050export fn getttynam() void {}
1051export fn getuid() void {}
1052export fn getusershell() void {}
1053export fn getutent() void {}
1054export fn getutent_r() void {}
1055export fn getutid() void {}
1056export fn getutid_r() void {}
1057export fn getutline() void {}
1058export fn getutline_r() void {}
1059export fn getutmp() void {}
1060export fn getutmpx() void {}
1061export fn getutxent() void {}
1062export fn getutxid() void {}
1063export fn getutxline() void {}
1064export fn getw() void {}
1065export fn getwc() void {}
1066export fn getwc_unlocked() void {}
1067export fn getwchar() void {}
1068export fn getwchar_unlocked() void {}
1069export fn getwd() void {}
1070export fn getxattr() void {}
1071export fn glob_pattern_p() void {}
1072export fn globfree() void {}
1073export fn globfree64() void {}
1074export fn gmtime() void {}
1075export fn gmtime_r() void {}
1076export fn gnu_dev_major() void {}
1077export fn gnu_dev_makedev() void {}
1078export fn gnu_dev_minor() void {}
1079export fn gnu_get_libc_release() void {}
1080export fn gnu_get_libc_version() void {}
1081export fn grantpt() void {}
1082export fn group_member() void {}
1083export fn gsignal() void {}
1084export fn gtty() void {}
1085export fn hasmntopt() void {}
1086export fn hcreate() void {}
1087export fn hcreate_r() void {}
1088export fn hdestroy() void {}
1089export fn hdestroy_r() void {}
1090export fn herror() void {}
1091export fn hsearch() void {}
1092export fn hsearch_r() void {}
1093export fn hstrerror() void {}
1094export fn htonl() void {}
1095export fn htons() void {}
1096export fn iconv() void {}
1097export fn iconv_close() void {}
1098export fn iconv_open() void {}
1099export fn if_freenameindex() void {}
1100export fn if_indextoname() void {}
1101export fn if_nameindex() void {}
1102export fn if_nametoindex() void {}
1103export fn imaxabs() void {}
1104export fn imaxdiv() void {}
1105export fn index() void {}
1106export fn inet6_opt_append() void {}
1107export fn inet6_opt_find() void {}
1108export fn inet6_opt_finish() void {}
1109export fn inet6_opt_get_val() void {}
1110export fn inet6_opt_init() void {}
1111export fn inet6_opt_next() void {}
1112export fn inet6_opt_set_val() void {}
1113export fn inet6_option_alloc() void {}
1114export fn inet6_option_append() void {}
1115export fn inet6_option_find() void {}
1116export fn inet6_option_init() void {}
1117export fn inet6_option_next() void {}
1118export fn inet6_option_space() void {}
1119export fn inet6_rth_add() void {}
1120export fn inet6_rth_getaddr() void {}
1121export fn inet6_rth_init() void {}
1122export fn inet6_rth_reverse() void {}
1123export fn inet6_rth_segments() void {}
1124export fn inet6_rth_space() void {}
1125export fn inet_addr() void {}
1126export fn inet_aton() void {}
1127export fn inet_lnaof() void {}
1128export fn inet_makeaddr() void {}
1129export fn inet_netof() void {}
1130export fn inet_network() void {}
1131export fn inet_nsap_addr() void {}
1132export fn inet_nsap_ntoa() void {}
1133export fn inet_ntoa() void {}
1134export fn inet_ntop() void {}
1135export fn inet_pton() void {}
1136export fn init_module() void {}
1137export fn initgroups() void {}
1138export fn initstate() void {}
1139export fn initstate_r() void {}
1140export fn innetgr() void {}
1141export fn inotify_add_watch() void {}
1142export fn inotify_init() void {}
1143export fn inotify_init1() void {}
1144export fn inotify_rm_watch() void {}
1145export fn insque() void {}
1146export fn ioctl() void {}
1147export fn ioperm() void {}
1148export fn iopl() void {}
1149export fn iruserok() void {}
1150export fn iruserok_af() void {}
1151export fn isalnum() void {}
1152export fn isalnum_l() void {}
1153export fn isalpha() void {}
1154export fn isalpha_l() void {}
1155export fn isascii() void {}
1156export fn isastream() void {}
1157export fn isatty() void {}
1158export fn isblank() void {}
1159export fn isblank_l() void {}
1160export fn iscntrl() void {}
1161export fn iscntrl_l() void {}
1162export fn isctype() void {}
1163export fn isdigit() void {}
1164export fn isdigit_l() void {}
1165export fn isfdtype() void {}
1166export fn isgraph() void {}
1167export fn isgraph_l() void {}
1168export fn isinf() void {}
1169export fn isinff() void {}
1170export fn isinfl() void {}
1171export fn islower() void {}
1172export fn islower_l() void {}
1173export fn isnan() void {}
1174export fn isnanf() void {}
1175export fn isnanl() void {}
1176export fn isprint() void {}
1177export fn isprint_l() void {}
1178export fn ispunct() void {}
1179export fn ispunct_l() void {}
1180export fn isspace() void {}
1181export fn isspace_l() void {}
1182export fn isupper() void {}
1183export fn isupper_l() void {}
1184export fn iswalnum() void {}
1185export fn iswalnum_l() void {}
1186export fn iswalpha() void {}
1187export fn iswalpha_l() void {}
1188export fn iswblank() void {}
1189export fn iswblank_l() void {}
1190export fn iswcntrl() void {}
1191export fn iswcntrl_l() void {}
1192export fn iswctype() void {}
1193export fn iswctype_l() void {}
1194export fn iswdigit() void {}
1195export fn iswdigit_l() void {}
1196export fn iswgraph() void {}
1197export fn iswgraph_l() void {}
1198export fn iswlower() void {}
1199export fn iswlower_l() void {}
1200export fn iswprint() void {}
1201export fn iswprint_l() void {}
1202export fn iswpunct() void {}
1203export fn iswpunct_l() void {}
1204export fn iswspace() void {}
1205export fn iswspace_l() void {}
1206export fn iswupper() void {}
1207export fn iswupper_l() void {}
1208export fn iswxdigit() void {}
1209export fn iswxdigit_l() void {}
1210export fn isxdigit() void {}
1211export fn isxdigit_l() void {}
1212export fn jrand48() void {}
1213export fn jrand48_r() void {}
1214export fn kill() void {}
1215export fn killpg() void {}
1216export fn klogctl() void {}
1217export fn l64a() void {}
1218export fn labs() void {}
1219export fn lchmod() void {}
1220export fn lchown() void {}
1221export fn lckpwdf() void {}
1222export fn lcong48() void {}
1223export fn lcong48_r() void {}
1224export fn ldexp() void {}
1225export fn ldexpf() void {}
1226export fn ldexpl() void {}
1227export fn ldiv() void {}
1228export fn lfind() void {}
1229export fn lgetxattr() void {}
1230export fn link() void {}
1231export fn linkat() void {}
1232export fn listen() void {}
1233export fn listxattr() void {}
1234export fn llabs() void {}
1235export fn lldiv() void {}
1236export fn llistxattr() void {}
1237export fn localtime() void {}
1238export fn localtime_r() void {}
1239export fn lockf() void {}
1240export fn lockf64() void {}
1241export fn longjmp() void {}
1242export fn lrand48() void {}
1243export fn lrand48_r() void {}
1244export fn lremovexattr() void {}
1245export fn lsearch() void {}
1246export fn lseek() void {}
1247export fn lseek64() void {}
1248export fn lsetxattr() void {}
1249export fn lutimes() void {}
1250export fn madvise() void {}
1251export fn makecontext() void {}
1252export fn mallinfo() void {}
1253export fn malloc() void {}
1254export fn malloc_info() void {}
1255export fn malloc_stats() void {}
1256export fn malloc_trim() void {}
1257export fn malloc_usable_size() void {}
1258export fn mallopt() void {}
1259export fn mblen() void {}
1260export fn mbrlen() void {}
1261export fn mbrtoc16() void {}
1262export fn mbrtoc32() void {}
1263export fn mbrtowc() void {}
1264export fn mbsinit() void {}
1265export fn mbsnrtowcs() void {}
1266export fn mbsrtowcs() void {}
1267export fn mbstowcs() void {}
1268export fn mbtowc() void {}
1269export fn mcheck() void {}
1270export fn mcheck_check_all() void {}
1271export fn mcheck_pedantic() void {}
1272export fn mcount() void {}
1273export fn memalign() void {}
1274export fn memccpy() void {}
1275export fn memchr() void {}
1276export fn memcmp() void {}
1277export fn memcpy() void {}
1278export fn memfd_create() void {}
1279export fn memfrob() void {}
1280export fn memmem() void {}
1281export fn memmove() void {}
1282export fn mempcpy() void {}
1283export fn memrchr() void {}
1284export fn memset() void {}
1285export fn mincore() void {}
1286export fn mkdir() void {}
1287export fn mkdirat() void {}
1288export fn mkdtemp() void {}
1289export fn mkfifo() void {}
1290export fn mkfifoat() void {}
1291export fn mkostemp() void {}
1292export fn mkostemp64() void {}
1293export fn mkostemps() void {}
1294export fn mkostemps64() void {}
1295export fn mkstemp() void {}
1296export fn mkstemp64() void {}
1297export fn mkstemps() void {}
1298export fn mkstemps64() void {}
1299export fn mktemp() void {}
1300export fn mktime() void {}
1301export fn mlock() void {}
1302export fn mlock2() void {}
1303export fn mlockall() void {}
1304export fn mmap() void {}
1305export fn mmap64() void {}
1306export fn modf() void {}
1307export fn modff() void {}
1308export fn modfl() void {}
1309export fn modify_ldt() void {}
1310export fn moncontrol() void {}
1311export fn monstartup() void {}
1312export fn mount() void {}
1313export fn mprobe() void {}
1314export fn mprotect() void {}
1315export fn mrand48() void {}
1316export fn mrand48_r() void {}
1317export fn mremap() void {}
1318export fn msgget() void {}
1319export fn msgrcv() void {}
1320export fn msgsnd() void {}
1321export fn msync() void {}
1322export fn mtrace() void {}
1323export fn munlock() void {}
1324export fn munlockall() void {}
1325export fn munmap() void {}
1326export fn muntrace() void {}
1327export fn name_to_handle_at() void {}
1328export fn nanosleep() void {}
1329export fn newlocale() void {}
1330export fn ngettext() void {}
1331export fn nice() void {}
1332export fn nl_langinfo() void {}
1333export fn nl_langinfo_l() void {}
1334export fn nrand48() void {}
1335export fn nrand48_r() void {}
1336export fn ntohl() void {}
1337export fn ntohs() void {}
1338export fn ntp_adjtime() void {}
1339export fn ntp_gettime() void {}
1340export fn ntp_gettimex() void {}
1341export fn obstack_free() void {}
1342export fn obstack_printf() void {}
1343export fn obstack_vprintf() void {}
1344export fn on_exit() void {}
1345export fn open() void {}
1346export fn open64() void {}
1347export fn open_by_handle_at() void {}
1348export fn open_memstream() void {}
1349export fn open_wmemstream() void {}
1350export fn openat() void {}
1351export fn openat64() void {}
1352export fn opendir() void {}
1353export fn openlog() void {}
1354export fn parse_printf_format() void {}
1355export fn pathconf() void {}
1356export fn pause() void {}
1357export fn perror() void {}
1358export fn personality() void {}
1359export fn pipe() void {}
1360export fn pipe2() void {}
1361export fn pivot_root() void {}
1362export fn pkey_alloc() void {}
1363export fn pkey_free() void {}
1364export fn pkey_get() void {}
1365export fn pkey_mprotect() void {}
1366export fn pkey_set() void {}
1367export fn poll() void {}
1368export fn posix_fadvise() void {}
1369export fn posix_fadvise64() void {}
1370export fn posix_fallocate() void {}
1371export fn posix_fallocate64() void {}
1372export fn posix_madvise() void {}
1373export fn posix_memalign() void {}
1374export fn posix_openpt() void {}
1375export fn posix_spawn_file_actions_addchdir_np() void {}
1376export fn posix_spawn_file_actions_addclose() void {}
1377export fn posix_spawn_file_actions_adddup2() void {}
1378export fn posix_spawn_file_actions_addfchdir_np() void {}
1379export fn posix_spawn_file_actions_addopen() void {}
1380export fn posix_spawn_file_actions_destroy() void {}
1381export fn posix_spawn_file_actions_init() void {}
1382export fn posix_spawnattr_destroy() void {}
1383export fn posix_spawnattr_getflags() void {}
1384export fn posix_spawnattr_getpgroup() void {}
1385export fn posix_spawnattr_getschedparam() void {}
1386export fn posix_spawnattr_getschedpolicy() void {}
1387export fn posix_spawnattr_getsigdefault() void {}
1388export fn posix_spawnattr_getsigmask() void {}
1389export fn posix_spawnattr_init() void {}
1390export fn posix_spawnattr_setflags() void {}
1391export fn posix_spawnattr_setpgroup() void {}
1392export fn posix_spawnattr_setschedparam() void {}
1393export fn posix_spawnattr_setschedpolicy() void {}
1394export fn posix_spawnattr_setsigdefault() void {}
1395export fn posix_spawnattr_setsigmask() void {}
1396export fn ppoll() void {}
1397export fn prctl() void {}
1398export fn pread() void {}
1399export fn pread64() void {}
1400export fn preadv() void {}
1401export fn preadv2() void {}
1402export fn preadv64() void {}
1403export fn preadv64v2() void {}
1404export fn printf() void {}
1405export fn printf_size() void {}
1406export fn printf_size_info() void {}
1407export fn prlimit() void {}
1408export fn prlimit64() void {}
1409export fn process_vm_readv() void {}
1410export fn process_vm_writev() void {}
1411export fn profil() void {}
1412export fn pselect() void {}
1413export fn psiginfo() void {}
1414export fn psignal() void {}
1415export fn pthread_attr_destroy() void {}
1416export fn pthread_attr_getdetachstate() void {}
1417export fn pthread_attr_getinheritsched() void {}
1418export fn pthread_attr_getschedparam() void {}
1419export fn pthread_attr_getschedpolicy() void {}
1420export fn pthread_attr_getscope() void {}
1421export fn pthread_attr_setdetachstate() void {}
1422export fn pthread_attr_setinheritsched() void {}
1423export fn pthread_attr_setschedparam() void {}
1424export fn pthread_attr_setschedpolicy() void {}
1425export fn pthread_attr_setscope() void {}
1426export fn pthread_condattr_destroy() void {}
1427export fn pthread_condattr_init() void {}
1428export fn pthread_equal() void {}
1429export fn pthread_exit() void {}
1430export fn pthread_getschedparam() void {}
1431export fn pthread_mutex_destroy() void {}
1432export fn pthread_mutex_init() void {}
1433export fn pthread_mutex_lock() void {}
1434export fn pthread_mutex_unlock() void {}
1435export fn pthread_self() void {}
1436export fn pthread_setcancelstate() void {}
1437export fn pthread_setcanceltype() void {}
1438export fn pthread_setschedparam() void {}
1439export fn ptrace() void {}
1440export fn ptsname() void {}
1441export fn ptsname_r() void {}
1442export fn putc() void {}
1443export fn putc_unlocked() void {}
1444export fn putchar() void {}
1445export fn putchar_unlocked() void {}
1446export fn putenv() void {}
1447export fn putgrent() void {}
1448export fn putmsg() void {}
1449export fn putpmsg() void {}
1450export fn putpwent() void {}
1451export fn puts() void {}
1452export fn putsgent() void {}
1453export fn putspent() void {}
1454export fn pututline() void {}
1455export fn pututxline() void {}
1456export fn putw() void {}
1457export fn putwc() void {}
1458export fn putwc_unlocked() void {}
1459export fn putwchar() void {}
1460export fn putwchar_unlocked() void {}
1461export fn pvalloc() void {}
1462export fn pwrite() void {}
1463export fn pwrite64() void {}
1464export fn pwritev() void {}
1465export fn pwritev2() void {}
1466export fn pwritev64() void {}
1467export fn pwritev64v2() void {}
1468export fn qecvt() void {}
1469export fn qecvt_r() void {}
1470export fn qfcvt() void {}
1471export fn qfcvt_r() void {}
1472export fn qgcvt() void {}
1473export fn qsort() void {}
1474export fn qsort_r() void {}
1475export fn quotactl() void {}
1476export fn raise() void {}
1477export fn rand() void {}
1478export fn rand_r() void {}
1479export fn random() void {}
1480export fn random_r() void {}
1481export fn rawmemchr() void {}
1482export fn rcmd() void {}
1483export fn rcmd_af() void {}
1484export fn re_comp() void {}
1485export fn re_compile_fastmap() void {}
1486export fn re_compile_pattern() void {}
1487export fn re_exec() void {}
1488export fn re_match() void {}
1489export fn re_match_2() void {}
1490export fn re_search() void {}
1491export fn re_search_2() void {}
1492export fn re_set_registers() void {}
1493export fn re_set_syntax() void {}
1494export fn read() void {}
1495export fn readahead() void {}
1496export fn readdir() void {}
1497export fn readdir64() void {}
1498export fn readdir64_r() void {}
1499export fn readdir_r() void {}
1500export fn readlink() void {}
1501export fn readlinkat() void {}
1502export fn readv() void {}
1503export fn realloc() void {}
1504export fn reallocarray() void {}
1505export fn reboot() void {}
1506export fn recv() void {}
1507export fn recvfrom() void {}
1508export fn recvmmsg() void {}
1509export fn recvmsg() void {}
1510export fn regcomp() void {}
1511export fn regerror() void {}
1512export fn regfree() void {}
1513export fn register_printf_function() void {}
1514export fn register_printf_modifier() void {}
1515export fn register_printf_specifier() void {}
1516export fn register_printf_type() void {}
1517export fn remap_file_pages() void {}
1518export fn remove() void {}
1519export fn removexattr() void {}
1520export fn remque() void {}
1521export fn rename() void {}
1522export fn renameat() void {}
1523export fn renameat2() void {}
1524export fn revoke() void {}
1525export fn rewind() void {}
1526export fn rewinddir() void {}
1527export fn rexec() void {}
1528export fn rexec_af() void {}
1529export fn rindex() void {}
1530export fn rmdir() void {}
1531export fn rpmatch() void {}
1532export fn rresvport() void {}
1533export fn rresvport_af() void {}
1534export fn ruserok() void {}
1535export fn ruserok_af() void {}
1536export fn ruserpass() void {}
1537export fn sbrk() void {}
1538export fn scalbn() void {}
1539export fn scalbnf() void {}
1540export fn scalbnl() void {}
1541export fn scandir() void {}
1542export fn scandir64() void {}
1543export fn scandirat() void {}
1544export fn scandirat64() void {}
1545export fn scanf() void {}
1546export fn sched_get_priority_max() void {}
1547export fn sched_get_priority_min() void {}
1548export fn sched_getcpu() void {}
1549export fn sched_getparam() void {}
1550export fn sched_getscheduler() void {}
1551export fn sched_rr_get_interval() void {}
1552export fn sched_setparam() void {}
1553export fn sched_setscheduler() void {}
1554export fn sched_yield() void {}
1555export fn secure_getenv() void {}
1556export fn seed48() void {}
1557export fn seed48_r() void {}
1558export fn seekdir() void {}
1559export fn select() void {}
1560export fn semget() void {}
1561export fn semop() void {}
1562export fn semtimedop() void {}
1563export fn send() void {}
1564export fn sendfile() void {}
1565export fn sendfile64() void {}
1566export fn sendmmsg() void {}
1567export fn sendmsg() void {}
1568export fn sendto() void {}
1569export fn setaliasent() void {}
1570export fn setbuf() void {}
1571export fn setbuffer() void {}
1572export fn setcontext() void {}
1573export fn setdomainname() void {}
1574export fn setegid() void {}
1575export fn setenv() void {}
1576export fn seteuid() void {}
1577export fn setfsent() void {}
1578export fn setfsgid() void {}
1579export fn setfsuid() void {}
1580export fn setgid() void {}
1581export fn setgrent() void {}
1582export fn setgroups() void {}
1583export fn sethostent() void {}
1584export fn sethostid() void {}
1585export fn sethostname() void {}
1586export fn setipv4sourcefilter() void {}
1587export fn setitimer() void {}
1588export fn setjmp() void {}
1589export fn setlinebuf() void {}
1590export fn setlocale() void {}
1591export fn setlogin() void {}
1592export fn setlogmask() void {}
1593export fn setmntent() void {}
1594export fn setnetent() void {}
1595export fn setnetgrent() void {}
1596export fn setns() void {}
1597export fn setpgid() void {}
1598export fn setpgrp() void {}
1599export fn setpriority() void {}
1600export fn setprotoent() void {}
1601export fn setpwent() void {}
1602export fn setregid() void {}
1603export fn setresgid() void {}
1604export fn setresuid() void {}
1605export fn setreuid() void {}
1606export fn setrlimit() void {}
1607export fn setrlimit64() void {}
1608export fn setrpcent() void {}
1609export fn setservent() void {}
1610export fn setsgent() void {}
1611export fn setsid() void {}
1612export fn setsockopt() void {}
1613export fn setsourcefilter() void {}
1614export fn setspent() void {}
1615export fn setstate() void {}
1616export fn setstate_r() void {}
1617export fn settimeofday() void {}
1618export fn setttyent() void {}
1619export fn setuid() void {}
1620export fn setusershell() void {}
1621export fn setutent() void {}
1622export fn setutxent() void {}
1623export fn setvbuf() void {}
1624export fn setxattr() void {}
1625export fn sgetsgent() void {}
1626export fn sgetsgent_r() void {}
1627export fn sgetspent() void {}
1628export fn sgetspent_r() void {}
1629export fn shmat() void {}
1630export fn shmdt() void {}
1631export fn shmget() void {}
1632export fn shutdown() void {}
1633export fn sigaction() void {}
1634export fn sigaddset() void {}
1635export fn sigaltstack() void {}
1636export fn sigandset() void {}
1637export fn sigblock() void {}
1638export fn sigdelset() void {}
1639export fn sigemptyset() void {}
1640export fn sigfillset() void {}
1641export fn siggetmask() void {}
1642export fn sighold() void {}
1643export fn sigignore() void {}
1644export fn siginterrupt() void {}
1645export fn sigisemptyset() void {}
1646export fn sigismember() void {}
1647export fn siglongjmp() void {}
1648export fn signal() void {}
1649export fn signalfd() void {}
1650export fn sigorset() void {}
1651export fn sigpause() void {}
1652export fn sigpending() void {}
1653export fn sigprocmask() void {}
1654export fn sigqueue() void {}
1655export fn sigrelse() void {}
1656export fn sigreturn() void {}
1657export fn sigset() void {}
1658export fn sigsetmask() void {}
1659export fn sigstack() void {}
1660export fn sigsuspend() void {}
1661export fn sigtimedwait() void {}
1662export fn sigwait() void {}
1663export fn sigwaitinfo() void {}
1664export fn sleep() void {}
1665export fn snprintf() void {}
1666export fn sockatmark() void {}
1667export fn socket() void {}
1668export fn socketpair() void {}
1669export fn splice() void {}
1670export fn sprintf() void {}
1671export fn sprofil() void {}
1672export fn srand() void {}
1673export fn srand48() void {}
1674export fn srand48_r() void {}
1675export fn srandom() void {}
1676export fn srandom_r() void {}
1677export fn sscanf() void {}
1678export fn ssignal() void {}
1679export fn sstk() void {}
1680export fn statfs() void {}
1681export fn statfs64() void {}
1682export fn statvfs() void {}
1683export fn statvfs64() void {}
1684export fn statx() void {}
1685export fn stime() void {}
1686export fn stpcpy() void {}
1687export fn stpncpy() void {}
1688export fn strcasecmp() void {}
1689export fn strcasecmp_l() void {}
1690export fn strcasestr() void {}
1691export fn strcat() void {}
1692export fn strchr() void {}
1693export fn strchrnul() void {}
1694export fn strcmp() void {}
1695export fn strcoll() void {}
1696export fn strcoll_l() void {}
1697export fn strcpy() void {}
1698export fn strcspn() void {}
1699export fn strdup() void {}
1700export fn strerror() void {}
1701export fn strerror_l() void {}
1702export fn strerror_r() void {}
1703export fn strfmon() void {}
1704export fn strfmon_l() void {}
1705export fn strfromd() void {}
1706export fn strfromf() void {}
1707export fn strfromf128() void {}
1708export fn strfromf32() void {}
1709export fn strfromf32x() void {}
1710export fn strfromf64() void {}
1711export fn strfromf64x() void {}
1712export fn strfroml() void {}
1713export fn strfry() void {}
1714export fn strftime() void {}
1715export fn strftime_l() void {}
1716export fn strlen() void {}
1717export fn strncasecmp() void {}
1718export fn strncasecmp_l() void {}
1719export fn strncat() void {}
1720export fn strncmp() void {}
1721export fn strncpy() void {}
1722export fn strndup() void {}
1723export fn strnlen() void {}
1724export fn strpbrk() void {}
1725export fn strptime() void {}
1726export fn strptime_l() void {}
1727export fn strrchr() void {}
1728export fn strsep() void {}
1729export fn strsignal() void {}
1730export fn strspn() void {}
1731export fn strstr() void {}
1732export fn strtod() void {}
1733export fn strtod_l() void {}
1734export fn strtof() void {}
1735export fn strtof128() void {}
1736export fn strtof128_l() void {}
1737export fn strtof32() void {}
1738export fn strtof32_l() void {}
1739export fn strtof32x() void {}
1740export fn strtof32x_l() void {}
1741export fn strtof64() void {}
1742export fn strtof64_l() void {}
1743export fn strtof64x() void {}
1744export fn strtof64x_l() void {}
1745export fn strtof_l() void {}
1746export fn strtoimax() void {}
1747export fn strtok() void {}
1748export fn strtok_r() void {}
1749export fn strtol() void {}
1750export fn strtol_l() void {}
1751export fn strtold() void {}
1752export fn strtold_l() void {}
1753export fn strtoll() void {}
1754export fn strtoll_l() void {}
1755export fn strtoq() void {}
1756export fn strtoul() void {}
1757export fn strtoul_l() void {}
1758export fn strtoull() void {}
1759export fn strtoull_l() void {}
1760export fn strtoumax() void {}
1761export fn strtouq() void {}
1762export fn strverscmp() void {}
1763export fn strxfrm() void {}
1764export fn strxfrm_l() void {}
1765export fn stty() void {}
1766export fn swab() void {}
1767export fn swapcontext() void {}
1768export fn swapoff() void {}
1769export fn swapon() void {}
1770export fn swprintf() void {}
1771export fn swscanf() void {}
1772export fn symlink() void {}
1773export fn symlinkat() void {}
1774export fn sync() void {}
1775export fn sync_file_range() void {}
1776export fn syncfs() void {}
1777export fn syscall() void {}
1778export fn sysconf() void {}
1779export fn sysctl() void {}
1780export fn sysinfo() void {}
1781export fn syslog() void {}
1782export fn system() void {}
1783export fn sysv_signal() void {}
1784export fn tcdrain() void {}
1785export fn tcflow() void {}
1786export fn tcflush() void {}
1787export fn tcgetattr() void {}
1788export fn tcgetpgrp() void {}
1789export fn tcgetsid() void {}
1790export fn tcsendbreak() void {}
1791export fn tcsetattr() void {}
1792export fn tcsetpgrp() void {}
1793export fn tdelete() void {}
1794export fn tdestroy() void {}
1795export fn tee() void {}
1796export fn telldir() void {}
1797export fn tempnam() void {}
1798export fn textdomain() void {}
1799export fn tfind() void {}
1800export fn thrd_current() void {}
1801export fn thrd_equal() void {}
1802export fn thrd_sleep() void {}
1803export fn thrd_yield() void {}
1804export fn time() void {}
1805export fn timegm() void {}
1806export fn timelocal() void {}
1807export fn timerfd_create() void {}
1808export fn timerfd_gettime() void {}
1809export fn timerfd_settime() void {}
1810export fn times() void {}
1811export fn timespec_get() void {}
1812export fn tmpfile64() void {}
1813export fn tmpnam() void {}
1814export fn tmpnam_r() void {}
1815export fn toascii() void {}
1816export fn tolower() void {}
1817export fn tolower_l() void {}
1818export fn toupper() void {}
1819export fn toupper_l() void {}
1820export fn towctrans() void {}
1821export fn towctrans_l() void {}
1822export fn towlower() void {}
1823export fn towlower_l() void {}
1824export fn towupper() void {}
1825export fn towupper_l() void {}
1826export fn tr_break() void {}
1827export fn truncate() void {}
1828export fn truncate64() void {}
1829export fn tsearch() void {}
1830export fn ttyname() void {}
1831export fn ttyname_r() void {}
1832export fn ttyslot() void {}
1833export fn twalk() void {}
1834export fn tzset() void {}
1835export fn ualarm() void {}
1836export fn ulckpwdf() void {}
1837export fn ulimit() void {}
1838export fn umask() void {}
1839export fn umount() void {}
1840export fn umount2() void {}
1841export fn uname() void {}
1842export fn ungetc() void {}
1843export fn ungetwc() void {}
1844export fn unlink() void {}
1845export fn unlinkat() void {}
1846export fn unlockpt() void {}
1847export fn unsetenv() void {}
1848export fn unshare() void {}
1849export fn updwtmp() void {}
1850export fn updwtmpx() void {}
1851export fn uselocale() void {}
1852export fn usleep() void {}
1853export fn utime() void {}
1854export fn utimensat() void {}
1855export fn utimes() void {}
1856export fn utmpname() void {}
1857export fn utmpxname() void {}
1858export fn valloc() void {}
1859export fn vasprintf() void {}
1860export fn vdprintf() void {}
1861export fn verr() void {}
1862export fn verrx() void {}
1863export fn versionsort() void {}
1864export fn versionsort64() void {}
1865export fn vfork() void {}
1866export fn vfprintf() void {}
1867export fn vfscanf() void {}
1868export fn vfwprintf() void {}
1869export fn vfwscanf() void {}
1870export fn vhangup() void {}
1871export fn vlimit() void {}
1872export fn vmsplice() void {}
1873export fn vprintf() void {}
1874export fn vscanf() void {}
1875export fn vsnprintf() void {}
1876export fn vsprintf() void {}
1877export fn vsscanf() void {}
1878export fn vswprintf() void {}
1879export fn vswscanf() void {}
1880export fn vsyslog() void {}
1881export fn vtimes() void {}
1882export fn vwarn() void {}
1883export fn vwarnx() void {}
1884export fn vwprintf() void {}
1885export fn vwscanf() void {}
1886export fn wait() void {}
1887export fn wait3() void {}
1888export fn wait4() void {}
1889export fn waitid() void {}
1890export fn waitpid() void {}
1891export fn warn() void {}
1892export fn warnx() void {}
1893export fn wcpcpy() void {}
1894export fn wcpncpy() void {}
1895export fn wcrtomb() void {}
1896export fn wcscasecmp() void {}
1897export fn wcscasecmp_l() void {}
1898export fn wcscat() void {}
1899export fn wcschr() void {}
1900export fn wcschrnul() void {}
1901export fn wcscmp() void {}
1902export fn wcscoll() void {}
1903export fn wcscoll_l() void {}
1904export fn wcscpy() void {}
1905export fn wcscspn() void {}
1906export fn wcsdup() void {}
1907export fn wcsftime() void {}
1908export fn wcsftime_l() void {}
1909export fn wcslen() void {}
1910export fn wcsncasecmp() void {}
1911export fn wcsncasecmp_l() void {}
1912export fn wcsncat() void {}
1913export fn wcsncmp() void {}
1914export fn wcsncpy() void {}
1915export fn wcsnlen() void {}
1916export fn wcsnrtombs() void {}
1917export fn wcspbrk() void {}
1918export fn wcsrchr() void {}
1919export fn wcsrtombs() void {}
1920export fn wcsspn() void {}
1921export fn wcsstr() void {}
1922export fn wcstod() void {}
1923export fn wcstod_l() void {}
1924export fn wcstof() void {}
1925export fn wcstof128() void {}
1926export fn wcstof128_l() void {}
1927export fn wcstof32() void {}
1928export fn wcstof32_l() void {}
1929export fn wcstof32x() void {}
1930export fn wcstof32x_l() void {}
1931export fn wcstof64() void {}
1932export fn wcstof64_l() void {}
1933export fn wcstof64x() void {}
1934export fn wcstof64x_l() void {}
1935export fn wcstof_l() void {}
1936export fn wcstoimax() void {}
1937export fn wcstok() void {}
1938export fn wcstol() void {}
1939export fn wcstol_l() void {}
1940export fn wcstold() void {}
1941export fn wcstold_l() void {}
1942export fn wcstoll() void {}
1943export fn wcstoll_l() void {}
1944export fn wcstombs() void {}
1945export fn wcstoq() void {}
1946export fn wcstoul() void {}
1947export fn wcstoul_l() void {}
1948export fn wcstoull() void {}
1949export fn wcstoull_l() void {}
1950export fn wcstoumax() void {}
1951export fn wcstouq() void {}
1952export fn wcswcs() void {}
1953export fn wcswidth() void {}
1954export fn wcsxfrm() void {}
1955export fn wcsxfrm_l() void {}
1956export fn wctob() void {}
1957export fn wctomb() void {}
1958export fn wctrans() void {}
1959export fn wctrans_l() void {}
1960export fn wctype() void {}
1961export fn wctype_l() void {}
1962export fn wcwidth() void {}
1963export fn wmemchr() void {}
1964export fn wmemcmp() void {}
1965export fn wmemcpy() void {}
1966export fn wmemmove() void {}
1967export fn wmempcpy() void {}
1968export fn wmemset() void {}
1969export fn wordexp() void {}
1970export fn wordfree() void {}
1971export fn wprintf() void {}
1972export fn write() void {}
1973export fn writev() void {}
1974export fn wscanf() void {}
src/all_types.hpp+3-1
...@@ -1693,6 +1693,7 @@ struct CodeGen {...@@ -1693,6 +1693,7 @@ struct CodeGen {
1693 ZigList<ZigFn *> test_fns;1693 ZigList<ZigFn *> test_fns;
1694 ZigList<ZigLLVMDIEnumerator *> err_enumerators;1694 ZigList<ZigLLVMDIEnumerator *> err_enumerators;
1695 ZigList<ErrorTableEntry *> errors_by_index;1695 ZigList<ErrorTableEntry *> errors_by_index;
1696 ZigList<CacheHash *> caches_to_release;
1696 size_t largest_err_name_len;1697 size_t largest_err_name_len;
16971698
1698 ZigPackage *std_package;1699 ZigPackage *std_package;
...@@ -1751,7 +1752,8 @@ struct CodeGen {...@@ -1751,7 +1752,8 @@ struct CodeGen {
1751 Buf output_file_path;1752 Buf output_file_path;
1752 Buf o_file_output_path;1753 Buf o_file_output_path;
1753 Buf *wanted_output_file_path;1754 Buf *wanted_output_file_path;
1754 Buf cache_dir;1755 Buf *cache_dir;
1756 Buf *libc_include_dir;
17551757
1756 Buf *zig_c_headers_dir; // Cannot be overridden; derived from zig_lib_dir.1758 Buf *zig_c_headers_dir; // Cannot be overridden; derived from zig_lib_dir.
1757 Buf *zig_std_special_dir; // Cannot be overridden; derived from zig_lib_dir.1759 Buf *zig_std_special_dir; // Cannot be overridden; derived from zig_lib_dir.
src/cache_hash.cpp+5-2
...@@ -281,8 +281,6 @@ Error cache_hit(CacheHash *ch, Buf *out_digest) {...@@ -281,8 +281,6 @@ Error cache_hit(CacheHash *ch, Buf *out_digest) {
281 SplitIterator line_it = memSplit(buf_to_slice(&line_buf), str("\n"));281 SplitIterator line_it = memSplit(buf_to_slice(&line_buf), str("\n"));
282 for (;; file_i += 1) {282 for (;; file_i += 1) {
283 Optional<Slice<uint8_t>> opt_line = SplitIterator_next(&line_it);283 Optional<Slice<uint8_t>> opt_line = SplitIterator_next(&line_it);
284 if (!opt_line.is_some)
285 break;
286284
287 CacheHashFile *chf;285 CacheHashFile *chf;
288 if (file_i < input_file_count) {286 if (file_i < input_file_count) {
...@@ -301,11 +299,16 @@ Error cache_hit(CacheHash *ch, Buf *out_digest) {...@@ -301,11 +299,16 @@ Error cache_hit(CacheHash *ch, Buf *out_digest) {
301 }299 }
302 // caller can notice that out_digest is unmodified.300 // caller can notice that out_digest is unmodified.
303 return ErrorNone;301 return ErrorNone;
302 } else if (!opt_line.is_some) {
303 break;
304 } else {304 } else {
305 chf = ch->files.add_one();305 chf = ch->files.add_one();
306 chf->path = nullptr;306 chf->path = nullptr;
307 }307 }
308308
309 if (!opt_line.is_some)
310 break;
311
309 SplitIterator it = memSplit(opt_line.value, str(" "));312 SplitIterator it = memSplit(opt_line.value, str(" "));
310313
311 Optional<Slice<uint8_t>> opt_mtime_sec = SplitIterator_next(&it);314 Optional<Slice<uint8_t>> opt_mtime_sec = SplitIterator_next(&it);
src/codegen.cpp+298-160
...@@ -89,7 +89,8 @@ static const char *symbols_that_llvm_depends_on[] = {...@@ -89,7 +89,8 @@ static const char *symbols_that_llvm_depends_on[] = {
89};89};
9090
91CodeGen *codegen_create(Buf *main_pkg_path, Buf *root_src_path, const ZigTarget *target,91CodeGen *codegen_create(Buf *main_pkg_path, Buf *root_src_path, const ZigTarget *target,
92 OutType out_type, BuildMode build_mode, Buf *zig_lib_dir, Buf *override_std_dir, ZigLibCInstallation *libc)92 OutType out_type, BuildMode build_mode, Buf *zig_lib_dir, Buf *override_std_dir,
93 ZigLibCInstallation *libc, Buf *cache_dir)
93{94{
94 CodeGen *g = allocate<CodeGen>(1);95 CodeGen *g = allocate<CodeGen>(1);
9596
...@@ -98,6 +99,7 @@ CodeGen *codegen_create(Buf *main_pkg_path, Buf *root_src_path, const ZigTarget...@@ -98,6 +99,7 @@ CodeGen *codegen_create(Buf *main_pkg_path, Buf *root_src_path, const ZigTarget
98 g->libc = libc;99 g->libc = libc;
99 g->zig_lib_dir = zig_lib_dir;100 g->zig_lib_dir = zig_lib_dir;
100 g->zig_target = target;101 g->zig_target = target;
102 g->cache_dir = cache_dir;
101103
102 if (override_std_dir == nullptr) {104 if (override_std_dir == nullptr) {
103 g->zig_std_dir = buf_alloc();105 g->zig_std_dir = buf_alloc();
...@@ -7912,12 +7914,27 @@ static void detect_libc(CodeGen *g) {...@@ -7912,12 +7914,27 @@ static void detect_libc(CodeGen *g) {
7912 if (g->libc != nullptr || g->libc_link_lib == nullptr)7914 if (g->libc != nullptr || g->libc_link_lib == nullptr)
7913 return;7915 return;
79147916
7917 if (g->zig_target->os == OsLinux && target_abi_is_gnu(g->zig_target->abi)) {
7918 // we have glibc headers and can build glibc start files from source
7919 if (g->is_static && g->out_type == OutTypeExe) {
7920 fprintf(stderr, "glibc does not support static linking\n");
7921 exit(1);
7922 }
7923
7924 Buf *libc_dir = buf_alloc();
7925 os_path_join(g->zig_lib_dir, buf_create_from_str("libc"), libc_dir);
7926
7927 g->libc_include_dir = buf_alloc();
7928 os_path_join(libc_dir, buf_create_from_str("glibc-include"), g->libc_include_dir);
7929 return;
7930 }
7931
7915 if (g->zig_target->is_native) {7932 if (g->zig_target->is_native) {
7916 g->libc = allocate<ZigLibCInstallation>(1);7933 g->libc = allocate<ZigLibCInstallation>(1);
79177934
7918 // Look for zig-cache/native_libc.txt7935 // Look for zig-cache/native_libc.txt
7919 Buf *native_libc_txt = buf_alloc();7936 Buf *native_libc_txt = buf_alloc();
7920 os_path_join(&g->cache_dir, buf_create_from_str("native_libc.txt"), native_libc_txt);7937 os_path_join(g->cache_dir, buf_create_from_str("native_libc.txt"), native_libc_txt);
7921 if ((err = zig_libc_parse(g->libc, native_libc_txt, g->zig_target, false))) {7938 if ((err = zig_libc_parse(g->libc, native_libc_txt, g->zig_target, false))) {
7922 if ((err = zig_libc_find_native(g->libc, true))) {7939 if ((err = zig_libc_find_native(g->libc, true))) {
7923 fprintf(stderr,7940 fprintf(stderr,
...@@ -7925,9 +7942,9 @@ static void detect_libc(CodeGen *g) {...@@ -7925,9 +7942,9 @@ static void detect_libc(CodeGen *g) {
7925 "See `zig libc --help` for more details.\n", err_str(err));7942 "See `zig libc --help` for more details.\n", err_str(err));
7926 exit(1);7943 exit(1);
7927 }7944 }
7928 if ((err = os_make_path(&g->cache_dir))) {7945 if ((err = os_make_path(g->cache_dir))) {
7929 fprintf(stderr, "Unable to create %s directory: %s\n",7946 fprintf(stderr, "Unable to create %s directory: %s\n",
7930 buf_ptr(&g->cache_dir), err_str(err));7947 buf_ptr(g->cache_dir), err_str(err));
7931 exit(1);7948 exit(1);
7932 }7949 }
7933 Buf *native_libc_tmp = buf_sprintf("%s.tmp", buf_ptr(native_libc_txt));7950 Buf *native_libc_tmp = buf_sprintf("%s.tmp", buf_ptr(native_libc_txt));
...@@ -7946,6 +7963,7 @@ static void detect_libc(CodeGen *g) {...@@ -7946,6 +7963,7 @@ static void detect_libc(CodeGen *g) {
7946 exit(1);7963 exit(1);
7947 }7964 }
7948 }7965 }
7966 g->libc_include_dir = &g->libc->include_dir;
7949 } else if ((g->out_type == OutTypeExe || (g->out_type == OutTypeLib && !g->is_static)) &&7967 } else if ((g->out_type == OutTypeExe || (g->out_type == OutTypeLib && !g->is_static)) &&
7950 !target_is_darwin(g->zig_target))7968 !target_is_darwin(g->zig_target))
7951 {7969 {
...@@ -8190,140 +8208,253 @@ static void print_zig_cc_cmd(const char *zig_exe, ZigList<const char *> *args) {...@@ -8190,140 +8208,253 @@ static void print_zig_cc_cmd(const char *zig_exe, ZigList<const char *> *args) {
8190 fprintf(stderr, "\n");8208 fprintf(stderr, "\n");
8191}8209}
81928210
8211// Caller should delete the file when done or rename it into a better location.
8212static Error get_tmp_filename(CodeGen *g, Buf *out, Buf *suffix) {
8213 Error err;
8214 buf_resize(out, 0);
8215 os_path_join(g->cache_dir, buf_create_from_str("tmp" OS_SEP), out);
8216 if ((err = os_make_path(out))) {
8217 return err;
8218 }
8219 const char base64[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_";
8220 assert(array_length(base64) == 64 + 1);
8221 for (size_t i = 0; i < 12; i += 1) {
8222 buf_append_char(out, base64[rand() % 64]);
8223 }
8224 buf_append_char(out, '-');
8225 buf_append_buf(out, suffix);
8226 return ErrorNone;
8227}
8228
8193static void gen_c_object(CodeGen *g, Buf *self_exe_path, CFile *c_file) {8229static void gen_c_object(CodeGen *g, Buf *self_exe_path, CFile *c_file) {
8194 Error err;8230 Error err;
81958231
8232 Buf *artifact_dir;
8233 Buf *o_final_path;
8234
8235 Buf *o_dir = buf_alloc();
8236 os_path_join(g->cache_dir, buf_create_from_str("o"), o_dir);
8237
8196 Buf *c_source_file = buf_create_from_str(c_file->source_path);8238 Buf *c_source_file = buf_create_from_str(c_file->source_path);
8197 Buf *c_source_basename = buf_alloc();8239 Buf *c_source_basename = buf_alloc();
8198 os_path_split(c_source_file, nullptr, c_source_basename);8240 os_path_split(c_source_file, nullptr, c_source_basename);
8199 Buf *out_obj_name = buf_sprintf("%s%s", buf_ptr(c_source_basename), target_o_file_ext(g->zig_target));8241 Buf *final_o_basename = buf_alloc();
8200 Buf *out_obj_path = buf_alloc();8242 os_path_extname(c_source_basename, final_o_basename, nullptr);
8201 os_path_join(&g->cache_dir, out_obj_name, out_obj_path);8243 buf_append_str(final_o_basename, target_o_file_ext(g->zig_target));
8202 Buf *out_dep_name = buf_sprintf("%s.d", buf_ptr(c_source_file));
8203 Buf *out_dep_path = buf_alloc();
8204 os_path_join(&g->cache_dir, out_dep_name, out_dep_path);
82058244
8206 Termination term;8245 CacheHash *cache_hash = allocate<CacheHash>(1);
8207 ZigList<const char *> args = {};8246 Buf *manifest_dir = buf_alloc();
8208 args.append("cc");8247 os_path_join(g->cache_dir, buf_create_from_str("c"), manifest_dir);
8248 cache_init(cache_hash, manifest_dir);
82098249
8210 if (g->enable_cache) {8250 Buf *compiler_id;
8251 if ((err = get_compiler_id(&compiler_id))) {
8252 fprintf(stderr, "unable to get compiler id: %s\n", err_str(err));
8253 exit(1);
8254 }
8255 cache_buf(cache_hash, compiler_id);
8256 cache_int(cache_hash, g->err_color);
8257 cache_buf(cache_hash, g->zig_c_headers_dir);
8258 cache_buf_opt(cache_hash, g->libc_include_dir);
8259 if (g->libc != nullptr) {
8260 cache_buf(cache_hash, &g->libc->sys_include_dir);
8261 }
8262 cache_int(cache_hash, g->zig_target->is_native);
8263 cache_int(cache_hash, g->zig_target->arch);
8264 cache_int(cache_hash, g->zig_target->sub_arch);
8265 cache_int(cache_hash, g->zig_target->vendor);
8266 cache_int(cache_hash, g->zig_target->os);
8267 cache_int(cache_hash, g->zig_target->abi);
8268 cache_bool(cache_hash, g->strip_debug_symbols);
8269 cache_int(cache_hash, g->build_mode);
8270 cache_file(cache_hash, c_source_file);
8271 cache_bool(cache_hash, g->disable_pic);
8272 for (size_t arg_i = 0; arg_i < g->clang_argv_len; arg_i += 1) {
8273 cache_str(cache_hash, g->clang_argv[arg_i]);
8274 }
8275 // Note: not directory args, just args that always have a file next
8276 static const char *file_args[] = {
8277 "-include",
8278 };
8279 for (size_t arg_i = 0; arg_i < c_file->args.length; arg_i += 1) {
8280 const char *arg = c_file->args.at(arg_i);
8281 cache_str(cache_hash, arg);
8282 for (size_t file_arg_i = 0; file_arg_i < array_length(file_args); file_arg_i += 1) {
8283 if (strcmp(arg, file_args[file_arg_i]) == 0 && arg_i + 1 < c_file->args.length) {
8284 arg_i += 1;
8285 cache_file(cache_hash, buf_create_from_str(c_file->args.at(arg_i)));
8286 }
8287 }
8288 }
8289
8290 Buf digest = BUF_INIT;
8291 buf_resize(&digest, 0);
8292 if ((err = cache_hit(cache_hash, &digest))) {
8293 if (err == ErrorCacheUnavailable) {
8294 // already printed error
8295 } else {
8296 fprintf(stderr, "unable to check cache when compiling C object: %s\n", err_str(err));
8297 }
8298 exit(1);
8299 }
8300 if (buf_len(&digest) == 0) {
8301 // cache miss
8302 // we can't know the digest until we do the C compiler invocation, so we
8303 // need a tmp filename.
8304 Buf *out_obj_path = buf_alloc();
8305 if ((err = get_tmp_filename(g, out_obj_path, final_o_basename))) {
8306 fprintf(stderr, "unable to create tmp dir: %s\n", err_str(err));
8307 exit(1);
8308 }
8309
8310 Termination term;
8311 ZigList<const char *> args = {};
8312 args.append("cc");
8313
8314 Buf *out_dep_path = buf_sprintf("%s.d", buf_ptr(out_obj_path));
8211 args.append("-MD");8315 args.append("-MD");
8212 args.append("-MF");8316 args.append("-MF");
8213 args.append(buf_ptr(out_dep_path));8317 args.append(buf_ptr(out_dep_path));
8214 }
8215
8216 args.append("-nostdinc");
8217 args.append("-fno-spell-checking");
82188318
8219 switch (g->err_color) {8319 args.append("-nostdinc");
8220 case ErrColorAuto:8320 args.append("-fno-spell-checking");
8221 break;
8222 case ErrColorOff:
8223 args.append("-fno-color-diagnostics");
8224 args.append("-fno-caret-diagnostics");
8225 break;
8226 case ErrColorOn:
8227 args.append("-fcolor-diagnostics");
8228 args.append("-fcaret-diagnostics");
8229 break;
8230 }
82318321
8232 args.append("-isystem");8322 switch (g->err_color) {
8233 args.append(buf_ptr(g->zig_c_headers_dir));8323 case ErrColorAuto:
8324 break;
8325 case ErrColorOff:
8326 args.append("-fno-color-diagnostics");
8327 args.append("-fno-caret-diagnostics");
8328 break;
8329 case ErrColorOn:
8330 args.append("-fcolor-diagnostics");
8331 args.append("-fcaret-diagnostics");
8332 break;
8333 }
82348334
8235 if (g->libc != nullptr) {
8236 args.append("-isystem");8335 args.append("-isystem");
8237 args.append(buf_ptr(&g->libc->include_dir));8336 args.append(buf_ptr(g->zig_c_headers_dir));
82388337
8239 if (!buf_eql_buf(&g->libc->include_dir, &g->libc->sys_include_dir)) {8338 if (g->libc_include_dir != nullptr) {
8240 args.append("-isystem");8339 args.append("-isystem");
8241 args.append(buf_ptr(&g->libc->sys_include_dir));8340 args.append(buf_ptr(g->libc_include_dir));
8341 }
8342 if (g->libc != nullptr) {
8343 if (!buf_eql_buf(&g->libc->include_dir, &g->libc->sys_include_dir)) {
8344 args.append("-isystem");
8345 args.append(buf_ptr(&g->libc->sys_include_dir));
8346 }
8242 }8347 }
8243 }
82448348
8245 if (g->zig_target->is_native) {8349 if (g->zig_target->is_native) {
8246 args.append("-march=native");8350 args.append("-march=native");
8247 } else {8351 } else {
8248 args.append("-target");8352 args.append("-target");
8249 args.append(buf_ptr(&g->triple_str));8353 args.append(buf_ptr(&g->triple_str));
8250 }8354 }
82518355
8252 if (!g->strip_debug_symbols) {8356 if (!g->strip_debug_symbols) {
8253 args.append("-g");8357 args.append("-g");
8254 }8358 }
8255 switch (g->build_mode) {8359
8256 case BuildModeDebug:8360 switch (g->build_mode) {
8257 if (g->libc_link_lib != nullptr) {8361 case BuildModeDebug:
8258 args.append("-fstack-protector-strong");8362 if (g->libc_link_lib != nullptr) {
8259 args.append("--param");8363 args.append("-fstack-protector-strong");
8260 args.append("ssp-buffer-size=4");8364 args.append("--param");
8261 } else {8365 args.append("ssp-buffer-size=4");
8366 } else {
8367 args.append("-fno-stack-protector");
8368 }
8369 break;
8370 case BuildModeSafeRelease:
8371 args.append("-O2");
8372 if (g->libc_link_lib != nullptr) {
8373 args.append("-D_FORTIFY_SOURCE=2");
8374 args.append("-fstack-protector-strong");
8375 args.append("--param");
8376 args.append("ssp-buffer-size=4");
8377 } else {
8378 args.append("-fno-stack-protector");
8379 }
8380 break;
8381 case BuildModeFastRelease:
8382 args.append("-O2");
8262 args.append("-fno-stack-protector");8383 args.append("-fno-stack-protector");
8263 }8384 break;
8264 break;8385 case BuildModeSmallRelease:
8265 case BuildModeSafeRelease:8386 args.append("-Os");
8266 args.append("-O2");
8267 if (g->libc_link_lib != nullptr) {
8268 args.append("-D_FORTIFY_SOURCE=2");
8269 args.append("-fstack-protector-strong");
8270 args.append("--param");
8271 args.append("ssp-buffer-size=4");
8272 } else {
8273 args.append("-fno-stack-protector");8387 args.append("-fno-stack-protector");
8274 }8388 break;
8275 break;8389 }
8276 case BuildModeFastRelease:
8277 args.append("-O2");
8278 args.append("-fno-stack-protector");
8279 break;
8280 case BuildModeSmallRelease:
8281 args.append("-Os");
8282 args.append("-fno-stack-protector");
8283 break;
8284 }
82858390
8286 args.append("-o");8391 args.append("-o");
8287 args.append(buf_ptr(out_obj_path));8392 args.append(buf_ptr(out_obj_path));
82888393
8289 args.append("-c");8394 args.append("-c");
8290 args.append(buf_ptr(c_source_file));8395 args.append(buf_ptr(c_source_file));
82918396
8292 if (!g->disable_pic && target_supports_fpic(g->zig_target)) {8397 if (target_supports_fpic(g->zig_target) && !g->disable_pic) {
8293 args.append("-fPIC");8398 args.append("-fPIC");
8294 }8399 }
82958400
8296 for (size_t arg_i = 0; arg_i < g->clang_argv_len; arg_i += 1) {8401 for (size_t arg_i = 0; arg_i < g->clang_argv_len; arg_i += 1) {
8297 args.append(g->clang_argv[arg_i]);8402 args.append(g->clang_argv[arg_i]);
8298 }8403 }
82998404
8300 for (size_t arg_i = 0; arg_i < c_file->args.length; arg_i += 1) {8405 for (size_t arg_i = 0; arg_i < c_file->args.length; arg_i += 1) {
8301 args.append(c_file->args.at(arg_i));8406 args.append(c_file->args.at(arg_i));
8302 }8407 }
83038408
8304 if (g->verbose_cc) {
8305 print_zig_cc_cmd("zig", &args);
8306 }
8307 os_spawn_process(buf_ptr(self_exe_path), args, &term);
8308 if (term.how != TerminationIdClean || term.code != 0) {
8309 fprintf(stderr, "\nThe following command failed:\n");
8310 print_zig_cc_cmd(buf_ptr(self_exe_path), &args);
8311 exit(1);
8312 }
83138409
8314 g->link_objects.append(out_obj_path);8410 if (g->verbose_cc) {
8411 print_zig_cc_cmd("zig", &args);
8412 }
8413 os_spawn_process(buf_ptr(self_exe_path), args, &term);
8414 if (term.how != TerminationIdClean || term.code != 0) {
8415 fprintf(stderr, "\nThe following command failed:\n");
8416 print_zig_cc_cmd(buf_ptr(self_exe_path), &args);
8417 exit(1);
8418 }
83158419
8316 if (g->enable_cache) {
8317 // add the files depended on to the cache system8420 // add the files depended on to the cache system
8318 if ((err = cache_add_file(&g->cache_hash, c_source_file))) {8421 if ((err = cache_add_dep_file(cache_hash, out_dep_path, true))) {
8319 fprintf(stderr, "unable to add %s to cache: %s\n", buf_ptr(c_source_file), err_str(err));8422 fprintf(stderr, "Failed to add C source dependencies to cache: %s\n", err_str(err));
8423 exit(1);
8424 }
8425 os_delete_file(out_dep_path);
8426
8427 if ((err = cache_final(cache_hash, &digest))) {
8428 fprintf(stderr, "Unable to finalize cache hash: %s\n", err_str(err));
8429 exit(1);
8430 }
8431 artifact_dir = buf_alloc();
8432 os_path_join(o_dir, &digest, artifact_dir);
8433 if ((err = os_make_path(artifact_dir))) {
8434 fprintf(stderr, "Unable to create output directory '%s': %s",
8435 buf_ptr(artifact_dir), err_str(err));
8320 exit(1);8436 exit(1);
8321 }8437 }
8322 if ((err = cache_add_dep_file(&g->cache_hash, out_dep_path, true))) {8438 o_final_path = buf_alloc();
8323 fprintf(stderr, "failed to add C source dependencies to cache: %s\n", err_str(err));8439 os_path_join(artifact_dir, final_o_basename, o_final_path);
8440 if ((err = os_rename(out_obj_path, o_final_path))) {
8441 fprintf(stderr, "Unable to rename object: %s\n", err_str(err));
8324 exit(1);8442 exit(1);
8325 }8443 }
8444 } else {
8445 // cache hit
8446 artifact_dir = buf_alloc();
8447 os_path_join(o_dir, &digest, artifact_dir);
8448 o_final_path = buf_alloc();
8449 os_path_join(artifact_dir, final_o_basename, o_final_path);
8450 }
8451
8452 if (g->enable_cache) {
8453 cache_buf(&g->cache_hash, &digest);
8326 }8454 }
8455
8456 g->link_objects.append(o_final_path);
8457 g->caches_to_release.append(cache_hash);
8327}8458}
83288459
8329static void gen_c_objects(CodeGen *g) {8460static void gen_c_objects(CodeGen *g) {
...@@ -8338,6 +8469,8 @@ static void gen_c_objects(CodeGen *g) {...@@ -8338,6 +8469,8 @@ static void gen_c_objects(CodeGen *g) {
8338 exit(1);8469 exit(1);
8339 }8470 }
83408471
8472 codegen_add_time_event(g, "Compile C Code");
8473
8341 for (size_t c_file_i = 0; c_file_i < g->c_source_files.length; c_file_i += 1) {8474 for (size_t c_file_i = 0; c_file_i < g->c_source_files.length; c_file_i += 1) {
8342 CFile *c_file = g->c_source_files.at(c_file_i);8475 CFile *c_file = g->c_source_files.at(c_file_i);
8343 gen_c_object(g, self_exe_path, c_file);8476 gen_c_object(g, self_exe_path, c_file);
...@@ -8862,13 +8995,6 @@ static Error check_cache(CodeGen *g, Buf *manifest_dir, Buf *digest) {...@@ -8862,13 +8995,6 @@ static Error check_cache(CodeGen *g, Buf *manifest_dir, Buf *digest) {
8862 cache_list_of_buf(ch, g->forbidden_libs.items, g->forbidden_libs.length);8995 cache_list_of_buf(ch, g->forbidden_libs.items, g->forbidden_libs.length);
8863 cache_list_of_file(ch, g->link_objects.items, g->link_objects.length);8996 cache_list_of_file(ch, g->link_objects.items, g->link_objects.length);
8864 cache_list_of_file(ch, g->assembly_files.items, g->assembly_files.length);8997 cache_list_of_file(ch, g->assembly_files.items, g->assembly_files.length);
8865 for (size_t c_file_i = 0; c_file_i < g->c_source_files.length; c_file_i += 1) {
8866 CFile *c_file = g->c_source_files.at(c_file_i);
8867 cache_file(ch, buf_create_from_str(c_file->source_path));
8868 for (size_t opt_i = 0; opt_i < c_file->args.length; opt_i += 1) {
8869 cache_buf(ch, buf_create_from_str(c_file->args.at(opt_i)));
8870 }
8871 }
8872 cache_int(ch, g->emit_file_type);8998 cache_int(ch, g->emit_file_type);
8873 cache_int(ch, g->build_mode);8999 cache_int(ch, g->build_mode);
8874 cache_int(ch, g->out_type);9000 cache_int(ch, g->out_type);
...@@ -8908,13 +9034,27 @@ static Error check_cache(CodeGen *g, Buf *manifest_dir, Buf *digest) {...@@ -8908,13 +9034,27 @@ static Error check_cache(CodeGen *g, Buf *manifest_dir, Buf *digest) {
8908 cache_buf(ch, &g->libc->dynamic_linker_path);9034 cache_buf(ch, &g->libc->dynamic_linker_path);
8909 }9035 }
89109036
9037 gen_c_objects(g);
9038
8911 buf_resize(digest, 0);9039 buf_resize(digest, 0);
8912 if ((err = cache_hit(ch, digest)))9040 if ((err = cache_hit(ch, digest)))
8913 return err;9041 return err;
89149042
9043 if (ch->manifest_file_path != nullptr) {
9044 g->caches_to_release.append(ch);
9045 }
9046
8915 return ErrorNone;9047 return ErrorNone;
8916}9048}
89179049
9050static bool need_llvm_module(CodeGen *g) {
9051 return g->assembly_files.length != 0 || buf_len(&g->root_package->root_src_path) != 0;
9052}
9053
9054static bool compilation_is_already_done(CodeGen *g) {
9055 return !need_llvm_module(g) && g->link_objects.length == 1 && g->out_type == OutTypeObj;
9056}
9057
8918static void resolve_out_paths(CodeGen *g) {9058static void resolve_out_paths(CodeGen *g) {
8919 Buf *o_basename = buf_create_from_buf(g->root_out_name);9059 Buf *o_basename = buf_create_from_buf(g->root_out_name);
89209060
...@@ -8941,7 +9081,9 @@ static void resolve_out_paths(CodeGen *g) {...@@ -8941,7 +9081,9 @@ static void resolve_out_paths(CodeGen *g) {
8941 zig_unreachable();9081 zig_unreachable();
8942 }9082 }
89439083
8944 if (g->enable_cache || g->out_type != OutTypeObj) {9084 if (compilation_is_already_done(g)) {
9085 buf_init_from_str(&g->o_file_output_path, buf_ptr(g->link_objects.at(0)));
9086 } else if (g->enable_cache || g->out_type != OutTypeObj) {
8945 os_path_join(&g->artifact_dir, o_basename, &g->o_file_output_path);9087 os_path_join(&g->artifact_dir, o_basename, &g->o_file_output_path);
8946 } else if (g->wanted_output_file_path != nullptr && g->out_type == OutTypeObj) {9088 } else if (g->wanted_output_file_path != nullptr && g->out_type == OutTypeObj) {
8947 buf_init_from_buf(&g->o_file_output_path, g->wanted_output_file_path);9089 buf_init_from_buf(&g->o_file_output_path, g->wanted_output_file_path);
...@@ -8949,39 +9091,41 @@ static void resolve_out_paths(CodeGen *g) {...@@ -8949,39 +9091,41 @@ static void resolve_out_paths(CodeGen *g) {
8949 buf_init_from_buf(&g->o_file_output_path, o_basename);9091 buf_init_from_buf(&g->o_file_output_path, o_basename);
8950 }9092 }
89519093
8952 if (g->out_type == OutTypeObj) {9094 if (!g->enable_cache && g->wanted_output_file_path != nullptr) {
9095 buf_init_from_buf(&g->output_file_path, g->wanted_output_file_path);
9096 return;
9097 }
9098
9099 if (compilation_is_already_done(g)) {
8953 buf_init_from_buf(&g->output_file_path, &g->o_file_output_path);9100 buf_init_from_buf(&g->output_file_path, &g->o_file_output_path);
8954 } else if (g->out_type == OutTypeExe) {9101 return;
8955 if (!g->enable_cache && g->wanted_output_file_path != nullptr) {9102 }
8956 buf_init_from_buf(&g->output_file_path, g->wanted_output_file_path);
8957 } else {
8958 assert(g->root_out_name);
89599103
8960 Buf basename = BUF_INIT;9104 const char *extname;
8961 buf_init_from_buf(&basename, g->root_out_name);9105 switch (g->out_type) {
8962 buf_append_str(&basename, target_exe_file_ext(g->zig_target));9106 case OutTypeUnknown:
8963 if (g->enable_cache || g->is_test_build) {9107 zig_unreachable();
8964 os_path_join(&g->artifact_dir, &basename, &g->output_file_path);9108 case OutTypeObj:
8965 } else {9109 extname = target_o_file_ext(g->zig_target);
8966 buf_init_from_buf(&g->output_file_path, &basename);9110 break;
8967 }9111 case OutTypeExe:
8968 }9112 extname = target_exe_file_ext(g->zig_target);
8969 } else if (g->out_type == OutTypeLib) {9113 break;
8970 if (!g->enable_cache && g->wanted_output_file_path != nullptr) {9114 case OutTypeLib:
8971 buf_init_from_buf(&g->output_file_path, g->wanted_output_file_path);9115 extname = target_lib_file_ext(g->zig_target, g->is_static,
8972 } else {9116 g->version_major, g->version_minor, g->version_patch);
8973 Buf basename = BUF_INIT;9117 break;
8974 buf_init_from_buf(&basename, g->root_out_name);9118 }
8975 buf_append_str(&basename, target_lib_file_ext(g->zig_target, g->is_static,9119
8976 g->version_major, g->version_minor, g->version_patch));9120 assert(g->root_out_name);
8977 if (g->enable_cache) {9121
8978 os_path_join(&g->artifact_dir, &basename, &g->output_file_path);9122 Buf basename = BUF_INIT;
8979 } else {9123 buf_init_from_buf(&basename, g->root_out_name);
8980 buf_init_from_buf(&g->output_file_path, &basename);9124 buf_append_str(&basename, extname);
8981 }9125 if (g->enable_cache || g->is_test_build) {
8982 }9126 os_path_join(&g->artifact_dir, &basename, &g->output_file_path);
8983 } else {9127 } else {
8984 zig_unreachable();9128 buf_init_from_buf(&g->output_file_path, &basename);
8985 }9129 }
8986}9130}
89879131
...@@ -8991,14 +9135,11 @@ void codegen_build_and_link(CodeGen *g) {...@@ -8991,14 +9135,11 @@ void codegen_build_and_link(CodeGen *g) {
89919135
8992 detect_libc(g);9136 detect_libc(g);
89939137
8994 Buf *stage1_dir = get_stage1_cache_path();
8995 Buf *artifact_dir = buf_alloc();9138 Buf *artifact_dir = buf_alloc();
8996 Buf digest = BUF_INIT;9139 Buf digest = BUF_INIT;
8997 if (g->enable_cache) {9140 if (g->enable_cache) {
8998 codegen_add_time_event(g, "Check Cache");
8999
9000 Buf *manifest_dir = buf_alloc();9141 Buf *manifest_dir = buf_alloc();
9001 os_path_join(stage1_dir, buf_create_from_str("build"), manifest_dir);9142 os_path_join(g->cache_dir, buf_create_from_str("build"), manifest_dir);
90029143
9003 if ((err = check_cache(g, manifest_dir, &digest))) {9144 if ((err = check_cache(g, manifest_dir, &digest))) {
9004 if (err == ErrorCacheUnavailable) {9145 if (err == ErrorCacheUnavailable) {
...@@ -9009,7 +9150,10 @@ void codegen_build_and_link(CodeGen *g) {...@@ -9009,7 +9150,10 @@ void codegen_build_and_link(CodeGen *g) {
9009 exit(1);9150 exit(1);
9010 }9151 }
90119152
9012 os_path_join(stage1_dir, buf_create_from_str("artifact"), artifact_dir);9153 os_path_join(g->cache_dir, buf_create_from_str("artifact"), artifact_dir);
9154 } else {
9155 // There is a call to this in check_cache
9156 gen_c_objects(g);
9013 }9157 }
90149158
9015 if (g->enable_cache && buf_len(&digest) != 0) {9159 if (g->enable_cache && buf_len(&digest) != 0) {
...@@ -9022,7 +9166,6 @@ void codegen_build_and_link(CodeGen *g) {...@@ -9022,7 +9166,6 @@ void codegen_build_and_link(CodeGen *g) {
90229166
9023 gen_global_asm(g);9167 gen_global_asm(g);
9024 gen_root_source(g);9168 gen_root_source(g);
9025 gen_c_objects(g);
90269169
9027 if (g->enable_cache) {9170 if (g->enable_cache) {
9028 if ((err = cache_final(&g->cache_hash, &digest))) {9171 if ((err = cache_final(&g->cache_hash, &digest))) {
...@@ -9031,7 +9174,7 @@ void codegen_build_and_link(CodeGen *g) {...@@ -9031,7 +9174,7 @@ void codegen_build_and_link(CodeGen *g) {
9031 }9174 }
9032 os_path_join(artifact_dir, &digest, &g->artifact_dir);9175 os_path_join(artifact_dir, &digest, &g->artifact_dir);
9033 } else {9176 } else {
9034 buf_init_from_buf(&g->artifact_dir, &g->cache_dir);9177 buf_init_from_buf(&g->artifact_dir, g->cache_dir);
9035 }9178 }
9036 if ((err = os_make_path(&g->artifact_dir))) {9179 if ((err = os_make_path(&g->artifact_dir))) {
9037 fprintf(stderr, "Unable to create artifact directory: %s\n", err_str(err));9180 fprintf(stderr, "Unable to create artifact directory: %s\n", err_str(err));
...@@ -9040,14 +9183,8 @@ void codegen_build_and_link(CodeGen *g) {...@@ -9040,14 +9183,8 @@ void codegen_build_and_link(CodeGen *g) {
9040 resolve_out_paths(g);9183 resolve_out_paths(g);
90419184
9042 codegen_add_time_event(g, "Code Generation");9185 codegen_add_time_event(g, "Code Generation");
9043 if (g->out_type == OutTypeObj && g->c_source_files.length == 1) {9186
9044 assert(g->link_objects.length == 1);9187 if (need_llvm_module(g)) {
9045 if ((err = os_rename(g->link_objects.pop(), &g->o_file_output_path))) {
9046 fprintf(stderr, "unable to move object to '%s': %s\n",
9047 buf_ptr(&g->o_file_output_path), err_str(err));
9048 exit(1);
9049 }
9050 } else {
9051 do_code_gen(g);9188 do_code_gen(g);
9052 codegen_add_time_event(g, "LLVM Emit Output");9189 codegen_add_time_event(g, "LLVM Emit Output");
9053 zig_llvm_emit_output(g);9190 zig_llvm_emit_output(g);
...@@ -9056,14 +9193,15 @@ void codegen_build_and_link(CodeGen *g) {...@@ -9056,14 +9193,15 @@ void codegen_build_and_link(CodeGen *g) {
9056 codegen_add_time_event(g, "Generate .h");9193 codegen_add_time_event(g, "Generate .h");
9057 gen_h_file(g);9194 gen_h_file(g);
9058 }9195 }
9059 if (g->out_type != OutTypeObj && g->emit_file_type == EmitFileTypeBinary) {9196 }
9060 codegen_link(g);9197
9061 }9198 if (g->emit_file_type == EmitFileTypeBinary && !compilation_is_already_done(g)) {
9199 codegen_link(g);
9062 }9200 }
9063 }9201 }
90649202
9065 if (g->enable_cache) {9203 while (g->caches_to_release.length != 0) {
9066 cache_release(&g->cache_hash);9204 cache_release(g->caches_to_release.pop());
9067 }9205 }
9068 codegen_add_time_event(g, "Done");9206 codegen_add_time_event(g, "Done");
9069}9207}
src/codegen.hpp+2-1
...@@ -16,7 +16,8 @@...@@ -16,7 +16,8 @@
16#include <stdio.h>16#include <stdio.h>
1717
18CodeGen *codegen_create(Buf *main_pkg_path, Buf *root_src_path, const ZigTarget *target,18CodeGen *codegen_create(Buf *main_pkg_path, Buf *root_src_path, const ZigTarget *target,
19 OutType out_type, BuildMode build_mode, Buf *zig_lib_dir, Buf *override_std_dir, ZigLibCInstallation *libc);19 OutType out_type, BuildMode build_mode, Buf *zig_lib_dir, Buf *override_std_dir,
20 ZigLibCInstallation *libc, Buf *cache_dir);
2021
21void codegen_set_clang_argv(CodeGen *codegen, const char **args, size_t len);22void codegen_set_clang_argv(CodeGen *codegen, const char **args, size_t len);
22void codegen_set_llvm_argv(CodeGen *codegen, const char **args, size_t len);23void codegen_set_llvm_argv(CodeGen *codegen, const char **args, size_t len);
src/link.cpp+316-51
...@@ -9,6 +9,8 @@...@@ -9,6 +9,8 @@
9#include "config.h"9#include "config.h"
10#include "codegen.hpp"10#include "codegen.hpp"
11#include "analyze.hpp"11#include "analyze.hpp"
12#include "compiler.hpp"
13
1214
13struct LinkJob {15struct LinkJob {
14 CodeGen *codegen;16 CodeGen *codegen;
...@@ -17,18 +19,290 @@ struct LinkJob {...@@ -17,18 +19,290 @@ struct LinkJob {
17 HashMap<Buf *, bool, buf_hash, buf_eql_buf> rpath_table;19 HashMap<Buf *, bool, buf_hash, buf_eql_buf> rpath_table;
18};20};
1921
20static const char *get_libc_crt_file(CodeGen *g, const char *file) {22static CodeGen *create_child_codegen(CodeGen *parent_gen, Buf *root_src_path, OutType out_type,
21 assert(g->libc != nullptr);23 ZigLibCInstallation *libc)
22 Buf *out_buf = buf_alloc();24{
23 os_path_join(&g->libc->crt_dir, buf_create_from_str(file), out_buf);25 CodeGen *child_gen = codegen_create(nullptr, root_src_path, parent_gen->zig_target, out_type,
24 return buf_ptr(out_buf);26 parent_gen->build_mode, parent_gen->zig_lib_dir, parent_gen->zig_std_dir, libc, get_stage1_cache_path());
27 child_gen->out_h_path = nullptr;
28 child_gen->verbose_tokenize = parent_gen->verbose_tokenize;
29 child_gen->verbose_ast = parent_gen->verbose_ast;
30 child_gen->verbose_link = parent_gen->verbose_link;
31 child_gen->verbose_ir = parent_gen->verbose_ir;
32 child_gen->verbose_llvm_ir = parent_gen->verbose_llvm_ir;
33 child_gen->verbose_cimport = parent_gen->verbose_cimport;
34 child_gen->verbose_cc = parent_gen->verbose_cc;
35
36 codegen_set_strip(child_gen, parent_gen->strip_debug_symbols);
37 child_gen->disable_pic = parent_gen->disable_pic;
38 child_gen->valgrind_support = ValgrindSupportDisabled;
39
40 codegen_set_errmsg_color(child_gen, parent_gen->err_color);
41
42 codegen_set_mmacosx_version_min(child_gen, parent_gen->mmacosx_version_min);
43 codegen_set_mios_version_min(child_gen, parent_gen->mios_version_min);
44
45 child_gen->enable_cache = true;
46
47 return child_gen;
48}
49
50
51static bool target_is_glibc(CodeGen *g) {
52 return g->zig_target->os == OsLinux && target_abi_is_gnu(g->zig_target->abi);
53}
54
55static const char *build_libc_object(CodeGen *parent_gen, const char *name, CFile *c_file) {
56 CodeGen *child_gen = create_child_codegen(parent_gen, nullptr, OutTypeObj, nullptr);
57 codegen_set_out_name(child_gen, buf_create_from_str(name));
58 ZigList<CFile *> c_source_files = {0};
59 c_source_files.append(c_file);
60 child_gen->c_source_files = c_source_files;
61 codegen_build_and_link(child_gen);
62 return buf_ptr(&child_gen->output_file_path);
25}63}
2664
27static const char *get_libc_static_file(CodeGen *g, const char *file) {65static const char *path_from_libc(CodeGen *g, const char *subpath) {
28 assert(g->libc != nullptr);66 Buf *libc_dir = buf_alloc();
29 Buf *out_buf = buf_alloc();67 os_path_join(g->zig_lib_dir, buf_create_from_str("libc"), libc_dir);
30 os_path_join(&g->libc->static_lib_dir, buf_create_from_str(file), out_buf);68 Buf *result = buf_alloc();
31 return buf_ptr(out_buf);69 os_path_join(libc_dir, buf_create_from_str(subpath), result);
70 return buf_ptr(result);
71}
72
73static const char *get_libc_crt_file(CodeGen *parent, const char *file) {
74 if (parent->libc == nullptr && target_is_glibc(parent)) {
75 if (strcmp(file, "crti.o") == 0) {
76 CFile *c_file = allocate<CFile>(1);
77 c_file->source_path = path_from_libc(parent, "glibc" OS_SEP "sysdeps" OS_SEP "x86_64" OS_SEP "crti.S");
78 c_file->args.append("-I");
79 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "include"));
80 c_file->args.append("-I");
81 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "sysdeps" OS_SEP "generic"));
82 c_file->args.append("-D_LIBC_REENTRANT");
83 c_file->args.append("-include");
84 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "include" OS_SEP "libc-modules.h"));
85 c_file->args.append("-DMODULE_NAME=libc");
86 c_file->args.append("-include");
87 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "include" OS_SEP "libc-symbols.h"));
88 c_file->args.append("-DTOP_NAMESPACE=glibc");
89 c_file->args.append("-DASSEMBLER");
90
91 // this is a workaround for:
92 // glibc/sysdeps/x86_64/crti.S:64:2: error: invalid instruction mnemonic '_cet_endbr'
93 // _CET_ENDBR
94 // ^~~~~~~~~~
95 c_file->args.append("-D_CET_ENDBR=");
96
97 c_file->args.append("-g");
98 c_file->args.append("-Wa,--noexecstack");
99 return build_libc_object(parent, "crti", c_file);
100 } else if (strcmp(file, "crtn.o") == 0) {
101 CFile *c_file = allocate<CFile>(1);
102 c_file->source_path = path_from_libc(parent, "glibc" OS_SEP "sysdeps" OS_SEP "x86_64" OS_SEP "crtn.S");
103 c_file->args.append("-D_LIBC_REENTRANT");
104 c_file->args.append("-DMODULE_NAME=libc");
105 c_file->args.append("-DTOP_NAMESPACE=glibc");
106 c_file->args.append("-DASSEMBLER");
107 c_file->args.append("-g");
108 c_file->args.append("-Wa,--noexecstack");
109 return build_libc_object(parent, "crtn", c_file);
110 } else if (strcmp(file, "start.os") == 0) {
111 CFile *c_file = allocate<CFile>(1);
112 c_file->source_path = path_from_libc(parent, "glibc" OS_SEP "sysdeps" OS_SEP "x86_64" OS_SEP "start.S");
113 c_file->args.append("-I");
114 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "sysdeps" OS_SEP "x86_64"));
115 c_file->args.append("-I");
116 c_file->args.append(path_from_libc(parent, "glibc"));
117 c_file->args.append("-I");
118 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "include"));
119 c_file->args.append("-I");
120 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "sysdeps" OS_SEP "generic"));
121 c_file->args.append("-D_LIBC_REENTRANT");
122 c_file->args.append("-include");
123 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "include" OS_SEP "libc-modules.h"));
124 c_file->args.append("-DMODULE_NAME=libc");
125 c_file->args.append("-include");
126 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "include" OS_SEP "libc-symbols.h"));
127 c_file->args.append("-DPIC");
128 c_file->args.append("-DSHARED");
129 c_file->args.append("-DTOP_NAMESPACE=glibc");
130 c_file->args.append("-DASSEMBLER");
131 c_file->args.append("-g");
132 c_file->args.append("-Wa,--noexecstack");
133 return build_libc_object(parent, "start", c_file);
134 } else if (strcmp(file, "abi-note.o") == 0) {
135 CFile *c_file = allocate<CFile>(1);
136 c_file->source_path = path_from_libc(parent, "glibc" OS_SEP "csu" OS_SEP "abi-note.S");
137 c_file->args.append("-I");
138 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "include"));
139 c_file->args.append("-I");
140 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "csu"));
141 c_file->args.append("-D_LIBC_REENTRANT");
142 c_file->args.append("-DMODULE_NAME=libc");
143 c_file->args.append("-DTOP_NAMESPACE=glibc");
144 c_file->args.append("-DASSEMBLER");
145 c_file->args.append("-g");
146 c_file->args.append("-Wa,--noexecstack");
147 return build_libc_object(parent, "abi-note", c_file);
148 } else if (strcmp(file, "init.o") == 0) {
149 CFile *c_file = allocate<CFile>(1);
150 c_file->source_path = path_from_libc(parent, "glibc" OS_SEP "csu" OS_SEP "init.c");
151 c_file->args.append("-std=gnu11");
152 c_file->args.append("-fgnu89-inline");
153 c_file->args.append("-g");
154 c_file->args.append("-O2");
155 c_file->args.append("-fmerge-all-constants");
156 c_file->args.append("-fno-stack-protector");
157 c_file->args.append("-fmath-errno");
158 c_file->args.append("-I");
159 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "include"));
160 c_file->args.append("-I");
161 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "sysdeps" OS_SEP "generic"));
162 c_file->args.append("-DSTACK_PROTECTOR_LEVEL=0");
163 c_file->args.append("-ftls-model=initial-exec");
164 c_file->args.append("-D_LIBC_REENTRANT");
165 c_file->args.append("-include");
166 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "include" OS_SEP "libc-modules.h"));
167 c_file->args.append("-DMODULE_NAME=libc");
168 c_file->args.append("-include");
169 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "include" OS_SEP "libc-symbols.h"));
170 c_file->args.append("-DTOP_NAMESPACE=glibc");
171 return build_libc_object(parent, "init", c_file);
172 } else if (strcmp(file, "Scrt1.o") == 0) {
173 const char *start_os = get_libc_crt_file(parent, "start.os");
174 const char *abi_note_o = get_libc_crt_file(parent, "abi-note.o");
175 const char *init_o = get_libc_crt_file(parent, "init.o");
176 CodeGen *child_gen = create_child_codegen(parent, nullptr, OutTypeObj, nullptr);
177 codegen_set_out_name(child_gen, buf_create_from_str("Scrt1"));
178 codegen_add_object(child_gen, buf_create_from_str(start_os));
179 codegen_add_object(child_gen, buf_create_from_str(abi_note_o));
180 codegen_add_object(child_gen, buf_create_from_str(init_o));
181 codegen_build_and_link(child_gen);
182 return buf_ptr(&child_gen->output_file_path);
183 } else if (strcmp(file, "libc.so.6") == 0) {
184 Buf *glibc_dummy_root_src = buf_create_from_str(path_from_libc(parent, "symbols.zig"));
185 CodeGen *child_gen = create_child_codegen(parent, glibc_dummy_root_src, OutTypeLib, nullptr);
186 codegen_set_out_name(child_gen, buf_create_from_str("c"));
187 codegen_set_lib_version(child_gen, 6, 0, 0);
188 child_gen->is_static = false;
189 codegen_build_and_link(child_gen);
190 return buf_ptr(&child_gen->output_file_path);
191 } else if (strcmp(file, "libc_nonshared.a") == 0) {
192 CodeGen *child_gen = create_child_codegen(parent, nullptr, OutTypeLib, nullptr);
193 codegen_set_out_name(child_gen, buf_create_from_str("c_nonshared"));
194 child_gen->is_static = true;
195 {
196 CFile *c_file = allocate<CFile>(1);
197 c_file->source_path = path_from_libc(parent, "glibc" OS_SEP "csu" OS_SEP "elf-init.c");
198 c_file->args.append("-std=gnu11");
199 c_file->args.append("-fgnu89-inline");
200 c_file->args.append("-g");
201 c_file->args.append("-O2");
202 c_file->args.append("-fmerge-all-constants");
203 c_file->args.append("-fno-stack-protector");
204 c_file->args.append("-fmath-errno");
205 c_file->args.append("-fno-stack-protector");
206 c_file->args.append("-I");
207 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "include"));
208 c_file->args.append("-I");
209 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "sysdeps" OS_SEP "generic"));
210 c_file->args.append("-DSTACK_PROTECTOR_LEVEL=0");
211 c_file->args.append("-fPIC");
212 c_file->args.append("-fno-stack-protector");
213 c_file->args.append("-ftls-model=initial-exec");
214 c_file->args.append("-D_LIBC_REENTRANT");
215 c_file->args.append("-include");
216 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "include" OS_SEP "libc-modules.h"));
217 c_file->args.append("-DMODULE_NAME=libc");
218 c_file->args.append("-include");
219 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "include" OS_SEP "libc-symbols.h"));
220 c_file->args.append("-DPIC");
221 c_file->args.append("-DLIBC_NONSHARED=1");
222 c_file->args.append("-DTOP_NAMESPACE=glibc");
223 codegen_add_object(child_gen, buf_create_from_str(build_libc_object(parent, "elf-init", c_file)));
224 }
225 static const struct {
226 const char *name;
227 const char *path;
228 } deps[] = {
229 {"atexit", "glibc" OS_SEP "stdlib" OS_SEP "atexit.c"},
230 {"at_quick_exit", "glibc" OS_SEP "stdlib" OS_SEP "at_quick_exit.c"},
231 {"stat", "glibc" OS_SEP "io" OS_SEP "stat.c"},
232 {"fstat", "glibc" OS_SEP "io" OS_SEP "fstat.c"},
233 {"lstat", "glibc" OS_SEP "io" OS_SEP "lstat.c"},
234 {"stat64", "glibc" OS_SEP "io" OS_SEP "stat64.c"},
235 {"fstat64", "glibc" OS_SEP "io" OS_SEP "fstat64.c"},
236 {"lstat64", "glibc" OS_SEP "io" OS_SEP "lstat64.c"},
237 {"fstatat", "glibc" OS_SEP "io" OS_SEP "fstatat.c"},
238 {"fstatat64", "glibc" OS_SEP "io" OS_SEP "fstatat64.c"},
239 {"mknod", "glibc" OS_SEP "io" OS_SEP "mknod.c"},
240 {"mknodat", "glibc" OS_SEP "io" OS_SEP "mknodat.c"},
241 {"pthread_atfork", "glibc" OS_SEP "nptl" OS_SEP "pthread_atfork.c"},
242 {"warning-nop", "glibc" OS_SEP "debug" OS_SEP "warning-nop.c"},
243 {"stack_chk_fail_local", "glibc" OS_SEP "debug" OS_SEP "stack_chk_fail_local.c"},
244 };
245 for (size_t i = 0; i < array_length(deps); i += 1) {
246 CFile *c_file = allocate<CFile>(1);
247 c_file->source_path = path_from_libc(parent, deps[i].path);
248 c_file->args.append("-std=gnu11");
249 c_file->args.append("-fgnu89-inline");
250 c_file->args.append("-g");
251 c_file->args.append("-O2");
252 c_file->args.append("-fmerge-all-constants");
253 c_file->args.append("-fno-stack-protector");
254 c_file->args.append("-fmath-errno");
255 c_file->args.append("-ftls-model=initial-exec");
256 c_file->args.append("-I");
257 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "include"));
258 c_file->args.append("-I");
259 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "sysdeps" OS_SEP
260 "unix" OS_SEP "sysv" OS_SEP "linux" OS_SEP "x86_64"));
261 c_file->args.append("-I");
262 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "sysdeps" OS_SEP
263 "unix" OS_SEP "sysv" OS_SEP "linux" OS_SEP "x86"));
264 c_file->args.append("-I");
265 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "sysdeps" OS_SEP "x86"));
266 c_file->args.append("-I");
267 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "sysdeps" OS_SEP "x86" OS_SEP "nptl"));
268 c_file->args.append("-I");
269 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "sysdeps" OS_SEP
270 "unix" OS_SEP "sysv" OS_SEP "linux" OS_SEP "include"));
271 c_file->args.append("-I");
272 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "sysdeps" OS_SEP
273 "unix" OS_SEP "sysv" OS_SEP "linux"));
274 c_file->args.append("-I");
275 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "sysdeps" OS_SEP "nptl"));
276 c_file->args.append("-I");
277 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "sysdeps" OS_SEP "pthread"));
278 c_file->args.append("-I");
279 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "sysdeps" OS_SEP "x86_64"));
280 c_file->args.append("-I");
281 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "sysdeps" OS_SEP "generic"));
282 c_file->args.append("-I");
283 c_file->args.append(path_from_libc(parent, "glibc"));
284 c_file->args.append("-D_LIBC_REENTRANT");
285 c_file->args.append("-include");
286 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "include" OS_SEP "libc-modules.h"));
287 c_file->args.append("-DMODULE_NAME=libc");
288 c_file->args.append("-include");
289 c_file->args.append(path_from_libc(parent, "glibc" OS_SEP "include" OS_SEP "libc-symbols.h"));
290 c_file->args.append("-DPIC");
291 c_file->args.append("-DLIBC_NONSHARED=1");
292 c_file->args.append("-DTOP_NAMESPACE=glibc");
293 codegen_add_object(child_gen, buf_create_from_str(build_libc_object(parent, deps[i].name, c_file)));
294 }
295 codegen_build_and_link(child_gen);
296 return buf_ptr(&child_gen->output_file_path);
297 } else {
298 zig_unreachable();
299 }
300 } else {
301 assert(parent->libc != nullptr);
302 Buf *out_buf = buf_alloc();
303 os_path_join(&parent->libc->crt_dir, buf_create_from_str(file), out_buf);
304 return buf_ptr(out_buf);
305 }
32}306}
33307
34static Buf *build_a_raw(CodeGen *parent_gen, const char *aname, Buf *full_path) {308static Buf *build_a_raw(CodeGen *parent_gen, const char *aname, Buf *full_path) {
...@@ -41,30 +315,12 @@ static Buf *build_a_raw(CodeGen *parent_gen, const char *aname, Buf *full_path)...@@ -41,30 +315,12 @@ static Buf *build_a_raw(CodeGen *parent_gen, const char *aname, Buf *full_path)
41 child_out_type = OutTypeObj;315 child_out_type = OutTypeObj;
42 }316 }
43317
44 CodeGen *child_gen = codegen_create(nullptr, full_path, parent_gen->zig_target, child_out_type,
45 parent_gen->build_mode, parent_gen->zig_lib_dir, parent_gen->zig_std_dir,
46 parent_gen->libc);
47
48 child_gen->out_h_path = nullptr;
49 child_gen->verbose_tokenize = parent_gen->verbose_tokenize;
50 child_gen->verbose_ast = parent_gen->verbose_ast;
51 child_gen->verbose_link = parent_gen->verbose_link;
52 child_gen->verbose_ir = parent_gen->verbose_ir;
53 child_gen->verbose_llvm_ir = parent_gen->verbose_llvm_ir;
54 child_gen->verbose_cimport = parent_gen->verbose_cimport;
55318
56 codegen_set_strip(child_gen, parent_gen->strip_debug_symbols);319 CodeGen *child_gen = create_child_codegen(parent_gen, full_path, child_out_type,
320 parent_gen->libc);
57 codegen_set_is_static(child_gen, true);321 codegen_set_is_static(child_gen, true);
58 child_gen->disable_pic = parent_gen->disable_pic;
59 child_gen->valgrind_support = ValgrindSupportDisabled;
60
61 codegen_set_out_name(child_gen, buf_create_from_str(aname));322 codegen_set_out_name(child_gen, buf_create_from_str(aname));
62323
63 codegen_set_errmsg_color(child_gen, parent_gen->err_color);
64
65 codegen_set_mmacosx_version_min(child_gen, parent_gen->mmacosx_version_min);
66 codegen_set_mios_version_min(child_gen, parent_gen->mios_version_min);
67
68 // This is so that compiler_rt and builtin libraries know whether they324 // This is so that compiler_rt and builtin libraries know whether they
69 // will eventually be linked with libc. They make different decisions325 // will eventually be linked with libc. They make different decisions
70 // about what to export depending on whether libc is linked.326 // about what to export depending on whether libc is linked.
...@@ -73,7 +329,6 @@ static Buf *build_a_raw(CodeGen *parent_gen, const char *aname, Buf *full_path)...@@ -73,7 +329,6 @@ static Buf *build_a_raw(CodeGen *parent_gen, const char *aname, Buf *full_path)
73 new_link_lib->provided_explicitly = parent_gen->libc_link_lib->provided_explicitly;329 new_link_lib->provided_explicitly = parent_gen->libc_link_lib->provided_explicitly;
74 }330 }
75331
76 child_gen->enable_cache = true;
77 codegen_build_and_link(child_gen);332 codegen_build_and_link(child_gen);
78 return &child_gen->output_file_path;333 return &child_gen->output_file_path;
79}334}
...@@ -180,7 +435,9 @@ static void construct_linker_job_elf(LinkJob *lj) {...@@ -180,7 +435,9 @@ static void construct_linker_job_elf(LinkJob *lj) {
180 lj->args.append(g->linker_script);435 lj->args.append(g->linker_script);
181 }436 }
182437
183 lj->args.append("--gc-sections");438 if (g->out_type != OutTypeObj) {
439 lj->args.append("--gc-sections");
440 }
184441
185 lj->args.append("-m");442 lj->args.append("-m");
186 lj->args.append(getLDMOption(g->zig_target));443 lj->args.append(getLDMOption(g->zig_target));
...@@ -211,20 +468,15 @@ static void construct_linker_job_elf(LinkJob *lj) {...@@ -211,20 +468,15 @@ static void construct_linker_job_elf(LinkJob *lj) {
211468
212 if (lj->link_in_crt) {469 if (lj->link_in_crt) {
213 const char *crt1o;470 const char *crt1o;
214 const char *crtbegino;
215 if (g->zig_target->os == OsNetBSD) {471 if (g->zig_target->os == OsNetBSD) {
216 crt1o = "crt0.o";472 crt1o = "crt0.o";
217 crtbegino = "crtbegin.o";
218 } else if (g->is_static) {473 } else if (g->is_static) {
219 crt1o = "crt1.o";474 crt1o = "crt1.o";
220 crtbegino = "crtbeginT.o";
221 } else {475 } else {
222 crt1o = "Scrt1.o";476 crt1o = "Scrt1.o";
223 crtbegino = "crtbegin.o";
224 }477 }
225 lj->args.append(get_libc_crt_file(g, crt1o));478 lj->args.append(get_libc_crt_file(g, crt1o));
226 lj->args.append(get_libc_crt_file(g, "crti.o"));479 lj->args.append(get_libc_crt_file(g, "crti.o"));
227 lj->args.append(get_libc_static_file(g, crtbegino));
228 }480 }
229481
230 for (size_t i = 0; i < g->rpath_list.length; i += 1) {482 for (size_t i = 0; i < g->rpath_list.length; i += 1) {
...@@ -259,22 +511,28 @@ static void construct_linker_job_elf(LinkJob *lj) {...@@ -259,22 +511,28 @@ static void construct_linker_job_elf(LinkJob *lj) {
259 }511 }
260512
261 if (g->libc_link_lib != nullptr) {513 if (g->libc_link_lib != nullptr) {
262 assert(g->libc != nullptr);514 if (g->libc != nullptr) {
263 lj->args.append("-L");515 lj->args.append("-L");
264 lj->args.append(buf_ptr(&g->libc->crt_dir));516 lj->args.append(buf_ptr(&g->libc->crt_dir));
517
518 if (!buf_eql_buf(&g->libc->crt_dir, &g->libc->lib_dir)) {
519 lj->args.append("-L");
520 lj->args.append(buf_ptr(&g->libc->lib_dir));
521 }
265522
266 if (!buf_eql_buf(&g->libc->crt_dir, &g->libc->lib_dir)) {
267 lj->args.append("-L");523 lj->args.append("-L");
268 lj->args.append(buf_ptr(&g->libc->lib_dir));524 lj->args.append(buf_ptr(&g->libc->static_lib_dir));
269 }525 }
270526
271 lj->args.append("-L");
272 lj->args.append(buf_ptr(&g->libc->static_lib_dir));
273
274 if (!g->is_static) {527 if (!g->is_static) {
275 assert(buf_len(&g->libc->dynamic_linker_path) != 0);528 if (g->libc != nullptr) {
276 lj->args.append("-dynamic-linker");529 assert(buf_len(&g->libc->dynamic_linker_path) != 0);
277 lj->args.append(buf_ptr(&g->libc->dynamic_linker_path));530 lj->args.append("-dynamic-linker");
531 lj->args.append(buf_ptr(&g->libc->dynamic_linker_path));
532 } else {
533 lj->args.append("-dynamic-linker");
534 lj->args.append(target_dynamic_linker(g->zig_target));
535 }
278 }536 }
279537
280 }538 }
...@@ -326,7 +584,7 @@ static void construct_linker_job_elf(LinkJob *lj) {...@@ -326,7 +584,7 @@ static void construct_linker_job_elf(LinkJob *lj) {
326 lj->args.append("-lc");584 lj->args.append("-lc");
327 lj->args.append("-lm");585 lj->args.append("-lm");
328 lj->args.append("--end-group");586 lj->args.append("--end-group");
329 } else {587 } else if (g->libc != nullptr) {
330 lj->args.append("-lgcc");588 lj->args.append("-lgcc");
331 lj->args.append("--as-needed");589 lj->args.append("--as-needed");
332 lj->args.append("-lgcc_s");590 lj->args.append("-lgcc_s");
...@@ -337,12 +595,16 @@ static void construct_linker_job_elf(LinkJob *lj) {...@@ -337,12 +595,16 @@ static void construct_linker_job_elf(LinkJob *lj) {
337 lj->args.append("--as-needed");595 lj->args.append("--as-needed");
338 lj->args.append("-lgcc_s");596 lj->args.append("-lgcc_s");
339 lj->args.append("--no-as-needed");597 lj->args.append("--no-as-needed");
598 } else if (target_is_glibc(g)) {
599 lj->args.append(get_libc_crt_file(g, "libc.so.6")); // this is our dummy so file
600 lj->args.append(get_libc_crt_file(g, "libc_nonshared.a"));
601 } else {
602 zig_unreachable();
340 }603 }
341 }604 }
342605
343 // crt end606 // crt end
344 if (lj->link_in_crt) {607 if (lj->link_in_crt) {
345 lj->args.append(get_libc_static_file(g, "crtend.o"));
346 lj->args.append(get_libc_crt_file(g, "crtn.o"));608 lj->args.append(get_libc_crt_file(g, "crtn.o"));
347 }609 }
348610
...@@ -975,7 +1237,6 @@ static void construct_linker_job(LinkJob *lj) {...@@ -975,7 +1237,6 @@ static void construct_linker_job(LinkJob *lj) {
975}1237}
9761238
977void codegen_link(CodeGen *g) {1239void codegen_link(CodeGen *g) {
978 assert(g->out_type != OutTypeObj);
979 codegen_add_time_event(g, "Build Dependencies");1240 codegen_add_time_event(g, "Build Dependencies");
9801241
981 LinkJob lj = {0};1242 LinkJob lj = {0};
...@@ -994,6 +1255,10 @@ void codegen_link(CodeGen *g) {...@@ -994,6 +1255,10 @@ void codegen_link(CodeGen *g) {
994 LLVMDumpModule(g->module);1255 LLVMDumpModule(g->module);
995 }1256 }
9961257
1258 if (g->out_type == OutTypeObj) {
1259 lj.args.append("-r");
1260 }
1261
997 if (g->out_type == OutTypeLib && g->is_static) {1262 if (g->out_type == OutTypeLib && g->is_static) {
998 ZigList<const char *> file_names = {};1263 ZigList<const char *> file_names = {};
999 for (size_t i = 0; i < g->link_objects.length; i += 1) {1264 for (size_t i = 0; i < g->link_objects.length; i += 1) {
src/main.cpp+20-36
...@@ -478,12 +478,6 @@ int main(int argc, char **argv) {...@@ -478,12 +478,6 @@ int main(int argc, char **argv) {
478478
479 ZigTarget target;479 ZigTarget target;
480 get_native_target(&target);480 get_native_target(&target);
481 CodeGen *g = codegen_create(main_pkg_path, build_runner_path, &target, OutTypeExe,
482 BuildModeDebug, get_zig_lib_dir(), override_std_dir, nullptr);
483 g->valgrind_support = valgrind_support;
484 g->enable_time_report = timing_info;
485 buf_init_from_str(&g->cache_dir, cache_dir ? cache_dir : default_zig_cache_name);
486 codegen_set_out_name(g, buf_create_from_str("build"));
487481
488 Buf *build_file_buf = buf_create_from_str(build_file);482 Buf *build_file_buf = buf_create_from_str(build_file);
489 Buf build_file_abs = os_path_resolve(&build_file_buf, 1);483 Buf build_file_abs = os_path_resolve(&build_file_buf, 1);
...@@ -491,7 +485,6 @@ int main(int argc, char **argv) {...@@ -491,7 +485,6 @@ int main(int argc, char **argv) {
491 Buf build_file_dirname = BUF_INIT;485 Buf build_file_dirname = BUF_INIT;
492 os_path_split(&build_file_abs, &build_file_dirname, &build_file_basename);486 os_path_split(&build_file_abs, &build_file_dirname, &build_file_basename);
493487
494
495 Buf full_cache_dir = BUF_INIT;488 Buf full_cache_dir = BUF_INIT;
496 if (cache_dir == nullptr) {489 if (cache_dir == nullptr) {
497 os_path_join(&build_file_dirname, buf_create_from_str(default_zig_cache_name), &full_cache_dir);490 os_path_join(&build_file_dirname, buf_create_from_str(default_zig_cache_name), &full_cache_dir);
...@@ -500,6 +493,12 @@ int main(int argc, char **argv) {...@@ -500,6 +493,12 @@ int main(int argc, char **argv) {
500 full_cache_dir = os_path_resolve(&cache_dir_buf, 1);493 full_cache_dir = os_path_resolve(&cache_dir_buf, 1);
501 }494 }
502495
496 CodeGen *g = codegen_create(main_pkg_path, build_runner_path, &target, OutTypeExe,
497 BuildModeDebug, get_zig_lib_dir(), override_std_dir, nullptr, &full_cache_dir);
498 g->valgrind_support = valgrind_support;
499 g->enable_time_report = timing_info;
500 codegen_set_out_name(g, buf_create_from_str("build"));
501
503 args.items[1] = buf_ptr(&build_file_dirname);502 args.items[1] = buf_ptr(&build_file_dirname);
504 args.items[2] = buf_ptr(&full_cache_dir);503 args.items[2] = buf_ptr(&full_cache_dir);
505504
...@@ -569,9 +568,9 @@ int main(int argc, char **argv) {...@@ -569,9 +568,9 @@ int main(int argc, char **argv) {
569 get_native_target(&target);568 get_native_target(&target);
570 Buf *fmt_runner_path = buf_alloc();569 Buf *fmt_runner_path = buf_alloc();
571 os_path_join(get_zig_special_dir(), buf_create_from_str("fmt_runner.zig"), fmt_runner_path);570 os_path_join(get_zig_special_dir(), buf_create_from_str("fmt_runner.zig"), fmt_runner_path);
571 Buf *cache_dir_buf = buf_create_from_str(cache_dir ? cache_dir : default_zig_cache_name);
572 CodeGen *g = codegen_create(main_pkg_path, fmt_runner_path, &target, OutTypeExe,572 CodeGen *g = codegen_create(main_pkg_path, fmt_runner_path, &target, OutTypeExe,
573 BuildModeDebug, get_zig_lib_dir(), nullptr, nullptr);573 BuildModeDebug, get_zig_lib_dir(), nullptr, nullptr, cache_dir_buf);
574 buf_init_from_str(&g->cache_dir, cache_dir ? cache_dir : default_zig_cache_name);
575 g->valgrind_support = valgrind_support;574 g->valgrind_support = valgrind_support;
576 g->is_single_threaded = true;575 g->is_single_threaded = true;
577 codegen_set_out_name(g, buf_create_from_str("fmt"));576 codegen_set_out_name(g, buf_create_from_str("fmt"));
...@@ -913,7 +912,7 @@ int main(int argc, char **argv) {...@@ -913,7 +912,7 @@ int main(int argc, char **argv) {
913 }912 }
914 case CmdBuiltin: {913 case CmdBuiltin: {
915 CodeGen *g = codegen_create(main_pkg_path, nullptr, &target,914 CodeGen *g = codegen_create(main_pkg_path, nullptr, &target,
916 out_type, build_mode, get_zig_lib_dir(), override_std_dir, nullptr);915 out_type, build_mode, get_zig_lib_dir(), override_std_dir, nullptr, nullptr);
917 g->valgrind_support = valgrind_support;916 g->valgrind_support = valgrind_support;
918 g->is_single_threaded = is_single_threaded;917 g->is_single_threaded = is_single_threaded;
919 Buf *builtin_source = codegen_generate_builtin_source(g);918 Buf *builtin_source = codegen_generate_builtin_source(g);
...@@ -941,30 +940,6 @@ int main(int argc, char **argv) {...@@ -941,30 +940,6 @@ int main(int argc, char **argv) {
941 } else if ((cmd == CmdTranslateC || cmd == CmdTest || cmd == CmdRun) && !in_file) {940 } else if ((cmd == CmdTranslateC || cmd == CmdTest || cmd == CmdRun) && !in_file) {
942 fprintf(stderr, "Expected source file argument.\n");941 fprintf(stderr, "Expected source file argument.\n");
943 return print_error_usage(arg0);942 return print_error_usage(arg0);
944 } else if (cmd == CmdBuild && out_type == OutTypeObj) {
945 if (objects.length != 0) {
946 fprintf(stderr,
947 "When building an object file, --object arguments are invalid.\n"
948 "Consider building a static library instead.\n");
949 return print_error_usage(arg0);
950 }
951 size_t zig_root_src_count = in_file ? 1 : 0;
952 if (zig_root_src_count + c_source_files.length > 1) {
953 fprintf(stderr,
954 "When building an object file, only one of these allowed:\n"
955 " * Zig root source file argument\n"
956 " * --c-source argument\n"
957 "Consider building a static library instead.\n");
958 return print_error_usage(arg0);
959 }
960 if (c_source_files.length != 0 && asm_files.length != 0) {
961 fprintf(stderr,
962 "When building an object file, only one of these allowed:\n"
963 " * --assembly argument\n"
964 " * --c-source argument\n"
965 "Consider building a static library instead.\n");
966 return print_error_usage(arg0);
967 }
968 }943 }
969944
970 assert(cmd != CmdBuild || out_type != OutTypeUnknown);945 assert(cmd != CmdBuild || out_type != OutTypeUnknown);
...@@ -1016,8 +991,18 @@ int main(int argc, char **argv) {...@@ -1016,8 +991,18 @@ int main(int argc, char **argv) {
1016 return EXIT_FAILURE;991 return EXIT_FAILURE;
1017 }992 }
1018 }993 }
994 Buf *cache_dir_buf;
995 if (cache_dir == nullptr) {
996 if (cmd == CmdRun) {
997 cache_dir_buf = get_stage1_cache_path();
998 } else {
999 cache_dir_buf = buf_create_from_str(default_zig_cache_name);
1000 }
1001 } else {
1002 cache_dir_buf = buf_create_from_str(cache_dir);
1003 }
1019 CodeGen *g = codegen_create(main_pkg_path, zig_root_source_file, &target, out_type, build_mode,1004 CodeGen *g = codegen_create(main_pkg_path, zig_root_source_file, &target, out_type, build_mode,
1020 get_zig_lib_dir(), override_std_dir, libc);1005 get_zig_lib_dir(), override_std_dir, libc, cache_dir_buf);
1021 g->valgrind_support = valgrind_support;1006 g->valgrind_support = valgrind_support;
1022 g->subsystem = subsystem;1007 g->subsystem = subsystem;
10231008
...@@ -1030,7 +1015,6 @@ int main(int argc, char **argv) {...@@ -1030,7 +1015,6 @@ int main(int argc, char **argv) {
1030 }1015 }
10311016
1032 g->enable_time_report = timing_info;1017 g->enable_time_report = timing_info;
1033 buf_init_from_str(&g->cache_dir, cache_dir ? cache_dir : default_zig_cache_name);
1034 codegen_set_out_name(g, buf_out_name);1018 codegen_set_out_name(g, buf_out_name);
1035 codegen_set_lib_version(g, ver_major, ver_minor, ver_patch);1019 codegen_set_lib_version(g, ver_major, ver_minor, ver_patch);
1036 codegen_set_is_test(g, cmd == CmdTest);1020 codegen_set_is_test(g, cmd == CmdTest);
src/os.cpp+31-1
...@@ -54,6 +54,10 @@ typedef SSIZE_T ssize_t;...@@ -54,6 +54,10 @@ typedef SSIZE_T ssize_t;
54#include <link.h>54#include <link.h>
55#endif55#endif
5656
57#if defined(ZIG_OS_LINUX)
58#include <sys/auxv.h>
59#endif
60
57#if defined(ZIG_OS_FREEBSD) || defined(ZIG_OS_NETBSD)61#if defined(ZIG_OS_FREEBSD) || defined(ZIG_OS_NETBSD)
58#include <sys/sysctl.h>62#include <sys/sysctl.h>
59#endif63#endif
...@@ -1396,8 +1400,34 @@ Error os_make_dir(Buf *path) {...@@ -1396,8 +1400,34 @@ Error os_make_dir(Buf *path) {
1396#endif1400#endif
1397}1401}
13981402
1403static void init_rand() {
1404#if defined(ZIG_OS_WINDOWS)
1405 const char bytes[sizeof(unsigned)];
1406 unsigned seed;
1407 RtlGenRandom(bytes, sizeof(unsigned));
1408 memcpy(&seed, bytes, sizeof(unsigned));
1409 srand(seed);
1410#elif defined(ZIG_OS_LINUX)
1411 srand(*((unsigned*)getauxval(AT_RANDOM)));
1412#else
1413 int fd = open("/dev/urandom", O_RDONLY|O_CLOEXEC);
1414 if (fd == -1) {
1415 zig_panic("unable to open /dev/urandom");
1416 }
1417 const char bytes[sizeof(unsigned)];
1418 unsigned seed;
1419 while (read(fd, bytes, sizeof(unsigned)) == -1) {
1420 if (errno == EINTR) continue;
1421 zig_panic("unable to read /dev/urandom");
1422 }
1423 close(fd);
1424 memcpy(&seed, bytes, sizeof(unsigned));
1425 srand(seed);
1426#endif
1427}
1428
1399int os_init(void) {1429int os_init(void) {
1400 srand((unsigned)time(NULL));1430 init_rand();
1401#if defined(ZIG_OS_WINDOWS)1431#if defined(ZIG_OS_WINDOWS)
1402 _setmode(fileno(stdout), _O_BINARY);1432 _setmode(fileno(stdout), _O_BINARY);
1403 _setmode(fileno(stderr), _O_BINARY);1433 _setmode(fileno(stderr), _O_BINARY);
src/target.cpp+14
...@@ -1330,3 +1330,17 @@ ZigLLVM_EnvironmentType target_default_abi(ZigLLVM_ArchType arch, Os os) {...@@ -1330,3 +1330,17 @@ ZigLLVM_EnvironmentType target_default_abi(ZigLLVM_ArchType arch, Os os) {
1330 }1330 }
1331 zig_unreachable();1331 zig_unreachable();
1332}1332}
1333
1334bool target_abi_is_gnu(ZigLLVM_EnvironmentType abi) {
1335 switch (abi) {
1336 case ZigLLVM_GNU:
1337 case ZigLLVM_GNUABIN32:
1338 case ZigLLVM_GNUABI64:
1339 case ZigLLVM_GNUEABI:
1340 case ZigLLVM_GNUEABIHF:
1341 case ZigLLVM_GNUX32:
1342 return true;
1343 default:
1344 return false;
1345 }
1346}
src/target.hpp+1
...@@ -157,5 +157,6 @@ bool target_has_valgrind_support(const ZigTarget *target);...@@ -157,5 +157,6 @@ bool target_has_valgrind_support(const ZigTarget *target);
157bool target_is_darwin(const ZigTarget *target);157bool target_is_darwin(const ZigTarget *target);
158bool target_requires_libc(const ZigTarget *target);158bool target_requires_libc(const ZigTarget *target);
159bool target_supports_fpic(const ZigTarget *target);159bool target_supports_fpic(const ZigTarget *target);
160bool target_abi_is_gnu(ZigLLVM_EnvironmentType abi);
160161
161#endif162#endif
src/translate_c.cpp+1-1
...@@ -4778,7 +4778,7 @@ Error parse_h_file(ZigType *import, ZigList<ErrorMsg *> *errors, const char *tar...@@ -4778,7 +4778,7 @@ Error parse_h_file(ZigType *import, ZigList<ErrorMsg *> *errors, const char *tar
47784778
4779 Buf *out_dep_path = nullptr;4779 Buf *out_dep_path = nullptr;
4780 if (codegen->enable_cache) {4780 if (codegen->enable_cache) {
4781 Buf *prefix = buf_sprintf("%s" OS_SEP, buf_ptr(&codegen->cache_dir));4781 Buf *prefix = buf_sprintf("%s" OS_SEP, buf_ptr(codegen->cache_dir));
4782 out_dep_path = os_tmp_filename(prefix, buf_create_from_str(".d"));4782 out_dep_path = os_tmp_filename(prefix, buf_create_from_str(".d"));
4783 clang_argv.append("-MD");4783 clang_argv.append("-MD");
4784 clang_argv.append("-MF");4784 clang_argv.append("-MF");