aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Mitchener <bruce.mitchener@gmail.com>2013-08-04 00:32:45 +0800
committerAlon Zakai <alonzakai@gmail.com>2013-09-13 10:07:02 -0700
commit5c6e1633d218bd5b9c5077634829eb14d326308f (patch)
tree50a4fd55b51a0fab6506addf610a666afabaec9b
parent27d496610e0ef93c9805a6a1a77de3f053405c6b (diff)
Update libc headers to use musl headers.
-rw-r--r--src/settings.js1469
-rw-r--r--system/include/bsd/float.h91
-rw-r--r--system/include/bsd/readme.txt2
-rw-r--r--system/include/bsd/sys/mman.h180
-rw-r--r--system/include/bsd/sys/utsname.h70
-rw-r--r--system/include/compat/ctype.h17
-rw-r--r--system/include/compat/sys/timeb.h10
-rw-r--r--system/include/compat/xlocale.h2
-rw-r--r--system/include/dlfcn.h31
-rw-r--r--system/include/err.h95
-rw-r--r--system/include/features.h3
-rw-r--r--system/include/libc/_ansi.h135
-rw-r--r--system/include/libc/_syslist.h40
-rw-r--r--system/include/libc/aio.h69
-rw-r--r--system/include/libc/alloca.h26
-rw-r--r--system/include/libc/ar.h82
-rw-r--r--system/include/libc/argz.h33
-rw-r--r--system/include/libc/arpa/ftp.h35
-rw-r--r--system/include/libc/arpa/inet.h36
-rw-r--r--system/include/libc/arpa/nameser.h467
-rw-r--r--system/include/libc/arpa/nameser_compat.h2
-rw-r--r--system/include/libc/arpa/telnet.h251
-rw-r--r--system/include/libc/arpa/tftp.h31
-rw-r--r--system/include/libc/assert.h45
-rw-r--r--system/include/libc/bits/alltypes.h397
-rw-r--r--system/include/libc/bits/endian.h1
-rw-r--r--system/include/libc/bits/errno.h134
-rw-r--r--system/include/libc/bits/fcntl.h38
-rw-r--r--system/include/libc/bits/fenv.h34
-rw-r--r--system/include/libc/bits/float.h17
-rw-r--r--system/include/libc/bits/io.h0
-rw-r--r--system/include/libc/bits/ioctl.h197
-rw-r--r--system/include/libc/bits/ipc.h14
-rw-r--r--system/include/libc/bits/limits.h8
-rw-r--r--system/include/libc/bits/mman.h62
-rw-r--r--system/include/libc/bits/msg.h16
-rw-r--r--system/include/libc/bits/posix.h2
-rw-r--r--system/include/libc/bits/reg.h19
-rw-r--r--system/include/libc/bits/setjmp.h1
-rw-r--r--system/include/libc/bits/shm.h18
-rw-r--r--system/include/libc/bits/signal.h112
-rw-r--r--system/include/libc/bits/socket.h17
-rw-r--r--system/include/libc/bits/stat.h22
-rw-r--r--system/include/libc/bits/statfs.h7
-rw-r--r--system/include/libc/bits/stdarg.h4
-rw-r--r--system/include/libc/bits/stdint.h20
-rw-r--r--system/include/libc/bits/syscall.h696
-rw-r--r--system/include/libc/bits/termios.h160
-rw-r--r--system/include/libc/bits/user.h48
-rw-r--r--system/include/libc/byteswap.h26
-rw-r--r--system/include/libc/complex.h109
-rw-r--r--system/include/libc/cpio.h29
-rw-r--r--system/include/libc/crypt.h20
-rw-r--r--system/include/libc/ctype.h245
-rw-r--r--system/include/libc/dirent.h75
-rw-r--r--system/include/libc/dlfcn.h42
-rw-r--r--system/include/libc/elf.h2555
-rw-r--r--system/include/libc/endian.h81
-rw-r--r--system/include/libc/envlock.h15
-rw-r--r--system/include/libc/envz.h16
-rw-r--r--system/include/libc/err.h25
-rw-r--r--system/include/libc/errno.h30
-rw-r--r--system/include/libc/fastmath.h13
-rw-r--r--system/include/libc/fcntl.h176
-rw-r--r--system/include/libc/features.h32
-rw-r--r--system/include/libc/fenv.h28
-rw-r--r--system/include/libc/float.h34
-rw-r--r--system/include/libc/fnmatch.h74
-rw-r--r--system/include/libc/ftw.h42
-rw-r--r--system/include/libc/getopt.h209
-rw-r--r--system/include/libc/glob.h125
-rw-r--r--system/include/libc/grp.h116
-rw-r--r--system/include/libc/iconv.h74
-rw-r--r--system/include/libc/ieeefp.h256
-rw-r--r--system/include/libc/ifaddrs.h77
-rw-r--r--system/include/libc/inttypes.h479
-rw-r--r--system/include/libc/iso646.h33
-rw-r--r--system/include/libc/langinfo.h404
-rw-r--r--system/include/libc/lastlog.h1
-rw-r--r--system/include/libc/libgen.h18
-rw-r--r--system/include/libc/libintl.h25
-rw-r--r--system/include/libc/limits.h289
-rw-r--r--system/include/libc/link.h54
-rw-r--r--system/include/libc/locale.h142
-rw-r--r--system/include/libc/machine/_default_types.h121
-rw-r--r--system/include/libc/machine/_types.h8
-rw-r--r--system/include/libc/machine/ansi.h1
-rw-r--r--system/include/libc/machine/endian.h31
-rw-r--r--system/include/libc/machine/fastmath.h100
-rw-r--r--system/include/libc/machine/ieeefp.h376
-rw-r--r--system/include/libc/machine/malloc.h8
-rw-r--r--system/include/libc/machine/param.h1
-rw-r--r--system/include/libc/machine/setjmp-dj.h43
-rw-r--r--system/include/libc/machine/setjmp.h361
-rw-r--r--system/include/libc/machine/stdlib.h8
-rw-r--r--system/include/libc/machine/termios.h1
-rw-r--r--system/include/libc/machine/time.h19
-rw-r--r--system/include/libc/machine/types.h30
-rw-r--r--system/include/libc/malloc.h169
-rw-r--r--system/include/libc/math.h966
-rw-r--r--system/include/libc/memory.h1
-rw-r--r--system/include/libc/mntent.h44
-rw-r--r--system/include/libc/monetary.h23
-rw-r--r--system/include/libc/mqueue.h36
-rw-r--r--system/include/libc/net/ethernet.h55
-rw-r--r--system/include/libc/net/if.h135
-rw-r--r--system/include/libc/net/if_arp.h133
-rw-r--r--system/include/libc/net/route.h124
-rw-r--r--system/include/libc/netdb.h161
-rw-r--r--system/include/libc/netinet/ether.h14
-rw-r--r--system/include/libc/netinet/icmp6.h305
-rw-r--r--system/include/libc/netinet/if_ether.h126
-rw-r--r--system/include/libc/netinet/in.h336
-rw-r--r--system/include/libc/netinet/in_systm.h9
-rw-r--r--system/include/libc/netinet/ip.h186
-rw-r--r--system/include/libc/netinet/ip6.h142
-rw-r--r--system/include/libc/netinet/ip_icmp.h192
-rw-r--r--system/include/libc/netinet/tcp.h36
-rw-r--r--system/include/libc/netinet/udp.h35
-rw-r--r--system/include/libc/netpacket/packet.h44
-rw-r--r--system/include/libc/newlib.h2
-rw-r--r--system/include/libc/nl_types.h22
-rw-r--r--system/include/libc/paths.h35
-rw-r--r--system/include/libc/poll.h46
-rw-r--r--system/include/libc/process.h44
-rw-r--r--system/include/libc/pthread.h519
-rw-r--r--system/include/libc/pty.h18
-rw-r--r--system/include/libc/pwd.h95
-rw-r--r--system/include/libc/readme.txt3
-rw-r--r--system/include/libc/reent.h183
-rw-r--r--system/include/libc/regdef.h7
-rw-r--r--system/include/libc/regex.h146
-rw-r--r--system/include/libc/resolv.h144
-rw-r--r--system/include/libc/sched.h140
-rw-r--r--system/include/libc/search.h88
-rw-r--r--system/include/libc/semaphore.h35
-rw-r--r--system/include/libc/setjmp.h48
-rw-r--r--system/include/libc/shadow.h44
-rw-r--r--system/include/libc/signal.h265
-rw-r--r--system/include/libc/spawn.h74
-rw-r--r--system/include/libc/stdalign.h15
-rw-r--r--system/include/libc/stdarg.h61
-rw-r--r--system/include/libc/stdbool.h14
-rw-r--r--system/include/libc/stddef.h70
-rw-r--r--system/include/libc/stdint.h540
-rw-r--r--system/include/libc/stdio.h863
-rw-r--r--system/include/libc/stdio_ext.h34
-rw-r--r--system/include/libc/stdlib.h345
-rw-r--r--system/include/libc/stdnoreturn.h5
-rw-r--r--system/include/libc/string.h173
-rw-r--r--system/include/libc/strings.h54
-rw-r--r--system/include/libc/stropts.h139
-rw-r--r--system/include/libc/sys/_default_fcntl.h223
-rw-r--r--system/include/libc/sys/_types.h93
-rw-r--r--system/include/libc/sys/acct.h75
-rw-r--r--system/include/libc/sys/cachectl.h22
-rw-r--r--system/include/libc/sys/cdefs.h123
-rw-r--r--system/include/libc/sys/config.h255
-rw-r--r--system/include/libc/sys/custom_file.h2
-rw-r--r--system/include/libc/sys/dir.h8
-rw-r--r--system/include/libc/sys/dirent.h58
-rw-r--r--system/include/libc/sys/epoll.h67
-rw-r--r--system/include/libc/sys/errno.h192
-rw-r--r--system/include/libc/sys/eventfd.h26
-rw-r--r--system/include/libc/sys/fcntl.h6
-rw-r--r--system/include/libc/sys/features.h212
-rw-r--r--system/include/libc/sys/file.h21
-rw-r--r--system/include/libc/sys/fsuid.h20
-rw-r--r--system/include/libc/sys/iconvnls.h77
-rw-r--r--system/include/libc/sys/inotify.h57
-rw-r--r--system/include/libc/sys/io.h17
-rw-r--r--system/include/libc/sys/ioctl.h14
-rw-r--r--system/include/libc/sys/ipc.h42
-rw-r--r--system/include/libc/sys/klog.h (renamed from system/include/sys/io.h)8
-rw-r--r--system/include/libc/sys/lock.h24
-rw-r--r--system/include/libc/sys/mman.h55
-rw-r--r--system/include/libc/sys/mount.h72
-rw-r--r--system/include/libc/sys/msg.h51
-rw-r--r--system/include/libc/sys/mtio.h188
-rw-r--r--system/include/libc/sys/param.h48
-rw-r--r--system/include/libc/sys/personality.h6
-rw-r--r--system/include/libc/sys/poll.h2
-rw-r--r--system/include/libc/sys/prctl.h101
-rw-r--r--system/include/libc/sys/procfs.h65
-rw-r--r--system/include/libc/sys/ptrace.h96
-rw-r--r--system/include/libc/sys/queue.h471
-rw-r--r--system/include/libc/sys/reboot.h20
-rw-r--r--system/include/libc/sys/reent.h843
-rw-r--r--system/include/libc/sys/reg.h9
-rw-r--r--system/include/libc/sys/resource.h134
-rw-r--r--system/include/libc/sys/sched.h67
-rw-r--r--system/include/libc/sys/select.h42
-rw-r--r--system/include/libc/sys/sem.h82
-rw-r--r--system/include/libc/sys/sendfile.h22
-rw-r--r--system/include/libc/sys/shm.h61
-rw-r--r--system/include/libc/sys/signal.h316
-rw-r--r--system/include/libc/sys/signalfd.h44
-rw-r--r--system/include/libc/sys/socket.h299
-rw-r--r--system/include/libc/sys/stat.h299
-rw-r--r--system/include/libc/sys/statfs.h32
-rw-r--r--system/include/libc/sys/statvfs.h57
-rw-r--r--system/include/libc/sys/stdio.h27
-rw-r--r--system/include/libc/sys/string.h2
-rw-r--r--system/include/libc/sys/stropts.h1
-rw-r--r--system/include/libc/sys/swap.h21
-rw-r--r--system/include/libc/sys/syscall.h6
-rw-r--r--system/include/libc/sys/sysctl.h17
-rw-r--r--system/include/libc/sys/sysinfo.h36
-rw-r--r--system/include/libc/sys/syslimits.h65
-rw-r--r--system/include/libc/sys/syslog.h1
-rw-r--r--system/include/libc/sys/sysmacros.h15
-rw-r--r--system/include/libc/sys/termios.h282
-rw-r--r--system/include/libc/sys/time.h108
-rw-r--r--system/include/libc/sys/timerfd.h24
-rw-r--r--system/include/libc/sys/times.h30
-rw-r--r--system/include/libc/sys/timex.h98
-rw-r--r--system/include/libc/sys/ttydefaults.h126
-rw-r--r--system/include/libc/sys/types.h568
-rw-r--r--system/include/libc/sys/ucontext.h1
-rw-r--r--system/include/libc/sys/uio.h48
-rw-r--r--system/include/libc/sys/un.h13
-rw-r--r--system/include/libc/sys/unistd.h513
-rw-r--r--system/include/libc/sys/user.h16
-rw-r--r--system/include/libc/sys/utime.h26
-rw-r--r--system/include/libc/sys/utsname.h30
-rw-r--r--system/include/libc/sys/vfs.h1
-rw-r--r--system/include/libc/sys/wait.h67
-rw-r--r--system/include/libc/sys/xattr.h30
-rw-r--r--system/include/libc/syscall.h1
-rw-r--r--system/include/libc/sysexits.h21
-rw-r--r--system/include/libc/syslog.h104
-rw-r--r--system/include/libc/tar.h60
-rw-r--r--system/include/libc/termios.h41
-rw-r--r--system/include/libc/tgmath.h270
-rw-r--r--system/include/libc/time.h333
-rw-r--r--system/include/libc/ucontext.h25
-rw-r--r--system/include/libc/ulimit.h17
-rw-r--r--system/include/libc/unctrl.h46
-rw-r--r--system/include/libc/unistd.h521
-rw-r--r--system/include/libc/utime.h18
-rw-r--r--system/include/libc/utmp.h41
-rw-r--r--system/include/libc/utmpx.h58
-rw-r--r--system/include/libc/values.h39
-rw-r--r--system/include/libc/wchar.h339
-rw-r--r--system/include/libc/wctype.h104
-rw-r--r--system/include/libc/wordexp.h73
-rw-r--r--system/include/memory.h10
-rw-r--r--system/include/mntent.h23
-rw-r--r--system/include/net/arpa/inet.h32
-rw-r--r--system/include/net/arpa/nameser.h535
-rw-r--r--system/include/net/arpa/nameser_compat.h187
-rw-r--r--system/include/net/if.h106
-rw-r--r--system/include/net/netinet/in.h230
-rw-r--r--system/include/net/netinet/tcp.h246
-rw-r--r--system/include/net/resolv.h389
-rw-r--r--system/include/netdb.h131
-rw-r--r--system/include/nl_types.h19
-rw-r--r--system/include/poll.h3
-rw-r--r--system/include/pty.h6
-rw-r--r--system/include/semaphore.h31
-rw-r--r--system/include/spawn.h105
-rw-r--r--system/include/stdbool.h16
-rw-r--r--system/include/sys/bitypes.h3
-rw-r--r--system/include/sys/ioctl.h78
-rw-r--r--system/include/sys/poll.h31
-rw-r--r--system/include/sys/select.h16
-rw-r--r--system/include/sys/sendfile.h16
-rw-r--r--system/include/sys/socket.h247
-rw-r--r--system/include/sys/socketvar.h3
-rw-r--r--system/include/sys/statvfs.h32
-rw-r--r--system/include/sys/sysctl.h14
-rw-r--r--system/include/sys/uio.h22
-rw-r--r--system/include/sys/un.h66
-rw-r--r--system/include/sysexits.h108
-rw-r--r--system/include/xlocale.h42
275 files changed, 15817 insertions, 16223 deletions
diff --git a/src/settings.js b/src/settings.js
index 1ef0cd58..e00f4e59 100644
--- a/src/settings.js
+++ b/src/settings.js
@@ -441,1057 +441,422 @@ var DEBUG_TAGS_SHOWING = [];
// If you modify the headers or use different ones, you will need
// to override this.
var C_DEFINES = {
- 'ABDAY_1': '14',
- 'ABDAY_2': '15',
- 'ABDAY_3': '16',
- 'ABDAY_4': '17',
- 'ABDAY_5': '18',
- 'ABDAY_6': '19',
- 'ABDAY_7': '20',
- 'ABMON_1': '33',
- 'ABMON_10': '42',
- 'ABMON_11': '43',
- 'ABMON_12': '44',
- 'ABMON_2': '34',
- 'ABMON_3': '35',
- 'ABMON_4': '36',
- 'ABMON_5': '37',
- 'ABMON_6': '38',
- 'ABMON_7': '39',
- 'ABMON_8': '40',
- 'ABMON_9': '41',
- 'ACCESSPERMS': '0000400',
- 'AF_UNSPEC': '0',
- 'AF_INET': '2',
- 'AF_INET6': '10',
- 'ALLPERMS': '0004000',
- 'ALT_DIGITS': '49',
- 'AM_STR': '5',
- 'ARG_MAX': '4096',
- 'AT_EACCESS': '1',
- 'AT_FDCWD': '-2',
- 'AT_REMOVEDIR': '8',
- 'AT_SYMLINK_FOLLOW': '4',
- 'AT_SYMLINK_NOFOLLOW': '2',
- 'CHAR_BIT': '8',
- 'CHAR_MAX': '127',
- 'CHAR_MIN': '-128',
- 'CLK_TCK': '1000',
- 'CLOCKS_PER_SEC': '1000',
- 'CLOCK_ALLOWED': '1',
- 'CLOCK_DISABLED': '0',
- 'CLOCK_DISALLOWED': '0',
- 'CLOCK_ENABLED': '1',
- 'CODESET': '0',
- 'CRNCYSTR': '56',
- 'DAY_1': '7',
- 'DAY_2': '8',
- 'DAY_3': '9',
- 'DAY_4': '10',
- 'DAY_5': '11',
- 'DAY_6': '12',
- 'DAY_7': '13',
- 'DEFFILEMODE': '0000400',
- 'DOMAIN': '1',
- 'D_FMT': '2',
- 'D_MD_ORDER': '57',
- 'D_T_FMT': '1',
- 'EOF': '-1',
- 'ERA': '45',
- 'ERA_D_FMT': '46',
- 'ERA_D_T_FMT': '47',
- 'ERA_T_FMT': '48',
- 'FAPPEND': '8',
- 'FASYNC': '64',
- 'FCREAT': '512',
- 'FDEFER': '32',
- 'FD_CLOEXEC': '1',
- 'FD_SETSIZE': '64',
- 'FEXCL': '2048',
- 'FEXLOCK': '256',
- 'FIONREAD': '1',
- 'FLT_EVAL_METHOD': '0',
- 'FMARK': '16',
- 'FNBIO': '4096',
- 'FNDELAY': '16384',
- 'FNOCTTY': '32768',
- 'FNONBIO': '16384',
- 'FOPEN': '-1',
- 'FP_ILOGBNAN': '2147483647',
- 'FP_INFINITE': '1',
- 'FP_NAN': '0',
- 'FP_NORMAL': '4',
- 'FP_SUBNORMAL': '3',
- 'FP_ZERO': '2',
- 'FREAD': '1',
- 'FSHLOCK': '128',
- 'FSYNC': '8192',
- 'FTRUNC': '1024',
- 'FWRITE': '2',
- 'F_CNVT': '12',
- 'F_DUPFD': '0',
- 'F_DUPFD_CLOEXEC': '14',
- 'F_GETFD': '1',
- 'F_GETFL': '3',
- 'F_GETLK': '7',
- 'F_GETLK64': '20',
- 'F_GETOWN': '5',
- 'F_LOCK': '1',
- 'F_OK': '0',
- 'F_RDLCK': '1',
- 'F_RGETLK': '10',
- 'F_RSETLK': '11',
- 'F_RSETLKW': '13',
- 'F_SETFD': '2',
- 'F_SETFL': '4',
- 'F_SETLK': '8',
- 'F_SETLK64': '21',
- 'F_SETLKW': '9',
- 'F_SETLKW64': '22',
- 'F_SETOWN': '6',
- 'F_TEST': '3',
- 'F_TLOCK': '2',
- 'F_ULOCK': '0',
- 'F_UNLCK': '3',
- 'F_UNLKSYS': '4',
- 'F_WRLCK': '2',
- 'H8300': '1',
- 'HAVE_ABS': '1',
- 'HAVE_ALLOCA': '1',
- 'HAVE_ALLOCA_H': '1',
- 'HAVE_ATAN': '1',
- 'HAVE_ATAN2': '1',
- 'HAVE_ATOF': '1',
- 'HAVE_ATOI': '1',
- 'HAVE_BCOPY': '1',
- 'HAVE_CALLOC': '1',
- 'HAVE_CEIL': '1',
- 'HAVE_COPYSIGN': '1',
- 'HAVE_COS': '1',
- 'HAVE_COSF': '1',
- 'HAVE_CTYPE_H': '1',
- 'HAVE_FABS': '1',
- 'HAVE_FLOOR': '1',
- 'HAVE_FREE': '1',
- 'HAVE_GCC_ATOMICS': '1',
- 'HAVE_GCC_SYNC_LOCK_TEST_AND_SET': '1',
- 'HAVE_GETENV': '1',
- 'HAVE_INDEX': '1',
- 'HAVE_INTTYPES_H': '1',
- 'HAVE_ITOA': '1',
- 'HAVE_LOG': '1',
- 'HAVE_MALLOC': '1',
- 'HAVE_MATH_H': '1',
- 'HAVE_MEMCMP': '1',
- 'HAVE_MEMCPY': '1',
- 'HAVE_MEMMOVE': '1',
- 'HAVE_MEMSET': '1',
- 'HAVE_M_PI': '1',
- 'HAVE_NANOSLEEP': '1',
- 'HAVE_POW': '1',
- 'HAVE_PUTENV': '1',
- 'HAVE_QSORT': '1',
- 'HAVE_REALLOC': '1',
- 'HAVE_RINDEX': '1',
- 'HAVE_SCALBN': '1',
- 'HAVE_SETENV': '1',
- 'HAVE_SETJMP': '1',
- 'HAVE_SIGACTION': '1',
- 'HAVE_SIGNAL_H': '1',
- 'HAVE_SIN': '1',
- 'HAVE_SINF': '1',
- 'HAVE_SNPRINTF': '1',
- 'HAVE_SQRT': '1',
- 'HAVE_SSCANF': '1',
- 'HAVE_STDARG_H': '1',
- 'HAVE_STDDEF_H': '1',
- 'HAVE_STDINT_H': '1',
- 'HAVE_STDIO_H': '1',
- 'HAVE_STRCASECMP': '1',
- 'HAVE_STRCHR': '1',
- 'HAVE_STRCMP': '1',
- 'HAVE_STRDUP': '1',
- 'HAVE_STRICMP': '1',
- 'HAVE_STRING_H': '1',
- 'HAVE_STRLCAT': '1',
- 'HAVE_STRLCPY': '1',
- 'HAVE_STRLEN': '1',
- 'HAVE_STRNCASECMP': '1',
- 'HAVE_STRNCMP': '1',
- 'HAVE_STRRCHR': '1',
- 'HAVE_STRSTR': '1',
- 'HAVE_STRTOD': '1',
- 'HAVE_STRTOL': '1',
- 'HAVE_STRTOLL': '1',
- 'HAVE_STRTOUL': '1',
- 'HAVE_STRTOULL': '1',
- 'HAVE_SYSCONF': '1',
- 'HAVE_SYSCTLBYNAME': '1',
- 'HAVE_SYS_TYPES_H': '1',
- 'HAVE_UNSETENV': '1',
- 'HAVE_VSNPRINTF': '1',
- 'HAVE__LTOA': '1',
- 'HAVE__STRICMP': '1',
- 'HAVE__STRLWR': '1',
- 'HAVE__STRNICMP': '1',
- 'HAVE__STRREV': '1',
- 'HAVE__STRUPR': '1',
- 'HAVE__ULTOA': '1',
- 'HUGE_VAL': 'inf',
- 'INT_MAX': '2147483647',
- 'IPPROTO_TCP': '6',
- 'IPPROTO_UDP': '17',
- 'ITIMER_PROF': '2',
- 'ITIMER_REAL': '0',
- 'ITIMER_VIRTUAL': '1',
- 'LACKS_SYS_MMAN_H': '1',
- 'LONG_MAX': '2147483647',
- 'MAC_OS_X_VERSION_10_4': '1040',
- 'MAC_OS_X_VERSION_10_5': '1050',
- 'MAC_OS_X_VERSION_10_6': '1060',
- 'MALLOC_ALIGNMENT': '16',
- 'MATH_ERREXCEPT': '2',
- 'math_errhandling': '1',
- 'MATH_ERRNO': '1',
- 'MAXPATHLEN': '1024',
- 'MB_LEN_MAX': '1',
- 'MON_1': '21',
- 'MON_10': '30',
- 'MON_11': '31',
- 'MON_12': '32',
- 'MON_2': '22',
- 'MON_3': '23',
- 'MON_4': '24',
- 'MON_5': '25',
- 'MON_6': '26',
- 'MON_7': '27',
- 'MON_8': '28',
- 'MON_9': '29',
- 'M_1_PI': '0.318309886184',
- 'M_2_PI': '0.636619772368',
- 'M_2_SQRTPI': '1.1283791671',
- 'M_3PI_4': '2.35619449019',
- 'M_E': '2.71828182846',
- 'M_INVLN2': '1.44269504089',
- 'M_IVLN10': '0.434294481903',
- 'M_LN10': '2.30258509299',
- 'M_LN2': '0.69314718056',
- 'M_LN2HI': '0.693147180369',
- 'M_LN2LO': '1.90821492927e-10',
- 'M_LOG10E': '0.434294481903',
- 'M_LOG2E': '1.44269504089',
- 'M_LOG2_E': '0.69314718056',
- 'M_PI': '3.14159265359',
- 'M_PI_2': '1.57079632679',
- 'M_PI_4': '0.785398163397',
- 'M_SQRT1_2': '0.707106781187',
- 'M_SQRT2': '1.41421356237',
- 'M_SQRT3': '1.73205080757',
- 'M_SQRTPI': '1.77245385091',
- 'M_TWOPI': '6.28318530718',
- 'NBBY': '8',
- 'NL_ARGMAX': '32',
- 'NOEXPR': '53',
- 'NOSTR': '55',
- 'NO_ARG': '0',
- 'no_argument': '0',
- 'NSIG': '64',
- 'NULL': '0',
- 'OPTIONAL_ARG': '2',
- 'optional_argument': '2',
- 'OPT_ARG': '2',
- 'OVERFLOW': '3',
- 'O_ACCMODE': '3',
- 'O_APPEND': '8',
- 'O_BINARY': '65536',
- 'O_CLOEXEC': '262144',
- 'O_CREAT': '512',
- 'O_EXCL': '2048',
- 'O_NOCTTY': '32768',
- 'O_NOINHERIT': '262144',
- 'O_NONBLOCK': '16384',
- 'O_RDONLY': '0',
- 'O_RDWR': '2',
- 'O_SYNC': '8192',
- 'O_TEXT': '131072',
- 'O_TRUNC': '1024',
- 'O_WRONLY': '1',
- 'PATH_MAX': '4096',
- 'PF_INET': '2',
- 'PF_INET6': '6',
- 'PLOSS': '6',
- 'PM_STR': '6',
- 'POLLERR': '8',
- 'POLLHUP': '16',
- 'POLLPRI': '32',
- 'POLLIN': '1',
- 'POLLNVAL': '4',
- 'POLLOUT': '2',
- 'POSIX_FADV_DONTNEED': '135',
- 'PTHREAD_CREATE_DETACHED': '0',
- 'PTHREAD_CREATE_JOINABLE': '1',
- 'PTHREAD_EXPLICIT_SCHED': '2',
- 'PTHREAD_INHERIT_SCHED': '1',
- 'PTHREAD_MUTEX_DEFAULT': '3',
- 'PTHREAD_MUTEX_ERRORCHECK': '2',
- 'PTHREAD_MUTEX_NORMAL': '0',
- 'PTHREAD_MUTEX_RECURSIVE': '1',
- 'PTHREAD_PRIO_INHERIT': '1',
- 'PTHREAD_PRIO_NONE': '0',
- 'PTHREAD_PRIO_PROTECT': '2',
- 'PTHREAD_PROCESS_PRIVATE': '0',
- 'PTHREAD_PROCESS_SHARED': '1',
- 'PTHREAD_SCOPE_PROCESS': '0',
- 'PTHREAD_SCOPE_SYSTEM': '1',
- 'PTHREAD_STACK_MIN': '200',
- 'RADIXCHAR': '50',
- 'REQUIRED_ARG': '1',
- 'required_argument': '1',
- 'REQ_ARG': '1',
- 'R_OK': '4',
- 'SA_NOCLDSTOP': '1',
- 'SA_NODEFER': '4',
- 'SA_RESETHAND': '8',
- 'SA_SIGINFO': '2',
- 'SCHAR_MAX': '127',
- 'SCHAR_MIN': '-128',
- 'SCHED_FIFO': '1',
- 'SCHED_OTHER': '0',
- 'SCHED_RR': '2',
- 'SCHED_SPORADIC': '4',
- 'SDL_ALTIVEC_BLITTERS': '1',
- 'SDL_ASSEMBLY_ROUTINES': '1',
- 'SDL_ASSERT_LEVEL': '1',
- 'SDL_AUDIO_DRIVER_ANDROID': '1',
- 'SDL_AUDIO_DRIVER_COREAUDIO': '1',
- 'SDL_AUDIO_DRIVER_COREAUDIOIPHONE': '1',
- 'SDL_AUDIO_DRIVER_DISK': '1',
- 'SDL_AUDIO_DRIVER_DSOUND': '1',
- 'SDL_AUDIO_DRIVER_DUMMY': '1',
- 'SDL_AUDIO_DRIVER_NDS': '1',
- 'SDL_AUDIO_DRIVER_WINMM': '1',
- 'SDL_AUDIO_DRIVER_XAUDIO2': '1',
- 'SDL_HAPTIC_DINPUT': '1',
- 'SDL_HAPTIC_DISABLED': '1',
- 'SDL_HAPTIC_DUMMY': '1',
- 'SDL_HAPTIC_IOKIT': '1',
- 'SDL_HAPTIC_NDS': '1',
- 'SDL_IPHONE_KEYBOARD': '1',
- 'SDL_IPHONE_MAX_GFORCE': '5.0',
- 'SDL_JOYSTICK_ANDROID': '1',
- 'SDL_JOYSTICK_DINPUT': '1',
- 'SDL_JOYSTICK_DISABLED': '1',
- 'SDL_JOYSTICK_IOKIT': '1',
- 'SDL_JOYSTICK_NDS': '1',
- 'SDL_LOADSO_DISABLED': '1',
- 'SDL_LOADSO_DLOPEN': '1',
- 'SDL_LOADSO_WINDOWS': '1',
- 'SDL_POWER_MACOSX': '1',
- 'SDL_POWER_NINTENDODS': '1',
- 'SDL_POWER_UIKIT': '1',
- 'SDL_POWER_WINDOWS': '1',
- 'SDL_THREADS_DISABLED': '1',
- 'SDL_THREAD_PTHREAD': '1',
- 'SDL_THREAD_PTHREAD_RECURSIVE_MUTEX': '1',
- 'SDL_THREAD_WINDOWS': '1',
- 'SDL_TIMERS_DISABLED': '1',
- 'SDL_TIMER_NDS': '1',
- 'SDL_TIMER_UNIX': '1',
- 'SDL_TIMER_WINCE': '1',
- 'SDL_TIMER_WINDOWS': '1',
- 'SDL_VIDEO_DRIVER_ANDROID': '1',
- 'SDL_VIDEO_DRIVER_COCOA': '1',
- 'SDL_VIDEO_DRIVER_DUMMY': '1',
- 'SDL_VIDEO_DRIVER_NDS': '1',
- 'SDL_VIDEO_DRIVER_UIKIT': '1',
- 'SDL_VIDEO_DRIVER_WINDOWS': '1',
- 'SDL_VIDEO_DRIVER_X11': '1',
- 'SDL_VIDEO_DRIVER_X11_XINERAMA': '1',
- 'SDL_VIDEO_DRIVER_X11_XINPUT': '1',
- 'SDL_VIDEO_DRIVER_X11_XRANDR': '1',
- 'SDL_VIDEO_DRIVER_X11_XSCRNSAVER': '1',
- 'SDL_VIDEO_DRIVER_X11_XSHAPE': '1',
- 'SDL_VIDEO_DRIVER_X11_XVIDMODE': '1',
- 'SDL_VIDEO_OPENGL': '1',
- 'SDL_VIDEO_OPENGL_CGL': '1',
- 'SDL_VIDEO_OPENGL_ES': '1',
- 'SDL_VIDEO_OPENGL_GLX': '1',
- 'SDL_VIDEO_OPENGL_WGL': '1',
- 'SDL_VIDEO_RENDER_D3D': '1',
- 'SDL_VIDEO_RENDER_NDS': '0',
- 'SDL_VIDEO_RENDER_OGL': '1',
- 'SDL_VIDEO_RENDER_OGL_ES': '1',
- 'SDL_VIDEO_RENDER_OGL_ES2': '1',
- 'SEEK_CUR': '1',
- 'SEEK_END': '2',
- 'SEEK_SET': '0',
- 'SHRT_MAX': '32767',
- 'SHRT_MIN': '-32768',
- 'SIGABRT': '6',
- 'SIGALRM': '14',
- 'SIGBUS': '10',
- 'SIGCHLD': '20',
- 'SIGCLD': '20',
- 'SIGCONT': '19',
- 'SIGEMT': '7',
- 'SIGEV_NONE': '1',
- 'SIGEV_SIGNAL': '2',
- 'SIGEV_THREAD': '3',
- 'SIGFPE': '8',
- 'SIGHUP': '1',
- 'SIGILL': '4',
- 'SIGINT': '2',
- 'SIGIO': '23',
- 'SIGIOT': '6',
- 'SIGKILL': '9',
- 'SIGLOST': '29',
- 'SIGPIPE': '13',
- 'SIGPOLL': '23',
- 'SIGPROF': '27',
- 'SIGPWR': '19',
- 'SIGQUIT': '3',
- 'SIGRTMAX': '64',
- 'SIGRTMIN': '32',
- 'SIGSEGV': '11',
- 'SIGSTOP': '17',
- 'SIGSYS': '12',
- 'SIGTERM': '15',
- 'SIGTRAP': '5',
- 'SIGTSTP': '18',
- 'SIGTTIN': '21',
- 'SIGTTOU': '22',
- 'SIGURG': '16',
- 'SIGUSR1': '30',
- 'SIGUSR2': '31',
- 'SIGVTALRM': '26',
- 'SIGWINCH': '28',
- 'SIGXCPU': '24',
- 'SIGXFSZ': '25',
- 'SIG_BLOCK': '1',
- 'SIG_SETMASK': '0',
- 'SIG_UNBLOCK': '2',
- 'SING': '2',
- 'SIZEOF_VOIDP': '4',
- 'SI_ASYNCIO': '4',
- 'SI_MESGQ': '5',
- 'SI_QUEUE': '2',
- 'SI_TIMER': '3',
- 'SI_USER': '1',
- 'SOCK_DGRAM': '2',
- 'SOCK_STREAM': '1',
- 'STDC_HEADERS': '1',
- 'STDERR_FILENO': '3',
- 'STDIN_FILENO': '1',
- 'STDOUT_FILENO': '2',
- 'S_BLKSIZE': '1024',
- 'S_ENFMT': '0002000',
- 'S_IEXEC': '0000100',
- 'S_IFBLK': '0060000',
- 'S_IFCHR': '0020000',
- 'S_IFDIR': '0040000',
- 'S_IFIFO': '0010000',
- 'S_IFLNK': '0120000',
- 'S_IFMT': '0170000',
- 'S_IFREG': '0100000',
- 'S_IFSOCK': '0140000',
- 'S_IREAD': '0000400',
- 'S_IRGRP': '0000040',
- 'S_IROTH': '0000004',
- 'S_IRUSR': '0000400',
- 'S_IRWXG': '0000070',
- 'S_IRWXO': '0000007',
- 'S_IRWXU': '0000700',
- 'S_ISGID': '0002000',
- 'S_ISUID': '0004000',
- 'S_ISVTX': '0001000',
- 'S_IWGRP': '0000020',
- 'S_IWOTH': '0000002',
- 'S_IWRITE': '0000200',
- 'S_IWUSR': '0000200',
- 'S_IXGRP': '0000010',
- 'S_IXOTH': '0000001',
- 'S_IXUSR': '0000100',
- 'THOUSEP': '51',
- 'TIMER_ABSTIME': '4',
- 'TLOSS': '5',
- 'T_FMT': '3',
- 'T_FMT_AMPM': '4',
- 'UCHAR_MAX': '255',
- 'UINT_MAX': '2147483647',
- 'ULONG_MAX': '2147483647',
- 'UNDERFLOW': '4',
- 'USHRT_MAX': '65535',
- 'UTIME_NOW': '-2',
- 'UTIME_OMIT': '-1',
- 'W_OK': '2',
- 'X_OK': '1',
- 'YESEXPR': '52',
- 'YESSTR': '54',
- '_ATEXIT_SIZE': '32',
- '_CLOCKS_PER_SEC_': '1000',
- '_CS_GNU_LIBC_VERSION': '42',
- '_CS_GNU_LIBPTHREAD_VERSION': '43',
- '_CS_PATH': '0',
- '_CS_POSIX_V6_ILP32_OFF32_CFLAGS': '1',
- '_CS_POSIX_V6_ILP32_OFF32_LDFLAGS': '2',
- '_CS_POSIX_V6_ILP32_OFF32_LIBS': '3',
- '_CS_POSIX_V6_ILP32_OFFBIG_CFLAGS': '5',
- '_CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS': '6',
- '_CS_POSIX_V6_ILP32_OFFBIG_LIBS': '7',
- '_CS_POSIX_V6_LP64_OFF64_CFLAGS': '9',
- '_CS_POSIX_V6_LP64_OFF64_LDFLAGS': '10',
- '_CS_POSIX_V6_LP64_OFF64_LIBS': '11',
- '_CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS': '13',
- '_CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS': '14',
- '_CS_POSIX_V6_LPBIG_OFFBIG_LIBS': '15',
- '_CS_POSIX_V6_WIDTH_RESTRICTED_ENVS': '17',
- '_CS_POSIX_V7_ILP32_OFF32_CFLAGS': '1',
- '_CS_POSIX_V7_ILP32_OFF32_LDFLAGS': '2',
- '_CS_POSIX_V7_ILP32_OFF32_LIBS': '3',
- '_CS_POSIX_V7_ILP32_OFFBIG_CFLAGS': '5',
- '_CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS': '6',
- '_CS_POSIX_V7_ILP32_OFFBIG_LIBS': '7',
- '_CS_POSIX_V7_LP64_OFF64_CFLAGS': '9',
- '_CS_POSIX_V7_LP64_OFF64_LDFLAGS': '10',
- '_CS_POSIX_V7_LP64_OFF64_LIBS': '11',
- '_CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS': '13',
- '_CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS': '14',
- '_CS_POSIX_V7_LPBIG_OFFBIG_LIBS': '15',
- '_CS_POSIX_V7_THREADS_CFLAGS': '18',
- '_CS_POSIX_V7_THREADS_LDFLAGS': '19',
- '_CS_POSIX_V7_WIDTH_RESTRICTED_ENVS': '17',
- '_CS_V7_ENV': '20',
- '_CS_XBS5_ILP32_OFF32_CFLAGS': '1',
- '_CS_XBS5_ILP32_OFF32_LDFLAGS': '2',
- '_CS_XBS5_ILP32_OFF32_LIBS': '3',
- '_CS_XBS5_ILP32_OFF32_LINTFLAGS': '4',
- '_CS_XBS5_ILP32_OFFBIG_CFLAGS': '5',
- '_CS_XBS5_ILP32_OFFBIG_LDFLAGS': '6',
- '_CS_XBS5_ILP32_OFFBIG_LIBS': '7',
- '_CS_XBS5_ILP32_OFFBIG_LINTFLAGS': '8',
- '_CS_XBS5_LP64_OFF64_CFLAGS': '9',
- '_CS_XBS5_LP64_OFF64_LDFLAGS': '10',
- '_CS_XBS5_LP64_OFF64_LIBS': '11',
- '_CS_XBS5_LP64_OFF64_LINTFLAGS': '12',
- '_CS_XBS5_LPBIG_OFFBIG_CFLAGS': '13',
- '_CS_XBS5_LPBIG_OFFBIG_LDFLAGS': '14',
- '_CS_XBS5_LPBIG_OFFBIG_LIBS': '15',
- '_CS_XBS5_LPBIG_OFFBIG_LINTFLAGS': '16',
- '_DATE_FMT': '84',
- '_FAPPEND': '8',
- '_FASYNC': '64',
- '_FBINARY': '65536',
- '_FCREAT': '512',
- '_FDEFER': '32',
- '_FEXCL': '2048',
- '_FEXLOCK': '256',
- '_FLOAT_ARG': "<type 'float'>",
- '_FMARK': '16',
- '_FNBIO': '4096',
- '_FNDELAY': '16384',
- '_FNOCTTY': '32768',
- '_FNOINHERIT': '262144',
- '_FNONBLOCK': '16384',
- '_FOPEN': '-1',
- '_FREAD': '1',
- '_FSHLOCK': '128',
- '_FSYNC': '8192',
- '_FTEXT': '131072',
- '_FTRUNC': '1024',
- '_FWRITE': '2',
- '_IFBLK': '0060000',
- '_IFCHR': '0020000',
- '_IFDIR': '0040000',
- '_IFIFO': '0010000',
- '_IFLNK': '0120000',
- '_IFMT': '0170000',
- '_IFREG': '0100000',
- '_IFSOCK': '0140000',
- '_LARGEFILE64_SOURCE': '1',
- '_LIBC_LIMITS_H_': '1',
- '_LIMITS_H': '1',
- '_LONG_LONG_TYPE': "<type 'long'>",
- '_MB_EXTENDED_CHARSETS_ISO': '1',
- '_MB_EXTENDED_CHARSETS_WINDOWS': '1',
- '_M_LN2': '0.69314718056',
- '_NL_CTYPE_CODESET_NAME': '0',
- '_NL_CTYPE_MB_CUR_MAX': '85',
- '_NL_MESSAGES_CODESET': '86',
- '_NL_TIME_DATE_FMT': '84',
- '_NULL': '0',
- '_N_LISTS': '30',
- '_O_APPEND': '8',
- '_O_BINARY': '65536',
- '_O_CREAT': '512',
- '_O_EXCL': '2048',
- '_O_NOINHERIT': '262144',
- '_O_RAW': '65536',
- '_O_RDONLY': '0',
- '_O_RDWR': '2',
- '_O_TEXT': '131072',
- '_O_TRUNC': '1024',
- '_O_WRONLY': '1',
- '_PC_2_SYMLINKS': '13',
- '_PC_ALLOC_SIZE_MIN': '15',
- '_PC_ASYNC_IO': '9',
- '_PC_CHOWN_RESTRICTED': '6',
- '_PC_FILESIZEBITS': '12',
- '_PC_LINK_MAX': '0',
- '_PC_MAX_CANON': '1',
- '_PC_MAX_INPUT': '2',
- '_PC_NAME_MAX': '3',
- '_PC_NO_TRUNC': '7',
- '_PC_PATH_MAX': '4',
- '_PC_PIPE_BUF': '5',
- '_PC_POSIX_PERMISSIONS': '90',
- '_PC_POSIX_SECURITY': '91',
- '_PC_PRIO_IO': '10',
- '_PC_REC_INCR_XFER_SIZE': '16',
- '_PC_REC_MAX_XFER_SIZE': '17',
- '_PC_REC_MIN_XFER_SIZE': '18',
- '_PC_REC_XFER_ALIGN': '19',
- '_PC_SOCK_MAXBUF': '100',
- '_PC_SYMLINK_MAX': '14',
- '_PC_SYNC_IO': '11',
- '_PC_TIMESTAMP_RESOLUTION': '20',
- '_PC_VDISABLE': '8',
- '_POINTER_INT': "<type 'long'>",
- '_POSIX2_CHAR_TERM': '200112',
- '_POSIX2_C_BIND': '200112',
- '_POSIX2_C_DEV': '200112',
- '_POSIX2_RE_DUP_MAX': '255',
- '_POSIX2_SW_DEV': '200112',
- '_POSIX2_UPE': '200112',
- '_POSIX2_VERSION': '200112',
- '_POSIX_ADVISORY_INFO': '200112',
- '_POSIX_ASYNCHRONOUS_IO': '1',
- '_POSIX_BARRIERS': '200112',
- '_POSIX_CHOWN_RESTRICTED': '1',
- '_POSIX_CPUTIME': '1',
- '_POSIX_C_SOURCE': '2',
- '_POSIX_DEVCTL_DIRECTION': '1',
- '_POSIX_DEVICE_CONTROL': '1',
- '_POSIX_FSYNC': '200112',
- '_POSIX_INTERRUPT_CONTROL': '1',
- '_POSIX_IPV6': '200112',
- '_POSIX_JOB_CONTROL': '1',
- '_POSIX_MAPPED_FILES': '200112',
- '_POSIX_MEMLOCK': '1',
- '_POSIX_MEMLOCK_RANGE': '200112',
- '_POSIX_MEMORY_PROTECTION': '200112',
- '_POSIX_MESSAGE_PASSING': '200112',
- '_POSIX_MONOTONIC_CLOCK': '200112',
- '_POSIX_NO_TRUNC': '1',
- '_POSIX_PRIORITIZED_IO': '1',
- '_POSIX_PRIORITY_SCHEDULING': '200112',
- '_POSIX_RAW_SOCKETS': '200112',
- '_POSIX_READER_WRITER_LOCKS': '200112',
- '_POSIX_REALTIME_SIGNALS': '200112',
- '_POSIX_REGEXP': '1',
- '_POSIX_SAVED_IDS': '1',
- '_POSIX_SEMAPHORES': '200112',
- '_POSIX_SHARED_MEMORY_OBJECTS': '200112',
- '_POSIX_SHELL': '1',
- '_POSIX_SPAWN': '1',
- '_POSIX_SPIN_LOCKS': '200112',
- '_POSIX_SPORADIC_SERVER': '1',
- '_POSIX_SYNCHRONIZED_IO': '200112',
- '_POSIX_THREADS': '200112',
- '_POSIX_THREAD_ATTR_STACKADDR': '1',
- '_POSIX_THREAD_ATTR_STACKSIZE': '200112',
- '_POSIX_THREAD_CPUTIME': '1',
- '_POSIX_THREAD_PRIORITY_SCHEDULING': '200112',
- '_POSIX_THREAD_PRIO_INHERIT': '1',
- '_POSIX_THREAD_PRIO_PROTECT': '1',
- '_POSIX_THREAD_PROCESS_SHARED': '200112',
- '_POSIX_THREAD_SAFE_FUNCTIONS': '200112',
- '_POSIX_THREAD_SPORADIC_SERVER': '1',
- '_POSIX_TIMEOUTS': '1',
- '_POSIX_TIMERS': '1',
- '_POSIX_V6_ILP32_OFF32': '-1',
- '_POSIX_V6_ILP32_OFFBIG': '1',
- '_POSIX_V6_LP64_OFF64': '-1',
- '_POSIX_V6_LPBIG_OFFBIG': '-1',
- '_POSIX_VERSION': '200112',
- '_RAND48_ADD': '11',
- '_RAND48_MULT_0': '58989',
- '_RAND48_MULT_1': '57068',
- '_RAND48_MULT_2': '5',
- '_RAND48_SEED_0': '13070',
- '_RAND48_SEED_1': '43981',
- '_RAND48_SEED_2': '4660',
- '_READ_WRITE_RETURN_TYPE': "<type 'int'>",
- '_REENT_ASCTIME_SIZE': '26',
- '_REENT_EMERGENCY_SIZE': '25',
- '_REENT_SIGNAL_SIZE': '24',
- '_SC_2_CHAR_TERM': '107',
- '_SC_2_C_BIND': '108',
- '_SC_2_C_DEV': '109',
- '_SC_2_FORT_DEV': '110',
- '_SC_2_FORT_RUN': '111',
- '_SC_2_LOCALEDEF': '112',
- '_SC_2_PBS': '113',
- '_SC_2_PBS_ACCOUNTING': '114',
- '_SC_2_PBS_CHECKPOINT': '115',
- '_SC_2_PBS_LOCATE': '116',
- '_SC_2_PBS_MESSAGE': '117',
- '_SC_2_PBS_TRACK': '118',
- '_SC_2_SW_DEV': '119',
- '_SC_2_UPE': '120',
- '_SC_2_VERSION': '121',
- '_SC_ADVISORY_INFO': '54',
- '_SC_AIO_LISTIO_MAX': '34',
- '_SC_AIO_MAX': '35',
- '_SC_AIO_PRIO_DELTA_MAX': '36',
- '_SC_ARG_MAX': '0',
- '_SC_ASYNCHRONOUS_IO': '21',
- '_SC_ATEXIT_MAX': '55',
- '_SC_AVPHYS_PAGES': '12',
- '_SC_BARRIERS': '56',
- '_SC_BC_BASE_MAX': '57',
- '_SC_BC_DIM_MAX': '58',
- '_SC_BC_SCALE_MAX': '59',
- '_SC_BC_STRING_MAX': '60',
- '_SC_CHILD_MAX': '1',
- '_SC_CLK_TCK': '2',
- '_SC_CLOCK_SELECTION': '61',
- '_SC_COLL_WEIGHTS_MAX': '62',
- '_SC_CPUTIME': '63',
- '_SC_DELAYTIMER_MAX': '37',
- '_SC_EXPR_NEST_MAX': '64',
- '_SC_FSYNC': '22',
- '_SC_GETGR_R_SIZE_MAX': '50',
- '_SC_GETPW_R_SIZE_MAX': '51',
- '_SC_HOST_NAME_MAX': '65',
- '_SC_IOV_MAX': '66',
- '_SC_IPV6': '67',
- '_SC_JOB_CONTROL': '5',
- '_SC_LINE_MAX': '68',
- '_SC_LOGIN_NAME_MAX': '52',
- '_SC_MAPPED_FILES': '23',
- '_SC_MEMLOCK': '24',
- '_SC_MEMLOCK_RANGE': '25',
- '_SC_MEMORY_PROTECTION': '26',
- '_SC_MESSAGE_PASSING': '27',
- '_SC_MONOTONIC_CLOCK': '69',
- '_SC_MQ_OPEN_MAX': '13',
- '_SC_MQ_PRIO_MAX': '14',
- '_SC_NGROUPS_MAX': '3',
- '_SC_NPROCESSORS_CONF': '9',
- '_SC_NPROCESSORS_ONLN': '10',
- '_SC_OPEN_MAX': '4',
- '_SC_PAGESIZE': '8',
- '_SC_PAGE_SIZE': '8',
- '_SC_PHYS_PAGES': '11',
- '_SC_PRIORITIZED_IO': '28',
- '_SC_PRIORITY_SCHEDULING': '101',
- '_SC_RAW_SOCKETS': '70',
- '_SC_READER_WRITER_LOCKS': '71',
- '_SC_REALTIME_SIGNALS': '29',
- '_SC_REGEXP': '72',
- '_SC_RE_DUP_MAX': '73',
- '_SC_RTSIG_MAX': '15',
- '_SC_SAVED_IDS': '6',
- '_SC_SEMAPHORES': '30',
- '_SC_SEM_NSEMS_MAX': '16',
- '_SC_SEM_VALUE_MAX': '17',
- '_SC_SHARED_MEMORY_OBJECTS': '199',
- '_SC_SHELL': '74',
- '_SC_SIGQUEUE_MAX': '18',
- '_SC_SPAWN': '75',
- '_SC_SPIN_LOCKS': '76',
- '_SC_SPORADIC_SERVER': '77',
- '_SC_SS_REPL_MAX': '78',
- '_SC_STREAM_MAX': '100',
- '_SC_SYMLOOP_MAX': '79',
- '_SC_SYNCHRONIZED_IO': '32',
- '_SC_THREADS': '42',
- '_SC_THREAD_ATTR_STACKADDR': '43',
- '_SC_THREAD_ATTR_STACKSIZE': '44',
- '_SC_THREAD_CPUTIME': '80',
- '_SC_THREAD_DESTRUCTOR_ITERATIONS': '53',
- '_SC_THREAD_KEYS_MAX': '38',
- '_SC_THREAD_PRIORITY_SCHEDULING': '45',
- '_SC_THREAD_PRIO_CEILING': '47',
- '_SC_THREAD_PRIO_INHERIT': '46',
- '_SC_THREAD_PRIO_PROTECT': '47',
- '_SC_THREAD_PROCESS_SHARED': '48',
- '_SC_THREAD_ROBUST_PRIO_INHERIT': '122',
- '_SC_THREAD_ROBUST_PRIO_PROTECT': '123',
- '_SC_THREAD_SAFE_FUNCTIONS': '49',
- '_SC_THREAD_SPORADIC_SERVER': '81',
- '_SC_THREAD_STACK_MIN': '39',
- '_SC_THREAD_THREADS_MAX': '40',
- '_SC_TIMEOUTS': '82',
- '_SC_TIMERS': '33',
- '_SC_TIMER_MAX': '19',
- '_SC_TRACE': '83',
- '_SC_TRACE_EVENT_FILTER': '84',
- '_SC_TRACE_EVENT_NAME_MAX': '85',
- '_SC_TRACE_INHERIT': '86',
- '_SC_TRACE_LOG': '87',
- '_SC_TRACE_NAME_MAX': '88',
- '_SC_TRACE_SYS_MAX': '89',
- '_SC_TRACE_USER_EVENT_MAX': '90',
- '_SC_TTY_NAME_MAX': '41',
- '_SC_TYPED_MEMORY_OBJECTS': '91',
- '_SC_TZNAME_MAX': '20',
- '_SC_V6_ILP32_OFF32': '92',
- '_SC_V6_ILP32_OFFBIG': '93',
- '_SC_V6_LP64_OFF64': '94',
- '_SC_V6_LPBIG_OFFBIG': '95',
- '_SC_V7_ILP32_OFF32': '92',
- '_SC_V7_ILP32_OFFBIG': '93',
- '_SC_V7_LP64_OFF64': '94',
- '_SC_V7_LPBIG_OFFBIG': '95',
- '_SC_VERSION': '7',
- '_SC_XBS5_ILP32_OFF32': '92',
- '_SC_XBS5_ILP32_OFFBIG': '93',
- '_SC_XBS5_LP64_OFF64': '94',
- '_SC_XBS5_LPBIG_OFFBIG': '95',
- '_SC_XOPEN_CRYPT': '96',
- '_SC_XOPEN_ENH_I18N': '97',
- '_SC_XOPEN_LEGACY': '98',
- '_SC_XOPEN_REALTIME': '99',
- '_SC_XOPEN_REALTIME_THREADS': '102',
- '_SC_XOPEN_SHM': '103',
- '_SC_XOPEN_STREAMS': '104',
- '_SC_XOPEN_UNIX': '105',
- '_SC_XOPEN_UUCP': '124',
- '_SC_XOPEN_VERSION': '106',
- '_S_IEXEC': '0000100',
- '_S_IFCHR': '0020000',
- '_S_IFDIR': '0040000',
- '_S_IFIFO': '0010000',
- '_S_IFMT': '0170000',
- '_S_IFREG': '0100000',
- '_S_IREAD': '0000400',
- '_S_IWRITE': '0000200',
- '_TIME_T_': "<type 'long'>",
- '_UNIX98_THREAD_MUTEX_ATTRIBUTES': '1',
- '_XBS5_ILP32_OFF32': '-1',
- '_XBS5_ILP32_OFFBIG': '1',
- '_XBS5_LP64_OFF64': '-1',
- '_XBS5_LPBIG_OFFBIG': '-1',
- '_XOPEN_CRYPT': '1',
- '_XOPEN_ENH_I18N': '1',
- '_XOPEN_SHM': '1',
- '_XOPEN_VERSION': '600',
- '__AIX__': '1',
- '__ANDROID__': '1',
- '__BEOS__': '1',
- '__BSDI__': '1',
- '__BUFSIZ__': '16',
- '__DREAMCAST__': '1',
- '__FILENAME_MAX__': '255',
- '__FREEBSD__': '1',
- '__GNUC_VA_LIST': '1',
- '__HAIKU__': '1',
- '__HPUX__': '1',
- '__INT_MAX__': '2147483647',
- '__IPHONEOS__': '1',
- '__IRIX__': '1',
- '__LARGE64_FILES': '1',
- '__LINUX__': '1',
- '__long_double_t': "<type 'long'>",
- '__LONG_MAX__': '2147483647',
- '__MACOSX__': '1',
- '__NETBSD__': '1',
- '__NINTENDODS__': '1',
- '__OPENBSD__': '1',
- '__OS2__': '1',
- '__OSF__': '1',
- '__QNXNTO__': '1',
- '__RAND_MAX': '2147483647',
- '__RISCOS__': '1',
- '__SIGFIRSTNOTRT': '1',
- '__SIGLASTNOTRT': '31',
- '__SOLARIS__': '1',
- '__USE_XOPEN2K': '1',
- '__WIN32__': '1',
- '___int16_t_defined': '1',
- '___int32_t_defined': '1',
- '___int64_t_defined': '1',
- '___int8_t_defined': '1',
- '___int_least16_t_defined': '1',
- '___int_least32_t_defined': '1',
- '___int_least8_t_defined': '1',
- 'FMODE_READ': '0x1',
- 'FMODE_WRITE': '0x2',
- 'FMODE_LSEEK': '0x4',
- 'FMODE_PREAD': '0x8',
- 'FMODE_PWRITE': '0x10',
- 'FMODE_EXEC': '0x20',
- 'FMODE_NDELAY': '0x40',
- 'FMODE_EXCL': '0x80',
- 'FMODE_NOCMTIME': '0x800',
- 'FMODE_RANDOM': '0x1000',
- 'FMODE_UNSIGNED_OFFSET': '0x2000',
- 'FMODE_PATH': '0x4000',
- 'FMODE_NONOTIFY': '0x1000000',
- 'S_IRWXUGO': '511',
- 'S_IALLUGO': '4095',
- 'S_IRUGO': '292',
- 'S_IWUGO': '146',
- 'S_IXUGO': '73',
- 'LOOKUP_FOLLOW': '0x0001',
- 'LOOKUP_DIRECTORY': '0x0002',
- 'LOOKUP_PARENT': '0x0010',
- 'MAP_SHARED': '0x01',
- 'MAP_PRIVATE': '0x02',
- 'MAP_TYPE': '0x0f',
- 'MAP_FIXED': '0x100',
- 'MAP_ANONYMOUS': '0x10',
- 'O_NOFOLLOW': '0200000',
- 'EPERM': '1',
- 'ENOENT': '2',
- 'ESRCH': '3',
- 'EINTR': '4',
- 'EIO': '5',
- 'ENXIO': '6',
- 'E2BIG': '7',
- 'ENOEXEC': '8',
- 'EBADF': '9',
- 'ECHILD': '10',
- 'EAGAIN': '11',
- 'EWOULDBLOCK': '11',
- 'ENOMEM': '12',
- 'EACCES': '13',
- 'EFAULT': '14',
- 'ENOTBLK': '15',
- 'EBUSY': '16',
- 'EEXIST': '17',
- 'EXDEV': '18',
- 'ENODEV': '19',
- 'ENOTDIR': '20',
- 'EISDIR': '21',
- 'EINVAL': '22',
- 'ENFILE': '23',
- 'EMFILE': '24',
- 'ENOTTY': '25',
- 'ETXTBSY': '26',
- 'EFBIG': '27',
- 'ENOSPC': '28',
- 'ESPIPE': '29',
- 'EROFS': '30',
- 'EMLINK': '31',
- 'EPIPE': '32',
- 'EDOM': '33',
- 'ERANGE': '34',
- 'ENOMSG': '35',
- 'EIDRM': '36',
- 'ECHRNG': '37',
- 'EL2NSYNC': '38',
- 'EL3HLT': '39',
- 'EL3RST': '40',
- 'ELNRNG': '41',
- 'EUNATCH': '42',
- 'ENOCSI': '43',
- 'EL2HLT': '44',
- 'EDEADLK': '45',
- 'ENOLCK': '46',
- 'EBADE': '50',
- 'EBADR': '51',
- 'EXFULL': '52',
- 'ENOANO': '53',
- 'EBADRQC': '54',
- 'EBADSLT': '55',
- 'EDEADLOCK': '56',
- 'EBFONT': '57',
- 'ENOSTR': '60',
- 'ENODATA': '61',
- 'ETIME': '62',
- 'ENOSR': '63',
- 'ENONET': '64',
- 'ENOPKG': '65',
- 'EREMOTE': '66',
- 'ENOLINK': '67',
- 'EADV': '68',
- 'ESRMNT': '69',
- 'ECOMM': '70',
- 'EPROTO': '71',
- 'EMULTIHOP': '74',
- 'EDOTDOT': '76',
- 'EBADMSG': '77',
- 'ENOTUNIQ': '80',
- 'EBADFD': '81',
- 'EREMCHG': '82',
- 'ELIBACC': '83',
- 'ELIBBAD': '84',
- 'ELIBSCN': '85',
- 'ELIBMAX': '86',
- 'ELIBEXEC': '87',
- 'ENOSYS': '88',
- 'ENOTEMPTY': '90',
- 'ENAMETOOLONG': '91',
- 'ELOOP': '92',
- 'EOPNOTSUPP': '95',
- 'EPFNOSUPPORT': '96',
- 'ECONNRESET': '104',
- 'ENOBUFS': '105',
- 'EAFNOSUPPORT': '106',
- 'EPROTOTYPE': '107',
- 'ENOTSOCK': '108',
- 'ENOPROTOOPT': '109',
- 'ESHUTDOWN': '110',
- 'ECONNREFUSED': '111',
- 'EADDRINUSE': '112',
- 'ECONNABORTED': '113',
- 'ENETUNREACH': '114',
- 'ENETDOWN': '115',
- 'ETIMEDOUT': '116',
- 'EHOSTDOWN': '117',
- 'EHOSTUNREACH': '118',
- 'EINPROGRESS': '119',
- 'EALREADY': '120',
- 'EDESTADDRREQ': '121',
- 'EMSGSIZE': '122',
- 'EPROTONOSUPPORT': '123',
- 'ESOCKTNOSUPPORT': '124',
- 'EADDRNOTAVAIL': '125',
- 'ENETRESET': '126',
- 'EISCONN': '127',
- 'ENOTCONN': '128',
- 'ETOOMANYREFS': '129',
- 'EUSERS': '131',
- 'EDQUOT': '132',
- 'ESTALE': '133',
- 'ENOTSUP': '134',
- 'ENOMEDIUM': '135',
- 'EILSEQ': '138',
- 'EOVERFLOW': '139',
- 'ECANCELED': '140',
- 'ENOTRECOVERABLE': '141',
- 'EOWNERDEAD': '142',
- 'ESTRPIPE': '143',
- 'AI_PASSIVE': '0x0001',
- 'AI_CANONNAME': '0x0002',
- 'AI_NUMERICHOST': '0x0004',
- 'AI_V4MAPPED': '0x0008',
- 'AI_ALL': '0x0010',
- 'AI_ADDRCONFIG': '0x0020',
- 'AI_NUMERICSERV': '0x0400',
- 'EAI_ADDRFAMILY': '1',
- 'EAI_AGAIN': '2',
- 'EAI_BADFLAGS': '3',
- 'EAI_FAIL': '4',
- 'EAI_FAMILY': '5',
- 'EAI_MEMORY': '6',
- 'EAI_NODATA': '7',
- 'EAI_NONAME': '8',
- 'EAI_SERVICE': '9',
- 'EAI_SOCKTYPE': '10',
- 'EAI_SYSTEM': '11',
- 'EAI_BADHINTS': '12',
- 'EAI_PROTOCOL': '13',
- 'EAI_OVERFLOW': '14',
- 'EAI_MAX': '15',
- 'NI_NOFQDN': '0x00000001',
- 'NI_NUMERICHOST': '0x00000002',
- 'NI_NAMEREQD': '0x00000004',
- 'NI_NUMERICSERV': '0x00000008',
- 'NI_DGRAM': '0x00000010',
- 'INADDR_ANY': '0',
- 'INADDR_LOOPBACK': '0x7f000001'
+ 'ABDAY_1': '131072',
+ 'ABDAY_2': '131073',
+ 'ABDAY_3': '131074',
+ 'ABDAY_4': '131075',
+ 'ABDAY_5': '131076',
+ 'ABDAY_6': '131077',
+ 'ABDAY_7': '131078',
+ 'ABMON_1': '131086',
+ 'ABMON_10': '131095',
+ 'ABMON_11': '131096',
+ 'ABMON_12': '131097',
+ 'ABMON_2': '131087',
+ 'ABMON_3': '131088',
+ 'ABMON_4': '131089',
+ 'ABMON_5': '131090',
+ 'ABMON_6': '131091',
+ 'ABMON_7': '131092',
+ 'ABMON_8': '131093',
+ 'ABMON_9': '131094',
+ 'AF_INET': '2',
+ 'AF_INET6': '10',
+ 'AF_UNSPEC': '0',
+ 'AI_ADDRCONFIG': '32',
+ 'AI_ALL': '16',
+ 'AI_CANONNAME': '2',
+ 'AI_NUMERICHOST': '4',
+ 'AI_NUMERICSERV': '1024',
+ 'AI_PASSIVE': '1',
+ 'AI_V4MAPPED': '8',
+ 'ALT_DIGITS': '131119',
+ 'AM_STR': '131110',
+ 'CLOCKS_PER_SEC': '1000000',
+ 'CODESET': '14',
+ 'CRNCYSTR': '262159',
+ 'DAY_1': '131079',
+ 'DAY_2': '131080',
+ 'DAY_3': '131081',
+ 'DAY_4': '131082',
+ 'DAY_5': '131083',
+ 'DAY_6': '131084',
+ 'DAY_7': '131085',
+ 'D_FMT': '131113',
+ 'D_T_FMT': '131112',
+ 'E2BIG': '7',
+ 'EACCES': '13',
+ 'EADDRINUSE': '98',
+ 'EADDRNOTAVAIL': '99',
+ 'EADV': '68',
+ 'EAFNOSUPPORT': '97',
+ 'EAGAIN': '11',
+ 'EAI_BADFLAGS': '-1',
+ 'EAI_FAMILY': '-6',
+ 'EAI_NONAME': '-2',
+ 'EAI_OVERFLOW': '-12',
+ 'EAI_SERVICE': '-8',
+ 'EAI_SOCKTYPE': '-7',
+ 'EALREADY': '114',
+ 'EBADE': '52',
+ 'EBADF': '9',
+ 'EBADFD': '77',
+ 'EBADMSG': '74',
+ 'EBADR': '53',
+ 'EBADRQC': '56',
+ 'EBADSLT': '57',
+ 'EBFONT': '59',
+ 'EBUSY': '16',
+ 'ECANCELED': '125',
+ 'ECHILD': '10',
+ 'ECHRNG': '44',
+ 'ECOMM': '70',
+ 'ECONNABORTED': '103',
+ 'ECONNREFUSED': '111',
+ 'ECONNRESET': '104',
+ 'EDEADLK': '35',
+ 'EDEADLOCK': '35',
+ 'EDESTADDRREQ': '89',
+ 'EDOM': '33',
+ 'EDOTDOT': '73',
+ 'EDQUOT': '122',
+ 'EEXIST': '17',
+ 'EFAULT': '14',
+ 'EFBIG': '27',
+ 'EHOSTDOWN': '112',
+ 'EHOSTUNREACH': '113',
+ 'EIDRM': '43',
+ 'EILSEQ': '84',
+ 'EINPROGRESS': '115',
+ 'EINTR': '4',
+ 'EINVAL': '22',
+ 'EIO': '5',
+ 'EISCONN': '106',
+ 'EISDIR': '21',
+ 'EL2HLT': '51',
+ 'EL2NSYNC': '45',
+ 'EL3HLT': '46',
+ 'EL3RST': '47',
+ 'ELIBACC': '79',
+ 'ELIBBAD': '80',
+ 'ELIBEXEC': '83',
+ 'ELIBMAX': '82',
+ 'ELIBSCN': '81',
+ 'ELNRNG': '48',
+ 'ELOOP': '40',
+ 'EMFILE': '24',
+ 'EMLINK': '31',
+ 'EMSGSIZE': '90',
+ 'EMULTIHOP': '72',
+ 'ENAMETOOLONG': '36',
+ 'ENETDOWN': '100',
+ 'ENETRESET': '102',
+ 'ENETUNREACH': '101',
+ 'ENFILE': '23',
+ 'ENOANO': '55',
+ 'ENOBUFS': '105',
+ 'ENOCSI': '50',
+ 'ENODATA': '61',
+ 'ENODEV': '19',
+ 'ENOENT': '2',
+ 'ENOEXEC': '8',
+ 'ENOLCK': '37',
+ 'ENOLINK': '67',
+ 'ENOMEDIUM': '123',
+ 'ENOMEM': '12',
+ 'ENOMSG': '42',
+ 'ENONET': '64',
+ 'ENOPKG': '65',
+ 'ENOPROTOOPT': '92',
+ 'ENOSPC': '28',
+ 'ENOSR': '63',
+ 'ENOSTR': '60',
+ 'ENOSYS': '38',
+ 'ENOTBLK': '15',
+ 'ENOTCONN': '107',
+ 'ENOTDIR': '20',
+ 'ENOTEMPTY': '39',
+ 'ENOTRECOVERABLE': '131',
+ 'ENOTSOCK': '88',
+ 'ENOTSUP': '95',
+ 'ENOTTY': '25',
+ 'ENOTUNIQ': '76',
+ 'ENXIO': '6',
+ 'EOF': '-1',
+ 'EOPNOTSUPP': '95',
+ 'EOVERFLOW': '75',
+ 'EOWNERDEAD': '130',
+ 'EPERM': '1',
+ 'EPFNOSUPPORT': '96',
+ 'EPIPE': '32',
+ 'EPROTO': '71',
+ 'EPROTONOSUPPORT': '93',
+ 'EPROTOTYPE': '91',
+ 'ERA': '131116',
+ 'ERANGE': '34',
+ 'ERA_D_FMT': '131118',
+ 'ERA_D_T_FMT': '131120',
+ 'ERA_T_FMT': '131121',
+ 'EREMCHG': '78',
+ 'EREMOTE': '66',
+ 'EROFS': '30',
+ 'ESHUTDOWN': '108',
+ 'ESOCKTNOSUPPORT': '94',
+ 'ESPIPE': '29',
+ 'ESRCH': '3',
+ 'ESRMNT': '69',
+ 'ESTALE': '116',
+ 'ESTRPIPE': '86',
+ 'ETIME': '62',
+ 'ETIMEDOUT': '110',
+ 'ETOOMANYREFS': '109',
+ 'ETXTBSY': '26',
+ 'EUNATCH': '49',
+ 'EUSERS': '87',
+ 'EWOULDBLOCK': '11',
+ 'EXDEV': '18',
+ 'EXFULL': '54',
+ 'FIONREAD': '21531',
+ 'FP_INFINITE': '1',
+ 'FP_NAN': '0',
+ 'FP_NORMAL': '4',
+ 'FP_ZERO': '2',
+ 'F_DUPFD': '0',
+ 'F_GETFD': '1',
+ 'F_GETFL': '3',
+ 'F_GETLK': '12',
+ 'F_GETLK64': '12',
+ 'F_GETOWN': '9',
+ 'F_SETFD': '2',
+ 'F_SETFL': '4',
+ 'F_SETLK': '13',
+ 'F_SETLK64': '13',
+ 'F_SETLKW': '14',
+ 'F_SETLKW64': '14',
+ 'F_SETOWN': '8',
+ 'F_UNLCK': '2',
+ 'INADDR_LOOPBACK': '2130706433',
+ 'IPPROTO_TCP': '6',
+ 'IPPROTO_UDP': '17',
+ 'MAP_PRIVATE': '2',
+ 'MON_1': '131098',
+ 'MON_10': '131107',
+ 'MON_11': '131108',
+ 'MON_12': '131109',
+ 'MON_2': '131099',
+ 'MON_3': '131100',
+ 'MON_4': '131101',
+ 'MON_5': '131102',
+ 'MON_6': '131103',
+ 'MON_7': '131104',
+ 'MON_8': '131105',
+ 'MON_9': '131106',
+ 'NI_NAMEREQD': '8',
+ 'NI_NUMERICHOST': '1',
+ 'NOEXPR': '327681',
+ 'O_ACCMODE': '2097155',
+ 'O_APPEND': '1024',
+ 'O_CREAT': '64',
+ 'O_EXCL': '128',
+ 'O_NOFOLLOW': '131072',
+ 'O_RDONLY': '0',
+ 'O_RDWR': '2',
+ 'O_SYNC': '1052672',
+ 'O_TRUNC': '512',
+ 'O_WRONLY': '1',
+ 'PM_STR': '131111',
+ 'POLLERR': '8',
+ 'POLLHUP': '16',
+ 'POLLIN': '1',
+ 'POLLNVAL': '32',
+ 'POLLOUT': '4',
+ 'POLLPRI': '2',
+ 'POLLRDNORM': '64',
+ 'RADIXCHAR': '65536',
+ 'R_OK': '4',
+ 'SEEK_END': '2',
+ 'SEEK_SET': '0',
+ 'SOCK_DGRAM': '2',
+ 'SOCK_STREAM': '1',
+ 'S_IALLUGO': '4095',
+ 'S_IFBLK': '24576',
+ 'S_IFCHR': '8192',
+ 'S_IFDIR': '16384',
+ 'S_IFIFO': '4096',
+ 'S_IFLNK': '40960',
+ 'S_IFMT': '61440',
+ 'S_IFREG': '32768',
+ 'S_IFSOCK': '49152',
+ 'S_IRUGO': '292',
+ 'S_IRWXO': '7',
+ 'S_IRWXUGO': '511',
+ 'S_ISVTX': '512',
+ 'S_IWUGO': '146',
+ 'S_IXUGO': '73',
+ 'THOUSEP': '65537',
+ 'T_FMT': '131114',
+ 'T_FMT_AMPM': '131115',
+ 'W_OK': '2',
+ 'X_OK': '1',
+ 'YESEXPR': '327680',
+ '_CS_GNU_LIBC_VERSION': '2',
+ '_CS_GNU_LIBPTHREAD_VERSION': '3',
+ '_CS_PATH': '0',
+ '_CS_POSIX_V6_ILP32_OFF32_CFLAGS': '1116',
+ '_CS_POSIX_V6_ILP32_OFF32_LDFLAGS': '1117',
+ '_CS_POSIX_V6_ILP32_OFF32_LIBS': '1118',
+ '_CS_POSIX_V6_ILP32_OFFBIG_CFLAGS': '1120',
+ '_CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS': '1121',
+ '_CS_POSIX_V6_ILP32_OFFBIG_LIBS': '1122',
+ '_CS_POSIX_V6_LP64_OFF64_CFLAGS': '1124',
+ '_CS_POSIX_V6_LP64_OFF64_LDFLAGS': '1125',
+ '_CS_POSIX_V6_LP64_OFF64_LIBS': '1126',
+ '_CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS': '1128',
+ '_CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS': '1129',
+ '_CS_POSIX_V6_LPBIG_OFFBIG_LIBS': '1130',
+ '_CS_POSIX_V6_WIDTH_RESTRICTED_ENVS': '1',
+ '_PC_2_SYMLINKS': '20',
+ '_PC_ALLOC_SIZE_MIN': '18',
+ '_PC_ASYNC_IO': '10',
+ '_PC_CHOWN_RESTRICTED': '6',
+ '_PC_FILESIZEBITS': '13',
+ '_PC_LINK_MAX': '0',
+ '_PC_MAX_CANON': '1',
+ '_PC_MAX_INPUT': '2',
+ '_PC_NAME_MAX': '3',
+ '_PC_NO_TRUNC': '7',
+ '_PC_PATH_MAX': '4',
+ '_PC_PIPE_BUF': '5',
+ '_PC_PRIO_IO': '11',
+ '_PC_REC_INCR_XFER_SIZE': '14',
+ '_PC_REC_MAX_XFER_SIZE': '15',
+ '_PC_REC_MIN_XFER_SIZE': '16',
+ '_PC_REC_XFER_ALIGN': '17',
+ '_PC_SOCK_MAXBUF': '12',
+ '_PC_SYMLINK_MAX': '19',
+ '_PC_SYNC_IO': '9',
+ '_PC_VDISABLE': '8',
+ '_SC_2_CHAR_TERM': '95',
+ '_SC_2_C_BIND': '47',
+ '_SC_2_C_DEV': '48',
+ '_SC_2_FORT_DEV': '49',
+ '_SC_2_FORT_RUN': '50',
+ '_SC_2_LOCALEDEF': '52',
+ '_SC_2_PBS': '168',
+ '_SC_2_PBS_ACCOUNTING': '169',
+ '_SC_2_PBS_CHECKPOINT': '175',
+ '_SC_2_PBS_LOCATE': '170',
+ '_SC_2_PBS_MESSAGE': '171',
+ '_SC_2_PBS_TRACK': '172',
+ '_SC_2_SW_DEV': '51',
+ '_SC_2_UPE': '97',
+ '_SC_2_VERSION': '46',
+ '_SC_ADVISORY_INFO': '132',
+ '_SC_AIO_LISTIO_MAX': '23',
+ '_SC_AIO_MAX': '24',
+ '_SC_AIO_PRIO_DELTA_MAX': '25',
+ '_SC_ARG_MAX': '0',
+ '_SC_ASYNCHRONOUS_IO': '12',
+ '_SC_ATEXIT_MAX': '87',
+ '_SC_BARRIERS': '133',
+ '_SC_BC_BASE_MAX': '36',
+ '_SC_BC_DIM_MAX': '37',
+ '_SC_BC_SCALE_MAX': '38',
+ '_SC_BC_STRING_MAX': '39',
+ '_SC_CHILD_MAX': '1',
+ '_SC_CLK_TCK': '2',
+ '_SC_CLOCK_SELECTION': '137',
+ '_SC_COLL_WEIGHTS_MAX': '40',
+ '_SC_CPUTIME': '138',
+ '_SC_DELAYTIMER_MAX': '26',
+ '_SC_EXPR_NEST_MAX': '42',
+ '_SC_FSYNC': '15',
+ '_SC_GETGR_R_SIZE_MAX': '69',
+ '_SC_GETPW_R_SIZE_MAX': '70',
+ '_SC_HOST_NAME_MAX': '180',
+ '_SC_IOV_MAX': '60',
+ '_SC_IPV6': '235',
+ '_SC_JOB_CONTROL': '7',
+ '_SC_LINE_MAX': '43',
+ '_SC_LOGIN_NAME_MAX': '71',
+ '_SC_MAPPED_FILES': '16',
+ '_SC_MEMLOCK': '17',
+ '_SC_MEMLOCK_RANGE': '18',
+ '_SC_MEMORY_PROTECTION': '19',
+ '_SC_MESSAGE_PASSING': '20',
+ '_SC_MONOTONIC_CLOCK': '149',
+ '_SC_MQ_OPEN_MAX': '27',
+ '_SC_MQ_PRIO_MAX': '28',
+ '_SC_NGROUPS_MAX': '3',
+ '_SC_NPROCESSORS_ONLN': '84',
+ '_SC_OPEN_MAX': '4',
+ '_SC_PAGE_SIZE': '30',
+ '_SC_PRIORITIZED_IO': '13',
+ '_SC_PRIORITY_SCHEDULING': '10',
+ '_SC_RAW_SOCKETS': '236',
+ '_SC_READER_WRITER_LOCKS': '153',
+ '_SC_REALTIME_SIGNALS': '9',
+ '_SC_REGEXP': '155',
+ '_SC_RE_DUP_MAX': '44',
+ '_SC_RTSIG_MAX': '31',
+ '_SC_SAVED_IDS': '8',
+ '_SC_SEMAPHORES': '21',
+ '_SC_SEM_NSEMS_MAX': '32',
+ '_SC_SEM_VALUE_MAX': '33',
+ '_SC_SHARED_MEMORY_OBJECTS': '22',
+ '_SC_SHELL': '157',
+ '_SC_SIGQUEUE_MAX': '34',
+ '_SC_SPAWN': '159',
+ '_SC_SPIN_LOCKS': '154',
+ '_SC_SPORADIC_SERVER': '160',
+ '_SC_STREAM_MAX': '5',
+ '_SC_SYMLOOP_MAX': '173',
+ '_SC_SYNCHRONIZED_IO': '14',
+ '_SC_THREADS': '67',
+ '_SC_THREAD_ATTR_STACKADDR': '77',
+ '_SC_THREAD_ATTR_STACKSIZE': '78',
+ '_SC_THREAD_CPUTIME': '139',
+ '_SC_THREAD_DESTRUCTOR_ITERATIONS': '73',
+ '_SC_THREAD_KEYS_MAX': '74',
+ '_SC_THREAD_PRIORITY_SCHEDULING': '79',
+ '_SC_THREAD_PRIO_INHERIT': '80',
+ '_SC_THREAD_PRIO_PROTECT': '81',
+ '_SC_THREAD_PROCESS_SHARED': '82',
+ '_SC_THREAD_SAFE_FUNCTIONS': '68',
+ '_SC_THREAD_SPORADIC_SERVER': '161',
+ '_SC_THREAD_STACK_MIN': '75',
+ '_SC_THREAD_THREADS_MAX': '76',
+ '_SC_TIMEOUTS': '164',
+ '_SC_TIMERS': '11',
+ '_SC_TIMER_MAX': '35',
+ '_SC_TRACE': '181',
+ '_SC_TRACE_EVENT_FILTER': '182',
+ '_SC_TRACE_EVENT_NAME_MAX': '242',
+ '_SC_TRACE_INHERIT': '183',
+ '_SC_TRACE_LOG': '184',
+ '_SC_TRACE_NAME_MAX': '243',
+ '_SC_TRACE_SYS_MAX': '244',
+ '_SC_TRACE_USER_EVENT_MAX': '245',
+ '_SC_TTY_NAME_MAX': '72',
+ '_SC_TYPED_MEMORY_OBJECTS': '165',
+ '_SC_TZNAME_MAX': '6',
+ '_SC_V6_ILP32_OFF32': '176',
+ '_SC_V6_ILP32_OFFBIG': '177',
+ '_SC_V6_LP64_OFF64': '178',
+ '_SC_V6_LPBIG_OFFBIG': '179',
+ '_SC_VERSION': '29',
+ '_SC_XBS5_ILP32_OFF32': '125',
+ '_SC_XBS5_ILP32_OFFBIG': '126',
+ '_SC_XBS5_LP64_OFF64': '127',
+ '_SC_XBS5_LPBIG_OFFBIG': '128',
+ '_SC_XOPEN_CRYPT': '92',
+ '_SC_XOPEN_ENH_I18N': '93',
+ '_SC_XOPEN_LEGACY': '129',
+ '_SC_XOPEN_REALTIME': '130',
+ '_SC_XOPEN_REALTIME_THREADS': '131',
+ '_SC_XOPEN_SHM': '94',
+ '_SC_XOPEN_STREAMS': '246',
+ '_SC_XOPEN_UNIX': '91',
+ '_SC_XOPEN_VERSION': '89'
};
diff --git a/system/include/bsd/float.h b/system/include/bsd/float.h
deleted file mode 100644
index 383e637c..00000000
--- a/system/include/bsd/float.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/* $OpenBSD: float.h,v 1.9 2011/08/29 13:13:21 kettenis Exp $ */
-/* $NetBSD: float.h,v 1.8 1995/06/20 20:45:37 jtc Exp $ */
-
-/*
- * Copyright (c) 1989 Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)float.h 7.1 (Berkeley) 5/8/90
- */
-
-#ifndef _MACHINE_FLOAT_H_
-#define _MACHINE_FLOAT_H_
-
-#include <sys/cdefs.h>
-
-__BEGIN_DECLS
-int __flt_rounds(void);
-__END_DECLS
-
-#define FLT_RADIX 2 /* b */
-/*
- * XXX Emscripten
- * See float.h documentation for these values
- * 1 seems best for JavaScript instead of:
- * #define FLT_ROUNDS __flt_rounds()
- */
-#define FLT_ROUNDS 1
-#if __ISO_C_VISIBLE >= 1999
-#define FLT_EVAL_METHOD 2 /* long double */
-#endif
-
-#define FLT_MANT_DIG 24 /* p */
-#define FLT_EPSILON 1.19209290E-07F /* b**(1-p) */
-#define FLT_DIG 6 /* floor((p-1)*log10(b))+(b == 10) */
-#define FLT_MIN_EXP (-125) /* emin */
-#define FLT_MIN 1.17549435E-38F /* b**(emin-1) */
-#define FLT_MIN_10_EXP (-37) /* ceil(log10(b**(emin-1))) */
-#define FLT_MAX_EXP 128 /* emax */
-#define FLT_MAX 3.40282347E+38F /* (1-b**(-p))*b**emax */
-#define FLT_MAX_10_EXP 38 /* floor(log10((1-b**(-p))*b**emax)) */
-
-#define DBL_MANT_DIG 53
-#define DBL_EPSILON 2.2204460492503131E-16
-#define DBL_DIG 15
-#define DBL_MIN_EXP (-1021)
-#define DBL_MIN 2.2250738585072014E-308
-#define DBL_MIN_10_EXP (-307)
-#define DBL_MAX_EXP 1024
-#define DBL_MAX 1.7976931348623157E+308
-#define DBL_MAX_10_EXP 308
-
-#define LDBL_MANT_DIG DBL_MANT_DIG
-#define LDBL_EPSILON DBL_EPSILON
-#define LDBL_DIG DBL_DIG
-#define LDBL_MIN_EXP DBL_MIN_EXP
-#define LDBL_MIN DBL_MIN
-#define LDBL_MIN_10_EXP DBL_MIN_10_EXP
-#define LDBL_MAX_EXP DBL_MAX_EXP
-#define LDBL_MAX DBL_MAX
-#define LDBL_MAX_10_EXP DBL_MAX_10_EXP
-
-#if __ISO_C_VISIBLE >= 1999
-#define DECIMAL_DIG 21
-#endif
-
-#endif /* _MACHINE_FLOAT_H_ */
-
diff --git a/system/include/bsd/readme.txt b/system/include/bsd/readme.txt
deleted file mode 100644
index b5a40cc0..00000000
--- a/system/include/bsd/readme.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-The contents of this directory are from FreeBSD or OpenBSD (see details in each file).
-
diff --git a/system/include/bsd/sys/mman.h b/system/include/bsd/sys/mman.h
deleted file mode 100644
index 3713cacd..00000000
--- a/system/include/bsd/sys/mman.h
+++ /dev/null
@@ -1,180 +0,0 @@
-/*-
- * Copyright (c) 1982, 1986, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)mman.h 8.2 (Berkeley) 1/9/95
- * $FreeBSD: src/sys/sys/mman.h,v 1.29.2.1 2001/08/25 07:25:43 dillon Exp $
- */
-
-#ifndef _SYS_MMAN_H_
-#define _SYS_MMAN_H_
-
-#include <stddef.h> /* XXX Emscripten for size_t */
-#include <sys/types.h> /* XXX Emscripten for C++ compilation, not just C */
-
-/* XXX Emscripten #include <sys/_posix.h> */
-
-/*
- * Inheritance for minherit()
- */
-#define INHERIT_SHARE 0
-#define INHERIT_COPY 1
-#define INHERIT_NONE 2
-
-/*
- * Protections are chosen from these bits, or-ed together
- */
-#define PROT_NONE 0x00 /* no permissions */
-#define PROT_READ 0x01 /* pages can be read */
-#define PROT_WRITE 0x02 /* pages can be written */
-#define PROT_EXEC 0x04 /* pages can be executed */
-
-/*
- * Flags contain sharing type and options.
- * Sharing types; choose one.
- */
-#define MAP_SHARED 0x0001 /* share changes */
-#define MAP_PRIVATE 0x0002 /* changes are private */
-#define MAP_COPY MAP_PRIVATE /* Obsolete */
-
-/*
- * Other flags
- */
-#define MAP_FIXED 0x0010 /* map addr must be exactly as requested */
-#define MAP_RENAME 0x0020 /* Sun: rename private pages to file */
-#define MAP_NORESERVE 0x0040 /* Sun: don't reserve needed swap area */
-#define MAP_INHERIT 0x0080 /* region is retained after exec */
-#define MAP_NOEXTEND 0x0100 /* for MAP_FILE, don't change file size */
-#define MAP_HASSEMAPHORE 0x0200 /* region may contain semaphores */
-#define MAP_STACK 0x0400 /* region grows down, like a stack */
-#define MAP_NOSYNC 0x0800 /* page to but do not sync underlying file */
-
-/*
- * Extended flags
- */
-#define MAP_NOCORE 0x00020000 /* dont include these pages in a coredump */
-
-#ifdef _P1003_1B_VISIBLE
-/*
- * Process memory locking
- */
-#define MCL_CURRENT 0x0001 /* Lock only current memory */
-#define MCL_FUTURE 0x0002 /* Lock all future memory as well */
-
-#endif /* _P1003_1B_VISIBLE */
-
-/*
- * Error return from mmap()
- */
-#define MAP_FAILED ((void *)-1)
-
-/*
- * msync() flags
- */
-#define MS_SYNC 0x0000 /* msync synchronously */
-#define MS_ASYNC 0x0001 /* return immediately */
-#define MS_INVALIDATE 0x0002 /* invalidate all cached data */
-
-
-/*
- * Mapping type
- */
-#define MAP_FILE 0x0000 /* map from file (default) */
-#define MAP_ANON 0x1000 /* allocated from memory, swap space */
-
-/*
- * Advice to madvise
- */
-#define MADV_NORMAL 0 /* no further special treatment */
-#define MADV_RANDOM 1 /* expect random page references */
-#define MADV_SEQUENTIAL 2 /* expect sequential page references */
-#define MADV_WILLNEED 3 /* will need these pages */
-#define MADV_DONTNEED 4 /* dont need these pages */
-#define MADV_FREE 5 /* dont need these pages, and junk contents */
-#define MADV_NOSYNC 6 /* try to avoid flushes to physical media */
-#define MADV_AUTOSYNC 7 /* revert to default flushing strategy */
-#define MADV_NOCORE 8 /* do not include these pages in a core file */
-#define MADV_CORE 9 /* revert to including pages in a core file */
-
-/*
- * Return bits from mincore
- */
-#define MINCORE_INCORE 0x1 /* Page is incore */
-#define MINCORE_REFERENCED 0x2 /* Page has been referenced by us */
-#define MINCORE_MODIFIED 0x4 /* Page has been modified by us */
-#define MINCORE_REFERENCED_OTHER 0x8 /* Page has been referenced */
-#define MINCORE_MODIFIED_OTHER 0x10 /* Page has been modified */
-
-#ifndef _KERNEL
-
-#include <sys/cdefs.h>
-
-__BEGIN_DECLS
-#ifdef _P1003_1B_VISIBLE
-int mlockall __P((int));
-int munlockall __P((void));
-int shm_open __P((const char *, int, mode_t));
-int shm_unlink __P((const char *));
-#endif /* _P1003_1B_VISIBLE */
-int mlock __P((const void *, size_t));
-#ifndef _MMAP_DECLARED
-#define _MMAP_DECLARED
-void * mmap __P((void *, size_t, int, int, int, off_t));
-#endif
-int mprotect __P((const void *, size_t, int));
-int msync __P((void *, size_t, int));
-int munlock __P((const void *, size_t));
-int munmap __P((void *, size_t));
-#ifndef _POSIX_SOURCE
-int madvise __P((void *, size_t, int));
-int mincore __P((const void *, size_t, unsigned char *));
-int minherit __P((void *, size_t, int));
-#endif
-
-/* XXX Emscripten */
-void *mremap(void *old_address, size_t old_size , size_t new_size, unsigned long flags);
-
-__END_DECLS
-
-#endif /* !_KERNEL */
-
-#endif
-
-
-
-
-
-
-
-
-
-
-
diff --git a/system/include/bsd/sys/utsname.h b/system/include/bsd/sys/utsname.h
deleted file mode 100644
index 136d46b0..00000000
--- a/system/include/bsd/sys/utsname.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*-
- * Copyright (c) 1994
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chuck Karish of Mindcraft, Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)utsname.h 8.1 (Berkeley) 1/4/94
- * $FreeBSD: src/sys/sys/utsname.h,v 1.7 1999/12/29 04:24:49 peter Exp $
- */
-
-#ifndef _SYS_UTSNAME_H
-#define _SYS_UTSNAME_H
-
-#define SYS_NMLN 32
-
-struct utsname {
- char sysname[SYS_NMLN]; /* Name of this OS. */
- char nodename[SYS_NMLN]; /* Name of this network node. */
- char release[SYS_NMLN]; /* Release level. */
- char version[SYS_NMLN]; /* Version level. */
- char machine[SYS_NMLN]; /* Hardware type. */
-};
-
-
-#include <sys/cdefs.h>
-
-
-#ifndef _KERNEL
-#ifdef __STDC__
-__BEGIN_DECLS
-int uname __P((struct utsname *));
-__END_DECLS
-#else
-extern int uname();
-#endif
-#else
-extern struct utsname utsname;
-#endif /* _KERNEL */
-
-#endif /* !_SYS_UTSNAME_H */
-
diff --git a/system/include/compat/ctype.h b/system/include/compat/ctype.h
new file mode 100644
index 00000000..891006d9
--- /dev/null
+++ b/system/include/compat/ctype.h
@@ -0,0 +1,17 @@
+#ifndef _COMPAT_CTYPE_H_
+#define _COMPAT_CTYPE_H_
+
+#define _CTYPE_A 0x00000400 /* Alpha */
+#define _CTYPE_C 0x00000002 /* Control */
+#define _CTYPE_D 0x00000800 /* Digit */
+#define _CTYPE_L 0x00000200 /* Lower */
+#define _CTYPE_P 0x00000004 /* Punct */
+#define _CTYPE_S 0x00002000 /* Space */
+#define _CTYPE_U 0x00000100 /* Upper */
+#define _CTYPE_X 0x00001000 /* X digit */
+#define _CTYPE_B 0x00000001 /* Blank */
+#define _CTYPE_R 0x00004000 /* Print */
+
+#include_next <ctype.h>
+
+#endif /* _COMPAT_CTYPE_H_ */
diff --git a/system/include/compat/sys/timeb.h b/system/include/compat/sys/timeb.h
index 0a2c3de8..2e678893 100644
--- a/system/include/compat/sys/timeb.h
+++ b/system/include/compat/sys/timeb.h
@@ -14,13 +14,9 @@ extern "C" {
#define _SYS_TIMEB_H
-#include <_ansi.h>
-#include <machine/types.h>
+#define __NEED_time_t
-#ifndef __time_t_defined
-typedef _TIME_T_ time_t;
-#define __time_t_defined
-#endif
+#include <bits/alltypes.h>
struct timeb
{
@@ -30,7 +26,7 @@ struct timeb
short dstflag;
};
-extern int ftime _PARAMS ((struct timeb *));
+extern int ftime(struct timeb *);
#ifdef __cplusplus
}
diff --git a/system/include/compat/xlocale.h b/system/include/compat/xlocale.h
index 4bafa27d..c0091164 100644
--- a/system/include/compat/xlocale.h
+++ b/system/include/compat/xlocale.h
@@ -15,7 +15,5 @@ double strtold_l(const char *start, char **end, locale_t loc);
}
#endif
-#include_next <xlocale.h>
-
#endif /* _COMPAT_XLOCALE_H_ */
diff --git a/system/include/dlfcn.h b/system/include/dlfcn.h
deleted file mode 100644
index 7986c12d..00000000
--- a/system/include/dlfcn.h
+++ /dev/null
@@ -1,31 +0,0 @@
-#ifndef _DLFCN_H_INCLUDED
-#define _DLFCN_H_INCLUDED
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define RTLD_DEFAULT 0
-#define RTLD_LAZY 1
-#define RTLD_NOW 2
-#define RTLD_GLOBAL 4
-#define RTLD_LOCAL 8
-
-typedef struct {
- const char *dli_fname;
- void *dli_fbase;
- const char *dli_sname;
- void *dli_saddr;
-} Dl_info;
-
-void *dlopen(const char *, int);
-void *dlsym(void *, const char *);
-int dlclose(void *);
-char *dlerror(void);
-int dladdr(void *addr, Dl_info *info);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/system/include/err.h b/system/include/err.h
deleted file mode 100644
index a9b92ee6..00000000
--- a/system/include/err.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/* $OpenBSD: err.h,v 1.10 2006/01/06 18:53:04 millert Exp $ */
-/* $NetBSD: err.h,v 1.11 1994/10/26 00:55:52 cgd Exp $ */
-
-/*-
- * Copyright (c) 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)err.h 8.1 (Berkeley) 6/2/93
- */
-
-#ifndef _ERR_H_
-#define _ERR_H_
-
-/*
- * Don't use va_list in the err/warn prototypes. Va_list is typedef'd in two
- * places (<machine/varargs.h> and <machine/stdarg.h>), so if we include one
- * of them here we may collide with the utility's includes. It's unreasonable
- * for utilities to have to include one of them to include err.h, so we get
- * va_list from <machine/_types.h> and use it.
- */
-#include <sys/cdefs.h>
-//#include <machine/_types.h>
-#include <stdarg.h>
-
-#define __dead __attribute__((__noreturn__))
-
-__BEGIN_DECLS
-
-__dead void err(int, const char *, ...)
- __attribute__((__format__ (printf, 2, 3)));
-__dead void verr(int, const char *, va_list)
- __attribute__((__format__ (printf, 2, 0)));
-__dead void errx(int, const char *, ...)
- __attribute__((__format__ (printf, 2, 3)));
-__dead void verrx(int, const char *, va_list)
- __attribute__((__format__ (printf, 2, 0)));
-void warn(const char *, ...)
- __attribute__((__format__ (printf, 1, 2)));
-void vwarn(const char *, va_list)
- __attribute__((__format__ (printf, 1, 0)));
-void warnx(const char *, ...)
- __attribute__((__format__ (printf, 1, 2)));
-void vwarnx(const char *, va_list)
- __attribute__((__format__ (printf, 1, 0)));
-
-/*
- * The _* versions are for use in library functions so user-defined
- * versions of err*,warn* do not get used.
- */
-__dead void _err(int, const char *, ...)
- __attribute__((__format__ (printf, 2, 3)));
-__dead void _verr(int, const char *, va_list)
- __attribute__((__format__ (printf, 2, 0)));
-__dead void _errx(int, const char *, ...)
- __attribute__((__format__ (printf, 2, 3)));
-__dead void _verrx(int, const char *, va_list)
- __attribute__((__format__ (printf, 2, 0)));
-void _warn(const char *, ...)
- __attribute__((__format__ (printf, 1, 2)));
-void _vwarn(const char *, va_list)
- __attribute__((__format__ (printf, 1, 0)));
-void _warnx(const char *, ...)
- __attribute__((__format__ (printf, 1, 2)));
-void _vwarnx(const char *, va_list)
- __attribute__((__format__ (printf, 1, 0)));
-
-#undef __dead
-
-__END_DECLS
-
-#endif /* !_ERR_H_ */
diff --git a/system/include/features.h b/system/include/features.h
deleted file mode 100644
index 1dd6ea6d..00000000
--- a/system/include/features.h
+++ /dev/null
@@ -1,3 +0,0 @@
-
-#include <sys/features.h>
-
diff --git a/system/include/libc/_ansi.h b/system/include/libc/_ansi.h
deleted file mode 100644
index c38e22e8..00000000
--- a/system/include/libc/_ansi.h
+++ /dev/null
@@ -1,135 +0,0 @@
-/* Provide support for both ANSI and non-ANSI environments. */
-
-/* Some ANSI environments are "broken" in the sense that __STDC__ cannot be
- relied upon to have it's intended meaning. Therefore we must use our own
- concoction: _HAVE_STDC. Always use _HAVE_STDC instead of __STDC__ in newlib
- sources!
-
- To get a strict ANSI C environment, define macro __STRICT_ANSI__. This will
- "comment out" the non-ANSI parts of the ANSI header files (non-ANSI header
- files aren't affected). */
-
-#ifndef _ANSIDECL_H_
-#define _ANSIDECL_H_
-
-#include <newlib.h>
-#include <sys/config.h>
-
-/* First try to figure out whether we really are in an ANSI C environment. */
-/* FIXME: This probably needs some work. Perhaps sys/config.h can be
- prevailed upon to give us a clue. */
-
-#ifdef __STDC__
-#define _HAVE_STDC
-#endif
-
-/* ISO C++. */
-
-#ifdef __cplusplus
-#if !(defined(_BEGIN_STD_C) && defined(_END_STD_C))
-#ifdef _HAVE_STD_CXX
-#define _BEGIN_STD_C namespace std { extern "C" {
-#define _END_STD_C } }
-#else
-#define _BEGIN_STD_C extern "C" {
-#define _END_STD_C }
-#endif
-#if defined(__GNUC__) && \
- ( (__GNUC__ >= 4) || \
- ( (__GNUC__ >= 3) && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ >= 3) ) )
-#define _NOTHROW __attribute__ ((nothrow))
-#else
-#define _NOTHROW throw()
-#endif
-#endif
-#else
-#define _BEGIN_STD_C
-#define _END_STD_C
-#define _NOTHROW
-#endif
-
-#ifdef _HAVE_STDC
-#define _PTR void *
-#define _AND ,
-#define _NOARGS void
-#define _CONST const
-#define _VOLATILE volatile
-#define _SIGNED signed
-#define _DOTS , ...
-#define _VOID void
-#ifdef __CYGWIN__
-#define _EXFUN_NOTHROW(name, proto) __cdecl name proto _NOTHROW
-#define _EXFUN(name, proto) __cdecl name proto
-#define _EXPARM(name, proto) (* __cdecl name) proto
-#define _EXFNPTR(name, proto) (__cdecl * name) proto
-#else
-#define _EXFUN_NOTHROW(name, proto) name proto _NOTHROW
-#define _EXFUN(name, proto) name proto
-#define _EXPARM(name, proto) (* name) proto
-#define _EXFNPTR(name, proto) (* name) proto
-#endif
-#define _DEFUN(name, arglist, args) name(args)
-#define _DEFUN_VOID(name) name(_NOARGS)
-#define _CAST_VOID (void)
-#ifndef _LONG_DOUBLE
-#define _LONG_DOUBLE long double
-#endif
-#ifndef _LONG_LONG_TYPE
-#define _LONG_LONG_TYPE long long
-#endif
-#ifndef _PARAMS
-#define _PARAMS(paramlist) paramlist
-#endif
-#else
-#define _PTR char *
-#define _AND ;
-#define _NOARGS
-#define _CONST
-#define _VOLATILE
-#define _SIGNED
-#define _DOTS
-#define _VOID void
-#define _EXFUN(name, proto) name()
-#define _EXFUN_NOTHROW(name, proto) name()
-#define _DEFUN(name, arglist, args) name arglist args;
-#define _DEFUN_VOID(name) name()
-#define _CAST_VOID
-#define _LONG_DOUBLE double
-#define _LONG_LONG_TYPE long
-#ifndef _PARAMS
-#define _PARAMS(paramlist) ()
-#endif
-#endif
-
-/* Support gcc's __attribute__ facility. */
-
-#ifndef _ATTRIBUTE /* XXX Emscripten */
-#ifdef __GNUC__
-#define _ATTRIBUTE(attr) __attribute__ ((attr))
-#else
-#define _ATTRIBUTE(attr)
-#endif
-#endif /* XXX Emscripten */
-
-/* The traditional meaning of 'extern inline' for GCC is not
- to emit the function body unless the address is explicitly
- taken. However this behaviour is changing to match the C99
- standard, which uses 'extern inline' to indicate that the
- function body *must* be emitted. If we are using GCC, but do
- not have the new behaviour, we need to use extern inline; if
- we are using a new GCC with the C99-compatible behaviour, or
- a non-GCC compiler (which we will have to hope is C99, since
- there is no other way to achieve the effect of omitting the
- function if it isn't referenced) we just use plain 'inline',
- which c99 defines to mean more-or-less the same as the Gnu C
- 'extern inline'. */
-#if defined(__GNUC__) && !defined(__GNUC_STDC_INLINE__)
-/* We're using GCC, but without the new C99-compatible behaviour. */
-#define _ELIDABLE_INLINE extern __inline__ _ATTRIBUTE ((__always_inline__))
-#else
-/* We're using GCC in C99 mode, or an unknown compiler which
- we just have to hope obeys the C99 semantics of inline. */
-#define _ELIDABLE_INLINE __inline__
-#endif
-
-#endif /* _ANSIDECL_H_ */
diff --git a/system/include/libc/_syslist.h b/system/include/libc/_syslist.h
deleted file mode 100644
index 271644ef..00000000
--- a/system/include/libc/_syslist.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/* internal use only -- mapping of "system calls" for libraries that lose
- and only provide C names, so that we end up in violation of ANSI */
-#ifndef __SYSLIST_H
-#define __SYSLIST_H
-
-#ifdef MISSING_SYSCALL_NAMES
-#define _close close
-#define _execve execve
-#define _fcntl fcntl
-#define _fork fork
-#define _fstat fstat
-#define _getpid getpid
-#define _gettimeofday gettimeofday
-#define _isatty isatty
-#define _kill kill
-#define _link link
-#define _lseek lseek
-#define _mkdir mkdir
-#define _open open
-#define _read read
-#define _sbrk sbrk
-#define _stat stat
-#define _times times
-#define _unlink unlink
-#define _wait wait
-#define _write write
-#endif /* MISSING_SYSCALL_NAMES */
-
-#if defined MISSING_SYSCALL_NAMES || !defined HAVE_OPENDIR
-/* If the system call interface is missing opendir, readdir, and
- closedir, there is an implementation of these functions in
- libc/posix that is implemented using open, getdents, and close.
- Note, these functions are currently not in the libc/syscalls
- directory. */
-#define _opendir opendir
-#define _readdir readdir
-#define _closedir closedir
-#endif /* MISSING_SYSCALL_NAMES || !HAVE_OPENDIR */
-
-#endif /* !__SYSLIST_H_ */
diff --git a/system/include/libc/aio.h b/system/include/libc/aio.h
new file mode 100644
index 00000000..d9330ebe
--- /dev/null
+++ b/system/include/libc/aio.h
@@ -0,0 +1,69 @@
+#ifndef _AIO_H
+#define _AIO_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <features.h>
+#include <signal.h>
+#include <time.h>
+
+#define __NEED_ssize_t
+#define __NEED_off_t
+
+#include <bits/alltypes.h>
+
+struct aiocb {
+ int aio_fildes, aio_lio_opcode, aio_reqprio;
+ volatile void *aio_buf;
+ size_t aio_nbytes;
+ struct sigevent aio_sigevent;
+ void *__td;
+ int __lock[2];
+ int __err;
+ ssize_t __ret;
+ off_t aio_offset;
+ void *__next, *__prev;
+ char __dummy4[32-2*sizeof(void *)];
+};
+
+#define AIO_CANCELED 0
+#define AIO_NOTCANCELED 1
+#define AIO_ALLDONE 2
+
+#define LIO_READ 0
+#define LIO_WRITE 1
+#define LIO_NOP 2
+
+#define LIO_WAIT 0
+#define LIO_NOWAIT 1
+
+int aio_read(struct aiocb *);
+int aio_write(struct aiocb *);
+int aio_error(const struct aiocb *);
+ssize_t aio_return(struct aiocb *);
+int aio_cancel(int, struct aiocb *);
+int aio_suspend(const struct aiocb *const [], int, const struct timespec *);
+int aio_fsync(int, struct aiocb *);
+
+int lio_listio(int, struct aiocb *__restrict const *__restrict, int, struct sigevent *__restrict);
+
+#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
+#define aiocb64 aiocb
+#define aio_read64 aio_read
+#define aio_write64 aio_write
+#define aio_error64 aio_error
+#define aio_return64 aio_return
+#define aio_cancel64 aio_cancel
+#define aio_suspend64 aio_suspend
+#define aio_fsync64 aio_fsync
+#define lio_listio64 lio_listio
+#define off64_t off_t
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/alloca.h b/system/include/libc/alloca.h
index 2ea0fd9b..d2e6f1c6 100644
--- a/system/include/libc/alloca.h
+++ b/system/include/libc/alloca.h
@@ -1,21 +1,21 @@
-/* libc/include/alloca.h - Allocate memory on stack */
+#ifndef _ALLOCA_H
+#define _ALLOCA_H
-/* Written 2000 by Werner Almesberger */
-/* Rearranged for general inclusion by stdlib.h.
- 2001, Corinna Vinschen <vinschen@redhat.com> */
-
-#ifndef _NEWLIB_ALLOCA_H
-#define _NEWLIB_ALLOCA_H
+#ifdef __cplusplus
+extern "C" {
+#endif
-#include "_ansi.h"
-#include <sys/reent.h>
+#define __NEED_size_t
+#include <bits/alltypes.h>
-#undef alloca
+void *alloca(size_t);
#ifdef __GNUC__
-#define alloca(size) __builtin_alloca(size)
-#else
-void * _EXFUN(alloca,(size_t));
+#define alloca __builtin_alloca
+#endif
+
+#ifdef __cplusplus
+}
#endif
#endif
diff --git a/system/include/libc/ar.h b/system/include/libc/ar.h
index ac2e4ca9..eafd51d0 100644
--- a/system/include/libc/ar.h
+++ b/system/include/libc/ar.h
@@ -1,69 +1,25 @@
-/* $NetBSD: ar.h,v 1.4 1994/10/26 00:55:43 cgd Exp $ */
+#ifndef _AR_H
+#define _AR_H
-/*-
- * Copyright (c) 1991, 1993
- * The Regents of the University of California. All rights reserved.
- * (c) UNIX System Laboratories, Inc.
- * All or some portions of this file are derived from material licensed
- * to the University of California by American Telephone and Telegraph
- * Co. or Unix System Laboratories, Inc. and are reproduced herein with
- * the permission of UNIX System Laboratories, Inc.
- *
- * This code is derived from software contributed to Berkeley by
- * Hugh Smith at The University of Guelph.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)ar.h 8.2 (Berkeley) 1/21/94
- */
+#ifdef __cplusplus
+extern "C" {
+#endif
-#ifndef _AR_H_
-#define _AR_H_
-
-/* Pre-4BSD archives had these magic numbers in them. */
-#define OARMAG1 0177555
-#define OARMAG2 0177545
-
-#define ARMAG "!<arch>\n" /* ar "magic number" */
-#define SARMAG 8 /* strlen(ARMAG); */
-
-#define AR_EFMT1 "#1/" /* extended format #1 */
+#define ARMAG "!<arch>\n"
+#define SARMAG 8
+#define ARFMAG "`\n"
struct ar_hdr {
- char ar_name[16]; /* name */
- char ar_date[12]; /* modification time */
- char ar_uid[6]; /* user id */
- char ar_gid[6]; /* group id */
- char ar_mode[8]; /* octal file permissions */
- char ar_size[10]; /* size in bytes */
-#define ARFMAG "`\n"
- char ar_fmag[2]; /* consistency check */
+ char ar_name[16];
+ char ar_date[12];
+ char ar_uid[6], ar_gid[6];
+ char ar_mode[8];
+ char ar_size[10];
+ char ar_fmag[2];
};
-#endif /* !_AR_H_ */
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/argz.h b/system/include/libc/argz.h
deleted file mode 100644
index 02c9adbf..00000000
--- a/system/include/libc/argz.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/* Copyright (C) 2002 by Red Hat, Incorporated. All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this software
- * is freely granted, provided that this notice is preserved.
- */
-
-#ifndef _ARGZ_H_
-#define _ARGZ_H_
-
-#include <errno.h>
-#include <sys/types.h>
-
-#include "_ansi.h"
-
-_BEGIN_STD_C
-
-/* The newlib implementation of these functions assumes that sizeof(char) == 1. */
-error_t argz_create (char *const argv[], char **argz, size_t *argz_len);
-error_t argz_create_sep (const char *string, int sep, char **argz, size_t *argz_len);
-size_t argz_count (const char *argz, size_t argz_len);
-void argz_extract (char *argz, size_t argz_len, char **argv);
-void argz_stringify (char *argz, size_t argz_len, int sep);
-error_t argz_add (char **argz, size_t *argz_len, const char *str);
-error_t argz_add_sep (char **argz, size_t *argz_len, const char *str, int sep);
-error_t argz_append (char **argz, size_t *argz_len, const char *buf, size_t buf_len);
-error_t argz_delete (char **argz, size_t *argz_len, char *entry);
-error_t argz_insert (char **argz, size_t *argz_len, char *before, const char *entry);
-char * argz_next (char *argz, size_t argz_len, const char *entry);
-error_t argz_replace (char **argz, size_t *argz_len, const char *str, const char *with, unsigned *replace_count);
-
-_END_STD_C
-
-#endif /* _ARGZ_H_ */
diff --git a/system/include/libc/arpa/ftp.h b/system/include/libc/arpa/ftp.h
new file mode 100644
index 00000000..4041aeba
--- /dev/null
+++ b/system/include/libc/arpa/ftp.h
@@ -0,0 +1,35 @@
+#ifndef _ARPA_FTP_H_
+#define _ARPA_FTP_H_
+#define PRELIM 1
+#define COMPLETE 2
+#define CONTINUE 3
+#define TRANSIENT 4
+#define ERROR 5
+#define TYPE_A 1
+#define TYPE_E 2
+#define TYPE_I 3
+#define TYPE_L 4
+#define FORM_N 1
+#define FORM_T 2
+#define FORM_C 3
+#define STRU_F 1
+#define STRU_R 2
+#define STRU_P 3
+#define MODE_S 1
+#define MODE_B 2
+#define MODE_C 3
+#define REC_ESC '\377'
+#define REC_EOR '\001'
+#define REC_EOF '\002'
+#define BLK_EOR 0x80
+#define BLK_EOF 0x40
+#define BLK_ERRORS 0x20
+#define BLK_RESTART 0x10
+#define BLK_BYTECOUNT 2
+#ifdef FTP_NAMES
+char *modenames[] = {"0", "Stream", "Block", "Compressed" };
+char *strunames[] = {"0", "File", "Record", "Page" };
+char *typenames[] = {"0", "ASCII", "EBCDIC", "Image", "Local" };
+char *formnames[] = {"0", "Nonprint", "Telnet", "Carriage-control" };
+#endif
+#endif
diff --git a/system/include/libc/arpa/inet.h b/system/include/libc/arpa/inet.h
new file mode 100644
index 00000000..5dcadaae
--- /dev/null
+++ b/system/include/libc/arpa/inet.h
@@ -0,0 +1,36 @@
+#ifndef _ARPA_INET_H
+#define _ARPA_INET_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <features.h>
+#include <netinet/in.h>
+
+uint32_t htonl(uint32_t);
+uint16_t htons(uint16_t);
+uint32_t ntohl(uint32_t);
+uint16_t ntohs(uint16_t);
+
+in_addr_t inet_addr (const char *);
+in_addr_t inet_network (const char *);
+char *inet_ntoa (struct in_addr);
+int inet_pton (int, const char *__restrict, void *__restrict);
+const char *inet_ntop (int, const void *__restrict, char *__restrict, socklen_t);
+
+int inet_aton (const char *, struct in_addr *);
+struct in_addr inet_makeaddr(int, int);
+in_addr_t inet_lnaof(struct in_addr);
+in_addr_t inet_netof(struct in_addr);
+
+#undef INET_ADDRSTRLEN
+#undef INET6_ADDRSTRLEN
+#define INET_ADDRSTRLEN 16
+#define INET6_ADDRSTRLEN 46
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/arpa/nameser.h b/system/include/libc/arpa/nameser.h
new file mode 100644
index 00000000..b9ee6659
--- /dev/null
+++ b/system/include/libc/arpa/nameser.h
@@ -0,0 +1,467 @@
+#ifndef _ARPA_NAMESER_H
+#define _ARPA_NAMESER_H
+
+#include <stdint.h>
+
+#define __NAMESER 19991006
+#define NS_PACKETSZ 512
+#define NS_MAXDNAME 1025
+#define NS_MAXMSG 65535
+#define NS_MAXCDNAME 255
+#define NS_MAXLABEL 63
+#define NS_HFIXEDSZ 12
+#define NS_QFIXEDSZ 4
+#define NS_RRFIXEDSZ 10
+#define NS_INT32SZ 4
+#define NS_INT16SZ 2
+#define NS_INT8SZ 1
+#define NS_INADDRSZ 4
+#define NS_IN6ADDRSZ 16
+#define NS_CMPRSFLGS 0xc0
+#define NS_DEFAULTPORT 53
+
+typedef enum __ns_sect {
+ ns_s_qd = 0,
+ ns_s_zn = 0,
+ ns_s_an = 1,
+ ns_s_pr = 1,
+ ns_s_ns = 2,
+ ns_s_ud = 2,
+ ns_s_ar = 3,
+ ns_s_max = 4
+} ns_sect;
+
+typedef struct __ns_msg {
+ const unsigned char *_msg, *_eom;
+ uint16_t _id, _flags, _counts[ns_s_max];
+ const unsigned char *_sections[ns_s_max];
+ ns_sect _sect;
+ int _rrnum;
+ const unsigned char *_msg_ptr;
+} ns_msg;
+
+struct _ns_flagdata { int mask, shift; };
+extern const struct _ns_flagdata _ns_flagdata[];
+
+#define ns_msg_id(handle) ((handle)._id + 0)
+#define ns_msg_base(handle) ((handle)._msg + 0)
+#define ns_msg_end(handle) ((handle)._eom + 0)
+#define ns_msg_size(handle) ((handle)._eom - (handle)._msg)
+#define ns_msg_count(handle, section) ((handle)._counts[section] + 0)
+
+typedef struct __ns_rr {
+ char name[NS_MAXDNAME];
+ uint16_t type;
+ uint16_t rr_class;
+ uint32_t ttl;
+ uint16_t rdlength;
+ const unsigned char *rdata;
+} ns_rr;
+
+#define ns_rr_name(rr) (((rr).name[0] != '\0') ? (rr).name : ".")
+#define ns_rr_type(rr) ((ns_type)((rr).type + 0))
+#define ns_rr_class(rr) ((ns_class)((rr).rr_class + 0))
+#define ns_rr_ttl(rr) ((rr).ttl + 0)
+#define ns_rr_rdlen(rr) ((rr).rdlength + 0)
+#define ns_rr_rdata(rr) ((rr).rdata + 0)
+
+typedef enum __ns_flag {
+ ns_f_qr,
+ ns_f_opcode,
+ ns_f_aa,
+ ns_f_tc,
+ ns_f_rd,
+ ns_f_ra,
+ ns_f_z,
+ ns_f_ad,
+ ns_f_cd,
+ ns_f_rcode,
+ ns_f_max
+} ns_flag;
+
+typedef enum __ns_opcode {
+ ns_o_query = 0,
+ ns_o_iquery = 1,
+ ns_o_status = 2,
+ ns_o_notify = 4,
+ ns_o_update = 5,
+ ns_o_max = 6
+} ns_opcode;
+
+typedef enum __ns_rcode {
+ ns_r_noerror = 0,
+ ns_r_formerr = 1,
+ ns_r_servfail = 2,
+ ns_r_nxdomain = 3,
+ ns_r_notimpl = 4,
+ ns_r_refused = 5,
+ ns_r_yxdomain = 6,
+ ns_r_yxrrset = 7,
+ ns_r_nxrrset = 8,
+ ns_r_notauth = 9,
+ ns_r_notzone = 10,
+ ns_r_max = 11,
+ ns_r_badvers = 16,
+ ns_r_badsig = 16,
+ ns_r_badkey = 17,
+ ns_r_badtime = 18
+} ns_rcode;
+
+typedef enum __ns_update_operation {
+ ns_uop_delete = 0,
+ ns_uop_add = 1,
+ ns_uop_max = 2
+} ns_update_operation;
+
+struct ns_tsig_key {
+ char name[NS_MAXDNAME], alg[NS_MAXDNAME];
+ unsigned char *data;
+ int len;
+};
+typedef struct ns_tsig_key ns_tsig_key;
+
+struct ns_tcp_tsig_state {
+ int counter;
+ struct dst_key *key;
+ void *ctx;
+ unsigned char sig[NS_PACKETSZ];
+ int siglen;
+};
+typedef struct ns_tcp_tsig_state ns_tcp_tsig_state;
+
+#define NS_TSIG_FUDGE 300
+#define NS_TSIG_TCP_COUNT 100
+#define NS_TSIG_ALG_HMAC_MD5 "HMAC-MD5.SIG-ALG.REG.INT"
+
+#define NS_TSIG_ERROR_NO_TSIG -10
+#define NS_TSIG_ERROR_NO_SPACE -11
+#define NS_TSIG_ERROR_FORMERR -12
+
+typedef enum __ns_type {
+ ns_t_invalid = 0,
+ ns_t_a = 1,
+ ns_t_ns = 2,
+ ns_t_md = 3,
+ ns_t_mf = 4,
+ ns_t_cname = 5,
+ ns_t_soa = 6,
+ ns_t_mb = 7,
+ ns_t_mg = 8,
+ ns_t_mr = 9,
+ ns_t_null = 10,
+ ns_t_wks = 11,
+ ns_t_ptr = 12,
+ ns_t_hinfo = 13,
+ ns_t_minfo = 14,
+ ns_t_mx = 15,
+ ns_t_txt = 16,
+ ns_t_rp = 17,
+ ns_t_afsdb = 18,
+ ns_t_x25 = 19,
+ ns_t_isdn = 20,
+ ns_t_rt = 21,
+ ns_t_nsap = 22,
+ ns_t_nsap_ptr = 23,
+ ns_t_sig = 24,
+ ns_t_key = 25,
+ ns_t_px = 26,
+ ns_t_gpos = 27,
+ ns_t_aaaa = 28,
+ ns_t_loc = 29,
+ ns_t_nxt = 30,
+ ns_t_eid = 31,
+ ns_t_nimloc = 32,
+ ns_t_srv = 33,
+ ns_t_atma = 34,
+ ns_t_naptr = 35,
+ ns_t_kx = 36,
+ ns_t_cert = 37,
+ ns_t_a6 = 38,
+ ns_t_dname = 39,
+ ns_t_sink = 40,
+ ns_t_opt = 41,
+ ns_t_apl = 42,
+ ns_t_tkey = 249,
+ ns_t_tsig = 250,
+ ns_t_ixfr = 251,
+ ns_t_axfr = 252,
+ ns_t_mailb = 253,
+ ns_t_maila = 254,
+ ns_t_any = 255,
+ ns_t_zxfr = 256,
+ ns_t_max = 65536
+} ns_type;
+
+#define ns_t_qt_p(t) (ns_t_xfr_p(t) || (t) == ns_t_any || \
+ (t) == ns_t_mailb || (t) == ns_t_maila)
+#define ns_t_mrr_p(t) ((t) == ns_t_tsig || (t) == ns_t_opt)
+#define ns_t_rr_p(t) (!ns_t_qt_p(t) && !ns_t_mrr_p(t))
+#define ns_t_udp_p(t) ((t) != ns_t_axfr && (t) != ns_t_zxfr)
+#define ns_t_xfr_p(t) ((t) == ns_t_axfr || (t) == ns_t_ixfr || \
+ (t) == ns_t_zxfr)
+
+typedef enum __ns_class {
+ ns_c_invalid = 0,
+ ns_c_in = 1,
+ ns_c_2 = 2,
+ ns_c_chaos = 3,
+ ns_c_hs = 4,
+ ns_c_none = 254,
+ ns_c_any = 255,
+ ns_c_max = 65536
+} ns_class;
+
+typedef enum __ns_key_types {
+ ns_kt_rsa = 1,
+ ns_kt_dh = 2,
+ ns_kt_dsa = 3,
+ ns_kt_private = 254
+} ns_key_types;
+
+typedef enum __ns_cert_types {
+ cert_t_pkix = 1,
+ cert_t_spki = 2,
+ cert_t_pgp = 3,
+ cert_t_url = 253,
+ cert_t_oid = 254
+} ns_cert_types;
+
+#define NS_KEY_TYPEMASK 0xC000
+#define NS_KEY_TYPE_AUTH_CONF 0x0000
+#define NS_KEY_TYPE_CONF_ONLY 0x8000
+#define NS_KEY_TYPE_AUTH_ONLY 0x4000
+#define NS_KEY_TYPE_NO_KEY 0xC000
+#define NS_KEY_NO_AUTH 0x8000
+#define NS_KEY_NO_CONF 0x4000
+#define NS_KEY_RESERVED2 0x2000
+#define NS_KEY_EXTENDED_FLAGS 0x1000
+#define NS_KEY_RESERVED4 0x0800
+#define NS_KEY_RESERVED5 0x0400
+#define NS_KEY_NAME_TYPE 0x0300
+#define NS_KEY_NAME_USER 0x0000
+#define NS_KEY_NAME_ENTITY 0x0200
+#define NS_KEY_NAME_ZONE 0x0100
+#define NS_KEY_NAME_RESERVED 0x0300
+#define NS_KEY_RESERVED8 0x0080
+#define NS_KEY_RESERVED9 0x0040
+#define NS_KEY_RESERVED10 0x0020
+#define NS_KEY_RESERVED11 0x0010
+#define NS_KEY_SIGNATORYMASK 0x000F
+#define NS_KEY_RESERVED_BITMASK ( NS_KEY_RESERVED2 | \
+ NS_KEY_RESERVED4 | \
+ NS_KEY_RESERVED5 | \
+ NS_KEY_RESERVED8 | \
+ NS_KEY_RESERVED9 | \
+ NS_KEY_RESERVED10 | \
+ NS_KEY_RESERVED11 )
+#define NS_KEY_RESERVED_BITMASK2 0xFFFF
+#define NS_ALG_MD5RSA 1
+#define NS_ALG_DH 2
+#define NS_ALG_DSA 3
+#define NS_ALG_DSS NS_ALG_DSA
+#define NS_ALG_EXPIRE_ONLY 253
+#define NS_ALG_PRIVATE_OID 254
+
+#define NS_KEY_PROT_TLS 1
+#define NS_KEY_PROT_EMAIL 2
+#define NS_KEY_PROT_DNSSEC 3
+#define NS_KEY_PROT_IPSEC 4
+#define NS_KEY_PROT_ANY 255
+
+#define NS_MD5RSA_MIN_BITS 512
+#define NS_MD5RSA_MAX_BITS 4096
+#define NS_MD5RSA_MAX_BYTES ((NS_MD5RSA_MAX_BITS+7/8)*2+3)
+#define NS_MD5RSA_MAX_BASE64 (((NS_MD5RSA_MAX_BYTES+2)/3)*4)
+#define NS_MD5RSA_MIN_SIZE ((NS_MD5RSA_MIN_BITS+7)/8)
+#define NS_MD5RSA_MAX_SIZE ((NS_MD5RSA_MAX_BITS+7)/8)
+
+#define NS_DSA_SIG_SIZE 41
+#define NS_DSA_MIN_SIZE 213
+#define NS_DSA_MAX_BYTES 405
+
+#define NS_SIG_TYPE 0
+#define NS_SIG_ALG 2
+#define NS_SIG_LABELS 3
+#define NS_SIG_OTTL 4
+#define NS_SIG_EXPIR 8
+#define NS_SIG_SIGNED 12
+#define NS_SIG_FOOT 16
+#define NS_SIG_SIGNER 18
+#define NS_NXT_BITS 8
+#define NS_NXT_BIT_SET( n,p) (p[(n)/NS_NXT_BITS] |= (0x80>>((n)%NS_NXT_BITS)))
+#define NS_NXT_BIT_CLEAR(n,p) (p[(n)/NS_NXT_BITS] &= ~(0x80>>((n)%NS_NXT_BITS)))
+#define NS_NXT_BIT_ISSET(n,p) (p[(n)/NS_NXT_BITS] & (0x80>>((n)%NS_NXT_BITS)))
+#define NS_NXT_MAX 127
+
+#define NS_OPT_DNSSEC_OK 0x8000U
+#define NS_OPT_NSID 3
+
+#define NS_GET16(s, cp) do { \
+ register const unsigned char *t_cp = (const unsigned char *)(cp); \
+ (s) = ((uint16_t)t_cp[0] << 8) \
+ | ((uint16_t)t_cp[1]) \
+ ; \
+ (cp) += NS_INT16SZ; \
+} while (0)
+
+#define NS_GET32(l, cp) do { \
+ register const unsigned char *t_cp = (const unsigned char *)(cp); \
+ (l) = ((uint32_t)t_cp[0] << 24) \
+ | ((uint32_t)t_cp[1] << 16) \
+ | ((uint32_t)t_cp[2] << 8) \
+ | ((uint32_t)t_cp[3]) \
+ ; \
+ (cp) += NS_INT32SZ; \
+} while (0)
+
+#define NS_PUT16(s, cp) do { \
+ register uint16_t t_s = (uint16_t)(s); \
+ register unsigned char *t_cp = (unsigned char *)(cp); \
+ *t_cp++ = t_s >> 8; \
+ *t_cp = t_s; \
+ (cp) += NS_INT16SZ; \
+} while (0)
+
+#define NS_PUT32(l, cp) do { \
+ register uint32_t t_l = (uint32_t)(l); \
+ register unsigned char *t_cp = (unsigned char *)(cp); \
+ *t_cp++ = t_l >> 24; \
+ *t_cp++ = t_l >> 16; \
+ *t_cp++ = t_l >> 8; \
+ *t_cp = t_l; \
+ (cp) += NS_INT32SZ; \
+} while (0)
+
+
+
+
+#define __BIND 19950621
+
+typedef struct {
+ unsigned id :16;
+#if __BYTE_ORDER == __BIG_ENDIAN
+ unsigned qr: 1;
+ unsigned opcode: 4;
+ unsigned aa: 1;
+ unsigned tc: 1;
+ unsigned rd: 1;
+ unsigned ra: 1;
+ unsigned unused :1;
+ unsigned ad: 1;
+ unsigned cd: 1;
+ unsigned rcode :4;
+#else
+ unsigned rd :1;
+ unsigned tc :1;
+ unsigned aa :1;
+ unsigned opcode :4;
+ unsigned qr :1;
+ unsigned rcode :4;
+ unsigned cd: 1;
+ unsigned ad: 1;
+ unsigned unused :1;
+ unsigned ra :1;
+#endif
+ unsigned qdcount :16;
+ unsigned ancount :16;
+ unsigned nscount :16;
+ unsigned arcount :16;
+} HEADER;
+
+#define PACKETSZ NS_PACKETSZ
+#define MAXDNAME NS_MAXDNAME
+#define MAXCDNAME NS_MAXCDNAME
+#define MAXLABEL NS_MAXLABEL
+#define HFIXEDSZ NS_HFIXEDSZ
+#define QFIXEDSZ NS_QFIXEDSZ
+#define RRFIXEDSZ NS_RRFIXEDSZ
+#define INT32SZ NS_INT32SZ
+#define INT16SZ NS_INT16SZ
+#define INT8SZ NS_INT8SZ
+#define INADDRSZ NS_INADDRSZ
+#define IN6ADDRSZ NS_IN6ADDRSZ
+#define INDIR_MASK NS_CMPRSFLGS
+#define NAMESERVER_PORT NS_DEFAULTPORT
+
+#define S_ZONE ns_s_zn
+#define S_PREREQ ns_s_pr
+#define S_UPDATE ns_s_ud
+#define S_ADDT ns_s_ar
+
+#define QUERY ns_o_query
+#define IQUERY ns_o_iquery
+#define STATUS ns_o_status
+#define NS_NOTIFY_OP ns_o_notify
+#define NS_UPDATE_OP ns_o_update
+
+#define NOERROR ns_r_noerror
+#define FORMERR ns_r_formerr
+#define SERVFAIL ns_r_servfail
+#define NXDOMAIN ns_r_nxdomain
+#define NOTIMP ns_r_notimpl
+#define REFUSED ns_r_refused
+#define YXDOMAIN ns_r_yxdomain
+#define YXRRSET ns_r_yxrrset
+#define NXRRSET ns_r_nxrrset
+#define NOTAUTH ns_r_notauth
+#define NOTZONE ns_r_notzone
+
+#define DELETE ns_uop_delete
+#define ADD ns_uop_add
+
+#define T_A ns_t_a
+#define T_NS ns_t_ns
+#define T_MD ns_t_md
+#define T_MF ns_t_mf
+#define T_CNAME ns_t_cname
+#define T_SOA ns_t_soa
+#define T_MB ns_t_mb
+#define T_MG ns_t_mg
+#define T_MR ns_t_mr
+#define T_NULL ns_t_null
+#define T_WKS ns_t_wks
+#define T_PTR ns_t_ptr
+#define T_HINFO ns_t_hinfo
+#define T_MINFO ns_t_minfo
+#define T_MX ns_t_mx
+#define T_TXT ns_t_txt
+#define T_RP ns_t_rp
+#define T_AFSDB ns_t_afsdb
+#define T_X25 ns_t_x25
+#define T_ISDN ns_t_isdn
+#define T_RT ns_t_rt
+#define T_NSAP ns_t_nsap
+#define T_NSAP_PTR ns_t_nsap_ptr
+#define T_SIG ns_t_sig
+#define T_KEY ns_t_key
+#define T_PX ns_t_px
+#define T_GPOS ns_t_gpos
+#define T_AAAA ns_t_aaaa
+#define T_LOC ns_t_loc
+#define T_NXT ns_t_nxt
+#define T_EID ns_t_eid
+#define T_NIMLOC ns_t_nimloc
+#define T_SRV ns_t_srv
+#define T_ATMA ns_t_atma
+#define T_NAPTR ns_t_naptr
+#define T_A6 ns_t_a6
+#define T_DNAME ns_t_dname
+#define T_TSIG ns_t_tsig
+#define T_IXFR ns_t_ixfr
+#define T_AXFR ns_t_axfr
+#define T_MAILB ns_t_mailb
+#define T_MAILA ns_t_maila
+#define T_ANY ns_t_any
+
+#define C_IN ns_c_in
+#define C_CHAOS ns_c_chaos
+#define C_HS ns_c_hs
+#define C_NONE ns_c_none
+#define C_ANY ns_c_any
+
+#define GETSHORT NS_GET16
+#define GETLONG NS_GET32
+#define PUTSHORT NS_PUT16
+#define PUTLONG NS_PUT32
+
+#endif
diff --git a/system/include/libc/arpa/nameser_compat.h b/system/include/libc/arpa/nameser_compat.h
new file mode 100644
index 00000000..3aac25c9
--- /dev/null
+++ b/system/include/libc/arpa/nameser_compat.h
@@ -0,0 +1,2 @@
+#include <arpa/nameser.h>
+
diff --git a/system/include/libc/arpa/telnet.h b/system/include/libc/arpa/telnet.h
new file mode 100644
index 00000000..e2ad9742
--- /dev/null
+++ b/system/include/libc/arpa/telnet.h
@@ -0,0 +1,251 @@
+#ifndef _ARPA_TELNET_H
+#define _ARPA_TELNET_H
+
+#define IAC 255
+#define DONT 254
+#define DO 253
+#define WONT 252
+#define WILL 251
+#define SB 250
+#define GA 249
+#define EL 248
+#define EC 247
+#define AYT 246
+#define AO 245
+#define IP 244
+#define BREAK 243
+#define DM 242
+#define NOP 241
+#define SE 240
+#define EOR 239
+#define ABORT 238
+#define SUSP 237
+#define xEOF 236
+
+#define SYNCH 242
+
+#define telcmds ((char [][6]){ "EOF", "SUSP", "ABORT", "EOR", "SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC", "EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC", 0 })
+
+#define TELCMD_FIRST xEOF
+#define TELCMD_LAST IAC
+#define TELCMD_OK(x) ((unsigned int)(x) <= TELCMD_LAST && \
+ (unsigned int)(x) >= TELCMD_FIRST)
+#define TELCMD(x) telcmds[(x)-TELCMD_FIRST]
+
+#define TELOPT_BINARY 0
+#define TELOPT_ECHO 1
+#define TELOPT_RCP 2
+#define TELOPT_SGA 3
+#define TELOPT_NAMS 4
+#define TELOPT_STATUS 5
+#define TELOPT_TM 6
+#define TELOPT_RCTE 7
+#define TELOPT_NAOL 8
+#define TELOPT_NAOP 9
+#define TELOPT_NAOCRD 10
+#define TELOPT_NAOHTS 11
+#define TELOPT_NAOHTD 12
+#define TELOPT_NAOFFD 13
+#define TELOPT_NAOVTS 14
+#define TELOPT_NAOVTD 15
+#define TELOPT_NAOLFD 16
+#define TELOPT_XASCII 17
+#define TELOPT_LOGOUT 18
+#define TELOPT_BM 19
+#define TELOPT_DET 20
+#define TELOPT_SUPDUP 21
+#define TELOPT_SUPDUPOUTPUT 22
+#define TELOPT_SNDLOC 23
+#define TELOPT_TTYPE 24
+#define TELOPT_EOR 25
+#define TELOPT_TUID 26
+#define TELOPT_OUTMRK 27
+#define TELOPT_TTYLOC 28
+#define TELOPT_3270REGIME 29
+#define TELOPT_X3PAD 30
+#define TELOPT_NAWS 31
+#define TELOPT_TSPEED 32
+#define TELOPT_LFLOW 33
+#define TELOPT_LINEMODE 34
+#define TELOPT_XDISPLOC 35
+#define TELOPT_OLD_ENVIRON 36
+#define TELOPT_AUTHENTICATION 37/* Authenticate */
+#define TELOPT_ENCRYPT 38
+#define TELOPT_NEW_ENVIRON 39
+#define TELOPT_EXOPL 255
+
+
+#define NTELOPTS (1+TELOPT_NEW_ENVIRON)
+#ifdef TELOPTS
+char *telopts[NTELOPTS+1] = {
+ "BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME",
+ "STATUS", "TIMING MARK", "RCTE", "NAOL", "NAOP",
+ "NAOCRD", "NAOHTS", "NAOHTD", "NAOFFD", "NAOVTS",
+ "NAOVTD", "NAOLFD", "EXTEND ASCII", "LOGOUT", "BYTE MACRO",
+ "DATA ENTRY TERMINAL", "SUPDUP", "SUPDUP OUTPUT",
+ "SEND LOCATION", "TERMINAL TYPE", "END OF RECORD",
+ "TACACS UID", "OUTPUT MARKING", "TTYLOC",
+ "3270 REGIME", "X.3 PAD", "NAWS", "TSPEED", "LFLOW",
+ "LINEMODE", "XDISPLOC", "OLD-ENVIRON", "AUTHENTICATION",
+ "ENCRYPT", "NEW-ENVIRON",
+ 0,
+};
+#define TELOPT_FIRST TELOPT_BINARY
+#define TELOPT_LAST TELOPT_NEW_ENVIRON
+#define TELOPT_OK(x) ((unsigned int)(x) <= TELOPT_LAST)
+#define TELOPT(x) telopts[(x)-TELOPT_FIRST]
+#endif
+
+#define TELQUAL_IS 0
+#define TELQUAL_SEND 1
+#define TELQUAL_INFO 2
+#define TELQUAL_REPLY 2
+#define TELQUAL_NAME 3
+
+#define LFLOW_OFF 0
+#define LFLOW_ON 1
+#define LFLOW_RESTART_ANY 2
+#define LFLOW_RESTART_XON 3
+
+
+#define LM_MODE 1
+#define LM_FORWARDMASK 2
+#define LM_SLC 3
+
+#define MODE_EDIT 0x01
+#define MODE_TRAPSIG 0x02
+#define MODE_ACK 0x04
+#define MODE_SOFT_TAB 0x08
+#define MODE_LIT_ECHO 0x10
+
+#define MODE_MASK 0x1f
+
+#define MODE_FLOW 0x0100
+#define MODE_ECHO 0x0200
+#define MODE_INBIN 0x0400
+#define MODE_OUTBIN 0x0800
+#define MODE_FORCE 0x1000
+
+#define SLC_SYNCH 1
+#define SLC_BRK 2
+#define SLC_IP 3
+#define SLC_AO 4
+#define SLC_AYT 5
+#define SLC_EOR 6
+#define SLC_ABORT 7
+#define SLC_EOF 8
+#define SLC_SUSP 9
+#define SLC_EC 10
+#define SLC_EL 11
+#define SLC_EW 12
+#define SLC_RP 13
+#define SLC_LNEXT 14
+#define SLC_XON 15
+#define SLC_XOFF 16
+#define SLC_FORW1 17
+#define SLC_FORW2 18
+
+#define NSLC 18
+
+#define SLC_NAMELIST "0", "SYNCH", "BRK", "IP", "AO", "AYT", "EOR", \
+ "ABORT", "EOF", "SUSP", "EC", "EL", "EW", "RP", \
+ "LNEXT", "XON", "XOFF", "FORW1", "FORW2", 0,
+#ifdef SLC_NAMES
+char *slc_names[] = {
+ SLC_NAMELIST
+};
+#else
+extern char *slc_names[];
+#define SLC_NAMES SLC_NAMELIST
+#endif
+
+#define SLC_NAME_OK(x) ((unsigned int)(x) <= NSLC)
+#define SLC_NAME(x) slc_names[x]
+
+#define SLC_NOSUPPORT 0
+#define SLC_CANTCHANGE 1
+#define SLC_VARIABLE 2
+#define SLC_DEFAULT 3
+#define SLC_LEVELBITS 0x03
+
+#define SLC_FUNC 0
+#define SLC_FLAGS 1
+#define SLC_VALUE 2
+
+#define SLC_ACK 0x80
+#define SLC_FLUSHIN 0x40
+#define SLC_FLUSHOUT 0x20
+
+#define OLD_ENV_VAR 1
+#define OLD_ENV_VALUE 0
+#define NEW_ENV_VAR 0
+#define NEW_ENV_VALUE 1
+#define ENV_ESC 2
+#define ENV_USERVAR 3
+
+#define AUTH_WHO_CLIENT 0
+#define AUTH_WHO_SERVER 1
+#define AUTH_WHO_MASK 1
+
+#define AUTH_HOW_ONE_WAY 0
+#define AUTH_HOW_MUTUAL 2
+#define AUTH_HOW_MASK 2
+
+#define AUTHTYPE_NULL 0
+#define AUTHTYPE_KERBEROS_V4 1
+#define AUTHTYPE_KERBEROS_V5 2
+#define AUTHTYPE_SPX 3
+#define AUTHTYPE_MINK 4
+#define AUTHTYPE_CNT 5
+
+#define AUTHTYPE_TEST 99
+
+#ifdef AUTH_NAMES
+char *authtype_names[] = {
+ "NULL", "KERBEROS_V4", "KERBEROS_V5", "SPX", "MINK", 0,
+};
+#else
+extern char *authtype_names[];
+#endif
+
+#define AUTHTYPE_NAME_OK(x) ((unsigned int)(x) < AUTHTYPE_CNT)
+#define AUTHTYPE_NAME(x) authtype_names[x]
+
+#define ENCRYPT_IS 0
+#define ENCRYPT_SUPPORT 1
+#define ENCRYPT_REPLY 2
+#define ENCRYPT_START 3
+#define ENCRYPT_END 4
+#define ENCRYPT_REQSTART 5
+#define ENCRYPT_REQEND 6
+#define ENCRYPT_ENC_KEYID 7
+#define ENCRYPT_DEC_KEYID 8
+#define ENCRYPT_CNT 9
+
+#define ENCTYPE_ANY 0
+#define ENCTYPE_DES_CFB64 1
+#define ENCTYPE_DES_OFB64 2
+#define ENCTYPE_CNT 3
+
+#ifdef ENCRYPT_NAMES
+char *encrypt_names[] = {
+ "IS", "SUPPORT", "REPLY", "START", "END",
+ "REQUEST-START", "REQUEST-END", "ENC-KEYID", "DEC-KEYID",
+ 0,
+};
+char *enctype_names[] = {
+ "ANY", "DES_CFB64", "DES_OFB64", 0,
+};
+#else
+extern char *encrypt_names[];
+extern char *enctype_names[];
+#endif
+
+
+#define ENCRYPT_NAME_OK(x) ((unsigned int)(x) < ENCRYPT_CNT)
+#define ENCRYPT_NAME(x) encrypt_names[x]
+
+#define ENCTYPE_NAME_OK(x) ((unsigned int)(x) < ENCTYPE_CNT)
+#define ENCTYPE_NAME(x) enctype_names[x]
+
+#endif
diff --git a/system/include/libc/arpa/tftp.h b/system/include/libc/arpa/tftp.h
new file mode 100644
index 00000000..799c54f2
--- /dev/null
+++ b/system/include/libc/arpa/tftp.h
@@ -0,0 +1,31 @@
+#ifndef _ARPA_TFTP_H
+#define _ARPA_TFTP_H
+#define SEGSIZE 512
+#define RRQ 01
+#define WRQ 02
+#define DATA 03
+#define ACK 04
+#define ERROR 05
+struct tftphdr {
+ short th_opcode;
+ union {
+ unsigned short tu_block;
+ short tu_code;
+ char tu_stuff[1];
+ } th_u;
+ char th_data[1];
+};
+#define th_block th_u.tu_block
+#define th_code th_u.tu_code
+#define th_stuff th_u.tu_stuff
+#define th_msg th_data
+#define EUNDEF 0
+#define ENOTFOUND 1
+#define EACCESS 2
+#define ENOSPACE 3
+#define EBADOP 4
+#define EBADID 5
+#define EEXISTS 6
+#define ENOUSER 7
+#endif
+
diff --git a/system/include/libc/assert.h b/system/include/libc/assert.h
index 8d112839..ab745db1 100644
--- a/system/include/libc/assert.h
+++ b/system/include/libc/assert.h
@@ -1,45 +1,18 @@
-/*
- assert.h
-*/
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "_ansi.h"
+#include <features.h>
#undef assert
-#ifdef NDEBUG /* required by ANSI standard */
-# define assert(__e) ((void)0)
+#ifdef NDEBUG
+#define assert(x) (void)0
#else
-# define assert(__e) ((__e) ? (void)0 : __assert_func (__FILE__, __LINE__, \
- __ASSERT_FUNC, #__e))
-
-# ifndef __ASSERT_FUNC
- /* Use g++'s demangled names in C++. */
-# if defined __cplusplus && defined __GNUC__
-# define __ASSERT_FUNC __PRETTY_FUNCTION__
-
- /* C99 requires the use of __func__. */
-# elif __STDC_VERSION__ >= 199901L
-# define __ASSERT_FUNC __func__
-
- /* Older versions of gcc don't have __func__ but can use __FUNCTION__. */
-# elif __GNUC__ >= 2
-# define __ASSERT_FUNC __FUNCTION__
+#define assert(x) ((void)((x) || (__assert_fail(#x, __FILE__, __LINE__, __func__),0)))
+#endif
- /* failed to detect __func__ support. */
-# else
-# define __ASSERT_FUNC ((char *) 0)
-# endif
-# endif /* !__ASSERT_FUNC */
-#endif /* !NDEBUG */
+#ifdef __cplusplus
+extern "C" {
+#endif
-void _EXFUN(__assert, (const char *, int, const char *)
- _ATTRIBUTE(noreturn));
-void _EXFUN(__assert_func, (const char *, int, const char *, const char *)
- _ATTRIBUTE(noreturn));
+void __assert_fail (const char *, const char *, int, const char *);
#ifdef __cplusplus
}
diff --git a/system/include/libc/bits/alltypes.h b/system/include/libc/bits/alltypes.h
new file mode 100644
index 00000000..e7f3bdc7
--- /dev/null
+++ b/system/include/libc/bits/alltypes.h
@@ -0,0 +1,397 @@
+#define _Addr int
+#define _Int64 long long
+#define _Reg int
+
+#if __GNUC__ >= 3
+#if defined(__NEED_va_list) && !defined(__DEFINED_va_list)
+typedef __builtin_va_list va_list;
+#define __DEFINED_va_list
+#endif
+
+#if defined(__NEED___isoc_va_list) && !defined(__DEFINED___isoc_va_list)
+typedef __builtin_va_list __isoc_va_list;
+#define __DEFINED___isoc_va_list
+#endif
+
+#else
+#if defined(__NEED_va_list) && !defined(__DEFINED_va_list)
+typedef struct __va_list * va_list;
+#define __DEFINED_va_list
+#endif
+
+#if defined(__NEED___isoc_va_list) && !defined(__DEFINED___isoc_va_list)
+typedef struct __va_list * __isoc_va_list;
+#define __DEFINED___isoc_va_list
+#endif
+
+#endif
+
+#ifndef __cplusplus
+#ifdef __WCHAR_TYPE__
+#if defined(__NEED_wchar_t) && !defined(__DEFINED_wchar_t)
+typedef __WCHAR_TYPE__ wchar_t;
+#define __DEFINED_wchar_t
+#endif
+
+#else
+#if defined(__NEED_wchar_t) && !defined(__DEFINED_wchar_t)
+typedef long wchar_t;
+#define __DEFINED_wchar_t
+#endif
+
+#endif
+#endif
+#if defined(__NEED_wint_t) && !defined(__DEFINED_wint_t)
+typedef unsigned wint_t;
+#define __DEFINED_wint_t
+#endif
+
+
+#if defined(__FLT_EVAL_METHOD__) && __FLT_EVAL_METHOD__ == 0
+#if defined(__NEED_float_t) && !defined(__DEFINED_float_t)
+typedef float float_t;
+#define __DEFINED_float_t
+#endif
+
+#if defined(__NEED_double_t) && !defined(__DEFINED_double_t)
+typedef double double_t;
+#define __DEFINED_double_t
+#endif
+
+#else
+#if defined(__NEED_float_t) && !defined(__DEFINED_float_t)
+typedef long double float_t;
+#define __DEFINED_float_t
+#endif
+
+#if defined(__NEED_double_t) && !defined(__DEFINED_double_t)
+typedef long double double_t;
+#define __DEFINED_double_t
+#endif
+
+#endif
+
+#if defined(__NEED_time_t) && !defined(__DEFINED_time_t)
+typedef long time_t;
+#define __DEFINED_time_t
+#endif
+
+#if defined(__NEED_suseconds_t) && !defined(__DEFINED_suseconds_t)
+typedef long suseconds_t;
+#define __DEFINED_suseconds_t
+#endif
+
+
+#if defined(__NEED_pthread_attr_t) && !defined(__DEFINED_pthread_attr_t)
+typedef struct { union { int __i[9]; unsigned __s[9]; } __u; } pthread_attr_t;
+#define __DEFINED_pthread_attr_t
+#endif
+
+#if defined(__NEED_pthread_mutex_t) && !defined(__DEFINED_pthread_mutex_t)
+typedef struct { union { int __i[6]; void *__p[6]; } __u; } pthread_mutex_t;
+#define __DEFINED_pthread_mutex_t
+#endif
+
+#if defined(__NEED_pthread_cond_t) && !defined(__DEFINED_pthread_cond_t)
+typedef struct { union { int __i[12]; void *__p[12]; } __u; } pthread_cond_t;
+#define __DEFINED_pthread_cond_t
+#endif
+
+#if defined(__NEED_pthread_rwlock_t) && !defined(__DEFINED_pthread_rwlock_t)
+typedef struct { union { int __i[8]; void *__p[8]; } __u; } pthread_rwlock_t;
+#define __DEFINED_pthread_rwlock_t
+#endif
+
+#if defined(__NEED_pthread_barrier_t) && !defined(__DEFINED_pthread_barrier_t)
+typedef struct { union { int __i[5]; void *__p[5]; } __u; } pthread_barrier_t;
+#define __DEFINED_pthread_barrier_t
+#endif
+
+#if defined(__NEED_size_t) && !defined(__DEFINED_size_t)
+typedef unsigned _Addr size_t;
+#define __DEFINED_size_t
+#endif
+
+#if defined(__NEED_uintptr_t) && !defined(__DEFINED_uintptr_t)
+typedef unsigned _Addr uintptr_t;
+#define __DEFINED_uintptr_t
+#endif
+
+#if defined(__NEED_ptrdiff_t) && !defined(__DEFINED_ptrdiff_t)
+typedef _Addr ptrdiff_t;
+#define __DEFINED_ptrdiff_t
+#endif
+
+#if defined(__NEED_ssize_t) && !defined(__DEFINED_ssize_t)
+typedef _Addr ssize_t;
+#define __DEFINED_ssize_t
+#endif
+
+#if defined(__NEED_intptr_t) && !defined(__DEFINED_intptr_t)
+typedef _Addr intptr_t;
+#define __DEFINED_intptr_t
+#endif
+
+#if defined(__NEED_regoff_t) && !defined(__DEFINED_regoff_t)
+typedef _Addr regoff_t;
+#define __DEFINED_regoff_t
+#endif
+
+#if defined(__NEED_register_t) && !defined(__DEFINED_register_t)
+typedef _Reg register_t;
+#define __DEFINED_register_t
+#endif
+
+
+#if defined(__NEED_int8_t) && !defined(__DEFINED_int8_t)
+typedef signed char int8_t;
+#define __DEFINED_int8_t
+#endif
+
+#if defined(__NEED_int16_t) && !defined(__DEFINED_int16_t)
+typedef short int16_t;
+#define __DEFINED_int16_t
+#endif
+
+#if defined(__NEED_int32_t) && !defined(__DEFINED_int32_t)
+typedef int int32_t;
+#define __DEFINED_int32_t
+#endif
+
+#if defined(__NEED_int64_t) && !defined(__DEFINED_int64_t)
+typedef _Int64 int64_t;
+#define __DEFINED_int64_t
+#endif
+
+#if defined(__NEED_intmax_t) && !defined(__DEFINED_intmax_t)
+typedef _Int64 intmax_t;
+#define __DEFINED_intmax_t
+#endif
+
+#if defined(__NEED_uint8_t) && !defined(__DEFINED_uint8_t)
+typedef unsigned char uint8_t;
+#define __DEFINED_uint8_t
+#endif
+
+#if defined(__NEED_uint16_t) && !defined(__DEFINED_uint16_t)
+typedef unsigned short uint16_t;
+#define __DEFINED_uint16_t
+#endif
+
+#if defined(__NEED_uint32_t) && !defined(__DEFINED_uint32_t)
+typedef unsigned int uint32_t;
+#define __DEFINED_uint32_t
+#endif
+
+#if defined(__NEED_uint64_t) && !defined(__DEFINED_uint64_t)
+typedef unsigned _Int64 uint64_t;
+#define __DEFINED_uint64_t
+#endif
+
+#if defined(__NEED_u_int64_t) && !defined(__DEFINED_u_int64_t)
+typedef unsigned _Int64 u_int64_t;
+#define __DEFINED_u_int64_t
+#endif
+
+#if defined(__NEED_uintmax_t) && !defined(__DEFINED_uintmax_t)
+typedef unsigned _Int64 uintmax_t;
+#define __DEFINED_uintmax_t
+#endif
+
+
+#if defined(__NEED_mode_t) && !defined(__DEFINED_mode_t)
+typedef unsigned mode_t;
+#define __DEFINED_mode_t
+#endif
+
+#if defined(__NEED_nlink_t) && !defined(__DEFINED_nlink_t)
+typedef unsigned _Reg nlink_t;
+#define __DEFINED_nlink_t
+#endif
+
+#if defined(__NEED_off_t) && !defined(__DEFINED_off_t)
+typedef _Int64 off_t;
+#define __DEFINED_off_t
+#endif
+
+#if defined(__NEED_ino_t) && !defined(__DEFINED_ino_t)
+typedef unsigned _Int64 ino_t;
+#define __DEFINED_ino_t
+#endif
+
+#if defined(__NEED_dev_t) && !defined(__DEFINED_dev_t)
+typedef unsigned _Int64 dev_t;
+#define __DEFINED_dev_t
+#endif
+
+#if defined(__NEED_blksize_t) && !defined(__DEFINED_blksize_t)
+typedef long blksize_t;
+#define __DEFINED_blksize_t
+#endif
+
+#if defined(__NEED_blkcnt_t) && !defined(__DEFINED_blkcnt_t)
+typedef _Int64 blkcnt_t;
+#define __DEFINED_blkcnt_t
+#endif
+
+#if defined(__NEED_fsblkcnt_t) && !defined(__DEFINED_fsblkcnt_t)
+typedef unsigned _Int64 fsblkcnt_t;
+#define __DEFINED_fsblkcnt_t
+#endif
+
+#if defined(__NEED_fsfilcnt_t) && !defined(__DEFINED_fsfilcnt_t)
+typedef unsigned _Int64 fsfilcnt_t;
+#define __DEFINED_fsfilcnt_t
+#endif
+
+
+#if defined(__NEED_wctype_t) && !defined(__DEFINED_wctype_t)
+typedef unsigned long wctype_t;
+#define __DEFINED_wctype_t
+#endif
+
+
+#if defined(__NEED_timer_t) && !defined(__DEFINED_timer_t)
+typedef void * timer_t;
+#define __DEFINED_timer_t
+#endif
+
+#if defined(__NEED_clockid_t) && !defined(__DEFINED_clockid_t)
+typedef int clockid_t;
+#define __DEFINED_clockid_t
+#endif
+
+#if defined(__NEED_clock_t) && !defined(__DEFINED_clock_t)
+typedef long clock_t;
+#define __DEFINED_clock_t
+#endif
+
+#if defined(__NEED_struct_timeval) && !defined(__DEFINED_struct_timeval)
+struct timeval { time_t tv_sec; suseconds_t tv_usec; };
+#define __DEFINED_struct_timeval
+#endif
+
+#if defined(__NEED_struct_timespec) && !defined(__DEFINED_struct_timespec)
+struct timespec { time_t tv_sec; long tv_nsec; };
+#define __DEFINED_struct_timespec
+#endif
+
+
+#if defined(__NEED_pid_t) && !defined(__DEFINED_pid_t)
+typedef int pid_t;
+#define __DEFINED_pid_t
+#endif
+
+#if defined(__NEED_id_t) && !defined(__DEFINED_id_t)
+typedef unsigned id_t;
+#define __DEFINED_id_t
+#endif
+
+#if defined(__NEED_uid_t) && !defined(__DEFINED_uid_t)
+typedef unsigned uid_t;
+#define __DEFINED_uid_t
+#endif
+
+#if defined(__NEED_gid_t) && !defined(__DEFINED_gid_t)
+typedef unsigned gid_t;
+#define __DEFINED_gid_t
+#endif
+
+#if defined(__NEED_key_t) && !defined(__DEFINED_key_t)
+typedef int key_t;
+#define __DEFINED_key_t
+#endif
+
+#if defined(__NEED_useconds_t) && !defined(__DEFINED_useconds_t)
+typedef unsigned useconds_t;
+#define __DEFINED_useconds_t
+#endif
+
+
+#ifdef __cplusplus
+#if defined(__NEED_pthread_t) && !defined(__DEFINED_pthread_t)
+typedef unsigned long pthread_t;
+#define __DEFINED_pthread_t
+#endif
+
+#else
+#if defined(__NEED_pthread_t) && !defined(__DEFINED_pthread_t)
+typedef struct __pthread * pthread_t;
+#define __DEFINED_pthread_t
+#endif
+
+#endif
+#if defined(__NEED_pthread_once_t) && !defined(__DEFINED_pthread_once_t)
+typedef int pthread_once_t;
+#define __DEFINED_pthread_once_t
+#endif
+
+#if defined(__NEED_pthread_key_t) && !defined(__DEFINED_pthread_key_t)
+typedef unsigned pthread_key_t;
+#define __DEFINED_pthread_key_t
+#endif
+
+#if defined(__NEED_pthread_spinlock_t) && !defined(__DEFINED_pthread_spinlock_t)
+typedef int pthread_spinlock_t;
+#define __DEFINED_pthread_spinlock_t
+#endif
+
+#if defined(__NEED_pthread_mutexattr_t) && !defined(__DEFINED_pthread_mutexattr_t)
+typedef struct { unsigned __attr; } pthread_mutexattr_t;
+#define __DEFINED_pthread_mutexattr_t
+#endif
+
+#if defined(__NEED_pthread_condattr_t) && !defined(__DEFINED_pthread_condattr_t)
+typedef struct { unsigned __attr; } pthread_condattr_t;
+#define __DEFINED_pthread_condattr_t
+#endif
+
+#if defined(__NEED_pthread_barrierattr_t) && !defined(__DEFINED_pthread_barrierattr_t)
+typedef struct { unsigned __attr; } pthread_barrierattr_t;
+#define __DEFINED_pthread_barrierattr_t
+#endif
+
+#if defined(__NEED_pthread_rwlockattr_t) && !defined(__DEFINED_pthread_rwlockattr_t)
+typedef struct { unsigned __attr[2]; } pthread_rwlockattr_t;
+#define __DEFINED_pthread_rwlockattr_t
+#endif
+
+
+#if defined(__NEED_FILE) && !defined(__DEFINED_FILE)
+typedef struct _IO_FILE FILE;
+#define __DEFINED_FILE
+#endif
+
+
+#if defined(__NEED_locale_t) && !defined(__DEFINED_locale_t)
+typedef struct __locale_struct * locale_t;
+#define __DEFINED_locale_t
+#endif
+
+
+#if defined(__NEED_sigset_t) && !defined(__DEFINED_sigset_t)
+typedef struct __sigset_t { unsigned long __bits[128/sizeof(long)]; } sigset_t;
+#define __DEFINED_sigset_t
+#endif
+
+
+#if defined(__NEED_struct_iovec) && !defined(__DEFINED_struct_iovec)
+struct iovec { void *iov_base; size_t iov_len; };
+#define __DEFINED_struct_iovec
+#endif
+
+
+#if defined(__NEED_socklen_t) && !defined(__DEFINED_socklen_t)
+typedef unsigned socklen_t;
+#define __DEFINED_socklen_t
+#endif
+
+#if defined(__NEED_sa_family_t) && !defined(__DEFINED_sa_family_t)
+typedef unsigned short sa_family_t;
+#define __DEFINED_sa_family_t
+#endif
+
+
+#undef _Addr
+#undef _Int64
+#undef _Reg
diff --git a/system/include/libc/bits/endian.h b/system/include/libc/bits/endian.h
new file mode 100644
index 00000000..172c338f
--- /dev/null
+++ b/system/include/libc/bits/endian.h
@@ -0,0 +1 @@
+#define __BYTE_ORDER __LITTLE_ENDIAN
diff --git a/system/include/libc/bits/errno.h b/system/include/libc/bits/errno.h
new file mode 100644
index 00000000..d2e1eeee
--- /dev/null
+++ b/system/include/libc/bits/errno.h
@@ -0,0 +1,134 @@
+#define EPERM 1
+#define ENOENT 2
+#define ESRCH 3
+#define EINTR 4
+#define EIO 5
+#define ENXIO 6
+#define E2BIG 7
+#define ENOEXEC 8
+#define EBADF 9
+#define ECHILD 10
+#define EAGAIN 11
+#define ENOMEM 12
+#define EACCES 13
+#define EFAULT 14
+#define ENOTBLK 15
+#define EBUSY 16
+#define EEXIST 17
+#define EXDEV 18
+#define ENODEV 19
+#define ENOTDIR 20
+#define EISDIR 21
+#define EINVAL 22
+#define ENFILE 23
+#define EMFILE 24
+#define ENOTTY 25
+#define ETXTBSY 26
+#define EFBIG 27
+#define ENOSPC 28
+#define ESPIPE 29
+#define EROFS 30
+#define EMLINK 31
+#define EPIPE 32
+#define EDOM 33
+#define ERANGE 34
+#define EDEADLK 35
+#define ENAMETOOLONG 36
+#define ENOLCK 37
+#define ENOSYS 38
+#define ENOTEMPTY 39
+#define ELOOP 40
+#define EWOULDBLOCK EAGAIN
+#define ENOMSG 42
+#define EIDRM 43
+#define ECHRNG 44
+#define EL2NSYNC 45
+#define EL3HLT 46
+#define EL3RST 47
+#define ELNRNG 48
+#define EUNATCH 49
+#define ENOCSI 50
+#define EL2HLT 51
+#define EBADE 52
+#define EBADR 53
+#define EXFULL 54
+#define ENOANO 55
+#define EBADRQC 56
+#define EBADSLT 57
+#define EDEADLOCK EDEADLK
+#define EBFONT 59
+#define ENOSTR 60
+#define ENODATA 61
+#define ETIME 62
+#define ENOSR 63
+#define ENONET 64
+#define ENOPKG 65
+#define EREMOTE 66
+#define ENOLINK 67
+#define EADV 68
+#define ESRMNT 69
+#define ECOMM 70
+#define EPROTO 71
+#define EMULTIHOP 72
+#define EDOTDOT 73
+#define EBADMSG 74
+#define EOVERFLOW 75
+#define ENOTUNIQ 76
+#define EBADFD 77
+#define EREMCHG 78
+#define ELIBACC 79
+#define ELIBBAD 80
+#define ELIBSCN 81
+#define ELIBMAX 82
+#define ELIBEXEC 83
+#define EILSEQ 84
+#define ERESTART 85
+#define ESTRPIPE 86
+#define EUSERS 87
+#define ENOTSOCK 88
+#define EDESTADDRREQ 89
+#define EMSGSIZE 90
+#define EPROTOTYPE 91
+#define ENOPROTOOPT 92
+#define EPROTONOSUPPORT 93
+#define ESOCKTNOSUPPORT 94
+#define EOPNOTSUPP 95
+#define ENOTSUP EOPNOTSUPP
+#define EPFNOSUPPORT 96
+#define EAFNOSUPPORT 97
+#define EADDRINUSE 98
+#define EADDRNOTAVAIL 99
+#define ENETDOWN 100
+#define ENETUNREACH 101
+#define ENETRESET 102
+#define ECONNABORTED 103
+#define ECONNRESET 104
+#define ENOBUFS 105
+#define EISCONN 106
+#define ENOTCONN 107
+#define ESHUTDOWN 108
+#define ETOOMANYREFS 109
+#define ETIMEDOUT 110
+#define ECONNREFUSED 111
+#define EHOSTDOWN 112
+#define EHOSTUNREACH 113
+#define EALREADY 114
+#define EINPROGRESS 115
+#define ESTALE 116
+#define EUCLEAN 117
+#define ENOTNAM 118
+#define ENAVAIL 119
+#define EISNAM 120
+#define EREMOTEIO 121
+#define EDQUOT 122
+#define ENOMEDIUM 123
+#define EMEDIUMTYPE 124
+#define ECANCELED 125
+#define ENOKEY 126
+#define EKEYEXPIRED 127
+#define EKEYREVOKED 128
+#define EKEYREJECTED 129
+#define EOWNERDEAD 130
+#define ENOTRECOVERABLE 131
+#define ERFKILL 132
+#define EHWPOISON 133
diff --git a/system/include/libc/bits/fcntl.h b/system/include/libc/bits/fcntl.h
new file mode 100644
index 00000000..4cc0312d
--- /dev/null
+++ b/system/include/libc/bits/fcntl.h
@@ -0,0 +1,38 @@
+#define O_CREAT 0100
+#define O_EXCL 0200
+#define O_NOCTTY 0400
+#define O_TRUNC 01000
+#define O_APPEND 02000
+#define O_NONBLOCK 04000
+#define O_DSYNC 010000
+#define O_SYNC 04010000
+#define O_RSYNC 04010000
+#define O_DIRECTORY 0200000
+#define O_NOFOLLOW 0400000
+#define O_CLOEXEC 02000000
+
+#define O_ASYNC 020000
+#define O_DIRECT 040000
+#define O_LARGEFILE 0100000
+#define O_NOATIME 01000000
+#define O_NDELAY O_NONBLOCK
+
+#define F_DUPFD 0
+#define F_GETFD 1
+#define F_SETFD 2
+#define F_GETFL 3
+#define F_SETFL 4
+
+#define F_SETOWN 8
+#define F_GETOWN 9
+#define F_SETSIG 10
+#define F_GETSIG 11
+
+#define F_GETLK 12
+#define F_SETLK 13
+#define F_SETLKW 14
+
+#define F_SETOWN_EX 15
+#define F_GETOWN_EX 16
+
+#define F_GETOWNER_UIDS 17
diff --git a/system/include/libc/bits/fenv.h b/system/include/libc/bits/fenv.h
new file mode 100644
index 00000000..24df0417
--- /dev/null
+++ b/system/include/libc/bits/fenv.h
@@ -0,0 +1,34 @@
+#define FE_INVALID 1
+#define __FE_DENORM 2
+#define FE_DIVBYZERO 4
+#define FE_OVERFLOW 8
+#define FE_UNDERFLOW 16
+#define FE_INEXACT 32
+
+#define FE_ALL_EXCEPT 63
+
+#define FE_TONEAREST 0
+#define FE_DOWNWARD 0x400
+#define FE_UPWARD 0x800
+#define FE_TOWARDZERO 0xc00
+
+typedef unsigned short fexcept_t;
+
+typedef struct {
+ unsigned short __control_word;
+ unsigned short __unused1;
+ unsigned short __status_word;
+ unsigned short __unused2;
+ unsigned short __tags;
+ unsigned short __unused3;
+ unsigned int __eip;
+ unsigned short __cs_selector;
+ unsigned int __opcode:11;
+ unsigned int __unused4:5;
+ unsigned int __data_offset;
+ unsigned short __data_selector;
+ unsigned short __unused5;
+ unsigned int __mxcsr;
+} fenv_t;
+
+#define FE_DFL_ENV ((const fenv_t *) -1)
diff --git a/system/include/libc/bits/float.h b/system/include/libc/bits/float.h
new file mode 100644
index 00000000..89e9eb6e
--- /dev/null
+++ b/system/include/libc/bits/float.h
@@ -0,0 +1,17 @@
+#define FLT_ROUNDS 1
+#define FLT_EVAL_METHOD 0
+
+#define LDBL_TRUE_MIN 4.9406564584124654e-324
+#define LDBL_MIN 2.2250738585072014e-308
+#define LDBL_MAX 1.7976931348623157e+308
+#define LDBL_EPSILON 2.2204460492503131e-16
+
+#define LDBL_MANT_DIG 53
+#define LDBL_MIN_EXP (-1021)
+#define LDBL_MAX_EXP 1024
+
+#define LDBL_DIG 15
+#define LDBL_MIN_10_EXP (-307)
+#define LDBL_MAX_10_EXP 308
+
+#define DECIMAL_DIG 17
diff --git a/system/include/libc/bits/io.h b/system/include/libc/bits/io.h
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/system/include/libc/bits/io.h
diff --git a/system/include/libc/bits/ioctl.h b/system/include/libc/bits/ioctl.h
new file mode 100644
index 00000000..9d75118e
--- /dev/null
+++ b/system/include/libc/bits/ioctl.h
@@ -0,0 +1,197 @@
+#define _IOC(a,b,c,d) ( ((a)<<30) | ((b)<<8) | (c) | ((d)<<16) )
+#define _IOC_NONE 0U
+#define _IOC_WRITE 1U
+#define _IOC_READ 2U
+
+#define _IO(a,b) _IOC(_IOC_NONE,(a),(b),0)
+#define _IOW(a,b,c) _IOC(_IOC_WRITE,(a),(b),sizeof(c))
+#define _IOR(a,b,c) _IOC(_IOC_READ,(a),(b),sizeof(c))
+#define _IOWR(a,b,c) _IOC(_IOC_READ|_IOC_WRITE,(a),(b),sizeof(c))
+
+#define TCGETS 0x5401
+#define TCSETS 0x5402
+#define TCSETSW 0x5403
+#define TCSETSF 0x5404
+#define TCGETA 0x5405
+#define TCSETA 0x5406
+#define TCSETAW 0x5407
+#define TCSETAF 0x5408
+#define TCSBRK 0x5409
+#define TCXONC 0x540A
+#define TCFLSH 0x540B
+#define TIOCEXCL 0x540C
+#define TIOCNXCL 0x540D
+#define TIOCSCTTY 0x540E
+#define TIOCGPGRP 0x540F
+#define TIOCSPGRP 0x5410
+#define TIOCOUTQ 0x5411
+#define TIOCSTI 0x5412
+#define TIOCGWINSZ 0x5413
+#define TIOCSWINSZ 0x5414
+#define TIOCMGET 0x5415
+#define TIOCMBIS 0x5416
+#define TIOCMBIC 0x5417
+#define TIOCMSET 0x5418
+#define TIOCGSOFTCAR 0x5419
+#define TIOCSSOFTCAR 0x541A
+#define FIONREAD 0x541B
+#define TIOCINQ FIONREAD
+#define TIOCLINUX 0x541C
+#define TIOCCONS 0x541D
+#define TIOCGSERIAL 0x541E
+#define TIOCSSERIAL 0x541F
+#define TIOCPKT 0x5420
+#define FIONBIO 0x5421
+#define TIOCNOTTY 0x5422
+#define TIOCSETD 0x5423
+#define TIOCGETD 0x5424
+#define TCSBRKP 0x5425
+#define TIOCTTYGSTRUCT 0x5426
+#define TIOCSBRK 0x5427
+#define TIOCCBRK 0x5428
+#define TIOCGSID 0x5429
+#define TIOCGPTN 0x80045430
+#define TIOCSPTLCK 0x40045431
+#define TCGETX 0x5432
+#define TCSETX 0x5433
+#define TCSETXF 0x5434
+#define TCSETXW 0x5435
+
+#define FIONCLEX 0x5450
+#define FIOCLEX 0x5451
+#define FIOASYNC 0x5452
+#define TIOCSERCONFIG 0x5453
+#define TIOCSERGWILD 0x5454
+#define TIOCSERSWILD 0x5455
+#define TIOCGLCKTRMIOS 0x5456
+#define TIOCSLCKTRMIOS 0x5457
+#define TIOCSERGSTRUCT 0x5458
+#define TIOCSERGETLSR 0x5459
+#define TIOCSERGETMULTI 0x545A
+#define TIOCSERSETMULTI 0x545B
+
+#define TIOCMIWAIT 0x545C
+#define TIOCGICOUNT 0x545D
+#define TIOCGHAYESESP 0x545E
+#define TIOCSHAYESESP 0x545F
+#define FIOQSIZE 0x5460
+
+#define TIOCPKT_DATA 0
+#define TIOCPKT_FLUSHREAD 1
+#define TIOCPKT_FLUSHWRITE 2
+#define TIOCPKT_STOP 4
+#define TIOCPKT_START 8
+#define TIOCPKT_NOSTOP 16
+#define TIOCPKT_DOSTOP 32
+#define TIOCPKT_IOCTL 64
+
+#define TIOCSER_TEMT 0x01
+
+struct winsize {
+ unsigned short ws_row;
+ unsigned short ws_col;
+ unsigned short ws_xpixel;
+ unsigned short ws_ypixel;
+};
+
+#define TIOCM_LE 0x001
+#define TIOCM_DTR 0x002
+#define TIOCM_RTS 0x004
+#define TIOCM_ST 0x008
+#define TIOCM_SR 0x010
+#define TIOCM_CTS 0x020
+#define TIOCM_CAR 0x040
+#define TIOCM_RNG 0x080
+#define TIOCM_DSR 0x100
+#define TIOCM_CD TIOCM_CAR
+#define TIOCM_RI TIOCM_RNG
+#define TIOCM_OUT1 0x2000
+#define TIOCM_OUT2 0x4000
+#define TIOCM_LOOP 0x8000
+#define TIOCM_MODEM_BITS TIOCM_OUT2
+
+#define N_TTY 0
+#define N_SLIP 1
+#define N_MOUSE 2
+#define N_PPP 3
+#define N_STRIP 4
+#define N_AX25 5
+#define N_X25 6
+#define N_6PACK 7
+#define N_MASC 8
+#define N_R3964 9
+#define N_PROFIBUS_FDL 10
+#define N_IRDA 11
+#define N_SMSBLOCK 12
+#define N_HDLC 13
+#define N_SYNC_PPP 14
+#define N_HCI 15
+
+#define FIOSETOWN 0x8901
+#define SIOCSPGRP 0x8902
+#define FIOGETOWN 0x8903
+#define SIOCGPGRP 0x8904
+#define SIOCATMARK 0x8905
+#define SIOCGSTAMP 0x8906
+
+#define SIOCADDRT 0x890B
+#define SIOCDELRT 0x890C
+#define SIOCRTMSG 0x890D
+
+#define SIOCGIFNAME 0x8910
+#define SIOCSIFLINK 0x8911
+#define SIOCGIFCONF 0x8912
+#define SIOCGIFFLAGS 0x8913
+#define SIOCSIFFLAGS 0x8914
+#define SIOCGIFADDR 0x8915
+#define SIOCSIFADDR 0x8916
+#define SIOCGIFDSTADDR 0x8917
+#define SIOCSIFDSTADDR 0x8918
+#define SIOCGIFBRDADDR 0x8919
+#define SIOCSIFBRDADDR 0x891a
+#define SIOCGIFNETMASK 0x891b
+#define SIOCSIFNETMASK 0x891c
+#define SIOCGIFMETRIC 0x891d
+#define SIOCSIFMETRIC 0x891e
+#define SIOCGIFMEM 0x891f
+#define SIOCSIFMEM 0x8920
+#define SIOCGIFMTU 0x8921
+#define SIOCSIFMTU 0x8922
+#define SIOCSIFHWADDR 0x8924
+#define SIOCGIFENCAP 0x8925
+#define SIOCSIFENCAP 0x8926
+#define SIOCGIFHWADDR 0x8927
+#define SIOCGIFSLAVE 0x8929
+#define SIOCSIFSLAVE 0x8930
+#define SIOCADDMULTI 0x8931
+#define SIOCDELMULTI 0x8932
+#define SIOCGIFINDEX 0x8933
+#define SIOGIFINDEX SIOCGIFINDEX
+#define SIOCSIFPFLAGS 0x8934
+#define SIOCGIFPFLAGS 0x8935
+#define SIOCDIFADDR 0x8936
+#define SIOCSIFHWBROADCAST 0x8937
+#define SIOCGIFCOUNT 0x8938
+
+#define SIOCGIFBR 0x8940
+#define SIOCSIFBR 0x8941
+
+#define SIOCGIFTXQLEN 0x8942
+#define SIOCSIFTXQLEN 0x8943
+
+#define SIOCDARP 0x8953
+#define SIOCGARP 0x8954
+#define SIOCSARP 0x8955
+
+#define SIOCDRARP 0x8960
+#define SIOCGRARP 0x8961
+#define SIOCSRARP 0x8962
+
+#define SIOCGIFMAP 0x8970
+#define SIOCSIFMAP 0x8971
+
+#define SIOCADDDLCI 0x8980
+#define SIOCDELDLCI 0x8981
+
+#define SIOCDEVPRIVATE 0x89F0
+#define SIOCPROTOPRIVATE 0x89E0
diff --git a/system/include/libc/bits/ipc.h b/system/include/libc/bits/ipc.h
new file mode 100644
index 00000000..b748d3b7
--- /dev/null
+++ b/system/include/libc/bits/ipc.h
@@ -0,0 +1,14 @@
+struct ipc_perm
+{
+ key_t __ipc_perm_key;
+ uid_t uid;
+ gid_t gid;
+ uid_t cuid;
+ gid_t cgid;
+ mode_t mode;
+ int __ipc_perm_seq;
+ long __pad1;
+ long __pad2;
+};
+
+#define IPC_64 0x100
diff --git a/system/include/libc/bits/limits.h b/system/include/libc/bits/limits.h
new file mode 100644
index 00000000..65a3dd64
--- /dev/null
+++ b/system/include/libc/bits/limits.h
@@ -0,0 +1,8 @@
+#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
+ || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+#define PAGE_SIZE 4096
+#define LONG_BIT 32
+#endif
+
+#define LONG_MAX 0x7fffffffL
+#define LLONG_MAX 0x7fffffffffffffffLL
diff --git a/system/include/libc/bits/mman.h b/system/include/libc/bits/mman.h
new file mode 100644
index 00000000..add63855
--- /dev/null
+++ b/system/include/libc/bits/mman.h
@@ -0,0 +1,62 @@
+#define MAP_FAILED ((void *) -1)
+
+#define PROT_NONE 0
+#define PROT_READ 1
+#define PROT_WRITE 2
+#define PROT_EXEC 4
+#define PROT_GROWSDOWN 0x01000000
+#define PROT_GROWSUP 0x02000000
+
+#define MAP_SHARED 0x01
+#define MAP_PRIVATE 0x02
+#define MAP_FIXED 0x10
+
+#define MAP_TYPE 0x0f
+#define MAP_FILE 0x00
+#define MAP_ANON 0x20
+#define MAP_ANONYMOUS MAP_ANON
+#define MAP_32BIT 0x40
+#define MAP_NORESERVE 0x4000
+#define MAP_GROWSDOWN 0x0100
+#define MAP_DENYWRITE 0x0800
+#define MAP_EXECUTABLE 0x1000
+#define MAP_LOCKED 0x2000
+#define MAP_POPULATE 0x8000
+#define MAP_NONBLOCK 0x10000
+#define MAP_STACK 0x20000
+#define MAP_HUGETLB 0x40000
+
+#define POSIX_MADV_NORMAL 0
+#define POSIX_MADV_RANDOM 1
+#define POSIX_MADV_SEQUENTIAL 2
+#define POSIX_MADV_WILLNEED 3
+#define POSIX_MADV_DONTNEED 0
+
+#define MS_ASYNC 1
+#define MS_INVALIDATE 2
+#define MS_SYNC 4
+
+#define MCL_CURRENT 1
+#define MCL_FUTURE 2
+
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+#define MADV_NORMAL 0
+#define MADV_RANDOM 1
+#define MADV_SEQUENTIAL 2
+#define MADV_WILLNEED 3
+#define MADV_DONTNEED 4
+#define MADV_REMOVE 9
+#define MADV_DONTFORK 10
+#define MADV_DOFORK 11
+#define MADV_MERGEABLE 12
+#define MADV_UNMERGEABLE 13
+#define MADV_HUGEPAGE 14
+#define MADV_NOHUGEPAGE 15
+#define MADV_DONTDUMP 16
+#define MADV_DODUMP 17
+#define MADV_HWPOISON 100
+#define MADV_SOFT_OFFLINE 101
+
+#define MREMAP_MAYMOVE 1
+#define MREMAP_FIXED 2
+#endif
diff --git a/system/include/libc/bits/msg.h b/system/include/libc/bits/msg.h
new file mode 100644
index 00000000..3db8576b
--- /dev/null
+++ b/system/include/libc/bits/msg.h
@@ -0,0 +1,16 @@
+struct msqid_ds
+{
+ struct ipc_perm msg_perm;
+ time_t msg_stime;
+ int __unused1;
+ time_t msg_rtime;
+ int __unused2;
+ time_t msg_ctime;
+ int __unused3;
+ unsigned long msg_cbytes;
+ msgqnum_t msg_qnum;
+ msglen_t msg_qbytes;
+ pid_t msg_lspid;
+ pid_t msg_lrpid;
+ unsigned long __unused[2];
+};
diff --git a/system/include/libc/bits/posix.h b/system/include/libc/bits/posix.h
new file mode 100644
index 00000000..30a38714
--- /dev/null
+++ b/system/include/libc/bits/posix.h
@@ -0,0 +1,2 @@
+#define _POSIX_V6_ILP32_OFFBIG 1
+#define _POSIX_V7_ILP32_OFFBIG 1
diff --git a/system/include/libc/bits/reg.h b/system/include/libc/bits/reg.h
new file mode 100644
index 00000000..8bc2582d
--- /dev/null
+++ b/system/include/libc/bits/reg.h
@@ -0,0 +1,19 @@
+#undef __WORDSIZE
+#define __WORDSIZE 32
+#define EBX 0
+#define ECX 1
+#define EDX 2
+#define ESI 3
+#define EDI 4
+#define EBP 5
+#define EAX 6
+#define DS 7
+#define ES 8
+#define FS 9
+#define GS 10
+#define ORIG_EAX 11
+#define EIP 12
+#define CS 13
+#define EFL 14
+#define UESP 15
+#define SS 16
diff --git a/system/include/libc/bits/setjmp.h b/system/include/libc/bits/setjmp.h
new file mode 100644
index 00000000..decd26dc
--- /dev/null
+++ b/system/include/libc/bits/setjmp.h
@@ -0,0 +1 @@
+typedef unsigned long __jmp_buf[6];
diff --git a/system/include/libc/bits/shm.h b/system/include/libc/bits/shm.h
new file mode 100644
index 00000000..8807c4fb
--- /dev/null
+++ b/system/include/libc/bits/shm.h
@@ -0,0 +1,18 @@
+#define SHMLBA 4096
+
+struct shmid_ds
+{
+ struct ipc_perm shm_perm;
+ size_t shm_segsz;
+ time_t shm_atime;
+ int __unused1;
+ time_t shm_dtime;
+ int __unused2;
+ time_t shm_ctime;
+ int __unused3;
+ pid_t shm_cpid;
+ pid_t shm_lpid;
+ unsigned long shm_nattch;
+ unsigned long __pad1;
+ unsigned long __pad2;
+};
diff --git a/system/include/libc/bits/signal.h b/system/include/libc/bits/signal.h
new file mode 100644
index 00000000..75844e5b
--- /dev/null
+++ b/system/include/libc/bits/signal.h
@@ -0,0 +1,112 @@
+#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
+ || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+
+#ifdef _GNU_SOURCE
+#define REG_GS 0
+#define REG_FS 1
+#define REG_ES 2
+#define REG_DS 3
+#define REG_EDI 4
+#define REG_ESI 5
+#define REG_EBP 6
+#define REG_ESP 7
+#define REG_EBX 8
+#define REG_EDX 9
+#define REG_ECX 10
+#define REG_EAX 11
+#define REG_TRAPNO 12
+#define REG_ERR 13
+#define REG_EIP 14
+#define REG_CS 15
+#define REG_EFL 16
+#define REG_UESP 17
+#define REG_SS 18
+#endif
+
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+typedef int greg_t, gregset_t[19];
+typedef struct _fpstate {
+ unsigned long cw, sw, tag, ipoff, cssel, dataoff, datasel;
+ struct {
+ unsigned short significand[4], exponent;
+ } _st[8];
+ unsigned long status;
+} *fpregset_t;
+struct sigcontext {
+ unsigned short gs, __gsh, fs, __fsh, es, __esh, ds, __dsh;
+ unsigned long edi, esi, ebp, esp, ebx, edx, ecx, eax;
+ unsigned long trapno, err, eip;
+ unsigned short cs, __csh;
+ unsigned long eflags, esp_at_signal;
+ unsigned short ss, __ssh;
+ struct _fpstate *fpstate;
+ unsigned long oldmask, cr2;
+};
+typedef struct {
+ gregset_t gregs;
+ fpregset_t fpregs;
+ unsigned long oldmask, cr2;
+} mcontext_t;
+#else
+typedef struct {
+ unsigned __space[22];
+} mcontext_t;
+#endif
+
+typedef struct __ucontext {
+ unsigned long uc_flags;
+ struct __ucontext *uc_link;
+ stack_t uc_stack;
+ mcontext_t uc_mcontext;
+ sigset_t uc_sigmask;
+ unsigned long __fpregs_mem[28];
+} ucontext_t;
+
+#define SA_NOCLDSTOP 1
+#define SA_NOCLDWAIT 2
+#define SA_SIGINFO 4
+#define SA_ONSTACK 0x08000000
+#define SA_RESTART 0x10000000
+#define SA_NODEFER 0x40000000
+#define SA_RESETHAND 0x80000000
+#define SA_RESTORER 0x04000000
+
+#endif
+
+#define SIGHUP 1
+#define SIGINT 2
+#define SIGQUIT 3
+#define SIGILL 4
+#define SIGTRAP 5
+#define SIGABRT 6
+#define SIGIOT SIGABRT
+#define SIGBUS 7
+#define SIGFPE 8
+#define SIGKILL 9
+#define SIGUSR1 10
+#define SIGSEGV 11
+#define SIGUSR2 12
+#define SIGPIPE 13
+#define SIGALRM 14
+#define SIGTERM 15
+#define SIGSTKFLT 16
+#define SIGCHLD 17
+#define SIGCONT 18
+#define SIGSTOP 19
+#define SIGTSTP 20
+#define SIGTTIN 21
+#define SIGTTOU 22
+#define SIGURG 23
+#define SIGXCPU 24
+#define SIGXFSZ 25
+#define SIGVTALRM 26
+#define SIGPROF 27
+#define SIGWINCH 28
+#define SIGIO 29
+#define SIGPOLL 29
+#define SIGPWR 30
+#define SIGSYS 31
+#define SIGUNUSED SIGSYS
+
+#define _NSIG 65
+
diff --git a/system/include/libc/bits/socket.h b/system/include/libc/bits/socket.h
new file mode 100644
index 00000000..36febbc2
--- /dev/null
+++ b/system/include/libc/bits/socket.h
@@ -0,0 +1,17 @@
+struct msghdr
+{
+ void *msg_name;
+ socklen_t msg_namelen;
+ struct iovec *msg_iov;
+ int msg_iovlen;
+ void *msg_control;
+ socklen_t msg_controllen;
+ int msg_flags;
+};
+
+struct cmsghdr
+{
+ socklen_t cmsg_len;
+ int cmsg_level;
+ int cmsg_type;
+};
diff --git a/system/include/libc/bits/stat.h b/system/include/libc/bits/stat.h
new file mode 100644
index 00000000..bb9314a5
--- /dev/null
+++ b/system/include/libc/bits/stat.h
@@ -0,0 +1,22 @@
+/* copied from kernel definition, but with padding replaced
+ * by the corresponding correctly-sized userspace types. */
+
+struct stat
+{
+ dev_t st_dev;
+ int __st_dev_padding;
+ long __st_ino_truncated;
+ mode_t st_mode;
+ nlink_t st_nlink;
+ uid_t st_uid;
+ gid_t st_gid;
+ dev_t st_rdev;
+ int __st_rdev_padding;
+ off_t st_size;
+ blksize_t st_blksize;
+ blkcnt_t st_blocks;
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
+ ino_t st_ino;
+};
diff --git a/system/include/libc/bits/statfs.h b/system/include/libc/bits/statfs.h
new file mode 100644
index 00000000..f103f4e4
--- /dev/null
+++ b/system/include/libc/bits/statfs.h
@@ -0,0 +1,7 @@
+struct statfs {
+ unsigned long f_type, f_bsize;
+ fsblkcnt_t f_blocks, f_bfree, f_bavail;
+ fsfilcnt_t f_files, f_ffree;
+ fsid_t f_fsid;
+ unsigned long f_namelen, f_frsize, f_flags, f_spare[4];
+};
diff --git a/system/include/libc/bits/stdarg.h b/system/include/libc/bits/stdarg.h
new file mode 100644
index 00000000..fde37814
--- /dev/null
+++ b/system/include/libc/bits/stdarg.h
@@ -0,0 +1,4 @@
+#define va_start(v,l) __builtin_va_start(v,l)
+#define va_end(v) __builtin_va_end(v)
+#define va_arg(v,l) __builtin_va_arg(v,l)
+#define va_copy(d,s) __builtin_va_copy(d,s)
diff --git a/system/include/libc/bits/stdint.h b/system/include/libc/bits/stdint.h
new file mode 100644
index 00000000..d1b27121
--- /dev/null
+++ b/system/include/libc/bits/stdint.h
@@ -0,0 +1,20 @@
+typedef int32_t int_fast16_t;
+typedef int32_t int_fast32_t;
+typedef uint32_t uint_fast16_t;
+typedef uint32_t uint_fast32_t;
+
+#define INT_FAST16_MIN INT32_MIN
+#define INT_FAST32_MIN INT32_MIN
+
+#define INT_FAST16_MAX INT32_MAX
+#define INT_FAST32_MAX INT32_MAX
+
+#define UINT_FAST16_MAX UINT32_MAX
+#define UINT_FAST32_MAX UINT32_MAX
+
+#define INTPTR_MIN INT32_MIN
+#define INTPTR_MAX INT32_MAX
+#define UINTPTR_MAX UINT32_MAX
+#define PTRDIFF_MIN INT32_MIN
+#define PTRDIFF_MAX INT32_MAX
+#define SIZE_MAX UINT32_MAX
diff --git a/system/include/libc/bits/syscall.h b/system/include/libc/bits/syscall.h
new file mode 100644
index 00000000..800409a7
--- /dev/null
+++ b/system/include/libc/bits/syscall.h
@@ -0,0 +1,696 @@
+#define __NR_restart_syscall 0
+#define __NR_exit 1
+#define __NR_fork 2
+#define __NR_read 3
+#define __NR_write 4
+#define __NR_open 5
+#define __NR_close 6
+#define __NR_waitpid 7
+#define __NR_creat 8
+#define __NR_link 9
+#define __NR_unlink 10
+#define __NR_execve 11
+#define __NR_chdir 12
+#define __NR_time 13
+#define __NR_mknod 14
+#define __NR_chmod 15
+#define __NR_lchown 16
+#define __NR_break 17
+#define __NR_oldstat 18
+#define __NR_lseek 19
+#define __NR_getpid 20
+#define __NR_mount 21
+#define __NR_umount 22
+#define __NR_setuid 23
+#define __NR_getuid 24
+#define __NR_stime 25
+#define __NR_ptrace 26
+#define __NR_alarm 27
+#define __NR_oldfstat 28
+#define __NR_pause 29
+#define __NR_utime 30
+#define __NR_stty 31
+#define __NR_gtty 32
+#define __NR_access 33
+#define __NR_nice 34
+#define __NR_ftime 35
+#define __NR_sync 36
+#define __NR_kill 37
+#define __NR_rename 38
+#define __NR_mkdir 39
+#define __NR_rmdir 40
+#define __NR_dup 41
+#define __NR_pipe 42
+#define __NR_times 43
+#define __NR_prof 44
+#define __NR_brk 45
+#define __NR_setgid 46
+#define __NR_getgid 47
+#define __NR_signal 48
+#define __NR_geteuid 49
+#define __NR_getegid 50
+#define __NR_acct 51
+#define __NR_umount2 52
+#define __NR_lock 53
+#define __NR_ioctl 54
+#define __NR_fcntl 55
+#define __NR_mpx 56
+#define __NR_setpgid 57
+#define __NR_ulimit 58
+#define __NR_oldolduname 59
+#define __NR_umask 60
+#define __NR_chroot 61
+#define __NR_ustat 62
+#define __NR_dup2 63
+#define __NR_getppid 64
+#define __NR_getpgrp 65
+#define __NR_setsid 66
+#define __NR_sigaction 67
+#define __NR_sgetmask 68
+#define __NR_ssetmask 69
+#define __NR_setreuid 70
+#define __NR_setregid 71
+#define __NR_sigsuspend 72
+#define __NR_sigpending 73
+#define __NR_sethostname 74
+#define __NR_setrlimit 75
+#define __NR_getrlimit 76 /* Back compatible 2Gig limited rlimit */
+#define __NR_getrusage 77
+#define __NR_gettimeofday 78
+#define __NR_settimeofday 79
+#define __NR_getgroups 80
+#define __NR_setgroups 81
+#define __NR_select 82
+#define __NR_symlink 83
+#define __NR_oldlstat 84
+#define __NR_readlink 85
+#define __NR_uselib 86
+#define __NR_swapon 87
+#define __NR_reboot 88
+#define __NR_readdir 89
+#define __NR_mmap 90
+#define __NR_munmap 91
+#define __NR_truncate 92
+#define __NR_ftruncate 93
+#define __NR_fchmod 94
+#define __NR_fchown 95
+#define __NR_getpriority 96
+#define __NR_setpriority 97
+#define __NR_profil 98
+#define __NR_statfs 99
+#define __NR_fstatfs 100
+#define __NR_ioperm 101
+#define __NR_socketcall 102
+#define __NR_syslog 103
+#define __NR_setitimer 104
+#define __NR_getitimer 105
+#define __NR_stat 106
+#define __NR_lstat 107
+#define __NR_fstat 108
+#define __NR_olduname 109
+#define __NR_iopl 110
+#define __NR_vhangup 111
+#define __NR_idle 112
+#define __NR_vm86old 113
+#define __NR_wait4 114
+#define __NR_swapoff 115
+#define __NR_sysinfo 116
+#define __NR_ipc 117
+#define __NR_fsync 118
+#define __NR_sigreturn 119
+#define __NR_clone 120
+#define __NR_setdomainname 121
+#define __NR_uname 122
+#define __NR_modify_ldt 123
+#define __NR_adjtimex 124
+#define __NR_mprotect 125
+#define __NR_sigprocmask 126
+#define __NR_create_module 127
+#define __NR_init_module 128
+#define __NR_delete_module 129
+#define __NR_get_kernel_syms 130
+#define __NR_quotactl 131
+#define __NR_getpgid 132
+#define __NR_fchdir 133
+#define __NR_bdflush 134
+#define __NR_sysfs 135
+#define __NR_personality 136
+#define __NR_afs_syscall 137
+#define __NR_setfsuid 138
+#define __NR_setfsgid 139
+#define __NR__llseek 140
+#define __NR_getdents 141
+#define __NR__newselect 142
+#define __NR_flock 143
+#define __NR_msync 144
+#define __NR_readv 145
+#define __NR_writev 146
+#define __NR_getsid 147
+#define __NR_fdatasync 148
+#define __NR__sysctl 149
+#define __NR_mlock 150
+#define __NR_munlock 151
+#define __NR_mlockall 152
+#define __NR_munlockall 153
+#define __NR_sched_setparam 154
+#define __NR_sched_getparam 155
+#define __NR_sched_setscheduler 156
+#define __NR_sched_getscheduler 157
+#define __NR_sched_yield 158
+#define __NR_sched_get_priority_max 159
+#define __NR_sched_get_priority_min 160
+#define __NR_sched_rr_get_interval 161
+#define __NR_nanosleep 162
+#define __NR_mremap 163
+#define __NR_setresuid 164
+#define __NR_getresuid 165
+#define __NR_vm86 166
+#define __NR_query_module 167
+#define __NR_poll 168
+#define __NR_nfsservctl 169
+#define __NR_setresgid 170
+#define __NR_getresgid 171
+#define __NR_prctl 172
+#define __NR_rt_sigreturn 173
+#define __NR_rt_sigaction 174
+#define __NR_rt_sigprocmask 175
+#define __NR_rt_sigpending 176
+#define __NR_rt_sigtimedwait 177
+#define __NR_rt_sigqueueinfo 178
+#define __NR_rt_sigsuspend 179
+#define __NR_pread64 180
+#define __NR_pwrite64 181
+#define __NR_chown 182
+#define __NR_getcwd 183
+#define __NR_capget 184
+#define __NR_capset 185
+#define __NR_sigaltstack 186
+#define __NR_sendfile 187
+#define __NR_getpmsg 188
+#define __NR_putpmsg 189
+#define __NR_vfork 190
+#define __NR_ugetrlimit 191
+#define __NR_mmap2 192
+#define __NR_truncate64 193
+#define __NR_ftruncate64 194
+#define __NR_stat64 195
+#define __NR_lstat64 196
+#define __NR_fstat64 197
+#define __NR_lchown32 198
+#define __NR_getuid32 199
+#define __NR_getgid32 200
+#define __NR_geteuid32 201
+#define __NR_getegid32 202
+#define __NR_setreuid32 203
+#define __NR_setregid32 204
+#define __NR_getgroups32 205
+#define __NR_setgroups32 206
+#define __NR_fchown32 207
+#define __NR_setresuid32 208
+#define __NR_getresuid32 209
+#define __NR_setresgid32 210
+#define __NR_getresgid32 211
+#define __NR_chown32 212
+#define __NR_setuid32 213
+#define __NR_setgid32 214
+#define __NR_setfsuid32 215
+#define __NR_setfsgid32 216
+#define __NR_pivot_root 217
+#define __NR_mincore 218
+#define __NR_madvise 219
+#define __NR_madvise1 219
+#define __NR_getdents64 220
+#define __NR_fcntl64 221
+/* 223 is unused */
+#define __NR_gettid 224
+#define __NR_readahead 225
+#define __NR_setxattr 226
+#define __NR_lsetxattr 227
+#define __NR_fsetxattr 228
+#define __NR_getxattr 229
+#define __NR_lgetxattr 230
+#define __NR_fgetxattr 231
+#define __NR_listxattr 232
+#define __NR_llistxattr 233
+#define __NR_flistxattr 234
+#define __NR_removexattr 235
+#define __NR_lremovexattr 236
+#define __NR_fremovexattr 237
+#define __NR_tkill 238
+#define __NR_sendfile64 239
+#define __NR_futex 240
+#define __NR_sched_setaffinity 241
+#define __NR_sched_getaffinity 242
+#define __NR_set_thread_area 243
+#define __NR_get_thread_area 244
+#define __NR_io_setup 245
+#define __NR_io_destroy 246
+#define __NR_io_getevents 247
+#define __NR_io_submit 248
+#define __NR_io_cancel 249
+#define __NR_fadvise64 250
+/* 251 is available for reuse (was briefly sys_set_zone_reclaim) */
+#define __NR_exit_group 252
+#define __NR_lookup_dcookie 253
+#define __NR_epoll_create 254
+#define __NR_epoll_ctl 255
+#define __NR_epoll_wait 256
+#define __NR_remap_file_pages 257
+#define __NR_set_tid_address 258
+#define __NR_timer_create 259
+#define __NR_timer_settime (__NR_timer_create+1)
+#define __NR_timer_gettime (__NR_timer_create+2)
+#define __NR_timer_getoverrun (__NR_timer_create+3)
+#define __NR_timer_delete (__NR_timer_create+4)
+#define __NR_clock_settime (__NR_timer_create+5)
+#define __NR_clock_gettime (__NR_timer_create+6)
+#define __NR_clock_getres (__NR_timer_create+7)
+#define __NR_clock_nanosleep (__NR_timer_create+8)
+#define __NR_statfs64 268
+#define __NR_fstatfs64 269
+#define __NR_tgkill 270
+#define __NR_utimes 271
+#define __NR_fadvise64_64 272
+#define __NR_vserver 273
+#define __NR_mbind 274
+#define __NR_get_mempolicy 275
+#define __NR_set_mempolicy 276
+#define __NR_mq_open 277
+#define __NR_mq_unlink (__NR_mq_open+1)
+#define __NR_mq_timedsend (__NR_mq_open+2)
+#define __NR_mq_timedreceive (__NR_mq_open+3)
+#define __NR_mq_notify (__NR_mq_open+4)
+#define __NR_mq_getsetattr (__NR_mq_open+5)
+#define __NR_kexec_load 283
+#define __NR_waitid 284
+/* #define __NR_sys_setaltroot 285 */
+#define __NR_add_key 286
+#define __NR_request_key 287
+#define __NR_keyctl 288
+#define __NR_ioprio_set 289
+#define __NR_ioprio_get 290
+#define __NR_inotify_init 291
+#define __NR_inotify_add_watch 292
+#define __NR_inotify_rm_watch 293
+#define __NR_migrate_pages 294
+#define __NR_openat 295
+#define __NR_mkdirat 296
+#define __NR_mknodat 297
+#define __NR_fchownat 298
+#define __NR_futimesat 299
+#define __NR_fstatat64 300
+#define __NR_unlinkat 301
+#define __NR_renameat 302
+#define __NR_linkat 303
+#define __NR_symlinkat 304
+#define __NR_readlinkat 305
+#define __NR_fchmodat 306
+#define __NR_faccessat 307
+#define __NR_pselect6 308
+#define __NR_ppoll 309
+#define __NR_unshare 310
+#define __NR_set_robust_list 311
+#define __NR_get_robust_list 312
+#define __NR_splice 313
+#define __NR_sync_file_range 314
+#define __NR_tee 315
+#define __NR_vmsplice 316
+#define __NR_move_pages 317
+#define __NR_getcpu 318
+#define __NR_epoll_pwait 319
+#define __NR_utimensat 320
+#define __NR_signalfd 321
+#define __NR_timerfd_create 322
+#define __NR_eventfd 323
+#define __NR_fallocate 324
+#define __NR_timerfd_settime 325
+#define __NR_timerfd_gettime 326
+#define __NR_signalfd4 327
+#define __NR_eventfd2 328
+#define __NR_epoll_create1 329
+#define __NR_dup3 330
+#define __NR_pipe2 331
+#define __NR_inotify_init1 332
+#define __NR_preadv 333
+#define __NR_pwritev 334
+#define __NR_prlimit64 340
+#define __NR_name_to_handle_at 341
+#define __NR_open_by_handle_at 342
+#define __NR_clock_adjtime 343
+#define __NR_syncfs 344
+#define __NR_sendmmsg 345
+#define __NR_setns 346
+#define __NR_process_vm_readv 347
+#define __NR_process_vm_writev 348
+#define __NR_kcmp 349
+#define __NR_finit_module 350
+
+
+/* Repeated with SYS_ prefix */
+
+#define SYS_restart_syscall 0
+#define SYS_exit 1
+#define SYS_fork 2
+#define SYS_read 3
+#define SYS_write 4
+#define SYS_open 5
+#define SYS_close 6
+#define SYS_waitpid 7
+#define SYS_creat 8
+#define SYS_link 9
+#define SYS_unlink 10
+#define SYS_execve 11
+#define SYS_chdir 12
+#define SYS_time 13
+#define SYS_mknod 14
+#define SYS_chmod 15
+#define SYS_lchown 16
+#define SYS_break 17
+#define SYS_oldstat 18
+#define SYS_lseek 19
+#define SYS_getpid 20
+#define SYS_mount 21
+#define SYS_umount 22
+#define SYS_setuid 23
+#define SYS_getuid 24
+#define SYS_stime 25
+#define SYS_ptrace 26
+#define SYS_alarm 27
+#define SYS_oldfstat 28
+#define SYS_pause 29
+#define SYS_utime 30
+#define SYS_stty 31
+#define SYS_gtty 32
+#define SYS_access 33
+#define SYS_nice 34
+#define SYS_ftime 35
+#define SYS_sync 36
+#define SYS_kill 37
+#define SYS_rename 38
+#define SYS_mkdir 39
+#define SYS_rmdir 40
+#define SYS_dup 41
+#define SYS_pipe 42
+#define SYS_times 43
+#define SYS_prof 44
+#define SYS_brk 45
+#define SYS_setgid 46
+#define SYS_getgid 47
+#define SYS_signal 48
+#define SYS_geteuid 49
+#define SYS_getegid 50
+#define SYS_acct 51
+#define SYS_umount2 52
+#define SYS_lock 53
+#define SYS_ioctl 54
+#define SYS_fcntl 55
+#define SYS_mpx 56
+#define SYS_setpgid 57
+#define SYS_ulimit 58
+#define SYS_oldolduname 59
+#define SYS_umask 60
+#define SYS_chroot 61
+#define SYS_ustat 62
+#define SYS_dup2 63
+#define SYS_getppid 64
+#define SYS_getpgrp 65
+#define SYS_setsid 66
+#define SYS_sigaction 67
+#define SYS_sgetmask 68
+#define SYS_ssetmask 69
+#define SYS_setreuid 70
+#define SYS_setregid 71
+#define SYS_sigsuspend 72
+#define SYS_sigpending 73
+#define SYS_sethostname 74
+#define SYS_setrlimit 75
+#define SYS_getrlimit 76 /* Back compatible 2Gig limited rlimit */
+#define SYS_getrusage 77
+#define SYS_gettimeofday 78
+#define SYS_settimeofday 79
+#define SYS_getgroups 80
+#define SYS_setgroups 81
+#define SYS_select 82
+#define SYS_symlink 83
+#define SYS_oldlstat 84
+#define SYS_readlink 85
+#define SYS_uselib 86
+#define SYS_swapon 87
+#define SYS_reboot 88
+#define SYS_readdir 89
+#define SYS_mmap 90
+#define SYS_munmap 91
+#define SYS_truncate 92
+#define SYS_ftruncate 93
+#define SYS_fchmod 94
+#define SYS_fchown 95
+#define SYS_getpriority 96
+#define SYS_setpriority 97
+#define SYS_profil 98
+#define SYS_statfs 99
+#define SYS_fstatfs 100
+#define SYS_ioperm 101
+#define SYS_socketcall 102
+#define SYS_syslog 103
+#define SYS_setitimer 104
+#define SYS_getitimer 105
+#define SYS_stat 106
+#define SYS_lstat 107
+#define SYS_fstat 108
+#define SYS_olduname 109
+#define SYS_iopl 110
+#define SYS_vhangup 111
+#define SYS_idle 112
+#define SYS_vm86old 113
+#define SYS_wait4 114
+#define SYS_swapoff 115
+#define SYS_sysinfo 116
+#define SYS_ipc 117
+#define SYS_fsync 118
+#define SYS_sigreturn 119
+#define SYS_clone 120
+#define SYS_setdomainname 121
+#define SYS_uname 122
+#define SYS_modify_ldt 123
+#define SYS_adjtimex 124
+#define SYS_mprotect 125
+#define SYS_sigprocmask 126
+#define SYS_create_module 127
+#define SYS_init_module 128
+#define SYS_delete_module 129
+#define SYS_get_kernel_syms 130
+#define SYS_quotactl 131
+#define SYS_getpgid 132
+#define SYS_fchdir 133
+#define SYS_bdflush 134
+#define SYS_sysfs 135
+#define SYS_personality 136
+#define SYS_afs_syscall 137
+#define SYS_setfsuid 138
+#define SYS_setfsgid 139
+#define SYS__llseek 140
+#define SYS_getdents 141
+#define SYS__newselect 142
+#define SYS_flock 143
+#define SYS_msync 144
+#define SYS_readv 145
+#define SYS_writev 146
+#define SYS_getsid 147
+#define SYS_fdatasync 148
+#define SYS__sysctl 149
+#define SYS_mlock 150
+#define SYS_munlock 151
+#define SYS_mlockall 152
+#define SYS_munlockall 153
+#define SYS_sched_setparam 154
+#define SYS_sched_getparam 155
+#define SYS_sched_setscheduler 156
+#define SYS_sched_getscheduler 157
+#define SYS_sched_yield 158
+#define SYS_sched_get_priority_max 159
+#define SYS_sched_get_priority_min 160
+#define SYS_sched_rr_get_interval 161
+#define SYS_nanosleep 162
+#define SYS_mremap 163
+#define SYS_setresuid 164
+#define SYS_getresuid 165
+#define SYS_vm86 166
+#define SYS_query_module 167
+#define SYS_poll 168
+#define SYS_nfsservctl 169
+#define SYS_setresgid 170
+#define SYS_getresgid 171
+#define SYS_prctl 172
+#define SYS_rt_sigreturn 173
+#define SYS_rt_sigaction 174
+#define SYS_rt_sigprocmask 175
+#define SYS_rt_sigpending 176
+#define SYS_rt_sigtimedwait 177
+#define SYS_rt_sigqueueinfo 178
+#define SYS_rt_sigsuspend 179
+#define SYS_pread64 180
+#define SYS_pwrite64 181
+#define SYS_chown 182
+#define SYS_getcwd 183
+#define SYS_capget 184
+#define SYS_capset 185
+#define SYS_sigaltstack 186
+#define SYS_sendfile 187
+#define SYS_getpmsg 188
+#define SYS_putpmsg 189
+#define SYS_vfork 190
+#define SYS_ugetrlimit 191
+#define SYS_mmap2 192
+#define SYS_truncate64 193
+#define SYS_ftruncate64 194
+#define SYS_stat64 195
+#define SYS_lstat64 196
+#define SYS_fstat64 197
+#define SYS_lchown32 198
+#define SYS_getuid32 199
+#define SYS_getgid32 200
+#define SYS_geteuid32 201
+#define SYS_getegid32 202
+#define SYS_setreuid32 203
+#define SYS_setregid32 204
+#define SYS_getgroups32 205
+#define SYS_setgroups32 206
+#define SYS_fchown32 207
+#define SYS_setresuid32 208
+#define SYS_getresuid32 209
+#define SYS_setresgid32 210
+#define SYS_getresgid32 211
+#define SYS_chown32 212
+#define SYS_setuid32 213
+#define SYS_setgid32 214
+#define SYS_setfsuid32 215
+#define SYS_setfsgid32 216
+#define SYS_pivot_root 217
+#define SYS_mincore 218
+#define SYS_madvise 219
+#define SYS_madvise1 219
+#define SYS_getdents64 220
+#define SYS_fcntl64 221
+/* 223 is unused */
+#define SYS_gettid 224
+#define SYS_readahead 225
+#define SYS_setxattr 226
+#define SYS_lsetxattr 227
+#define SYS_fsetxattr 228
+#define SYS_getxattr 229
+#define SYS_lgetxattr 230
+#define SYS_fgetxattr 231
+#define SYS_listxattr 232
+#define SYS_llistxattr 233
+#define SYS_flistxattr 234
+#define SYS_removexattr 235
+#define SYS_lremovexattr 236
+#define SYS_fremovexattr 237
+#define SYS_tkill 238
+#define SYS_sendfile64 239
+#define SYS_futex 240
+#define SYS_sched_setaffinity 241
+#define SYS_sched_getaffinity 242
+#define SYS_set_thread_area 243
+#define SYS_get_thread_area 244
+#define SYS_io_setup 245
+#define SYS_io_destroy 246
+#define SYS_io_getevents 247
+#define SYS_io_submit 248
+#define SYS_io_cancel 249
+#define SYS_fadvise64 250
+/* 251 is available for reuse (was briefly sys_set_zone_reclaim) */
+#define SYS_exit_group 252
+#define SYS_lookup_dcookie 253
+#define SYS_epoll_create 254
+#define SYS_epoll_ctl 255
+#define SYS_epoll_wait 256
+#define SYS_remap_file_pages 257
+#define SYS_set_tid_address 258
+#define SYS_timer_create 259
+#define SYS_timer_settime (SYS_timer_create+1)
+#define SYS_timer_gettime (SYS_timer_create+2)
+#define SYS_timer_getoverrun (SYS_timer_create+3)
+#define SYS_timer_delete (SYS_timer_create+4)
+#define SYS_clock_settime (SYS_timer_create+5)
+#define SYS_clock_gettime (SYS_timer_create+6)
+#define SYS_clock_getres (SYS_timer_create+7)
+#define SYS_clock_nanosleep (SYS_timer_create+8)
+#define SYS_statfs64 268
+#define SYS_fstatfs64 269
+#define SYS_tgkill 270
+#define SYS_utimes 271
+#define SYS_fadvise64_64 272
+#define SYS_vserver 273
+#define SYS_mbind 274
+#define SYS_get_mempolicy 275
+#define SYS_set_mempolicy 276
+#define SYS_mq_open 277
+#define SYS_mq_unlink (SYS_mq_open+1)
+#define SYS_mq_timedsend (SYS_mq_open+2)
+#define SYS_mq_timedreceive (SYS_mq_open+3)
+#define SYS_mq_notify (SYS_mq_open+4)
+#define SYS_mq_getsetattr (SYS_mq_open+5)
+#define SYS_kexec_load 283
+#define SYS_waitid 284
+/* #define SYS_sys_setaltroot 285 */
+#define SYS_add_key 286
+#define SYS_request_key 287
+#define SYS_keyctl 288
+#define SYS_ioprio_set 289
+#define SYS_ioprio_get 290
+#define SYS_inotify_init 291
+#define SYS_inotify_add_watch 292
+#define SYS_inotify_rm_watch 293
+#define SYS_migrate_pages 294
+#define SYS_openat 295
+#define SYS_mkdirat 296
+#define SYS_mknodat 297
+#define SYS_fchownat 298
+#define SYS_futimesat 299
+#define SYS_fstatat64 300
+#define SYS_unlinkat 301
+#define SYS_renameat 302
+#define SYS_linkat 303
+#define SYS_symlinkat 304
+#define SYS_readlinkat 305
+#define SYS_fchmodat 306
+#define SYS_faccessat 307
+#define SYS_pselect6 308
+#define SYS_ppoll 309
+#define SYS_unshare 310
+#define SYS_set_robust_list 311
+#define SYS_get_robust_list 312
+#define SYS_splice 313
+#define SYS_sync_file_range 314
+#define SYS_tee 315
+#define SYS_vmsplice 316
+#define SYS_move_pages 317
+#define SYS_getcpu 318
+#define SYS_epoll_pwait 319
+#define SYS_utimensat 320
+#define SYS_signalfd 321
+#define SYS_timerfd_create 322
+#define SYS_eventfd 323
+#define SYS_fallocate 324
+#define SYS_timerfd_settime 325
+#define SYS_timerfd_gettime 326
+#define SYS_signalfd4 327
+#define SYS_eventfd2 328
+#define SYS_epoll_create1 329
+#define SYS_dup3 330
+#define SYS_pipe2 331
+#define SYS_inotify_init1 332
+#define SYS_preadv 333
+#define SYS_pwritev 334
+#define SYS_prlimit64 340
+#define SYS_name_to_handle_at 341
+#define SYS_open_by_handle_at 342
+#define SYS_clock_adjtime 343
+#define SYS_syncfs 344
+#define SYS_sendmmsg 345
+#define SYS_setns 346
+#define SYS_process_vm_readv 347
+#define SYS_process_vm_writev 348
+#define SYS_kcmp 349
+#define SYS_finit_module 350
diff --git a/system/include/libc/bits/termios.h b/system/include/libc/bits/termios.h
new file mode 100644
index 00000000..61c888f4
--- /dev/null
+++ b/system/include/libc/bits/termios.h
@@ -0,0 +1,160 @@
+struct termios
+{
+ tcflag_t c_iflag;
+ tcflag_t c_oflag;
+ tcflag_t c_cflag;
+ tcflag_t c_lflag;
+ cc_t c_line;
+ cc_t c_cc[NCCS];
+ speed_t __c_ispeed;
+ speed_t __c_ospeed;
+};
+
+#define VINTR 0
+#define VQUIT 1
+#define VERASE 2
+#define VKILL 3
+#define VEOF 4
+#define VTIME 5
+#define VMIN 6
+#define VSWTC 7
+#define VSTART 8
+#define VSTOP 9
+#define VSUSP 10
+#define VEOL 11
+#define VREPRINT 12
+#define VDISCARD 13
+#define VWERASE 14
+#define VLNEXT 15
+#define VEOL2 16
+
+#define IGNBRK 0000001
+#define BRKINT 0000002
+#define IGNPAR 0000004
+#define PARMRK 0000010
+#define INPCK 0000020
+#define ISTRIP 0000040
+#define INLCR 0000100
+#define IGNCR 0000200
+#define ICRNL 0000400
+#define IUCLC 0001000
+#define IXON 0002000
+#define IXANY 0004000
+#define IXOFF 0010000
+#define IMAXBEL 0020000
+
+#define OPOST 0000001
+#define OLCUC 0000002
+#define ONLCR 0000004
+#define OCRNL 0000010
+#define ONOCR 0000020
+#define ONLRET 0000040
+#define OFILL 0000100
+#define OFDEL 0000200
+#define NLDLY 0000400
+#define NL0 0000000
+#define NL1 0000400
+#define CRDLY 0003000
+#define CR0 0000000
+#define CR1 0001000
+#define CR2 0002000
+#define CR3 0003000
+#define TABDLY 0014000
+#define TAB0 0000000
+#define TAB1 0004000
+#define TAB2 0010000
+#define TAB3 0014000
+#define BSDLY 0020000
+#define BS0 0000000
+#define BS1 0020000
+#define FFDLY 0100000
+#define FF0 0000000
+#define FF1 0100000
+
+#define VTDLY 0040000
+#define VT0 0000000
+#define VT1 0040000
+
+/* ?? */
+#define XTABS 0014000
+
+#define B0 0000000
+#define B50 0000001
+#define B75 0000002
+#define B110 0000003
+#define B134 0000004
+#define B150 0000005
+#define B200 0000006
+#define B300 0000007
+#define B600 0000010
+#define B1200 0000011
+#define B1800 0000012
+#define B2400 0000013
+#define B4800 0000014
+#define B9600 0000015
+#define B19200 0000016
+#define B38400 0000017
+
+#define B57600 0010001
+#define B115200 0010002
+#define B230400 0010003
+#define B460800 0010004
+#define B500000 0010005
+#define B576000 0010006
+#define B921600 0010007
+#define B1000000 0010010
+#define B1152000 0010011
+#define B1500000 0010012
+#define B2000000 0010013
+#define B2500000 0010014
+#define B3000000 0010015
+#define B3500000 0010016
+#define B4000000 0010017
+
+#define CBAUD 0010017
+
+#define CSIZE 0000060
+#define CS5 0000000
+#define CS6 0000020
+#define CS7 0000040
+#define CS8 0000060
+#define CSTOPB 0000100
+#define CREAD 0000200
+#define PARENB 0000400
+#define PARODD 0001000
+#define HUPCL 0002000
+#define CLOCAL 0004000
+
+#define CRTSCTS 020000000000
+
+#define ISIG 0000001
+#define ICANON 0000002
+#define ECHO 0000010
+#define ECHOE 0000020
+#define ECHOK 0000040
+#define ECHONL 0000100
+#define NOFLSH 0000200
+#define TOSTOP 0000400
+#define IEXTEN 0100000
+
+/* Extensions? */
+#define CBAUDEX 0010000
+#define ECHOCTL 0001000
+#define ECHOPRT 0002000
+#define ECHOKE 0004000
+#define FLUSHO 0010000
+#define PENDIN 0040000
+#define EXTPROC 0200000
+
+#define TCOOFF 0
+#define TCOON 1
+#define TCIOFF 2
+#define TCION 3
+
+#define TCIFLUSH 0
+#define TCOFLUSH 1
+#define TCIOFLUSH 2
+
+#define TCSANOW 0
+#define TCSADRAIN 1
+#define TCSAFLUSH 2
diff --git a/system/include/libc/bits/user.h b/system/include/libc/bits/user.h
new file mode 100644
index 00000000..fa623621
--- /dev/null
+++ b/system/include/libc/bits/user.h
@@ -0,0 +1,48 @@
+#undef __WORDSIZE
+#define __WORDSIZE 32
+
+typedef struct user_fpregs_struct
+{
+ long cwd, swd, twd, fip, fcs, foo, fos, st_space[20];
+} elf_fpregset_t;
+
+typedef struct user_fpxregs_struct
+{
+ unsigned short cwd, swd, twd, fop;
+ long fip, fcs, foo, fos, mxcsr, reserved;
+ long st_space[32], xmm_space[32], padding[56];
+} elf_fpxregset_t;
+
+struct user_regs_struct
+{
+ long ebx, ecx, edx, esi, edi, ebp, eax, xds, xes, xfs, xgs;
+ long orig_eax, eip, xcs, eflags, esp, xss;
+};
+
+#define ELF_NGREG 17
+typedef unsigned long elf_greg_t, elf_gregset_t[ELF_NGREG];
+
+struct user
+{
+ struct user_regs_struct regs;
+ int u_fpvalid;
+ struct user_fpregs_struct i387;
+ unsigned long u_tsize;
+ unsigned long u_dsize;
+ unsigned long u_ssize;
+ unsigned long start_code;
+ unsigned long start_stack;
+ long signal;
+ int reserved;
+ struct user_regs_struct *u_ar0;
+ struct user_fpregs_struct *u_fpstate;
+ unsigned long magic;
+ char u_comm[32];
+ int u_debugreg[8];
+};
+
+#define PAGE_MASK (~(PAGE_SIZE-1))
+#define NBPG PAGE_SIZE
+#define UPAGES 1
+#define HOST_TEXT_START_ADDR (u.start_code)
+#define HOST_STACK_END_ADDR (u.start_stack + u.u_ssize * NBPG)
diff --git a/system/include/libc/byteswap.h b/system/include/libc/byteswap.h
new file mode 100644
index 00000000..00b9df3c
--- /dev/null
+++ b/system/include/libc/byteswap.h
@@ -0,0 +1,26 @@
+#ifndef _BYTESWAP_H
+#define _BYTESWAP_H
+
+#include <features.h>
+#include <stdint.h>
+
+static __inline uint16_t __bswap_16(uint16_t __x)
+{
+ return __x<<8 | __x>>8;
+}
+
+static __inline uint32_t __bswap_32(uint32_t __x)
+{
+ return __x>>24 | __x>>8&0xff00 | __x<<8&0xff0000 | __x<<24;
+}
+
+static __inline uint64_t __bswap_64(uint64_t __x)
+{
+ return __bswap_32(__x)+0ULL<<32 | __bswap_32(__x>>32);
+}
+
+#define bswap_16(x) __bswap_16(x)
+#define bswap_32(x) __bswap_32(x)
+#define bswap_64(x) __bswap_64(x)
+
+#endif
diff --git a/system/include/libc/complex.h b/system/include/libc/complex.h
index d5ce5f87..13a45c57 100644
--- a/system/include/libc/complex.h
+++ b/system/include/libc/complex.h
@@ -1,124 +1,125 @@
-/* $NetBSD: complex.h,v 1.3 2010/09/15 16:11:30 christos Exp $ */
+#ifndef _COMPLEX_H
+#define _COMPLEX_H
-/*
- * Written by Matthias Drochner.
- * Public domain.
- */
-
-#ifndef _COMPLEX_H
-#define _COMPLEX_H
+#ifdef __cplusplus
+extern "C" {
+#endif
#define complex _Complex
+#ifdef __GNUC__
+#define _Complex_I (__extension__ 1.0fi)
+#else
#define _Complex_I 1.0fi
+#endif
#define I _Complex_I
-#include <sys/cdefs.h>
-
-__BEGIN_DECLS
-
-/* 7.3.5 Trigonometric functions */
-/* 7.3.5.1 The cacos functions */
double complex cacos(double complex);
float complex cacosf(float complex);
+long double complex cacosl(long double complex);
-/* 7.3.5.2 The casin functions */
double complex casin(double complex);
float complex casinf(float complex);
+long double complex casinl(long double complex);
-/* 7.3.5.1 The catan functions */
double complex catan(double complex);
float complex catanf(float complex);
+long double complex catanl(long double complex);
-/* 7.3.5.1 The ccos functions */
double complex ccos(double complex);
float complex ccosf(float complex);
+long double complex ccosl(long double complex);
-/* 7.3.5.1 The csin functions */
double complex csin(double complex);
float complex csinf(float complex);
+long double complex csinl(long double complex);
-/* 7.3.5.1 The ctan functions */
double complex ctan(double complex);
float complex ctanf(float complex);
+long double complex ctanl(long double complex);
-/* 7.3.6 Hyperbolic functions */
-/* 7.3.6.1 The cacosh functions */
double complex cacosh(double complex);
float complex cacoshf(float complex);
+long double complex cacoshl(long double complex);
-/* 7.3.6.2 The casinh functions */
double complex casinh(double complex);
float complex casinhf(float complex);
+long double complex casinhl(long double complex);
-/* 7.3.6.3 The catanh functions */
double complex catanh(double complex);
float complex catanhf(float complex);
+long double complex catanhl(long double complex);
-/* 7.3.6.4 The ccosh functions */
double complex ccosh(double complex);
float complex ccoshf(float complex);
+long double complex ccoshl(long double complex);
-/* 7.3.6.5 The csinh functions */
double complex csinh(double complex);
float complex csinhf(float complex);
+long double complex csinhl(long double complex);
-/* 7.3.6.6 The ctanh functions */
double complex ctanh(double complex);
float complex ctanhf(float complex);
+long double complex ctanhl(long double complex);
-/* 7.3.7 Exponential and logarithmic functions */
-/* 7.3.7.1 The cexp functions */
double complex cexp(double complex);
float complex cexpf(float complex);
+long double complex cexpl(long double complex);
-/* 7.3.7.2 The clog functions */
double complex clog(double complex);
float complex clogf(float complex);
+long double complex clogl(long double complex);
+
+double cabs(double complex);
+float cabsf(float complex);
+long double cabsl(long double complex);
-/* 7.3.8 Power and absolute-value functions */
-/* 7.3.8.1 The cabs functions */
-/*#ifndef __LIBM0_SOURCE__
-/* avoid conflict with historical cabs(struct complex) */
-/* double cabs(double complex) __RENAME(__c99_cabs);
- float cabsf(float complex) __RENAME(__c99_cabsf);
- #endif
-*/
-double cabs(double complex) ;
-float cabsf(float complex) ;
-
-/* 7.3.8.2 The cpow functions */
double complex cpow(double complex, double complex);
float complex cpowf(float complex, float complex);
+long double complex cpowl(long double complex, long double complex);
-/* 7.3.8.3 The csqrt functions */
double complex csqrt(double complex);
float complex csqrtf(float complex);
+long double complex csqrtl(long double complex);
-/* 7.3.9 Manipulation functions */
-/* 7.3.9.1 The carg functions */
double carg(double complex);
float cargf(float complex);
+long double cargl(long double complex);
-/* 7.3.9.2 The cimag functions */
double cimag(double complex);
float cimagf(float complex);
-/*long double cimagl(long double complex); */
+long double cimagl(long double complex);
-/* 7.3.9.3 The conj functions */
double complex conj(double complex);
float complex conjf(float complex);
-/*long double complex conjl(long double complex); */
+long double complex conjl(long double complex);
-/* 7.3.9.4 The cproj functions */
double complex cproj(double complex);
float complex cprojf(float complex);
-/*long double complex cprojl(long double complex); */
+long double complex cprojl(long double complex);
-/* 7.3.9.5 The creal functions */
double creal(double complex);
float crealf(float complex);
-/*long double creall(long double complex); */
+long double creall(long double complex);
+
+#define __CIMAG(x, t) \
+ ((union { _Complex t __z; t __xy[2]; }){(_Complex t)(x)}.__xy[1])
+
+#define creal(x) ((double)(x))
+#define crealf(x) ((float)(x))
+#define creall(x) ((long double)(x))
+
+#define cimag(x) __CIMAG(x, double)
+#define cimagf(x) __CIMAG(x, float)
+#define cimagl(x) __CIMAG(x, long double)
+
+#define __CMPLX(x, y, t) \
+ ((union { _Complex t __z; t __xy[2]; }){.__xy = {(x),(y)}}.__z)
-__END_DECLS
+#define CMPLX(x, y) __CMPLX(x, y, double)
+#define CMPLXF(x, y) __CMPLX(x, y, float)
+#define CMPLXL(x, y) __CMPLX(x, y, long double)
-#endif /* ! _COMPLEX_H */
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/system/include/libc/cpio.h b/system/include/libc/cpio.h
new file mode 100644
index 00000000..39a1f8bb
--- /dev/null
+++ b/system/include/libc/cpio.h
@@ -0,0 +1,29 @@
+#ifndef _CPIO_H
+#define _CPIO_H
+
+#define MAGIC "070707"
+
+#define C_IRUSR 000400
+#define C_IWUSR 000200
+#define C_IXUSR 000100
+#define C_IRGRP 000040
+#define C_IWGRP 000020
+#define C_IXGRP 000010
+#define C_IROTH 000004
+#define C_IWOTH 000002
+#define C_IXOTH 000001
+
+#define C_ISUID 004000
+#define C_ISGID 002000
+#define C_ISVTX 001000
+
+#define C_ISBLK 060000
+#define C_ISCHR 020000
+#define C_ISDIR 040000
+#define C_ISFIFO 010000
+#define C_ISSOCK 0140000
+#define C_ISLNK 0120000
+#define C_ISCTG 0110000
+#define C_ISREG 0100000
+
+#endif
diff --git a/system/include/libc/crypt.h b/system/include/libc/crypt.h
new file mode 100644
index 00000000..07de2169
--- /dev/null
+++ b/system/include/libc/crypt.h
@@ -0,0 +1,20 @@
+#ifndef _CRYPT_H
+#define _CRYPT_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct crypt_data {
+ int initialized;
+ char __buf[256];
+};
+
+char *crypt(const char *, const char *);
+char *crypt_r(const char *, const char *, struct crypt_data *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/ctype.h b/system/include/libc/ctype.h
index 666c4d7c..8f0d1687 100644
--- a/system/include/libc/ctype.h
+++ b/system/include/libc/ctype.h
@@ -1,196 +1,67 @@
-#ifndef _CTYPE_H_
-#define _CTYPE_H_
+#ifndef _CTYPE_H
+#define _CTYPE_H
-#include "_ansi.h"
-
-_BEGIN_STD_C
-
-int _EXFUN(isalnum, (int __c));
-int _EXFUN(isalpha, (int __c));
-int _EXFUN(iscntrl, (int __c));
-int _EXFUN(isdigit, (int __c));
-int _EXFUN(isgraph, (int __c));
-int _EXFUN(islower, (int __c));
-int _EXFUN(isprint, (int __c));
-int _EXFUN(ispunct, (int __c));
-int _EXFUN(isspace, (int __c));
-int _EXFUN(isupper, (int __c));
-int _EXFUN(isxdigit,(int __c));
-int _EXFUN(tolower, (int __c));
-int _EXFUN(toupper, (int __c));
-
-#if !defined(__STRICT_ANSI__) || defined(__cplusplus) || __STDC_VERSION__ >= 199901L
-int _EXFUN(isblank, (int __c));
+#ifdef __cplusplus
+extern "C" {
#endif
-#ifndef __STRICT_ANSI__
-int _EXFUN(isascii, (int __c));
-int _EXFUN(toascii, (int __c));
-#define _tolower(__c) ((unsigned char)(__c) - 'A' + 'a')
-#define _toupper(__c) ((unsigned char)(__c) - 'a' + 'A')
-#endif
+#include <features.h>
+
+int isalnum(int);
+int isalpha(int);
+int isblank(int);
+int iscntrl(int);
+int isdigit(int);
+int isgraph(int);
+int islower(int);
+int isprint(int);
+int ispunct(int);
+int isspace(int);
+int isupper(int);
+int isxdigit(int);
+int tolower(int);
+int toupper(int);
+
+#define isalpha(a) ((((unsigned)(a)|32)-'a') < 26)
+#define isdigit(a) (((unsigned)(a)-'0') < 10)
+#define islower(a) (((unsigned)(a)-'a') < 26)
+#define isupper(a) (((unsigned)(a)-'A') < 26)
+#define isprint(a) (((unsigned)(a)-0x20) < 0x5f)
+#define isgraph(a) (((unsigned)(a)-0x21) < 0x5e)
+
+
+
+#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
+ || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
+ || defined(_BSD_SOURCE)
+
+#define __NEED_locale_t
+#include <bits/alltypes.h>
+
+int isalnum_l(int, locale_t);
+int isalpha_l(int, locale_t);
+int isblank_l(int, locale_t);
+int iscntrl_l(int, locale_t);
+int isdigit_l(int, locale_t);
+int isgraph_l(int, locale_t);
+int islower_l(int, locale_t);
+int isprint_l(int, locale_t);
+int ispunct_l(int, locale_t);
+int isspace_l(int, locale_t);
+int isupper_l(int, locale_t);
+int isxdigit_l(int, locale_t);
+int tolower_l(int, locale_t);
+int toupper_l(int, locale_t);
+
+int isascii(int);
+int toascii(int);
+#define _tolower(a) ((a)|0x20)
+#define _toupper(a) ((a)&0x5f)
-/* XXX Emscripten
-#ifndef _MB_CAPABLE
-_CONST
#endif
- extern __IMPORT char *__ctype_ptr__;
-*/
-
-#if 0 /* ndef __cplusplus XXX Emscripten: Do not use the macros here. always use the simple functions */
-
-/* XXX Emscripten - these confuse libc++. moved to inside ifndef __cplusplus, and added CTYPE_ */
-#define CTYPE__U 01
-#define CTYPE__L 02
-#define CTYPE__N 04
-#define CTYPE__S 010
-#define CTYPE__P 020
-#define CTYPE__C 040
-#define CTYPE__X 0100
-#define CTYPE__B 0200
-
-/* These macros are intentionally written in a manner that will trigger
- a gcc -Wall warning if the user mistakenly passes a 'char' instead
- of an int containing an 'unsigned char'. Note that the sizeof will
- always be 1, which is what we want for mapping EOF to __ctype_ptr__[0];
- the use of a raw index inside the sizeof triggers the gcc warning if
- __c was of type char, and sizeof masks side effects of the extra __c.
- Meanwhile, the real index to __ctype_ptr__+1 must be cast to int,
- since isalpha(0x100000001LL) must equal isalpha(1), rather than being
- an out-of-bounds reference on a 64-bit machine. */
-#define __ctype_lookup(__c) ((__ctype_ptr__+sizeof(""[__c]))[(int)(__c)])
-
-#define isalpha(__c) (__ctype_lookup(__c)&(CTYPE__U|CTYPE__L))
-#define isupper(__c) ((__ctype_lookup(__c)&(CTYPE__U|CTYPE__L))==CTYPE__U)
-#define islower(__c) ((__ctype_lookup(__c)&(CTYPE__U|CTYPE__L))==CTYPE__L)
-#define isdigit(__c) (__ctype_lookup(__c)&CTYPE__N)
-#define isxdigit(__c) (__ctype_lookup(__c)&(CTYPE__X|CTYPE__N))
-#define isspace(__c) (__ctype_lookup(__c)&CTYPE__S)
-#define ispunct(__c) (__ctype_lookup(__c)&CTYPE__P)
-#define isalnum(__c) (__ctype_lookup(__c)&(CTYPE__U|CTYPE__L|CTYPE__N))
-#define isprint(__c) (__ctype_lookup(__c)&(CTYPE__P|CTYPE__U|CTYPE__L|CTYPE__N|CTYPE__B))
-#define isgraph(__c) (__ctype_lookup(__c)&(CTYPE__P|CTYPE__U|CTYPE__L|CTYPE__N))
-#define iscntrl(__c) (__ctype_lookup(__c)&CTYPE__C)
-/* XXX: EMSCRIPTEN: We alter the names of __typeof__ declarations to
- reduce the chance of them conflicting when expanded */
-
-#if defined(__GNUC__) && \
- (!defined(__STRICT_ANSI__) || __STDC_VERSION__ >= 199901L)
-#define isblank(__c) \
- __extension__ ({ __typeof__ (__c) __ctb_x = (__c); \
- (__ctype_lookup(__ctb_x)&_B) || (int) (__ctb_x) == '\t';})
+#ifdef __cplusplus
+}
#endif
-
-/* Non-gcc versions will get the library versions, and will be
- slightly slower. These macros are not NLS-aware so they are
- disabled if the system supports the extended character sets. */
-# if defined(__GNUC__)
-# if !defined (_MB_EXTENDED_CHARSETS_ISO) && !defined (_MB_EXTENDED_CHARSETS_WINDOWS)
-# define toupper(__c) \
- __extension__ ({ __typeof__ (__c) __cttu_x = (__c); \
- islower (__cttu_x) ? (int) __cttu_x - 'a' + 'A' : (int) __cttu_x;})
-# define tolower(__c) \
- __extension__ ({ __typeof__ (__c) __cttl_x = (__c); \
- isupper (__cttl_x) ? (int) __cttl_x - 'A' + 'a' : (int) __cttl_x;})
-# else /* _MB_EXTENDED_CHARSETS* */
-/* Allow a gcc warning if the user passed 'char', but defer to the
- function. */
-# define toupper(__c) \
- __extension__ ({ __typeof__ (__c) __cttu_x = (__c); \
- (void) __ctype_ptr__[__cttu_x]; (toupper) (__cttu_x);})
-# define tolower(__c) \
- __extension__ ({ __typeof__ (__c) __cttl_x = (__c); \
- (void) __ctype_ptr__[__cttl_x]; (tolower) (__cttl_x);})
-# endif /* _MB_EXTENDED_CHARSETS* */
-# endif /* __GNUC__ */
-#endif /* !__cplusplus */
-
-#ifndef __STRICT_ANSI__
-#define isascii(__c) ((unsigned)(__c)<=0177)
-#define toascii(__c) ((__c)&0177)
#endif
-
-/* For C++ backward-compatibility only. */
-extern __IMPORT _CONST char _ctype_[];
-
-_END_STD_C
-
-/*
- * Copyright (c) 2000, 2005, 2008 Apple Inc. All rights reserved.
- *
- * @APPLE_LICENSE_HEADER_START@
- *
- * This file contains Original Code and/or Modifications of Original Code
- * as defined in and that are subject to the Apple Public Source License
- * Version 2.0 (the 'License'). You may not use this file except in
- * compliance with the License. Please obtain a copy of the License at
- * http://www.opensource.apple.com/apsl/ and read it before using this
- * file.
- *
- * The Original Code and all software distributed under the License are
- * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
- * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
- * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
- * Please see the License for the specific language governing rights and
- * limitations under the License.
- *
- * @APPLE_LICENSE_HEADER_END@
- */
-/*
- * Copyright (c) 1989, 1993
- * The Regents of the University of California. All rights reserved.
- * (c) UNIX System Laboratories, Inc.
- * All or some portions of this file are derived from material licensed
- * to the University of California by American Telephone and Telegraph
- * Co. or Unix System Laboratories, Inc. and are reproduced herein with
- * the permission of UNIX System Laboratories, Inc.
- *
- * This code is derived from software contributed to Berkeley by
- * Paul Borman at Krystal Technologies.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)ctype.h 8.4 (Berkeley) 1/21/94
- */
-
-#define _CTYPE_A 0x00000400 /* Alpha */
-#define _CTYPE_C 0x00000002 /* Control */
-#define _CTYPE_D 0x00000800 /* Digit */
-#define _CTYPE_L 0x00000200 /* Lower */
-#define _CTYPE_P 0x00000004 /* Punct */
-#define _CTYPE_S 0x00002000 /* Space */
-#define _CTYPE_U 0x00000100 /* Upper */
-#define _CTYPE_X 0x00001000 /* X digit */
-#define _CTYPE_B 0x00000001 /* Blank */
-#define _CTYPE_R 0x00004000 /* Print */
-
-#endif /* _CTYPE_H_ */
diff --git a/system/include/libc/dirent.h b/system/include/libc/dirent.h
index 97700f30..5aa8510b 100644
--- a/system/include/libc/dirent.h
+++ b/system/include/libc/dirent.h
@@ -1,16 +1,79 @@
-#ifndef _DIRENT_H_
-#define _DIRENT_H_
+#ifndef _DIRENT_H
+#define _DIRENT_H
+
#ifdef __cplusplus
extern "C" {
#endif
-#if !defined(MAXNAMLEN) && !defined(_POSIX_SOURCE)
-#define MAXNAMLEN 1024
+#include <features.h>
+
+#define __NEED_ino_t
+#define __NEED_off_t
+#if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
+#define __NEED_size_t
#endif
-#include <sys/dirent.h>
+#include <bits/alltypes.h>
+
+typedef struct __dirstream DIR;
+
+struct dirent
+{
+ ino_t d_ino;
+ off_t d_off;
+ unsigned short d_reclen;
+ unsigned char d_type;
+ char d_name[256];
+};
+
+#define d_fileno d_ino
+
+int closedir(DIR *);
+DIR *fdopendir(int);
+DIR *opendir(const char *);
+struct dirent *readdir(DIR *);
+int readdir_r(DIR *__restrict, struct dirent *__restrict, struct dirent **__restrict);
+void rewinddir(DIR *);
+void seekdir(DIR *, long);
+long telldir(DIR *);
+int dirfd(DIR *);
+
+int alphasort(const struct dirent **, const struct dirent **);
+int scandir(const char *, struct dirent ***, int (*)(const struct dirent *), int (*)(const struct dirent **, const struct dirent **));
+
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+#define DT_UNKNOWN 0
+#define DT_FIFO 1
+#define DT_CHR 2
+#define DT_DIR 4
+#define DT_BLK 6
+#define DT_REG 8
+#define DT_LNK 10
+#define DT_SOCK 12
+#define DT_WHT 14
+#define IFTODT(x) ((x)>>12 & 017)
+#define DTTOIF(x) ((x)<<12)
+int getdents(int, struct dirent *, size_t);
+#endif
+
+#ifdef _GNU_SOURCE
+int versionsort(const struct dirent **, const struct dirent **);
+#endif
+
+#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
+#define dirent64 dirent
+#define readdir64 readdir
+#define readdir64_r readdir_r
+#define scandir64 scandir
+#define alphasort64 alphasort
+#define versionsort64 versionsort
+#define off64_t off_t
+#define ino64_t ino_t
+#define getdents64 getdents
+#endif
#ifdef __cplusplus
}
#endif
-#endif /*_DIRENT_H_*/
+
+#endif
diff --git a/system/include/libc/dlfcn.h b/system/include/libc/dlfcn.h
new file mode 100644
index 00000000..db26194b
--- /dev/null
+++ b/system/include/libc/dlfcn.h
@@ -0,0 +1,42 @@
+#ifndef _DLFCN_H
+#define _DLFCN_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <features.h>
+
+#define RTLD_LAZY 1
+#define RTLD_NOW 2
+#define RTLD_NOLOAD 4
+#define RTLD_NODELETE 4096
+#define RTLD_GLOBAL 256
+#define RTLD_LOCAL 0
+
+#define RTLD_NEXT ((void *)-1)
+#define RTLD_DEFAULT ((void *)0)
+
+#define RTLD_DI_LINKMAP 2
+
+int dlclose(void *);
+char *dlerror(void);
+void *dlopen(const char *, int);
+void *dlsym(void *__restrict, const char *__restrict);
+
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+typedef struct {
+ const char *dli_fname;
+ void *dli_fbase;
+ const char *dli_sname;
+ void *dli_saddr;
+} Dl_info;
+int dladdr(void *, Dl_info *);
+int dlinfo(void *, int, void *);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/elf.h b/system/include/libc/elf.h
new file mode 100644
index 00000000..0075f9fc
--- /dev/null
+++ b/system/include/libc/elf.h
@@ -0,0 +1,2555 @@
+#ifndef _ELF_H
+#define _ELF_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+
+typedef uint16_t Elf32_Half;
+typedef uint16_t Elf64_Half;
+
+typedef uint32_t Elf32_Word;
+typedef int32_t Elf32_Sword;
+typedef uint32_t Elf64_Word;
+typedef int32_t Elf64_Sword;
+
+typedef uint64_t Elf32_Xword;
+typedef int64_t Elf32_Sxword;
+typedef uint64_t Elf64_Xword;
+typedef int64_t Elf64_Sxword;
+
+typedef uint32_t Elf32_Addr;
+typedef uint64_t Elf64_Addr;
+
+typedef uint32_t Elf32_Off;
+typedef uint64_t Elf64_Off;
+
+typedef uint16_t Elf32_Section;
+typedef uint16_t Elf64_Section;
+
+typedef Elf32_Half Elf32_Versym;
+typedef Elf64_Half Elf64_Versym;
+
+#define EI_NIDENT (16)
+
+typedef struct {
+ unsigned char e_ident[EI_NIDENT];
+ Elf32_Half e_type;
+ Elf32_Half e_machine;
+ Elf32_Word e_version;
+ Elf32_Addr e_entry;
+ Elf32_Off e_phoff;
+ Elf32_Off e_shoff;
+ Elf32_Word e_flags;
+ Elf32_Half e_ehsize;
+ Elf32_Half e_phentsize;
+ Elf32_Half e_phnum;
+ Elf32_Half e_shentsize;
+ Elf32_Half e_shnum;
+ Elf32_Half e_shstrndx;
+} Elf32_Ehdr;
+
+typedef struct {
+ unsigned char e_ident[EI_NIDENT];
+ Elf64_Half e_type;
+ Elf64_Half e_machine;
+ Elf64_Word e_version;
+ Elf64_Addr e_entry;
+ Elf64_Off e_phoff;
+ Elf64_Off e_shoff;
+ Elf64_Word e_flags;
+ Elf64_Half e_ehsize;
+ Elf64_Half e_phentsize;
+ Elf64_Half e_phnum;
+ Elf64_Half e_shentsize;
+ Elf64_Half e_shnum;
+ Elf64_Half e_shstrndx;
+} Elf64_Ehdr;
+
+#define EI_MAG0 0
+#define ELFMAG0 0x7f
+
+#define EI_MAG1 1
+#define ELFMAG1 'E'
+
+#define EI_MAG2 2
+#define ELFMAG2 'L'
+
+#define EI_MAG3 3
+#define ELFMAG3 'F'
+
+
+#define ELFMAG "\177ELF"
+#define SELFMAG 4
+
+#define EI_CLASS 4
+#define ELFCLASSNONE 0
+#define ELFCLASS32 1
+#define ELFCLASS64 2
+#define ELFCLASSNUM 3
+
+#define EI_DATA 5
+#define ELFDATANONE 0
+#define ELFDATA2LSB 1
+#define ELFDATA2MSB 2
+#define ELFDATANUM 3
+
+#define EI_VERSION 6
+
+
+#define EI_OSABI 7
+#define ELFOSABI_NONE 0
+#define ELFOSABI_SYSV 0
+#define ELFOSABI_HPUX 1
+#define ELFOSABI_NETBSD 2
+#define ELFOSABI_LINUX 3
+#define ELFOSABI_SOLARIS 6
+#define ELFOSABI_AIX 7
+#define ELFOSABI_IRIX 8
+#define ELFOSABI_FREEBSD 9
+#define ELFOSABI_TRU64 10
+#define ELFOSABI_MODESTO 11
+#define ELFOSABI_OPENBSD 12
+#define ELFOSABI_ARM 97
+#define ELFOSABI_STANDALONE 255
+
+#define EI_ABIVERSION 8
+
+#define EI_PAD 9
+
+
+
+#define ET_NONE 0
+#define ET_REL 1
+#define ET_EXEC 2
+#define ET_DYN 3
+#define ET_CORE 4
+#define ET_NUM 5
+#define ET_LOOS 0xfe00
+#define ET_HIOS 0xfeff
+#define ET_LOPROC 0xff00
+#define ET_HIPROC 0xffff
+
+
+
+#define EM_NONE 0
+#define EM_M32 1
+#define EM_SPARC 2
+#define EM_386 3
+#define EM_68K 4
+#define EM_88K 5
+#define EM_860 7
+#define EM_MIPS 8
+#define EM_S370 9
+#define EM_MIPS_RS3_LE 10
+
+#define EM_PARISC 15
+#define EM_VPP500 17
+#define EM_SPARC32PLUS 18
+#define EM_960 19
+#define EM_PPC 20
+#define EM_PPC64 21
+#define EM_S390 22
+
+#define EM_V800 36
+#define EM_FR20 37
+#define EM_RH32 38
+#define EM_RCE 39
+#define EM_ARM 40
+#define EM_FAKE_ALPHA 41
+#define EM_SH 42
+#define EM_SPARCV9 43
+#define EM_TRICORE 44
+#define EM_ARC 45
+#define EM_H8_300 46
+#define EM_H8_300H 47
+#define EM_H8S 48
+#define EM_H8_500 49
+#define EM_IA_64 50
+#define EM_MIPS_X 51
+#define EM_COLDFIRE 52
+#define EM_68HC12 53
+#define EM_MMA 54
+#define EM_PCP 55
+#define EM_NCPU 56
+#define EM_NDR1 57
+#define EM_STARCORE 58
+#define EM_ME16 59
+#define EM_ST100 60
+#define EM_TINYJ 61
+#define EM_X86_64 62
+#define EM_PDSP 63
+
+#define EM_FX66 66
+#define EM_ST9PLUS 67
+#define EM_ST7 68
+#define EM_68HC16 69
+#define EM_68HC11 70
+#define EM_68HC08 71
+#define EM_68HC05 72
+#define EM_SVX 73
+#define EM_ST19 74
+#define EM_VAX 75
+#define EM_CRIS 76
+#define EM_JAVELIN 77
+#define EM_FIREPATH 78
+#define EM_ZSP 79
+#define EM_MMIX 80
+#define EM_HUANY 81
+#define EM_PRISM 82
+#define EM_AVR 83
+#define EM_FR30 84
+#define EM_D10V 85
+#define EM_D30V 86
+#define EM_V850 87
+#define EM_M32R 88
+#define EM_MN10300 89
+#define EM_MN10200 90
+#define EM_PJ 91
+#define EM_OPENRISC 92
+#define EM_ARC_A5 93
+#define EM_XTENSA 94
+#define EM_NUM 95
+#define EM_ALPHA 0x9026
+
+#define EV_NONE 0
+#define EV_CURRENT 1
+#define EV_NUM 2
+
+typedef struct {
+ Elf32_Word sh_name;
+ Elf32_Word sh_type;
+ Elf32_Word sh_flags;
+ Elf32_Addr sh_addr;
+ Elf32_Off sh_offset;
+ Elf32_Word sh_size;
+ Elf32_Word sh_link;
+ Elf32_Word sh_info;
+ Elf32_Word sh_addralign;
+ Elf32_Word sh_entsize;
+} Elf32_Shdr;
+
+typedef struct {
+ Elf64_Word sh_name;
+ Elf64_Word sh_type;
+ Elf64_Xword sh_flags;
+ Elf64_Addr sh_addr;
+ Elf64_Off sh_offset;
+ Elf64_Xword sh_size;
+ Elf64_Word sh_link;
+ Elf64_Word sh_info;
+ Elf64_Xword sh_addralign;
+ Elf64_Xword sh_entsize;
+} Elf64_Shdr;
+
+
+
+#define SHN_UNDEF 0
+#define SHN_LORESERVE 0xff00
+#define SHN_LOPROC 0xff00
+#define SHN_BEFORE 0xff00
+
+#define SHN_AFTER 0xff01
+
+#define SHN_HIPROC 0xff1f
+#define SHN_LOOS 0xff20
+#define SHN_HIOS 0xff3f
+#define SHN_ABS 0xfff1
+#define SHN_COMMON 0xfff2
+#define SHN_XINDEX 0xffff
+#define SHN_HIRESERVE 0xffff
+
+
+
+#define SHT_NULL 0
+#define SHT_PROGBITS 1
+#define SHT_SYMTAB 2
+#define SHT_STRTAB 3
+#define SHT_RELA 4
+#define SHT_HASH 5
+#define SHT_DYNAMIC 6
+#define SHT_NOTE 7
+#define SHT_NOBITS 8
+#define SHT_REL 9
+#define SHT_SHLIB 10
+#define SHT_DYNSYM 11
+#define SHT_INIT_ARRAY 14
+#define SHT_FINI_ARRAY 15
+#define SHT_PREINIT_ARRAY 16
+#define SHT_GROUP 17
+#define SHT_SYMTAB_SHNDX 18
+#define SHT_NUM 19
+#define SHT_LOOS 0x60000000
+#define SHT_GNU_ATTRIBUTES 0x6ffffff5
+#define SHT_GNU_HASH 0x6ffffff6
+#define SHT_GNU_LIBLIST 0x6ffffff7
+#define SHT_CHECKSUM 0x6ffffff8
+#define SHT_LOSUNW 0x6ffffffa
+#define SHT_SUNW_move 0x6ffffffa
+#define SHT_SUNW_COMDAT 0x6ffffffb
+#define SHT_SUNW_syminfo 0x6ffffffc
+#define SHT_GNU_verdef 0x6ffffffd
+#define SHT_GNU_verneed 0x6ffffffe
+#define SHT_GNU_versym 0x6fffffff
+#define SHT_HISUNW 0x6fffffff
+#define SHT_HIOS 0x6fffffff
+#define SHT_LOPROC 0x70000000
+#define SHT_HIPROC 0x7fffffff
+#define SHT_LOUSER 0x80000000
+#define SHT_HIUSER 0x8fffffff
+
+#define SHF_WRITE (1 << 0)
+#define SHF_ALLOC (1 << 1)
+#define SHF_EXECINSTR (1 << 2)
+#define SHF_MERGE (1 << 4)
+#define SHF_STRINGS (1 << 5)
+#define SHF_INFO_LINK (1 << 6)
+#define SHF_LINK_ORDER (1 << 7)
+#define SHF_OS_NONCONFORMING (1 << 8)
+
+#define SHF_GROUP (1 << 9)
+#define SHF_TLS (1 << 10)
+#define SHF_MASKOS 0x0ff00000
+#define SHF_MASKPROC 0xf0000000
+#define SHF_ORDERED (1 << 30)
+#define SHF_EXCLUDE (1 << 31)
+
+#define GRP_COMDAT 0x1
+
+typedef struct {
+ Elf32_Word st_name;
+ Elf32_Addr st_value;
+ Elf32_Word st_size;
+ unsigned char st_info;
+ unsigned char st_other;
+ Elf32_Section st_shndx;
+} Elf32_Sym;
+
+typedef struct {
+ Elf64_Word st_name;
+ unsigned char st_info;
+ unsigned char st_other;
+ Elf64_Section st_shndx;
+ Elf64_Addr st_value;
+ Elf64_Xword st_size;
+} Elf64_Sym;
+
+typedef struct {
+ Elf32_Half si_boundto;
+ Elf32_Half si_flags;
+} Elf32_Syminfo;
+
+typedef struct {
+ Elf64_Half si_boundto;
+ Elf64_Half si_flags;
+} Elf64_Syminfo;
+
+#define SYMINFO_BT_SELF 0xffff
+#define SYMINFO_BT_PARENT 0xfffe
+#define SYMINFO_BT_LOWRESERVE 0xff00
+
+#define SYMINFO_FLG_DIRECT 0x0001
+#define SYMINFO_FLG_PASSTHRU 0x0002
+#define SYMINFO_FLG_COPY 0x0004
+#define SYMINFO_FLG_LAZYLOAD 0x0008
+
+#define SYMINFO_NONE 0
+#define SYMINFO_CURRENT 1
+#define SYMINFO_NUM 2
+
+#define ELF32_ST_BIND(val) (((unsigned char) (val)) >> 4)
+#define ELF32_ST_TYPE(val) ((val) & 0xf)
+#define ELF32_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf))
+
+#define ELF64_ST_BIND(val) ELF32_ST_BIND (val)
+#define ELF64_ST_TYPE(val) ELF32_ST_TYPE (val)
+#define ELF64_ST_INFO(bind, type) ELF32_ST_INFO ((bind), (type))
+
+#define STB_LOCAL 0
+#define STB_GLOBAL 1
+#define STB_WEAK 2
+#define STB_NUM 3
+#define STB_LOOS 10
+#define STB_GNU_UNIQUE 10
+#define STB_HIOS 12
+#define STB_LOPROC 13
+#define STB_HIPROC 15
+
+#define STT_NOTYPE 0
+#define STT_OBJECT 1
+#define STT_FUNC 2
+#define STT_SECTION 3
+#define STT_FILE 4
+#define STT_COMMON 5
+#define STT_TLS 6
+#define STT_NUM 7
+#define STT_LOOS 10
+#define STT_GNU_IFUNC 10
+#define STT_HIOS 12
+#define STT_LOPROC 13
+#define STT_HIPROC 15
+
+#define STN_UNDEF 0
+
+#define ELF32_ST_VISIBILITY(o) ((o) & 0x03)
+#define ELF64_ST_VISIBILITY(o) ELF32_ST_VISIBILITY (o)
+
+#define STV_DEFAULT 0
+#define STV_INTERNAL 1
+#define STV_HIDDEN 2
+#define STV_PROTECTED 3
+
+
+
+
+typedef struct
+{
+ Elf32_Addr r_offset;
+ Elf32_Word r_info;
+} Elf32_Rel;
+
+typedef struct {
+ Elf64_Addr r_offset;
+ Elf64_Xword r_info;
+} Elf64_Rel;
+
+
+
+typedef struct {
+ Elf32_Addr r_offset;
+ Elf32_Word r_info;
+ Elf32_Sword r_addend;
+} Elf32_Rela;
+
+typedef struct {
+ Elf64_Addr r_offset;
+ Elf64_Xword r_info;
+ Elf64_Sxword r_addend;
+} Elf64_Rela;
+
+
+
+#define ELF32_R_SYM(val) ((val) >> 8)
+#define ELF32_R_TYPE(val) ((val) & 0xff)
+#define ELF32_R_INFO(sym, type) (((sym) << 8) + ((type) & 0xff))
+
+#define ELF64_R_SYM(i) ((i) >> 32)
+#define ELF64_R_TYPE(i) ((i) & 0xffffffff)
+#define ELF64_R_INFO(sym,type) ((((Elf64_Xword) (sym)) << 32) + (type))
+
+
+
+typedef struct {
+ Elf32_Word p_type;
+ Elf32_Off p_offset;
+ Elf32_Addr p_vaddr;
+ Elf32_Addr p_paddr;
+ Elf32_Word p_filesz;
+ Elf32_Word p_memsz;
+ Elf32_Word p_flags;
+ Elf32_Word p_align;
+} Elf32_Phdr;
+
+typedef struct {
+ Elf64_Word p_type;
+ Elf64_Word p_flags;
+ Elf64_Off p_offset;
+ Elf64_Addr p_vaddr;
+ Elf64_Addr p_paddr;
+ Elf64_Xword p_filesz;
+ Elf64_Xword p_memsz;
+ Elf64_Xword p_align;
+} Elf64_Phdr;
+
+
+
+#define PT_NULL 0
+#define PT_LOAD 1
+#define PT_DYNAMIC 2
+#define PT_INTERP 3
+#define PT_NOTE 4
+#define PT_SHLIB 5
+#define PT_PHDR 6
+#define PT_TLS 7
+#define PT_NUM 8
+#define PT_LOOS 0x60000000
+#define PT_GNU_EH_FRAME 0x6474e550
+#define PT_GNU_STACK 0x6474e551
+#define PT_GNU_RELRO 0x6474e552
+#define PT_LOSUNW 0x6ffffffa
+#define PT_SUNWBSS 0x6ffffffa
+#define PT_SUNWSTACK 0x6ffffffb
+#define PT_HISUNW 0x6fffffff
+#define PT_HIOS 0x6fffffff
+#define PT_LOPROC 0x70000000
+#define PT_HIPROC 0x7fffffff
+
+
+
+#define PF_X (1 << 0)
+#define PF_W (1 << 1)
+#define PF_R (1 << 2)
+#define PF_MASKOS 0x0ff00000
+#define PF_MASKPROC 0xf0000000
+
+
+
+#define NT_PRSTATUS 1
+#define NT_FPREGSET 2
+#define NT_PRPSINFO 3
+#define NT_PRXREG 4
+#define NT_TASKSTRUCT 4
+#define NT_PLATFORM 5
+#define NT_AUXV 6
+#define NT_GWINDOWS 7
+#define NT_ASRS 8
+#define NT_PSTATUS 10
+#define NT_PSINFO 13
+#define NT_PRCRED 14
+#define NT_UTSNAME 15
+#define NT_LWPSTATUS 16
+#define NT_LWPSINFO 17
+#define NT_PRFPXREG 20
+#define NT_PRXFPREG 0x46e62b7f
+#define NT_PPC_VMX 0x100
+#define NT_PPC_SPE 0x101
+#define NT_PPC_VSX 0x102
+#define NT_386_TLS 0x200
+#define NT_386_IOPERM 0x201
+#define NT_VERSION 1
+
+
+
+
+typedef struct {
+ Elf32_Sword d_tag;
+ union {
+ Elf32_Word d_val;
+ Elf32_Addr d_ptr;
+ } d_un;
+} Elf32_Dyn;
+
+typedef struct {
+ Elf64_Sxword d_tag;
+ union {
+ Elf64_Xword d_val;
+ Elf64_Addr d_ptr;
+ } d_un;
+} Elf64_Dyn;
+
+
+
+#define DT_NULL 0
+#define DT_NEEDED 1
+#define DT_PLTRELSZ 2
+#define DT_PLTGOT 3
+#define DT_HASH 4
+#define DT_STRTAB 5
+#define DT_SYMTAB 6
+#define DT_RELA 7
+#define DT_RELASZ 8
+#define DT_RELAENT 9
+#define DT_STRSZ 10
+#define DT_SYMENT 11
+#define DT_INIT 12
+#define DT_FINI 13
+#define DT_SONAME 14
+#define DT_RPATH 15
+#define DT_SYMBOLIC 16
+#define DT_REL 17
+#define DT_RELSZ 18
+#define DT_RELENT 19
+#define DT_PLTREL 20
+#define DT_DEBUG 21
+#define DT_TEXTREL 22
+#define DT_JMPREL 23
+#define DT_BIND_NOW 24
+#define DT_INIT_ARRAY 25
+#define DT_FINI_ARRAY 26
+#define DT_INIT_ARRAYSZ 27
+#define DT_FINI_ARRAYSZ 28
+#define DT_RUNPATH 29
+#define DT_FLAGS 30
+#define DT_ENCODING 32
+#define DT_PREINIT_ARRAY 32
+#define DT_PREINIT_ARRAYSZ 33
+#define DT_NUM 34
+#define DT_LOOS 0x6000000d
+#define DT_HIOS 0x6ffff000
+#define DT_LOPROC 0x70000000
+#define DT_HIPROC 0x7fffffff
+#define DT_PROCNUM DT_MIPS_NUM
+
+#define DT_VALRNGLO 0x6ffffd00
+#define DT_GNU_PRELINKED 0x6ffffdf5
+#define DT_GNU_CONFLICTSZ 0x6ffffdf6
+#define DT_GNU_LIBLISTSZ 0x6ffffdf7
+#define DT_CHECKSUM 0x6ffffdf8
+#define DT_PLTPADSZ 0x6ffffdf9
+#define DT_MOVEENT 0x6ffffdfa
+#define DT_MOVESZ 0x6ffffdfb
+#define DT_FEATURE_1 0x6ffffdfc
+#define DT_POSFLAG_1 0x6ffffdfd
+
+#define DT_SYMINSZ 0x6ffffdfe
+#define DT_SYMINENT 0x6ffffdff
+#define DT_VALRNGHI 0x6ffffdff
+#define DT_VALTAGIDX(tag) (DT_VALRNGHI - (tag))
+#define DT_VALNUM 12
+
+#define DT_ADDRRNGLO 0x6ffffe00
+#define DT_GNU_HASH 0x6ffffef5
+#define DT_TLSDESC_PLT 0x6ffffef6
+#define DT_TLSDESC_GOT 0x6ffffef7
+#define DT_GNU_CONFLICT 0x6ffffef8
+#define DT_GNU_LIBLIST 0x6ffffef9
+#define DT_CONFIG 0x6ffffefa
+#define DT_DEPAUDIT 0x6ffffefb
+#define DT_AUDIT 0x6ffffefc
+#define DT_PLTPAD 0x6ffffefd
+#define DT_MOVETAB 0x6ffffefe
+#define DT_SYMINFO 0x6ffffeff
+#define DT_ADDRRNGHI 0x6ffffeff
+#define DT_ADDRTAGIDX(tag) (DT_ADDRRNGHI - (tag))
+#define DT_ADDRNUM 11
+
+
+
+#define DT_VERSYM 0x6ffffff0
+
+#define DT_RELACOUNT 0x6ffffff9
+#define DT_RELCOUNT 0x6ffffffa
+
+
+#define DT_FLAGS_1 0x6ffffffb
+#define DT_VERDEF 0x6ffffffc
+
+#define DT_VERDEFNUM 0x6ffffffd
+#define DT_VERNEED 0x6ffffffe
+
+#define DT_VERNEEDNUM 0x6fffffff
+#define DT_VERSIONTAGIDX(tag) (DT_VERNEEDNUM - (tag))
+#define DT_VERSIONTAGNUM 16
+
+
+
+#define DT_AUXILIARY 0x7ffffffd
+#define DT_FILTER 0x7fffffff
+#define DT_EXTRATAGIDX(tag) ((Elf32_Word)-((Elf32_Sword) (tag) <<1>>1)-1)
+#define DT_EXTRANUM 3
+
+
+#define DF_ORIGIN 0x00000001
+#define DF_SYMBOLIC 0x00000002
+#define DF_TEXTREL 0x00000004
+#define DF_BIND_NOW 0x00000008
+#define DF_STATIC_TLS 0x00000010
+
+
+
+#define DF_1_NOW 0x00000001
+#define DF_1_GLOBAL 0x00000002
+#define DF_1_GROUP 0x00000004
+#define DF_1_NODELETE 0x00000008
+#define DF_1_LOADFLTR 0x00000010
+#define DF_1_INITFIRST 0x00000020
+#define DF_1_NOOPEN 0x00000040
+#define DF_1_ORIGIN 0x00000080
+#define DF_1_DIRECT 0x00000100
+#define DF_1_TRANS 0x00000200
+#define DF_1_INTERPOSE 0x00000400
+#define DF_1_NODEFLIB 0x00000800
+#define DF_1_NODUMP 0x00001000
+#define DF_1_CONFALT 0x00002000
+#define DF_1_ENDFILTEE 0x00004000
+#define DF_1_DISPRELDNE 0x00008000
+#define DF_1_DISPRELPND 0x00010000
+
+
+#define DTF_1_PARINIT 0x00000001
+#define DTF_1_CONFEXP 0x00000002
+
+
+#define DF_P1_LAZYLOAD 0x00000001
+#define DF_P1_GROUPPERM 0x00000002
+
+
+
+
+typedef struct {
+ Elf32_Half vd_version;
+ Elf32_Half vd_flags;
+ Elf32_Half vd_ndx;
+ Elf32_Half vd_cnt;
+ Elf32_Word vd_hash;
+ Elf32_Word vd_aux;
+ Elf32_Word vd_next;
+} Elf32_Verdef;
+
+typedef struct {
+ Elf64_Half vd_version;
+ Elf64_Half vd_flags;
+ Elf64_Half vd_ndx;
+ Elf64_Half vd_cnt;
+ Elf64_Word vd_hash;
+ Elf64_Word vd_aux;
+ Elf64_Word vd_next;
+} Elf64_Verdef;
+
+
+
+#define VER_DEF_NONE 0
+#define VER_DEF_CURRENT 1
+#define VER_DEF_NUM 2
+
+
+#define VER_FLG_BASE 0x1
+#define VER_FLG_WEAK 0x2
+
+
+#define VER_NDX_LOCAL 0
+#define VER_NDX_GLOBAL 1
+#define VER_NDX_LORESERVE 0xff00
+#define VER_NDX_ELIMINATE 0xff01
+
+
+
+typedef struct {
+ Elf32_Word vda_name;
+ Elf32_Word vda_next;
+} Elf32_Verdaux;
+
+typedef struct {
+ Elf64_Word vda_name;
+ Elf64_Word vda_next;
+} Elf64_Verdaux;
+
+
+
+
+typedef struct {
+ Elf32_Half vn_version;
+ Elf32_Half vn_cnt;
+ Elf32_Word vn_file;
+ Elf32_Word vn_aux;
+ Elf32_Word vn_next;
+} Elf32_Verneed;
+
+typedef struct {
+ Elf64_Half vn_version;
+ Elf64_Half vn_cnt;
+ Elf64_Word vn_file;
+ Elf64_Word vn_aux;
+ Elf64_Word vn_next;
+} Elf64_Verneed;
+
+
+
+#define VER_NEED_NONE 0
+#define VER_NEED_CURRENT 1
+#define VER_NEED_NUM 2
+
+
+
+typedef struct {
+ Elf32_Word vna_hash;
+ Elf32_Half vna_flags;
+ Elf32_Half vna_other;
+ Elf32_Word vna_name;
+ Elf32_Word vna_next;
+} Elf32_Vernaux;
+
+typedef struct {
+ Elf64_Word vna_hash;
+ Elf64_Half vna_flags;
+ Elf64_Half vna_other;
+ Elf64_Word vna_name;
+ Elf64_Word vna_next;
+} Elf64_Vernaux;
+
+
+
+#define VER_FLG_WEAK 0x2
+
+
+
+typedef struct {
+ uint32_t a_type;
+ union {
+ uint32_t a_val;
+ } a_un;
+} Elf32_auxv_t;
+
+typedef struct {
+ uint64_t a_type;
+ union {
+ uint64_t a_val;
+ } a_un;
+} Elf64_auxv_t;
+
+
+
+#define AT_NULL 0
+#define AT_IGNORE 1
+#define AT_EXECFD 2
+#define AT_PHDR 3
+#define AT_PHENT 4
+#define AT_PHNUM 5
+#define AT_PAGESZ 6
+#define AT_BASE 7
+#define AT_FLAGS 8
+#define AT_ENTRY 9
+#define AT_NOTELF 10
+#define AT_UID 11
+#define AT_EUID 12
+#define AT_GID 13
+#define AT_EGID 14
+#define AT_CLKTCK 17
+
+
+#define AT_PLATFORM 15
+#define AT_HWCAP 16
+
+
+
+
+#define AT_FPUCW 18
+
+
+#define AT_DCACHEBSIZE 19
+#define AT_ICACHEBSIZE 20
+#define AT_UCACHEBSIZE 21
+
+
+
+#define AT_IGNOREPPC 22
+
+#define AT_SECURE 23
+
+#define AT_BASE_PLATFORM 24
+
+#define AT_RANDOM 25
+
+#define AT_EXECFN 31
+
+
+
+#define AT_SYSINFO 32
+#define AT_SYSINFO_EHDR 33
+
+
+
+#define AT_L1I_CACHESHAPE 34
+#define AT_L1D_CACHESHAPE 35
+#define AT_L2_CACHESHAPE 36
+#define AT_L3_CACHESHAPE 37
+
+
+
+
+typedef struct {
+ Elf32_Word n_namesz;
+ Elf32_Word n_descsz;
+ Elf32_Word n_type;
+} Elf32_Nhdr;
+
+typedef struct {
+ Elf64_Word n_namesz;
+ Elf64_Word n_descsz;
+ Elf64_Word n_type;
+} Elf64_Nhdr;
+
+
+
+
+#define ELF_NOTE_SOLARIS "SUNW Solaris"
+
+
+#define ELF_NOTE_GNU "GNU"
+
+
+
+
+
+#define ELF_NOTE_PAGESIZE_HINT 1
+
+
+#define NT_GNU_ABI_TAG 1
+#define ELF_NOTE_ABI NT_GNU_ABI_TAG
+
+
+
+#define ELF_NOTE_OS_LINUX 0
+#define ELF_NOTE_OS_GNU 1
+#define ELF_NOTE_OS_SOLARIS2 2
+#define ELF_NOTE_OS_FREEBSD 3
+
+#define NT_GNU_BUILD_ID 3
+#define NT_GNU_GOLD_VERSION 4
+
+
+
+typedef struct {
+ Elf32_Xword m_value;
+ Elf32_Word m_info;
+ Elf32_Word m_poffset;
+ Elf32_Half m_repeat;
+ Elf32_Half m_stride;
+} Elf32_Move;
+
+typedef struct {
+ Elf64_Xword m_value;
+ Elf64_Xword m_info;
+ Elf64_Xword m_poffset;
+ Elf64_Half m_repeat;
+ Elf64_Half m_stride;
+} Elf64_Move;
+
+
+#define ELF32_M_SYM(info) ((info) >> 8)
+#define ELF32_M_SIZE(info) ((unsigned char) (info))
+#define ELF32_M_INFO(sym, size) (((sym) << 8) + (unsigned char) (size))
+
+#define ELF64_M_SYM(info) ELF32_M_SYM (info)
+#define ELF64_M_SIZE(info) ELF32_M_SIZE (info)
+#define ELF64_M_INFO(sym, size) ELF32_M_INFO (sym, size)
+
+#define EF_CPU32 0x00810000
+
+#define R_68K_NONE 0
+#define R_68K_32 1
+#define R_68K_16 2
+#define R_68K_8 3
+#define R_68K_PC32 4
+#define R_68K_PC16 5
+#define R_68K_PC8 6
+#define R_68K_GOT32 7
+#define R_68K_GOT16 8
+#define R_68K_GOT8 9
+#define R_68K_GOT32O 10
+#define R_68K_GOT16O 11
+#define R_68K_GOT8O 12
+#define R_68K_PLT32 13
+#define R_68K_PLT16 14
+#define R_68K_PLT8 15
+#define R_68K_PLT32O 16
+#define R_68K_PLT16O 17
+#define R_68K_PLT8O 18
+#define R_68K_COPY 19
+#define R_68K_GLOB_DAT 20
+#define R_68K_JMP_SLOT 21
+#define R_68K_RELATIVE 22
+#define R_68K_NUM 23
+
+#define R_386_NONE 0
+#define R_386_32 1
+#define R_386_PC32 2
+#define R_386_GOT32 3
+#define R_386_PLT32 4
+#define R_386_COPY 5
+#define R_386_GLOB_DAT 6
+#define R_386_JMP_SLOT 7
+#define R_386_RELATIVE 8
+#define R_386_GOTOFF 9
+#define R_386_GOTPC 10
+#define R_386_32PLT 11
+#define R_386_TLS_TPOFF 14
+#define R_386_TLS_IE 15
+#define R_386_TLS_GOTIE 16
+#define R_386_TLS_LE 17
+#define R_386_TLS_GD 18
+#define R_386_TLS_LDM 19
+#define R_386_16 20
+#define R_386_PC16 21
+#define R_386_8 22
+#define R_386_PC8 23
+#define R_386_TLS_GD_32 24
+#define R_386_TLS_GD_PUSH 25
+#define R_386_TLS_GD_CALL 26
+#define R_386_TLS_GD_POP 27
+#define R_386_TLS_LDM_32 28
+#define R_386_TLS_LDM_PUSH 29
+#define R_386_TLS_LDM_CALL 30
+#define R_386_TLS_LDM_POP 31
+#define R_386_TLS_LDO_32 32
+#define R_386_TLS_IE_32 33
+#define R_386_TLS_LE_32 34
+#define R_386_TLS_DTPMOD32 35
+#define R_386_TLS_DTPOFF32 36
+#define R_386_TLS_TPOFF32 37
+#define R_386_TLS_GOTDESC 39
+#define R_386_TLS_DESC_CALL 40
+#define R_386_TLS_DESC 41
+#define R_386_IRELATIVE 42
+#define R_386_NUM 43
+
+
+
+
+
+#define STT_SPARC_REGISTER 13
+
+
+
+#define EF_SPARCV9_MM 3
+#define EF_SPARCV9_TSO 0
+#define EF_SPARCV9_PSO 1
+#define EF_SPARCV9_RMO 2
+#define EF_SPARC_LEDATA 0x800000
+#define EF_SPARC_EXT_MASK 0xFFFF00
+#define EF_SPARC_32PLUS 0x000100
+#define EF_SPARC_SUN_US1 0x000200
+#define EF_SPARC_HAL_R1 0x000400
+#define EF_SPARC_SUN_US3 0x000800
+
+
+
+#define R_SPARC_NONE 0
+#define R_SPARC_8 1
+#define R_SPARC_16 2
+#define R_SPARC_32 3
+#define R_SPARC_DISP8 4
+#define R_SPARC_DISP16 5
+#define R_SPARC_DISP32 6
+#define R_SPARC_WDISP30 7
+#define R_SPARC_WDISP22 8
+#define R_SPARC_HI22 9
+#define R_SPARC_22 10
+#define R_SPARC_13 11
+#define R_SPARC_LO10 12
+#define R_SPARC_GOT10 13
+#define R_SPARC_GOT13 14
+#define R_SPARC_GOT22 15
+#define R_SPARC_PC10 16
+#define R_SPARC_PC22 17
+#define R_SPARC_WPLT30 18
+#define R_SPARC_COPY 19
+#define R_SPARC_GLOB_DAT 20
+#define R_SPARC_JMP_SLOT 21
+#define R_SPARC_RELATIVE 22
+#define R_SPARC_UA32 23
+
+
+
+#define R_SPARC_PLT32 24
+#define R_SPARC_HIPLT22 25
+#define R_SPARC_LOPLT10 26
+#define R_SPARC_PCPLT32 27
+#define R_SPARC_PCPLT22 28
+#define R_SPARC_PCPLT10 29
+#define R_SPARC_10 30
+#define R_SPARC_11 31
+#define R_SPARC_64 32
+#define R_SPARC_OLO10 33
+#define R_SPARC_HH22 34
+#define R_SPARC_HM10 35
+#define R_SPARC_LM22 36
+#define R_SPARC_PC_HH22 37
+#define R_SPARC_PC_HM10 38
+#define R_SPARC_PC_LM22 39
+#define R_SPARC_WDISP16 40
+#define R_SPARC_WDISP19 41
+#define R_SPARC_GLOB_JMP 42
+#define R_SPARC_7 43
+#define R_SPARC_5 44
+#define R_SPARC_6 45
+#define R_SPARC_DISP64 46
+#define R_SPARC_PLT64 47
+#define R_SPARC_HIX22 48
+#define R_SPARC_LOX10 49
+#define R_SPARC_H44 50
+#define R_SPARC_M44 51
+#define R_SPARC_L44 52
+#define R_SPARC_REGISTER 53
+#define R_SPARC_UA64 54
+#define R_SPARC_UA16 55
+#define R_SPARC_TLS_GD_HI22 56
+#define R_SPARC_TLS_GD_LO10 57
+#define R_SPARC_TLS_GD_ADD 58
+#define R_SPARC_TLS_GD_CALL 59
+#define R_SPARC_TLS_LDM_HI22 60
+#define R_SPARC_TLS_LDM_LO10 61
+#define R_SPARC_TLS_LDM_ADD 62
+#define R_SPARC_TLS_LDM_CALL 63
+#define R_SPARC_TLS_LDO_HIX22 64
+#define R_SPARC_TLS_LDO_LOX10 65
+#define R_SPARC_TLS_LDO_ADD 66
+#define R_SPARC_TLS_IE_HI22 67
+#define R_SPARC_TLS_IE_LO10 68
+#define R_SPARC_TLS_IE_LD 69
+#define R_SPARC_TLS_IE_LDX 70
+#define R_SPARC_TLS_IE_ADD 71
+#define R_SPARC_TLS_LE_HIX22 72
+#define R_SPARC_TLS_LE_LOX10 73
+#define R_SPARC_TLS_DTPMOD32 74
+#define R_SPARC_TLS_DTPMOD64 75
+#define R_SPARC_TLS_DTPOFF32 76
+#define R_SPARC_TLS_DTPOFF64 77
+#define R_SPARC_TLS_TPOFF32 78
+#define R_SPARC_TLS_TPOFF64 79
+#define R_SPARC_GOTDATA_HIX22 80
+#define R_SPARC_GOTDATA_LOX10 81
+#define R_SPARC_GOTDATA_OP_HIX22 82
+#define R_SPARC_GOTDATA_OP_LOX10 83
+#define R_SPARC_GOTDATA_OP 84
+#define R_SPARC_H34 85
+#define R_SPARC_SIZE32 86
+#define R_SPARC_SIZE64 87
+#define R_SPARC_GNU_VTINHERIT 250
+#define R_SPARC_GNU_VTENTRY 251
+#define R_SPARC_REV32 252
+
+#define R_SPARC_NUM 253
+
+
+
+#define DT_SPARC_REGISTER 0x70000001
+#define DT_SPARC_NUM 2
+
+
+
+#define HWCAP_SPARC_FLUSH 1
+#define HWCAP_SPARC_STBAR 2
+#define HWCAP_SPARC_SWAP 4
+#define HWCAP_SPARC_MULDIV 8
+#define HWCAP_SPARC_V9 16
+#define HWCAP_SPARC_ULTRA3 32
+#define HWCAP_SPARC_BLKINIT 64
+#define HWCAP_SPARC_N2 128
+
+
+
+
+
+#define EF_MIPS_NOREORDER 1
+#define EF_MIPS_PIC 2
+#define EF_MIPS_CPIC 4
+#define EF_MIPS_XGOT 8
+#define EF_MIPS_64BIT_WHIRL 16
+#define EF_MIPS_ABI2 32
+#define EF_MIPS_ABI_ON32 64
+#define EF_MIPS_ARCH 0xf0000000
+
+
+
+#define EF_MIPS_ARCH_1 0x00000000
+#define EF_MIPS_ARCH_2 0x10000000
+#define EF_MIPS_ARCH_3 0x20000000
+#define EF_MIPS_ARCH_4 0x30000000
+#define EF_MIPS_ARCH_5 0x40000000
+#define EF_MIPS_ARCH_32 0x60000000
+#define EF_MIPS_ARCH_64 0x70000000
+
+
+
+#define E_MIPS_ARCH_1 0x00000000
+#define E_MIPS_ARCH_2 0x10000000
+#define E_MIPS_ARCH_3 0x20000000
+#define E_MIPS_ARCH_4 0x30000000
+#define E_MIPS_ARCH_5 0x40000000
+#define E_MIPS_ARCH_32 0x60000000
+#define E_MIPS_ARCH_64 0x70000000
+
+
+
+#define SHN_MIPS_ACOMMON 0xff00
+#define SHN_MIPS_TEXT 0xff01
+#define SHN_MIPS_DATA 0xff02
+#define SHN_MIPS_SCOMMON 0xff03
+#define SHN_MIPS_SUNDEFINED 0xff04
+
+
+
+#define SHT_MIPS_LIBLIST 0x70000000
+#define SHT_MIPS_MSYM 0x70000001
+#define SHT_MIPS_CONFLICT 0x70000002
+#define SHT_MIPS_GPTAB 0x70000003
+#define SHT_MIPS_UCODE 0x70000004
+#define SHT_MIPS_DEBUG 0x70000005
+#define SHT_MIPS_REGINFO 0x70000006
+#define SHT_MIPS_PACKAGE 0x70000007
+#define SHT_MIPS_PACKSYM 0x70000008
+#define SHT_MIPS_RELD 0x70000009
+#define SHT_MIPS_IFACE 0x7000000b
+#define SHT_MIPS_CONTENT 0x7000000c
+#define SHT_MIPS_OPTIONS 0x7000000d
+#define SHT_MIPS_SHDR 0x70000010
+#define SHT_MIPS_FDESC 0x70000011
+#define SHT_MIPS_EXTSYM 0x70000012
+#define SHT_MIPS_DENSE 0x70000013
+#define SHT_MIPS_PDESC 0x70000014
+#define SHT_MIPS_LOCSYM 0x70000015
+#define SHT_MIPS_AUXSYM 0x70000016
+#define SHT_MIPS_OPTSYM 0x70000017
+#define SHT_MIPS_LOCSTR 0x70000018
+#define SHT_MIPS_LINE 0x70000019
+#define SHT_MIPS_RFDESC 0x7000001a
+#define SHT_MIPS_DELTASYM 0x7000001b
+#define SHT_MIPS_DELTAINST 0x7000001c
+#define SHT_MIPS_DELTACLASS 0x7000001d
+#define SHT_MIPS_DWARF 0x7000001e
+#define SHT_MIPS_DELTADECL 0x7000001f
+#define SHT_MIPS_SYMBOL_LIB 0x70000020
+#define SHT_MIPS_EVENTS 0x70000021
+#define SHT_MIPS_TRANSLATE 0x70000022
+#define SHT_MIPS_PIXIE 0x70000023
+#define SHT_MIPS_XLATE 0x70000024
+#define SHT_MIPS_XLATE_DEBUG 0x70000025
+#define SHT_MIPS_WHIRL 0x70000026
+#define SHT_MIPS_EH_REGION 0x70000027
+#define SHT_MIPS_XLATE_OLD 0x70000028
+#define SHT_MIPS_PDR_EXCEPTION 0x70000029
+
+
+
+#define SHF_MIPS_GPREL 0x10000000
+#define SHF_MIPS_MERGE 0x20000000
+#define SHF_MIPS_ADDR 0x40000000
+#define SHF_MIPS_STRINGS 0x80000000
+#define SHF_MIPS_NOSTRIP 0x08000000
+#define SHF_MIPS_LOCAL 0x04000000
+#define SHF_MIPS_NAMES 0x02000000
+#define SHF_MIPS_NODUPE 0x01000000
+
+
+
+
+
+#define STO_MIPS_DEFAULT 0x0
+#define STO_MIPS_INTERNAL 0x1
+#define STO_MIPS_HIDDEN 0x2
+#define STO_MIPS_PROTECTED 0x3
+#define STO_MIPS_PLT 0x8
+#define STO_MIPS_SC_ALIGN_UNUSED 0xff
+
+
+#define STB_MIPS_SPLIT_COMMON 13
+
+
+
+typedef union {
+ struct {
+ Elf32_Word gt_current_g_value;
+ Elf32_Word gt_unused;
+ } gt_header;
+ struct {
+ Elf32_Word gt_g_value;
+ Elf32_Word gt_bytes;
+ } gt_entry;
+} Elf32_gptab;
+
+
+
+typedef struct {
+ Elf32_Word ri_gprmask;
+ Elf32_Word ri_cprmask[4];
+ Elf32_Sword ri_gp_value;
+} Elf32_RegInfo;
+
+
+
+typedef struct {
+ unsigned char kind;
+
+ unsigned char size;
+ Elf32_Section section;
+
+ Elf32_Word info;
+} Elf_Options;
+
+
+
+#define ODK_NULL 0
+#define ODK_REGINFO 1
+#define ODK_EXCEPTIONS 2
+#define ODK_PAD 3
+#define ODK_HWPATCH 4
+#define ODK_FILL 5
+#define ODK_TAGS 6
+#define ODK_HWAND 7
+#define ODK_HWOR 8
+
+
+
+#define OEX_FPU_MIN 0x1f
+#define OEX_FPU_MAX 0x1f00
+#define OEX_PAGE0 0x10000
+#define OEX_SMM 0x20000
+#define OEX_FPDBUG 0x40000
+#define OEX_PRECISEFP OEX_FPDBUG
+#define OEX_DISMISS 0x80000
+
+#define OEX_FPU_INVAL 0x10
+#define OEX_FPU_DIV0 0x08
+#define OEX_FPU_OFLO 0x04
+#define OEX_FPU_UFLO 0x02
+#define OEX_FPU_INEX 0x01
+
+
+
+#define OHW_R4KEOP 0x1
+#define OHW_R8KPFETCH 0x2
+#define OHW_R5KEOP 0x4
+#define OHW_R5KCVTL 0x8
+
+#define OPAD_PREFIX 0x1
+#define OPAD_POSTFIX 0x2
+#define OPAD_SYMBOL 0x4
+
+
+
+typedef struct {
+ Elf32_Word hwp_flags1;
+ Elf32_Word hwp_flags2;
+} Elf_Options_Hw;
+
+
+
+#define OHWA0_R4KEOP_CHECKED 0x00000001
+#define OHWA1_R4KEOP_CLEAN 0x00000002
+
+
+
+#define R_MIPS_NONE 0
+#define R_MIPS_16 1
+#define R_MIPS_32 2
+#define R_MIPS_REL32 3
+#define R_MIPS_26 4
+#define R_MIPS_HI16 5
+#define R_MIPS_LO16 6
+#define R_MIPS_GPREL16 7
+#define R_MIPS_LITERAL 8
+#define R_MIPS_GOT16 9
+#define R_MIPS_PC16 10
+#define R_MIPS_CALL16 11
+#define R_MIPS_GPREL32 12
+
+#define R_MIPS_SHIFT5 16
+#define R_MIPS_SHIFT6 17
+#define R_MIPS_64 18
+#define R_MIPS_GOT_DISP 19
+#define R_MIPS_GOT_PAGE 20
+#define R_MIPS_GOT_OFST 21
+#define R_MIPS_GOT_HI16 22
+#define R_MIPS_GOT_LO16 23
+#define R_MIPS_SUB 24
+#define R_MIPS_INSERT_A 25
+#define R_MIPS_INSERT_B 26
+#define R_MIPS_DELETE 27
+#define R_MIPS_HIGHER 28
+#define R_MIPS_HIGHEST 29
+#define R_MIPS_CALL_HI16 30
+#define R_MIPS_CALL_LO16 31
+#define R_MIPS_SCN_DISP 32
+#define R_MIPS_REL16 33
+#define R_MIPS_ADD_IMMEDIATE 34
+#define R_MIPS_PJUMP 35
+#define R_MIPS_RELGOT 36
+#define R_MIPS_JALR 37
+#define R_MIPS_TLS_DTPMOD32 38
+#define R_MIPS_TLS_DTPREL32 39
+#define R_MIPS_TLS_DTPMOD64 40
+#define R_MIPS_TLS_DTPREL64 41
+#define R_MIPS_TLS_GD 42
+#define R_MIPS_TLS_LDM 43
+#define R_MIPS_TLS_DTPREL_HI16 44
+#define R_MIPS_TLS_DTPREL_LO16 45
+#define R_MIPS_TLS_GOTTPREL 46
+#define R_MIPS_TLS_TPREL32 47
+#define R_MIPS_TLS_TPREL64 48
+#define R_MIPS_TLS_TPREL_HI16 49
+#define R_MIPS_TLS_TPREL_LO16 50
+#define R_MIPS_GLOB_DAT 51
+#define R_MIPS_COPY 126
+#define R_MIPS_JUMP_SLOT 127
+
+#define R_MIPS_NUM 128
+
+
+
+#define PT_MIPS_REGINFO 0x70000000
+#define PT_MIPS_RTPROC 0x70000001
+#define PT_MIPS_OPTIONS 0x70000002
+
+
+
+#define PF_MIPS_LOCAL 0x10000000
+
+
+
+#define DT_MIPS_RLD_VERSION 0x70000001
+#define DT_MIPS_TIME_STAMP 0x70000002
+#define DT_MIPS_ICHECKSUM 0x70000003
+#define DT_MIPS_IVERSION 0x70000004
+#define DT_MIPS_FLAGS 0x70000005
+#define DT_MIPS_BASE_ADDRESS 0x70000006
+#define DT_MIPS_MSYM 0x70000007
+#define DT_MIPS_CONFLICT 0x70000008
+#define DT_MIPS_LIBLIST 0x70000009
+#define DT_MIPS_LOCAL_GOTNO 0x7000000a
+#define DT_MIPS_CONFLICTNO 0x7000000b
+#define DT_MIPS_LIBLISTNO 0x70000010
+#define DT_MIPS_SYMTABNO 0x70000011
+#define DT_MIPS_UNREFEXTNO 0x70000012
+#define DT_MIPS_GOTSYM 0x70000013
+#define DT_MIPS_HIPAGENO 0x70000014
+#define DT_MIPS_RLD_MAP 0x70000016
+#define DT_MIPS_DELTA_CLASS 0x70000017
+#define DT_MIPS_DELTA_CLASS_NO 0x70000018
+
+#define DT_MIPS_DELTA_INSTANCE 0x70000019
+#define DT_MIPS_DELTA_INSTANCE_NO 0x7000001a
+
+#define DT_MIPS_DELTA_RELOC 0x7000001b
+#define DT_MIPS_DELTA_RELOC_NO 0x7000001c
+
+#define DT_MIPS_DELTA_SYM 0x7000001d
+
+#define DT_MIPS_DELTA_SYM_NO 0x7000001e
+
+#define DT_MIPS_DELTA_CLASSSYM 0x70000020
+
+#define DT_MIPS_DELTA_CLASSSYM_NO 0x70000021
+
+#define DT_MIPS_CXX_FLAGS 0x70000022
+#define DT_MIPS_PIXIE_INIT 0x70000023
+#define DT_MIPS_SYMBOL_LIB 0x70000024
+#define DT_MIPS_LOCALPAGE_GOTIDX 0x70000025
+#define DT_MIPS_LOCAL_GOTIDX 0x70000026
+#define DT_MIPS_HIDDEN_GOTIDX 0x70000027
+#define DT_MIPS_PROTECTED_GOTIDX 0x70000028
+#define DT_MIPS_OPTIONS 0x70000029
+#define DT_MIPS_INTERFACE 0x7000002a
+#define DT_MIPS_DYNSTR_ALIGN 0x7000002b
+#define DT_MIPS_INTERFACE_SIZE 0x7000002c
+#define DT_MIPS_RLD_TEXT_RESOLVE_ADDR 0x7000002d
+
+#define DT_MIPS_PERF_SUFFIX 0x7000002e
+
+#define DT_MIPS_COMPACT_SIZE 0x7000002f
+#define DT_MIPS_GP_VALUE 0x70000030
+#define DT_MIPS_AUX_DYNAMIC 0x70000031
+
+#define DT_MIPS_PLTGOT 0x70000032
+
+#define DT_MIPS_RWPLT 0x70000034
+#define DT_MIPS_NUM 0x35
+
+
+
+#define RHF_NONE 0
+#define RHF_QUICKSTART (1 << 0)
+#define RHF_NOTPOT (1 << 1)
+#define RHF_NO_LIBRARY_REPLACEMENT (1 << 2)
+#define RHF_NO_MOVE (1 << 3)
+#define RHF_SGI_ONLY (1 << 4)
+#define RHF_GUARANTEE_INIT (1 << 5)
+#define RHF_DELTA_C_PLUS_PLUS (1 << 6)
+#define RHF_GUARANTEE_START_INIT (1 << 7)
+#define RHF_PIXIE (1 << 8)
+#define RHF_DEFAULT_DELAY_LOAD (1 << 9)
+#define RHF_REQUICKSTART (1 << 10)
+#define RHF_REQUICKSTARTED (1 << 11)
+#define RHF_CORD (1 << 12)
+#define RHF_NO_UNRES_UNDEF (1 << 13)
+#define RHF_RLD_ORDER_SAFE (1 << 14)
+
+
+
+typedef struct
+{
+ Elf32_Word l_name;
+ Elf32_Word l_time_stamp;
+ Elf32_Word l_checksum;
+ Elf32_Word l_version;
+ Elf32_Word l_flags;
+} Elf32_Lib;
+
+typedef struct
+{
+ Elf64_Word l_name;
+ Elf64_Word l_time_stamp;
+ Elf64_Word l_checksum;
+ Elf64_Word l_version;
+ Elf64_Word l_flags;
+} Elf64_Lib;
+
+
+
+
+#define LL_NONE 0
+#define LL_EXACT_MATCH (1 << 0)
+#define LL_IGNORE_INT_VER (1 << 1)
+#define LL_REQUIRE_MINOR (1 << 2)
+#define LL_EXPORTS (1 << 3)
+#define LL_DELAY_LOAD (1 << 4)
+#define LL_DELTA (1 << 5)
+
+
+
+typedef Elf32_Addr Elf32_Conflict;
+
+
+
+
+
+
+#define EF_PARISC_TRAPNIL 0x00010000
+#define EF_PARISC_EXT 0x00020000
+#define EF_PARISC_LSB 0x00040000
+#define EF_PARISC_WIDE 0x00080000
+#define EF_PARISC_NO_KABP 0x00100000
+
+#define EF_PARISC_LAZYSWAP 0x00400000
+#define EF_PARISC_ARCH 0x0000ffff
+
+
+
+#define EFA_PARISC_1_0 0x020b
+#define EFA_PARISC_1_1 0x0210
+#define EFA_PARISC_2_0 0x0214
+
+
+
+#define SHN_PARISC_ANSI_COMMON 0xff00
+
+#define SHN_PARISC_HUGE_COMMON 0xff01
+
+
+
+#define SHT_PARISC_EXT 0x70000000
+#define SHT_PARISC_UNWIND 0x70000001
+#define SHT_PARISC_DOC 0x70000002
+
+
+
+#define SHF_PARISC_SHORT 0x20000000
+#define SHF_PARISC_HUGE 0x40000000
+#define SHF_PARISC_SBP 0x80000000
+
+
+
+#define STT_PARISC_MILLICODE 13
+
+#define STT_HP_OPAQUE (STT_LOOS + 0x1)
+#define STT_HP_STUB (STT_LOOS + 0x2)
+
+
+
+#define R_PARISC_NONE 0
+#define R_PARISC_DIR32 1
+#define R_PARISC_DIR21L 2
+#define R_PARISC_DIR17R 3
+#define R_PARISC_DIR17F 4
+#define R_PARISC_DIR14R 6
+#define R_PARISC_PCREL32 9
+#define R_PARISC_PCREL21L 10
+#define R_PARISC_PCREL17R 11
+#define R_PARISC_PCREL17F 12
+#define R_PARISC_PCREL14R 14
+#define R_PARISC_DPREL21L 18
+#define R_PARISC_DPREL14R 22
+#define R_PARISC_GPREL21L 26
+#define R_PARISC_GPREL14R 30
+#define R_PARISC_LTOFF21L 34
+#define R_PARISC_LTOFF14R 38
+#define R_PARISC_SECREL32 41
+#define R_PARISC_SEGBASE 48
+#define R_PARISC_SEGREL32 49
+#define R_PARISC_PLTOFF21L 50
+#define R_PARISC_PLTOFF14R 54
+#define R_PARISC_LTOFF_FPTR32 57
+#define R_PARISC_LTOFF_FPTR21L 58
+#define R_PARISC_LTOFF_FPTR14R 62
+#define R_PARISC_FPTR64 64
+#define R_PARISC_PLABEL32 65
+#define R_PARISC_PLABEL21L 66
+#define R_PARISC_PLABEL14R 70
+#define R_PARISC_PCREL64 72
+#define R_PARISC_PCREL22F 74
+#define R_PARISC_PCREL14WR 75
+#define R_PARISC_PCREL14DR 76
+#define R_PARISC_PCREL16F 77
+#define R_PARISC_PCREL16WF 78
+#define R_PARISC_PCREL16DF 79
+#define R_PARISC_DIR64 80
+#define R_PARISC_DIR14WR 83
+#define R_PARISC_DIR14DR 84
+#define R_PARISC_DIR16F 85
+#define R_PARISC_DIR16WF 86
+#define R_PARISC_DIR16DF 87
+#define R_PARISC_GPREL64 88
+#define R_PARISC_GPREL14WR 91
+#define R_PARISC_GPREL14DR 92
+#define R_PARISC_GPREL16F 93
+#define R_PARISC_GPREL16WF 94
+#define R_PARISC_GPREL16DF 95
+#define R_PARISC_LTOFF64 96
+#define R_PARISC_LTOFF14WR 99
+#define R_PARISC_LTOFF14DR 100
+#define R_PARISC_LTOFF16F 101
+#define R_PARISC_LTOFF16WF 102
+#define R_PARISC_LTOFF16DF 103
+#define R_PARISC_SECREL64 104
+#define R_PARISC_SEGREL64 112
+#define R_PARISC_PLTOFF14WR 115
+#define R_PARISC_PLTOFF14DR 116
+#define R_PARISC_PLTOFF16F 117
+#define R_PARISC_PLTOFF16WF 118
+#define R_PARISC_PLTOFF16DF 119
+#define R_PARISC_LTOFF_FPTR64 120
+#define R_PARISC_LTOFF_FPTR14WR 123
+#define R_PARISC_LTOFF_FPTR14DR 124
+#define R_PARISC_LTOFF_FPTR16F 125
+#define R_PARISC_LTOFF_FPTR16WF 126
+#define R_PARISC_LTOFF_FPTR16DF 127
+#define R_PARISC_LORESERVE 128
+#define R_PARISC_COPY 128
+#define R_PARISC_IPLT 129
+#define R_PARISC_EPLT 130
+#define R_PARISC_TPREL32 153
+#define R_PARISC_TPREL21L 154
+#define R_PARISC_TPREL14R 158
+#define R_PARISC_LTOFF_TP21L 162
+#define R_PARISC_LTOFF_TP14R 166
+#define R_PARISC_LTOFF_TP14F 167
+#define R_PARISC_TPREL64 216
+#define R_PARISC_TPREL14WR 219
+#define R_PARISC_TPREL14DR 220
+#define R_PARISC_TPREL16F 221
+#define R_PARISC_TPREL16WF 222
+#define R_PARISC_TPREL16DF 223
+#define R_PARISC_LTOFF_TP64 224
+#define R_PARISC_LTOFF_TP14WR 227
+#define R_PARISC_LTOFF_TP14DR 228
+#define R_PARISC_LTOFF_TP16F 229
+#define R_PARISC_LTOFF_TP16WF 230
+#define R_PARISC_LTOFF_TP16DF 231
+#define R_PARISC_GNU_VTENTRY 232
+#define R_PARISC_GNU_VTINHERIT 233
+#define R_PARISC_TLS_GD21L 234
+#define R_PARISC_TLS_GD14R 235
+#define R_PARISC_TLS_GDCALL 236
+#define R_PARISC_TLS_LDM21L 237
+#define R_PARISC_TLS_LDM14R 238
+#define R_PARISC_TLS_LDMCALL 239
+#define R_PARISC_TLS_LDO21L 240
+#define R_PARISC_TLS_LDO14R 241
+#define R_PARISC_TLS_DTPMOD32 242
+#define R_PARISC_TLS_DTPMOD64 243
+#define R_PARISC_TLS_DTPOFF32 244
+#define R_PARISC_TLS_DTPOFF64 245
+#define R_PARISC_TLS_LE21L R_PARISC_TPREL21L
+#define R_PARISC_TLS_LE14R R_PARISC_TPREL14R
+#define R_PARISC_TLS_IE21L R_PARISC_LTOFF_TP21L
+#define R_PARISC_TLS_IE14R R_PARISC_LTOFF_TP14R
+#define R_PARISC_TLS_TPREL32 R_PARISC_TPREL32
+#define R_PARISC_TLS_TPREL64 R_PARISC_TPREL64
+#define R_PARISC_HIRESERVE 255
+
+
+
+#define PT_HP_TLS (PT_LOOS + 0x0)
+#define PT_HP_CORE_NONE (PT_LOOS + 0x1)
+#define PT_HP_CORE_VERSION (PT_LOOS + 0x2)
+#define PT_HP_CORE_KERNEL (PT_LOOS + 0x3)
+#define PT_HP_CORE_COMM (PT_LOOS + 0x4)
+#define PT_HP_CORE_PROC (PT_LOOS + 0x5)
+#define PT_HP_CORE_LOADABLE (PT_LOOS + 0x6)
+#define PT_HP_CORE_STACK (PT_LOOS + 0x7)
+#define PT_HP_CORE_SHM (PT_LOOS + 0x8)
+#define PT_HP_CORE_MMF (PT_LOOS + 0x9)
+#define PT_HP_PARALLEL (PT_LOOS + 0x10)
+#define PT_HP_FASTBIND (PT_LOOS + 0x11)
+#define PT_HP_OPT_ANNOT (PT_LOOS + 0x12)
+#define PT_HP_HSL_ANNOT (PT_LOOS + 0x13)
+#define PT_HP_STACK (PT_LOOS + 0x14)
+
+#define PT_PARISC_ARCHEXT 0x70000000
+#define PT_PARISC_UNWIND 0x70000001
+
+
+
+#define PF_PARISC_SBP 0x08000000
+
+#define PF_HP_PAGE_SIZE 0x00100000
+#define PF_HP_FAR_SHARED 0x00200000
+#define PF_HP_NEAR_SHARED 0x00400000
+#define PF_HP_CODE 0x01000000
+#define PF_HP_MODIFY 0x02000000
+#define PF_HP_LAZYSWAP 0x04000000
+#define PF_HP_SBP 0x08000000
+
+
+
+
+
+
+#define EF_ALPHA_32BIT 1
+#define EF_ALPHA_CANRELAX 2
+
+
+
+
+#define SHT_ALPHA_DEBUG 0x70000001
+#define SHT_ALPHA_REGINFO 0x70000002
+
+
+
+#define SHF_ALPHA_GPREL 0x10000000
+
+
+#define STO_ALPHA_NOPV 0x80
+#define STO_ALPHA_STD_GPLOAD 0x88
+
+
+
+#define R_ALPHA_NONE 0
+#define R_ALPHA_REFLONG 1
+#define R_ALPHA_REFQUAD 2
+#define R_ALPHA_GPREL32 3
+#define R_ALPHA_LITERAL 4
+#define R_ALPHA_LITUSE 5
+#define R_ALPHA_GPDISP 6
+#define R_ALPHA_BRADDR 7
+#define R_ALPHA_HINT 8
+#define R_ALPHA_SREL16 9
+#define R_ALPHA_SREL32 10
+#define R_ALPHA_SREL64 11
+#define R_ALPHA_GPRELHIGH 17
+#define R_ALPHA_GPRELLOW 18
+#define R_ALPHA_GPREL16 19
+#define R_ALPHA_COPY 24
+#define R_ALPHA_GLOB_DAT 25
+#define R_ALPHA_JMP_SLOT 26
+#define R_ALPHA_RELATIVE 27
+#define R_ALPHA_TLS_GD_HI 28
+#define R_ALPHA_TLSGD 29
+#define R_ALPHA_TLS_LDM 30
+#define R_ALPHA_DTPMOD64 31
+#define R_ALPHA_GOTDTPREL 32
+#define R_ALPHA_DTPREL64 33
+#define R_ALPHA_DTPRELHI 34
+#define R_ALPHA_DTPRELLO 35
+#define R_ALPHA_DTPREL16 36
+#define R_ALPHA_GOTTPREL 37
+#define R_ALPHA_TPREL64 38
+#define R_ALPHA_TPRELHI 39
+#define R_ALPHA_TPRELLO 40
+#define R_ALPHA_TPREL16 41
+
+#define R_ALPHA_NUM 46
+
+
+#define LITUSE_ALPHA_ADDR 0
+#define LITUSE_ALPHA_BASE 1
+#define LITUSE_ALPHA_BYTOFF 2
+#define LITUSE_ALPHA_JSR 3
+#define LITUSE_ALPHA_TLS_GD 4
+#define LITUSE_ALPHA_TLS_LDM 5
+
+
+#define DT_ALPHA_PLTRO (DT_LOPROC + 0)
+#define DT_ALPHA_NUM 1
+
+
+
+
+#define EF_PPC_EMB 0x80000000
+
+
+#define EF_PPC_RELOCATABLE 0x00010000
+#define EF_PPC_RELOCATABLE_LIB 0x00008000
+
+
+
+#define R_PPC_NONE 0
+#define R_PPC_ADDR32 1
+#define R_PPC_ADDR24 2
+#define R_PPC_ADDR16 3
+#define R_PPC_ADDR16_LO 4
+#define R_PPC_ADDR16_HI 5
+#define R_PPC_ADDR16_HA 6
+#define R_PPC_ADDR14 7
+#define R_PPC_ADDR14_BRTAKEN 8
+#define R_PPC_ADDR14_BRNTAKEN 9
+#define R_PPC_REL24 10
+#define R_PPC_REL14 11
+#define R_PPC_REL14_BRTAKEN 12
+#define R_PPC_REL14_BRNTAKEN 13
+#define R_PPC_GOT16 14
+#define R_PPC_GOT16_LO 15
+#define R_PPC_GOT16_HI 16
+#define R_PPC_GOT16_HA 17
+#define R_PPC_PLTREL24 18
+#define R_PPC_COPY 19
+#define R_PPC_GLOB_DAT 20
+#define R_PPC_JMP_SLOT 21
+#define R_PPC_RELATIVE 22
+#define R_PPC_LOCAL24PC 23
+#define R_PPC_UADDR32 24
+#define R_PPC_UADDR16 25
+#define R_PPC_REL32 26
+#define R_PPC_PLT32 27
+#define R_PPC_PLTREL32 28
+#define R_PPC_PLT16_LO 29
+#define R_PPC_PLT16_HI 30
+#define R_PPC_PLT16_HA 31
+#define R_PPC_SDAREL16 32
+#define R_PPC_SECTOFF 33
+#define R_PPC_SECTOFF_LO 34
+#define R_PPC_SECTOFF_HI 35
+#define R_PPC_SECTOFF_HA 36
+
+
+#define R_PPC_TLS 67
+#define R_PPC_DTPMOD32 68
+#define R_PPC_TPREL16 69
+#define R_PPC_TPREL16_LO 70
+#define R_PPC_TPREL16_HI 71
+#define R_PPC_TPREL16_HA 72
+#define R_PPC_TPREL32 73
+#define R_PPC_DTPREL16 74
+#define R_PPC_DTPREL16_LO 75
+#define R_PPC_DTPREL16_HI 76
+#define R_PPC_DTPREL16_HA 77
+#define R_PPC_DTPREL32 78
+#define R_PPC_GOT_TLSGD16 79
+#define R_PPC_GOT_TLSGD16_LO 80
+#define R_PPC_GOT_TLSGD16_HI 81
+#define R_PPC_GOT_TLSGD16_HA 82
+#define R_PPC_GOT_TLSLD16 83
+#define R_PPC_GOT_TLSLD16_LO 84
+#define R_PPC_GOT_TLSLD16_HI 85
+#define R_PPC_GOT_TLSLD16_HA 86
+#define R_PPC_GOT_TPREL16 87
+#define R_PPC_GOT_TPREL16_LO 88
+#define R_PPC_GOT_TPREL16_HI 89
+#define R_PPC_GOT_TPREL16_HA 90
+#define R_PPC_GOT_DTPREL16 91
+#define R_PPC_GOT_DTPREL16_LO 92
+#define R_PPC_GOT_DTPREL16_HI 93
+#define R_PPC_GOT_DTPREL16_HA 94
+
+
+
+#define R_PPC_EMB_NADDR32 101
+#define R_PPC_EMB_NADDR16 102
+#define R_PPC_EMB_NADDR16_LO 103
+#define R_PPC_EMB_NADDR16_HI 104
+#define R_PPC_EMB_NADDR16_HA 105
+#define R_PPC_EMB_SDAI16 106
+#define R_PPC_EMB_SDA2I16 107
+#define R_PPC_EMB_SDA2REL 108
+#define R_PPC_EMB_SDA21 109
+#define R_PPC_EMB_MRKREF 110
+#define R_PPC_EMB_RELSEC16 111
+#define R_PPC_EMB_RELST_LO 112
+#define R_PPC_EMB_RELST_HI 113
+#define R_PPC_EMB_RELST_HA 114
+#define R_PPC_EMB_BIT_FLD 115
+#define R_PPC_EMB_RELSDA 116
+
+
+#define R_PPC_DIAB_SDA21_LO 180
+#define R_PPC_DIAB_SDA21_HI 181
+#define R_PPC_DIAB_SDA21_HA 182
+#define R_PPC_DIAB_RELSDA_LO 183
+#define R_PPC_DIAB_RELSDA_HI 184
+#define R_PPC_DIAB_RELSDA_HA 185
+
+
+#define R_PPC_IRELATIVE 248
+
+
+#define R_PPC_REL16 249
+#define R_PPC_REL16_LO 250
+#define R_PPC_REL16_HI 251
+#define R_PPC_REL16_HA 252
+
+
+
+#define R_PPC_TOC16 255
+
+
+#define DT_PPC_GOT (DT_LOPROC + 0)
+#define DT_PPC_NUM 1
+
+
+#define R_PPC64_NONE R_PPC_NONE
+#define R_PPC64_ADDR32 R_PPC_ADDR32
+#define R_PPC64_ADDR24 R_PPC_ADDR24
+#define R_PPC64_ADDR16 R_PPC_ADDR16
+#define R_PPC64_ADDR16_LO R_PPC_ADDR16_LO
+#define R_PPC64_ADDR16_HI R_PPC_ADDR16_HI
+#define R_PPC64_ADDR16_HA R_PPC_ADDR16_HA
+#define R_PPC64_ADDR14 R_PPC_ADDR14
+#define R_PPC64_ADDR14_BRTAKEN R_PPC_ADDR14_BRTAKEN
+#define R_PPC64_ADDR14_BRNTAKEN R_PPC_ADDR14_BRNTAKEN
+#define R_PPC64_REL24 R_PPC_REL24
+#define R_PPC64_REL14 R_PPC_REL14
+#define R_PPC64_REL14_BRTAKEN R_PPC_REL14_BRTAKEN
+#define R_PPC64_REL14_BRNTAKEN R_PPC_REL14_BRNTAKEN
+#define R_PPC64_GOT16 R_PPC_GOT16
+#define R_PPC64_GOT16_LO R_PPC_GOT16_LO
+#define R_PPC64_GOT16_HI R_PPC_GOT16_HI
+#define R_PPC64_GOT16_HA R_PPC_GOT16_HA
+
+#define R_PPC64_COPY R_PPC_COPY
+#define R_PPC64_GLOB_DAT R_PPC_GLOB_DAT
+#define R_PPC64_JMP_SLOT R_PPC_JMP_SLOT
+#define R_PPC64_RELATIVE R_PPC_RELATIVE
+
+#define R_PPC64_UADDR32 R_PPC_UADDR32
+#define R_PPC64_UADDR16 R_PPC_UADDR16
+#define R_PPC64_REL32 R_PPC_REL32
+#define R_PPC64_PLT32 R_PPC_PLT32
+#define R_PPC64_PLTREL32 R_PPC_PLTREL32
+#define R_PPC64_PLT16_LO R_PPC_PLT16_LO
+#define R_PPC64_PLT16_HI R_PPC_PLT16_HI
+#define R_PPC64_PLT16_HA R_PPC_PLT16_HA
+
+#define R_PPC64_SECTOFF R_PPC_SECTOFF
+#define R_PPC64_SECTOFF_LO R_PPC_SECTOFF_LO
+#define R_PPC64_SECTOFF_HI R_PPC_SECTOFF_HI
+#define R_PPC64_SECTOFF_HA R_PPC_SECTOFF_HA
+#define R_PPC64_ADDR30 37
+#define R_PPC64_ADDR64 38
+#define R_PPC64_ADDR16_HIGHER 39
+#define R_PPC64_ADDR16_HIGHERA 40
+#define R_PPC64_ADDR16_HIGHEST 41
+#define R_PPC64_ADDR16_HIGHESTA 42
+#define R_PPC64_UADDR64 43
+#define R_PPC64_REL64 44
+#define R_PPC64_PLT64 45
+#define R_PPC64_PLTREL64 46
+#define R_PPC64_TOC16 47
+#define R_PPC64_TOC16_LO 48
+#define R_PPC64_TOC16_HI 49
+#define R_PPC64_TOC16_HA 50
+#define R_PPC64_TOC 51
+#define R_PPC64_PLTGOT16 52
+#define R_PPC64_PLTGOT16_LO 53
+#define R_PPC64_PLTGOT16_HI 54
+#define R_PPC64_PLTGOT16_HA 55
+
+#define R_PPC64_ADDR16_DS 56
+#define R_PPC64_ADDR16_LO_DS 57
+#define R_PPC64_GOT16_DS 58
+#define R_PPC64_GOT16_LO_DS 59
+#define R_PPC64_PLT16_LO_DS 60
+#define R_PPC64_SECTOFF_DS 61
+#define R_PPC64_SECTOFF_LO_DS 62
+#define R_PPC64_TOC16_DS 63
+#define R_PPC64_TOC16_LO_DS 64
+#define R_PPC64_PLTGOT16_DS 65
+#define R_PPC64_PLTGOT16_LO_DS 66
+
+
+#define R_PPC64_TLS 67
+#define R_PPC64_DTPMOD64 68
+#define R_PPC64_TPREL16 69
+#define R_PPC64_TPREL16_LO 70
+#define R_PPC64_TPREL16_HI 71
+#define R_PPC64_TPREL16_HA 72
+#define R_PPC64_TPREL64 73
+#define R_PPC64_DTPREL16 74
+#define R_PPC64_DTPREL16_LO 75
+#define R_PPC64_DTPREL16_HI 76
+#define R_PPC64_DTPREL16_HA 77
+#define R_PPC64_DTPREL64 78
+#define R_PPC64_GOT_TLSGD16 79
+#define R_PPC64_GOT_TLSGD16_LO 80
+#define R_PPC64_GOT_TLSGD16_HI 81
+#define R_PPC64_GOT_TLSGD16_HA 82
+#define R_PPC64_GOT_TLSLD16 83
+#define R_PPC64_GOT_TLSLD16_LO 84
+#define R_PPC64_GOT_TLSLD16_HI 85
+#define R_PPC64_GOT_TLSLD16_HA 86
+#define R_PPC64_GOT_TPREL16_DS 87
+#define R_PPC64_GOT_TPREL16_LO_DS 88
+#define R_PPC64_GOT_TPREL16_HI 89
+#define R_PPC64_GOT_TPREL16_HA 90
+#define R_PPC64_GOT_DTPREL16_DS 91
+#define R_PPC64_GOT_DTPREL16_LO_DS 92
+#define R_PPC64_GOT_DTPREL16_HI 93
+#define R_PPC64_GOT_DTPREL16_HA 94
+#define R_PPC64_TPREL16_DS 95
+#define R_PPC64_TPREL16_LO_DS 96
+#define R_PPC64_TPREL16_HIGHER 97
+#define R_PPC64_TPREL16_HIGHERA 98
+#define R_PPC64_TPREL16_HIGHEST 99
+#define R_PPC64_TPREL16_HIGHESTA 100
+#define R_PPC64_DTPREL16_DS 101
+#define R_PPC64_DTPREL16_LO_DS 102
+#define R_PPC64_DTPREL16_HIGHER 103
+#define R_PPC64_DTPREL16_HIGHERA 104
+#define R_PPC64_DTPREL16_HIGHEST 105
+#define R_PPC64_DTPREL16_HIGHESTA 106
+
+
+#define R_PPC64_JMP_IREL 247
+#define R_PPC64_IRELATIVE 248
+#define R_PPC64_REL16 249
+#define R_PPC64_REL16_LO 250
+#define R_PPC64_REL16_HI 251
+#define R_PPC64_REL16_HA 252
+
+
+#define DT_PPC64_GLINK (DT_LOPROC + 0)
+#define DT_PPC64_OPD (DT_LOPROC + 1)
+#define DT_PPC64_OPDSZ (DT_LOPROC + 2)
+#define DT_PPC64_NUM 3
+
+
+
+
+
+#define EF_ARM_RELEXEC 0x01
+#define EF_ARM_HASENTRY 0x02
+#define EF_ARM_INTERWORK 0x04
+#define EF_ARM_APCS_26 0x08
+#define EF_ARM_APCS_FLOAT 0x10
+#define EF_ARM_PIC 0x20
+#define EF_ARM_ALIGN8 0x40
+#define EF_ARM_NEW_ABI 0x80
+#define EF_ARM_OLD_ABI 0x100
+#define EF_ARM_SOFT_FLOAT 0x200
+#define EF_ARM_VFP_FLOAT 0x400
+#define EF_ARM_MAVERICK_FLOAT 0x800
+
+
+
+
+#define EF_ARM_SYMSARESORTED 0x04
+#define EF_ARM_DYNSYMSUSESEGIDX 0x08
+#define EF_ARM_MAPSYMSFIRST 0x10
+#define EF_ARM_EABIMASK 0XFF000000
+
+
+#define EF_ARM_BE8 0x00800000
+#define EF_ARM_LE8 0x00400000
+
+#define EF_ARM_EABI_VERSION(flags) ((flags) & EF_ARM_EABIMASK)
+#define EF_ARM_EABI_UNKNOWN 0x00000000
+#define EF_ARM_EABI_VER1 0x01000000
+#define EF_ARM_EABI_VER2 0x02000000
+#define EF_ARM_EABI_VER3 0x03000000
+#define EF_ARM_EABI_VER4 0x04000000
+#define EF_ARM_EABI_VER5 0x05000000
+
+
+#define STT_ARM_TFUNC STT_LOPROC
+#define STT_ARM_16BIT STT_HIPROC
+
+
+#define SHF_ARM_ENTRYSECT 0x10000000
+#define SHF_ARM_COMDEF 0x80000000
+
+
+
+#define PF_ARM_SB 0x10000000
+
+#define PF_ARM_PI 0x20000000
+#define PF_ARM_ABS 0x40000000
+
+
+#define PT_ARM_EXIDX (PT_LOPROC + 1)
+
+
+#define SHT_ARM_EXIDX (SHT_LOPROC + 1)
+#define SHT_ARM_PREEMPTMAP (SHT_LOPROC + 2)
+#define SHT_ARM_ATTRIBUTES (SHT_LOPROC + 3)
+
+
+
+
+#define R_ARM_NONE 0
+#define R_ARM_PC24 1
+#define R_ARM_ABS32 2
+#define R_ARM_REL32 3
+#define R_ARM_PC13 4
+#define R_ARM_ABS16 5
+#define R_ARM_ABS12 6
+#define R_ARM_THM_ABS5 7
+#define R_ARM_ABS8 8
+#define R_ARM_SBREL32 9
+#define R_ARM_THM_PC22 10
+#define R_ARM_THM_PC8 11
+#define R_ARM_AMP_VCALL9 12
+#define R_ARM_SWI24 13
+#define R_ARM_THM_SWI8 14
+#define R_ARM_XPC25 15
+#define R_ARM_THM_XPC22 16
+#define R_ARM_TLS_DTPMOD32 17
+#define R_ARM_TLS_DTPOFF32 18
+#define R_ARM_TLS_TPOFF32 19
+#define R_ARM_COPY 20
+#define R_ARM_GLOB_DAT 21
+#define R_ARM_JUMP_SLOT 22
+#define R_ARM_RELATIVE 23
+#define R_ARM_GOTOFF 24
+#define R_ARM_GOTPC 25
+#define R_ARM_GOT32 26
+#define R_ARM_PLT32 27
+#define R_ARM_ALU_PCREL_7_0 32
+#define R_ARM_ALU_PCREL_15_8 33
+#define R_ARM_ALU_PCREL_23_15 34
+#define R_ARM_LDR_SBREL_11_0 35
+#define R_ARM_ALU_SBREL_19_12 36
+#define R_ARM_ALU_SBREL_27_20 37
+#define R_ARM_GNU_VTENTRY 100
+#define R_ARM_GNU_VTINHERIT 101
+#define R_ARM_THM_PC11 102
+#define R_ARM_THM_PC9 103
+#define R_ARM_TLS_GD32 104
+
+#define R_ARM_TLS_LDM32 105
+
+#define R_ARM_TLS_LDO32 106
+
+#define R_ARM_TLS_IE32 107
+
+#define R_ARM_TLS_LE32 108
+
+#define R_ARM_RXPC25 249
+#define R_ARM_RSBREL32 250
+#define R_ARM_THM_RPC22 251
+#define R_ARM_RREL32 252
+#define R_ARM_RABS22 253
+#define R_ARM_RPC24 254
+#define R_ARM_RBASE 255
+
+#define R_ARM_NUM 256
+
+
+
+
+#define EF_IA_64_MASKOS 0x0000000f
+#define EF_IA_64_ABI64 0x00000010
+#define EF_IA_64_ARCH 0xff000000
+
+
+#define PT_IA_64_ARCHEXT (PT_LOPROC + 0)
+#define PT_IA_64_UNWIND (PT_LOPROC + 1)
+#define PT_IA_64_HP_OPT_ANOT (PT_LOOS + 0x12)
+#define PT_IA_64_HP_HSL_ANOT (PT_LOOS + 0x13)
+#define PT_IA_64_HP_STACK (PT_LOOS + 0x14)
+
+
+#define PF_IA_64_NORECOV 0x80000000
+
+
+#define SHT_IA_64_EXT (SHT_LOPROC + 0)
+#define SHT_IA_64_UNWIND (SHT_LOPROC + 1)
+
+
+#define SHF_IA_64_SHORT 0x10000000
+#define SHF_IA_64_NORECOV 0x20000000
+
+
+#define DT_IA_64_PLT_RESERVE (DT_LOPROC + 0)
+#define DT_IA_64_NUM 1
+
+
+#define R_IA64_NONE 0x00
+#define R_IA64_IMM14 0x21
+#define R_IA64_IMM22 0x22
+#define R_IA64_IMM64 0x23
+#define R_IA64_DIR32MSB 0x24
+#define R_IA64_DIR32LSB 0x25
+#define R_IA64_DIR64MSB 0x26
+#define R_IA64_DIR64LSB 0x27
+#define R_IA64_GPREL22 0x2a
+#define R_IA64_GPREL64I 0x2b
+#define R_IA64_GPREL32MSB 0x2c
+#define R_IA64_GPREL32LSB 0x2d
+#define R_IA64_GPREL64MSB 0x2e
+#define R_IA64_GPREL64LSB 0x2f
+#define R_IA64_LTOFF22 0x32
+#define R_IA64_LTOFF64I 0x33
+#define R_IA64_PLTOFF22 0x3a
+#define R_IA64_PLTOFF64I 0x3b
+#define R_IA64_PLTOFF64MSB 0x3e
+#define R_IA64_PLTOFF64LSB 0x3f
+#define R_IA64_FPTR64I 0x43
+#define R_IA64_FPTR32MSB 0x44
+#define R_IA64_FPTR32LSB 0x45
+#define R_IA64_FPTR64MSB 0x46
+#define R_IA64_FPTR64LSB 0x47
+#define R_IA64_PCREL60B 0x48
+#define R_IA64_PCREL21B 0x49
+#define R_IA64_PCREL21M 0x4a
+#define R_IA64_PCREL21F 0x4b
+#define R_IA64_PCREL32MSB 0x4c
+#define R_IA64_PCREL32LSB 0x4d
+#define R_IA64_PCREL64MSB 0x4e
+#define R_IA64_PCREL64LSB 0x4f
+#define R_IA64_LTOFF_FPTR22 0x52
+#define R_IA64_LTOFF_FPTR64I 0x53
+#define R_IA64_LTOFF_FPTR32MSB 0x54
+#define R_IA64_LTOFF_FPTR32LSB 0x55
+#define R_IA64_LTOFF_FPTR64MSB 0x56
+#define R_IA64_LTOFF_FPTR64LSB 0x57
+#define R_IA64_SEGREL32MSB 0x5c
+#define R_IA64_SEGREL32LSB 0x5d
+#define R_IA64_SEGREL64MSB 0x5e
+#define R_IA64_SEGREL64LSB 0x5f
+#define R_IA64_SECREL32MSB 0x64
+#define R_IA64_SECREL32LSB 0x65
+#define R_IA64_SECREL64MSB 0x66
+#define R_IA64_SECREL64LSB 0x67
+#define R_IA64_REL32MSB 0x6c
+#define R_IA64_REL32LSB 0x6d
+#define R_IA64_REL64MSB 0x6e
+#define R_IA64_REL64LSB 0x6f
+#define R_IA64_LTV32MSB 0x74
+#define R_IA64_LTV32LSB 0x75
+#define R_IA64_LTV64MSB 0x76
+#define R_IA64_LTV64LSB 0x77
+#define R_IA64_PCREL21BI 0x79
+#define R_IA64_PCREL22 0x7a
+#define R_IA64_PCREL64I 0x7b
+#define R_IA64_IPLTMSB 0x80
+#define R_IA64_IPLTLSB 0x81
+#define R_IA64_COPY 0x84
+#define R_IA64_SUB 0x85
+#define R_IA64_LTOFF22X 0x86
+#define R_IA64_LDXMOV 0x87
+#define R_IA64_TPREL14 0x91
+#define R_IA64_TPREL22 0x92
+#define R_IA64_TPREL64I 0x93
+#define R_IA64_TPREL64MSB 0x96
+#define R_IA64_TPREL64LSB 0x97
+#define R_IA64_LTOFF_TPREL22 0x9a
+#define R_IA64_DTPMOD64MSB 0xa6
+#define R_IA64_DTPMOD64LSB 0xa7
+#define R_IA64_LTOFF_DTPMOD22 0xaa
+#define R_IA64_DTPREL14 0xb1
+#define R_IA64_DTPREL22 0xb2
+#define R_IA64_DTPREL64I 0xb3
+#define R_IA64_DTPREL32MSB 0xb4
+#define R_IA64_DTPREL32LSB 0xb5
+#define R_IA64_DTPREL64MSB 0xb6
+#define R_IA64_DTPREL64LSB 0xb7
+#define R_IA64_LTOFF_DTPREL22 0xba
+
+
+
+
+#define R_SH_NONE 0
+#define R_SH_DIR32 1
+#define R_SH_REL32 2
+#define R_SH_DIR8WPN 3
+#define R_SH_IND12W 4
+#define R_SH_DIR8WPL 5
+#define R_SH_DIR8WPZ 6
+#define R_SH_DIR8BP 7
+#define R_SH_DIR8W 8
+#define R_SH_DIR8L 9
+#define R_SH_SWITCH16 25
+#define R_SH_SWITCH32 26
+#define R_SH_USES 27
+#define R_SH_COUNT 28
+#define R_SH_ALIGN 29
+#define R_SH_CODE 30
+#define R_SH_DATA 31
+#define R_SH_LABEL 32
+#define R_SH_SWITCH8 33
+#define R_SH_GNU_VTINHERIT 34
+#define R_SH_GNU_VTENTRY 35
+#define R_SH_TLS_GD_32 144
+#define R_SH_TLS_LD_32 145
+#define R_SH_TLS_LDO_32 146
+#define R_SH_TLS_IE_32 147
+#define R_SH_TLS_LE_32 148
+#define R_SH_TLS_DTPMOD32 149
+#define R_SH_TLS_DTPOFF32 150
+#define R_SH_TLS_TPOFF32 151
+#define R_SH_GOT32 160
+#define R_SH_PLT32 161
+#define R_SH_COPY 162
+#define R_SH_GLOB_DAT 163
+#define R_SH_JMP_SLOT 164
+#define R_SH_RELATIVE 165
+#define R_SH_GOTOFF 166
+#define R_SH_GOTPC 167
+
+#define R_SH_NUM 256
+
+
+
+#define R_390_NONE 0
+#define R_390_8 1
+#define R_390_12 2
+#define R_390_16 3
+#define R_390_32 4
+#define R_390_PC32 5
+#define R_390_GOT12 6
+#define R_390_GOT32 7
+#define R_390_PLT32 8
+#define R_390_COPY 9
+#define R_390_GLOB_DAT 10
+#define R_390_JMP_SLOT 11
+#define R_390_RELATIVE 12
+#define R_390_GOTOFF32 13
+#define R_390_GOTPC 14
+#define R_390_GOT16 15
+#define R_390_PC16 16
+#define R_390_PC16DBL 17
+#define R_390_PLT16DBL 18
+#define R_390_PC32DBL 19
+#define R_390_PLT32DBL 20
+#define R_390_GOTPCDBL 21
+#define R_390_64 22
+#define R_390_PC64 23
+#define R_390_GOT64 24
+#define R_390_PLT64 25
+#define R_390_GOTENT 26
+#define R_390_GOTOFF16 27
+#define R_390_GOTOFF64 28
+#define R_390_GOTPLT12 29
+#define R_390_GOTPLT16 30
+#define R_390_GOTPLT32 31
+#define R_390_GOTPLT64 32
+#define R_390_GOTPLTENT 33
+#define R_390_PLTOFF16 34
+#define R_390_PLTOFF32 35
+#define R_390_PLTOFF64 36
+#define R_390_TLS_LOAD 37
+#define R_390_TLS_GDCALL 38
+
+#define R_390_TLS_LDCALL 39
+
+#define R_390_TLS_GD32 40
+
+#define R_390_TLS_GD64 41
+
+#define R_390_TLS_GOTIE12 42
+
+#define R_390_TLS_GOTIE32 43
+
+#define R_390_TLS_GOTIE64 44
+
+#define R_390_TLS_LDM32 45
+
+#define R_390_TLS_LDM64 46
+
+#define R_390_TLS_IE32 47
+
+#define R_390_TLS_IE64 48
+
+#define R_390_TLS_IEENT 49
+
+#define R_390_TLS_LE32 50
+
+#define R_390_TLS_LE64 51
+
+#define R_390_TLS_LDO32 52
+
+#define R_390_TLS_LDO64 53
+
+#define R_390_TLS_DTPMOD 54
+#define R_390_TLS_DTPOFF 55
+#define R_390_TLS_TPOFF 56
+
+#define R_390_20 57
+#define R_390_GOT20 58
+#define R_390_GOTPLT20 59
+#define R_390_TLS_GOTIE20 60
+
+
+#define R_390_NUM 61
+
+
+
+#define R_CRIS_NONE 0
+#define R_CRIS_8 1
+#define R_CRIS_16 2
+#define R_CRIS_32 3
+#define R_CRIS_8_PCREL 4
+#define R_CRIS_16_PCREL 5
+#define R_CRIS_32_PCREL 6
+#define R_CRIS_GNU_VTINHERIT 7
+#define R_CRIS_GNU_VTENTRY 8
+#define R_CRIS_COPY 9
+#define R_CRIS_GLOB_DAT 10
+#define R_CRIS_JUMP_SLOT 11
+#define R_CRIS_RELATIVE 12
+#define R_CRIS_16_GOT 13
+#define R_CRIS_32_GOT 14
+#define R_CRIS_16_GOTPLT 15
+#define R_CRIS_32_GOTPLT 16
+#define R_CRIS_32_GOTREL 17
+#define R_CRIS_32_PLT_GOTREL 18
+#define R_CRIS_32_PLT_PCREL 19
+
+#define R_CRIS_NUM 20
+
+
+
+#define R_X86_64_NONE 0
+#define R_X86_64_64 1
+#define R_X86_64_PC32 2
+#define R_X86_64_GOT32 3
+#define R_X86_64_PLT32 4
+#define R_X86_64_COPY 5
+#define R_X86_64_GLOB_DAT 6
+#define R_X86_64_JUMP_SLOT 7
+#define R_X86_64_RELATIVE 8
+#define R_X86_64_GOTPCREL 9
+
+#define R_X86_64_32 10
+#define R_X86_64_32S 11
+#define R_X86_64_16 12
+#define R_X86_64_PC16 13
+#define R_X86_64_8 14
+#define R_X86_64_PC8 15
+#define R_X86_64_DTPMOD64 16
+#define R_X86_64_DTPOFF64 17
+#define R_X86_64_TPOFF64 18
+#define R_X86_64_TLSGD 19
+
+#define R_X86_64_TLSLD 20
+
+#define R_X86_64_DTPOFF32 21
+#define R_X86_64_GOTTPOFF 22
+
+#define R_X86_64_TPOFF32 23
+#define R_X86_64_PC64 24
+#define R_X86_64_GOTOFF64 25
+#define R_X86_64_GOTPC32 26
+
+
+#define R_X86_64_GOTPC32_TLSDESC 34
+#define R_X86_64_TLSDESC_CALL 35
+
+#define R_X86_64_TLSDESC 36
+#define R_X86_64_IRELATIVE 37
+
+#define R_X86_64_NUM 38
+
+
+
+#define R_MN10300_NONE 0
+#define R_MN10300_32 1
+#define R_MN10300_16 2
+#define R_MN10300_8 3
+#define R_MN10300_PCREL32 4
+#define R_MN10300_PCREL16 5
+#define R_MN10300_PCREL8 6
+#define R_MN10300_GNU_VTINHERIT 7
+#define R_MN10300_GNU_VTENTRY 8
+#define R_MN10300_24 9
+#define R_MN10300_GOTPC32 10
+#define R_MN10300_GOTPC16 11
+#define R_MN10300_GOTOFF32 12
+#define R_MN10300_GOTOFF24 13
+#define R_MN10300_GOTOFF16 14
+#define R_MN10300_PLT32 15
+#define R_MN10300_PLT16 16
+#define R_MN10300_GOT32 17
+#define R_MN10300_GOT24 18
+#define R_MN10300_GOT16 19
+#define R_MN10300_COPY 20
+#define R_MN10300_GLOB_DAT 21
+#define R_MN10300_JMP_SLOT 22
+#define R_MN10300_RELATIVE 23
+
+#define R_MN10300_NUM 24
+
+
+
+#define R_M32R_NONE 0
+#define R_M32R_16 1
+#define R_M32R_32 2
+#define R_M32R_24 3
+#define R_M32R_10_PCREL 4
+#define R_M32R_18_PCREL 5
+#define R_M32R_26_PCREL 6
+#define R_M32R_HI16_ULO 7
+#define R_M32R_HI16_SLO 8
+#define R_M32R_LO16 9
+#define R_M32R_SDA16 10
+#define R_M32R_GNU_VTINHERIT 11
+#define R_M32R_GNU_VTENTRY 12
+
+#define R_M32R_16_RELA 33
+#define R_M32R_32_RELA 34
+#define R_M32R_24_RELA 35
+#define R_M32R_10_PCREL_RELA 36
+#define R_M32R_18_PCREL_RELA 37
+#define R_M32R_26_PCREL_RELA 38
+#define R_M32R_HI16_ULO_RELA 39
+#define R_M32R_HI16_SLO_RELA 40
+#define R_M32R_LO16_RELA 41
+#define R_M32R_SDA16_RELA 42
+#define R_M32R_RELA_GNU_VTINHERIT 43
+#define R_M32R_RELA_GNU_VTENTRY 44
+#define R_M32R_REL32 45
+
+#define R_M32R_GOT24 48
+#define R_M32R_26_PLTREL 49
+#define R_M32R_COPY 50
+#define R_M32R_GLOB_DAT 51
+#define R_M32R_JMP_SLOT 52
+#define R_M32R_RELATIVE 53
+#define R_M32R_GOTOFF 54
+#define R_M32R_GOTPC24 55
+#define R_M32R_GOT16_HI_ULO 56
+
+#define R_M32R_GOT16_HI_SLO 57
+
+#define R_M32R_GOT16_LO 58
+#define R_M32R_GOTPC_HI_ULO 59
+
+#define R_M32R_GOTPC_HI_SLO 60
+
+#define R_M32R_GOTPC_LO 61
+
+#define R_M32R_GOTOFF_HI_ULO 62
+
+#define R_M32R_GOTOFF_HI_SLO 63
+
+#define R_M32R_GOTOFF_LO 64
+#define R_M32R_NUM 256
+
+#define R_MICROBLAZE_NONE 0
+#define R_MICROBLAZE_32 1
+#define R_MICROBLAZE_32_PCREL 2
+#define R_MICROBLAZE_64_PCREL 3
+#define R_MICROBLAZE_32_PCREL_LO 4
+#define R_MICROBLAZE_64 5
+#define R_MICROBLAZE_32_LO 6
+#define R_MICROBLAZE_SRO32 7
+#define R_MICROBLAZE_SRW32 8
+#define R_MICROBLAZE_64_NONE 9
+#define R_MICROBLAZE_32_SYM_OP_SYM 10
+#define R_MICROBLAZE_GNU_VTINHERIT 11
+#define R_MICROBLAZE_GNU_VTENTRY 12
+#define R_MICROBLAZE_GOTPC_64 13
+#define R_MICROBLAZE_GOT_64 14
+#define R_MICROBLAZE_PLT_64 15
+#define R_MICROBLAZE_REL 16
+#define R_MICROBLAZE_JUMP_SLOT 17
+#define R_MICROBLAZE_GLOB_DAT 18
+#define R_MICROBLAZE_GOTOFF_64 19
+#define R_MICROBLAZE_GOTOFF_32 20
+#define R_MICROBLAZE_COPY 21
+#define R_MICROBLAZE_TLS 22
+#define R_MICROBLAZE_TLSGD 23
+#define R_MICROBLAZE_TLSLD 24
+#define R_MICROBLAZE_TLSDTPMOD32 25
+#define R_MICROBLAZE_TLSDTPREL32 26
+#define R_MICROBLAZE_TLSDTPREL64 27
+#define R_MICROBLAZE_TLSGOTTPREL32 28
+#define R_MICROBLAZE_TLSTPREL32 29
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif
diff --git a/system/include/libc/endian.h b/system/include/libc/endian.h
index e2ccbebb..1bd44451 100644
--- a/system/include/libc/endian.h
+++ b/system/include/libc/endian.h
@@ -1,3 +1,82 @@
+#ifndef _ENDIAN_H
+#define _ENDIAN_H
-#include "machine/endian.h"
+#include <features.h>
+#define __LITTLE_ENDIAN 1234
+#define __BIG_ENDIAN 4321
+#define __PDP_ENDIAN 3412
+
+#if defined(__GNUC__) && defined(__BYTE_ORDER__)
+#define __BYTE_ORDER __BYTE_ORDER__
+#else
+#include <bits/endian.h>
+#endif
+
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+
+#define BIG_ENDIAN __BIG_ENDIAN
+#define LITTLE_ENDIAN __LITTLE_ENDIAN
+#define PDP_ENDIAN __PDP_ENDIAN
+#define BYTE_ORDER __BYTE_ORDER
+
+#include <stdint.h>
+
+static __inline uint16_t __bswap16(uint16_t __x)
+{
+ return __x<<8 | __x>>8;
+}
+
+static __inline uint32_t __bswap32(uint32_t __x)
+{
+ return __x>>24 | __x>>8&0xff00 | __x<<8&0xff0000 | __x<<24;
+}
+
+static __inline uint64_t __bswap64(uint64_t __x)
+{
+ return __bswap32(__x)+0ULL<<32 | __bswap32(__x>>32);
+}
+
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+#define htobe16(x) __bswap16(x)
+#define be16toh(x) __bswap16(x)
+#define betoh16(x) __bswap16(x)
+#define htobe32(x) __bswap32(x)
+#define be32toh(x) __bswap32(x)
+#define betoh32(x) __bswap32(x)
+#define htobe64(x) __bswap64(x)
+#define be64toh(x) __bswap64(x)
+#define betoh64(x) __bswap64(x)
+#define htole16(x) (uint16_t)(x)
+#define le16toh(x) (uint16_t)(x)
+#define letoh16(x) (uint16_t)(x)
+#define htole32(x) (uint32_t)(x)
+#define le32toh(x) (uint32_t)(x)
+#define letoh32(x) (uint32_t)(x)
+#define htole64(x) (uint64_t)(x)
+#define le64toh(x) (uint64_t)(x)
+#define letoh64(x) (uint64_t)(x)
+#else
+#define htobe16(x) (uint16_t)(x)
+#define be16toh(x) (uint16_t)(x)
+#define betoh16(x) (uint16_t)(x)
+#define htobe32(x) (uint32_t)(x)
+#define be32toh(x) (uint32_t)(x)
+#define betoh32(x) (uint32_t)(x)
+#define htobe64(x) (uint64_t)(x)
+#define be64toh(x) (uint64_t)(x)
+#define betoh64(x) (uint64_t)(x)
+#define htole16(x) __bswap16(x)
+#define le16toh(x) __bswap16(x)
+#define letoh16(x) __bswap16(x)
+#define htole32(x) __bswap32(x)
+#define le32toh(x) __bswap32(x)
+#define letoh32(x) __bswap32(x)
+#define htole64(x) __bswap64(x)
+#define le64toh(x) __bswap64(x)
+#define letoh64(x) __bswap64(x)
+#endif
+
+#endif
+
+#endif
diff --git a/system/include/libc/envlock.h b/system/include/libc/envlock.h
deleted file mode 100644
index 9bb6a813..00000000
--- a/system/include/libc/envlock.h
+++ /dev/null
@@ -1,15 +0,0 @@
-/* envlock.h -- header file for env routines. */
-
-#ifndef _INCLUDE_ENVLOCK_H_
-#define _INCLUDE_ENVLOCK_H_
-
-#include <_ansi.h>
-#include <sys/reent.h>
-
-#define ENV_LOCK __env_lock(reent_ptr)
-#define ENV_UNLOCK __env_unlock(reent_ptr)
-
-void _EXFUN(__env_lock,(struct _reent *reent));
-void _EXFUN(__env_unlock,(struct _reent *reent));
-
-#endif /* _INCLUDE_ENVLOCK_H_ */
diff --git a/system/include/libc/envz.h b/system/include/libc/envz.h
deleted file mode 100644
index e6a31c31..00000000
--- a/system/include/libc/envz.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/* Copyright (C) 2002 by Red Hat, Incorporated. All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this software
- * is freely granted, provided that this notice is preserved.
- */
-
-#include <errno.h>
-#include <sys/types.h>
-
-/* The newlib implementation of these functions assumes that sizeof(char) == 1. */
-char * envz_entry (const char *envz, size_t envz_len, const char *name);
-char * envz_get (const char *envz, size_t envz_len, const char *name);
-error_t envz_add (char **envz, size_t *envz_len, const char *name, const char *value);
-error_t envz_merge (char **envz, size_t *envz_len, const char *envz2, size_t envz2_len, int override);
-void envz_remove(char **envz, size_t *envz_len, const char *name);
-void envz_strip (char **envz, size_t *envz_len);
diff --git a/system/include/libc/err.h b/system/include/libc/err.h
new file mode 100644
index 00000000..9f5cb6b9
--- /dev/null
+++ b/system/include/libc/err.h
@@ -0,0 +1,25 @@
+#ifndef _ERR_H
+#define _ERR_H
+
+#include <features.h>
+#include <stdarg.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void warn(const char *, ...);
+void vwarn(const char *, va_list);
+void warnx(const char *, ...);
+void vwarnx(const char *, va_list);
+
+_Noreturn void err(int, const char *, ...);
+_Noreturn void verr(int, const char *, va_list);
+_Noreturn void errx(int, const char *, ...);
+_Noreturn void verrx(int, const char *, va_list);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/errno.h b/system/include/libc/errno.h
index 7cc2ca86..0361b33a 100644
--- a/system/include/libc/errno.h
+++ b/system/include/libc/errno.h
@@ -1,11 +1,27 @@
-#ifndef __ERRNO_H__
-#define __ERRNO_H__
+#ifndef _ERRNO_H
+#define _ERRNO_H
-#ifndef __error_t_defined
-typedef int error_t;
-#define __error_t_defined 1
+#ifdef __cplusplus
+extern "C" {
#endif
-#include <sys/errno.h>
+#include <features.h>
+
+#include <bits/errno.h>
+
+#ifdef __GNUC__
+__attribute__((const))
+#endif
+int *__errno_location(void);
+#define errno (*__errno_location())
+
+#ifdef _GNU_SOURCE
+extern char *program_invocation_short_name, *program_invocation_name;
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
-#endif /* !__ERRNO_H__ */
diff --git a/system/include/libc/fastmath.h b/system/include/libc/fastmath.h
deleted file mode 100644
index 95eea5f3..00000000
--- a/system/include/libc/fastmath.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef _FASTMATH_H_
-#ifdef __cplusplus
-extern "C" {
-#endif
-#define _FASTMATH_H_
-
-#include <math.h>
-#include <machine/fastmath.h>
-
-#ifdef __cplusplus
-}
-#endif
-#endif /* _FASTMATH_H_ */
diff --git a/system/include/libc/fcntl.h b/system/include/libc/fcntl.h
index 86a91677..b9bc2695 100644
--- a/system/include/libc/fcntl.h
+++ b/system/include/libc/fcntl.h
@@ -1 +1,175 @@
-#include <sys/fcntl.h>
+#ifndef _FCNTL_H
+#define _FCNTL_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <features.h>
+
+#define __NEED_off_t
+#define __NEED_pid_t
+#define __NEED_mode_t
+
+#ifdef _GNU_SOURCE
+#define __NEED_size_t
+#define __NEED_ssize_t
+#define __NEED_struct_iovec
+#endif
+
+#include <bits/alltypes.h>
+
+#include <bits/fcntl.h>
+
+struct flock
+{
+ short l_type;
+ short l_whence;
+ off_t l_start;
+ off_t l_len;
+ pid_t l_pid;
+};
+
+int creat(const char *, mode_t);
+int fcntl(int, int, ...);
+int open(const char *, int, ...);
+int openat(int, const char *, int, ...);
+int posix_fadvise(int, off_t, off_t, int);
+int posix_fallocate(int, off_t, off_t);
+
+#define O_SEARCH 010000000
+#define O_EXEC 010000000
+#define O_PATH 010000000
+
+#define O_ACCMODE (03|O_SEARCH)
+#define O_RDONLY 00
+#define O_WRONLY 01
+#define O_RDWR 02
+
+#define F_DUPFD_CLOEXEC 1030
+
+#define F_RDLCK 0
+#define F_WRLCK 1
+#define F_UNLCK 2
+
+#define FD_CLOEXEC 1
+
+#define AT_FDCWD (-100)
+#define AT_SYMLINK_NOFOLLOW 0x100
+#define AT_REMOVEDIR 0x200
+#define AT_SYMLINK_FOLLOW 0x400
+#define AT_EACCESS 0x200
+#define AT_NO_AUTOMOUNT 0x800
+#define AT_EMPTY_PATH 0x1000
+
+#define POSIX_FADV_NORMAL 0
+#define POSIX_FADV_RANDOM 1
+#define POSIX_FADV_SEQUENTIAL 2
+#define POSIX_FADV_WILLNEED 3
+#define POSIX_FADV_DONTNEED 4
+#define POSIX_FADV_NOREUSE 5
+
+#undef SEEK_SET
+#undef SEEK_CUR
+#undef SEEK_END
+#define SEEK_SET 0
+#define SEEK_CUR 1
+#define SEEK_END 2
+
+#ifndef S_IRUSR
+#define S_ISUID 04000
+#define S_ISGID 02000
+#define S_ISVTX 01000
+#define S_IRUSR 0400
+#define S_IWUSR 0200
+#define S_IXUSR 0100
+#define S_IRWXU 0700
+#define S_IRGRP 0040
+#define S_IWGRP 0020
+#define S_IXGRP 0010
+#define S_IRWXG 0070
+#define S_IROTH 0004
+#define S_IWOTH 0002
+#define S_IXOTH 0001
+#define S_IRWXO 0007
+#endif
+
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+#define FAPPEND O_APPEND
+#define FFSYNC O_FSYNC
+#define FASYNC O_ASYNC
+#define FNONBLOCK O_NONBLOCK
+#define FNDELAY O_NDELAY
+
+#define F_OK 0
+#define R_OK 4
+#define W_OK 2
+#define X_OK 1
+#define F_ULOCK 0
+#define F_LOCK 1
+#define F_TLOCK 2
+#define F_TEST 3
+
+#define F_SETLEASE 1024
+#define F_GETLEASE 1025
+#define F_NOTIFY 1026
+#define F_CANCELLK 1029
+#define F_SETPIPE_SZ 1031
+#define F_GETPIPE_SZ 1032
+
+#define DN_ACCESS 0x00000001
+#define DN_MODIFY 0x00000002
+#define DN_CREATE 0x00000004
+#define DN_DELETE 0x00000008
+#define DN_RENAME 0x00000010
+#define DN_ATTRIB 0x00000020
+#define DN_MULTISHOT 0x80000000
+
+int lockf(int, int, off_t);
+#endif
+
+#if defined(_GNU_SOURCE)
+#define F_OWNER_TID 0
+#define F_OWNER_PID 1
+#define F_OWNER_PGRP 2
+#define F_OWNER_GID 2
+struct f_owner_ex {
+ int type;
+ pid_t pid;
+};
+#define FALLOC_FL_KEEP_SIZE 1
+#define FALLOC_FL_PUNCH_HOLE 2
+#define SYNC_FILE_RANGE_WAIT_BEFORE 1
+#define SYNC_FILE_RANGE_WRITE 2
+#define SYNC_FILE_RANGE_WAIT_AFTER 4
+#define SPLICE_F_MOVE 1
+#define SPLICE_F_NONBLOCK 2
+#define SPLICE_F_MORE 4
+#define SPLICE_F_GIFT 8
+int fallocate(int, int, off_t, off_t);
+ssize_t readahead(int, off_t, size_t);
+int sync_file_range(int, off_t, off_t, unsigned);
+ssize_t vmsplice(int, const struct iovec *, size_t, unsigned);
+ssize_t splice(int, off_t *, int, off_t *, size_t, unsigned);
+ssize_t tee(int, int, size_t, unsigned);
+#define loff_t off_t
+#endif
+
+#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
+#define F_GETLK64 F_GETLK
+#define F_SETLK64 F_SETLK
+#define F_SETLKW64 F_SETLKW
+#define open64 open
+#define openat64 openat
+#define creat64 creat
+#define lockf64 lockf
+#define posix_fadvise64 posix_fadvise
+#define posix_fallocate64 posix_fallocate
+#define off64_t off_t
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/features.h b/system/include/libc/features.h
new file mode 100644
index 00000000..294c61dd
--- /dev/null
+++ b/system/include/libc/features.h
@@ -0,0 +1,32 @@
+#ifndef _FEATURES_H
+#define _FEATURES_H
+
+#ifdef _ALL_SOURCE
+#define _GNU_SOURCE 1
+#endif
+
+#if !defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE) \
+ && !defined(_XOPEN_SOURCE) && !defined(_GNU_SOURCE) \
+ && !defined(_BSD_SOURCE) && !defined(__STRICT_ANSI__)
+#define _BSD_SOURCE 1
+#define _XOPEN_SOURCE 700
+#endif
+
+#if __STDC_VERSION__ >= 199901L
+#define __restrict restrict
+#elif !defined(__GNUC__)
+#define __restrict
+#endif
+
+#if __STDC_VERSION__ >= 199901L || defined(__cplusplus)
+#define __inline inline
+#endif
+
+#if __STDC_VERSION__ >= 201112L
+#elif defined(__GNUC__)
+#define _Noreturn __attribute__((__noreturn__))
+#else
+#define _Noreturn
+#endif
+
+#endif
diff --git a/system/include/libc/fenv.h b/system/include/libc/fenv.h
new file mode 100644
index 00000000..05de990c
--- /dev/null
+++ b/system/include/libc/fenv.h
@@ -0,0 +1,28 @@
+#ifndef _FENV_H
+#define _FENV_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <bits/fenv.h>
+
+int feclearexcept(int);
+int fegetexceptflag(fexcept_t *, int);
+int feraiseexcept(int);
+int fesetexceptflag(const fexcept_t *, int);
+int fetestexcept(int);
+
+int fegetround(void);
+int fesetround(int);
+
+int fegetenv(fenv_t *);
+int feholdexcept(fenv_t *);
+int fesetenv(const fenv_t *);
+int feupdateenv(const fenv_t *);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
+
diff --git a/system/include/libc/float.h b/system/include/libc/float.h
new file mode 100644
index 00000000..c7b208af
--- /dev/null
+++ b/system/include/libc/float.h
@@ -0,0 +1,34 @@
+#ifndef _FLOAT_H
+#define _FLOAT_H
+
+#define FLT_RADIX 2
+
+#define FLT_TRUE_MIN 1.40129846e-45F
+#define FLT_MIN 1.17549435e-38F
+#define FLT_MAX 3.40282347e+38F
+#define FLT_EPSILON 1.19209290e-07F
+
+#define FLT_MANT_DIG 24
+#define FLT_MIN_EXP (-125)
+#define FLT_MAX_EXP 128
+
+#define FLT_DIG 6
+#define FLT_MIN_10_EXP (-37)
+#define FLT_MAX_10_EXP 38
+
+#define DBL_TRUE_MIN 4.9406564584124654e-324
+#define DBL_MIN 2.2250738585072014e-308
+#define DBL_MAX 1.7976931348623157e+308
+#define DBL_EPSILON 2.2204460492503131e-16
+
+#define DBL_MANT_DIG 53
+#define DBL_MIN_EXP (-1021)
+#define DBL_MAX_EXP 1024
+
+#define DBL_DIG 15
+#define DBL_MIN_10_EXP (-307)
+#define DBL_MAX_10_EXP 308
+
+#include <bits/float.h>
+
+#endif
diff --git a/system/include/libc/fnmatch.h b/system/include/libc/fnmatch.h
index 06311fc4..72345b8b 100644
--- a/system/include/libc/fnmatch.h
+++ b/system/include/libc/fnmatch.h
@@ -1,55 +1,29 @@
-/*-
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD: src/include/fnmatch.h,v 1.10 2002/03/23 17:24:53 imp Exp $
- * @(#)fnmatch.h 8.1 (Berkeley) 6/2/93
- */
-
-#ifndef _FNMATCH_H_
-#define _FNMATCH_H_
-
-#define FNM_NOMATCH 1 /* Match failed. */
-
-#define FNM_NOESCAPE 0x01 /* Disable backslash escaping. */
-#define FNM_PATHNAME 0x02 /* Slash must be matched by slash. */
-#define FNM_PERIOD 0x04 /* Period must be matched by period. */
-
-#if defined(_GNU_SOURCE) || !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
-#define FNM_LEADING_DIR 0x08 /* Ignore /<tail> after Imatch. */
-#define FNM_CASEFOLD 0x10 /* Case insensitive search. */
-#define FNM_IGNORECASE FNM_CASEFOLD
+#ifndef _FNMATCH_H
+#define _FNMATCH_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <features.h>
+
+#define FNM_PATHNAME 0x1
+#define FNM_NOESCAPE 0x2
+#define FNM_PERIOD 0x4
+
+#ifdef _GNU_SOURCE
+#define FNM_LEADING_DIR 0x8
+#define FNM_CASEFOLD 0x10
#define FNM_FILE_NAME FNM_PATHNAME
#endif
-#include <sys/cdefs.h>
+#define FNM_NOMATCH 1
+#define FNM_NOSYS (-1)
+
+int fnmatch(const char *, const char *, int);
-__BEGIN_DECLS
-int fnmatch(const char *, const char *, int);
-__END_DECLS
+#ifdef __cplusplus
+}
+#endif
-#endif /* !_FNMATCH_H_ */
+#endif
diff --git a/system/include/libc/ftw.h b/system/include/libc/ftw.h
new file mode 100644
index 00000000..c8eadbc9
--- /dev/null
+++ b/system/include/libc/ftw.h
@@ -0,0 +1,42 @@
+#ifndef _FTW_H
+#define _FTW_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <features.h>
+#include <sys/stat.h>
+
+#define FTW_F 1
+#define FTW_D 2
+#define FTW_DNR 3
+#define FTW_NS 4
+#define FTW_SL 5
+#define FTW_DP 6
+#define FTW_SLN 7
+
+#define FTW_PHYS 1
+#define FTW_MOUNT 2
+#define FTW_CHDIR 4
+#define FTW_DEPTH 8
+
+struct FTW
+{
+ int base;
+ int level;
+};
+
+int ftw(const char *, int (*)(const char *, const struct stat *, int), int);
+int nftw(const char *, int (*)(const char *, const struct stat *, int, struct FTW *), int, int);
+
+#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
+#define ftw64 ftw
+#define nftw64 nftw
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/getopt.h b/system/include/libc/getopt.h
index dd21deb6..c1d0df92 100644
--- a/system/include/libc/getopt.h
+++ b/system/include/libc/getopt.h
@@ -1,196 +1,31 @@
-/****************************************************************************
-
-getopt.h - Read command line options
-
-AUTHOR: Gregory Pietsch
-CREATED Thu Jan 09 22:37:00 1997
-
-DESCRIPTION:
-
-The getopt() function parses the command line arguments. Its arguments argc
-and argv are the argument count and array as passed to the main() function
-on program invocation. The argument optstring is a list of available option
-characters. If such a character is followed by a colon (`:'), the option
-takes an argument, which is placed in optarg. If such a character is
-followed by two colons, the option takes an optional argument, which is
-placed in optarg. If the option does not take an argument, optarg is NULL.
-
-The external variable optind is the index of the next array element of argv
-to be processed; it communicates from one call to the next which element to
-process.
-
-The getopt_long() function works like getopt() except that it also accepts
-long options started by two dashes `--'. If these take values, it is either
-in the form
-
---arg=value
-
- or
-
---arg value
-
-It takes the additional arguments longopts which is a pointer to the first
-element of an array of type GETOPT_LONG_OPTION_T, defined below. The last
-element of the array has to be filled with NULL for the name field.
-
-The longind pointer points to the index of the current long option relative
-to longopts if it is non-NULL.
-
-The getopt() function returns the option character if the option was found
-successfully, `:' if there was a missing parameter for one of the options,
-`?' for an unknown option character, and EOF for the end of the option list.
-
-The getopt_long() function's return value is described below.
-
-The function getopt_long_only() is identical to getopt_long(), except that a
-plus sign `+' can introduce long options as well as `--'.
-
-Describe how to deal with options that follow non-option ARGV-elements.
-
-If the caller did not specify anything, the default is REQUIRE_ORDER if the
-environment variable POSIXLY_CORRECT is defined, PERMUTE otherwise.
-
-REQUIRE_ORDER means don't recognize them as options; stop option processing
-when the first non-option is seen. This is what Unix does. This mode of
-operation is selected by either setting the environment variable
-POSIXLY_CORRECT, or using `+' as the first character of the optstring
-parameter.
-
-PERMUTE is the default. We permute the contents of ARGV as we scan, so that
-eventually all the non-options are at the end. This allows options to be
-given in any order, even with programs that were not written to expect this.
-
-RETURN_IN_ORDER is an option available to programs that were written to
-expect options and other ARGV-elements in any order and that care about the
-ordering of the two. We describe each non-option ARGV-element as if it were
-the argument of an option with character code 1. Using `-' as the first
-character of the optstring parameter selects this mode of operation.
-
-The special argument `--' forces an end of option-scanning regardless of the
-value of `ordering'. In the case of RETURN_IN_ORDER, only `--' can cause
-getopt() and friends to return EOF with optind != argc.
-
-COPYRIGHT NOTICE AND DISCLAIMER:
-
-Copyright (C) 1997 Gregory Pietsch
-
-This file and the accompanying getopt.c implementation file are hereby
-placed in the public domain without restrictions. Just give the author
-credit, don't claim you wrote it or prevent anyone else from using it.
-
-Gregory Pietsch's current e-mail address:
-gpietsch@comcast.net
-****************************************************************************/
-
-/* This is a glibc-extension header file. */
-
-#ifndef GETOPT_H
-#define GETOPT_H
-
-#include <_ansi.h>
-
-/* include files needed by this include file */
-
-#define no_argument 0
-#define required_argument 1
-#define optional_argument 2
+#ifndef _GETOPT_H
+#define _GETOPT_H
#ifdef __cplusplus
-extern "C"
-{
-
-#endif /* __cplusplus */
-
-/* types defined by this include file */
- struct option
- {
- char *name; /* the name of the long option */
- int has_arg; /* one of the above macros */
- int *flag; /* determines if getopt_long() returns a
- * value for a long option; if it is
- * non-NULL, 0 is returned as a function
- * value and the value of val is stored in
- * the area pointed to by flag. Otherwise,
- * val is returned. */
- int val; /* determines the value to return if flag is
- * NULL. */
-
- };
-
- /* XXX Emscripten */
- #define NO_ARG 0
- #define REQ_ARG 1
- #define OPT_ARG 2
- typedef struct option option_t;
-
-/* While getopt.h is a glibc extension, the following are newlib extensions.
- * They are optionally included via the __need_getopt_newlib flag. */
-
-#ifdef __need_getopt_newlib
-
- /* macros defined by this include file */
- #define NO_ARG no_argument
- #define REQUIRED_ARG required_argument
- #define OPTIONAL_ARG optional_argument
+extern "C" {
+#endif
- /* The GETOPT_DATA_INITIALIZER macro is used to initialize a statically-
- allocated variable of type struct getopt_data. */
- #define GETOPT_DATA_INITIALIZER {0,0,0,0,0}
+int getopt(int, char * const [], const char *);
+extern char *optarg;
+extern int optind, opterr, optopt, optreset;
- /* These #defines are to make accessing the reentrant functions easier. */
- #define getopt_r __getopt_r
- #define getopt_long_r __getopt_long_r
- #define getopt_long_only_r __getopt_long_only_r
-
- /* The getopt_data structure is for reentrancy. Its members are similar to
- the externally-defined variables. */
- typedef struct getopt_data
- {
- char *optarg;
- int optind, opterr, optopt, optwhere;
- } getopt_data;
-
-#endif /* __need_getopt_newlib */
-
- /* externally-defined variables */
- extern char *optarg;
- extern int optind;
- extern int opterr;
- extern int optopt;
-
- /* function prototypes */
- int _EXFUN (getopt,
- (int __argc, char *const __argv[], const char *__optstring));
-
- int _EXFUN (getopt_long,
- (int __argc, char *const __argv[], const char *__shortopts,
- const struct option * __longopts, int *__longind));
-
- int _EXFUN (getopt_long_only,
- (int __argc, char *const __argv[], const char *__shortopts,
- const struct option * __longopts, int *__longind));
-
-#ifdef __need_getopt_newlib
- int _EXFUN (__getopt_r,
- (int __argc, char *const __argv[], const char *__optstring,
- struct getopt_data * __data));
+struct option
+{
+ const char *name;
+ int has_arg;
+ int *flag;
+ int val;
+};
- int _EXFUN (__getopt_long_r,
- (int __argc, char *const __argv[], const char *__shortopts,
- const struct option * __longopts, int *__longind,
- struct getopt_data * __data));
+int getopt_long(int, char *const *, const char *, const struct option *, int *);
+int getopt_long_only(int, char *const *, const char *, const struct option *, int *);
- int _EXFUN (__getopt_long_only_r,
- (int __argc, char *const __argv[], const char *__shortopts,
- const struct option * __longopts, int *__longind,
- struct getopt_data * __data));
-#endif /* __need_getopt_newlib */
+#define no_argument 0
+#define required_argument 1
+#define optional_argument 2
#ifdef __cplusplus
-};
-
-#endif /* __cplusplus */
-
-#endif /* GETOPT_H */
+}
+#endif
-/* END OF FILE getopt.h */
+#endif
diff --git a/system/include/libc/glob.h b/system/include/libc/glob.h
index a7351350..9fbbaa65 100644
--- a/system/include/libc/glob.h
+++ b/system/include/libc/glob.h
@@ -1,89 +1,48 @@
-/*
- * Copyright (c) 1989, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Guido van Rossum.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)glob.h 8.1 (Berkeley) 6/2/93
- * $FreeBSD: src/include/glob.h,v 1.6 2002/03/23 17:24:53 imp Exp $
- */
+#ifndef _GLOB_H
+#define _GLOB_H
-#ifndef _GLOB_H_
-#define _GLOB_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
-#include <sys/cdefs.h>
+#include <features.h>
-struct stat;
-typedef struct {
- int gl_pathc; /* Count of total paths so far. */
- int gl_matchc; /* Count of paths matching pattern. */
- int gl_offs; /* Reserved at beginning of gl_pathv. */
- int gl_flags; /* Copy of flags parameter to glob. */
- char **gl_pathv; /* List of paths matching pattern. */
- /* Copy of errfunc parameter to glob. */
- int (*gl_errfunc)(const char *, int);
-
- /*
- * Alternate filesystem access methods for glob; replacement
- * versions of closedir(3), readdir(3), opendir(3), stat(2)
- * and lstat(2).
- */
- void (*gl_closedir)(void *);
- struct dirent *(*gl_readdir)(void *);
- void *(*gl_opendir)(const char *);
- int (*gl_lstat)(const char *, struct stat *);
- int (*gl_stat)(const char *, struct stat *);
-} glob_t;
-
-#define GLOB_APPEND 0x0001 /* Append to output from previous call. */
-#define GLOB_DOOFFS 0x0002 /* Use gl_offs. */
-#define GLOB_ERR 0x0004 /* Return on error. */
-#define GLOB_MARK 0x0008 /* Append / to matching directories. */
-#define GLOB_NOCHECK 0x0010 /* Return pattern itself if nothing matches. */
-#define GLOB_NOSORT 0x0020 /* Don't sort. */
+#define __NEED_size_t
-#define GLOB_ALTDIRFUNC 0x0040 /* Use alternately specified directory funcs. */
-#define GLOB_BRACE 0x0080 /* Expand braces ala csh. */
-#define GLOB_MAGCHAR 0x0100 /* Pattern had globbing characters. */
-#define GLOB_NOMAGIC 0x0200 /* GLOB_NOCHECK without magic chars (csh). */
-#define GLOB_QUOTE 0x0400 /* Quote special chars with \. */
-#define GLOB_TILDE 0x0800 /* Expand tilde names from the passwd file. */
-#define GLOB_LIMIT 0x1000 /* limit number of returned paths */
+#include <bits/alltypes.h>
-/* backwards compatibility, this is the old name for this option */
-#define GLOB_MAXPATH GLOB_LIMIT
-
-#define GLOB_NOSPACE (-1) /* Malloc call failed. */
-#define GLOB_ABEND (-2) /* Unignored error. */
-
-__BEGIN_DECLS
-int glob(const char *, int, int (*)(const char *, int), glob_t *);
-void globfree(glob_t *);
-__END_DECLS
+typedef struct {
+ size_t gl_pathc;
+ char **gl_pathv;
+ size_t gl_offs;
+ int __dummy1;
+ void *__dummy2[5];
+} glob_t;
-#endif /* !_GLOB_H_ */
+int glob(const char *__restrict, int, int (*)(const char *, int), glob_t *__restrict);
+void globfree(glob_t *);
+
+#define GLOB_ERR 0x01
+#define GLOB_MARK 0x02
+#define GLOB_NOSORT 0x04
+#define GLOB_DOOFFS 0x08
+#define GLOB_NOCHECK 0x10
+#define GLOB_APPEND 0x20
+#define GLOB_NOESCAPE 0x40
+#define GLOB_PERIOD 0x80
+
+#define GLOB_NOSPACE 1
+#define GLOB_ABORTED 2
+#define GLOB_NOMATCH 3
+#define GLOB_NOSYS 4
+
+#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
+#define glob64 glob
+#define globfree64 globfree
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/grp.h b/system/include/libc/grp.h
index 61a1b2c7..b331d326 100644
--- a/system/include/libc/grp.h
+++ b/system/include/libc/grp.h
@@ -1,94 +1,52 @@
-/* $NetBSD: grp.h,v 1.7 1995/04/29 05:30:40 cgd Exp $ */
+#ifndef _GRP_H
+#define _GRP_H
-/*-
- * Copyright (c) 1989, 1993
- * The Regents of the University of California. All rights reserved.
- * (c) UNIX System Laboratories, Inc.
- * All or some portions of this file are derived from material licensed
- * to the University of California by American Telephone and Telegraph
- * Co. or Unix System Laboratories, Inc. and are reproduced herein with
- * the permission of UNIX System Laboratories, Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)grp.h 8.2 (Berkeley) 1/21/94
- */
+#ifdef __cplusplus
+extern "C" {
+#endif
-#ifndef _GRP_H_
-#define _GRP_H_
+#include <features.h>
-#include <sys/types.h>
-#ifdef __CYGWIN__
-#include <cygwin/grp.h>
-#endif
+#define __NEED_size_t
+#define __NEED_gid_t
-#if !defined(_POSIX_SOURCE) && !defined(_XOPEN_SOURCE)
-#define _PATH_GROUP "/etc/group"
+#ifdef _GNU_SOURCE
+#define __NEED_FILE
#endif
-struct group {
- char *gr_name; /* group name */
- char *gr_passwd; /* group password */
- gid_t gr_gid; /* group id */
- char **gr_mem; /* group members */
+#include <bits/alltypes.h>
+
+struct group
+{
+ char *gr_name;
+ char *gr_passwd;
+ gid_t gr_gid;
+ char **gr_mem;
};
-#ifdef __cplusplus
-extern "C" {
+struct group *getgrgid(gid_t);
+struct group *getgrnam(const char *);
+
+int getgrgid_r(gid_t, struct group *, char *, size_t, struct group **);
+int getgrnam_r(const char *, struct group *, char *, size_t, struct group **);
+
+struct group *getgrent(void);
+void endgrent(void);
+void setgrent(void);
+
+#ifdef _GNU_SOURCE
+struct group *fgetgrent(FILE *stream);
+int putgrent(const struct group *, FILE *);
#endif
-#ifndef __INSIDE_CYGWIN__
-struct group *getgrgid (gid_t);
-struct group *getgrnam (const char *);
-int getgrnam_r (const char *, struct group *,
- char *, size_t, struct group **);
-int getgrgid_r (gid_t, struct group *,
- char *, size_t, struct group **);
-#ifndef _POSIX_SOURCE
-struct group *getgrent (void);
-void setgrent (void);
-void endgrent (void);
-#ifndef __CYGWIN__
-void setgrfile (const char *);
-#endif /* !__CYGWIN__ */
-#ifndef _XOPEN_SOURCE
-#ifndef __CYGWIN__
-char *group_from_gid (gid_t, int);
-int setgroupent (int);
-#endif /* !__CYGWIN__ */
-#endif /* !_XOPEN_SOURCE */
-#endif /* !_POSIX_SOURCE */
-int initgroups (const char *, gid_t);
-#endif /* !__INSIDE_CYGWIN__ */
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+int getgrouplist(const char *, gid_t, gid_t *, int *);
+int setgroups(size_t, const gid_t *);
+int initgroups(const char *, gid_t);
+#endif
#ifdef __cplusplus
}
#endif
-#endif /* !_GRP_H_ */
+#endif
diff --git a/system/include/libc/iconv.h b/system/include/libc/iconv.h
index c4a283af..ebe9bfda 100644
--- a/system/include/libc/iconv.h
+++ b/system/include/libc/iconv.h
@@ -1,62 +1,24 @@
-/*
- * Copyright (c) 2003-2004, Artem B. Bityuckiy, SoftMine Corporation.
- * Rights transferred to Franklin Electronic Publishers.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-#ifndef _ICONV_H_
-#define _ICONV_H_
-
-#include <_ansi.h>
-#include <reent.h>
-#include <sys/types.h>
-#include <sys/_types.h>
-
-/* iconv_t: charset conversion descriptor type */
-typedef _iconv_t iconv_t;
-
-_BEGIN_STD_C
-
-#ifndef _REENT_ONLY
-iconv_t
-_EXFUN(iconv_open, (_CONST char *, _CONST char *));
-
-size_t
-_EXFUN(iconv, (iconv_t, char **, size_t *, char **, size_t *));
-
-int
-_EXFUN(iconv_close, (iconv_t));
+#ifndef _ICONV_H
+#define _ICONV_H
+
+#ifdef __cplusplus
+extern "C" {
#endif
-iconv_t
-_EXFUN(_iconv_open_r, (struct _reent *, _CONST char *, _CONST char *));
+#include <features.h>
+
+#define __NEED_size_t
-size_t
-_EXFUN(_iconv_r, (struct _reent *, iconv_t, _CONST char **,
- size_t *, char **, size_t *));
+#include <bits/alltypes.h>
-int
-_EXFUN(_iconv_close_r, (struct _reent *, iconv_t));
+typedef void *iconv_t;
-_END_STD_C
+iconv_t iconv_open(const char *, const char *);
+size_t iconv(iconv_t, char **__restrict, size_t *__restrict, char **__restrict, size_t *__restrict);
+int iconv_close(iconv_t);
-#endif /* #ifndef _ICONV_H_ */
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/ieeefp.h b/system/include/libc/ieeefp.h
deleted file mode 100644
index 0b06fb78..00000000
--- a/system/include/libc/ieeefp.h
+++ /dev/null
@@ -1,256 +0,0 @@
-#ifndef _IEEE_FP_H_
-#define _IEEE_FP_H_
-
-#include "_ansi.h"
-
-#include <machine/ieeefp.h>
-
-_BEGIN_STD_C
-
-/* FIXME FIXME FIXME:
- Neither of __ieee_{float,double}_shape_tape seem to be used anywhere
- except in libm/test. If that is the case, please delete these from here.
- If that is not the case, please insert documentation here describing why
- they're needed. */
-
-#ifdef __IEEE_BIG_ENDIAN
-
-typedef union
-{
- double value;
- struct
- {
- unsigned int sign : 1;
- unsigned int exponent: 11;
- unsigned int fraction0:4;
- unsigned int fraction1:16;
- unsigned int fraction2:16;
- unsigned int fraction3:16;
-
- } number;
- struct
- {
- unsigned int sign : 1;
- unsigned int exponent: 11;
- unsigned int quiet:1;
- unsigned int function0:3;
- unsigned int function1:16;
- unsigned int function2:16;
- unsigned int function3:16;
- } nan;
- struct
- {
- unsigned long msw;
- unsigned long lsw;
- } parts;
- long aslong[2];
-} __ieee_double_shape_type;
-
-#endif
-
-#ifdef __IEEE_LITTLE_ENDIAN
-
-typedef union
-{
- double value;
- struct
- {
-#ifdef __SMALL_BITFIELDS
- unsigned int fraction3:16;
- unsigned int fraction2:16;
- unsigned int fraction1:16;
- unsigned int fraction0: 4;
-#else
- unsigned int fraction1:32;
- unsigned int fraction0:20;
-#endif
- unsigned int exponent :11;
- unsigned int sign : 1;
- } number;
- struct
- {
-#ifdef __SMALL_BITFIELDS
- unsigned int function3:16;
- unsigned int function2:16;
- unsigned int function1:16;
- unsigned int function0:3;
-#else
- unsigned int function1:32;
- unsigned int function0:19;
-#endif
- unsigned int quiet:1;
- unsigned int exponent: 11;
- unsigned int sign : 1;
- } nan;
- struct
- {
- unsigned long lsw;
- unsigned long msw;
- } parts;
-
- long aslong[2];
-
-} __ieee_double_shape_type;
-
-#endif
-
-#ifdef __IEEE_BIG_ENDIAN
-
-typedef union
-{
- float value;
- struct
- {
- unsigned int sign : 1;
- unsigned int exponent: 8;
- unsigned int fraction0: 7;
- unsigned int fraction1: 16;
- } number;
- struct
- {
- unsigned int sign:1;
- unsigned int exponent:8;
- unsigned int quiet:1;
- unsigned int function0:6;
- unsigned int function1:16;
- } nan;
- long p1;
-
-} __ieee_float_shape_type;
-
-#endif
-
-#ifdef __IEEE_LITTLE_ENDIAN
-
-typedef union
-{
- float value;
- struct
- {
- unsigned int fraction0: 7;
- unsigned int fraction1: 16;
- unsigned int exponent: 8;
- unsigned int sign : 1;
- } number;
- struct
- {
- unsigned int function1:16;
- unsigned int function0:6;
- unsigned int quiet:1;
- unsigned int exponent:8;
- unsigned int sign:1;
- } nan;
- long p1;
-
-} __ieee_float_shape_type;
-
-#endif
-
-
-
-
-
-/* FLOATING ROUNDING */
-
-typedef int fp_rnd;
-#define FP_RN 0 /* Round to nearest */
-#define FP_RM 1 /* Round down */
-#define FP_RP 2 /* Round up */
-#define FP_RZ 3 /* Round to zero (trunate) */
-
-fp_rnd _EXFUN(fpgetround,(void));
-fp_rnd _EXFUN(fpsetround, (fp_rnd));
-
-/* EXCEPTIONS */
-
-typedef int fp_except;
-#define FP_X_INV 0x10 /* Invalid operation */
-#define FP_X_DX 0x80 /* Divide by zero */
-#define FP_X_OFL 0x04 /* Overflow exception */
-#define FP_X_UFL 0x02 /* Underflow exception */
-#define FP_X_IMP 0x01 /* imprecise exception */
-
-fp_except _EXFUN(fpgetmask,(void));
-fp_except _EXFUN(fpsetmask,(fp_except));
-fp_except _EXFUN(fpgetsticky,(void));
-fp_except _EXFUN(fpsetsticky, (fp_except));
-
-/* INTEGER ROUNDING */
-
-typedef int fp_rdi;
-#define FP_RDI_TOZ 0 /* Round to Zero */
-#define FP_RDI_RD 1 /* Follow float mode */
-
-fp_rdi _EXFUN(fpgetroundtoi,(void));
-fp_rdi _EXFUN(fpsetroundtoi,(fp_rdi));
-
-#undef isnan
-#undef isinf
-
-int _EXFUN(isnan, (double));
-int _EXFUN(isinf, (double));
-int _EXFUN(finite, (double));
-
-
-
-int _EXFUN(isnanf, (float));
-int _EXFUN(isinff, (float));
-int _EXFUN(finitef, (float));
-
-#define __IEEE_DBL_EXPBIAS 1023
-#define __IEEE_FLT_EXPBIAS 127
-
-#define __IEEE_DBL_EXPLEN 11
-#define __IEEE_FLT_EXPLEN 8
-
-
-#define __IEEE_DBL_FRACLEN (64 - (__IEEE_DBL_EXPLEN + 1))
-#define __IEEE_FLT_FRACLEN (32 - (__IEEE_FLT_EXPLEN + 1))
-
-#define __IEEE_DBL_MAXPOWTWO ((double)(1L << 32 - 2) * (1L << (32-11) - 32 + 1))
-#define __IEEE_FLT_MAXPOWTWO ((float)(1L << (32-8) - 1))
-
-#define __IEEE_DBL_NAN_EXP 0x7ff
-#define __IEEE_FLT_NAN_EXP 0xff
-
-#ifndef __ieeefp_isnanf
-#define __ieeefp_isnanf(x) (((*(long *)&(x) & 0x7f800000L)==0x7f800000L) && \
- ((*(long *)&(x) & 0x007fffffL)!=0000000000L))
-#endif
-#define isnanf(x) __ieeefp_isnanf(x)
-
-#ifndef __ieeefp_isinff
-#define __ieeefp_isinff(x) (((*(long *)&(x) & 0x7f800000L)==0x7f800000L) && \
- ((*(long *)&(x) & 0x007fffffL)==0000000000L))
-#endif
-#define isinff(x) __ieeefp_isinff(x)
-
-#ifndef __ieeefp_finitef
-#define __ieeefp_finitef(x) (((*(long *)&(x) & 0x7f800000L)!=0x7f800000L))
-#endif
-#define finitef(x) __ieeefp_finitef(x)
-
-#ifdef _DOUBLE_IS_32BITS
-#undef __IEEE_DBL_EXPBIAS
-#define __IEEE_DBL_EXPBIAS __IEEE_FLT_EXPBIAS
-
-#undef __IEEE_DBL_EXPLEN
-#define __IEEE_DBL_EXPLEN __IEEE_FLT_EXPLEN
-
-#undef __IEEE_DBL_FRACLEN
-#define __IEEE_DBL_FRACLEN __IEEE_FLT_FRACLEN
-
-#undef __IEEE_DBL_MAXPOWTWO
-#define __IEEE_DBL_MAXPOWTWO __IEEE_FLT_MAXPOWTWO
-
-#undef __IEEE_DBL_NAN_EXP
-#define __IEEE_DBL_NAN_EXP __IEEE_FLT_NAN_EXP
-
-#undef __ieee_double_shape_type
-#define __ieee_double_shape_type __ieee_float_shape_type
-
-#endif /* _DOUBLE_IS_32BITS */
-
-_END_STD_C
-
-#endif /* _IEEE_FP_H_ */
diff --git a/system/include/libc/ifaddrs.h b/system/include/libc/ifaddrs.h
index f96d57e3..4726db6e 100644
--- a/system/include/libc/ifaddrs.h
+++ b/system/include/libc/ifaddrs.h
@@ -1,64 +1,35 @@
-/*
- * Copyright (c) 1995, 1999
- * Berkeley Software Design, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * THIS SOFTWARE IS PROVIDED BY Berkeley Software Design, Inc. ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Berkeley Software Design, Inc. BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * BSDI ifaddrs.h,v 2.5 2000/02/23 14:51:59 dab Exp
- */
+#ifndef _IFADDRS_H
+#define _IFADDRS_H
-#ifndef _IFADDRS_H_
-#define _IFADDRS_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+#include <features.h>
+#include <netinet/in.h>
#include <sys/socket.h>
struct ifaddrs {
- struct ifaddrs *ifa_next;
- char *ifa_name;
- unsigned int ifa_flags;
- struct sockaddr *ifa_addr;
- struct sockaddr *ifa_netmask;
- struct sockaddr *ifa_dstaddr;
- void *ifa_data;
-};
-
-/*
- * This may have been defined in <net/if.h>. Note that if <net/if.h> is
- * to be included it must be included before this header file.
- */
-#ifndef ifa_broadaddr
-#define ifa_broadaddr ifa_dstaddr /* broadcast address interface */
-#endif
-
-struct ifmaddrs {
- struct ifmaddrs *ifma_next;
- struct sockaddr *ifma_name;
- struct sockaddr *ifma_addr;
- struct sockaddr *ifma_lladdr;
+ struct ifaddrs *ifa_next;
+ char *ifa_name;
+ unsigned ifa_flags;
+ struct sockaddr *ifa_addr;
+ struct sockaddr *ifa_netmask;
+ union {
+ struct sockaddr *ifu_broadaddr;
+ struct sockaddr *ifu_dstaddr;
+ } ifa_ifu;
+ void *ifa_data;
};
+#define ifa_broadaddr ifa_ifu.ifu_broadaddr
+#define ifa_dstaddr ifa_ifu.ifu_dstaddr
-#include <sys/cdefs.h>
+void freeifaddrs(struct ifaddrs *ifp);
+int getifaddrs(struct ifaddrs **ifap);
-extern int getifaddrs(struct ifaddrs **);
-extern void freeifaddrs(struct ifaddrs *);
-extern int getifmaddrs(struct ifmaddrs **);
-extern void freeifmaddrs(struct ifmaddrs *);
+#ifdef __cplusplus
+}
+#endif
#endif
diff --git a/system/include/libc/inttypes.h b/system/include/libc/inttypes.h
index 02bef1ac..c51769fa 100644
--- a/system/include/libc/inttypes.h
+++ b/system/include/libc/inttypes.h
@@ -1,290 +1,227 @@
-/*
- * Copyright (c) 2004, 2005 by
- * Ralf Corsepius, Ulm/Germany. All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this software
- * is freely granted, provided that this notice is preserved.
- */
-
-/**
- * @file inttypes.h
- */
-
#ifndef _INTTYPES_H
#define _INTTYPES_H
-#include <stdint.h>
-#define __need_wchar_t
-#include <stddef.h>
-
-#define __STRINGIFY(a) #a
-
-/* 8-bit types */
-#define __PRI8(x) __STRINGIFY(x)
-#define __SCN8(x) __STRINGIFY(hh##x)
-
-
-#define PRId8 __PRI8(d)
-#define PRIi8 __PRI8(i)
-#define PRIo8 __PRI8(o)
-#define PRIu8 __PRI8(u)
-#define PRIx8 __PRI8(x)
-#define PRIX8 __PRI8(X)
-
-#define SCNd8 __SCN8(d)
-#define SCNi8 __SCN8(i)
-#define SCNo8 __SCN8(o)
-#define SCNu8 __SCN8(u)
-#define SCNx8 __SCN8(x)
-
-
-#define PRIdLEAST8 __PRI8(d)
-#define PRIiLEAST8 __PRI8(i)
-#define PRIoLEAST8 __PRI8(o)
-#define PRIuLEAST8 __PRI8(u)
-#define PRIxLEAST8 __PRI8(x)
-#define PRIXLEAST8 __PRI8(X)
-
-#define SCNdLEAST8 __SCN8(d)
-#define SCNiLEAST8 __SCN8(i)
-#define SCNoLEAST8 __SCN8(o)
-#define SCNuLEAST8 __SCN8(u)
-#define SCNxLEAST8 __SCN8(x)
-
-
-#define PRIdFAST8 __PRI8(d)
-#define PRIiFAST8 __PRI8(i)
-#define PRIoFAST8 __PRI8(o)
-#define PRIuFAST8 __PRI8(u)
-#define PRIxFAST8 __PRI8(x)
-#define PRIXFAST8 __PRI8(X)
-
-#define SCNdFAST8 __SCN8(d)
-#define SCNiFAST8 __SCN8(i)
-#define SCNoFAST8 __SCN8(o)
-#define SCNuFAST8 __SCN8(u)
-#define SCNxFAST8 __SCN8(x)
-
-/* 16-bit types */
-#define __PRI16(x) __STRINGIFY(x)
-#define __SCN16(x) __STRINGIFY(h##x)
-
-
-#define PRId16 __PRI16(d)
-#define PRIi16 __PRI16(i)
-#define PRIo16 __PRI16(o)
-#define PRIu16 __PRI16(u)
-#define PRIx16 __PRI16(x)
-#define PRIX16 __PRI16(X)
-
-#define SCNd16 __SCN16(d)
-#define SCNi16 __SCN16(i)
-#define SCNo16 __SCN16(o)
-#define SCNu16 __SCN16(u)
-#define SCNx16 __SCN16(x)
-
-
-#define PRIdLEAST16 __PRI16(d)
-#define PRIiLEAST16 __PRI16(i)
-#define PRIoLEAST16 __PRI16(o)
-#define PRIuLEAST16 __PRI16(u)
-#define PRIxLEAST16 __PRI16(x)
-#define PRIXLEAST16 __PRI16(X)
-
-#define SCNdLEAST16 __SCN16(d)
-#define SCNiLEAST16 __SCN16(i)
-#define SCNoLEAST16 __SCN16(o)
-#define SCNuLEAST16 __SCN16(u)
-#define SCNxLEAST16 __SCN16(x)
-
-
-#define PRIdFAST16 __PRI16(d)
-#define PRIiFAST16 __PRI16(i)
-#define PRIoFAST16 __PRI16(o)
-#define PRIuFAST16 __PRI16(u)
-#define PRIxFAST16 __PRI16(x)
-#define PRIXFAST16 __PRI16(X)
-
-#define SCNdFAST16 __SCN16(d)
-#define SCNiFAST16 __SCN16(i)
-#define SCNoFAST16 __SCN16(o)
-#define SCNuFAST16 __SCN16(u)
-#define SCNxFAST16 __SCN16(x)
-
-/* 32-bit types */
-#if __have_long32
-#define __PRI32(x) __STRINGIFY(l##x)
-#define __SCN32(x) __STRINGIFY(l##x)
-#else
-#define __PRI32(x) __STRINGIFY(x)
-#define __SCN32(x) __STRINGIFY(x)
-#endif
-
-#define PRId32 __PRI32(d)
-#define PRIi32 __PRI32(i)
-#define PRIo32 __PRI32(o)
-#define PRIu32 __PRI32(u)
-#define PRIx32 __PRI32(x)
-#define PRIX32 __PRI32(X)
-
-#define SCNd32 __SCN32(d)
-#define SCNi32 __SCN32(i)
-#define SCNo32 __SCN32(o)
-#define SCNu32 __SCN32(u)
-#define SCNx32 __SCN32(x)
-
-
-#define PRIdLEAST32 __PRI32(d)
-#define PRIiLEAST32 __PRI32(i)
-#define PRIoLEAST32 __PRI32(o)
-#define PRIuLEAST32 __PRI32(u)
-#define PRIxLEAST32 __PRI32(x)
-#define PRIXLEAST32 __PRI32(X)
-
-#define SCNdLEAST32 __SCN32(d)
-#define SCNiLEAST32 __SCN32(i)
-#define SCNoLEAST32 __SCN32(o)
-#define SCNuLEAST32 __SCN32(u)
-#define SCNxLEAST32 __SCN32(x)
-
-
-#define PRIdFAST32 __PRI32(d)
-#define PRIiFAST32 __PRI32(i)
-#define PRIoFAST32 __PRI32(o)
-#define PRIuFAST32 __PRI32(u)
-#define PRIxFAST32 __PRI32(x)
-#define PRIXFAST32 __PRI32(X)
-
-#define SCNdFAST32 __SCN32(d)
-#define SCNiFAST32 __SCN32(i)
-#define SCNoFAST32 __SCN32(o)
-#define SCNuFAST32 __SCN32(u)
-#define SCNxFAST32 __SCN32(x)
-
-
-/* 64-bit types */
-#if __have_long64
-#define __PRI64(x) __STRINGIFY(l##x)
-#define __SCN64(x) __STRINGIFY(l##x)
-#elif __have_longlong64
-#define __PRI64(x) __STRINGIFY(ll##x)
-#define __SCN64(x) __STRINGIFY(ll##x)
-#else
-#define __PRI64(x) __STRINGIFY(x)
-#define __SCN64(x) __STRINGIFY(x)
-#endif
-
-#define PRId64 __PRI64(d)
-#define PRIi64 __PRI64(i)
-#define PRIo64 __PRI64(o)
-#define PRIu64 __PRI64(u)
-#define PRIx64 __PRI64(x)
-#define PRIX64 __PRI64(X)
-
-#define SCNd64 __SCN64(d)
-#define SCNi64 __SCN64(i)
-#define SCNo64 __SCN64(o)
-#define SCNu64 __SCN64(u)
-#define SCNx64 __SCN64(x)
-
-#if __int64_t_defined
-#define PRIdLEAST64 __PRI64(d)
-#define PRIiLEAST64 __PRI64(i)
-#define PRIoLEAST64 __PRI64(o)
-#define PRIuLEAST64 __PRI64(u)
-#define PRIxLEAST64 __PRI64(x)
-#define PRIXLEAST64 __PRI64(X)
-
-#define SCNdLEAST64 __SCN64(d)
-#define SCNiLEAST64 __SCN64(i)
-#define SCNoLEAST64 __SCN64(o)
-#define SCNuLEAST64 __SCN64(u)
-#define SCNxLEAST64 __SCN64(x)
-
-
-#define PRIdFAST64 __PRI64(d)
-#define PRIiFAST64 __PRI64(i)
-#define PRIoFAST64 __PRI64(o)
-#define PRIuFAST64 __PRI64(u)
-#define PRIxFAST64 __PRI64(x)
-#define PRIXFAST64 __PRI64(X)
-
-#define SCNdFAST64 __SCN64(d)
-#define SCNiFAST64 __SCN64(i)
-#define SCNoFAST64 __SCN64(o)
-#define SCNuFAST64 __SCN64(u)
-#define SCNxFAST64 __SCN64(x)
+#ifdef __cplusplus
+extern "C" {
#endif
-/* max-bit types */
-#if __have_long64
-#define __PRIMAX(x) __STRINGIFY(l##x)
-#define __SCNMAX(x) __STRINGIFY(l##x)
-#elif __have_longlong64
-#define __PRIMAX(x) __STRINGIFY(ll##x)
-#define __SCNMAX(x) __STRINGIFY(ll##x)
-#else
-#define __PRIMAX(x) __STRINGIFY(x)
-#define __SCNMAX(x) __STRINGIFY(x)
-#endif
+#include <features.h>
+#include <stdint.h>
-#define PRIdMAX __PRIMAX(d)
-#define PRIiMAX __PRIMAX(i)
-#define PRIoMAX __PRIMAX(o)
-#define PRIuMAX __PRIMAX(u)
-#define PRIxMAX __PRIMAX(x)
-#define PRIXMAX __PRIMAX(X)
-
-#define SCNdMAX __SCNMAX(d)
-#define SCNiMAX __SCNMAX(i)
-#define SCNoMAX __SCNMAX(o)
-#define SCNuMAX __SCNMAX(u)
-#define SCNxMAX __SCNMAX(x)
-
-/* ptr types */
-#if __have_long64
-#define __PRIPTR(x) __STRINGIFY(l##x)
-#define __SCNPTR(x) __STRINGIFY(l##x)
-#elif __have_longlong64
-#define __PRIPTR(x) __STRINGIFY(ll##x)
-#define __SCNPTR(x) __STRINGIFY(ll##x)
-#else
-#define __PRIPTR(x) __STRINGIFY(x)
-#define __SCNPTR(x) __STRINGIFY(x)
-#endif
+#define __NEED_wchar_t
+#include <bits/alltypes.h>
-#define PRIdPTR __PRIPTR(d)
-#define PRIiPTR __PRIPTR(i)
-#define PRIoPTR __PRIPTR(o)
-#define PRIuPTR __PRIPTR(u)
-#define PRIxPTR __PRIPTR(x)
-#define PRIXPTR __PRIPTR(X)
+typedef struct { intmax_t quot, rem; } imaxdiv_t;
-#define SCNdPTR __SCNPTR(d)
-#define SCNiPTR __SCNPTR(i)
-#define SCNoPTR __SCNPTR(o)
-#define SCNuPTR __SCNPTR(u)
-#define SCNxPTR __SCNPTR(x)
+intmax_t imaxabs(intmax_t);
+imaxdiv_t imaxdiv(intmax_t, intmax_t);
+intmax_t strtoimax(const char *__restrict, char **__restrict, int);
+uintmax_t strtoumax(const char *__restrict, char **__restrict, int);
-typedef struct {
- intmax_t quot;
- intmax_t rem;
-} imaxdiv_t;
+intmax_t wcstoimax(const wchar_t *__restrict, wchar_t **__restrict, int);
+uintmax_t wcstoumax(const wchar_t *__restrict, wchar_t **__restrict, int);
-#ifdef __cplusplus
-extern "C" {
+#if UINTPTR_MAX == UINT64_MAX
+#define __PRI64 "l"
+#else
+#define __PRI64 "ll"
#endif
-extern intmax_t imaxabs(intmax_t j);
-extern imaxdiv_t imaxdiv(intmax_t numer, intmax_t denomer);
-extern intmax_t strtoimax(const char *__restrict, char **__restrict, int);
-extern uintmax_t strtoumax(const char *__restrict, char **__restrict, int);
-extern intmax_t wcstoimax(const wchar_t *__restrict, wchar_t **__restrict, int);
-extern uintmax_t wcstoumax(const wchar_t *__restrict, wchar_t **__restrict, int);
+#define PRId8 "d"
+#define PRId16 "d"
+#define PRId32 "d"
+#define PRId64 __PRI64 "d"
+
+#define PRIdLEAST8 "d"
+#define PRIdLEAST16 "d"
+#define PRIdLEAST32 "d"
+#define PRIdLEAST64 __PRI64 "d"
+
+#define PRIdFAST8 "d"
+#define PRIdFAST16 "d"
+#define PRIdFAST32 "d"
+#define PRIdFAST64 __PRI64 "d"
+
+#define PRIi8 "i"
+#define PRIi16 "i"
+#define PRIi32 "i"
+#define PRIi64 __PRI64 "i"
+
+#define PRIiLEAST8 "i"
+#define PRIiLEAST16 "i"
+#define PRIiLEAST32 "i"
+#define PRIiLEAST64 __PRI64 "i"
+
+#define PRIiFAST8 "i"
+#define PRIiFAST16 "i"
+#define PRIiFAST32 "i"
+#define PRIiFAST64 __PRI64 "i"
+
+#define PRIo8 "o"
+#define PRIo16 "o"
+#define PRIo32 "o"
+#define PRIo64 __PRI64 "o"
+
+#define PRIoLEAST8 "o"
+#define PRIoLEAST16 "o"
+#define PRIoLEAST32 "o"
+#define PRIoLEAST64 __PRI64 "o"
+
+#define PRIoFAST8 "o"
+#define PRIoFAST16 "o"
+#define PRIoFAST32 "o"
+#define PRIoFAST64 __PRI64 "o"
+
+#define PRIu8 "u"
+#define PRIu16 "u"
+#define PRIu32 "u"
+#define PRIu64 __PRI64 "u"
+
+#define PRIuLEAST8 "u"
+#define PRIuLEAST16 "u"
+#define PRIuLEAST32 "u"
+#define PRIuLEAST64 __PRI64 "u"
+
+#define PRIuFAST8 "u"
+#define PRIuFAST16 "u"
+#define PRIuFAST32 "u"
+#define PRIuFAST64 __PRI64 "u"
+
+#define PRIx8 "x"
+#define PRIx16 "x"
+#define PRIx32 "x"
+#define PRIx64 __PRI64 "x"
+
+#define PRIxLEAST8 "x"
+#define PRIxLEAST16 "x"
+#define PRIxLEAST32 "x"
+#define PRIxLEAST64 __PRI64 "x"
+
+#define PRIxFAST8 "x"
+#define PRIxFAST16 "x"
+#define PRIxFAST32 "x"
+#define PRIxFAST64 __PRI64 "x"
+
+#define PRIX8 "X"
+#define PRIX16 "X"
+#define PRIX32 "X"
+#define PRIX64 __PRI64 "X"
+
+#define PRIXLEAST8 "X"
+#define PRIXLEAST16 "X"
+#define PRIXLEAST32 "X"
+#define PRIXLEAST64 __PRI64 "X"
+
+#define PRIXFAST8 "X"
+#define PRIXFAST16 "X"
+#define PRIXFAST32 "X"
+#define PRIXFAST64 __PRI64 "X"
+
+#define PRIdMAX __PRI64 "d"
+#define PRIiMAX __PRI64 "i"
+#define PRIoMAX __PRI64 "o"
+#define PRIuMAX __PRI64 "u"
+#define PRIxMAX __PRI64 "x"
+#define PRIXMAX __PRI64 "X"
+
+#define PRIdPTR "ld"
+#define PRIiPTR "li"
+#define PRIoPTR "lo"
+#define PRIuPTR "lu"
+#define PRIxPTR "lx"
+#define PRIXPTR "lX"
+
+#define SCNd8 "hhd"
+#define SCNd16 "hd"
+#define SCNd32 "d"
+#define SCNd64 __PRI64 "d"
+
+#define SCNdLEAST8 "hhd"
+#define SCNdLEAST16 "hd"
+#define SCNdLEAST32 "d"
+#define SCNdLEAST64 __PRI64 "d"
+
+#define SCNdFAST8 "hhd"
+#define SCNdFAST16 "d"
+#define SCNdFAST32 "d"
+#define SCNdFAST64 __PRI64 "d"
+
+#define SCNi8 "hhi"
+#define SCNi16 "hi"
+#define SCNi32 "i"
+#define SCNi64 __PRI64 "i"
+
+#define SCNiLEAST8 "hhi"
+#define SCNiLEAST16 "hi"
+#define SCNiLEAST32 "i"
+#define SCNiLEAST64 __PRI64 "i"
+
+#define SCNiFAST8 "hhi"
+#define SCNiFAST16 "i"
+#define SCNiFAST32 "i"
+#define SCNiFAST64 __PRI64 "i"
+
+#define SCNu8 "hhu"
+#define SCNu16 "hu"
+#define SCNu32 "u"
+#define SCNu64 __PRI64 "u"
+
+#define SCNuLEAST8 "hhu"
+#define SCNuLEAST16 "hu"
+#define SCNuLEAST32 "u"
+#define SCNuLEAST64 __PRI64 "u"
+
+#define SCNuFAST8 "hhu"
+#define SCNuFAST16 "u"
+#define SCNuFAST32 "u"
+#define SCNuFAST64 __PRI64 "u"
+
+#define SCNo8 "hho"
+#define SCNo16 "ho"
+#define SCNo32 "o"
+#define SCNo64 __PRI64 "o"
+
+#define SCNoLEAST8 "hho"
+#define SCNoLEAST16 "ho"
+#define SCNoLEAST32 "o"
+#define SCNoLEAST64 __PRI64 "o"
+
+#define SCNoFAST8 "hho"
+#define SCNoFAST16 "o"
+#define SCNoFAST32 "o"
+#define SCNoFAST64 __PRI64 "o"
+
+#define SCNx8 "hhx"
+#define SCNx16 "hx"
+#define SCNx32 "x"
+#define SCNx64 __PRI64 "x"
+
+#define SCNxLEAST8 "hhx"
+#define SCNxLEAST16 "hx"
+#define SCNxLEAST32 "x"
+#define SCNxLEAST64 __PRI64 "x"
+
+#define SCNxFAST8 "hhx"
+#define SCNxFAST16 "x"
+#define SCNxFAST32 "x"
+#define SCNxFAST64 __PRI64 "x"
+
+#define SCNdMAX __PRI64 "d"
+#define SCNiMAX __PRI64 "i"
+#define SCNoMAX __PRI64 "o"
+#define SCNuMAX __PRI64 "u"
+#define SCNxMAX __PRI64 "x"
+
+#define SCNdPTR "ld"
+#define SCNiPTR "li"
+#define SCNoPTR "lo"
+#define SCNuPTR "lu"
+#define SCNxPTR "lx"
#ifdef __cplusplus
}
#endif
#endif
+
diff --git a/system/include/libc/iso646.h b/system/include/libc/iso646.h
index dca13c5b..88ff53d7 100644
--- a/system/include/libc/iso646.h
+++ b/system/include/libc/iso646.h
@@ -1,32 +1,8 @@
-/*===---- iso646.h - Standard header for alternate spellings of operators---===
- *
- * Copyright (c) 2008 Eli Friedman
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- *===-----------------------------------------------------------------------===
- */
-
-#ifndef __ISO646_H
-#define __ISO646_H
+#ifndef _ISO646_H
+#define _ISO646_H
#ifndef __cplusplus
+
#define and &&
#define and_eq &=
#define bitand &
@@ -38,6 +14,7 @@
#define or_eq |=
#define xor ^
#define xor_eq ^=
+
#endif
-#endif /* __ISO646_H */
+#endif
diff --git a/system/include/libc/langinfo.h b/system/include/libc/langinfo.h
index 23bddb96..c6349ad1 100644
--- a/system/include/libc/langinfo.h
+++ b/system/include/libc/langinfo.h
@@ -1,316 +1,88 @@
-/*-
- * Copyright (c) 2001 Alexey Zelkin <phantom@FreeBSD.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD: src/include/langinfo.h,v 1.5 2002/03/23 17:24:53 imp Exp $
- */
-
-#ifndef _LANGINFO_H_
-#define _LANGINFO_H_
-
-#include <newlib.h>
-#include <sys/config.h>
-#include <sys/cdefs.h>
-
-typedef int nl_item;
-
-enum __nl_item
-{
- /* POSIX and BSD defined items have to stick to the original values
- to maintain backward compatibility. */
- _NL_CTYPE_CODESET_NAME = 0, /* codeset name */
-#define CODESET _NL_CTYPE_CODESET_NAME
- D_T_FMT = 1, /* string for formatting date and time */
-#define D_T_FMT D_T_FMT
- D_FMT = 2, /* date format string */
-#define D_FMT D_FMT
- T_FMT = 3, /* time format string */
-#define T_FMT T_FMT
- T_FMT_AMPM = 4, /* a.m. or p.m. time formatting string */
-#define T_FMT_AMPM T_FMT_AMPM
- AM_STR = 5, /* Ante Meridian affix */
-#define AM_STR AM_STR
- PM_STR = 6, /* Post Meridian affix */
-#define PM_STR PM_STR
-
-/* week day names */
- DAY_1 = 7,
-#define DAY_1 DAY_1
- DAY_2 = 8,
-#define DAY_2 DAY_2
- DAY_3 = 9,
-#define DAY_3 DAY_3
- DAY_4 = 10,
-#define DAY_4 DAY_4
- DAY_5 = 11,
-#define DAY_5 DAY_5
- DAY_6 = 12,
-#define DAY_6 DAY_6
- DAY_7 = 13,
-#define DAY_7 DAY_7
-
-/* abbreviated week day names */
- ABDAY_1 = 14,
-#define ABDAY_1 ABDAY_1
- ABDAY_2 = 15,
-#define ABDAY_2 ABDAY_2
- ABDAY_3 = 16,
-#define ABDAY_3 ABDAY_3
- ABDAY_4 = 17,
-#define ABDAY_4 ABDAY_4
- ABDAY_5 = 18,
-#define ABDAY_5 ABDAY_5
- ABDAY_6 = 19,
-#define ABDAY_6 ABDAY_6
- ABDAY_7 = 20,
-#define ABDAY_7 ABDAY_7
-
-/* month names */
- MON_1 = 21,
-#define MON_1 MON_1
- MON_2 = 22,
-#define MON_2 MON_2
- MON_3 = 23,
-#define MON_3 MON_3
- MON_4 = 24,
-#define MON_4 MON_4
- MON_5 = 25,
-#define MON_5 MON_5
- MON_6 = 26,
-#define MON_6 MON_6
- MON_7 = 27,
-#define MON_7 MON_7
- MON_8 = 28,
-#define MON_8 MON_8
- MON_9 = 29,
-#define MON_9 MON_9
- MON_10 = 30,
-#define MON_10 MON_10
- MON_11 = 31,
-#define MON_11 MON_11
- MON_12 = 32,
-#define MON_12 MON_12
-
-/* abbreviated month names */
- ABMON_1 = 33,
-#define ABMON_1 ABMON_1
- ABMON_2 = 34,
-#define ABMON_2 ABMON_2
- ABMON_3 = 35,
-#define ABMON_3 ABMON_3
- ABMON_4 = 36,
-#define ABMON_4 ABMON_4
- ABMON_5 = 37,
-#define ABMON_5 ABMON_5
- ABMON_6 = 38,
-#define ABMON_6 ABMON_6
- ABMON_7 = 39,
-#define ABMON_7 ABMON_7
- ABMON_8 = 40,
-#define ABMON_8 ABMON_8
- ABMON_9 = 41,
-#define ABMON_9 ABMON_9
- ABMON_10 = 42,
-#define ABMON_10 ABMON_10
- ABMON_11 = 43,
-#define ABMON_11 ABMON_11
- ABMON_12 = 44,
-#define ABMON_12 ABMON_12
-
- ERA = 45, /* era description segments */
-#define ERA ERA
- ERA_D_FMT = 46, /* era date format string */
-#define ERA_D_FMT ERA_D_FMT
- ERA_D_T_FMT = 47, /* era date and time format string */
-#define ERA_D_T_FMT ERA_D_T_FMT
- ERA_T_FMT = 48, /* era time format string */
-#define ERA_T_FMT ERA_T_FMT
- ALT_DIGITS = 49, /* alternative symbols for digits */
-#define ALT_DIGITS ALT_DIGITS
-
- RADIXCHAR = 50, /* radix char */
-#define RADIXCHAR RADIXCHAR
- THOUSEP = 51, /* separator for thousands */
-#define THOUSEP THOUSEP
-
- YESEXPR = 52, /* affirmative response expression */
-#define YESEXPR YESEXPR
- NOEXPR = 53, /* negative response expression */
-#define NOEXPR NOEXPR
- YESSTR = 54, /* affirmative response for yes/no queries */
-#define YESSTR YESSTR
- NOSTR = 55, /* negative response for yes/no queries */
-#define NOSTR NOSTR
-
- CRNCYSTR = 56, /* currency symbol */
-#define CRNCYSTR CRNCYSTR
-
- D_MD_ORDER = 57, /* month/day order (BSD extension) */
-#define D_MD_ORDER D_MD_ORDER
-
- _NL_TIME_DATE_FMT = 84, /* date fmt used by date(1) (GNU extension) */
-#define _DATE_FMT _NL_TIME_DATE_FMT
-
-#ifdef __HAVE_LOCALE_INFO__
- _NL_CTYPE_MB_CUR_MAX = 85,
- _NL_MESSAGES_CODESET = 86,
-
-#ifdef __HAVE_LOCALE_INFO_EXTENDED__
-
- /* NOTE:
-
- Always maintain the order and position of existing entries!
- Always append new entry to the list, prior to the definition
- of _NL_LOCALE_EXTENDED_LAST_ENTRY. */
-
- _NL_LOCALE_EXTENDED_FIRST_ENTRY,
-
- _NL_CTYPE_OUTDIGITS0_MB,
- _NL_CTYPE_OUTDIGITS1_MB,
- _NL_CTYPE_OUTDIGITS2_MB,
- _NL_CTYPE_OUTDIGITS3_MB,
- _NL_CTYPE_OUTDIGITS4_MB,
- _NL_CTYPE_OUTDIGITS5_MB,
- _NL_CTYPE_OUTDIGITS6_MB,
- _NL_CTYPE_OUTDIGITS7_MB,
- _NL_CTYPE_OUTDIGITS8_MB,
- _NL_CTYPE_OUTDIGITS9_MB,
- _NL_CTYPE_OUTDIGITS0_WC,
- _NL_CTYPE_OUTDIGITS1_WC,
- _NL_CTYPE_OUTDIGITS2_WC,
- _NL_CTYPE_OUTDIGITS3_WC,
- _NL_CTYPE_OUTDIGITS4_WC,
- _NL_CTYPE_OUTDIGITS5_WC,
- _NL_CTYPE_OUTDIGITS6_WC,
- _NL_CTYPE_OUTDIGITS7_WC,
- _NL_CTYPE_OUTDIGITS8_WC,
- _NL_CTYPE_OUTDIGITS9_WC,
-
- _NL_TIME_CODESET,
- _NL_TIME_WMON_1,
- _NL_TIME_WMON_2,
- _NL_TIME_WMON_3,
- _NL_TIME_WMON_4,
- _NL_TIME_WMON_5,
- _NL_TIME_WMON_6,
- _NL_TIME_WMON_7,
- _NL_TIME_WMON_8,
- _NL_TIME_WMON_9,
- _NL_TIME_WMON_10,
- _NL_TIME_WMON_11,
- _NL_TIME_WMON_12,
- _NL_TIME_WMONTH_1,
- _NL_TIME_WMONTH_2,
- _NL_TIME_WMONTH_3,
- _NL_TIME_WMONTH_4,
- _NL_TIME_WMONTH_5,
- _NL_TIME_WMONTH_6,
- _NL_TIME_WMONTH_7,
- _NL_TIME_WMONTH_8,
- _NL_TIME_WMONTH_9,
- _NL_TIME_WMONTH_10,
- _NL_TIME_WMONTH_11,
- _NL_TIME_WMONTH_12,
- _NL_TIME_WWDAY_1,
- _NL_TIME_WWDAY_2,
- _NL_TIME_WWDAY_3,
- _NL_TIME_WWDAY_4,
- _NL_TIME_WWDAY_5,
- _NL_TIME_WWDAY_6,
- _NL_TIME_WWDAY_7,
- _NL_TIME_WWEEKDAY_1,
- _NL_TIME_WWEEKDAY_2,
- _NL_TIME_WWEEKDAY_3,
- _NL_TIME_WWEEKDAY_4,
- _NL_TIME_WWEEKDAY_5,
- _NL_TIME_WWEEKDAY_6,
- _NL_TIME_WWEEKDAY_7,
- _NL_TIME_WT_FMT,
- _NL_TIME_WD_FMT,
- _NL_TIME_WD_T_FMT,
- _NL_TIME_WAM_STR,
- _NL_TIME_WPM_STR,
- _NL_TIME_WDATE_FMT,
- _NL_TIME_WT_FMT_AMPM,
- _NL_TIME_WERA,
- _NL_TIME_WERA_D_FMT,
- _NL_TIME_WERA_D_T_FMT,
- _NL_TIME_WERA_T_FMT,
- _NL_TIME_WALT_DIGITS,
-
- _NL_NUMERIC_CODESET,
- _NL_NUMERIC_GROUPING,
- _NL_NUMERIC_DECIMAL_POINT_WC,
- _NL_NUMERIC_THOUSANDS_SEP_WC,
-
- _NL_MONETARY_INT_CURR_SYMBOL,
- _NL_MONETARY_CURRENCY_SYMBOL,
- _NL_MONETARY_MON_DECIMAL_POINT,
- _NL_MONETARY_MON_THOUSANDS_SEP,
- _NL_MONETARY_MON_GROUPING,
- _NL_MONETARY_POSITIVE_SIGN,
- _NL_MONETARY_NEGATIVE_SIGN,
- _NL_MONETARY_INT_FRAC_DIGITS,
- _NL_MONETARY_FRAC_DIGITS,
- _NL_MONETARY_P_CS_PRECEDES,
- _NL_MONETARY_P_SEP_BY_SPACE,
- _NL_MONETARY_N_CS_PRECEDES,
- _NL_MONETARY_N_SEP_BY_SPACE,
- _NL_MONETARY_P_SIGN_POSN,
- _NL_MONETARY_N_SIGN_POSN,
- _NL_MONETARY_INT_P_CS_PRECEDES,
- _NL_MONETARY_INT_P_SEP_BY_SPACE,
- _NL_MONETARY_INT_N_CS_PRECEDES,
- _NL_MONETARY_INT_N_SEP_BY_SPACE,
- _NL_MONETARY_INT_P_SIGN_POSN,
- _NL_MONETARY_INT_N_SIGN_POSN,
- _NL_MONETARY_CODESET,
- _NL_MONETARY_WINT_CURR_SYMBOL,
- _NL_MONETARY_WCURRENCY_SYMBOL,
- _NL_MONETARY_WMON_DECIMAL_POINT,
- _NL_MONETARY_WMON_THOUSANDS_SEP,
- _NL_MONETARY_WPOSITIVE_SIGN,
- _NL_MONETARY_WNEGATIVE_SIGN,
-
- _NL_MESSAGES_WYESEXPR,
- _NL_MESSAGES_WNOEXPR,
- _NL_MESSAGES_WYESSTR,
- _NL_MESSAGES_WNOSTR,
-
- _NL_COLLATE_CODESET,
-
- /* This MUST be the last entry since it's used to check for an array
- index in nl_langinfo(). */
- _NL_LOCALE_EXTENDED_LAST_ENTRY
-
-#endif /* __HAVE_LOCALE_INFO_EXTENDED__ */
-#endif /* __HAVE_LOCALE_INFO__ */
-
-};
-
-__BEGIN_DECLS
-char *nl_langinfo(nl_item);
-__END_DECLS
-
-#endif /* !_LANGINFO_H_ */
+#ifndef _LANGINFO_H
+#define _LANGINFO_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <nl_types.h>
+
+#define __NEED_locale_t
+
+#include <bits/alltypes.h>
+
+#define ABDAY_1 0x20000
+#define ABDAY_2 0x20001
+#define ABDAY_3 0x20002
+#define ABDAY_4 0x20003
+#define ABDAY_5 0x20004
+#define ABDAY_6 0x20005
+#define ABDAY_7 0x20006
+
+#define DAY_1 0x20007
+#define DAY_2 0x20008
+#define DAY_3 0x20009
+#define DAY_4 0x2000A
+#define DAY_5 0x2000B
+#define DAY_6 0x2000C
+#define DAY_7 0x2000D
+
+#define ABMON_1 0x2000E
+#define ABMON_2 0x2000F
+#define ABMON_3 0x20010
+#define ABMON_4 0x20011
+#define ABMON_5 0x20012
+#define ABMON_6 0x20013
+#define ABMON_7 0x20014
+#define ABMON_8 0x20015
+#define ABMON_9 0x20016
+#define ABMON_10 0x20017
+#define ABMON_11 0x20018
+#define ABMON_12 0x20019
+
+#define MON_1 0x2001A
+#define MON_2 0x2001B
+#define MON_3 0x2001C
+#define MON_4 0x2001D
+#define MON_5 0x2001E
+#define MON_6 0x2001F
+#define MON_7 0x20020
+#define MON_8 0x20021
+#define MON_9 0x20022
+#define MON_10 0x20023
+#define MON_11 0x20024
+#define MON_12 0x20025
+
+#define AM_STR 0x20026
+#define PM_STR 0x20027
+
+#define D_T_FMT 0x20028
+#define D_FMT 0x20029
+#define T_FMT 0x2002A
+#define T_FMT_AMPM 0x2002B
+
+#define ERA 0x2002C
+#define ERA_D_FMT 0x2002E
+#define ALT_DIGITS 0x2002F
+#define ERA_D_T_FMT 0x20030
+#define ERA_T_FMT 0x20031
+
+#define CODESET 14
+
+#define CRNCYSTR 0x4000F
+
+#define RADIXCHAR 0x10000
+#define THOUSEP 0x10001
+#define YESEXPR 0x50000
+#define NOEXPR 0x50001
+#define YESSTR 0x50002
+#define NOSTR 0x50003
+
+char *nl_langinfo(nl_item);
+char *nl_langinfo_l(nl_item, locale_t);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/lastlog.h b/system/include/libc/lastlog.h
new file mode 100644
index 00000000..5fa45ee4
--- /dev/null
+++ b/system/include/libc/lastlog.h
@@ -0,0 +1 @@
+#include <utmp.h>
diff --git a/system/include/libc/libgen.h b/system/include/libc/libgen.h
index abfab0e5..7c7fd9c6 100644
--- a/system/include/libc/libgen.h
+++ b/system/include/libc/libgen.h
@@ -1,23 +1,15 @@
-/*
- * libgen.h - defined by XPG4
- */
-
-#ifndef _LIBGEN_H_
-#define _LIBGEN_H_
-
-#include "_ansi.h"
-#include <sys/reent.h>
+#ifndef _LIBGEN_H
+#define _LIBGEN_H
#ifdef __cplusplus
extern "C" {
#endif
-char *_EXFUN(basename, (char *));
-char *_EXFUN(dirname, (char *));
+char *dirname(char *);
+char *basename(char *);
#ifdef __cplusplus
}
#endif
-#endif /* _LIBGEN_H_ */
-
+#endif
diff --git a/system/include/libc/libintl.h b/system/include/libc/libintl.h
new file mode 100644
index 00000000..a2dada67
--- /dev/null
+++ b/system/include/libc/libintl.h
@@ -0,0 +1,25 @@
+#ifndef _LIBINTL_H
+#define _LIBINTL_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define __USE_GNU_GETTEXT 1
+#define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 1 : -1)
+
+char *gettext(const char *);
+char *dgettext(const char *, const char *);
+char *dcgettext(const char *, const char *, int);
+char *ngettext(const char *, const char *, unsigned long);
+char *dngettext(const char *, const char *, const char *, unsigned long);
+char *dcngettext(const char *, const char *, const char *, unsigned long, int);
+char *textdomain(const char *);
+char *bindtextdomain (const char *, const char *);
+char *bind_textdomain_codeset(const char *, const char *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/limits.h b/system/include/libc/limits.h
index 3f1def0f..54d1940b 100644
--- a/system/include/libc/limits.h
+++ b/system/include/libc/limits.h
@@ -1,155 +1,146 @@
-#ifndef _LIBC_LIMITS_H_
-# define _LIBC_LIMITS_H_ 1
-
-#include <newlib.h>
-
-# ifdef _MB_LEN_MAX
-# define MB_LEN_MAX _MB_LEN_MAX
-# else
-# define MB_LEN_MAX 1
-# endif
-
-/* Maximum number of positional arguments, if _WANT_IO_POS_ARGS. */
-# ifndef NL_ARGMAX
-# define NL_ARGMAX 32
-# endif
-
-/* if do not have #include_next support, then we
- have to define the limits here. */
-# if 1 /* XXX Emscripten: force this !defined __GNUC__ || __GNUC__ < 2 */
-
-# ifndef _LIMITS_H
-# define _LIMITS_H 1
-
-# include <sys/config.h>
-
-/* Number of bits in a `char'. */
-# undef CHAR_BIT
-# define CHAR_BIT 8
-
-/* Minimum and maximum values a `signed char' can hold. */
-# undef SCHAR_MIN
-# define SCHAR_MIN (-128)
-# undef SCHAR_MAX
-# define SCHAR_MAX 127
-
-/* Maximum value an `unsigned char' can hold. (Minimum is 0). */
-# undef UCHAR_MAX
-# define UCHAR_MAX 255
-
-/* Minimum and maximum values a `char' can hold. */
-# ifdef __CHAR_UNSIGNED__
-# undef CHAR_MIN
-# define CHAR_MIN 0
-# undef CHAR_MAX
-# define CHAR_MAX 255
-# else
-# undef CHAR_MIN
-# define CHAR_MIN (-128)
-# undef CHAR_MAX
-# define CHAR_MAX 127
-# endif
-
-/* Minimum and maximum values a `signed short int' can hold. */
-# undef SHRT_MIN
-/* For the sake of 16 bit hosts, we may not use -32768 */
-# define SHRT_MIN (-32767-1)
-# undef SHRT_MAX
-# define SHRT_MAX 32767
-
-/* Maximum value an `unsigned short int' can hold. (Minimum is 0). */
-# undef USHRT_MAX
-# define USHRT_MAX 65535
-
-/* Minimum and maximum values a `signed int' can hold. */
-# ifndef __INT_MAX__
-# define __INT_MAX__ 2147483647
-# endif
-# undef INT_MIN
-# define INT_MIN (-INT_MAX-1)
-# undef INT_MAX
-# define INT_MAX __INT_MAX__
-
-/* Maximum value an `unsigned int' can hold. (Minimum is 0). */
-# undef UINT_MAX
-# define UINT_MAX (INT_MAX * 2U + 1)
-
-/* Minimum and maximum values a `signed long int' can hold.
- (Same as `int'). */
-# ifndef __LONG_MAX__
-# if defined (__alpha__) || (defined (__sparc__) && defined(__arch64__)) || defined (__sparcv9)
-# define __LONG_MAX__ 9223372036854775807L
-# else
-# define __LONG_MAX__ 2147483647L
-# endif /* __alpha__ || sparc64 */
-# endif
-# undef LONG_MIN
-# define LONG_MIN (-LONG_MAX-1)
-# undef LONG_MAX
-# define LONG_MAX __LONG_MAX__
-
-/* Maximum value an `unsigned long int' can hold. (Minimum is 0). */
-# undef ULONG_MAX
-# define ULONG_MAX (LONG_MAX * 2UL + 1)
-
-# ifndef __LONG_LONG_MAX__
-# define __LONG_LONG_MAX__ 9223372036854775807LL
-# endif
-
-# if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
-/* Minimum and maximum values a `signed long long int' can hold. */
-# undef LLONG_MIN
-# define LLONG_MIN (-LLONG_MAX-1)
-# undef LLONG_MAX
-# define LLONG_MAX __LONG_LONG_MAX__
-
-/* Maximum value an `unsigned long long int' can hold. (Minimum is 0). */
-# undef ULLONG_MAX
-# define ULLONG_MAX (LLONG_MAX * 2ULL + 1)
-# endif
-
-# if defined (__GNU_LIBRARY__) ? defined (__USE_GNU) : !defined (__STRICT_ANSI__)
-/* Minimum and maximum values a `signed long long int' can hold. */
-# undef LONG_LONG_MIN
-# define LONG_LONG_MIN (-LONG_LONG_MAX-1)
-# undef LONG_LONG_MAX
-# define LONG_LONG_MAX __LONG_LONG_MAX__
-
-/* Maximum value an `unsigned long long int' can hold. (Minimum is 0). */
-# undef ULONG_LONG_MAX
-# define ULONG_LONG_MAX (LONG_LONG_MAX * 2ULL + 1)
-# endif
-
-# endif /* _LIMITS_H */
-# endif /* GCC 2. */
-
-#endif /* !_LIBC_LIMITS_H_ */
-
-#if defined __GNUC__ && !defined _GCC_LIMITS_H_
-/* `_GCC_LIMITS_H_' is what GCC's file defines. */
-/* XXX Emscripten # include_next <limits.h> */
-#endif /* __GNUC__ && !_GCC_LIMITS_H_ */
-
-#ifndef _POSIX2_RE_DUP_MAX
-/* The maximum number of repeated occurrences of a regular expression
- * permitted when using the interval notation `\{M,N\}'. */
-#define _POSIX2_RE_DUP_MAX 255
-#endif /* _POSIX2_RE_DUP_MAX */
-
-#ifndef ARG_MAX
-#define ARG_MAX 4096
-#endif
+#ifndef _LIMITS_H
+#define _LIMITS_H
-#ifndef PATH_MAX
-#define PATH_MAX 4096
-#endif
+#include <features.h>
+
+/* Most limits are system-specific */
+
+#include <bits/limits.h>
-/* XXX EMSCRIPTEN */
-#ifndef _LIBC_LIMITS2_H_
-#define _LIBC_LIMITS2_H_ 1
+/* Support signed or unsigned plain-char */
-#define _POSIX_PATH_MAX PATH_MAX
-#define PTHREAD_STACK_MIN 0
+#if '\0'-1 > 0
+#define CHAR_MIN 0
+#define CHAR_MAX 255
+#else
+#define CHAR_MIN (-128)
+#define CHAR_MAX 127
+#endif
+
+/* Some universal constants... */
+
+#define CHAR_BIT 8
+#define SCHAR_MIN (-128)
+#define SCHAR_MAX 127
+#define UCHAR_MAX 255
+#define SHRT_MIN (-1-0x7fff)
+#define SHRT_MAX 0x7fff
+#define USHRT_MAX 0xffff
+#define INT_MIN (-1-0x7fffffff)
+#define INT_MAX 0x7fffffff
+#define UINT_MAX 0xffffffffU
+#define LONG_MIN (-LONG_MAX-1)
+#define ULONG_MAX (2UL*LONG_MAX+1)
+#define LLONG_MIN (-LLONG_MAX-1)
+#define ULLONG_MAX (2ULL*LLONG_MAX+1)
+
+#define MB_LEN_MAX 4
+
+#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
+ || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+
+#define PIPE_BUF 4096
+#define PAGESIZE PAGE_SIZE
+#define FILESIZEBITS 64
+#define NAME_MAX 255
+#define SYMLINK_MAX 255
+#define PATH_MAX 4096
+#define NZERO 20
+#define NGROUPS_MAX 32
+#define ARG_MAX 131072
+#define IOV_MAX 1024
+#define SYMLOOP_MAX 40
+#define WORD_BIT 32
+#define SSIZE_MAX LONG_MAX
+#define TZNAME_MAX 6
+#define TTY_NAME_MAX 20
+#define HOST_NAME_MAX 255
+
+/* Implementation choices... */
+
+#define PTHREAD_KEYS_MAX 128
+#define PTHREAD_STACK_MIN 2048
+#define PTHREAD_DESTRUCTOR_ITERATIONS 4
+#define SEM_VALUE_MAX 0x7fffffff
+#define SEM_NSEMS_MAX 256
+#define DELAYTIMER_MAX 0x7fffffff
+#define MQ_PRIO_MAX 32768
+#define LOGIN_NAME_MAX 256
+
+/* Arbitrary numbers... */
+
+#define BC_BASE_MAX 99
+#define BC_DIM_MAX 2048
+#define BC_SCALE_MAX 99
+#define BC_STRING_MAX 1000
+#define CHARCLASS_NAME_MAX 14
+#define COLL_WEIGHTS_MAX 2
+#define EXPR_NEST_MAX 32
+#define LINE_MAX 4096
+#define RE_DUP_MAX 255
+
+#define NL_ARGMAX 9
+#define NL_LANGMAX 32
+#define NL_MSGMAX 32767
+#define NL_NMAX (MB_LEN_MAX*4)
+#define NL_SETMAX 255
+#define NL_TEXTMAX 2048
#endif
+/* POSIX/SUS requirements follow. These numbers come directly
+ * from SUS and have nothing to do with the host system. */
+
+#define _POSIX_AIO_LISTIO_MAX 2
+#define _POSIX_AIO_MAX 1
+#define _POSIX_ARG_MAX 4096
+#define _POSIX_CHILD_MAX 25
+#define _POSIX_CLOCKRES_MIN 20000000
+#define _POSIX_DELAYTIMER_MAX 32
+#define _POSIX_HOST_NAME_MAX 255
+#define _POSIX_LINK_MAX 8
+#define _POSIX_LOGIN_NAME_MAX 9
+#define _POSIX_MAX_CANON 255
+#define _POSIX_MAX_INPUT 255
+#define _POSIX_MQ_OPEN_MAX 8
+#define _POSIX_MQ_PRIO_MAX 32
+#define _POSIX_NAME_MAX 14
+#define _POSIX_NGROUPS_MAX 8
+#define _POSIX_OPEN_MAX 20
+#define _POSIX_PATH_MAX 256
+#define _POSIX_PIPE_BUF 512
+#define _POSIX_RE_DUP_MAX 255
+#define _POSIX_RTSIG_MAX 8
+#define _POSIX_SEM_NSEMS_MAX 256
+#define _POSIX_SEM_VALUE_MAX 32767
+#define _POSIX_SIGQUEUE_MAX 32
+#define _POSIX_SSIZE_MAX 32767
+#define _POSIX_STREAM_MAX 8
+#define _POSIX_SS_REPL_MAX 4
+#define _POSIX_SYMLINK_MAX 255
+#define _POSIX_SYMLOOP_MAX 8
+#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4
+#define _POSIX_THREAD_KEYS_MAX 128
+#define _POSIX_THREAD_THREADS_MAX 64
+#define _POSIX_TIMER_MAX 32
+#define _POSIX_TRACE_EVENT_NAME_MAX 30
+#define _POSIX_TRACE_NAME_MAX 8
+#define _POSIX_TRACE_SYS_MAX 8
+#define _POSIX_TRACE_USER_EVENT_MAX 32
+#define _POSIX_TTY_NAME_MAX 9
+#define _POSIX_TZNAME_MAX 6
+#define _POSIX2_BC_BASE_MAX 99
+#define _POSIX2_BC_DIM_MAX 2048
+#define _POSIX2_BC_SCALE_MAX 99
+#define _POSIX2_BC_STRING_MAX 1000
+#define _POSIX2_CHARCLASS_NAME_MAX 14
+#define _POSIX2_COLL_WEIGHTS_MAX 2
+#define _POSIX2_EXPR_NEST_MAX 32
+#define _POSIX2_LINE_MAX 2048
+#define _POSIX2_RE_DUP_MAX 255
+
+#define _XOPEN_IOV_MAX 16
+#define _XOPEN_NAME_MAX 255
+#define _XOPEN_PATH_MAX 1024
+
+#endif
diff --git a/system/include/libc/link.h b/system/include/libc/link.h
new file mode 100644
index 00000000..9349cddd
--- /dev/null
+++ b/system/include/libc/link.h
@@ -0,0 +1,54 @@
+#ifndef _LINK_H
+#define _LINK_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <elf.h>
+#define __NEED_size_t
+#define __NEED_uint32_t
+#include <bits/alltypes.h>
+
+#if UINTPTR_MAX > 0xffffffff
+#define ElfW(type) Elf64_ ## type
+#else
+#define ElfW(type) Elf32_ ## type
+#endif
+
+/* this is the same everywhere except alpha and s390 */
+typedef uint32_t Elf_Symndx;
+
+struct dl_phdr_info {
+ ElfW(Addr) dlpi_addr;
+ const char *dlpi_name;
+ const ElfW(Phdr) *dlpi_phdr;
+ ElfW(Half) dlpi_phnum;
+ unsigned long long int dlpi_adds;
+ unsigned long long int dlpi_subs;
+ size_t dlpi_tls_modid;
+ void *dlpi_tls_data;
+};
+
+struct link_map {
+ ElfW(Addr) l_addr;
+ char *l_name;
+ ElfW(Dyn) *l_ld;
+ struct link_map *l_next, *l_prev;
+};
+
+struct r_debug {
+ int r_version;
+ struct link_map *r_map;
+ ElfW(Addr) r_brk;
+ enum { RT_CONSISTENT, RT_ADD, RT_DELETE } r_state;
+ ElfW(Addr) r_ldbase;
+};
+
+int dl_iterate_phdr(int (*)(struct dl_phdr_info *, size_t, void *), void *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/locale.h b/system/include/libc/locale.h
index b75bed7a..7e80fd93 100644
--- a/system/include/libc/locale.h
+++ b/system/include/libc/locale.h
@@ -1,80 +1,82 @@
-/*
- locale.h
- Values appropriate for the formatting of monetary and other
- numberic quantities.
-*/
+#ifndef _LOCALE_H
+#define _LOCALE_H
-#ifndef _LOCALE_H_
-#define _LOCALE_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
-#include "_ansi.h"
+#include <features.h>
-#ifndef NULL
-#define NULL 0
-#endif
+#define NULL 0L
+
+#define LC_CTYPE 0
+#define LC_NUMERIC 1
+#define LC_TIME 2
+#define LC_COLLATE 3
+#define LC_MONETARY 4
+#define LC_MESSAGES 5
+#define LC_ALL 6
+
+struct lconv {
+ char *decimal_point;
+ char *thousands_sep;
+ char *grouping;
-#define LC_ALL 0
-#define LC_COLLATE 1
-#define LC_CTYPE 2
-#define LC_MONETARY 3
-#define LC_NUMERIC 4
-#define LC_TIME 5
-#define LC_MESSAGES 6
-
-/* XXX Emscripten: add masks */
-#define LC_ALL_MASK (1 << LC_ALL)
-#define LC_COLLATE_MASK (1 << LC_COLLATE)
-#define LC_CTYPE_MASK (1 << LC_CTYPE)
-#define LC_MONETARY_MASK (1 << LC_MONETARY)
-#define LC_NUMERIC_MASK (1 << LC_NUMERIC)
-#define LC_TIME_MASK (1 << LC_TIME)
-#define LC_MESSAGES_MASK (1 << LC_MESSAGES)
-
-_BEGIN_STD_C
-
-struct lconv
-{
- char *decimal_point;
- char *thousands_sep;
- char *grouping;
- char *int_curr_symbol;
- char *currency_symbol;
- char *mon_decimal_point;
- char *mon_thousands_sep;
- char *mon_grouping;
- char *positive_sign;
- char *negative_sign;
- char int_frac_digits;
- char frac_digits;
- char p_cs_precedes;
- char p_sep_by_space;
- char n_cs_precedes;
- char n_sep_by_space;
- char p_sign_posn;
- char n_sign_posn;
- char int_n_cs_precedes;
- char int_n_sep_by_space;
- char int_n_sign_posn;
- char int_p_cs_precedes;
- char int_p_sep_by_space;
- char int_p_sign_posn;
+ char *int_curr_symbol;
+ char *currency_symbol;
+ char *mon_decimal_point;
+ char *mon_thousands_sep;
+ char *mon_grouping;
+ char *positive_sign;
+ char *negative_sign;
+ char int_frac_digits;
+ char frac_digits;
+ char p_cs_precedes;
+ char p_sep_by_space;
+ char n_cs_precedes;
+ char n_sep_by_space;
+ char p_sign_posn;
+ char n_sign_posn;
+ char int_p_cs_precedes;
+ char int_p_sep_by_space;
+ char int_n_cs_precedes;
+ char int_n_sep_by_space;
+ char int_p_sign_posn;
+ char int_n_sign_posn;
};
-#ifndef _REENT_ONLY
-char *_EXFUN(setlocale,(int category, const char *locale));
-struct lconv *_EXFUN(localeconv,(void));
-#endif
-struct _reent;
-char *_EXFUN(_setlocale_r,(struct _reent *, int category, const char *locale));
-struct lconv *_EXFUN(_localeconv_r,(struct _reent *));
+char *setlocale (int, const char *);
+struct lconv *localeconv(void);
+
+
+#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
+ || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+
+#define __NEED_locale_t
-/* XXX Emscripten */
-typedef void* locale_t;
-locale_t newlocale(int category_mask, const char *locale, locale_t base);
-void freelocale(locale_t locobj);
-locale_t uselocale(locale_t newloc);
+#include <bits/alltypes.h>
-_END_STD_C
+#define LC_GLOBAL_LOCALE ((locale_t)-1)
-#endif /* _LOCALE_H_ */
+#define LC_CTYPE_MASK (1<<LC_CTYPE)
+#define LC_NUMERIC_MASK (1<<LC_NUMERIC)
+#define LC_TIME_MASK (1<<LC_TIME)
+#define LC_COLLATE_MASK (1<<LC_COLLATE)
+#define LC_MONETARY_MASK (1<<LC_MONETARY)
+#define LC_MESSAGES_MASK (1<<LC_MESSAGES)
+#define LC_ALL_MASK 0x7fffffff
+
+locale_t duplocale(locale_t);
+void freelocale(locale_t);
+locale_t newlocale(int, const char *, locale_t);
+locale_t uselocale(locale_t);
+
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/machine/_default_types.h b/system/include/libc/machine/_default_types.h
deleted file mode 100644
index 9a5fc8d9..00000000
--- a/system/include/libc/machine/_default_types.h
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * $Id: _default_types.h,v 1.2 2008/06/11 22:14:54 jjohnstn Exp $
- */
-
-#ifndef _MACHINE__DEFAULT_TYPES_H
-#define _MACHINE__DEFAULT_TYPES_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * Guess on types by examining *_MIN / *_MAX defines.
- */
-#if defined(__GNUC__) && ((__GNUC__ >= 4) || (__GNUC__ >= 3 ) \
- && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ > 2 ))
-/* GCC >= 3.3.0 has __<val>__ implicitly defined. */
-#define __EXP(x) __##x##__
-#else
-/* Fall back to POSIX versions from <limits.h> */
-#define __EXP(x) x
-#include <limits.h>
-#endif
-
-#if __EXP(SCHAR_MAX) == 0x7f
-typedef signed char __int8_t ;
-typedef unsigned char __uint8_t ;
-#define ___int8_t_defined 1
-#endif
-
-#if __EXP(INT_MAX) == 0x7fff
-typedef signed int __int16_t;
-typedef unsigned int __uint16_t;
-#define ___int16_t_defined 1
-#elif __EXP(SHRT_MAX) == 0x7fff
-typedef signed short __int16_t;
-typedef unsigned short __uint16_t;
-#define ___int16_t_defined 1
-#elif __EXP(SCHAR_MAX) == 0x7fff
-typedef signed char __int16_t;
-typedef unsigned char __uint16_t;
-#define ___int16_t_defined 1
-#endif
-
-#if ___int16_t_defined
-typedef __int16_t __int_least16_t;
-typedef __uint16_t __uint_least16_t;
-#define ___int_least16_t_defined 1
-
-#if !___int8_t_defined
-typedef __int16_t __int_least8_t;
-typedef __uint16_t __uint_least8_t;
-#define ___int_least8_t_defined 1
-#endif
-#endif
-
-#if __EXP(INT_MAX) == 0x7fffffffL
-typedef signed int __int32_t;
-typedef unsigned int __uint32_t;
-#define ___int32_t_defined 1
-#elif __EXP(LONG_MAX) == 0x7fffffffL
-typedef signed long __int32_t;
-typedef unsigned long __uint32_t;
-#define ___int32_t_defined 1
-#elif __EXP(SHRT_MAX) == 0x7fffffffL
-typedef signed short __int32_t;
-typedef unsigned short __uint32_t;
-#define ___int32_t_defined 1
-#elif __EXP(SCHAR_MAX) == 0x7fffffffL
-typedef signed char __int32_t;
-typedef unsigned char __uint32_t;
-#define ___int32_t_defined 1
-#endif
-
-#if ___int32_t_defined
-typedef __int32_t __int_least32_t;
-typedef __uint32_t __uint_least32_t;
-#define ___int_least32_t_defined 1
-
-#if !___int8_t_defined
-typedef __int32_t __int_least8_t;
-typedef __uint32_t __uint_least8_t;
-#define ___int_least8_t_defined 1
-#endif
-#if !___int16_t_defined
-typedef __int32_t __int_least16_t;
-typedef __uint32_t __uint_least16_t;
-#define ___int_least16_t_defined 1
-#endif
-#endif
-
-#if __EXP(LONG_MAX) > 0x7fffffff
-typedef signed long __int64_t;
-typedef unsigned long __uint64_t;
-#define ___int64_t_defined 1
-
-/* GCC has __LONG_LONG_MAX__ */
-#elif defined(__LONG_LONG_MAX__) && (__LONG_LONG_MAX__ > 0x7fffffff)
-typedef signed long long __int64_t;
-typedef unsigned long long __uint64_t;
-#define ___int64_t_defined 1
-
-/* POSIX mandates LLONG_MAX in <limits.h> */
-#elif defined(LLONG_MAX) && (LLONG_MAX > 0x7fffffff)
-typedef signed long long __int64_t;
-typedef unsigned long long __uint64_t;
-#define ___int64_t_defined 1
-
-#elif __EXP(INT_MAX) > 0x7fffffff
-typedef signed int __int64_t;
-typedef unsigned int __uint64_t;
-#define ___int64_t_defined 1
-#endif
-
-#undef __EXP
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _MACHINE__DEFAULT_TYPES_H */
diff --git a/system/include/libc/machine/_types.h b/system/include/libc/machine/_types.h
deleted file mode 100644
index 18f96d5f..00000000
--- a/system/include/libc/machine/_types.h
+++ /dev/null
@@ -1,8 +0,0 @@
-/*
- * $Id: _types.h,v 1.3 2007/09/07 21:16:25 jjohnstn Exp $
- */
-
-#ifndef _MACHINE__TYPES_H
-#define _MACHINE__TYPES_H
-#include <machine/_default_types.h>
-#endif
diff --git a/system/include/libc/machine/ansi.h b/system/include/libc/machine/ansi.h
deleted file mode 100644
index 737b6d06..00000000
--- a/system/include/libc/machine/ansi.h
+++ /dev/null
@@ -1 +0,0 @@
-/* dummy header file to support BSD compiler */
diff --git a/system/include/libc/machine/endian.h b/system/include/libc/machine/endian.h
deleted file mode 100644
index cec97a7b..00000000
--- a/system/include/libc/machine/endian.h
+++ /dev/null
@@ -1,31 +0,0 @@
-#ifndef __MACHINE_ENDIAN_H__
-
-#include <sys/config.h>
-
-#ifndef BIG_ENDIAN
-#define BIG_ENDIAN 4321
-#endif
-#ifndef LITTLE_ENDIAN
-#define LITTLE_ENDIAN 1234
-#endif
-
-#ifndef __LITTLE_ENDIAN
-#define __LITTLE_ENDIAN LITTLE_ENDIAN
-#endif
-#ifndef __BIG_ENDIAN
-#define __BIG_ENDIAN BIG_ENDIAN
-#endif
-
-#ifndef BYTE_ORDER
-#if defined(__IEEE_LITTLE_ENDIAN) || defined(__IEEE_BYTES_LITTLE_ENDIAN)
-#define BYTE_ORDER LITTLE_ENDIAN
-#else
-#define BYTE_ORDER BIG_ENDIAN
-#endif
-#endif
-
-#ifndef __BYTE_ORDER
-#define __BYTE_ORDER BYTE_ORDER
-#endif
-
-#endif /* __MACHINE_ENDIAN_H__ */
diff --git a/system/include/libc/machine/fastmath.h b/system/include/libc/machine/fastmath.h
deleted file mode 100644
index b13befa2..00000000
--- a/system/include/libc/machine/fastmath.h
+++ /dev/null
@@ -1,100 +0,0 @@
-#ifdef __sysvnecv70_target
-double EXFUN(fast_sin,(double));
-double EXFUN(fast_cos,(double));
-double EXFUN(fast_tan,(double));
-
-double EXFUN(fast_asin,(double));
-double EXFUN(fast_acos,(double));
-double EXFUN(fast_atan,(double));
-
-double EXFUN(fast_sinh,(double));
-double EXFUN(fast_cosh,(double));
-double EXFUN(fast_tanh,(double));
-
-double EXFUN(fast_asinh,(double));
-double EXFUN(fast_acosh,(double));
-double EXFUN(fast_atanh,(double));
-
-double EXFUN(fast_abs,(double));
-double EXFUN(fast_sqrt,(double));
-double EXFUN(fast_exp2,(double));
-double EXFUN(fast_exp10,(double));
-double EXFUN(fast_expe,(double));
-double EXFUN(fast_log10,(double));
-double EXFUN(fast_log2,(double));
-double EXFUN(fast_loge,(double));
-
-
-#define sin(x) fast_sin(x)
-#define cos(x) fast_cos(x)
-#define tan(x) fast_tan(x)
-#define asin(x) fast_asin(x)
-#define acos(x) fast_acos(x)
-#define atan(x) fast_atan(x)
-#define sinh(x) fast_sinh(x)
-#define cosh(x) fast_cosh(x)
-#define tanh(x) fast_tanh(x)
-#define asinh(x) fast_asinh(x)
-#define acosh(x) fast_acosh(x)
-#define atanh(x) fast_atanh(x)
-#define abs(x) fast_abs(x)
-#define sqrt(x) fast_sqrt(x)
-#define exp2(x) fast_exp2(x)
-#define exp10(x) fast_exp10(x)
-#define expe(x) fast_expe(x)
-#define log10(x) fast_log10(x)
-#define log2(x) fast_log2(x)
-#define loge(x) fast_loge(x)
-
-#ifdef _HAVE_STDC
-/* These functions are in assembler, they really do take floats. This
- can only be used with a real ANSI compiler */
-
-float EXFUN(fast_sinf,(float));
-float EXFUN(fast_cosf,(float));
-float EXFUN(fast_tanf,(float));
-
-float EXFUN(fast_asinf,(float));
-float EXFUN(fast_acosf,(float));
-float EXFUN(fast_atanf,(float));
-
-float EXFUN(fast_sinhf,(float));
-float EXFUN(fast_coshf,(float));
-float EXFUN(fast_tanhf,(float));
-
-float EXFUN(fast_asinhf,(float));
-float EXFUN(fast_acoshf,(float));
-float EXFUN(fast_atanhf,(float));
-
-float EXFUN(fast_absf,(float));
-float EXFUN(fast_sqrtf,(float));
-float EXFUN(fast_exp2f,(float));
-float EXFUN(fast_exp10f,(float));
-float EXFUN(fast_expef,(float));
-float EXFUN(fast_log10f,(float));
-float EXFUN(fast_log2f,(float));
-float EXFUN(fast_logef,(float));
-#define sinf(x) fast_sinf(x)
-#define cosf(x) fast_cosf(x)
-#define tanf(x) fast_tanf(x)
-#define asinf(x) fast_asinf(x)
-#define acosf(x) fast_acosf(x)
-#define atanf(x) fast_atanf(x)
-#define sinhf(x) fast_sinhf(x)
-#define coshf(x) fast_coshf(x)
-#define tanhf(x) fast_tanhf(x)
-#define asinhf(x) fast_asinhf(x)
-#define acoshf(x) fast_acoshf(x)
-#define atanhf(x) fast_atanhf(x)
-#define absf(x) fast_absf(x)
-#define sqrtf(x) fast_sqrtf(x)
-#define exp2f(x) fast_exp2f(x)
-#define exp10f(x) fast_exp10f(x)
-#define expef(x) fast_expef(x)
-#define log10f(x) fast_log10f(x)
-#define log2f(x) fast_log2f(x)
-#define logef(x) fast_logef(x)
-#endif
-/* Override the functions defined in math.h */
-#endif /* __sysvnecv70_target */
-
diff --git a/system/include/libc/machine/ieeefp.h b/system/include/libc/machine/ieeefp.h
deleted file mode 100644
index fd3fca97..00000000
--- a/system/include/libc/machine/ieeefp.h
+++ /dev/null
@@ -1,376 +0,0 @@
-#ifndef __IEEE_BIG_ENDIAN
-#ifndef __IEEE_LITTLE_ENDIAN
-
-/* This file can define macros to choose variations of the IEEE float
- format:
-
- _FLT_LARGEST_EXPONENT_IS_NORMAL
-
- Defined if the float format uses the largest exponent for finite
- numbers rather than NaN and infinity representations. Such a
- format cannot represent NaNs or infinities at all, but it's FLT_MAX
- is twice the IEEE value.
-
- _FLT_NO_DENORMALS
-
- Defined if the float format does not support IEEE denormals. Every
- float with a zero exponent is taken to be a zero representation.
-
- ??? At the moment, there are no equivalent macros above for doubles and
- the macros are not fully supported by --enable-newlib-hw-fp.
-
- __IEEE_BIG_ENDIAN
-
- Defined if the float format is big endian. This is mutually exclusive
- with __IEEE_LITTLE_ENDIAN.
-
- __IEEE_LITTLE_ENDIAN
-
- Defined if the float format is little endian. This is mutually exclusive
- with __IEEE_BIG_ENDIAN.
-
- Note that one of __IEEE_BIG_ENDIAN or __IEEE_LITTLE_ENDIAN must be specified for a
- platform or error will occur.
-
- __IEEE_BYTES_LITTLE_ENDIAN
-
- This flag is used in conjunction with __IEEE_BIG_ENDIAN to describe a situation
- whereby multiple words of an IEEE floating point are in big endian order, but the
- words themselves are little endian with respect to the bytes.
-
- _DOUBLE_IS_32BITS
-
- This is used on platforms that support double by using the 32-bit IEEE
- float type.
-
- _FLOAT_ARG
-
- This represents what type a float arg is passed as. It is used when the type is
- not promoted to double.
-
-*/
-
-#if (defined(__arm__) || defined(__thumb__)) && !defined(__MAVERICK__)
-/* ARM traditionally used big-endian words; and within those words the
- byte ordering was big or little endian depending upon the target.
- Modern floating-point formats are naturally ordered; in this case
- __VFP_FP__ will be defined, even if soft-float. */
-#ifdef __VFP_FP__
-# ifdef __ARMEL__
-# define __IEEE_LITTLE_ENDIAN
-# else
-# define __IEEE_BIG_ENDIAN
-# endif
-#else
-# define __IEEE_BIG_ENDIAN
-# ifdef __ARMEL__
-# define __IEEE_BYTES_LITTLE_ENDIAN
-# endif
-#endif
-#endif
-
-#ifdef __hppa__
-#define __IEEE_BIG_ENDIAN
-#endif
-
-#ifdef __SPU__
-#define __IEEE_BIG_ENDIAN
-
-#define isfinite(__y) \
- (__extension__ ({int __cy; \
- (sizeof (__y) == sizeof (float)) ? (1) : \
- (__cy = fpclassify(__y)) != FP_INFINITE && __cy != FP_NAN;}))
-
-#define isinf(__x) ((sizeof (__x) == sizeof (float)) ? (0) : __isinfd(__x))
-#define isnan(__x) ((sizeof (__x) == sizeof (float)) ? (0) : __isnand(__x))
-
-/*
- * Macros for use in ieeefp.h. We can't just define the real ones here
- * (like those above) as we have name space issues when this is *not*
- * included via generic the ieeefp.h.
- */
-#define __ieeefp_isnanf(x) 0
-#define __ieeefp_isinff(x) 0
-#define __ieeefp_finitef(x) 1
-#endif
-
-#ifdef __sparc__
-#ifdef __LITTLE_ENDIAN_DATA__
-#define __IEEE_LITTLE_ENDIAN
-#else
-#define __IEEE_BIG_ENDIAN
-#endif
-#endif
-
-#if defined(__m68k__) || defined(__mc68000__)
-#define __IEEE_BIG_ENDIAN
-#endif
-
-#if defined(__mc68hc11__) || defined(__mc68hc12__) || defined(__mc68hc1x__)
-#define __IEEE_BIG_ENDIAN
-#ifdef __HAVE_SHORT_DOUBLE__
-# define _DOUBLE_IS_32BITS
-#endif
-#endif
-
-#if defined (__H8300__) || defined (__H8300H__) || defined (__H8300S__) || defined (__H8500__) || defined (__H8300SX__)
-#define __IEEE_BIG_ENDIAN
-#define _FLOAT_ARG float
-#define _DOUBLE_IS_32BITS
-#endif
-
-#if defined (__xc16x__) || defined (__xc16xL__) || defined (__xc16xS__)
-#define __IEEE_LITTLE_ENDIAN
-#define _FLOAT_ARG float
-#define _DOUBLE_IS_32BITS
-#endif
-
-
-#ifdef __sh__
-#ifdef __LITTLE_ENDIAN__
-#define __IEEE_LITTLE_ENDIAN
-#else
-#define __IEEE_BIG_ENDIAN
-#endif
-#if defined(__SH2E__) || defined(__SH3E__) || defined(__SH4_SINGLE_ONLY__) || defined(__SH2A_SINGLE_ONLY__)
-#define _DOUBLE_IS_32BITS
-#endif
-#endif
-
-#ifdef _AM29K
-#define __IEEE_BIG_ENDIAN
-#endif
-
-#ifdef _WIN32
-#define __IEEE_LITTLE_ENDIAN
-#endif
-
-#ifdef __i386__
-#define __IEEE_LITTLE_ENDIAN
-#endif
-
-#ifdef __i960__
-#define __IEEE_LITTLE_ENDIAN
-#endif
-
-#ifdef __lm32__
-#define __IEEE_BIG_ENDIAN
-#endif
-
-#ifdef __M32R__
-#define __IEEE_BIG_ENDIAN
-#endif
-
-#if defined(_C4x) || defined(_C3x)
-#define __IEEE_BIG_ENDIAN
-#define _DOUBLE_IS_32BITS
-#endif
-
-#ifdef __TMS320C6X__
-#ifdef _BIG_ENDIAN
-#define __IEEE_BIG_ENDIAN
-#else
-#define __IEEE_LITTLE_ENDIAN
-#endif
-#endif
-
-#ifdef __TIC80__
-#define __IEEE_LITTLE_ENDIAN
-#endif
-
-#ifdef __MIPSEL__
-#define __IEEE_LITTLE_ENDIAN
-#endif
-#ifdef __MIPSEB__
-#define __IEEE_BIG_ENDIAN
-#endif
-
-#ifdef __MMIX__
-#define __IEEE_BIG_ENDIAN
-#endif
-
-#ifdef __D30V__
-#define __IEEE_BIG_ENDIAN
-#endif
-
-/* necv70 was __IEEE_LITTLE_ENDIAN. */
-
-#ifdef __W65__
-#define __IEEE_LITTLE_ENDIAN
-#define _DOUBLE_IS_32BITS
-#endif
-
-#if defined(__Z8001__) || defined(__Z8002__)
-#define __IEEE_BIG_ENDIAN
-#endif
-
-#ifdef __m88k__
-#define __IEEE_BIG_ENDIAN
-#endif
-
-#ifdef __mn10300__
-#define __IEEE_LITTLE_ENDIAN
-#endif
-
-#ifdef __mn10200__
-#define __IEEE_LITTLE_ENDIAN
-#define _DOUBLE_IS_32BITS
-#endif
-
-#ifdef __v800
-#define __IEEE_LITTLE_ENDIAN
-#endif
-
-#ifdef __v850
-#define __IEEE_LITTLE_ENDIAN
-#endif
-
-#ifdef __D10V__
-#define __IEEE_BIG_ENDIAN
-#if __DOUBLE__ == 32
-#define _DOUBLE_IS_32BITS
-#endif
-#endif
-
-#ifdef __PPC__
-#if (defined(_BIG_ENDIAN) && _BIG_ENDIAN) || (defined(_AIX) && _AIX)
-#define __IEEE_BIG_ENDIAN
-#else
-#if (defined(_LITTLE_ENDIAN) && _LITTLE_ENDIAN) || (defined(__sun__) && __sun__) || (defined(_WIN32) && _WIN32)
-#define __IEEE_LITTLE_ENDIAN
-#endif
-#endif
-#endif
-
-#ifdef __xstormy16__
-#define __IEEE_LITTLE_ENDIAN
-#endif
-
-#ifdef __arc__
-#ifdef __big_endian__
-#define __IEEE_BIG_ENDIAN
-#else
-#define __IEEE_LITTLE_ENDIAN
-#endif
-#endif
-
-#ifdef __CRX__
-#define __IEEE_LITTLE_ENDIAN
-#endif
-
-#ifdef __fr30__
-#define __IEEE_BIG_ENDIAN
-#endif
-
-#ifdef __mcore__
-#define __IEEE_BIG_ENDIAN
-#endif
-
-#ifdef __mt__
-#define __IEEE_BIG_ENDIAN
-#endif
-
-#ifdef __frv__
-#define __IEEE_BIG_ENDIAN
-#endif
-
-#ifdef __moxie__
-#define __IEEE_BIG_ENDIAN
-#endif
-
-#ifdef __ia64__
-#ifdef __BIG_ENDIAN__
-#define __IEEE_BIG_ENDIAN
-#else
-#define __IEEE_LITTLE_ENDIAN
-#endif
-#endif
-
-#ifdef __AVR__
-#define __IEEE_LITTLE_ENDIAN
-#define _DOUBLE_IS_32BITS
-#endif
-
-#if defined(__or32__) || defined(__or1k__) || defined(__or16__)
-#define __IEEE_BIG_ENDIAN
-#endif
-
-#ifdef __IP2K__
-#define __IEEE_BIG_ENDIAN
-#define __SMALL_BITFIELDS
-#define _DOUBLE_IS_32BITS
-#endif
-
-#ifdef __iq2000__
-#define __IEEE_BIG_ENDIAN
-#endif
-
-#ifdef __MAVERICK__
-#ifdef __ARMEL__
-# define __IEEE_LITTLE_ENDIAN
-#else /* must be __ARMEB__ */
-# define __IEEE_BIG_ENDIAN
-#endif /* __ARMEL__ */
-#endif /* __MAVERICK__ */
-
-#ifdef __m32c__
-#define __IEEE_LITTLE_ENDIAN
-#define __SMALL_BITFIELDS
-#endif
-
-#ifdef __CRIS__
-#define __IEEE_LITTLE_ENDIAN
-#endif
-
-#ifdef __BFIN__
-#define __IEEE_LITTLE_ENDIAN
-#endif
-
-#ifdef __x86_64__
-#define __IEEE_LITTLE_ENDIAN
-#endif
-
-#ifdef __mep__
-#ifdef __LITTLE_ENDIAN__
-#define __IEEE_LITTLE_ENDIAN
-#else
-#define __IEEE_BIG_ENDIAN
-#endif
-#endif
-
-#ifdef __MICROBLAZE__
-#define __IEEE_BIG_ENDIAN
-#endif
-
-#ifdef __RX__
-
-#ifdef __RX_BIG_ENDIAN__
-#define __IEEE_BIG_ENDIAN
-#else
-#define __IEEE_LITTLE_ENDIAN
-#endif
-
-#ifndef __RX_64BIT_DOUBLES__
-#define _DOUBLE_IS_32BITS
-#endif
-
-#ifdef __RX_16BIT_INTS__
-#define __SMALL_BITFIELDS
-#endif
-
-#endif
-
-#if (defined(__CR16__) || defined(__CR16C__) ||defined(__CR16CP__))
-#define __IEEE_LITTLE_ENDIAN
-#define __SMALL_BITFIELDS /* 16 Bit INT */
-#endif
-
-#ifndef __IEEE_BIG_ENDIAN
-#ifndef __IEEE_LITTLE_ENDIAN
-/* XXX Emscripten #error Endianess not declared!! */
-#endif /* not __IEEE_LITTLE_ENDIAN */
-#endif /* not __IEEE_BIG_ENDIAN */
-
-#endif /* not __IEEE_LITTLE_ENDIAN */
-#endif /* not __IEEE_BIG_ENDIAN */
-
diff --git a/system/include/libc/machine/malloc.h b/system/include/libc/machine/malloc.h
deleted file mode 100644
index fdada9ed..00000000
--- a/system/include/libc/machine/malloc.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef _MACHMALLOC_H_
-#define _MACHMALLOC_H_
-
-/* place holder so platforms may add malloc.h extensions */
-
-#endif /* _MACHMALLOC_H_ */
-
-
diff --git a/system/include/libc/machine/param.h b/system/include/libc/machine/param.h
deleted file mode 100644
index bdf8bf70..00000000
--- a/system/include/libc/machine/param.h
+++ /dev/null
@@ -1 +0,0 @@
-/* Place holder for machine-specific param.h. */
diff --git a/system/include/libc/machine/setjmp-dj.h b/system/include/libc/machine/setjmp-dj.h
deleted file mode 100644
index 9eb6bcf0..00000000
--- a/system/include/libc/machine/setjmp-dj.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 1991 DJ Delorie
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms is permitted
- * provided that the above copyright notice and following paragraph are
- * duplicated in all such forms.
- *
- * This file is distributed WITHOUT ANY WARRANTY; without even the implied
- * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-/* Modified to use SETJMP_DJ_H rather than SETJMP_H to avoid
- conflicting with setjmp.h. Ian Taylor, Cygnus support, April,
- 1993. */
-
-#ifndef _SETJMP_DJ_H_
-#define _SETJMP_DJ_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct {
- unsigned long eax;
- unsigned long ebx;
- unsigned long ecx;
- unsigned long edx;
- unsigned long esi;
- unsigned long edi;
- unsigned long ebp;
- unsigned long esp;
- unsigned long eip;
-} jmp_buf[1];
-
-extern int setjmp(jmp_buf);
-extern void longjmp(jmp_buf, int);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/system/include/libc/machine/setjmp.h b/system/include/libc/machine/setjmp.h
deleted file mode 100644
index d3f9bda3..00000000
--- a/system/include/libc/machine/setjmp.h
+++ /dev/null
@@ -1,361 +0,0 @@
-
-_BEGIN_STD_C
-
-#if defined(__arm__) || defined(__thumb__)
-/*
- * All callee preserved registers:
- * v1 - v7, fp, ip, sp, lr, f4, f5, f6, f7
- */
-#define _JBLEN 23
-#endif
-
-#if defined(__AVR__)
-#define _JBLEN 24
-#endif
-
-#ifdef __sparc__
-/*
- * onsstack,sigmask,sp,pc,npc,psr,g1,o0,wbcnt (sigcontext).
- * All else recovered by under/over(flow) handling.
- */
-#define _JBLEN 13
-#endif
-
-#ifdef __BFIN__
-#define _JBLEN 40
-#endif
-
-/* necv70 was 9 as well. */
-
-#if defined(__m68k__) || defined(__mc68000__)
-/*
- * onsstack,sigmask,sp,pc,psl,d2-d7,a2-a6,
- * fp2-fp7 for 68881.
- * All else recovered by under/over(flow) handling.
- */
-#define _JBLEN 34
-#endif
-
-#if defined(__mc68hc11__) || defined(__mc68hc12__) || defined(__mc68hc1x__)
-/*
- * D, X, Y are not saved.
- * Only take into account the pseudo soft registers (max 32).
- */
-#define _JBLEN 32
-#endif
-
-#if defined(__Z8001__) || defined(__Z8002__)
-/* 16 regs + pc */
-#define _JBLEN 20
-#endif
-
-#ifdef _AM29K
-/*
- * onsstack,sigmask,sp,pc,npc,psr,g1,o0,wbcnt (sigcontext).
- * All else recovered by under/over(flow) handling.
- */
-#define _JBLEN 9
-#endif
-
-#if defined(__CYGWIN__) && !defined (_JBLEN)
-#define _JBLEN (13 * 4)
-#elif defined (__i386__)
-#if defined(__unix__) || defined(__rtems__)
-# define _JBLEN 9
-#else
-#include "setjmp-dj.h"
-#endif
-#endif
-
-#ifdef __x86_64__
-#define _JBTYPE long long
-#define _JBLEN 8
-#endif
-
-#ifdef __i960__
-#define _JBLEN 35
-#endif
-
-#ifdef __M32R__
-/* Only 8 words are currently needed. 10 gives us some slop if we need
- to expand. */
-#define _JBLEN 10
-#endif
-
-#ifdef __mips__
-#ifdef __mips64
-#define _JBTYPE long long
-#endif
-#ifdef __mips_soft_float
-#define _JBLEN 11
-#else
-#define _JBLEN 23
-#endif
-#endif
-
-#ifdef __m88000__
-#define _JBLEN 21
-#endif
-
-#ifdef __H8300__
-#define _JBLEN 5
-#define _JBTYPE int
-#endif
-
-#ifdef __H8300H__
-/* same as H8/300 but registers are twice as big */
-#define _JBLEN 5
-#define _JBTYPE long
-#endif
-
-#if defined (__H8300S__) || defined (__H8300SX__)
-/* same as H8/300 but registers are twice as big */
-#define _JBLEN 5
-#define _JBTYPE long
-#endif
-
-#ifdef __H8500__
-#define _JBLEN 4
-#endif
-
-#ifdef __sh__
-#if __SH5__
-#define _JBLEN 50
-#define _JBTYPE long long
-#else
-#define _JBLEN 20
-#endif /* __SH5__ */
-#endif
-
-#ifdef __v800
-#define _JBLEN 28
-#endif
-
-#ifdef __PPC__
-#ifdef __ALTIVEC__
-#define _JBLEN 64
-#else
-#define _JBLEN 32
-#endif
-#define _JBTYPE double
-#endif
-
-#ifdef __MICROBLAZE__
-#define _JBLEN 20
-#define _JBTYPE unsigned int
-#endif
-
-#ifdef __hppa__
-/* %r30, %r2-%r18, %r27, pad, %fr12-%fr15.
- Note space exists for the FP registers, but they are not
- saved. */
-#define _JBLEN 28
-#endif
-
-#if defined(__mn10300__) || defined(__mn10200__)
-#ifdef __AM33_2__
-#define _JBLEN 26
-#else
-/* A guess */
-#define _JBLEN 10
-#endif
-#endif
-
-#ifdef __v850
-/* I think our setjmp is saving 15 regs at the moment. Gives us one word
- slop if we need to expand. */
-#define _JBLEN 16
-#endif
-
-#if defined(_C4x)
-#define _JBLEN 10
-#endif
-#if defined(_C3x)
-#define _JBLEN 9
-#endif
-
-#ifdef __TMS320C6X__
-#define _JBLEN 13
-#endif
-
-#ifdef __TIC80__
-#define _JBLEN 13
-#endif
-
-#ifdef __D10V__
-#define _JBLEN 8
-#endif
-
-#ifdef __D30V__
-#define _JBLEN ((64 /* GPR */ + (2*2) /* ACs */ + 18 /* CRs */) / 2)
-#define _JBTYPE double
-#endif
-
-#ifdef __frv__
-#define _JBLEN (68/2) /* room for 68 32-bit regs */
-#define _JBTYPE double
-#endif
-
-#ifdef __moxie__
-#define _JBLEN 16
-#endif
-
-#ifdef __CRX__
-#define _JBLEN 9
-#endif
-
-#if (defined(__CR16__) || defined(__CR16C__) ||defined(__CR16CP__))
-/* r6, r7, r8, r9, r10, r11, r12 (r12L, r12H),
- * r13 (r13L, r13H), ra(raL, raH), sp(spL, spH) */
-#define _JBLEN 14
-#define _JBTYPE unsigned short
-#endif
-
-#ifdef __fr30__
-#define _JBLEN 10
-#endif
-
-#ifdef __iq2000__
-#define _JBLEN 32
-#endif
-
-#ifdef __mcore__
-#define _JBLEN 16
-#endif
-
-#ifdef __MMIX__
-/* Using a layout compatible with GCC's built-in. */
-#define _JBLEN 5
-#define _JBTYPE unsigned long
-#endif
-
-#ifdef __mt__
-#define _JBLEN 16
-#endif
-
-#ifdef __SPU__
-#define _JBLEN 50
-#define _JBTYPE __vector signed int
-#endif
-
-#ifdef __xstormy16__
-/* 4 GPRs plus SP plus PC. */
-#define _JBLEN 8
-#endif
-
-#ifdef __mep__
-/* 16 GPRs, pc, hi, lo */
-#define _JBLEN 19
-#endif
-
-#ifdef __CRIS__
-#define _JBLEN 18
-#endif
-
-#ifdef __lm32__
-#define _JBLEN 19
-#endif
-
-#ifdef __m32c__
-#if defined(__r8c_cpu__) || defined(__m16c_cpu__)
-#define _JBLEN (22/2)
-#else
-#define _JBLEN (34/2)
-#endif
-#define _JBTYPE unsigned short
-#endif /* __m32c__ */
-
-#ifdef __RX__
-#define _JBLEN 0x44
-#endif
-
-#ifdef EMSCRIPTEN /* Not that this can actually work... */
-#define _JBLEN 20
-#define _JBTYPE unsigned short
-#endif
-
-#ifdef _JBLEN
-#ifdef _JBTYPE
-typedef _JBTYPE jmp_buf[_JBLEN];
-#else
-typedef int jmp_buf[_JBLEN];
-#endif
-#endif
-
-_END_STD_C
-
-#if defined(__CYGWIN__) || defined(__rtems__)
-#include <signal.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* POSIX sigsetjmp/siglongjmp macros */
-#ifdef _JBTYPE
-typedef _JBTYPE sigjmp_buf[_JBLEN+1+(sizeof (sigset_t)/sizeof (_JBTYPE))];
-#else
-typedef int sigjmp_buf[_JBLEN+1+(sizeof (sigset_t)/sizeof (int))];
-#endif
-
-#define _SAVEMASK _JBLEN
-#define _SIGMASK (_JBLEN+1)
-
-#ifdef __CYGWIN__
-# define _CYGWIN_WORKING_SIGSETJMP
-#endif
-
-#ifdef _POSIX_THREADS
-#define __SIGMASK_FUNC pthread_sigmask
-#else
-#define __SIGMASK_FUNC sigprocmask
-#endif
-
-#if defined(__GNUC__)
-
-#define sigsetjmp(env, savemask) \
- __extension__ \
- ({ \
- sigjmp_buf *_sjbuf = &(env); \
- ((*_sjbuf)[_SAVEMASK] = savemask,\
- __SIGMASK_FUNC (SIG_SETMASK, 0, (sigset_t *)((*_sjbuf) + _SIGMASK)),\
- setjmp (*_sjbuf)); \
- })
-
-#define siglongjmp(env, val) \
- __extension__ \
- ({ \
- sigjmp_buf *_sjbuf = &(env); \
- ((((*_sjbuf)[_SAVEMASK]) ? \
- __SIGMASK_FUNC (SIG_SETMASK, (sigset_t *)((*_sjbuf) + _SIGMASK), 0)\
- : 0), \
- longjmp (*_sjbuf, val)); \
- })
-
-#else /* !__GNUC__ */
-
-#define sigsetjmp(env, savemask) ((env)[_SAVEMASK] = savemask,\
- __SIGMASK_FUNC (SIG_SETMASK, 0, (sigset_t *) ((env) + _SIGMASK)),\
- setjmp (env))
-
-#define siglongjmp(env, val) ((((env)[_SAVEMASK])?\
- __SIGMASK_FUNC (SIG_SETMASK, (sigset_t *) ((env) + _SIGMASK), 0):0),\
- longjmp (env, val))
-
-#endif
-
-/* POSIX _setjmp/_longjmp, maintained for XSI compatibility. These
- are equivalent to sigsetjmp/siglongjmp when not saving the signal mask.
- New applications should use sigsetjmp/siglongjmp instead. */
-#ifdef __CYGWIN__
-extern void _longjmp(jmp_buf, int);
-extern int _setjmp(jmp_buf);
-#else
-#define _setjmp(env) sigsetjmp ((env), 0)
-#define _longjmp(env, val) siglongjmp ((env), (val))
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-#endif /* __CYGWIN__ or __rtems__ */
diff --git a/system/include/libc/machine/stdlib.h b/system/include/libc/machine/stdlib.h
deleted file mode 100644
index fa3f3a13..00000000
--- a/system/include/libc/machine/stdlib.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef _MACHSTDLIB_H_
-#define _MACHSTDLIB_H_
-
-/* place holder so platforms may add stdlib.h extensions */
-
-#endif /* _MACHSTDLIB_H_ */
-
-
diff --git a/system/include/libc/machine/termios.h b/system/include/libc/machine/termios.h
deleted file mode 100644
index 41fd4593..00000000
--- a/system/include/libc/machine/termios.h
+++ /dev/null
@@ -1 +0,0 @@
-#define __MAX_BAUD B4000000
diff --git a/system/include/libc/machine/time.h b/system/include/libc/machine/time.h
deleted file mode 100644
index 54de2700..00000000
--- a/system/include/libc/machine/time.h
+++ /dev/null
@@ -1,19 +0,0 @@
-#ifndef _MACHTIME_H_
-#define _MACHTIME_H_
-
-#if defined(__rtems__)
-/* XXX Emscripten #define _CLOCKS_PER_SEC_ sysconf(_SC_CLK_TCK) */
-#else /* !__rtems__ */
-#if defined(__arm__) || defined(__thumb__)
-/* XXX Emscripten #define _CLOCKS_PER_SEC_ 100 */
-#endif
-#endif /* !__rtems__ */
-
-#ifdef __SPU__
-#include <sys/types.h>
-int nanosleep (const struct timespec *, struct timespec *);
-#endif
-
-#endif /* _MACHTIME_H_ */
-
-
diff --git a/system/include/libc/machine/types.h b/system/include/libc/machine/types.h
deleted file mode 100644
index 40a75faa..00000000
--- a/system/include/libc/machine/types.h
+++ /dev/null
@@ -1,30 +0,0 @@
-#ifndef _MACHTYPES_H_
-#define _MACHTYPES_H_
-
-/*
- * The following section is RTEMS specific and is needed to more
- * closely match the types defined in the BSD machine/types.h.
- * This is needed to let the RTEMS/BSD TCP/IP stack compile.
- */
-#if defined(__rtems__)
-#include <machine/_types.h>
-#endif
-
-#define _CLOCK_T_ unsigned long /* clock() */
-#define _TIME_T_ long /* time() */
-#define _CLOCKID_T_ unsigned long
-#define _TIMER_T_ unsigned long
-
-#ifndef _HAVE_SYSTYPES
-typedef long int __off_t;
-typedef int __pid_t;
-#ifdef __GNUC__
-__extension__ typedef long long int __loff_t;
-#else
-typedef long int __loff_t;
-#endif
-#endif
-
-#endif /* _MACHTYPES_H_ */
-
-
diff --git a/system/include/libc/malloc.h b/system/include/libc/malloc.h
index c46357c6..e69de29b 100644
--- a/system/include/libc/malloc.h
+++ b/system/include/libc/malloc.h
@@ -1,169 +0,0 @@
-/* malloc.h -- header file for memory routines. */
-
-#ifndef _INCLUDE_MALLOC_H_
-#define _INCLUDE_MALLOC_H_
-
-#include <_ansi.h>
-#include <sys/reent.h>
-
-#define __need_size_t
-#include <stddef.h>
-
-/* include any machine-specific extensions */
-#include <machine/malloc.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* This version of struct mallinfo must match the one in
- libc/stdlib/mallocr.c. */
-
-struct mallinfo {
- int arena; /* total space allocated from system */
- int ordblks; /* number of non-inuse chunks */
- int smblks; /* unused -- always zero */
- int hblks; /* number of mmapped regions */
- int hblkhd; /* total space in mmapped regions */
- int usmblks; /* unused -- always zero */
- int fsmblks; /* unused -- always zero */
- int uordblks; /* total allocated space */
- int fordblks; /* total non-inuse space */
- int keepcost; /* top-most, releasable (via malloc_trim) space */
-};
-
-/* The routines. */
-
-extern _PTR malloc _PARAMS ((size_t));
-#ifdef __CYGWIN__
-#undef _malloc_r
-#define _malloc_r(r, s) malloc (s)
-#else
-extern _PTR _malloc_r _PARAMS ((struct _reent *, size_t));
-#endif
-
-extern _VOID free _PARAMS ((_PTR));
-#ifdef __CYGWIN__
-#undef _free_r
-#define _free_r(r, p) free (p)
-#else
-extern _VOID _free_r _PARAMS ((struct _reent *, _PTR));
-#endif
-
-extern _PTR realloc _PARAMS ((_PTR, size_t));
-#ifdef __CYGWIN__
-#undef _realloc_r
-#define _realloc_r(r, p, s) realloc (p, s)
-#else
-extern _PTR _realloc_r _PARAMS ((struct _reent *, _PTR, size_t));
-#endif
-
-extern _PTR calloc _PARAMS ((size_t, size_t));
-#ifdef __CYGWIN__
-#undef _calloc_r
-#define _calloc_r(r, s1, s2) calloc (s1, s2);
-#else
-extern _PTR _calloc_r _PARAMS ((struct _reent *, size_t, size_t));
-#endif
-
-extern _PTR memalign _PARAMS ((size_t, size_t));
-#ifdef __CYGWIN__
-#undef _memalign_r
-#define _memalign_r(r, s1, s2) memalign (s1, s2);
-#else
-extern _PTR _memalign_r _PARAMS ((struct _reent *, size_t, size_t));
-#endif
-
-extern struct mallinfo mallinfo _PARAMS ((void));
-#ifdef __CYGWIN__
-#undef _mallinfo_r
-#define _mallinfo_r(r) mallinfo ()
-#else
-extern struct mallinfo _mallinfo_r _PARAMS ((struct _reent *));
-#endif
-
-extern void malloc_stats _PARAMS ((void));
-#ifdef __CYGWIN__
-#undef _malloc_stats_r
-#define _malloc_stats_r(r) malloc_stats ()
-#else
-extern void _malloc_stats_r _PARAMS ((struct _reent *));
-#endif
-
-extern int mallopt _PARAMS ((int, int));
-#ifdef __CYGWIN__
-#undef _mallopt_r
-#define _mallopt_r(i1, i2) mallopt (i1, i2)
-#else
-extern int _mallopt_r _PARAMS ((struct _reent *, int, int));
-#endif
-
-extern size_t malloc_usable_size _PARAMS ((_PTR));
-#ifdef __CYGWIN__
-#undef _malloc_usable_size_r
-#define _malloc_usable_size_r(r, p) malloc_usable_size (p)
-#else
-extern size_t _malloc_usable_size_r _PARAMS ((struct _reent *, _PTR));
-#endif
-
-/* These aren't too useful on an embedded system, but we define them
- anyhow. */
-
-extern _PTR valloc _PARAMS ((size_t));
-#ifdef __CYGWIN__
-#undef _valloc_r
-#define _valloc_r(r, s) valloc (s)
-#else
-extern _PTR _valloc_r _PARAMS ((struct _reent *, size_t));
-#endif
-
-extern _PTR pvalloc _PARAMS ((size_t));
-#ifdef __CYGWIN__
-#undef _pvalloc_r
-#define _pvalloc_r(r, s) pvalloc (s)
-#else
-extern _PTR _pvalloc_r _PARAMS ((struct _reent *, size_t));
-#endif
-
-extern int malloc_trim _PARAMS ((size_t));
-#ifdef __CYGWIN__
-#undef _malloc_trim_r
-#define _malloc_trim_r(r, s) malloc_trim (s)
-#else
-extern int _malloc_trim_r _PARAMS ((struct _reent *, size_t));
-#endif
-
-/* A compatibility routine for an earlier version of the allocator. */
-
-extern _VOID mstats _PARAMS ((char *));
-#ifdef __CYGWIN__
-#undef _mstats_r
-#define _mstats_r(r, p) mstats (p)
-#else
-extern _VOID _mstats_r _PARAMS ((struct _reent *, char *));
-#endif
-
-/* SVID2/XPG mallopt options */
-
-#define M_MXFAST 1 /* UNUSED in this malloc */
-#define M_NLBLKS 2 /* UNUSED in this malloc */
-#define M_GRAIN 3 /* UNUSED in this malloc */
-#define M_KEEP 4 /* UNUSED in this malloc */
-
-/* mallopt options that actually do something */
-
-#define M_TRIM_THRESHOLD -1
-#define M_TOP_PAD -2
-#define M_MMAP_THRESHOLD -3
-#define M_MMAP_MAX -4
-
-#ifndef __CYGWIN__
-/* Some systems provide this, so do too for compatibility. */
-extern void cfree _PARAMS ((_PTR));
-#endif /* __CYGWIN__ */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _INCLUDE_MALLOC_H_ */
diff --git a/system/include/libc/math.h b/system/include/libc/math.h
index e9af660f..c029156a 100644
--- a/system/include/libc/math.h
+++ b/system/include/libc/math.h
@@ -1,602 +1,422 @@
-#ifndef _MATH_H_
+#ifndef _MATH_H
+#define _MATH_H
-#define _MATH_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
-#include <sys/reent.h>
-#include <machine/ieeefp.h>
-#include "_ansi.h"
+#include <features.h>
-_BEGIN_STD_C
+#define __NEED_float_t
+#define __NEED_double_t
+#include <bits/alltypes.h>
-/* __dmath, __fmath, and __ldmath are only here for backwards compatibility
- * in case any code used them. They are no longer used by Newlib, itself,
- * other than legacy. */
-union __dmath
-{
- double d;
- __ULong i[2];
-};
+#if 100*__GNUC__+__GNUC_MINOR__ >= 303
+#define NAN __builtin_nanf("")
+#define INFINITY __builtin_inff()
+#else
+#define NAN (0.0f/0.0f)
+#define INFINITY 1e40f
+#endif
-union __fmath
-{
- float f;
- __ULong i[1];
-};
+#define HUGE_VALF INFINITY
+#define HUGE_VAL ((double)INFINITY)
+#define HUGE_VALL ((long double)INFINITY)
+
+#define MATH_ERRNO 1
+#define MATH_ERREXCEPT 2
+#define math_errhandling 2
+
+#define FP_ILOGBNAN (-1-(int)(((unsigned)-1)>>1))
+#define FP_ILOGB0 FP_ILOGBNAN
+
+#define FP_NAN 0
+#define FP_INFINITE 1
+#define FP_ZERO 2
+#define FP_SUBNORMAL 3
+#define FP_NORMAL 4
-#if defined(_HAVE_LONG_DOUBLE)
-union __ldmath
+int __fpclassify(double);
+int __fpclassifyf(float);
+int __fpclassifyl(long double);
+
+static __inline unsigned __FLOAT_BITS(float __f)
{
- long double ld;
- __ULong i[4];
-};
-#endif
+ union {float __f; unsigned __i;} __u = {__f};
+ return __u.__i;
+}
+static __inline unsigned long long __DOUBLE_BITS(double __f)
+{
+ union {double __f; unsigned long long __i;} __u = {__f};
+ return __u.__i;
+}
+
+#define fpclassify(x) ( \
+ sizeof(x) == sizeof(float) ? __fpclassifyf(x) : \
+ sizeof(x) == sizeof(double) ? __fpclassify(x) : \
+ __fpclassifyl(x) )
+
+#define isinf(x) ( \
+ sizeof(x) == sizeof(float) ? (__FLOAT_BITS(x) & 0x7fffffff) == 0x7f800000 : \
+ sizeof(x) == sizeof(double) ? (__DOUBLE_BITS(x) & -1ULL>>1) == 0x7ffULL<<52 : \
+ __fpclassifyl(x) == FP_INFINITE)
+
+#define isnan(x) ( \
+ sizeof(x) == sizeof(float) ? (__FLOAT_BITS(x) & 0x7fffffff) > 0x7f800000 : \
+ sizeof(x) == sizeof(double) ? (__DOUBLE_BITS(x) & -1ULL>>1) > 0x7ffULL<<52 : \
+ __fpclassifyl(x) == FP_NAN)
+
+#define isnormal(x) ( \
+ sizeof(x) == sizeof(float) ? ((__FLOAT_BITS(x)+0x00800000) & 0x7fffffff) >= 0x01000000 : \
+ sizeof(x) == sizeof(double) ? ((__DOUBLE_BITS(x)+(1ULL<<52)) & -1ULL>>1) >= 1ULL<<53 : \
+ __fpclassifyl(x) == FP_NORMAL)
+
+#define isfinite(x) ( \
+ sizeof(x) == sizeof(float) ? (__FLOAT_BITS(x) & 0x7fffffff) < 0x7f800000 : \
+ sizeof(x) == sizeof(double) ? (__DOUBLE_BITS(x) & -1ULL>>1) < 0x7ffULL<<52 : \
+ __fpclassifyl(x) > FP_INFINITE)
+
+int __signbit(double);
+int __signbitf(float);
+int __signbitl(long double);
+
+#define signbit(x) ( \
+ sizeof(x) == sizeof(float) ? (int)(__FLOAT_BITS(x)>>31) : \
+ sizeof(x) == sizeof(double) ? (int)(__DOUBLE_BITS(x)>>63) : \
+ __signbitl(x) )
+
+#define isunordered(x,y) (isnan((x)) ? ((void)(y),1) : isnan((y)))
+
+#define __ISREL_DEF(rel, op, type) \
+static __inline int __is##rel(type __x, type __y) \
+{ return !isunordered(__x,__y) && __x op __y; }
+
+__ISREL_DEF(lessf, <, float)
+__ISREL_DEF(less, <, double)
+__ISREL_DEF(lessl, <, long double)
+__ISREL_DEF(lessequalf, <=, float)
+__ISREL_DEF(lessequal, <=, double)
+__ISREL_DEF(lessequall, <=, long double)
+__ISREL_DEF(lessgreaterf, !=, float)
+__ISREL_DEF(lessgreater, !=, double)
+__ISREL_DEF(lessgreaterl, !=, long double)
+__ISREL_DEF(greaterf, >, float)
+__ISREL_DEF(greater, >, double)
+__ISREL_DEF(greaterl, >, long double)
+__ISREL_DEF(greaterequalf, >=, float)
+__ISREL_DEF(greaterequal, >=, double)
+__ISREL_DEF(greaterequall, >=, long double)
+
+#define __tg_pred_2(x, y, p) ( \
+ sizeof((x)+(y)) == sizeof(float) ? p##f(x, y) : \
+ sizeof((x)+(y)) == sizeof(double) ? p(x, y) : \
+ p##l(x, y) )
+
+#define isless(x, y) __tg_pred_2(x, y, __isless)
+#define islessequal(x, y) __tg_pred_2(x, y, __islessequal)
+#define islessgreater(x, y) __tg_pred_2(x, y, __islessgreater)
+#define isgreater(x, y) __tg_pred_2(x, y, __isgreater)
+#define isgreaterequal(x, y) __tg_pred_2(x, y, __isgreaterequal)
+
+double acos(double);
+float acosf(float);
+long double acosl(long double);
+
+double acosh(double);
+float acoshf(float);
+long double acoshl(long double);
+
+double asin(double);
+float asinf(float);
+long double asinl(long double);
+
+double asinh(double);
+float asinhf(float);
+long double asinhl(long double);
+
+double atan(double);
+float atanf(float);
+long double atanl(long double);
+
+double atan2(double, double);
+float atan2f(float, float);
+long double atan2l(long double, long double);
+
+double atanh(double);
+float atanhf(float);
+long double atanhl(long double);
+
+double cbrt(double);
+float cbrtf(float);
+long double cbrtl(long double);
+
+double ceil(double);
+float ceilf(float);
+long double ceill(long double);
+
+double copysign(double, double);
+float copysignf(float, float);
+long double copysignl(long double, long double);
+
+double cos(double);
+float cosf(float);
+long double cosl(long double);
+
+double cosh(double);
+float coshf(float);
+long double coshl(long double);
+
+double erf(double);
+float erff(float);
+long double erfl(long double);
+
+double erfc(double);
+float erfcf(float);
+long double erfcl(long double);
+
+double exp(double);
+float expf(float);
+long double expl(long double);
+
+double exp2(double);
+float exp2f(float);
+long double exp2l(long double);
+
+double expm1(double);
+float expm1f(float);
+long double expm1l(long double);
+
+double fabs(double);
+float fabsf(float);
+long double fabsl(long double);
+
+double fdim(double, double);
+float fdimf(float, float);
+long double fdiml(long double, long double);
+
+double floor(double);
+float floorf(float);
+long double floorl(long double);
+
+double fma(double, double, double);
+float fmaf(float, float, float);
+long double fmal(long double, long double, long double);
+
+double fmax(double, double);
+float fmaxf(float, float);
+long double fmaxl(long double, long double);
-/* Natural log of 2 */
-#define _M_LN2 0.693147180559945309417
-
-#if defined(__GNUC__) && \
- ( (__GNUC__ >= 4) || \
- ( (__GNUC__ >= 3) && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ >= 3) ) )
-
- /* gcc >= 3.3 implicitly defines builtins for HUGE_VALx values. */
-
-# ifndef HUGE_VAL
-# define HUGE_VAL (__builtin_huge_val())
-# endif
-
-# ifndef HUGE_VALF
-# define HUGE_VALF (__builtin_huge_valf())
-# endif
-
-# ifndef HUGE_VALL
-# define HUGE_VALL (__builtin_huge_vall())
-# endif
-
-# ifndef INFINITY
-# define INFINITY (__builtin_inff())
-# endif
-
-# ifndef NAN
-# define NAN (__builtin_nanf(""))
-# endif
-
-#else /* !gcc >= 3.3 */
-
- /* No builtins. Use fixed defines instead. (All 3 HUGE plus the INFINITY
- * and NAN macros are required to be constant expressions. Using a variable--
- * even a static const--does not meet this requirement, as it cannot be
- * evaluated at translation time.)
- * The infinities are done using numbers that are far in excess of
- * something that would be expected to be encountered in a floating-point
- * implementation. (A more certain way uses values from float.h, but that is
- * avoided because system includes are not supposed to include each other.)
- * This method might produce warnings from some compilers. (It does in
- * newer GCCs, but not for ones that would hit this #else.) If this happens,
- * please report details to the Newlib mailing list. */
-
- #ifndef HUGE_VAL
- #define HUGE_VAL (1.0e999999999)
- #endif
-
- #ifndef HUGE_VALF
- #define HUGE_VALF (1.0e999999999F)
- #endif
-
- #if !defined(HUGE_VALL) && defined(_HAVE_LONG_DOUBLE)
- #define HUGE_VALL (1.0e999999999L)
- #endif
-
- #if !defined(INFINITY)
- #define INFINITY (HUGE_VALF)
- #endif
-
- #if !defined(NAN)
- #if defined(__GNUC__) && defined(__cplusplus)
- /* Exception: older g++ versions warn about the divide by 0 used in the
- * normal case (even though older gccs do not). This trick suppresses the
- * warning, but causes errors for plain gcc, so is only used in the one
- * special case. */
- static const union { __ULong __i[1]; float __d; } __Nanf = {0x7FC00000};
- #define NAN (__Nanf.__d)
- #else
- #define NAN (0.0F/0.0F)
- #endif
- #endif
-
-#endif /* !gcc >= 3.3 */
-
-/* Reentrant ANSI C functions. */
-
-#ifndef __math_68881
-extern double atan _PARAMS((double));
-extern double cos _PARAMS((double));
-extern double sin _PARAMS((double));
-extern double tan _PARAMS((double));
-extern double tanh _PARAMS((double));
-extern double frexp _PARAMS((double, int *));
-extern double modf _PARAMS((double, double *));
-extern double ceil _PARAMS((double));
-extern double fabs _PARAMS((double));
-extern double floor _PARAMS((double));
-#endif /* ! defined (__math_68881) */
-
-/* Non reentrant ANSI C functions. */
-
-#ifndef _REENT_ONLY
-#ifndef __math_68881
-extern double acos _PARAMS((double));
-extern double asin _PARAMS((double));
-extern double atan2 _PARAMS((double, double));
-extern double cosh _PARAMS((double));
-extern double sinh _PARAMS((double));
-extern double exp _PARAMS((double));
-extern double ldexp _PARAMS((double, int));
-extern double log _PARAMS((double));
-extern double log10 _PARAMS((double));
-extern double pow _PARAMS((double, double));
-extern double sqrt _PARAMS((double));
-extern double fmod _PARAMS((double, double));
-#endif /* ! defined (__math_68881) */
-#endif /* ! defined (_REENT_ONLY) */
-
-#if !defined(__STRICT_ANSI__) || defined(__cplusplus) || __STDC_VERSION__ >= 199901L
-
-/* ISO C99 types and macros. */
-
-#ifndef FLT_EVAL_METHOD
-#define FLT_EVAL_METHOD 0
-#endif /* FLT_EVAL_METHOD */
-/* XXX EMSCRIPTEN: moved these out of previous if */
-typedef float float_t;
-typedef double double_t;
-
-#define FP_NAN 0
-#define FP_INFINITE 1
-#define FP_ZERO 2
-#define FP_SUBNORMAL 3
-#define FP_NORMAL 4
-
-#ifndef FP_ILOGB0
-# define FP_ILOGB0 (-INT_MAX)
-#endif
-#ifndef FP_ILOGBNAN
-# define FP_ILOGBNAN INT_MAX
-#endif
+double fmin(double, double);
+float fminf(float, float);
+long double fminl(long double, long double);
-#ifndef MATH_ERRNO
-# define MATH_ERRNO 1
-#endif
-#ifndef MATH_ERREXCEPT
-# define MATH_ERREXCEPT 2
-#endif
-#ifndef math_errhandling
-# define math_errhandling MATH_ERRNO
-#endif
+double fmod(double, double);
+float fmodf(float, float);
+long double fmodl(long double, long double);
-extern int __isinff (float x);
-extern int __isinfd (double x);
-extern int __isnanf (float x);
-extern int __isnand (double x);
-extern int __fpclassifyf (float x);
-extern int __fpclassifyd (double x);
-extern int __signbitf (float x);
-extern int __signbitd (double x);
-
-#define fpclassify(__x) \
- ((sizeof(__x) == sizeof(float)) ? __fpclassifyf(__x) : \
- __fpclassifyd(__x))
-
-#ifndef isfinite
- #define isfinite(__y) \
- (__extension__ ({int __cy = fpclassify(__y); \
- __cy != FP_INFINITE && __cy != FP_NAN;}))
-#endif
+double frexp(double, int *);
+float frexpf(float, int *);
+long double frexpl(long double, int *);
-/* Note: isinf and isnan were once functions in newlib that took double
- * arguments. C99 specifies that these names are reserved for macros
- * supporting multiple floating point types. Thus, they are
- * now defined as macros. Implementations of the old functions
- * taking double arguments still exist for compatibility purposes
- * (prototypes for them are in <ieeefp.h>). */
-#ifndef isinf
- #define isinf(y) (fpclassify(y) == FP_INFINITE)
-#endif
+double hypot(double, double);
+float hypotf(float, float);
+long double hypotl(long double, long double);
-#ifndef isinff
- #define isinff isinf
-#endif
+int ilogb(double);
+int ilogbf(float);
+int ilogbl(long double);
-#ifndef isnan
- #define isnan(y) (fpclassify(y) == FP_NAN)
-#endif
+double ldexp(double, int);
+float ldexpf(float, int);
+long double ldexpl(long double, int);
-#ifndef isnanf
- #define isnanf isnan
-#endif
+double lgamma(double);
+float lgammaf(float);
+long double lgammal(long double);
-#define isnormal(y) (fpclassify(y) == FP_NORMAL)
-#define signbit(__x) \
- ((sizeof(__x) == sizeof(float)) ? __signbitf(__x) : \
- __signbitd(__x))
-
-/* XXX: EMSCRIPTEN: We alter the names of __typeof__ declarations to
- reduce the chance of them conflicting when expanded */
-
-#define isgreater(x,y) \
- (__extension__ ({__typeof__(x) __isg_x = (x); __typeof__(y) __isg_y = (y); \
- !isunordered(__isg_x,__isg_y) && (__isg_x > __isg_y);}))
-#define isgreaterequal(x,y) \
- (__extension__ ({__typeof__(x) __isge_x = (x); __typeof__(y) __isge_y = (y); \
- !isunordered(__isge_x,__isge_y) && (__isge_x >= __isge_y);}))
-#define isless(x,y) \
- (__extension__ ({__typeof__(x) __isl_x = (x); __typeof__(y) __isl_y = (y); \
- !isunordered(__isl_x,__isl_y) && (__isl_x < __isl_y);}))
-#define islessequal(x,y) \
- (__extension__ ({__typeof__(x) __isle_x = (x); __typeof__(y) __isle_y = (y); \
- !isunordered(__isle_x,__isle_y) && (__isle_x <= __isle_y);}))
-#define islessgreater(x,y) \
- (__extension__ ({__typeof__(x) __islg_x = (x); __typeof__(y) __islg_y = (y); \
- !isunordered(__islg_x,__islg_y) && (__islg_x < __islg_y || __islg_x > __islg_y);}))
-
-#define isunordered(a,b) \
- (__extension__ ({__typeof__(a) __isu_a = (a); __typeof__(b) __isu_b = (b); \
- fpclassify(__isu_a) == FP_NAN || fpclassify(__isu_b) == FP_NAN;}))
-
-/* Non ANSI double precision functions. */
-
-/* XXX Emscripten extern double infinity _PARAMS((void)); */
-extern double nan _PARAMS((const char *));
-extern int finite _PARAMS((double));
-extern double copysign _PARAMS((double, double));
-extern double logb _PARAMS((double));
-extern int ilogb _PARAMS((double));
-
-extern double asinh _PARAMS((double));
-extern double cbrt _PARAMS((double));
-extern double nextafter _PARAMS((double, double));
-extern double rint _PARAMS((double));
-extern double scalbn _PARAMS((double, int));
-
-extern double exp2 _PARAMS((double));
-extern double scalbln _PARAMS((double, long int));
-extern double tgamma _PARAMS((double));
-extern double nearbyint _PARAMS((double));
-extern long int lrint _PARAMS((double));
-extern _LONG_LONG_TYPE int llrint _PARAMS((double));
-extern double round _PARAMS((double));
-extern long int lround _PARAMS((double));
-extern long long int llround _PARAMS((double));
-extern double trunc _PARAMS((double));
-extern double remquo _PARAMS((double, double, int *));
-extern double fdim _PARAMS((double, double));
-extern double fmax _PARAMS((double, double));
-extern double fmin _PARAMS((double, double));
-extern double fma _PARAMS((double, double, double));
-
-#ifndef __math_68881
-extern double log1p _PARAMS((double));
-extern double expm1 _PARAMS((double));
-#endif /* ! defined (__math_68881) */
-
-#ifndef _REENT_ONLY
-extern double acosh _PARAMS((double));
-extern double atanh _PARAMS((double));
-extern double remainder _PARAMS((double, double));
-extern double gamma _PARAMS((double));
-extern double lgamma _PARAMS((double));
-extern double erf _PARAMS((double));
-extern double erfc _PARAMS((double));
-extern double log2 _PARAMS((double));
-#if !defined(__cplusplus)
-#define log2(x) (log (x) / _M_LN2)
-#endif
+long long llrint(double);
+long long llrintf(float);
+long long llrintl(long double);
-#ifndef __math_68881
-extern double hypot _PARAMS((double, double));
-#endif
+long long llround(double);
+long long llroundf(float);
+long long llroundl(long double);
-#endif /* ! defined (_REENT_ONLY) */
-
-/* Single precision versions of ANSI functions. */
-
-extern float atanf _PARAMS((float));
-extern float cosf _PARAMS((float));
-extern float sinf _PARAMS((float));
-extern float tanf _PARAMS((float));
-extern float tanhf _PARAMS((float));
-extern float frexpf _PARAMS((float, int *));
-extern float modff _PARAMS((float, float *));
-extern float ceilf _PARAMS((float));
-extern float fabsf _PARAMS((float));
-extern float floorf _PARAMS((float));
-
-#ifndef _REENT_ONLY
-extern float acosf _PARAMS((float));
-extern float asinf _PARAMS((float));
-extern float atan2f _PARAMS((float, float));
-extern float coshf _PARAMS((float));
-extern float sinhf _PARAMS((float));
-extern float expf _PARAMS((float));
-extern float ldexpf _PARAMS((float, int));
-extern float logf _PARAMS((float));
-extern float log10f _PARAMS((float));
-extern float powf _PARAMS((float, float));
-extern float sqrtf _PARAMS((float));
-extern float fmodf _PARAMS((float, float));
-#endif /* ! defined (_REENT_ONLY) */
-
-/* Other single precision functions. */
-
-extern float exp2f _PARAMS((float));
-extern float scalblnf _PARAMS((float, long int));
-extern float tgammaf _PARAMS((float));
-extern float nearbyintf _PARAMS((float));
-extern long int lrintf _PARAMS((float));
-extern _LONG_LONG_TYPE llrintf _PARAMS((float));
-extern float roundf _PARAMS((float));
-extern long int lroundf _PARAMS((float));
-extern long long int llroundf _PARAMS((float));
-extern float truncf _PARAMS((float));
-extern float remquof _PARAMS((float, float, int *));
-extern float fdimf _PARAMS((float, float));
-extern float fmaxf _PARAMS((float, float));
-extern float fminf _PARAMS((float, float));
-extern float fmaf _PARAMS((float, float, float));
-
-extern float infinityf _PARAMS((void));
-extern float nanf _PARAMS((const char *));
-extern int finitef _PARAMS((float));
-extern float copysignf _PARAMS((float, float));
-extern float logbf _PARAMS((float));
-extern int ilogbf _PARAMS((float));
-
-extern float asinhf _PARAMS((float));
-extern float cbrtf _PARAMS((float));
-extern float nextafterf _PARAMS((float, float));
-extern float rintf _PARAMS((float));
-extern float scalbnf _PARAMS((float, int));
-extern float log1pf _PARAMS((float));
-extern float expm1f _PARAMS((float));
-
-#ifndef _REENT_ONLY
-extern float acoshf _PARAMS((float));
-extern float atanhf _PARAMS((float));
-extern float remainderf _PARAMS((float, float));
-extern float gammaf _PARAMS((float));
-extern float lgammaf _PARAMS((float));
-extern float erff _PARAMS((float));
-extern float erfcf _PARAMS((float));
-extern float log2f _PARAMS((float));
-#if !defined(__cplusplus)
-#define log2f(x) (logf (x) / (float_t) _M_LN2)
-#endif
-extern float hypotf _PARAMS((float, float));
-#endif /* ! defined (_REENT_ONLY) */
-
-/* On platforms where long double equals double. */
-#if defined(_LDBL_EQ_DBL) || defined(EMSCRIPTEN)
-/* Reentrant ANSI C functions. */
-#ifndef __math_68881
-extern long double atanl _PARAMS((long double));
-extern long double cosl _PARAMS((long double));
-extern long double sinl _PARAMS((long double));
-extern long double tanl _PARAMS((long double));
-extern long double tanhl _PARAMS((long double));
-extern long double frexpl _PARAMS((long double value, int *));
-extern long double modfl _PARAMS((long double, long double *));
-extern long double ceill _PARAMS((long double));
-extern long double fabsl _PARAMS((long double));
-extern long double floorl _PARAMS((long double));
-extern long double log1pl _PARAMS((long double));
-extern long double expm1l _PARAMS((long double));
-#endif /* ! defined (__math_68881) */
-/* Non reentrant ANSI C functions. */
-
-#ifndef _REENT_ONLY
-#ifndef __math_68881
-
-extern long double acosl _PARAMS((long double));
-extern long double asinl _PARAMS((long double));
-extern long double atan2l _PARAMS((long double, long double));
-extern long double coshl _PARAMS((long double));
-extern long double sinhl _PARAMS((long double));
-extern long double expl _PARAMS((long double));
-extern long double ldexpl _PARAMS((long double, int));
-extern long double logl _PARAMS((long double));
-extern long double log10l _PARAMS((long double));
-extern long double powl _PARAMS((long double, long double));
-extern long double sqrtl _PARAMS((long double));
-extern long double fmodl _PARAMS((long double, long double));
-extern long double hypotl _PARAMS((long double, long double));
-#endif /* ! defined (__math_68881) */
-#endif /* ! defined (_REENT_ONLY) */
-extern long double copysignl _PARAMS((long double, long double));
-extern long double nanl _PARAMS((const char *));
-extern int ilogbl _PARAMS((long double));
-extern long double asinhl _PARAMS((long double));
-extern long double cbrtl _PARAMS((long double));
-extern long double nextafterl _PARAMS((long double, long double));
-extern long double rintl _PARAMS((long double));
-extern long double scalbnl _PARAMS((long double, int));
-extern long double exp2l _PARAMS((long double));
-extern long double scalblnl _PARAMS((long double, long));
-extern long double tgammal _PARAMS((long double));
-extern long double nearbyintl _PARAMS((long double));
-extern long int lrintl _PARAMS((long double));
-extern long long int llrintl _PARAMS((long double));
-extern long double roundl _PARAMS((long double));
-extern long lroundl _PARAMS((long double));
-extern _LONG_LONG_TYPE int llroundl _PARAMS((long double));
-extern long double truncl _PARAMS((long double));
-extern long double remquol _PARAMS((long double, long double, int *));
-extern long double fdiml _PARAMS((long double, long double));
-extern long double fmaxl _PARAMS((long double, long double));
-extern long double fminl _PARAMS((long double, long double));
-extern long double fmal _PARAMS((long double, long double, long double));
-#ifndef _REENT_ONLY
-extern long double acoshl _PARAMS((long double));
-extern long double atanhl _PARAMS((long double));
-extern long double remainderl _PARAMS((long double, long double));
-extern long double lgammal _PARAMS((long double));
-extern long double erfl _PARAMS((long double));
-extern long double erfcl _PARAMS((long double));
-
-/* XXX Emscripten: 5 more */
-extern long double log2l _PARAMS((long double));
-extern long double logbl _PARAMS((long double));
-double nexttoward(double x, long double y);
-float nexttowardf(float x, long double y);
-long double nexttowardl(long double x, long double y);
-
-#endif /* ! defined (_REENT_ONLY) */
-#else /* !_LDBL_EQ_DBL */
-#ifdef __i386__
-/* Other long double precision functions. */
-extern _LONG_DOUBLE rintl _PARAMS((_LONG_DOUBLE));
-extern long int lrintl _PARAMS((_LONG_DOUBLE));
-extern _LONG_LONG_TYPE llrintl _PARAMS((_LONG_DOUBLE));
-#endif /* __i386__ */
-#endif /* !_LDBL_EQ_DBL */
-
-#endif /* !defined (__STRICT_ANSI__) || defined(__cplusplus) || __STDC_VERSION__ >= 199901L */
-
-#if !defined (__STRICT_ANSI__) || defined(__cplusplus)
-
-extern double drem _PARAMS((double, double));
-extern void sincos _PARAMS((double, double *, double *));
-extern double gamma_r _PARAMS((double, int *));
-extern double lgamma_r _PARAMS((double, int *));
-
-extern double y0 _PARAMS((double));
-extern double y1 _PARAMS((double));
-extern double yn _PARAMS((int, double));
-extern double j0 _PARAMS((double));
-extern double j1 _PARAMS((double));
-extern double jn _PARAMS((int, double));
-
-extern float dremf _PARAMS((float, float));
-extern void sincosf _PARAMS((float, float *, float *));
-extern float gammaf_r _PARAMS((float, int *));
-extern float lgammaf_r _PARAMS((float, int *));
-
-extern float y0f _PARAMS((float));
-extern float y1f _PARAMS((float));
-extern float ynf _PARAMS((int, float));
-extern float j0f _PARAMS((float));
-extern float j1f _PARAMS((float));
-extern float jnf _PARAMS((int, float));
-
-/* GNU extensions */
-# ifndef exp10
-extern double exp10 _PARAMS((double));
-# endif
-# ifndef pow10
-extern double pow10 _PARAMS((double));
-# endif
-# ifndef exp10f
-extern float exp10f _PARAMS((float));
-# endif
-# ifndef pow10f
-extern float pow10f _PARAMS((float));
-# endif
-
-#endif /* !defined (__STRICT_ANSI__) || defined(__cplusplus) */
-
-#ifndef __STRICT_ANSI__
-
-/* The gamma functions use a global variable, signgam. */
-#ifndef _REENT_ONLY
-#define signgam (*__signgam())
-extern int *__signgam _PARAMS((void));
-#endif /* ! defined (_REENT_ONLY) */
-
-#define __signgam_r(ptr) _REENT_SIGNGAM(ptr)
-
-/* The exception structure passed to the matherr routine. */
-/* We have a problem when using C++ since `exception' is a reserved
- name in C++. */
-#ifdef __cplusplus
-struct __exception
-#else
-struct exception
+double log(double);
+float logf(float);
+long double logl(long double);
+
+double log10(double);
+float log10f(float);
+long double log10l(long double);
+
+double log1p(double);
+float log1pf(float);
+long double log1pl(long double);
+
+double log2(double);
+float log2f(float);
+long double log2l(long double);
+
+double logb(double);
+float logbf(float);
+long double logbl(long double);
+
+long lrint(double);
+long lrintf(float);
+long lrintl(long double);
+
+long lround(double);
+long lroundf(float);
+long lroundl(long double);
+
+double modf(double, double *);
+float modff(float, float *);
+long double modfl(long double, long double *);
+
+double nan(const char *);
+float nanf(const char *);
+long double nanl(const char *);
+
+double nearbyint(double);
+float nearbyintf(float);
+long double nearbyintl(long double);
+
+double nextafter(double, double);
+float nextafterf(float, float);
+long double nextafterl(long double, long double);
+
+double nexttoward(double, long double);
+float nexttowardf(float, long double);
+long double nexttowardl(long double, long double);
+
+double pow(double, double);
+float powf(float, float);
+long double powl(long double, long double);
+
+double remainder(double, double);
+float remainderf(float, float);
+long double remainderl(long double, long double);
+
+double remquo(double, double, int *);
+float remquof(float, float, int *);
+long double remquol(long double, long double, int *);
+
+double rint(double);
+float rintf(float);
+long double rintl(long double);
+
+double round(double);
+float roundf(float);
+long double roundl(long double);
+
+double scalbln(double, long);
+float scalblnf(float, long);
+long double scalblnl(long double, long);
+
+double scalbn(double, int);
+float scalbnf(float, int);
+long double scalbnl(long double, int);
+
+double sin(double);
+float sinf(float);
+long double sinl(long double);
+
+double sinh(double);
+float sinhf(float);
+long double sinhl(long double);
+
+double sqrt(double);
+float sqrtf(float);
+long double sqrtl(long double);
+
+double tan(double);
+float tanf(float);
+long double tanl(long double);
+
+double tanh(double);
+float tanhf(float);
+long double tanhl(long double);
+
+double tgamma(double);
+float tgammaf(float);
+long double tgammal(long double);
+
+double trunc(double);
+float truncf(float);
+long double truncl(long double);
+
+
+#if defined(_XOPEN_SOURCE) || defined(_BSD_SOURCE)
+#undef MAXFLOAT
+#define MAXFLOAT 3.40282347e+38F
#endif
-{
- int type;
- char *name;
- double arg1;
- double arg2;
- double retval;
- int err;
-};
-#ifdef __cplusplus
-extern int matherr _PARAMS((struct __exception *e));
-#else
-extern int matherr _PARAMS((struct exception *e));
+#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+#define M_E 2.7182818284590452354 /* e */
+#define M_LOG2E 1.4426950408889634074 /* log_2 e */
+#define M_LOG10E 0.43429448190325182765 /* log_10 e */
+#define M_LN2 0.69314718055994530942 /* log_e 2 */
+#define M_LN10 2.30258509299404568402 /* log_e 10 */
+#define M_PI 3.14159265358979323846 /* pi */
+#define M_PI_2 1.57079632679489661923 /* pi/2 */
+#define M_PI_4 0.78539816339744830962 /* pi/4 */
+#define M_1_PI 0.31830988618379067154 /* 1/pi */
+#define M_2_PI 0.63661977236758134308 /* 2/pi */
+#define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */
+#define M_SQRT2 1.41421356237309504880 /* sqrt(2) */
+#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */
+
+extern int signgam;
+
+double j0(double);
+double j1(double);
+double jn(int, double);
+
+double y0(double);
+double y1(double);
+double yn(int, double);
#endif
-/* Values for the type field of struct exception. */
-
-#define DOMAIN 1
-#define SING 2
-#define OVERFLOW 3
-#define UNDERFLOW 4
-#define TLOSS 5
-#define PLOSS 6
-
-/* Useful constants. */
-
-#define MAXFLOAT 3.40282347e+38F
-
-#define M_E 2.7182818284590452354
-#define M_LOG2E 1.4426950408889634074
-#define M_LOG10E 0.43429448190325182765
-#define M_LN2 _M_LN2
-#define M_LN10 2.30258509299404568402
-#define M_PI 3.14159265358979323846
-#define M_TWOPI (M_PI * 2.0)
-#define M_PI_2 1.57079632679489661923
-#define M_PI_4 0.78539816339744830962
-#define M_3PI_4 2.3561944901923448370E0
-#define M_SQRTPI 1.77245385090551602792981
-#define M_1_PI 0.31830988618379067154
-#define M_2_PI 0.63661977236758134308
-#define M_2_SQRTPI 1.12837916709551257390
-#define M_SQRT2 1.41421356237309504880
-#define M_SQRT1_2 0.70710678118654752440
-#define M_LN2LO 1.9082149292705877000E-10
-#define M_LN2HI 6.9314718036912381649E-1
-#define M_SQRT3 1.73205080756887719000
-#define M_IVLN10 0.43429448190325182765 /* 1 / log(10) */
-#define M_LOG2_E _M_LN2
-#define M_INVLN2 1.4426950408889633870E0 /* 1 / log(2) */
-
-/* Global control over fdlibm error handling. */
-
-enum __fdlibm_version
-{
- __fdlibm_ieee = -1,
- __fdlibm_svid,
- __fdlibm_xopen,
- __fdlibm_posix
-};
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+#define HUGE 3.40282347e+38F
-#define _LIB_VERSION_TYPE enum __fdlibm_version
-#define _LIB_VERSION __fdlib_version
+double scalb(double, double);
+float scalbf(float, float);
-extern __IMPORT _LIB_VERSION_TYPE _LIB_VERSION;
+double significand(double);
+float significandf(float);
-#define _IEEE_ __fdlibm_ieee
-#define _SVID_ __fdlibm_svid
-#define _XOPEN_ __fdlibm_xopen
-#define _POSIX_ __fdlibm_posix
+double lgamma_r(double, int*);
+float lgammaf_r(float, int*);
-#endif /* ! defined (__STRICT_ANSI__) */
+float j0f(float);
+float j1f(float);
+float jnf(int, float);
-_END_STD_C
+float y0f(float);
+float y1f(float);
+float ynf(int, float);
+#endif
+
+#ifdef _GNU_SOURCE
+long double lgammal_r(long double, int*);
+
+void sincos(double, double*, double*);
+void sincosf(float, float*, float*);
+void sincosl(long double, long double*, long double*);
+
+double exp10(double);
+float exp10f(float);
+long double exp10l(long double);
-#ifdef __FAST_MATH__
-#include <machine/fastmath.h>
+double pow10(double);
+float pow10f(float);
+long double pow10l(long double);
#endif
-#endif /* _MATH_H_ */
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/memory.h b/system/include/libc/memory.h
new file mode 100644
index 00000000..3b2f5900
--- /dev/null
+++ b/system/include/libc/memory.h
@@ -0,0 +1 @@
+#include <string.h>
diff --git a/system/include/libc/mntent.h b/system/include/libc/mntent.h
new file mode 100644
index 00000000..d03c414a
--- /dev/null
+++ b/system/include/libc/mntent.h
@@ -0,0 +1,44 @@
+#ifndef _MNTENT_H
+#define _MNTENT_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define __NEED_FILE
+#include <bits/alltypes.h>
+
+#define MOUNTED "/etc/mtab"
+
+#define MNTTYPE_IGNORE "ignore"
+#define MNTTYPE_NFS "nfs"
+#define MNTTYPE_SWAP "swap"
+#define MNTOPT_DEFAULTS "defaults"
+#define MNTOPT_RO "ro"
+#define MNTOPT_RW "rw"
+#define MNTOPT_SUID "suid"
+#define MNTOPT_NOSUID "nosuid"
+#define MNTOPT_NOAUTO "noauto"
+
+struct mntent
+{
+ char *mnt_fsname;
+ char *mnt_dir;
+ char *mnt_type;
+ char *mnt_opts;
+ int mnt_freq;
+ int mnt_passno;
+};
+
+FILE *setmntent(const char *, const char *);
+int endmntent(FILE *);
+struct mntent *getmntent(FILE *);
+struct mntent *getmntent_r(FILE *, struct mntent *, char *, int);
+int addmntent(FILE *, const struct mntent *);
+char *hasmntopt(const struct mntent *, const char *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/monetary.h b/system/include/libc/monetary.h
new file mode 100644
index 00000000..a91fa565
--- /dev/null
+++ b/system/include/libc/monetary.h
@@ -0,0 +1,23 @@
+#ifndef _MONETARY_H
+#define _MONETARY_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <features.h>
+
+#define __NEED_ssize_t
+#define __NEED_size_t
+#define __NEED_locale_t
+
+#include <bits/alltypes.h>
+
+ssize_t strfmon(char *__restrict, size_t, const char *__restrict, ...);
+ssize_t strfmon_l(char *__restrict, size_t, locale_t, const char *__restrict, ...);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/mqueue.h b/system/include/libc/mqueue.h
new file mode 100644
index 00000000..f5cbe796
--- /dev/null
+++ b/system/include/libc/mqueue.h
@@ -0,0 +1,36 @@
+#ifndef _MQUEUE_H
+#define _MQUEUE_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <features.h>
+
+#define __NEED_size_t
+#define __NEED_ssize_t
+#define __NEED_pthread_attr_t
+#define __NEED_time_t
+#define __NEED_struct_timespec
+#include <bits/alltypes.h>
+
+typedef int mqd_t;
+struct mq_attr {
+ long mq_flags, mq_maxmsg, mq_msgsize, mq_curmsgs, __unused[4];
+};
+struct sigevent;
+
+int mq_close(mqd_t);
+int mq_getattr(mqd_t, struct mq_attr *);
+int mq_notify(mqd_t, const struct sigevent *);
+mqd_t mq_open(const char *, int, ...);
+ssize_t mq_receive(mqd_t, char *, size_t, unsigned *);
+int mq_send(mqd_t, const char *, size_t, unsigned);
+int mq_setattr(mqd_t, const struct mq_attr *__restrict, struct mq_attr *__restrict);
+ssize_t mq_timedreceive(mqd_t, char *__restrict, size_t, unsigned *__restrict, const struct timespec *__restrict);
+int mq_timedsend(mqd_t, const char *, size_t, unsigned, const struct timespec *);
+int mq_unlink(const char *);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/system/include/libc/net/ethernet.h b/system/include/libc/net/ethernet.h
new file mode 100644
index 00000000..c8d4177f
--- /dev/null
+++ b/system/include/libc/net/ethernet.h
@@ -0,0 +1,55 @@
+#ifndef _NET_ETHERNET_H
+#define _NET_ETHERNET_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+#include <sys/types.h>
+#include <netinet/if_ether.h>
+
+struct ether_addr {
+ uint8_t ether_addr_octet[ETH_ALEN];
+};
+
+struct ether_header {
+ uint8_t ether_dhost[ETH_ALEN];
+ uint8_t ether_shost[ETH_ALEN];
+ uint16_t ether_type;
+};
+
+#define ETHERTYPE_PUP 0x0200
+#define ETHERTYPE_SPRITE 0x0500
+#define ETHERTYPE_IP 0x0800
+#define ETHERTYPE_ARP 0x0806
+#define ETHERTYPE_REVARP 0x8035
+#define ETHERTYPE_AT 0x809B
+#define ETHERTYPE_AARP 0x80F3
+#define ETHERTYPE_VLAN 0x8100
+#define ETHERTYPE_IPX 0x8137
+#define ETHERTYPE_IPV6 0x86dd
+#define ETHERTYPE_LOOPBACK 0x9000
+
+
+#define ETHER_ADDR_LEN ETH_ALEN
+#define ETHER_TYPE_LEN 2
+#define ETHER_CRC_LEN 4
+#define ETHER_HDR_LEN ETH_HLEN
+#define ETHER_MIN_LEN (ETH_ZLEN + ETHER_CRC_LEN)
+#define ETHER_MAX_LEN (ETH_FRAME_LEN + ETHER_CRC_LEN)
+
+#define ETHER_IS_VALID_LEN(foo) \
+ ((foo) >= ETHER_MIN_LEN && (foo) <= ETHER_MAX_LEN)
+
+#define ETHERTYPE_TRAIL 0x1000
+#define ETHERTYPE_NTRAILER 16
+
+#define ETHERMTU ETH_DATA_LEN
+#define ETHERMIN (ETHER_MIN_LEN - ETHER_HDR_LEN - ETHER_CRC_LEN)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/net/if.h b/system/include/libc/net/if.h
new file mode 100644
index 00000000..3f4fc092
--- /dev/null
+++ b/system/include/libc/net/if.h
@@ -0,0 +1,135 @@
+#ifndef _NET_IF_H
+#define _NET_IF_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <features.h>
+
+#define IF_NAMESIZE 16
+
+struct if_nameindex
+{
+ unsigned int if_index;
+ char *if_name;
+};
+
+unsigned int if_nametoindex (const char *);
+char *if_indextoname (unsigned int, char *);
+struct if_nameindex *if_nameindex (void);
+void if_freenameindex (struct if_nameindex *);
+
+
+
+
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+
+#include <sys/socket.h>
+
+#define IFF_UP 0x1
+#define IFF_BROADCAST 0x2
+#define IFF_DEBUG 0x4
+#define IFF_LOOPBACK 0x8
+#define IFF_POINTOPOINT 0x10
+#define IFF_NOTRAILERS 0x20
+#define IFF_RUNNING 0x40
+#define IFF_NOARP 0x80
+#define IFF_PROMISC 0x100
+#define IFF_ALLMULTI 0x200
+#define IFF_MASTER 0x400
+#define IFF_SLAVE 0x800
+#define IFF_MULTICAST 0x1000
+#define IFF_PORTSEL 0x2000
+#define IFF_AUTOMEDIA 0x4000
+#define IFF_DYNAMIC 0x8000
+#define IFF_LOWER_UP 0x10000
+#define IFF_DORMANT 0x20000
+#define IFF_ECHO 0x40000
+#define IFF_VOLATILE (IFF_LOOPBACK|IFF_POINTOPOINT|IFF_BROADCAST| \
+ IFF_ECHO|IFF_MASTER|IFF_SLAVE|IFF_RUNNING|IFF_LOWER_UP|IFF_DORMANT)
+
+struct ifaddr {
+ struct sockaddr ifa_addr;
+ union {
+ struct sockaddr ifu_broadaddr;
+ struct sockaddr ifu_dstaddr;
+ } ifa_ifu;
+ struct iface *ifa_ifp;
+ struct ifaddr *ifa_next;
+};
+
+#define ifa_broadaddr ifa_ifu.ifu_broadaddr
+#define ifa_dstaddr ifa_ifu.ifu_dstaddr
+
+struct ifmap {
+ unsigned long int mem_start;
+ unsigned long int mem_end;
+ unsigned short int base_addr;
+ unsigned char irq;
+ unsigned char dma;
+ unsigned char port;
+};
+
+#define IFHWADDRLEN 6
+#define IFNAMSIZ IF_NAMESIZE
+
+struct ifreq {
+ union {
+ char ifrn_name[IFNAMSIZ];
+ } ifr_ifrn;
+ union {
+ struct sockaddr ifru_addr;
+ struct sockaddr ifru_dstaddr;
+ struct sockaddr ifru_broadaddr;
+ struct sockaddr ifru_netmask;
+ struct sockaddr ifru_hwaddr;
+ short int ifru_flags;
+ int ifru_ivalue;
+ int ifru_mtu;
+ struct ifmap ifru_map;
+ char ifru_slave[IFNAMSIZ];
+ char ifru_newname[IFNAMSIZ];
+ void *ifru_data;
+ } ifr_ifru;
+};
+
+#define ifr_name ifr_ifrn.ifrn_name
+#define ifr_hwaddr ifr_ifru.ifru_hwaddr
+#define ifr_addr ifr_ifru.ifru_addr
+#define ifr_dstaddr ifr_ifru.ifru_dstaddr
+#define ifr_broadaddr ifr_ifru.ifru_broadaddr
+#define ifr_netmask ifr_ifru.ifru_netmask
+#define ifr_flags ifr_ifru.ifru_flags
+#define ifr_metric ifr_ifru.ifru_ivalue
+#define ifr_mtu ifr_ifru.ifru_mtu
+#define ifr_map ifr_ifru.ifru_map
+#define ifr_slave ifr_ifru.ifru_slave
+#define ifr_data ifr_ifru.ifru_data
+#define ifr_ifindex ifr_ifru.ifru_ivalue
+#define ifr_bandwidth ifr_ifru.ifru_ivalue
+#define ifr_qlen ifr_ifru.ifru_ivalue
+#define ifr_newname ifr_ifru.ifru_newname
+#define _IOT_ifreq _IOT(_IOTS(char),IFNAMSIZ,_IOTS(char),16,0,0)
+#define _IOT_ifreq_short _IOT(_IOTS(char),IFNAMSIZ,_IOTS(short),1,0,0)
+#define _IOT_ifreq_int _IOT(_IOTS(char),IFNAMSIZ,_IOTS(int),1,0,0)
+
+struct ifconf {
+ int ifc_len;
+ union {
+ void *ifcu_buf;
+ struct ifreq *ifcu_req;
+ } ifc_ifcu;
+};
+
+#define ifc_buf ifc_ifcu.ifcu_buf
+#define ifc_req ifc_ifcu.ifcu_req
+#define _IOT_ifconf _IOT(_IOTS(struct ifconf),1,0,0,0,0)
+
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/net/if_arp.h b/system/include/libc/net/if_arp.h
new file mode 100644
index 00000000..371ab104
--- /dev/null
+++ b/system/include/libc/net/if_arp.h
@@ -0,0 +1,133 @@
+/* Nonstandard header */
+#ifndef _NET_IF_ARP_H
+#define _NET_IF_ARP_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <inttypes.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+
+#define MAX_ADDR_LEN 7
+
+#define ARPOP_REQUEST 1
+#define ARPOP_REPLY 2
+#define ARPOP_RREQUEST 3
+#define ARPOP_RREPLY 4
+#define ARPOP_InREQUEST 8
+#define ARPOP_InREPLY 9
+#define ARPOP_NAK 10
+
+struct arphdr {
+ uint16_t ar_hrd;
+ uint16_t ar_pro;
+ uint8_t ar_hln;
+ uint8_t ar_pln;
+ uint16_t ar_op;
+};
+
+
+#define ARPHRD_NETROM 0
+#define ARPHRD_ETHER 1
+#define ARPHRD_EETHER 2
+#define ARPHRD_AX25 3
+#define ARPHRD_PRONET 4
+#define ARPHRD_CHAOS 5
+#define ARPHRD_IEEE802 6
+#define ARPHRD_ARCNET 7
+#define ARPHRD_APPLETLK 8
+#define ARPHRD_DLCI 15
+#define ARPHRD_ATM 19
+#define ARPHRD_METRICOM 23
+#define ARPHRD_IEEE1394 24
+#define ARPHRD_EUI64 27
+#define ARPHRD_INFINIBAND 32
+#define ARPHRD_SLIP 256
+#define ARPHRD_CSLIP 257
+#define ARPHRD_SLIP6 258
+#define ARPHRD_CSLIP6 259
+#define ARPHRD_RSRVD 260
+#define ARPHRD_ADAPT 264
+#define ARPHRD_ROSE 270
+#define ARPHRD_X25 271
+#define ARPHRD_HWX25 272
+#define ARPHRD_PPP 512
+#define ARPHRD_CISCO 513
+#define ARPHRD_HDLC ARPHRD_CISCO
+#define ARPHRD_LAPB 516
+#define ARPHRD_DDCMP 517
+#define ARPHRD_RAWHDLC 518
+
+#define ARPHRD_TUNNEL 768
+#define ARPHRD_TUNNEL6 769
+#define ARPHRD_FRAD 770
+#define ARPHRD_SKIP 771
+#define ARPHRD_LOOPBACK 772
+#define ARPHRD_LOCALTLK 773
+#define ARPHRD_FDDI 774
+#define ARPHRD_BIF 775
+#define ARPHRD_SIT 776
+#define ARPHRD_IPDDP 777
+#define ARPHRD_IPGRE 778
+#define ARPHRD_PIMREG 779
+#define ARPHRD_HIPPI 780
+#define ARPHRD_ASH 781
+#define ARPHRD_ECONET 782
+#define ARPHRD_IRDA 783
+#define ARPHRD_FCPP 784
+#define ARPHRD_FCAL 785
+#define ARPHRD_FCPL 786
+#define ARPHRD_FCFABRIC 787
+#define ARPHRD_IEEE802_TR 800
+#define ARPHRD_IEEE80211 801
+#define ARPHRD_IEEE80211_PRISM 802
+#define ARPHRD_IEEE80211_RADIOTAP 803
+#define ARPHRD_IEEE802154 804
+#define ARPHRD_IEEE802154_PHY 805
+
+#define ARPHRD_VOID 0xFFFF
+#define ARPHRD_NONE 0xFFFE
+
+struct arpreq {
+ struct sockaddr arp_pa;
+ struct sockaddr arp_ha;
+ int arp_flags;
+ struct sockaddr arp_netmask;
+ char arp_dev[16];
+};
+
+struct arpreq_old {
+ struct sockaddr arp_pa;
+ struct sockaddr arp_ha;
+ int arp_flags;
+ struct sockaddr arp_netmask;
+};
+
+#define ATF_COM 0x02
+#define ATF_PERM 0x04
+#define ATF_PUBL 0x08
+#define ATF_USETRAILERS 0x10
+#define ATF_NETMASK 0x20
+#define ATF_DONTPUB 0x40
+#define ATF_MAGIC 0x80
+
+#define ARPD_UPDATE 0x01
+#define ARPD_LOOKUP 0x02
+#define ARPD_FLUSH 0x03
+
+struct arpd_request {
+ unsigned short req;
+ uint32_t ip;
+ unsigned long dev;
+ unsigned long stamp;
+ unsigned long updated;
+ unsigned char ha[MAX_ADDR_LEN];
+};
+
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/system/include/libc/net/route.h b/system/include/libc/net/route.h
new file mode 100644
index 00000000..96ff48e0
--- /dev/null
+++ b/system/include/libc/net/route.h
@@ -0,0 +1,124 @@
+#ifndef _NET_ROUTE_H
+#define _NET_ROUTE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <netinet/in.h>
+
+
+struct rtentry {
+ unsigned long int rt_pad1;
+ struct sockaddr rt_dst;
+ struct sockaddr rt_gateway;
+ struct sockaddr rt_genmask;
+ unsigned short int rt_flags;
+ short int rt_pad2;
+ unsigned long int rt_pad3;
+ unsigned char rt_tos;
+ unsigned char rt_class;
+ short int rt_pad4[sizeof(long)/2-1];
+ short int rt_metric;
+ char *rt_dev;
+ unsigned long int rt_mtu;
+ unsigned long int rt_window;
+ unsigned short int rt_irtt;
+};
+
+#define rt_mss rt_mtu
+
+
+struct in6_rtmsg {
+ struct in6_addr rtmsg_dst;
+ struct in6_addr rtmsg_src;
+ struct in6_addr rtmsg_gateway;
+ uint32_t rtmsg_type;
+ uint16_t rtmsg_dst_len;
+ uint16_t rtmsg_src_len;
+ uint32_t rtmsg_metric;
+ unsigned long int rtmsg_info;
+ uint32_t rtmsg_flags;
+ int rtmsg_ifindex;
+};
+
+
+#define RTF_UP 0x0001
+#define RTF_GATEWAY 0x0002
+
+#define RTF_HOST 0x0004
+#define RTF_REINSTATE 0x0008
+#define RTF_DYNAMIC 0x0010
+#define RTF_MODIFIED 0x0020
+#define RTF_MTU 0x0040
+#define RTF_MSS RTF_MTU
+#define RTF_WINDOW 0x0080
+#define RTF_IRTT 0x0100
+#define RTF_REJECT 0x0200
+#define RTF_STATIC 0x0400
+#define RTF_XRESOLVE 0x0800
+#define RTF_NOFORWARD 0x1000
+#define RTF_THROW 0x2000
+#define RTF_NOPMTUDISC 0x4000
+
+#define RTF_DEFAULT 0x00010000
+#define RTF_ALLONLINK 0x00020000
+#define RTF_ADDRCONF 0x00040000
+
+#define RTF_LINKRT 0x00100000
+#define RTF_NONEXTHOP 0x00200000
+
+#define RTF_CACHE 0x01000000
+#define RTF_FLOW 0x02000000
+#define RTF_POLICY 0x04000000
+
+#define RTCF_VALVE 0x00200000
+#define RTCF_MASQ 0x00400000
+#define RTCF_NAT 0x00800000
+#define RTCF_DOREDIRECT 0x01000000
+#define RTCF_LOG 0x02000000
+#define RTCF_DIRECTSRC 0x04000000
+
+#define RTF_LOCAL 0x80000000
+#define RTF_INTERFACE 0x40000000
+#define RTF_MULTICAST 0x20000000
+#define RTF_BROADCAST 0x10000000
+#define RTF_NAT 0x08000000
+
+#define RTF_ADDRCLASSMASK 0xF8000000
+#define RT_ADDRCLASS(flags) ((uint32_t) flags >> 23)
+
+#define RT_TOS(tos) ((tos) & IPTOS_TOS_MASK)
+
+#define RT_LOCALADDR(flags) ((flags & RTF_ADDRCLASSMASK) \
+ == (RTF_LOCAL|RTF_INTERFACE))
+
+#define RT_CLASS_UNSPEC 0
+#define RT_CLASS_DEFAULT 253
+
+#define RT_CLASS_MAIN 254
+#define RT_CLASS_LOCAL 255
+#define RT_CLASS_MAX 255
+
+
+#define RTMSG_ACK NLMSG_ACK
+#define RTMSG_OVERRUN NLMSG_OVERRUN
+
+#define RTMSG_NEWDEVICE 0x11
+#define RTMSG_DELDEVICE 0x12
+#define RTMSG_NEWROUTE 0x21
+#define RTMSG_DELROUTE 0x22
+#define RTMSG_NEWRULE 0x31
+#define RTMSG_DELRULE 0x32
+#define RTMSG_CONTROL 0x40
+
+#define RTMSG_AR_FAILED 0x51
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/netdb.h b/system/include/libc/netdb.h
new file mode 100644
index 00000000..8a7013ad
--- /dev/null
+++ b/system/include/libc/netdb.h
@@ -0,0 +1,161 @@
+#ifndef _NETDB_H
+#define _NETDB_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <features.h>
+#include <netinet/in.h>
+
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+#define __NEED_size_t
+#include <bits/alltypes.h>
+#endif
+
+struct addrinfo
+{
+ int ai_flags;
+ int ai_family;
+ int ai_socktype;
+ int ai_protocol;
+ socklen_t ai_addrlen;
+ struct sockaddr *ai_addr;
+ char *ai_canonname;
+ struct addrinfo *ai_next;
+};
+
+#define IPPORT_RESERVED 1024
+
+#define AI_PASSIVE 0x01
+#define AI_CANONNAME 0x02
+#define AI_NUMERICHOST 0x04
+#define AI_V4MAPPED 0x08
+#define AI_ALL 0x10
+#define AI_ADDRCONFIG 0x20
+#define AI_NUMERICSERV 0x400
+
+
+#define NI_NUMERICHOST 0x01
+#define NI_NUMERICSERV 0x02
+#define NI_NOFQDN 0x04
+#define NI_NAMEREQD 0x08
+#define NI_DGRAM 0x10
+/*#define NI_NUMERICSCOPE */
+
+#define EAI_BADFLAGS -1
+#define EAI_NONAME -2
+#define EAI_AGAIN -3
+#define EAI_FAIL -4
+#define EAI_FAMILY -6
+#define EAI_SOCKTYPE -7
+#define EAI_SERVICE -8
+#define EAI_MEMORY -10
+#define EAI_SYSTEM -11
+#define EAI_OVERFLOW -12
+
+int getaddrinfo (const char *__restrict, const char *__restrict, const struct addrinfo *__restrict, struct addrinfo **__restrict);
+void freeaddrinfo (struct addrinfo *);
+int getnameinfo (const struct sockaddr *__restrict, socklen_t, char *__restrict, socklen_t, char *__restrict, socklen_t, int);
+const char *gai_strerror(int);
+
+
+/* Legacy functions follow (marked OBsolete in SUS) */
+
+struct netent
+{
+ char *n_name;
+ char **n_aliases;
+ int n_addrtype;
+ uint32_t n_net;
+};
+
+struct hostent
+{
+ char *h_name;
+ char **h_aliases;
+ int h_addrtype;
+ int h_length;
+ char **h_addr_list;
+};
+#define h_addr h_addr_list[0]
+
+struct servent
+{
+ char *s_name;
+ char **s_aliases;
+ int s_port;
+ char *s_proto;
+};
+
+struct protoent
+{
+ char *p_name;
+ char **p_aliases;
+ int p_proto;
+};
+
+void sethostent (int);
+void endhostent (void);
+struct hostent *gethostent (void);
+
+void setnetent (int);
+void endnetent (void);
+struct netent *getnetent (void);
+struct netent *getnetbyaddr (uint32_t, int);
+struct netent *getnetbyname (const char *);
+
+void setservent (int);
+void endservent (void);
+struct servent *getservent (void);
+struct servent *getservbyname (const char *, const char *);
+struct servent *getservbyport (int, const char *);
+
+void setprotoent (int);
+void endprotoent (void);
+struct protoent *getprotoent (void);
+struct protoent *getprotobyname (const char *);
+struct protoent *getprotobynumber (int);
+
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) || defined(_POSIX_SOURCE) \
+ || (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE+0 < 200809L) \
+ || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE+0 < 700)
+struct hostent *gethostbyname (const char *);
+struct hostent *gethostbyaddr (const void *, socklen_t, int);
+#ifdef __GNUC__
+__attribute__((const))
+#endif
+int *__h_errno_location(void);
+#define h_errno (*__h_errno_location())
+#define HOST_NOT_FOUND 1
+#define TRY_AGAIN 2
+#define NO_RECOVERY 3
+#define NO_DATA 4
+#endif
+
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+const char *hstrerror(int);
+int gethostbyname_r(const char *, struct hostent *, char *, size_t, struct hostent **, int *);
+int gethostbyname2_r(const char *, int, struct hostent *, char *, size_t, struct hostent **, int *);
+struct hostent *gethostbyname2(const char *, int);
+int gethostbyaddr_r(const void *, socklen_t, int, struct hostent *, char *, size_t, struct hostent **, int *);
+int getservbyport_r(int, const char *, struct servent *, char *, size_t, struct servent **);
+int getservbyname_r(const char *, const char *, struct servent *, char *, size_t, struct servent **);
+#define EAI_NODATA -5
+#define EAI_ADDRFAMILY -9
+#define EAI_INPROGRESS -100
+#define EAI_CANCELED -101
+#define EAI_NOTCANCELED -102
+#define EAI_ALLDONE -103
+#define EAI_INTR -104
+#define EAI_IDN_ENCODE -105
+#define NI_MAXHOST 255
+#define NI_MAXSERV 32
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/netinet/ether.h b/system/include/libc/netinet/ether.h
new file mode 100644
index 00000000..d64c9ef5
--- /dev/null
+++ b/system/include/libc/netinet/ether.h
@@ -0,0 +1,14 @@
+#ifndef _NETINET_ETHER_H
+#define _NETINET_ETHER_H
+
+#include <netinet/if_ether.h>
+
+char *ether_ntoa (const struct ether_addr *);
+struct ether_addr *ether_aton (const char *);
+char *ether_ntoa_r (const struct ether_addr *, char *);
+struct ether_addr *ether_aton_r (const char *, struct ether_addr *);
+int ether_line(const char *, struct ether_addr *, char *);
+int ether_ntohost(char *, const struct ether_addr *);
+int ether_hostton(const char *, struct ether_addr *);
+
+#endif
diff --git a/system/include/libc/netinet/icmp6.h b/system/include/libc/netinet/icmp6.h
new file mode 100644
index 00000000..01269e7d
--- /dev/null
+++ b/system/include/libc/netinet/icmp6.h
@@ -0,0 +1,305 @@
+#ifndef _NETINET_ICMP6_H
+#define _NETINET_ICMP6_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+#include <string.h>
+#include <sys/types.h>
+#include <netinet/in.h>
+
+#define ICMP6_FILTER 1
+
+#define ICMP6_FILTER_BLOCK 1
+#define ICMP6_FILTER_PASS 2
+#define ICMP6_FILTER_BLOCKOTHERS 3
+#define ICMP6_FILTER_PASSONLY 4
+
+struct icmp6_filter {
+ uint32_t icmp6_filt[8];
+};
+
+struct icmp6_hdr {
+ uint8_t icmp6_type;
+ uint8_t icmp6_code;
+ uint16_t icmp6_cksum;
+ union {
+ uint32_t icmp6_un_data32[1];
+ uint16_t icmp6_un_data16[2];
+ uint8_t icmp6_un_data8[4];
+ } icmp6_dataun;
+};
+
+#define icmp6_data32 icmp6_dataun.icmp6_un_data32
+#define icmp6_data16 icmp6_dataun.icmp6_un_data16
+#define icmp6_data8 icmp6_dataun.icmp6_un_data8
+#define icmp6_pptr icmp6_data32[0]
+#define icmp6_mtu icmp6_data32[0]
+#define icmp6_id icmp6_data16[0]
+#define icmp6_seq icmp6_data16[1]
+#define icmp6_maxdelay icmp6_data16[0]
+
+#define ICMP6_DST_UNREACH 1
+#define ICMP6_PACKET_TOO_BIG 2
+#define ICMP6_TIME_EXCEEDED 3
+#define ICMP6_PARAM_PROB 4
+
+#define ICMP6_INFOMSG_MASK 0x80
+
+#define ICMP6_ECHO_REQUEST 128
+#define ICMP6_ECHO_REPLY 129
+#define MLD_LISTENER_QUERY 130
+#define MLD_LISTENER_REPORT 131
+#define MLD_LISTENER_REDUCTION 132
+
+#define ICMP6_DST_UNREACH_NOROUTE 0
+#define ICMP6_DST_UNREACH_ADMIN 1
+#define ICMP6_DST_UNREACH_BEYONDSCOPE 2
+#define ICMP6_DST_UNREACH_ADDR 3
+#define ICMP6_DST_UNREACH_NOPORT 4
+
+#define ICMP6_TIME_EXCEED_TRANSIT 0
+#define ICMP6_TIME_EXCEED_REASSEMBLY 1
+
+#define ICMP6_PARAMPROB_HEADER 0
+#define ICMP6_PARAMPROB_NEXTHEADER 1
+#define ICMP6_PARAMPROB_OPTION 2
+
+#define ICMP6_FILTER_WILLPASS(type, filterp) \
+ ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) == 0)
+
+#define ICMP6_FILTER_WILLBLOCK(type, filterp) \
+ ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) != 0)
+
+#define ICMP6_FILTER_SETPASS(type, filterp) \
+ ((((filterp)->icmp6_filt[(type) >> 5]) &= ~(1 << ((type) & 31))))
+
+#define ICMP6_FILTER_SETBLOCK(type, filterp) \
+ ((((filterp)->icmp6_filt[(type) >> 5]) |= (1 << ((type) & 31))))
+
+#define ICMP6_FILTER_SETPASSALL(filterp) \
+ memset (filterp, 0, sizeof (struct icmp6_filter));
+
+#define ICMP6_FILTER_SETBLOCKALL(filterp) \
+ memset (filterp, 0xFF, sizeof (struct icmp6_filter));
+
+#define ND_ROUTER_SOLICIT 133
+#define ND_ROUTER_ADVERT 134
+#define ND_NEIGHBOR_SOLICIT 135
+#define ND_NEIGHBOR_ADVERT 136
+#define ND_REDIRECT 137
+
+struct nd_router_solicit {
+ struct icmp6_hdr nd_rs_hdr;
+};
+
+#define nd_rs_type nd_rs_hdr.icmp6_type
+#define nd_rs_code nd_rs_hdr.icmp6_code
+#define nd_rs_cksum nd_rs_hdr.icmp6_cksum
+#define nd_rs_reserved nd_rs_hdr.icmp6_data32[0]
+
+struct nd_router_advert {
+ struct icmp6_hdr nd_ra_hdr;
+ uint32_t nd_ra_reachable;
+ uint32_t nd_ra_retransmit;
+};
+
+#define nd_ra_type nd_ra_hdr.icmp6_type
+#define nd_ra_code nd_ra_hdr.icmp6_code
+#define nd_ra_cksum nd_ra_hdr.icmp6_cksum
+#define nd_ra_curhoplimit nd_ra_hdr.icmp6_data8[0]
+#define nd_ra_flags_reserved nd_ra_hdr.icmp6_data8[1]
+#define ND_RA_FLAG_MANAGED 0x80
+#define ND_RA_FLAG_OTHER 0x40
+#define ND_RA_FLAG_HOME_AGENT 0x20
+#define nd_ra_router_lifetime nd_ra_hdr.icmp6_data16[1]
+
+struct nd_neighbor_solicit {
+ struct icmp6_hdr nd_ns_hdr;
+ struct in6_addr nd_ns_target;
+};
+
+#define nd_ns_type nd_ns_hdr.icmp6_type
+#define nd_ns_code nd_ns_hdr.icmp6_code
+#define nd_ns_cksum nd_ns_hdr.icmp6_cksum
+#define nd_ns_reserved nd_ns_hdr.icmp6_data32[0]
+
+struct nd_neighbor_advert {
+ struct icmp6_hdr nd_na_hdr;
+ struct in6_addr nd_na_target;
+};
+
+#define nd_na_type nd_na_hdr.icmp6_type
+#define nd_na_code nd_na_hdr.icmp6_code
+#define nd_na_cksum nd_na_hdr.icmp6_cksum
+#define nd_na_flags_reserved nd_na_hdr.icmp6_data32[0]
+#if __BYTE_ORDER == __BIG_ENDIAN
+#define ND_NA_FLAG_ROUTER 0x80000000
+#define ND_NA_FLAG_SOLICITED 0x40000000
+#define ND_NA_FLAG_OVERRIDE 0x20000000
+#else
+#define ND_NA_FLAG_ROUTER 0x00000080
+#define ND_NA_FLAG_SOLICITED 0x00000040
+#define ND_NA_FLAG_OVERRIDE 0x00000020
+#endif
+
+struct nd_redirect {
+ struct icmp6_hdr nd_rd_hdr;
+ struct in6_addr nd_rd_target;
+ struct in6_addr nd_rd_dst;
+};
+
+#define nd_rd_type nd_rd_hdr.icmp6_type
+#define nd_rd_code nd_rd_hdr.icmp6_code
+#define nd_rd_cksum nd_rd_hdr.icmp6_cksum
+#define nd_rd_reserved nd_rd_hdr.icmp6_data32[0]
+
+struct nd_opt_hdr {
+ uint8_t nd_opt_type;
+ uint8_t nd_opt_len;
+};
+
+#define ND_OPT_SOURCE_LINKADDR 1
+#define ND_OPT_TARGET_LINKADDR 2
+#define ND_OPT_PREFIX_INFORMATION 3
+#define ND_OPT_REDIRECTED_HEADER 4
+#define ND_OPT_MTU 5
+#define ND_OPT_RTR_ADV_INTERVAL 7
+#define ND_OPT_HOME_AGENT_INFO 8
+
+struct nd_opt_prefix_info {
+ uint8_t nd_opt_pi_type;
+ uint8_t nd_opt_pi_len;
+ uint8_t nd_opt_pi_prefix_len;
+ uint8_t nd_opt_pi_flags_reserved;
+ uint32_t nd_opt_pi_valid_time;
+ uint32_t nd_opt_pi_preferred_time;
+ uint32_t nd_opt_pi_reserved2;
+ struct in6_addr nd_opt_pi_prefix;
+};
+
+#define ND_OPT_PI_FLAG_ONLINK 0x80
+#define ND_OPT_PI_FLAG_AUTO 0x40
+#define ND_OPT_PI_FLAG_RADDR 0x20
+
+struct nd_opt_rd_hdr {
+ uint8_t nd_opt_rh_type;
+ uint8_t nd_opt_rh_len;
+ uint16_t nd_opt_rh_reserved1;
+ uint32_t nd_opt_rh_reserved2;
+};
+
+struct nd_opt_mtu {
+ uint8_t nd_opt_mtu_type;
+ uint8_t nd_opt_mtu_len;
+ uint16_t nd_opt_mtu_reserved;
+ uint32_t nd_opt_mtu_mtu;
+};
+
+struct mld_hdr {
+ struct icmp6_hdr mld_icmp6_hdr;
+ struct in6_addr mld_addr;
+};
+
+#define mld_type mld_icmp6_hdr.icmp6_type
+#define mld_code mld_icmp6_hdr.icmp6_code
+#define mld_cksum mld_icmp6_hdr.icmp6_cksum
+#define mld_maxdelay mld_icmp6_hdr.icmp6_data16[0]
+#define mld_reserved mld_icmp6_hdr.icmp6_data16[1]
+
+#define ICMP6_ROUTER_RENUMBERING 138
+
+struct icmp6_router_renum {
+ struct icmp6_hdr rr_hdr;
+ uint8_t rr_segnum;
+ uint8_t rr_flags;
+ uint16_t rr_maxdelay;
+ uint32_t rr_reserved;
+};
+
+#define rr_type rr_hdr.icmp6_type
+#define rr_code rr_hdr.icmp6_code
+#define rr_cksum rr_hdr.icmp6_cksum
+#define rr_seqnum rr_hdr.icmp6_data32[0]
+
+#define ICMP6_RR_FLAGS_TEST 0x80
+#define ICMP6_RR_FLAGS_REQRESULT 0x40
+#define ICMP6_RR_FLAGS_FORCEAPPLY 0x20
+#define ICMP6_RR_FLAGS_SPECSITE 0x10
+#define ICMP6_RR_FLAGS_PREVDONE 0x08
+
+struct rr_pco_match {
+ uint8_t rpm_code;
+ uint8_t rpm_len;
+ uint8_t rpm_ordinal;
+ uint8_t rpm_matchlen;
+ uint8_t rpm_minlen;
+ uint8_t rpm_maxlen;
+ uint16_t rpm_reserved;
+ struct in6_addr rpm_prefix;
+};
+
+#define RPM_PCO_ADD 1
+#define RPM_PCO_CHANGE 2
+#define RPM_PCO_SETGLOBAL 3
+
+struct rr_pco_use {
+ uint8_t rpu_uselen;
+ uint8_t rpu_keeplen;
+ uint8_t rpu_ramask;
+ uint8_t rpu_raflags;
+ uint32_t rpu_vltime;
+ uint32_t rpu_pltime;
+ uint32_t rpu_flags;
+ struct in6_addr rpu_prefix;
+};
+
+#define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK 0x20
+#define ICMP6_RR_PCOUSE_RAFLAGS_AUTO 0x10
+
+#if __BYTE_ORDER == __BIG_ENDIAN
+#define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80000000
+#define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40000000
+#else
+#define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80
+#define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40
+#endif
+
+struct rr_result {
+ uint16_t rrr_flags;
+ uint8_t rrr_ordinal;
+ uint8_t rrr_matchedlen;
+ uint32_t rrr_ifid;
+ struct in6_addr rrr_prefix;
+};
+
+#if __BYTE_ORDER == __BIG_ENDIAN
+#define ICMP6_RR_RESULT_FLAGS_OOB 0x0002
+#define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0001
+#else
+#define ICMP6_RR_RESULT_FLAGS_OOB 0x0200
+#define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0100
+#endif
+
+struct nd_opt_adv_interval {
+ uint8_t nd_opt_adv_interval_type;
+ uint8_t nd_opt_adv_interval_len;
+ uint16_t nd_opt_adv_interval_reserved;
+ uint32_t nd_opt_adv_interval_ival;
+};
+
+struct nd_opt_home_agent_info {
+ uint8_t nd_opt_home_agent_info_type;
+ uint8_t nd_opt_home_agent_info_len;
+ uint16_t nd_opt_home_agent_info_reserved;
+ uint16_t nd_opt_home_agent_info_preference;
+ uint16_t nd_opt_home_agent_info_lifetime;
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/netinet/if_ether.h b/system/include/libc/netinet/if_ether.h
new file mode 100644
index 00000000..17d5dabd
--- /dev/null
+++ b/system/include/libc/netinet/if_ether.h
@@ -0,0 +1,126 @@
+#ifndef _NETINET_IF_ETHER_H
+#define _NETINET_IF_ETHER_H
+
+#include <stdint.h>
+#include <sys/types.h>
+
+#define ETH_ALEN 6
+#define ETH_HLEN 14
+#define ETH_ZLEN 60
+#define ETH_DATA_LEN 1500
+#define ETH_FRAME_LEN 1514
+#define ETH_FCS_LEN 4
+
+#define ETH_P_LOOP 0x0060
+#define ETH_P_PUP 0x0200
+#define ETH_P_PUPAT 0x0201
+#define ETH_P_IP 0x0800
+#define ETH_P_X25 0x0805
+#define ETH_P_ARP 0x0806
+#define ETH_P_BPQ 0x08FF
+#define ETH_P_IEEEPUP 0x0a00
+#define ETH_P_IEEEPUPAT 0x0a01
+#define ETH_P_BATMAN 0x4305
+#define ETH_P_DEC 0x6000
+#define ETH_P_DNA_DL 0x6001
+#define ETH_P_DNA_RC 0x6002
+#define ETH_P_DNA_RT 0x6003
+#define ETH_P_LAT 0x6004
+#define ETH_P_DIAG 0x6005
+#define ETH_P_CUST 0x6006
+#define ETH_P_SCA 0x6007
+#define ETH_P_TEB 0x6558
+#define ETH_P_RARP 0x8035
+#define ETH_P_ATALK 0x809B
+#define ETH_P_AARP 0x80F3
+#define ETH_P_8021Q 0x8100
+#define ETH_P_IPX 0x8137
+#define ETH_P_IPV6 0x86DD
+#define ETH_P_PAUSE 0x8808
+#define ETH_P_SLOW 0x8809
+#define ETH_P_WCCP 0x883E
+#define ETH_P_PPP_DISC 0x8863
+#define ETH_P_PPP_SES 0x8864
+#define ETH_P_MPLS_UC 0x8847
+#define ETH_P_MPLS_MC 0x8848
+#define ETH_P_ATMMPOA 0x884c
+#define ETH_P_LINK_CTL 0x886c
+#define ETH_P_ATMFATE 0x8884
+#define ETH_P_PAE 0x888E
+#define ETH_P_AOE 0x88A2
+#define ETH_P_8021AD 0x88A8
+#define ETH_P_802_EX1 0x88B5
+#define ETH_P_TIPC 0x88CA
+#define ETH_P_8021AH 0x88E7
+#define ETH_P_MVRP 0x88F5
+#define ETH_P_1588 0x88F7
+#define ETH_P_FCOE 0x8906
+#define ETH_P_TDLS 0x890D
+#define ETH_P_FIP 0x8914
+#define ETH_P_QINQ1 0x9100
+#define ETH_P_QINQ2 0x9200
+#define ETH_P_QINQ3 0x9300
+#define ETH_P_EDSA 0xDADA
+#define ETH_P_AF_IUCV 0xFBFB
+
+#define ETH_P_802_3_MIN 0x0600
+
+#define ETH_P_802_3 0x0001
+#define ETH_P_AX25 0x0002
+#define ETH_P_ALL 0x0003
+#define ETH_P_802_2 0x0004
+#define ETH_P_SNAP 0x0005
+#define ETH_P_DDCMP 0x0006
+#define ETH_P_WAN_PPP 0x0007
+#define ETH_P_PPP_MP 0x0008
+#define ETH_P_LOCALTALK 0x0009
+#define ETH_P_CAN 0x000C
+#define ETH_P_CANFD 0x000D
+#define ETH_P_PPPTALK 0x0010
+#define ETH_P_TR_802_2 0x0011
+#define ETH_P_MOBITEX 0x0015
+#define ETH_P_CONTROL 0x0016
+#define ETH_P_IRDA 0x0017
+#define ETH_P_ECONET 0x0018
+#define ETH_P_HDLC 0x0019
+#define ETH_P_ARCNET 0x001A
+#define ETH_P_DSA 0x001B
+#define ETH_P_TRAILER 0x001C
+#define ETH_P_PHONET 0x00F5
+#define ETH_P_IEEE802154 0x00F6
+#define ETH_P_CAIF 0x00F7
+
+struct ethhdr {
+ uint8_t h_dest[ETH_ALEN];
+ uint8_t h_source[ETH_ALEN];
+ uint16_t h_proto;
+};
+
+#include <net/ethernet.h>
+#include <net/if_arp.h>
+
+struct ether_arp {
+ struct arphdr ea_hdr;
+ uint8_t arp_sha[ETH_ALEN];
+ uint8_t arp_spa[4];
+ uint8_t arp_tha[ETH_ALEN];
+ uint8_t arp_tpa[4];
+};
+#define arp_hrd ea_hdr.ar_hrd
+#define arp_pro ea_hdr.ar_pro
+#define arp_hln ea_hdr.ar_hln
+#define arp_pln ea_hdr.ar_pln
+#define arp_op ea_hdr.ar_op
+
+#define ETHER_MAP_IP_MULTICAST(ipaddr, enaddr) \
+do { \
+ (enaddr)[0] = 0x01; \
+ (enaddr)[1] = 0x00; \
+ (enaddr)[2] = 0x5e; \
+ (enaddr)[3] = ((uint8_t *)ipaddr)[1] & 0x7f; \
+ (enaddr)[4] = ((uint8_t *)ipaddr)[2]; \
+ (enaddr)[5] = ((uint8_t *)ipaddr)[3]; \
+} while(0)
+
+
+#endif
diff --git a/system/include/libc/netinet/in.h b/system/include/libc/netinet/in.h
new file mode 100644
index 00000000..d886fc28
--- /dev/null
+++ b/system/include/libc/netinet/in.h
@@ -0,0 +1,336 @@
+#ifndef _NETINET_IN_H
+#define _NETINET_IN_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <features.h>
+#include <inttypes.h>
+#include <sys/socket.h>
+
+typedef uint16_t in_port_t;
+typedef uint32_t in_addr_t;
+struct in_addr { in_addr_t s_addr; };
+
+struct sockaddr_in
+{
+ sa_family_t sin_family;
+ in_port_t sin_port;
+ struct in_addr sin_addr;
+ uint8_t sin_zero[8];
+};
+
+struct in6_addr
+{
+ union {
+ uint8_t __s6_addr[16];
+ uint16_t __s6_addr16[8];
+ uint32_t __s6_addr32[4];
+ } __in6_union;
+};
+#define s6_addr __in6_union.__s6_addr
+#define s6_addr16 __in6_union.__s6_addr16
+#define s6_addr32 __in6_union.__s6_addr32
+
+struct sockaddr_in6
+{
+ sa_family_t sin6_family;
+ in_port_t sin6_port;
+ uint32_t sin6_flowinfo;
+ struct in6_addr sin6_addr;
+ uint32_t sin6_scope_id;
+};
+
+struct ipv6_mreq
+{
+ struct in6_addr ipv6mr_multiaddr;
+ unsigned ipv6mr_interface;
+};
+
+#define INADDR_ANY ((in_addr_t) 0x00000000)
+#define INADDR_BROADCAST ((in_addr_t) 0xffffffff)
+#define INADDR_NONE ((in_addr_t) 0xffffffff)
+#define INADDR_LOOPBACK ((in_addr_t) 0x7f000001)
+
+#define IN6ADDR_ANY_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } }
+#define IN6ADDR_LOOPBACK_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } }
+
+extern const struct in6_addr in6addr_any, in6addr_loopback;
+
+#undef INET_ADDRSTRLEN
+#undef INET6_ADDRSTRLEN
+#define INET_ADDRSTRLEN 16
+#define INET6_ADDRSTRLEN 46
+
+uint32_t htonl(uint32_t);
+uint16_t htons(uint16_t);
+uint32_t ntohl(uint32_t);
+uint16_t ntohs(uint16_t);
+
+#define IPPROTO_IP 0
+#define IPPROTO_HOPOPTS 0
+#define IPPROTO_ICMP 1
+#define IPPROTO_IGMP 2
+#define IPPROTO_IPIP 4
+#define IPPROTO_TCP 6
+#define IPPROTO_EGP 8
+#define IPPROTO_PUP 12
+#define IPPROTO_UDP 17
+#define IPPROTO_IDP 22
+#define IPPROTO_TP 29
+#define IPPROTO_DCCP 33
+#define IPPROTO_IPV6 41
+#define IPPROTO_ROUTING 43
+#define IPPROTO_FRAGMENT 44
+#define IPPROTO_RSVP 46
+#define IPPROTO_GRE 47
+#define IPPROTO_ESP 50
+#define IPPROTO_AH 51
+#define IPPROTO_ICMPV6 58
+#define IPPROTO_NONE 59
+#define IPPROTO_DSTOPTS 60
+#define IPPROTO_MTP 92
+#define IPPROTO_ENCAP 98
+#define IPPROTO_PIM 103
+#define IPPROTO_COMP 108
+#define IPPROTO_SCTP 132
+#define IPPROTO_UDPLITE 136
+#define IPPROTO_RAW 255
+#define IPPROTO_MAX 256
+
+#define IN6_IS_ADDR_UNSPECIFIED(a) \
+ (((uint32_t *) (a))[0] == 0 && ((uint32_t *) (a))[1] == 0 && \
+ ((uint32_t *) (a))[2] == 0 && ((uint32_t *) (a))[3] == 0)
+
+#define IN6_IS_ADDR_LOOPBACK(a) \
+ (((uint32_t *) (a))[0] == 0 && ((uint32_t *) (a))[1] == 0 && \
+ ((uint32_t *) (a))[2] == 0 && \
+ ((uint8_t *) (a))[12] == 0 && ((uint8_t *) (a))[13] == 0 && \
+ ((uint8_t *) (a))[14] == 0 && ((uint8_t *) (a))[15] == 1 )
+
+#define IN6_IS_ADDR_MULTICAST(a) (((uint8_t *) (a))[0] == 0xff)
+
+#define IN6_IS_ADDR_LINKLOCAL(a) \
+ ((((uint8_t *) (a))[0]) == 0xfe && (((uint8_t *) (a))[1] & 0xc0) == 0x80)
+
+#define IN6_IS_ADDR_SITELOCAL(a) \
+ ((((uint8_t *) (a))[0]) == 0xfe && (((uint8_t *) (a))[1] & 0xc0) == 0xc0)
+
+#define IN6_IS_ADDR_V4MAPPED(a) \
+ (((uint32_t *) (a))[0] == 0 && ((uint32_t *) (a))[1] == 0 && \
+ ((uint8_t *) (a))[8] == 0 && ((uint8_t *) (a))[9] == 0 && \
+ ((uint8_t *) (a))[10] == 0xff && ((uint8_t *) (a))[11] == 0xff)
+
+#define IN6_IS_ADDR_V4COMPAT(a) \
+ (((uint32_t *) (a))[0] == 0 && ((uint32_t *) (a))[1] == 0 && \
+ ((uint32_t *) (a))[2] == 0 && ((uint8_t *) (a))[15] > 1)
+
+#define IN6_IS_ADDR_MC_NODELOCAL(a) \
+ (IN6_IS_ADDR_MULTICAST(a) && ((((uint8_t *) (a))[1] & 0xf) == 0x1))
+
+#define IN6_IS_ADDR_MC_LINKLOCAL(a) \
+ (IN6_IS_ADDR_MULTICAST(a) && ((((uint8_t *) (a))[1] & 0xf) == 0x2))
+
+#define IN6_IS_ADDR_MC_SITELOCAL(a) \
+ (IN6_IS_ADDR_MULTICAST(a) && ((((uint8_t *) (a))[1] & 0xf) == 0x5))
+
+#define IN6_IS_ADDR_MC_ORGLOCAL(a) \
+ (IN6_IS_ADDR_MULTICAST(a) && ((((uint8_t *) (a))[1] & 0xf) == 0x8))
+
+#define IN6_IS_ADDR_MC_GLOBAL(a) \
+ (IN6_IS_ADDR_MULTICAST(a) && ((((uint8_t *) (a))[1] & 0xf) == 0xe))
+
+#define __ARE_4_EQUAL(a,b) \
+ (!( 0[a]-0[b] | 1[a]-1[b] | 2[a]-2[b] | 3[a]-3[b] ))
+#define IN6_ARE_ADDR_EQUAL(a,b) \
+ __ARE_4_EQUAL((const uint32_t *)(a), (const uint32_t *)(b))
+
+#define IN_CLASSA(a) ((((in_addr_t)(a)) & 0x80000000) == 0)
+#define IN_CLASSA_NET 0xff000000
+#define IN_CLASSA_NSHIFT 24
+#define IN_CLASSA_HOST (0xffffffff & ~IN_CLASSA_NET)
+#define IN_CLASSA_MAX 128
+#define IN_CLASSB(a) ((((in_addr_t)(a)) & 0xc0000000) == 0x80000000)
+#define IN_CLASSB_NET 0xffff0000
+#define IN_CLASSB_NSHIFT 16
+#define IN_CLASSB_HOST (0xffffffff & ~IN_CLASSB_NET)
+#define IN_CLASSB_MAX 65536
+#define IN_CLASSC(a) ((((in_addr_t)(a)) & 0xe0000000) == 0xc0000000)
+#define IN_CLASSC_NET 0xffffff00
+#define IN_CLASSC_NSHIFT 8
+#define IN_CLASSC_HOST (0xffffffff & ~IN_CLASSC_NET)
+#define IN_CLASSD(a) ((((in_addr_t)(a)) & 0xf0000000) == 0xe0000000)
+#define IN_MULTICAST(a) IN_CLASSD(a)
+#define IN_EXPERIMENTAL(a) ((((in_addr_t)(a)) & 0xe0000000) == 0xe0000000)
+#define IN_BADCLASS(a) ((((in_addr_t)(a)) & 0xf0000000) == 0xf0000000)
+
+#define IN_LOOPBACKNET 127
+
+
+#define IP_TOS 1
+#define IP_TTL 2
+#define IP_HDRINCL 3
+#define IP_OPTIONS 4
+#define IP_ROUTER_ALERT 5
+#define IP_RECVOPTS 6
+#define IP_RETOPTS 7
+#define IP_PKTINFO 8
+#define IP_PKTOPTIONS 9
+#define IP_PMTUDISC 10
+#define IP_MTU_DISCOVER 10
+#define IP_RECVERR 11
+#define IP_RECVTTL 12
+#define IP_RECVTOS 13
+#define IP_MTU 14
+#define IP_FREEBIND 15
+#define IP_IPSEC_POLICY 16
+#define IP_XFRM_POLICY 17
+#define IP_PASSSEC 18
+#define IP_TRANSPARENT 19
+#define IP_ORIGDSTADDR 20
+#define IP_RECVORIGDSTADDR IP_ORIGDSTADDR
+#define IP_MINTTL 21
+#define IP_MULTICAST_IF 32
+#define IP_MULTICAST_TTL 33
+#define IP_MULTICAST_LOOP 34
+#define IP_ADD_MEMBERSHIP 35
+#define IP_DROP_MEMBERSHIP 36
+#define IP_UNBLOCK_SOURCE 37
+#define IP_BLOCK_SOURCE 38
+#define IP_ADD_SOURCE_MEMBERSHIP 39
+#define IP_DROP_SOURCE_MEMBERSHIP 40
+#define IP_MSFILTER 41
+#define IP_MULTICAST_ALL 49
+#define IP_UNICAST_IF 50
+
+#ifdef _GNU_SOURCE
+#define MCAST_JOIN_GROUP 42
+#define MCAST_BLOCK_SOURCE 43
+#define MCAST_UNBLOCK_SOURCE 44
+#define MCAST_LEAVE_GROUP 45
+#define MCAST_JOIN_SOURCE_GROUP 46
+#define MCAST_LEAVE_SOURCE_GROUP 47
+#define MCAST_MSFILTER 48
+
+#define MCAST_EXCLUDE 0
+#define MCAST_INCLUDE 1
+#endif
+
+#define IP_RECVRETOPTS IP_RETOPTS
+
+#define IP_PMTUDISC_DONT 0
+#define IP_PMTUDISC_WANT 1
+#define IP_PMTUDISC_DO 2
+#define IP_PMTUDISC_PROBE 3
+
+#define SOL_IP 0
+
+#define IP_DEFAULT_MULTICAST_TTL 1
+#define IP_DEFAULT_MULTICAST_LOOP 1
+#define IP_MAX_MEMBERSHIPS 20
+
+struct ip_opts
+{
+ struct in_addr ip_dst;
+ char ip_opts[40];
+};
+
+struct ip_mreq
+{
+ struct in_addr imr_multiaddr;
+ struct in_addr imr_interface;
+};
+
+struct ip_mreqn
+{
+ struct in_addr imr_multiaddr;
+ struct in_addr imr_address;
+ int imr_ifindex;
+};
+
+struct in_pktinfo
+{
+ int ipi_ifindex;
+ struct in_addr ipi_spec_dst;
+ struct in_addr ipi_addr;
+};
+
+struct in6_pktinfo
+{
+ struct in6_addr ipi6_addr;
+ unsigned ipi6_ifindex;
+};
+
+struct ip6_mtuinfo
+{
+ struct sockaddr_in6 ip6m_addr;
+ uint32_t ip6m_mtu;
+};
+
+#define IPV6_ADDRFORM 1
+#define IPV6_2292PKTINFO 2
+#define IPV6_2292HOPOPTS 3
+#define IPV6_2292DSTOPTS 4
+#define IPV6_2292RTHDR 5
+#define IPV6_2292PKTOPTIONS 6
+#define IPV6_CHECKSUM 7
+#define IPV6_2292HOPLIMIT 8
+#define SCM_SRCRT IPV6_RXSRCRT
+#define IPV6_NEXTHOP 9
+#define IPV6_AUTHHDR 10
+#define IPV6_UNICAST_HOPS 16
+#define IPV6_MULTICAST_IF 17
+#define IPV6_MULTICAST_HOPS 18
+#define IPV6_MULTICAST_LOOP 19
+#define IPV6_JOIN_GROUP 20
+#define IPV6_LEAVE_GROUP 21
+#define IPV6_ROUTER_ALERT 22
+#define IPV6_MTU_DISCOVER 23
+#define IPV6_MTU 24
+#define IPV6_RECVERR 25
+#define IPV6_V6ONLY 26
+#define IPV6_JOIN_ANYCAST 27
+#define IPV6_LEAVE_ANYCAST 28
+#define IPV6_IPSEC_POLICY 34
+#define IPV6_XFRM_POLICY 35
+
+#define IPV6_RECVPKTINFO 49
+#define IPV6_PKTINFO 50
+#define IPV6_RECVHOPLIMIT 51
+#define IPV6_HOPLIMIT 52
+#define IPV6_RECVHOPOPTS 53
+#define IPV6_HOPOPTS 54
+#define IPV6_RTHDRDSTOPTS 55
+#define IPV6_RECVRTHDR 56
+#define IPV6_RTHDR 57
+#define IPV6_RECVDSTOPTS 58
+#define IPV6_DSTOPTS 59
+
+#define IPV6_RECVTCLASS 66
+#define IPV6_TCLASS 67
+
+#define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP
+#define IPV6_DROP_MEMBERSHIP IPV6_LEAVE_GROUP
+#define IPV6_RXHOPOPTS IPV6_HOPOPTS
+#define IPV6_RXDSTOPTS IPV6_DSTOPTS
+
+
+#define IPV6_PMTUDISC_DONT 0
+#define IPV6_PMTUDISC_WANT 1
+#define IPV6_PMTUDISC_DO 2
+#define IPV6_PMTUDISC_PROBE 3
+
+#define SOL_IPV6 41
+#define SOL_ICMPV6 58
+
+#define IPV6_RTHDR_LOOSE 0
+#define IPV6_RTHDR_STRICT 1
+
+#define IPV6_RTHDR_TYPE_0 0
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/netinet/in_systm.h b/system/include/libc/netinet/in_systm.h
new file mode 100644
index 00000000..a7b41772
--- /dev/null
+++ b/system/include/libc/netinet/in_systm.h
@@ -0,0 +1,9 @@
+#ifndef _NETINET_IN_SYSTM_H
+#define _NETINET_IN_SYSTM_H
+
+#include <stdint.h>
+
+typedef uint16_t n_short;
+typedef uint32_t n_long, n_time;
+
+#endif
diff --git a/system/include/libc/netinet/ip.h b/system/include/libc/netinet/ip.h
new file mode 100644
index 00000000..41187414
--- /dev/null
+++ b/system/include/libc/netinet/ip.h
@@ -0,0 +1,186 @@
+#ifndef _NETINET_IP_H
+#define _NETINET_IP_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+#include <netinet/in.h>
+#include <endian.h>
+
+struct timestamp {
+ uint8_t len;
+ uint8_t ptr;
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+ unsigned int flags:4;
+ unsigned int overflow:4;
+#else
+ unsigned int overflow:4;
+ unsigned int flags:4;
+#endif
+ uint32_t data[9];
+ };
+
+struct iphdr {
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+ unsigned int ihl:4;
+ unsigned int version:4;
+#else
+ unsigned int version:4;
+ unsigned int ihl:4;
+#endif
+ uint8_t tos;
+ uint16_t tot_len;
+ uint16_t id;
+ uint16_t frag_off;
+ uint8_t ttl;
+ uint8_t protocol;
+ uint16_t check;
+ uint32_t saddr;
+ uint32_t daddr;
+};
+
+struct ip {
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+ unsigned int ip_hl:4;
+ unsigned int ip_v:4;
+#else
+ unsigned int ip_v:4;
+ unsigned int ip_hl:4;
+#endif
+ uint8_t ip_tos;
+ uint16_t ip_len;
+ uint16_t ip_id;
+ uint16_t ip_off;
+ uint8_t ip_ttl;
+ uint8_t ip_p;
+ uint16_t ip_sum;
+ struct in_addr ip_src, ip_dst;
+};
+
+#define IP_RF 0x8000
+#define IP_DF 0x4000
+#define IP_MF 0x2000
+#define IP_OFFMASK 0x1fff
+
+struct ip_timestamp {
+ uint8_t ipt_code;
+ uint8_t ipt_len;
+ uint8_t ipt_ptr;
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+ unsigned int ipt_flg:4;
+ unsigned int ipt_oflw:4;
+#else
+ unsigned int ipt_oflw:4;
+ unsigned int ipt_flg:4;
+#endif
+ uint32_t data[9];
+};
+
+#define IPVERSION 4
+#define IP_MAXPACKET 65535
+
+#define IPTOS_ECN_MASK 0x03
+#define IPTOS_ECN(x) ((x) & IPTOS_ECN_MASK)
+#define IPTOS_ECN_NOT_ECT 0x00
+#define IPTOS_ECN_ECT1 0x01
+#define IPTOS_ECN_ECT0 0x02
+#define IPTOS_ECN_CE 0x03
+
+#define IPTOS_DSCP_MASK 0xfc
+#define IPTOS_DSCP(x) ((x) & IPTOS_DSCP_MASK)
+#define IPTOS_DSCP_AF11 0x28
+#define IPTOS_DSCP_AF12 0x30
+#define IPTOS_DSCP_AF13 0x38
+#define IPTOS_DSCP_AF21 0x48
+#define IPTOS_DSCP_AF22 0x50
+#define IPTOS_DSCP_AF23 0x58
+#define IPTOS_DSCP_AF31 0x68
+#define IPTOS_DSCP_AF32 0x70
+#define IPTOS_DSCP_AF33 0x78
+#define IPTOS_DSCP_AF41 0x88
+#define IPTOS_DSCP_AF42 0x90
+#define IPTOS_DSCP_AF43 0x98
+#define IPTOS_DSCP_EF 0xb8
+
+#define IPTOS_TOS_MASK 0x1E
+#define IPTOS_TOS(tos) ((tos) & IPTOS_TOS_MASK)
+#define IPTOS_LOWDELAY 0x10
+#define IPTOS_THROUGHPUT 0x08
+#define IPTOS_RELIABILITY 0x04
+#define IPTOS_LOWCOST 0x02
+#define IPTOS_MINCOST IPTOS_LOWCOST
+
+#define IPTOS_PREC_MASK 0xe0
+#define IPTOS_PREC(tos) ((tos) & IPTOS_PREC_MASK)
+#define IPTOS_PREC_NETCONTROL 0xe0
+#define IPTOS_PREC_INTERNETCONTROL 0xc0
+#define IPTOS_PREC_CRITIC_ECP 0xa0
+#define IPTOS_PREC_FLASHOVERRIDE 0x80
+#define IPTOS_PREC_FLASH 0x60
+#define IPTOS_PREC_IMMEDIATE 0x40
+#define IPTOS_PREC_PRIORITY 0x20
+#define IPTOS_PREC_ROUTINE 0x00
+
+#define IPOPT_COPY 0x80
+#define IPOPT_CLASS_MASK 0x60
+#define IPOPT_NUMBER_MASK 0x1f
+
+#define IPOPT_COPIED(o) ((o) & IPOPT_COPY)
+#define IPOPT_CLASS(o) ((o) & IPOPT_CLASS_MASK)
+#define IPOPT_NUMBER(o) ((o) & IPOPT_NUMBER_MASK)
+
+#define IPOPT_CONTROL 0x00
+#define IPOPT_RESERVED1 0x20
+#define IPOPT_DEBMEAS 0x40
+#define IPOPT_MEASUREMENT IPOPT_DEBMEAS
+#define IPOPT_RESERVED2 0x60
+
+#define IPOPT_EOL 0
+#define IPOPT_END IPOPT_EOL
+#define IPOPT_NOP 1
+#define IPOPT_NOOP IPOPT_NOP
+
+#define IPOPT_RR 7
+#define IPOPT_TS 68
+#define IPOPT_TIMESTAMP IPOPT_TS
+#define IPOPT_SECURITY 130
+#define IPOPT_SEC IPOPT_SECURITY
+#define IPOPT_LSRR 131
+#define IPOPT_SATID 136
+#define IPOPT_SID IPOPT_SATID
+#define IPOPT_SSRR 137
+#define IPOPT_RA 148
+
+#define IPOPT_OPTVAL 0
+#define IPOPT_OLEN 1
+#define IPOPT_OFFSET 2
+#define IPOPT_MINOFF 4
+
+#define MAX_IPOPTLEN 40
+
+#define IPOPT_TS_TSONLY 0
+#define IPOPT_TS_TSANDADDR 1
+#define IPOPT_TS_PRESPEC 3
+
+#define IPOPT_SECUR_UNCLASS 0x0000
+#define IPOPT_SECUR_CONFID 0xf135
+#define IPOPT_SECUR_EFTO 0x789a
+#define IPOPT_SECUR_MMMM 0xbc4d
+#define IPOPT_SECUR_RESTR 0xaf13
+#define IPOPT_SECUR_SECRET 0xd788
+#define IPOPT_SECUR_TOPSECRET 0x6bc5
+
+#define MAXTTL 255
+#define IPDEFTTL 64
+#define IPFRAGTTL 60
+#define IPTTLDEC 1
+
+#define IP_MSS 576
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/netinet/ip6.h b/system/include/libc/netinet/ip6.h
new file mode 100644
index 00000000..a4347a53
--- /dev/null
+++ b/system/include/libc/netinet/ip6.h
@@ -0,0 +1,142 @@
+#ifndef _NETINET_IP6_H
+#define _NETINET_IP6_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+#include <netinet/in.h>
+#include <endian.h>
+
+struct ip6_hdr {
+ union {
+ struct ip6_hdrctl {
+ uint32_t ip6_un1_flow;
+ uint16_t ip6_un1_plen;
+ uint8_t ip6_un1_nxt;
+ uint8_t ip6_un1_hlim;
+ } ip6_un1;
+ uint8_t ip6_un2_vfc;
+ } ip6_ctlun;
+ struct in6_addr ip6_src;
+ struct in6_addr ip6_dst;
+};
+
+#define ip6_vfc ip6_ctlun.ip6_un2_vfc
+#define ip6_flow ip6_ctlun.ip6_un1.ip6_un1_flow
+#define ip6_plen ip6_ctlun.ip6_un1.ip6_un1_plen
+#define ip6_nxt ip6_ctlun.ip6_un1.ip6_un1_nxt
+#define ip6_hlim ip6_ctlun.ip6_un1.ip6_un1_hlim
+#define ip6_hops ip6_ctlun.ip6_un1.ip6_un1_hlim
+
+struct ip6_ext {
+ uint8_t ip6e_nxt;
+ uint8_t ip6e_len;
+};
+
+struct ip6_hbh {
+ uint8_t ip6h_nxt;
+ uint8_t ip6h_len;
+};
+
+struct ip6_dest {
+ uint8_t ip6d_nxt;
+ uint8_t ip6d_len;
+};
+
+struct ip6_rthdr {
+ uint8_t ip6r_nxt;
+ uint8_t ip6r_len;
+ uint8_t ip6r_type;
+ uint8_t ip6r_segleft;
+};
+
+struct ip6_rthdr0 {
+ uint8_t ip6r0_nxt;
+ uint8_t ip6r0_len;
+ uint8_t ip6r0_type;
+ uint8_t ip6r0_segleft;
+ uint8_t ip6r0_reserved;
+ uint8_t ip6r0_slmap[3];
+ struct in6_addr ip6r0_addr[];
+};
+
+struct ip6_frag {
+ uint8_t ip6f_nxt;
+ uint8_t ip6f_reserved;
+ uint16_t ip6f_offlg;
+ uint32_t ip6f_ident;
+};
+
+#if __BYTE_ORDER == __BIG_ENDIAN
+#define IP6F_OFF_MASK 0xfff8
+#define IP6F_RESERVED_MASK 0x0006
+#define IP6F_MORE_FRAG 0x0001
+#else
+#define IP6F_OFF_MASK 0xf8ff
+#define IP6F_RESERVED_MASK 0x0600
+#define IP6F_MORE_FRAG 0x0100
+#endif
+
+struct ip6_opt {
+ uint8_t ip6o_type;
+ uint8_t ip6o_len;
+};
+
+#define IP6OPT_TYPE(o) ((o) & 0xc0)
+#define IP6OPT_TYPE_SKIP 0x00
+#define IP6OPT_TYPE_DISCARD 0x40
+#define IP6OPT_TYPE_FORCEICMP 0x80
+#define IP6OPT_TYPE_ICMP 0xc0
+#define IP6OPT_TYPE_MUTABLE 0x20
+
+#define IP6OPT_PAD1 0
+#define IP6OPT_PADN 1
+
+#define IP6OPT_JUMBO 0xc2
+#define IP6OPT_NSAP_ADDR 0xc3
+#define IP6OPT_TUNNEL_LIMIT 0x04
+#define IP6OPT_ROUTER_ALERT 0x05
+
+struct ip6_opt_jumbo {
+ uint8_t ip6oj_type;
+ uint8_t ip6oj_len;
+ uint8_t ip6oj_jumbo_len[4];
+};
+#define IP6OPT_JUMBO_LEN 6
+
+struct ip6_opt_nsap {
+ uint8_t ip6on_type;
+ uint8_t ip6on_len;
+ uint8_t ip6on_src_nsap_len;
+ uint8_t ip6on_dst_nsap_len;
+};
+
+struct ip6_opt_tunnel {
+ uint8_t ip6ot_type;
+ uint8_t ip6ot_len;
+ uint8_t ip6ot_encap_limit;
+};
+
+struct ip6_opt_router {
+ uint8_t ip6or_type;
+ uint8_t ip6or_len;
+ uint8_t ip6or_value[2];
+};
+
+#if __BYTE_ORDER == __BIG_ENDIAN
+#define IP6_ALERT_MLD 0x0000
+#define IP6_ALERT_RSVP 0x0001
+#define IP6_ALERT_AN 0x0002
+#else
+#define IP6_ALERT_MLD 0x0000
+#define IP6_ALERT_RSVP 0x0100
+#define IP6_ALERT_AN 0x0200
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/netinet/ip_icmp.h b/system/include/libc/netinet/ip_icmp.h
new file mode 100644
index 00000000..2f4a86dd
--- /dev/null
+++ b/system/include/libc/netinet/ip_icmp.h
@@ -0,0 +1,192 @@
+#ifndef _NETINET_IP_ICMP_H
+#define _NETINET_IP_ICMP_H
+
+#include <stdint.h>
+#include <netinet/in.h>
+#include <netinet/ip.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct icmphdr {
+ uint8_t type;
+ uint8_t code;
+ uint16_t checksum;
+ union {
+ struct {
+ uint16_t id;
+ uint16_t sequence;
+ } echo;
+ uint32_t gateway;
+ struct {
+ uint16_t __unused;
+ uint16_t mtu;
+ } frag;
+ } un;
+};
+
+#define ICMP_ECHOREPLY 0
+#define ICMP_DEST_UNREACH 3
+#define ICMP_SOURCE_QUENCH 4
+#define ICMP_REDIRECT 5
+#define ICMP_ECHO 8
+#define ICMP_TIME_EXCEEDED 11
+#define ICMP_PARAMETERPROB 12
+#define ICMP_TIMESTAMP 13
+#define ICMP_TIMESTAMPREPLY 14
+#define ICMP_INFO_REQUEST 15
+#define ICMP_INFO_REPLY 16
+#define ICMP_ADDRESS 17
+#define ICMP_ADDRESSREPLY 18
+#define NR_ICMP_TYPES 18
+
+
+#define ICMP_NET_UNREACH 0
+#define ICMP_HOST_UNREACH 1
+#define ICMP_PROT_UNREACH 2
+#define ICMP_PORT_UNREACH 3
+#define ICMP_FRAG_NEEDED 4
+#define ICMP_SR_FAILED 5
+#define ICMP_NET_UNKNOWN 6
+#define ICMP_HOST_UNKNOWN 7
+#define ICMP_HOST_ISOLATED 8
+#define ICMP_NET_ANO 9
+#define ICMP_HOST_ANO 10
+#define ICMP_NET_UNR_TOS 11
+#define ICMP_HOST_UNR_TOS 12
+#define ICMP_PKT_FILTERED 13
+#define ICMP_PREC_VIOLATION 14
+#define ICMP_PREC_CUTOFF 15
+#define NR_ICMP_UNREACH 15
+
+#define ICMP_REDIR_NET 0
+#define ICMP_REDIR_HOST 1
+#define ICMP_REDIR_NETTOS 2
+#define ICMP_REDIR_HOSTTOS 3
+
+#define ICMP_EXC_TTL 0
+#define ICMP_EXC_FRAGTIME 1
+
+
+struct icmp_ra_addr {
+ uint32_t ira_addr;
+ uint32_t ira_preference;
+};
+
+struct icmp {
+ uint8_t icmp_type;
+ uint8_t icmp_code;
+ uint16_t icmp_cksum;
+ union {
+ uint8_t ih_pptr;
+ struct in_addr ih_gwaddr;
+ struct ih_idseq {
+ uint16_t icd_id;
+ uint16_t icd_seq;
+ } ih_idseq;
+ uint32_t ih_void;
+
+ struct ih_pmtu {
+ uint16_t ipm_void;
+ uint16_t ipm_nextmtu;
+ } ih_pmtu;
+
+ struct ih_rtradv {
+ uint8_t irt_num_addrs;
+ uint8_t irt_wpa;
+ uint16_t irt_lifetime;
+ } ih_rtradv;
+ } icmp_hun;
+ union {
+ struct {
+ uint32_t its_otime;
+ uint32_t its_rtime;
+ uint32_t its_ttime;
+ } id_ts;
+ struct {
+ struct ip idi_ip;
+ } id_ip;
+ struct icmp_ra_addr id_radv;
+ uint32_t id_mask;
+ uint8_t id_data[1];
+ } icmp_dun;
+};
+
+#define icmp_pptr icmp_hun.ih_pptr
+#define icmp_gwaddr icmp_hun.ih_gwaddr
+#define icmp_id icmp_hun.ih_idseq.icd_id
+#define icmp_seq icmp_hun.ih_idseq.icd_seq
+#define icmp_void icmp_hun.ih_void
+#define icmp_pmvoid icmp_hun.ih_pmtu.ipm_void
+#define icmp_nextmtu icmp_hun.ih_pmtu.ipm_nextmtu
+#define icmp_num_addrs icmp_hun.ih_rtradv.irt_num_addrs
+#define icmp_wpa icmp_hun.ih_rtradv.irt_wpa
+#define icmp_lifetime icmp_hun.ih_rtradv.irt_lifetime
+#define icmp_otime icmp_dun.id_ts.its_otime
+#define icmp_rtime icmp_dun.id_ts.its_rtime
+#define icmp_ttime icmp_dun.id_ts.its_ttime
+#define icmp_ip icmp_dun.id_ip.idi_ip
+#define icmp_radv icmp_dun.id_radv
+#define icmp_mask icmp_dun.id_mask
+#define icmp_data icmp_dun.id_data
+
+#define ICMP_MINLEN 8
+#define ICMP_TSLEN (8 + 3 * sizeof (n_time))
+#define ICMP_MASKLEN 12
+#define ICMP_ADVLENMIN (8 + sizeof (struct ip) + 8)
+#define ICMP_ADVLEN(p) (8 + ((p)->icmp_ip.ip_hl << 2) + 8)
+
+#define ICMP_UNREACH 3
+#define ICMP_SOURCEQUENCH 4
+#define ICMP_ROUTERADVERT 9
+#define ICMP_ROUTERSOLICIT 10
+#define ICMP_TIMXCEED 11
+#define ICMP_PARAMPROB 12
+#define ICMP_TSTAMP 13
+#define ICMP_TSTAMPREPLY 14
+#define ICMP_IREQ 15
+#define ICMP_IREQREPLY 16
+#define ICMP_MASKREQ 17
+#define ICMP_MASKREPLY 18
+#define ICMP_MAXTYPE 18
+
+#define ICMP_UNREACH_NET 0
+#define ICMP_UNREACH_HOST 1
+#define ICMP_UNREACH_PROTOCOL 2
+#define ICMP_UNREACH_PORT 3
+#define ICMP_UNREACH_NEEDFRAG 4
+#define ICMP_UNREACH_SRCFAIL 5
+#define ICMP_UNREACH_NET_UNKNOWN 6
+#define ICMP_UNREACH_HOST_UNKNOWN 7
+#define ICMP_UNREACH_ISOLATED 8
+#define ICMP_UNREACH_NET_PROHIB 9
+#define ICMP_UNREACH_HOST_PROHIB 10
+#define ICMP_UNREACH_TOSNET 11
+#define ICMP_UNREACH_TOSHOST 12
+#define ICMP_UNREACH_FILTER_PROHIB 13
+#define ICMP_UNREACH_HOST_PRECEDENCE 14
+#define ICMP_UNREACH_PRECEDENCE_CUTOFF 15
+
+#define ICMP_REDIRECT_NET 0
+#define ICMP_REDIRECT_HOST 1
+#define ICMP_REDIRECT_TOSNET 2
+#define ICMP_REDIRECT_TOSHOST 3
+
+#define ICMP_TIMXCEED_INTRANS 0
+#define ICMP_TIMXCEED_REASS 1
+
+#define ICMP_PARAMPROB_OPTABSENT 1
+
+#define ICMP_INFOTYPE(type) \
+ ((type) == ICMP_ECHOREPLY || (type) == ICMP_ECHO || \
+ (type) == ICMP_ROUTERADVERT || (type) == ICMP_ROUTERSOLICIT || \
+ (type) == ICMP_TSTAMP || (type) == ICMP_TSTAMPREPLY || \
+ (type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || \
+ (type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/netinet/tcp.h b/system/include/libc/netinet/tcp.h
new file mode 100644
index 00000000..b7828a50
--- /dev/null
+++ b/system/include/libc/netinet/tcp.h
@@ -0,0 +1,36 @@
+#ifndef _NETINET_TCP_H
+#define _NETINET_TCP_H
+
+#include <features.h>
+
+#define TCP_NODELAY 1
+#define TCP_MAXSEG 2
+#define TCP_CORK 3
+#define TCP_KEEPIDLE 4
+#define TCP_KEEPINTVL 5
+#define TCP_KEEPCNT 6
+#define TCP_SYNCNT 7
+#define TCP_LINGER2 8
+#define TCP_DEFER_ACCEPT 9
+#define TCP_WINDOW_CLAMP 10
+#define TCP_INFO 11
+#define TCP_QUICKACK 12
+#define TCP_CONGESTION 13
+#define TCP_MD5SIG 14
+#define TCP_THIN_LINEAR_TIMEOUTS 16
+#define TCP_THIN_DUPACK 17
+#define TCP_USER_TIMEOUT 18
+#define TCP_REPAIR 19
+#define TCP_REPAIR_QUEUE 20
+#define TCP_QUEUE_SEQ 21
+#define TCP_REPAIR_OPTIONS 22
+#define TCP_FASTOPEN 23
+#define TCP_TIMESTAMP 24
+
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+#define SOL_TCP 6
+#include <sys/types.h>
+#include <sys/socket.h>
+#endif
+
+#endif
diff --git a/system/include/libc/netinet/udp.h b/system/include/libc/netinet/udp.h
new file mode 100644
index 00000000..15b91454
--- /dev/null
+++ b/system/include/libc/netinet/udp.h
@@ -0,0 +1,35 @@
+#ifndef _NETINET_UDP_H
+#define _NETINET_UDP_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+
+struct udphdr {
+ uint16_t source;
+ uint16_t dest;
+ uint16_t len;
+ uint16_t check;
+};
+
+#define uh_sport source
+#define uh_dport dest
+#define uh_ulen len
+#define uh_sum check
+
+#define UDP_CORK 1
+#define UDP_ENCAP 100
+
+#define UDP_ENCAP_ESPINUDP_NON_IKE 1
+#define UDP_ENCAP_ESPINUDP 2
+#define UDP_ENCAP_L2TPINUDP 3
+
+#define SOL_UDP 17
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/netpacket/packet.h b/system/include/libc/netpacket/packet.h
new file mode 100644
index 00000000..fa53712f
--- /dev/null
+++ b/system/include/libc/netpacket/packet.h
@@ -0,0 +1,44 @@
+#ifndef _NETPACKET_PACKET_H
+#define _NETPACKET_PACKET_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct sockaddr_ll {
+ unsigned short sll_family, sll_protocol;
+ int sll_ifindex;
+ unsigned short sll_hatype;
+ unsigned char sll_pkttype, sll_halen;
+ unsigned char sll_addr[8];
+};
+
+struct packet_mreq {
+ int mr_ifindex;
+ unsigned short int mr_type, mr_alen;
+ unsigned char mr_address[8];
+};
+
+#define PACKET_HOST 0
+#define PACKET_BROADCAST 1
+#define PACKET_MULTICAST 2
+#define PACKET_OTHERHOST 3
+#define PACKET_OUTGOING 4
+#define PACKET_LOOPBACK 5
+#define PACKET_FASTROUTE 6
+
+#define PACKET_ADD_MEMBERSHIP 1
+#define PACKET_DROP_MEMBERSHIP 2
+#define PACKET_RECV_OUTPUT 3
+#define PACKET_RX_RING 5
+#define PACKET_STATISTICS 6
+
+#define PACKET_MR_MULTICAST 0
+#define PACKET_MR_PROMISC 1
+#define PACKET_MR_ALLMULTI 2
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/newlib.h b/system/include/libc/newlib.h
deleted file mode 100644
index d4fffb16..00000000
--- a/system/include/libc/newlib.h
+++ /dev/null
@@ -1,2 +0,0 @@
-/* dummy file for external tools to use. Real file is created by
- newlib configuration. */
diff --git a/system/include/libc/nl_types.h b/system/include/libc/nl_types.h
new file mode 100644
index 00000000..7c2d48e0
--- /dev/null
+++ b/system/include/libc/nl_types.h
@@ -0,0 +1,22 @@
+#ifndef _NL_TYPES_H
+#define _NL_TYPES_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define NL_SETD 1
+#define NL_CAT_LOCALE 1
+
+typedef int nl_item;
+typedef void *nl_catd;
+
+nl_catd catopen (const char *, int);
+char *catgets (nl_catd, int, int, const char *);
+int catclose (nl_catd);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/paths.h b/system/include/libc/paths.h
index 36cf78a9..22848704 100644
--- a/system/include/libc/paths.h
+++ b/system/include/libc/paths.h
@@ -1,7 +1,32 @@
-#ifndef _PATHS_H_
-#define _PATHS_H_
+#ifndef _PATHS_H
+#define _PATHS_H
-#define _PATH_DEV "/dev/"
-#define _PATH_BSHELL "/bin/sh"
+#define _PATH_DEFPATH "/usr/local/bin:/bin:/usr/bin"
+#define _PATH_STDPATH "/bin:/usr/bin:/sbin:/usr/sbin"
-#endif /* _PATHS_H_ */
+#define _PATH_BSHELL "/bin/sh"
+#define _PATH_CONSOLE "/dev/console"
+#define _PATH_DEVNULL "/dev/null"
+#define _PATH_KLOG "/proc/kmsg"
+#define _PATH_LASTLOG "/var/log/lastlog"
+#define _PATH_MAILDIR "/var/mail"
+#define _PATH_MAN "/usr/share/man"
+#define _PATH_MNTTAB "/etc/fstab"
+#define _PATH_MOUNTED "/etc/mtab"
+#define _PATH_NOLOGIN "/etc/nologin"
+#define _PATH_SENDMAIL "/usr/sbin/sendmail"
+#define _PATH_SHADOW "/etc/shadow"
+#define _PATH_SHELLS "/etc/shells"
+#define _PATH_TTY "/dev/tty"
+#define _PATH_UTMP "/dev/null/utmp"
+#define _PATH_VI "/usr/bin/vi"
+#define _PATH_WTMP "/dev/null/wtmp"
+#define _PATH_LASTLOG "/var/log/lastlog"
+
+#define _PATH_DEV "/dev/"
+#define _PATH_TMP "/tmp/"
+#define _PATH_VARDB "/var/lib/misc/"
+#define _PATH_VARRUN "/var/run/"
+#define _PATH_VARTMP "/var/tmp/"
+
+#endif
diff --git a/system/include/libc/poll.h b/system/include/libc/poll.h
new file mode 100644
index 00000000..9a785307
--- /dev/null
+++ b/system/include/libc/poll.h
@@ -0,0 +1,46 @@
+#ifndef _POLL_H
+#define _POLL_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <features.h>
+
+#define POLLIN 0x001
+#define POLLPRI 0x002
+#define POLLOUT 0x004
+#define POLLERR 0x008
+#define POLLHUP 0x010
+#define POLLNVAL 0x020
+#define POLLRDNORM 0x040
+#define POLLRDBAND 0x080
+#define POLLWRNORM 0x100
+#define POLLWRBAND 0x200
+#define POLLMSG 0x400
+#define POLLRDHUP 0x2000
+
+typedef unsigned long nfds_t;
+
+struct pollfd
+{
+ int fd;
+ short events;
+ short revents;
+};
+
+int poll (struct pollfd *, nfds_t, int);
+
+#ifdef _GNU_SOURCE
+#define __NEED_time_t
+#define __NEED_struct_timespec
+#define __NEED_sigset_t
+#include <bits/alltypes.h>
+int ppoll(struct pollfd *, nfds_t, const struct timespec *, const sigset_t *);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/process.h b/system/include/libc/process.h
deleted file mode 100644
index a73564a3..00000000
--- a/system/include/libc/process.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/* process.h. This file comes with MSDOS and WIN32 systems. */
-
-#ifndef __PROCESS_H_
-#define __PROCESS_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-int execl(const char *path, const char *argv0, ...);
-int execle(const char *path, const char *argv0, ... /*, char * const *envp */);
-int execlp(const char *path, const char *argv0, ...);
-int execlpe(const char *path, const char *argv0, ... /*, char * const *envp */);
-
-int execv(const char *path, char * const *argv);
-int execve(const char *path, char * const *argv, char * const *envp);
-int execvp(const char *path, char * const *argv);
-int execvpe(const char *path, char * const *argv, char * const *envp);
-
-int spawnl(int mode, const char *path, const char *argv0, ...);
-int spawnle(int mode, const char *path, const char *argv0, ... /*, char * const *envp */);
-int spawnlp(int mode, const char *path, const char *argv0, ...);
-int spawnlpe(int mode, const char *path, const char *argv0, ... /*, char * const *envp */);
-
-int spawnv(int mode, const char *path, const char * const *argv);
-int spawnve(int mode, const char *path, const char * const *argv, const char * const *envp);
-int spawnvp(int mode, const char *path, const char * const *argv);
-int spawnvpe(int mode, const char *path, const char * const *argv, const char * const *envp);
-
-int cwait(int *, int, int);
-
-#define _P_WAIT 1
-#define _P_NOWAIT 2 /* always generates error */
-#define _P_OVERLAY 3
-#define _P_NOWAITO 4
-#define _P_DETACH 5
-
-#define WAIT_CHILD 1
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/system/include/libc/pthread.h b/system/include/libc/pthread.h
index ae9f2c88..731bce38 100644
--- a/system/include/libc/pthread.h
+++ b/system/include/libc/pthread.h
@@ -1,362 +1,219 @@
-/* pthread.h
- *
- * Written by Joel Sherrill <joel@OARcorp.com>.
- *
- * COPYRIGHT (c) 1989-2010.
- * On-Line Applications Research Corporation (OAR).
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose without fee is hereby granted, provided that this entire notice
- * is included in all copies of any software which is or includes a copy
- * or modification of this software.
- *
- * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
- * WARRANTY. IN PARTICULAR, THE AUTHOR MAKES NO REPRESENTATION
- * OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY OF THIS
- * SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
- *
- * $Id: pthread.h,v 1.9 2010/12/08 14:44:06 corinna Exp $
- */
-
-#ifndef __PTHREAD_h
-#define __PTHREAD_h
-
+#ifndef _PTHREAD_H
+#define _PTHREAD_H
#ifdef __cplusplus
extern "C" {
#endif
-#include <unistd.h>
-
-#if defined(_POSIX_THREADS)
-
-#include <sys/types.h>
+#include <features.h>
+
+#define __NEED_time_t
+#define __NEED_clockid_t
+#define __NEED_struct_timespec
+#define __NEED_sigset_t
+#define __NEED_pthread_t
+#define __NEED_pthread_attr_t
+#define __NEED_pthread_mutexattr_t
+#define __NEED_pthread_condattr_t
+#define __NEED_pthread_rwlockattr_t
+#define __NEED_pthread_barrierattr_t
+#define __NEED_pthread_mutex_t
+#define __NEED_pthread_cond_t
+#define __NEED_pthread_rwlock_t
+#define __NEED_pthread_barrier_t
+#define __NEED_pthread_spinlock_t
+#define __NEED_pthread_key_t
+#define __NEED_pthread_once_t
+#define __NEED_size_t
+
+#include <bits/alltypes.h>
+
+#include <sched.h>
#include <time.h>
-#include <sched.h> /* XXX Emscripten: removed sys/ */
-
-/* Register Fork Handlers */
-int _EXFUN(pthread_atfork,(void (*prepare)(void), void (*parent)(void),
- void (*child)(void)));
-
-/* Mutex Initialization Attributes, P1003.1c/Draft 10, p. 81 */
-
-int _EXFUN(pthread_mutexattr_init, (pthread_mutexattr_t *__attr));
-int _EXFUN(pthread_mutexattr_destroy, (pthread_mutexattr_t *__attr));
-int _EXFUN(pthread_mutexattr_getpshared,
- (_CONST pthread_mutexattr_t *__attr, int *__pshared));
-int _EXFUN(pthread_mutexattr_setpshared,
- (pthread_mutexattr_t *__attr, int __pshared));
-
-#if defined(_UNIX98_THREAD_MUTEX_ATTRIBUTES)
-
-/* Single UNIX Specification 2 Mutex Attributes types */
-
-int _EXFUN(pthread_mutexattr_gettype,
- (_CONST pthread_mutexattr_t *__attr, int *__kind));
-int _EXFUN(pthread_mutexattr_settype,
- (pthread_mutexattr_t *__attr, int __kind));
-
-#endif
-
-/* Initializing and Destroying a Mutex, P1003.1c/Draft 10, p. 87 */
-
-int _EXFUN(pthread_mutex_init,
- (pthread_mutex_t *__mutex, _CONST pthread_mutexattr_t *__attr));
-int _EXFUN(pthread_mutex_destroy, (pthread_mutex_t *__mutex));
-
-/* This is used to statically initialize a pthread_mutex_t. Example:
-
- pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
- */
-
-#define PTHREAD_MUTEX_INITIALIZER ((pthread_mutex_t) 0xFFFFFFFF)
-
-/* Locking and Unlocking a Mutex, P1003.1c/Draft 10, p. 93
- NOTE: P1003.4b/D8 adds pthread_mutex_timedlock(), p. 29 */
-
-int _EXFUN(pthread_mutex_lock, (pthread_mutex_t *__mutex));
-int _EXFUN(pthread_mutex_trylock, (pthread_mutex_t *__mutex));
-int _EXFUN(pthread_mutex_unlock, (pthread_mutex_t *__mutex));
-
-#if defined(_POSIX_TIMEOUTS)
-
-int _EXFUN(pthread_mutex_timedlock,
- (pthread_mutex_t *__mutex, _CONST struct timespec *__timeout));
-
-#endif /* _POSIX_TIMEOUTS */
-
-/* Condition Variable Initialization Attributes, P1003.1c/Draft 10, p. 96 */
-
-int _EXFUN(pthread_condattr_init, (pthread_condattr_t *__attr));
-int _EXFUN(pthread_condattr_destroy, (pthread_condattr_t *__attr));
-int _EXFUN(pthread_condattr_getpshared,
- (_CONST pthread_condattr_t *__attr, int *__pshared));
-int _EXFUN(pthread_condattr_setpshared,
- (pthread_condattr_t *__attr, int __pshared));
-
-/* Initializing and Destroying a Condition Variable, P1003.1c/Draft 10, p. 87 */
-
-int _EXFUN(pthread_cond_init,
- (pthread_cond_t *__cond, _CONST pthread_condattr_t *__attr));
-int _EXFUN(pthread_cond_destroy, (pthread_cond_t *__mutex));
-
-/* This is used to statically initialize a pthread_cond_t. Example:
-
- pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
- */
-
-#define PTHREAD_COND_INITIALIZER ((pthread_mutex_t) 0xFFFFFFFF)
-
-/* Broadcasting and Signaling a Condition, P1003.1c/Draft 10, p. 101 */
-
-int _EXFUN(pthread_cond_signal, (pthread_cond_t *__cond));
-int _EXFUN(pthread_cond_broadcast, (pthread_cond_t *__cond));
-
-/* Waiting on a Condition, P1003.1c/Draft 10, p. 105 */
-
-int _EXFUN(pthread_cond_wait,
- (pthread_cond_t *__cond, pthread_mutex_t *__mutex));
-
-int _EXFUN(pthread_cond_timedwait,
- (pthread_cond_t *__cond, pthread_mutex_t *__mutex,
- _CONST struct timespec *__abstime));
-
-#if defined(_POSIX_THREAD_PRIORITY_SCHEDULING)
-
-/* Thread Creation Scheduling Attributes, P1003.1c/Draft 10, p. 120 */
-
-int _EXFUN(pthread_attr_setscope,
- (pthread_attr_t *__attr, int __contentionscope));
-int _EXFUN(pthread_attr_getscope,
- (_CONST pthread_attr_t *__attr, int *__contentionscope));
-int _EXFUN(pthread_attr_setinheritsched,
- (pthread_attr_t *__attr, int __inheritsched));
-int _EXFUN(pthread_attr_getinheritsched,
- (_CONST pthread_attr_t *__attr, int *__inheritsched));
-int _EXFUN(pthread_attr_setschedpolicy,
- (pthread_attr_t *__attr, int __policy));
-int _EXFUN(pthread_attr_getschedpolicy,
- (_CONST pthread_attr_t *__attr, int *__policy));
-
-#endif /* defined(_POSIX_THREAD_PRIORITY_SCHEDULING) */
-
-int _EXFUN(pthread_attr_setschedparam,
- (pthread_attr_t *__attr, _CONST struct sched_param *__param));
-int _EXFUN(pthread_attr_getschedparam,
- (_CONST pthread_attr_t *__attr, struct sched_param *__param));
-
-#if defined(_POSIX_THREAD_PRIORITY_SCHEDULING)
-
-/* Dynamic Thread Scheduling Parameters Access, P1003.1c/Draft 10, p. 124 */
-
-int _EXFUN(pthread_getschedparam,
- (pthread_t __pthread, int *__policy, struct sched_param *__param));
-int _EXFUN(pthread_setschedparam,
- (pthread_t __pthread, int __policy, struct sched_param *__param));
-
-#endif /* defined(_POSIX_THREAD_PRIORITY_SCHEDULING) */
-
-#if defined(_POSIX_THREAD_PRIO_INHERIT) || defined(_POSIX_THREAD_PRIO_PROTECT)
-
-/* Mutex Initialization Scheduling Attributes, P1003.1c/Draft 10, p. 128 */
-
-int _EXFUN(pthread_mutexattr_setprotocol,
- (pthread_mutexattr_t *__attr, int __protocol));
-int _EXFUN(pthread_mutexattr_getprotocol,
- (_CONST pthread_mutexattr_t *__attr, int *__protocol));
-int _EXFUN(pthread_mutexattr_setprioceiling,
- (pthread_mutexattr_t *__attr, int __prioceiling));
-int _EXFUN(pthread_mutexattr_getprioceiling,
- (_CONST pthread_mutexattr_t *__attr, int *__prioceiling));
-
-#endif /* _POSIX_THREAD_PRIO_INHERIT || _POSIX_THREAD_PRIO_PROTECT */
-
-#if defined(_POSIX_THREAD_PRIO_PROTECT)
-
-/* Change the Priority Ceiling of a Mutex, P1003.1c/Draft 10, p. 131 */
-
-int _EXFUN(pthread_mutex_setprioceiling,
- (pthread_mutex_t *__mutex, int __prioceiling, int *__old_ceiling));
-int _EXFUN(pthread_mutex_getprioceiling,
- (pthread_mutex_t *__mutex, int *__prioceiling));
-
-#endif /* _POSIX_THREAD_PRIO_PROTECT */
-
-/* Thread Creation Attributes, P1003.1c/Draft 10, p, 140 */
-
-int _EXFUN(pthread_attr_init, (pthread_attr_t *__attr));
-int _EXFUN(pthread_attr_destroy, (pthread_attr_t *__attr));
-int _EXFUN(pthread_attr_setstack, (pthread_attr_t *attr,
- void *__stackaddr, size_t __stacksize));
-int _EXFUN(pthread_attr_getstack, (_CONST pthread_attr_t *attr,
- void **__stackaddr, size_t *__stacksize));
-int _EXFUN(pthread_attr_getstacksize,
- (_CONST pthread_attr_t *__attr, size_t *__stacksize));
-int _EXFUN(pthread_attr_setstacksize,
- (pthread_attr_t *__attr, size_t __stacksize));
-int _EXFUN(pthread_attr_getstackaddr,
- (_CONST pthread_attr_t *__attr, void **__stackaddr));
-int _EXFUN(pthread_attr_setstackaddr,
- (pthread_attr_t *__attr, void *__stackaddr));
-int _EXFUN(pthread_attr_getdetachstate,
- (_CONST pthread_attr_t *__attr, int *__detachstate));
-int _EXFUN(pthread_attr_setdetachstate,
- (pthread_attr_t *__attr, int __detachstate));
-int _EXFUN(pthread_attr_getguardsize,
- (_CONST pthread_attr_t *__attr, size_t *__guardsize));
-int _EXFUN(pthread_attr_setguardsize,
- (pthread_attr_t *__attr, size_t __guardsize));
-
-/* Thread Creation, P1003.1c/Draft 10, p. 144 */
-
-int _EXFUN(pthread_create,
- (pthread_t *__pthread, _CONST pthread_attr_t *__attr,
- void *(*__start_routine)( void * ), void *__arg));
-
-/* Wait for Thread Termination, P1003.1c/Draft 10, p. 147 */
-
-int _EXFUN(pthread_join, (pthread_t __pthread, void **__value_ptr));
-
-/* Detaching a Thread, P1003.1c/Draft 10, p. 149 */
-
-int _EXFUN(pthread_detach, (pthread_t __pthread));
-
-/* Thread Termination, p1003.1c/Draft 10, p. 150 */
-
-void _EXFUN(pthread_exit, (void *__value_ptr));
-
-/* Get Calling Thread's ID, p1003.1c/Draft 10, p. XXX */
-
-pthread_t _EXFUN(pthread_self, (void));
-/* Compare Thread IDs, p1003.1c/Draft 10, p. 153 */
+#define PTHREAD_CREATE_JOINABLE 0
+#define PTHREAD_CREATE_DETACHED 1
-int _EXFUN(pthread_equal, (pthread_t __t1, pthread_t __t2));
+#define PTHREAD_MUTEX_NORMAL 0
+#define PTHREAD_MUTEX_DEFAULT 0
+#define PTHREAD_MUTEX_RECURSIVE 1
+#define PTHREAD_MUTEX_ERRORCHECK 2
-/* Dynamic Package Initialization */
+#define PTHREAD_MUTEX_STALLED 0
+#define PTHREAD_MUTEX_ROBUST 1
-/* This is used to statically initialize a pthread_once_t. Example:
-
- pthread_once_t once = PTHREAD_ONCE_INIT;
-
- NOTE: This is named inconsistently -- it should be INITIALIZER. */
-
-#define PTHREAD_ONCE_INIT { 1, 0 } /* is initialized and not run */
-
-int _EXFUN(pthread_once,
- (pthread_once_t *__once_control, void (*__init_routine)(void)));
+#define PTHREAD_PRIO_NONE 0
+#define PTHREAD_PRIO_INHERIT 1
+#define PTHREAD_PRIO_PROTECT 2
-/* Thread-Specific Data Key Create, P1003.1c/Draft 10, p. 163 */
+#define PTHREAD_INHERIT_SCHED 0
+#define PTHREAD_EXPLICIT_SCHED 1
-int _EXFUN(pthread_key_create,
- (pthread_key_t *__key, void (*__destructor)( void * )));
+#define PTHREAD_SCOPE_SYSTEM 0
+#define PTHREAD_SCOPE_PROCESS 1
-/* Thread-Specific Data Management, P1003.1c/Draft 10, p. 165 */
+#define PTHREAD_PROCESS_PRIVATE 0
+#define PTHREAD_PROCESS_SHARED 1
-int _EXFUN(pthread_setspecific,
- (pthread_key_t __key, _CONST void *__value));
-void * _EXFUN(pthread_getspecific, (pthread_key_t __key));
-/* Thread-Specific Data Key Deletion, P1003.1c/Draft 10, p. 167 */
+#define PTHREAD_MUTEX_INITIALIZER {{{0}}}
+#define PTHREAD_RWLOCK_INITIALIZER {{{0}}}
+#define PTHREAD_COND_INITIALIZER {{{0}}}
+#define PTHREAD_ONCE_INIT 0
-int _EXFUN(pthread_key_delete, (pthread_key_t __key));
-/* Execution of a Thread, P1003.1c/Draft 10, p. 181 */
-
-#define PTHREAD_CANCEL_ENABLE 0
+#define PTHREAD_CANCEL_ENABLE 0
#define PTHREAD_CANCEL_DISABLE 1
#define PTHREAD_CANCEL_DEFERRED 0
#define PTHREAD_CANCEL_ASYNCHRONOUS 1
-#define PTHREAD_CANCELED ((void *) -1)
-
-int _EXFUN(pthread_cancel, (pthread_t __pthread));
-
-/* Setting Cancelability State, P1003.1c/Draft 10, p. 183 */
-
-int _EXFUN(pthread_setcancelstate, (int __state, int *__oldstate));
-int _EXFUN(pthread_setcanceltype, (int __type, int *__oldtype));
-void _EXFUN(pthread_testcancel, (void));
-
-/* Establishing Cancellation Handlers, P1003.1c/Draft 10, p. 184 */
-
-void _EXFUN(pthread_cleanup_push,
- (void (*__routine)( void * ), void *__arg));
-void _EXFUN(pthread_cleanup_pop, (int __execute));
-
-#if defined(_POSIX_THREAD_CPUTIME)
-
-/* Accessing a Thread CPU-time Clock, P1003.4b/D8, p. 58 */
-
-int _EXFUN(pthread_getcpuclockid,
- (pthread_t __pthread_id, clockid_t *__clock_id));
-
-#endif /* defined(_POSIX_THREAD_CPUTIME) */
-
-
-#endif /* defined(_POSIX_THREADS) */
-
-#if defined(_POSIX_BARRIERS)
-
-int _EXFUN(pthread_barrierattr_init, (pthread_barrierattr_t *__attr));
-int _EXFUN(pthread_barrierattr_destroy, (pthread_barrierattr_t *__attr));
-int _EXFUN(pthread_barrierattr_getpshared,
- (_CONST pthread_barrierattr_t *__attr, int *__pshared));
-int _EXFUN(pthread_barrierattr_setpshared,
- (pthread_barrierattr_t *__attr, int __pshared));
+#define PTHREAD_CANCELED ((void *)-1)
-#define PTHREAD_BARRIER_SERIAL_THREAD -1
-int _EXFUN(pthread_barrier_init,
- (pthread_barrier_t *__barrier,
- _CONST pthread_barrierattr_t *__attr, unsigned __count));
-int _EXFUN(pthread_barrier_destroy, (pthread_barrier_t *__barrier));
-int _EXFUN(pthread_barrier_wait,(pthread_barrier_t *__barrier));
+#define PTHREAD_BARRIER_SERIAL_THREAD (-1)
-#endif /* defined(_POSIX_BARRIERS) */
-#if defined(_POSIX_SPIN_LOCKS)
-
-int _EXFUN(pthread_spin_init,
- (pthread_spinlock_t *__spinlock, int __pshared));
-int _EXFUN(pthread_spin_destroy, (pthread_spinlock_t *__spinlock));
-int _EXFUN(pthread_spin_lock, (pthread_spinlock_t *__spinlock));
-int _EXFUN(pthread_spin_trylock, (pthread_spinlock_t *__spinlock));
-int _EXFUN(pthread_spin_unlock, (pthread_spinlock_t *__spinlock));
-
-#endif /* defined(_POSIX_SPIN_LOCKS) */
-
-#if defined(_POSIX_READER_WRITER_LOCKS)
-
-int _EXFUN(pthread_rwlockattr_init, (pthread_rwlockattr_t *__attr));
-int _EXFUN(pthread_rwlockattr_destroy, (pthread_rwlockattr_t *__attr));
-int _EXFUN(pthread_rwlockattr_getpshared,
- (_CONST pthread_rwlockattr_t *__attr, int *__pshared));
-int _EXFUN(pthread_rwlockattr_setpshared,
- (pthread_rwlockattr_t *__attr, int __pshared));
-
-int _EXFUN(pthread_rwlock_init,
- (pthread_rwlock_t *__rwlock, _CONST pthread_rwlockattr_t *__attr));
-int _EXFUN(pthread_rwlock_destroy, (pthread_rwlock_t *__rwlock));
-int _EXFUN(pthread_rwlock_rdlock,(pthread_rwlock_t *__rwlock));
-int _EXFUN(pthread_rwlock_tryrdlock,(pthread_rwlock_t *__rwlock));
-int _EXFUN(pthread_rwlock_timedrdlock,
- (pthread_rwlock_t *__rwlock, _CONST struct timespec *__abstime));
-int _EXFUN(pthread_rwlock_unlock,(pthread_rwlock_t *__rwlock));
-int _EXFUN(pthread_rwlock_wrlock,(pthread_rwlock_t *__rwlock));
-int _EXFUN(pthread_rwlock_trywrlock,(pthread_rwlock_t *__rwlock));
-int _EXFUN(pthread_rwlock_timedwrlock,
- (pthread_rwlock_t *__rwlock, _CONST struct timespec *__abstime));
-
-#endif /* defined(_POSIX_READER_WRITER_LOCKS) */
-
-/* XXX Emscripten */
-int _EXFUN(pthread_getattr_np,(pthread_t __th, pthread_attr_t *__attr));
+int pthread_create(pthread_t *__restrict, const pthread_attr_t *__restrict, void *(*)(void *), void *__restrict);
+int pthread_detach(pthread_t);
+_Noreturn void pthread_exit(void *);
+int pthread_join(pthread_t, void **);
+#ifdef __GNUC__
+__attribute__((const))
+#endif
+pthread_t pthread_self(void);
+
+int pthread_equal(pthread_t, pthread_t);
+#define pthread_equal(x,y) ((x)==(y))
+
+int pthread_setcancelstate(int, int *);
+int pthread_setcanceltype(int, int *);
+void pthread_testcancel(void);
+int pthread_cancel(pthread_t);
+
+int pthread_getschedparam(pthread_t, int *__restrict, struct sched_param *__restrict);
+int pthread_setschedparam(pthread_t, int, const struct sched_param *);
+int pthread_setschedprio(pthread_t, int);
+
+int pthread_once(pthread_once_t *, void (*)(void));
+
+int pthread_mutex_init(pthread_mutex_t *__restrict, const pthread_mutexattr_t *__restrict);
+int pthread_mutex_lock(pthread_mutex_t *);
+int pthread_mutex_unlock(pthread_mutex_t *);
+int pthread_mutex_trylock(pthread_mutex_t *);
+int pthread_mutex_timedlock(pthread_mutex_t *__restrict, const struct timespec *__restrict);
+int pthread_mutex_destroy(pthread_mutex_t *);
+int pthread_mutex_consistent(pthread_mutex_t *);
+
+int pthread_mutex_getprioceiling(const pthread_mutex_t *__restrict, int *__restrict);
+int pthread_mutex_setprioceiling(pthread_mutex_t *__restrict, int, int *__restrict);
+
+int pthread_cond_init(pthread_cond_t *__restrict, const pthread_condattr_t *__restrict);
+int pthread_cond_destroy(pthread_cond_t *);
+int pthread_cond_wait(pthread_cond_t *__restrict, pthread_mutex_t *__restrict);
+int pthread_cond_timedwait(pthread_cond_t *__restrict, pthread_mutex_t *__restrict, const struct timespec *__restrict);
+int pthread_cond_broadcast(pthread_cond_t *);
+int pthread_cond_signal(pthread_cond_t *);
+
+int pthread_rwlock_init(pthread_rwlock_t *__restrict, const pthread_rwlockattr_t *__restrict);
+int pthread_rwlock_destroy(pthread_rwlock_t *);
+int pthread_rwlock_rdlock(pthread_rwlock_t *);
+int pthread_rwlock_tryrdlock(pthread_rwlock_t *);
+int pthread_rwlock_timedrdlock(pthread_rwlock_t *__restrict, const struct timespec *__restrict);
+int pthread_rwlock_wrlock(pthread_rwlock_t *);
+int pthread_rwlock_trywrlock(pthread_rwlock_t *);
+int pthread_rwlock_timedwrlock(pthread_rwlock_t *__restrict, const struct timespec *__restrict);
+int pthread_rwlock_unlock(pthread_rwlock_t *);
+
+int pthread_spin_init(pthread_spinlock_t *, int);
+int pthread_spin_destroy(pthread_spinlock_t *);
+int pthread_spin_lock(pthread_spinlock_t *);
+int pthread_spin_trylock(pthread_spinlock_t *);
+int pthread_spin_unlock(pthread_spinlock_t *);
+
+int pthread_barrier_init(pthread_barrier_t *__restrict, const pthread_barrierattr_t *__restrict, unsigned);
+int pthread_barrier_destroy(pthread_barrier_t *);
+int pthread_barrier_wait(pthread_barrier_t *);
+
+int pthread_key_create(pthread_key_t *, void (*)(void *));
+int pthread_key_delete(pthread_key_t);
+void *pthread_getspecific(pthread_key_t);
+int pthread_setspecific(pthread_key_t, const void *);
+
+int pthread_attr_init(pthread_attr_t *);
+int pthread_attr_destroy(pthread_attr_t *);
+
+int pthread_attr_getguardsize(const pthread_attr_t *__restrict, size_t *__restrict);
+int pthread_attr_setguardsize(pthread_attr_t *, size_t);
+int pthread_attr_getstacksize(const pthread_attr_t *__restrict, size_t *__restrict);
+int pthread_attr_setstacksize(pthread_attr_t *, size_t);
+int pthread_attr_getdetachstate(const pthread_attr_t *, int *);
+int pthread_attr_setdetachstate(pthread_attr_t *, int);
+int pthread_attr_getstack(const pthread_attr_t *__restrict, void **__restrict, size_t *__restrict);
+int pthread_attr_setstack(pthread_attr_t *, void *, size_t);
+int pthread_attr_getscope(const pthread_attr_t *__restrict, int *__restrict);
+int pthread_attr_setscope(pthread_attr_t *, int);
+int pthread_attr_getschedpolicy(const pthread_attr_t *__restrict, int *__restrict);
+int pthread_attr_setschedpolicy(pthread_attr_t *, int);
+int pthread_attr_getschedparam(const pthread_attr_t *__restrict, struct sched_param *__restrict);
+int pthread_attr_setschedparam(pthread_attr_t *__restrict, const struct sched_param *__restrict);
+int pthread_attr_getinheritsched(const pthread_attr_t *__restrict, int *__restrict);
+int pthread_attr_setinheritsched(pthread_attr_t *, int);
+
+int pthread_mutexattr_destroy(pthread_mutexattr_t *);
+int pthread_mutexattr_getprioceiling(const pthread_mutexattr_t *__restrict, int *__restrict);
+int pthread_mutexattr_getprotocol(const pthread_mutexattr_t *__restrict, int *__restrict);
+int pthread_mutexattr_getpshared(const pthread_mutexattr_t *__restrict, int *__restrict);
+int pthread_mutexattr_getrobust(const pthread_mutexattr_t *__restrict, int *__restrict);
+int pthread_mutexattr_gettype(const pthread_mutexattr_t *__restrict, int *__restrict);
+int pthread_mutexattr_init(pthread_mutexattr_t *);
+int pthread_mutexattr_setprioceiling(pthread_mutexattr_t *, int);
+int pthread_mutexattr_setprotocol(pthread_mutexattr_t *, int);
+int pthread_mutexattr_setpshared(pthread_mutexattr_t *, int);
+int pthread_mutexattr_setrobust(pthread_mutexattr_t *, int);
+int pthread_mutexattr_settype(pthread_mutexattr_t *, int);
+
+int pthread_condattr_init(pthread_condattr_t *);
+int pthread_condattr_destroy(pthread_condattr_t *);
+int pthread_condattr_setclock(pthread_condattr_t *, clockid_t);
+int pthread_condattr_setpshared(pthread_condattr_t *, int);
+int pthread_condattr_getclock(const pthread_condattr_t *__restrict, clockid_t *__restrict);
+int pthread_condattr_getpshared(const pthread_condattr_t *__restrict, int *__restrict);
+
+int pthread_rwlockattr_init(pthread_rwlockattr_t *);
+int pthread_rwlockattr_destroy(pthread_rwlockattr_t *);
+int pthread_rwlockattr_setpshared(pthread_rwlockattr_t *, int);
+int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t *__restrict, int *__restrict);
+
+int pthread_barrierattr_destroy(pthread_barrierattr_t *);
+int pthread_barrierattr_getpshared(const pthread_barrierattr_t *__restrict, int *__restrict);
+int pthread_barrierattr_init(pthread_barrierattr_t *);
+int pthread_barrierattr_setpshared(pthread_barrierattr_t *, int);
+
+int pthread_atfork(void (*)(void), void (*)(void), void (*)(void));
+
+int pthread_getconcurrency(void);
+int pthread_setconcurrency(int);
+
+int pthread_getcpuclockid(pthread_t, clockid_t *);
+
+struct __ptcb {
+ void (*__f)(void *);
+ void *__x;
+ struct __ptcb *__next;
+};
+
+void _pthread_cleanup_push(struct __ptcb *, void (*)(void *), void *);
+void _pthread_cleanup_pop(struct __ptcb *, int);
+
+#define pthread_cleanup_push(f, x) do { struct __ptcb __cb; _pthread_cleanup_push(&__cb, f, x);
+#define pthread_cleanup_pop(r) _pthread_cleanup_pop(&__cb, (r)); } while(0)
+
+#ifdef _GNU_SOURCE
+int pthread_getattr_np(pthread_t, pthread_attr_t *);
+#endif
#ifdef __cplusplus
}
#endif
-
#endif
-/* end of include file */
diff --git a/system/include/libc/pty.h b/system/include/libc/pty.h
new file mode 100644
index 00000000..db638534
--- /dev/null
+++ b/system/include/libc/pty.h
@@ -0,0 +1,18 @@
+#ifndef _PTY_H
+#define _PTY_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <termios.h>
+#include <sys/ioctl.h>
+
+int openpty(int *, int *, char *, const struct termios *, const struct winsize *);
+int forkpty(int *, char *, const struct termios *, const struct winsize *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/pwd.h b/system/include/libc/pwd.h
index 1526abfb..55d9d42d 100644
--- a/system/include/libc/pwd.h
+++ b/system/include/libc/pwd.h
@@ -1,78 +1,49 @@
-/*-
- * Copyright (c) 1989 The Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)pwd.h 5.13 (Berkeley) 5/28/91
- */
+#ifndef _PWD_H
+#define _PWD_H
-#ifndef _PWD_H_
#ifdef __cplusplus
extern "C" {
#endif
-#define _PWD_H_
-#include <sys/types.h>
+#include <features.h>
-#ifndef _POSIX_SOURCE
-#define _PATH_PASSWD "/etc/passwd"
+#define __NEED_size_t
+#define __NEED_uid_t
+#define __NEED_gid_t
-#define _PASSWORD_LEN 128 /* max length, not counting NULL */
+#ifdef _GNU_SOURCE
+#define __NEED_FILE
#endif
-struct passwd {
- char *pw_name; /* user name */
- char *pw_passwd; /* encrypted password */
- uid_t pw_uid; /* user uid */
- gid_t pw_gid; /* user gid */
- char *pw_comment; /* comment */
- char *pw_gecos; /* Honeywell login info */
- char *pw_dir; /* home directory */
- char *pw_shell; /* default shell */
+#include <bits/alltypes.h>
+
+struct passwd
+{
+ char *pw_name;
+ char *pw_passwd;
+ uid_t pw_uid;
+ gid_t pw_gid;
+ char *pw_gecos;
+ char *pw_dir;
+ char *pw_shell;
};
-#ifndef __INSIDE_CYGWIN__
-struct passwd *getpwuid (uid_t);
-struct passwd *getpwnam (const char *);
-int getpwnam_r (const char *, struct passwd *,
- char *, size_t , struct passwd **);
-int getpwuid_r (uid_t, struct passwd *, char *,
- size_t, struct passwd **);
-#ifndef _POSIX_SOURCE
-struct passwd *getpwent (void);
-void setpwent (void);
-void endpwent (void);
-#endif
+void setpwent (void);
+void endpwent (void);
+struct passwd *getpwent (void);
+
+struct passwd *getpwuid (uid_t);
+struct passwd *getpwnam (const char *);
+int getpwuid_r (uid_t, struct passwd *, char *, size_t, struct passwd **);
+int getpwnam_r (const char *, struct passwd *, char *, size_t, struct passwd **);
+
+#ifdef _GNU_SOURCE
+struct passwd *fgetpwent(FILE *);
+int putpwent(const struct passwd *, FILE *);
#endif
#ifdef __cplusplus
}
#endif
-#endif /* _PWD_H_ */
+
+#endif
diff --git a/system/include/libc/readme.txt b/system/include/libc/readme.txt
deleted file mode 100644
index 7c2820f4..00000000
--- a/system/include/libc/readme.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-stddef.h, stdarg.h - from Clang (svn pre-3.0)
-Everything else - from Newlib (1.19)
-
diff --git a/system/include/libc/reent.h b/system/include/libc/reent.h
deleted file mode 100644
index 4617c0d9..00000000
--- a/system/include/libc/reent.h
+++ /dev/null
@@ -1,183 +0,0 @@
-/* This header file provides the reentrancy. */
-
-/* The reentrant system calls here serve two purposes:
-
- 1) Provide reentrant versions of the system calls the ANSI C library
- requires.
- 2) Provide these system calls in a namespace clean way.
-
- It is intended that *all* system calls that the ANSI C library needs
- be declared here. It documents them all in one place. All library access
- to the system is via some form of these functions.
-
- The target may provide the needed syscalls by any of the following:
-
- 1) Define the reentrant versions of the syscalls directly.
- (eg: _open_r, _close_r, etc.). Please keep the namespace clean.
- When you do this, set "syscall_dir" to "syscalls" and add
- -DREENTRANT_SYSCALLS_PROVIDED to newlib_cflags in configure.host.
-
- 2) Define namespace clean versions of the system calls by prefixing
- them with '_' (eg: _open, _close, etc.). Technically, there won't be
- true reentrancy at the syscall level, but the library will be namespace
- clean.
- When you do this, set "syscall_dir" to "syscalls" in configure.host.
-
- 3) Define or otherwise provide the regular versions of the syscalls
- (eg: open, close, etc.). The library won't be reentrant nor namespace
- clean, but at least it will work.
- When you do this, add -DMISSING_SYSCALL_NAMES to newlib_cflags in
- configure.host.
-
- 4) Define or otherwise provide the regular versions of the syscalls,
- and do not supply functional interfaces for any of the reentrant
- calls. With this method, the reentrant syscalls are redefined to
- directly call the regular system call without the reentrancy argument.
- When you do this, specify both -DREENTRANT_SYSCALLS_PROVIDED and
- -DMISSING_SYSCALL_NAMES via newlib_cflags in configure.host and do
- not specify "syscall_dir".
-
- Stubs of the reentrant versions of the syscalls exist in the libc/reent
- source directory and are provided if REENTRANT_SYSCALLS_PROVIDED isn't
- defined. These stubs call the native system calls: _open, _close, etc.
- if MISSING_SYSCALL_NAMES is *not* defined, otherwise they call the
- non-underscored versions: open, close, etc. when MISSING_SYSCALL_NAMES
- *is* defined.
-
- By default, newlib functions call the reentrant syscalls internally,
- passing a reentrancy structure as an argument. This reentrancy structure
- contains data that is thread-specific. For example, the errno value is
- kept in the reentrancy structure. If multiple threads exist, each will
- keep a separate errno value which is intuitive since the application flow
- cannot check for failure reliably otherwise.
-
- The reentrant syscalls are either provided by the platform, by the
- libc/reent stubs, or in the case of both MISSING_SYSCALL_NAMES and
- REENTRANT_SYSCALLS_PROVIDED being defined, the calls are redefined to
- simply call the regular syscalls with no reentrancy struct argument.
-
- A single-threaded application does not need to worry about the reentrancy
- structure. It is used internally.
-
- A multi-threaded application needs either to manually manage reentrancy
- structures or use dynamic reentrancy.
-
- Manually managing reentrancy structures entails calling special reentrant
- versions of newlib functions that have an additional reentrancy argument.
- For example, _printf_r. By convention, the first argument is the
- reentrancy structure. By default, the normal version of the function
- uses the default reentrancy structure: _REENT. The reentrancy structure
- is passed internally, eventually to the reentrant syscalls themselves.
- How the structures are stored and accessed in this model is up to the
- application.
-
- Dynamic reentrancy is specified by the __DYNAMIC_REENT__ flag. This
- flag denotes setting up a macro to replace _REENT with a function call
- to __getreent(). This function needs to be implemented by the platform
- and it is meant to return the reentrancy structure for the current
- thread. When the regular C functions (e.g. printf) go to call internal
- routines with the default _REENT structure, they end up calling with
- the reentrancy structure for the thread. Thus, application code does not
- need to call the _r routines nor worry about reentrancy structures. */
-
-/* WARNING: All identifiers here must begin with an underscore. This file is
- included by stdio.h and others and we therefore must only use identifiers
- in the namespace allotted to us. */
-
-#ifndef _REENT_H_
-#ifdef __cplusplus
-extern "C" {
-#endif
-#define _REENT_H_
-
-#include <sys/reent.h>
-#include <sys/_types.h>
-#include <machine/types.h>
-
-#define __need_size_t
-#define __need_ptrdiff_t
-#include <stddef.h>
-
-/* FIXME: not namespace clean */
-struct stat;
-struct tms;
-struct timeval;
-struct timezone;
-
-#if defined(REENTRANT_SYSCALLS_PROVIDED) && defined(MISSING_SYSCALL_NAMES)
-
-#define _close_r(__reent, __fd) close(__fd)
-#define _execve_r(__reent, __f, __arg, __env) execve(__f, __arg, __env)
-#define _fcntl_r(__reent, __fd, __cmd, __arg) fcntl(__fd, __cmd, __arg)
-#define _fork_r(__reent) fork()
-#define _fstat_r(__reent, __fdes, __stat) fstat(__fdes, __stat)
-#define _getpid_r(__reent) getpid()
-#define _isatty_r(__reent, __desc) isatty(__desc)
-#define _kill_r(__reent, __pid, __signal) kill(__pid, __signal)
-#define _link_r(__reent, __oldpath, __newpath) link(__oldpath, __newpath)
-#define _lseek_r(__reent, __fdes, __off, __w) lseek(__fdes, __off, __w)
-#define _mkdir_r(__reent, __path, __m) mkdir(__path, __m)
-#define _open_r(__reent, __path, __flag, __m) open(__path, __flag, __m)
-#define _read_r(__reent, __fd, __buff, __cnt) read(__fd, __buff, __cnt)
-#define _rename_r(__reent, __old, __new) rename(__old, __new)
-#define _sbrk_r(__reent, __incr) sbrk(__incr)
-#define _stat_r(__reent, __path, __buff) stat(__path, __buff)
-#define _times_r(__reent, __time) times(__time)
-#define _unlink_r(__reent, __path) unlink(__path)
-#define _wait_r(__reent, __status) wait(__status)
-#define _write_r(__reent, __fd, __buff, __cnt) write(__fd, __buff, __cnt)
-#define _gettimeofday_r(__reent, __tp, __tzp) gettimeofday(__tp, __tzp)
-
-#ifdef __LARGE64_FILES
-#define _lseek64_r(__reent, __fd, __off, __w) lseek64(__fd, __off, __w)
-#define _fstat64_r(__reent, __fd, __buff) fstat64(__fd, __buff)
-#define _open64_r(__reent, __path, __flag, __m) open64(__path, __flag, __m)
-#endif
-
-#else
-/* Reentrant versions of system calls. */
-
-extern int _close_r _PARAMS ((struct _reent *, int));
-extern int _execve_r _PARAMS ((struct _reent *, const char *, char *const *, char *const *));
-extern int _fcntl_r _PARAMS ((struct _reent *, int, int, int));
-extern int _fork_r _PARAMS ((struct _reent *));
-extern int _fstat_r _PARAMS ((struct _reent *, int, struct stat *));
-extern int _getpid_r _PARAMS ((struct _reent *));
-extern int _isatty_r _PARAMS ((struct _reent *, int));
-extern int _kill_r _PARAMS ((struct _reent *, int, int));
-extern int _link_r _PARAMS ((struct _reent *, const char *, const char *));
-extern _off_t _lseek_r _PARAMS ((struct _reent *, int, _off_t, int));
-extern int _mkdir_r _PARAMS ((struct _reent *, const char *, int));
-extern int _open_r _PARAMS ((struct _reent *, const char *, int, int));
-extern _ssize_t _read_r _PARAMS ((struct _reent *, int, void *, size_t));
-extern int _rename_r _PARAMS ((struct _reent *, const char *, const char *));
-extern void *_sbrk_r _PARAMS ((struct _reent *, ptrdiff_t));
-extern int _stat_r _PARAMS ((struct _reent *, const char *, struct stat *));
-extern _CLOCK_T_ _times_r _PARAMS ((struct _reent *, struct tms *));
-extern int _unlink_r _PARAMS ((struct _reent *, const char *));
-extern int _wait_r _PARAMS ((struct _reent *, int *));
-extern _ssize_t _write_r _PARAMS ((struct _reent *, int, const void *, size_t));
-
-/* This one is not guaranteed to be available on all targets. */
-extern int _gettimeofday_r _PARAMS ((struct _reent *, struct timeval *__tp, void *__tzp));
-
-#ifdef __LARGE64_FILES
-
-#if defined(__CYGWIN__) && defined(_COMPILING_NEWLIB)
-#define stat64 __stat64
-#endif
-
-struct stat64;
-
-extern _off64_t _lseek64_r _PARAMS ((struct _reent *, int, _off64_t, int));
-extern int _fstat64_r _PARAMS ((struct _reent *, int, struct stat64 *));
-extern int _open64_r _PARAMS ((struct _reent *, const char *, int, int));
-extern int _stat64_r _PARAMS ((struct _reent *, const char *, struct stat64 *));
-#endif
-
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-#endif /* _REENT_H_ */
diff --git a/system/include/libc/regdef.h b/system/include/libc/regdef.h
deleted file mode 100644
index 8cf144b8..00000000
--- a/system/include/libc/regdef.h
+++ /dev/null
@@ -1,7 +0,0 @@
-/* regdef.h -- define register names. */
-
-/* This is a standard include file for MIPS targets. Other target
- probably don't define it, and attempts to include this file will
- fail. */
-
-#include <machine/regdef.h>
diff --git a/system/include/libc/regex.h b/system/include/libc/regex.h
index 2ac78f4c..dce21771 100644
--- a/system/include/libc/regex.h
+++ b/system/include/libc/regex.h
@@ -1,102 +1,62 @@
-/*-
- * Copyright (c) 1992 Henry Spencer.
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Henry Spencer of the University of Toronto.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)regex.h 8.2 (Berkeley) 1/3/94
- * $FreeBSD: src/include/regex.h,v 1.4 2002/03/23 17:24:53 imp Exp $
- */
+#ifndef _REGEX_H
+#define _REGEX_H
-#ifndef _REGEX_H_
-#define _REGEX_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
-#include <sys/cdefs.h>
+#include <features.h>
-/* types */
-typedef off_t regoff_t;
+#define __NEED_regoff_t
+#define __NEED_size_t
-typedef struct {
- int re_magic;
- size_t re_nsub; /* number of parenthesized subexpressions */
- __const char *re_endp; /* end pointer for REG_PEND */
- struct re_guts *re_g; /* none of your business :-) */
+#include <bits/alltypes.h>
+
+typedef struct re_pattern_buffer {
+ size_t re_nsub;
+ void *__opaque, *__padding[4];
+ size_t __nsub2;
+ char __padding2;
} regex_t;
typedef struct {
- regoff_t rm_so; /* start of match */
- regoff_t rm_eo; /* end of match */
+ regoff_t rm_so;
+ regoff_t rm_eo;
} regmatch_t;
-/* regcomp() flags */
-#define REG_BASIC 0000
-#define REG_EXTENDED 0001
-#define REG_ICASE 0002
-#define REG_NOSUB 0004
-#define REG_NEWLINE 0010
-#define REG_NOSPEC 0020
-#define REG_PEND 0040
-#define REG_DUMP 0200
-
-/* regerror() flags */
-#define REG_NOMATCH 1
-#define REG_BADPAT 2
-#define REG_ECOLLATE 3
-#define REG_ECTYPE 4
-#define REG_EESCAPE 5
-#define REG_ESUBREG 6
-#define REG_EBRACK 7
-#define REG_EPAREN 8
-#define REG_EBRACE 9
-#define REG_BADBR 10
-#define REG_ERANGE 11
-#define REG_ESPACE 12
-#define REG_BADRPT 13
-#define REG_EMPTY 14
-#define REG_ASSERT 15
-#define REG_INVARG 16
-#define REG_ATOI 255 /* convert name to number (!) */
-#define REG_ITOA 0400 /* convert number to name (!) */
-
-/* regexec() flags */
-#define REG_NOTBOL 00001
-#define REG_NOTEOL 00002
-#define REG_STARTEND 00004
-#define REG_TRACE 00400 /* tracing of execution */
-#define REG_LARGE 01000 /* force large representation */
-#define REG_BACKR 02000 /* force use of backref code */
-
-__BEGIN_DECLS
-int regcomp(regex_t *, const char *, int);
-size_t regerror(int, const regex_t *, char *, size_t);
-int regexec(const regex_t *, const char *, size_t, regmatch_t [], int);
-void regfree(regex_t *);
-__END_DECLS
-
-#endif /* !_REGEX_H_ */
+#define REG_EXTENDED 1
+#define REG_ICASE 2
+#define REG_NEWLINE 4
+#define REG_NOSUB 8
+
+#define REG_NOTBOL 1
+#define REG_NOTEOL 2
+
+#define REG_OK 0
+#define REG_NOMATCH 1
+#define REG_BADPAT 2
+#define REG_ECOLLATE 3
+#define REG_ECTYPE 4
+#define REG_EESCAPE 5
+#define REG_ESUBREG 6
+#define REG_EBRACK 7
+#define REG_EPAREN 8
+#define REG_EBRACE 9
+#define REG_BADBR 10
+#define REG_ERANGE 11
+#define REG_ESPACE 12
+#define REG_BADRPT 13
+
+#define REG_ENOSYS -1
+
+int regcomp(regex_t *__restrict, const char *__restrict, int);
+int regexec(const regex_t *__restrict, const char *__restrict, size_t, regmatch_t *__restrict, int);
+void regfree(regex_t *);
+
+size_t regerror(int, const regex_t *__restrict, char *__restrict, size_t);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/resolv.h b/system/include/libc/resolv.h
new file mode 100644
index 00000000..cdedd274
--- /dev/null
+++ b/system/include/libc/resolv.h
@@ -0,0 +1,144 @@
+#ifndef _RESOLV_H
+#define _RESOLV_H
+
+#include <stdint.h>
+#include <arpa/nameser.h>
+#include <netinet/in.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define MAXNS 3
+#define MAXDFLSRCH 3
+#define MAXDNSRCH 6
+#define LOCALDOMAINPARTS 2
+
+#define RES_TIMEOUT 5
+#define MAXRESOLVSORT 10
+#define RES_MAXNDOTS 15
+#define RES_MAXRETRANS 30
+#define RES_MAXRETRY 5
+#define RES_DFLRETRY 2
+#define RES_MAXTIME 65535
+
+/* unused; purely for broken apps */
+typedef struct __res_state {
+ int retrans;
+ int retry;
+ unsigned long options;
+ int nscount;
+ struct sockaddr_in nsaddr_list[MAXNS];
+# define nsaddr nsaddr_list[0]
+ unsigned short id;
+ char *dnsrch[MAXDNSRCH+1];
+ char defdname[256];
+ unsigned long pfcode;
+ unsigned ndots:4;
+ unsigned nsort:4;
+ unsigned ipv6_unavail:1;
+ unsigned unused:23;
+ struct {
+ struct in_addr addr;
+ uint32_t mask;
+ } sort_list[MAXRESOLVSORT];
+ void *qhook;
+ void *rhook;
+ int res_h_errno;
+ int _vcsock;
+ unsigned _flags;
+ union {
+ char pad[52];
+ struct {
+ uint16_t nscount;
+ uint16_t nsmap[MAXNS];
+ int nssocks[MAXNS];
+ uint16_t nscount6;
+ uint16_t nsinit;
+ struct sockaddr_in6 *nsaddrs[MAXNS];
+ unsigned int _initstamp[2];
+ } _ext;
+ } _u;
+} *res_state;
+
+#define __RES 19991006
+
+#ifndef _PATH_RESCONF
+#define _PATH_RESCONF "/etc/resolv.conf"
+#endif
+
+struct res_sym {
+ int number;
+ char *name;
+ char *humanname;
+};
+
+#define RES_F_VC 0x00000001
+#define RES_F_CONN 0x00000002
+#define RES_F_EDNS0ERR 0x00000004
+
+#define RES_EXHAUSTIVE 0x00000001
+
+#define RES_INIT 0x00000001
+#define RES_DEBUG 0x00000002
+#define RES_AAONLY 0x00000004
+#define RES_USEVC 0x00000008
+#define RES_PRIMARY 0x00000010
+#define RES_IGNTC 0x00000020
+#define RES_RECURSE 0x00000040
+#define RES_DEFNAMES 0x00000080
+#define RES_STAYOPEN 0x00000100
+#define RES_DNSRCH 0x00000200
+#define RES_INSECURE1 0x00000400
+#define RES_INSECURE2 0x00000800
+#define RES_NOALIASES 0x00001000
+#define RES_USE_INET6 0x00002000
+#define RES_ROTATE 0x00004000
+#define RES_NOCHECKNAME 0x00008000
+#define RES_KEEPTSIG 0x00010000
+#define RES_BLAST 0x00020000
+#define RES_USEBSTRING 0x00040000
+#define RES_NOIP6DOTINT 0x00080000
+#define RES_USE_EDNS0 0x00100000
+#define RES_SNGLKUP 0x00200000
+#define RES_SNGLKUPREOP 0x00400000
+#define RES_USE_DNSSEC 0x00800000
+
+#define RES_DEFAULT (RES_RECURSE|RES_DEFNAMES|RES_DNSRCH|RES_NOIP6DOTINT)
+
+#define RES_PRF_STATS 0x00000001
+#define RES_PRF_UPDATE 0x00000002
+#define RES_PRF_CLASS 0x00000004
+#define RES_PRF_CMD 0x00000008
+#define RES_PRF_QUES 0x00000010
+#define RES_PRF_ANS 0x00000020
+#define RES_PRF_AUTH 0x00000040
+#define RES_PRF_ADD 0x00000080
+#define RES_PRF_HEAD1 0x00000100
+#define RES_PRF_HEAD2 0x00000200
+#define RES_PRF_TTLID 0x00000400
+#define RES_PRF_HEADX 0x00000800
+#define RES_PRF_QUERY 0x00001000
+#define RES_PRF_REPLY 0x00002000
+#define RES_PRF_INIT 0x00004000
+
+struct __res_state *__res_state(void);
+#define _res (*__res_state())
+
+struct rrec;
+
+int res_init(void);
+int res_query(const char *, int, int, unsigned char *, int);
+int res_querydomain(const char *, const char *, int, int, unsigned char *, int);
+int res_search(const char *, int, int, unsigned char *, int);
+int res_mkquery(int, const char *, int, int, char *, int, struct rrec *, char *, int);
+int res_send(const char *, int, char *, int);
+int dn_comp(unsigned char *, unsigned char *, int, unsigned char **, unsigned char *, unsigned char **);
+int dn_expand(unsigned char *, unsigned char *, unsigned char *, unsigned char *, int);
+int dn_skipname(const unsigned char *, const unsigned char *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/sched.h b/system/include/libc/sched.h
index 13586878..994260d0 100644
--- a/system/include/libc/sched.h
+++ b/system/include/libc/sched.h
@@ -1,97 +1,71 @@
-/*
- * Written by Joel Sherrill <joel@OARcorp.com>.
- *
- * COPYRIGHT (c) 1989-2010.
- * On-Line Applications Research Corporation (OAR).
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose without fee is hereby granted, provided that this entire notice
- * is included in all copies of any software which is or includes a copy
- * or modification of this software.
- *
- * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
- * WARRANTY. IN PARTICULAR, THE AUTHOR MAKES NO REPRESENTATION
- * OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY OF THIS
- * SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
- *
- * $Id: sched.h,v 1.2 2010/04/01 18:33:33 jjohnstn Exp $
- */
-
-#ifndef _SCHED_H_
-#define _SCHED_H_
-
-#include <sys/types.h>
-#include <sys/sched.h>
-
+#ifndef _SCHED_H
+#define _SCHED_H
#ifdef __cplusplus
extern "C" {
#endif
-#if defined(_POSIX_PRIORITY_SCHEDULING)
-/*
- * XBD 13 - Set Scheduling Parameters, P1003.1b-2008, p. 1803
- */
-int sched_setparam(
- pid_t __pid,
- const struct sched_param *__param
-);
-
-/*
- * XBD 13 - Set Scheduling Parameters, P1003.1b-2008, p. 1800
- */
-int sched_getparam(
- pid_t __pid,
- struct sched_param *__param
-);
-
-/*
- * XBD 13 - Set Scheduling Policy and Scheduling Parameters,
- * P1003.1b-2008, p. 1805
- */
-int sched_setscheduler(
- pid_t __pid,
- int __policy,
- const struct sched_param *__param
-);
+#include <features.h>
-/*
- * XBD 13 - Get Scheduling Policy, P1003.1b-2008, p. 1801
- */
-int sched_getscheduler(
- pid_t __pid
-);
+#define __NEED_struct_timespec
+#define __NEED_pid_t
+#define __NEED_time_t
-/*
- * XBD 13 - Get Scheduling Parameter Limits, P1003.1b-2008, p. 1799
- */
-int sched_get_priority_max(
- int __policy
-);
+#include <bits/alltypes.h>
-int sched_get_priority_min(
- int __policy
-);
+struct sched_param {
+ int sched_priority;
+ int sched_ss_low_priority;
+ struct timespec sched_ss_repl_period;
+ struct timespec sched_ss_init_budget;
+ int sched_ss_max_repl;
+};
-/*
- * XBD 13 - Get Scheduling Parameter Limits, P1003.1b-2008, p. 1802
- */
-int sched_rr_get_interval(
- pid_t __pid,
- struct timespec *__interval
-);
-#endif /* _POSIX_PRIORITY_SCHEDULING */
+int sched_get_priority_max(int);
+int sched_get_priority_min(int);
+int sched_getparam(pid_t, struct sched_param *);
+int sched_getscheduler(pid_t);
+int sched_rr_get_interval(pid_t, struct timespec *);
+int sched_setparam(pid_t, const struct sched_param *);
+int sched_setscheduler(pid_t, int, const struct sched_param *);
+int sched_yield(void);
-#if defined(_POSIX_THREADS) || defined(_POSIX_PRIORITY_SCHEDULING) || defined(EMSCRIPTEN)
+#define SCHED_OTHER 0
+#define SCHED_FIFO 1
+#define SCHED_RR 2
+#define SCHED_BATCH 3
+#define SCHED_IDLE 5
+#define SCHED_RESET_ON_FORK 0x40000000
-/*
- * XBD 13 - Yield Processor, P1003.1b-2008, p. 1807
- */
-int sched_yield( void );
-
-#endif /* _POSIX_THREADS or _POSIX_PRIORITY_SCHEDULING */
+#ifdef _GNU_SOURCE
+#define CSIGNAL 0x000000ff
+#define CLONE_VM 0x00000100
+#define CLONE_FS 0x00000200
+#define CLONE_FILES 0x00000400
+#define CLONE_SIGHAND 0x00000800
+#define CLONE_PTRACE 0x00002000
+#define CLONE_VFORK 0x00004000
+#define CLONE_PARENT 0x00008000
+#define CLONE_THREAD 0x00010000
+#define CLONE_NEWNS 0x00020000
+#define CLONE_SYSVSEM 0x00040000
+#define CLONE_SETTLS 0x00080000
+#define CLONE_PARENT_SETTID 0x00100000
+#define CLONE_CHILD_CLEARTID 0x00200000
+#define CLONE_DETACHED 0x00400000
+#define CLONE_UNTRACED 0x00800000
+#define CLONE_CHILD_SETTID 0x01000000
+#define CLONE_NEWUTS 0x04000000
+#define CLONE_NEWIPC 0x08000000
+#define CLONE_NEWUSER 0x10000000
+#define CLONE_NEWPID 0x20000000
+#define CLONE_NEWNET 0x40000000
+#define CLONE_IO 0x80000000
+int clone (int (*)(void *), void *, int, void *, ...);
+int unshare(int);
+int setns(int, int);
+#endif
#ifdef __cplusplus
}
#endif
-
-#endif /* _SCHED_H_ */
+#endif
diff --git a/system/include/libc/search.h b/system/include/libc/search.h
index c78ce184..ebfe08a2 100644
--- a/system/include/libc/search.h
+++ b/system/include/libc/search.h
@@ -1,59 +1,51 @@
-/* $NetBSD: search.h,v 1.12 1999/02/22 10:34:28 christos Exp $ */
-/* $FreeBSD: src/include/search.h,v 1.4 2002/03/23 17:24:53 imp Exp $ */
+#ifndef _SEARCH_H
+#define _SEARCH_H
-/*
- * Written by J.T. Conklin <jtc@netbsd.org>
- * Public domain.
- */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <features.h>
-#ifndef _SEARCH_H_
-#define _SEARCH_H_
+#define __NEED_size_t
+#include <bits/alltypes.h>
-#include <sys/cdefs.h>
-#include <machine/ansi.h>
-#include <sys/types.h>
+typedef enum { FIND, ENTER } ACTION;
+typedef enum { preorder, postorder, endorder, leaf } VISIT;
-typedef struct entry {
+typedef struct {
char *key;
void *data;
} ENTRY;
-typedef enum {
- FIND, ENTER
-} ACTION;
-
-typedef enum {
- preorder,
- postorder,
- endorder,
- leaf
-} VISIT;
-
-#ifdef _SEARCH_PRIVATE
-typedef struct node {
- char *key;
- struct node *llink, *rlink;
-} node_t;
-#endif
+int hcreate(size_t);
+void hdestroy(void);
+ENTRY *hsearch(ENTRY, ACTION);
+
+void insque(void *, void *);
+void remque(void *);
+
+void *lsearch(const void *, void *, size_t *, size_t,
+ int (*)(const void *, const void *));
+void *lfind(const void *, const void *, size_t *, size_t,
+ int (*)(const void *, const void *));
+
+void *tdelete(const void *__restrict, void **__restrict, int(*)(const void *, const void *));
+void *tfind(const void *, void *const *, int(*)(const void *, const void *));
+void *tsearch(const void *, void **, int (*)(const void *, const void *));
+void twalk(const void *, void (*)(const void *, VISIT, int));
-struct hsearch_data
-{
- struct internal_head *htable;
- size_t htablesize;
+#ifdef _GNU_SOURCE
+struct qelem {
+ struct qelem *q_forw, *q_back;
+ char q_data[1];
};
-__BEGIN_DECLS
-int hcreate(size_t);
-void hdestroy(void);
-ENTRY *hsearch(ENTRY, ACTION);
-int hcreate_r(size_t, struct hsearch_data *);
-void hdestroy_r(struct hsearch_data *);
-int hsearch_r(ENTRY, ACTION, ENTRY **, struct hsearch_data *);
-void *tdelete(const void *, void **, int (*)(const void *, const void *));
-void tdestroy (void *, void (*)(void *));
-void *tfind(const void *, void **, int (*)(const void *, const void *));
-void *tsearch(const void *, void **, int (*)(const void *, const void *));
-void twalk(const void *, void (*)(const void *, VISIT, int));
-__END_DECLS
-
-#endif /* !_SEARCH_H_ */
+void tdestroy(void *, void (*)(void *));
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/semaphore.h b/system/include/libc/semaphore.h
new file mode 100644
index 00000000..20d46f0d
--- /dev/null
+++ b/system/include/libc/semaphore.h
@@ -0,0 +1,35 @@
+#ifndef _SEMAPHORE_H
+#define _SEMAPHORE_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <features.h>
+
+#define __NEED_time_t
+#define __NEED_struct_timespec
+#include <bits/alltypes.h>
+
+#include <fcntl.h>
+
+#define SEM_FAILED ((sem_t *)0)
+
+typedef struct {
+ int __val[4*sizeof(long)/sizeof(int)];
+} sem_t;
+
+int sem_close(sem_t *);
+int sem_destroy(sem_t *);
+int sem_getvalue(sem_t *__restrict, int *__restrict);
+int sem_init(sem_t *, int, unsigned);
+sem_t *sem_open(const char *, int, ...);
+int sem_post(sem_t *);
+int sem_timedwait(sem_t *__restrict, const struct timespec *__restrict);
+int sem_trywait(sem_t *);
+int sem_unlink(const char *);
+int sem_wait(sem_t *);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/system/include/libc/setjmp.h b/system/include/libc/setjmp.h
index c958d904..0da27de6 100644
--- a/system/include/libc/setjmp.h
+++ b/system/include/libc/setjmp.h
@@ -1,20 +1,42 @@
-/*
- setjmp.h
- stubs for future use.
-*/
+#ifndef _SETJMP_H
+#define _SETJMP_H
-#ifndef _SETJMP_H_
-#define _SETJMP_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
-#include "_ansi.h"
-#include <machine/setjmp.h>
+#include <features.h>
-_BEGIN_STD_C
+#include <bits/setjmp.h>
-void _EXFUN(longjmp,(jmp_buf __jmpb, int __retval));
-int _EXFUN(setjmp,(jmp_buf __jmpb));
+typedef struct __jmp_buf_tag {
+ __jmp_buf __jb;
+ unsigned long __fl;
+ unsigned long __ss[128/sizeof(long)];
+} jmp_buf[1];
-_END_STD_C
+#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
+ || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
+ || defined(_BSD_SOURCE)
+typedef jmp_buf sigjmp_buf;
+int sigsetjmp (sigjmp_buf, int);
+_Noreturn void siglongjmp (sigjmp_buf, int);
+#endif
-#endif /* _SETJMP_H_ */
+#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
+ || defined(_BSD_SOURCE)
+int _setjmp (jmp_buf);
+_Noreturn void _longjmp (jmp_buf, int);
+#endif
+int setjmp (jmp_buf);
+_Noreturn void longjmp (jmp_buf, int);
+
+#define setjmp setjmp
+#define longjmp longjmp
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/shadow.h b/system/include/libc/shadow.h
new file mode 100644
index 00000000..2b1be413
--- /dev/null
+++ b/system/include/libc/shadow.h
@@ -0,0 +1,44 @@
+#ifndef _SHADOW_H
+#define _SHADOW_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define __NEED_FILE
+#define __NEED_size_t
+
+#include <bits/alltypes.h>
+
+#define SHADOW "/etc/shadow"
+
+struct spwd {
+ char *sp_namp;
+ char *sp_pwdp;
+ long sp_lstchg;
+ long sp_min;
+ long sp_max;
+ long sp_warn;
+ long sp_inact;
+ long sp_expire;
+ unsigned long sp_flag;
+};
+
+void setspent(void);
+void endspent(void);
+struct spwd *getspent(void);
+struct spwd *fgetspent(FILE *);
+struct spwd *sgetspent(const char *);
+int putspent(const struct spwd *, FILE *);
+
+struct spwd *getspnam(const char *);
+int getspnam_r(const char *, struct spwd *, char *, size_t, struct spwd **);
+
+int lckpwdf(void);
+int ulckpwdf(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/signal.h b/system/include/libc/signal.h
index a0030474..e65a8065 100644
--- a/system/include/libc/signal.h
+++ b/system/include/libc/signal.h
@@ -1,30 +1,255 @@
-#ifndef _SIGNAL_H_
-#define _SIGNAL_H_
+#ifndef _SIGNAL_H
+#define _SIGNAL_H
-#include "_ansi.h"
-#include <sys/signal.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <features.h>
+
+#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
+ || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
+ || defined(_BSD_SOURCE)
+
+#ifdef _GNU_SOURCE
+#define __ucontext ucontext
+#endif
+
+#define __NEED_size_t
+#define __NEED_pid_t
+#define __NEED_uid_t
+#define __NEED_struct_timespec
+#define __NEED_pthread_t
+#define __NEED_pthread_attr_t
+#define __NEED_time_t
+#define __NEED_clock_t
+#define __NEED_sigset_t
+
+#include <bits/alltypes.h>
+
+#define SIG_HOLD ((void (*)(int)) 2)
+
+#define SIG_BLOCK 0
+#define SIG_UNBLOCK 1
+#define SIG_SETMASK 2
+
+#define SI_ASYNCNL (-60)
+#define SI_TKILL (-6)
+#define SI_SIGIO (-5)
+#define SI_ASYNCIO (-4)
+#define SI_MESGQ (-3)
+#define SI_TIMER (-2)
+#define SI_QUEUE (-1)
+#define SI_USER 0
+#define SI_KERNEL 128
+
+#define FPE_INTDIV 1
+#define FPE_INTOVF 2
+#define FPE_FLTDIV 3
+#define FPE_FLTOVF 4
+#define FPE_FLTUND 5
+#define FPE_FLTRES 6
+#define FPE_FLTINV 7
+#define FPE_FLTSUB 8
+
+#define ILL_ILLOPC 1
+#define ILL_ILLOPN 2
+#define ILL_ILLADR 3
+#define ILL_ILLTRP 4
+#define ILL_PRVOPC 5
+#define ILL_PRVREG 6
+#define ILL_COPROC 7
+#define ILL_BADSTK 8
+
+#define SEGV_MAPERR 1
+#define SEGV_ACCERR 2
+
+#define BUS_ADRALN 1
+#define BUS_ADRERR 2
+#define BUS_OBJERR 3
+#define BUS_MCEERR_AR 4
+#define BUS_MCEERR_AO 5
+
+#define CLD_EXITED 1
+#define CLD_KILLED 2
+#define CLD_DUMPED 3
+#define CLD_TRAPPED 4
+#define CLD_STOPPED 5
+#define CLD_CONTINUED 6
+
+typedef struct sigaltstack {
+ void *ss_sp;
+ int ss_flags;
+ size_t ss_size;
+} stack_t;
+
+union sigval {
+ int sival_int;
+ void *sival_ptr;
+};
+
+typedef struct {
+ int si_signo, si_errno, si_code;
+ union {
+ char __pad[128 - 2*sizeof(int) - sizeof(long)];
+ struct {
+ pid_t si_pid;
+ uid_t si_uid;
+ union sigval si_sigval;
+ } __rt;
+ struct {
+ unsigned int si_timer1, si_timer2;
+ } __timer;
+ struct {
+ pid_t si_pid;
+ uid_t si_uid;
+ int si_status;
+ clock_t si_utime, si_stime;
+ } __sigchld;
+ struct {
+ void *si_addr;
+ short si_addr_lsb;
+ } __sigfault;
+ struct {
+ long si_band;
+ int si_fd;
+ } __sigpoll;
+ struct {
+ void *si_call_addr;
+ int si_syscall;
+ unsigned si_arch;
+ } __sigsys;
+ } __si_fields;
+} siginfo_t;
+#define si_pid __si_fields.__sigchld.si_pid
+#define si_uid __si_fields.__sigchld.si_uid
+#define si_status __si_fields.__sigchld.si_status
+#define si_utime __si_fields.__sigchld.si_utime
+#define si_stime __si_fields.__sigchld.si_stime
+#define si_value __si_fields.__rt.si_sigval
+#define si_addr __si_fields.__sigfault.si_addr
+#define si_addr_lsb __si_fields.__sigfault.si_addr_lsb
+#define si_band __si_fields.__sigpoll.si_band
+#define si_fd __si_fields.__sigpoll.si_fd
+#define si_timer1 __si_fields.__timer.si_timer1
+#define si_timer2 __si_fields.__timer.si_timer2
+#define si_ptr __si_fields.__rt.si_sigval.sival_ptr
+#define si_int __si_fields.__rt.si_sigval.sival_int
+#define si_call_addr __si_fields.__sigsys.si_call_addr
+#define si_syscall __si_fields.__sigsys.si_syscall
+#define si_arch __si_fields.__sigsys.si_arch
+
+struct sigaction {
+ union {
+ void (*sa_handler)(int);
+ void (*sa_sigaction)(int, siginfo_t *, void *);
+ } __sa_handler;
+ sigset_t sa_mask;
+ int sa_flags;
+ void (*sa_restorer)(void);
+};
+#define sa_handler __sa_handler.sa_handler
+#define sa_sigaction __sa_handler.sa_sigaction
-_BEGIN_STD_C
+struct sigevent {
+ union sigval sigev_value;
+ int sigev_signo;
+ int sigev_notify;
+ void (*sigev_notify_function)(union sigval);
+ pthread_attr_t *sigev_notify_attributes;
+ char __pad[56-3*sizeof(long)];
+};
-typedef int sig_atomic_t; /* Atomic entity type (ANSI) */
-#ifndef _POSIX_SOURCE
-typedef _sig_func_ptr sighandler_t; /* glibc naming */
-#endif /* !_POSIX_SOURCE */
+#define SIGEV_SIGNAL 0
+#define SIGEV_NONE 1
+#define SIGEV_THREAD 2
-#define SIG_DFL ((_sig_func_ptr)0) /* Default action */
-#define SIG_IGN ((_sig_func_ptr)1) /* Ignore action */
-#define SIG_ERR ((_sig_func_ptr)-1) /* Error return */
+int __libc_current_sigrtmin(void);
+int __libc_current_sigrtmax(void);
-struct _reent;
+#define SIGRTMIN (__libc_current_sigrtmin())
+#define SIGRTMAX (__libc_current_sigrtmax())
-_sig_func_ptr _EXFUN(_signal_r, (struct _reent *, int, _sig_func_ptr));
-int _EXFUN(_raise_r, (struct _reent *, int));
+int kill(pid_t, int);
-#ifndef _REENT_ONLY
-_sig_func_ptr _EXFUN(signal, (int, _sig_func_ptr));
-int _EXFUN(raise, (int));
+int sigemptyset(sigset_t *);
+int sigfillset(sigset_t *);
+int sigaddset(sigset_t *, int);
+int sigdelset(sigset_t *, int);
+int sigismember(const sigset_t *, int);
+
+int sigprocmask(int, const sigset_t *__restrict, sigset_t *__restrict);
+int sigsuspend(const sigset_t *);
+int sigaction(int, const struct sigaction *__restrict, struct sigaction *__restrict);
+int sigpending(sigset_t *);
+int sigwait(const sigset_t *__restrict, int *__restrict);
+int sigwaitinfo(const sigset_t *__restrict, siginfo_t *__restrict);
+int sigtimedwait(const sigset_t *__restrict, siginfo_t *__restrict, const struct timespec *__restrict);
+int sigqueue(pid_t, int, const union sigval);
+
+int pthread_sigmask(int, const sigset_t *__restrict, sigset_t *__restrict);
+int pthread_kill(pthread_t, int);
+
+void psiginfo(const siginfo_t *, const char *);
+void psignal(int, const char *);
+
+#endif
+
+#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE)
+int killpg(pid_t, int);
+int sigaltstack(const stack_t *__restrict, stack_t *__restrict);
+int sighold(int);
+int sigignore(int);
+int siginterrupt(int, int);
+int sigpause(int);
+int sigrelse(int);
+void (*sigset(int, void (*)(int)))(int);
+#define TRAP_BRKPT 1
+#define TRAP_TRACE 2
+#define POLL_IN 1
+#define POLL_OUT 2
+#define POLL_MSG 3
+#define POLL_ERR 4
+#define POLL_PRI 5
+#define POLL_HUP 6
+#define SS_ONSTACK 1
+#define SS_DISABLE 2
+#define MINSIGSTKSZ 2048
+#define SIGSTKSZ 8192
+#endif
+
+#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE)
+#define NSIG _NSIG
+#endif
+
+#if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
+typedef void (*sig_t)(int);
#endif
-_END_STD_C
+#ifdef _GNU_SOURCE
+typedef void (*sighandler_t)(int);
+void (*bsd_signal(int, void (*)(int)))(int);
+int sigisemptyset(const sigset_t *);
+int sigorset (sigset_t *, sigset_t *, sigset_t *);
+int sigandset(sigset_t *, sigset_t *, sigset_t *);
-#endif /* _SIGNAL_H_ */
+#define SA_NOMASK SA_NODEFER
+#define SA_ONESHOT SA_RESETHAND
+#endif
+
+#include <bits/signal.h>
+
+#define SIG_ERR ((void (*)(int))-1)
+#define SIG_DFL ((void (*)(int)) 0)
+#define SIG_IGN ((void (*)(int)) 1)
+
+typedef int sig_atomic_t;
+
+void (*signal(int, void (*)(int)))(int);
+int raise(int);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/spawn.h b/system/include/libc/spawn.h
new file mode 100644
index 00000000..29c799ee
--- /dev/null
+++ b/system/include/libc/spawn.h
@@ -0,0 +1,74 @@
+#ifndef _SPAWN_H
+#define _SPAWN_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <features.h>
+
+#define __NEED_mode_t
+#define __NEED_pid_t
+#define __NEED_sigset_t
+
+#include <bits/alltypes.h>
+
+struct sched_param;
+
+#define POSIX_SPAWN_RESETIDS 1
+#define POSIX_SPAWN_SETPGROUP 2
+#define POSIX_SPAWN_SETSIGDEF 4
+#define POSIX_SPAWN_SETSIGMASK 8
+#define POSIX_SPAWN_SETSCHEDPARAM 16
+#define POSIX_SPAWN_SETSCHEDULER 32
+
+typedef struct {
+ int __flags;
+ pid_t __pgrp;
+ sigset_t __def, __mask;
+ int __prio, __pol, __pad[16];
+} posix_spawnattr_t;
+
+typedef struct {
+ int __pad0[2];
+ void *__actions;
+ int __pad[16];
+} posix_spawn_file_actions_t;
+
+int posix_spawn(pid_t *__restrict, const char *__restrict, const posix_spawn_file_actions_t *,
+ const posix_spawnattr_t *__restrict, char *const *__restrict, char *const *__restrict);
+int posix_spawnp(pid_t *__restrict, const char *__restrict, const posix_spawn_file_actions_t *,
+ const posix_spawnattr_t *__restrict, char *const *__restrict, char *const *__restrict);
+
+int posix_spawnattr_init(posix_spawnattr_t *);
+int posix_spawnattr_destroy(posix_spawnattr_t *);
+
+int posix_spawnattr_setflags(posix_spawnattr_t *, short);
+int posix_spawnattr_getflags(const posix_spawnattr_t *__restrict, short *__restrict);
+
+int posix_spawnattr_setpgroup(posix_spawnattr_t *, pid_t);
+int posix_spawnattr_getpgroup(const posix_spawnattr_t *__restrict, pid_t *__restrict);
+
+int posix_spawnattr_setsigmask(posix_spawnattr_t *__restrict, const sigset_t *__restrict);
+int posix_spawnattr_getsigmask(const posix_spawnattr_t *__restrict, sigset_t *__restrict);
+
+int posix_spawnattr_setsigdefault(posix_spawnattr_t *__restrict, const sigset_t *__restrict);
+int posix_spawnattr_getsigdefault(const posix_spawnattr_t *__restrict, sigset_t *__restrict);
+
+int posix_spawnattr_setschedparam(posix_spawnattr_t *__restrict, const struct sched_param *__restrict);
+int posix_spawnattr_getschedparam(const posix_spawnattr_t *__restrict, struct sched_param *__restrict);
+int posix_spawnattr_setschedpolicy(posix_spawnattr_t *, int);
+int posix_spawnattr_getschedpolicy(const posix_spawnattr_t *__restrict, int *__restrict);
+
+int posix_spawn_file_actions_init(posix_spawn_file_actions_t *);
+int posix_spawn_file_actions_destroy(posix_spawn_file_actions_t *);
+
+int posix_spawn_file_actions_addopen(posix_spawn_file_actions_t *__restrict, int, const char *__restrict, int, mode_t);
+int posix_spawn_file_actions_addclose(posix_spawn_file_actions_t *, int);
+int posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t *, int, int);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/stdalign.h b/system/include/libc/stdalign.h
new file mode 100644
index 00000000..b6e50aeb
--- /dev/null
+++ b/system/include/libc/stdalign.h
@@ -0,0 +1,15 @@
+#ifndef _STDALIGN_H
+#define _STDALIGN_H
+
+/* this whole header only works in C11 or with compiler extensions */
+#if __STDC_VERSION__ < 201112L && defined( __GNUC__)
+#define _Alignas(t) __attribute__((__aligned__(t)))
+#define _Alignof(t) __alignof__(t)
+#endif
+
+#define alignas _Alignas
+#define alignof _Alignof
+#define __alignas_is_defined 1
+#define __alignof_is_defined 1
+
+#endif
diff --git a/system/include/libc/stdarg.h b/system/include/libc/stdarg.h
index 1d462684..60d4e2af 100644
--- a/system/include/libc/stdarg.h
+++ b/system/include/libc/stdarg.h
@@ -1,50 +1,25 @@
-/*===---- stdarg.h - Variable argument handling ----------------------------===
- *
- * Copyright (c) 2008 Eli Friedman
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- *===-----------------------------------------------------------------------===
- */
+#ifndef _STDARG_H
+#define _STDARG_H
-#ifndef __STDARG_H
-#define __STDARG_H
-
-#ifndef _VA_LIST
-typedef __builtin_va_list va_list;
-#define _VA_LIST
+#ifdef __cplusplus
+extern "C" {
#endif
-#define va_start(ap, param) __builtin_va_start(ap, param)
-#define va_end(ap) __builtin_va_end(ap)
-#define va_arg(ap, type) __builtin_va_arg(ap, type)
-/* GCC always defines __va_copy, but does not define va_copy unless in c99 mode
- * or -ansi is not specified, since it was not part of C90.
- */
-#define __va_copy(d,s) __builtin_va_copy(d,s)
+#define __NEED_va_list
+
+#include <bits/alltypes.h>
-#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199900L) || (defined(__cplusplus) && __cplusplus >= 201103L) || !defined(__STRICT_ANSI__)
-#define va_copy(dest, src) __builtin_va_copy(dest, src)
+#if __GNUC__ >= 3
+#define va_start(v,l) __builtin_va_start(v,l)
+#define va_end(v) __builtin_va_end(v)
+#define va_arg(v,l) __builtin_va_arg(v,l)
+#define va_copy(d,s) __builtin_va_copy(d,s)
+#else
+#include <bits/stdarg.h>
#endif
-/* Hack required to make standard headers work, at least on Ubuntu */
-#define __GNUC_VA_LIST 1
-typedef __builtin_va_list __gnuc_va_list;
+#ifdef __cplusplus
+}
+#endif
-#endif /* __STDARG_H */
+#endif
diff --git a/system/include/libc/stdbool.h b/system/include/libc/stdbool.h
new file mode 100644
index 00000000..a9d7ab78
--- /dev/null
+++ b/system/include/libc/stdbool.h
@@ -0,0 +1,14 @@
+#ifndef _STDBOOL_H
+#define _STDBOOL_H
+
+#ifndef __cplusplus
+
+#define true 1
+#define false 0
+#define bool _Bool
+
+#endif
+
+#define __bool_true_false_are_defined 1
+
+#endif
diff --git a/system/include/libc/stddef.h b/system/include/libc/stddef.h
index 9e87ee89..9d522486 100644
--- a/system/include/libc/stddef.h
+++ b/system/include/libc/stddef.h
@@ -1,64 +1,18 @@
-/*===---- stddef.h - Basic type definitions --------------------------------===
- *
- * Copyright (c) 2008 Eli Friedman
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- *===-----------------------------------------------------------------------===
- */
+#ifndef _STDDEF_H
+#define _STDDEF_H
-#ifndef __STDDEF_H
-#define __STDDEF_H
+#define NULL 0L
-#ifndef _PTRDIFF_T
-#define _PTRDIFF_T
-typedef __typeof__(((int*)0)-((int*)0)) ptrdiff_t;
-#endif
-#ifndef _SIZE_T
-#define _SIZE_T
-typedef __typeof__(sizeof(int)) size_t;
-#endif
-#ifndef __cplusplus
-#ifndef _WCHAR_T
-#define _WCHAR_T
-typedef __WCHAR_TYPE__ wchar_t;
-#endif
-#endif
+#define __NEED_ptrdiff_t
+#define __NEED_size_t
+#define __NEED_wchar_t
-#undef NULL
-#ifdef __cplusplus
-#undef __null // VC++ hack.
-#define NULL __null
+#include <bits/alltypes.h>
+
+#if __GNUC__ > 3
+#define offsetof(type, member) __builtin_offsetof(type, member)
#else
-#define NULL ((void*)0)
+#define offsetof(type, member) ((size_t)( (char *)&(((type *)0)->member) - (char *)0 ))
#endif
-#define offsetof(t, d) __builtin_offsetof(t, d)
-
-#endif /* __STDDEF_H */
-
-/* Some C libraries expect to see a wint_t here. Others (notably MinGW) will use
-__WINT_TYPE__ directly; accommodate both by requiring __need_wint_t */
-#if defined(__need_wint_t)
-#if !defined(_WINT_T)
-#define _WINT_T
-typedef __WINT_TYPE__ wint_t;
-#endif /* _WINT_T */
-#undef __need_wint_t
-#endif /* __need_wint_t */
+#endif
diff --git a/system/include/libc/stdint.h b/system/include/libc/stdint.h
index d6cea665..ad6aaead 100644
--- a/system/include/libc/stdint.h
+++ b/system/include/libc/stdint.h
@@ -1,493 +1,117 @@
-/*
- * Copyright (c) 2004, 2005 by
- * Ralf Corsepius, Ulm/Germany. All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this software
- * is freely granted, provided that this notice is preserved.
- */
-
#ifndef _STDINT_H
#define _STDINT_H
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#if defined(__GNUC__) && \
- ( (__GNUC__ >= 4) || \
- ( (__GNUC__ >= 3) && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ > 2) ) )
-/* gcc > 3.2 implicitly defines the values we are interested */
-#define __STDINT_EXP(x) __##x##__
-#else
-#define __STDINT_EXP(x) x
-#include <limits.h>
-#endif
-
-/* Check if "long long" is 64bit wide */
-/* Modern GCCs provide __LONG_LONG_MAX__, SUSv3 wants LLONG_MAX */
-#if ( defined(__LONG_LONG_MAX__) && (__LONG_LONG_MAX__ > 0x7fffffff) ) \
- || ( defined(LLONG_MAX) && (LLONG_MAX > 0x7fffffff) )
-#define __have_longlong64 1
-#endif
-
-/* Check if "long" is 64bit or 32bit wide */
-#if __STDINT_EXP(LONG_MAX) > 0x7fffffff
-#define __have_long64 1
-#elif __STDINT_EXP(LONG_MAX) == 0x7fffffff && !defined(__SPU__) && !defined(EMSCRIPTEN)
-#define __have_long32 1
-#endif
-
-#if __STDINT_EXP(SCHAR_MAX) == 0x7f
-typedef signed char int8_t ;
-typedef unsigned char uint8_t ;
-#define __int8_t_defined 1
-#endif
-
-#if __int8_t_defined
-typedef signed char int_least8_t;
-typedef unsigned char uint_least8_t;
-#define __int_least8_t_defined 1
-#endif
-
-#if __STDINT_EXP(SHRT_MAX) == 0x7fff
-typedef signed short int16_t;
-typedef unsigned short uint16_t;
-#define __int16_t_defined 1
-#elif __STDINT_EXP(INT_MAX) == 0x7fff
-typedef signed int int16_t;
-typedef unsigned int uint16_t;
-#define __int16_t_defined 1
-#elif __STDINT_EXP(SCHAR_MAX) == 0x7fff
-typedef signed char int16_t;
-typedef unsigned char uint16_t;
-#define __int16_t_defined 1
-#endif
-
-#if __int16_t_defined
-typedef int16_t int_least16_t;
-typedef uint16_t uint_least16_t;
-#define __int_least16_t_defined 1
-
-#if !__int_least8_t_defined
-typedef int16_t int_least8_t;
-typedef uint16_t uint_least8_t;
-#define __int_least8_t_defined 1
-#endif
-#endif
-
-#if __have_long32
-typedef signed long int32_t;
-typedef unsigned long uint32_t;
-#define __int32_t_defined 1
-#elif __STDINT_EXP(INT_MAX) == 0x7fffffffL
-typedef signed int int32_t;
-typedef unsigned int uint32_t;
-#define __int32_t_defined 1
-#elif __STDINT_EXP(SHRT_MAX) == 0x7fffffffL
-typedef signed short int32_t;
-typedef unsigned short uint32_t;
-#define __int32_t_defined 1
-#elif __STDINT_EXP(SCHAR_MAX) == 0x7fffffffL
-typedef signed char int32_t;
-typedef unsigned char uint32_t;
-#define __int32_t_defined 1
-#endif
-
-#if __int32_t_defined
-typedef int32_t int_least32_t;
-typedef uint32_t uint_least32_t;
-#define __int_least32_t_defined 1
-
-#if !__int_least8_t_defined
-typedef int32_t int_least8_t;
-typedef uint32_t uint_least8_t;
-#define __int_least8_t_defined 1
-#endif
-
-#if !__int_least16_t_defined
-typedef int32_t int_least16_t;
-typedef uint32_t uint_least16_t;
-#define __int_least16_t_defined 1
-#endif
-#endif
-
-#if __have_long64
-typedef signed long int64_t;
-typedef unsigned long uint64_t;
-#define __int64_t_defined 1
-#elif __have_longlong64
-typedef signed long long int64_t;
-typedef unsigned long long uint64_t;
-#define __int64_t_defined 1
-#elif __STDINT_EXP(INT_MAX) > 0x7fffffff
-typedef signed int int64_t;
-typedef unsigned int uint64_t;
-#define __int64_t_defined 1
-#endif
-
-#if __int64_t_defined
-typedef int64_t int_least64_t;
-typedef uint64_t uint_least64_t;
-#define __int_least64_t_defined 1
+#define __NEED_int8_t
+#define __NEED_int16_t
+#define __NEED_int32_t
+#define __NEED_int64_t
-#if !__int_least8_t_defined
-typedef int64_t int_least8_t;
-typedef uint64_t uint_least8_t;
-#define __int_least8_t_defined 1
-#endif
-
-#if !__int_least16_t_defined
-typedef int64_t int_least16_t;
-typedef uint64_t uint_least16_t;
-#define __int_least16_t_defined 1
-#endif
-
-#if !__int_least32_t_defined
-typedef int64_t int_least32_t;
-typedef uint64_t uint_least32_t;
-#define __int_least32_t_defined 1
-#endif
-#endif
-
-/*
- * Fastest minimum-width integer types
- *
- * Assume int to be the fastest type for all types with a width
- * less than __INT_MAX__ rsp. INT_MAX
- */
-#if __STDINT_EXP(INT_MAX) >= 0x7f
- typedef signed int int_fast8_t;
- typedef unsigned int uint_fast8_t;
-#define __int_fast8_t_defined 1
-#endif
-
-#if __STDINT_EXP(INT_MAX) >= 0x7fff
- typedef signed int int_fast16_t;
- typedef unsigned int uint_fast16_t;
-#define __int_fast16_t_defined 1
-#endif
-
-#if __STDINT_EXP(INT_MAX) >= 0x7fffffff
- typedef signed int int_fast32_t;
- typedef unsigned int uint_fast32_t;
-#define __int_fast32_t_defined 1
-#endif
-
-#if __STDINT_EXP(INT_MAX) > 0x7fffffff
- typedef signed int int_fast64_t;
- typedef unsigned int uint_fast64_t;
-#define __int_fast64_t_defined 1
-#endif
-
-/*
- * Fall back to [u]int_least<N>_t for [u]int_fast<N>_t types
- * not having been defined, yet.
- * Leave undefined, if [u]int_least<N>_t should not be available.
- */
-#if !__int_fast8_t_defined
-#if __int_least8_t_defined
- typedef int_least8_t int_fast8_t;
- typedef uint_least8_t uint_fast8_t;
-#define __int_fast8_t_defined 1
-#endif
-#endif
-
-#if !__int_fast16_t_defined
-#if __int_least16_t_defined
- typedef int_least16_t int_fast16_t;
- typedef uint_least16_t uint_fast16_t;
-#define __int_fast16_t_defined 1
-#endif
-#endif
-
-#if !__int_fast32_t_defined
-#if __int_least32_t_defined
- typedef int_least32_t int_fast32_t;
- typedef uint_least32_t uint_fast32_t;
-#define __int_fast32_t_defined 1
-#endif
-#endif
-
-#if !__int_fast64_t_defined
-#if __int_least64_t_defined
- typedef int_least64_t int_fast64_t;
- typedef uint_least64_t uint_fast64_t;
-#define __int_fast64_t_defined 1
-#endif
-#endif
-
-/* Greatest-width integer types */
-/* Modern GCCs provide __INTMAX_TYPE__ */
-#if defined(__INTMAX_TYPE__)
- typedef __INTMAX_TYPE__ intmax_t;
-#elif __have_longlong64
- typedef signed long long intmax_t;
-#else
- typedef signed long intmax_t;
-#endif
+#define __NEED_uint8_t
+#define __NEED_uint16_t
+#define __NEED_uint32_t
+#define __NEED_uint64_t
-/* Modern GCCs provide __UINTMAX_TYPE__ */
-#if defined(__UINTMAX_TYPE__)
- typedef __UINTMAX_TYPE__ uintmax_t;
-#elif __have_longlong64
- typedef unsigned long long uintmax_t;
-#else
- typedef unsigned long uintmax_t;
-#endif
+#define __NEED_intptr_t
+#define __NEED_uintptr_t
-/*
- * GCC doesn't provide an appropriate macro for [u]intptr_t
- * For now, use __PTRDIFF_TYPE__
- */
-#if defined(__PTRDIFF_TYPE__)
-typedef signed __PTRDIFF_TYPE__ intptr_t;
-typedef unsigned __PTRDIFF_TYPE__ uintptr_t;
-#define INTPTR_MAX PTRDIFF_MAX
-#define INTPTR_MIN PTRDIFF_MIN
-#ifdef __UINTPTR_MAX__
-#define UINTPTR_MAX __UINTPTR_MAX__
-#else
-#define UINTPTR_MAX (2UL * PTRDIFF_MAX + 1)
-#endif
-#else
-/*
- * Fallback to hardcoded values,
- * should be valid on cpu's with 32bit int/32bit void*
- */
-typedef signed long intptr_t;
-typedef unsigned long uintptr_t;
-#define INTPTR_MAX __STDINT_EXP(LONG_MAX)
-#define INTPTR_MIN (-__STDINT_EXP(LONG_MAX) - 1)
-#define UINTPTR_MAX (__STDINT_EXP(LONG_MAX) * 2UL + 1)
-#endif
+#define __NEED_intmax_t
+#define __NEED_uintmax_t
-/* Limits of Specified-Width Integer Types */
+#include <bits/alltypes.h>
-#if __int8_t_defined
-#define INT8_MIN -128
-#define INT8_MAX 127
-#define UINT8_MAX 255
-#endif
+typedef int8_t int_fast8_t;
+typedef int64_t int_fast64_t;
-#if __int_least8_t_defined
-#define INT_LEAST8_MIN -128
-#define INT_LEAST8_MAX 127
-#define UINT_LEAST8_MAX 255
-#else
-#error required type int_least8_t missing
-#endif
+typedef int8_t int_least8_t;
+typedef int16_t int_least16_t;
+typedef int32_t int_least32_t;
+typedef int64_t int_least64_t;
-#if __int16_t_defined
-#define INT16_MIN -32768
-#define INT16_MAX 32767
-#define UINT16_MAX 65535
-#endif
+typedef uint8_t uint_fast8_t;
+typedef uint64_t uint_fast64_t;
-#if __int_least16_t_defined
-#define INT_LEAST16_MIN -32768
-#define INT_LEAST16_MAX 32767
-#define UINT_LEAST16_MAX 65535
-#else
-#error required type int_least16_t missing
-#endif
+typedef uint8_t uint_least8_t;
+typedef uint16_t uint_least16_t;
+typedef uint32_t uint_least32_t;
+typedef uint64_t uint_least64_t;
-#if __int32_t_defined
-#if __have_long32
-#define INT32_MIN (-2147483647L-1)
-#define INT32_MAX 2147483647L
-#define UINT32_MAX 4294967295UL
-#else
-#define INT32_MIN (-2147483647-1)
-#define INT32_MAX 2147483647
-#define UINT32_MAX 4294967295U
-#endif
-#endif
+#define INT8_MIN (-1-0x7f)
+#define INT16_MIN (-1-0x7fff)
+#define INT32_MIN (-1-0x7fffffff)
+#define INT64_MIN (-1-0x7fffffffffffffff)
-#if __int_least32_t_defined
-#if __have_long32
-#define INT_LEAST32_MIN (-2147483647L-1)
-#define INT_LEAST32_MAX 2147483647L
-#define UINT_LEAST32_MAX 4294967295UL
-#else
-#define INT_LEAST32_MIN (-2147483647-1)
-#define INT_LEAST32_MAX 2147483647
-#define UINT_LEAST32_MAX 4294967295U
-#endif
-#else
-#error required type int_least32_t missing
-#endif
+#define INT8_MAX (0x7f)
+#define INT16_MAX (0x7fff)
+#define INT32_MAX (0x7fffffff)
+#define INT64_MAX (0x7fffffffffffffff)
-#if __int64_t_defined
-#if __have_long64
-#define INT64_MIN (-9223372036854775807L-1L)
-#define INT64_MAX 9223372036854775807L
-#define UINT64_MAX 18446744073709551615U
-#elif __have_longlong64
-#define INT64_MIN (-9223372036854775807LL-1LL)
-#define INT64_MAX 9223372036854775807LL
-#define UINT64_MAX 18446744073709551615ULL
-#endif
-#endif
+#define UINT8_MAX (0xff)
+#define UINT16_MAX (0xffff)
+#define UINT32_MAX (0xffffffff)
+#define UINT64_MAX (0xffffffffffffffff)
-#if __int_least64_t_defined
-#if __have_long64
-#define INT_LEAST64_MIN (-9223372036854775807L-1L)
-#define INT_LEAST64_MAX 9223372036854775807L
-#define UINT_LEAST64_MAX 18446744073709551615U
-#elif __have_longlong64
-#define INT_LEAST64_MIN (-9223372036854775807LL-1LL)
-#define INT_LEAST64_MAX 9223372036854775807LL
-#define UINT_LEAST64_MAX 18446744073709551615ULL
-#endif
-#endif
+#define INT_FAST8_MIN INT8_MIN
+#define INT_FAST64_MIN INT64_MIN
-#if __int_fast8_t_defined
-#if __STDINT_EXP(INT_MAX) >= 0x7f
-#define INT_FAST8_MIN (-__STDINT_EXP(INT_MAX)-1)
-#define INT_FAST8_MAX __STDINT_EXP(INT_MAX)
-#define UINT_FAST8_MAX (__STDINT_EXP(INT_MAX)*2U+1U)
-#else
-#define INT_FAST8_MIN INT_LEAST8_MIN
-#define INT_FAST8_MAX INT_LEAST8_MAX
-#define UINT_FAST8_MAX UINT_LEAST8_MAX
-#endif
-#endif
+#define INT_LEAST8_MIN INT8_MIN
+#define INT_LEAST16_MIN INT16_MIN
+#define INT_LEAST32_MIN INT32_MIN
+#define INT_LEAST64_MIN INT64_MIN
-#if __int_fast16_t_defined
-#if __STDINT_EXP(INT_MAX) >= 0x7fff
-#define INT_FAST16_MIN (-__STDINT_EXP(INT_MAX)-1)
-#define INT_FAST16_MAX __STDINT_EXP(INT_MAX)
-#define UINT_FAST16_MAX (__STDINT_EXP(INT_MAX)*2U+1U)
-#else
-#define INT_FAST16_MIN INT_LEAST16_MIN
-#define INT_FAST16_MAX INT_LEAST16_MAX
-#define UINT_FAST16_MAX UINT_LEAST16_MAX
-#endif
-#endif
+#define INT_FAST8_MAX INT8_MAX
+#define INT_FAST64_MAX INT64_MAX
-#if __int_fast32_t_defined
-#if __STDINT_EXP(INT_MAX) >= 0x7fffffff
-#define INT_FAST32_MIN (-__STDINT_EXP(INT_MAX)-1)
-#define INT_FAST32_MAX __STDINT_EXP(INT_MAX)
-#define UINT_FAST32_MAX (__STDINT_EXP(INT_MAX)*2U+1U)
-#else
-#define INT_FAST32_MIN INT_LEAST32_MIN
-#define INT_FAST32_MAX INT_LEAST32_MAX
-#define UINT_FAST32_MAX UINT_LEAST32_MAX
-#endif
-#endif
+#define INT_LEAST8_MAX INT8_MAX
+#define INT_LEAST16_MAX INT16_MAX
+#define INT_LEAST32_MAX INT32_MAX
+#define INT_LEAST64_MAX INT64_MAX
-#if __int_fast64_t_defined
-#if __STDINT_EXP(INT_MAX) > 0x7fffffff
-#define INT_FAST64_MIN (-__STDINT_EXP(INT_MAX)-1)
-#define INT_FAST64_MAX __STDINT_EXP(INT_MAX)
-#define UINT_FAST64_MAX (__STDINT_EXP(INT_MAX)*2U+1U)
-#else
-#define INT_FAST64_MIN INT_LEAST64_MIN
-#define INT_FAST64_MAX INT_LEAST64_MAX
-#define UINT_FAST64_MAX UINT_LEAST64_MAX
-#endif
-#endif
+#define UINT_FAST8_MAX UINT8_MAX
+#define UINT_FAST64_MAX UINT64_MAX
-#ifdef __INTMAX_MAX__
-#define INTMAX_MAX __INTMAX_MAX__
-#define INTMAX_MIN (-INTMAX_MAX - 1)
-#elif defined(__INTMAX_TYPE__)
-/* All relevant GCC versions prefer long to long long for intmax_t. */
-#define INTMAX_MAX INT64_MAX
-#define INTMAX_MIN INT64_MIN
-#endif
+#define UINT_LEAST8_MAX UINT8_MAX
+#define UINT_LEAST16_MAX UINT16_MAX
+#define UINT_LEAST32_MAX UINT32_MAX
+#define UINT_LEAST64_MAX UINT64_MAX
-#ifdef __UINTMAX_MAX__
-#define UINTMAX_MAX __UINTMAX_MAX__
-#elif defined(__UINTMAX_TYPE__)
-/* All relevant GCC versions prefer long to long long for intmax_t. */
+#define INTMAX_MIN INT64_MIN
+#define INTMAX_MAX INT64_MAX
#define UINTMAX_MAX UINT64_MAX
-#endif
-/* This must match size_t in stddef.h, currently long unsigned int */
-#ifdef __SIZE_MAX__
-#define SIZE_MAX __SIZE_MAX__
-#else
-#define SIZE_MAX (__STDINT_EXP(LONG_MAX) * 2UL + 1)
-#endif
-
-/* This must match sig_atomic_t in <signal.h> (currently int) */
-#define SIG_ATOMIC_MIN (-__STDINT_EXP(INT_MAX) - 1)
-#define SIG_ATOMIC_MAX __STDINT_EXP(INT_MAX)
+#define WINT_MIN 0
+#define WINT_MAX UINT32_MAX
-/* This must match ptrdiff_t in <stddef.h> (currently long int) */
-#ifdef __PTRDIFF_MAX__
-#define PTRDIFF_MAX __PTRDIFF_MAX__
+#if L'\0'-1 > 0
+#define WCHAR_MAX (0xffffffffu+L'\0')
+#define WCHAR_MIN (0+L'\0')
#else
-#define PTRDIFF_MAX __STDINT_EXP(LONG_MAX)
+#define WCHAR_MAX (0x7fffffff+L'\0')
+#define WCHAR_MIN (-1-0x7fffffff+L'\0')
#endif
-#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)
-#ifdef __WCHAR_MAX__
-#define WCHAR_MAX __WCHAR_MAX__
-#endif
-#ifdef __WCHAR_MIN__
-#define WCHAR_MIN __WCHAR_MIN__
-#endif
+#define SIG_ATOMIC_MIN INT32_MIN
+#define SIG_ATOMIC_MAX INT32_MAX
-/* wint_t is unsigned int on almost all GCC targets. */
-#ifdef __WINT_MAX__
-#define WINT_MAX __WINT_MAX__
-#else
-#define WINT_MAX (__STDINT_EXP(INT_MAX) * 2U + 1U)
-#endif
-#ifdef __WINT_MIN__
-#define WINT_MIN __WINT_MIN__
-#else
-#define WINT_MIN 0U
-#endif
-
-/** Macros for minimum-width integer constant expressions */
-#define INT8_C(x) x
-#if __STDINT_EXP(INT_MAX) > 0x7f
-#define UINT8_C(x) x
-#else
-#define UINT8_C(x) x##U
-#endif
-
-#define INT16_C(x) x
-#if __STDINT_EXP(INT_MAX) > 0x7fff
-#define UINT16_C(x) x
-#else
-#define UINT16_C(x) x##U
-#endif
+#include <bits/stdint.h>
-#if __have_long32
-#define INT32_C(x) x##L
-#define UINT32_C(x) x##UL
-#else
-#define INT32_C(x) x
-#define UINT32_C(x) x##U
-#endif
+#define INT8_C(c) c
+#define INT16_C(c) c
+#define INT32_C(c) c
-#if __int64_t_defined
-#if __have_long64
-#define INT64_C(x) x##L
-#define UINT64_C(x) x##UL
-#else
-#define INT64_C(x) x##LL
-#define UINT64_C(x) x##ULL
-#endif
-#endif
+#define UINT8_C(c) c
+#define UINT16_C(c) c
+#define UINT32_C(c) c ## U
-/** Macros for greatest-width integer constant expression */
-#if __have_long64
-#define INTMAX_C(x) x##L
-#define UINTMAX_C(x) x##UL
+#if UINTPTR_MAX == UINT64_MAX
+#define INT64_C(c) c ## L
+#define UINT64_C(c) c ## UL
+#define INTMAX_C(c) c ## L
+#define UINTMAX_C(c) c ## UL
#else
-#define INTMAX_C(x) x##LL
-#define UINTMAX_C(x) x##ULL
+#define INT64_C(c) c ## LL
+#define UINT64_C(c) c ## ULL
+#define INTMAX_C(c) c ## LL
+#define UINTMAX_C(c) c ## ULL
#endif
-
-#ifdef __cplusplus
-}
#endif
-
-#endif /* _STDINT_H */
diff --git a/system/include/libc/stdio.h b/system/include/libc/stdio.h
index 19e11039..cd60bb55 100644
--- a/system/include/libc/stdio.h
+++ b/system/include/libc/stdio.h
@@ -1,694 +1,199 @@
-/*
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley. The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * @(#)stdio.h 5.3 (Berkeley) 3/15/86
- */
-
-/*
- * NB: to fit things in six character monocase externals, the
- * stdio code uses the prefix `__s' for stdio objects, typically
- * followed by a three-character attempt at a mnemonic.
- */
-
-#ifndef _STDIO_H_
-#define _STDIO_H_
-
-#include "_ansi.h"
-
-#define _FSTDIO /* ``function stdio'' */
-
-#define __need_size_t
-#include <stddef.h>
-
-#define __need___va_list
-#include <stdarg.h>
-
-/*
- * <sys/reent.h> defines __FILE, _fpos_t.
- * They must be defined there because struct _reent needs them (and we don't
- * want reent.h to include this file.
- */
-
-#include <sys/reent.h>
-#include <sys/types.h>
-
-_BEGIN_STD_C
-
-typedef __FILE FILE;
-
-#ifdef __CYGWIN__
-typedef _fpos64_t fpos_t;
-#else
-typedef _fpos_t fpos_t;
-#ifdef __LARGE64_FILES
-typedef _fpos64_t fpos64_t;
-#endif
-#endif /* !__CYGWIN__ */
-
-#include <sys/stdio.h>
-
-#define __SLBF 0x0001 /* line buffered */
-#define __SNBF 0x0002 /* unbuffered */
-#define __SRD 0x0004 /* OK to read */
-#define __SWR 0x0008 /* OK to write */
- /* RD and WR are never simultaneously asserted */
-#define __SRW 0x0010 /* open for reading & writing */
-#define __SEOF 0x0020 /* found EOF */
-#define __SERR 0x0040 /* found error */
-#define __SMBF 0x0080 /* _buf is from malloc */
-#define __SAPP 0x0100 /* fdopen()ed in append mode - so must write to end */
-#define __SSTR 0x0200 /* this is an sprintf/snprintf string */
-#define __SOPT 0x0400 /* do fseek() optimisation */
-#define __SNPT 0x0800 /* do not do fseek() optimisation */
-#define __SOFF 0x1000 /* set iff _offset is in fact correct */
-#define __SORD 0x2000 /* true => stream orientation (byte/wide) decided */
-#if defined(__CYGWIN__)
-# define __SCLE 0x4000 /* convert line endings CR/LF <-> NL */
-#endif
-#define __SL64 0x8000 /* is 64-bit offset large file */
-
-/* _flags2 flags */
-#define __SWID 0x2000 /* true => stream orientation wide, false => byte, only valid if __SORD in _flags is true */
-
-/*
- * The following three definitions are for ANSI C, which took them
- * from System V, which stupidly took internal interface macros and
- * made them official arguments to setvbuf(), without renaming them.
- * Hence, these ugly _IOxxx names are *supposed* to appear in user code.
- *
- * Although these happen to match their counterparts above, the
- * implementation does not rely on that (so these could be renumbered).
- */
-#define _IOFBF 0 /* setvbuf should set fully buffered */
-#define _IOLBF 1 /* setvbuf should set line buffered */
-#define _IONBF 2 /* setvbuf should set unbuffered */
-
-#ifndef NULL
-#define NULL 0
-#endif
-
-#define EOF (-1)
-
-#ifdef __BUFSIZ__
-#define BUFSIZ __BUFSIZ__
-#else
-#define BUFSIZ 1024
-#endif
+#ifndef _STDIO_H
+#define _STDIO_H
-#ifdef __FOPEN_MAX__
-#define FOPEN_MAX __FOPEN_MAX__
-#else
-#define FOPEN_MAX 20
+#ifdef __cplusplus
+extern "C" {
#endif
-#ifdef __FILENAME_MAX__
-#define FILENAME_MAX __FILENAME_MAX__
-#else
-#define FILENAME_MAX 1024
-#endif
+#include <features.h>
-#ifdef __L_tmpnam__
-#define L_tmpnam __L_tmpnam__
-#else
-#define L_tmpnam FILENAME_MAX
-#endif
-
-#ifndef __STRICT_ANSI__
-#define P_tmpdir "/tmp"
-#endif
+#define __NEED_FILE
+#define __NEED___isoc_va_list
+#define __NEED_size_t
-#ifndef SEEK_SET
-#define SEEK_SET 0 /* set file offset to offset */
-#endif
-#ifndef SEEK_CUR
-#define SEEK_CUR 1 /* set file offset to current plus offset */
-#endif
-#ifndef SEEK_END
-#define SEEK_END 2 /* set file offset to EOF plus offset */
+#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
+ || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
+ || defined(_BSD_SOURCE)
+#define __NEED_ssize_t
+#define __NEED_off_t
+#define __NEED_va_list
#endif
-#define TMP_MAX 26
-
-#if 0 /* XXX Emscripten: do not use impure stuff for std*, it makes comparing to native builds harder */
-#ifndef _REENT_ONLY
-#define stdin (_REENT->_stdin)
-#define stdout (_REENT->_stdout)
-#define stderr (_REENT->_stderr)
-#else /* _REENT_ONLY */
-#define stdin (_impure_ptr->_stdin)
-#define stdout (_impure_ptr->_stdout)
-#define stderr (_impure_ptr->_stderr)
-#endif /* _REENT_ONLY */
-#else
-extern FILE *stdin;
-extern FILE *stdout;
-extern FILE *stderr;
-#define stdin stdin
-#define stdout stdout
-#define stderr stderr
-#endif
+#include <bits/alltypes.h>
-#define _stdin_r(x) ((x)->_stdin)
-#define _stdout_r(x) ((x)->_stdout)
-#define _stderr_r(x) ((x)->_stderr)
+#define NULL 0L
-/*
- * Functions defined in ANSI C standard.
- */
+#undef EOF
+#define EOF (-1)
-#ifndef __VALIST
-#ifdef __GNUC__
-#define __VALIST __gnuc_va_list
-#else
-#define __VALIST char*
-#endif
-#endif
+#undef SEEK_SET
+#undef SEEK_CUR
+#undef SEEK_END
+#define SEEK_SET 0
+#define SEEK_CUR 1
+#define SEEK_END 2
-FILE * _EXFUN(tmpfile, (void));
-char * _EXFUN(tmpnam, (char *));
-int _EXFUN(fclose, (FILE *));
-int _EXFUN(fflush, (FILE *));
-FILE * _EXFUN(freopen, (const char *, const char *, FILE *));
-void _EXFUN(setbuf, (FILE *, char *));
-int _EXFUN(setvbuf, (FILE *, char *, int, size_t));
-int _EXFUN(fprintf, (FILE *, const char *, ...)
- _ATTRIBUTE (__format__ (__printf__, 2, 3)));
-int _EXFUN(fscanf, (FILE *, const char *, ...)
- _ATTRIBUTE (__format__ (__scanf__, 2, 3)));
-int _EXFUN(printf, (const char *, ...)
- _ATTRIBUTE (__format__ (__printf__, 1, 2)));
-int _EXFUN(scanf, (const char *, ...)
- _ATTRIBUTE (__format__ (__scanf__, 1, 2)));
-int _EXFUN(sscanf, (const char *, const char *, ...)
- _ATTRIBUTE (__format__ (__scanf__, 2, 3)));
-int _EXFUN(vfprintf, (FILE *, const char *, __VALIST)
- _ATTRIBUTE (__format__ (__printf__, 2, 0)));
-int _EXFUN(vprintf, (const char *, __VALIST)
- _ATTRIBUTE (__format__ (__printf__, 1, 0)));
-int _EXFUN(vsprintf, (char *, const char *, __VALIST)
- _ATTRIBUTE (__format__ (__printf__, 2, 0)));
-int _EXFUN(fgetc, (FILE *));
-char * _EXFUN(fgets, (char *, int, FILE *));
-int _EXFUN(fputc, (int, FILE *));
-int _EXFUN(fputs, (const char *, FILE *));
-int _EXFUN(getc, (FILE *));
-int _EXFUN(getchar, (void));
-char * _EXFUN(gets, (char *));
-int _EXFUN(putc, (int, FILE *));
-int _EXFUN(putchar, (int));
-int _EXFUN(puts, (const char *));
-int _EXFUN(ungetc, (int, FILE *));
-size_t _EXFUN(fread, (_PTR, size_t _size, size_t _n, FILE *));
-size_t _EXFUN(fwrite, (const _PTR , size_t _size, size_t _n, FILE *));
-#ifdef _COMPILING_NEWLIB
-int _EXFUN(fgetpos, (FILE *, _fpos_t *));
-#else
-int _EXFUN(fgetpos, (FILE *, fpos_t *));
-#endif
-int _EXFUN(fseek, (FILE *, long, int));
-#ifdef _COMPILING_NEWLIB
-int _EXFUN(fsetpos, (FILE *, const _fpos_t *));
-#else
-int _EXFUN(fsetpos, (FILE *, const fpos_t *));
-#endif
-long _EXFUN(ftell, ( FILE *));
-void _EXFUN(rewind, (FILE *));
-void _EXFUN(clearerr, (FILE *));
-int _EXFUN(feof, (FILE *));
-int _EXFUN(ferror, (FILE *));
-void _EXFUN(perror, (const char *));
-#ifndef _REENT_ONLY
-FILE * _EXFUN(fopen, (const char *_name, const char *_type));
-int _EXFUN(sprintf, (char *, const char *, ...)
- _ATTRIBUTE (__format__ (__printf__, 2, 3)));
-int _EXFUN(remove, (const char *));
-int _EXFUN(rename, (const char *, const char *));
-#endif
-#if !defined(__STRICT_ANSI__) || defined(__USE_XOPEN2K)
-#ifdef _COMPILING_NEWLIB
-int _EXFUN(fseeko, (FILE *, _off_t, int));
-_off_t _EXFUN(ftello, ( FILE *));
-#else
-int _EXFUN(fseeko, (FILE *, off_t, int));
-off_t _EXFUN(ftello, ( FILE *));
-#endif
-#endif
-#if !defined(__STRICT_ANSI__) || (__STDC_VERSION__ >= 199901L)
-#ifndef _REENT_ONLY
-int _EXFUN(asiprintf, (char **, const char *, ...)
- _ATTRIBUTE (__format__ (__printf__, 2, 3)));
-char * _EXFUN(asniprintf, (char *, size_t *, const char *, ...)
- _ATTRIBUTE (__format__ (__printf__, 3, 4)));
-char * _EXFUN(asnprintf, (char *, size_t *, const char *, ...)
- _ATTRIBUTE (__format__ (__printf__, 3, 4)));
-int _EXFUN(asprintf, (char **, const char *, ...)
- _ATTRIBUTE (__format__ (__printf__, 2, 3)));
-#ifndef diprintf
-int _EXFUN(diprintf, (int, const char *, ...)
- _ATTRIBUTE (__format__ (__printf__, 2, 3)));
-#endif
-int _EXFUN(fcloseall, (_VOID));
-int _EXFUN(fiprintf, (FILE *, const char *, ...)
- _ATTRIBUTE (__format__ (__printf__, 2, 3)));
-int _EXFUN(fiscanf, (FILE *, const char *, ...)
- _ATTRIBUTE (__format__ (__scanf__, 2, 3)));
-int _EXFUN(iprintf, (const char *, ...)
- _ATTRIBUTE (__format__ (__printf__, 1, 2)));
-int _EXFUN(iscanf, (const char *, ...)
- _ATTRIBUTE (__format__ (__scanf__, 1, 2)));
-int _EXFUN(siprintf, (char *, const char *, ...)
- _ATTRIBUTE (__format__ (__printf__, 2, 3)));
-int _EXFUN(siscanf, (const char *, const char *, ...)
- _ATTRIBUTE (__format__ (__scanf__, 2, 3)));
-int _EXFUN(snprintf, (char *, size_t, const char *, ...)
- _ATTRIBUTE (__format__ (__printf__, 3, 4)));
-int _EXFUN(sniprintf, (char *, size_t, const char *, ...)
- _ATTRIBUTE (__format__ (__printf__, 3, 4)));
-char * _EXFUN(tempnam, (const char *, const char *));
-int _EXFUN(vasiprintf, (char **, const char *, __VALIST)
- _ATTRIBUTE (__format__ (__printf__, 2, 0)));
-char * _EXFUN(vasniprintf, (char *, size_t *, const char *, __VALIST)
- _ATTRIBUTE (__format__ (__printf__, 3, 0)));
-char * _EXFUN(vasnprintf, (char *, size_t *, const char *, __VALIST)
- _ATTRIBUTE (__format__ (__printf__, 3, 0)));
-int _EXFUN(vasprintf, (char **, const char *, __VALIST)
- _ATTRIBUTE (__format__ (__printf__, 2, 0)));
-int _EXFUN(vdiprintf, (int, const char *, __VALIST)
- _ATTRIBUTE (__format__ (__printf__, 2, 0)));
-int _EXFUN(vfiprintf, (FILE *, const char *, __VALIST)
- _ATTRIBUTE (__format__ (__printf__, 2, 0)));
-int _EXFUN(vfiscanf, (FILE *, const char *, __VALIST)
- _ATTRIBUTE (__format__ (__scanf__, 2, 0)));
-int _EXFUN(vfscanf, (FILE *, const char *, __VALIST)
- _ATTRIBUTE (__format__ (__scanf__, 2, 0)));
-int _EXFUN(viprintf, (const char *, __VALIST)
- _ATTRIBUTE (__format__ (__printf__, 1, 0)));
-int _EXFUN(viscanf, (const char *, __VALIST)
- _ATTRIBUTE (__format__ (__scanf__, 1, 0)));
-int _EXFUN(vscanf, (const char *, __VALIST)
- _ATTRIBUTE (__format__ (__scanf__, 1, 0)));
-int _EXFUN(vsiprintf, (char *, const char *, __VALIST)
- _ATTRIBUTE (__format__ (__printf__, 2, 0)));
-int _EXFUN(vsiscanf, (const char *, const char *, __VALIST)
- _ATTRIBUTE (__format__ (__scanf__, 2, 0)));
-int _EXFUN(vsniprintf, (char *, size_t, const char *, __VALIST)
- _ATTRIBUTE (__format__ (__printf__, 3, 0)));
-int _EXFUN(vsnprintf, (char *, size_t, const char *, __VALIST)
- _ATTRIBUTE (__format__ (__printf__, 3, 0)));
-int _EXFUN(vsscanf, (const char *, const char *, __VALIST)
- _ATTRIBUTE (__format__ (__scanf__, 2, 0)));
-#endif /* !_REENT_ONLY */
-#endif /* !__STRICT_ANSI__ */
-
-/*
- * Routines in POSIX 1003.1:2001.
- */
-
-#ifndef __STRICT_ANSI__
-#ifndef _REENT_ONLY
-FILE * _EXFUN(fdopen, (int, const char *));
-#endif
-int _EXFUN(fileno, (FILE *));
-int _EXFUN(getw, (FILE *));
-int _EXFUN(pclose, (FILE *));
-FILE * _EXFUN(popen, (const char *, const char *));
-int _EXFUN(putw, (int, FILE *));
-void _EXFUN(setbuffer, (FILE *, char *, int));
-int _EXFUN(setlinebuf, (FILE *));
-int _EXFUN(getc_unlocked, (FILE *));
-int _EXFUN(getchar_unlocked, (void));
-void _EXFUN(flockfile, (FILE *));
-int _EXFUN(ftrylockfile, (FILE *));
-void _EXFUN(funlockfile, (FILE *));
-int _EXFUN(putc_unlocked, (int, FILE *));
-int _EXFUN(putchar_unlocked, (int));
-#endif /* ! __STRICT_ANSI__ */
-
-/*
- * Routines in POSIX 1003.1:200x.
- */
-
-#ifndef __STRICT_ANSI__
-# ifndef _REENT_ONLY
-# ifndef dprintf
-int _EXFUN(dprintf, (int, const char *, ...)
- _ATTRIBUTE (__format__ (__printf__, 2, 3)));
-# endif
-FILE * _EXFUN(fmemopen, (void *, size_t, const char *));
-/* getdelim - see __getdelim for now */
-/* getline - see __getline for now */
-FILE * _EXFUN(open_memstream, (char **, size_t *));
-#if defined (__CYGWIN__)
-int _EXFUN(renameat, (int, const char *, int, const char *));
-#endif
-int _EXFUN(vdprintf, (int, const char *, __VALIST)
- _ATTRIBUTE (__format__ (__printf__, 2, 0)));
-# endif
-#endif
-
-/*
- * Recursive versions of the above.
- */
-
-int _EXFUN(_asiprintf_r, (struct _reent *, char **, const char *, ...)
- _ATTRIBUTE (__format__ (__printf__, 3, 4)));
-char * _EXFUN(_asniprintf_r, (struct _reent *, char *, size_t *, const char *, ...)
- _ATTRIBUTE (__format__ (__printf__, 4, 5)));
-char * _EXFUN(_asnprintf_r, (struct _reent *, char *, size_t *, const char *, ...)
- _ATTRIBUTE (__format__ (__printf__, 4, 5)));
-int _EXFUN(_asprintf_r, (struct _reent *, char **, const char *, ...)
- _ATTRIBUTE (__format__ (__printf__, 3, 4)));
-int _EXFUN(_diprintf_r, (struct _reent *, int, const char *, ...)
- _ATTRIBUTE (__format__ (__printf__, 3, 4)));
-int _EXFUN(_dprintf_r, (struct _reent *, int, const char *, ...)
- _ATTRIBUTE (__format__ (__printf__, 3, 4)));
-int _EXFUN(_fclose_r, (struct _reent *, FILE *));
-int _EXFUN(_fcloseall_r, (struct _reent *));
-FILE * _EXFUN(_fdopen_r, (struct _reent *, int, const char *));
-int _EXFUN(_fflush_r, (struct _reent *, FILE *));
-int _EXFUN(_fgetc_r, (struct _reent *, FILE *));
-char * _EXFUN(_fgets_r, (struct _reent *, char *, int, FILE *));
-#ifdef _COMPILING_NEWLIB
-int _EXFUN(_fgetpos_r, (struct _reent *, FILE *, _fpos_t *));
-int _EXFUN(_fsetpos_r, (struct _reent *, FILE *, const _fpos_t *));
-#else
-int _EXFUN(_fgetpos_r, (struct _reent *, FILE *, fpos_t *));
-int _EXFUN(_fsetpos_r, (struct _reent *, FILE *, const fpos_t *));
-#endif
-int _EXFUN(_fiprintf_r, (struct _reent *, FILE *, const char *, ...)
- _ATTRIBUTE (__format__ (__printf__, 3, 4)));
-int _EXFUN(_fiscanf_r, (struct _reent *, FILE *, const char *, ...)
- _ATTRIBUTE (__format__ (__scanf__, 3, 4)));
-FILE * _EXFUN(_fmemopen_r, (struct _reent *, void *, size_t, const char *));
-FILE * _EXFUN(_fopen_r, (struct _reent *, const char *, const char *));
-FILE * _EXFUN(_freopen_r, (struct _reent *, const char *, const char *, FILE *));
-int _EXFUN(_fprintf_r, (struct _reent *, FILE *, const char *, ...)
- _ATTRIBUTE (__format__ (__printf__, 3, 4)));
-int _EXFUN(_fpurge_r, (struct _reent *, FILE *));
-int _EXFUN(_fputc_r, (struct _reent *, int, FILE *));
-int _EXFUN(_fputs_r, (struct _reent *, const char *, FILE *));
-size_t _EXFUN(_fread_r, (struct _reent *, _PTR, size_t _size, size_t _n, FILE *));
-int _EXFUN(_fscanf_r, (struct _reent *, FILE *, const char *, ...)
- _ATTRIBUTE (__format__ (__scanf__, 3, 4)));
-int _EXFUN(_fseek_r, (struct _reent *, FILE *, long, int));
-int _EXFUN(_fseeko_r,(struct _reent *, FILE *, _off_t, int));
-long _EXFUN(_ftell_r, (struct _reent *, FILE *));
-_off_t _EXFUN(_ftello_r,(struct _reent *, FILE *));
-void _EXFUN(_rewind_r, (struct _reent *, FILE *));
-size_t _EXFUN(_fwrite_r, (struct _reent *, const _PTR , size_t _size, size_t _n, FILE *));
-int _EXFUN(_getc_r, (struct _reent *, FILE *));
-int _EXFUN(_getc_unlocked_r, (struct _reent *, FILE *));
-int _EXFUN(_getchar_r, (struct _reent *));
-int _EXFUN(_getchar_unlocked_r, (struct _reent *));
-char * _EXFUN(_gets_r, (struct _reent *, char *));
-int _EXFUN(_iprintf_r, (struct _reent *, const char *, ...)
- _ATTRIBUTE (__format__ (__printf__, 2, 3)));
-int _EXFUN(_iscanf_r, (struct _reent *, const char *, ...)
- _ATTRIBUTE (__format__ (__scanf__, 2, 3)));
-FILE * _EXFUN(_open_memstream_r, (struct _reent *, char **, size_t *));
-void _EXFUN(_perror_r, (struct _reent *, const char *));
-int _EXFUN(_printf_r, (struct _reent *, const char *, ...)
- _ATTRIBUTE (__format__ (__printf__, 2, 3)));
-int _EXFUN(_putc_r, (struct _reent *, int, FILE *));
-int _EXFUN(_putc_unlocked_r, (struct _reent *, int, FILE *));
-int _EXFUN(_putchar_unlocked_r, (struct _reent *, int));
-int _EXFUN(_putchar_r, (struct _reent *, int));
-int _EXFUN(_puts_r, (struct _reent *, const char *));
-int _EXFUN(_remove_r, (struct _reent *, const char *));
-int _EXFUN(_rename_r, (struct _reent *,
- const char *_old, const char *_new));
-int _EXFUN(_scanf_r, (struct _reent *, const char *, ...)
- _ATTRIBUTE (__format__ (__scanf__, 2, 3)));
-int _EXFUN(_siprintf_r, (struct _reent *, char *, const char *, ...)
- _ATTRIBUTE (__format__ (__printf__, 3, 4)));
-int _EXFUN(_siscanf_r, (struct _reent *, const char *, const char *, ...)
- _ATTRIBUTE (__format__ (__scanf__, 3, 4)));
-int _EXFUN(_sniprintf_r, (struct _reent *, char *, size_t, const char *, ...)
- _ATTRIBUTE (__format__ (__printf__, 4, 5)));
-int _EXFUN(_snprintf_r, (struct _reent *, char *, size_t, const char *, ...)
- _ATTRIBUTE (__format__ (__printf__, 4, 5)));
-int _EXFUN(_sprintf_r, (struct _reent *, char *, const char *, ...)
- _ATTRIBUTE (__format__ (__printf__, 3, 4)));
-int _EXFUN(_sscanf_r, (struct _reent *, const char *, const char *, ...)
- _ATTRIBUTE (__format__ (__scanf__, 3, 4)));
-char * _EXFUN(_tempnam_r, (struct _reent *, const char *, const char *));
-FILE * _EXFUN(_tmpfile_r, (struct _reent *));
-char * _EXFUN(_tmpnam_r, (struct _reent *, char *));
-int _EXFUN(_ungetc_r, (struct _reent *, int, FILE *));
-int _EXFUN(_vasiprintf_r, (struct _reent *, char **, const char *, __VALIST)
- _ATTRIBUTE (__format__ (__printf__, 3, 0)));
-char * _EXFUN(_vasniprintf_r, (struct _reent*, char *, size_t *, const char *, __VALIST)
- _ATTRIBUTE (__format__ (__printf__, 4, 0)));
-char * _EXFUN(_vasnprintf_r, (struct _reent*, char *, size_t *, const char *, __VALIST)
- _ATTRIBUTE (__format__ (__printf__, 4, 0)));
-int _EXFUN(_vasprintf_r, (struct _reent *, char **, const char *, __VALIST)
- _ATTRIBUTE (__format__ (__printf__, 3, 0)));
-int _EXFUN(_vdiprintf_r, (struct _reent *, int, const char *, __VALIST)
- _ATTRIBUTE (__format__ (__printf__, 3, 0)));
-int _EXFUN(_vdprintf_r, (struct _reent *, int, const char *, __VALIST)
- _ATTRIBUTE (__format__ (__printf__, 3, 0)));
-int _EXFUN(_vfiprintf_r, (struct _reent *, FILE *, const char *, __VALIST)
- _ATTRIBUTE (__format__ (__printf__, 3, 0)));
-int _EXFUN(_vfiscanf_r, (struct _reent *, FILE *, const char *, __VALIST)
- _ATTRIBUTE (__format__ (__scanf__, 3, 0)));
-int _EXFUN(_vfprintf_r, (struct _reent *, FILE *, const char *, __VALIST)
- _ATTRIBUTE (__format__ (__printf__, 3, 0)));
-int _EXFUN(_vfscanf_r, (struct _reent *, FILE *, const char *, __VALIST)
- _ATTRIBUTE (__format__ (__scanf__, 3, 0)));
-int _EXFUN(_viprintf_r, (struct _reent *, const char *, __VALIST)
- _ATTRIBUTE (__format__ (__printf__, 2, 0)));
-int _EXFUN(_viscanf_r, (struct _reent *, const char *, __VALIST)
- _ATTRIBUTE (__format__ (__scanf__, 2, 0)));
-int _EXFUN(_vprintf_r, (struct _reent *, const char *, __VALIST)
- _ATTRIBUTE (__format__ (__printf__, 2, 0)));
-int _EXFUN(_vscanf_r, (struct _reent *, const char *, __VALIST)
- _ATTRIBUTE (__format__ (__scanf__, 2, 0)));
-int _EXFUN(_vsiprintf_r, (struct _reent *, char *, const char *, __VALIST)
- _ATTRIBUTE (__format__ (__printf__, 3, 0)));
-int _EXFUN(_vsiscanf_r, (struct _reent *, const char *, const char *, __VALIST)
- _ATTRIBUTE (__format__ (__scanf__, 3, 0)));
-int _EXFUN(_vsniprintf_r, (struct _reent *, char *, size_t, const char *, __VALIST)
- _ATTRIBUTE (__format__ (__printf__, 4, 0)));
-int _EXFUN(_vsnprintf_r, (struct _reent *, char *, size_t, const char *, __VALIST)
- _ATTRIBUTE (__format__ (__printf__, 4, 0)));
-int _EXFUN(_vsprintf_r, (struct _reent *, char *, const char *, __VALIST)
- _ATTRIBUTE (__format__ (__printf__, 3, 0)));
-int _EXFUN(_vsscanf_r, (struct _reent *, const char *, const char *, __VALIST)
- _ATTRIBUTE (__format__ (__scanf__, 3, 0)));
-
-/* Other extensions. */
-
-int _EXFUN(fpurge, (FILE *));
-ssize_t _EXFUN(__getdelim, (char **, size_t *, int, FILE *));
-ssize_t _EXFUN(__getline, (char **, size_t *, FILE *));
-
-#ifdef __LARGE64_FILES
-#if !defined(__CYGWIN__) || defined(_COMPILING_NEWLIB)
-FILE * _EXFUN(fdopen64, (int, const char *));
-FILE * _EXFUN(fopen64, (const char *, const char *));
-FILE * _EXFUN(freopen64, (_CONST char *, _CONST char *, FILE *));
-_off64_t _EXFUN(ftello64, (FILE *));
-_off64_t _EXFUN(fseeko64, (FILE *, _off64_t, int));
-int _EXFUN(fgetpos64, (FILE *, _fpos64_t *));
-int _EXFUN(fsetpos64, (FILE *, const _fpos64_t *));
-FILE * _EXFUN(tmpfile64, (void));
-
-FILE * _EXFUN(_fdopen64_r, (struct _reent *, int, const char *));
-FILE * _EXFUN(_fopen64_r, (struct _reent *,const char *, const char *));
-FILE * _EXFUN(_freopen64_r, (struct _reent *, _CONST char *, _CONST char *, FILE *));
-_off64_t _EXFUN(_ftello64_r, (struct _reent *, FILE *));
-_off64_t _EXFUN(_fseeko64_r, (struct _reent *, FILE *, _off64_t, int));
-int _EXFUN(_fgetpos64_r, (struct _reent *, FILE *, _fpos64_t *));
-int _EXFUN(_fsetpos64_r, (struct _reent *, FILE *, const _fpos64_t *));
-FILE * _EXFUN(_tmpfile64_r, (struct _reent *));
-#endif /* !__CYGWIN__ */
-#endif /* __LARGE64_FILES */
-
-/*
- * Routines internal to the implementation.
- */
-
-int _EXFUN(__srget_r, (struct _reent *, FILE *));
-int _EXFUN(__swbuf_r, (struct _reent *, int, FILE *));
-
-/*
- * Stdio function-access interface.
- */
-
-#ifndef __STRICT_ANSI__
-# ifdef __LARGE64_FILES
-FILE *_EXFUN(funopen,(const _PTR __cookie,
- int (*__readfn)(_PTR __c, char *__buf, int __n),
- int (*__writefn)(_PTR __c, const char *__buf, int __n),
- _fpos64_t (*__seekfn)(_PTR __c, _fpos64_t __off, int __whence),
- int (*__closefn)(_PTR __c)));
-FILE *_EXFUN(_funopen_r,(struct _reent *, const _PTR __cookie,
- int (*__readfn)(_PTR __c, char *__buf, int __n),
- int (*__writefn)(_PTR __c, const char *__buf, int __n),
- _fpos64_t (*__seekfn)(_PTR __c, _fpos64_t __off, int __whence),
- int (*__closefn)(_PTR __c)));
-# else
-FILE *_EXFUN(funopen,(const _PTR __cookie,
- int (*__readfn)(_PTR __cookie, char *__buf, int __n),
- int (*__writefn)(_PTR __cookie, const char *__buf, int __n),
- fpos_t (*__seekfn)(_PTR __cookie, fpos_t __off, int __whence),
- int (*__closefn)(_PTR __cookie)));
-FILE *_EXFUN(_funopen_r,(struct _reent *, const _PTR __cookie,
- int (*__readfn)(_PTR __cookie, char *__buf, int __n),
- int (*__writefn)(_PTR __cookie, const char *__buf, int __n),
- fpos_t (*__seekfn)(_PTR __cookie, fpos_t __off, int __whence),
- int (*__closefn)(_PTR __cookie)));
-# endif /* !__LARGE64_FILES */
-
-# define fropen(__cookie, __fn) funopen(__cookie, __fn, (int (*)())0, \
- (fpos_t (*)())0, (int (*)())0)
-# define fwopen(__cookie, __fn) funopen(__cookie, (int (*)())0, __fn, \
- (fpos_t (*)())0, (int (*)())0)
-
-typedef ssize_t cookie_read_function_t(void *__cookie, char *__buf, size_t __n);
-typedef ssize_t cookie_write_function_t(void *__cookie, const char *__buf,
- size_t __n);
-# ifdef __LARGE64_FILES
-typedef int cookie_seek_function_t(void *__cookie, _off64_t *__off,
- int __whence);
-# else
-typedef int cookie_seek_function_t(void *__cookie, off_t *__off, int __whence);
-# endif /* !__LARGE64_FILES */
-typedef int cookie_close_function_t(void *__cookie);
-typedef struct
-{
- /* These four struct member names are dictated by Linux; hopefully,
- they don't conflict with any macros. */
- cookie_read_function_t *read;
- cookie_write_function_t *write;
- cookie_seek_function_t *seek;
- cookie_close_function_t *close;
-} cookie_io_functions_t;
-FILE *_EXFUN(fopencookie,(void *__cookie,
- const char *__mode, cookie_io_functions_t __functions));
-FILE *_EXFUN(_fopencookie_r,(struct _reent *, void *__cookie,
- const char *__mode, cookie_io_functions_t __functions));
-#endif /* ! __STRICT_ANSI__ */
-
-#ifndef __CUSTOM_FILE_IO__
-/*
- * The __sfoo macros are here so that we can
- * define function versions in the C library.
- */
-#define __sgetc_raw_r(__ptr, __f) (--(__f)->_r < 0 ? __srget_r(__ptr, __f) : (int)(*(__f)->_p++))
-
-#ifdef __SCLE
-/* For a platform with CR/LF, additional logic is required by
- __sgetc_r which would otherwise simply be a macro; therefore we
- use an inlined function. The function is only meant to be inlined
- in place as used and the function body should never be emitted.
-
- There are two possible means to this end when compiling with GCC,
- one when compiling with a standard C99 compiler, and for other
- compilers we're just stuck. At the moment, this issue only
- affects the Cygwin target, so we'll most likely be using GCC. */
-
-_ELIDABLE_INLINE int __sgetc_r(struct _reent *__ptr, FILE *__p);
-
-_ELIDABLE_INLINE int __sgetc_r(struct _reent *__ptr, FILE *__p)
- {
- int __c = __sgetc_raw_r(__ptr, __p);
- if ((__p->_flags & __SCLE) && (__c == '\r'))
- {
- int __c2 = __sgetc_raw_r(__ptr, __p);
- if (__c2 == '\n')
- __c = __c2;
- else
- ungetc(__c2, __p);
- }
- return __c;
- }
-#else
-#define __sgetc_r(__ptr, __p) __sgetc_raw_r(__ptr, __p)
-#endif
-
-#ifdef _never /* __GNUC__ */
-/* If this inline is actually used, then systems using coff debugging
- info get hopelessly confused. 21sept93 rich@cygnus.com. */
-_ELIDABLE_INLINE int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) {
- if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n'))
- return (*_p->_p++ = _c);
- else
- return (__swbuf_r(_ptr, _c, _p));
+#define _IOFBF 0
+#define _IOLBF 1
+#define _IONBF 2
+
+#define BUFSIZ 1024
+#define FILENAME_MAX 4096
+#define FOPEN_MAX 1000
+#define TMP_MAX 10000
+#define L_tmpnam 20
+
+typedef union _G_fpos64_t {
+ char __opaque[16];
+ double __align;
+} fpos_t;
+
+extern FILE *const stdin;
+extern FILE *const stdout;
+extern FILE *const stderr;
+
+#define stdin (stdin)
+#define stdout (stdout)
+#define stderr (stderr)
+
+FILE *fopen(const char *__restrict, const char *__restrict);
+FILE *freopen(const char *__restrict, const char *__restrict, FILE *__restrict);
+int fclose(FILE *);
+
+int remove(const char *);
+int rename(const char *, const char *);
+
+int feof(FILE *);
+int ferror(FILE *);
+int fflush(FILE *);
+void clearerr(FILE *);
+
+int fseek(FILE *, long, int);
+long ftell(FILE *);
+void rewind(FILE *);
+
+int fgetpos(FILE *__restrict, fpos_t *__restrict);
+int fsetpos(FILE *, const fpos_t *);
+
+size_t fread(void *__restrict, size_t, size_t, FILE *__restrict);
+size_t fwrite(const void *__restrict, size_t, size_t, FILE *__restrict);
+
+int fgetc(FILE *);
+int getc(FILE *);
+int getchar(void);
+int ungetc(int, FILE *);
+
+int fputc(int, FILE *);
+int putc(int, FILE *);
+int putchar(int);
+
+char *fgets(char *__restrict, int, FILE *__restrict);
+#if __STDC_VERSION__ < 201112L
+char *gets(char *);
+#endif
+
+int fputs(const char *__restrict, FILE *__restrict);
+int puts(const char *);
+
+int printf(const char *__restrict, ...);
+int fprintf(FILE *__restrict, const char *__restrict, ...);
+int sprintf(char *__restrict, const char *__restrict, ...);
+int snprintf(char *__restrict, size_t, const char *__restrict, ...);
+
+int vprintf(const char *__restrict, __isoc_va_list);
+int vfprintf(FILE *__restrict, const char *__restrict, __isoc_va_list);
+int vsprintf(char *__restrict, const char *__restrict, __isoc_va_list);
+int vsnprintf(char *__restrict, size_t, const char *__restrict, __isoc_va_list);
+
+int scanf(const char *__restrict, ...);
+int fscanf(FILE *__restrict, const char *__restrict, ...);
+int sscanf(const char *__restrict, const char *__restrict, ...);
+int vscanf(const char *__restrict, __isoc_va_list);
+int vfscanf(FILE *__restrict, const char *__restrict, __isoc_va_list);
+int vsscanf(const char *__restrict, const char *__restrict, __isoc_va_list);
+
+void perror(const char *);
+
+int setvbuf(FILE *__restrict, char *__restrict, int, size_t);
+void setbuf(FILE *__restrict, char *__restrict);
+
+char *tmpnam(char *);
+FILE *tmpfile(void);
+
+#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
+ || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
+ || defined(_BSD_SOURCE)
+FILE *fmemopen(void *__restrict, size_t, const char *__restrict);
+FILE *open_memstream(char **, size_t *);
+FILE *fdopen(int, const char *);
+FILE *popen(const char *, const char *);
+int pclose(FILE *);
+int fileno(FILE *);
+int fseeko(FILE *, off_t, int);
+off_t ftello(FILE *);
+int dprintf(int, const char *__restrict, ...);
+int vdprintf(int, const char *__restrict, __isoc_va_list);
+void flockfile(FILE *);
+int ftrylockfile(FILE *);
+void funlockfile(FILE *);
+int getc_unlocked(FILE *);
+int getchar_unlocked(void);
+int putc_unlocked(int, FILE *);
+int putchar_unlocked(int);
+ssize_t getdelim(char **__restrict, size_t *__restrict, int, FILE *__restrict);
+ssize_t getline(char **__restrict, size_t *__restrict, FILE *__restrict);
+int renameat(int, const char *, int, const char *);
+char *ctermid(char *);
+#define L_ctermid 20
+#endif
+
+
+#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
+ || defined(_BSD_SOURCE)
+#define P_tmpdir "/tmp"
+char *tempnam(const char *, const char *);
+#endif
+
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+#define L_cuserid 20
+char *cuserid(char *);
+void setlinebuf(FILE *);
+void setbuffer(FILE *, char *, size_t);
+int fgetc_unlocked(FILE *);
+int fputc_unlocked(int, FILE *);
+int fflush_unlocked(FILE *);
+size_t fread_unlocked(void *, size_t, size_t, FILE *);
+size_t fwrite_unlocked(const void *, size_t, size_t, FILE *);
+void clearerr_unlocked(FILE *);
+int feof_unlocked(FILE *);
+int ferror_unlocked(FILE *);
+int fileno_unlocked(FILE *);
+int getw(FILE *);
+int putw(int, FILE *);
+char *fgetln(FILE *, size_t *);
+int asprintf(char **, const char *, ...);
+int vasprintf(char **, const char *, __isoc_va_list);
+#endif
+
+#ifdef _GNU_SOURCE
+char *fgets_unlocked(char *, int, FILE *);
+int fputs_unlocked(const char *, FILE *);
+#endif
+
+#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
+#define tmpfile64 tmpfile
+#define fopen64 fopen
+#define freopen64 freopen
+#define fseeko64 fseeko
+#define ftello64 ftello
+#define fgetpos64 fgetpos
+#define fsetpos64 fsetpos
+#define fpos64_t fpos_t
+#define off64_t off_t
+#endif
+
+#ifdef __cplusplus
}
-#else
-/*
- * This has been tuned to generate reasonable code on the vax using pcc
- */
-#define __sputc_raw_r(__ptr, __c, __p) \
- (--(__p)->_w < 0 ? \
- (__p)->_w >= (__p)->_lbfsize ? \
- (*(__p)->_p = (__c)), *(__p)->_p != '\n' ? \
- (int)*(__p)->_p++ : \
- __swbuf_r(__ptr, '\n', __p) : \
- __swbuf_r(__ptr, (int)(__c), __p) : \
- (*(__p)->_p = (__c), (int)*(__p)->_p++))
-#ifdef __SCLE
-#define __sputc_r(__ptr, __c, __p) \
- ((((__p)->_flags & __SCLE) && ((__c) == '\n')) \
- ? __sputc_raw_r(__ptr, '\r', (__p)) : 0 , \
- __sputc_raw_r((__ptr), (__c), (__p)))
-#else
-#define __sputc_r(__ptr, __c, __p) __sputc_raw_r(__ptr, __c, __p)
#endif
-#endif
-
-#define __sfeof(p) (((p)->_flags & __SEOF) != 0)
-#define __sferror(p) (((p)->_flags & __SERR) != 0)
-#define __sclearerr(p) ((void)((p)->_flags &= ~(__SERR|__SEOF)))
-#define __sfileno(p) ((p)->_file)
-#if 0 /* XXX Emscripten ndef _REENT_SMALL */
-#define feof(p) __sfeof(p)
-#define ferror(p) __sferror(p)
-#define clearerr(p) __sclearerr(p)
#endif
-
-#if 0 /*ndef __STRICT_ANSI__ - FIXME: must initialize stdio first, use fn */
-#define fileno(p) __sfileno(p)
-#endif
-
-#if !defined(__CYGWIN__) && !defined(EMSCRIPTEN)
-#ifndef lint
-#define getc(fp) __sgetc_r(_REENT, fp)
-#define putc(x, fp) __sputc_r(_REENT, x, fp)
-#endif /* lint */
-#endif /* __CYGWIN__ */
-
-#ifndef __STRICT_ANSI__
-/* fast always-buffered version, true iff error */
-#define fast_putc(x,p) (--(p)->_w < 0 ? \
- __swbuf_r(_REENT, (int)(x), p) == EOF : (*(p)->_p = (x), (p)->_p++, 0))
-
-#define L_cuserid 9 /* posix says it goes in stdio.h :( */
-#if defined(__CYGWIN__) || defined(EMSCRIPTEN)
-#define L_ctermid 16
-#endif
-#endif
-
-#endif /* !__CUSTOM_FILE_IO__ */
-
-#define getchar() getc(stdin)
-#define putchar(x) putc(x, stdout)
-
-_END_STD_C
-
-#endif /* _STDIO_H_ */
diff --git a/system/include/libc/stdio_ext.h b/system/include/libc/stdio_ext.h
new file mode 100644
index 00000000..e3ab7fd4
--- /dev/null
+++ b/system/include/libc/stdio_ext.h
@@ -0,0 +1,34 @@
+#ifndef _STDIO_EXT_H
+#define _STDIO_EXT_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdio.h>
+
+#define FSETLOCKING_QUERY 0
+#define FSETLOCKING_INTERNAL 1
+#define FSETLOCKING_BYCALLER 2
+
+void _flushlbf(void);
+int __fsetlocking(FILE *, int);
+int __fwriting(FILE *);
+int __freading(FILE *);
+int __freadable(FILE *);
+int __fwritable(FILE *);
+int __flbf(FILE *);
+size_t __fbufsize(FILE *);
+size_t __fpending(FILE *);
+int __fpurge(FILE *);
+
+size_t __freadahead(FILE *);
+const char *__freadptr(FILE *, size_t *);
+void __freadptrinc(FILE *, size_t);
+void __fseterr(FILE *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/stdlib.h b/system/include/libc/stdlib.h
index 6fdef40b..0bcc9f4f 100644
--- a/system/include/libc/stdlib.h
+++ b/system/include/libc/stdlib.h
@@ -1,228 +1,167 @@
-/*
- * stdlib.h
- *
- * Definitions for common types, variables, and functions.
- */
+#ifndef _STDLIB_H
+#define _STDLIB_H
-#ifndef _STDLIB_H_
-#define _STDLIB_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
-#include <machine/ieeefp.h>
-#include "_ansi.h"
+#include <features.h>
-#define __need_size_t
-#define __need_wchar_t
-#include <stddef.h>
+#define NULL 0L
-#include <sys/reent.h>
-#include <machine/stdlib.h>
-#ifndef __STRICT_ANSI__
-#include <alloca.h>
-#endif
+#define __NEED_size_t
+#define __NEED_wchar_t
-#ifdef __CYGWIN__
-#include <cygwin/stdlib.h>
-#endif
+#include <bits/alltypes.h>
-_BEGIN_STD_C
-
-typedef struct
-{
- int quot; /* quotient */
- int rem; /* remainder */
-} div_t;
-
-typedef struct
-{
- long quot; /* quotient */
- long rem; /* remainder */
-} ldiv_t;
-
-#if !defined(__STRICT_ANSI__) || defined(EMSCRIPTEN)
-typedef struct
-{
- long long int quot; /* quotient */
- long long int rem; /* remainder */
-} lldiv_t;
-#endif
+int atoi (const char *);
+long atol (const char *);
+long long atoll (const char *);
+double atof (const char *);
-#ifndef NULL
-#define NULL 0
-#endif
+float strtof (const char *__restrict, char **__restrict);
+double strtod (const char *__restrict, char **__restrict);
+long double strtold (const char *__restrict, char **__restrict);
+
+long strtol (const char *__restrict, char **__restrict, int);
+unsigned long strtoul (const char *__restrict, char **__restrict, int);
+long long strtoll (const char *__restrict, char **__restrict, int);
+unsigned long long strtoull (const char *__restrict, char **__restrict, int);
+
+int rand (void);
+void srand (unsigned);
+
+void *malloc (size_t);
+void *calloc (size_t, size_t);
+void *realloc (void *, size_t);
+void free (void *);
+void *aligned_alloc(size_t alignment, size_t size);
+
+_Noreturn void abort (void);
+int atexit (void (*) (void));
+_Noreturn void exit (int);
+_Noreturn void _Exit (int);
+int at_quick_exit (void (*) (void));
+_Noreturn void quick_exit (int);
+
+char *getenv (const char *);
+
+int system (const char *);
+
+void *bsearch (const void *, const void *, size_t, size_t, int (*)(const void *, const void *));
+void qsort (void *, size_t, size_t, int (*)(const void *, const void *));
+
+int abs (int);
+long labs (long);
+long long llabs (long long);
+
+typedef struct { int quot, rem; } div_t;
+typedef struct { long quot, rem; } ldiv_t;
+typedef struct { long long quot, rem; } lldiv_t;
+
+div_t div (int, int);
+ldiv_t ldiv (long, long);
+lldiv_t lldiv (long long, long long);
+
+int mblen (const char *, size_t);
+int mbtowc (wchar_t *__restrict, const char *__restrict, size_t);
+int wctomb (char *, wchar_t);
+size_t mbstowcs (wchar_t *__restrict, const char *__restrict, size_t);
+size_t wcstombs (char *__restrict, const wchar_t *__restrict, size_t);
#define EXIT_FAILURE 1
#define EXIT_SUCCESS 0
-#define RAND_MAX __RAND_MAX
+#define MB_CUR_MAX ((size_t)+4)
-int _EXFUN(__locale_mb_cur_max,(_VOID));
+#define RAND_MAX (0x7fffffff)
-#define MB_CUR_MAX __locale_mb_cur_max()
-_VOID _EXFUN(abort,(_VOID) _ATTRIBUTE(noreturn));
-int _EXFUN(abs,(int));
-int _EXFUN(atexit,(_VOID (*__func)(_VOID)));
-double _EXFUN(atof,(const char *__nptr));
-#ifndef __STRICT_ANSI__
-float _EXFUN(atoff,(const char *__nptr));
+#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
+ || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
+ || defined(_BSD_SOURCE)
+
+#define WNOHANG 1
+#define WUNTRACED 2
+
+#define WEXITSTATUS(s) (((s) & 0xff00) >> 8)
+#define WTERMSIG(s) ((s) & 0x7f)
+#define WSTOPSIG(s) WEXITSTATUS(s)
+#define WIFEXITED(s) (!WTERMSIG(s))
+#define WIFSTOPPED(s) (((s) & 0xff) == 0x7f)
+#define WIFSIGNALED(s) (((signed char) (((s) & 0x7f) + 1) >> 1) > 0)
+
+int posix_memalign (void **, size_t, size_t);
+int setenv (const char *, const char *, int);
+int unsetenv (const char *);
+int mkstemp (char *);
+int mkostemp (char *, int);
+char *mkdtemp (char *);
+int getsubopt (char **, char *const *, char **);
+int rand_r (unsigned *);
+
#endif
-int _EXFUN(atoi,(const char *__nptr));
-int _EXFUN(_atoi_r,(struct _reent *, const char *__nptr));
-long _EXFUN(atol,(const char *__nptr));
-long _EXFUN(_atol_r,(struct _reent *, const char *__nptr));
-_PTR _EXFUN(bsearch,(const _PTR __key,
- const _PTR __base,
- size_t __nmemb,
- size_t __size,
- int _EXFNPTR(_compar,(const _PTR, const _PTR))));
-_PTR _EXFUN_NOTHROW(calloc,(size_t __nmemb, size_t __size));
-div_t _EXFUN(div,(int __numer, int __denom));
-_VOID _EXFUN(exit,(int __status) _ATTRIBUTE(noreturn));
-_VOID _EXFUN_NOTHROW(free,(_PTR));
-char * _EXFUN(getenv,(const char *__string));
-char * _EXFUN(_getenv_r,(struct _reent *, const char *__string));
-char * _EXFUN(_findenv,(_CONST char *, int *));
-char * _EXFUN(_findenv_r,(struct _reent *, _CONST char *, int *));
-#ifndef __STRICT_ANSI__
-extern char *suboptarg; /* getsubopt(3) external variable */
-int _EXFUN(getsubopt,(char **, char * const *, char **));
+
+
+#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
+ || defined(_BSD_SOURCE)
+char *realpath (const char *__restrict, char *__restrict);
+long int random (void);
+void srandom (unsigned int);
+char *initstate (unsigned int, char *, size_t);
+char *setstate (char *);
#endif
-long _EXFUN(labs,(long));
-ldiv_t _EXFUN(ldiv,(long __numer, long __denom));
-_PTR _EXFUN_NOTHROW(malloc,(size_t __size));
-int _EXFUN(mblen,(const char *, size_t));
-int _EXFUN(_mblen_r,(struct _reent *, const char *, size_t, _mbstate_t *));
-int _EXFUN(mbtowc,(wchar_t *, const char *, size_t));
-int _EXFUN(_mbtowc_r,(struct _reent *, wchar_t *, const char *, size_t, _mbstate_t *));
-int _EXFUN(wctomb,(char *, wchar_t));
-int _EXFUN(_wctomb_r,(struct _reent *, char *, wchar_t, _mbstate_t *));
-size_t _EXFUN(mbstowcs,(wchar_t *, const char *, size_t));
-size_t _EXFUN(_mbstowcs_r,(struct _reent *, wchar_t *, const char *, size_t, _mbstate_t *));
-size_t _EXFUN(wcstombs,(char *, const wchar_t *, size_t));
-size_t _EXFUN(_wcstombs_r,(struct _reent *, char *, const wchar_t *, size_t, _mbstate_t *));
-#ifndef __STRICT_ANSI__
-#ifndef _REENT_ONLY
-char * _EXFUN(mkdtemp,(char *));
-int _EXFUN(mkostemp,(char *, int));
-int _EXFUN(mkostemps,(char *, int, int));
-int _EXFUN(mkstemp,(char *));
-int _EXFUN(mkstemps,(char *, int));
-char * _EXFUN(mktemp,(char *) _ATTRIBUTE (__warning__ ("the use of `mktemp' is dangerous; use `mkstemp' instead")));
+
+#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE)
+int putenv (char *);
+int posix_openpt (int);
+int grantpt (int);
+int unlockpt (int);
+char *ptsname (int);
+char *l64a (long);
+long a64l (const char *);
+void setkey (const char *);
+double drand48 (void);
+double erand48 (unsigned short [3]);
+long int lrand48 (void);
+long int nrand48 (unsigned short [3]);
+long mrand48 (void);
+long jrand48 (unsigned short [3]);
+void srand48 (long);
+unsigned short *seed48 (unsigned short [3]);
+void lcong48 (unsigned short [7]);
#endif
-char * _EXFUN(_mkdtemp_r, (struct _reent *, char *));
-int _EXFUN(_mkostemp_r, (struct _reent *, char *, int));
-int _EXFUN(_mkostemps_r, (struct _reent *, char *, int, int));
-int _EXFUN(_mkstemp_r, (struct _reent *, char *));
-int _EXFUN(_mkstemps_r, (struct _reent *, char *, int));
-char * _EXFUN(_mktemp_r, (struct _reent *, char *) _ATTRIBUTE (__warning__ ("the use of `mktemp' is dangerous; use `mkstemp' instead")));
+
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+#include <alloca.h>
+char *mktemp (char *);
+int mkstemps (char *, int);
+int mkostemps (char *, int, int);
+void *valloc (size_t);
+void *memalign(size_t, size_t);
+#define WCOREDUMP(s) ((s) & 0x80)
+#define WIFCONTINUED(s) ((s) == 0xffff)
#endif
-_VOID _EXFUN(qsort,(_PTR __base, size_t __nmemb, size_t __size, int(*_compar)(const _PTR, const _PTR)));
-int _EXFUN(rand,(_VOID));
-_PTR _EXFUN_NOTHROW(realloc,(_PTR __r, size_t __size));
-#ifndef __STRICT_ANSI__
-_PTR _EXFUN(reallocf,(_PTR __r, size_t __size));
+
+#ifdef _GNU_SOURCE
+int clearenv(void);
+int ptsname_r(int, char *, size_t);
+char *ecvt(double, int, int *, int *);
+char *fcvt(double, int, int *, int *);
+char *gcvt(double, int, char *);
#endif
-_VOID _EXFUN(srand,(unsigned __seed));
-double _EXFUN(strtod,(const char *__n, char **__end_PTR));
-double _EXFUN(_strtod_r,(struct _reent *,const char *__n, char **__end_PTR));
-float _EXFUN(strtof,(const char *__n, char **__end_PTR));
-#ifndef __STRICT_ANSI__
-/* the following strtodf interface is deprecated...use strtof instead */
-# ifndef strtodf
-# define strtodf strtof
-# endif
+
+#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
+#define mkstemp64 mkstemp
+#define mkostemp64 mkostemp
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+#define mkstemps64 mkstemps
+#define mkostemps64 mkostemps
#endif
-long _EXFUN(strtol,(const char *__n, char **__end_PTR, int __base));
-long _EXFUN(_strtol_r,(struct _reent *,const char *__n, char **__end_PTR, int __base));
-unsigned long _EXFUN(strtoul,(const char *__n, char **__end_PTR, int __base));
-unsigned long _EXFUN(_strtoul_r,(struct _reent *,const char *__n, char **__end_PTR, int __base));
-
-int _EXFUN(system,(const char *__string));
-
-#if !defined(__STRICT_ANSI__) || defined(EMSCRIPTEN)
-long _EXFUN(a64l,(const char *__input));
-char * _EXFUN(l64a,(long __input));
-char * _EXFUN(_l64a_r,(struct _reent *,long __input));
-int _EXFUN(on_exit,(_VOID (*__func)(int, _PTR),_PTR __arg));
-_VOID _EXFUN(_Exit,(int __status) _ATTRIBUTE(noreturn));
-int _EXFUN(putenv,(char *__string));
-int _EXFUN(_putenv_r,(struct _reent *, char *__string));
-_PTR _EXFUN(_reallocf_r,(struct _reent *, _PTR, size_t));
-char *realpath(const char *file_name, char *resolved_name); /* XXX Emscripten */
-int _EXFUN(setenv,(const char *__string, const char *__value, int __overwrite));
-int _EXFUN(_setenv_r,(struct _reent *, const char *__string, const char *__value, int __overwrite));
-
-char * _EXFUN(gcvt,(double,int,char *));
-char * _EXFUN(gcvtf,(float,int,char *));
-char * _EXFUN(fcvt,(double,int,int *,int *));
-char * _EXFUN(fcvtf,(float,int,int *,int *));
-char * _EXFUN(ecvt,(double,int,int *,int *));
-char * _EXFUN(ecvtbuf,(double, int, int*, int*, char *));
-char * _EXFUN(fcvtbuf,(double, int, int*, int*, char *));
-char * _EXFUN(ecvtf,(float,int,int *,int *));
-char * _EXFUN(dtoa,(double, int, int, int *, int*, char**));
-int _EXFUN(rand_r,(unsigned *__seed));
-
-double _EXFUN(drand48,(_VOID));
-double _EXFUN(_drand48_r,(struct _reent *));
-double _EXFUN(erand48,(unsigned short [3]));
-double _EXFUN(_erand48_r,(struct _reent *, unsigned short [3]));
-long _EXFUN(jrand48,(unsigned short [3]));
-long _EXFUN(_jrand48_r,(struct _reent *, unsigned short [3]));
-_VOID _EXFUN(lcong48,(unsigned short [7]));
-_VOID _EXFUN(_lcong48_r,(struct _reent *, unsigned short [7]));
-long _EXFUN(lrand48,(_VOID));
-long _EXFUN(_lrand48_r,(struct _reent *));
-long _EXFUN(mrand48,(_VOID));
-long _EXFUN(_mrand48_r,(struct _reent *));
-long _EXFUN(nrand48,(unsigned short [3]));
-long _EXFUN(_nrand48_r,(struct _reent *, unsigned short [3]));
-unsigned short *
- _EXFUN(seed48,(unsigned short [3]));
-unsigned short *
- _EXFUN(_seed48_r,(struct _reent *, unsigned short [3]));
-_VOID _EXFUN(srand48,(long));
-_VOID _EXFUN(_srand48_r,(struct _reent *, long));
-long long _EXFUN(atoll,(const char *__nptr));
-long long _EXFUN(_atoll_r,(struct _reent *, const char *__nptr));
-long long _EXFUN(llabs,(long long));
-lldiv_t _EXFUN(lldiv,(long long __numer, long long __denom));
-
-long long _EXFUN(strtoll,(const char *__n, char **__end_PTR, int __base));
-long long _EXFUN(_strtoll_r,(struct _reent *, const char *__n, char **__end_PTR, int __base));
-unsigned long long _EXFUN(strtoull,(const char *__n, char **__end_PTR, int __base));
-unsigned long long _EXFUN(_strtoull_r,(struct _reent *, const char *__n, char **__end_PTR, int __base));
-
-#ifndef __CYGWIN__
-_VOID _EXFUN(cfree,(_PTR));
-int _EXFUN(unsetenv,(const char *__string));
-int _EXFUN(_unsetenv_r,(struct _reent *, const char *__string));
#endif
-#if defined(__rtems__) || defined(EMSCRIPTEN)
-int _EXFUN(posix_memalign,(void **, size_t, size_t));
+#ifdef __cplusplus
+}
#endif
-#endif /* ! __STRICT_ANSI__ */
-
-char * _EXFUN(_dtoa_r,(struct _reent *, double, int, int, int *, int*, char**));
-#ifndef __CYGWIN__
-_PTR _EXFUN_NOTHROW(_malloc_r,(struct _reent *, size_t));
-_PTR _EXFUN_NOTHROW(_calloc_r,(struct _reent *, size_t, size_t));
-_VOID _EXFUN_NOTHROW(_free_r,(struct _reent *, _PTR));
-_PTR _EXFUN_NOTHROW(_realloc_r,(struct _reent *, _PTR, size_t));
-_VOID _EXFUN(_mstats_r,(struct _reent *, char *));
#endif
-int _EXFUN(_system_r,(struct _reent *, const char *));
-
-_VOID _EXFUN(__eprintf,(const char *, const char *, unsigned int, const char *));
-
-/* On platforms where long double equals double. */
-#if defined(_LDBL_EQ_DBL) || defined(EMSCRIPTEN)
-extern long double strtold (const char *, char **);
-extern long double wcstold (const wchar_t *, wchar_t **);
-#endif /* _LDBL_EQ_DBL */
-
-_END_STD_C
-
-#endif /* _STDLIB_H_ */
diff --git a/system/include/libc/stdnoreturn.h b/system/include/libc/stdnoreturn.h
new file mode 100644
index 00000000..60d924a0
--- /dev/null
+++ b/system/include/libc/stdnoreturn.h
@@ -0,0 +1,5 @@
+#ifndef _STDNORETURN_H
+#define _STDNORETURN_H
+#include <features.h>
+#define noreturn _Noreturn
+#endif
diff --git a/system/include/libc/string.h b/system/include/libc/string.h
index 8fd9ea43..d4412333 100644
--- a/system/include/libc/string.h
+++ b/system/include/libc/string.h
@@ -1,103 +1,102 @@
-/*
- * string.h
- *
- * Definitions for memory and string functions.
- */
+#ifndef _STRING_H
+#define _STRING_H
-#ifndef _STRING_H_
-#define _STRING_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
-#include "_ansi.h"
-#include <sys/reent.h>
+#include <features.h>
-#define __need_size_t
-#include <stddef.h>
+#define NULL 0L
-#ifndef NULL
-#define NULL 0
+#define __NEED_size_t
+#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
+ || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
+ || defined(_BSD_SOURCE)
+#define __NEED_locale_t
#endif
-_BEGIN_STD_C
-
-_PTR _EXFUN(memchr,(const _PTR, int, size_t));
-int _EXFUN(memcmp,(const _PTR, const _PTR, size_t));
-_PTR _EXFUN(memcpy,(_PTR, const _PTR, size_t));
-_PTR _EXFUN(memmove,(_PTR, const _PTR, size_t));
-_PTR _EXFUN(memset,(_PTR, int, size_t));
-char *_EXFUN(strcat,(char *, const char *));
-char *_EXFUN(strchr,(const char *, int));
-int _EXFUN(strcmp,(const char *, const char *));
-int _EXFUN(strcoll,(const char *, const char *));
-char *_EXFUN(strcpy,(char *, const char *));
-size_t _EXFUN(strcspn,(const char *, const char *));
-char *_EXFUN(strerror,(int));
-size_t _EXFUN(strlen,(const char *));
-char *_EXFUN(strncat,(char *, const char *, size_t));
-int _EXFUN(strncmp,(const char *, const char *, size_t));
-char *_EXFUN(strncpy,(char *, const char *, size_t));
-char *_EXFUN(strpbrk,(const char *, const char *));
-char *_EXFUN(strrchr,(const char *, int));
-size_t _EXFUN(strspn,(const char *, const char *));
-char *_EXFUN(strstr,(const char *, const char *));
-
-#if defined(EMSCRIPTEN) || !defined(_REENT_ONLY)
-char *_EXFUN(strtok,(char *, const char *));
-#endif
+#include <bits/alltypes.h>
+
+void *memcpy (void *__restrict, const void *__restrict, size_t);
+void *memmove (void *, const void *, size_t);
+void *memset (void *, int, size_t);
+int memcmp (const void *, const void *, size_t);
+void *memchr (const void *, int, size_t);
+
+char *strcpy (char *__restrict, const char *__restrict);
+char *strncpy (char *__restrict, const char *__restrict, size_t);
+
+char *strcat (char *__restrict, const char *__restrict);
+char *strncat (char *__restrict, const char *__restrict, size_t);
+
+int strcmp (const char *, const char *);
+int strncmp (const char *, const char *, size_t);
+
+int strcoll (const char *, const char *);
+size_t strxfrm (char *__restrict, const char *__restrict, size_t);
+
+char *strchr (const char *, int);
+char *strrchr (const char *, int);
+
+size_t strcspn (const char *, const char *);
+size_t strspn (const char *, const char *);
+char *strpbrk (const char *, const char *);
+char *strstr (const char *, const char *);
+char *strtok (char *__restrict, const char *__restrict);
+
+size_t strlen (const char *);
-size_t _EXFUN(strxfrm,(char *, const char *, size_t));
-
-#if defined(EMSCRIPTEN) || !defined(__STRICT_ANSI__)
-char *_EXFUN(strtok_r,(char *, const char *, char **));
-
-int _EXFUN(bcmp,(const void *, const void *, size_t));
-void _EXFUN(bcopy,(const void *, void *, size_t));
-void _EXFUN(bzero,(void *, size_t));
-int _EXFUN(ffs,(int));
-char *_EXFUN(index,(const char *, int));
-_PTR _EXFUN(memccpy,(_PTR, const _PTR, int, size_t));
-_PTR _EXFUN(mempcpy,(_PTR, const _PTR, size_t));
-_PTR _EXFUN(memmem, (const _PTR, size_t, const _PTR, size_t));
-char *_EXFUN(rindex,(const char *, int));
-char *_EXFUN(stpcpy,(char *, const char *));
-char *_EXFUN(stpncpy,(char *, const char *, size_t));
-int _EXFUN(strcasecmp,(const char *, const char *));
-char *_EXFUN(strcasestr,(const char *, const char *));
-char *_EXFUN(strdup,(const char *));
-char *_EXFUN(_strdup_r,(struct _reent *, const char *));
-char *_EXFUN(strndup,(const char *, size_t));
-char *_EXFUN(_strndup_r,(struct _reent *, const char *, size_t));
-char *_EXFUN(strerror_r,(int, char *, size_t));
-size_t _EXFUN(strlcat,(char *, const char *, size_t));
-size_t _EXFUN(strlcpy,(char *, const char *, size_t));
-int _EXFUN(strncasecmp,(const char *, const char *, size_t));
-size_t _EXFUN(strnlen,(const char *, size_t));
-char *_EXFUN(strsep,(char **, const char *));
-#if defined(__CYGWIN__) || defined(EMSCRIPTEN)
-#ifndef DEFS_H /* Kludge to work around problem compiling in gdb */
-char *_EXFUN(strsignal, (int __signo));
+char *strerror (int);
+
+#if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
+#include <strings.h>
#endif
-int _EXFUN(strtosigno, (const char *__name));
+
+#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
+ || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
+ || defined(_BSD_SOURCE)
+char *strtok_r (char *__restrict, const char *__restrict, char **__restrict);
+int strerror_r (int, char *, size_t);
+char *stpcpy(char *__restrict, const char *__restrict);
+char *stpncpy(char *__restrict, const char *__restrict, size_t);
+size_t strnlen (const char *, size_t);
+char *strdup (const char *);
+char *strndup (const char *, size_t);
+char *strsignal(int);
+char *strerror_l (int, locale_t);
+int strcoll_l (const char *, const char *, locale_t);
+size_t strxfrm_l (char *__restrict, const char *__restrict, size_t, locale_t);
#endif
-/* These function names are used on Windows and perhaps other systems. */
-#ifndef strcmpi
-#define strcmpi strcasecmp
+#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
+ || defined(_BSD_SOURCE)
+void *memccpy (void *__restrict, const void *__restrict, int, size_t);
#endif
-#ifndef stricmp
-#define stricmp strcasecmp
+
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+char *strsep(char **, const char *);
+size_t strlcat (char *, const char *, size_t);
+size_t strlcpy (char *, const char *, size_t);
#endif
-#ifndef strncmpi
-#define strncmpi strncasecmp
+
+#ifdef _GNU_SOURCE
+#define strdupa(x) strcpy(alloca(strlen(x)+1),x)
+int strverscmp (const char *, const char *);
+int strcasecmp_l (const char *, const char *, locale_t);
+int strncasecmp_l (const char *, const char *, size_t, locale_t);
+char *strchrnul(const char *, int);
+char *strcasestr(const char *, const char *);
+void *memmem(const void *, size_t, const void *, size_t);
+void *memrchr(const void *, int, size_t);
+void *mempcpy(void *, const void *, size_t);
+#ifndef __cplusplus
+char *basename();
#endif
-#ifndef strnicmp
-#define strnicmp strncasecmp
#endif
-#endif /* ! __STRICT_ANSI__ */
-
-#include <sys/string.h>
-
-_END_STD_C
-
-#endif /* _STRING_H_ */
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/system/include/libc/strings.h b/system/include/libc/strings.h
index 131d81d2..2b7e086c 100644
--- a/system/include/libc/strings.h
+++ b/system/include/libc/strings.h
@@ -1,35 +1,35 @@
-/*
- * strings.h
- *
- * Definitions for string operations.
- */
+#ifndef _STRINGS_H
+#define _STRINGS_H
-#ifndef _STRINGS_H_
-#define _STRINGS_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
-#include "_ansi.h"
-#include <sys/reent.h>
-#include <sys/types.h> /* for size_t */
+#define __NEED_size_t
+#define __NEED_locale_t
+#include <bits/alltypes.h>
-_BEGIN_STD_C
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) || defined(_POSIX_SOURCE) \
+ || (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE+0 < 200809L) \
+ || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE+0 < 700)
+int bcmp (const void *, const void *, size_t);
+void bcopy (const void *, void *, size_t);
+void bzero (void *, size_t);
+char *index (const char *, int);
+char *rindex (const char *, int);
+#endif
-#if !defined __STRICT_ANSI__ && _POSIX_VERSION < 200809L
-/*
- * Marked LEGACY in Open Group Base Specifications Issue 6/IEEE Std 1003.1-2004
- * Removed from Open Group Base Specifications Issue 7/IEEE Std 1003.1-2008
- */
-int _EXFUN(bcmp,(const void *, const void *, size_t));
-void _EXFUN(bcopy,(const void *, void *, size_t));
-void _EXFUN(bzero,(void *, size_t));
-char *_EXFUN(index,(const char *, int));
-char *_EXFUN(rindex,(const char *, int));
-#endif /* ! __STRICT_ANSI__ */
+int ffs (int);
-int _EXFUN(ffs,(int));
-int _EXFUN(strcasecmp,(const char *, const char *));
-int _EXFUN(strncasecmp,(const char *, const char *, size_t));
+int strcasecmp (const char *, const char *);
+int strncasecmp (const char *, const char *, size_t);
-_END_STD_C
+int strcasecmp_l (const char *, const char *, locale_t);
+int strncasecmp_l (const char *, const char *, size_t, locale_t);
-#endif /* _STRINGS_H_ */
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/stropts.h b/system/include/libc/stropts.h
new file mode 100644
index 00000000..c99c922e
--- /dev/null
+++ b/system/include/libc/stropts.h
@@ -0,0 +1,139 @@
+#ifndef _STROPTS_H
+#define _STROPTS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define __SID ('S' << 8)
+
+#define I_NREAD (__SID | 1)
+#define I_PUSH (__SID | 2)
+#define I_POP (__SID | 3)
+#define I_LOOK (__SID | 4)
+#define I_FLUSH (__SID | 5)
+#define I_SRDOPT (__SID | 6)
+#define I_GRDOPT (__SID | 7)
+#define I_STR (__SID | 8)
+#define I_SETSIG (__SID | 9)
+#define I_GETSIG (__SID |10)
+#define I_FIND (__SID |11)
+#define I_LINK (__SID |12)
+#define I_UNLINK (__SID |13)
+#define I_PEEK (__SID |15)
+#define I_FDINSERT (__SID |16)
+#define I_SENDFD (__SID |17)
+#define I_RECVFD (__SID |14)
+#define I_SWROPT (__SID |19)
+#define I_GWROPT (__SID |20)
+#define I_LIST (__SID |21)
+#define I_PLINK (__SID |22)
+#define I_PUNLINK (__SID |23)
+#define I_FLUSHBAND (__SID |28)
+#define I_CKBAND (__SID |29)
+#define I_GETBAND (__SID |30)
+#define I_ATMARK (__SID |31)
+#define I_SETCLTIME (__SID |32)
+#define I_GETCLTIME (__SID |33)
+#define I_CANPUT (__SID |34)
+
+#define FMNAMESZ 8
+
+#define FLUSHR 0x01
+#define FLUSHW 0x02
+#define FLUSHRW 0x03
+#define FLUSHBAND 0x04
+
+#define S_INPUT 0x0001
+#define S_HIPRI 0x0002
+#define S_OUTPUT 0x0004
+#define S_MSG 0x0008
+#define S_ERROR 0x0010
+#define S_HANGUP 0x0020
+#define S_RDNORM 0x0040
+#define S_WRNORM S_OUTPUT
+#define S_RDBAND 0x0080
+#define S_WRBAND 0x0100
+#define S_BANDURG 0x0200
+
+#define RS_HIPRI 0x01
+
+#define RNORM 0x0000
+#define RMSGD 0x0001
+#define RMSGN 0x0002
+#define RPROTDAT 0x0004
+#define RPROTDIS 0x0008
+#define RPROTNORM 0x0010
+#define RPROTMASK 0x001C
+
+#define SNDZERO 0x001
+#define SNDPIPE 0x002
+
+#define ANYMARK 0x01
+#define LASTMARK 0x02
+
+#define MUXID_ALL (-1)
+
+#define MSG_HIPRI 0x01
+#define MSG_ANY 0x02
+#define MSG_BAND 0x04
+
+#define MORECTL 1
+#define MOREDATA 2
+
+struct bandinfo {
+ unsigned char bi_pri;
+ int bi_flag;
+};
+
+struct strbuf {
+ int maxlen;
+ int len;
+ char *buf;
+};
+
+struct strpeek {
+ struct strbuf ctlbuf;
+ struct strbuf databuf;
+ unsigned flags;
+};
+
+struct strfdinsert {
+ struct strbuf ctlbuf;
+ struct strbuf databuf;
+ unsigned flags;
+ int fildes;
+ int offset;
+};
+
+struct strioctl {
+ int ic_cmd;
+ int ic_timout;
+ int ic_len;
+ char *ic_dp;
+};
+
+struct strrecvfd {
+ int fd;
+ int uid;
+ int gid;
+ char __fill[8];
+};
+
+struct str_mlist {
+ char l_name[FMNAMESZ + 1];
+};
+
+struct str_list {
+ int sl_nmods;
+ struct str_mlist *sl_modlist;
+};
+
+int isastream(int);
+int ioctl(int, int, ...);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/sys/_default_fcntl.h b/system/include/libc/sys/_default_fcntl.h
deleted file mode 100644
index 379147ed..00000000
--- a/system/include/libc/sys/_default_fcntl.h
+++ /dev/null
@@ -1,223 +0,0 @@
-
-#ifndef _SYS__DEFAULT_FCNTL_H_
-#ifdef __cplusplus
-extern "C" {
-#endif
-#define _SYS__DEFAULT_FCNTL_H_
-#include <_ansi.h>
-#define _FOPEN (-1) /* from sys/file.h, kernel use only */
-#define _FREAD 0x0001 /* read enabled */
-#define _FWRITE 0x0002 /* write enabled */
-#define _FAPPEND 0x0008 /* append (writes guaranteed at the end) */
-#define _FMARK 0x0010 /* internal; mark during gc() */
-#define _FDEFER 0x0020 /* internal; defer for next gc pass */
-#define _FASYNC 0x0040 /* signal pgrp when data ready */
-#define _FSHLOCK 0x0080 /* BSD flock() shared lock present */
-#define _FEXLOCK 0x0100 /* BSD flock() exclusive lock present */
-#define _FCREAT 0x0200 /* open with file create */
-#define _FTRUNC 0x0400 /* open with truncation */
-#define _FEXCL 0x0800 /* error on open if file exists */
-#define _FNBIO 0x1000 /* non blocking I/O (sys5 style) */
-#define _FSYNC 0x2000 /* do all writes synchronously */
-#define _FNONBLOCK 0x4000 /* non blocking I/O (POSIX style) */
-#define _FNDELAY _FNONBLOCK /* non blocking I/O (4.2 style) */
-#define _FNOCTTY 0x8000 /* don't assign a ctty on this open */
-
-#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR)
-
-/*
- * Flag values for open(2) and fcntl(2)
- * The kernel adds 1 to the open modes to turn it into some
- * combination of FREAD and FWRITE.
- */
-#define O_RDONLY 0 /* +1 == FREAD */
-#define O_WRONLY 1 /* +1 == FWRITE */
-#define O_RDWR 2 /* +1 == FREAD|FWRITE */
-#define O_APPEND _FAPPEND
-#define O_CREAT _FCREAT
-#define O_TRUNC _FTRUNC
-#define O_EXCL _FEXCL
-#define O_SYNC _FSYNC
-/* O_NDELAY _FNDELAY set in include/fcntl.h */
-/* O_NDELAY _FNBIO set in include/fcntl.h */
-#define O_NONBLOCK _FNONBLOCK
-#define O_NOCTTY _FNOCTTY
-/* For machines which care - */
-#if defined (_WIN32) || defined (__CYGWIN__)
-#define _FBINARY 0x10000
-#define _FTEXT 0x20000
-#define _FNOINHERIT 0x40000
-
-#define O_BINARY _FBINARY
-#define O_TEXT _FTEXT
-#define O_NOINHERIT _FNOINHERIT
-/* O_CLOEXEC is the Linux equivalent to O_NOINHERIT */
-#define O_CLOEXEC _FNOINHERIT
-
-/* The windows header files define versions with a leading underscore. */
-#define _O_RDONLY O_RDONLY
-#define _O_WRONLY O_WRONLY
-#define _O_RDWR O_RDWR
-#define _O_APPEND O_APPEND
-#define _O_CREAT O_CREAT
-#define _O_TRUNC O_TRUNC
-#define _O_EXCL O_EXCL
-#define _O_TEXT O_TEXT
-#define _O_BINARY O_BINARY
-#define _O_RAW O_BINARY
-#define _O_NOINHERIT O_NOINHERIT
-#endif
-
-#ifndef _POSIX_SOURCE
-
-/*
- * Flags that work for fcntl(fd, F_SETFL, FXXXX)
- */
-#define FAPPEND _FAPPEND
-#define FSYNC _FSYNC
-#define FASYNC _FASYNC
-#define FNBIO _FNBIO
-#define FNONBIO _FNONBLOCK /* XXX fix to be NONBLOCK everywhere */
-#define FNDELAY _FNDELAY
-
-/*
- * Flags that are disallowed for fcntl's (FCNTLCANT);
- * used for opens, internal state, or locking.
- */
-#define FREAD _FREAD
-#define FWRITE _FWRITE
-#define FMARK _FMARK
-#define FDEFER _FDEFER
-#define FSHLOCK _FSHLOCK
-#define FEXLOCK _FEXLOCK
-
-/*
- * The rest of the flags, used only for opens
- */
-#define FOPEN _FOPEN
-#define FCREAT _FCREAT
-#define FTRUNC _FTRUNC
-#define FEXCL _FEXCL
-#define FNOCTTY _FNOCTTY
-
-#endif /* !_POSIX_SOURCE */
-
-/* XXX close on exec request; must match UF_EXCLOSE in user.h */
-#define FD_CLOEXEC 1 /* posix */
-
-/* fcntl(2) requests */
-#define F_DUPFD 0 /* Duplicate fildes */
-#define F_GETFD 1 /* Get fildes flags (close on exec) */
-#define F_SETFD 2 /* Set fildes flags (close on exec) */
-#define F_GETFL 3 /* Get file flags */
-#define F_SETFL 4 /* Set file flags */
-#ifndef _POSIX_SOURCE
-#define F_GETOWN 5 /* Get owner - for ASYNC */
-#define F_SETOWN 6 /* Set owner - for ASYNC */
-#endif /* !_POSIX_SOURCE */
-#define F_GETLK 7 /* Get record-locking information */
-#define F_SETLK 8 /* Set or Clear a record-lock (Non-Blocking) */
-#define F_SETLKW 9 /* Set or Clear a record-lock (Blocking) */
-#ifndef _POSIX_SOURCE
-#define F_RGETLK 10 /* Test a remote lock to see if it is blocked */
-#define F_RSETLK 11 /* Set or unlock a remote lock */
-#define F_CNVT 12 /* Convert a fhandle to an open fd */
-#define F_RSETLKW 13 /* Set or Clear remote record-lock(Blocking) */
-#endif /* !_POSIX_SOURCE */
-#ifdef __CYGWIN__
-#define F_DUPFD_CLOEXEC 14 /* As F_DUPFD, but set close-on-exec flag */
-#endif
-
-/* XXX Emscripten: 3 more not really needed ones */
-#define F_GETLK64 20
-#define F_SETLK64 21
-#define F_SETLKW64 22
-
-
-/* fcntl(2) flags (l_type field of flock structure) */
-#define F_RDLCK 1 /* read lock */
-#define F_WRLCK 2 /* write lock */
-#define F_UNLCK 3 /* remove lock(s) */
-#ifndef _POSIX_SOURCE
-#define F_UNLKSYS 4 /* remove remote locks for a given system */
-#endif /* !_POSIX_SOURCE */
-
-#ifdef __CYGWIN__
-/* Special descriptor value to denote the cwd in calls to openat(2) etc. */
-#define AT_FDCWD -2
-
-/* Flag values for faccessat2) et al. */
-#define AT_EACCESS 1
-#define AT_SYMLINK_NOFOLLOW 2
-#define AT_SYMLINK_FOLLOW 4
-#define AT_REMOVEDIR 8
-#endif
-
-/*#include <sys/stdtypes.h>*/
-
-#ifndef __CYGWIN__
-/* file segment locking set data type - information passed to system by user */
-struct flock {
- short l_type; /* F_RDLCK, F_WRLCK, or F_UNLCK */
- short l_whence; /* flag to choose starting offset */
- long l_start; /* relative offset, in bytes */
- long l_len; /* length, in bytes; 0 means lock to EOF */
- short l_pid; /* returned with F_GETLK */
- short l_xxx; /* reserved for future use */
-};
-#endif /* __CYGWIN__ */
-
-#ifndef _POSIX_SOURCE
-/* extended file segment locking set data type */
-struct eflock {
- short l_type; /* F_RDLCK, F_WRLCK, or F_UNLCK */
- short l_whence; /* flag to choose starting offset */
- long l_start; /* relative offset, in bytes */
- long l_len; /* length, in bytes; 0 means lock to EOF */
- short l_pid; /* returned with F_GETLK */
- short l_xxx; /* reserved for future use */
- long l_rpid; /* Remote process id wanting this lock */
- long l_rsys; /* Remote system id wanting this lock */
-};
-#endif /* !_POSIX_SOURCE */
-
-
-#include <sys/types.h>
-#include <sys/stat.h> /* sigh. for the mode bits for open/creat */
-
-extern int open _PARAMS ((const char *, int, ...));
-extern int open64 _PARAMS ((const char *, int, ...)); /* XXX Emscripten */
-extern int creat _PARAMS ((const char *, mode_t));
-extern int fcntl _PARAMS ((int, int, ...));
-#ifdef __CYGWIN__
-#include <sys/time.h>
-extern int futimesat _PARAMS ((int, const char *, const struct timeval *));
-extern int openat _PARAMS ((int, const char *, int, ...));
-#endif
-
-/* Provide _<systemcall> prototypes for functions provided by some versions
- of newlib. */
-#ifdef _COMPILING_NEWLIB
-extern int _open _PARAMS ((const char *, int, ...));
-extern int _fcntl _PARAMS ((int, int, ...));
-#ifdef __LARGE64_FILES
-extern int _open64 _PARAMS ((const char *, int, ...));
-#endif
-#endif
-
-/* XXX Emscripten */
-#define POSIX_FADV_DONTNEED 135
-#define POSIX_FADV_SEQUENTIAL 136
-#define POSIX_FADV_RANDOM 137
-int posix_fadvise(int fd, off_t offset, off_t len, int advice);
-int posix_fallocate(int fd, off_t offset, off_t len);
-#define LOCK_SH 1
-#define LOCK_EX 2
-#define LOCK_UN 4
-#define LOCK_NB 8
-int flock(int fd, int operation);
-
-#ifdef __cplusplus
-}
-#endif
-#endif /* !_SYS__DEFAULT_FCNTL_H_ */
diff --git a/system/include/libc/sys/_types.h b/system/include/libc/sys/_types.h
deleted file mode 100644
index 0511602c..00000000
--- a/system/include/libc/sys/_types.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/* ANSI C namespace clean utility typedefs */
-
-/* This file defines various typedefs needed by the system calls that support
- the C library. Basically, they're just the POSIX versions with an '_'
- prepended. This file lives in the `sys' directory so targets can provide
- their own if desired (or they can put target dependant conditionals here).
-*/
-
-#ifndef _SYS__TYPES_H
-#define _SYS__TYPES_H
-
-#include <machine/_types.h>
-#include <sys/lock.h>
-
-#ifndef __off_t_defined
-typedef long _off_t;
-#endif
-
-#if defined(__rtems__)
-/* device numbers are 32-bit major and and 32-bit minor */
-typedef unsigned long long __dev_t;
-#else
-#ifndef __dev_t_defined
-typedef unsigned __dev_t; /* XXX Emscripten */
-#endif
-#endif
-
-#ifndef __uid_t_defined
-typedef unsigned __uid_t; /* XXX Emscripten */
-#define __uid_t_defined 1
-#endif
-#ifndef __gid_t_defined
-typedef unsigned __gid_t; /* XXX Emscripten */
-#define __gid_t_defined 1
-#endif
-#ifndef __id_t_defined
-typedef unsigned __id_t; /* can hold a gid_t, pid_t, or uid_t XXX EMSCRIPTEN specific*/
-#define __id_t_defined 1
-#endif
-
-#ifndef __off64_t_defined
-__extension__ typedef unsigned _off64_t; /* XXX Emscripten */
-#endif
-
-/*
- * We need fpos_t for the following, but it doesn't have a leading "_",
- * so we use _fpos_t instead.
- */
-#ifndef __fpos_t_defined
-typedef long _fpos_t; /* XXX must match off_t in <sys/types.h> */
- /* (and must be `long' for now) */
-#endif
-
-#ifdef __LARGE64_FILES
-#ifndef __fpos64_t_defined
-typedef _off64_t _fpos64_t;
-#endif
-#endif
-
-#ifndef __ssize_t_defined
-#if defined(__INT_MAX__) && __INT_MAX__ == 2147483647
-typedef int _ssize_t;
-#else
-typedef long _ssize_t;
-#endif
-#endif
-
-#define __need_wint_t
-#include <stddef.h>
-
-#ifndef __mbstate_t_defined
-/* Conversion state information. */
-typedef struct
-{
- int __count;
- union
- {
- wint_t __wch;
- unsigned char __wchb[4];
- } __value; /* Value so far. */
-} _mbstate_t;
-#endif
-
-#ifndef __flock_t_defined
-typedef _LOCK_RECURSIVE_T _flock_t;
-#endif
-
-#ifndef __iconv_t_defined
-/* Iconv descriptor type */
-typedef void *_iconv_t;
-#endif
-
-#endif /* _SYS__TYPES_H */
diff --git a/system/include/libc/sys/acct.h b/system/include/libc/sys/acct.h
new file mode 100644
index 00000000..ee576c4a
--- /dev/null
+++ b/system/include/libc/sys/acct.h
@@ -0,0 +1,75 @@
+#ifndef _SYS_ACCT_H
+#define _SYS_ACCT_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <features.h>
+#include <endian.h>
+#include <time.h>
+#include <stdint.h>
+
+#define ACCT_COMM 16
+
+typedef uint16_t comp_t;
+
+struct acct
+{
+ char ac_flag;
+ uint16_t ac_uid;
+ uint16_t ac_gid;
+ uint16_t ac_tty;
+ uint32_t ac_btime;
+ comp_t ac_utime;
+ comp_t ac_stime;
+ comp_t ac_etime;
+ comp_t ac_mem;
+ comp_t ac_io;
+ comp_t ac_rw;
+ comp_t ac_minflt;
+ comp_t ac_majflt;
+ comp_t ac_swaps;
+ uint32_t ac_exitcode;
+ char ac_comm[ACCT_COMM+1];
+ char ac_pad[10];
+};
+
+
+struct acct_v3
+{
+ char ac_flag;
+ char ac_version;
+ uint16_t ac_tty;
+ uint32_t ac_exitcode;
+ uint32_t ac_uid;
+ uint32_t ac_gid;
+ uint32_t ac_pid;
+ uint32_t ac_ppid;
+ uint32_t ac_btime;
+ float ac_etime;
+ comp_t ac_utime;
+ comp_t ac_stime;
+ comp_t ac_mem;
+ comp_t ac_io;
+ comp_t ac_rw;
+ comp_t ac_minflt;
+ comp_t ac_majflt;
+ comp_t ac_swaps;
+ char ac_comm[ACCT_COMM];
+};
+
+#define AFORK 1
+#define ASU 2
+#define ACORE 8
+#define AXSIG 16
+#define ACCT_BYTEORDER (128*(__BYTE_ORDER==__BIG_ENDIAN))
+#define AHZ 100
+
+int acct(const char *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/sys/cachectl.h b/system/include/libc/sys/cachectl.h
new file mode 100644
index 00000000..f3b896a8
--- /dev/null
+++ b/system/include/libc/sys/cachectl.h
@@ -0,0 +1,22 @@
+#ifndef _SYS_CACHECTL_H
+#define _SYS_CACHECTL_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define ICACHE (1<<0)
+#define DCACHE (1<<1)
+#define BCACHE (ICACHE|DCACHE)
+#define CACHEABLE 0
+#define UNCACHEABLE 1
+
+int cachectl(void *, int, int);
+int cacheflush(void *, int, int);
+int _flush_cache(void *, int, int);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/sys/cdefs.h b/system/include/libc/sys/cdefs.h
deleted file mode 100644
index f0b6a27b..00000000
--- a/system/include/libc/sys/cdefs.h
+++ /dev/null
@@ -1,123 +0,0 @@
-/* libc/sys/linux/sys/cdefs.h - Helper macros for K&R vs. ANSI C compat. */
-
-/* Written 2000 by Werner Almesberger */
-
-/*
- * Copyright (c) 1991, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Berkeley Software Design, Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)cdefs.h 8.8 (Berkeley) 1/9/95
- * $FreeBSD: src/sys/sys/cdefs.h,v 1.54 2002/05/11 03:58:24 alfred Exp $
- */
-
-#ifndef _SYS_CDEFS_H
-#define _SYS_CDEFS_H
-
-#define __FBSDID(x) /* nothing */
-/*
- * Note: the goal here is not compatibility to K&R C. Since we know that we
- * have GCC which understands ANSI C perfectly well, we make use of this.
- */
-
-#define __P(args) args
-#define __PMT(args) args
-#define __const const
-#define __signed signed
-#define __volatile volatile
-#define __DOTS , ...
-#define __THROW
-
-#define __ptr_t void *
-#define __long_double_t long double
-
-#define __attribute_malloc__
-#define __attribute_pure__
-#define __attribute_format_strfmon__(a,b)
-#define __flexarr [0]
-
-#ifdef __cplusplus
-# define __BEGIN_DECLS extern "C" {
-# define __END_DECLS }
-#else
-# define __BEGIN_DECLS
-# define __END_DECLS
-#endif
-
-#ifndef __BOUNDED_POINTERS__
-# define __bounded /* nothing */
-# define __unbounded /* nothing */
-# define __ptrvalue /* nothing */
-#endif
-
-#ifdef __GNUC__
-#define __strong_reference(sym,aliassym) \
- extern __typeof (sym) aliassym __attribute__ ((__alias__ (#sym)));
-#ifdef __ELF__
-#ifdef __STDC__
-#define __weak_reference(sym,alias) \
- __asm__(".weak " #alias); \
- __asm__(".equ " #alias ", " #sym)
-#define __warn_references(sym,msg) \
- __asm__(".section .gnu.warning." #sym); \
- __asm__(".asciz \"" msg "\""); \
- __asm__(".previous")
-#else
-#define __weak_reference(sym,alias) \
- __asm__(".weak alias"); \
- __asm__(".equ alias, sym")
-#define __warn_references(sym,msg) \
- __asm__(".section .gnu.warning.sym"); \
- __asm__(".asciz \"msg\""); \
- __asm__(".previous")
-#endif /* __STDC__ */
-#else /* !__ELF__ */
-#ifdef __STDC__
-#define __weak_reference(sym,alias) \
- __asm__(".stabs \"_" #alias "\",11,0,0,0"); \
- __asm__(".stabs \"_" #sym "\",1,0,0,0")
-#define __warn_references(sym,msg) \
- __asm__(".stabs \"" msg "\",30,0,0,0"); \
- __asm__(".stabs \"_" #sym "\",1,0,0,0")
-#else
-#define __weak_reference(sym,alias) \
- __asm__(".stabs \"_/**/alias\",11,0,0,0"); \
- __asm__(".stabs \"_/**/sym\",1,0,0,0")
-#define __warn_references(sym,msg) \
- __asm__(".stabs msg,30,0,0,0"); \
- __asm__(".stabs \"_/**/sym\",1,0,0,0")
-#endif /* __STDC__ */
-#endif /* __ELF__ */
-#endif /* __GNUC__ */
-
-#endif /* _SYS_CDEFS_H */
diff --git a/system/include/libc/sys/config.h b/system/include/libc/sys/config.h
deleted file mode 100644
index 49c81f91..00000000
--- a/system/include/libc/sys/config.h
+++ /dev/null
@@ -1,255 +0,0 @@
-#ifndef __SYS_CONFIG_H__
-#define __SYS_CONFIG_H__
-
-#include <machine/ieeefp.h> /* floating point macros */
-#include <sys/features.h> /* POSIX defs */
-
-/* exceptions first */
-#if defined(__H8500__) || defined(__W65__)
-#define __SMALL_BITFIELDS
-/* ??? This conditional is true for the h8500 and the w65, defining H8300
- in those cases probably isn't the right thing to do. */
-#define H8300 1
-#endif
-
-/* 16 bit integer machines */
-#if defined(__Z8001__) || defined(__Z8002__) || defined(__H8500__) || defined(__W65__) || defined (__mn10200__) || defined (__AVR__)
-
-#undef INT_MAX
-#undef UINT_MAX
-#define INT_MAX 32767
-#define UINT_MAX 65535
-#endif
-
-#if defined (__H8300__) || defined (__H8300H__) || defined(__H8300S__) || defined (__H8300SX__)
-#define __SMALL_BITFIELDS
-#define H8300 1
-#undef INT_MAX
-#undef UINT_MAX
-#define INT_MAX __INT_MAX__
-#define UINT_MAX (__INT_MAX__ * 2U + 1)
-#endif
-
-#if (defined(__CR16__) || defined(__CR16C__) ||defined(__CR16CP__))
-#ifndef __INT32__
-#define __SMALL_BITFIELDS
-#undef INT_MAX
-#undef UINT_MAX
-#define INT_MAX 32767
-#define UINT_MAX (__INT_MAX__ * 2U + 1)
-#else /* INT32 */
-#undef INT_MAX
-#undef UINT_MAX
-#define INT_MAX 2147483647
-#define UINT_MAX (__INT_MAX__ * 2U + 1)
-#endif /* INT32 */
-
-#endif /* CR16C */
-
-#if defined (__xc16x__) || defined (__xc16xL__) || defined (__xc16xS__)
-#define __SMALL_BITFIELDS
-#endif
-
-#ifdef __W65__
-#define __SMALL_BITFIELDS
-#endif
-
-#if defined(__D10V__)
-#define __SMALL_BITFIELDS
-#undef INT_MAX
-#undef UINT_MAX
-#define INT_MAX __INT_MAX__
-#define UINT_MAX (__INT_MAX__ * 2U + 1)
-#define _POINTER_INT short
-#endif
-
-#if defined(__mc68hc11__) || defined(__mc68hc12__) || defined(__mc68hc1x__)
-#undef INT_MAX
-#undef UINT_MAX
-#define INT_MAX __INT_MAX__
-#define UINT_MAX (__INT_MAX__ * 2U + 1)
-#define _POINTER_INT short
-#endif
-
-#ifdef ___AM29K__
-#define _FLOAT_RET double
-#endif
-
-#ifdef __i386__
-#ifndef __unix__
-/* in other words, go32 */
-#define _FLOAT_RET double
-#endif
-#if defined(__linux__) || defined(__RDOS__)
-/* we want the reentrancy structure to be returned by a function */
-#define __DYNAMIC_REENT__
-#define HAVE_GETDATE
-#define _HAVE_SYSTYPES
-#define _READ_WRITE_RETURN_TYPE _ssize_t
-#define __LARGE64_FILES 1
-/* we use some glibc header files so turn on glibc large file feature */
-#define _LARGEFILE64_SOURCE 1
-#endif
-#endif
-
-#ifdef __mn10200__
-#define __SMALL_BITFIELDS
-#endif
-
-#ifdef __AVR__
-#define __SMALL_BITFIELDS
-#define _POINTER_INT short
-#endif
-
-#ifdef __v850
-#define __ATTRIBUTE_IMPURE_PTR__ __attribute__((__sda__))
-#endif
-
-/* For the PowerPC eabi, force the _impure_ptr to be in .sdata */
-#if defined(__PPC__)
-#if defined(_CALL_SYSV)
-#define __ATTRIBUTE_IMPURE_PTR__ __attribute__((__section__(".sdata")))
-#endif
-#ifdef __SPE__
-#define _LONG_DOUBLE double
-#endif
-#endif
-
-/* Configure small REENT structure for Xilinx MicroBlaze platforms */
-#if defined (__MICROBLAZE__)
-#ifndef _REENT_SMALL
-#define _REENT_SMALL
-#endif
-/* Xilinx XMK uses Unix98 mutex */
-#ifdef __XMK__
-#define _UNIX98_THREAD_MUTEX_ATTRIBUTES
-#endif
-#endif
-
-#if defined(__mips__) && !defined(__rtems__)
-#define __ATTRIBUTE_IMPURE_PTR__ __attribute__((__section__(".sdata")))
-#endif
-
-#ifdef __xstormy16__
-#define __SMALL_BITFIELDS
-#undef INT_MAX
-#undef UINT_MAX
-#define INT_MAX __INT_MAX__
-#define UINT_MAX (__INT_MAX__ * 2U + 1)
-#define MALLOC_ALIGNMENT 8
-#define _POINTER_INT short
-#define __BUFSIZ__ 16
-#define _REENT_SMALL
-#endif
-#ifdef __m32c__
-#define __SMALL_BITFIELDS
-#undef INT_MAX
-#undef UINT_MAX
-#define INT_MAX __INT_MAX__
-#define UINT_MAX (__INT_MAX__ * 2U + 1)
-#define MALLOC_ALIGNMENT 8
-#if defined(__r8c_cpu__) || defined(__m16c_cpu__)
-#define _POINTER_INT short
-#else
-#define _POINTER_INT long
-#endif
-#define __BUFSIZ__ 16
-#define _REENT_SMALL
-#endif /* __m32c__ */
-
-#ifdef __SPU__
-#define MALLOC_ALIGNMENT 16
-#define __CUSTOM_FILE_IO__
-#endif
-
-/* This block should be kept in sync with GCC's limits.h. The point
- of having these definitions here is to not include limits.h, which
- would pollute the user namespace, while still using types of the
- the correct widths when deciding how to define __int32_t and
- __int64_t. */
-#ifndef __INT_MAX__
-# ifdef INT_MAX
-# define __INT_MAX__ INT_MAX
-# else
-# define __INT_MAX__ 2147483647
-# endif
-#endif
-
-#ifndef __LONG_MAX__
-# ifdef LONG_MAX
-# define __LONG_MAX__ LONG_MAX
-# else
-# if defined (__alpha__) || (defined (__sparc__) && defined(__arch64__)) \
- || defined (__sparcv9)
-# define __LONG_MAX__ 9223372036854775807L
-# else
-# define __LONG_MAX__ 2147483647L
-# endif /* __alpha__ || sparc64 */
-# endif
-#endif
-/* End of block that should be kept in sync with GCC's limits.h. */
-
-#ifndef _POINTER_INT
-#define _POINTER_INT long
-#endif
-
-#ifdef __frv__
-#define __ATTRIBUTE_IMPURE_PTR__ __attribute__((__section__(".sdata")))
-#endif
-#undef __RAND_MAX
-#if __INT_MAX__ == 32767
-#define __RAND_MAX 32767
-#else
-#define __RAND_MAX 0x7fffffff
-#endif
-
-#if defined(__CYGWIN__)
-#include <cygwin/config.h>
-#if !defined (__STRICT_ANSI__) || (__STDC_VERSION__ >= 199901L)
-#define __USE_XOPEN2K 1
-#endif
-#endif
-
-#if defined(__rtems__)
-#define __FILENAME_MAX__ 255
-#define _READ_WRITE_RETURN_TYPE _ssize_t
-#endif
-
-#ifndef __EXPORT
-#define __EXPORT
-#endif
-
-#ifndef __IMPORT
-#define __IMPORT
-#endif
-
-/* Define return type of read/write routines. In POSIX, the return type
- for read()/write() is "ssize_t" but legacy newlib code has been using
- "int" for some time. If not specified, "int" is defaulted. */
-#ifndef _READ_WRITE_RETURN_TYPE
-#define _READ_WRITE_RETURN_TYPE int
-#endif
-
-#ifndef __WCHAR_MAX__
-#if __INT_MAX__ == 32767 || defined (_WIN32)
-#define __WCHAR_MAX__ 0xffffu
-#endif
-#endif
-
-/* See if small reent asked for at configuration time and
- is not chosen by the platform by default. */
-#ifdef _WANT_REENT_SMALL
-#ifndef _REENT_SMALL
-#define _REENT_SMALL
-#endif
-#endif
-
-/* If _MB_EXTENDED_CHARSETS_ALL is set, we want all of the extended
- charsets. The extended charsets add a few functions and a couple
- of tables of a few K each. */
-#ifdef _MB_EXTENDED_CHARSETS_ALL
-#define _MB_EXTENDED_CHARSETS_ISO 1
-#define _MB_EXTENDED_CHARSETS_WINDOWS 1
-#endif
-
-#endif /* __SYS_CONFIG_H__ */
diff --git a/system/include/libc/sys/custom_file.h b/system/include/libc/sys/custom_file.h
deleted file mode 100644
index 96314fb9..00000000
--- a/system/include/libc/sys/custom_file.h
+++ /dev/null
@@ -1,2 +0,0 @@
-#error System-specific custom_file.h is missing.
-
diff --git a/system/include/libc/sys/dir.h b/system/include/libc/sys/dir.h
index 220150dc..9ba1c79e 100644
--- a/system/include/libc/sys/dir.h
+++ b/system/include/libc/sys/dir.h
@@ -1,10 +1,2 @@
-/* BSD predecessor of POSIX.1 <dirent.h> and struct dirent */
-
-#ifndef _SYS_DIR_H_
-#define _SYS_DIR_H_
-
#include <dirent.h>
-
#define direct dirent
-
-#endif /*_SYS_DIR_H_*/
diff --git a/system/include/libc/sys/dirent.h b/system/include/libc/sys/dirent.h
deleted file mode 100644
index e6ce831e..00000000
--- a/system/include/libc/sys/dirent.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/* <dirent.h> includes <sys/dirent.h>, which is this file. On a
- system which supports <dirent.h>, this file is overridden by
- dirent.h in the libc/sys/.../sys directory. On a system which does
- not support <dirent.h>, we will get this file which uses #error to force
- an error. */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* XXX Emscripten */
-#include <sys/types.h>
-struct dirent {
- ino_t d_ino;
- char d_name[MAXNAMLEN];
- int d_off;
- int d_reclen;
- char d_type;
-};
-
-#define DIR struct dirent
-
-DIR *opendir(const char *);
-void seekdir(DIR *, long);
-long telldir(DIR *);
-DIR *readdir(DIR *);
-int readdir_r(DIR *, struct dirent *, struct dirent **);
-int closedir(DIR *dirp);
-void rewinddir(DIR *dirp);
-int scandir(const char *dirp,
- struct dirent ***namelist,
- int (*filter)(const struct dirent *),
- int (*compar)(const struct dirent **, const struct dirent **));
-
-enum {
- DT_UNKNOWN = 0,
-#define DT_UNKNOWN DT_UNKNOWN
- DT_FIFO = 1,
-#define DT_FIFO DT_FIFO
- DT_CHR = 2,
-#define DT_CHR DT_CHR
- DT_DIR = 4,
-#define DT_DIR DT_DIR
- DT_BLK = 6,
-#define DT_BLK DT_BLK
- DT_REG = 8,
-#define DT_REG DT_REG
- DT_LNK = 10,
-#define DT_LNK DT_LNK
- DT_SOCK = 12,
-#define DT_SOCK DT_SOCK
- DT_WHT = 14
-#define DT_WHT DT_WHT
-};
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/system/include/libc/sys/epoll.h b/system/include/libc/sys/epoll.h
new file mode 100644
index 00000000..1f0312e5
--- /dev/null
+++ b/system/include/libc/sys/epoll.h
@@ -0,0 +1,67 @@
+#ifndef _SYS_EPOLL_H
+#define _SYS_EPOLL_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+#include <sys/types.h>
+#include <fcntl.h>
+
+#define __NEED_sigset_t
+
+#include <bits/alltypes.h>
+
+#define EPOLL_CLOEXEC O_CLOEXEC
+#define EPOLL_NONBLOCK O_NONBLOCK
+
+enum EPOLL_EVENTS { __EPOLL_DUMMY };
+#define EPOLLIN 0x001
+#define EPOLLPRI 0x002
+#define EPOLLOUT 0x004
+#define EPOLLRDNORM 0x040
+#define EPOLLRDBAND 0x080
+#define EPOLLWRNORM 0x100
+#define EPOLLWRBAND 0x200
+#define EPOLLMSG 0x400
+#define EPOLLERR 0x008
+#define EPOLLHUP 0x010
+#define EPOLLRDHUP 0x2000
+#define EPOLLWAKEUP (1U<<29)
+#define EPOLLONESHOT (1U<<30)
+#define EPOLLET (1U<<31)
+
+#define EPOLL_CTL_ADD 1
+#define EPOLL_CTL_DEL 2
+#define EPOLL_CTL_MOD 3
+
+typedef union epoll_data {
+ void *ptr;
+ int fd;
+ uint32_t u32;
+ uint64_t u64;
+} epoll_data_t;
+
+struct epoll_event {
+ uint32_t events;
+ epoll_data_t data;
+}
+#ifdef __x86_64__
+__attribute__ ((__packed__))
+#endif
+;
+
+
+int epoll_create(int);
+int epoll_create1(int);
+int epoll_ctl(int, int, int, struct epoll_event *);
+int epoll_wait(int, struct epoll_event *, int, int);
+int epoll_pwait(int, struct epoll_event *, int, int, const sigset_t *);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* sys/epoll.h */
diff --git a/system/include/libc/sys/errno.h b/system/include/libc/sys/errno.h
index ac45fbc5..35a3e5a2 100644
--- a/system/include/libc/sys/errno.h
+++ b/system/include/libc/sys/errno.h
@@ -1,190 +1,2 @@
-/* errno is not a global variable, because that would make using it
- non-reentrant. Instead, its address is returned by the function
- __errno. */
-
-#ifndef _SYS_ERRNO_H_
-#ifdef __cplusplus
-extern "C" {
-#endif
-#define _SYS_ERRNO_H_
-
-#include <sys/reent.h>
-
-#ifndef _REENT_ONLY
-#define errno (*__errno())
-extern int *__errno _PARAMS ((void));
-#endif
-
-/* Please don't use these variables directly.
- Use strerror instead. */
-extern __IMPORT _CONST char * _CONST _sys_errlist[];
-extern __IMPORT int _sys_nerr;
-#ifdef __CYGWIN__
-extern __IMPORT const char * const sys_errlist[];
-extern __IMPORT int sys_nerr;
-#endif
-
-#define __errno_r(ptr) ((ptr)->_errno)
-
-#define EPERM 1 /* Not super-user */
-#define ENOENT 2 /* No such file or directory */
-#define ESRCH 3 /* No such process */
-#define EINTR 4 /* Interrupted system call */
-#define EIO 5 /* I/O error */
-#define ENXIO 6 /* No such device or address */
-#define E2BIG 7 /* Arg list too long */
-#define ENOEXEC 8 /* Exec format error */
-#define EBADF 9 /* Bad file number */
-#define ECHILD 10 /* No children */
-#define EAGAIN 11 /* No more processes */
-#define ENOMEM 12 /* Not enough core */
-#define EACCES 13 /* Permission denied */
-#define EFAULT 14 /* Bad address */
-#ifdef __LINUX_ERRNO_EXTENSIONS__
-#define ENOTBLK 15 /* Block device required */
-#endif
-#define EBUSY 16 /* Mount device busy */
-#define EEXIST 17 /* File exists */
-#define EXDEV 18 /* Cross-device link */
-#define ENODEV 19 /* No such device */
-#define ENOTDIR 20 /* Not a directory */
-#define EISDIR 21 /* Is a directory */
-#define EINVAL 22 /* Invalid argument */
-#define ENFILE 23 /* Too many open files in system */
-#define EMFILE 24 /* Too many open files */
-#define ENOTTY 25 /* Not a typewriter */
-#define ETXTBSY 26 /* Text file busy */
-#define EFBIG 27 /* File too large */
-#define ENOSPC 28 /* No space left on device */
-#define ESPIPE 29 /* Illegal seek */
-#define EROFS 30 /* Read only file system */
-#define EMLINK 31 /* Too many links */
-#define EPIPE 32 /* Broken pipe */
-#define EDOM 33 /* Math arg out of domain of func */
-#define ERANGE 34 /* Math result not representable */
-#define ENOMSG 35 /* No message of desired type */
-#define EIDRM 36 /* Identifier removed */
-#ifdef __LINUX_ERRNO_EXTENSIONS__
-#define ECHRNG 37 /* Channel number out of range */
-#define EL2NSYNC 38 /* Level 2 not synchronized */
-#define EL3HLT 39 /* Level 3 halted */
-#define EL3RST 40 /* Level 3 reset */
-#define ELNRNG 41 /* Link number out of range */
-#define EUNATCH 42 /* Protocol driver not attached */
-#define ENOCSI 43 /* No CSI structure available */
-#define EL2HLT 44 /* Level 2 halted */
-#endif
-#define EDEADLK 45 /* Deadlock condition */
-#define ENOLCK 46 /* No record locks available */
-#ifdef __LINUX_ERRNO_EXTENSIONS__
-#define EBADE 50 /* Invalid exchange */
-#define EBADR 51 /* Invalid request descriptor */
-#define EXFULL 52 /* Exchange full */
-#define ENOANO 53 /* No anode */
-#define EBADRQC 54 /* Invalid request code */
-#define EBADSLT 55 /* Invalid slot */
-#define EDEADLOCK 56 /* File locking deadlock error */
-#define EBFONT 57 /* Bad font file fmt */
-#endif
-#define ENOSTR 60 /* Device not a stream */
-#define ENODATA 61 /* No data (for no delay io) */
-#define ETIME 62 /* Timer expired */
-#define ENOSR 63 /* Out of streams resources */
-#ifdef __LINUX_ERRNO_EXTENSIONS__
-#define ENONET 64 /* Machine is not on the network */
-#define ENOPKG 65 /* Package not installed */
-#define EREMOTE 66 /* The object is remote */
-#endif
-#define ENOLINK 67 /* The link has been severed */
-#ifdef __LINUX_ERRNO_EXTENSIONS__
-#define EADV 68 /* Advertise error */
-#define ESRMNT 69 /* Srmount error */
-#define ECOMM 70 /* Communication error on send */
-#endif
-#define EPROTO 71 /* Protocol error */
-#define EMULTIHOP 74 /* Multihop attempted */
-#ifdef __LINUX_ERRNO_EXTENSIONS__
-#define ELBIN 75 /* Inode is remote (not really error) */
-#define EDOTDOT 76 /* Cross mount point (not really error) */
-#endif
-#define EBADMSG 77 /* Trying to read unreadable message */
-#define EFTYPE 79 /* Inappropriate file type or format */
-#ifdef __LINUX_ERRNO_EXTENSIONS__
-#define ENOTUNIQ 80 /* Given log. name not unique */
-#define EBADFD 81 /* f.d. invalid for this operation */
-#define EREMCHG 82 /* Remote address changed */
-#define ELIBACC 83 /* Can't access a needed shared lib */
-#define ELIBBAD 84 /* Accessing a corrupted shared lib */
-#define ELIBSCN 85 /* .lib section in a.out corrupted */
-#define ELIBMAX 86 /* Attempting to link in too many libs */
-#define ELIBEXEC 87 /* Attempting to exec a shared library */
-#endif
-#define ENOSYS 88 /* Function not implemented */
-#ifdef __CYGWIN__
-#define ENMFILE 89 /* No more files */
-#endif
-#define ENOTEMPTY 90 /* Directory not empty */
-#define ENAMETOOLONG 91 /* File or path name too long */
-#define ELOOP 92 /* Too many symbolic links */
-#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */
-#define EPFNOSUPPORT 96 /* Protocol family not supported */
-#define ECONNRESET 104 /* Connection reset by peer */
-#define ENOBUFS 105 /* No buffer space available */
-#define EAFNOSUPPORT 106 /* Address family not supported by protocol family */
-#define EPROTOTYPE 107 /* Protocol wrong type for socket */
-#define ENOTSOCK 108 /* Socket operation on non-socket */
-#define ENOPROTOOPT 109 /* Protocol not available */
-#ifdef __LINUX_ERRNO_EXTENSIONS__
-#define ESHUTDOWN 110 /* Can't send after socket shutdown */
-#endif
-#define ECONNREFUSED 111 /* Connection refused */
-#define EADDRINUSE 112 /* Address already in use */
-#define ECONNABORTED 113 /* Connection aborted */
-#define ENETUNREACH 114 /* Network is unreachable */
-#define ENETDOWN 115 /* Network interface is not configured */
-#define ETIMEDOUT 116 /* Connection timed out */
-#define EHOSTDOWN 117 /* Host is down */
-#define EHOSTUNREACH 118 /* Host is unreachable */
-#define EINPROGRESS 119 /* Connection already in progress */
-#define EALREADY 120 /* Socket already connected */
-#define EDESTADDRREQ 121 /* Destination address required */
-#define EMSGSIZE 122 /* Message too long */
-#define EPROTONOSUPPORT 123 /* Unknown protocol */
-#ifdef __LINUX_ERRNO_EXTENSIONS__
-#define ESOCKTNOSUPPORT 124 /* Socket type not supported */
-#endif
-#define EADDRNOTAVAIL 125 /* Address not available */
-#define ENETRESET 126
-#define EISCONN 127 /* Socket is already connected */
-#define ENOTCONN 128 /* Socket is not connected */
-#define ETOOMANYREFS 129
-#ifdef __LINUX_ERRNO_EXTENSIONS__
-#define EPROCLIM 130
-#define EUSERS 131
-#endif
-#define EDQUOT 132
-#define ESTALE 133
-#define ENOTSUP 134 /* Not supported */
-#ifdef __LINUX_ERRNO_EXTENSIONS__
-#define ENOMEDIUM 135 /* No medium (in tape drive) */
-#endif
-#ifdef __CYGWIN__
-#define ENOSHARE 136 /* No such host or network path */
-#define ECASECLASH 137 /* Filename exists with different case */
-#endif
-#define EILSEQ 138
-#define EOVERFLOW 139 /* Value too large for defined data type */
-#define ECANCELED 140 /* Operation canceled */
-#define ENOTRECOVERABLE 141 /* State not recoverable */
-#define EOWNERDEAD 142 /* Previous owner died */
-#ifdef __LINUX_ERRNO_EXTENSIONS__
-#define ESTRPIPE 143 /* Streams pipe error */
-#endif
-#define EWOULDBLOCK EAGAIN /* Operation would block */
-
-#define __ELASTERROR 2000 /* Users can add values starting here */
-
-#ifdef __cplusplus
-}
-#endif
-#endif /* _SYS_ERRNO_H */
+#warning redirecting incorrect #include <sys/errno.h> to <errno.h>
+#include <errno.h>
diff --git a/system/include/libc/sys/eventfd.h b/system/include/libc/sys/eventfd.h
new file mode 100644
index 00000000..dc5c88f0
--- /dev/null
+++ b/system/include/libc/sys/eventfd.h
@@ -0,0 +1,26 @@
+#ifndef _SYS_EVENTFD_H
+#define _SYS_EVENTFD_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+#include <fcntl.h>
+
+typedef uint64_t eventfd_t;
+
+#define EFD_SEMAPHORE 1
+#define EFD_CLOEXEC O_CLOEXEC
+#define EFD_NONBLOCK O_NONBLOCK
+
+int eventfd(unsigned int, int);
+int eventfd_read(int, eventfd_t *);
+int eventfd_write(int, eventfd_t);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* sys/eventfd.h */
diff --git a/system/include/libc/sys/fcntl.h b/system/include/libc/sys/fcntl.h
index be85f40c..3dd928ef 100644
--- a/system/include/libc/sys/fcntl.h
+++ b/system/include/libc/sys/fcntl.h
@@ -1,4 +1,2 @@
-#ifndef _SYS_FCNTL_H_
-#define _SYS_FCNTL_H_
-#include <sys/_default_fcntl.h>
-#endif
+#warning redirecting incorrect #include <sys/fcntl.h> to <fcntl.h>
+#include <fcntl.h>
diff --git a/system/include/libc/sys/features.h b/system/include/libc/sys/features.h
deleted file mode 100644
index 8c32bf04..00000000
--- a/system/include/libc/sys/features.h
+++ /dev/null
@@ -1,212 +0,0 @@
-/*
- * Written by Joel Sherrill <joel@OARcorp.com>.
- *
- * COPYRIGHT (c) 1989-2000.
- *
- * On-Line Applications Research Corporation (OAR).
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose without fee is hereby granted, provided that this entire notice
- * is included in all copies of any software which is or includes a copy
- * or modification of this software.
- *
- * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
- * WARRANTY. IN PARTICULAR, THE AUTHOR MAKES NO REPRESENTATION
- * OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY OF THIS
- * SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
- *
- * $Id: features.h,v 1.22 2010/08/09 08:29:22 corinna Exp $
- */
-
-#ifndef _SYS_FEATURES_H
-#define _SYS_FEATURES_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#if EMSCRIPTEN
-#define _POSIX_REALTIME_SIGNALS 1
-#define _POSIX_THREADS 200112L
-#define _UNIX98_THREAD_MUTEX_ATTRIBUTES 1
-#define _POSIX_READER_WRITER_LOCKS 200112L
-#endif
-
-/* RTEMS adheres to POSIX -- 1003.1b with some features from annexes. */
-
-#ifdef __rtems__
-#define _POSIX_JOB_CONTROL 1
-#define _POSIX_SAVED_IDS 1
-#define _POSIX_VERSION 199309L
-#define _POSIX_ASYNCHRONOUS_IO 1
-#define _POSIX_FSYNC 1
-#define _POSIX_MAPPED_FILES 1
-#define _POSIX_MEMLOCK 1
-#define _POSIX_MEMLOCK_RANGE 1
-#define _POSIX_MEMORY_PROTECTION 1
-#define _POSIX_MESSAGE_PASSING 1
-#define _POSIX_MONOTONIC_CLOCK 200112L
-#define _POSIX_PRIORITIZED_IO 1
-#define _POSIX_PRIORITY_SCHEDULING 1
-#define _POSIX_REALTIME_SIGNALS 1
-#define _POSIX_SEMAPHORES 1
-/* #define _POSIX_SHARED_MEMORY_OBJECTS 1 */
-#define _POSIX_SYNCHRONIZED_IO 1
-#define _POSIX_TIMERS 1
-#define _POSIX_BARRIERS 200112L
-#define _POSIX_READER_WRITER_LOCKS 200112L
-#define _POSIX_SPIN_LOCKS 200112L
-
-
-/* In P1003.1b but defined by drafts at least as early as P1003.1c/D10 */
-#define _POSIX_THREADS 1
-#define _POSIX_THREAD_ATTR_STACKADDR 1
-#define _POSIX_THREAD_ATTR_STACKSIZE 1
-#define _POSIX_THREAD_PRIORITY_SCHEDULING 1
-#define _POSIX_THREAD_PRIO_INHERIT 1
-#define _POSIX_THREAD_PRIO_PROTECT 1
-#define _POSIX_THREAD_PROCESS_SHARED 1
-#define _POSIX_THREAD_SAFE_FUNCTIONS 1
-
-/* P1003.4b/D8 defines the constants below this comment. */
-#define _POSIX_SPAWN 1
-#define _POSIX_TIMEOUTS 1
-#define _POSIX_CPUTIME 1
-#define _POSIX_THREAD_CPUTIME 1
-#define _POSIX_SPORADIC_SERVER 1
-#define _POSIX_THREAD_SPORADIC_SERVER 1
-#define _POSIX_DEVICE_CONTROL 1
-#define _POSIX_DEVCTL_DIRECTION 1
-#define _POSIX_INTERRUPT_CONTROL 1
-#define _POSIX_ADVISORY_INFO 1
-
-/* UNIX98 added some new pthread mutex attributes */
-#define _UNIX98_THREAD_MUTEX_ATTRIBUTES 1
-
-#endif
-
-/* XMK loosely adheres to POSIX -- 1003.1 */
-#ifdef __XMK__
-#define _POSIX_THREADS 1
-#define _POSIX_THREAD_PRIORITY_SCHEDULING 1
-#endif
-
-
-#ifdef __svr4__
-# define _POSIX_JOB_CONTROL 1
-# define _POSIX_SAVED_IDS 1
-# define _POSIX_VERSION 199009L
-#endif
-
-#ifdef __CYGWIN__
-
-#if !defined(__STRICT_ANSI__) || defined(__cplusplus) || __STDC_VERSION__ >= 199901L
-#define _POSIX_VERSION 200112L
-#define _POSIX2_VERSION 200112L
-#define _XOPEN_VERSION 600
-
-#define _POSIX_ADVISORY_INFO 200112L
-/* #define _POSIX_ASYNCHRONOUS_IO -1 */
-/* #define _POSIX_BARRIERS -1 */
-#define _POSIX_CHOWN_RESTRICTED 1
-/* #define _POSIX_CLOCK_SELECTION -1 */
-/* #define _POSIX_CPUTIME -1 */
-#define _POSIX_FSYNC 200112L
-#define _POSIX_IPV6 200112L
-#define _POSIX_JOB_CONTROL 1
-#define _POSIX_MAPPED_FILES 200112L
-/* #define _POSIX_MEMLOCK -1 */
-#define _POSIX_MEMLOCK_RANGE 200112L
-#define _POSIX_MEMORY_PROTECTION 200112L
-#define _POSIX_MESSAGE_PASSING 200112L
-#define _POSIX_MONOTONIC_CLOCK 200112L
-#define _POSIX_NO_TRUNC 1
-/* #define _POSIX_PRIORITIZED_IO -1 */
-#define _POSIX_PRIORITY_SCHEDULING 200112L
-#define _POSIX_RAW_SOCKETS 200112L
-#define _POSIX_READER_WRITER_LOCKS 200112L
-#define _POSIX_REALTIME_SIGNALS 200112L
-#define _POSIX_REGEXP 1
-#define _POSIX_SAVED_IDS 1
-#define _POSIX_SEMAPHORES 200112L
-#define _POSIX_SHARED_MEMORY_OBJECTS 200112L
-#define _POSIX_SHELL 1
-/* #define _POSIX_SPAWN -1 */
-/* #define _POSIX_SPIN_LOCKS -1 */
-/* #define _POSIX_SPORADIC_SERVER -1 */
-#define _POSIX_SYNCHRONIZED_IO 200112L
-/* #define _POSIX_THREAD_ATTR_STACKADDR -1 */
-#define _POSIX_THREAD_ATTR_STACKSIZE 200112L
-/* #define _POSIX_THREAD_CPUTIME -1 */
-/* #define _POSIX_THREAD_PRIO_INHERIT -1 */
-/* #define _POSIX_THREAD_PRIO_PROTECT -1 */
-#define _POSIX_THREAD_PRIORITY_SCHEDULING 200112L
-#define _POSIX_THREAD_PROCESS_SHARED 200112L
-#define _POSIX_THREAD_SAFE_FUNCTIONS 200112L
-/* #define _POSIX_THREAD_SPORADIC_SERVER -1 */
-#define _POSIX_THREADS 200112L
-/* #define _POSIX_TIMEOUTS -1 */
-#define _POSIX_TIMERS 1
-/* #define _POSIX_TRACE -1 */
-/* #define _POSIX_TRACE_EVENT_FILTER -1 */
-/* #define _POSIX_TRACE_INHERIT -1 */
-/* #define _POSIX_TRACE_LOG -1 */
-/* #define _POSIX_TYPED_MEMORY_OBJECTS -1 */
-#define _POSIX_VDISABLE '\0'
-#define _POSIX2_C_BIND 200112L
-#define _POSIX2_C_DEV 200112L
-#define _POSIX2_CHAR_TERM 200112L
-/* #define _POSIX2_FORT_DEV -1 */
-/* #define _POSIX2_FORT_RUN -1 */
-/* #define _POSIX2_LOCALEDEF -1 */
-/* #define _POSIX2_PBS -1 */
-/* #define _POSIX2_PBS_ACCOUNTING -1 */
-/* #define _POSIX2_PBS_CHECKPOINT -1 */
-/* #define _POSIX2_PBS_LOCATE -1 */
-/* #define _POSIX2_PBS_MESSAGE -1 */
-/* #define _POSIX2_PBS_TRACK -1 */
-#define _POSIX2_SW_DEV 200112L
-#define _POSIX2_UPE 200112L
-#define _POSIX_V6_ILP32_OFF32 -1
-#define _XBS5_ILP32_OFF32 _POSIX_V6_ILP32_OFF32
-#define _POSIX_V6_ILP32_OFFBIG 1
-#define _XBS5_ILP32_OFFBIG _POSIX_V6_ILP32_OFFBIG
-#define _POSIX_V6_LP64_OFF64 -1
-#define _XBS5_LP64_OFF64 _POSIX_V6_LP64_OFF64
-#define _POSIX_V6_LPBIG_OFFBIG -1
-#define _XBS5_LPBIG_OFFBIG _POSIX_V6_LPBIG_OFFBIG
-#define _XOPEN_CRYPT 1
-#define _XOPEN_ENH_I18N 1
-/* #define _XOPEN_LEGACY -1 */
-/* #define _XOPEN_REALTIME -1 */
-/* #define _XOPEN_REALTIME_THREADS -1 */
-#define _XOPEN_SHM 1
-/* #define _XOPEN_STREAMS -1 */
-/* #define _XOPEN_UNIX -1 */
-
-#endif /* !__STRICT_ANSI__ || __cplusplus || __STDC_VERSION__ >= 199901L */
-#endif /* __CYGWIN__ */
-
-/* Per the permission given in POSIX.1-2008 section 2.2.1, define
- * _POSIX_C_SOURCE if _XOPEN_SOURCE is defined and _POSIX_C_SOURCE is not.
- * (_XOPEN_SOURCE indicates that XSI extensions are desired by an application.)
- * This permission is first granted in 2008, but use it for older ones, also.
- * Allow for _XOPEN_SOURCE to be empty (from the earliest form of it, before it
- * was required to have specific values).
- */
-#if !defined(_POSIX_C_SOURCE) && defined(_XOPEN_SOURCE)
- #if (_XOPEN_SOURCE - 0) == 700 /* POSIX.1-2008 */
- #define _POSIX_C_SOURCE 200809L
- #elif (_XOPEN_SOURCE - 0) == 600 /* POSIX.1-2001 or 2004 */
- #define _POSIX_C_SOURCE 200112L
- #elif (_XOPEN_SOURCE - 0) == 500 /* POSIX.1-1995 */
- #define _POSIX_C_SOURCE 199506L
- #elif (_XOPEN_SOURCE - 0) < 500 /* really old */
- #define _POSIX_C_SOURCE 2
- #endif
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-#endif /* _SYS_FEATURES_H */
diff --git a/system/include/libc/sys/file.h b/system/include/libc/sys/file.h
index 58d4fac3..4fc83b98 100644
--- a/system/include/libc/sys/file.h
+++ b/system/include/libc/sys/file.h
@@ -1,2 +1,21 @@
+#ifndef _SYS_FILE_H
+#define _SYS_FILE_H
+#ifdef __cplusplus
+extern "C" {
+#endif
-#include <sys/fcntl.h>
+#define LOCK_SH 1
+#define LOCK_EX 2
+#define LOCK_NB 4
+#define LOCK_UN 8
+
+#define L_SET 0
+#define L_INCR 1
+#define L_XTND 2
+
+int flock(int, int);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/system/include/libc/sys/fsuid.h b/system/include/libc/sys/fsuid.h
new file mode 100644
index 00000000..c7a9b8fa
--- /dev/null
+++ b/system/include/libc/sys/fsuid.h
@@ -0,0 +1,20 @@
+#ifndef _SYS_FSUID_H
+#define _SYS_FSUID_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define __NEED_uid_t
+#define __NEED_gid_t
+
+#include <bits/alltypes.h>
+
+int setfsuid(uid_t);
+int setfsgid(gid_t);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/sys/iconvnls.h b/system/include/libc/sys/iconvnls.h
deleted file mode 100644
index 09ea1831..00000000
--- a/system/include/libc/sys/iconvnls.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (c) 2003-2004, Artem B. Bityuckiy.
- * Rights transferred to Franklin Electronic Publishers.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*
- * Funtions, macros, etc implimented in iconv library but used by other
- * NLS-related subsystems too.
- */
-#ifndef __SYS_ICONVNLS_H__
-#define __SYS_ICONVNLS_H__
-
-#include <_ansi.h>
-#include <reent.h>
-#include <wchar.h>
-#include <iconv.h>
-
-/* Iconv data path environment variable name */
-#define NLS_ENVVAR_NAME "NLSPATH"
-/* Default NLSPATH value */
-#define ICONV_DEFAULT_NLSPATH "/usr/locale"
-/* Direction markers */
-#define ICONV_NLS_FROM 0
-#define ICONV_NLS_TO 1
-
-_VOID
-_EXFUN(_iconv_nls_get_state, (iconv_t cd, mbstate_t *ps, int direction));
-
-int
-_EXFUN(_iconv_nls_set_state, (iconv_t cd, mbstate_t *ps, int direction));
-
-int
-_EXFUN(_iconv_nls_is_stateful, (iconv_t cd, int direction));
-
-int
-_EXFUN(_iconv_nls_get_mb_cur_max, (iconv_t cd, int direction));
-
-size_t
-_EXFUN(_iconv_nls_conv, (struct _reent *rptr, iconv_t cd,
- _CONST char **inbuf, size_t *inbytesleft,
- char **outbuf, size_t *outbytesleft));
-
-_CONST char *
-_EXFUN(_iconv_nls_construct_filename, (struct _reent *rptr, _CONST char *file,
- _CONST char *dir, _CONST char *ext));
-
-
-int
-_EXFUN(_iconv_nls_open, (struct _reent *rptr, _CONST char *encoding,
- iconv_t *towc, iconv_t *fromwc, int flag));
-
-char *
-_EXFUN(_iconv_resolve_encoding_name, (struct _reent *rptr, _CONST char *ca));
-
-#endif /* __SYS_ICONVNLS_H__ */
-
diff --git a/system/include/libc/sys/inotify.h b/system/include/libc/sys/inotify.h
new file mode 100644
index 00000000..a5bf96a6
--- /dev/null
+++ b/system/include/libc/sys/inotify.h
@@ -0,0 +1,57 @@
+#ifndef _SYS_INOTIFY_H
+#define _SYS_INOTIFY_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+#include <fcntl.h>
+
+struct inotify_event {
+ int wd;
+ uint32_t mask, cookie, len;
+ char name[];
+};
+
+#define IN_CLOEXEC O_CLOEXEC
+#define IN_NONBLOCK O_NONBLOCK
+
+#define IN_ACCESS 0x00000001
+#define IN_MODIFY 0x00000002
+#define IN_ATTRIB 0x00000004
+#define IN_CLOSE_WRITE 0x00000008
+#define IN_CLOSE_NOWRITE 0x00000010
+#define IN_CLOSE (IN_CLOSE_WRITE | IN_CLOSE_NOWRITE)
+#define IN_OPEN 0x00000020
+#define IN_MOVED_FROM 0x00000040
+#define IN_MOVED_TO 0x00000080
+#define IN_MOVE (IN_MOVED_FROM | IN_MOVED_TO)
+#define IN_CREATE 0x00000100
+#define IN_DELETE 0x00000200
+#define IN_DELETE_SELF 0x00000400
+#define IN_MOVE_SELF 0x00000800
+#define IN_ALL_EVENTS 0x00000fff
+
+#define IN_UNMOUNT 0x00002000
+#define IN_Q_OVERFLOW 0x00004000
+#define IN_IGNORED 0x00008000
+
+#define IN_ONLYDIR 0x01000000
+#define IN_DONT_FOLLOW 0x02000000
+#define IN_EXCL_UNLINK 0x04000000
+#define IN_MASK_ADD 0x20000000
+
+#define IN_ISDIR 0x40000000
+#define IN_ONESHOT 0x80000000
+
+int inotify_init(void);
+int inotify_init1(int);
+int inotify_add_watch(int, const char *, uint32_t);
+int inotify_rm_watch(int, uint32_t);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/sys/io.h b/system/include/libc/sys/io.h
new file mode 100644
index 00000000..16658cec
--- /dev/null
+++ b/system/include/libc/sys/io.h
@@ -0,0 +1,17 @@
+#ifndef _SYS_IO_H
+#define _SYS_IO_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <features.h>
+
+#include <bits/io.h>
+
+int iopl(int);
+int ioperm(unsigned long, unsigned long, int);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/system/include/libc/sys/ioctl.h b/system/include/libc/sys/ioctl.h
new file mode 100644
index 00000000..d0415b3d
--- /dev/null
+++ b/system/include/libc/sys/ioctl.h
@@ -0,0 +1,14 @@
+#ifndef _SYS_IOCTL_H
+#define _SYS_IOCTL_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <bits/ioctl.h>
+
+int ioctl (int, int, ...);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/system/include/libc/sys/ipc.h b/system/include/libc/sys/ipc.h
new file mode 100644
index 00000000..c5a39819
--- /dev/null
+++ b/system/include/libc/sys/ipc.h
@@ -0,0 +1,42 @@
+#ifndef _SYS_IPC_H
+#define _SYS_IPC_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <features.h>
+
+#define __NEED_uid_t
+#define __NEED_gid_t
+#define __NEED_mode_t
+#define __NEED_key_t
+
+#include <bits/alltypes.h>
+
+#define __ipc_perm_key __key
+#define __ipc_perm_seq __seq
+
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+#define __key key
+#define __seq seq
+#endif
+
+#include <bits/ipc.h>
+
+#define IPC_CREAT 01000
+#define IPC_EXCL 02000
+#define IPC_NOWAIT 04000
+
+#define IPC_RMID 0
+#define IPC_SET 1
+#define IPC_STAT 2
+#define IPC_INFO 3
+
+#define IPC_PRIVATE ((key_t) 0)
+
+key_t ftok (const char *, int);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/system/include/sys/io.h b/system/include/libc/sys/klog.h
index 8caea237..aa66684e 100644
--- a/system/include/sys/io.h
+++ b/system/include/libc/sys/klog.h
@@ -1,14 +1,14 @@
-
-#ifndef _SYS_IO_H
-#define _SYS_IO_H
+#ifndef _SYS_KLOG_H
+#define _SYS_KLOG_H
#ifdef __cplusplus
extern "C" {
#endif
+int klogctl (int, char *, int);
+
#ifdef __cplusplus
}
#endif
#endif
-
diff --git a/system/include/libc/sys/lock.h b/system/include/libc/sys/lock.h
deleted file mode 100644
index 9075e35c..00000000
--- a/system/include/libc/sys/lock.h
+++ /dev/null
@@ -1,24 +0,0 @@
-#ifndef __SYS_LOCK_H__
-#define __SYS_LOCK_H__
-
-/* dummy lock routines for single-threaded aps */
-
-typedef int _LOCK_T;
-typedef int _LOCK_RECURSIVE_T;
-
-#include <_ansi.h>
-
-#define __LOCK_INIT(class,lock) static int lock = 0;
-#define __LOCK_INIT_RECURSIVE(class,lock) static int lock = 0;
-#define __lock_init(lock) (_CAST_VOID 0)
-#define __lock_init_recursive(lock) (_CAST_VOID 0)
-#define __lock_close(lock) (_CAST_VOID 0)
-#define __lock_close_recursive(lock) (_CAST_VOID 0)
-#define __lock_acquire(lock) (_CAST_VOID 0)
-#define __lock_acquire_recursive(lock) (_CAST_VOID 0)
-#define __lock_try_acquire(lock) (_CAST_VOID 0)
-#define __lock_try_acquire_recursive(lock) (_CAST_VOID 0)
-#define __lock_release(lock) (_CAST_VOID 0)
-#define __lock_release_recursive(lock) (_CAST_VOID 0)
-
-#endif /* __SYS_LOCK_H__ */
diff --git a/system/include/libc/sys/mman.h b/system/include/libc/sys/mman.h
new file mode 100644
index 00000000..9a1e60ff
--- /dev/null
+++ b/system/include/libc/sys/mman.h
@@ -0,0 +1,55 @@
+#ifndef _SYS_MMAN_H
+#define _SYS_MMAN_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <features.h>
+
+#define __NEED_mode_t
+#define __NEED_size_t
+#define __NEED_off_t
+
+#if defined(_GNU_SOURCE)
+#define __NEED_ssize_t
+#endif
+
+#include <bits/alltypes.h>
+
+#include <bits/mman.h>
+
+void *mmap (void *, size_t, int, int, int, off_t);
+int munmap (void *, size_t);
+
+int mprotect (void *, size_t, int);
+int msync (void *, size_t, int);
+
+int posix_madvise (void *, size_t, int);
+
+int mlock (const void *, size_t);
+int munlock (const void *, size_t);
+int mlockall (int);
+int munlockall (void);
+
+#ifdef _GNU_SOURCE
+void *mremap (void *, size_t, size_t, int, ...);
+int remap_file_pages (void *, size_t, int, ssize_t, int);
+#endif
+
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+int madvise (void *, size_t, int);
+int mincore (void *, size_t, unsigned char *);
+#endif
+
+int shm_open (const char *, int, mode_t);
+int shm_unlink (const char *);
+
+#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
+#define mmap64 mmap
+#define off64_t off_t
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/system/include/libc/sys/mount.h b/system/include/libc/sys/mount.h
new file mode 100644
index 00000000..1e1907f4
--- /dev/null
+++ b/system/include/libc/sys/mount.h
@@ -0,0 +1,72 @@
+#ifndef _SYS_MOUNT_H
+#define _SYS_MOUNT_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <sys/ioctl.h>
+
+#define BLKROSET _IO(0x12, 93)
+#define BLKROGET _IO(0x12, 94)
+#define BLKRRPART _IO(0x12, 95)
+#define BLKGETSIZE _IO(0x12, 96)
+#define BLKFLSBUF _IO(0x12, 97)
+#define BLKRASET _IO(0x12, 98)
+#define BLKRAGET _IO(0x12, 99)
+#define BLKFRASET _IO(0x12,100)
+#define BLKFRAGET _IO(0x12,101)
+#define BLKSECTSET _IO(0x12,102)
+#define BLKSECTGET _IO(0x12,103)
+#define BLKSSZGET _IO(0x12,104)
+#define BLKBSZGET _IOR(0x12,112,size_t)
+#define BLKBSZSET _IOW(0x12,113,size_t)
+#define BLKGETSIZE64 _IOR(0x12,114,size_t)
+
+#define MS_RDONLY 1
+#define MS_NOSUID 2
+#define MS_NODEV 4
+#define MS_NOEXEC 8
+#define MS_SYNCHRONOUS 16
+#define MS_REMOUNT 32
+#define MS_MANDLOCK 64
+#define MS_DIRSYNC 128
+#define MS_NOATIME 1024
+#define MS_NODIRATIME 2048
+#define MS_BIND 4096
+#define MS_MOVE 8192
+#define MS_REC 16384
+#define MS_SILENT 32768
+#define MS_POSIXACL (1<<16)
+#define MS_UNBINDABLE (1<<17)
+#define MS_PRIVATE (1<<18)
+#define MS_SLAVE (1<<19)
+#define MS_SHARED (1<<20)
+#define MS_RELATIME (1<<21)
+#define MS_KERNMOUNT (1<<22)
+#define MS_I_VERSION (1<<23)
+#define MS_STRICTATIME (1<<24)
+#define MS_NOSEC (1<<28)
+#define MS_BORN (1<<29)
+#define MS_ACTIVE (1<<30)
+#define MS_NOUSER (1U<<31)
+
+#define MS_RMT_MASK (MS_RDONLY|MS_SYNCHRONOUS|MS_MANDLOCK|MS_I_VERSION)
+
+#define MS_MGC_VAL 0xc0ed0000
+#define MS_MGC_MSK 0xffff0000
+
+#define MNT_FORCE 1
+#define MNT_DETACH 2
+#define MNT_EXPIRE 4
+#define UMOUNT_NOFOLLOW 8
+
+int mount(const char *, const char *, const char *, unsigned long, const void *);
+int umount(const char *);
+int umount2(const char *, int);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/sys/msg.h b/system/include/libc/sys/msg.h
new file mode 100644
index 00000000..ceedd1c6
--- /dev/null
+++ b/system/include/libc/sys/msg.h
@@ -0,0 +1,51 @@
+#ifndef _SYS_MSG_H
+#define _SYS_MSG_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <sys/ipc.h>
+
+#define __NEED_pid_t
+#define __NEED_key_t
+#define __NEED_time_t
+#define __NEED_size_t
+#define __NEED_ssize_t
+
+#include <bits/alltypes.h>
+
+typedef unsigned long msgqnum_t;
+typedef unsigned long msglen_t;
+
+#include <bits/msg.h>
+
+#define __msg_cbytes msg_cbytes
+
+#define MSG_NOERROR 010000
+
+#define MSG_STAT 11
+#define MSG_INFO 12
+
+struct msginfo {
+ int msgpool, msgmap, msgmax, msgmnb, msgmni, msgssz, msgtql;
+ unsigned short msgseg;
+};
+
+int msgctl (int, int, struct msqid_ds *);
+int msgget (key_t, int);
+ssize_t msgrcv (int, void *, size_t, long, int);
+int msgsnd (int, const void *, size_t, int);
+
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+struct msgbuf {
+ long mtype;
+ char mtext[1];
+};
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/sys/mtio.h b/system/include/libc/sys/mtio.h
new file mode 100644
index 00000000..dc8e5f52
--- /dev/null
+++ b/system/include/libc/sys/mtio.h
@@ -0,0 +1,188 @@
+#ifndef _SYS_MTIO_H
+#define _SYS_MTIO_H
+
+#include <sys/types.h>
+#include <sys/ioctl.h>
+
+struct mtop {
+ short mt_op;
+ int mt_count;
+};
+
+#define _IOT_mtop _IOT (_IOTS (short), 1, _IOTS (int), 1, 0, 0)
+#define _IOT_mtget _IOT (_IOTS (long), 7, 0, 0, 0, 0)
+#define _IOT_mtpos _IOT_SIMPLE (long)
+#define _IOT_mtconfiginfo _IOT (_IOTS (long), 2, _IOTS (short), 3, _IOTS (long), 1)
+
+
+#define MTRESET 0
+#define MTFSF 1
+#define MTBSF 2
+#define MTFSR 3
+#define MTBSR 4
+#define MTWEOF 5
+#define MTREW 6
+#define MTOFFL 7
+#define MTNOP 8
+#define MTRETEN 9
+#define MTBSFM 10
+#define MTFSFM 11
+#define MTEOM 12
+#define MTERASE 13
+#define MTRAS1 14
+#define MTRAS2 15
+#define MTRAS3 16
+#define MTSETBLK 20
+#define MTSETDENSITY 21
+#define MTSEEK 22
+#define MTTELL 23
+#define MTSETDRVBUFFER 24
+#define MTFSS 25
+#define MTBSS 26
+#define MTWSM 27
+#define MTLOCK 28
+#define MTUNLOCK 29
+#define MTLOAD 30
+#define MTUNLOAD 31
+#define MTCOMPRESSION 32
+#define MTSETPART 33
+#define MTMKPART 34
+
+struct mtget {
+ long mt_type;
+ long mt_resid;
+ long mt_dsreg;
+ long mt_gstat;
+ long mt_erreg;
+ int mt_fileno;
+ int mt_blkno;
+};
+
+#define MT_ISUNKNOWN 0x01
+#define MT_ISQIC02 0x02
+#define MT_ISWT5150 0x03
+#define MT_ISARCHIVE_5945L2 0x04
+#define MT_ISCMSJ500 0x05
+#define MT_ISTDC3610 0x06
+#define MT_ISARCHIVE_VP60I 0x07
+#define MT_ISARCHIVE_2150L 0x08
+#define MT_ISARCHIVE_2060L 0x09
+#define MT_ISARCHIVESC499 0x0A
+#define MT_ISQIC02_ALL_FEATURES 0x0F
+#define MT_ISWT5099EEN24 0x11
+#define MT_ISTEAC_MT2ST 0x12
+#define MT_ISEVEREX_FT40A 0x32
+#define MT_ISDDS1 0x51
+#define MT_ISDDS2 0x52
+#define MT_ISSCSI1 0x71
+#define MT_ISSCSI2 0x72
+#define MT_ISFTAPE_UNKNOWN 0x800000
+#define MT_ISFTAPE_FLAG 0x800000
+
+struct mt_tape_info {
+ long t_type;
+ char *t_name;
+};
+
+#define MT_TAPE_INFO \
+{ \
+ {MT_ISUNKNOWN, "Unknown type of tape device"}, \
+ {MT_ISQIC02, "Generic QIC-02 tape streamer"}, \
+ {MT_ISWT5150, "Wangtek 5150, QIC-150"}, \
+ {MT_ISARCHIVE_5945L2, "Archive 5945L-2"}, \
+ {MT_ISCMSJ500, "CMS Jumbo 500"}, \
+ {MT_ISTDC3610, "Tandberg TDC 3610, QIC-24"}, \
+ {MT_ISARCHIVE_VP60I, "Archive VP60i, QIC-02"}, \
+ {MT_ISARCHIVE_2150L, "Archive Viper 2150L"}, \
+ {MT_ISARCHIVE_2060L, "Archive Viper 2060L"}, \
+ {MT_ISARCHIVESC499, "Archive SC-499 QIC-36 controller"}, \
+ {MT_ISQIC02_ALL_FEATURES, "Generic QIC-02 tape, all features"}, \
+ {MT_ISWT5099EEN24, "Wangtek 5099-een24, 60MB"}, \
+ {MT_ISTEAC_MT2ST, "Teac MT-2ST 155mb data cassette drive"}, \
+ {MT_ISEVEREX_FT40A, "Everex FT40A, QIC-40"}, \
+ {MT_ISSCSI1, "Generic SCSI-1 tape"}, \
+ {MT_ISSCSI2, "Generic SCSI-2 tape"}, \
+ {0, NULL} \
+}
+
+struct mtpos {
+ long mt_blkno;
+};
+
+struct mtconfiginfo {
+ long mt_type;
+ long ifc_type;
+ unsigned short irqnr;
+ unsigned short dmanr;
+ unsigned short port;
+ unsigned long debug;
+ unsigned have_dens:1;
+ unsigned have_bsf:1;
+ unsigned have_fsr:1;
+ unsigned have_bsr:1;
+ unsigned have_eod:1;
+ unsigned have_seek:1;
+ unsigned have_tell:1;
+ unsigned have_ras1:1;
+ unsigned have_ras2:1;
+ unsigned have_ras3:1;
+ unsigned have_qfa:1;
+ unsigned pad1:5;
+ char reserved[10];
+};
+
+#define MTIOCTOP _IOW('m', 1, struct mtop)
+#define MTIOCGET _IOR('m', 2, struct mtget)
+#define MTIOCPOS _IOR('m', 3, struct mtpos)
+
+#define MTIOCGETCONFIG _IOR('m', 4, struct mtconfiginfo)
+#define MTIOCSETCONFIG _IOW('m', 5, struct mtconfiginfo)
+
+#define GMT_EOF(x) ((x) & 0x80000000)
+#define GMT_BOT(x) ((x) & 0x40000000)
+#define GMT_EOT(x) ((x) & 0x20000000)
+#define GMT_SM(x) ((x) & 0x10000000)
+#define GMT_EOD(x) ((x) & 0x08000000)
+#define GMT_WR_PROT(x) ((x) & 0x04000000)
+#define GMT_ONLINE(x) ((x) & 0x01000000)
+#define GMT_D_6250(x) ((x) & 0x00800000)
+#define GMT_D_1600(x) ((x) & 0x00400000)
+#define GMT_D_800(x) ((x) & 0x00200000)
+#define GMT_DR_OPEN(x) ((x) & 0x00040000)
+#define GMT_IM_REP_EN(x) ((x) & 0x00010000)
+
+#define MT_ST_BLKSIZE_SHIFT 0
+#define MT_ST_BLKSIZE_MASK 0xffffff
+#define MT_ST_DENSITY_SHIFT 24
+#define MT_ST_DENSITY_MASK 0xff000000
+#define MT_ST_SOFTERR_SHIFT 0
+#define MT_ST_SOFTERR_MASK 0xffff
+#define MT_ST_OPTIONS 0xf0000000
+#define MT_ST_BOOLEANS 0x10000000
+#define MT_ST_SETBOOLEANS 0x30000000
+#define MT_ST_CLEARBOOLEANS 0x40000000
+#define MT_ST_WRITE_THRESHOLD 0x20000000
+#define MT_ST_DEF_BLKSIZE 0x50000000
+#define MT_ST_DEF_OPTIONS 0x60000000
+#define MT_ST_BUFFER_WRITES 0x1
+#define MT_ST_ASYNC_WRITES 0x2
+#define MT_ST_READ_AHEAD 0x4
+#define MT_ST_DEBUGGING 0x8
+#define MT_ST_TWO_FM 0x10
+#define MT_ST_FAST_MTEOM 0x20
+#define MT_ST_AUTO_LOCK 0x40
+#define MT_ST_DEF_WRITES 0x80
+#define MT_ST_CAN_BSR 0x100
+#define MT_ST_NO_BLKLIMS 0x200
+#define MT_ST_CAN_PARTITIONS 0x400
+#define MT_ST_SCSI2LOGICAL 0x800
+#define MT_ST_CLEAR_DEFAULT 0xfffff
+#define MT_ST_DEF_DENSITY (MT_ST_DEF_OPTIONS | 0x100000)
+#define MT_ST_DEF_COMPRESSION (MT_ST_DEF_OPTIONS | 0x200000)
+#define MT_ST_DEF_DRVBUFFER (MT_ST_DEF_OPTIONS | 0x300000)
+#define MT_ST_HPLOADER_OFFSET 10000
+#ifndef DEFTAPE
+# define DEFTAPE "/dev/tape"
+#endif
+
+#endif
diff --git a/system/include/libc/sys/param.h b/system/include/libc/sys/param.h
index 7e8762a6..344c0d23 100644
--- a/system/include/libc/sys/param.h
+++ b/system/include/libc/sys/param.h
@@ -1,25 +1,35 @@
-/* This is a dummy <sys/param.h> file, not customized for any
- particular system. If there is a param.h in libc/sys/SYSDIR/sys,
- it will override this one. */
-
#ifndef _SYS_PARAM_H
-# define _SYS_PARAM_H
+#define _SYS_PARAM_H
-#include <sys/config.h>
-#include <machine/endian.h>
-#include <machine/param.h>
+#define MAXSYMLINKS 20
+#define MAXHOSTNAMELEN 64
+#define MAXNAMLEN 255
+#define MAXPATHLEN 4096
+#define NBBY 8
+#define NGROUPS 32
+#define CANBSIZE 255
+#define NOFILE 256
+#define NCARGS 131072
+#define DEV_BSIZE 512
+#define NOGROUP (-1)
-#ifndef HZ
-# define HZ (60)
-#endif
-#ifndef NOFILE
-# define NOFILE (60)
-#endif
-#ifndef PATHSIZE
-# define PATHSIZE (1024)
-#endif
+#undef MIN
+#undef MAX
+#define MIN(a,b) (((a)<(b))?(a):(b))
+#define MAX(a,b) (((a)>(b))?(a):(b))
+
+#define __bitop(x,i,o) ((x)[(i)/8] o (1<<(i)%8))
+#define setbit(x,i) __bitop(x,i,|=)
+#define clrbit(x,i) __bitop(x,i,&=~)
+#define isset(x,i) __bitop(x,i,&)
+#define isclr(x,i) !isset(x,i)
+
+#define howmany(n,d) (((n)+((d)-1))/(d))
+#define roundup(n,d) (howmany(n,d)*(d))
+#define powerof2(n) !(((n)-1) & (n))
-#define MAX(a,b) ((a) > (b) ? (a) : (b))
-#define MIN(a,b) ((a) < (b) ? (a) : (b))
+#include <sys/resource.h>
+#include <endian.h>
+#include <limits.h>
#endif
diff --git a/system/include/libc/sys/personality.h b/system/include/libc/sys/personality.h
new file mode 100644
index 00000000..852c0248
--- /dev/null
+++ b/system/include/libc/sys/personality.h
@@ -0,0 +1,6 @@
+#ifndef _PERSONALITY_H
+#define _PERSONALITY_H
+
+int personality(unsigned long);
+
+#endif
diff --git a/system/include/libc/sys/poll.h b/system/include/libc/sys/poll.h
new file mode 100644
index 00000000..99170401
--- /dev/null
+++ b/system/include/libc/sys/poll.h
@@ -0,0 +1,2 @@
+#warning redirecting incorrect #include <sys/poll.h> to <poll.h>
+#include <poll.h>
diff --git a/system/include/libc/sys/prctl.h b/system/include/libc/sys/prctl.h
new file mode 100644
index 00000000..d41ff0f6
--- /dev/null
+++ b/system/include/libc/sys/prctl.h
@@ -0,0 +1,101 @@
+#ifndef _SYS_PRCTL_H
+#define _SYS_PRCTL_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define PR_SET_PDEATHSIG 1
+#define PR_GET_PDEATHSIG 2
+#define PR_GET_DUMPABLE 3
+#define PR_SET_DUMPABLE 4
+#define PR_GET_UNALIGN 5
+#define PR_SET_UNALIGN 6
+#define PR_UNALIGN_NOPRINT 1
+#define PR_UNALIGN_SIGBUS 2
+#define PR_GET_KEEPCAPS 7
+#define PR_SET_KEEPCAPS 8
+#define PR_GET_FPEMU 9
+#define PR_SET_FPEMU 10
+#define PR_FPEMU_NOPRINT 1
+#define PR_FPEMU_SIGFPE 2
+#define PR_GET_FPEXC 11
+#define PR_SET_FPEXC 12
+#define PR_FP_EXC_SW_ENABLE 0x80
+#define PR_FP_EXC_DIV 0x010000
+#define PR_FP_EXC_OVF 0x020000
+#define PR_FP_EXC_UND 0x040000
+#define PR_FP_EXC_RES 0x080000
+#define PR_FP_EXC_INV 0x100000
+#define PR_FP_EXC_DISABLED 0
+#define PR_FP_EXC_NONRECOV 1
+#define PR_FP_EXC_ASYNC 2
+#define PR_FP_EXC_PRECISE 3
+#define PR_GET_TIMING 13
+#define PR_SET_TIMING 14
+#define PR_TIMING_STATISTICAL 0
+#define PR_TIMING_TIMESTAMP 1
+#define PR_SET_NAME 15
+#define PR_GET_NAME 16
+#define PR_GET_ENDIAN 19
+#define PR_SET_ENDIAN 20
+#define PR_ENDIAN_BIG 0
+#define PR_ENDIAN_LITTLE 1
+#define PR_ENDIAN_PPC_LITTLE 2
+#define PR_GET_SECCOMP 21
+#define PR_SET_SECCOMP 22
+#define PR_CAPBSET_READ 23
+#define PR_CAPBSET_DROP 24
+#define PR_GET_TSC 25
+#define PR_SET_TSC 26
+#define PR_TSC_ENABLE 1
+#define PR_TSC_SIGSEGV 2
+#define PR_GET_SECUREBITS 27
+#define PR_SET_SECUREBITS 28
+#define PR_SET_TIMERSLACK 29
+#define PR_GET_TIMERSLACK 30
+
+#define PR_TASK_PERF_EVENTS_DISABLE 31
+#define PR_TASK_PERF_EVENTS_ENABLE 32
+
+#define PR_MCE_KILL 33
+#define PR_MCE_KILL_CLEAR 0
+#define PR_MCE_KILL_SET 1
+#define PR_MCE_KILL_LATE 0
+#define PR_MCE_KILL_EARLY 1
+#define PR_MCE_KILL_DEFAULT 2
+#define PR_MCE_KILL_GET 34
+
+#define PR_SET_MM 35
+#define PR_SET_MM_START_CODE 1
+#define PR_SET_MM_END_CODE 2
+#define PR_SET_MM_START_DATA 3
+#define PR_SET_MM_END_DATA 4
+#define PR_SET_MM_START_STACK 5
+#define PR_SET_MM_START_BRK 6
+#define PR_SET_MM_BRK 7
+#define PR_SET_MM_ARG_START 8
+#define PR_SET_MM_ARG_END 9
+#define PR_SET_MM_ENV_START 10
+#define PR_SET_MM_ENV_END 11
+#define PR_SET_MM_AUXV 12
+#define PR_SET_MM_EXE_FILE 13
+
+#define PR_SET_PTRACER 0x59616d61
+#define PR_SET_PTRACER_ANY (-1UL)
+
+#define PR_SET_CHILD_SUBREAPER 36
+#define PR_GET_CHILD_SUBREAPER 37
+
+#define PR_SET_NO_NEW_PRIVS 38
+#define PR_GET_NO_NEW_PRIVS 39
+
+#define PR_GET_TID_ADDRESS 40
+
+int prctl (int, ...);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/sys/procfs.h b/system/include/libc/sys/procfs.h
new file mode 100644
index 00000000..6a346053
--- /dev/null
+++ b/system/include/libc/sys/procfs.h
@@ -0,0 +1,65 @@
+#ifndef _SYS_PROCFS_H
+#define _SYS_PROCFS_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/user.h>
+
+struct elf_siginfo {
+ int si_signo;
+ int si_code;
+ int si_errno;
+};
+
+struct elf_prstatus {
+ struct elf_siginfo pr_info;
+ short int pr_cursig;
+ unsigned long int pr_sigpend;
+ unsigned long int pr_sighold;
+ pid_t pr_pid;
+ pid_t pr_ppid;
+ pid_t pr_pgrp;
+ pid_t pr_sid;
+ struct timeval pr_utime;
+ struct timeval pr_stime;
+ struct timeval pr_cutime;
+ struct timeval pr_cstime;
+ elf_gregset_t pr_reg;
+ int pr_fpvalid;
+};
+
+#define ELF_PRARGSZ 80
+
+struct elf_prpsinfo
+ {
+ char pr_state;
+ char pr_sname;
+ char pr_zomb;
+ char pr_nice;
+ unsigned long int pr_flag;
+#if __WORDSIZE == 32
+ unsigned short int pr_uid;
+ unsigned short int pr_gid;
+#else
+ unsigned int pr_uid;
+ unsigned int pr_gid;
+#endif
+ int pr_pid, pr_ppid, pr_pgrp, pr_sid;
+ char pr_fname[16];
+ char pr_psargs[ELF_PRARGSZ];
+};
+
+typedef void *psaddr_t;
+typedef elf_gregset_t prgregset_t;
+typedef elf_fpregset_t prfpregset_t;
+typedef pid_t lwpid_t;
+typedef struct elf_prstatus prstatus_t;
+typedef struct elf_prpsinfo prpsinfo_t;
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/system/include/libc/sys/ptrace.h b/system/include/libc/sys/ptrace.h
new file mode 100644
index 00000000..6cd3afdd
--- /dev/null
+++ b/system/include/libc/sys/ptrace.h
@@ -0,0 +1,96 @@
+#ifndef _SYS_PTRACE_H
+#define _SYS_PTRACE_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+
+#define PTRACE_TRACEME 0
+#define PT_TRACE_ME PTRACE_TRACEME
+
+#define PTRACE_PEEKTEXT 1
+#define PTRACE_PEEKDATA 2
+#define PTRACE_PEEKUSER 3
+#define PTRACE_POKETEXT 4
+#define PTRACE_POKEDATA 5
+#define PTRACE_POKEUSER 6
+#define PTRACE_CONT 7
+#define PTRACE_KILL 8
+#define PTRACE_SINGLESTEP 9
+#define PTRACE_GETREGS 12
+#define PTRACE_SETREGS 13
+#define PTRACE_GETFPREGS 14
+#define PTRACE_SETFPREGS 15
+#define PTRACE_ATTACH 16
+#define PTRACE_DETACH 17
+#define PTRACE_GETFPXREGS 18
+#define PTRACE_SETFPXREGS 19
+#define PTRACE_SYSCALL 24
+#define PTRACE_SETOPTIONS 0x4200
+#define PTRACE_GETEVENTMSG 0x4201
+#define PTRACE_GETSIGINFO 0x4202
+#define PTRACE_SETSIGINFO 0x4203
+#define PTRACE_GETREGSET 0x4204
+#define PTRACE_SETREGSET 0x4205
+#define PTRACE_SEIZE 0x4206
+#define PTRACE_INTERRUPT 0x4207
+#define PTRACE_LISTEN 0x4208
+#define PTRACE_PEEKSIGINFO 0x4209
+
+#define PT_READ_I PTRACE_PEEKTEXT
+#define PT_READ_D PTRACE_PEEKDATA
+#define PT_READ_U PTRACE_PEEKUSER
+#define PT_WRITE_I PTRACE_POKETEXT
+#define PT_WRITE_D PTRACE_POKEDATA
+#define PT_WRITE_U PTRACE_POKEUSER
+#define PT_CONTINUE PTRACE_CONT
+#define PT_KILL PTRACE_KILL
+#define PT_STEP PTRACE_SINGLESTEP
+#define PT_GETREGS PTRACE_GETREGS
+#define PT_SETREGS PTRACE_SETREGS
+#define PT_GETFPREGS PTRACE_GETFPREGS
+#define PT_SETFPREGS PTRACE_SETFPREGS
+#define PT_ATTACH PTRACE_ATTACH
+#define PT_DETACH PTRACE_DETACH
+#define PT_GETFPXREGS PTRACE_GETFPXREGS
+#define PT_SETFPXREGS PTRACE_SETFPXREGS
+#define PT_SYSCALL PTRACE_SYSCALL
+#define PT_SETOPTIONS PTRACE_SETOPTIONS
+#define PT_GETEVENTMSG PTRACE_GETEVENTMSG
+#define PT_GETSIGINFO PTRACE_GETSIGINFO
+#define PT_SETSIGINFO PTRACE_SETSIGINFO
+
+#define PTRACE_O_TRACESYSGOOD 0x00000001
+#define PTRACE_O_TRACEFORK 0x00000002
+#define PTRACE_O_TRACEVFORK 0x00000004
+#define PTRACE_O_TRACECLONE 0x00000008
+#define PTRACE_O_TRACEEXEC 0x00000010
+#define PTRACE_O_TRACEVFORKDONE 0x00000020
+#define PTRACE_O_TRACEEXIT 0x00000040
+#define PTRACE_O_TRACESECCOMP 0x00000080
+#define PTRACE_O_EXITKILL 0x00100000
+#define PTRACE_O_MASK 0x001000ff
+
+#define PTRACE_EVENT_FORK 1
+#define PTRACE_EVENT_VFORK 2
+#define PTRACE_EVENT_CLONE 3
+#define PTRACE_EVENT_EXEC 4
+#define PTRACE_EVENT_VFORK_DONE 5
+#define PTRACE_EVENT_EXIT 6
+#define PTRACE_EVENT_SECCOMP 7
+
+#define PTRACE_PEEKSIGINFO_SHARED 1
+
+struct ptrace_peeksiginfo_args {
+ uint64_t off;
+ uint32_t flags;
+ int32_t nr;
+};
+
+long ptrace(int, ...);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/system/include/libc/sys/queue.h b/system/include/libc/sys/queue.h
deleted file mode 100644
index af637ca0..00000000
--- a/system/include/libc/sys/queue.h
+++ /dev/null
@@ -1,471 +0,0 @@
-/*
- * Copyright (c) 1991, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)queue.h 8.5 (Berkeley) 8/20/94
- * $FreeBSD: src/sys/sys/queue.h,v 1.48 2002/04/17 14:00:37 tmm Exp $
- */
-
-#ifndef _SYS_QUEUE_H_
-#define _SYS_QUEUE_H_
-
-#include <machine/ansi.h> /* for __offsetof */
-
-/*
- * This file defines four types of data structures: singly-linked lists,
- * singly-linked tail queues, lists and tail queues.
- *
- * A singly-linked list is headed by a single forward pointer. The elements
- * are singly linked for minimum space and pointer manipulation overhead at
- * the expense of O(n) removal for arbitrary elements. New elements can be
- * added to the list after an existing element or at the head of the list.
- * Elements being removed from the head of the list should use the explicit
- * macro for this purpose for optimum efficiency. A singly-linked list may
- * only be traversed in the forward direction. Singly-linked lists are ideal
- * for applications with large datasets and few or no removals or for
- * implementing a LIFO queue.
- *
- * A singly-linked tail queue is headed by a pair of pointers, one to the
- * head of the list and the other to the tail of the list. The elements are
- * singly linked for minimum space and pointer manipulation overhead at the
- * expense of O(n) removal for arbitrary elements. New elements can be added
- * to the list after an existing element, at the head of the list, or at the
- * end of the list. Elements being removed from the head of the tail queue
- * should use the explicit macro for this purpose for optimum efficiency.
- * A singly-linked tail queue may only be traversed in the forward direction.
- * Singly-linked tail queues are ideal for applications with large datasets
- * and few or no removals or for implementing a FIFO queue.
- *
- * A list is headed by a single forward pointer (or an array of forward
- * pointers for a hash table header). The elements are doubly linked
- * so that an arbitrary element can be removed without a need to
- * traverse the list. New elements can be added to the list before
- * or after an existing element or at the head of the list. A list
- * may only be traversed in the forward direction.
- *
- * A tail queue is headed by a pair of pointers, one to the head of the
- * list and the other to the tail of the list. The elements are doubly
- * linked so that an arbitrary element can be removed without a need to
- * traverse the list. New elements can be added to the list before or
- * after an existing element, at the head of the list, or at the end of
- * the list. A tail queue may be traversed in either direction.
- *
- * For details on the use of these macros, see the queue(3) manual page.
- *
- *
- * SLIST LIST STAILQ TAILQ
- * _HEAD + + + +
- * _HEAD_INITIALIZER + + + +
- * _ENTRY + + + +
- * _INIT + + + +
- * _EMPTY + + + +
- * _FIRST + + + +
- * _NEXT + + + +
- * _PREV - - - +
- * _LAST - - + +
- * _FOREACH + + + +
- * _FOREACH_REVERSE - - - +
- * _INSERT_HEAD + + + +
- * _INSERT_BEFORE - + - +
- * _INSERT_AFTER + + + +
- * _INSERT_TAIL - - + +
- * _CONCAT - - + +
- * _REMOVE_HEAD + - + -
- * _REMOVE + + + +
- *
- */
-
-/*
- * Singly-linked List declarations.
- */
-#define SLIST_HEAD(name, type) \
-struct name { \
- struct type *slh_first; /* first element */ \
-}
-
-#define SLIST_HEAD_INITIALIZER(head) \
- { NULL }
-
-#define SLIST_ENTRY(type) \
-struct { \
- struct type *sle_next; /* next element */ \
-}
-
-/*
- * Singly-linked List functions.
- */
-#define SLIST_EMPTY(head) ((head)->slh_first == NULL)
-
-#define SLIST_FIRST(head) ((head)->slh_first)
-
-#define SLIST_FOREACH(var, head, field) \
- for ((var) = SLIST_FIRST((head)); \
- (var); \
- (var) = SLIST_NEXT((var), field))
-
-#define SLIST_INIT(head) do { \
- SLIST_FIRST((head)) = NULL; \
-} while (0)
-
-#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \
- SLIST_NEXT((elm), field) = SLIST_NEXT((slistelm), field); \
- SLIST_NEXT((slistelm), field) = (elm); \
-} while (0)
-
-#define SLIST_INSERT_HEAD(head, elm, field) do { \
- SLIST_NEXT((elm), field) = SLIST_FIRST((head)); \
- SLIST_FIRST((head)) = (elm); \
-} while (0)
-
-#define SLIST_NEXT(elm, field) ((elm)->field.sle_next)
-
-#define SLIST_REMOVE(head, elm, type, field) do { \
- if (SLIST_FIRST((head)) == (elm)) { \
- SLIST_REMOVE_HEAD((head), field); \
- } \
- else { \
- struct type *curelm = SLIST_FIRST((head)); \
- while (SLIST_NEXT(curelm, field) != (elm)) \
- curelm = SLIST_NEXT(curelm, field); \
- SLIST_NEXT(curelm, field) = \
- SLIST_NEXT(SLIST_NEXT(curelm, field), field); \
- } \
-} while (0)
-
-#define SLIST_REMOVE_HEAD(head, field) do { \
- SLIST_FIRST((head)) = SLIST_NEXT(SLIST_FIRST((head)), field); \
-} while (0)
-
-/*
- * Singly-linked Tail queue declarations.
- */
-#define STAILQ_HEAD(name, type) \
-struct name { \
- struct type *stqh_first;/* first element */ \
- struct type **stqh_last;/* addr of last next element */ \
-}
-
-#define STAILQ_HEAD_INITIALIZER(head) \
- { NULL, &(head).stqh_first }
-
-#define STAILQ_ENTRY(type) \
-struct { \
- struct type *stqe_next; /* next element */ \
-}
-
-/*
- * Singly-linked Tail queue functions.
- */
-#define STAILQ_CONCAT(head1, head2) do { \
- if (!STAILQ_EMPTY((head2))) { \
- *(head1)->stqh_last = (head2)->stqh_first; \
- (head1)->stqh_last = (head2)->stqh_last; \
- STAILQ_INIT((head2)); \
- } \
-} while (0)
-
-#define STAILQ_EMPTY(head) ((head)->stqh_first == NULL)
-
-#define STAILQ_FIRST(head) ((head)->stqh_first)
-
-#define STAILQ_FOREACH(var, head, field) \
- for((var) = STAILQ_FIRST((head)); \
- (var); \
- (var) = STAILQ_NEXT((var), field))
-
-#define STAILQ_INIT(head) do { \
- STAILQ_FIRST((head)) = NULL; \
- (head)->stqh_last = &STAILQ_FIRST((head)); \
-} while (0)
-
-#define STAILQ_INSERT_AFTER(head, tqelm, elm, field) do { \
- if ((STAILQ_NEXT((elm), field) = STAILQ_NEXT((tqelm), field)) == NULL)\
- (head)->stqh_last = &STAILQ_NEXT((elm), field); \
- STAILQ_NEXT((tqelm), field) = (elm); \
-} while (0)
-
-#define STAILQ_INSERT_HEAD(head, elm, field) do { \
- if ((STAILQ_NEXT((elm), field) = STAILQ_FIRST((head))) == NULL) \
- (head)->stqh_last = &STAILQ_NEXT((elm), field); \
- STAILQ_FIRST((head)) = (elm); \
-} while (0)
-
-#define STAILQ_INSERT_TAIL(head, elm, field) do { \
- STAILQ_NEXT((elm), field) = NULL; \
- *(head)->stqh_last = (elm); \
- (head)->stqh_last = &STAILQ_NEXT((elm), field); \
-} while (0)
-
-#define STAILQ_LAST(head, type, field) \
- (STAILQ_EMPTY((head)) ? \
- NULL : \
- ((struct type *) \
- ((char *)((head)->stqh_last) - __offsetof(struct type, field))))
-
-#define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next)
-
-#define STAILQ_REMOVE(head, elm, type, field) do { \
- if (STAILQ_FIRST((head)) == (elm)) { \
- STAILQ_REMOVE_HEAD((head), field); \
- } \
- else { \
- struct type *curelm = STAILQ_FIRST((head)); \
- while (STAILQ_NEXT(curelm, field) != (elm)) \
- curelm = STAILQ_NEXT(curelm, field); \
- if ((STAILQ_NEXT(curelm, field) = \
- STAILQ_NEXT(STAILQ_NEXT(curelm, field), field)) == NULL)\
- (head)->stqh_last = &STAILQ_NEXT((curelm), field);\
- } \
-} while (0)
-
-#define STAILQ_REMOVE_HEAD(head, field) do { \
- if ((STAILQ_FIRST((head)) = \
- STAILQ_NEXT(STAILQ_FIRST((head)), field)) == NULL) \
- (head)->stqh_last = &STAILQ_FIRST((head)); \
-} while (0)
-
-#define STAILQ_REMOVE_HEAD_UNTIL(head, elm, field) do { \
- if ((STAILQ_FIRST((head)) = STAILQ_NEXT((elm), field)) == NULL) \
- (head)->stqh_last = &STAILQ_FIRST((head)); \
-} while (0)
-
-/*
- * List declarations.
- */
-#define LIST_HEAD(name, type) \
-struct name { \
- struct type *lh_first; /* first element */ \
-}
-
-#define LIST_HEAD_INITIALIZER(head) \
- { NULL }
-
-#define LIST_ENTRY(type) \
-struct { \
- struct type *le_next; /* next element */ \
- struct type **le_prev; /* address of previous next element */ \
-}
-
-/*
- * List functions.
- */
-
-#define LIST_EMPTY(head) ((head)->lh_first == NULL)
-
-#define LIST_FIRST(head) ((head)->lh_first)
-
-#define LIST_FOREACH(var, head, field) \
- for ((var) = LIST_FIRST((head)); \
- (var); \
- (var) = LIST_NEXT((var), field))
-
-#define LIST_INIT(head) do { \
- LIST_FIRST((head)) = NULL; \
-} while (0)
-
-#define LIST_INSERT_AFTER(listelm, elm, field) do { \
- if ((LIST_NEXT((elm), field) = LIST_NEXT((listelm), field)) != NULL)\
- LIST_NEXT((listelm), field)->field.le_prev = \
- &LIST_NEXT((elm), field); \
- LIST_NEXT((listelm), field) = (elm); \
- (elm)->field.le_prev = &LIST_NEXT((listelm), field); \
-} while (0)
-
-#define LIST_INSERT_BEFORE(listelm, elm, field) do { \
- (elm)->field.le_prev = (listelm)->field.le_prev; \
- LIST_NEXT((elm), field) = (listelm); \
- *(listelm)->field.le_prev = (elm); \
- (listelm)->field.le_prev = &LIST_NEXT((elm), field); \
-} while (0)
-
-#define LIST_INSERT_HEAD(head, elm, field) do { \
- if ((LIST_NEXT((elm), field) = LIST_FIRST((head))) != NULL) \
- LIST_FIRST((head))->field.le_prev = &LIST_NEXT((elm), field);\
- LIST_FIRST((head)) = (elm); \
- (elm)->field.le_prev = &LIST_FIRST((head)); \
-} while (0)
-
-#define LIST_NEXT(elm, field) ((elm)->field.le_next)
-
-#define LIST_REMOVE(elm, field) do { \
- if (LIST_NEXT((elm), field) != NULL) \
- LIST_NEXT((elm), field)->field.le_prev = \
- (elm)->field.le_prev; \
- *(elm)->field.le_prev = LIST_NEXT((elm), field); \
-} while (0)
-
-/*
- * Tail queue declarations.
- */
-#define TAILQ_HEAD(name, type) \
-struct name { \
- struct type *tqh_first; /* first element */ \
- struct type **tqh_last; /* addr of last next element */ \
-}
-
-#define TAILQ_HEAD_INITIALIZER(head) \
- { NULL, &(head).tqh_first }
-
-#define TAILQ_ENTRY(type) \
-struct { \
- struct type *tqe_next; /* next element */ \
- struct type **tqe_prev; /* address of previous next element */ \
-}
-
-/*
- * Tail queue functions.
- */
-#define TAILQ_CONCAT(head1, head2, field) do { \
- if (!TAILQ_EMPTY(head2)) { \
- *(head1)->tqh_last = (head2)->tqh_first; \
- (head2)->tqh_first->field.tqe_prev = (head1)->tqh_last; \
- (head1)->tqh_last = (head2)->tqh_last; \
- TAILQ_INIT((head2)); \
- } \
-} while (0)
-
-#define TAILQ_EMPTY(head) ((head)->tqh_first == NULL)
-
-#define TAILQ_FIRST(head) ((head)->tqh_first)
-
-#define TAILQ_FOREACH(var, head, field) \
- for ((var) = TAILQ_FIRST((head)); \
- (var); \
- (var) = TAILQ_NEXT((var), field))
-
-#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \
- for ((var) = TAILQ_LAST((head), headname); \
- (var); \
- (var) = TAILQ_PREV((var), headname, field))
-
-#define TAILQ_INIT(head) do { \
- TAILQ_FIRST((head)) = NULL; \
- (head)->tqh_last = &TAILQ_FIRST((head)); \
-} while (0)
-
-#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \
- if ((TAILQ_NEXT((elm), field) = TAILQ_NEXT((listelm), field)) != NULL)\
- TAILQ_NEXT((elm), field)->field.tqe_prev = \
- &TAILQ_NEXT((elm), field); \
- else \
- (head)->tqh_last = &TAILQ_NEXT((elm), field); \
- TAILQ_NEXT((listelm), field) = (elm); \
- (elm)->field.tqe_prev = &TAILQ_NEXT((listelm), field); \
-} while (0)
-
-#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \
- (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \
- TAILQ_NEXT((elm), field) = (listelm); \
- *(listelm)->field.tqe_prev = (elm); \
- (listelm)->field.tqe_prev = &TAILQ_NEXT((elm), field); \
-} while (0)
-
-#define TAILQ_INSERT_HEAD(head, elm, field) do { \
- if ((TAILQ_NEXT((elm), field) = TAILQ_FIRST((head))) != NULL) \
- TAILQ_FIRST((head))->field.tqe_prev = \
- &TAILQ_NEXT((elm), field); \
- else \
- (head)->tqh_last = &TAILQ_NEXT((elm), field); \
- TAILQ_FIRST((head)) = (elm); \
- (elm)->field.tqe_prev = &TAILQ_FIRST((head)); \
-} while (0)
-
-#define TAILQ_INSERT_TAIL(head, elm, field) do { \
- TAILQ_NEXT((elm), field) = NULL; \
- (elm)->field.tqe_prev = (head)->tqh_last; \
- *(head)->tqh_last = (elm); \
- (head)->tqh_last = &TAILQ_NEXT((elm), field); \
-} while (0)
-
-#define TAILQ_LAST(head, headname) \
- (*(((struct headname *)((head)->tqh_last))->tqh_last))
-
-#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
-
-#define TAILQ_PREV(elm, headname, field) \
- (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
-
-#define TAILQ_REMOVE(head, elm, field) do { \
- if ((TAILQ_NEXT((elm), field)) != NULL) \
- TAILQ_NEXT((elm), field)->field.tqe_prev = \
- (elm)->field.tqe_prev; \
- else \
- (head)->tqh_last = (elm)->field.tqe_prev; \
- *(elm)->field.tqe_prev = TAILQ_NEXT((elm), field); \
-} while (0)
-
-
-#ifdef _KERNEL
-
-/*
- * XXX insque() and remque() are an old way of handling certain queues.
- * They bogusly assumes that all queue heads look alike.
- */
-
-struct quehead {
- struct quehead *qh_link;
- struct quehead *qh_rlink;
-};
-
-#ifdef __GNUC__
-
-static __inline void
-insque(void *a, void *b)
-{
- struct quehead *element = (struct quehead *)a,
- *head = (struct quehead *)b;
-
- element->qh_link = head->qh_link;
- element->qh_rlink = head;
- head->qh_link = element;
- element->qh_link->qh_rlink = element;
-}
-
-static __inline void
-remque(void *a)
-{
- struct quehead *element = (struct quehead *)a;
-
- element->qh_link->qh_rlink = element->qh_rlink;
- element->qh_rlink->qh_link = element->qh_link;
- element->qh_rlink = 0;
-}
-
-#else /* !__GNUC__ */
-
-void insque(void *a, void *b);
-void remque(void *a);
-
-#endif /* __GNUC__ */
-
-#endif /* _KERNEL */
-
-#endif /* !_SYS_QUEUE_H_ */
diff --git a/system/include/libc/sys/reboot.h b/system/include/libc/sys/reboot.h
new file mode 100644
index 00000000..9702eddb
--- /dev/null
+++ b/system/include/libc/sys/reboot.h
@@ -0,0 +1,20 @@
+#ifndef _SYS_REBOOT_H
+#define _SYS_REBOOT_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define RB_AUTOBOOT 0x01234567
+#define RB_HALT_SYSTEM 0xcdef0123
+#define RB_ENABLE_CAD 0x89abcdef
+#define RB_DISABLE_CAD 0
+#define RB_POWER_OFF 0x4321fedc
+#define RB_SW_SUSPEND 0xd000fce2
+#define RB_KEXEC 0x45584543
+
+int reboot(int);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/system/include/libc/sys/reent.h b/system/include/libc/sys/reent.h
deleted file mode 100644
index 8518964f..00000000
--- a/system/include/libc/sys/reent.h
+++ /dev/null
@@ -1,843 +0,0 @@
-/* This header file provides the reentrancy. */
-
-/* WARNING: All identifiers here must begin with an underscore. This file is
- included by stdio.h and others and we therefore must only use identifiers
- in the namespace allotted to us. */
-
-#ifndef _SYS_REENT_H_
-#ifdef __cplusplus
-extern "C" {
-#endif
-#define _SYS_REENT_H_
-
-#include <_ansi.h>
-#include <sys/_types.h>
-
-#define _NULL 0
-
-#ifndef __Long
-#if __LONG_MAX__ == 2147483647L
-#define __Long long
-typedef unsigned __Long __ULong;
-#elif __INT_MAX__ == 2147483647
-#define __Long int
-typedef unsigned __Long __ULong;
-#endif
-#endif
-
-#if !defined( __Long)
-#include <sys/types.h>
-#endif
-
-#ifndef __Long
-#define __Long __int32_t
-typedef __uint32_t __ULong;
-#endif
-
-struct _reent;
-
-/*
- * If _REENT_SMALL is defined, we make struct _reent as small as possible,
- * by having nearly everything possible allocated at first use.
- */
-
-struct _Bigint
-{
- struct _Bigint *_next;
- int _k, _maxwds, _sign, _wds;
- __ULong _x[1];
-};
-
-/* needed by reentrant structure */
-struct __tm
-{
- int __tm_sec;
- int __tm_min;
- int __tm_hour;
- int __tm_mday;
- int __tm_mon;
- int __tm_year;
- int __tm_wday;
- int __tm_yday;
- int __tm_isdst;
-};
-
-/*
- * atexit() support.
- */
-
-#define _ATEXIT_SIZE 32 /* must be at least 32 to guarantee ANSI conformance */
-
-struct _on_exit_args {
- void * _fnargs[_ATEXIT_SIZE]; /* user fn args */
- void * _dso_handle[_ATEXIT_SIZE];
- /* Bitmask is set if user function takes arguments. */
- __ULong _fntypes; /* type of exit routine -
- Must have at least _ATEXIT_SIZE bits */
- /* Bitmask is set if function was registered via __cxa_atexit. */
- __ULong _is_cxa;
-};
-
-#ifdef _REENT_SMALL
-struct _atexit {
- struct _atexit *_next; /* next in list */
- int _ind; /* next index in this table */
- void (*_fns[_ATEXIT_SIZE])(void); /* the table itself */
- struct _on_exit_args * _on_exit_args_ptr;
-};
-#else
-struct _atexit {
- struct _atexit *_next; /* next in list */
- int _ind; /* next index in this table */
- /* Some entries may already have been called, and will be NULL. */
- void (*_fns[_ATEXIT_SIZE])(void); /* the table itself */
- struct _on_exit_args _on_exit_args;
-};
-#endif
-
-/*
- * Stdio buffers.
- *
- * This and __FILE are defined here because we need them for struct _reent,
- * but we don't want stdio.h included when stdlib.h is.
- */
-
-struct __sbuf {
- unsigned char *_base;
- int _size;
-};
-
-/*
- * Stdio state variables.
- *
- * The following always hold:
- *
- * if (_flags&(__SLBF|__SWR)) == (__SLBF|__SWR),
- * _lbfsize is -_bf._size, else _lbfsize is 0
- * if _flags&__SRD, _w is 0
- * if _flags&__SWR, _r is 0
- *
- * This ensures that the getc and putc macros (or inline functions) never
- * try to write or read from a file that is in `read' or `write' mode.
- * (Moreover, they can, and do, automatically switch from read mode to
- * write mode, and back, on "r+" and "w+" files.)
- *
- * _lbfsize is used only to make the inline line-buffered output stream
- * code as compact as possible.
- *
- * _ub, _up, and _ur are used when ungetc() pushes back more characters
- * than fit in the current _bf, or when ungetc() pushes back a character
- * that does not match the previous one in _bf. When this happens,
- * _ub._base becomes non-nil (i.e., a stream has ungetc() data iff
- * _ub._base!=NULL) and _up and _ur save the current values of _p and _r.
- */
-
-#ifdef _REENT_SMALL
-/*
- * struct __sFILE_fake is the start of a struct __sFILE, with only the
- * minimal fields allocated. In __sinit() we really allocate the 3
- * standard streams, etc., and point away from this fake.
- */
-struct __sFILE_fake {
- unsigned char *_p; /* current position in (some) buffer */
- int _r; /* read space left for getc() */
- int _w; /* write space left for putc() */
- short _flags; /* flags, below; this FILE is free if 0 */
- short _file; /* fileno, if Unix descriptor, else -1 */
- struct __sbuf _bf; /* the buffer (at least 1 byte, if !NULL) */
- int _lbfsize; /* 0 or -_bf._size, for inline putc */
-
- struct _reent *_data;
-};
-
-/* Following is needed both in libc/stdio and libc/stdlib so we put it
- * here instead of libc/stdio/local.h where it was previously. */
-
-extern _VOID _EXFUN(__sinit,(struct _reent *));
-
-# define _REENT_SMALL_CHECK_INIT(ptr) \
- do \
- { \
- if ((ptr) && !(ptr)->__sdidinit) \
- __sinit (ptr); \
- } \
- while (0)
-#else
-# define _REENT_SMALL_CHECK_INIT(ptr) /* nothing */
-#endif
-
-struct __sFILE {
- unsigned char *_p; /* current position in (some) buffer */
- int _r; /* read space left for getc() */
- int _w; /* write space left for putc() */
- short _flags; /* flags, below; this FILE is free if 0 */
- short _file; /* fileno, if Unix descriptor, else -1 */
- struct __sbuf _bf; /* the buffer (at least 1 byte, if !NULL) */
- int _lbfsize; /* 0 or -_bf._size, for inline putc */
-
-#ifdef _REENT_SMALL
- struct _reent *_data;
-#endif
-
- /* operations */
- _PTR _cookie; /* cookie passed to io functions */
-
- _READ_WRITE_RETURN_TYPE _EXFNPTR(_read, (struct _reent *, _PTR,
- char *, int));
- _READ_WRITE_RETURN_TYPE _EXFNPTR(_write, (struct _reent *, _PTR,
- const char *, int));
- _fpos_t _EXFNPTR(_seek, (struct _reent *, _PTR, _fpos_t, int));
- int _EXFNPTR(_close, (struct _reent *, _PTR));
-
- /* separate buffer for long sequences of ungetc() */
- struct __sbuf _ub; /* ungetc buffer */
- unsigned char *_up; /* saved _p when _p is doing ungetc data */
- int _ur; /* saved _r when _r is counting ungetc data */
-
- /* tricks to meet minimum requirements even when malloc() fails */
- unsigned char _ubuf[3]; /* guarantee an ungetc() buffer */
- unsigned char _nbuf[1]; /* guarantee a getc() buffer */
-
- /* separate buffer for fgetline() when line crosses buffer boundary */
- struct __sbuf _lb; /* buffer for fgetline() */
-
- /* Unix stdio files get aligned to block boundaries on fseek() */
- int _blksize; /* stat.st_blksize (may be != _bf._size) */
- int _offset; /* current lseek offset */
-
-#ifndef _REENT_SMALL
- struct _reent *_data; /* Here for binary compatibility? Remove? */
-#endif
-
-#ifndef __SINGLE_THREAD__
- _flock_t _lock; /* for thread-safety locking */
-#endif
- _mbstate_t _mbstate; /* for wide char stdio functions. */
- int _flags2; /* for future use */
-};
-
-#ifdef __CUSTOM_FILE_IO__
-
-/* Get custom _FILE definition. */
-#include <sys/custom_file.h>
-
-#else /* !__CUSTOM_FILE_IO__ */
-#ifdef __LARGE64_FILES
-struct __sFILE64 {
- unsigned char *_p; /* current position in (some) buffer */
- int _r; /* read space left for getc() */
- int _w; /* write space left for putc() */
- short _flags; /* flags, below; this FILE is free if 0 */
- short _file; /* fileno, if Unix descriptor, else -1 */
- struct __sbuf _bf; /* the buffer (at least 1 byte, if !NULL) */
- int _lbfsize; /* 0 or -_bf._size, for inline putc */
-
- struct _reent *_data;
-
- /* operations */
- _PTR _cookie; /* cookie passed to io functions */
-
- _READ_WRITE_RETURN_TYPE _EXFNPTR(_read, (struct _reent *, _PTR,
- char *, int));
- _READ_WRITE_RETURN_TYPE _EXFNPTR(_write, (struct _reent *, _PTR,
- const char *, int));
- _fpos_t _EXFNPTR(_seek, (struct _reent *, _PTR, _fpos_t, int));
- int _EXFNPTR(_close, (struct _reent *, _PTR));
-
- /* separate buffer for long sequences of ungetc() */
- struct __sbuf _ub; /* ungetc buffer */
- unsigned char *_up; /* saved _p when _p is doing ungetc data */
- int _ur; /* saved _r when _r is counting ungetc data */
-
- /* tricks to meet minimum requirements even when malloc() fails */
- unsigned char _ubuf[3]; /* guarantee an ungetc() buffer */
- unsigned char _nbuf[1]; /* guarantee a getc() buffer */
-
- /* separate buffer for fgetline() when line crosses buffer boundary */
- struct __sbuf _lb; /* buffer for fgetline() */
-
- /* Unix stdio files get aligned to block boundaries on fseek() */
- int _blksize; /* stat.st_blksize (may be != _bf._size) */
- int _flags2; /* for future use */
-
- _off64_t _offset; /* current lseek offset */
- _fpos64_t _EXFNPTR(_seek64, (struct _reent *, _PTR, _fpos64_t, int));
-
-#ifndef __SINGLE_THREAD__
- _flock_t _lock; /* for thread-safety locking */
-#endif
- _mbstate_t _mbstate; /* for wide char stdio functions. */
-};
-typedef struct __sFILE64 __FILE;
-#else
-typedef struct __sFILE __FILE;
-#endif /* __LARGE64_FILES */
-#endif /* !__CUSTOM_FILE_IO__ */
-
-struct _glue
-{
- struct _glue *_next;
- int _niobs;
- __FILE *_iobs;
-};
-
-/*
- * rand48 family support
- *
- * Copyright (c) 1993 Martin Birgmeier
- * All rights reserved.
- *
- * You may redistribute unmodified or modified versions of this source
- * code provided that the above copyright notice and this and the
- * following conditions are retained.
- *
- * This software is provided ``as is'', and comes with no warranties
- * of any kind. I shall in no event be liable for anything that happens
- * to anyone/anything when using this software.
- */
-#define _RAND48_SEED_0 (0x330e)
-#define _RAND48_SEED_1 (0xabcd)
-#define _RAND48_SEED_2 (0x1234)
-#define _RAND48_MULT_0 (0xe66d)
-#define _RAND48_MULT_1 (0xdeec)
-#define _RAND48_MULT_2 (0x0005)
-#define _RAND48_ADD (0x000b)
-struct _rand48 {
- unsigned short _seed[3];
- unsigned short _mult[3];
- unsigned short _add;
-#ifdef _REENT_SMALL
- /* Put this in here as well, for good luck. */
- __extension__ unsigned long long _rand_next;
-#endif
-};
-
-/* How big the some arrays are. */
-#define _REENT_EMERGENCY_SIZE 25
-#define _REENT_ASCTIME_SIZE 26
-#define _REENT_SIGNAL_SIZE 24
-
-/*
- * struct _reent
- *
- * This structure contains *all* globals needed by the library.
- * It's raison d'etre is to facilitate threads by making all library routines
- * reentrant. IE: All state information is contained here.
- */
-
-#ifdef _REENT_SMALL
-
-struct _mprec
-{
- /* used by mprec routines */
- struct _Bigint *_result;
- int _result_k;
- struct _Bigint *_p5s;
- struct _Bigint **_freelist;
-};
-
-
-struct _misc_reent
-{
- /* miscellaneous reentrant data */
- char *_strtok_last;
- _mbstate_t _mblen_state;
- _mbstate_t _wctomb_state;
- _mbstate_t _mbtowc_state;
- char _l64a_buf[8];
- int _getdate_err;
- _mbstate_t _mbrlen_state;
- _mbstate_t _mbrtowc_state;
- _mbstate_t _mbsrtowcs_state;
- _mbstate_t _wcrtomb_state;
- _mbstate_t _wcsrtombs_state;
-};
-
-/* This version of _reent is layed our with "int"s in pairs, to help
- * ports with 16-bit int's but 32-bit pointers, align nicely. */
-struct _reent
-{
- /* As an exception to the above put _errno first for binary
- compatibility with non _REENT_SMALL targets. */
- int _errno; /* local copy of errno */
-
- /* FILE is a big struct and may change over time. To try to achieve binary
- compatibility with future versions, put stdin,stdout,stderr here.
- These are pointers into member __sf defined below. */
- __FILE *_stdin, *_stdout, *_stderr; /* XXX */
-
- int _inc; /* used by tmpnam */
-
- char *_emergency;
-
- int __sdidinit; /* 1 means stdio has been init'd */
-
- int _current_category; /* unused */
- _CONST char *_current_locale; /* unused */
-
- struct _mprec *_mp;
-
- void _EXFNPTR(__cleanup, (struct _reent *));
-
- int _gamma_signgam;
-
- /* used by some fp conversion routines */
- int _cvtlen; /* should be size_t */
- char *_cvtbuf;
-
- struct _rand48 *_r48;
- struct __tm *_localtime_buf;
- char *_asctime_buf;
-
- /* signal info */
- void (**(_sig_func))(int);
-
- /* atexit stuff */
- struct _atexit *_atexit;
- struct _atexit _atexit0;
-
- struct _glue __sglue; /* root of glue chain */
- __FILE *__sf; /* file descriptors */
- struct _misc_reent *_misc; /* strtok, multibyte states */
- char *_signal_buf; /* strsignal */
-};
-
-extern const struct __sFILE_fake __sf_fake_stdin;
-extern const struct __sFILE_fake __sf_fake_stdout;
-extern const struct __sFILE_fake __sf_fake_stderr;
-
-# define _REENT_INIT(var) \
- { 0, \
- (__FILE *)&__sf_fake_stdin, \
- (__FILE *)&__sf_fake_stdout, \
- (__FILE *)&__sf_fake_stderr, \
- 0, \
- _NULL, \
- 0, \
- 0, \
- "C", \
- _NULL, \
- _NULL, \
- 0, \
- 0, \
- _NULL, \
- _NULL, \
- _NULL, \
- _NULL, \
- _NULL, \
- _NULL, \
- {_NULL, 0, {_NULL}, _NULL}, \
- {_NULL, 0, _NULL}, \
- _NULL, \
- _NULL, \
- _NULL \
- }
-
-#define _REENT_INIT_PTR(var) \
- { (var)->_stdin = (__FILE *)&__sf_fake_stdin; \
- (var)->_stdout = (__FILE *)&__sf_fake_stdout; \
- (var)->_stderr = (__FILE *)&__sf_fake_stderr; \
- (var)->_errno = 0; \
- (var)->_inc = 0; \
- (var)->_emergency = _NULL; \
- (var)->__sdidinit = 0; \
- (var)->_current_category = 0; \
- (var)->_current_locale = "C"; \
- (var)->_mp = _NULL; \
- (var)->__cleanup = _NULL; \
- (var)->_gamma_signgam = 0; \
- (var)->_cvtlen = 0; \
- (var)->_cvtbuf = _NULL; \
- (var)->_r48 = _NULL; \
- (var)->_localtime_buf = _NULL; \
- (var)->_asctime_buf = _NULL; \
- (var)->_sig_func = _NULL; \
- (var)->_atexit = _NULL; \
- (var)->_atexit0._next = _NULL; \
- (var)->_atexit0._ind = 0; \
- (var)->_atexit0._fns[0] = _NULL; \
- (var)->_atexit0._on_exit_args_ptr = _NULL; \
- (var)->__sglue._next = _NULL; \
- (var)->__sglue._niobs = 0; \
- (var)->__sglue._iobs = _NULL; \
- (var)->__sf = 0; \
- (var)->_misc = _NULL; \
- (var)->_signal_buf = _NULL; \
- }
-
-/* Only built the assert() calls if we are built with debugging. */
-#if DEBUG
-#include <assert.h>
-#define __reent_assert(x) assert(x)
-#else
-#define __reent_assert(x) ((void)0)
-#endif
-
-#ifdef __CUSTOM_FILE_IO__
-#error Custom FILE I/O and _REENT_SMALL not currently supported.
-#endif
-
-/* Generic _REENT check macro. */
-#define _REENT_CHECK(var, what, type, size, init) do { \
- struct _reent *_r = (var); \
- if (_r->what == NULL) { \
- _r->what = (type)malloc(size); \
- __reent_assert(_r->what); \
- init; \
- } \
-} while (0)
-
-#define _REENT_CHECK_TM(var) \
- _REENT_CHECK(var, _localtime_buf, struct __tm *, sizeof *((var)->_localtime_buf), \
- /* nothing */)
-
-#define _REENT_CHECK_ASCTIME_BUF(var) \
- _REENT_CHECK(var, _asctime_buf, char *, _REENT_ASCTIME_SIZE, \
- memset((var)->_asctime_buf, 0, _REENT_ASCTIME_SIZE))
-
-/* Handle the dynamically allocated rand48 structure. */
-#define _REENT_INIT_RAND48(var) do { \
- struct _reent *_r = (var); \
- _r->_r48->_seed[0] = _RAND48_SEED_0; \
- _r->_r48->_seed[1] = _RAND48_SEED_1; \
- _r->_r48->_seed[2] = _RAND48_SEED_2; \
- _r->_r48->_mult[0] = _RAND48_MULT_0; \
- _r->_r48->_mult[1] = _RAND48_MULT_1; \
- _r->_r48->_mult[2] = _RAND48_MULT_2; \
- _r->_r48->_add = _RAND48_ADD; \
- _r->_r48->_rand_next = 1; \
-} while (0)
-#define _REENT_CHECK_RAND48(var) \
- _REENT_CHECK(var, _r48, struct _rand48 *, sizeof *((var)->_r48), _REENT_INIT_RAND48((var)))
-
-#define _REENT_INIT_MP(var) do { \
- struct _reent *_r = (var); \
- _r->_mp->_result_k = 0; \
- _r->_mp->_result = _r->_mp->_p5s = _NULL; \
- _r->_mp->_freelist = _NULL; \
-} while (0)
-#define _REENT_CHECK_MP(var) \
- _REENT_CHECK(var, _mp, struct _mprec *, sizeof *((var)->_mp), _REENT_INIT_MP(var))
-
-#define _REENT_CHECK_EMERGENCY(var) \
- _REENT_CHECK(var, _emergency, char *, _REENT_EMERGENCY_SIZE, /* nothing */)
-
-#define _REENT_INIT_MISC(var) do { \
- struct _reent *_r = (var); \
- _r->_misc->_strtok_last = _NULL; \
- _r->_misc->_mblen_state.__count = 0; \
- _r->_misc->_mblen_state.__value.__wch = 0; \
- _r->_misc->_wctomb_state.__count = 0; \
- _r->_misc->_wctomb_state.__value.__wch = 0; \
- _r->_misc->_mbtowc_state.__count = 0; \
- _r->_misc->_mbtowc_state.__value.__wch = 0; \
- _r->_misc->_mbrlen_state.__count = 0; \
- _r->_misc->_mbrlen_state.__value.__wch = 0; \
- _r->_misc->_mbrtowc_state.__count = 0; \
- _r->_misc->_mbrtowc_state.__value.__wch = 0; \
- _r->_misc->_mbsrtowcs_state.__count = 0; \
- _r->_misc->_mbsrtowcs_state.__value.__wch = 0; \
- _r->_misc->_wcrtomb_state.__count = 0; \
- _r->_misc->_wcrtomb_state.__value.__wch = 0; \
- _r->_misc->_wcsrtombs_state.__count = 0; \
- _r->_misc->_wcsrtombs_state.__value.__wch = 0; \
- _r->_misc->_l64a_buf[0] = '\0'; \
- _r->_misc->_getdate_err = 0; \
-} while (0)
-#define _REENT_CHECK_MISC(var) \
- _REENT_CHECK(var, _misc, struct _misc_reent *, sizeof *((var)->_misc), _REENT_INIT_MISC(var))
-
-#define _REENT_CHECK_SIGNAL_BUF(var) \
- _REENT_CHECK(var, _signal_buf, char *, _REENT_SIGNAL_SIZE, /* nothing */)
-
-#define _REENT_SIGNGAM(ptr) ((ptr)->_gamma_signgam)
-#define _REENT_RAND_NEXT(ptr) ((ptr)->_r48->_rand_next)
-#define _REENT_RAND48_SEED(ptr) ((ptr)->_r48->_seed)
-#define _REENT_RAND48_MULT(ptr) ((ptr)->_r48->_mult)
-#define _REENT_RAND48_ADD(ptr) ((ptr)->_r48->_add)
-#define _REENT_MP_RESULT(ptr) ((ptr)->_mp->_result)
-#define _REENT_MP_RESULT_K(ptr) ((ptr)->_mp->_result_k)
-#define _REENT_MP_P5S(ptr) ((ptr)->_mp->_p5s)
-#define _REENT_MP_FREELIST(ptr) ((ptr)->_mp->_freelist)
-#define _REENT_ASCTIME_BUF(ptr) ((ptr)->_asctime_buf)
-#define _REENT_TM(ptr) ((ptr)->_localtime_buf)
-#define _REENT_EMERGENCY(ptr) ((ptr)->_emergency)
-#define _REENT_STRTOK_LAST(ptr) ((ptr)->_misc->_strtok_last)
-#define _REENT_MBLEN_STATE(ptr) ((ptr)->_misc->_mblen_state)
-#define _REENT_MBTOWC_STATE(ptr)((ptr)->_misc->_mbtowc_state)
-#define _REENT_WCTOMB_STATE(ptr)((ptr)->_misc->_wctomb_state)
-#define _REENT_MBRLEN_STATE(ptr) ((ptr)->_misc->_mbrlen_state)
-#define _REENT_MBRTOWC_STATE(ptr) ((ptr)->_misc->_mbrtowc_state)
-#define _REENT_MBSRTOWCS_STATE(ptr) ((ptr)->_misc->_mbsrtowcs_state)
-#define _REENT_WCRTOMB_STATE(ptr) ((ptr)->_misc->_wcrtomb_state)
-#define _REENT_WCSRTOMBS_STATE(ptr) ((ptr)->_misc->_wcsrtombs_state)
-#define _REENT_L64A_BUF(ptr) ((ptr)->_misc->_l64a_buf)
-#define _REENT_GETDATE_ERR_P(ptr) (&((ptr)->_misc->_getdate_err))
-#define _REENT_SIGNAL_BUF(ptr) ((ptr)->_signal_buf)
-
-#else /* !_REENT_SMALL */
-
-struct _reent
-{
- int _errno; /* local copy of errno */
-
- /* FILE is a big struct and may change over time. To try to achieve binary
- compatibility with future versions, put stdin,stdout,stderr here.
- These are pointers into member __sf defined below. */
- __FILE *_stdin, *_stdout, *_stderr;
-
- int _inc; /* used by tmpnam */
- char _emergency[_REENT_EMERGENCY_SIZE];
-
- int _current_category; /* used by setlocale */
- _CONST char *_current_locale;
-
- int __sdidinit; /* 1 means stdio has been init'd */
-
- void _EXFNPTR(__cleanup, (struct _reent *));
-
- /* used by mprec routines */
- struct _Bigint *_result;
- int _result_k;
- struct _Bigint *_p5s;
- struct _Bigint **_freelist;
-
- /* used by some fp conversion routines */
- int _cvtlen; /* should be size_t */
- char *_cvtbuf;
-
- union
- {
- struct
- {
- unsigned int _unused_rand;
- char * _strtok_last;
- char _asctime_buf[_REENT_ASCTIME_SIZE];
- struct __tm _localtime_buf;
- int _gamma_signgam;
- __extension__ unsigned long long _rand_next;
- struct _rand48 _r48;
- _mbstate_t _mblen_state;
- _mbstate_t _mbtowc_state;
- _mbstate_t _wctomb_state;
- char _l64a_buf[8];
- char _signal_buf[_REENT_SIGNAL_SIZE];
- int _getdate_err;
- _mbstate_t _mbrlen_state;
- _mbstate_t _mbrtowc_state;
- _mbstate_t _mbsrtowcs_state;
- _mbstate_t _wcrtomb_state;
- _mbstate_t _wcsrtombs_state;
- int _h_errno;
- } _reent;
- /* Two next two fields were once used by malloc. They are no longer
- used. They are used to preserve the space used before so as to
- allow addition of new reent fields and keep binary compatibility. */
- struct
- {
-#define _N_LISTS 30
- unsigned char * _nextf[_N_LISTS];
- unsigned int _nmalloc[_N_LISTS];
- } _unused;
- } _new;
-
- /* atexit stuff */
- struct _atexit *_atexit; /* points to head of LIFO stack */
- struct _atexit _atexit0; /* one guaranteed table, required by ANSI */
-
- /* signal info */
- void (**(_sig_func))(int);
-
- /* These are here last so that __FILE can grow without changing the offsets
- of the above members (on the off chance that future binary compatibility
- would be broken otherwise). */
- struct _glue __sglue; /* root of glue chain */
- __FILE __sf[3]; /* first three file descriptors */
-};
-
-#define _REENT_INIT(var) \
- { 0, \
- &(var).__sf[0], \
- &(var).__sf[1], \
- &(var).__sf[2], \
- 0, \
- "", \
- 0, \
- "C", \
- 0, \
- _NULL, \
- _NULL, \
- 0, \
- _NULL, \
- _NULL, \
- 0, \
- _NULL, \
- { \
- { \
- 0, \
- _NULL, \
- "", \
- {0, 0, 0, 0, 0, 0, 0, 0, 0}, \
- 0, \
- 1, \
- { \
- {_RAND48_SEED_0, _RAND48_SEED_1, _RAND48_SEED_2}, \
- {_RAND48_MULT_0, _RAND48_MULT_1, _RAND48_MULT_2}, \
- _RAND48_ADD \
- }, \
- {0, {0}}, \
- {0, {0}}, \
- {0, {0}}, \
- "", \
- "", \
- 0, \
- {0, {0}}, \
- {0, {0}}, \
- {0, {0}}, \
- {0, {0}}, \
- {0, {0}} \
- } \
- }, \
- _NULL, \
- {_NULL, 0, {_NULL}, {{_NULL}, {_NULL}, 0, 0}}, \
- _NULL, \
- {_NULL, 0, _NULL} \
- }
-
-#define _REENT_INIT_PTR(var) \
- { (var)->_errno = 0; \
- (var)->_stdin = &(var)->__sf[0]; \
- (var)->_stdout = &(var)->__sf[1]; \
- (var)->_stderr = &(var)->__sf[2]; \
- (var)->_inc = 0; \
- memset(&(var)->_emergency, 0, sizeof((var)->_emergency)); \
- (var)->_current_category = 0; \
- (var)->_current_locale = "C"; \
- (var)->__sdidinit = 0; \
- (var)->__cleanup = _NULL; \
- (var)->_result = _NULL; \
- (var)->_result_k = 0; \
- (var)->_p5s = _NULL; \
- (var)->_freelist = _NULL; \
- (var)->_cvtlen = 0; \
- (var)->_cvtbuf = _NULL; \
- (var)->_new._reent._unused_rand = 0; \
- (var)->_new._reent._strtok_last = _NULL; \
- (var)->_new._reent._asctime_buf[0] = 0; \
- memset(&(var)->_new._reent._localtime_buf, 0, sizeof((var)->_new._reent._localtime_buf)); \
- (var)->_new._reent._gamma_signgam = 0; \
- (var)->_new._reent._rand_next = 1; \
- (var)->_new._reent._r48._seed[0] = _RAND48_SEED_0; \
- (var)->_new._reent._r48._seed[1] = _RAND48_SEED_1; \
- (var)->_new._reent._r48._seed[2] = _RAND48_SEED_2; \
- (var)->_new._reent._r48._mult[0] = _RAND48_MULT_0; \
- (var)->_new._reent._r48._mult[1] = _RAND48_MULT_1; \
- (var)->_new._reent._r48._mult[2] = _RAND48_MULT_2; \
- (var)->_new._reent._r48._add = _RAND48_ADD; \
- (var)->_new._reent._mblen_state.__count = 0; \
- (var)->_new._reent._mblen_state.__value.__wch = 0; \
- (var)->_new._reent._mbtowc_state.__count = 0; \
- (var)->_new._reent._mbtowc_state.__value.__wch = 0; \
- (var)->_new._reent._wctomb_state.__count = 0; \
- (var)->_new._reent._wctomb_state.__value.__wch = 0; \
- (var)->_new._reent._mbrlen_state.__count = 0; \
- (var)->_new._reent._mbrlen_state.__value.__wch = 0; \
- (var)->_new._reent._mbrtowc_state.__count = 0; \
- (var)->_new._reent._mbrtowc_state.__value.__wch = 0; \
- (var)->_new._reent._mbsrtowcs_state.__count = 0; \
- (var)->_new._reent._mbsrtowcs_state.__value.__wch = 0; \
- (var)->_new._reent._wcrtomb_state.__count = 0; \
- (var)->_new._reent._wcrtomb_state.__value.__wch = 0; \
- (var)->_new._reent._wcsrtombs_state.__count = 0; \
- (var)->_new._reent._wcsrtombs_state.__value.__wch = 0; \
- (var)->_new._reent._l64a_buf[0] = '\0'; \
- (var)->_new._reent._signal_buf[0] = '\0'; \
- (var)->_new._reent._getdate_err = 0; \
- (var)->_atexit = _NULL; \
- (var)->_atexit0._next = _NULL; \
- (var)->_atexit0._ind = 0; \
- (var)->_atexit0._fns[0] = _NULL; \
- (var)->_atexit0._on_exit_args._fntypes = 0; \
- (var)->_atexit0._on_exit_args._fnargs[0] = _NULL; \
- (var)->_sig_func = _NULL; \
- (var)->__sglue._next = _NULL; \
- (var)->__sglue._niobs = 0; \
- (var)->__sglue._iobs = _NULL; \
- memset(&(var)->__sf, 0, sizeof((var)->__sf)); \
- }
-
-#define _REENT_CHECK_RAND48(ptr) /* nothing */
-#define _REENT_CHECK_MP(ptr) /* nothing */
-#define _REENT_CHECK_TM(ptr) /* nothing */
-#define _REENT_CHECK_ASCTIME_BUF(ptr) /* nothing */
-#define _REENT_CHECK_EMERGENCY(ptr) /* nothing */
-#define _REENT_CHECK_MISC(ptr) /* nothing */
-#define _REENT_CHECK_SIGNAL_BUF(ptr) /* nothing */
-
-#define _REENT_SIGNGAM(ptr) ((ptr)->_new._reent._gamma_signgam)
-#define _REENT_RAND_NEXT(ptr) ((ptr)->_new._reent._rand_next)
-#define _REENT_RAND48_SEED(ptr) ((ptr)->_new._reent._r48._seed)
-#define _REENT_RAND48_MULT(ptr) ((ptr)->_new._reent._r48._mult)
-#define _REENT_RAND48_ADD(ptr) ((ptr)->_new._reent._r48._add)
-#define _REENT_MP_RESULT(ptr) ((ptr)->_result)
-#define _REENT_MP_RESULT_K(ptr) ((ptr)->_result_k)
-#define _REENT_MP_P5S(ptr) ((ptr)->_p5s)
-#define _REENT_MP_FREELIST(ptr) ((ptr)->_freelist)
-#define _REENT_ASCTIME_BUF(ptr) ((ptr)->_new._reent._asctime_buf)
-#define _REENT_TM(ptr) (&(ptr)->_new._reent._localtime_buf)
-#define _REENT_EMERGENCY(ptr) ((ptr)->_emergency)
-#define _REENT_STRTOK_LAST(ptr) ((ptr)->_new._reent._strtok_last)
-#define _REENT_MBLEN_STATE(ptr) ((ptr)->_new._reent._mblen_state)
-#define _REENT_MBTOWC_STATE(ptr)((ptr)->_new._reent._mbtowc_state)
-#define _REENT_WCTOMB_STATE(ptr)((ptr)->_new._reent._wctomb_state)
-#define _REENT_MBRLEN_STATE(ptr)((ptr)->_new._reent._mbrlen_state)
-#define _REENT_MBRTOWC_STATE(ptr)((ptr)->_new._reent._mbrtowc_state)
-#define _REENT_MBSRTOWCS_STATE(ptr)((ptr)->_new._reent._mbsrtowcs_state)
-#define _REENT_WCRTOMB_STATE(ptr)((ptr)->_new._reent._wcrtomb_state)
-#define _REENT_WCSRTOMBS_STATE(ptr)((ptr)->_new._reent._wcsrtombs_state)
-#define _REENT_L64A_BUF(ptr) ((ptr)->_new._reent._l64a_buf)
-#define _REENT_SIGNAL_BUF(ptr) ((ptr)->_new._reent._signal_buf)
-#define _REENT_GETDATE_ERR_P(ptr) (&((ptr)->_new._reent._getdate_err))
-
-#endif /* !_REENT_SMALL */
-
-/* This value is used in stdlib/misc.c. reent/reent.c has to know it
- as well to make sure the freelist is correctly free'd. Therefore
- we define it here, rather than in stdlib/misc.c, as before. */
-#define _Kmax (sizeof (size_t) << 3)
-
-/*
- * All references to struct _reent are via this pointer.
- * Internally, newlib routines that need to reference it should use _REENT.
- */
-
-#ifndef __ATTRIBUTE_IMPURE_PTR__
-#define __ATTRIBUTE_IMPURE_PTR__
-#endif
-
-extern struct _reent *_impure_ptr __ATTRIBUTE_IMPURE_PTR__;
-extern struct _reent *_CONST _global_impure_ptr __ATTRIBUTE_IMPURE_PTR__;
-
-void _reclaim_reent _PARAMS ((struct _reent *));
-
-/* #define _REENT_ONLY define this to get only reentrant routines */
-
-#ifndef _REENT_ONLY
-
-#if defined(__DYNAMIC_REENT__) && !defined(__SINGLE_THREAD__)
-#ifndef __getreent
- struct _reent * _EXFUN(__getreent, (void));
-#endif
-# define _REENT (__getreent())
-#else /* __SINGLE_THREAD__ || !__DYNAMIC_REENT__ */
-# define _REENT _impure_ptr
-#endif /* __SINGLE_THREAD__ || !__DYNAMIC_REENT__ */
-
-#endif /* !_REENT_ONLY */
-
-#define _GLOBAL_REENT _global_impure_ptr
-
-#ifdef __cplusplus
-}
-#endif
-#endif /* _SYS_REENT_H_ */
diff --git a/system/include/libc/sys/reg.h b/system/include/libc/sys/reg.h
new file mode 100644
index 00000000..b47452d0
--- /dev/null
+++ b/system/include/libc/sys/reg.h
@@ -0,0 +1,9 @@
+#ifndef _SYS_REG_H
+#define _SYS_REG_H
+
+#include <limits.h>
+#include <unistd.h>
+
+#include <bits/reg.h>
+
+#endif
diff --git a/system/include/libc/sys/resource.h b/system/include/libc/sys/resource.h
index 1e451e0d..0cfbcf44 100644
--- a/system/include/libc/sys/resource.h
+++ b/system/include/libc/sys/resource.h
@@ -1,59 +1,103 @@
-#ifndef _SYS_RESOURCE_H_
-#define _SYS_RESOURCE_H_
-
-#include <sys/time.h>
+#ifndef _SYS_RESOURCE_H
+#define _SYS_RESOURCE_H
#ifdef __cplusplus
extern "C" {
#endif
-#define RUSAGE_SELF 0 /* calling process */
-#define RUSAGE_CHILDREN -1 /* terminated child processes */
-
-struct rusage {
- struct timeval ru_utime; /* user time used */
- struct timeval ru_stime; /* system time used */
- /* XXX Emscripten */
- int ru_maxrss;
- int ru_ixrss;
- int ru_idrss;
- int ru_isrss;
- int ru_minflt;
- int ru_majflt;
- int ru_nswap;
- int ru_inblock;
- int ru_oublock;
- int ru_msgsnd;
- int ru_msgrcv;
- int ru_nsignals;
- int ru_nvcsw;
- int ru_nivcsw;
+#include <features.h>
+#include <sys/time.h>
+
+#define __NEED_id_t
+
+#ifdef _GNU_SOURCE
+#define __NEED_pid_t
+#endif
+
+#include <bits/alltypes.h>
+
+typedef unsigned long long rlim_t;
+
+struct rlimit
+{
+ rlim_t rlim_cur;
+ rlim_t rlim_max;
};
-/* XXX Emscripten */
-#define PRIO_PROCESS 0
-int getrusage(int who, struct rusage *r_usage);
-
-/* XXX Emscripten */
-#define RLIMIT_CORE 100
-#define RLIMIT_CPU 1
-#define RLIMIT_DATA 2
-#define RLIMIT_FSIZE 3
-#define RLIMIT_NOFILE 4
-#define RLIMIT_STACK 5
-#define RLIMIT_AS 6
-
-typedef unsigned rlim_t;
-struct rlimit {
- rlim_t rlim_cur;
- rlim_t rlim_max;
+struct rusage
+{
+ struct timeval ru_utime;
+ struct timeval ru_stime;
+ /* linux extentions, but useful */
+ long ru_maxrss;
+ long ru_ixrss;
+ long ru_idrss;
+ long ru_isrss;
+ long ru_minflt;
+ long ru_majflt;
+ long ru_nswap;
+ long ru_inblock;
+ long ru_oublock;
+ long ru_msgsnd;
+ long ru_msgrcv;
+ long ru_nsignals;
+ long ru_nvcsw;
+ long ru_nivcsw;
+ /* room for more... */
+ long __reserved[16];
};
-int getrlimit(int resource, struct rlimit *rlim);
-int setrlimit(int resource, const struct rlimit *rlim);
+
+int getrlimit (int, struct rlimit *);
+int setrlimit (int, const struct rlimit *);
+int getrusage (int, struct rusage *);
+
+int getpriority (int, id_t);
+int setpriority (int, id_t, int);
+
+#ifdef _GNU_SOURCE
+int prlimit(pid_t, int, const struct rlimit *, struct rlimit *);
+#define prlimit64 prlimit
+#endif
+
+#define PRIO_PROCESS 0
+#define PRIO_PGRP 1
+#define PRIO_USER 2
+
+#define RUSAGE_SELF 0
+#define RUSAGE_CHILDREN 1
+
+#define RLIM_INFINITY (~0ULL)
+#define RLIM_SAVED_CUR RLIM_INFINITY
+#define RLIM_SAVED_MAX RLIM_INFINITY
+
+#define RLIMIT_CPU 0
+#define RLIMIT_FSIZE 1
+#define RLIMIT_DATA 2
+#define RLIMIT_STACK 3
+#define RLIMIT_CORE 4
+#define RLIMIT_RSS 5
+#define RLIMIT_NOFILE 7
+#define RLIMIT_AS 9
+#define RLIMIT_NPROC 6
+#define RLIMIT_MEMLOCK 8
+#define RLIMIT_LOCKS 10
+#define RLIMIT_SIGPENDING 11
+#define RLIMIT_MSGQUEUE 12
+#define RLIMIT_NICE 13
+#define RLIMIT_RTPRIO 14
+#define RLIMIT_NLIMITS 15
+
+#define RLIM_NLIMITS RLIMIT_NLIMITS
+
+#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
+#define getrlimit64 getrlimit
+#define setrlimit64 setrlimit
+#define rlimit64 rlimit
+#define rlim64_t rlim_t
+#endif
#ifdef __cplusplus
}
#endif
#endif
-
diff --git a/system/include/libc/sys/sched.h b/system/include/libc/sys/sched.h
deleted file mode 100644
index bed14bfc..00000000
--- a/system/include/libc/sys/sched.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Written by Joel Sherrill <joel@OARcorp.com>.
- *
- * COPYRIGHT (c) 1989-2010.
- * On-Line Applications Research Corporation (OAR).
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose without fee is hereby granted, provided that this entire notice
- * is included in all copies of any software which is or includes a copy
- * or modification of this software.
- *
- * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
- * WARRANTY. IN PARTICULAR, THE AUTHOR MAKES NO REPRESENTATION
- * OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY OF THIS
- * SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
- *
- * $Id: sched.h,v 1.3 2010/04/01 18:33:37 jjohnstn Exp $
- */
-
-
-#ifndef _SYS_SCHED_H_
-#define _SYS_SCHED_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Scheduling Policies */
-/* Open Group Specifications Issue 6 */
-#if defined(__CYGWIN__)
-#define SCHED_OTHER 3
-#else
-#define SCHED_OTHER 0
-#endif
-
-#define SCHED_FIFO 1
-#define SCHED_RR 2
-
-#if defined(_POSIX_SPORADIC_SERVER)
-#define SCHED_SPORADIC 4
-#endif
-
-/* Scheduling Parameters */
-/* Open Group Specifications Issue 6 */
-
-struct sched_param {
- int sched_priority; /* Process execution scheduling priority */
-
-#if defined(_POSIX_SPORADIC_SERVER) || defined(_POSIX_THREAD_SPORADIC_SERVER)
- int sched_ss_low_priority; /* Low scheduling priority for sporadic */
- /* server */
- struct timespec sched_ss_repl_period;
- /* Replenishment period for sporadic server */
- struct timespec sched_ss_init_budget;
- /* Initial budget for sporadic server */
- int sched_ss_max_repl; /* Maximum pending replenishments for */
- /* sporadic server */
-#endif
-};
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-/* end of include file */
-
diff --git a/system/include/libc/sys/select.h b/system/include/libc/sys/select.h
new file mode 100644
index 00000000..e25257d2
--- /dev/null
+++ b/system/include/libc/sys/select.h
@@ -0,0 +1,42 @@
+#ifndef _SYS_SELECT_H
+#define _SYS_SELECT_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <features.h>
+
+#define __NEED_size_t
+#define __NEED_time_t
+#define __NEED_suseconds_t
+#define __NEED_struct_timeval
+#define __NEED_struct_timespec
+#define __NEED_sigset_t
+
+#include <bits/alltypes.h>
+
+#define FD_SETSIZE 1024
+
+typedef unsigned long fd_mask;
+
+typedef struct
+{
+ unsigned long fds_bits[FD_SETSIZE / 8 / sizeof(long)];
+} fd_set;
+
+#define FD_ZERO(s) do { int __i; unsigned long *__b=(s)->fds_bits; for(__i=sizeof (fd_set)/sizeof (long); __i; __i--) *__b++=0; } while(0)
+#define FD_SET(d, s) ((s)->fds_bits[(d)/(8*sizeof(long))] |= (1UL<<((d)%(8*sizeof(long)))))
+#define FD_CLR(d, s) ((s)->fds_bits[(d)/(8*sizeof(long))] &= ~(1UL<<((d)%(8*sizeof(long)))))
+#define FD_ISSET(d, s) !!((s)->fds_bits[(d)/(8*sizeof(long))] & (1UL<<((d)%(8*sizeof(long)))))
+
+int select (int, fd_set *__restrict, fd_set *__restrict, fd_set *__restrict, struct timeval *__restrict);
+int pselect (int, fd_set *__restrict, fd_set *__restrict, fd_set *__restrict, const struct timespec *__restrict, const sigset_t *__restrict);
+
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+#define NFDBITS (8*(int)sizeof(long))
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/system/include/libc/sys/sem.h b/system/include/libc/sys/sem.h
new file mode 100644
index 00000000..e74ea208
--- /dev/null
+++ b/system/include/libc/sys/sem.h
@@ -0,0 +1,82 @@
+#ifndef _SYS_SEM_H
+#define _SYS_SEM_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <features.h>
+
+#define __NEED_size_t
+#define __NEED_pid_t
+#define __NEED_time_t
+#ifdef _GNU_SOURCE
+#define __NEED_struct_timespec
+#endif
+#include <bits/alltypes.h>
+
+#include <sys/ipc.h>
+
+#define SEM_UNDO 0x1000
+#define GETPID 11
+#define GETVAL 12
+#define GETALL 13
+#define GETNCNT 14
+#define GETZCNT 15
+#define SETVAL 16
+#define SETALL 17
+
+#include <endian.h>
+
+struct semid_ds {
+ struct ipc_perm sem_perm;
+ long sem_otime;
+ unsigned long __unused1;
+ long sem_ctime;
+ unsigned long __unused2;
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+ unsigned short sem_nsems;
+ char __sem_nsems_pad[sizeof(long)-sizeof(short)];
+#else
+ char __sem_nsems_pad[sizeof(long)-sizeof(short)];
+ unsigned short sem_nsems;
+#endif
+ unsigned long __unused3;
+ unsigned long __unused4;
+};
+
+#define _SEM_SEMUN_UNDEFINED 1
+
+#define SEM_STAT 18
+#define SEM_INFO 19
+
+struct seminfo {
+ int semmap;
+ int semmni;
+ int semmns;
+ int semmnu;
+ int semmsl;
+ int semopm;
+ int semume;
+ int semusz;
+ int semvmx;
+ int semaem;
+};
+
+struct sembuf {
+ unsigned short sem_num;
+ short sem_op;
+ short sem_flg;
+};
+
+int semctl(int, int, int, ...);
+int semget(key_t, int, int);
+int semop(int, struct sembuf *, size_t);
+
+#ifdef _GNU_SOURCE
+int semtimedop(int, struct sembuf *, size_t, const struct timespec *);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/system/include/libc/sys/sendfile.h b/system/include/libc/sys/sendfile.h
new file mode 100644
index 00000000..e7570d8e
--- /dev/null
+++ b/system/include/libc/sys/sendfile.h
@@ -0,0 +1,22 @@
+#ifndef _SYS_SENDFILE_H
+#define _SYS_SENDFILE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <features.h>
+#include <unistd.h>
+
+ssize_t sendfile(int, int, off_t *, size_t);
+
+#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
+#define sendfile64 sendfile
+#define off64_t off_t
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/sys/shm.h b/system/include/libc/sys/shm.h
new file mode 100644
index 00000000..c20f0334
--- /dev/null
+++ b/system/include/libc/sys/shm.h
@@ -0,0 +1,61 @@
+#ifndef _SYS_SHM_H
+#define _SYS_SHM_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <features.h>
+
+#define __NEED_time_t
+#define __NEED_size_t
+#define __NEED_pid_t
+
+#include <bits/alltypes.h>
+
+#include <sys/ipc.h>
+#include <bits/shm.h>
+
+#define SHM_R 0400
+#define SHM_W 0200
+
+#define SHM_RDONLY 010000
+#define SHM_RND 020000
+#define SHM_REMAP 040000
+#define SHM_EXEC 0100000
+
+#define SHM_LOCK 11
+#define SHM_UNLOCK 12
+#define SHM_STAT 13
+#define SHM_INFO 14
+#define SHM_DEST 01000
+#define SHM_LOCKED 02000
+#define SHM_HUGETLB 04000
+#define SHM_NORESERVE 010000
+
+struct shminfo {
+ unsigned long shmmax, shmmin, shmmni, shmseg, shmall, __unused[4];
+};
+
+struct shm_info {
+ int used_ids;
+ unsigned long shm_tot, shm_rss, shm_swp;
+#ifdef _GNU_SOURCE
+ unsigned long swap_attempts, swap_successes;
+#else
+ unsigned long __reserved[2];
+#endif
+};
+
+typedef unsigned long shmatt_t;
+
+void *shmat(int, const void *, int);
+int shmctl(int, int, struct shmid_ds *);
+int shmdt(const void *);
+int shmget(key_t, size_t, int);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/sys/signal.h b/system/include/libc/sys/signal.h
index fc9b67d5..45bdcc64 100644
--- a/system/include/libc/sys/signal.h
+++ b/system/include/libc/sys/signal.h
@@ -1,316 +1,2 @@
-/* sys/signal.h */
-
-#ifndef _SYS_SIGNAL_H
-#define _SYS_SIGNAL_H
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "_ansi.h"
-#include <sys/features.h>
-#include <sys/types.h>
-
-/* #ifndef __STRICT_ANSI__*/
-
-typedef unsigned long sigset_t;
-
-#if defined(__rtems__) || defined(EMSCRIPTEN)
-
-#if defined(_POSIX_REALTIME_SIGNALS)
-
-/* sigev_notify values
- NOTE: P1003.1c/D10, p. 34 adds SIGEV_THREAD. */
-
-#define SIGEV_NONE 1 /* No asynchronous notification shall be delivered */
- /* when the event of interest occurs. */
-#define SIGEV_SIGNAL 2 /* A queued signal, with an application defined */
- /* value, shall be delivered when the event of */
- /* interest occurs. */
-#define SIGEV_THREAD 3 /* A notification function shall be called to */
- /* perform notification. */
-
-/* Signal Generation and Delivery, P1003.1b-1993, p. 63
- NOTE: P1003.1c/D10, p. 34 adds sigev_notify_function and
- sigev_notify_attributes to the sigevent structure. */
-
-union sigval {
- int sival_int; /* Integer signal value */
- void *sival_ptr; /* Pointer signal value */
-};
-
-struct sigevent {
- int sigev_notify; /* Notification type */
- int sigev_signo; /* Signal number */
- union sigval sigev_value; /* Signal value */
-
-#if defined(_POSIX_THREADS)
- void (*sigev_notify_function)( union sigval );
- /* Notification function */
- pthread_attr_t *sigev_notify_attributes; /* Notification Attributes */
-#endif
-};
-
-/* Signal Actions, P1003.1b-1993, p. 64 */
-/* si_code values, p. 66 */
-
-#define SI_USER 1 /* Sent by a user. kill(), abort(), etc */
-#define SI_QUEUE 2 /* Sent by sigqueue() */
-#define SI_TIMER 3 /* Sent by expiration of a timer_settime() timer */
-#define SI_ASYNCIO 4 /* Indicates completion of asycnhronous IO */
-#define SI_MESGQ 5 /* Indicates arrival of a message at an empty queue */
-
-typedef struct {
- int si_signo; /* Signal number */
- int si_code; /* Cause of the signal */
- union sigval si_value; /* Signal value */
-} siginfo_t;
-#endif
-
-/* 3.3.8 Synchronously Accept a Signal, P1003.1b-1993, p. 76 */
-
-#define SA_NOCLDSTOP 1 /* Do not generate SIGCHLD when children stop */
-#define SA_SIGINFO 2 /* Invoke the signal catching function with */
- /* three arguments instead of one. */
-#define SA_NODEFER 4 /* XXX Emscripten */
-#define SA_RESETHAND 8 /* XXX Emscripten */
-#define SA_RESTART 16 /* XXX Emscripten */
-
-/* struct sigaction notes from POSIX:
- *
- * (1) Routines stored in sa_handler should take a single int as
- * their argument although the POSIX standard does not require this.
- * (2) The fields sa_handler and sa_sigaction may overlap, and a conforming
- * application should not use both simultaneously.
- */
-
-typedef void (*_sig_func_ptr)(int); /* XXX Emscripten */
-
-struct sigaction {
- int sa_flags; /* Special flags to affect behavior of signal */
- sigset_t sa_mask; /* Additional set of signals to be blocked */
- /* during execution of signal-catching */
- /* function. */
- union {
- _sig_func_ptr _handler; /* SIG_DFL, SIG_IGN, or pointer to a function */
-#if defined(_POSIX_REALTIME_SIGNALS)
- void (*_sigaction)( int, siginfo_t *, void * );
-#endif
- } _signal_handlers;
-};
-
-#define sa_handler _signal_handlers._handler
-#if defined(_POSIX_REALTIME_SIGNALS)
-#define sa_sigaction _signal_handlers._sigaction
-#endif
-
-#elif defined(__CYGWIN__)
-#include <cygwin/signal.h>
-#else
-#define SA_NOCLDSTOP 1 /* only value supported now for sa_flags */
-
-typedef void (*_sig_func_ptr)(int);
-
-struct sigaction
-{
- _sig_func_ptr sa_handler;
- sigset_t sa_mask;
- int sa_flags;
- void (*sa_sigaction)(int, siginfo_t *, void *); /* XXX EMSCRIPTEN */
-};
-#endif /* defined(__rtems__) */
-
-#define SIG_SETMASK 0 /* set mask with sigprocmask() */
-#define SIG_BLOCK 1 /* set of signals to block */
-#define SIG_UNBLOCK 2 /* set of signals to, well, unblock */
-
-/* These depend upon the type of sigset_t, which right now
- is always a long.. They're in the POSIX namespace, but
- are not ANSI. */
-#define sigaddset(what,sig) (*(what) |= (1<<(sig)), 0)
-#define sigdelset(what,sig) (*(what) &= ~(1<<(sig)), 0)
-#define sigemptyset(what) (*(what) = 0, 0)
-#define sigfillset(what) (*(what) = ~(0), 0)
-#define sigismember(what,sig) (((*(what)) & (1<<(sig))) != 0)
-
-int _EXFUN(sigprocmask, (int how, const sigset_t *set, sigset_t *oset));
-
-#if defined(_POSIX_THREADS)
-int _EXFUN(pthread_sigmask, (int how, const sigset_t *set, sigset_t *oset));
-#endif
-
-/* protos for functions found in winsup sources for CYGWIN */
-#if defined(EMSCRIPTEN) || defined(__CYGWIN__) || defined(__rtems__)
-#undef sigaddset
-#undef sigdelset
-#undef sigemptyset
-#undef sigfillset
-#undef sigismember
-
-int _EXFUN(kill, (pid_t, int));
-int _EXFUN(killpg, (pid_t, int));
-int _EXFUN(sigaction, (int, const struct sigaction *, struct sigaction *));
-int _EXFUN(sigaddset, (sigset_t *, const int));
-int _EXFUN(sigdelset, (sigset_t *, const int));
-int _EXFUN(sigismember, (const sigset_t *, int));
-int _EXFUN(sigfillset, (sigset_t *));
-int _EXFUN(sigemptyset, (sigset_t *));
-int _EXFUN(sigpending, (sigset_t *));
-int _EXFUN(sigsuspend, (const sigset_t *));
-int _EXFUN(sigpause, (int));
-
-#if defined(_POSIX_THREADS)
-#ifdef __CYGWIN__
-# ifndef _CYGWIN_TYPES_H
-# error You need the winsup sources or a cygwin installation to compile the cygwin version of newlib.
-# endif
-#endif
-int _EXFUN(pthread_kill, (pthread_t thread, int sig));
-#endif
-
-#if defined(_POSIX_REALTIME_SIGNALS)
-
-/* 3.3.8 Synchronously Accept a Signal, P1003.1b-1993, p. 76
- NOTE: P1003.1c/D10, p. 39 adds sigwait(). */
-
-int _EXFUN(sigwaitinfo, (const sigset_t *set, siginfo_t *info));
-int _EXFUN(sigtimedwait,
- (const sigset_t *set, siginfo_t *info, const struct timespec *timeout)
-);
-int _EXFUN(sigwait, (const sigset_t *set, int *sig));
-
-/* 3.3.9 Queue a Signal to a Process, P1003.1b-1993, p. 78 */
-int _EXFUN(sigqueue, (pid_t pid, int signo, const union sigval value));
-
-#endif /* defined(_POSIX_REALTIME_SIGNALS) */
-
-#endif /* defined(__CYGWIN__) || defined(__rtems__) */
-
-/* #endif __STRICT_ANSI__ */
-
-#if defined(___AM29K__)
-/* These all need to be defined for ANSI C, but I don't think they are
- meaningful. */
-#define SIGABRT 1
-#define SIGFPE 1
-#define SIGILL 1
-#define SIGINT 1
-#define SIGSEGV 1
-#define SIGTERM 1
-/* These need to be defined for POSIX, and some others do too. */
-#define SIGHUP 1
-#define SIGQUIT 1
-#define NSIG 2
-#elif defined(__GO32__)
-#define SIGINT 1
-#define SIGKILL 2
-#define SIGPIPE 3
-#define SIGFPE 4
-#define SIGHUP 5
-#define SIGTERM 6
-#define SIGSEGV 7
-#define SIGTSTP 8
-#define SIGQUIT 9
-#define SIGTRAP 10
-#define SIGILL 11
-#define SIGEMT 12
-#define SIGALRM 13
-#define SIGBUS 14
-#define SIGLOST 15
-#define SIGSTOP 16
-#define SIGABRT 17
-#define SIGUSR1 18
-#define SIGUSR2 19
-#define NSIG 20
-#elif !defined(SIGTRAP)
-#define SIGHUP 1 /* hangup */
-#define SIGINT 2 /* interrupt */
-#define SIGQUIT 3 /* quit */
-#define SIGILL 4 /* illegal instruction (not reset when caught) */
-#define SIGTRAP 5 /* trace trap (not reset when caught) */
-#define SIGIOT 6 /* IOT instruction */
-#define SIGABRT 6 /* used by abort, replace SIGIOT in the future */
-#define SIGEMT 7 /* EMT instruction */
-#define SIGFPE 8 /* floating point exception */
-#define SIGKILL 9 /* kill (cannot be caught or ignored) */
-#define SIGBUS 10 /* bus error */
-#define SIGSEGV 11 /* segmentation violation */
-#define SIGSYS 12 /* bad argument to system call */
-#define SIGPIPE 13 /* write on a pipe with no one to read it */
-#define SIGALRM 14 /* alarm clock */
-#define SIGTERM 15 /* software termination signal from kill */
-
-#if defined(__rtems__)
-#define SIGURG 16 /* urgent condition on IO channel */
-#define SIGSTOP 17 /* sendable stop signal not from tty */
-#define SIGTSTP 18 /* stop signal from tty */
-#define SIGCONT 19 /* continue a stopped process */
-#define SIGCHLD 20 /* to parent on child stop or exit */
-#define SIGCLD 20 /* System V name for SIGCHLD */
-#define SIGTTIN 21 /* to readers pgrp upon background tty read */
-#define SIGTTOU 22 /* like TTIN for output if (tp->t_local&LTOSTOP) */
-#define SIGIO 23 /* input/output possible signal */
-#define SIGPOLL SIGIO /* System V name for SIGIO */
-#define SIGWINCH 24 /* window changed */
-#define SIGUSR1 25 /* user defined signal 1 */
-#define SIGUSR2 26 /* user defined signal 2 */
-
-/* Real-Time Signals Range, P1003.1b-1993, p. 61
- NOTE: By P1003.1b-1993, this should be at least RTSIG_MAX
- (which is a minimum of 8) signals.
- */
-#define SIGRTMIN 27
-#define SIGRTMAX 31
-#define __SIGFIRSTNOTRT SIGHUP
-#define __SIGLASTNOTRT SIGUSR2
-
-#define NSIG 32 /* signal 0 implied */
-
-#elif defined(__svr4__)
-/* svr4 specifics. different signals above 15, and sigaction. */
-#define SIGUSR1 16
-#define SIGUSR2 17
-#define SIGCLD 18
-#define SIGPWR 19
-#define SIGWINCH 20
-#define SIGPOLL 22 /* 20 for x.out binaries!!!! */
-#define SIGSTOP 23 /* sendable stop signal not from tty */
-#define SIGTSTP 24 /* stop signal from tty */
-#define SIGCONT 25 /* continue a stopped process */
-#define SIGTTIN 26 /* to readers pgrp upon background tty read */
-#define SIGTTOU 27 /* like TTIN for output if (tp->t_local&LTOSTOP) */
-#define NSIG 28
-#else
-#define SIGURG 16 /* urgent condition on IO channel */
-#define SIGSTOP 17 /* sendable stop signal not from tty */
-#define SIGTSTP 18 /* stop signal from tty */
-#define SIGCONT 19 /* continue a stopped process */
-#define SIGCHLD 20 /* to parent on child stop or exit */
-#define SIGCLD 20 /* System V name for SIGCHLD */
-#define SIGTTIN 21 /* to readers pgrp upon background tty read */
-#define SIGTTOU 22 /* like TTIN for output if (tp->t_local&LTOSTOP) */
-#define SIGIO 23 /* input/output possible signal */
-#define SIGPOLL SIGIO /* System V name for SIGIO */
-#define SIGXCPU 24 /* exceeded CPU time limit */
-#define SIGXFSZ 25 /* exceeded file size limit */
-#define SIGVTALRM 26 /* virtual time alarm */
-#define SIGPROF 27 /* profiling time alarm */
-#define SIGWINCH 28 /* window changed */
-#define SIGLOST 29 /* resource lost (eg, record-lock lost) */
-#define SIGUSR1 30 /* user defined signal 1 */
-#define SIGUSR2 31 /* user defined signal 2 */
-#define NSIG 64 /* signal 0 implied */
-#define SIGRTMIN 32
-#define SIGRTMAX NSIG
-#endif
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#ifndef _SIGNAL_H_
-/* Some applications take advantage of the fact that <sys/signal.h>
- * and <signal.h> are equivalent in glibc. Allow for that here. */
+#warning redirecting incorrect #include <sys/signal.h> to <signal.h>
#include <signal.h>
-#endif
-#endif /* _SYS_SIGNAL_H */
diff --git a/system/include/libc/sys/signalfd.h b/system/include/libc/sys/signalfd.h
new file mode 100644
index 00000000..4f3d3999
--- /dev/null
+++ b/system/include/libc/sys/signalfd.h
@@ -0,0 +1,44 @@
+#ifndef _SYS_SIGNALFD_H
+#define _SYS_SIGNALFD_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+#include <fcntl.h>
+
+#define __NEED_sigset_t
+
+#include <bits/alltypes.h>
+
+#define SFD_CLOEXEC O_CLOEXEC
+#define SFD_NONBLOCK O_NONBLOCK
+
+int signalfd(int, const sigset_t *, int);
+
+struct signalfd_siginfo {
+ uint32_t ssi_signo;
+ int32_t ssi_errno;
+ int32_t ssi_code;
+ uint32_t ssi_pid;
+ uint32_t ssi_uid;
+ int32_t ssi_fd;
+ uint32_t ssi_tid;
+ uint32_t ssi_band;
+ uint32_t ssi_overrun;
+ uint32_t ssi_trapno;
+ int32_t ssi_status;
+ int32_t ssi_int;
+ uintptr_t ssi_ptr;
+ uint64_t ssi_utime;
+ uint64_t ssi_stime;
+ uint64_t ssi_addr;
+ uint8_t pad[128-12*4-sizeof(void *)-3*8];
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/sys/socket.h b/system/include/libc/sys/socket.h
new file mode 100644
index 00000000..08488c8b
--- /dev/null
+++ b/system/include/libc/sys/socket.h
@@ -0,0 +1,299 @@
+#ifndef _SYS_SOCKET_H
+#define _SYS_SOCKET_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <features.h>
+
+#define __NEED_socklen_t
+#define __NEED_sa_family_t
+#define __NEED_size_t
+#define __NEED_ssize_t
+#define __NEED_uid_t
+#define __NEED_pid_t
+#define __NEED_gid_t
+#define __NEED_struct_iovec
+
+#include <bits/alltypes.h>
+
+#include <bits/socket.h>
+
+struct ucred
+{
+ pid_t pid;
+ uid_t uid;
+ gid_t gid;
+};
+
+struct linger
+{
+ int l_onoff;
+ int l_linger;
+};
+
+#define SHUT_RD 0
+#define SHUT_WD 1
+#define SHUT_RDWR 2
+
+#ifndef SOCK_STREAM
+#define SOCK_STREAM 1
+#define SOCK_DGRAM 2
+#endif
+
+#define SOCK_RAW 3
+#define SOCK_RDM 4
+#define SOCK_SEQPACKET 5
+#define SOCK_DCCP 6
+#define SOCK_PACKET 10
+
+#ifndef SOCK_CLOEXEC
+#define SOCK_CLOEXEC 02000000
+#define SOCK_NONBLOCK 04000
+#endif
+
+#define PF_UNSPEC 0
+#define PF_LOCAL 1
+#define PF_UNIX PF_LOCAL
+#define PF_FILE PF_LOCAL
+#define PF_INET 2
+#define PF_AX25 3
+#define PF_IPX 4
+#define PF_APPLETALK 5
+#define PF_NETROM 6
+#define PF_BRIDGE 7
+#define PF_ATMPVC 8
+#define PF_X25 9
+#define PF_INET6 10
+#define PF_ROSE 11
+#define PF_DECnet 12
+#define PF_NETBEUI 13
+#define PF_SECURITY 14
+#define PF_KEY 15
+#define PF_NETLINK 16
+#define PF_ROUTE PF_NETLINK
+#define PF_PACKET 17
+#define PF_ASH 18
+#define PF_ECONET 19
+#define PF_ATMSVC 20
+#define PF_RDS 21
+#define PF_SNA 22
+#define PF_IRDA 23
+#define PF_PPPOX 24
+#define PF_WANPIPE 25
+#define PF_LLC 26
+#define PF_IB 27
+#define PF_CAN 29
+#define PF_TIPC 30
+#define PF_BLUETOOTH 31
+#define PF_IUCV 32
+#define PF_RXRPC 33
+#define PF_ISDN 34
+#define PF_PHONET 35
+#define PF_IEEE802154 36
+#define PF_CAIF 37
+#define PF_ALG 38
+#define PF_NFC 39
+#define PF_VSOCK 40
+#define PF_MAX 41
+
+#define AF_UNSPEC PF_UNSPEC
+#define AF_LOCAL PF_LOCAL
+#define AF_UNIX AF_LOCAL
+#define AF_FILE AF_LOCAL
+#define AF_INET PF_INET
+#define AF_AX25 PF_AX25
+#define AF_IPX PF_IPX
+#define AF_APPLETALK PF_APPLETALK
+#define AF_NETROM PF_NETROM
+#define AF_BRIDGE PF_BRIDGE
+#define AF_ATMPVC PF_ATMPVC
+#define AF_X25 PF_X25
+#define AF_INET6 PF_INET6
+#define AF_ROSE PF_ROSE
+#define AF_DECnet PF_DECnet
+#define AF_NETBEUI PF_NETBEUI
+#define AF_SECURITY PF_SECURITY
+#define AF_KEY PF_KEY
+#define AF_NETLINK PF_NETLINK
+#define AF_ROUTE PF_ROUTE
+#define AF_PACKET PF_PACKET
+#define AF_ASH PF_ASH
+#define AF_ECONET PF_ECONET
+#define AF_ATMSVC PF_ATMSVC
+#define AF_RDS PF_RDS
+#define AF_SNA PF_SNA
+#define AF_IRDA PF_IRDA
+#define AF_PPPOX PF_PPPOX
+#define AF_WANPIPE PF_WANPIPE
+#define AF_LLC PF_LLC
+#define AF_IB PF_IB
+#define AF_CAN PF_CAN
+#define AF_TIPC PF_TIPC
+#define AF_BLUETOOTH PF_BLUETOOTH
+#define AF_IUCV PF_IUCV
+#define AF_RXRPC PF_RXRPC
+#define AF_ISDN PF_ISDN
+#define AF_PHONET PF_PHONET
+#define AF_IEEE802154 PF_IEEE802154
+#define AF_CAIF PF_CAIF
+#define AF_ALG PF_ALG
+#define AF_NFC PF_NFC
+#define AF_VSOCK PF_VSOCK
+#define AF_MAX PF_MAX
+
+#ifndef SO_DEBUG
+#define SO_DEBUG 1
+#define SO_REUSEADDR 2
+#define SO_TYPE 3
+#define SO_ERROR 4
+#define SO_DONTROUTE 5
+#define SO_BROADCAST 6
+#define SO_SNDBUF 7
+#define SO_RCVBUF 8
+#define SO_KEEPALIVE 9
+#define SO_OOBINLINE 10
+#define SO_NO_CHECK 11
+#define SO_PRIORITY 12
+#define SO_LINGER 13
+#define SO_BSDCOMPAT 14
+#define SO_REUSEPORT 15
+#define SO_PASSCRED 16
+#define SO_PEERCRED 17
+#define SO_RCVLOWAT 18
+#define SO_SNDLOWAT 19
+#define SO_RCVTIMEO 20
+#define SO_SNDTIMEO 21
+#define SO_SNDBUFFORCE 32
+#define SO_RCVBUFFORCE 33
+#endif
+
+#define SO_SECURITY_AUTHENTICATION 22
+#define SO_SECURITY_ENCRYPTION_TRANSPORT 23
+#define SO_SECURITY_ENCRYPTION_NETWORK 24
+
+#define SO_BINDTODEVICE 25
+
+#define SO_ATTACH_FILTER 26
+#define SO_DETACH_FILTER 27
+#define SO_GET_FILTER SO_ATTACH_FILTER
+
+#define SO_PEERNAME 28
+#define SO_TIMESTAMP 29
+#define SCM_TIMESTAMP SO_TIMESTAMP
+
+#define SO_ACCEPTCONN 30
+#define SO_PEERSEC 31
+#define SO_PASSSEC 34
+#define SO_TIMESTAMPNS 35
+#define SCM_TIMESTAMPNS SO_TIMESTAMPNS
+#define SO_MARK 36
+#define SO_TIMESTAMPING 37
+#define SCM_TIMESTAMPING SO_TIMESTAMPING
+#define SO_PROTOCOL 38
+#define SO_DOMAIN 39
+#define SO_RXQ_OVFL 40
+#define SO_WIFI_STATUS 41
+#define SCM_WIFI_STATUS SO_WIFI_STATUS
+#define SO_PEEK_OFF 42
+#define SO_NOFCS 43
+#define SO_LOCK_FILTER 44
+#define SO_SELECT_ERR_QUEUE 45
+
+#ifndef SOL_SOCKET
+#define SOL_SOCKET 1
+#endif
+
+#define SOL_RAW 255
+#define SOL_DECNET 261
+#define SOL_X25 262
+#define SOL_PACKET 263
+#define SOL_ATM 264
+#define SOL_AAL 265
+#define SOL_IRDA 266
+
+#define SOMAXCONN 128
+
+#define MSG_OOB 0x0001
+#define MSG_PEEK 0x0002
+#define MSG_DONTROUTE 0x0004
+#define MSG_CTRUNC 0x0008
+#define MSG_PROXY 0x0010
+#define MSG_TRUNC 0x0020
+#define MSG_DONTWAIT 0x0040
+#define MSG_EOR 0x0080
+#define MSG_WAITALL 0x0100
+#define MSG_FIN 0x0200
+#define MSD_SYN 0x0400
+#define MSG_CONFIRM 0x0800
+#define MSG_RST 0x1000
+#define MSG_ERRQUEUE 0x2000
+#define MSG_NOSIGNAL 0x4000
+#define MSG_MORE 0x8000
+#define MSG_WAITFORONE 0x10000
+#define MSG_CMSG_CLOEXEC 0x40000000
+
+#define __CMSG_LEN(cmsg) (((cmsg)->cmsg_len + sizeof(long) - 1) & ~(long)(sizeof(long) - 1))
+#define __CMSG_NEXT(cmsg) ((unsigned char *)(cmsg) + __CMSG_LEN(cmsg))
+#define __MHDR_END(mhdr) ((unsigned char *)(mhdr)->msg_control + (mhdr)->msg_controllen)
+
+#define CMSG_DATA(cmsg) ((unsigned char *) (((struct cmsghdr *)(cmsg)) + 1))
+#define CMSG_NXTHDR(mhdr, cmsg) ((cmsg)->cmsg_len < sizeof (struct cmsghdr) ? (struct cmsghdr *)0 : \
+ (__CMSG_NEXT(cmsg) + sizeof (struct cmsghdr) >= __MHDR_END(mhdr) ? (struct cmsghdr *)0 : \
+ ((struct cmsghdr *)__CMSG_NEXT(cmsg))))
+#define CMSG_FIRSTHDR(mhdr) ((size_t) (mhdr)->msg_controllen >= sizeof (struct cmsghdr) ? (struct cmsghdr *) (mhdr)->msg_control : (struct cmsghdr *) 0)
+
+#define CMSG_ALIGN(len) (((len) + sizeof (size_t) - 1) & (size_t) ~(sizeof (size_t) - 1))
+#define CMSG_SPACE(len) (CMSG_ALIGN (len) + CMSG_ALIGN (sizeof (struct cmsghdr)))
+#define CMSG_LEN(len) (CMSG_ALIGN (sizeof (struct cmsghdr)) + (len))
+
+#define SCM_RIGHTS 0x01
+#define SCM_CREDENTIALS 0x02
+
+struct sockaddr
+{
+ sa_family_t sa_family;
+ char sa_data[14];
+};
+
+struct sockaddr_storage
+{
+ sa_family_t ss_family;
+ unsigned long __ss_align;
+ char __ss_padding[128-2*sizeof(unsigned long)];
+};
+
+int socket (int, int, int);
+int socketpair (int, int, int, int [2]);
+
+int shutdown (int, int);
+
+int bind (int, const struct sockaddr *, socklen_t);
+int connect (int, const struct sockaddr *, socklen_t);
+int listen (int, int);
+int accept (int, struct sockaddr *__restrict, socklen_t *__restrict);
+int accept4(int, struct sockaddr *__restrict, socklen_t *__restrict, int);
+
+int getsockname (int, struct sockaddr *__restrict, socklen_t *__restrict);
+int getpeername (int, struct sockaddr *__restrict, socklen_t *__restrict);
+
+ssize_t send (int, const void *, size_t, int);
+ssize_t recv (int, void *, size_t, int);
+ssize_t sendto (int, const void *, size_t, int, const struct sockaddr *, socklen_t);
+ssize_t recvfrom (int, void *__restrict, size_t, int, struct sockaddr *__restrict, socklen_t *__restrict);
+ssize_t sendmsg (int, const struct msghdr *, int);
+ssize_t recvmsg (int, struct msghdr *, int);
+
+int getsockopt (int, int, int, void *__restrict, socklen_t *__restrict);
+int setsockopt (int, int, int, const void *, socklen_t);
+
+int sockatmark (int);
+
+#define SHUT_RD 0
+#define SHUT_WR 1
+#define SHUT_RDWR 2
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/system/include/libc/sys/stat.h b/system/include/libc/sys/stat.h
index 2285b294..c6abab5a 100644
--- a/system/include/libc/sys/stat.h
+++ b/system/include/libc/sys/stat.h
@@ -1,223 +1,114 @@
#ifndef _SYS_STAT_H
#define _SYS_STAT_H
-
#ifdef __cplusplus
extern "C" {
#endif
-#include <_ansi.h>
-#include <time.h>
-#include <sys/types.h>
+#include <features.h>
-/* dj's stat defines _STAT_H_ */
-#ifndef _STAT_H_
+#define __NEED_dev_t
+#define __NEED_ino_t
+#define __NEED_mode_t
+#define __NEED_nlink_t
+#define __NEED_uid_t
+#define __NEED_gid_t
+#define __NEED_off_t
+#define __NEED_time_t
+#define __NEED_blksize_t
+#define __NEED_blkcnt_t
+#define __NEED_struct_timespec
-/* It is intended that the layout of this structure not change when the
- sizes of any of the basic types change (short, int, long) [via a compile
- time option]. */
+#include <bits/alltypes.h>
-#ifdef __CYGWIN__
-#include <cygwin/stat.h>
-#ifdef _COMPILING_NEWLIB
-#define stat64 __stat64
-#endif
-#else
-struct stat
-{
- dev_t st_dev;
- ino_t st_ino;
- mode_t st_mode;
- nlink_t st_nlink;
- uid_t st_uid;
- gid_t st_gid;
- dev_t st_rdev;
- off_t st_size;
-#if defined(__rtems__)
- struct timespec st_atim;
- struct timespec st_mtim;
- struct timespec st_ctim;
- blksize_t st_blksize;
- blkcnt_t st_blocks;
-#else
- /* SysV/sco doesn't have the rest... But Solaris, eabi does. */
-#if defined(__svr4__) && !defined(__PPC__) && !defined(__sun__)
- time_t st_atime;
- time_t st_mtime;
- time_t st_ctime;
-#else
- time_t st_atime;
- long st_spare1;
- time_t st_mtime;
- long st_spare2;
- time_t st_ctime;
- long st_spare3;
- long st_blksize;
- long st_blocks;
- long st_spare4[2];
-#endif
-#endif
-};
-
-struct stat64
-{
- dev_t st_dev;
- ino_t st_ino;
- mode_t st_mode;
- nlink_t st_nlink;
- uid_t st_uid;
- gid_t st_gid;
- dev_t st_rdev;
- off_t st_size;
-#if defined(__rtems__)
- struct timespec st_atim;
- struct timespec st_mtim;
- struct timespec st_ctim;
- blksize_t st_blksize;
- blkcnt_t st_blocks;
-#else
- /* SysV/sco doesn't have the rest... But Solaris, eabi does. */
-#if defined(__svr4__) && !defined(__PPC__) && !defined(__sun__)
- time_t st_atime;
- time_t st_mtime;
- time_t st_ctime;
-#else
- time_t st_atime;
- long st_spare1;
- time_t st_mtime;
- long st_spare2;
- time_t st_ctime;
- long st_spare3;
- long st_blksize;
- long st_blocks;
- long st_spare4[2];
-#endif
-#endif
-};
+#include <bits/stat.h>
-#if defined(__rtems__)
#define st_atime st_atim.tv_sec
-#define st_ctime st_ctim.tv_sec
#define st_mtime st_mtim.tv_sec
-#endif
-
-#endif
-
-#define _IFMT 0170000 /* type of file */
-#define _IFDIR 0040000 /* directory */
-#define _IFCHR 0020000 /* character special */
-#define _IFBLK 0060000 /* block special */
-#define _IFREG 0100000 /* regular */
-#define _IFLNK 0120000 /* symbolic link */
-#define _IFSOCK 0140000 /* socket */
-#define _IFIFO 0010000 /* fifo */
-
-#define S_BLKSIZE 1024 /* size of a block */
-
-#define S_ISUID 0004000 /* set user id on execution */
-#define S_ISGID 0002000 /* set group id on execution */
-#define S_ISVTX 0001000 /* save swapped text even after use */
-#ifndef _POSIX_SOURCE
-#define S_IREAD 0000400 /* read permission, owner */
-#define S_IWRITE 0000200 /* write permission, owner */
-#define S_IEXEC 0000100 /* execute/search permission, owner */
-#define S_ENFMT 0002000 /* enforcement-mode locking */
-#endif /* !_POSIX_SOURCE */
-
-#define S_IFMT _IFMT
-#define S_IFDIR _IFDIR
-#define S_IFCHR _IFCHR
-#define S_IFBLK _IFBLK
-#define S_IFREG _IFREG
-#define S_IFLNK _IFLNK
-#define S_IFSOCK _IFSOCK
-#define S_IFIFO _IFIFO
-
-#ifdef _WIN32
-/* The Windows header files define _S_ forms of these, so we do too
- for easier portability. */
-#define _S_IFMT _IFMT
-#define _S_IFDIR _IFDIR
-#define _S_IFCHR _IFCHR
-#define _S_IFIFO _IFIFO
-#define _S_IFREG _IFREG
-#define _S_IREAD 0000400
-#define _S_IWRITE 0000200
-#define _S_IEXEC 0000100
-#endif
+#define st_ctime st_ctim.tv_sec
-#define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
-#define S_IRUSR 0000400 /* read permission, owner */
-#define S_IWUSR 0000200 /* write permission, owner */
-#define S_IXUSR 0000100/* execute/search permission, owner */
-#define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
-#define S_IRGRP 0000040 /* read permission, group */
-#define S_IWGRP 0000020 /* write permission, grougroup */
-#define S_IXGRP 0000010/* execute/search permission, group */
-#define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
-#define S_IROTH 0000004 /* read permission, other */
-#define S_IWOTH 0000002 /* write permission, other */
-#define S_IXOTH 0000001/* execute/search permission, other */
-
-#ifndef _POSIX_SOURCE
-#define ACCESSPERMS (S_IRWXU | S_IRWXG | S_IRWXO) /* 0777 */
-#define ALLPERMS (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO) /* 07777 */
-#define DEFFILEMODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) /* 0666 */
+#define S_IFMT 0170000
+
+#define S_IFDIR 0040000
+#define S_IFCHR 0020000
+#define S_IFBLK 0060000
+#define S_IFREG 0100000
+#define S_IFIFO 0010000
+#define S_IFLNK 0120000
+#define S_IFSOCK 0140000
+
+#define S_TYPEISMQ(buf) 0
+#define S_TYPEISSEM(buf) 0
+#define S_TYPEISSHM(buf) 0
+#define S_TYPEISTMO(buf) 0
+
+#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
+#define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR)
+#define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK)
+#define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
+#define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFIFO)
+#define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK)
+#define S_ISSOCK(mode) (((mode) & S_IFMT) == S_IFSOCK)
+
+#ifndef S_IRUSR
+#define S_ISUID 04000
+#define S_ISGID 02000
+#define S_ISVTX 01000
+#define S_IRUSR 0400
+#define S_IWUSR 0200
+#define S_IXUSR 0100
+#define S_IRWXU 0700
+#define S_IRGRP 0040
+#define S_IWGRP 0020
+#define S_IXGRP 0010
+#define S_IRWXG 0070
+#define S_IROTH 0004
+#define S_IWOTH 0002
+#define S_IXOTH 0001
+#define S_IRWXO 0007
+#endif
+
+#define UTIME_NOW 0x3fffffff
+#define UTIME_OMIT 0x3ffffffe
+
+int stat(const char *__restrict, struct stat *__restrict);
+int fstat(int, struct stat *);
+int lstat(const char *__restrict, struct stat *__restrict);
+int fstatat(int, const char *__restrict, struct stat *__restrict, int);
+int chmod(const char *, mode_t);
+int fchmod(int, mode_t);
+int fchmodat(int, const char *, mode_t, int);
+mode_t umask(mode_t);
+int mkdir(const char *, mode_t);
+int mknod(const char *, mode_t, dev_t);
+int mkfifo(const char *, mode_t);
+int mkdirat(int, const char *, mode_t);
+int mknodat(int, const char *, mode_t, dev_t);
+int mkfifoat(int, const char *, mode_t);
+
+int futimens(int, const struct timespec [2]);
+int utimensat(int, const char *, const struct timespec [2], int);
+
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+int lchmod(const char *, mode_t);
+#define S_IREAD S_IRUSR
+#define S_IWRITE S_IWUSR
+#define S_IEXEC S_IXUSR
+#endif
+
+#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
+#define stat64 stat
+#define fstat64 fstat
+#define lstat64 lstat
+#define fstatat64 fstatat
+#define blksize64_t blksize_t
+#define blkcnt64_t blkcnt_t
+#define ino64_t ino_t
+#define off64_t off_t
#endif
-#define S_ISBLK(m) (((m)&_IFMT) == _IFBLK)
-#define S_ISCHR(m) (((m)&_IFMT) == _IFCHR)
-#define S_ISDIR(m) (((m)&_IFMT) == _IFDIR)
-#define S_ISFIFO(m) (((m)&_IFMT) == _IFIFO)
-#define S_ISREG(m) (((m)&_IFMT) == _IFREG)
-#define S_ISLNK(m) (((m)&_IFMT) == _IFLNK)
-#define S_ISSOCK(m) (((m)&_IFMT) == _IFSOCK)
-
-#if defined(__CYGWIN__)
-/* Special tv_nsec values for futimens(2) and utimensat(2). */
-#define UTIME_NOW -2L
-#define UTIME_OMIT -1L
+#ifdef __cplusplus
+}
#endif
-
-int _EXFUN(chmod,( const char *__path, mode_t __mode ));
-int _EXFUN(lchmod,( const char *__path, mode_t __mode ));
-int _EXFUN(fchmod,(int __fd, mode_t __mode));
-int _EXFUN(fstat,( int __fd, struct stat *__sbuf ));
-int _EXFUN(fstat64,( int __fd, struct stat64 *__sbuf )); /* XXX Emscripten */
-int _EXFUN(mkdir,( const char *_path, mode_t __mode ));
-int _EXFUN(mkfifo,( const char *__path, mode_t __mode ));
-int _EXFUN(stat,( const char *__path, struct stat *__sbuf ));
-int _EXFUN(stat64,( const char *__path, struct stat64 *__sbuf )); /* XXX Emscripten */
-mode_t _EXFUN(umask,( mode_t __mask ));
-
-#if defined(EMSCRIPTEN) || defined (__SPU__) || defined(__rtems__) || defined(__CYGWIN__) && !defined(__INSIDE_CYGWIN__)
-int _EXFUN(lstat,( const char *__path, struct stat *__buf ));
-int _EXFUN(lstat64,( const char *__path, struct stat64 *__buf )); /* XXX Emscripten */
-int _EXFUN(mknod,( const char *__path, mode_t __mode, dev_t __dev ));
#endif
-#if defined (__CYGWIN__) && !defined(__INSIDE_CYGWIN__)
-int _EXFUN(fchmodat, (int, const char *, mode_t, int));
-int _EXFUN(fstatat, (int, const char *, struct stat *, int));
-int _EXFUN(mkdirat, (int, const char *, mode_t));
-int _EXFUN(mkfifoat, (int, const char *, mode_t));
-int _EXFUN(mknodat, (int, const char *, mode_t, dev_t));
-int _EXFUN(utimensat, (int, const char *, const struct timespec *, int));
-int _EXFUN(futimens, (int, const struct timespec *));
-#endif
-/* Provide prototypes for most of the _<systemcall> names that are
- provided in newlib for some compilers. */
-#ifdef _COMPILING_NEWLIB
-int _EXFUN(_fstat,( int __fd, struct stat *__sbuf ));
-int _EXFUN(_stat,( const char *__path, struct stat *__sbuf ));
-#ifdef __LARGE64_FILES
-struct stat64;
-int _EXFUN(_fstat64,( int __fd, struct stat64 *__sbuf ));
-#endif
-#endif
-
-#endif /* !_STAT_H_ */
-#ifdef __cplusplus
-}
-#endif
-#endif /* _SYS_STAT_H */
diff --git a/system/include/libc/sys/statfs.h b/system/include/libc/sys/statfs.h
new file mode 100644
index 00000000..6f4c6230
--- /dev/null
+++ b/system/include/libc/sys/statfs.h
@@ -0,0 +1,32 @@
+#ifndef _SYS_STATFS_H
+#define _SYS_STATFS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <features.h>
+
+#include <sys/statvfs.h>
+
+typedef struct __fsid_t {
+ int __val[2];
+} fsid_t;
+
+#include <bits/statfs.h>
+
+int statfs (const char *, struct statfs *);
+int fstatfs (int, struct statfs *);
+
+#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
+#define statfs64 statfs
+#define fstatfs64 fstatfs
+#define fsblkcnt64_t fsblkcnt_t
+#define fsfilcnt64_t fsfilcnt_t
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/sys/statvfs.h b/system/include/libc/sys/statvfs.h
new file mode 100644
index 00000000..e0839eca
--- /dev/null
+++ b/system/include/libc/sys/statvfs.h
@@ -0,0 +1,57 @@
+#ifndef _SYS_STATVFS_H
+#define _SYS_STATVFS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <features.h>
+
+#define __NEED_fsblkcnt_t
+#define __NEED_fsfilcnt_t
+#include <bits/alltypes.h>
+
+#include <endian.h>
+
+struct statvfs {
+ unsigned long f_bsize, f_frsize;
+ fsblkcnt_t f_blocks, f_bfree, f_bavail;
+ fsfilcnt_t f_files, f_ffree, f_favail;
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+ unsigned long f_fsid;
+ unsigned :8*(2*sizeof(int)-sizeof(long));
+#else
+ unsigned :8*(2*sizeof(int)-sizeof(long));
+ unsigned long f_fsid;
+#endif
+ unsigned long f_flag, f_namemax;
+ int __reserved[6];
+};
+
+int statvfs (const char *__restrict, struct statvfs *__restrict);
+int fstatvfs (int, struct statvfs *);
+
+#define ST_RDONLY 1
+#define ST_NOSUID 2
+#define ST_NODEV 4
+#define ST_NOEXEC 8
+#define ST_SYNCHRONOUS 16
+#define ST_MANDLOCK 64
+#define ST_WRITE 128
+#define ST_APPEND 256
+#define ST_IMMUTABLE 512
+#define ST_NOATIME 1024
+#define ST_NODIRATIME 2048
+
+#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
+#define statvfs64 statvfs
+#define fstatvfs64 fstatvfs
+#define fsblkcnt64_t fsblkcnt_t
+#define fsfilcnt64_t fsfilcnt_t
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/sys/stdio.h b/system/include/libc/sys/stdio.h
deleted file mode 100644
index 0918fe15..00000000
--- a/system/include/libc/sys/stdio.h
+++ /dev/null
@@ -1,27 +0,0 @@
-#ifndef _NEWLIB_STDIO_H
-#define _NEWLIB_STDIO_H
-
-#include <sys/lock.h>
-#include <sys/reent.h>
-
-/* Internal locking macros, used to protect stdio functions. In the
- general case, expand to nothing. Use __SSTR flag in FILE _flags to
- detect if FILE is private to sprintf/sscanf class of functions; if
- set then do nothing as lock is not initialised. */
-#if !defined(_flockfile)
-#ifndef __SINGLE_THREAD__
-# define _flockfile(fp) (((fp)->_flags & __SSTR) ? 0 : __lock_acquire_recursive((fp)->_lock))
-#else
-# define _flockfile(fp) (_CAST_VOID 0)
-#endif
-#endif
-
-#if !defined(_funlockfile)
-#ifndef __SINGLE_THREAD__
-# define _funlockfile(fp) (((fp)->_flags & __SSTR) ? 0 : __lock_release_recursive((fp)->_lock))
-#else
-# define _funlockfile(fp) (_CAST_VOID 0)
-#endif
-#endif
-
-#endif /* _NEWLIB_STDIO_H */
diff --git a/system/include/libc/sys/string.h b/system/include/libc/sys/string.h
deleted file mode 100644
index ceedf4be..00000000
--- a/system/include/libc/sys/string.h
+++ /dev/null
@@ -1,2 +0,0 @@
-/* This is a dummy <sys/string.h> used as a placeholder for
- systems that need to have a special header file. */
diff --git a/system/include/libc/sys/stropts.h b/system/include/libc/sys/stropts.h
new file mode 100644
index 00000000..5b5bc02f
--- /dev/null
+++ b/system/include/libc/sys/stropts.h
@@ -0,0 +1 @@
+#include <stropts.h>
diff --git a/system/include/libc/sys/swap.h b/system/include/libc/sys/swap.h
new file mode 100644
index 00000000..11c0f929
--- /dev/null
+++ b/system/include/libc/sys/swap.h
@@ -0,0 +1,21 @@
+#ifndef _SYS_SWAP_H
+#define _SYS_SWAP_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#define SWAP_FLAG_PREFER 0x8000
+#define SWAP_FLAG_PRIO_MASK 0x7fff
+#define SWAP_FLAG_PRIO_SHIFT 0
+#define SWAP_FLAG_DISCARD 0x10000
+
+int swapon (const char *, int);
+int swapoff (const char *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/sys/syscall.h b/system/include/libc/sys/syscall.h
new file mode 100644
index 00000000..24987ddf
--- /dev/null
+++ b/system/include/libc/sys/syscall.h
@@ -0,0 +1,6 @@
+#ifndef _SYS_SYSCALL_H
+#define _SYS_SYSCALL_H
+
+#include <bits/syscall.h>
+
+#endif
diff --git a/system/include/libc/sys/sysctl.h b/system/include/libc/sys/sysctl.h
new file mode 100644
index 00000000..c358b794
--- /dev/null
+++ b/system/include/libc/sys/sysctl.h
@@ -0,0 +1,17 @@
+#ifndef _SYS_SYSCTL_H
+#define _SYS_SYSCTL_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define __NEED_size_t
+#include <bits/alltypes.h>
+
+int sysctl (int *, int, void *, size_t *, void *, size_t);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/sys/sysinfo.h b/system/include/libc/sys/sysinfo.h
new file mode 100644
index 00000000..6a3931e5
--- /dev/null
+++ b/system/include/libc/sys/sysinfo.h
@@ -0,0 +1,36 @@
+#ifndef _SYS_SYSINFO_H
+#define _SYS_SYSINFO_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define SI_LOAD_SHIFT 16
+
+struct sysinfo {
+ unsigned long uptime;
+ unsigned long loads[3];
+ unsigned long totalram;
+ unsigned long freeram;
+ unsigned long sharedram;
+ unsigned long bufferram;
+ unsigned long totalswap;
+ unsigned long freeswap;
+ unsigned short procs, pad;
+ unsigned long totalhigh;
+ unsigned long freehigh;
+ unsigned mem_unit;
+ char __reserved[256];
+};
+
+int sysinfo (struct sysinfo *);
+int get_nprocs_conf (void);
+int get_nprocs (void);
+long get_phys_pages (void);
+long get_avphys_pages (void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/sys/syslimits.h b/system/include/libc/sys/syslimits.h
deleted file mode 100644
index ba9dbd66..00000000
--- a/system/include/libc/sys/syslimits.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (c) 1988, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)syslimits.h 8.1 (Berkeley) 6/2/93
- * $FreeBSD: src/sys/sys/syslimits.h,v 1.10 2001/06/18 20:24:54 wollman Exp $
- */
-
-#ifndef _SYS_SYSLIMITS_H_
-#define _SYS_SYSLIMITS_H_
-
-#define ARG_MAX 65536 /* max bytes for an exec function */
-#ifndef CHILD_MAX
-#define CHILD_MAX 40 /* max simultaneous processes */
-#endif
-#define LINK_MAX 32767 /* max file link count */
-#define MAX_CANON 255 /* max bytes in term canon input line */
-#define MAX_INPUT 255 /* max bytes in terminal input */
-#define NAME_MAX 255 /* max bytes in a file name */
-#define NGROUPS_MAX 16 /* max supplemental group id's */
-#ifndef OPEN_MAX
-#define OPEN_MAX 64 /* max open files per process */
-#endif
-#define PATH_MAX 1024 /* max bytes in pathname */
-#define PIPE_BUF 512 /* max bytes for atomic pipe writes */
-#define IOV_MAX 1024 /* max elements in i/o vector */
-
-#define BC_BASE_MAX 99 /* max ibase/obase values in bc(1) */
-#define BC_DIM_MAX 2048 /* max array elements in bc(1) */
-#define BC_SCALE_MAX 99 /* max scale value in bc(1) */
-#define BC_STRING_MAX 1000 /* max const string length in bc(1) */
-#define COLL_WEIGHTS_MAX 0 /* max weights for order keyword */
-#define EXPR_NEST_MAX 32 /* max expressions nested in expr(1) */
-#define LINE_MAX 2048 /* max bytes in an input line */
-#define RE_DUP_MAX 255 /* max RE's in interval notation */
-
-#endif
diff --git a/system/include/libc/sys/syslog.h b/system/include/libc/sys/syslog.h
new file mode 100644
index 00000000..7761ecee
--- /dev/null
+++ b/system/include/libc/sys/syslog.h
@@ -0,0 +1 @@
+#include <syslog.h>
diff --git a/system/include/libc/sys/sysmacros.h b/system/include/libc/sys/sysmacros.h
new file mode 100644
index 00000000..07a3ef18
--- /dev/null
+++ b/system/include/libc/sys/sysmacros.h
@@ -0,0 +1,15 @@
+#ifndef _SYS_SYSMACROS_H
+#define _SYS_SYSMACROS_H
+
+#define major(x) \
+ ((unsigned)( (((x)>>31>>1) & 0xfffff000) | (((x)>>8) & 0x00000fff) ))
+#define minor(x) \
+ ((unsigned)( (((x)>>12) & 0xffffff00) | ((x) & 0x000000ff) ))
+
+#define makedev(x,y) ( \
+ (((x)&0xfffff000ULL) << 32) | \
+ (((x)&0x00000fffULL) << 8) | \
+ (((y)&0xffffff00ULL) << 12) | \
+ (((y)&0x000000ffULL)) )
+
+#endif
diff --git a/system/include/libc/sys/termios.h b/system/include/libc/sys/termios.h
index 88e8ad16..f5f751f0 100644
--- a/system/include/libc/sys/termios.h
+++ b/system/include/libc/sys/termios.h
@@ -1,280 +1,2 @@
-/*
- * Copyright (c) 1988, 1989, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)termios.h 8.3 (Berkeley) 3/28/94
- * $Id: termios.h,v 1.11 1998/05/05 21:49:37 jb Exp $
- */
-
-#ifndef _SYS_TERMIOS_H_
-#define _SYS_TERMIOS_H_
-
-/*
- * Special Control Characters
- *
- * Index into c_cc[] character array.
- *
- * Name Subscript Enabled by
- */
-#define VEOF 0 /* ICANON */
-#define VEOL 1 /* ICANON */
-#ifndef _POSIX_SOURCE
-#define VEOL2 2 /* ICANON together with IEXTEN */
-#endif
-#define VERASE 3 /* ICANON */
-#ifndef _POSIX_SOURCE
-#define VWERASE 4 /* ICANON together with IEXTEN */
-#endif
-#define VKILL 5 /* ICANON */
-#ifndef _POSIX_SOURCE
-#define VREPRINT 6 /* ICANON together with IEXTEN */
-#endif
-/* 7 spare 1 */
-#define VINTR 8 /* ISIG */
-#define VQUIT 9 /* ISIG */
-#define VSUSP 10 /* ISIG */
-#ifndef _POSIX_SOURCE
-#define VDSUSP 11 /* ISIG together with IEXTEN */
-#endif
-#define VSTART 12 /* IXON, IXOFF */
-#define VSTOP 13 /* IXON, IXOFF */
-#ifndef _POSIX_SOURCE
-#define VLNEXT 14 /* IEXTEN */
-#define VDISCARD 15 /* IEXTEN */
-#endif
-#define VMIN 16 /* !ICANON */
-#define VTIME 17 /* !ICANON */
-#ifndef _POSIX_SOURCE
-#define VSTATUS 18 /* ICANON together with IEXTEN */
-/* 19 spare 2 */
-#endif
-#define NCCS 20
-
-#define _POSIX_VDISABLE 0xff
-
-#ifndef _POSIX_SOURCE
-#define CCEQ(val, c) ((c) == (val) ? (val) != _POSIX_VDISABLE : 0)
-#endif
-
-/*
- * Input flags - software input processing
- */
-#define IGNBRK 0x00000001 /* ignore BREAK condition */
-#define BRKINT 0x00000002 /* map BREAK to SIGINTR */
-#define IGNPAR 0x00000004 /* ignore (discard) parity errors */
-#define PARMRK 0x00000008 /* mark parity and framing errors */
-#define INPCK 0x00000010 /* enable checking of parity errors */
-#define ISTRIP 0x00000020 /* strip 8th bit off chars */
-#define INLCR 0x00000040 /* map NL into CR */
-#define IGNCR 0x00000080 /* ignore CR */
-#define ICRNL 0x00000100 /* map CR to NL (ala CRMOD) */
-#define IXON 0x00000200 /* enable output flow control */
-#define IXOFF 0x00000400 /* enable input flow control */
-#ifndef _POSIX_SOURCE
-#define IXANY 0x00000800 /* any char will restart after stop */
-#define IMAXBEL 0x00002000 /* ring bell on input queue full */
-#endif /*_POSIX_SOURCE */
-
-/*
- * Output flags - software output processing
- */
-#define OPOST 0x00000001 /* enable following output processing */
-#ifndef _POSIX_SOURCE
-#define ONLCR 0x00000002 /* map NL to CR-NL (ala CRMOD) */
-#define OXTABS 0x00000004 /* expand tabs to spaces */
-#define ONOEOT 0x00000008 /* discard EOT's (^D) on output) */
-#endif /*_POSIX_SOURCE */
-
-/*
- * Control flags - hardware control of terminal
- */
-#ifndef _POSIX_SOURCE
-#define CIGNORE 0x00000001 /* ignore control flags */
-#endif
-#define CSIZE 0x00000300 /* character size mask */
-#define CS5 0x00000000 /* 5 bits (pseudo) */
-#define CS6 0x00000100 /* 6 bits */
-#define CS7 0x00000200 /* 7 bits */
-#define CS8 0x00000300 /* 8 bits */
-#define CSTOPB 0x00000400 /* send 2 stop bits */
-#define CREAD 0x00000800 /* enable receiver */
-#define PARENB 0x00001000 /* parity enable */
-#define PARODD 0x00002000 /* odd parity, else even */
-#define HUPCL 0x00004000 /* hang up on last close */
-#define CLOCAL 0x00008000 /* ignore modem status lines */
-#ifndef _POSIX_SOURCE
-#define CCTS_OFLOW 0x00010000 /* CTS flow control of output */
-#define CRTSCTS (CCTS_OFLOW | CRTS_IFLOW)
-#define CRTS_IFLOW 0x00020000 /* RTS flow control of input */
-#define CDTR_IFLOW 0x00040000 /* DTR flow control of input */
-#define CDSR_OFLOW 0x00080000 /* DSR flow control of output */
-#define CCAR_OFLOW 0x00100000 /* DCD flow control of output */
-#define MDMBUF 0x00100000 /* old name for CCAR_OFLOW */
-#endif
-
-
-/*
- * "Local" flags - dumping ground for other state
- *
- * Warning: some flags in this structure begin with
- * the letter "I" and look like they belong in the
- * input flag.
- */
-
-#ifndef _POSIX_SOURCE
-#define ECHOKE 0x00000001 /* visual erase for line kill */
-#endif /*_POSIX_SOURCE */
-#define ECHOE 0x00000002 /* visually erase chars */
-#define ECHOK 0x00000004 /* echo NL after line kill */
-#define ECHO 0x00000008 /* enable echoing */
-#define ECHONL 0x00000010 /* echo NL even if ECHO is off */
-#ifndef _POSIX_SOURCE
-#define ECHOPRT 0x00000020 /* visual erase mode for hardcopy */
-#define ECHOCTL 0x00000040 /* echo control chars as ^(Char) */
-#endif /*_POSIX_SOURCE */
-#define ISIG 0x00000080 /* enable signals INTR, QUIT, [D]SUSP */
-#define ICANON 0x00000100 /* canonicalize input lines */
-#ifndef _POSIX_SOURCE
-#define ALTWERASE 0x00000200 /* use alternate WERASE algorithm */
-#endif /*_POSIX_SOURCE */
-#define IEXTEN 0x00000400 /* enable DISCARD and LNEXT */
-#define EXTPROC 0x00000800 /* external processing */
-#define TOSTOP 0x00400000 /* stop background jobs from output */
-#ifndef _POSIX_SOURCE
-#define FLUSHO 0x00800000 /* output being flushed (state) */
-#define NOKERNINFO 0x02000000 /* no kernel output from VSTATUS */
-#define PENDIN 0x20000000 /* XXX retype pending input (state) */
-#endif /*_POSIX_SOURCE */
-#define NOFLSH 0x80000000 /* don't flush after interrupt */
-
-typedef unsigned int tcflag_t;
-typedef unsigned char cc_t;
-typedef unsigned int speed_t;
-
-struct termios {
- tcflag_t c_iflag; /* input flags */
- tcflag_t c_oflag; /* output flags */
- tcflag_t c_cflag; /* control flags */
- tcflag_t c_lflag; /* local flags */
- cc_t c_cc[NCCS]; /* control chars */
- speed_t c_ispeed; /* input speed */
- speed_t c_ospeed; /* output speed */
-};
-
-/*
- * Commands passed to tcsetattr() for setting the termios structure.
- */
-#define TCSANOW 0 /* make change immediate */
-#define TCSADRAIN 1 /* drain output, then change */
-#define TCSAFLUSH 2 /* drain output, flush input */
-#ifndef _POSIX_SOURCE
-#define TCSASOFT 0x10 /* flag - don't alter h.w. state */
-#endif
-
-/*
- * Standard speeds
- */
-#define B0 0
-#define B50 50
-#define B75 75
-#define B110 110
-#define B134 134
-#define B150 150
-#define B200 200
-#define B300 300
-#define B600 600
-#define B1200 1200
-#define B1800 1800
-#define B2400 2400
-#define B4800 4800
-#define B9600 9600
-#define B19200 19200
-#define B38400 38400
-#ifndef _POSIX_SOURCE
-#define B7200 7200
-#define B14400 14400
-#define B28800 28800
-#define B57600 57600
-#define B76800 76800
-#define B115200 115200
-#define B230400 230400
-#define EXTA 19200
-#define EXTB 38400
-#endif /* !_POSIX_SOURCE */
-
-#ifndef KERNEL
-
-#define TCIFLUSH 1
-#define TCOFLUSH 2
-#define TCIOFLUSH 3
-#define TCOOFF 1
-#define TCOON 2
-#define TCIOFF 3
-#define TCION 4
-
-#include <sys/cdefs.h>
-
-__BEGIN_DECLS
-speed_t cfgetispeed __P((const struct termios *));
-speed_t cfgetospeed __P((const struct termios *));
-int cfsetispeed __P((struct termios *, speed_t));
-int cfsetospeed __P((struct termios *, speed_t));
-int tcgetattr __P((int, struct termios *));
-int tcsetattr __P((int, int, const struct termios *));
-int tcdrain __P((int));
-int tcflow __P((int, int));
-int tcflush __P((int, int));
-int tcsendbreak __P((int, int));
-
-#ifndef _POSIX_SOURCE
-void cfmakeraw __P((struct termios *));
-int cfsetspeed __P((struct termios *, speed_t));
-#endif /* !_POSIX_SOURCE */
-__END_DECLS
-
-#endif /* !KERNEL */
-
-/* XXX Emscripten */
-struct winsize {
- unsigned short ws_row;
- unsigned short ws_col;
- unsigned short ws_xpixel;
- unsigned short ws_ypixel;
-};
-
-/*
- * END OF PROTECTED INCLUDE.
- */
-#endif /* !_SYS_TERMIOS_H_ */
-
-#ifndef _POSIX_SOURCE
-#include <sys/ttydefaults.h>
-#endif
+#warning redirecting incorrect #include <sys/termios.h> to <termios.h>
+#include <termios.h>
diff --git a/system/include/libc/sys/time.h b/system/include/libc/sys/time.h
index 2bd2421e..3ce824e6 100644
--- a/system/include/libc/sys/time.h
+++ b/system/include/libc/sys/time.h
@@ -1,85 +1,57 @@
-/* time.h -- An implementation of the standard Unix <sys/time.h> file.
- Written by Geoffrey Noer <noer@cygnus.com>
- Public domain; no rights reserved. */
-
-#ifndef _SYS_TIME_H_
-#define _SYS_TIME_H_
-
-#include <_ansi.h>
-#include <sys/types.h>
-#include <time.h> /* XXX Emscripten */
-
+#ifndef _SYS_TIME_H
+#define _SYS_TIME_H
#ifdef __cplusplus
extern "C" {
#endif
-#ifndef _WINSOCK_H
-#define _TIMEVAL_DEFINED
-struct timeval {
- time_t tv_sec;
- suseconds_t tv_usec;
-};
+#include <features.h>
-struct timezone {
- int tz_minuteswest;
- int tz_dsttime;
-};
+#include <sys/select.h>
-#ifdef __CYGWIN__
-#include <cygwin/sys_time.h>
-#endif /* __CYGWIN__ */
+int gettimeofday (struct timeval *__restrict, void *__restrict);
-#endif /* _WINSOCK_H */
+#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
+ || defined(_BSD_SOURCE)
-#define ITIMER_REAL 0
-#define ITIMER_VIRTUAL 1
-#define ITIMER_PROF 2
+#define ITIMER_REAL 0
+#define ITIMER_VIRTUAL 1
+#define ITIMER_PROF 2
-struct itimerval {
- struct timeval it_interval;
- struct timeval it_value;
+struct itimerval
+{
+ struct timeval it_interval;
+ struct timeval it_value;
};
-/* BSD time macros used by RTEMS code */
-#if defined (__rtems__) || defined (__CYGWIN__) || defined (EMSCRIPTEN)
+int getitimer (int, struct itimerval *);
+int setitimer (int, const struct itimerval *__restrict, struct itimerval *__restrict);
+int utimes (const char *, const struct timeval [2]);
-/* Convenience macros for operations on timevals.
- NOTE: `timercmp' does not work for >= or <=. */
-#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
-#define timerclear(tvp) ((tvp)->tv_sec = (tvp)->tv_usec = 0)
-#define timercmp(a, b, CMP) \
- (((a)->tv_sec == (b)->tv_sec) ? \
- ((a)->tv_usec CMP (b)->tv_usec) : \
- ((a)->tv_sec CMP (b)->tv_sec))
-#define timeradd(a, b, result) \
- do { \
- (result)->tv_sec = (a)->tv_sec + (b)->tv_sec; \
- (result)->tv_usec = (a)->tv_usec + (b)->tv_usec; \
- if ((result)->tv_usec >= 1000000) \
- { \
- ++(result)->tv_sec; \
- (result)->tv_usec -= 1000000; \
- } \
- } while (0)
-#define timersub(a, b, result) \
- do { \
- (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
- (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
- if ((result)->tv_usec < 0) { \
- --(result)->tv_sec; \
- (result)->tv_usec += 1000000; \
- } \
- } while (0)
-#endif /* defined (__rtems__) || defined (__CYGWIN__) */
+#endif
-int _EXFUN(gettimeofday, (struct timeval *__p, void *__tz));
-int _EXFUN(settimeofday, (const struct timeval *, const struct timezone *));
-int _EXFUN(utimes, (const char *__path, const struct timeval *__tvp));
-int _EXFUN(getitimer, (int __which, struct itimerval *__value));
-int _EXFUN(setitimer, (int __which, const struct itimerval *__value,
- struct itimerval *__ovalue));
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+struct timezone {
+ int tz_minuteswest;
+ int tz_dsttime;
+};
+int futimes(int, const struct timeval [2]);
+int futimesat(int, const char *, const struct timeval [2]);
+int lutimes(const char *, const struct timeval [2]);
+int settimeofday(const struct timeval *, const struct timezone *);
+int adjtime (const struct timeval *, struct timeval *);
+#define timerisset(t) ((t)->tv_sec || (t)->tv_usec)
+#define timerclear(t) ((t)->tv_sec = (t)->tv_usec = 0)
+#define timercmp(s,t,op) ((s)->tv_sec == (t)->tv_sec ? \
+ (s)->tv_usec op (t)->tv_usec : (s)->tv_sec op (t)->tv_sec)
+#define timeradd(s,t,a) ( (a)->tv_sec = (s)->tv_sec + (t)->tv_sec, \
+ ((a)->tv_usec = (s)->tv_usec + (t)->tv_usec) >= 1000000 && \
+ ((a)->tv_usec -= 1000000, (a)->tv_sec++) )
+#define timersub(s,t,a) ( (a)->tv_sec = (s)->tv_sec - (t)->tv_sec, \
+ ((a)->tv_usec = (s)->tv_usec - (t)->tv_usec) < 0 && \
+ ((a)->tv_usec += 1000000, (a)->tv_sec--) )
+#endif
#ifdef __cplusplus
}
#endif
-#endif /* _SYS_TIME_H_ */
+#endif
diff --git a/system/include/libc/sys/timerfd.h b/system/include/libc/sys/timerfd.h
new file mode 100644
index 00000000..df645fe8
--- /dev/null
+++ b/system/include/libc/sys/timerfd.h
@@ -0,0 +1,24 @@
+#ifndef _SYS_TIMERFD_H
+#define _SYS_TIMERFD_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <time.h>
+#include <fcntl.h>
+
+#define TFD_NONBLOCK O_NONBLOCK
+#define TFD_CLOEXEC O_CLOEXEC
+
+#define TFD_TIMER_ABSTIME 1
+
+int timerfd_create(int, int);
+int timerfd_settime(int, int, const struct itimerspec *, struct itimerspec *);
+int timerfd_gettime(int, struct itimerspec *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/sys/times.h b/system/include/libc/sys/times.h
index 9375cb19..cc55e573 100644
--- a/system/include/libc/sys/times.h
+++ b/system/include/libc/sys/times.h
@@ -1,28 +1,26 @@
#ifndef _SYS_TIMES_H
+#define _SYS_TIMES_H
+
#ifdef __cplusplus
extern "C" {
#endif
-#define _SYS_TIMES_H
-
-#include <_ansi.h>
-#include <machine/types.h>
-#ifndef __clock_t_defined
-typedef _CLOCK_T_ clock_t;
-#define __clock_t_defined
-#endif
+#define __NEED_clock_t
+#include <bits/alltypes.h>
-/* Get Process Times, P1003.1b-1993, p. 92 */
-struct tms {
- clock_t tms_utime; /* user time */
- clock_t tms_stime; /* system time */
- clock_t tms_cutime; /* user time, children */
- clock_t tms_cstime; /* system time, children */
+struct tms
+{
+ clock_t tms_utime;
+ clock_t tms_stime;
+ clock_t tms_cutime;
+ clock_t tms_cstime;
};
-clock_t _EXFUN(times,(struct tms *));
+clock_t times (struct tms *);
#ifdef __cplusplus
}
#endif
-#endif /* !_SYS_TIMES_H */
+
+#endif
+
diff --git a/system/include/libc/sys/timex.h b/system/include/libc/sys/timex.h
new file mode 100644
index 00000000..2e688880
--- /dev/null
+++ b/system/include/libc/sys/timex.h
@@ -0,0 +1,98 @@
+#ifndef _SYS_TIMEX_H
+#define _SYS_TIMEX_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define __NEED_clockid_t
+
+#include <bits/alltypes.h>
+
+#include <sys/time.h>
+
+struct ntptimeval {
+ struct timeval time;
+ long maxerror, esterror;
+};
+
+struct timex {
+ unsigned modes;
+ long offset, freq, maxerror, esterror;
+ int status;
+ long constant, precision, tolerance;
+ struct timeval time;
+ long tick, ppsfreq, jitter;
+ int shift;
+ long stabil, jitcnt, calcnt, errcnt, stbcnt;
+ int tai;
+ int __padding[11];
+};
+
+#define ADJ_OFFSET 0x0001
+#define ADJ_FREQUENCY 0x0002
+#define ADJ_MAXERROR 0x0004
+#define ADJ_ESTERROR 0x0008
+#define ADJ_STATUS 0x0010
+#define ADJ_TIMECONST 0x0020
+#define ADJ_TAI 0x0080
+#define ADJ_SETOFFSET 0x0100
+#define ADJ_MICRO 0x1000
+#define ADJ_NANO 0x2000
+#define ADJ_TICK 0x4000
+#define ADJ_OFFSET_SINGLESHOT 0x8001
+#define ADJ_OFFSET_SS_READ 0xa001
+
+#define MOD_OFFSET ADJ_OFFSET
+#define MOD_FREQUENCY ADJ_FREQUENCY
+#define MOD_MAXERROR ADJ_MAXERROR
+#define MOD_ESTERROR ADJ_ESTERROR
+#define MOD_STATUS ADJ_STATUS
+#define MOD_TIMECONST ADJ_TIMECONST
+#define MOD_CLKB ADJ_TICK
+#define MOD_CLKA ADJ_OFFSET_SINGLESHOT
+#define MOD_TAI ADJ_TAI
+#define MOD_MICRO ADJ_MICRO
+#define MOD_NANO ADJ_NANO
+
+#define STA_PLL 0x0001
+#define STA_PPSFREQ 0x0002
+#define STA_PPSTIME 0x0004
+#define STA_FLL 0x0008
+
+#define STA_INS 0x0010
+#define STA_DEL 0x0020
+#define STA_UNSYNC 0x0040
+#define STA_FREQHOLD 0x0080
+
+#define STA_PPSSIGNAL 0x0100
+#define STA_PPSJITTER 0x0200
+#define STA_PPSWANDER 0x0400
+#define STA_PPSERROR 0x0800
+
+#define STA_CLOCKERR 0x1000
+#define STA_NANO 0x2000
+#define STA_MODE 0x4000
+#define STA_CLK 0x8000
+
+#define STA_RONLY (STA_PPSSIGNAL | STA_PPSJITTER | STA_PPSWANDER | \
+ STA_PPSERROR | STA_CLOCKERR | STA_NANO | STA_MODE | STA_CLK)
+
+#define TIME_OK 0
+#define TIME_INS 1
+#define TIME_DEL 2
+#define TIME_OOP 3
+#define TIME_WAIT 4
+#define TIME_ERROR 5
+#define TIME_BAD TIME_ERROR
+
+#define MAXTC 6
+
+int adjtimex(struct timex *);
+int clock_adjtime(clockid_t, struct timex *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/sys/ttydefaults.h b/system/include/libc/sys/ttydefaults.h
index 65b9c6e8..d251b715 100644
--- a/system/include/libc/sys/ttydefaults.h
+++ b/system/include/libc/sys/ttydefaults.h
@@ -1,97 +1,39 @@
-/*-
- * Copyright (c) 1982, 1986, 1993
- * The Regents of the University of California. All rights reserved.
- * (c) UNIX System Laboratories, Inc.
- * All or some portions of this file are derived from material licensed
- * to the University of California by American Telephone and Telegraph
- * Co. or Unix System Laboratories, Inc. and are reproduced herein with
- * the permission of UNIX System Laboratories, Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)ttydefaults.h 8.4 (Berkeley) 1/21/94
- * $Id: ttydefaults.h,v 1.12 1997/08/15 22:43:22 ache Exp $
- */
+#ifndef _SYS_TTYDEFAULTS_H
+#define _SYS_TTYDEFAULTS_H
-/*
- * System wide defaults for terminal state.
- */
-#ifndef _SYS_TTYDEFAULTS_H_
-#define _SYS_TTYDEFAULTS_H_
+#define TTYDEF_IFLAG (BRKINT | ISTRIP | ICRNL | IMAXBEL | IXON | IXANY)
+#define TTYDEF_OFLAG (OPOST | ONLCR | XTABS)
+#define TTYDEF_LFLAG (ECHO | ICANON | ISIG | IEXTEN | ECHOE|ECHOKE|ECHOCTL)
+#define TTYDEF_CFLAG (CREAD | CS7 | PARENB | HUPCL)
+#define TTYDEF_SPEED (B9600)
+#define CTRL(x) (x&037)
+#define CEOF CTRL('d')
-/*
- * Defaults on "first" open.
- */
-#define TTYDEF_IFLAG (BRKINT | ICRNL | IMAXBEL | IXON | IXANY)
-#define TTYDEF_OFLAG (OPOST | ONLCR)
-#define TTYDEF_LFLAG (ECHO | ICANON | ISIG | IEXTEN | ECHOE|ECHOKE|ECHOCTL)
-#define TTYDEF_CFLAG (CREAD | CS8 | HUPCL)
-#define TTYDEF_SPEED (B9600)
-
-/*
- * Control Character Defaults
- */
-#define CTRL(x) (x&037)
-#define CEOF CTRL('d')
-#define CEOL 0xff /* XXX avoid _POSIX_VDISABLE */
-#define CERASE 0177
-#define CINTR CTRL('c')
-#define CSTATUS CTRL('t')
-#define CKILL CTRL('u')
-#define CMIN 1
-#define CQUIT 034 /* FS, ^\ */
-#define CSUSP CTRL('z')
-#define CTIME 0
-#define CDSUSP CTRL('y')
-#define CSTART CTRL('q')
-#define CSTOP CTRL('s')
-#define CLNEXT CTRL('v')
-#define CDISCARD CTRL('o')
-#define CWERASE CTRL('w')
-#define CREPRINT CTRL('r')
-#define CEOT CEOF
-/* compat */
-#define CBRK CEOL
-#define CRPRNT CREPRINT
-#define CFLUSH CDISCARD
+#ifdef _POSIX_VDISABLE
+#define CEOL _POSIX_VDISABLE
+#define CSTATUS _POSIX_VDISABLE
+#else
+#define CEOL '\0'
+#define CSTATUS '\0'
+#endif
-/* PROTECTED INCLUSION ENDS HERE */
-#endif /* !_SYS_TTYDEFAULTS_H_ */
+#define CERASE 0177
+#define CINTR CTRL('c')
+#define CKILL CTRL('u')
+#define CMIN 1
+#define CQUIT 034
+#define CSUSP CTRL('z')
+#define CTIME 0
+#define CDSUSP CTRL('y')
+#define CSTART CTRL('q')
+#define CSTOP CTRL('s')
+#define CLNEXT CTRL('v')
+#define CDISCARD CTRL('o')
+#define CWERASE CTRL('w')
+#define CREPRINT CTRL('r')
+#define CEOT CEOF
+#define CBRK CEOL
+#define CRPRNT CREPRINT
+#define CFLUSH CDISCARD
-/*
- * #define TTYDEFCHARS to include an array of default control characters.
- */
-#ifdef TTYDEFCHARS
-static cc_t ttydefchars[NCCS] = {
- CEOF, CEOL, CEOL, CERASE, CWERASE, CKILL, CREPRINT,
- _POSIX_VDISABLE, CINTR, CQUIT, CSUSP, CDSUSP, CSTART, CSTOP, CLNEXT,
- CDISCARD, CMIN, CTIME, CSTATUS, _POSIX_VDISABLE
-};
-#undef TTYDEFCHARS
#endif
diff --git a/system/include/libc/sys/types.h b/system/include/libc/sys/types.h
index fe5d552a..27170f64 100644
--- a/system/include/libc/sys/types.h
+++ b/system/include/libc/sys/types.h
@@ -1,485 +1,91 @@
-/* unified sys/types.h:
- start with sef's sysvi386 version.
- merge go32 version -- a few ifdefs.
- h8300hms, h8300xray, and sysvnecv70 disagree on the following types:
-
- typedef int gid_t;
- typedef int uid_t;
- typedef int dev_t;
- typedef int ino_t;
- typedef int mode_t;
- typedef int caddr_t;
-
- however, these aren't "reasonable" values, the sysvi386 ones make far
- more sense, and should work sufficiently well (in particular, h8300
- doesn't have a stat, and the necv70 doesn't matter.) -- eichin
- */
-
-#ifndef _SYS_TYPES_H
-
-#include <_ansi.h>
-
-#ifndef __INTTYPES_DEFINED__
-#define __INTTYPES_DEFINED__
-
-#include <machine/_types.h>
-
-#if defined(__rtems__) || defined(__XMK__) || defined(EMSCRIPTEN)
-/*
- * The following section is RTEMS specific and is needed to more
- * closely match the types defined in the BSD sys/types.h.
- * This is needed to let the RTEMS/BSD TCP/IP stack compile.
- */
-
-/* deprecated */
-#if ___int8_t_defined
-typedef __uint8_t u_int8_t;
-#endif
-#if ___int16_t_defined
-typedef __uint16_t u_int16_t;
-#endif
-#if ___int32_t_defined
-typedef __uint32_t u_int32_t;
-#endif
-
-#if ___int64_t_defined
-typedef __uint64_t u_int64_t;
-
-/* deprecated */
-typedef __uint64_t u_quad_t;
-typedef __int64_t quad_t;
-typedef quad_t * qaddr_t;
-#endif
-
-#endif
-
-#endif /* ! __INTTYPES_DEFINED */
-
-#ifndef __need_inttypes
-
-#define _SYS_TYPES_H
-#include <sys/_types.h>
-
-#ifdef __i386__
-#if defined (GO32) || defined (__MSDOS__)
-#define __MS_types__
-#endif
-#endif
-
-# include <stddef.h>
-# include <machine/types.h>
-
-/* To ensure the stat struct's layout doesn't change when sizeof(int), etc.
- changes, we assume sizeof short and long never change and have all types
- used to define struct stat use them and not int where possible.
- Where not possible, _ST_INTxx are used. It would be preferable to not have
- such assumptions, but until the extra fluff is necessary, it's avoided.
- No 64 bit targets use stat yet. What to do about them is postponed
- until necessary. */
-#ifdef __GNUC__
-#define _ST_INT32 __attribute__ ((__mode__ (__SI__)))
-#else
-#define _ST_INT32
-#endif
-
-# ifndef _POSIX_SOURCE
-
-# define physadr physadr_t
-# define quad quad_t
-
-#ifndef _BSDTYPES_DEFINED
-/* also defined in mingw/gmon.h and in w32api/winsock[2].h */
-typedef unsigned char u_char;
-typedef unsigned short u_short;
-typedef unsigned int u_int;
-typedef unsigned long u_long;
-#define _BSDTYPES_DEFINED
-#endif
-
-typedef unsigned short ushort; /* System V compatibility */
-typedef unsigned int uint; /* System V compatibility */
-# endif /*!_POSIX_SOURCE */
-
-#ifndef __clock_t_defined
-typedef _CLOCK_T_ clock_t;
-#define __clock_t_defined
-#endif
-
-#ifndef __time_t_defined
-typedef _TIME_T_ time_t;
-#define __time_t_defined
-
-/* Time Value Specification Structures, P1003.1b-1993, p. 261 */
-
-struct timespec {
- time_t tv_sec; /* Seconds */
- long tv_nsec; /* Nanoseconds */
-};
-
-struct itimerspec {
- struct timespec it_interval; /* Timer period */
- struct timespec it_value; /* Timer expiration */
-};
-#endif
-
-typedef long daddr_t;
-typedef char * caddr_t;
-
-#ifndef __CYGWIN__
-#if defined(__MS_types__) || defined(__rtems__) || \
- defined(__sparc__) || defined(__SPU__)
-typedef unsigned long ino_t;
-#else
-typedef unsigned long ino_t; /* XXX Emscripten */
-#endif
-#endif /*__CYGWIN__*/
-
-#if defined(__MS_types__) || defined(EMSCRIPTEN)
-typedef unsigned long vm_offset_t;
-typedef unsigned long vm_size_t;
-
-#define __BIT_TYPES_DEFINED__
-
-// XXX Emscripten: removed types which are already defined, get them from stdint
-#include <stdint.h>
-#endif /* __MS_types__ */
-
-/*
- * All these should be machine specific - right now they are all broken.
- * However, for all of Cygnus' embedded targets, we want them to all be
- * the same. Otherwise things like sizeof (struct stat) might depend on
- * how the file was compiled (e.g. -mint16 vs -mint32, etc.).
- */
-
-#ifndef __CYGWIN__ /* which defines these types in it's own types.h. */
-typedef _off_t off_t;
-typedef __dev_t dev_t;
-typedef __uid_t uid_t;
-typedef __gid_t gid_t;
-typedef __id_t id_t ; /* can hold a uid_t or pid_t */
-#endif
-
-__int32_t major(__uint32_t _x);
-__int32_t minor(__uint32_t _x);
-dev_t makedev(__uint32_t _major, __uint32_t _minor);
-
-#if defined(__XMK__)
-typedef signed char pid_t;
-#else
-typedef int pid_t;
-#endif
-
-#if defined(__rtems__)
-typedef _mode_t mode_t;
-#endif
-
-#ifndef __CYGWIN__
-typedef long key_t;
-#endif
-typedef _ssize_t ssize_t;
-
-#if !defined(__CYGWIN__) && !defined(__rtems__)
-#ifdef __MS_types__
-typedef char * addr_t;
-typedef int mode_t;
-#else
-#if defined (__sparc__) && !defined (__sparc_v9__)
-#ifdef __svr4__
-typedef unsigned long mode_t;
-#else
-typedef unsigned short mode_t;
-#endif
-#else
-typedef unsigned int mode_t _ST_INT32;
+#ifndef _SYS_TYPES_H
+#define _SYS_TYPES_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <features.h>
+
+#define __NEED_ino_t
+#define __NEED_dev_t
+#define __NEED_uid_t
+#define __NEED_gid_t
+#define __NEED_mode_t
+#define __NEED_nlink_t
+#define __NEED_off_t
+#define __NEED_pid_t
+#define __NEED_size_t
+#define __NEED_ssize_t
+#define __NEED_time_t
+#define __NEED_timer_t
+#define __NEED_clockid_t
+
+#define __NEED_int8_t
+#define __NEED_int16_t
+#define __NEED_int32_t
+#define __NEED_int64_t
+
+#define __NEED_blkcnt_t
+#define __NEED_fsblkcnt_t
+#define __NEED_fsfilcnt_t
+
+#define __NEED_id_t
+#define __NEED_key_t
+#define __NEED_clock_t
+#define __NEED_suseconds_t
+#define __NEED_blksize_t
+
+#define __NEED_pthread_t
+#define __NEED_pthread_attr_t
+#define __NEED_pthread_mutexattr_t
+#define __NEED_pthread_condattr_t
+#define __NEED_pthread_rwlockattr_t
+#define __NEED_pthread_barrierattr_t
+#define __NEED_pthread_mutex_t
+#define __NEED_pthread_cond_t
+#define __NEED_pthread_rwlock_t
+#define __NEED_pthread_barrier_t
+#define __NEED_pthread_spinlock_t
+#define __NEED_pthread_key_t
+#define __NEED_pthread_once_t
+#define __NEED_useconds_t
+#define __NEED_u_int64_t
+
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+#define __NEED_register_t
+#endif
+
+#include <bits/alltypes.h>
+
+typedef unsigned char u_int8_t;
+typedef unsigned short u_int16_t;
+typedef unsigned u_int32_t;
+
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+typedef char *caddr_t;
+typedef unsigned char u_char;
+typedef unsigned short u_short, ushort;
+typedef unsigned u_int, uint;
+typedef unsigned long u_long, ulong;
+typedef long long quad_t;
+typedef unsigned long long u_quad_t;
+#include <endian.h>
+#include <sys/select.h>
+#include <sys/sysmacros.h>
+#endif
+
+#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
+#define blksize64_t blksize_t
+#define blkcnt64_t blkcnt_t
+#define fsblkcnt64_t fsblkcnt_t
+#define fsfilcnt64_t fsfilcnt_t
+#define ino64_t ino_t
+#define off64_t off_t
+#endif
+
+#ifdef __cplusplus
+}
#endif
-#endif /* ! __MS_types__ */
-#endif /*__CYGWIN__*/
-
-typedef unsigned long nlink_t; /* XXX Emscripten */
-
-/* We don't define fd_set and friends if we are compiling POSIX
- source, or if we have included (or may include as indicated
- by __USE_W32_SOCKETS) the W32api winsock[2].h header which
- defines Windows versions of them. Note that a program which
- includes the W32api winsock[2].h header must know what it is doing;
- it must not call the cygwin32 select function.
-*/
-# if !(defined (_POSIX_SOURCE) || defined (_WINSOCK_H) || defined (__USE_W32_SOCKETS))
-# define _SYS_TYPES_FD_SET
-# define NBBY 8 /* number of bits in a byte */
-/*
- * Select uses bit masks of file descriptors in longs.
- * These macros manipulate such bit fields (the filesystem macros use chars).
- * FD_SETSIZE may be defined by the user, but the default here
- * should be >= NOFILE (param.h).
- */
-# ifndef FD_SETSIZE
-# define FD_SETSIZE 64
-# endif
-
-typedef long fd_mask;
-# define NFDBITS (sizeof (fd_mask) * NBBY) /* bits per mask */
-# ifndef howmany
-# define howmany(x,y) (((x)+((y)-1))/(y))
-# endif
-
-/* We use a macro for fd_set so that including Sockets.h afterwards
- can work. */
-typedef struct _types_fd_set {
- fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)];
-} _types_fd_set;
-
-#define fd_set _types_fd_set
-
-# define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1L << ((n) % NFDBITS)))
-# define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1L << ((n) % NFDBITS)))
-# define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1L << ((n) % NFDBITS)))
-# define FD_ZERO(p) (__extension__ (void)({ \
- size_t __i; \
- char *__tmp = (char *)p; \
- for (__i = 0; __i < sizeof (*(p)); ++__i) \
- *__tmp++ = 0; \
-}))
-
-# endif /* !(defined (_POSIX_SOURCE) || defined (_WINSOCK_H) || defined (__USE_W32_SOCKETS)) */
-
-#undef __MS_types__
-#undef _ST_INT32
-
-
-#ifndef __clockid_t_defined
-typedef _CLOCKID_T_ clockid_t;
-#define __clockid_t_defined
#endif
-#ifndef __timer_t_defined
-typedef _TIMER_T_ timer_t;
-#define __timer_t_defined
-#endif
-
-typedef unsigned long useconds_t;
-typedef long suseconds_t;
-
-#include <sys/features.h>
-
-
-/* Cygwin will probably never have full posix compliance due to little things
- * like an inability to set the stackaddress. Cygwin is also using void *
- * pointers rather than structs to ensure maximum binary compatability with
- * previous releases.
- * This means that we don't use the types defined here, but rather in
- * <cygwin/types.h>
- */
-#if defined(_POSIX_THREADS) && !defined(__CYGWIN__) || defined(EMSCRIPTEN)
-
-#include <sys/sched.h>
-
-/*
- * 2.5 Primitive System Data Types, P1003.1c/D10, p. 19.
- */
-
-#if defined(__XMK__)
-typedef unsigned int pthread_t; /* identify a thread */
-#else
-typedef __uint32_t pthread_t; /* identify a thread */
-#endif
-
-/* P1003.1c/D10, p. 118-119 */
-#define PTHREAD_SCOPE_PROCESS 0
-#define PTHREAD_SCOPE_SYSTEM 1
-
-/* P1003.1c/D10, p. 111 */
-#define PTHREAD_INHERIT_SCHED 1 /* scheduling policy and associated */
- /* attributes are inherited from */
- /* the calling thread. */
-#define PTHREAD_EXPLICIT_SCHED 2 /* set from provided attribute object */
-
-/* P1003.1c/D10, p. 141 */
-#define PTHREAD_CREATE_DETACHED 0
-#define PTHREAD_CREATE_JOINABLE 1
-
-#if defined(__XMK__) || defined(__rtems__) || defined(EMSCRIPTEN)
-/* The following defines are part of the X/Open System Interface (XSI). */
-
-/* This type of mutex does not detect deadlock. A thread attempting to relock this mutex without first unlocking
- * it shall deadlock. Attempting to unlock a mutex locked by a different thread results in undefined behavior.
- * Attempting to unlock an unlocked mutex results in undefined behavior.
- */
-#define PTHREAD_MUTEX_NORMAL 1
-
-/*
- * This type of mutex provides error checking. A thread attempting to relock this mutex without first unlocking
- * it shall return with an error. A thread attempting to unlock a mutex which another thread has locked shall return
- * with an error. A thread attempting to unlock an unlocked mutex shall return with an error.
- */
-#define PTHREAD_MUTEX_ERRORCHECK 2
-
-/* A thread attempting to relock this mutex without first unlocking it shall succeed in locking the mutex.
- * The relocking deadlock which can occur with mutexes of type PTHREAD_MUTEX_NORMAL cannot occur with this type of mutex.
- * Multiple locks of this mutex shall require the same number of unlocks to release the mutex before another thread can
- * acquire the mutex. A thread attempting to unlock a mutex which another thread has locked shall return with an error.
- * A thread attempting to unlock an unlocked mutex shall return with an error.
- */
-#define PTHREAD_MUTEX_RECURSIVE 3
-
-/* Attempting to recursively lock a mutex of this type results in undefined behavior. Attempting to unlock a
- * mutex of this type which was not locked by the calling thread results in undefined behavior. Attempting to
- * unlock a mutex of this type which is not locked results in undefined behavior. An implementation may map this
- * mutex to one of the other mutex types.
- */
-#define PTHREAD_MUTEX_DEFAULT 4
-
-#endif /* defined(__XMK__) || defined(__rtems__) */
-
-#if defined(__XMK__)
-typedef struct pthread_attr_s {
- int contentionscope;
- struct sched_param schedparam;
- int detachstate;
- void *stackaddr;
- size_t stacksize;
-} pthread_attr_t;
-
-#define PTHREAD_STACK_MIN 200
-
-#else /* !defined(__XMK__) */
-typedef struct {
- int is_initialized;
- void *stackaddr;
- int stacksize;
- int contentionscope;
- int inheritsched;
- int schedpolicy;
- struct sched_param schedparam;
-#if defined(__rtems__)
- size_t guardsize;
-#endif
-
- /* P1003.4b/D8, p. 54 adds cputime_clock_allowed attribute. */
-#if defined(_POSIX_THREAD_CPUTIME)
- int cputime_clock_allowed; /* see time.h */
-#endif
- int detachstate;
-
-} pthread_attr_t;
-
-#endif /* !defined(__XMK__) */
-
-#if defined(_POSIX_THREAD_PROCESS_SHARED) || defined(EMSCRIPTEN)
-/* NOTE: P1003.1c/D10, p. 81 defines following values for process_shared. */
-
-#define PTHREAD_PROCESS_PRIVATE 0 /* visible within only the creating process */
-#define PTHREAD_PROCESS_SHARED 1 /* visible too all processes with access to */
- /* the memory where the resource is */
- /* located */
-#endif
-
-#if defined(_POSIX_THREAD_PRIO_PROTECT)
-/* Mutexes */
-
-/* Values for blocking protocol. */
-
-#define PTHREAD_PRIO_NONE 0
-#define PTHREAD_PRIO_INHERIT 1
-#define PTHREAD_PRIO_PROTECT 2
-#endif
-
-#if defined(_UNIX98_THREAD_MUTEX_ATTRIBUTES)
-
-/* Values for mutex type */
-
-#define PTHREAD_MUTEX_NORMAL 0
-#define PTHREAD_MUTEX_RECURSIVE 1
-#define PTHREAD_MUTEX_ERRORCHECK 2
-#define PTHREAD_MUTEX_DEFAULT 3
-
-#endif
-
-#if defined(__XMK__)
-typedef unsigned int pthread_mutex_t; /* identify a mutex */
-
-typedef struct {
- int type;
-} pthread_mutexattr_t;
-
-#else /* !defined(__XMK__) */
-typedef __uint32_t pthread_mutex_t; /* identify a mutex */
-
-typedef struct {
- int is_initialized;
-#if defined(_POSIX_THREAD_PROCESS_SHARED)
- int process_shared; /* allow mutex to be shared amongst processes */
-#endif
-#if defined(_POSIX_THREAD_PRIO_PROTECT)
- int prio_ceiling;
- int protocol;
-#endif
-#if defined(_UNIX98_THREAD_MUTEX_ATTRIBUTES)
- int type;
-#endif
- int recursive;
-} pthread_mutexattr_t;
-#endif /* !defined(__XMK__) */
-
-/* Condition Variables */
-
-typedef __uint32_t pthread_cond_t; /* identify a condition variable */
-
-typedef struct {
- int is_initialized;
-#if defined(_POSIX_THREAD_PROCESS_SHARED)
- int process_shared; /* allow this to be shared amongst processes */
-#endif
-} pthread_condattr_t; /* a condition attribute object */
-
-/* Keys */
-
-typedef __uint32_t pthread_key_t; /* thread-specific data keys */
-
-typedef struct {
- int is_initialized; /* is this structure initialized? */
- int init_executed; /* has the initialization routine been run? */
-} pthread_once_t; /* dynamic package initialization */
-#else
-#if defined (__CYGWIN__)
-#include <cygwin/types.h>
-#endif
-#endif /* defined(_POSIX_THREADS) */
-
-/* POSIX Barrier Types */
-
-#if defined(_POSIX_BARRIERS)
-typedef __uint32_t pthread_barrier_t; /* POSIX Barrier Object */
-typedef struct {
- int is_initialized; /* is this structure initialized? */
-#if defined(_POSIX_THREAD_PROCESS_SHARED)
- int process_shared; /* allow this to be shared amongst processes */
-#endif
-} pthread_barrierattr_t;
-#endif /* defined(_POSIX_BARRIERS) */
-
-/* POSIX Spin Lock Types */
-
-#if defined(_POSIX_SPIN_LOCKS)
-typedef __uint32_t pthread_spinlock_t; /* POSIX Spin Lock Object */
-#endif /* defined(_POSIX_SPIN_LOCKS) */
-
-/* POSIX Reader/Writer Lock Types */
-
-#if !defined (__CYGWIN__)
-#if defined(_POSIX_READER_WRITER_LOCKS)
-typedef __uint32_t pthread_rwlock_t; /* POSIX RWLock Object */
-typedef struct {
- int is_initialized; /* is this structure initialized? */
-#if defined(_POSIX_THREAD_PROCESS_SHARED)
- int process_shared; /* allow this to be shared amongst processes */
-#endif
-} pthread_rwlockattr_t;
-#endif /* defined(_POSIX_READER_WRITER_LOCKS) */
-#endif /* __CYGWIN__ */
-
-#endif /* !__need_inttypes */
-
-#undef __need_inttypes
-#endif /* _SYS_TYPES_H */
diff --git a/system/include/libc/sys/ucontext.h b/system/include/libc/sys/ucontext.h
new file mode 100644
index 00000000..5fdbd63d
--- /dev/null
+++ b/system/include/libc/sys/ucontext.h
@@ -0,0 +1 @@
+#include <ucontext.h>
diff --git a/system/include/libc/sys/uio.h b/system/include/libc/sys/uio.h
new file mode 100644
index 00000000..00f73a2f
--- /dev/null
+++ b/system/include/libc/sys/uio.h
@@ -0,0 +1,48 @@
+#ifndef _SYS_UIO_H
+#define _SYS_UIO_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <features.h>
+
+#define __NEED_size_t
+#define __NEED_ssize_t
+#define __NEED_struct_iovec
+
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+#define __NEED_off_t
+#endif
+
+#ifdef _GNU_SOURCE
+#define __NEED_pid_t
+#endif
+
+#include <bits/alltypes.h>
+
+#define UIO_MAXIOV 1024
+
+ssize_t readv (int, const struct iovec *, int);
+ssize_t writev (int, const struct iovec *, int);
+
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+ssize_t preadv (int, const struct iovec *, int, off_t);
+ssize_t pwritev (int, const struct iovec *, int, off_t);
+#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
+#define preadv64 preadv
+#define pwritev64 pwritev
+#define off64_t off_t
+#endif
+#endif
+
+#ifdef _GNU_SOURCE
+ssize_t process_vm_writev(pid_t, const struct iovec *, unsigned long, const struct iovec *, unsigned long, unsigned long);
+ssize_t process_vm_readv(pid_t, const struct iovec *, unsigned long, const struct iovec *, unsigned long, unsigned long);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/sys/un.h b/system/include/libc/sys/un.h
new file mode 100644
index 00000000..769dac6b
--- /dev/null
+++ b/system/include/libc/sys/un.h
@@ -0,0 +1,13 @@
+#ifndef _SYS_UN_H
+#define _SYS_UN_H
+
+#define __NEED_sa_family_t
+#include <bits/alltypes.h>
+
+struct sockaddr_un
+{
+ sa_family_t sun_family;
+ char sun_path[108];
+};
+
+#endif
diff --git a/system/include/libc/sys/unistd.h b/system/include/libc/sys/unistd.h
deleted file mode 100644
index a4219d4d..00000000
--- a/system/include/libc/sys/unistd.h
+++ /dev/null
@@ -1,513 +0,0 @@
-#ifndef _SYS_UNISTD_H
-#define _SYS_UNISTD_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <_ansi.h>
-#include <sys/types.h>
-#include <sys/_types.h>
-#define __need_size_t
-#define __need_ptrdiff_t
-#include <stddef.h>
-
-extern char **environ;
-
-void _EXFUN(_exit, (int __status ) _ATTRIBUTE(noreturn));
-
-int _EXFUN(access,(const char *__path, int __amode ));
-unsigned _EXFUN(alarm, (unsigned __secs ));
-int _EXFUN(chdir, (const char *__path ));
-int _EXFUN(chmod, (const char *__path, mode_t __mode ));
-#if !defined(__INSIDE_CYGWIN__)
-int _EXFUN(chown, (const char *__path, uid_t __owner, gid_t __group ));
-#endif
-#if defined(__CYGWIN__) || defined(__rtems__)
-int _EXFUN(chroot, (const char *__path ));
-#endif
-int _EXFUN(close, (int __fildes ));
-#if 1 /* XXX Emscripten defined(__CYGWIN__) */
-size_t _EXFUN(confstr, (int __name, char *__buf, size_t __len));
-#endif
-char * _EXFUN(ctermid, (char *__s ));
-char * _EXFUN(cuserid, (char *__s ));
-#if defined(__CYGWIN__)
-int _EXFUN(daemon, (int nochdir, int noclose));
-#endif
-int _EXFUN(dup, (int __fildes ));
-int _EXFUN(dup2, (int __fildes, int __fildes2 ));
-#if defined(__CYGWIN__)
-int _EXFUN(dup3, (int __fildes, int __fildes2, int flags));
-int _EXFUN(eaccess, (const char *__path, int __mode));
-void _EXFUN(endusershell, (void));
-int _EXFUN(euidaccess, (const char *__path, int __mode));
-#endif
-int _EXFUN(execl, (const char *__path, const char *, ... ));
-int _EXFUN(execle, (const char *__path, const char *, ... ));
-int _EXFUN(execlp, (const char *__file, const char *, ... ));
-int _EXFUN(execv, (const char *__path, char * const __argv[] ));
-int _EXFUN(execve, (const char *__path, char * const __argv[], char * const __envp[] ));
-int _EXFUN(execvp, (const char *__file, char * const __argv[] ));
-#if defined(__CYGWIN__)
-int _EXFUN(execvpe, (const char *__file, char * const __argv[], char * const __envp[] ));
-int _EXFUN(faccessat, (int __dirfd, const char *__path, int __mode, int __flags));
-#endif
-#if defined(EMSCRIPTEN) || defined(__CYGWIN__) || defined(__rtems__) || defined(__SPU__)
-int _EXFUN(fchdir, (int __fildes));
-#endif
-int _EXFUN(fchmod, (int __fildes, mode_t __mode ));
-#if !defined(__INSIDE_CYGWIN__)
-int _EXFUN(fchown, (int __fildes, uid_t __owner, gid_t __group ));
-#endif
-#if defined(__CYGWIN__)
-int _EXFUN(fchownat, (int __dirfd, const char *__path, uid_t __owner, gid_t __group, int __flags));
-int _EXFUN(fexecve, (int __fd, char * const __argv[], char * const __envp[] ));
-#endif
-pid_t _EXFUN(fork, (void ));
-long _EXFUN(fpathconf, (int __fd, int __name ));
-int _EXFUN(fsync, (int __fd));
-int _EXFUN(fdatasync, (int __fd));
-char * _EXFUN(getcwd, (char *__buf, size_t __size ));
-#if defined(__CYGWIN__)
-int _EXFUN(getdomainname ,(char *__name, size_t __len));
-#endif
-#if !defined(__INSIDE_CYGWIN__)
-gid_t _EXFUN(getegid, (void ));
-uid_t _EXFUN(geteuid, (void ));
-gid_t _EXFUN(getgid, (void ));
-#endif
-int _EXFUN(getgroups, (int __gidsetsize, gid_t __grouplist[] ));
-#if defined(EMSCRIPTEN) || defined(__CYGWIN__)
-long _EXFUN(gethostid, (void));
-#endif
-char * _EXFUN(getlogin, (void ));
-#if defined(EMSCRIPTEN) || defined(_POSIX_THREAD_SAFE_FUNCTIONS)
-int _EXFUN(getlogin_r, (char *name, size_t namesize) );
-#endif
-char * _EXFUN(getpass, (const char *__prompt));
-int _EXFUN(getpagesize, (void));
-#if defined(__CYGWIN__)
-int _EXFUN(getpeereid, (int, uid_t *, gid_t *));
-#endif
-pid_t _EXFUN(getpgid, (pid_t));
-pid_t _EXFUN(getpgrp, (void ));
-pid_t _EXFUN(getpid, (void ));
-pid_t _EXFUN(getppid, (void ));
-#if defined(EMSCRIPTEN) || defined(__CYGWIN__) || defined(__rtems__)
-pid_t _EXFUN(getsid, (pid_t));
-#endif
-#if defined(EMSCRIPTEN) || !defined(__INSIDE_CYGWIN__)
-uid_t _EXFUN(getuid, (void ));
-#endif
-#if defined(EMSCRIPTEN) || defined(__CYGWIN__)
-char * _EXFUN(getusershell, (void));
-int _EXFUN(iruserok, (unsigned long raddr, int superuser, const char *ruser, const char *luser));
-#endif
-int _EXFUN(isatty, (int __fildes ));
-#if !defined(__INSIDE_CYGWIN__)
-int _EXFUN(lchown, (const char *__path, uid_t __owner, gid_t __group ));
-#endif
-int _EXFUN(link, (const char *__path1, const char *__path2 ));
-#if defined(__CYGWIN__)
-int _EXFUN(linkat, (int __dirfd1, const char *__path1, int __dirfd2, const char *__path2, int __flags ));
-#endif
-int _EXFUN(nice, (int __nice_value ));
-#if !defined(__INSIDE_CYGWIN__)
-off_t _EXFUN(lseek, (int __fildes, off_t __offset, int __whence ));
-off_t _EXFUN(lseek64, (int __fildes, off_t __offset, int __whence )); /* XXX Emscripten */
-#endif
-#if defined(EMSCRIPTEN) || defined(__SPU__) || defined(__CYGWIN__)
-#define F_ULOCK 0
-#define F_LOCK 1
-#define F_TLOCK 2
-#define F_TEST 3
-int _EXFUN(lockf, (int __fd, int __cmd, off_t __len));
-#endif
-long _EXFUN(pathconf, (const char *__path, int __name ));
-int _EXFUN(pause, (void ));
-#ifdef __CYGWIN__
-int _EXFUN(pthread_atfork, (void (*)(void), void (*)(void), void (*)(void)));
-#endif
-int _EXFUN(pipe, (int __fildes[2] ));
-#ifdef __CYGWIN__
-int _EXFUN(pipe2, (int __fildes[2], int flags));
-#endif
-ssize_t _EXFUN(pread, (int __fd, void *__buf, size_t __nbytes, off_t __offset));
-ssize_t _EXFUN(pwrite, (int __fd, const void *__buf, size_t __nbytes, off_t __offset));
-_READ_WRITE_RETURN_TYPE _EXFUN(read, (int __fd, void *__buf, size_t __nbyte ));
-#if defined(__CYGWIN__)
-int _EXFUN(rresvport, (int *__alport));
-int _EXFUN(revoke, (char *__path));
-#endif
-int _EXFUN(rmdir, (const char *__path ));
-#if defined(__CYGWIN__)
-int _EXFUN(ruserok, (const char *rhost, int superuser, const char *ruser, const char *luser));
-#endif
-void * _EXFUN(sbrk, (ptrdiff_t __incr));
-#if !defined(__INSIDE_CYGWIN__)
-#if defined(EMSCRIPTEN) || defined(__CYGWIN__) || defined(__rtems__)
-int _EXFUN(setegid, (gid_t __gid ));
-int _EXFUN(seteuid, (uid_t __uid ));
-#endif
-int _EXFUN(setgid, (gid_t __gid ));
-#endif
-#if defined(EMSCRIPTEN) || defined(__CYGWIN__)
-int _EXFUN(setgroups, (int ngroups, const gid_t *gidset));
-#endif
-int _EXFUN(setpgid, (pid_t __pid, pid_t __pgid ));
-int _EXFUN(setpgrp, (void ));
-#if defined(EMSCRIPTEN) || defined(__CYGWIN__) && !defined(__INSIDE_CYGWIN__)
-int _EXFUN(setregid, (gid_t __rgid, gid_t __egid));
-int _EXFUN(setreuid, (uid_t __ruid, uid_t __euid));
-#endif
-pid_t _EXFUN(setsid, (void ));
-#if !defined(__INSIDE_CYGWIN__)
-int _EXFUN(setuid, (uid_t __uid ));
-#endif
-#if defined(__CYGWIN__)
-void _EXFUN(setusershell, (void));
-#endif
-unsigned _EXFUN(sleep, (unsigned int __seconds ));
-void _EXFUN(swab, (const void *, void *, ssize_t));
-long _EXFUN(sysconf, (int __name ));
-pid_t _EXFUN(tcgetpgrp, (int __fildes ));
-int _EXFUN(tcsetpgrp, (int __fildes, pid_t __pgrp_id ));
-char * _EXFUN(ttyname, (int __fildes ));
-#if defined(EMSCRIPTEN) || defined(__CYGWIN__) || defined(__rtems__)
-int _EXFUN(ttyname_r, (int, char *, size_t));
-#endif
-int _EXFUN(unlink, (const char *__path ));
-int _EXFUN(usleep, (useconds_t __useconds));
-int _EXFUN(vhangup, (void ));
-_READ_WRITE_RETURN_TYPE _EXFUN(write, (int __fd, const void *__buf, size_t __nbyte ));
-
-#ifdef __CYGWIN__
-# define __UNISTD_GETOPT__
-# include <getopt.h>
-# undef __UNISTD_GETOPT__
-#else
-extern char *optarg; /* getopt(3) external variables */
-extern int optind, opterr, optopt;
-int getopt(int, char * const [], const char *);
-extern int optreset; /* getopt(3) external variable */
-#endif
-
-#ifndef _POSIX_SOURCE
-pid_t _EXFUN(vfork, (void ));
-#endif /* _POSIX_SOURCE */
-
-#ifdef _COMPILING_NEWLIB
-/* Provide prototypes for most of the _<systemcall> names that are
- provided in newlib for some compilers. */
-int _EXFUN(_close, (int __fildes ));
-pid_t _EXFUN(_fork, (void ));
-pid_t _EXFUN(_getpid, (void ));
-int _EXFUN(_isatty, (int __fildes ));
-int _EXFUN(_link, (const char *__path1, const char *__path2 ));
-_off_t _EXFUN(_lseek, (int __fildes, _off_t __offset, int __whence ));
-#ifdef __LARGE64_FILES
-_off64_t _EXFUN(_lseek64, (int __filedes, _off64_t __offset, int __whence ));
-#endif
-_READ_WRITE_RETURN_TYPE _EXFUN(_read, (int __fd, void *__buf, size_t __nbyte ));
-void * _EXFUN(_sbrk, (ptrdiff_t __incr));
-int _EXFUN(_unlink, (const char *__path ));
-_READ_WRITE_RETURN_TYPE _EXFUN(_write, (int __fd, const void *__buf, size_t __nbyte ));
-int _EXFUN(_execve, (const char *__path, char * const __argv[], char * const __envp[] ));
-#endif
-
-#if defined(__CYGWIN__) || defined(__rtems__) || defined(__sh__) || defined(__SPU__) || defined(EMSCRIPTEN)
-#if !defined(__INSIDE_CYGWIN__)
-int _EXFUN(ftruncate, (int __fd, off_t __length));
-int _EXFUN(truncate, (const char *, off_t __length));
-#endif
-#endif
-
-#if defined(EMSCRIPTEN) || defined(__CYGWIN__) || defined(__rtems__)
-int _EXFUN(getdtablesize, (void));
-int _EXFUN(setdtablesize, (int));
-useconds_t _EXFUN(ualarm, (useconds_t __useconds, useconds_t __interval));
-#if !(defined (_WINSOCK_H) || defined (__USE_W32_SOCKETS))
-/* winsock[2].h defines as __stdcall, and with int as 2nd arg */
- int _EXFUN(gethostname, (char *__name, size_t __len));
-#endif
-char * _EXFUN(mktemp, (char *));
-#endif
-
-#if defined(EMSCRIPTEN) || defined(__CYGWIN__) || defined(__SPU__) || defined(__rtems__)
-void _EXFUN(sync, (void));
-#endif
-
-ssize_t _EXFUN(readlink, (const char *__path, char *__buf, size_t __buflen));
-#if defined(__CYGWIN__)
-ssize_t _EXFUN(readlinkat, (int __dirfd1, const char *__path, char *__buf, size_t __buflen));
-#endif
-int _EXFUN(symlink, (const char *__name1, const char *__name2));
-#if defined(__CYGWIN__)
-int _EXFUN(symlinkat, (const char *, int, const char *));
-int _EXFUN(unlinkat, (int, const char *, int));
-#endif
-
-#define F_OK 0
-#define R_OK 4
-#define W_OK 2
-#define X_OK 1
-
-# define SEEK_SET 0
-# define SEEK_CUR 1
-# define SEEK_END 2
-
-#include <sys/features.h>
-
-/* XXX Emscripten: start these at 1, we can use pointers as equals to file descriptors */
-#define STDIN_FILENO 1 /* standard input file descriptor */
-#define STDOUT_FILENO 2 /* standard output file descriptor */
-#define STDERR_FILENO 3 /* standard error file descriptor */
-
-/*
- * sysconf values per IEEE Std 1003.1, 2008 Edition
- */
-
-#define _SC_ARG_MAX 0
-#define _SC_CHILD_MAX 1
-#define _SC_CLK_TCK 2
-#define _SC_NGROUPS_MAX 3
-#define _SC_OPEN_MAX 4
-#define _SC_JOB_CONTROL 5
-#define _SC_SAVED_IDS 6
-#define _SC_VERSION 7
-#define _SC_PAGESIZE 8
-#define _SC_PAGE_SIZE _SC_PAGESIZE
-/* These are non-POSIX values we accidentally introduced in 2000 without
- guarding them. Keeping them unguarded for backward compatibility. */
-#define _SC_NPROCESSORS_CONF 9
-#define _SC_NPROCESSORS_ONLN 10
-#define _SC_PHYS_PAGES 11
-#define _SC_AVPHYS_PAGES 12
-/* End of non-POSIX values. */
-#define _SC_MQ_OPEN_MAX 13
-#define _SC_MQ_PRIO_MAX 14
-#define _SC_RTSIG_MAX 15
-#define _SC_SEM_NSEMS_MAX 16
-#define _SC_SEM_VALUE_MAX 17
-#define _SC_SIGQUEUE_MAX 18
-#define _SC_TIMER_MAX 19
-#define _SC_TZNAME_MAX 20
-#define _SC_ASYNCHRONOUS_IO 21
-#define _SC_FSYNC 22
-#define _SC_MAPPED_FILES 23
-#define _SC_MEMLOCK 24
-#define _SC_MEMLOCK_RANGE 25
-#define _SC_MEMORY_PROTECTION 26
-#define _SC_MESSAGE_PASSING 27
-#define _SC_PRIORITIZED_IO 28
-#define _SC_REALTIME_SIGNALS 29
-#define _SC_SEMAPHORES 30
-#define _SC_SHARED_MEMORY_OBJECTS 199 /* XXX Emscripten changed 31 to 199 */
-#define _SC_SYNCHRONIZED_IO 32
-#define _SC_TIMERS 33
-#define _SC_AIO_LISTIO_MAX 34
-#define _SC_AIO_MAX 35
-#define _SC_AIO_PRIO_DELTA_MAX 36
-#define _SC_DELAYTIMER_MAX 37
-#define _SC_THREAD_KEYS_MAX 38
-#define _SC_THREAD_STACK_MIN 39
-#define _SC_THREAD_THREADS_MAX 40
-#define _SC_TTY_NAME_MAX 41
-#define _SC_THREADS 42
-#define _SC_THREAD_ATTR_STACKADDR 43
-#define _SC_THREAD_ATTR_STACKSIZE 44
-#define _SC_THREAD_PRIORITY_SCHEDULING 45
-#define _SC_THREAD_PRIO_INHERIT 46
-/* _SC_THREAD_PRIO_PROTECT was _SC_THREAD_PRIO_CEILING in early drafts */
-#define _SC_THREAD_PRIO_PROTECT 47
-#define _SC_THREAD_PRIO_CEILING _SC_THREAD_PRIO_PROTECT
-#define _SC_THREAD_PROCESS_SHARED 48
-#define _SC_THREAD_SAFE_FUNCTIONS 49
-#define _SC_GETGR_R_SIZE_MAX 50
-#define _SC_GETPW_R_SIZE_MAX 51
-#define _SC_LOGIN_NAME_MAX 52
-#define _SC_THREAD_DESTRUCTOR_ITERATIONS 53
-#define _SC_ADVISORY_INFO 54
-#define _SC_ATEXIT_MAX 55
-#define _SC_BARRIERS 56
-#define _SC_BC_BASE_MAX 57
-#define _SC_BC_DIM_MAX 58
-#define _SC_BC_SCALE_MAX 59
-#define _SC_BC_STRING_MAX 60
-#define _SC_CLOCK_SELECTION 61
-#define _SC_COLL_WEIGHTS_MAX 62
-#define _SC_CPUTIME 63
-#define _SC_EXPR_NEST_MAX 64
-#define _SC_HOST_NAME_MAX 65
-#define _SC_IOV_MAX 66
-#define _SC_IPV6 67
-#define _SC_LINE_MAX 68
-#define _SC_MONOTONIC_CLOCK 69
-#define _SC_RAW_SOCKETS 70
-#define _SC_READER_WRITER_LOCKS 71
-#define _SC_REGEXP 72
-#define _SC_RE_DUP_MAX 73
-#define _SC_SHELL 74
-#define _SC_SPAWN 75
-#define _SC_SPIN_LOCKS 76
-#define _SC_SPORADIC_SERVER 77
-#define _SC_SS_REPL_MAX 78
-#define _SC_SYMLOOP_MAX 79
-#define _SC_THREAD_CPUTIME 80
-#define _SC_THREAD_SPORADIC_SERVER 81
-#define _SC_TIMEOUTS 82
-#define _SC_TRACE 83
-#define _SC_TRACE_EVENT_FILTER 84
-#define _SC_TRACE_EVENT_NAME_MAX 85
-#define _SC_TRACE_INHERIT 86
-#define _SC_TRACE_LOG 87
-#define _SC_TRACE_NAME_MAX 88
-#define _SC_TRACE_SYS_MAX 89
-#define _SC_TRACE_USER_EVENT_MAX 90
-#define _SC_TYPED_MEMORY_OBJECTS 91
-#define _SC_V7_ILP32_OFF32 92
-#define _SC_V6_ILP32_OFF32 _SC_V7_ILP32_OFF32
-#define _SC_XBS5_ILP32_OFF32 _SC_V7_ILP32_OFF32
-#define _SC_V7_ILP32_OFFBIG 93
-#define _SC_V6_ILP32_OFFBIG _SC_V7_ILP32_OFFBIG
-#define _SC_XBS5_ILP32_OFFBIG _SC_V7_ILP32_OFFBIG
-#define _SC_V7_LP64_OFF64 94
-#define _SC_V6_LP64_OFF64 _SC_V7_LP64_OFF64
-#define _SC_XBS5_LP64_OFF64 _SC_V7_LP64_OFF64
-#define _SC_V7_LPBIG_OFFBIG 95
-#define _SC_V6_LPBIG_OFFBIG _SC_V7_LPBIG_OFFBIG
-#define _SC_XBS5_LPBIG_OFFBIG _SC_V7_LPBIG_OFFBIG
-#define _SC_XOPEN_CRYPT 96
-#define _SC_XOPEN_ENH_I18N 97
-#define _SC_XOPEN_LEGACY 98
-#define _SC_XOPEN_REALTIME 99
-#define _SC_STREAM_MAX 100
-#define _SC_PRIORITY_SCHEDULING 101
-#define _SC_XOPEN_REALTIME_THREADS 102
-#define _SC_XOPEN_SHM 103
-#define _SC_XOPEN_STREAMS 104
-#define _SC_XOPEN_UNIX 105
-#define _SC_XOPEN_VERSION 106
-#define _SC_2_CHAR_TERM 107
-#define _SC_2_C_BIND 108
-#define _SC_2_C_DEV 109
-#define _SC_2_FORT_DEV 110
-#define _SC_2_FORT_RUN 111
-#define _SC_2_LOCALEDEF 112
-#define _SC_2_PBS 113
-#define _SC_2_PBS_ACCOUNTING 114
-#define _SC_2_PBS_CHECKPOINT 115
-#define _SC_2_PBS_LOCATE 116
-#define _SC_2_PBS_MESSAGE 117
-#define _SC_2_PBS_TRACK 118
-#define _SC_2_SW_DEV 119
-#define _SC_2_UPE 120
-#define _SC_2_VERSION 121
-#define _SC_THREAD_ROBUST_PRIO_INHERIT 122
-#define _SC_THREAD_ROBUST_PRIO_PROTECT 123
-#define _SC_XOPEN_UUCP 124
-
-/*
- * pathconf values per IEEE Std 1003.1, 2008 Edition
- */
-
-#define _PC_LINK_MAX 0
-#define _PC_MAX_CANON 1
-#define _PC_MAX_INPUT 2
-#define _PC_NAME_MAX 3
-#define _PC_PATH_MAX 4
-#define _PC_PIPE_BUF 5
-#define _PC_CHOWN_RESTRICTED 6
-#define _PC_NO_TRUNC 7
-#define _PC_VDISABLE 8
-#define _PC_ASYNC_IO 9
-#define _PC_PRIO_IO 10
-#define _PC_SYNC_IO 11
-#define _PC_FILESIZEBITS 12
-#define _PC_2_SYMLINKS 13
-#define _PC_SYMLINK_MAX 14
-#define _PC_ALLOC_SIZE_MIN 15
-#define _PC_REC_INCR_XFER_SIZE 16
-#define _PC_REC_MAX_XFER_SIZE 17
-#define _PC_REC_MIN_XFER_SIZE 18
-#define _PC_REC_XFER_ALIGN 19
-#define _PC_TIMESTAMP_RESOLUTION 20
-#ifdef __CYGWIN__
-/* Ask for POSIX permission bits support. */
-#define _PC_POSIX_PERMISSIONS 90
-/* Ask for full POSIX permission support including uid/gid settings. */
-#define _PC_POSIX_SECURITY 91
-#endif
-/* XXX Emscripten */
-#define _PC_SOCK_MAXBUF 100
-
-/*
- * confstr values per IEEE Std 1003.1, 2004 Edition
- */
-
-#if 1 /* XXX Emscripten: Enable these def __CYGWIN__ / * Only defined on Cygwin for now. */
-#define _CS_PATH 0
-#define _CS_POSIX_V7_ILP32_OFF32_CFLAGS 1
-#define _CS_POSIX_V6_ILP32_OFF32_CFLAGS _CS_POSIX_V7_ILP32_OFF32_CFLAGS
-#define _CS_XBS5_ILP32_OFF32_CFLAGS _CS_POSIX_V7_ILP32_OFF32_CFLAGS
-#define _CS_POSIX_V7_ILP32_OFF32_LDFLAGS 2
-#define _CS_POSIX_V6_ILP32_OFF32_LDFLAGS _CS_POSIX_V7_ILP32_OFF32_LDFLAGS
-#define _CS_XBS5_ILP32_OFF32_LDFLAGS _CS_POSIX_V7_ILP32_OFF32_LDFLAGS
-#define _CS_POSIX_V7_ILP32_OFF32_LIBS 3
-#define _CS_POSIX_V6_ILP32_OFF32_LIBS _CS_POSIX_V7_ILP32_OFF32_LIBS
-#define _CS_XBS5_ILP32_OFF32_LIBS _CS_POSIX_V7_ILP32_OFF32_LIBS
-#define _CS_XBS5_ILP32_OFF32_LINTFLAGS 4
-#define _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS 5
-#define _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS
-#define _CS_XBS5_ILP32_OFFBIG_CFLAGS _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS
-#define _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS 6
-#define _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS
-#define _CS_XBS5_ILP32_OFFBIG_LDFLAGS _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS
-#define _CS_POSIX_V7_ILP32_OFFBIG_LIBS 7
-#define _CS_POSIX_V6_ILP32_OFFBIG_LIBS _CS_POSIX_V7_ILP32_OFFBIG_LIBS
-#define _CS_XBS5_ILP32_OFFBIG_LIBS _CS_POSIX_V7_ILP32_OFFBIG_LIBS
-#define _CS_XBS5_ILP32_OFFBIG_LINTFLAGS 8
-#define _CS_POSIX_V7_LP64_OFF64_CFLAGS 9
-#define _CS_POSIX_V6_LP64_OFF64_CFLAGS _CS_POSIX_V7_LP64_OFF64_CFLAGS
-#define _CS_XBS5_LP64_OFF64_CFLAGS _CS_POSIX_V7_LP64_OFF64_CFLAGS
-#define _CS_POSIX_V7_LP64_OFF64_LDFLAGS 10
-#define _CS_POSIX_V6_LP64_OFF64_LDFLAGS _CS_POSIX_V7_LP64_OFF64_LDFLAGS
-#define _CS_XBS5_LP64_OFF64_LDFLAGS _CS_POSIX_V7_LP64_OFF64_LDFLAGS
-#define _CS_POSIX_V7_LP64_OFF64_LIBS 11
-#define _CS_POSIX_V6_LP64_OFF64_LIBS _CS_POSIX_V7_LP64_OFF64_LIBS
-#define _CS_XBS5_LP64_OFF64_LIBS _CS_POSIX_V7_LP64_OFF64_LIBS
-#define _CS_XBS5_LP64_OFF64_LINTFLAGS 12
-#define _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS 13
-#define _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS
-#define _CS_XBS5_LPBIG_OFFBIG_CFLAGS _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS
-#define _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS 14
-#define _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS
-#define _CS_XBS5_LPBIG_OFFBIG_LDFLAGS _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS
-#define _CS_POSIX_V7_LPBIG_OFFBIG_LIBS 15
-#define _CS_POSIX_V6_LPBIG_OFFBIG_LIBS _CS_POSIX_V7_LPBIG_OFFBIG_LIBS
-#define _CS_XBS5_LPBIG_OFFBIG_LIBS _CS_POSIX_V7_LPBIG_OFFBIG_LIBS
-#define _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS 16
-#define _CS_POSIX_V7_WIDTH_RESTRICTED_ENVS 17
-#define _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS _CS_POSIX_V7_WIDTH_RESTRICTED_ENVS
-#define _CS_POSIX_V7_THREADS_CFLAGS 18
-#define _CS_POSIX_V7_THREADS_LDFLAGS 19
-#define _CS_V7_ENV 20
-
-/* XXX Emscripten: remove self-ref, and add two additional ones */
-/* #define _CS_V6_ENV _CS_V6_ENV */
-#define _CS_GNU_LIBC_VERSION 42
-#define _CS_GNU_LIBPTHREAD_VERSION 43
-char *crypt(const char *key, const char *salt);
-void encrypt(char block[64], int edflag);
-
-#endif
-
-#ifndef __CYGWIN__
-# define MAXPATHLEN 1024
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-#endif /* _SYS_UNISTD_H */
diff --git a/system/include/libc/sys/user.h b/system/include/libc/sys/user.h
new file mode 100644
index 00000000..96a03400
--- /dev/null
+++ b/system/include/libc/sys/user.h
@@ -0,0 +1,16 @@
+#ifndef _SYS_USER_H
+#define _SYS_USER_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <limits.h>
+#include <stdint.h>
+#include <unistd.h>
+
+#include <bits/user.h>
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/system/include/libc/sys/utime.h b/system/include/libc/sys/utime.h
deleted file mode 100644
index 07fa6c2a..00000000
--- a/system/include/libc/sys/utime.h
+++ /dev/null
@@ -1,26 +0,0 @@
-#ifndef _SYS_UTIME_H
-#define _SYS_UTIME_H
-
-/* This is a dummy <sys/utime.h> file, not customized for any
- particular system. If there is a utime.h in libc/sys/SYSDIR/sys,
- it will override this one. */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <time.h> /* XXX Emscripten */
-
-struct utimbuf
-{
- time_t actime;
- time_t modtime;
-};
-
-int utime(const char *path, const struct utimbuf *times); /* XXX Emscripten */
-
-#ifdef __cplusplus
-};
-#endif
-
-#endif /* _SYS_UTIME_H */
diff --git a/system/include/libc/sys/utsname.h b/system/include/libc/sys/utsname.h
new file mode 100644
index 00000000..6b9ea970
--- /dev/null
+++ b/system/include/libc/sys/utsname.h
@@ -0,0 +1,30 @@
+#ifndef _SYS_UTSNAME_H
+#define _SYS_UTSNAME_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <features.h>
+
+struct utsname
+{
+ char sysname[65];
+ char nodename[65];
+ char release[65];
+ char version[65];
+ char machine[65];
+#ifdef _GNU_SOURCE
+ char domainname[65];
+#else
+ char __domainname[65];
+#endif
+};
+
+int uname (struct utsname *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/sys/vfs.h b/system/include/libc/sys/vfs.h
new file mode 100644
index 00000000..a899db27
--- /dev/null
+++ b/system/include/libc/sys/vfs.h
@@ -0,0 +1 @@
+#include <sys/statfs.h>
diff --git a/system/include/libc/sys/wait.h b/system/include/libc/sys/wait.h
index 0e4a3394..b6dfe01d 100644
--- a/system/include/libc/sys/wait.h
+++ b/system/include/libc/sys/wait.h
@@ -1,40 +1,55 @@
-#ifndef _SYS_WAIT_H
-#define _SYS_WAIT_H
-
+#ifndef _SYS_WAIT_H
+#define _SYS_WAIT_H
#ifdef __cplusplus
extern "C" {
#endif
-#include <sys/types.h>
+#include <features.h>
-#define WNOHANG 1
-#define WUNTRACED 2
+#include <signal.h>
-/* A status looks like:
- <2 bytes info> <2 bytes code>
+#define __NEED_pid_t
+#define __NEED_id_t
+#include <bits/alltypes.h>
- <code> == 0, child has exited, info is the exit value
- <code> == 1..7e, child has exited, info is the signal number.
- <code> == 7f, child has stopped, info was the signal number.
- <code> == 80, there was a core dump.
-*/
-
-#define WIFEXITED(w) (((w) & 0xff) == 0)
-#define WIFSIGNALED(w) (((w) & 0x7f) > 0 && (((w) & 0x7f) < 0x7f))
-#define WIFSTOPPED(w) (((w) & 0xff) == 0x7f)
-#define WEXITSTATUS(w) (((w) >> 8) & 0xff)
-#define WTERMSIG(w) ((w) & 0x7f)
-#define WSTOPSIG WEXITSTATUS
+typedef enum {
+ P_ALL = 0,
+ P_PID = 1,
+ P_PGID = 2
+} idtype_t;
pid_t wait (int *);
-pid_t waitpid (pid_t, int *, int);
+int waitid (idtype_t, id_t, siginfo_t *, int);
+pid_t waitpid (pid_t, int *, int );
+
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+#include <sys/resource.h>
+pid_t wait3 (int *, int, struct rusage *);
+pid_t wait4 (pid_t, int *, int, struct rusage *);
+#endif
+
+#define WNOHANG 1
+#define WUNTRACED 2
-/* Provide prototypes for most of the _<systemcall> names that are
- provided in newlib for some compilers. */
-pid_t _wait (int *);
+#define WSTOPPED 2
+#define WEXITED 4
+#define WCONTINUED 8
+#define WNOWAIT 0x1000000
+
+#define __WNOTHREAD 0x20000000
+#define __WALL 0x40000000
+#define __WCLONE 0x80000000
+
+#define WEXITSTATUS(s) (((s) & 0xff00) >> 8)
+#define WTERMSIG(s) ((s) & 0x7f)
+#define WSTOPSIG(s) WEXITSTATUS(s)
+#define WCOREDUMP(s) ((s) & 0x80)
+#define WIFEXITED(s) (!WTERMSIG(s))
+#define WIFSTOPPED(s) (((s) & 0xff) == 0x7f)
+#define WIFSIGNALED(s) (((signed char) (((s) & 0x7f) + 1) >> 1) > 0)
+#define WIFCONTINUED(s) ((s) == 0xffff)
#ifdef __cplusplus
-};
+}
#endif
-
#endif
diff --git a/system/include/libc/sys/xattr.h b/system/include/libc/sys/xattr.h
new file mode 100644
index 00000000..f926493c
--- /dev/null
+++ b/system/include/libc/sys/xattr.h
@@ -0,0 +1,30 @@
+#ifndef _SYS_XATTR_H
+#define _SYS_XATTR_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define __NEED_ssize_t
+#define __NEED_size_t
+#include <bits/alltypes.h>
+
+#define XATTR_CREATE 1
+#define XATTR_REPLACE 2
+
+ssize_t getxattr(const char *, const char *, void *, size_t);
+ssize_t lgetxattr(const char *, const char *, void *, size_t);
+ssize_t fgetxattr(int filedes, const char *, void *, size_t);
+ssize_t listxattr(const char *, char *, size_t);
+ssize_t llistxattr(const char *, char *, size_t);
+ssize_t flistxattr(int filedes, char *, size_t);
+int setxattr(const char *, const char *, const void *, size_t, int);
+int lsetxattr(const char *, const char *, const void *, size_t, int);
+int fsetxattr(int, const char *, const void *, size_t, int);
+int removexattr(const char *, const char *);
+int lremovexattr(const char *, const char *);
+int fremovexattr(int, const char *);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/system/include/libc/syscall.h b/system/include/libc/syscall.h
new file mode 100644
index 00000000..4c305784
--- /dev/null
+++ b/system/include/libc/syscall.h
@@ -0,0 +1 @@
+#include <sys/syscall.h>
diff --git a/system/include/libc/sysexits.h b/system/include/libc/sysexits.h
new file mode 100644
index 00000000..16eeb419
--- /dev/null
+++ b/system/include/libc/sysexits.h
@@ -0,0 +1,21 @@
+#ifndef _SYSEXITS_H
+#define _SYSEXITS_H
+#define EX_OK 0
+#define EX__BASE 64
+#define EX_USAGE 64
+#define EX_DATAERR 65
+#define EX_NOINPUT 66
+#define EX_NOUSER 67
+#define EX_NOHOST 68
+#define EX_UNAVAILABLE 69
+#define EX_SOFTWARE 70
+#define EX_OSERR 71
+#define EX_OSFILE 72
+#define EX_CANTCREAT 73
+#define EX_IOERR 74
+#define EX_TEMPFAIL 75
+#define EX_PROTOCOL 76
+#define EX_NOPERM 77
+#define EX_CONFIG 78
+#define EX__MAX 78
+#endif
diff --git a/system/include/libc/syslog.h b/system/include/libc/syslog.h
new file mode 100644
index 00000000..a9468d4d
--- /dev/null
+++ b/system/include/libc/syslog.h
@@ -0,0 +1,104 @@
+#ifndef _SYSLOG_H
+#define _SYSLOG_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <features.h>
+
+#define LOG_EMERG 0
+#define LOG_ALERT 1
+#define LOG_CRIT 2
+#define LOG_ERR 3
+#define LOG_WARNING 4
+#define LOG_NOTICE 5
+#define LOG_INFO 6
+#define LOG_DEBUG 7
+
+#define LOG_PRIMASK 7
+#define LOG_PRI(p) ((p)&LOG_PRIMASK)
+#define LOG_MAKEPRI(f, p) (((f)<<3)|(p))
+
+#define LOG_MASK(p) (1<<(p))
+#define LOG_UPTO(p) ((1<<(p)+1)-1)
+
+#define LOG_KERN (0<<3)
+#define LOG_USER (1<<3)
+#define LOG_MAIL (2<<3)
+#define LOG_DAEMON (3<<3)
+#define LOG_AUTH (4<<3)
+#define LOG_SYSLOG (5<<3)
+#define LOG_LPR (6<<3)
+#define LOG_NEWS (7<<3)
+#define LOG_UUCP (8<<3)
+#define LOG_CRON (9<<3)
+#define LOG_AUTHPRIV (10<<3)
+#define LOG_FTP (11<<3)
+
+#define LOG_LOCAL0 (16<<3)
+#define LOG_LOCAL1 (17<<3)
+#define LOG_LOCAL2 (18<<3)
+#define LOG_LOCAL3 (19<<3)
+#define LOG_LOCAL4 (20<<3)
+#define LOG_LOCAL5 (21<<3)
+#define LOG_LOCAL6 (22<<3)
+#define LOG_LOCAL7 (23<<3)
+
+#define LOG_NFACILITIES 24
+#define LOG_FACMASK 0x3f8
+#define LOG_FAC(p) (((p)&LOG_FACMASK)>>3)
+
+#define LOG_PID 0x01
+#define LOG_CONS 0x02
+#define LOG_ODELAY 0x04
+#define LOG_NDELAY 0x08
+#define LOG_NOWAIT 0x10
+#define LOG_PERROR 0x20
+
+void closelog (void);
+void openlog (const char *, int, int);
+int setlogmask (int);
+void syslog (int, const char *, ...);
+
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+#define _PATH_LOG "/dev/log"
+#define __NEED_va_list
+#include <bits/alltypes.h>
+void vsyslog (int, const char *, va_list);
+#if defined(SYSLOG_NAMES)
+#define INTERNAL_NOPRI 0x10
+#define INTERNAL_MARK (LOG_NFACILITIES<<3)
+struct __CODE {
+ const char *c_name;
+ int c_val;
+};
+typedef struct {
+ char *c_name;
+ int c_val;
+} CODE;
+#define prioritynames ((CODE *)(const struct __CODE []){ \
+ { "alert", LOG_ALERT }, { "crit", LOG_CRIT }, { "debug", LOG_DEBUG }, \
+ { "emerg", LOG_EMERG }, { "err", LOG_ERR }, { "error", LOG_ERR }, \
+ { "info", LOG_INFO }, { "none", INTERNAL_NOPRI }, \
+ { "notice", LOG_NOTICE }, { "panic", LOG_EMERG }, \
+ { "warn", LOG_WARNING }, { "warning", LOG_WARNING }, { NULL, -1 } })
+#define facilitynames ((CODE *)(const struct __CODE []){ \
+ { "auth", LOG_AUTH }, { "authpriv", LOG_AUTHPRIV }, \
+ { "cron", LOG_CRON }, { "daemon", LOG_DAEMON }, { "ftp", LOG_FTP }, \
+ { "kern", LOG_KERN }, { "lpr", LOG_LPR }, { "mail", LOG_MAIL }, \
+ { "mark", INTERNAL_MARK }, { "news", LOG_NEWS }, \
+ { "security", LOG_AUTH }, { "syslog", LOG_SYSLOG }, \
+ { "user", LOG_USER }, { "uucp", LOG_UUCP }, \
+ { "local0", LOG_LOCAL0 }, { "local1", LOG_LOCAL1 }, \
+ { "local2", LOG_LOCAL2 }, { "local3", LOG_LOCAL3 }, \
+ { "local4", LOG_LOCAL4 }, { "local5", LOG_LOCAL5 }, \
+ { "local6", LOG_LOCAL6 }, { "local7", LOG_LOCAL7 }, { NULL, -1 } })
+#endif
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/tar.h b/system/include/libc/tar.h
index 07b06dd7..be589842 100644
--- a/system/include/libc/tar.h
+++ b/system/include/libc/tar.h
@@ -1,39 +1,33 @@
-/*
- * tar.h
- */
+#ifndef _TAR_H
+#define _TAR_H
-#ifndef _TAR_H
-#define _TAR_H
+#define TSUID 04000
+#define TSGID 02000
+#define TSVTX 01000
+#define TUREAD 00400
+#define TUWRITE 00200
+#define TUEXEC 00100
+#define TGREAD 00040
+#define TGWRITE 00020
+#define TGEXEC 00010
+#define TOREAD 00004
+#define TOWRITE 00002
+#define TOEXEC 00001
-/* General definitions */
-#define TMAGIC "ustar" /* ustar plus null byte. */
-#define TMAGLEN 6 /* Length of the above. */
-#define TVERSION "00" /* 00 without a null byte. */
-#define TVERSLEN 2 /* Length of the above. */
+#define REGTYPE '0'
+#define AREGTYPE '\0'
+#define LNKTYPE '1'
+#define SYMTYPE '2'
+#define CHRTYPE '3'
+#define BLKTYPE '4'
+#define DIRTYPE '5'
+#define FIFOTYPE '6'
+#define CONTTYPE '7'
-/* Typeflag field definitions */
-#define REGTYPE '0' /* Regular file. */
-#define AREGTYPE '\0' /* Regular file. */
-#define LNKTYPE '1' /* Link. */
-#define SYMTYPE '2' /* Symbolic link. */
-#define CHRTYPE '3' /* Character special. */
-#define BLKTYPE '4' /* Block special. */
-#define DIRTYPE '5' /* Directory. */
-#define FIFOTYPE '6' /* FIFO special. */
-#define CONTTYPE '7' /* Reserved. */
+#define TMAGIC "ustar"
+#define TMAGLEN 6
-/* Mode field bit definitions (octal) */
-#define TSUID 04000 /* Set UID on execution. */
-#define TSGID 02000 /* Set GID on execution. */
-#define TSVTX 01000 /* On directories, restricted deletion flag. */
-#define TUREAD 00400 /* Read by owner. */
-#define TUWRITE 00200 /* Write by owner. */
-#define TUEXEC 00100 /* Execute/search by owner. */
-#define TGREAD 00040 /* Read by group. */
-#define TGWRITE 00020 /* Write by group. */
-#define TGEXEC 00010 /* Execute/search by group. */
-#define TOREAD 00004 /* Read by other. */
-#define TOWRITE 00002 /* Write by other. */
-#define TOEXEC 00001 /* Execute/search by other. */
+#define TVERSION "00"
+#define TVERSLEN 2
#endif
diff --git a/system/include/libc/termios.h b/system/include/libc/termios.h
index ee1820ce..d73c780d 100644
--- a/system/include/libc/termios.h
+++ b/system/include/libc/termios.h
@@ -1,7 +1,46 @@
+#ifndef _TERMIOS_H
+#define _TERMIOS_H
+
#ifdef __cplusplus
extern "C" {
#endif
-#include <sys/termios.h>
+
+#include <features.h>
+
+#define __NEED_pid_t
+
+#include <bits/alltypes.h>
+
+typedef unsigned char cc_t;
+typedef unsigned int speed_t;
+typedef unsigned int tcflag_t;
+
+#define NCCS 32
+
+#include <bits/termios.h>
+
+speed_t cfgetospeed (const struct termios *);
+speed_t cfgetispeed (const struct termios *);
+int cfsetospeed (struct termios *, speed_t);
+int cfsetispeed (struct termios *, speed_t);
+
+int tcgetattr (int, struct termios *);
+int tcsetattr (int, int, const struct termios *);
+
+int tcsendbreak (int, int);
+int tcdrain (int);
+int tcflush (int, int);
+int tcflow (int, int);
+
+pid_t tcgetsid (int);
+
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+void cfmakeraw(struct termios *);
+int cfsetspeed(struct termios *, speed_t);
+#endif
+
#ifdef __cplusplus
}
#endif
+
+#endif
diff --git a/system/include/libc/tgmath.h b/system/include/libc/tgmath.h
new file mode 100644
index 00000000..e41ccac9
--- /dev/null
+++ b/system/include/libc/tgmath.h
@@ -0,0 +1,270 @@
+#ifndef _TGMATH_H
+#define _TGMATH_H
+
+/*
+the return types are only correct with gcc (__GNUC__)
+otherwise they are long double or long double complex
+
+the long double version of a function is never chosen when
+sizeof(double) == sizeof(long double)
+(but the return type is set correctly with gcc)
+*/
+
+#include <math.h>
+#include <complex.h>
+
+#define __IS_FP(x) (sizeof((x)+1ULL) == sizeof((x)+1.0f))
+#define __IS_CX(x) (__IS_FP(x) && sizeof(x) == sizeof((x)+I))
+#define __IS_REAL(x) (__IS_FP(x) && 2*sizeof(x) == sizeof((x)+I))
+
+#define __FLT(x) (__IS_REAL(x) && sizeof(x) == sizeof(float))
+#define __LDBL(x) (__IS_REAL(x) && sizeof(x) == sizeof(long double) && sizeof(long double) != sizeof(double))
+
+#define __FLTCX(x) (__IS_CX(x) && sizeof(x) == sizeof(float complex))
+#define __DBLCX(x) (__IS_CX(x) && sizeof(x) == sizeof(double complex))
+#define __LDBLCX(x) (__IS_CX(x) && sizeof(x) == sizeof(long double complex) && sizeof(long double) != sizeof(double))
+
+/* return type */
+
+#ifdef __GNUC__
+/*
+the result must be casted to the right type
+(otherwise the result type is determined by the conversion
+rules applied to all the function return types so it is long
+double or long double complex except for integral functions)
+
+this cannot be done in c99, so the typeof gcc extension is
+used and that the type of ?: depends on wether an operand is
+a null pointer constant or not
+(in c11 _Generic can be used)
+
+the c arguments below must be integer constant expressions
+so they can be in null pointer constants
+(__IS_FP above was carefully chosen this way)
+*/
+/* if c then t else void */
+#define __type1(c,t) __typeof__(*(0?(t*)0:(void*)!(c)))
+/* if c then t1 else t2 */
+#define __type2(c,t1,t2) __typeof__(*(0?(__type1(c,t1)*)0:(__type1(!(c),t2)*)0))
+/* cast to double when x is integral, otherwise use typeof(x) */
+#define __RETCAST(x) ( \
+ __type2(__IS_FP(x), __typeof__(x), double))
+/* 2 args case, should work for complex types (cpow) */
+#define __RETCAST_2(x, y) ( \
+ __type2(__IS_FP(x) && __IS_FP(y), \
+ __typeof__((x)+(y)), \
+ __typeof__((x)+(y)+1.0)))
+/* 3 args case (fma only) */
+#define __RETCAST_3(x, y, z) ( \
+ __type2(__IS_FP(x) && __IS_FP(y) && __IS_FP(z), \
+ __typeof__((x)+(y)+(z)), \
+ __typeof__((x)+(y)+(z)+1.0)))
+/* drop complex from the type of x */
+/* TODO: wrong when sizeof(long double)==sizeof(double) */
+#define __RETCAST_REAL(x) ( \
+ __type2(__IS_FP(x) && sizeof((x)+I) == sizeof(float complex), float, \
+ __type2(sizeof((x)+1.0+I) == sizeof(double complex), double, \
+ long double)))
+/* add complex to the type of x */
+#define __RETCAST_CX(x) (__typeof__(__RETCAST(x)0+I))
+#else
+#define __RETCAST(x)
+#define __RETCAST_2(x, y)
+#define __RETCAST_3(x, y, z)
+#define __RETCAST_REAL(x)
+#define __RETCAST_CX(x)
+#endif
+
+/* function selection */
+
+#define __tg_real_nocast(fun, x) ( \
+ __FLT(x) ? fun ## f (x) : \
+ __LDBL(x) ? fun ## l (x) : \
+ fun(x) )
+
+#define __tg_real(fun, x) (__RETCAST(x)__tg_real_nocast(fun, x))
+
+#define __tg_real_2_1(fun, x, y) (__RETCAST(x)( \
+ __FLT(x) ? fun ## f (x, y) : \
+ __LDBL(x) ? fun ## l (x, y) : \
+ fun(x, y) ))
+
+#define __tg_real_2(fun, x, y) (__RETCAST_2(x, y)( \
+ __FLT(x) && __FLT(y) ? fun ## f (x, y) : \
+ __LDBL((x)+(y)) ? fun ## l (x, y) : \
+ fun(x, y) ))
+
+#define __tg_complex(fun, x) (__RETCAST_CX(x)( \
+ __FLTCX((x)+I) && __IS_FP(x) ? fun ## f (x) : \
+ __LDBLCX((x)+I) ? fun ## l (x) : \
+ fun(x) ))
+
+#define __tg_complex_retreal(fun, x) (__RETCAST_REAL(x)( \
+ __FLTCX((x)+I) && __IS_FP(x) ? fun ## f (x) : \
+ __LDBLCX((x)+I) ? fun ## l (x) : \
+ fun(x) ))
+
+#define __tg_real_complex(fun, x) (__RETCAST(x)( \
+ __FLTCX(x) ? c ## fun ## f (x) : \
+ __DBLCX(x) ? c ## fun (x) : \
+ __LDBLCX(x) ? c ## fun ## l (x) : \
+ __FLT(x) ? fun ## f (x) : \
+ __LDBL(x) ? fun ## l (x) : \
+ fun(x) ))
+
+/* special cases */
+
+#define __tg_real_remquo(x, y, z) (__RETCAST_2(x, y)( \
+ __FLT(x) && __FLT(y) ? remquof(x, y, z) : \
+ __LDBL((x)+(y)) ? remquol(x, y, z) : \
+ remquo(x, y, z) ))
+
+#define __tg_real_fma(x, y, z) (__RETCAST_3(x, y, z)( \
+ __FLT(x) && __FLT(y) && __FLT(z) ? fmaf(x, y, z) : \
+ __LDBL((x)+(y)+(z)) ? fmal(x, y, z) : \
+ fma(x, y, z) ))
+
+#define __tg_real_complex_pow(x, y) (__RETCAST_2(x, y)( \
+ __FLTCX((x)+(y)) && __IS_FP(x) && __IS_FP(y) ? cpowf(x, y) : \
+ __FLTCX((x)+(y)) ? cpow(x, y) : \
+ __DBLCX((x)+(y)) ? cpow(x, y) : \
+ __LDBLCX((x)+(y)) ? cpowl(x, y) : \
+ __FLT(x) && __FLT(y) ? powf(x, y) : \
+ __LDBL((x)+(y)) ? powl(x, y) : \
+ pow(x, y) ))
+
+#define __tg_real_complex_fabs(x) (__RETCAST_REAL(x)( \
+ __FLTCX(x) ? cabsf(x) : \
+ __DBLCX(x) ? cabs(x) : \
+ __LDBLCX(x) ? cabsl(x) : \
+ __FLT(x) ? fabsf(x) : \
+ __LDBL(x) ? fabsl(x) : \
+ fabs(x) ))
+
+/* suppress any macros in math.h or complex.h */
+
+#undef acos
+#undef acosh
+#undef asin
+#undef asinh
+#undef atan
+#undef atan2
+#undef atanh
+#undef carg
+#undef cbrt
+#undef ceil
+#undef cimag
+#undef conj
+#undef copysign
+#undef cos
+#undef cosh
+#undef cproj
+#undef creal
+#undef erf
+#undef erfc
+#undef exp
+#undef exp2
+#undef expm1
+#undef fabs
+#undef fdim
+#undef floor
+#undef fma
+#undef fmax
+#undef fmin
+#undef fmod
+#undef frexp
+#undef hypot
+#undef ilogb
+#undef ldexp
+#undef lgamma
+#undef llrint
+#undef llround
+#undef log
+#undef log10
+#undef log1p
+#undef log2
+#undef logb
+#undef lrint
+#undef lround
+#undef nearbyint
+#undef nextafter
+#undef nexttoward
+#undef pow
+#undef remainder
+#undef remquo
+#undef rint
+#undef round
+#undef scalbln
+#undef scalbn
+#undef sin
+#undef sinh
+#undef sqrt
+#undef tan
+#undef tanh
+#undef tgamma
+#undef trunc
+
+/* tg functions */
+
+#define acos(x) __tg_real_complex(acos, (x))
+#define acosh(x) __tg_real_complex(acosh, (x))
+#define asin(x) __tg_real_complex(asin, (x))
+#define asinh(x) __tg_real_complex(asinh, (x))
+#define atan(x) __tg_real_complex(atan, (x))
+#define atan2(x,y) __tg_real_2(atan2, (x), (y))
+#define atanh(x) __tg_real_complex(atanh, (x))
+#define carg(x) __tg_complex_retreal(carg, (x))
+#define cbrt(x) __tg_real(cbrt, (x))
+#define ceil(x) __tg_real(ceil, (x))
+#define cimag(x) __tg_complex_retreal(cimag, (x))
+#define conj(x) __tg_complex(conj, (x))
+#define copysign(x,y) __tg_real_2(copysign, (x), (y))
+#define cos(x) __tg_real_complex(cos, (x))
+#define cosh(x) __tg_real_complex(cosh, (x))
+#define cproj(x) __tg_complex(cproj, (x))
+#define creal(x) __tg_complex_retreal(creal, (x))
+#define erf(x) __tg_real(erf, (x))
+#define erfc(x) __tg_real(erfc, (x))
+#define exp(x) __tg_real_complex(exp, (x))
+#define exp2(x) __tg_real(exp2, (x))
+#define expm1(x) __tg_real(expm1, (x))
+#define fabs(x) __tg_real_complex_fabs(x)
+#define fdim(x,y) __tg_real_2(fdim, (x), (y))
+#define floor(x) __tg_real(floor, (x))
+#define fma(x,y,z) __tg_real_fma((x), (y), (z))
+#define fmax(x,y) __tg_real_2(fmax, (x), (y))
+#define fmin(x,y) __tg_real_2(fmin, (x), (y))
+#define fmod(x,y) __tg_real_2(fmod, (x), (y))
+#define frexp(x,y) __tg_real_2_1(frexp, (x), (y))
+#define hypot(x,y) __tg_real_2(hypot, (x), (y))
+#define ilogb(x) __tg_real_nocast(ilogb, (x))
+#define ldexp(x,y) __tg_real_2_1(ldexp, (x), (y))
+#define lgamma(x) __tg_real(lgamma, (x))
+#define llrint(x) __tg_real_nocast(llrint, (x))
+#define llround(x) __tg_real_nocast(llround, (x))
+#define log(x) __tg_real_complex(log, (x))
+#define log10(x) __tg_real(log10, (x))
+#define log1p(x) __tg_real(log1p, (x))
+#define log2(x) __tg_real(log2, (x))
+#define logb(x) __tg_real(logb, (x))
+#define lrint(x) __tg_real_nocast(lrint, (x))
+#define lround(x) __tg_real_nocast(lround, (x))
+#define nearbyint(x) __tg_real(nearbyint, (x))
+#define nextafter(x,y) __tg_real_2(nextafter, (x), (y))
+#define nexttoward(x,y) __tg_real_2(nexttoward, (x), (y))
+#define pow(x,y) __tg_real_complex_pow((x), (y))
+#define remainder(x,y) __tg_real_2(remainder, (x), (y))
+#define remquo(x,y,z) __tg_real_remquo((x), (y), (z))
+#define rint(x) __tg_real(rint, (x))
+#define round(x) __tg_real(round, (x))
+#define scalbln(x,y) __tg_real_2_1(scalbln, (x), (y))
+#define scalbn(x,y) __tg_real_2_1(scalbn, (x), (y))
+#define sin(x) __tg_real_complex(sin, (x))
+#define sinh(x) __tg_real_complex(sinh, (x))
+#define sqrt(x) __tg_real_complex(sqrt, (x))
+#define tan(x) __tg_real_complex(tan, (x))
+#define tanh(x) __tg_real_complex(tanh, (x))
+#define tgamma(x) __tg_real(tgamma, (x))
+#define trunc(x) __tg_real(trunc, (x))
+
+#endif
diff --git a/system/include/libc/time.h b/system/include/libc/time.h
index 2548d6be..6b2a0693 100644
--- a/system/include/libc/time.h
+++ b/system/include/libc/time.h
@@ -1,273 +1,132 @@
-/*
- * time.h
- *
- * Struct and function declarations for dealing with time.
- */
-
-#ifndef _TIME_H_
-#define _TIME_H_
-
-#include "_ansi.h"
-#include <sys/reent.h>
-
-#ifndef NULL
-#define NULL 0
-#endif
-
-/* Get _CLOCKS_PER_SEC_ */
-#include <machine/time.h>
-
-#ifndef _CLOCKS_PER_SEC_
-#define _CLOCKS_PER_SEC_ 1000
-#endif
-
-#define CLOCKS_PER_SEC _CLOCKS_PER_SEC_
-#define CLK_TCK CLOCKS_PER_SEC
-#define __need_size_t
-#include <stddef.h>
-
-#include <sys/types.h>
-
-_BEGIN_STD_C
-
-struct tm
-{
- int tm_sec;
- int tm_min;
- int tm_hour;
- int tm_mday;
- int tm_mon;
- int tm_year;
- int tm_wday;
- int tm_yday;
- int tm_isdst;
- /* XXX Emscripten */
- int tm_gmtoff;
- char *tm_zone;
-};
-
-clock_t _EXFUN(clock, (void));
-double _EXFUN(difftime, (time_t _time2, time_t _time1));
-time_t _EXFUN(mktime, (struct tm *_timeptr));
-time_t _EXFUN(time, (time_t *_timer));
-#ifndef _REENT_ONLY
-char *_EXFUN(asctime, (const struct tm *_tblock));
-char *_EXFUN(ctime, (const time_t *_time));
-struct tm *_EXFUN(gmtime, (const time_t *_timer));
-struct tm *_EXFUN(localtime,(const time_t *_timer));
-#endif
-size_t _EXFUN(strftime, (char *_s, size_t _maxsize, const char *_fmt, const struct tm *_t));
-
-char *_EXFUN(asctime_r, (const struct tm *, char *));
-char *_EXFUN(ctime_r, (const time_t *, char *));
-struct tm *_EXFUN(gmtime_r, (const time_t *, struct tm *));
-struct tm *_EXFUN(localtime_r, (const time_t *, struct tm *));
-
-_END_STD_C
+#ifndef _TIME_H
+#define _TIME_H
#ifdef __cplusplus
extern "C" {
#endif
-#ifndef __STRICT_ANSI__
-char *_EXFUN(strptime, (const char *, const char *, struct tm *));
-_VOID _EXFUN(tzset, (_VOID));
-_VOID _EXFUN(_tzset_r, (struct _reent *));
+#include <features.h>
-typedef struct __tzrule_struct
-{
- char ch;
- int m;
- int n;
- int d;
- int s;
- time_t change;
- long offset; /* Match type of _timezone. */
-} __tzrule_type;
+#define NULL 0L
-typedef struct __tzinfo_struct
-{
- int __tznorth;
- int __tzyear;
- __tzrule_type __tzrule[2];
-} __tzinfo_type;
+#define __NEED_size_t
+#define __NEED_time_t
+#define __NEED_clock_t
-__tzinfo_type *_EXFUN (__gettzinfo, (_VOID));
-
-/* getdate functions */
-
-#ifdef HAVE_GETDATE
-#ifndef _REENT_ONLY
-#define getdate_err (*__getdate_err())
-int *_EXFUN(__getdate_err,(_VOID));
-
-struct tm * _EXFUN(getdate, (const char *));
-/* getdate_err is set to one of the following values to indicate the error.
- 1 the DATEMSK environment variable is null or undefined,
- 2 the template file cannot be opened for reading,
- 3 failed to get file status information,
- 4 the template file is not a regular file,
- 5 an error is encountered while reading the template file,
- 6 memory allication failed (not enough memory available),
- 7 there is no line in the template that matches the input,
- 8 invalid input specification */
-#endif /* !_REENT_ONLY */
-
-/* getdate_r returns the error code as above */
-int _EXFUN(getdate_r, (const char *, struct tm *));
-#endif /* HAVE_GETDATE */
-
-/* defines for the opengroup specifications Derived from Issue 1 of the SVID. */
-extern __IMPORT long _timezone;
-extern __IMPORT int _daylight;
-extern __IMPORT char *_tzname[2];
-
-/* POSIX defines the external tzname being defined in time.h */
-#ifndef tzname
-#define tzname _tzname
-#endif
-#ifndef timezone
-#define timezone _timezone
+#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
+ || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
+ || defined(_BSD_SOURCE)
+#define __NEED_struct_timespec
+#define __NEED_clockid_t
+#define __NEED_timer_t
+#define __NEED_pid_t
+#define __NEED_locale_t
#endif
-#endif /* !__STRICT_ANSI__ */
-#ifdef __cplusplus
-}
-#endif
+#include <bits/alltypes.h>
-#include <sys/features.h>
-
-#ifdef __CYGWIN__
-#include <cygwin/time.h>
-#endif /*__CYGWIN__*/
-
-#if defined(EMSCRIPTEN) || defined(_POSIX_TIMERS)
-
-#include <signal.h>
-
-#ifdef __cplusplus
-extern "C" {
+#if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
+#define __tm_gmtoff tm_gmtoff
+#define __tm_zone tm_zone
#endif
-/* Clocks, P1003.1b-1993, p. 263 */
-
-int _EXFUN(clock_settime, (clockid_t clock_id, const struct timespec *tp));
-int _EXFUN(clock_gettime, (clockid_t clock_id, struct timespec *tp));
-int _EXFUN(clock_getres, (clockid_t clock_id, struct timespec *res));
-
-/* Create a Per-Process Timer, P1003.1b-1993, p. 264 */
-
-int _EXFUN(timer_create,
- (clockid_t clock_id, struct sigevent *evp, timer_t *timerid));
-
-/* Delete a Per_process Timer, P1003.1b-1993, p. 266 */
-
-int _EXFUN(timer_delete, (timer_t timerid));
-
-/* Per-Process Timers, P1003.1b-1993, p. 267 */
-
-int _EXFUN(timer_settime,
- (timer_t timerid, int flags, const struct itimerspec *value,
- struct itimerspec *ovalue));
-int _EXFUN(timer_gettime, (timer_t timerid, struct itimerspec *value));
-int _EXFUN(timer_getoverrun, (timer_t timerid));
-
-/* High Resolution Sleep, P1003.1b-1993, p. 269 */
-
-int _EXFUN(nanosleep, (const struct timespec *rqtp, struct timespec *rmtp));
-
-#ifdef __cplusplus
-}
-#endif
-#endif /* _POSIX_TIMERS */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* CPU-time Clock Attributes, P1003.4b/D8, p. 54 */
-
-/* values for the clock enable attribute */
-
-#define CLOCK_ENABLED 1 /* clock is enabled, i.e. counting execution time */
-#define CLOCK_DISABLED 0 /* clock is disabled */
-
-/* values for the pthread cputime_clock_allowed attribute */
+struct tm
+{
+ int tm_sec;
+ int tm_min;
+ int tm_hour;
+ int tm_mday;
+ int tm_mon;
+ int tm_year;
+ int tm_wday;
+ int tm_yday;
+ int tm_isdst;
+ long __tm_gmtoff;
+ const char *__tm_zone;
+};
-#define CLOCK_ALLOWED 1 /* If a thread is created with this value a */
- /* CPU-time clock attached to that thread */
- /* shall be accessible. */
-#define CLOCK_DISALLOWED 0 /* If a thread is created with this value, the */
- /* thread shall not have a CPU-time clock */
- /* accessible. */
+clock_t clock (void);
+time_t time (time_t *);
+double difftime (time_t, time_t);
+time_t mktime (struct tm *);
+size_t strftime (char *__restrict, size_t, const char *__restrict, const struct tm *__restrict);
+struct tm *gmtime (const time_t *);
+struct tm *localtime (const time_t *);
+char *asctime (const struct tm *);
+char *ctime (const time_t *);
-/* Manifest Constants, P1003.1b-1993, p. 262 */
+#define CLOCKS_PER_SEC 1000000L
-#define CLOCK_REALTIME (clockid_t)1
-/* Flag indicating time is "absolute" with respect to the clock
- associated with a time. */
+#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
+ || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
+ || defined(_BSD_SOURCE)
-#define TIMER_ABSTIME 4
+size_t strftime_l (char * __restrict, size_t, const char * __restrict, const struct tm * __restrict, locale_t);
-/* Manifest Constants, P1003.4b/D8, p. 55 */
+struct tm *gmtime_r (const time_t *__restrict, struct tm *__restrict);
+struct tm *localtime_r (const time_t *__restrict, struct tm *__restrict);
+char *asctime_r (const struct tm *__restrict, char *__restrict);
+char *ctime_r (const time_t *, char *);
-#if defined(_POSIX_CPUTIME)
+void tzset (void);
-/* When used in a clock or timer function call, this is interpreted as
- the identifier of the CPU_time clock associated with the PROCESS
- making the function call. */
+struct itimerspec
+{
+ struct timespec it_interval;
+ struct timespec it_value;
+};
-#define CLOCK_PROCESS_CPUTIME (clockid_t)2
+#define CLOCK_REALTIME 0
+#define CLOCK_MONOTONIC 1
+#define CLOCK_PROCESS_CPUTIME_ID 2
+#define CLOCK_THREAD_CPUTIME_ID 3
+#define CLOCK_MONOTONIC_RAW 4
+#define CLOCK_REALTIME_COURSE 5
+#define CLOCK_MONOTONIC_COURSE 6
+#define CLOCK_BOOTTIME 7
+#define CLOCK_REALTIME_ALARM 8
+#define CLOCK_BOOTTIME_ALARM 9
+#define CLOCK_SGI_CYCLE 10
+#define CLOCK_TAI 11
+
+#define TIMER_ABSTIME 1
+
+int nanosleep (const struct timespec *, struct timespec *);
+int clock_getres (clockid_t, struct timespec *);
+int clock_gettime (clockid_t, struct timespec *);
+int clock_settime (clockid_t, const struct timespec *);
+int clock_nanosleep (clockid_t, int, const struct timespec *, struct timespec *);
+int clock_getcpuclockid (pid_t, clockid_t *);
+
+struct sigevent;
+int timer_create (clockid_t, struct sigevent *__restrict, timer_t *__restrict);
+int timer_delete (timer_t);
+int timer_settime (timer_t, int, const struct itimerspec *__restrict, struct itimerspec *__restrict);
+int timer_gettime (timer_t, struct itimerspec *);
+int timer_getoverrun (timer_t);
#endif
-#if defined(_POSIX_THREAD_CPUTIME)
-
-/* When used in a clock or timer function call, this is interpreted as
- the identifier of the CPU_time clock associated with the THREAD
- making the function call. */
-
-#define CLOCK_THREAD_CPUTIME (clockid_t)3
+#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE)
+char *strptime (const char *__restrict, const char *__restrict, struct tm *__restrict);
+extern int daylight;
+extern long timezone;
+extern char *tzname[2];
+extern int getdate_err;
+struct tm *getdate (const char *);
#endif
-#if defined(_POSIX_MONOTONIC_CLOCK) || defined(EMSCRIPTEN)
-
-/* The identifier for the system-wide monotonic clock, which is defined
- * as a clock whose value cannot be set via clock_settime() and which
- * cannot have backward clock jumps. */
-
-#define CLOCK_MONOTONIC (clockid_t)4
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+int stime(time_t *);
+time_t timegm(struct tm *);
#endif
-#if defined(_POSIX_CPUTIME)
-
-/* Accessing a Process CPU-time CLock, P1003.4b/D8, p. 55 */
-
-int _EXFUN(clock_getcpuclockid, (pid_t pid, clockid_t *clock_id));
-
-#endif /* _POSIX_CPUTIME */
-
-#if defined(_POSIX_CPUTIME) || defined(_POSIX_THREAD_CPUTIME)
-
-/* CPU-time Clock Attribute Access, P1003.4b/D8, p. 56 */
-
-int _EXFUN(clock_setenable_attr, (clockid_t clock_id, int attr));
-int _EXFUN(clock_getenable_attr, (clockid_t clock_id, int *attr));
-
-#endif /* _POSIX_CPUTIME or _POSIX_THREAD_CPUTIME */
-
-/* XXX Emscripten */
-
-int _EXFUN(stime, (time_t *t));
-time_t _EXFUN(timegm, (struct tm *t));
-int _EXFUN(dysize, (int year));
-
#ifdef __cplusplus
}
#endif
-#endif /* _TIME_H_ */
+#endif
diff --git a/system/include/libc/ucontext.h b/system/include/libc/ucontext.h
new file mode 100644
index 00000000..3bb776ed
--- /dev/null
+++ b/system/include/libc/ucontext.h
@@ -0,0 +1,25 @@
+#ifndef _UCONTEXT_H
+#define _UCONTEXT_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <features.h>
+
+#include <signal.h>
+
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+#define NGREG (sizeof(gregset_t)/sizeof(greg_t))
+#endif
+
+struct __ucontext;
+
+int getcontext(struct __ucontext *);
+void makecontext(struct __ucontext *, void (*)(void), int, ...);
+int setcontext(const struct __ucontext *);
+int swapcontext(struct __ucontext *, const struct __ucontext *);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/system/include/libc/ulimit.h b/system/include/libc/ulimit.h
new file mode 100644
index 00000000..efdcd311
--- /dev/null
+++ b/system/include/libc/ulimit.h
@@ -0,0 +1,17 @@
+#ifndef _ULIMIT_H
+#define _ULIMIT_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define UL_GETFSIZE 1
+#define UL_SETFSIZE 2
+
+long ulimit (int, ...);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/unctrl.h b/system/include/libc/unctrl.h
deleted file mode 100644
index 00407523..00000000
--- a/system/include/libc/unctrl.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/* From curses.h. */
-/*
- * Copyright (c) 1981, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef _UNCTRL_H_
-#define _UNCTRL_H_
-
-#include <_ansi.h>
-
-#define unctrl(c) __unctrl[(c) & 0xff]
-#define unctrllen(ch) __unctrllen[(ch) & 0xff]
-
-extern __IMPORT _CONST char * _CONST __unctrl[256]; /* Control strings. */
-extern __IMPORT _CONST char __unctrllen[256]; /* Control strings length. */
-
-#endif /* _UNCTRL_H_ */
diff --git a/system/include/libc/unistd.h b/system/include/libc/unistd.h
index f9fca847..a00a9c4f 100644
--- a/system/include/libc/unistd.h
+++ b/system/include/libc/unistd.h
@@ -1,6 +1,519 @@
-#ifndef _UNISTD_H_
-#define _UNISTD_H_
+#ifndef _UNISTD_H
+#define _UNISTD_H
-# include <sys/unistd.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
-#endif /* _UNISTD_H_ */
+#include <features.h>
+
+#define STDIN_FILENO 0
+#define STDOUT_FILENO 1
+#define STDERR_FILENO 2
+
+#define SEEK_SET 0
+#define SEEK_CUR 1
+#define SEEK_END 2
+
+#define NULL 0L
+
+#define __NEED_size_t
+#define __NEED_ssize_t
+#define __NEED_uid_t
+#define __NEED_gid_t
+#define __NEED_off_t
+#define __NEED_pid_t
+#define __NEED_intptr_t
+#define __NEED_useconds_t
+
+#include <bits/alltypes.h>
+
+int pipe(int [2]);
+int pipe2(int [2], int);
+int close(int);
+int dup(int);
+int dup2(int, int);
+int dup3(int, int, int);
+off_t lseek(int, off_t, int);
+int fsync(int);
+int fdatasync(int);
+
+ssize_t read(int, void *, size_t);
+ssize_t write(int, const void *, size_t);
+ssize_t pread(int, void *, size_t, off_t);
+ssize_t pwrite(int, const void *, size_t, off_t);
+
+int chown(const char *, uid_t, gid_t);
+int fchown(int, uid_t, gid_t);
+int lchown(const char *, uid_t, gid_t);
+int fchownat(int, const char *, uid_t, gid_t, int);
+
+int link(const char *, const char *);
+int linkat(int, const char *, int, const char *, int);
+int symlink(const char *, const char *);
+int symlinkat(const char *, int, const char *);
+ssize_t readlink(const char *__restrict, char *__restrict, size_t);
+ssize_t readlinkat(int, const char *__restrict, char *__restrict, size_t);
+int unlink(const char *);
+int unlinkat(int, const char *, int);
+int rmdir(const char *);
+int truncate(const char *, off_t);
+int ftruncate(int, off_t);
+
+#define F_OK 0
+#define R_OK 4
+#define W_OK 2
+#define X_OK 1
+
+int access(const char *, int);
+int faccessat(int, const char *, int, int);
+
+int chdir(const char *);
+int fchdir(int);
+char *getcwd(char *, size_t);
+
+unsigned alarm(unsigned);
+unsigned sleep(unsigned);
+int pause(void);
+
+pid_t fork(void);
+int execve(const char *, char *const [], char *const []);
+int execv(const char *, char *const []);
+int execle(const char *, const char *, ...);
+int execl(const char *, const char *, ...);
+int execvp(const char *, char *const []);
+int execlp(const char *, const char *, ...);
+int fexecve(int, char *const [], char *const []);
+_Noreturn void _exit(int);
+
+pid_t getpid(void);
+pid_t getppid(void);
+pid_t getpgrp(void);
+pid_t getpgid(pid_t);
+int setpgid(pid_t, pid_t);
+pid_t setsid(void);
+pid_t getsid(pid_t);
+char *ttyname(int);
+int ttyname_r(int, char *, size_t);
+int isatty(int);
+pid_t tcgetpgrp(int);
+int tcsetpgrp(int, pid_t);
+
+uid_t getuid(void);
+uid_t geteuid(void);
+gid_t getgid(void);
+gid_t getegid(void);
+int getgroups(int, gid_t []);
+int setuid(uid_t);
+int setreuid(uid_t, uid_t);
+int seteuid(uid_t);
+int setgid(gid_t);
+int setregid(gid_t, gid_t);
+int setegid(gid_t);
+
+char *getlogin(void);
+int getlogin_r(char *, size_t);
+int gethostname(char *, size_t);
+char *ctermid(char *);
+
+int getopt(int, char * const [], const char *);
+extern char *optarg;
+extern int optind, opterr, optopt;
+
+long pathconf(const char *, int);
+long fpathconf(int, int);
+long sysconf(int);
+size_t confstr(int, char *, size_t);
+
+#define F_ULOCK 0
+#define F_LOCK 1
+#define F_TLOCK 2
+#define F_TEST 3
+
+#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+int lockf(int, int, off_t);
+long gethostid(void);
+int nice(int);
+void sync(void);
+#endif
+
+#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE)
+pid_t setpgrp(void);
+char *crypt(const char *, const char *);
+void encrypt(char *, int);
+void swab(const void *__restrict, void *__restrict, ssize_t);
+#endif
+
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) \
+ || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE+0 < 700)
+int usleep(unsigned);
+unsigned ualarm(unsigned, unsigned);
+#endif
+
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+#define L_SET 0
+#define L_INCR 1
+#define L_XTND 2
+int brk(void *);
+void *sbrk(intptr_t);
+pid_t vfork(void);
+int vhangup(void);
+int chroot(const char *);
+int getpagesize(void);
+int getdtablesize(void);
+int sethostname(const char *, size_t);
+int getdomainname(char *, size_t);
+int setdomainname(const char *, size_t);
+int setgroups(size_t, const gid_t *);
+char *getpass(const char *);
+int daemon(int, int);
+void setusershell(void);
+void endusershell(void);
+char *getusershell(void);
+int acct(const char *);
+long syscall(long, ...);
+#endif
+
+#ifdef _GNU_SOURCE
+extern char **environ;
+int setresuid(uid_t, uid_t, uid_t);
+int setresgid(gid_t, gid_t, gid_t);
+int getresuid(uid_t *, uid_t *, uid_t *);
+int getresgid(gid_t *, gid_t *, gid_t *);
+char *get_current_dir_name(void);
+void syncfs(int);
+int euidaccess(const char *, int);
+int eaccess(const char *, int);
+#endif
+
+#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
+#define lseek64 lseek
+#define pread64 pread
+#define pwrite64 pwrite
+#define truncate64 truncate
+#define ftruncate64 ftruncate
+#define lockf64 lockf
+#define off64_t off_t
+#endif
+
+#define _XOPEN_VERSION 700
+#define _XOPEN_UNIX 1
+#define _XOPEN_ENH_I18N 1
+
+#define _POSIX_VERSION 200809L
+#define _POSIX2_VERSION _POSIX_VERSION
+
+#define _POSIX_ADVISORY_INFO _POSIX_VERSION
+#define _POSIX_CHOWN_RESTRICTED 1
+#define _POSIX_IPV6 _POSIX_VERSION
+#define _POSIX_JOB_CONTROL 1
+#define _POSIX_MAPPED_FILES _POSIX_VERSION
+#define _POSIX_MEMLOCK _POSIX_VERSION
+#define _POSIX_MEMLOCK_RANGE _POSIX_VERSION
+#define _POSIX_MEMORY_PROTECTION _POSIX_VERSION
+#define _POSIX_MESSAGE_PASSING _POSIX_VERSION
+#define _POSIX_FSYNC _POSIX_VERSION
+#define _POSIX_NO_TRUNC 1
+#define _POSIX_RAW_SOCKETS _POSIX_VERSION
+#define _POSIX_REALTIME_SIGNALS _POSIX_VERSION
+#define _POSIX_REGEXP 1
+#define _POSIX_SAVED_IDS 1
+#define _POSIX_SHELL 1
+#define _POSIX_SPAWN _POSIX_VERSION
+#define _POSIX_VDISABLE 0
+
+#define _POSIX_THREADS _POSIX_VERSION
+#define _POSIX_THREAD_PROCESS_SHARED _POSIX_VERSION
+#define _POSIX_THREAD_SAFE_FUNCTIONS _POSIX_VERSION
+#define _POSIX_THREAD_ATTR_STACKADDR _POSIX_VERSION
+#define _POSIX_THREAD_ATTR_STACKSIZE _POSIX_VERSION
+#define _POSIX_THREAD_PRIORITY_SCHEDULING _POSIX_VERSION
+#define _POSIX_THREAD_CPUTIME _POSIX_VERSION
+#define _POSIX_TIMERS _POSIX_VERSION
+#define _POSIX_TIMEOUTS _POSIX_VERSION
+#define _POSIX_MONOTONIC_CLOCK _POSIX_VERSION
+#define _POSIX_CPUTIME _POSIX_VERSION
+#define _POSIX_CLOCK_SELECTION _POSIX_VERSION
+#define _POSIX_BARRIERS _POSIX_VERSION
+#define _POSIX_SPIN_LOCKS _POSIX_VERSION
+#define _POSIX_READER_WRITER_LOCKS _POSIX_VERSION
+#define _POSIX_ASYNCHRONOUS_IO _POSIX_VERSION
+#define _POSIX_SEMAPHORES _POSIX_VERSION
+#define _POSIX_SHARED_MEMORY_OBJECTS _POSIX_VERSION
+
+#define _POSIX2_C_BIND _POSIX_VERSION
+
+#include <bits/posix.h>
+
+
+
+#define _PC_LINK_MAX 0
+#define _PC_MAX_CANON 1
+#define _PC_MAX_INPUT 2
+#define _PC_NAME_MAX 3
+#define _PC_PATH_MAX 4
+#define _PC_PIPE_BUF 5
+#define _PC_CHOWN_RESTRICTED 6
+#define _PC_NO_TRUNC 7
+#define _PC_VDISABLE 8
+#define _PC_SYNC_IO 9
+#define _PC_ASYNC_IO 10
+#define _PC_PRIO_IO 11
+#define _PC_SOCK_MAXBUF 12
+#define _PC_FILESIZEBITS 13
+#define _PC_REC_INCR_XFER_SIZE 14
+#define _PC_REC_MAX_XFER_SIZE 15
+#define _PC_REC_MIN_XFER_SIZE 16
+#define _PC_REC_XFER_ALIGN 17
+#define _PC_ALLOC_SIZE_MIN 18
+#define _PC_SYMLINK_MAX 19
+#define _PC_2_SYMLINKS 20
+
+#define _SC_ARG_MAX 0
+#define _SC_CHILD_MAX 1
+#define _SC_CLK_TCK 2
+#define _SC_NGROUPS_MAX 3
+#define _SC_OPEN_MAX 4
+#define _SC_STREAM_MAX 5
+#define _SC_TZNAME_MAX 6
+#define _SC_JOB_CONTROL 7
+#define _SC_SAVED_IDS 8
+#define _SC_REALTIME_SIGNALS 9
+#define _SC_PRIORITY_SCHEDULING 10
+#define _SC_TIMERS 11
+#define _SC_ASYNCHRONOUS_IO 12
+#define _SC_PRIORITIZED_IO 13
+#define _SC_SYNCHRONIZED_IO 14
+#define _SC_FSYNC 15
+#define _SC_MAPPED_FILES 16
+#define _SC_MEMLOCK 17
+#define _SC_MEMLOCK_RANGE 18
+#define _SC_MEMORY_PROTECTION 19
+#define _SC_MESSAGE_PASSING 20
+#define _SC_SEMAPHORES 21
+#define _SC_SHARED_MEMORY_OBJECTS 22
+#define _SC_AIO_LISTIO_MAX 23
+#define _SC_AIO_MAX 24
+#define _SC_AIO_PRIO_DELTA_MAX 25
+#define _SC_DELAYTIMER_MAX 26
+#define _SC_MQ_OPEN_MAX 27
+#define _SC_MQ_PRIO_MAX 28
+#define _SC_VERSION 29
+#define _SC_PAGE_SIZE 30
+#define _SC_PAGESIZE 30 /* !! */
+#define _SC_RTSIG_MAX 31
+#define _SC_SEM_NSEMS_MAX 32
+#define _SC_SEM_VALUE_MAX 33
+#define _SC_SIGQUEUE_MAX 34
+#define _SC_TIMER_MAX 35
+#define _SC_BC_BASE_MAX 36
+#define _SC_BC_DIM_MAX 37
+#define _SC_BC_SCALE_MAX 38
+#define _SC_BC_STRING_MAX 39
+#define _SC_COLL_WEIGHTS_MAX 40
+#define _SC_EQUIV_CLASS_MAX 41
+#define _SC_EXPR_NEST_MAX 42
+#define _SC_LINE_MAX 43
+#define _SC_RE_DUP_MAX 44
+#define _SC_CHARCLASS_NAME_MAX 45
+#define _SC_2_VERSION 46
+#define _SC_2_C_BIND 47
+#define _SC_2_C_DEV 48
+#define _SC_2_FORT_DEV 49
+#define _SC_2_FORT_RUN 50
+#define _SC_2_SW_DEV 51
+#define _SC_2_LOCALEDEF 52
+#define _SC_PII 53
+#define _SC_PII_XTI 54
+#define _SC_PII_SOCKET 55
+#define _SC_PII_INTERNET 56
+#define _SC_PII_OSI 57
+#define _SC_POLL 58
+#define _SC_SELECT 59
+#define _SC_UIO_MAXIOV 60 /* !! */
+#define _SC_IOV_MAX 60
+#define _SC_PII_INTERNET_STREAM 61
+#define _SC_PII_INTERNET_DGRAM 62
+#define _SC_PII_OSI_COTS 63
+#define _SC_PII_OSI_CLTS 64
+#define _SC_PII_OSI_M 65
+#define _SC_T_IOV_MAX 66
+#define _SC_THREADS 67
+#define _SC_THREAD_SAFE_FUNCTIONS 68
+#define _SC_GETGR_R_SIZE_MAX 69
+#define _SC_GETPW_R_SIZE_MAX 70
+#define _SC_LOGIN_NAME_MAX 71
+#define _SC_TTY_NAME_MAX 72
+#define _SC_THREAD_DESTRUCTOR_ITERATIONS 73
+#define _SC_THREAD_KEYS_MAX 74
+#define _SC_THREAD_STACK_MIN 75
+#define _SC_THREAD_THREADS_MAX 76
+#define _SC_THREAD_ATTR_STACKADDR 77
+#define _SC_THREAD_ATTR_STACKSIZE 78
+#define _SC_THREAD_PRIORITY_SCHEDULING 79
+#define _SC_THREAD_PRIO_INHERIT 80
+#define _SC_THREAD_PRIO_PROTECT 81
+#define _SC_THREAD_PROCESS_SHARED 82
+#define _SC_NPROCESSORS_CONF 83
+#define _SC_NPROCESSORS_ONLN 84
+#define _SC_PHYS_PAGES 85
+#define _SC_AVPHYS_PAGES 86
+#define _SC_ATEXIT_MAX 87
+#define _SC_PASS_MAX 88
+#define _SC_XOPEN_VERSION 89
+#define _SC_XOPEN_XCU_VERSION 90
+#define _SC_XOPEN_UNIX 91
+#define _SC_XOPEN_CRYPT 92
+#define _SC_XOPEN_ENH_I18N 93
+#define _SC_XOPEN_SHM 94
+#define _SC_2_CHAR_TERM 95
+#define _SC_2_C_VERSION 96
+#define _SC_2_UPE 97
+#define _SC_XOPEN_XPG2 98
+#define _SC_XOPEN_XPG3 99
+#define _SC_XOPEN_XPG4 100
+#define _SC_CHAR_BIT 101
+#define _SC_CHAR_MAX 102
+#define _SC_CHAR_MIN 103
+#define _SC_INT_MAX 104
+#define _SC_INT_MIN 105
+#define _SC_LONG_BIT 106
+#define _SC_WORD_BIT 107
+#define _SC_MB_LEN_MAX 108
+#define _SC_NZERO 109
+#define _SC_SSIZE_MAX 110
+#define _SC_SCHAR_MAX 111
+#define _SC_SCHAR_MIN 112
+#define _SC_SHRT_MAX 113
+#define _SC_SHRT_MIN 114
+#define _SC_UCHAR_MAX 115
+#define _SC_UINT_MAX 116
+#define _SC_ULONG_MAX 117
+#define _SC_USHRT_MAX 118
+#define _SC_NL_ARGMAX 119
+#define _SC_NL_LANGMAX 120
+#define _SC_NL_MSGMAX 121
+#define _SC_NL_NMAX 122
+#define _SC_NL_SETMAX 123
+#define _SC_NL_TEXTMAX 124
+#define _SC_XBS5_ILP32_OFF32 125
+#define _SC_XBS5_ILP32_OFFBIG 126
+#define _SC_XBS5_LP64_OFF64 127
+#define _SC_XBS5_LPBIG_OFFBIG 128
+#define _SC_XOPEN_LEGACY 129
+#define _SC_XOPEN_REALTIME 130
+#define _SC_XOPEN_REALTIME_THREADS 131
+#define _SC_ADVISORY_INFO 132
+#define _SC_BARRIERS 133
+#define _SC_BASE 134
+#define _SC_C_LANG_SUPPORT 135
+#define _SC_C_LANG_SUPPORT_R 136
+#define _SC_CLOCK_SELECTION 137
+#define _SC_CPUTIME 138
+#define _SC_THREAD_CPUTIME 139
+#define _SC_DEVICE_IO 140
+#define _SC_DEVICE_SPECIFIC 141
+#define _SC_DEVICE_SPECIFIC_R 142
+#define _SC_FD_MGMT 143
+#define _SC_FIFO 144
+#define _SC_PIPE 145
+#define _SC_FILE_ATTRIBUTES 146
+#define _SC_FILE_LOCKING 147
+#define _SC_FILE_SYSTEM 148
+#define _SC_MONOTONIC_CLOCK 149
+#define _SC_MULTI_PROCESS 150
+#define _SC_SINGLE_PROCESS 151
+#define _SC_NETWORKING 152
+#define _SC_READER_WRITER_LOCKS 153
+#define _SC_SPIN_LOCKS 154
+#define _SC_REGEXP 155
+#define _SC_REGEX_VERSION 156
+#define _SC_SHELL 157
+#define _SC_SIGNALS 158
+#define _SC_SPAWN 159
+#define _SC_SPORADIC_SERVER 160
+#define _SC_THREAD_SPORADIC_SERVER 161
+#define _SC_SYSTEM_DATABASE 162
+#define _SC_SYSTEM_DATABASE_R 163
+#define _SC_TIMEOUTS 164
+#define _SC_TYPED_MEMORY_OBJECTS 165
+#define _SC_USER_GROUPS 166
+#define _SC_USER_GROUPS_R 167
+#define _SC_2_PBS 168
+#define _SC_2_PBS_ACCOUNTING 169
+#define _SC_2_PBS_LOCATE 170
+#define _SC_2_PBS_MESSAGE 171
+#define _SC_2_PBS_TRACK 172
+#define _SC_SYMLOOP_MAX 173
+#define _SC_STREAMS 174
+#define _SC_2_PBS_CHECKPOINT 175
+#define _SC_V6_ILP32_OFF32 176
+#define _SC_V6_ILP32_OFFBIG 177
+#define _SC_V6_LP64_OFF64 178
+#define _SC_V6_LPBIG_OFFBIG 179
+#define _SC_HOST_NAME_MAX 180
+#define _SC_TRACE 181
+#define _SC_TRACE_EVENT_FILTER 182
+#define _SC_TRACE_INHERIT 183
+#define _SC_TRACE_LOG 184
+
+#define _SC_IPV6 235
+#define _SC_RAW_SOCKETS 236
+#define _SC_V7_ILP32_OFF32 237
+#define _SC_V7_ILP32_OFFBIG 238
+#define _SC_V7_LP64_OFF64 239
+#define _SC_V7_LPBIG_OFFBIG 240
+#define _SC_SS_REPL_MAX 241
+#define _SC_TRACE_EVENT_NAME_MAX 242
+#define _SC_TRACE_NAME_MAX 243
+#define _SC_TRACE_SYS_MAX 244
+#define _SC_TRACE_USER_EVENT_MAX 245
+#define _SC_XOPEN_STREAMS 246
+#define _SC_THREAD_ROBUST_PRIO_INHERIT 247
+#define _SC_THREAD_ROBUST_PRIO_PROTECT 248
+
+#define _CS_PATH 0
+#define _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS 1
+#define _CS_GNU_LIBC_VERSION 2
+#define _CS_GNU_LIBPTHREAD_VERSION 3
+#define _CS_POSIX_V5_WIDTH_RESTRICTED_ENVS 4
+#define _CS_POSIX_V7_WIDTH_RESTRICTED_ENVS 5
+
+#define _CS_POSIX_V6_ILP32_OFF32_CFLAGS 1116
+#define _CS_POSIX_V6_ILP32_OFF32_LDFLAGS 1117
+#define _CS_POSIX_V6_ILP32_OFF32_LIBS 1118
+#define _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS 1119
+#define _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS 1120
+#define _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS 1121
+#define _CS_POSIX_V6_ILP32_OFFBIG_LIBS 1122
+#define _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS 1123
+#define _CS_POSIX_V6_LP64_OFF64_CFLAGS 1124
+#define _CS_POSIX_V6_LP64_OFF64_LDFLAGS 1125
+#define _CS_POSIX_V6_LP64_OFF64_LIBS 1126
+#define _CS_POSIX_V6_LP64_OFF64_LINTFLAGS 1127
+#define _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS 1128
+#define _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS 1129
+#define _CS_POSIX_V6_LPBIG_OFFBIG_LIBS 1130
+#define _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS 1131
+#define _CS_POSIX_V7_ILP32_OFF32_CFLAGS 1132
+#define _CS_POSIX_V7_ILP32_OFF32_LDFLAGS 1133
+#define _CS_POSIX_V7_ILP32_OFF32_LIBS 1134
+#define _CS_POSIX_V7_ILP32_OFF32_LINTFLAGS 1135
+#define _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS 1136
+#define _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS 1137
+#define _CS_POSIX_V7_ILP32_OFFBIG_LIBS 1138
+#define _CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS 1139
+#define _CS_POSIX_V7_LP64_OFF64_CFLAGS 1140
+#define _CS_POSIX_V7_LP64_OFF64_LDFLAGS 1141
+#define _CS_POSIX_V7_LP64_OFF64_LIBS 1142
+#define _CS_POSIX_V7_LP64_OFF64_LINTFLAGS 1143
+#define _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS 1144
+#define _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS 1145
+#define _CS_POSIX_V7_LPBIG_OFFBIG_LIBS 1146
+#define _CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS 1147
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/utime.h b/system/include/libc/utime.h
index 652891aa..ec82e0f3 100644
--- a/system/include/libc/utime.h
+++ b/system/include/libc/utime.h
@@ -1,12 +1,24 @@
+#ifndef _UTIME_H
+#define _UTIME_H
+
#ifdef __cplusplus
extern "C" {
#endif
-#include <_ansi.h>
+#define __NEED_time_t
+
+#include <bits/alltypes.h>
+
+struct utimbuf
+{
+ time_t actime;
+ time_t modtime;
+};
-/* The utime function is defined in libc/sys/<arch>/sys if it exists. */
-#include <sys/utime.h>
+int utime (const char *, const struct utimbuf *);
#ifdef __cplusplus
}
#endif
+
+#endif
diff --git a/system/include/libc/utmp.h b/system/include/libc/utmp.h
index 88cf6f85..b357ac8c 100644
--- a/system/include/libc/utmp.h
+++ b/system/include/libc/utmp.h
@@ -1,8 +1,47 @@
+#ifndef _UTMP_H
+#define _UTMP_H
+
#ifdef __cplusplus
extern "C" {
#endif
-#include <sys/utmp.h>
+
+#include <utmpx.h>
+
+#define ACCOUNTING 9
+#define UT_NAMESIZE 32
+#define UT_HOSTSIZE 256
+
+struct lastlog {
+ time_t ll_time;
+ char ll_line[UT_LINESIZE];
+ char ll_host[UT_HOSTSIZE];
+};
+
+#define ut_time ut_tv.tv_sec
+#define ut_name ut_user
+#define ut_addr ut_addr_v6[0]
+#define utmp utmpx
+#define utmpname(x) (-1)
+
+void endutent(void);
+struct utmp *getutent(void);
+struct utmp *getutid(const struct utmp *);
+struct utmp *getutline(const struct utmp *);
+struct utmp *pututline(const struct utmp *);
+void setutent(void);
+
+void updwtmp(const char *, const struct utmp *);
+
+#define _PATH_UTMP "/dev/null/utmp"
+#define _PATH_WTMP "/dev/null/wtmp"
+
+#define UTMP_FILE _PATH_UTMP
+#define WTMP_FILE _PATH_WTMP
+#define UTMP_FILENAME _PATH_UTMP
+#define WTMP_FILENAME _PATH_WTMP
+
#ifdef __cplusplus
}
#endif
+#endif
diff --git a/system/include/libc/utmpx.h b/system/include/libc/utmpx.h
new file mode 100644
index 00000000..fd5f515a
--- /dev/null
+++ b/system/include/libc/utmpx.h
@@ -0,0 +1,58 @@
+#ifndef _UTMPX_H
+#define _UTMPX_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define __NEED_pid_t
+#define __NEED_time_t
+#define __NEED_suseconds_t
+#define __NEED_struct_timeval
+
+#include <bits/alltypes.h>
+
+#define UT_LINESIZE 32
+
+struct utmpx
+{
+ short ut_type;
+ pid_t ut_pid;
+ char ut_line[UT_LINESIZE];
+ char ut_id[4];
+ char ut_user[32];
+ char ut_host[256];
+ struct {
+ short e_termination;
+ short e_exit;
+ } ut_exit;
+ long ut_session;
+ struct timeval ut_tv;
+ unsigned ut_addr_v6[4];
+ char __unused[20];
+};
+
+void endutxent(void);
+struct utmpx *getutxent(void);
+struct utmpx *getutxid(const struct utmpx *);
+struct utmpx *getutxline(const struct utmpx *);
+struct utmpx *pututxline(const struct utmpx *);
+void setutxent(void);
+
+void updwtmpx(const char *, const struct utmpx *);
+
+#define EMPTY 0
+#define RUN_LVL 1
+#define BOOT_TIME 2
+#define NEW_TIME 3
+#define OLD_TIME 4
+#define INIT_PROCESS 5
+#define LOGIN_PROCESS 6
+#define USER_PROCESS 7
+#define DEAD_PROCESS 8
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/system/include/libc/values.h b/system/include/libc/values.h
new file mode 100644
index 00000000..fe4949f8
--- /dev/null
+++ b/system/include/libc/values.h
@@ -0,0 +1,39 @@
+#ifndef _VALUES_H
+#define _VALUES_H
+
+#include <limits.h>
+
+#define CHARBITS (sizeof(char) * 8)
+#define SHORTBITS (sizeof(short) * 8)
+#define INTBITS (sizeof(int) * 8)
+#define LONGBITS (sizeof(long) * 8)
+#define PTRBITS (sizeof(char *) * 8)
+#define DOUBLEBITS (sizeof(double) * 8)
+#define FLOATBITS (sizeof(float) * 8)
+
+#define MINSHORT SHRT_MIN
+#define MININT INT_MIN
+#define MINLONG LONG_MIN
+
+#define MAXSHORT SHRT_MAX
+#define MAXINT INT_MAX
+#define MAXLONG LONG_MAX
+
+#define HIBITS MINSHORT
+#define HIBITL MINLONG
+
+#include <float.h>
+
+#define MAXDOUBLE DBL_MAX
+#undef MAXFLOAT
+#define MAXFLOAT FLT_MAX
+#define MINDOUBLE DBL_MIN
+#define MINFLOAT FLT_MIN
+#define DMINEXP DBL_MIN_EXP
+#define FMINEXP FLT_MIN_EXP
+#define DMAXEXP DBL_MAX_EXP
+#define FMAXEXP FLT_MAX_EXP
+
+#define BITSPERBYTE CHAR_BIT
+
+#endif
diff --git a/system/include/libc/wchar.h b/system/include/libc/wchar.h
index 4331bc79..fd5aac5f 100644
--- a/system/include/libc/wchar.h
+++ b/system/include/libc/wchar.h
@@ -1,194 +1,183 @@
-#ifndef _WCHAR_H_
-#define _WCHAR_H_
+#ifndef _WCHAR_H
+#define _WCHAR_H
-#include <_ansi.h>
-
-#include <sys/reent.h>
-
-#define __need_size_t
-#define __need_wchar_t
-#define __need_wint_t
-#include <stddef.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
-#define __need___va_list
-#include <stdarg.h>
+#include <features.h>
-/* For _mbstate_t definition. */
-#include <sys/_types.h>
+#define __NEED_FILE
+#define __NEED___isoc_va_list
+#define __NEED_size_t
+#define __NEED_wchar_t
+#define __NEED_wint_t
-#ifndef NULL
-#define NULL 0
+#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
+ || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+#define __NEED_locale_t
+#define __NEED_va_list
#endif
-#ifndef WEOF
-# define WEOF ((wint_t)-1)
+#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+#define __NEED_wctype_t
#endif
-#ifndef WCHAR_MIN
-#define WCHAR_MIN 0
-#endif
+#include <bits/alltypes.h>
-#ifndef WCHAR_MAX
-#ifdef __WCHAR_MAX__
-#define WCHAR_MAX __WCHAR_MAX__
+#if L'\0'-1 > 0
+#define WCHAR_MAX (0xffffffffu+L'\0')
+#define WCHAR_MIN (0+L'\0')
#else
-#define WCHAR_MAX 0x7fffffffu
-#endif
+#define WCHAR_MAX (0x7fffffff+L'\0')
+#define WCHAR_MIN (-1-0x7fffffff+L'\0')
#endif
-_BEGIN_STD_C
+#define NULL 0L
-/* As required by POSIX.1-2008, declare tm as incomplete type.
- The actual definition is in time.h. */
-struct tm;
+#undef WEOF
+#define WEOF 0xffffffffU
-#ifndef _MBSTATE_T
-#define _MBSTATE_T
-typedef _mbstate_t mbstate_t;
-#endif /* _MBSTATE_T */
-
-wint_t _EXFUN(btowc, (int));
-int _EXFUN(wctob, (wint_t));
-size_t _EXFUN(mbrlen, (const char * , size_t, mbstate_t *));
-size_t _EXFUN(mbrtowc, (wchar_t * , const char * , size_t, mbstate_t *));
-size_t _EXFUN(_mbrtowc_r, (struct _reent *, wchar_t * , const char * ,
- size_t, mbstate_t *));
-int _EXFUN(mbsinit, (const mbstate_t *));
-size_t _EXFUN(mbsnrtowcs, (wchar_t * , const char ** , size_t, size_t,
- mbstate_t *));
-size_t _EXFUN(_mbsnrtowcs_r, (struct _reent *, wchar_t * , const char ** ,
- size_t, size_t, mbstate_t *));
-size_t _EXFUN(mbsrtowcs, (wchar_t * , const char ** , size_t, mbstate_t *));
-size_t _EXFUN(_mbsrtowcs_r, (struct _reent *, wchar_t * , const char ** , size_t, mbstate_t *));
-size_t _EXFUN(wcrtomb, (char * , wchar_t, mbstate_t *));
-size_t _EXFUN(_wcrtomb_r, (struct _reent *, char * , wchar_t, mbstate_t *));
-size_t _EXFUN(wcsnrtombs, (char * , const wchar_t ** , size_t, size_t,
- mbstate_t *));
-size_t _EXFUN(_wcsnrtombs_r, (struct _reent *, char * , const wchar_t ** ,
- size_t, size_t, mbstate_t *));
-size_t _EXFUN(wcsrtombs, (char * , const wchar_t ** , size_t, mbstate_t *));
-size_t _EXFUN(_wcsrtombs_r, (struct _reent *, char * , const wchar_t ** ,
- size_t, mbstate_t *));
-int _EXFUN(wcscasecmp, (const wchar_t *, const wchar_t *));
-wchar_t *_EXFUN(wcscat, (wchar_t * , const wchar_t *));
-wchar_t *_EXFUN(wcschr, (const wchar_t *, wchar_t));
-int _EXFUN(wcscmp, (const wchar_t *, const wchar_t *));
-int _EXFUN(wcscoll, (const wchar_t *, const wchar_t *));
-wchar_t *_EXFUN(wcscpy, (wchar_t * , const wchar_t *));
-wchar_t *_EXFUN(wcpcpy, (wchar_t * , const wchar_t *));
-wchar_t *_EXFUN(wcsdup, (const wchar_t *));
-wchar_t *_EXFUN(_wcsdup_r, (struct _reent *, const wchar_t * ));
-size_t _EXFUN(wcscspn, (const wchar_t *, const wchar_t *));
-size_t _EXFUN(wcsftime, (wchar_t *, size_t, const wchar_t *, const struct tm *));
-size_t _EXFUN(wcslcat, (wchar_t *, const wchar_t *, size_t));
-size_t _EXFUN(wcslcpy, (wchar_t *, const wchar_t *, size_t));
-size_t _EXFUN(wcslen, (const wchar_t *));
-int _EXFUN(wcsncasecmp, (const wchar_t *, const wchar_t *, size_t));
-wchar_t *_EXFUN(wcsncat, (wchar_t * , const wchar_t * , size_t));
-int _EXFUN(wcsncmp, (const wchar_t *, const wchar_t *, size_t));
-wchar_t *_EXFUN(wcsncpy, (wchar_t * , const wchar_t * , size_t));
-wchar_t *_EXFUN(wcpncpy, (wchar_t * , const wchar_t * , size_t));
-size_t _EXFUN(wcsnlen, (const wchar_t *, size_t));
-wchar_t *_EXFUN(wcspbrk, (const wchar_t *, const wchar_t *));
-wchar_t *_EXFUN(wcsrchr, (const wchar_t *, wchar_t));
-size_t _EXFUN(wcsspn, (const wchar_t *, const wchar_t *));
-wchar_t *_EXFUN(wcsstr, (const wchar_t *, const wchar_t *));
-wchar_t *_EXFUN(wcstok, (wchar_t *, const wchar_t *, wchar_t **));
-double _EXFUN(wcstod, (const wchar_t *, wchar_t **));
-double _EXFUN(_wcstod_r, (struct _reent *, const wchar_t *, wchar_t **));
-float _EXFUN(wcstof, (const wchar_t *, wchar_t **));
-float _EXFUN(_wcstof_r, (struct _reent *, const wchar_t *, wchar_t **));
-int _EXFUN(wcswidth, (const wchar_t *, size_t));
-size_t _EXFUN(wcsxfrm, (wchar_t *, const wchar_t *, size_t));
-int _EXFUN(wcwidth, (const wchar_t));
-wchar_t *_EXFUN(wmemchr, (const wchar_t *, wchar_t, size_t));
-int _EXFUN(wmemcmp, (const wchar_t *, const wchar_t *, size_t));
-wchar_t *_EXFUN(wmemcpy, (wchar_t * , const wchar_t * , size_t));
-wchar_t *_EXFUN(wmemmove, (wchar_t *, const wchar_t *, size_t));
-wchar_t *_EXFUN(wmemset, (wchar_t *, wchar_t, size_t));
-
-long _EXFUN(wcstol, (const wchar_t *, wchar_t **, int));
-long long _EXFUN(wcstoll, (const wchar_t *, wchar_t **, int));
-unsigned long _EXFUN(wcstoul, (const wchar_t *, wchar_t **, int));
-unsigned long long _EXFUN(wcstoull, (const wchar_t *, wchar_t **, int));
-long _EXFUN(_wcstol_r, (struct _reent *, const wchar_t *, wchar_t **, int));
-long long _EXFUN(_wcstoll_r, (struct _reent *, const wchar_t *, wchar_t **, int));
-unsigned long _EXFUN(_wcstoul_r, (struct _reent *, const wchar_t *, wchar_t **, int));
-unsigned long long _EXFUN(_wcstoull_r, (struct _reent *, const wchar_t *, wchar_t **, int));
-
-wint_t _EXFUN(fgetwc, (__FILE *));
-wchar_t *_EXFUN(fgetws, (wchar_t *, int, __FILE *));
-wint_t _EXFUN(fputwc, (wchar_t, __FILE *));
-int _EXFUN(fputws, (const wchar_t *, __FILE *));
-int _EXFUN (fwide, (__FILE *, int));
-wint_t _EXFUN (getwc, (__FILE *));
-wint_t _EXFUN (getwchar, (void));
-wint_t _EXFUN(putwc, (wchar_t, __FILE *));
-wint_t _EXFUN(putwchar, (wchar_t));
-wint_t _EXFUN (ungetwc, (wint_t wc, __FILE *));
-
-wint_t _EXFUN(_fgetwc_r, (struct _reent *, __FILE *));
-wchar_t *_EXFUN(_fgetws_r, (struct _reent *, wchar_t *, int, __FILE *));
-wint_t _EXFUN(_fputwc_r, (struct _reent *, wchar_t, __FILE *));
-int _EXFUN(_fputws_r, (struct _reent *, const wchar_t *, __FILE *));
-int _EXFUN (_fwide_r, (struct _reent *, __FILE *, int));
-wint_t _EXFUN (_getwc_r, (struct _reent *, __FILE *));
-wint_t _EXFUN (_getwchar_r, (struct _reent *ptr));
-wint_t _EXFUN(_putwc_r, (struct _reent *, wchar_t, __FILE *));
-wint_t _EXFUN(_putwchar_r, (struct _reent *, wchar_t));
-wint_t _EXFUN (_ungetwc_r, (struct _reent *, wint_t wc, __FILE *));
-
-__FILE *_EXFUN (open_wmemstream, (wchar_t **, size_t *));
-__FILE *_EXFUN (_open_wmemstream_r, (struct _reent *, wchar_t **, size_t *));
-
-#ifndef __VALIST
-#ifdef __GNUC__
-#define __VALIST __gnuc_va_list
-#else
-#define __VALIST char*
-#endif
+typedef struct __mbstate_t
+{
+ unsigned __opaque1, __opaque2;
+} mbstate_t;
+
+wchar_t *wcscpy (wchar_t *__restrict, const wchar_t *__restrict);
+wchar_t *wcsncpy (wchar_t *__restrict, const wchar_t *__restrict, size_t);
+
+wchar_t *wcscat (wchar_t *__restrict, const wchar_t *__restrict);
+wchar_t *wcsncat (wchar_t *__restrict, const wchar_t *__restrict, size_t);
+
+int wcscmp (const wchar_t *, const wchar_t *);
+int wcsncmp (const wchar_t *, const wchar_t *, size_t);
+
+int wcscoll(const wchar_t *, const wchar_t *);
+size_t wcsxfrm (wchar_t *__restrict, const wchar_t *__restrict, size_t n);
+
+wchar_t *wcschr (const wchar_t *, wchar_t);
+wchar_t *wcsrchr (const wchar_t *, wchar_t);
+
+size_t wcscspn (const wchar_t *, const wchar_t *);
+size_t wcsspn (const wchar_t *, const wchar_t *);
+wchar_t *wcspbrk (const wchar_t *, const wchar_t *);
+
+wchar_t *wcstok (wchar_t *__restrict, const wchar_t *__restrict, wchar_t **__restrict);
+
+size_t wcslen (const wchar_t *);
+
+wchar_t *wcsstr (const wchar_t *__restrict, const wchar_t *__restrict);
+wchar_t *wcswcs (const wchar_t *, const wchar_t *);
+
+wchar_t *wmemchr (const wchar_t *, wchar_t, size_t);
+int wmemcmp (const wchar_t *, const wchar_t *, size_t);
+wchar_t *wmemcpy (wchar_t *__restrict, const wchar_t *__restrict, size_t);
+wchar_t *wmemmove (wchar_t *, const wchar_t *, size_t);
+wchar_t *wmemset (wchar_t *, wchar_t, size_t);
+
+wint_t btowc (int);
+int wctob (wint_t);
+
+int mbsinit (const mbstate_t *);
+size_t mbrtowc (wchar_t *__restrict, const char *__restrict, size_t, mbstate_t *__restrict);
+size_t wcrtomb (char *__restrict, wchar_t, mbstate_t *__restrict);
+
+size_t mbrlen (const char *__restrict, size_t, mbstate_t *__restrict);
+
+size_t mbsrtowcs (wchar_t *__restrict, const char **__restrict, size_t, mbstate_t *__restrict);
+size_t wcsrtombs (char *__restrict, const wchar_t **__restrict, size_t, mbstate_t *__restrict);
+
+float wcstof (const wchar_t *__restrict, wchar_t **__restrict);
+double wcstod (const wchar_t *__restrict, wchar_t **__restrict);
+long double wcstold (const wchar_t *__restrict, wchar_t **__restrict);
+
+long wcstol (const wchar_t *__restrict, wchar_t **__restrict, int);
+unsigned long wcstoul (const wchar_t *__restrict, wchar_t **__restrict, int);
+
+long long wcstoll (const wchar_t *__restrict, wchar_t **__restrict, int);
+unsigned long long wcstoull (const wchar_t *__restrict, wchar_t **__restrict, int);
+
+
+
+int fwide (FILE *, int);
+
+
+int wprintf (const wchar_t *__restrict, ...);
+int fwprintf (FILE *__restrict, const wchar_t *__restrict, ...);
+int swprintf (wchar_t *__restrict, size_t, const wchar_t *__restrict, ...);
+
+int vwprintf (const wchar_t *__restrict, __isoc_va_list);
+int vfwprintf (FILE *__restrict, const wchar_t *__restrict, __isoc_va_list);
+int vswprintf (wchar_t *__restrict, size_t, const wchar_t *__restrict, __isoc_va_list);
+
+int wscanf (const wchar_t *__restrict, ...);
+int fwscanf (FILE *__restrict, const wchar_t *__restrict, ...);
+int swscanf (const wchar_t *__restrict, const wchar_t *__restrict, ...);
+
+int vwscanf (const wchar_t *__restrict, __isoc_va_list);
+int vfwscanf (FILE *__restrict, const wchar_t *__restrict, __isoc_va_list);
+int vswscanf (const wchar_t *__restrict, const wchar_t *__restrict, __isoc_va_list);
+
+wint_t fgetwc (FILE *);
+wint_t getwc (FILE *);
+wint_t getwchar (void);
+
+wint_t fputwc (wchar_t, FILE *);
+wint_t putwc (wchar_t, FILE *);
+wint_t putwchar (wchar_t);
+
+wchar_t *fgetws (wchar_t *__restrict, int, FILE *__restrict);
+int fputws (const wchar_t *__restrict, FILE *__restrict);
+
+wint_t ungetwc (wint_t, FILE *);
+
+struct tm;
+size_t wcsftime (wchar_t *__restrict, size_t, const wchar_t *__restrict, const struct tm *__restrict);
+
+#undef iswdigit
+
+#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
+ || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+FILE *open_wmemstream(wchar_t **, size_t *);
+size_t mbsnrtowcs(wchar_t *__restrict, const char **__restrict, size_t, size_t, mbstate_t *__restrict);
+size_t wcsnrtombs(char *__restrict, const wchar_t **__restrict, size_t, size_t, mbstate_t *__restrict);
+wchar_t *wcsdup(const wchar_t *);
+size_t wcsnlen (const wchar_t *, size_t);
+wchar_t *wcpcpy (wchar_t *__restrict, const wchar_t *__restrict);
+wchar_t *wcpncpy (wchar_t *__restrict, const wchar_t *__restrict, size_t);
+int wcscasecmp(const wchar_t *, const wchar_t *);
+int wcscasecmp_l(const wchar_t *, const wchar_t *, locale_t);
+int wcsncasecmp(const wchar_t *, const wchar_t *, size_t);
+int wcsncasecmp_l(const wchar_t *, const wchar_t *, size_t, locale_t);
+int wcscoll_l(const wchar_t *, const wchar_t *, locale_t);
+size_t wcsxfrm_l(wchar_t *__restrict, const wchar_t *__restrict, size_t n, locale_t);
#endif
-int _EXFUN(fwprintf, (__FILE *, const wchar_t *, ...));
-int _EXFUN(swprintf, (wchar_t *, size_t, const wchar_t *, ...));
-int _EXFUN(vfwprintf, (__FILE *, const wchar_t *, __VALIST));
-int _EXFUN(vswprintf, (wchar_t *, size_t, const wchar_t *, __VALIST));
-int _EXFUN(vwprintf, (const wchar_t *, __VALIST));
-int _EXFUN(wprintf, (const wchar_t *, ...));
-
-int _EXFUN(_fwprintf_r, (struct _reent *, __FILE *, const wchar_t *, ...));
-int _EXFUN(_swprintf_r, (struct _reent *, wchar_t *, size_t, const wchar_t *, ...));
-int _EXFUN(_vfwprintf_r, (struct _reent *, __FILE *, const wchar_t *, __VALIST));
-int _EXFUN(_vswprintf_r, (struct _reent *, wchar_t *, size_t, const wchar_t *, __VALIST));
-int _EXFUN(_vwprintf_r, (struct _reent *, const wchar_t *, __VALIST));
-int _EXFUN(_wprintf_r, (struct _reent *, const wchar_t *, ...));
-
-int _EXFUN(fwscanf, (__FILE *, const wchar_t *, ...));
-int _EXFUN(swscanf, (const wchar_t *, const wchar_t *, ...));
-int _EXFUN(vfwscanf, (__FILE *, const wchar_t *, __VALIST));
-int _EXFUN(vswscanf, (const wchar_t *, const wchar_t *, __VALIST));
-int _EXFUN(vwscanf, (const wchar_t *, __VALIST));
-int _EXFUN(wscanf, (const wchar_t *, ...));
-
-int _EXFUN(_fwscanf_r, (struct _reent *, __FILE *, const wchar_t *, ...));
-int _EXFUN(_swscanf_r, (struct _reent *, const wchar_t *, const wchar_t *, ...));
-int _EXFUN(_vfwscanf_r, (struct _reent *, __FILE *, const wchar_t *, __VALIST));
-int _EXFUN(_vswscanf_r, (struct _reent *, const wchar_t *, const wchar_t *, __VALIST));
-int _EXFUN(_vwscanf_r, (struct _reent *, const wchar_t *, __VALIST));
-int _EXFUN(_wscanf_r, (struct _reent *, const wchar_t *, ...));
-
-long double _EXFUN(wcstold, (const wchar_t *nptr, wchar_t **endptr)); /* XXX Emscripten */
-
-#define getwc(fp) fgetwc(fp)
-#define putwc(wc,fp) fputwc((wc), (fp))
-#ifndef _REENT_ONLY
-#define getwchar() fgetwc(_REENT->_stdin)
-#define putwchar(wc) fputwc((wc), _REENT->_stdout)
-#else
-#define getwchar() fgetwc(_impure_ptr->_stdin)
-#define putwchar(wc) fputwc((wc), _impure_ptr->_stdout)
+#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+int wcwidth (wchar_t);
+int wcswidth (const wchar_t *, size_t);
+int iswalnum(wint_t);
+int iswalpha(wint_t);
+int iswblank(wint_t);
+int iswcntrl(wint_t);
+int iswdigit(wint_t);
+int iswgraph(wint_t);
+int iswlower(wint_t);
+int iswprint(wint_t);
+int iswpunct(wint_t);
+int iswspace(wint_t);
+int iswupper(wint_t);
+int iswxdigit(wint_t);
+int iswctype(wint_t, wctype_t);
+wint_t towlower(wint_t);
+wint_t towupper(wint_t);
+wctype_t wctype(const char *);
+#undef iswdigit
+#define iswdigit(a) ((unsigned)(a)-'0' < 10)
#endif
-_END_STD_C
+#ifdef __cplusplus
+}
+#endif
-#endif /* _WCHAR_H_ */
+#endif
diff --git a/system/include/libc/wctype.h b/system/include/libc/wctype.h
index c72c9dec..3ac24f13 100644
--- a/system/include/libc/wctype.h
+++ b/system/include/libc/wctype.h
@@ -1,47 +1,77 @@
-#ifndef _WCTYPE_H_
-#define _WCTYPE_H_
+#ifndef _WCTYPE_H
+#define _WCTYPE_H
-#include <_ansi.h>
-#include <sys/_types.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <features.h>
-#define __need_wint_t
-#include <stddef.h>
+#define __NEED_wint_t
+#define __NEED_wctype_t
-#ifndef WEOF
-# define WEOF ((wint_t)-1)
+#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
+ || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+#define __NEED_locale_t
#endif
-_BEGIN_STD_C
+#include <bits/alltypes.h>
+
+typedef const int * wctrans_t;
+
+#undef WEOF
+#define WEOF 0xffffffffU
+
+#undef iswdigit
+
+int iswalnum(wint_t);
+int iswalpha(wint_t);
+int iswblank(wint_t);
+int iswcntrl(wint_t);
+int iswdigit(wint_t);
+int iswgraph(wint_t);
+int iswlower(wint_t);
+int iswprint(wint_t);
+int iswpunct(wint_t);
+int iswspace(wint_t);
+int iswupper(wint_t);
+int iswxdigit(wint_t);
+int iswctype(wint_t, wctype_t);
+wint_t towctrans(wint_t, wctrans_t);
+wint_t towlower(wint_t);
+wint_t towupper(wint_t);
+wctrans_t wctrans(const char *);
+wctype_t wctype(const char *);
+
+#undef iswdigit
+#define iswdigit(a) (((unsigned)(a)-L'0') < 10)
+
+#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
+ || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+
+int iswalnum_l(wint_t, locale_t);
+int iswalpha_l(wint_t, locale_t);
+int iswblank_l(wint_t, locale_t);
+int iswcntrl_l(wint_t, locale_t);
+int iswdigit_l(wint_t, locale_t);
+int iswgraph_l(wint_t, locale_t);
+int iswlower_l(wint_t, locale_t);
+int iswprint_l(wint_t, locale_t);
+int iswpunct_l(wint_t, locale_t);
+int iswspace_l(wint_t, locale_t);
+int iswupper_l(wint_t, locale_t);
+int iswxdigit_l(wint_t, locale_t);
+int iswctype_l(wint_t, wctype_t, locale_t);
+wint_t towlower_l(wint_t, locale_t);
+wint_t towupper_l(wint_t, locale_t);
+wint_t towctrans_l(wint_t, wctrans_t, locale_t);
+wctrans_t wctrans_l(const char *, locale_t);
+wctype_t wctype_l(const char *, locale_t);
-#ifndef _WCTYPE_T
-#define _WCTYPE_T
-typedef int wctype_t;
#endif
-#ifndef _WCTRANS_T
-#define _WCTRANS_T
-typedef int wctrans_t;
+#ifdef __cplusplus
+}
#endif
-int _EXFUN(iswalpha, (wint_t));
-int _EXFUN(iswalnum, (wint_t));
-int _EXFUN(iswblank, (wint_t));
-int _EXFUN(iswcntrl, (wint_t));
-int _EXFUN(iswctype, (wint_t, wctype_t));
-int _EXFUN(iswdigit, (wint_t));
-int _EXFUN(iswgraph, (wint_t));
-int _EXFUN(iswlower, (wint_t));
-int _EXFUN(iswprint, (wint_t));
-int _EXFUN(iswpunct, (wint_t));
-int _EXFUN(iswspace, (wint_t));
-int _EXFUN(iswupper, (wint_t));
-int _EXFUN(iswxdigit, (wint_t));
-wint_t _EXFUN(towctrans, (wint_t, wctrans_t));
-wint_t _EXFUN(towupper, (wint_t));
-wint_t _EXFUN(towlower, (wint_t));
-wctrans_t _EXFUN(wctrans, (const char *));
-wctype_t _EXFUN(wctype, (const char *));
-
-_END_STD_C
-
-#endif /* _WCTYPE_H_ */
+#endif
diff --git a/system/include/libc/wordexp.h b/system/include/libc/wordexp.h
index 8f87681a..d12081e8 100644
--- a/system/include/libc/wordexp.h
+++ b/system/include/libc/wordexp.h
@@ -1,53 +1,42 @@
-/* Copyright (C) 2002, 2010 by Red Hat, Incorporated. All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this software
- * is freely granted, provided that this notice is preserved.
- */
-
-#ifndef _WORDEXP_H_
-#define _WORDEXP_H_
-
-#include <sys/types.h>
+#ifndef _WORDEXP_H
+#define _WORDEXP_H
#ifdef __cplusplus
extern "C" {
#endif
-struct _wordexp_t
+#include <features.h>
+
+#define __NEED_size_t
+
+#include <bits/alltypes.h>
+
+#define WRDE_DOOFFS 1
+#define WRDE_APPEND 2
+#define WRDE_NOCMD 4
+#define WRDE_REUSE 8
+#define WRDE_SHOWERR 16
+#define WRDE_UNDEF 32
+
+typedef struct
{
- size_t we_wordc; /* Count of words matched by words. */
- char **we_wordv; /* Pointer to list of expanded words. */
- size_t we_offs; /* Slots to reserve at the beginning of we_wordv. */
-};
-
-typedef struct _wordexp_t wordexp_t;
-
-#define WRDE_DOOFFS 0x0001 /* Use we_offs. */
-#define WRDE_APPEND 0x0002 /* Append to output from previous call. */
-#define WRDE_NOCMD 0x0004 /* Don't perform command substitution. */
-#define WRDE_REUSE 0x0008 /* pwordexp points to a wordexp_t struct returned from
- a previous successful call to wordexp. */
-#define WRDE_SHOWERR 0x0010 /* Print error messages to stderr. */
-#define WRDE_UNDEF 0x0020 /* Report attempt to expand undefined shell variable. */
-
-enum {
- WRDE_SUCCESS,
- WRDE_NOSPACE,
- WRDE_BADCHAR,
- WRDE_BADVAL,
- WRDE_CMDSUB,
- WRDE_SYNTAX,
- WRDE_NOSYS
-};
-
-/* Note: This implementation of wordexp requires a version of bash
- that supports the --wordexp and --protected arguments to be present
- on the system. It does not support the WRDE_UNDEF flag. */
-int wordexp(const char *, wordexp_t *, int);
-void wordfree(wordexp_t *);
+ size_t we_wordc;
+ char **we_wordv;
+ size_t we_offs;
+} wordexp_t;
+
+#define WRDE_NOSYS -1
+#define WRDE_NOSPACE 1
+#define WRDE_BADCHAR 2
+#define WRDE_BADVAL 3
+#define WRDE_CMDSUB 4
+#define WRDE_SYNTAX 5
+
+int wordexp (const char *__restrict, wordexp_t *__restrict, int);
+void wordfree (wordexp_t *);
#ifdef __cplusplus
}
#endif
-#endif /* _WORDEXP_H_ */
+#endif
diff --git a/system/include/memory.h b/system/include/memory.h
deleted file mode 100644
index 01e2d041..00000000
--- a/system/include/memory.h
+++ /dev/null
@@ -1,10 +0,0 @@
-
-#ifndef _MEMORY_H
-#define _MEMORY_H
-
-#include <sys/features.h>
-
-#include <string.h>
-
-#endif
-
diff --git a/system/include/mntent.h b/system/include/mntent.h
deleted file mode 100644
index 462c6065..00000000
--- a/system/include/mntent.h
+++ /dev/null
@@ -1,23 +0,0 @@
-
-#ifndef _MNTENT_H
-#define _MNTENT_H
-
-#include <stdio.h>
-
-struct mntent {
- char *mnt_fsname;
- char *mnt_dir;
- char *mnt_type;
- char *mnt_opts;
- int mnt_freq;
- int mnt_passno;
-};
-
-struct mntent *getmntent(FILE *f);
-FILE *setmntent(const char *filename, const char *type);
-int addmntent(FILE *f, const struct mntent *m);
-int endmntent(FILE *f);
-char *hasmntopt(const struct mntent *m, const char *opt);
-
-#endif
-
diff --git a/system/include/net/arpa/inet.h b/system/include/net/arpa/inet.h
deleted file mode 100644
index 2b701c15..00000000
--- a/system/include/net/arpa/inet.h
+++ /dev/null
@@ -1,32 +0,0 @@
-
-#ifndef _NET_ARPA_INET_H
-#define _NET_ARPA_INET_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <stdint.h>
-#include <netdb.h>
-#include <netinet/in.h>
-
-uint32_t htonl(uint32_t hostlong);
-uint16_t htons(uint16_t hostshort);
-uint32_t ntohl(uint32_t netlong);
-uint16_t ntohs(uint16_t netshort);
-
-int inet_aton(const char *cp, struct in_addr *addr);
-char *inet_ntoa(struct in_addr in);
-
-int inet_pton(int af, const char *src, void *dst);
-const char *inet_ntop(int af, const void *src, char *dst, socklen_t size);
-
-typedef long in_addr_t;
-in_addr_t inet_addr(const char *cp);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
diff --git a/system/include/net/arpa/nameser.h b/system/include/net/arpa/nameser.h
deleted file mode 100644
index 6a2c8376..00000000
--- a/system/include/net/arpa/nameser.h
+++ /dev/null
@@ -1,535 +0,0 @@
-/*
- * Copyright (c) 1983, 1989, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*
- * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
- * Copyright (c) 1996-1999 by Internet Software Consortium.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
- * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
- * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
- * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
- * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
- * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- */
-
-/*
- * $BINDId: nameser.h,v 8.37 2000/03/30 21:16:49 vixie Exp $
- */
-
-#ifndef _ARPA_NAMESER_H_
-#define _ARPA_NAMESER_H_
-
-/*! \file */
-
-#define BIND_4_COMPAT
-
-#include <sys/param.h>
-#if (!defined(BSD)) || (BSD < 199306)
-# include <sys/bitypes.h>
-#else
-# include <sys/types.h>
-#endif
-#include <sys/cdefs.h>
-
-/*%
- * Revision information. This is the release date in YYYYMMDD format.
- * It can change every day so the right thing to do with it is use it
- * in preprocessor commands such as "#if (__NAMESER > 19931104)". Do not
- * compare for equality; rather, use it to determine whether your libbind.a
- * contains a new enough lib/nameser/ to support the feature you need.
- */
-
-#define __NAMESER 19991006 /*%< New interface version stamp. */
-/*
- * Define constants based on RFC 883, RFC 1034, RFC 1035
- */
-#define NS_PACKETSZ 512 /*%< default UDP packet size */
-#define NS_MAXDNAME 1025 /*%< maximum domain name */
-#define NS_MAXMSG 65535 /*%< maximum message size */
-#define NS_MAXCDNAME 255 /*%< maximum compressed domain name */
-#define NS_MAXLABEL 63 /*%< maximum length of domain label */
-#define NS_HFIXEDSZ 12 /*%< #/bytes of fixed data in header */
-#define NS_QFIXEDSZ 4 /*%< #/bytes of fixed data in query */
-#define NS_RRFIXEDSZ 10 /*%< #/bytes of fixed data in r record */
-#define NS_INT32SZ 4 /*%< #/bytes of data in a u_int32_t */
-#define NS_INT16SZ 2 /*%< #/bytes of data in a u_int16_t */
-#define NS_INT8SZ 1 /*%< #/bytes of data in a u_int8_t */
-#define NS_INADDRSZ 4 /*%< IPv4 T_A */
-#define NS_IN6ADDRSZ 16 /*%< IPv6 T_AAAA */
-#define NS_CMPRSFLGS 0xc0 /*%< Flag bits indicating name compression. */
-#define NS_DEFAULTPORT 53 /*%< For both TCP and UDP. */
-/*
- * These can be expanded with synonyms, just keep ns_parse.c:ns_parserecord()
- * in synch with it.
- */
-typedef enum __ns_sect {
- ns_s_qd = 0, /*%< Query: Question. */
- ns_s_zn = 0, /*%< Update: Zone. */
- ns_s_an = 1, /*%< Query: Answer. */
- ns_s_pr = 1, /*%< Update: Prerequisites. */
- ns_s_ns = 2, /*%< Query: Name servers. */
- ns_s_ud = 2, /*%< Update: Update. */
- ns_s_ar = 3, /*%< Query|Update: Additional records. */
- ns_s_max = 4
-} ns_sect;
-
-/*%
- * This is a message handle. It is caller allocated and has no dynamic data.
- * This structure is intended to be opaque to all but ns_parse.c, thus the
- * leading _'s on the member names. Use the accessor functions, not the _'s.
- */
-typedef struct __ns_msg {
- const u_char *_msg, *_eom;
- u_int16_t _id, _flags, _counts[ns_s_max];
- const u_char *_sections[ns_s_max];
- ns_sect _sect;
- int _rrnum;
- const u_char *_msg_ptr;
-} ns_msg;
-
-/* Private data structure - do not use from outside library. */
-struct _ns_flagdata { int mask, shift; };
-extern const struct _ns_flagdata _ns_flagdata[];
-
-/* Accessor macros - this is part of the public interface. */
-
-#define ns_msg_id(handle) ((handle)._id + 0)
-#define ns_msg_base(handle) ((handle)._msg + 0)
-#define ns_msg_end(handle) ((handle)._eom + 0)
-#define ns_msg_size(handle) ((handle)._eom - (handle)._msg)
-#define ns_msg_count(handle, section) ((handle)._counts[section] + 0)
-
-/*%
- * This is a parsed record. It is caller allocated and has no dynamic data.
- */
-typedef struct __ns_rr {
- char name[NS_MAXDNAME];
- u_int16_t type;
- u_int16_t rr_class;
- u_int32_t ttl;
- u_int16_t rdlength;
- const u_char * rdata;
-} ns_rr;
-
-/* Accessor macros - this is part of the public interface. */
-#define ns_rr_name(rr) (((rr).name[0] != '\0') ? (rr).name : ".")
-#define ns_rr_type(rr) ((ns_type)((rr).type + 0))
-#define ns_rr_class(rr) ((ns_class)((rr).rr_class + 0))
-#define ns_rr_ttl(rr) ((rr).ttl + 0)
-#define ns_rr_rdlen(rr) ((rr).rdlength + 0)
-#define ns_rr_rdata(rr) ((rr).rdata + 0)
-
-/*%
- * These don't have to be in the same order as in the packet flags word,
- * and they can even overlap in some cases, but they will need to be kept
- * in synch with ns_parse.c:ns_flagdata[].
- */
-typedef enum __ns_flag {
- ns_f_qr, /*%< Question/Response. */
- ns_f_opcode, /*%< Operation code. */
- ns_f_aa, /*%< Authoritative Answer. */
- ns_f_tc, /*%< Truncation occurred. */
- ns_f_rd, /*%< Recursion Desired. */
- ns_f_ra, /*%< Recursion Available. */
- ns_f_z, /*%< MBZ. */
- ns_f_ad, /*%< Authentic Data (DNSSEC). */
- ns_f_cd, /*%< Checking Disabled (DNSSEC). */
- ns_f_rcode, /*%< Response code. */
- ns_f_max
-} ns_flag;
-
-/*%
- * Currently defined opcodes.
- */
-typedef enum __ns_opcode {
- ns_o_query = 0, /*%< Standard query. */
- ns_o_iquery = 1, /*%< Inverse query (deprecated/unsupported). */
- ns_o_status = 2, /*%< Name server status query (unsupported). */
- /* Opcode 3 is undefined/reserved. */
- ns_o_notify = 4, /*%< Zone change notification. */
- ns_o_update = 5, /*%< Zone update message. */
- ns_o_max = 6
-} ns_opcode;
-
-/*%
- * Currently defined response codes.
- */
-typedef enum __ns_rcode {
- ns_r_noerror = 0, /*%< No error occurred. */
- ns_r_formerr = 1, /*%< Format error. */
- ns_r_servfail = 2, /*%< Server failure. */
- ns_r_nxdomain = 3, /*%< Name error. */
- ns_r_notimpl = 4, /*%< Unimplemented. */
- ns_r_refused = 5, /*%< Operation refused. */
- /* these are for BIND_UPDATE */
- ns_r_yxdomain = 6, /*%< Name exists */
- ns_r_yxrrset = 7, /*%< RRset exists */
- ns_r_nxrrset = 8, /*%< RRset does not exist */
- ns_r_notauth = 9, /*%< Not authoritative for zone */
- ns_r_notzone = 10, /*%< Zone of record different from zone section */
- ns_r_max = 11,
- /* The following are EDNS extended rcodes */
- ns_r_badvers = 16,
- /* The following are TSIG errors */
- ns_r_badsig = 16,
- ns_r_badkey = 17,
- ns_r_badtime = 18
-} ns_rcode;
-
-/* BIND_UPDATE */
-typedef enum __ns_update_operation {
- ns_uop_delete = 0,
- ns_uop_add = 1,
- ns_uop_max = 2
-} ns_update_operation;
-
-/*%
- * This structure is used for TSIG authenticated messages
- */
-struct ns_tsig_key {
- char name[NS_MAXDNAME], alg[NS_MAXDNAME];
- unsigned char *data;
- int len;
-};
-typedef struct ns_tsig_key ns_tsig_key;
-
-/*%
- * This structure is used for TSIG authenticated TCP messages
- */
-struct ns_tcp_tsig_state {
- int counter;
- struct dst_key *key;
- void *ctx;
- unsigned char sig[NS_PACKETSZ];
- int siglen;
-};
-typedef struct ns_tcp_tsig_state ns_tcp_tsig_state;
-
-#define NS_TSIG_FUDGE 300
-#define NS_TSIG_TCP_COUNT 100
-#define NS_TSIG_ALG_HMAC_MD5 "HMAC-MD5.SIG-ALG.REG.INT"
-
-#define NS_TSIG_ERROR_NO_TSIG -10
-#define NS_TSIG_ERROR_NO_SPACE -11
-#define NS_TSIG_ERROR_FORMERR -12
-
-/*%
- * Currently defined type values for resources and queries.
- */
-typedef enum __ns_type {
- ns_t_invalid = 0, /*%< Cookie. */
- ns_t_a = 1, /*%< Host address. */
- ns_t_ns = 2, /*%< Authoritative server. */
- ns_t_md = 3, /*%< Mail destination. */
- ns_t_mf = 4, /*%< Mail forwarder. */
- ns_t_cname = 5, /*%< Canonical name. */
- ns_t_soa = 6, /*%< Start of authority zone. */
- ns_t_mb = 7, /*%< Mailbox domain name. */
- ns_t_mg = 8, /*%< Mail group member. */
- ns_t_mr = 9, /*%< Mail rename name. */
- ns_t_null = 10, /*%< Null resource record. */
- ns_t_wks = 11, /*%< Well known service. */
- ns_t_ptr = 12, /*%< Domain name pointer. */
- ns_t_hinfo = 13, /*%< Host information. */
- ns_t_minfo = 14, /*%< Mailbox information. */
- ns_t_mx = 15, /*%< Mail routing information. */
- ns_t_txt = 16, /*%< Text strings. */
- ns_t_rp = 17, /*%< Responsible person. */
- ns_t_afsdb = 18, /*%< AFS cell database. */
- ns_t_x25 = 19, /*%< X_25 calling address. */
- ns_t_isdn = 20, /*%< ISDN calling address. */
- ns_t_rt = 21, /*%< Router. */
- ns_t_nsap = 22, /*%< NSAP address. */
- ns_t_nsap_ptr = 23, /*%< Reverse NSAP lookup (deprecated). */
- ns_t_sig = 24, /*%< Security signature. */
- ns_t_key = 25, /*%< Security key. */
- ns_t_px = 26, /*%< X.400 mail mapping. */
- ns_t_gpos = 27, /*%< Geographical position (withdrawn). */
- ns_t_aaaa = 28, /*%< Ip6 Address. */
- ns_t_loc = 29, /*%< Location Information. */
- ns_t_nxt = 30, /*%< Next domain (security). */
- ns_t_eid = 31, /*%< Endpoint identifier. */
- ns_t_nimloc = 32, /*%< Nimrod Locator. */
- ns_t_srv = 33, /*%< Server Selection. */
- ns_t_atma = 34, /*%< ATM Address */
- ns_t_naptr = 35, /*%< Naming Authority PoinTeR */
- ns_t_kx = 36, /*%< Key Exchange */
- ns_t_cert = 37, /*%< Certification record */
- ns_t_a6 = 38, /*%< IPv6 address (deprecated, use ns_t_aaaa) */
- ns_t_dname = 39, /*%< Non-terminal DNAME (for IPv6) */
- ns_t_sink = 40, /*%< Kitchen sink (experimentatl) */
- ns_t_opt = 41, /*%< EDNS0 option (meta-RR) */
- ns_t_apl = 42, /*%< Address prefix list (RFC3123) */
- ns_t_tkey = 249, /*%< Transaction key */
- ns_t_tsig = 250, /*%< Transaction signature. */
- ns_t_ixfr = 251, /*%< Incremental zone transfer. */
- ns_t_axfr = 252, /*%< Transfer zone of authority. */
- ns_t_mailb = 253, /*%< Transfer mailbox records. */
- ns_t_maila = 254, /*%< Transfer mail agent records. */
- ns_t_any = 255, /*%< Wildcard match. */
- ns_t_zxfr = 256, /*%< BIND-specific, nonstandard. */
- ns_t_max = 65536
-} ns_type;
-
-/* Exclusively a QTYPE? (not also an RTYPE) */
-#define ns_t_qt_p(t) (ns_t_xfr_p(t) || (t) == ns_t_any || \
- (t) == ns_t_mailb || (t) == ns_t_maila)
-/* Some kind of meta-RR? (not a QTYPE, but also not an RTYPE) */
-#define ns_t_mrr_p(t) ((t) == ns_t_tsig || (t) == ns_t_opt)
-/* Exclusively an RTYPE? (not also a QTYPE or a meta-RR) */
-#define ns_t_rr_p(t) (!ns_t_qt_p(t) && !ns_t_mrr_p(t))
-#define ns_t_udp_p(t) ((t) != ns_t_axfr && (t) != ns_t_zxfr)
-#define ns_t_xfr_p(t) ((t) == ns_t_axfr || (t) == ns_t_ixfr || \
- (t) == ns_t_zxfr)
-
-/*%
- * Values for class field
- */
-typedef enum __ns_class {
- ns_c_invalid = 0, /*%< Cookie. */
- ns_c_in = 1, /*%< Internet. */
- ns_c_2 = 2, /*%< unallocated/unsupported. */
- ns_c_chaos = 3, /*%< MIT Chaos-net. */
- ns_c_hs = 4, /*%< MIT Hesiod. */
- /* Query class values which do not appear in resource records */
- ns_c_none = 254, /*%< for prereq. sections in update requests */
- ns_c_any = 255, /*%< Wildcard match. */
- ns_c_max = 65536
-} ns_class;
-
-/* DNSSEC constants. */
-
-typedef enum __ns_key_types {
- ns_kt_rsa = 1, /*%< key type RSA/MD5 */
- ns_kt_dh = 2, /*%< Diffie Hellman */
- ns_kt_dsa = 3, /*%< Digital Signature Standard (MANDATORY) */
- ns_kt_private = 254 /*%< Private key type starts with OID */
-} ns_key_types;
-
-typedef enum __ns_cert_types {
- cert_t_pkix = 1, /*%< PKIX (X.509v3) */
- cert_t_spki = 2, /*%< SPKI */
- cert_t_pgp = 3, /*%< PGP */
- cert_t_url = 253, /*%< URL private type */
- cert_t_oid = 254 /*%< OID private type */
-} ns_cert_types;
-
-/* Flags field of the KEY RR rdata. */
-#define NS_KEY_TYPEMASK 0xC000 /*%< Mask for "type" bits */
-#define NS_KEY_TYPE_AUTH_CONF 0x0000 /*%< Key usable for both */
-#define NS_KEY_TYPE_CONF_ONLY 0x8000 /*%< Key usable for confidentiality */
-#define NS_KEY_TYPE_AUTH_ONLY 0x4000 /*%< Key usable for authentication */
-#define NS_KEY_TYPE_NO_KEY 0xC000 /*%< No key usable for either; no key */
-/* The type bits can also be interpreted independently, as single bits: */
-#define NS_KEY_NO_AUTH 0x8000 /*%< Key unusable for authentication */
-#define NS_KEY_NO_CONF 0x4000 /*%< Key unusable for confidentiality */
-#define NS_KEY_RESERVED2 0x2000 /* Security is *mandatory* if bit=0 */
-#define NS_KEY_EXTENDED_FLAGS 0x1000 /*%< reserved - must be zero */
-#define NS_KEY_RESERVED4 0x0800 /*%< reserved - must be zero */
-#define NS_KEY_RESERVED5 0x0400 /*%< reserved - must be zero */
-#define NS_KEY_NAME_TYPE 0x0300 /*%< these bits determine the type */
-#define NS_KEY_NAME_USER 0x0000 /*%< key is assoc. with user */
-#define NS_KEY_NAME_ENTITY 0x0200 /*%< key is assoc. with entity eg host */
-#define NS_KEY_NAME_ZONE 0x0100 /*%< key is zone key */
-#define NS_KEY_NAME_RESERVED 0x0300 /*%< reserved meaning */
-#define NS_KEY_RESERVED8 0x0080 /*%< reserved - must be zero */
-#define NS_KEY_RESERVED9 0x0040 /*%< reserved - must be zero */
-#define NS_KEY_RESERVED10 0x0020 /*%< reserved - must be zero */
-#define NS_KEY_RESERVED11 0x0010 /*%< reserved - must be zero */
-#define NS_KEY_SIGNATORYMASK 0x000F /*%< key can sign RR's of same name */
-#define NS_KEY_RESERVED_BITMASK ( NS_KEY_RESERVED2 | \
- NS_KEY_RESERVED4 | \
- NS_KEY_RESERVED5 | \
- NS_KEY_RESERVED8 | \
- NS_KEY_RESERVED9 | \
- NS_KEY_RESERVED10 | \
- NS_KEY_RESERVED11 )
-#define NS_KEY_RESERVED_BITMASK2 0xFFFF /*%< no bits defined here */
-/* The Algorithm field of the KEY and SIG RR's is an integer, {1..254} */
-#define NS_ALG_MD5RSA 1 /*%< MD5 with RSA */
-#define NS_ALG_DH 2 /*%< Diffie Hellman KEY */
-#define NS_ALG_DSA 3 /*%< DSA KEY */
-#define NS_ALG_DSS NS_ALG_DSA
-#define NS_ALG_EXPIRE_ONLY 253 /*%< No alg, no security */
-#define NS_ALG_PRIVATE_OID 254 /*%< Key begins with OID giving alg */
-/* Protocol values */
-/* value 0 is reserved */
-#define NS_KEY_PROT_TLS 1
-#define NS_KEY_PROT_EMAIL 2
-#define NS_KEY_PROT_DNSSEC 3
-#define NS_KEY_PROT_IPSEC 4
-#define NS_KEY_PROT_ANY 255
-
-/* Signatures */
-#define NS_MD5RSA_MIN_BITS 512 /*%< Size of a mod or exp in bits */
-#define NS_MD5RSA_MAX_BITS 4096
- /* Total of binary mod and exp */
-#define NS_MD5RSA_MAX_BYTES ((NS_MD5RSA_MAX_BITS+7/8)*2+3)
- /* Max length of text sig block */
-#define NS_MD5RSA_MAX_BASE64 (((NS_MD5RSA_MAX_BYTES+2)/3)*4)
-#define NS_MD5RSA_MIN_SIZE ((NS_MD5RSA_MIN_BITS+7)/8)
-#define NS_MD5RSA_MAX_SIZE ((NS_MD5RSA_MAX_BITS+7)/8)
-
-#define NS_DSA_SIG_SIZE 41
-#define NS_DSA_MIN_SIZE 213
-#define NS_DSA_MAX_BYTES 405
-
-/* Offsets into SIG record rdata to find various values */
-#define NS_SIG_TYPE 0 /*%< Type flags */
-#define NS_SIG_ALG 2 /*%< Algorithm */
-#define NS_SIG_LABELS 3 /*%< How many labels in name */
-#define NS_SIG_OTTL 4 /*%< Original TTL */
-#define NS_SIG_EXPIR 8 /*%< Expiration time */
-#define NS_SIG_SIGNED 12 /*%< Signature time */
-#define NS_SIG_FOOT 16 /*%< Key footprint */
-#define NS_SIG_SIGNER 18 /*%< Domain name of who signed it */
-/* How RR types are represented as bit-flags in NXT records */
-#define NS_NXT_BITS 8
-#define NS_NXT_BIT_SET( n,p) (p[(n)/NS_NXT_BITS] |= (0x80>>((n)%NS_NXT_BITS)))
-#define NS_NXT_BIT_CLEAR(n,p) (p[(n)/NS_NXT_BITS] &= ~(0x80>>((n)%NS_NXT_BITS)))
-#define NS_NXT_BIT_ISSET(n,p) (p[(n)/NS_NXT_BITS] & (0x80>>((n)%NS_NXT_BITS)))
-#define NS_NXT_MAX 127
-
-/*%
- * EDNS0 extended flags and option codes, host order.
- */
-#define NS_OPT_DNSSEC_OK 0x8000U
-#define NS_OPT_NSID 3
-
-/*%
- * Inline versions of get/put short/long. Pointer is advanced.
- */
-#define NS_GET16(s, cp) do { \
- register const u_char *t_cp = (const u_char *)(cp); \
- (s) = ((u_int16_t)t_cp[0] << 8) \
- | ((u_int16_t)t_cp[1]) \
- ; \
- (cp) += NS_INT16SZ; \
-} while (0)
-
-#define NS_GET32(l, cp) do { \
- register const u_char *t_cp = (const u_char *)(cp); \
- (l) = ((u_int32_t)t_cp[0] << 24) \
- | ((u_int32_t)t_cp[1] << 16) \
- | ((u_int32_t)t_cp[2] << 8) \
- | ((u_int32_t)t_cp[3]) \
- ; \
- (cp) += NS_INT32SZ; \
-} while (0)
-
-#define NS_PUT16(s, cp) do { \
- register u_int16_t t_s = (u_int16_t)(s); \
- register u_char *t_cp = (u_char *)(cp); \
- *t_cp++ = t_s >> 8; \
- *t_cp = t_s; \
- (cp) += NS_INT16SZ; \
-} while (0)
-
-#define NS_PUT32(l, cp) do { \
- register u_int32_t t_l = (u_int32_t)(l); \
- register u_char *t_cp = (u_char *)(cp); \
- *t_cp++ = t_l >> 24; \
- *t_cp++ = t_l >> 16; \
- *t_cp++ = t_l >> 8; \
- *t_cp = t_l; \
- (cp) += NS_INT32SZ; \
-} while (0)
-
-__BEGIN_DECLS
-int ns_msg_getflag (ns_msg, int) __THROW;
-u_int ns_get16 (const u_char *) __THROW;
-u_long ns_get32 (const u_char *) __THROW;
-void ns_put16 (u_int, u_char *) __THROW;
-void ns_put32 (u_long, u_char *) __THROW;
-int ns_initparse (const u_char *, int, ns_msg *) __THROW;
-int ns_skiprr (const u_char *, const u_char *, ns_sect, int)
- __THROW;
-int ns_parserr (ns_msg *, ns_sect, int, ns_rr *) __THROW;
-int ns_sprintrr (const ns_msg *, const ns_rr *,
- const char *, const char *, char *, size_t)
- __THROW;
-int ns_sprintrrf (const u_char *, size_t, const char *,
- ns_class, ns_type, u_long, const u_char *,
- size_t, const char *, const char *,
- char *, size_t) __THROW;
-int ns_format_ttl (u_long, char *, size_t) __THROW;
-int ns_parse_ttl (const char *, u_long *) __THROW;
-u_int32_t ns_datetosecs (const char *, int *) __THROW;
-int ns_name_ntol (const u_char *, u_char *, size_t) __THROW;
-int ns_name_ntop (const u_char *, char *, size_t) __THROW;
-int ns_name_pton (const char *, u_char *, size_t) __THROW;
-int ns_name_unpack (const u_char *, const u_char *,
- const u_char *, u_char *, size_t) __THROW;
-int ns_name_pack (const u_char *, u_char *, int,
- const u_char **, const u_char **) __THROW;
-int ns_name_uncompress (const u_char *, const u_char *,
- const u_char *, char *, size_t) __THROW;
-int ns_name_compress (const char *, u_char *, size_t,
- const u_char **, const u_char **) __THROW;
-int ns_name_skip (const u_char **, const u_char *) __THROW;
-void ns_name_rollback (const u_char *, const u_char **,
- const u_char **) __THROW;
-int ns_sign (u_char *, int *, int, int, void *,
- const u_char *, int, u_char *, int *, time_t) __THROW;
-int ns_sign2 (u_char *, int *, int, int, void *,
- const u_char *, int, u_char *, int *, time_t,
- u_char **, u_char **) __THROW;
-int ns_sign_tcp (u_char *, int *, int, int,
- ns_tcp_tsig_state *, int) __THROW;
-int ns_sign_tcp2 (u_char *, int *, int, int,
- ns_tcp_tsig_state *, int,
- u_char **, u_char **) __THROW;
-int ns_sign_tcp_init (void *, const u_char *, int,
- ns_tcp_tsig_state *) __THROW;
-u_char *ns_find_tsig (u_char *, u_char *) __THROW;
-int ns_verify (u_char *, int *, void *, const u_char *, int,
- u_char *, int *, time_t *, int) __THROW;
-int ns_verify_tcp (u_char *, int *, ns_tcp_tsig_state *, int)
- __THROW;
-int ns_verify_tcp_init (void *, const u_char *, int,
- ns_tcp_tsig_state *) __THROW;
-int ns_samedomain (const char *, const char *) __THROW;
-int ns_subdomain (const char *, const char *) __THROW;
-int ns_makecanon (const char *, char *, size_t) __THROW;
-int ns_samename (const char *, const char *) __THROW;
-__END_DECLS
-
-#ifdef BIND_4_COMPAT
-#include <arpa/nameser_compat.h>
-#endif
-
-#endif /* !_ARPA_NAMESER_H_ */
-/*! \file */
diff --git a/system/include/net/arpa/nameser_compat.h b/system/include/net/arpa/nameser_compat.h
deleted file mode 100644
index d59c9e41..00000000
--- a/system/include/net/arpa/nameser_compat.h
+++ /dev/null
@@ -1,187 +0,0 @@
-/* Copyright (c) 1983, 1989
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*%
- * from nameser.h 8.1 (Berkeley) 6/2/93
- * $BINDId: nameser_compat.h,v 8.11 1999/01/02 08:00:58 vixie Exp $
- */
-
-#ifndef _ARPA_NAMESER_COMPAT_
-#define _ARPA_NAMESER_COMPAT_
-
-#define __BIND 19950621 /*%< (DEAD) interface version stamp. */
-
-#include <endian.h>
-
-/*%
- * Structure for query header. The order of the fields is machine- and
- * compiler-dependent, depending on the byte/bit order and the layout
- * of bit fields. We use bit fields only in int variables, as this
- * is all ANSI requires. This requires a somewhat confusing rearrangement.
- */
-
-typedef struct {
- unsigned id :16; /*%< query identification number */
-#if BYTE_ORDER == BIG_ENDIAN
- /* fields in third byte */
- unsigned qr: 1; /*%< response flag */
- unsigned opcode: 4; /*%< purpose of message */
- unsigned aa: 1; /*%< authoritive answer */
- unsigned tc: 1; /*%< truncated message */
- unsigned rd: 1; /*%< recursion desired */
- /* fields in fourth byte */
- unsigned ra: 1; /*%< recursion available */
- unsigned unused :1; /*%< unused bits (MBZ as of 4.9.3a3) */
- unsigned ad: 1; /*%< authentic data from named */
- unsigned cd: 1; /*%< checking disabled by resolver */
- unsigned rcode :4; /*%< response code */
-#endif
-#if BYTE_ORDER == LITTLE_ENDIAN || BYTE_ORDER == PDP_ENDIAN
- /* fields in third byte */
- unsigned rd :1; /*%< recursion desired */
- unsigned tc :1; /*%< truncated message */
- unsigned aa :1; /*%< authoritive answer */
- unsigned opcode :4; /*%< purpose of message */
- unsigned qr :1; /*%< response flag */
- /* fields in fourth byte */
- unsigned rcode :4; /*%< response code */
- unsigned cd: 1; /*%< checking disabled by resolver */
- unsigned ad: 1; /*%< authentic data from named */
- unsigned unused :1; /*%< unused bits (MBZ as of 4.9.3a3) */
- unsigned ra :1; /*%< recursion available */
-#endif
- /* remaining bytes */
- unsigned qdcount :16; /*%< number of question entries */
- unsigned ancount :16; /*%< number of answer entries */
- unsigned nscount :16; /*%< number of authority entries */
- unsigned arcount :16; /*%< number of resource entries */
-} HEADER;
-
-#define PACKETSZ NS_PACKETSZ
-#define MAXDNAME NS_MAXDNAME
-#define MAXCDNAME NS_MAXCDNAME
-#define MAXLABEL NS_MAXLABEL
-#define HFIXEDSZ NS_HFIXEDSZ
-#define QFIXEDSZ NS_QFIXEDSZ
-#define RRFIXEDSZ NS_RRFIXEDSZ
-#define INT32SZ NS_INT32SZ
-#define INT16SZ NS_INT16SZ
-#define INT8SZ NS_INT8SZ
-#define INADDRSZ NS_INADDRSZ
-#define IN6ADDRSZ NS_IN6ADDRSZ
-#define INDIR_MASK NS_CMPRSFLGS
-#define NAMESERVER_PORT NS_DEFAULTPORT
-
-#define S_ZONE ns_s_zn
-#define S_PREREQ ns_s_pr
-#define S_UPDATE ns_s_ud
-#define S_ADDT ns_s_ar
-
-#define QUERY ns_o_query
-#define IQUERY ns_o_iquery
-#define STATUS ns_o_status
-#define NS_NOTIFY_OP ns_o_notify
-#define NS_UPDATE_OP ns_o_update
-
-#define NOERROR ns_r_noerror
-#define FORMERR ns_r_formerr
-#define SERVFAIL ns_r_servfail
-#define NXDOMAIN ns_r_nxdomain
-#define NOTIMP ns_r_notimpl
-#define REFUSED ns_r_refused
-#define YXDOMAIN ns_r_yxdomain
-#define YXRRSET ns_r_yxrrset
-#define NXRRSET ns_r_nxrrset
-#define NOTAUTH ns_r_notauth
-#define NOTZONE ns_r_notzone
-/*#define BADSIG ns_r_badsig*/
-/*#define BADKEY ns_r_badkey*/
-/*#define BADTIME ns_r_badtime*/
-
-
-#define DELETE ns_uop_delete
-#define ADD ns_uop_add
-
-#define T_A ns_t_a
-#define T_NS ns_t_ns
-#define T_MD ns_t_md
-#define T_MF ns_t_mf
-#define T_CNAME ns_t_cname
-#define T_SOA ns_t_soa
-#define T_MB ns_t_mb
-#define T_MG ns_t_mg
-#define T_MR ns_t_mr
-#define T_NULL ns_t_null
-#define T_WKS ns_t_wks
-#define T_PTR ns_t_ptr
-#define T_HINFO ns_t_hinfo
-#define T_MINFO ns_t_minfo
-#define T_MX ns_t_mx
-#define T_TXT ns_t_txt
-#define T_RP ns_t_rp
-#define T_AFSDB ns_t_afsdb
-#define T_X25 ns_t_x25
-#define T_ISDN ns_t_isdn
-#define T_RT ns_t_rt
-#define T_NSAP ns_t_nsap
-#define T_NSAP_PTR ns_t_nsap_ptr
-#define T_SIG ns_t_sig
-#define T_KEY ns_t_key
-#define T_PX ns_t_px
-#define T_GPOS ns_t_gpos
-#define T_AAAA ns_t_aaaa
-#define T_LOC ns_t_loc
-#define T_NXT ns_t_nxt
-#define T_EID ns_t_eid
-#define T_NIMLOC ns_t_nimloc
-#define T_SRV ns_t_srv
-#define T_ATMA ns_t_atma
-#define T_NAPTR ns_t_naptr
-#define T_A6 ns_t_a6
-#define T_DNAME ns_t_dname
-#define T_TSIG ns_t_tsig
-#define T_IXFR ns_t_ixfr
-#define T_AXFR ns_t_axfr
-#define T_MAILB ns_t_mailb
-#define T_MAILA ns_t_maila
-#define T_ANY ns_t_any
-
-#define C_IN ns_c_in
-#define C_CHAOS ns_c_chaos
-#define C_HS ns_c_hs
-/* BIND_UPDATE */
-#define C_NONE ns_c_none
-#define C_ANY ns_c_any
-
-#define GETSHORT NS_GET16
-#define GETLONG NS_GET32
-#define PUTSHORT NS_PUT16
-#define PUTLONG NS_PUT32
-
-#endif /* _ARPA_NAMESER_COMPAT_ */
-/*! \file */
diff --git a/system/include/net/if.h b/system/include/net/if.h
deleted file mode 100644
index 0ef18520..00000000
--- a/system/include/net/if.h
+++ /dev/null
@@ -1,106 +0,0 @@
-
-#ifndef _NET_IF_H
-#define _NET_IF_H
-
-#include <sys/socket.h>
-#include <sys/types.h>
-#include <sys/ioctl.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct if_nameindex {
- unsigned if_index;
- char *if_name;
-};
-
-#define IFHWADDRLEN 6
-#define IFNAMSIZ 16
-
-struct ifmap {
- unsigned long int mem_start;
- unsigned long int mem_end;
- unsigned short int base_addr;
- unsigned char irq;
- unsigned char dma;
- unsigned char port;
-};
-
-struct ifreq {
- union {
- char ifrn_name[IFNAMSIZ];
- } ifr_ifrn;
- union {
- struct sockaddr ifru_addr;
- struct sockaddr ifru_destaddr;
- struct sockaddr ifru_broadaddr;
- struct sockaddr ifru_netmask;
- struct sockaddr ifru_hwaddr;
- short int ifru_flags;
- int ifru_ivalue;
- int ifru_mtu;
- struct ifmap ifru_map;
- char ifru_slave[IFNAMSIZ];
- char ifru_newname[IFNAMSIZ];
- caddr_t ifru_data;
- } ifr_ifru;
-};
-#define ifr_name ifr_ifrn.ifrn_name
-#define ifr_addr ifr_ifru.ifru_addr
-#define ifr_destaddr ifr_ifru.ifru_destaddr
-#define ifr_broadaddr ifr_ifru.ifru_broadaddr
-#define ifr_netmask ifr_ifru.ifru_netmask
-#define ifr_hwaddr ifr_ifru.ifru_hwaddr
-#define ifr_flags ifr_ifru.ifru_flags
-#define ifr_ivalue ifr_ifru.ifru_ivalue
-#define ifr_mtu ifr_ifru.ifru_mtu
-#define ifr_map ifr_ifru.ifru_map
-#define ifr_slave ifr_ifru.ifru_slave
-#define ifr_newname ifr_ifru.ifru_newname
-#define ifr_data ifr_ifru.ifru_data
-
-struct ifconf {
- int ifc_len;
- union {
- caddr_t ifcu_buf;
- struct ifreq* ifcu_req;
- } ifc_ifcu;
-};
-#define ifc_buf ifc_ifcu.ifcu_buf
-#define ifc_req ifc_ifcu.ifcu_req
-
-#define IF_NAMESIZE abort(0);
-
-unsigned if_nametoindex(const char *a);
-char *if_indextoname(unsigned int a, char *b);
-struct if_nameindex *if_nameindex();
-void if_freenameindex(struct if_nameindex *a);
-
-#define IFF_UP 0x1
-#define IFF_BROADCAST 0x2
-#define IFF_DEBUG 0x4
-#define IFF_LOOPBACK 0x8
-#define IFF_POINTOPOINT 0x10
-#define IFF_NOTRAILERS 0x20
-#define IFF_RUNNING 0x40
-#define IFF_NOARP 0x80
-#define IFF_PROMISC 0x100
-#define IFF_ALLMULTI 0x200
-#define IFF_MASTER 0x400
-#define IFF_SLAVE 0x800
-#define IFF_MULTICAST 0x1000
-#define IFF_PORTSEL 0x2000
-#define IFF_AUTOMEDIA 0x4000
-#define IFF_DYNAMIC 0x8000
-#define IFF_LOWER_UP 0x10000
-#define IFF_DORMANT 0x20000
-#define IFF_ECHO 0x40000
-#define IFF_VOLATILE (IFF_LOOPBACK|IFF_POINTOPOINT|IFF_BROADCAST|IFF_ECHO|IFF_MASTER|IFF_SLAVE|IFF_RUNNING|IFF_LOWER_UP|IFF_DORMANT)
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
diff --git a/system/include/net/netinet/in.h b/system/include/net/netinet/in.h
deleted file mode 100644
index 1d3952f5..00000000
--- a/system/include/net/netinet/in.h
+++ /dev/null
@@ -1,230 +0,0 @@
-
-#ifndef _NET_NETINET_IN_H
-#define _NET_NETINET_IN_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <arpa/inet.h>
-#include <stdint.h>
-
-enum {
- IPPROTO_IP = 0,
-#define IPPROTO_IP IPPROTO_IP
- IPPROTO_HOPOPTS = 0,
-#define IPPROTO_HOPOPTS IPPROTO_HOPOPTS
- IPPROTO_ICMP = 1,
-#define IPPROTO_ICMP IPPROTO_ICMP
- IPPROTO_IGMP = 2,
-#define IPPROTO_IGMP IPPROTO_IGMP
- IPPROTO_IPIP = 4,
-#define IPPROTO_IPIP IPPROTO_IPIP
- IPPROTO_TCP = 6,
-#define IPPROTO_TCP IPPROTO_TCP
- IPPROTO_EGP = 8,
-#define IPPROTO_EGP IPPROTO_EGP
- IPPROTO_PUP = 12,
-#define IPPROTO_PUP IPPROTO_PUP
- IPPROTO_UDP = 17,
-#define IPPROTO_UDP IPPROTO_UDP
- IPPROTO_IDP = 22,
-#define IPPROTO_IDP IPPROTO_IDP
- IPPROTO_TP = 29,
-#define IPPROTO_TP IPPROTO_TP
- IPPROTO_DCCP = 33,
-#define IPPROTO_DCCP IPPROTO_DCCP
- IPPROTO_IPV6 = 41,
-#define IPPROTO_IPV6 IPPROTO_IPV6
- IPPROTO_ROUTING = 43,
-#define IPPROTO_ROUTING IPPROTO_ROUTING
- IPPROTO_FRAGMENT = 44,
-#define IPPROTO_FRAGMENT IPPROTO_FRAGMENT
- IPPROTO_RSVP = 46,
-#define IPPROTO_RSVP IPPROTO_RSVP
- IPPROTO_GRE = 47,
-#define IPPROTO_GRE IPPROTO_GRE
- IPPROTO_ESP = 50,
-#define IPPROTO_ESP IPPROTO_ESP
- IPPROTO_AH = 51,
-#define IPPROTO_AH IPPROTO_AH
- IPPROTO_ICMPV6 = 58,
-#define IPPROTO_ICMPV6 IPPROTO_ICMPV6
- IPPROTO_NONE = 59,
-#define IPPROTO_NONE IPPROTO_NONE
- IPPROTO_DSTOPTS = 60,
-#define IPPROTO_DSTOPTS IPPROTO_DSTOPTS
- IPPROTO_MTP = 92,
-#define IPPROTO_MTP IPPROTO_MTP
- IPPROTO_ENCAP = 98,
-#define IPPROTO_ENCAP IPPROTO_ENCAP
- IPPROTO_PIM = 103,
-#define IPPROTO_PIM IPPROTO_PIM
- IPPROTO_COMP = 108,
-#define IPPROTO_COMP IPPROTO_COMP
- IPPROTO_SCTP = 132,
-#define IPPROTO_SCTP IPPROTO_SCTP
- IPPROTO_UDPLITE = 136,
-#define IPPROTO_UDPLITE IPPROTO_UDPLITE
- IPPROTO_RAW = 255,
-#define IPPROTO_RAW IPPROTO_RAW
- IPPROTO_MAX
-};
-
-#define INET_ADDRSTRLEN 16
-#define INET6_ADDRSTRLEN 46
-
-#define INADDR_ANY 0
-#define INADDR_LOOPBACK 0x7f000001 /* 127.0.0.1 */
-
-struct in_addr {
- unsigned long s_addr;
-};
-
-struct sockaddr_in {
- int sin_family;
- unsigned short sin_port;
- struct in_addr sin_addr;
- char sin_zero[6];
-};
-
-struct in6_addr {
- union {
- uint8_t _s6_addr8[16];
- uint16_t _s6_addr16[8];
- uint32_t _s6_addr32[4];
- } _u;
-#define s6_addr _u._s6_addr8
-#define s6_addr16 _u._s6_addr16
-#define s6_addr32 _u._s6_addr32
-};
-
-extern const struct in6_addr in6addr_any;
-extern const struct in6_addr in6addr_loopback;
-extern const struct in6_addr in6addr_linklocal_allnodes;
-extern const struct in6_addr in6addr_linklocal_allrouters;
-extern const struct in6_addr in6addr_interfacelocal_allnodes;
-extern const struct in6_addr in6addr_interfacelocal_allrouters;
-extern const struct in6_addr in6addr_sitelocal_allrouters;
-
-#define IN6ADDR_ANY_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } }
-#define IN6ADDR_LOOPBACK_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } }
-#define IN6ADDR_LINKLOCAL_ALLNODES_INIT \
- { { { 0xff,2,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } }
-#define IN6ADDR_LINKLOCAL_ALLROUTERS_INIT \
- { { { 0xff,2,0,0,0,0,0,0,0,0,0,0,0,0,0,2 } } }
-
-struct sockaddr_in6 {
- int sin6_family;
- unsigned short sin6_port;
- int sin6_flowinfo;
- struct in6_addr sin6_addr;
- int sin6_scope_id;
-};
-
-struct ip_mreq {
- struct in_addr imr_multiaddr;
- struct in_addr imr_interface;
-};
-
-#define IP_PMTUDISC_DONT 0
-#define IP_PMTUDISC_WANT 1
-#define IP_PMTUDISC_DO 2
-#define IP_PMTUDISC_PROBE 3
-
-#define IP_MULTICAST_IF 32
-#define IP_MULTICAST_TTL 33
-#define IP_MULTICAST_LOOP 34
-#define IP_ADD_MEMBERSHIP 35
-#define IP_DROP_MEMBERSHIP 36
-#define IP_UNBLOCK_SOURCE 37
-#define IP_BLOCK_SOURCE 38
-#define IP_ADD_SOURCE_MEMBERSHIP 39
-#define IP_DROP_SOURCE_MEMBERSHIP 40
-#define IP_MSFILTER 41
-#define MCAST_JOIN_GROUP 42
-#define MCAST_BLOCK_SOURCE 43
-#define MCAST_UNBLOCK_SOURCE 44
-#define MCAST_LEAVE_GROUP 45
-#define MCAST_JOIN_SOURCE_GROUP 46
-#define MCAST_LEAVE_SOURCE_GROUP 47
-#define MCAST_MSFILTER 48
-#define IP_MULTICAST_ALL 49
-#define IP_UNICAST_IF 50
-
-/*
- * Tests for IPv6 address types
- */
-
-#define IN6_IS_ADDR_LINKLOCAL(addr) \
- (((addr)->s6_addr32[0] & htonl(0xffc00000)) == htonl(0xfe800000))
-
-#define IN6_IS_ADDR_LOOPBACK(addr) \
- (((addr)->s6_addr32[0] == 0) && ((addr)->s6_addr32[1] == 0) && \
- ((addr)->s6_addr32[2] == 0) && ((addr)->s6_addr32[3] == htonl(1)))
-
-#define IN6_IS_ADDR_MULTICAST(addr) \
- ((addr)->s6_addr8[0] == 0xff)
-
-#define IN6_IS_ADDR_SITELOCAL(addr) \
- (((addr)->s6_addr32[0] & htonl(0xffc00000)) == htonl(0xfec00000))
-
-#define IN6_IS_ADDR_UNSPECIFIED(addr) \
- (((addr)->s6_addr32[0] == 0) && ((addr)->s6_addr32[1] == 0) && \
- ((addr)->s6_addr32[2] == 0) && ((addr)->s6_addr32[3] == 0))
-
-#define IN6_IS_ADDR_V4COMPAT(addr) \
- (((addr)->s6_addr32[0] == 0) && ((addr)->s6_addr32[1] == 0) && \
- ((addr)->s6_addr32[2] == 0) && ((addr)->s6_addr32[3] & ~htonl(1)))
-
-#define IN6_IS_ADDR_V4MAPPED(addr) \
- (((addr)->s6_addr32[0] == 0) && ((addr)->s6_addr32[1] == 0) && \
- ((addr)->s6_addr32[2] == htonl(0xffff)))
-
-#define IN6_ARE_ADDR_EQUAL(addr1, addr2) \
- (((addr1)->s6_addr32[0] == (addr2)->s6_addr32[0]) && \
- ((addr1)->s6_addr32[1] == (addr2)->s6_addr32[1]) && \
- ((addr1)->s6_addr32[2] == (addr2)->s6_addr32[2]) && \
- ((addr1)->s6_addr32[3] == (addr2)->s6_addr32[3]))
-
-/*
- * IPv6 Multicast scoping. The scope is stored
- * in the bottom 4 bits of the second byte of the
- * multicast address.
- */
- /* 0x0 */ /* reserved */
-#define IN6_NODE_LOCAL 0x1 /* node-local scope */
-#define IN6_LINK_LOCAL 0x2 /* link-local scope */
- /* 0x3 */ /* (unassigned) */
- /* 0x4 */ /* (unassigned) */
-#define IN6_SITE_LOCAL 0x5 /* site-local scope */
- /* 0x6 */ /* (unassigned) */
- /* 0x7 */ /* (unassigned) */
-#define IN6_ORG_LOCAL 0x8 /* organization-local scope */
- /* 0x9 */ /* (unassigned) */
- /* 0xA */ /* (unassigned) */
- /* 0xB */ /* (unassigned) */
- /* 0xC */ /* (unassigned) */
- /* 0xD */ /* (unassigned) */
-#define IN6_GLOBAL 0xE /* global scope */
- /* 0xF */ /* reserved */
-
-#define IN6_MSCOPE(addr) ((addr)->s6_addr8[1] & 0x0f)
-
-#define IN6_IS_ADDR_MC_NODELOCAL(addr) \
- (IN6_IS_ADDR_MULTICAST(addr) && (IN6_MSCOPE(addr) == IN6_NODE_LOCAL))
-#define IN6_IS_ADDR_MC_LINKLOCAL(addr) \
- (IN6_IS_ADDR_MULTICAST(addr) && (IN6_MSCOPE(addr) == IN6_LINK_LOCAL))
-#define IN6_IS_ADDR_MC_SITELOCAL(addr) \
- (IN6_IS_ADDR_MULTICAST(addr) && (IN6_MSCOPE(addr) == IN6_SITE_LOCAL))
-#define IN6_IS_ADDR_MC_ORGLOCAL(addr) \
- (IN6_IS_ADDR_MULTICAST(addr) && (IN6_MSCOPE(addr) == IN6_ORG_LOCAL))
-#define IN6_IS_ADDR_MC_GLOBAL(addr) \
- (IN6_IS_ADDR_MULTICAST(addr) && (IN6_MSCOPE(addr) == IN6_GLOBAL))
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
diff --git a/system/include/net/netinet/tcp.h b/system/include/net/netinet/tcp.h
deleted file mode 100644
index 06e8414b..00000000
--- a/system/include/net/netinet/tcp.h
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * Copyright (c) 1982, 1986, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)tcp.h 8.1 (Berkeley) 6/10/93
- */
-
-#ifndef _NETINET_TCP_H
-#define _NETINET_TCP_H 1
-
-#include <features.h>
-
-/*
- * User-settable options (used with setsockopt).
- */
-#define TCP_NODELAY 1 /* Don't delay send to coalesce packets */
-#define TCP_MAXSEG 2 /* Set maximum segment size */
-#define TCP_CORK 3 /* Control sending of partial frames */
-#define TCP_KEEPIDLE 4 /* Start keeplives after this period */
-#define TCP_KEEPINTVL 5 /* Interval between keepalives */
-#define TCP_KEEPCNT 6 /* Number of keepalives before death */
-#define TCP_SYNCNT 7 /* Number of SYN retransmits */
-#define TCP_LINGER2 8 /* Life time of orphaned FIN-WAIT-2 state */
-#define TCP_DEFER_ACCEPT 9 /* Wake up listener only when data arrive */
-#define TCP_WINDOW_CLAMP 10 /* Bound advertised window */
-#define TCP_INFO 11 /* Information about this connection. */
-#define TCP_QUICKACK 12 /* Bock/reenable quick ACKs. */
-#define TCP_CONGESTION 13 /* Congestion control algorithm. */
-#define TCP_MD5SIG 14 /* TCP MD5 Signature (RFC2385) */
-
-#ifdef __USE_MISC
-# include <sys/types.h>
-# include <sys/socket.h>
-
-# ifdef __FAVOR_BSD
-typedef u_int32_t tcp_seq;
-/*
- * TCP header.
- * Per RFC 793, September, 1981.
- */
-struct tcphdr
- {
- u_int16_t th_sport; /* source port */
- u_int16_t th_dport; /* destination port */
- tcp_seq th_seq; /* sequence number */
- tcp_seq th_ack; /* acknowledgement number */
-# if __BYTE_ORDER == __LITTLE_ENDIAN
- u_int8_t th_x2:4; /* (unused) */
- u_int8_t th_off:4; /* data offset */
-# endif
-# if __BYTE_ORDER == __BIG_ENDIAN
- u_int8_t th_off:4; /* data offset */
- u_int8_t th_x2:4; /* (unused) */
-# endif
- u_int8_t th_flags;
-# define TH_FIN 0x01
-# define TH_SYN 0x02
-# define TH_RST 0x04
-# define TH_PUSH 0x08
-# define TH_ACK 0x10
-# define TH_URG 0x20
- u_int16_t th_win; /* window */
- u_int16_t th_sum; /* checksum */
- u_int16_t th_urp; /* urgent pointer */
-};
-
-# else /* !__FAVOR_BSD */
-struct tcphdr
- {
- u_int16_t source;
- u_int16_t dest;
- u_int32_t seq;
- u_int32_t ack_seq;
-# if __BYTE_ORDER == __LITTLE_ENDIAN
- u_int16_t res1:4;
- u_int16_t doff:4;
- u_int16_t fin:1;
- u_int16_t syn:1;
- u_int16_t rst:1;
- u_int16_t psh:1;
- u_int16_t ack:1;
- u_int16_t urg:1;
- u_int16_t res2:2;
-# elif __BYTE_ORDER == __BIG_ENDIAN
- u_int16_t doff:4;
- u_int16_t res1:4;
- u_int16_t res2:2;
- u_int16_t urg:1;
- u_int16_t ack:1;
- u_int16_t psh:1;
- u_int16_t rst:1;
- u_int16_t syn:1;
- u_int16_t fin:1;
-# else
-# error "Adjust your <bits/endian.h> defines"
-# endif
- u_int16_t window;
- u_int16_t check;
- u_int16_t urg_ptr;
-};
-# endif /* __FAVOR_BSD */
-
-enum
-{
- TCP_ESTABLISHED = 1,
- TCP_SYN_SENT,
- TCP_SYN_RECV,
- TCP_FIN_WAIT1,
- TCP_FIN_WAIT2,
- TCP_TIME_WAIT,
- TCP_CLOSE,
- TCP_CLOSE_WAIT,
- TCP_LAST_ACK,
- TCP_LISTEN,
- TCP_CLOSING /* now a valid state */
-};
-
-# define TCPOPT_EOL 0
-# define TCPOPT_NOP 1
-# define TCPOPT_MAXSEG 2
-# define TCPOLEN_MAXSEG 4
-# define TCPOPT_WINDOW 3
-# define TCPOLEN_WINDOW 3
-# define TCPOPT_SACK_PERMITTED 4 /* Experimental */
-# define TCPOLEN_SACK_PERMITTED 2
-# define TCPOPT_SACK 5 /* Experimental */
-# define TCPOPT_TIMESTAMP 8
-# define TCPOLEN_TIMESTAMP 10
-# define TCPOLEN_TSTAMP_APPA (TCPOLEN_TIMESTAMP+2) /* appendix A */
-
-# define TCPOPT_TSTAMP_HDR \
- (TCPOPT_NOP<<24|TCPOPT_NOP<<16|TCPOPT_TIMESTAMP<<8|TCPOLEN_TIMESTAMP)
-
-/*
- * Default maximum segment size for TCP.
- * With an IP MSS of 576, this is 536,
- * but 512 is probably more convenient.
- * This should be defined as MIN(512, IP_MSS - sizeof (struct tcpiphdr)).
- */
-# define TCP_MSS 512
-
-# define TCP_MAXWIN 65535 /* largest value for (unscaled) window */
-
-# define TCP_MAX_WINSHIFT 14 /* maximum window shift */
-
-# define SOL_TCP 6 /* TCP level */
-
-
-# define TCPI_OPT_TIMESTAMPS 1
-# define TCPI_OPT_SACK 2
-# define TCPI_OPT_WSCALE 4
-# define TCPI_OPT_ECN 8
-
-/* Values for tcpi_state. */
-enum tcp_ca_state
-{
- TCP_CA_Open = 0,
- TCP_CA_Disorder = 1,
- TCP_CA_CWR = 2,
- TCP_CA_Recovery = 3,
- TCP_CA_Loss = 4
-};
-
-struct tcp_info
-{
- u_int8_t tcpi_state;
- u_int8_t tcpi_ca_state;
- u_int8_t tcpi_retransmits;
- u_int8_t tcpi_probes;
- u_int8_t tcpi_backoff;
- u_int8_t tcpi_options;
- u_int8_t tcpi_snd_wscale : 4, tcpi_rcv_wscale : 4;
-
- u_int32_t tcpi_rto;
- u_int32_t tcpi_ato;
- u_int32_t tcpi_snd_mss;
- u_int32_t tcpi_rcv_mss;
-
- u_int32_t tcpi_unacked;
- u_int32_t tcpi_sacked;
- u_int32_t tcpi_lost;
- u_int32_t tcpi_retrans;
- u_int32_t tcpi_fackets;
-
- /* Times. */
- u_int32_t tcpi_last_data_sent;
- u_int32_t tcpi_last_ack_sent; /* Not remembered, sorry. */
- u_int32_t tcpi_last_data_recv;
- u_int32_t tcpi_last_ack_recv;
-
- /* Metrics. */
- u_int32_t tcpi_pmtu;
- u_int32_t tcpi_rcv_ssthresh;
- u_int32_t tcpi_rtt;
- u_int32_t tcpi_rttvar;
- u_int32_t tcpi_snd_ssthresh;
- u_int32_t tcpi_snd_cwnd;
- u_int32_t tcpi_advmss;
- u_int32_t tcpi_reordering;
-
- u_int32_t tcpi_rcv_rtt;
- u_int32_t tcpi_rcv_space;
-
- u_int32_t tcpi_total_retrans;
-};
-
-
-/* For TCP_MD5SIG socket option. */
-#define TCP_MD5SIG_MAXKEYLEN 80
-
-struct tcp_md5sig
-{
- struct sockaddr_storage tcpm_addr; /* Address associated. */
- u_int16_t __tcpm_pad1; /* Zero. */
- u_int16_t tcpm_keylen; /* Key length. */
- u_int32_t __tcpm_pad2; /* Zero. */
- u_int8_t tcpm_key[TCP_MD5SIG_MAXKEYLEN]; /* Key (binary). */
-};
-
-#endif /* Misc. */
-
-#endif /* netinet/tcp.h */
diff --git a/system/include/net/resolv.h b/system/include/net/resolv.h
deleted file mode 100644
index ed15a702..00000000
--- a/system/include/net/resolv.h
+++ /dev/null
@@ -1,389 +0,0 @@
-/*
- * Copyright (c) 1983, 1987, 1989
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*
- * Portions Copyright (c) 1996-1999 by Internet Software Consortium.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
- * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
- * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
- * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
- * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
- * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- */
-
-/*
- * @(#)resolv.h 8.1 (Berkeley) 6/2/93
- * $BINDId: resolv.h,v 8.31 2000/03/30 20:16:50 vixie Exp $
- */
-
-#ifndef _RESOLV_H_
-
-/* These headers are needed for types used in the `struct res_state'
- declaration. */
-#include <sys/types.h>
-#include <netinet/in.h>
-
-#ifndef __need_res_state
-# define _RESOLV_H_
-
-# include <sys/param.h>
-# include <sys/cdefs.h>
-# include <stdio.h>
-# include <arpa/nameser.h>
-#endif
-
-#ifndef __res_state_defined
-# define __res_state_defined
-
-typedef enum { res_goahead, res_nextns, res_modified, res_done, res_error }
- res_sendhookact;
-
-typedef res_sendhookact (*res_send_qhook) (struct sockaddr_in * const *__ns,
- const u_char **__query,
- int *__querylen,
- u_char *__ans,
- int __anssiz,
- int *__resplen);
-
-typedef res_sendhookact (*res_send_rhook) (const struct sockaddr_in *__ns,
- const u_char *__query,
- int __querylen,
- u_char *__ans,
- int __anssiz,
- int *__resplen);
-
-/*
- * Global defines and variables for resolver stub.
- */
-# define MAXNS 3 /* max # name servers we'll track */
-# define MAXDFLSRCH 3 /* # default domain levels to try */
-# define MAXDNSRCH 6 /* max # domains in search path */
-# define LOCALDOMAINPARTS 2 /* min levels in name that is "local" */
-
-# define RES_TIMEOUT 5 /* min. seconds between retries */
-# define MAXRESOLVSORT 10 /* number of net to sort on */
-# define RES_MAXNDOTS 15 /* should reflect bit field size */
-# define RES_MAXRETRANS 30 /* only for resolv.conf/RES_OPTIONS */
-# define RES_MAXRETRY 5 /* only for resolv.conf/RES_OPTIONS */
-# define RES_DFLRETRY 2 /* Default #/tries. */
-# define RES_MAXTIME 65535 /* Infinity, in milliseconds. */
-
-struct __res_state {
- int retrans; /* retransmition time interval */
- int retry; /* number of times to retransmit */
- u_long options; /* option flags - see below. */
- int nscount; /* number of name servers */
- struct sockaddr_in
- nsaddr_list[MAXNS]; /* address of name server */
-# define nsaddr nsaddr_list[0] /* for backward compatibility */
- u_short id; /* current message id */
- /* 2 byte hole here. */
- char *dnsrch[MAXDNSRCH+1]; /* components of domain to search */
- char defdname[256]; /* default domain (deprecated) */
- u_long pfcode; /* RES_PRF_ flags - see below. */
- unsigned ndots:4; /* threshold for initial abs. query */
- unsigned nsort:4; /* number of elements in sort_list[] */
- unsigned ipv6_unavail:1; /* connecting to IPv6 server failed */
- unsigned unused:23;
- struct {
- struct in_addr addr;
- u_int32_t mask;
- } sort_list[MAXRESOLVSORT];
- /* 4 byte hole here on 64-bit architectures. */
- res_send_qhook qhook; /* query hook */
- res_send_rhook rhook; /* response hook */
- int res_h_errno; /* last one set for this context */
- int _vcsock; /* PRIVATE: for res_send VC i/o */
- u_int _flags; /* PRIVATE: see below */
- /* 4 byte hole here on 64-bit architectures. */
- union {
- char pad[52]; /* On an i386 this means 512b total. */
- struct {
- u_int16_t nscount;
- u_int16_t nsmap[MAXNS];
- int nssocks[MAXNS];
- u_int16_t nscount6;
- u_int16_t nsinit;
- struct sockaddr_in6 *nsaddrs[MAXNS];
-#ifdef _LIBC
- unsigned long long int initstamp
- __attribute__((packed));
-#else
- unsigned int _initstamp[2];
-#endif
- } _ext;
- } _u;
-};
-
-typedef struct __res_state *res_state;
-# undef __need_res_state
-#endif
-
-#ifdef _RESOLV_H_
-/*
- * Revision information. This is the release date in YYYYMMDD format.
- * It can change every day so the right thing to do with it is use it
- * in preprocessor commands such as "#if (__RES > 19931104)". Do not
- * compare for equality; rather, use it to determine whether your resolver
- * is new enough to contain a certain feature.
- */
-
-#define __RES 19991006
-
-/*
- * Resolver configuration file.
- * Normally not present, but may contain the address of the
- * inital name server(s) to query and the domain search list.
- */
-
-#ifndef _PATH_RESCONF
-#define _PATH_RESCONF "/etc/resolv.conf"
-#endif
-
-struct res_sym {
- int number; /* Identifying number, like T_MX */
- char * name; /* Its symbolic name, like "MX" */
- char * humanname; /* Its fun name, like "mail exchanger" */
-};
-
-/*
- * Resolver flags (used to be discrete per-module statics ints).
- */
-#define RES_F_VC 0x00000001 /* socket is TCP */
-#define RES_F_CONN 0x00000002 /* socket is connected */
-#define RES_F_EDNS0ERR 0x00000004 /* EDNS0 caused errors */
-
-/* res_findzonecut() options */
-#define RES_EXHAUSTIVE 0x00000001 /* always do all queries */
-
-/*
- * Resolver options (keep these in synch with res_debug.c, please)
- */
-#define RES_INIT 0x00000001 /* address initialized */
-#define RES_DEBUG 0x00000002 /* print debug messages */
-#define RES_AAONLY 0x00000004 /* authoritative answers only (!IMPL)*/
-#define RES_USEVC 0x00000008 /* use virtual circuit */
-#define RES_PRIMARY 0x00000010 /* query primary server only (!IMPL) */
-#define RES_IGNTC 0x00000020 /* ignore trucation errors */
-#define RES_RECURSE 0x00000040 /* recursion desired */
-#define RES_DEFNAMES 0x00000080 /* use default domain name */
-#define RES_STAYOPEN 0x00000100 /* Keep TCP socket open */
-#define RES_DNSRCH 0x00000200 /* search up local domain tree */
-#define RES_INSECURE1 0x00000400 /* type 1 security disabled */
-#define RES_INSECURE2 0x00000800 /* type 2 security disabled */
-#define RES_NOALIASES 0x00001000 /* shuts off HOSTALIASES feature */
-#define RES_USE_INET6 0x00002000 /* use/map IPv6 in gethostbyname() */
-#define RES_ROTATE 0x00004000 /* rotate ns list after each query */
-#define RES_NOCHECKNAME 0x00008000 /* do not check names for sanity. */
-#define RES_KEEPTSIG 0x00010000 /* do not strip TSIG records */
-#define RES_BLAST 0x00020000 /* blast all recursive servers */
-#define RES_USEBSTRING 0x00040000 /* IPv6 reverse lookup with byte
- strings */
-#define RES_NOIP6DOTINT 0x00080000 /* Do not use .ip6.int in IPv6
- reverse lookup */
-#define RES_USE_EDNS0 0x00100000 /* Use EDNS0. */
-#define RES_SNGLKUP 0x00200000 /* one outstanding request at a time */
-#define RES_SNGLKUPREOP 0x00400000 /* -"-, but open new socket for each
- request */
-#define RES_USE_DNSSEC 0x00800000 /* use DNSSEC using OK bit in OPT */
-#define RES_NOTLDQUERY 0x01000000 /* Do not look up unqualified name
- as a TLD. */
-
-#define RES_DEFAULT (RES_RECURSE|RES_DEFNAMES|RES_DNSRCH|RES_NOIP6DOTINT)
-
-/*
- * Resolver "pfcode" values. Used by dig.
- */
-#define RES_PRF_STATS 0x00000001
-#define RES_PRF_UPDATE 0x00000002
-#define RES_PRF_CLASS 0x00000004
-#define RES_PRF_CMD 0x00000008
-#define RES_PRF_QUES 0x00000010
-#define RES_PRF_ANS 0x00000020
-#define RES_PRF_AUTH 0x00000040
-#define RES_PRF_ADD 0x00000080
-#define RES_PRF_HEAD1 0x00000100
-#define RES_PRF_HEAD2 0x00000200
-#define RES_PRF_TTLID 0x00000400
-#define RES_PRF_HEADX 0x00000800
-#define RES_PRF_QUERY 0x00001000
-#define RES_PRF_REPLY 0x00002000
-#define RES_PRF_INIT 0x00004000
-/* 0x00008000 */
-
-/* Things involving an internal (static) resolver context. */
-__BEGIN_DECLS
-extern struct __res_state *__res_state(void) __attribute__ ((__const__));
-__END_DECLS
-#define _res (*__res_state())
-
-#ifndef __BIND_NOSTATIC
-#define fp_nquery __fp_nquery
-#define fp_query __fp_query
-#define hostalias __hostalias
-#define p_query __p_query
-#define res_close __res_close
-#define res_init __res_init
-#define res_isourserver __res_isourserver
-#define res_mkquery __res_mkquery
-#define res_query __res_query
-#define res_querydomain __res_querydomain
-#define res_search __res_search
-#define res_send __res_send
-
-__BEGIN_DECLS
-void fp_nquery (const u_char *, int, FILE *) __THROW;
-void fp_query (const u_char *, FILE *) __THROW;
-const char * hostalias (const char *) __THROW;
-void p_query (const u_char *) __THROW;
-void res_close (void) __THROW;
-int res_init (void) __THROW;
-int res_isourserver (const struct sockaddr_in *) __THROW;
-int res_mkquery (int, const char *, int, int, const u_char *,
- int, const u_char *, u_char *, int) __THROW;
-int res_query (const char *, int, int, u_char *, int) __THROW;
-int res_querydomain (const char *, const char *, int, int,
- u_char *, int) __THROW;
-int res_search (const char *, int, int, u_char *, int) __THROW;
-int res_send (const u_char *, int, u_char *, int) __THROW;
-__END_DECLS
-#endif
-
-#define b64_ntop __b64_ntop
-#define b64_pton __b64_pton
-#define dn_comp __dn_comp
-#define dn_count_labels __dn_count_labels
-#define dn_expand __dn_expand
-#define dn_skipname __dn_skipname
-#define fp_resstat __fp_resstat
-#define loc_aton __loc_aton
-#define loc_ntoa __loc_ntoa
-#define p_cdname __p_cdname
-#define p_cdnname __p_cdnname
-#define p_class __p_class
-#define p_fqname __p_fqname
-#define p_fqnname __p_fqnname
-#define p_option __p_option
-#define p_secstodate __p_secstodate
-#define p_section __p_section
-#define p_time __p_time
-#define p_type __p_type
-#define p_rcode __p_rcode
-#define putlong __putlong
-#define putshort __putshort
-#define res_dnok __res_dnok
-#define res_hnok __res_hnok
-#define res_hostalias __res_hostalias
-#define res_mailok __res_mailok
-#define res_nameinquery __res_nameinquery
-#define res_nclose __res_nclose
-#define res_ninit __res_ninit
-#define res_nmkquery __res_nmkquery
-#define res_npquery __res_npquery
-#define res_nquery __res_nquery
-#define res_nquerydomain __res_nquerydomain
-#define res_nsearch __res_nsearch
-#define res_nsend __res_nsend
-#define res_nisourserver __res_nisourserver
-#define res_ownok __res_ownok
-#define res_queriesmatch __res_queriesmatch
-#define res_randomid __res_randomid
-#define sym_ntop __sym_ntop
-#define sym_ntos __sym_ntos
-#define sym_ston __sym_ston
-__BEGIN_DECLS
-int res_hnok (const char *) __THROW;
-int res_ownok (const char *) __THROW;
-int res_mailok (const char *) __THROW;
-int res_dnok (const char *) __THROW;
-int sym_ston (const struct res_sym *, const char *, int *) __THROW;
-const char * sym_ntos (const struct res_sym *, int, int *) __THROW;
-const char * sym_ntop (const struct res_sym *, int, int *) __THROW;
-int b64_ntop (u_char const *, size_t, char *, size_t) __THROW;
-int b64_pton (char const *, u_char *, size_t) __THROW;
-int loc_aton (const char *__ascii, u_char *__binary) __THROW;
-const char * loc_ntoa (const u_char *__binary, char *__ascii) __THROW;
-int dn_skipname (const u_char *, const u_char *) __THROW;
-void putlong (u_int32_t, u_char *) __THROW;
-void putshort (u_int16_t, u_char *) __THROW;
-const char * p_class (int) __THROW;
-const char * p_time (u_int32_t) __THROW;
-const char * p_type (int) __THROW;
-const char * p_rcode (int) __THROW;
-const u_char * p_cdnname (const u_char *, const u_char *, int, FILE *)
- __THROW;
-const u_char * p_cdname (const u_char *, const u_char *, FILE *) __THROW;
-const u_char * p_fqnname (const u_char *__cp, const u_char *__msg,
- int, char *, int) __THROW;
-const u_char * p_fqname (const u_char *, const u_char *, FILE *) __THROW;
-const char * p_option (u_long __option) __THROW;
-char * p_secstodate (u_long) __THROW;
-int dn_count_labels (const char *) __THROW;
-int dn_comp (const char *, u_char *, int, u_char **, u_char **)
- __THROW;
-int dn_expand (const u_char *, const u_char *, const u_char *,
- char *, int) __THROW;
-u_int res_randomid (void) __THROW;
-int res_nameinquery (const char *, int, int,
- const u_char *, const u_char *) __THROW;
-int res_queriesmatch (const u_char *, const u_char *,
- const u_char *, const u_char *) __THROW;
-const char * p_section (int __section, int __opcode) __THROW;
-/* Things involving a resolver context. */
-int res_ninit (res_state) __THROW;
-int res_nisourserver (const res_state,
- const struct sockaddr_in *) __THROW;
-void fp_resstat (const res_state, FILE *) __THROW;
-void res_npquery (const res_state, const u_char *, int, FILE *)
- __THROW;
-const char * res_hostalias (const res_state, const char *, char *, size_t)
- __THROW;
-int res_nquery (res_state, const char *, int, int, u_char *, int)
- __THROW;
-int res_nsearch (res_state, const char *, int, int, u_char *, int)
- __THROW;
-int res_nquerydomain (res_state, const char *, const char *, int,
- int, u_char *, int) __THROW;
-int res_nmkquery (res_state, int, const char *, int, int,
- const u_char *, int, const u_char *, u_char *,
- int) __THROW;
-int res_nsend (res_state, const u_char *, int, u_char *, int)
- __THROW;
-void res_nclose (res_state) __THROW;
-__END_DECLS
-#endif
-
-#endif /* !_RESOLV_H_ */
diff --git a/system/include/netdb.h b/system/include/netdb.h
deleted file mode 100644
index 8860a14a..00000000
--- a/system/include/netdb.h
+++ /dev/null
@@ -1,131 +0,0 @@
-#ifndef _NETDB_H
-#define _NETDB_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define HOST_NOT_FOUND 1
-#define TRY_AGAIN 2
-#define NO_RECOVERY 3
-#define NO_DATA 4
-#define NO_ADDRESS 5
-
-#define AI_PASSIVE 0x0001
-#define AI_CANONNAME 0x0002
-#define AI_NUMERICHOST 0x0004
-#define AI_V4MAPPED 0x0008
-#define AI_ALL 0x0010
-#define AI_ADDRCONFIG 0x0020
-#ifdef __USE_GNU
-# define AI_IDN 0x0040
-# define AI_CANONIDN 0x0080
-# define AI_IDN_ALLOW_UNASSIGNED 0x0100
-# define AI_IDN_USE_STD3_ASCII_RULES 0x0200
-#endif
-#define AI_NUMERICSERV 0x0400
-
-#define EAI_ADDRFAMILY 1
-#define EAI_AGAIN 2
-#define EAI_BADFLAGS 3
-#define EAI_FAIL 4
-#define EAI_FAMILY 5
-#define EAI_MEMORY 6
-#define EAI_NODATA 7
-#define EAI_NONAME 8
-#define EAI_SERVICE 9
-#define EAI_SOCKTYPE 10
-#define EAI_SYSTEM 11
-#define EAI_BADHINTS 12
-#define EAI_PROTOCOL 13
-#define EAI_OVERFLOW 14
-#define EAI_MAX 15
-
-#define IP_TOS 1
-#define IP_TTL 2
-#define IP_HDRINCL 3
-#define IP_OPTIONS 4
-#define IP_ROUTER_ALERT 5
-#define IP_RECVOPTS 6
-#define IP_RETOPTS 7
-#define IP_PKTINFO 8
-#define IP_PKTOPTIONS 9
-#define IP_MTU_DISCOVER 10
-#define IP_RECVERR 11
-#define IP_RECVTTL 12
-#define IP_RECVTOS 13
-#define IP_MTU 14
-#define IP_FREEBIND 15
-#define IP_IPSEC_POLICY 16
-#define IP_XFRM_POLICY 17
-#define IP_PASSSEC 18
-#define IP_TRANSPARENT 19
-
-#define NI_MAXHOST 1025
-#define NI_MAXSERV 32
-
-#define NI_NOFQDN 0x00000001
-#define NI_NUMERICHOST 0x00000002
-#define NI_NAMEREQD 0x00000004
-#define NI_NUMERICSERV 0x00000008
-#define NI_DGRAM 0x00000010
-
-typedef int socklen_t;
-
-struct addrinfo
-{
- int ai_flags;
- int ai_family;
- int ai_socktype;
- int ai_protocol;
- socklen_t ai_addrlen;
- struct sockaddr *ai_addr;
- char *ai_canonname;
- struct addrinfo *ai_next;
-};
-
-extern int getaddrinfo(const char *name, const char *service, const struct addrinfo *req, struct addrinfo **pai);
-extern void freeaddrinfo(struct addrinfo *ai);
-extern int getnameinfo (struct sockaddr *sa, socklen_t salen, char *host, socklen_t hostlen, char *serv, socklen_t servlen, unsigned int flags);
-const char *gai_strerror(int ecode);
-
-struct hostent
-{
- char *h_name;
- char **h_aliases;
- int h_addrtype;
- int h_length;
- char **h_addr_list;
-};
-#define h_addr h_addr_list[0]
-
-struct hostent* gethostbyaddr(const void* addr, socklen_t len, int type);
-struct hostent* gethostbyname(const char* name);
-struct hostent* gethostbyname_r(const char *name, struct hostent *ret, char *buf, int buflen, int *err); // XXX not quite standard, see http://linux.die.net/man/3/gethostbyname_r
-void sethostent(int stayopen);
-void endhostent(void);
-void herror(const char* s);
-const char* hstrerror(int err);
-
-extern int h_errno;
-
-struct servent {
- char *s_name;
- char **s_aliases;
- int s_port;
- char *s_proto;
-};
-
-struct servent *getservent(void);
-struct servent *getservbyname(const char *name, const char *proto);
-struct servent *getservbyport(int port, const char *proto);
-void setservent(int stayopen);
-void endservent(void);
-
-#include <netinet/in.h>
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/system/include/nl_types.h b/system/include/nl_types.h
deleted file mode 100644
index 818e9af8..00000000
--- a/system/include/nl_types.h
+++ /dev/null
@@ -1,19 +0,0 @@
-
-#ifndef _NL_TYPES_H_
-#define _NL_TYPES_H_
-
-typedef struct _nl_catd {
- void *data;
- int size;
-} *nl_catd;
-typedef int nl_item;
-
-#define NL_SETD 100
-#define NL_CAT_LOCALE 200
-
-nl_catd catopen(const char *, int);
-int catclose(nl_catd);
-char *catgets(nl_catd, int, int, const char *);
-
-#endif
-
diff --git a/system/include/poll.h b/system/include/poll.h
deleted file mode 100644
index e4c40dca..00000000
--- a/system/include/poll.h
+++ /dev/null
@@ -1,3 +0,0 @@
-
-#include "sys/poll.h"
-
diff --git a/system/include/pty.h b/system/include/pty.h
deleted file mode 100644
index 0ad5b6d5..00000000
--- a/system/include/pty.h
+++ /dev/null
@@ -1,6 +0,0 @@
-
-#include <sys/termios.h>
-
-int openpty(int *amaster, int *aslave, char *name, struct termios *termp, struct winsize *winp);
-int forkpty(int *amaster, char *name, struct termios *termp, struct winsize *winp);
-
diff --git a/system/include/semaphore.h b/system/include/semaphore.h
deleted file mode 100644
index 6ea1553c..00000000
--- a/system/include/semaphore.h
+++ /dev/null
@@ -1,31 +0,0 @@
-
-#ifndef _SYS_SEMAPHORE_H
-#define _SYS_SEMAPHORE_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef int sem_t;
-
-sem_t *sem_open(const char *, int, ...);
-int sem_close(sem_t *);
-
-int sem_init(sem_t *, int, unsigned);
-int sem_destroy(sem_t *);
-
-int sem_getvalue(sem_t *, int *);
-int sem_post(sem_t *);
-
-int sem_timedwait(sem_t *, const struct timespec *);
-int sem_trywait(sem_t *);
-int sem_wait(sem_t *);
-
-int sem_unlink(const char *);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
diff --git a/system/include/spawn.h b/system/include/spawn.h
deleted file mode 100644
index e251b6f1..00000000
--- a/system/include/spawn.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/* $OpenBSD: spawn.h,v 1.1 2012/03/21 23:20:35 matthew Exp $ */
-/*-
- * Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD: src/include/spawn.h,v 1.3.2.1.6.1 2010/12/21 17:09:25 kensmith Exp $
- */
-
-#ifndef _SPAWN_H_
-#define _SPAWN_H_
-
-#include <sys/cdefs.h>
-#include <sys/types.h>
-#include <sys/signal.h>
-
-struct sched_param;
-
-typedef struct __posix_spawnattr *posix_spawnattr_t;
-typedef struct __posix_spawn_file_actions *posix_spawn_file_actions_t;
-
-#define POSIX_SPAWN_RESETIDS 0x01
-#define POSIX_SPAWN_SETPGROUP 0x02
-#define POSIX_SPAWN_SETSCHEDPARAM 0x04
-#define POSIX_SPAWN_SETSCHEDULER 0x08
-#define POSIX_SPAWN_SETSIGDEF 0x10
-#define POSIX_SPAWN_SETSIGMASK 0x20
-
-__BEGIN_DECLS
-/*
- * Spawn routines
- *
- * XXX both arrays should be __restrict, but this does not work when GCC
- * is invoked with -std=c99.
- */
-int posix_spawn(pid_t *__restrict, const char *__restrict,
- const posix_spawn_file_actions_t *, const posix_spawnattr_t *__restrict,
- char *const [], char *const []);
-int posix_spawnp(pid_t *__restrict, const char *__restrict,
- const posix_spawn_file_actions_t *, const posix_spawnattr_t *__restrict,
- char *const [], char *const []);
-
-/*
- * File descriptor actions
- */
-int posix_spawn_file_actions_init(posix_spawn_file_actions_t *);
-int posix_spawn_file_actions_destroy(posix_spawn_file_actions_t *);
-
-int posix_spawn_file_actions_addopen(posix_spawn_file_actions_t *__restrict,
- int, const char *__restrict, int, mode_t);
-int posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t *, int, int);
-int posix_spawn_file_actions_addclose(posix_spawn_file_actions_t *, int);
-
-/*
- * Spawn attributes
- */
-int posix_spawnattr_init(posix_spawnattr_t *);
-int posix_spawnattr_destroy(posix_spawnattr_t *);
-
-int posix_spawnattr_getflags(const posix_spawnattr_t *__restrict,
- short *__restrict);
-int posix_spawnattr_getpgroup(const posix_spawnattr_t *__restrict,
- pid_t *__restrict);
-int posix_spawnattr_getschedparam(const posix_spawnattr_t *__restrict,
- struct sched_param *__restrict);
-int posix_spawnattr_getschedpolicy(const posix_spawnattr_t *__restrict,
- int *__restrict);
-int posix_spawnattr_getsigdefault(const posix_spawnattr_t *__restrict,
- sigset_t *__restrict);
-int posix_spawnattr_getsigmask(const posix_spawnattr_t *__restrict,
- sigset_t *__restrict sigmask);
-
-int posix_spawnattr_setflags(posix_spawnattr_t *, short);
-int posix_spawnattr_setpgroup(posix_spawnattr_t *, pid_t);
-int posix_spawnattr_setschedparam(posix_spawnattr_t *__restrict,
- const struct sched_param *__restrict);
-int posix_spawnattr_setschedpolicy(posix_spawnattr_t *, int);
-int posix_spawnattr_setsigdefault(posix_spawnattr_t *__restrict,
- const sigset_t *__restrict);
-int posix_spawnattr_setsigmask(posix_spawnattr_t *__restrict,
- const sigset_t *__restrict);
-__END_DECLS
-
-#endif /* !_SPAWN_H_ */
-
diff --git a/system/include/stdbool.h b/system/include/stdbool.h
deleted file mode 100644
index 561eed3f..00000000
--- a/system/include/stdbool.h
+++ /dev/null
@@ -1,16 +0,0 @@
-
-#ifndef __stdbool_h__
-#define __stdbool_h__
-
-#define __bool_true_false_are_defined 1
-
-#ifndef __cplusplus
-
-#define bool _Bool
-#define true 1
-#define false 0
-
-#endif
-
-#endif
-
diff --git a/system/include/sys/bitypes.h b/system/include/sys/bitypes.h
deleted file mode 100644
index 88c62c0b..00000000
--- a/system/include/sys/bitypes.h
+++ /dev/null
@@ -1,3 +0,0 @@
-
-#include <sys/types.h>
-
diff --git a/system/include/sys/ioctl.h b/system/include/sys/ioctl.h
deleted file mode 100644
index 047329cb..00000000
--- a/system/include/sys/ioctl.h
+++ /dev/null
@@ -1,78 +0,0 @@
-#ifndef _IOCTL_H
-#define _IOCTL_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define TIOCGSIZE 80 // bogus
-#define TIOCGWINSZ 80 // bogus
-
-#define FIONREAD 1
-#define FIONBIO 2
-
-int ioctl(int d, int request, ...);
-
-#define SO_RCVTIMEO 1000
-#define SO_SNDTIMEO 2000
-
-#define SIOCADDRT 0x890B
-#define SIOCDELRT 0x890C
-#define SIOCRTMSG 0x890D
-#define SIOCGIFNAME 0x8910
-#define SIOCSIFLINK 0x8911
-#define SIOCGIFCONF 0x8912
-#define SIOCGIFFLAGS 0x8913
-#define SIOCSIFFLAGS 0x8914
-#define SIOCGIFADDR 0x8915
-#define SIOCSIFADDR 0x8916
-#define SIOCGIFDSTADDR 0x8917
-#define SIOCSIFDSTADDR 0x8918
-#define SIOCGIFBRDADDR 0x8919
-#define SIOCSIFBRDADDR 0x891a
-#define SIOCGIFNETMASK 0x891b
-#define SIOCSIFNETMASK 0x891c
-#define SIOCGIFMETRIC 0x891d
-#define SIOCSIFMETRIC 0x891e
-#define SIOCGIFMEM 0x891f
-#define SIOCSIFMEM 0x8920
-#define SIOCGIFMTU 0x8921
-#define SIOCSIFMTU 0x8922
-#define SIOCSIFNAME 0x8923
-#define SIOCSIFHWADDR 0x8924
-#define SIOCGIFENCAP 0x8925
-#define SIOCSIFENCAP 0x8926
-#define SIOCGIFHWADDR 0x8927
-#define SIOCGIFSLAVE 0x8929
-#define SIOCSIFSLAVE 0x8930
-#define SIOCADDMULTI 0x8931
-#define SIOCDELMULTI 0x8932
-#define SIOCGIFINDEX 0x8933
-#define SIOGIFINDEX SIOCGIFINDEX
-#define SIOCSIFPFLAGS 0x8934
-#define SIOCGIFPFLAGS 0x8935
-#define SIOCDIFADDR 0x8936
-#define SIOCSIFHWBROADCAST 0x8937
-#define SIOCGIFCOUNT 0x8938
-#define SIOCGIFBR 0x8940
-#define SIOCSIFBR 0x8941
-#define SIOCGIFTXQLEN 0x8942
-#define SIOCSIFTXQLEN 0x8943
-#define SIOCDARP 0x8953
-#define SIOCGARP 0x8954
-#define SIOCSARP 0x8955
-#define SIOCDRARP 0x8960
-#define SIOCGRARP 0x8961
-#define SIOCSRARP 0x8962
-#define SIOCGIFMAP 0x8970
-#define SIOCSIFMAP 0x8971
-#define SIOCADDDLCI 0x8980
-#define SIOCDELDLCI 0x8981
-#define SIOCDEVPRIVATE 0x89F0
-#define SIOCPROTOPRIVATE 0x89E0
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/system/include/sys/poll.h b/system/include/sys/poll.h
deleted file mode 100644
index 7521ed0e..00000000
--- a/system/include/sys/poll.h
+++ /dev/null
@@ -1,31 +0,0 @@
-
-#ifndef _SYS_POLL_H
-#define _SYS_POLL_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define POLLIN 1
-#define POLLOUT 2
-#define POLLNVAL 4
-#define POLLERR 8
-#define POLLHUP 16
-#define POLLPRI 32
-
-struct pollfd {
- int fd;
- short events;
- short revents;
-};
-
-typedef unsigned int nfds_t;
-
-int poll(struct pollfd *data, nfds_t num, int extra);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
diff --git a/system/include/sys/select.h b/system/include/sys/select.h
deleted file mode 100644
index d6957fea..00000000
--- a/system/include/sys/select.h
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef _SELECT_H
-#define _SELECT_H
-
-#include <unistd.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/system/include/sys/sendfile.h b/system/include/sys/sendfile.h
deleted file mode 100644
index 1f58f0dd..00000000
--- a/system/include/sys/sendfile.h
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef _SYS_SENDFILE_H
-#define _SYS_SENDFILE_H
-
-#include <sys/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-ssize_t sendfile(int out_fd, int in_fd, off_t *offset, size_t count);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/system/include/sys/socket.h b/system/include/sys/socket.h
deleted file mode 100644
index abc0aa62..00000000
--- a/system/include/sys/socket.h
+++ /dev/null
@@ -1,247 +0,0 @@
-#ifndef _SYS_SOCKET_H
-#define _SYS_SOCKET_H
-
-#include <netdb.h>
-#include <sys/select.h>
-#include <sys/uio.h>
-#include <unistd.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define SOCK_STREAM 1
-#define SOCK_DGRAM 2
-#define SOCK_RAW 3
-#define SOCK_RDM 4
-#define SOCK_SEQPACKET 5
-#define SOCK_DCCP 6
-#define SOCK_PACKET 10
-#define SOCK_CLOEXEC 02000000
-#define SOCK_NONBLOCK 04000
-
-#define PF_UNSPEC 0
-#define PF_LOCAL 1
-#define PF_UNIX PF_LOCAL
-#define PF_FILE PF_LOCAL
-#define PF_INET 2
-#define PF_AX25 3
-#define PF_IPX 4
-#define PF_APPLETALK 5
-#define PF_NETROM 6
-#define PF_BRIDGE 7
-#define PF_ATMPVC 8
-#define PF_X25 9
-#define PF_INET6 10
-#define PF_ROSE 11
-#define PF_DECnet 12
-#define PF_NETBEUI 13
-#define PF_SECURITY 14
-#define PF_KEY 15
-#define PF_NETLINK 16
-#define PF_ROUTE PF_NETLINK
-#define PF_PACKET 17
-#define PF_ASH 18
-#define PF_ECONET 19
-#define PF_ATMSVC 20
-#define PF_RDS 21
-#define PF_SNA 22
-#define PF_IRDA 23
-#define PF_PPPOX 24
-#define PF_WANPIPE 25
-#define PF_LLC 26
-#define PF_CAN 29
-#define PF_TIPC 30
-#define PF_BLUETOOTH 31
-#define PF_IUCV 32
-#define PF_RXRPC 33
-#define PF_ISDN 34
-#define PF_PHONET 35
-#define PF_IEEE802154 36
-#define PF_CAIF 37
-#define PF_ALG 38
-#define PF_NFC 39
-#define PF_MAX 40
-
-#define AF_UNSPEC PF_UNSPEC
-#define AF_LOCAL PF_LOCAL
-#define AF_UNIX PF_UNIX
-#define AF_FILE PF_FILE
-#define AF_INET PF_INET
-#define AF_AX25 PF_AX25
-#define AF_IPX PF_IPX
-#define AF_APPLETALK PF_APPLETALK
-#define AF_NETROM PF_NETROM
-#define AF_BRIDGE PF_BRIDGE
-#define AF_ATMPVC PF_ATMPVC
-#define AF_X25 PF_X25
-#define AF_INET6 PF_INET6
-#define AF_ROSE PF_ROSE
-#define AF_DECnet PF_DECnet
-#define AF_NETBEUI PF_NETBEUI
-#define AF_SECURITY PF_SECURITY
-#define AF_KEY PF_KEY
-#define AF_NETLINK PF_NETLINK
-#define AF_ROUTE PF_ROUTE
-#define AF_PACKET PF_PACKET
-#define AF_ASH PF_ASH
-#define AF_ECONET PF_ECONET
-#define AF_ATMSVC PF_ATMSVC
-#define AF_RDS PF_RDS
-#define AF_SNA PF_SNA
-#define AF_IRDA PF_IRDA
-#define AF_PPPOX PF_PPPOX
-#define AF_WANPIPE PF_WANPIPE
-#define AF_LLC PF_LLC
-#define AF_CAN PF_CAN
-#define AF_TIPC PF_TIPC
-#define AF_BLUETOOTH PF_BLUETOOTH
-#define AF_IUCV PF_IUCV
-#define AF_RXRPC PF_RXRPC
-#define AF_ISDN PF_ISDN
-#define AF_PHONET PF_PHONET
-#define AF_IEEE802154 PF_IEEE802154
-#define AF_CAIF PF_CAIF
-#define AF_ALG PF_ALG
-#define AF_NFC PF_NFC
-#define AF_MAX PF_MAX
-
-#define SOMAXCONN 128
-
-#define SOL_SOCKET 1
-
-#define SO_DEBUG 1
-#define SO_REUSEADDR 2
-#define SO_TYPE 3
-#define SO_ERROR 4
-#define SO_DONTROUTE 5
-#define SO_BROADCAST 6
-#define SO_SNDBUF 7
-#define SO_RCVBUF 8
-#define SO_SNDBUFFORCE 32
-#define SO_RCVBUFFORCE 33
-#define SO_KEEPALIVE 9
-#define SO_OOBINLINE 10
-#define SO_NO_CHECK 11
-#define SO_PRIORITY 12
-#define SO_LINGER 13
-#define SO_BSDCOMPAT 14
-#ifndef SO_PASSCRED
-#define SO_PASSCRED 16
-#define SO_PEERCRED 17
-#define SO_RCVLOWAT 18
-#define SO_SNDLOWAT 19
-#define SO_RCVTIMEO 20
-#define SO_SNDTIMEO 21
-#endif
-#define SO_SECURITY_AUTHENTICATION 22
-#define SO_SECURITY_ENCRYPTION_TRANSPORT 23
-#define SO_SECURITY_ENCRYPTION_NETWORK 24
-#define SO_BINDTODEVICE 25
-#define SO_ATTACH_FILTER 26
-#define SO_DETACH_FILTER 27
-#define SO_PEERNAME 28
-#define SO_TIMESTAMP 29
-#define SCM_TIMESTAMP SO_TIMESTAMP
-#define SO_ACCEPTCONN 30
-#define SO_PEERSEC 31
-#define SO_PASSSEC 34
-#define SO_TIMESTAMPNS 35
-#define SCM_TIMESTAMPNS SO_TIMESTAMPNS
-#define SO_MARK 36
-#define SO_TIMESTAMPING 37
-#define SCM_TIMESTAMPING SO_TIMESTAMPING
-#define SO_PROTOCOL 38
-#define SO_DOMAIN 39
-#define SO_RXQ_OVFL 40
-
-#if __BSD_VISIBLE
-#define SO_NOSIGPIPE 0x0800
-#endif
-
-#define MSG_OOB 0x01
-#define MSG_PEEK 0x02
-#define MSG_DONTROUTE 0x04
-#ifdef __USE_GNU
-# define MSG_TRYHARD MSG_DONTROUTE
-#endif
-#define MSG_CTRUNC 0x08
-#define MSG_PROXY 0x10
-#define MSG_TRUNC 0x20
-#define MSG_DONTWAIT 0x40
-#define MSG_EOR 0x80
-#define MSG_WAITALL 0x100
-#define MSG_FIN 0x200
-#define MSG_SYN 0x400
-#define MSG_CONFIRM 0x800
-#define MSG_RST 0x1000
-#define MSG_ERRQUEUE 0x2000
-#define MSG_NOSIGNAL 0x4000
-#define MSG_MORE 0x8000
-#define MSG_WAITFORONE 0x10000
-#define MSG_CMSG_CLOEXEC 0x40000000
-
-#define SHUT_RD 0
-#define SHUT_WR 1
-#define SHUT_RDWR 2
-
-#define FIOSETOWN 0x8901
-#define SIOCSPGRP 0x8902
-#define FIOGETOWN 0x8903
-#define SIOCGPGRP 0x8904
-#define SIOCATMARK 0x8905
-#define SIOCGSTAMP 0x8906
-#define SIOCGSTAMPNS 0x8907
-
-typedef unsigned int sa_family_t;
-
-struct sockaddr {
- sa_family_t sa_family;
- char sa_data[16];
-};
-
-struct sockaddr_storage {
- sa_family_t ss_family;
- unsigned short ss_port;
- unsigned long ss_addr;
- char ss_zero[6];
-};
-
-ssize_t recvfrom(int socket, void *buffer, size_t length, int flags, struct sockaddr *address, socklen_t *address_len);
-int getpeername(int socket, struct sockaddr *address, socklen_t *address_len);
-int getsockname(int socket, struct sockaddr *address, socklen_t *address_len);
-int socket(int domain, int type, int protocol);
-int bind(int sockfd, const struct sockaddr *my_addr, socklen_t addrlen);
-int listen(int sockfd, int backlog);
-int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen);
-int connect(int sockfd, const struct sockaddr *serv_addr, socklen_t addrlen);
-int shutdown(int sockfd, int how);
-int getsockopt(int s, int level, int optname, void *optval, socklen_t *optlen);
-ssize_t recv(int s, void *buf, size_t len, int flags);
-ssize_t send(int s, const void *buf, size_t len, int flags);
-int setsockopt(int s, int level, int optname, const void *optval, socklen_t optlen);
-ssize_t sendto(int s, const void *buf, size_t len, int flags, const struct sockaddr *to, socklen_t tolen);
-int socketpair(int domain, int type, int protocol, int sv[2]);
-
-struct msghdr
-{
- void *msg_name;
- socklen_t msg_namelen;
- struct iovec *msg_iov;
- size_t msg_iovlen;
- void * msg_control;
- size_t msg_controllen;
- int msg_flags;
-};
-
-struct linger {
- int l_onoff;
- int l_linger;
-};
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
diff --git a/system/include/sys/socketvar.h b/system/include/sys/socketvar.h
deleted file mode 100644
index 58fe99cf..00000000
--- a/system/include/sys/socketvar.h
+++ /dev/null
@@ -1,3 +0,0 @@
-
-#include <sys/socket.h>
-
diff --git a/system/include/sys/statvfs.h b/system/include/sys/statvfs.h
deleted file mode 100644
index 8e17f817..00000000
--- a/system/include/sys/statvfs.h
+++ /dev/null
@@ -1,32 +0,0 @@
-
-#ifndef _SYS_STATVFS_H
-#define _SYS_STATVFS_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct statvfs {
- int f_bsize;
- int f_frsize;
- int f_blocks;
- int f_bfree;
- int f_bavail;
- int f_files;
- int f_ffree;
- int f_favail;
- int f_fsid;
- int f_flag;
- int f_namemax;
-};
-
-int statvfs(const char *path, struct statvfs *s);
-
-#define ST_RDONLY 0
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
diff --git a/system/include/sys/sysctl.h b/system/include/sys/sysctl.h
deleted file mode 100644
index 2863201a..00000000
--- a/system/include/sys/sysctl.h
+++ /dev/null
@@ -1,14 +0,0 @@
-
-#ifndef _SYS_POLL_H
-#define _SYS_POLL_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
diff --git a/system/include/sys/uio.h b/system/include/sys/uio.h
deleted file mode 100644
index 07f169ee..00000000
--- a/system/include/sys/uio.h
+++ /dev/null
@@ -1,22 +0,0 @@
-
-#ifndef _SYS_UIO_H
-#define _SYS_UIO_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct iovec {
- void *iov_base;
- size_t iov_len;
-};
-
-ssize_t readv(int, const struct iovec *, int);
-ssize_t writev(int, const struct iovec *, int);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
diff --git a/system/include/sys/un.h b/system/include/sys/un.h
deleted file mode 100644
index ca002158..00000000
--- a/system/include/sys/un.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*-
- * Copyright (c) 1982, 1986, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)un.h 8.3 (Berkeley) 2/19/95
- * $FreeBSD$
- */
-
-#ifndef _SYS_UN_H_
-#define _SYS_UN_H_
-
-#include <sys/cdefs.h>
-#include <sys/_types.h>
-#include <sys/socket.h>
-
-/*
- * Definitions for UNIX IPC domain.
- */
-struct sockaddr_un {
- unsigned char sun_len; /* sockaddr len including null */
- sa_family_t sun_family; /* AF_UNIX */
- char sun_path[104]; /* path name (gag) */
-};
-
-#if __BSD_VISIBLE
-
-/* Socket options. */
-#define LOCAL_PEERCRED 0x001 /* retrieve peer credentials */
-#define LOCAL_CREDS 0x002 /* pass credentials to receiver */
-#define LOCAL_CONNWAIT 0x004 /* connects block until accepted */
-
-#ifndef _KERNEL
-
-/* actual length of an initialized sockaddr_un */
-#define SUN_LEN(su) \
- (sizeof(*(su)) - sizeof((su)->sun_path) + strlen((su)->sun_path))
-
-#endif /* !_KERNEL */
-
-#endif /* __BSD_VISIBLE */
-
-#endif /* !_SYS_UN_H_ */
diff --git a/system/include/sysexits.h b/system/include/sysexits.h
deleted file mode 100644
index cc3e786b..00000000
--- a/system/include/sysexits.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
-* Copyright (c) 1987, 1993
-* The Regents of the University of California. All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions
-* are met:
-* 1. Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* 2. Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-* 4. Neither the name of the University nor the names of its contributors
-* may be used to endorse or promote products derived from this software
-* without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-* SUCH DAMAGE.
-*
-* @(#)sysexits.h 8.1 (Berkeley) 6/2/93
-*/
-#ifndef _SYSEXITS_H
-#define _SYSEXITS_H 1
-/*
-* SYSEXITS.H -- Exit status codes for system programs.
-*
-* This include file attempts to categorize possible error
-* exit statuses for system programs, notably delivermail
-* and the Berkeley network.
-*
-* Error numbers begin at EX__BASE to reduce the possibility of
-* clashing with other exit statuses that random programs may
-* already return. The meaning of the codes is approximately
-* as follows:
-*
-* EX_USAGE -- The command was used incorrectly, e.g., with
-* the wrong number of arguments, a bad flag, a bad
-* syntax in a parameter, or whatever.
-* EX_DATAERR -- The input data was incorrect in some way.
-* This should only be used for user's data & not
-* system files.
-* EX_NOINPUT -- An input file (not a system file) did not
-* exist or was not readable. This could also include
-* errors like "No message" to a mailer (if it cared
-* to catch it).
-* EX_NOUSER -- The user specified did not exist. This might
-* be used for mail addresses or remote logins.
-* EX_NOHOST -- The host specified did not exist. This is used
-* in mail addresses or network requests.
-* EX_UNAVAILABLE -- A service is unavailable. This can occur
-* if a support program or file does not exist. This
-* can also be used as a catchall message when something
-* you wanted to do doesn't work, but you don't know
-* why.
-* EX_SOFTWARE -- An internal software error has been detected.
-* This should be limited to non-operating system related
-* errors as possible.
-* EX_OSERR -- An operating system error has been detected.
-* This is intended to be used for such things as "cannot
-* fork", "cannot create pipe", or the like. It includes
-* things like getuid returning a user that does not
-* exist in the passwd file.
-* EX_OSFILE -- Some system file (e.g., /etc/passwd, /etc/utmp,
-* etc.) does not exist, cannot be opened, or has some
-* sort of error (e.g., syntax error).
-* EX_CANTCREAT -- A (user specified) output file cannot be
-* created.
-* EX_IOERR -- An error occurred while doing I/O on some file.
-* EX_TEMPFAIL -- temporary failure, indicating something that
-* is not really an error. In sendmail, this means
-* that a mailer (e.g.) could not create a connection,
-* and the request should be reattempted later.
-* EX_PROTOCOL -- the remote system returned something that
-* was "not possible" during a protocol exchange.
-* EX_NOPERM -- You did not have sufficient permission to
-* perform the operation. This is not intended for
-* file system problems, which should use NOINPUT or
-* CANTCREAT, but rather for higher level permissions.
-*/
-#define EX_OK 0 /* successful termination */
-#define EX__BASE 64 /* base value for error messages */
-#define EX_USAGE 64 /* command line usage error */
-#define EX_DATAERR 65 /* data format error */
-#define EX_NOINPUT 66 /* cannot open input */
-#define EX_NOUSER 67 /* addressee unknown */
-#define EX_NOHOST 68 /* host name unknown */
-#define EX_UNAVAILABLE 69 /* service unavailable */
-#define EX_SOFTWARE 70 /* internal software error */
-#define EX_OSERR 71 /* system error (e.g., can't fork) */
-#define EX_OSFILE 72 /* critical OS file missing */
-#define EX_CANTCREAT 73 /* can't create (user) output file */
-#define EX_IOERR 74 /* input/output error */
-#define EX_TEMPFAIL 75 /* temp failure; user is invited to retry */
-#define EX_PROTOCOL 76 /* remote error in protocol */
-#define EX_NOPERM 77 /* permission denied */
-#define EX_CONFIG 78 /* configuration error */
-#define EX__MAX 78 /* maximum listed value */
-#endif /* sysexits.h */
-
diff --git a/system/include/xlocale.h b/system/include/xlocale.h
deleted file mode 100644
index 6867d25f..00000000
--- a/system/include/xlocale.h
+++ /dev/null
@@ -1,42 +0,0 @@
-#ifndef _XLOCALE_H_
-#define _XLOCALE_H_
-
-#include <string.h>
-#include <locale.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-int strcoll_l(const char *s1, const char *s2, locale_t locale);
-int wcscoll_l(const wchar_t *ws1, const wchar_t *ws2, locale_t locale);
-
-size_t strxfrm_l(char *s1, const char *s2, size_t n, locale_t locale);
-size_t wcsxfrm_l(wchar_t *ws1, const wchar_t *ws2, size_t n, locale_t locale);
-
-int isxdigit_l(int c, locale_t locale);
-int isdigit_l(int c, locale_t locale);
-int toupper_l(int c, locale_t locale);
-int tolower_l(int c, locale_t locale);
-
-int iswspace_l(wint_t wc, locale_t locale);
-int iswupper_l(wint_t wc, locale_t locale);
-int iswlower_l(wint_t wc, locale_t locale);
-int iswprint_l(wint_t wc, locale_t locale);
-int iswcntrl_l(wint_t wc, locale_t locale);
-int iswalpha_l(wint_t wc, locale_t locale);
-int iswdigit_l(wint_t wc, locale_t locale);
-int iswpunct_l(wint_t wc, locale_t locale);
-int iswblank_l(wint_t wc, locale_t locale);
-int iswxdigit_l(wint_t wc, locale_t locale);
-int towupper_l(wint_t wc, locale_t locale);
-int towlower_l(wint_t wc, locale_t locale);
-
-size_t strftime_l(char *s, size_t maxsize, const char *format, const struct tm *timeptr, locale_t locale);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _XLOCALE_H_ */
-