summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@suse.de>2005-11-09 15:42:07 +0100
committerKay Sievers <kay.sievers@suse.de>2005-11-09 15:42:07 +0100
commita8349b33e564f7faa83341cb1fa58466b0589ae9 (patch)
tree45985cfc248e5219a25230959b00b7baa2b8b276
parentaccff726856a0b3258a413d823a534f4f437e6b2 (diff)
remove our own copy of klibc
Signed-off-by: Kay Sievers <kay.sievers@suse.de>
-rw-r--r--ChangeLog3
-rw-r--r--Makefile25
-rw-r--r--README17
-rw-r--r--RELEASE-NOTES5
-rw-r--r--klibc/MCONFIG98
-rw-r--r--klibc/MRULES45
-rw-r--r--klibc/Makefile77
-rw-r--r--klibc/README21
-rw-r--r--klibc/include/alloca.h13
-rw-r--r--klibc/include/arch/alpha/klibc/archsetjmp.h33
-rw-r--r--klibc/include/arch/alpha/klibc/archsignal.h13
-rw-r--r--klibc/include/arch/alpha/klibc/archstat.h26
-rw-r--r--klibc/include/arch/alpha/klibc/archsys.h53
-rw-r--r--klibc/include/arch/alpha/machine/asm.h44
-rw-r--r--klibc/include/arch/arm/klibc/archsetjmp.h14
-rw-r--r--klibc/include/arch/arm/klibc/archsignal.h13
-rw-r--r--klibc/include/arch/arm/klibc/archstat.h45
-rw-r--r--klibc/include/arch/arm/klibc/archsys.h12
-rw-r--r--klibc/include/arch/cris/klibc/archsetjmp.h24
-rw-r--r--klibc/include/arch/cris/klibc/archsignal.h13
-rw-r--r--klibc/include/arch/cris/klibc/archstat.h37
-rw-r--r--klibc/include/arch/cris/klibc/archsys.h12
-rw-r--r--klibc/include/arch/i386/klibc/archsetjmp.h19
-rw-r--r--klibc/include/arch/i386/klibc/archsignal.h13
-rw-r--r--klibc/include/arch/i386/klibc/archstat.h37
-rw-r--r--klibc/include/arch/i386/klibc/archsys.h12
-rw-r--r--klibc/include/arch/i386/klibc/diverr.h16
-rw-r--r--klibc/include/arch/i386/sys/io.h126
-rw-r--r--klibc/include/arch/i386/sys/vm86.h41
-rw-r--r--klibc/include/arch/ia64/klibc/archsetjmp.h17
-rw-r--r--klibc/include/arch/ia64/klibc/archsignal.h31
-rw-r--r--klibc/include/arch/ia64/klibc/archstat.h24
-rw-r--r--klibc/include/arch/ia64/klibc/archsys.h218
-rw-r--r--klibc/include/arch/m32r/klibc/archsetjmp.h21
-rw-r--r--klibc/include/arch/m32r/klibc/archsignal.h13
-rw-r--r--klibc/include/arch/m32r/klibc/archstat.h37
-rw-r--r--klibc/include/arch/m32r/klibc/archsys.h12
-rw-r--r--klibc/include/arch/m68k/klibc/archsignal.h13
-rw-r--r--klibc/include/arch/m68k/klibc/archstat.h37
-rw-r--r--klibc/include/arch/m68k/klibc/archsys.h12
-rw-r--r--klibc/include/arch/mips/klibc/archfcntl.h87
-rw-r--r--klibc/include/arch/mips/klibc/archsetjmp.h39
-rw-r--r--klibc/include/arch/mips/klibc/archsignal.h13
-rw-r--r--klibc/include/arch/mips/klibc/archstat.h39
-rw-r--r--klibc/include/arch/mips/klibc/archsys.h12
-rw-r--r--klibc/include/arch/mips/machine/asm.h11
-rw-r--r--klibc/include/arch/mips/sgidefs.h20
-rw-r--r--klibc/include/arch/mips/spaces.h1
-rw-r--r--klibc/include/arch/mips64/klibc/archsignal.h13
-rw-r--r--klibc/include/arch/mips64/klibc/archstat.h33
-rw-r--r--klibc/include/arch/mips64/klibc/archsys.h12
-rw-r--r--klibc/include/arch/parisc/klibc/archsetjmp.h14
-rw-r--r--klibc/include/arch/parisc/klibc/archsignal.h24
-rw-r--r--klibc/include/arch/parisc/klibc/archstat.h27
-rw-r--r--klibc/include/arch/parisc/klibc/archsys.h12
-rw-r--r--klibc/include/arch/ppc/klibc/archsetjmp.h36
-rw-r--r--klibc/include/arch/ppc/klibc/archsignal.h13
-rw-r--r--klibc/include/arch/ppc/klibc/archstat.h28
-rw-r--r--klibc/include/arch/ppc/klibc/archsys.h61
-rw-r--r--klibc/include/arch/ppc64/klibc/archsetjmp.h36
-rw-r--r--klibc/include/arch/ppc64/klibc/archsignal.h13
-rw-r--r--klibc/include/arch/ppc64/klibc/archstat.h25
-rw-r--r--klibc/include/arch/ppc64/klibc/archsys.h52
-rw-r--r--klibc/include/arch/s390/klibc/archsetjmp.h15
-rw-r--r--klibc/include/arch/s390/klibc/archsignal.h13
-rw-r--r--klibc/include/arch/s390/klibc/archstat.h31
-rw-r--r--klibc/include/arch/s390/klibc/archsys.h41
-rw-r--r--klibc/include/arch/s390x/klibc/archsetjmp.h15
-rw-r--r--klibc/include/arch/s390x/klibc/archsignal.h13
-rw-r--r--klibc/include/arch/s390x/klibc/archstat.h24
-rw-r--r--klibc/include/arch/s390x/klibc/archsys.h41
-rw-r--r--klibc/include/arch/sh/klibc/archsetjmp.h22
-rw-r--r--klibc/include/arch/sh/klibc/archsignal.h13
-rw-r--r--klibc/include/arch/sh/klibc/archstat.h45
-rw-r--r--klibc/include/arch/sh/klibc/archsys.h12
-rw-r--r--klibc/include/arch/sparc/klibc/archsetjmp.h16
-rw-r--r--klibc/include/arch/sparc/klibc/archsignal.h38
-rw-r--r--klibc/include/arch/sparc/klibc/archstat.h35
-rw-r--r--klibc/include/arch/sparc/klibc/archsys.h10
-rw-r--r--klibc/include/arch/sparc/machine/asm.h192
-rw-r--r--klibc/include/arch/sparc/machine/frame.h138
-rw-r--r--klibc/include/arch/sparc/machine/trap.h141
-rw-r--r--klibc/include/arch/sparc64/klibc/archsetjmp.h16
-rw-r--r--klibc/include/arch/sparc64/klibc/archsignal.h13
-rw-r--r--klibc/include/arch/sparc64/klibc/archstat.h22
-rw-r--r--klibc/include/arch/sparc64/klibc/archsys.h10
-rw-r--r--klibc/include/arch/x86_64/klibc/archsetjmp.h21
-rw-r--r--klibc/include/arch/x86_64/klibc/archsignal.h17
-rw-r--r--klibc/include/arch/x86_64/klibc/archstat.h26
-rw-r--r--klibc/include/arch/x86_64/klibc/archsys.h109
-rw-r--r--klibc/include/arch/x86_64/sys/io.h126
-rw-r--r--klibc/include/arpa/inet.h24
-rw-r--r--klibc/include/assert.h22
-rw-r--r--klibc/include/bits32/bitsize.h3
-rw-r--r--klibc/include/bits32/bitsize/limits.h14
-rw-r--r--klibc/include/bits32/bitsize/stddef.h18
-rw-r--r--klibc/include/bits32/bitsize/stdint.h34
-rw-r--r--klibc/include/bits32/bitsize/stdintconst.h18
-rw-r--r--klibc/include/bits32/bitsize/stdintlimits.h22
-rw-r--r--klibc/include/bits64/bitsize.h3
-rw-r--r--klibc/include/bits64/bitsize/limits.h14
-rw-r--r--klibc/include/bits64/bitsize/stddef.h13
-rw-r--r--klibc/include/bits64/bitsize/stdint.h36
-rw-r--r--klibc/include/bits64/bitsize/stdintconst.h18
-rw-r--r--klibc/include/bits64/bitsize/stdintlimits.h22
-rw-r--r--klibc/include/ctype.h119
-rw-r--r--klibc/include/dirent.h32
-rw-r--r--klibc/include/elf.h12
-rw-r--r--klibc/include/endian.h42
-rw-r--r--klibc/include/errno.h8
-rw-r--r--klibc/include/fcntl.h46
-rw-r--r--klibc/include/grp.h13
-rw-r--r--klibc/include/inttypes.h226
-rw-r--r--klibc/include/klibc/compiler.h123
-rw-r--r--klibc/include/klibc/diverr.h16
-rw-r--r--klibc/include/klibc/extern.h16
-rw-r--r--klibc/include/klibc/sysconfig.h34
-rw-r--r--klibc/include/limits.h40
-rw-r--r--klibc/include/malloc.h21
-rw-r--r--klibc/include/net/if.h1
-rw-r--r--klibc/include/net/if_arp.h1
-rw-r--r--klibc/include/net/if_packet.h1
-rw-r--r--klibc/include/net/route.h1
-rw-r--r--klibc/include/netinet/if_ether.h1
-rw-r--r--klibc/include/netinet/in.h39
-rw-r--r--klibc/include/netinet/in6.h10
-rw-r--r--klibc/include/netinet/ip.h13
-rw-r--r--klibc/include/netinet/tcp.h11
-rw-r--r--klibc/include/netinet/udp.h19
-rw-r--r--klibc/include/netpacket/packet.h1
-rw-r--r--klibc/include/paths.h74
-rw-r--r--klibc/include/poll.h16
-rw-r--r--klibc/include/sched.h36
-rw-r--r--klibc/include/setjmp.h43
-rw-r--r--klibc/include/signal.h88
-rw-r--r--klibc/include/stdarg.h14
-rw-r--r--klibc/include/stddef.h24
-rw-r--r--klibc/include/stdint.h116
-rw-r--r--klibc/include/stdio.h125
-rw-r--r--klibc/include/stdlib.h89
-rw-r--r--klibc/include/string.h46
-rw-r--r--klibc/include/sys/dirent.h21
-rw-r--r--klibc/include/sys/elf32.h115
-rw-r--r--klibc/include/sys/elf64.h115
-rw-r--r--klibc/include/sys/elfcommon.h188
-rw-r--r--klibc/include/sys/fsuid.h14
-rw-r--r--klibc/include/sys/inotify.h16
-rw-r--r--klibc/include/sys/ioctl.h14
-rw-r--r--klibc/include/sys/klog.h24
-rw-r--r--klibc/include/sys/mman.h25
-rw-r--r--klibc/include/sys/mount.h72
-rw-r--r--klibc/include/sys/param.h11
-rw-r--r--klibc/include/sys/reboot.h25
-rw-r--r--klibc/include/sys/resource.h15
-rw-r--r--klibc/include/sys/select.h14
-rw-r--r--klibc/include/sys/socket.h50
-rw-r--r--klibc/include/sys/socketcalls.h28
-rw-r--r--klibc/include/sys/stat.h31
-rw-r--r--klibc/include/sys/statfs.h1
-rw-r--r--klibc/include/sys/syscall.h17
-rw-r--r--klibc/include/sys/sysinfo.h12
-rw-r--r--klibc/include/sys/sysmacros.h31
-rw-r--r--klibc/include/sys/time.h18
-rw-r--r--klibc/include/sys/times.h14
-rw-r--r--klibc/include/sys/types.h104
-rw-r--r--klibc/include/sys/uio.h15
-rw-r--r--klibc/include/sys/un.h10
-rw-r--r--klibc/include/sys/utime.h10
-rw-r--r--klibc/include/sys/utsname.h23
-rw-r--r--klibc/include/sys/vfs.h112
-rw-r--r--klibc/include/sys/wait.h28
-rw-r--r--klibc/include/syslog.h64
-rw-r--r--klibc/include/termios.h86
-rw-r--r--klibc/include/time.h18
-rw-r--r--klibc/include/unistd.h140
-rw-r--r--klibc/include/utime.h15
-rw-r--r--klibc/klcc.1116
-rw-r--r--klibc/klcc.in258
-rw-r--r--klibc/klibc.spec.in126
-rw-r--r--klibc/klibc/CAVEATS61
-rw-r--r--klibc/klibc/Kbuild149
-rw-r--r--klibc/klibc/LICENSE73
-rw-r--r--klibc/klibc/MCONFIG20
-rw-r--r--klibc/klibc/Makefile192
-rw-r--r--klibc/klibc/README81
-rw-r--r--klibc/klibc/SOCKETCALLS.def21
-rw-r--r--klibc/klibc/SYSCALLS.def231
-rw-r--r--klibc/klibc/__put_env.c60
-rw-r--r--klibc/klibc/__shared_init.c2
-rw-r--r--klibc/klibc/__signal.c22
-rw-r--r--klibc/klibc/__static_init.c2
-rw-r--r--klibc/klibc/abort.c19
-rw-r--r--klibc/klibc/alarm.c25
-rw-r--r--klibc/klibc/arch/README67
-rw-r--r--klibc/klibc/arch/alpha/MCONFIG17
-rw-r--r--klibc/klibc/arch/alpha/Makefile.inc95
-rw-r--r--klibc/klibc/arch/alpha/README-gcc23
-rw-r--r--klibc/klibc/arch/alpha/crt0.S22
-rw-r--r--klibc/klibc/arch/alpha/divide.c57
-rw-r--r--klibc/klibc/arch/alpha/pipe.c28
-rw-r--r--klibc/klibc/arch/alpha/setjmp.S77
-rw-r--r--klibc/klibc/arch/alpha/syscall.S26
-rw-r--r--klibc/klibc/arch/alpha/sysdual.S33
-rw-r--r--klibc/klibc/arch/alpha/sysstub.ph37
-rw-r--r--klibc/klibc/arch/arm/MCONFIG26
-rw-r--r--klibc/klibc/arch/arm/Makefile.inc43
-rw-r--r--klibc/klibc/arch/arm/crt0.S23
-rw-r--r--klibc/klibc/arch/arm/setjmp-arm.S39
-rw-r--r--klibc/klibc/arch/arm/setjmp-thumb.S58
-rw-r--r--klibc/klibc/arch/arm/syscall.S50
-rw-r--r--klibc/klibc/arch/arm/sysstub.ph44
-rw-r--r--klibc/klibc/arch/cris/MCONFIG26
-rw-r--r--klibc/klibc/arch/cris/Makefile.inc33
-rw-r--r--klibc/klibc/arch/cris/__negdi2.S25
-rw-r--r--klibc/klibc/arch/cris/crt0.S28
-rw-r--r--klibc/klibc/arch/cris/divide.c92
-rw-r--r--klibc/klibc/arch/cris/setjmp.S37
-rw-r--r--klibc/klibc/arch/cris/syscall.S30
-rw-r--r--klibc/klibc/arch/cris/sysstub.ph29
-rw-r--r--klibc/klibc/arch/i386/MCONFIG33
-rw-r--r--klibc/klibc/arch/i386/Makefile.inc28
-rw-r--r--klibc/klibc/arch/i386/crt0.S32
-rw-r--r--klibc/klibc/arch/i386/exits.S45
-rw-r--r--klibc/klibc/arch/i386/libgcc/__ashldi3.S29
-rw-r--r--klibc/klibc/arch/i386/libgcc/__ashrdi3.S29
-rw-r--r--klibc/klibc/arch/i386/libgcc/__lshrdi3.S29
-rw-r--r--klibc/klibc/arch/i386/libgcc/__muldi3.S34
-rw-r--r--klibc/klibc/arch/i386/libgcc/__negdi2.S21
-rw-r--r--klibc/klibc/arch/i386/open.S29
-rw-r--r--klibc/klibc/arch/i386/setjmp.S58
-rw-r--r--klibc/klibc/arch/i386/sigreturn.S15
-rw-r--r--klibc/klibc/arch/i386/socketcall.S42
-rw-r--r--klibc/klibc/arch/i386/syscall.S60
-rw-r--r--klibc/klibc/arch/i386/sysstub.ph32
-rw-r--r--klibc/klibc/arch/ia64/MCONFIG11
-rw-r--r--klibc/klibc/arch/ia64/Makefile.inc26
-rw-r--r--klibc/klibc/arch/ia64/crt0.S27
-rw-r--r--klibc/klibc/arch/ia64/pipe.c42
-rw-r--r--klibc/klibc/arch/ia64/setjmp.S343
-rw-r--r--klibc/klibc/arch/ia64/syscall.S20
-rw-r--r--klibc/klibc/arch/ia64/sysstub.ph29
-rw-r--r--klibc/klibc/arch/ia64/vfork.S42
-rw-r--r--klibc/klibc/arch/m32r/MCONFIG18
-rw-r--r--klibc/klibc/arch/m32r/Makefile.inc19
-rw-r--r--klibc/klibc/arch/m32r/crt0.S25
-rw-r--r--klibc/klibc/arch/m32r/setjmp.S47
-rw-r--r--klibc/klibc/arch/m32r/syscall.S29
-rw-r--r--klibc/klibc/arch/m32r/sysstub.ph25
-rw-r--r--klibc/klibc/arch/m68k/MCONFIG11
-rw-r--r--klibc/klibc/arch/m68k/Makefile.inc10
-rw-r--r--klibc/klibc/arch/mips/MCONFIG15
-rw-r--r--klibc/klibc/arch/mips/Makefile.inc25
-rw-r--r--klibc/klibc/arch/mips/crt0.S25
-rw-r--r--klibc/klibc/arch/mips/klibc.ld217
-rw-r--r--klibc/klibc/arch/mips/pipe.S16
-rw-r--r--klibc/klibc/arch/mips/setjmp.S82
-rw-r--r--klibc/klibc/arch/mips/syscall.S15
-rw-r--r--klibc/klibc/arch/mips/sysstub.ph30
-rw-r--r--klibc/klibc/arch/mips/vfork.S16
-rw-r--r--klibc/klibc/arch/mips64/MCONFIG11
-rw-r--r--klibc/klibc/arch/mips64/Makefile.inc10
-rw-r--r--klibc/klibc/arch/parisc/MCONFIG11
-rw-r--r--klibc/klibc/arch/parisc/Makefile.inc19
-rw-r--r--klibc/klibc/arch/parisc/crt0.S34
-rw-r--r--klibc/klibc/arch/parisc/setjmp.S88
-rw-r--r--klibc/klibc/arch/parisc/syscall.c29
-rw-r--r--klibc/klibc/arch/parisc/sysstub.ph28
-rw-r--r--klibc/klibc/arch/ppc/MCONFIG18
-rw-r--r--klibc/klibc/arch/ppc/Makefile.inc22
-rw-r--r--klibc/klibc/arch/ppc/crt0.S20
-rw-r--r--klibc/klibc/arch/ppc/setjmp.S35
-rw-r--r--klibc/klibc/arch/ppc/syscall.S16
-rw-r--r--klibc/klibc/arch/ppc/sysstub.ph25
-rw-r--r--klibc/klibc/arch/ppc64/MCONFIG20
-rw-r--r--klibc/klibc/arch/ppc64/Makefile.inc25
-rw-r--r--klibc/klibc/arch/ppc64/crt0.S32
-rw-r--r--klibc/klibc/arch/ppc64/setjmp.S85
-rw-r--r--klibc/klibc/arch/ppc64/syscall.c14
-rw-r--r--klibc/klibc/arch/ppc64/sysstub.ph31
-rw-r--r--klibc/klibc/arch/s390/MCONFIG13
-rw-r--r--klibc/klibc/arch/s390/Makefile.inc23
-rw-r--r--klibc/klibc/arch/s390/crt0.S25
-rw-r--r--klibc/klibc/arch/s390/mmap.c41
-rw-r--r--klibc/klibc/arch/s390/setjmp.S32
-rw-r--r--klibc/klibc/arch/s390/syscall.c16
-rw-r--r--klibc/klibc/arch/s390/sysstub.ph31
-rw-r--r--klibc/klibc/arch/s390x/MCONFIG13
-rw-r--r--klibc/klibc/arch/s390x/Makefile.inc18
-rw-r--r--klibc/klibc/arch/s390x/crt0.S21
-rw-r--r--klibc/klibc/arch/s390x/mmap.c41
-rw-r--r--klibc/klibc/arch/s390x/setjmp.S36
-rw-r--r--klibc/klibc/arch/s390x/syscall.c16
-rw-r--r--klibc/klibc/arch/s390x/sysstub.ph28
-rw-r--r--klibc/klibc/arch/sh/MCONFIG19
-rw-r--r--klibc/klibc/arch/sh/Makefile.inc15
-rw-r--r--klibc/klibc/arch/sh/crt0.S27
-rw-r--r--klibc/klibc/arch/sh/setjmp.S65
-rw-r--r--klibc/klibc/arch/sh/syscall.S35
-rw-r--r--klibc/klibc/arch/sh/sysstub.ph34
-rw-r--r--klibc/klibc/arch/sparc/MCONFIG18
-rw-r--r--klibc/klibc/arch/sparc/Makefile.inc51
-rw-r--r--klibc/klibc/arch/sparc/crt0.S2
-rw-r--r--klibc/klibc/arch/sparc/crt0i.S100
-rw-r--r--klibc/klibc/arch/sparc/divrem.m4276
-rw-r--r--klibc/klibc/arch/sparc/setjmp.S38
-rw-r--r--klibc/klibc/arch/sparc/smul.S160
-rw-r--r--klibc/klibc/arch/sparc/syscall.S19
-rw-r--r--klibc/klibc/arch/sparc/sysfork.S25
-rw-r--r--klibc/klibc/arch/sparc/sysstub.ph25
-rw-r--r--klibc/klibc/arch/sparc/umul.S193
-rw-r--r--klibc/klibc/arch/sparc64/MCONFIG21
-rw-r--r--klibc/klibc/arch/sparc64/Makefile.inc15
-rw-r--r--klibc/klibc/arch/sparc64/crt0.S2
-rw-r--r--klibc/klibc/arch/sparc64/setjmp.S55
-rw-r--r--klibc/klibc/arch/sparc64/syscall.S18
-rw-r--r--klibc/klibc/arch/sparc64/sysfork.S26
-rw-r--r--klibc/klibc/arch/sparc64/sysstub.ph25
-rw-r--r--klibc/klibc/arch/x86_64/MCONFIG36
-rw-r--r--klibc/klibc/arch/x86_64/Makefile.inc18
-rw-r--r--klibc/klibc/arch/x86_64/crt0.S22
-rw-r--r--klibc/klibc/arch/x86_64/exits.S35
-rw-r--r--klibc/klibc/arch/x86_64/setjmp.S54
-rw-r--r--klibc/klibc/arch/x86_64/sigreturn.S15
-rw-r--r--klibc/klibc/arch/x86_64/syscall.S28
-rw-r--r--klibc/klibc/arch/x86_64/sysstub.ph23
-rw-r--r--klibc/klibc/asprintf.c30
-rw-r--r--klibc/klibc/assert.c13
-rw-r--r--klibc/klibc/atexit.c10
-rw-r--r--klibc/klibc/atexit.h17
-rw-r--r--klibc/klibc/atoi.c3
-rw-r--r--klibc/klibc/atol.c3
-rw-r--r--klibc/klibc/atoll.c3
-rw-r--r--klibc/klibc/atox.c14
-rw-r--r--klibc/klibc/brk.c24
-rw-r--r--klibc/klibc/bsd_signal.c11
-rw-r--r--klibc/klibc/calloc.c21
-rw-r--r--klibc/klibc/closelog.c18
-rw-r--r--klibc/klibc/creat.c12
-rw-r--r--klibc/klibc/ctypes.c284
-rw-r--r--klibc/klibc/daemon.c38
-rw-r--r--klibc/klibc/exec_l.c57
-rw-r--r--klibc/klibc/execl.c8
-rw-r--r--klibc/klibc/execle.c8
-rw-r--r--klibc/klibc/execlp.c8
-rw-r--r--klibc/klibc/execlpe.c8
-rw-r--r--klibc/klibc/execv.c13
-rw-r--r--klibc/klibc/execvp.c13
-rw-r--r--klibc/klibc/execvpe.c75
-rw-r--r--klibc/klibc/exitc.c23
-rw-r--r--klibc/klibc/fgetc.c20
-rw-r--r--klibc/klibc/fgets.c34
-rw-r--r--klibc/klibc/fopen.c40
-rw-r--r--klibc/klibc/fork.c20
-rw-r--r--klibc/klibc/fprintf.c19
-rw-r--r--klibc/klibc/fputc.c14
-rw-r--r--klibc/klibc/fputs.c15
-rw-r--r--klibc/klibc/fread.c36
-rw-r--r--klibc/klibc/fread2.c13
-rw-r--r--klibc/klibc/fstatfs.c19
-rw-r--r--klibc/klibc/fwrite.c36
-rw-r--r--klibc/klibc/fwrite2.c13
-rw-r--r--klibc/klibc/getcwd.c16
-rw-r--r--klibc/klibc/getdomainname.c25
-rw-r--r--klibc/klibc/getenv.c22
-rw-r--r--klibc/klibc/gethostname.c25
-rw-r--r--klibc/klibc/getopt.c75
-rw-r--r--klibc/klibc/getpgrp.c9
-rw-r--r--klibc/klibc/getpriority.c23
-rw-r--r--klibc/klibc/getpt.c17
-rw-r--r--klibc/klibc/globals.c10
-rw-r--r--klibc/klibc/inet/bindresvport.c45
-rw-r--r--klibc/klibc/inet/inet_addr.c14
-rw-r--r--klibc/klibc/inet/inet_aton.c23
-rw-r--r--klibc/klibc/inet/inet_ntoa.c19
-rw-r--r--klibc/klibc/inet/inet_ntop.c52
-rw-r--r--klibc/klibc/inet/inet_pton.c74
-rw-r--r--klibc/klibc/interp.S13
-rw-r--r--klibc/klibc/isatty.c21
-rw-r--r--klibc/klibc/jrand48.c24
-rw-r--r--klibc/klibc/libc_init.c86
-rw-r--r--klibc/klibc/libgcc/__divdi3.c29
-rw-r--r--klibc/klibc/libgcc/__divsi3.c29
-rw-r--r--klibc/klibc/libgcc/__moddi3.c29
-rw-r--r--klibc/klibc/libgcc/__modsi3.c29
-rw-r--r--klibc/klibc/libgcc/__udivdi3.c13
-rw-r--r--klibc/klibc/libgcc/__udivmoddi4.c32
-rw-r--r--klibc/klibc/libgcc/__udivmodsi4.c32
-rw-r--r--klibc/klibc/libgcc/__udivsi3.c13
-rw-r--r--klibc/klibc/libgcc/__umoddi3.c16
-rw-r--r--klibc/klibc/libgcc/__umodsi3.c16
-rw-r--r--klibc/klibc/llseek.c30
-rw-r--r--klibc/klibc/lrand48.c14
-rw-r--r--klibc/klibc/makeerrlist.pl100
-rw-r--r--klibc/klibc/malloc.c197
-rw-r--r--klibc/klibc/malloc.h45
-rw-r--r--klibc/klibc/memccpy.c23
-rw-r--r--klibc/klibc/memchr.c19
-rw-r--r--klibc/klibc/memcmp.c19
-rw-r--r--klibc/klibc/memcpy.c29
-rw-r--r--klibc/klibc/memmem.c52
-rw-r--r--klibc/klibc/memmove.c34
-rw-r--r--klibc/klibc/memrchr.c20
-rw-r--r--klibc/klibc/memset.c30
-rw-r--r--klibc/klibc/memswap.c23
-rw-r--r--klibc/klibc/mmap.c49
-rw-r--r--klibc/klibc/mrand48.c13
-rw-r--r--klibc/klibc/nice.c18
-rw-r--r--klibc/klibc/nrand48.c11
-rw-r--r--klibc/klibc/onexit.c39
-rw-r--r--klibc/klibc/open.c22
-rw-r--r--klibc/klibc/pause.c17
-rw-r--r--klibc/klibc/perror.c13
-rw-r--r--klibc/klibc/printf.c19
-rw-r--r--klibc/klibc/pty.c31
-rw-r--r--klibc/klibc/putchar.c15
-rw-r--r--klibc/klibc/putenv.c40
-rw-r--r--klibc/klibc/puts.c13
-rw-r--r--klibc/klibc/qsort.c42
-rw-r--r--klibc/klibc/raise.c11
-rw-r--r--klibc/klibc/readdir.c57
-rw-r--r--klibc/klibc/realloc.c49
-rw-r--r--klibc/klibc/reboot.c15
-rw-r--r--klibc/klibc/recv.c11
-rw-r--r--klibc/klibc/sbrk.c41
-rw-r--r--klibc/klibc/seed48.c19
-rw-r--r--klibc/klibc/send.c11
-rw-r--r--klibc/klibc/setegid.c10
-rw-r--r--klibc/klibc/setenv.c45
-rw-r--r--klibc/klibc/seteuid.c10
-rw-r--r--klibc/klibc/setpgrp.c10
-rw-r--r--klibc/klibc/sha1hash.c317
-rw-r--r--klibc/klibc/sigaction.c44
-rw-r--r--klibc/klibc/siglist.c115
-rw-r--r--klibc/klibc/siglongjmp.c16
-rw-r--r--klibc/klibc/sigpending.c17
-rw-r--r--klibc/klibc/sigprocmask.c17
-rw-r--r--klibc/klibc/sigsuspend.c17
-rw-r--r--klibc/klibc/sleep.c20
-rw-r--r--klibc/klibc/snprintf.c16
-rw-r--r--klibc/klibc/socketcalls.pl88
-rw-r--r--klibc/klibc/socketcommon.h16
-rw-r--r--klibc/klibc/sprintf.c18
-rw-r--r--klibc/klibc/srand48.c15
-rw-r--r--klibc/klibc/sscanf.c17
-rw-r--r--klibc/klibc/statfs.c19
-rw-r--r--klibc/klibc/strcasecmp.c23
-rw-r--r--klibc/klibc/strcat.c11
-rw-r--r--klibc/klibc/strchr.c19
-rw-r--r--klibc/klibc/strcmp.c20
-rw-r--r--klibc/klibc/strcpy.c20
-rw-r--r--klibc/klibc/strcspn.c11
-rw-r--r--klibc/klibc/strdup.c17
-rw-r--r--klibc/klibc/strerror.c34
-rw-r--r--klibc/klibc/strlcat.c33
-rw-r--r--klibc/klibc/strlcpy.c29
-rw-r--r--klibc/klibc/strlen.c14
-rw-r--r--klibc/klibc/strncasecmp.c23
-rw-r--r--klibc/klibc/strncat.c22
-rw-r--r--klibc/klibc/strncmp.c20
-rw-r--r--klibc/klibc/strncpy.c24
-rw-r--r--klibc/klibc/strndup.c17
-rw-r--r--klibc/klibc/strnlen.c19
-rw-r--r--klibc/klibc/strntoimax.c13
-rw-r--r--klibc/klibc/strntoumax.c76
-rw-r--r--klibc/klibc/strpbrk.c14
-rw-r--r--klibc/klibc/strrchr.c21
-rw-r--r--klibc/klibc/strsep.c21
-rw-r--r--klibc/klibc/strspn.c11
-rw-r--r--klibc/klibc/strstr.c10
-rw-r--r--klibc/klibc/strtoimax.c3
-rw-r--r--klibc/klibc/strtok.c16
-rw-r--r--klibc/klibc/strtol.c3
-rw-r--r--klibc/klibc/strtoll.c3
-rw-r--r--klibc/klibc/strtotimespec.c5
-rw-r--r--klibc/klibc/strtotimeval.c5
-rw-r--r--klibc/klibc/strtotimex.c39
-rw-r--r--klibc/klibc/strtoul.c3
-rw-r--r--klibc/klibc/strtoull.c3
-rw-r--r--klibc/klibc/strtoumax.c3
-rw-r--r--klibc/klibc/strtox.c13
-rw-r--r--klibc/klibc/strxspn.c30
-rw-r--r--klibc/klibc/strxspn.h13
-rw-r--r--klibc/klibc/syscalls.pl120
-rw-r--r--klibc/klibc/syscommon.h32
-rw-r--r--klibc/klibc/syslog.c87
-rw-r--r--klibc/klibc/system.c61
-rw-r--r--klibc/klibc/sysv_signal.c11
-rw-r--r--klibc/klibc/time.c23
-rw-r--r--klibc/klibc/umount.c12
-rw-r--r--klibc/klibc/unsetenv.c40
-rw-r--r--klibc/klibc/usleep.c15
-rw-r--r--klibc/klibc/utime.c24
-rw-r--r--klibc/klibc/vasprintf.c25
-rw-r--r--klibc/klibc/vfprintf.c26
-rw-r--r--klibc/klibc/vprintf.c11
-rw-r--r--klibc/klibc/vsnprintf.c433
-rw-r--r--klibc/klibc/vsprintf.c11
-rw-r--r--klibc/klibc/vsscanf.c365
-rw-r--r--klibc/klibc/wait.c12
-rw-r--r--klibc/klibc/wait3.c12
-rw-r--r--klibc/klibc/waitpid.c12
-rw-r--r--klibc/klibc/zlib/FAQ315
-rw-r--r--klibc/klibc/zlib/INDEX48
-rw-r--r--klibc/klibc/zlib/README126
-rw-r--r--klibc/klibc/zlib/adler32.c74
-rw-r--r--klibc/klibc/zlib/algorithm.txt209
-rw-r--r--klibc/klibc/zlib/compress.c79
-rw-r--r--klibc/klibc/zlib/crc32.c311
-rw-r--r--klibc/klibc/zlib/crc32.h441
-rw-r--r--klibc/klibc/zlib/deflate.c1502
-rw-r--r--klibc/klibc/zlib/deflate.h326
-rw-r--r--klibc/klibc/zlib/gzio.c1008
-rw-r--r--klibc/klibc/zlib/infback.c619
-rw-r--r--klibc/klibc/zlib/inffast.c305
-rw-r--r--klibc/klibc/zlib/inffast.h11
-rw-r--r--klibc/klibc/zlib/inffixed.h94
-rw-r--r--klibc/klibc/zlib/inflate.c1270
-rw-r--r--klibc/klibc/zlib/inflate.h117
-rw-r--r--klibc/klibc/zlib/inftrees.c321
-rw-r--r--klibc/klibc/zlib/inftrees.h55
-rw-r--r--klibc/klibc/zlib/trees.c1215
-rw-r--r--klibc/klibc/zlib/trees.h128
-rw-r--r--klibc/klibc/zlib/uncompr.c61
-rw-r--r--klibc/klibc/zlib/zconf.h323
-rw-r--r--klibc/klibc/zlib/zconf.in.h323
-rw-r--r--klibc/klibc/zlib/zlib.3159
-rw-r--r--klibc/klibc/zlib/zlib.h1200
-rw-r--r--klibc/klibc/zlib/zutil.c319
-rw-r--r--klibc/klibc/zlib/zutil.h258
-rwxr-xr-xklibc/makeklcc.pl55
-rw-r--r--klibc/version1
-rwxr-xr-xtest/simple-build-check.sh15
532 files changed, 25 insertions, 30176 deletions
diff --git a/ChangeLog b/ChangeLog
index e6fd84f582..3ef3c4b838 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+Summary of changes from v74 to v075
+============================================
+
Summary of changes from v73 to v074
============================================
diff --git a/Makefile b/Makefile
index bc97388a12..c105dab2e2 100644
--- a/Makefile
+++ b/Makefile
@@ -122,7 +122,6 @@ configdir = ${etcdir}/udev
udevdir = /dev
udevdb = ${udevdir}/.udevdb
LOCAL_CFG_DIR = etc/udev
-KERNEL_DIR = /lib/modules/${shell uname -r}/build
DESTDIR =
INSTALL = /usr/bin/install -c
@@ -177,8 +176,7 @@ endif
# if our own version of klibc is used, we need to build it
ifeq ($(strip $(USE_KLIBC)),true)
- KLIBC_INSTALL = $(PWD)/klibc/.install
- KLCC = $(KLIBC_INSTALL)/bin/$(CROSS)klcc
+ KLCC = /usr/bin/$(CROSS)klcc
CC = $(KLCC)
LD = $(KLCC)
V = true
@@ -203,7 +201,7 @@ else
HOST_PROGS=
endif
-all: $(KLCC) $(PROGRAMS) $(MAN_PAGES)
+all: $(PROGRAMS) $(MAN_PAGES)
@extras="$(EXTRAS)"; for target in $$extras; do \
echo $$target; \
$(MAKE) CC="$(CC)" \
@@ -214,7 +212,6 @@ all: $(KLCC) $(PROGRAMS) $(MAN_PAGES)
LIB_OBJS="$(LIB_OBJS)" \
LIBUDEV="$(PWD)/$(LIBUDEV)" \
LIBSYSFS="$(PWD)/$(LIBSYSFS)" \
- KERNEL_DIR="$(KERNEL_DIR)" \
QUIET="$(QUIET)" \
-C $$target $@; \
done;
@@ -229,28 +226,19 @@ all: $(KLCC) $(PROGRAMS) $(MAN_PAGES)
$(QUIET) $(CC) -c $(CFLAGS) $< -o $@
# "Static Pattern Rule" to build all programs
-$(PROGRAMS): %: $(HOST_PROGS) $(KLCC) $(HEADERS) $(GEN_HEADERS) $(LIBSYSFS) $(LIBUDEV) %.o
+$(PROGRAMS): %: $(HOST_PROGS) $(HEADERS) $(GEN_HEADERS) $(LIBSYSFS) $(LIBUDEV) %.o
$(QUIET) $(LD) $(LDFLAGS) $@.o -o $@ $(LIBUDEV) $(LIBSYSFS) $(LIB_OBJS)
ifneq ($(STRIPCMD),)
$(QUIET) $(STRIPCMD) $@
endif
-# our own copy of klibc, it is not used if KLCC is given
-$(KLCC):
- $(MAKE) -C klibc KRNLSRC=$(KERNEL_DIR) SUBDIRS=klibc TESTS= \
- SHLIBDIR=$(KLIBC_INSTALL)/lib \
- INSTALLDIR=$(KLIBC_INSTALL) \
- bindir=$(KLIBC_INSTALL)/bin \
- mandir=$(KLIBC_INSTALL)/man all install
-.NOTPARALLEL: $(KLCC)
-
-$(UDEV_OBJS): $(KLCC)
+$(UDEV_OBJS):
$(LIBUDEV): $(HOST_PROGS) $(HEADERS) $(GEN_HEADERS) $(UDEV_OBJS)
@rm -f $@
$(QUIET) $(AR) cq $@ $(UDEV_OBJS)
$(QUIET) $(RANLIB) $@
-$(SYSFS_OBJS): $(KLCC)
+$(SYSFS_OBJS):
$(LIBSYSFS): $(HOST_PROGS) $(SYSFS_OBJS)
@rm -f $@
$(QUIET) $(AR) cq $@ $(SYSFS_OBJS)
@@ -288,13 +276,10 @@ clean:
- rm -f udev_gcov.txt
- rm -f core $(PROGRAMS) $(GEN_HEADERS) $(GEN_CONFIGS)
- rm -f udev-$(VERSION).tar.gz
- $(MAKE) -C klibc SUBDIRS=klibc clean
@extras="$(EXTRAS)"; for target in $$extras; do \
echo $$target; \
$(MAKE) -C $$target $@; \
done;
- $(MAKE) -C klibc SUBDIRS=klibc spotless
- rm -rf klibc/.install
.PHONY: clean
release:
diff --git a/README b/README
index 19ed4468ea..3f4f947f79 100644
--- a/README
+++ b/README
@@ -45,9 +45,7 @@ Setting which are used for building udev:
USE_LOG
if set to 'true', udev will emit messages to the syslog when
it creates or removes device nodes. This is helpful to see
- what udev is doing. This is enabled by default. Note, if you
- are building udev against klibc it is recommended that you
- disable this option (due to klibc's syslog implementation.)
+ what udev is doing. This is enabled by default.
DEBUG
if set to 'true', verbose debugging messages will be compiled into
the udev binaries. Default value is 'false'.
@@ -55,20 +53,13 @@ Setting which are used for building udev:
if set to 'true', udev will be built with SELinux support
enabled. This is disabled by default.
USE_KLIBC
- if set to 'true', udev is built and linked against the
- included version of klibc. Default value is 'false'.
- KERNEL_DIR
- If this is not set it will default to /lib/modules/`uname -r`/build
- This is used if USE_KLIBC=true to find the kernel include
- directory that klibc needs to build against. This must be set
- if you are not building udev while running a 2.6 kernel.
+ if set to 'true', udev is built and linked against klibc.
+ Default value is 'false'. KLCC specifies the klibc compiler
+ wrapper, usually in /usr/bin/klcc
EXTRAS
if set, will build the "extra" helper programs as specified
as listed (see below for an example.)
-if you want to build udev using klibc with debugging messages:
- make USE_KLIBC=true DEBUG=true
-
if you want to build the udev helper program cdrom_id and scsi_id:
make EXTRAS="extras/cdrom_id extras/scsi_id"
diff --git a/RELEASE-NOTES b/RELEASE-NOTES
index 8a1bde8a3b..d89aeaa69f 100644
--- a/RELEASE-NOTES
+++ b/RELEASE-NOTES
@@ -1,3 +1,8 @@
+udev 075
+========
+The copy of klibc is removed. A systemwide installed version of klibc
+can be used to buil a klibc udev.
+
udev 074
========
NAME="" will not create any nodes, but execute RUN keys. To completely
diff --git a/klibc/MCONFIG b/klibc/MCONFIG
deleted file mode 100644
index 450e5c7f5c..0000000000
--- a/klibc/MCONFIG
+++ /dev/null
@@ -1,98 +0,0 @@
-# -*- makefile -*-
-#
-# Makefile configuration, without explicit rules
-#
-
-# CROSS is the prefix used for system tools like gcc, ld etc.
-CROSS =
-
-# KCROSS is the prefix we use for klibc installations. This is usually
-# the same as CROSS, but may be different, e.g. to install an i386
-# cross-compilation suite on an x86-64 system, using the same gcc/binutils.
-KCROSS ?= $(CROSS)
-
-# Location for installation
-prefix = /usr
-bindir = $(prefix)/bin
-libdir = $(prefix)/lib
-mandir = $(prefix)/man
-INSTALLDIR = $(prefix)/lib/klibc
-INSTALLROOT =
-
-INSTALL_EXEC = install -m 755
-INSTALL_DATA = install -m 644
-
-# Eventually support separate compilation, but we don't have it yet...
-OBJROOT = $(SRCROOT)
-
-# Kernel trees (source and obj) - can potentially be different
-KRNLSRC = $(SRCROOT)/linux
-KRNLOBJ = $(SRCROOT)/linux
-
-# klibc version information
-KLIBCVER = -D__KLIBC__=$(shell cut -d. -f1 < $(SRCROOT)/version) \
- -D__KLIBC_MINOR__=$(shell cut -d. -f2 < $(SRCROOT)/version)
-
-ARCH = $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/ -e s/parisc.*/parisc/)
-CC = $(CROSS)gcc
-LD = $(CROSS)ld
-KLIBSRC = $(SRCROOT)/klibc
-KLIBOBJ = $(OBJROOT)/klibc
-INCLUDE = -I$(SRCROOT)/include/arch/$(ARCH) \
- -I$(SRCROOT)/include/bits$(BITSIZE) \
- -I$(SRCROOT)/include \
- -I$(KRNLOBJ)/include -I$(KRNLOBJ)/include2 -I$(KRNLSRC)/include
-REQFLAGS = $(ARCHREQFLAGS) $(KLIBCVER) -nostdlib -nostdinc -iwithprefix include \
- $(INCLUDE)
-LDFLAGS =
-AR = $(CROSS)ar
-RANLIB = $(CROSS)ranlib
-NM = $(CROSS)nm
-PERL = perl
-OBJCOPY = $(CROSS)objcopy
-
-STRIP = $(CROSS)strip
-STRIPFLAGS = --strip-all -R .comment -R .note
-STRIPCMD = $(STRIP) $(STRIPFLAGS)
-
-HOST_CC = gcc
-HOST_CFLAGS = -g -O
-HOST_LDFLAGS =
-HOST_LIBS =
-
-# Static library paths
-CRT0 = $(KLIBOBJ)/crt0.o
-KLIBC = $(KLIBOBJ)/libc.a
-LIBGCC = $(shell $(CC) $(REQFLAGS) $(OPTFLAGS) --print-libgcc)
-
-# Shared library paths
-CRTSHARED = $(KLIBOBJ)/interp.o
-LIBSHARED = $(KLIBOBJ)/libc.so
-
-#
-# This indicates the location of the final version of the shared library.
-# THIS MUST BE AN ABSOLUTE PATH WITH NO FINAL SLASH.
-# Leave this empty to make it the root.
-#
-SHLIBDIR = /lib
-
-# Enable this to make perror/strerror return real error messages
-# This makes klibc.so and any static binary which uses these functions
-# about 4K bigger.
-ERRLIST = 1
-
-# Include zlib in klibc. This roughly triples the size of klibc!
-ZLIB = 0
-
-#
-# Include arch-specific rule fragments
-#
-include $(KLIBSRC)/arch/$(ARCH)/MCONFIG
-
-ifeq ($(DEBUG),y)
-STRIP = /bin/true -Since_we_are_debugging
-OPTFLAGS += -O1 -g
-endif
-
-# How to tell the linker main() is the entrypoint
-EMAIN ?= -e main
diff --git a/klibc/MRULES b/klibc/MRULES
deleted file mode 100644
index 41fdd07af8..0000000000
--- a/klibc/MRULES
+++ /dev/null
@@ -1,45 +0,0 @@
-# -*- makefile -*-
-#
-# Standard pattern rules
-#
-
-.SUFFIXES: .c .o .a .so .lo .i .S .s .ls .ss .lss
-
-% : %.c # Cancel default rule
-
-% : %.S
-
-.c.o:
- $(CC) $(CFLAGS) -c -o $@ $<
-
-.c.i:
- $(CC) $(CFLAGS) -E -o $@ $<
-
-.c.s:
- $(CC) $(CFLAGS) -S -o $@ $<
-
-.S.o:
- $(CC) $(CFLAGS) -D__ASSEMBLY__ -c -o $@ $<
-
-.S.s:
- $(CC) $(CFLAGS) -D__ASSEMBLY__ -E -o $@ $<
-
-.S.lo:
- $(CC) $(CFLAGS) $(SOFLAGS) -D__ASSEMBLY__ -c -o $@ $<
-
-.S.ls:
- $(CC) $(CFLAGS) $(SOFLAGS) -D__ASSEMBLY__ -E -o $@ $<
-
-.s.o:
- $(CC) $(CFLAGS) -x assembler -c -o $@ $<
-
-.ls.lo:
- $(CC) $(CFLAGS) $(SOFLAGS) -x assembler -c -o $@ $<
-
-.c.lo:
- $(CC) $(CFLAGS) $(SOFLAGS) -c -o $@ $<
-
-.c.ls:
- $(CC) $(CFLAGS) $(SOFLAGS) -S -o $@ $<
-
-
diff --git a/klibc/Makefile b/klibc/Makefile
deleted file mode 100644
index e634aaccb5..0000000000
--- a/klibc/Makefile
+++ /dev/null
@@ -1,77 +0,0 @@
-VERSION := $(shell cat version)
-SUBDIRS = klibc ash ipconfig nfsmount utils kinit gzip
-SRCROOT = .
-
-all:
-
-rpmbuild = $(shell which rpmbuild 2>/dev/null || which rpm)
-
-klibc.spec: klibc.spec.in version
- sed -e 's/@@VERSION@@/$(VERSION)/g' < $< > $@
-
-.PHONY: rpm
-rpm: klibc.spec
- +$(rpmbuild) -bb klibc.spec --target=$(ARCH)
-
-$(CROSS)klibc.config: Makefile
- rm -f $@
- echo 'ARCH=$(ARCH)' >> $@
- echo 'CROSS=$(CROSS)' >> $@
- echo 'KCROSS=$(KCROSS)' >> $@
- echo 'CC=$(CC)' >> $@
- echo 'LD=$(LD)' >> $@
- echo 'REQFLAGS=$(filter-out -I%,$(REQFLAGS))' >> $@
- echo 'OPTFLAGS=$(OPTFLAGS)' >> $@
- echo 'LDFLAGS=$(LDFLAGS)' >> $@
- echo 'STRIP=$(STRIP)' >> $@
- echo 'STRIPFLAGS=$(STRIPFLAGS)' >> $@
- echo 'EMAIN=$(EMAIN)' >> $@
- echo 'BITSIZE=$(BITSIZE)' >> $@
- echo 'prefix=$(INSTALLDIR)' >> $@
- echo 'bindir=$(INSTALLDIR)/$(KCROSS)bin' >> $@
- echo 'libdir=$(INSTALLDIR)/$(KCROSS)lib' >> $@
- echo 'includedir=$(INSTALLDIR)/$(KCROSS)include' >> $@
-
-$(CROSS)klcc: klcc.in $(CROSS)klibc.config makeklcc.pl
- $(PERL) makeklcc.pl klcc.in $(CROSS)klibc.config \
- $(shell bash -c 'type -p $(PERL)') > $@ || ( rm -f $@ ; exit 1 )
- chmod a+x $@
-
-%: local-%
- @set -e; for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
-
-local-all: $(CROSS)klcc
-
-local-clean:
- rm -f klibc.config klcc
-
-local-spotless: local-clean
- rm -f klibc.spec *~ tags
-
-local-install: $(CROSS)klcc
- mkdir -p $(INSTALLROOT)$(bindir)
- mkdir -p $(INSTALLROOT)$(mandir)/man1
- mkdir -p $(INSTALLROOT)$(SHLIBDIR)
- mkdir -p $(INSTALLROOT)$(INSTALLDIR)
- -rm -rf $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)include
- mkdir -p $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)include
- mkdir -p $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)lib
- mkdir -p $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)bin
- set -xe ; for d in linux scsi asm-$(ARCH) asm-generic $(ASMARCH); do \
- mkdir -p $(INSTALLROOT)$(INSTALLDIR)/$(CROSS)include/$$d ; \
- for r in $(KRNLSRC)/include $(KRNLOBJ)/include $(KRNLOBJ)/include2 ; do \
- [ ! -d $$r/$$d ] || \
- cp -rfL $$r/$$d/. $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)include/$$d/. ; \
- done ; \
- done
- cd $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)include && ln -sf asm-$(ARCH) asm
- cp -rf include/. $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)include/.
- $(INSTALL_DATA) klcc.1 $(INSTALLROOT)$(mandir)/man1/$(KCROSS)klcc.1
- $(INSTALL_EXEC) $(KCROSS)klcc $(INSTALLROOT)$(bindir)
-
-# This does all the prep work needed to turn a freshly exported git repository
-# into a release tarball tree
-release: klibc.spec
- rm -f maketar.sh
-
--include MCONFIG
diff --git a/klibc/README b/klibc/README
deleted file mode 100644
index eb72e1c239..0000000000
--- a/klibc/README
+++ /dev/null
@@ -1,21 +0,0 @@
-Please see klibc/README for build instructions and for the status of
-various platforms.
-
-
-
-klibc is archived at:
-
- ftp://ftp.kernel.org/pub/linux/libs/klibc/
-
-There is a mailing list for klibc and early-userspace issues at:
-
- http://www.zytor.com/mailman/listinfo/klibc/
-
-There is also a cvsweb repository at:
-
- http://www.zytor.com/cvsweb.cgi/klibc/
-
-There is no direct public CVS access yet, however, the CVS repository
-is available for rsync from:
-
- rsync://rsync.kernel.org/pub/linux/libs/klibc/cvsroot/
diff --git a/klibc/include/alloca.h b/klibc/include/alloca.h
deleted file mode 100644
index 41a4d94d44..0000000000
--- a/klibc/include/alloca.h
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * alloca.h
- *
- * Just call the builtin alloca() function
- */
-
-#ifndef _ALLOCA_H
-#define _ALLOCA_H
-
-#define alloca(size) __builtin_alloca(size)
-
-#endif /* _ALLOCA_H */
-
diff --git a/klibc/include/arch/alpha/klibc/archsetjmp.h b/klibc/include/arch/alpha/klibc/archsetjmp.h
deleted file mode 100644
index 9dc570a6f5..0000000000
--- a/klibc/include/arch/alpha/klibc/archsetjmp.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * arch/alpha/include/klibc/archsetjmp.h
- */
-
-#ifndef _KLIBC_ARCHSETJMP_H
-#define _KLIBC_ARCHSETJMP_H
-
-struct __jmp_buf {
- unsigned long __s0;
- unsigned long __s1;
- unsigned long __s2;
- unsigned long __s3;
- unsigned long __s4;
- unsigned long __s5;
- unsigned long __fp;
- unsigned long __ra;
- unsigned long __gp;
- unsigned long __sp;
-
- unsigned long __f2;
- unsigned long __f3;
- unsigned long __f4;
- unsigned long __f5;
- unsigned long __f6;
- unsigned long __f7;
- unsigned long __f8;
- unsigned long __f9;
-};
-
-/* Must be an array so it will decay to a pointer when a function is called */
-typedef struct __jmp_buf jmp_buf[1];
-
-#endif /* _KLIBC_ARCHSETJMP_H */
diff --git a/klibc/include/arch/alpha/klibc/archsignal.h b/klibc/include/arch/alpha/klibc/archsignal.h
deleted file mode 100644
index b870a05131..0000000000
--- a/klibc/include/arch/alpha/klibc/archsignal.h
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * arch/alpha/include/klibc/archsignal.h
- *
- * Architecture-specific signal definitions
- *
- */
-
-#ifndef _KLIBC_ARCHSIGNAL_H
-#define _KLIBC_ARCHSIGNAL_H
-
-/* No special stuff for this architecture */
-
-#endif
diff --git a/klibc/include/arch/alpha/klibc/archstat.h b/klibc/include/arch/alpha/klibc/archstat.h
deleted file mode 100644
index 23302d737d..0000000000
--- a/klibc/include/arch/alpha/klibc/archstat.h
+++ /dev/null
@@ -1,26 +0,0 @@
-#ifndef _KLIBC_ARCHSTAT_H
-#define _KLIBC_ARCHSTAT_H
-
-#define _STATBUF_ST_NSEC
-
-struct stat {
- unsigned long st_dev;
- unsigned long st_ino;
- unsigned long st_rdev;
- long st_size;
- unsigned long st_blocks;
-
- unsigned int st_mode;
- unsigned int st_uid;
- unsigned int st_gid;
- unsigned int st_blksize;
- unsigned int st_nlink;
- unsigned int __pad0;
-
- struct timespec st_atim;
- struct timespec st_mtim;
- struct timespec st_ctim;
- long __unused[3];
-};
-
-#endif
diff --git a/klibc/include/arch/alpha/klibc/archsys.h b/klibc/include/arch/alpha/klibc/archsys.h
deleted file mode 100644
index 16ed658987..0000000000
--- a/klibc/include/arch/alpha/klibc/archsys.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * arch/alpha/include/klibc/archsys.h
- *
- * Architecture-specific syscall definitions
- */
-
-#ifndef _KLIBC_ARCHSYS_H
-#define _KLIBC_ARCHSYS_H
-
-/* Alpha has some bizarre Tru64-derived system calls which return two
- different values in $0 and $20(!), respectively. The standard
- macros can't deal with these; even the ones that give the right
- return value have the wrong clobbers. */
-
-#define _syscall0_dual0(type, name) \
-type name(void) \
-{ \
- long _sc_ret, _sc_err; \
- { \
- register long _sc_0 __asm__("$0"); \
- register long _sc_19 __asm__("$19"); \
- register long _sc_20 __asm__("$20"); \
- \
- _sc_0 = __NR_##name; \
- __asm__("callsys" \
- : "=r"(_sc_0), "=r"(_sc_19), "=r" (_sc_20) \
- : "0"(_sc_0) \
- : _syscall_clobbers); \
- _sc_ret = _sc_0, _sc_err = _sc_19; (void)(_sc_20); \
- } \
- _syscall_return(type); \
-}
-
-#define _syscall0_dual1(type, name) \
-type name(void) \
-{ \
- long _sc_ret, _sc_err; \
- { \
- register long _sc_0 __asm__("$0"); \
- register long _sc_19 __asm__("$19"); \
- register long _sc_20 __asm__("$20"); \
- \
- _sc_0 = __NR_##name; \
- __asm__("callsys" \
- : "=r"(_sc_0), "=r"(_sc_19), "=r" (_sc_20) \
- : "0"(_sc_0) \
- : _syscall_clobbers); \
- _sc_ret = _sc_20, _sc_err = _sc_19; (void)(_sc_0); \
- } \
- _syscall_return(type); \
-}
-
-#endif /* _KLIBC_ARCHSYS_H */
diff --git a/klibc/include/arch/alpha/machine/asm.h b/klibc/include/arch/alpha/machine/asm.h
deleted file mode 100644
index e22db90412..0000000000
--- a/klibc/include/arch/alpha/machine/asm.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * machine/asm.h
- */
-
-#ifndef _MACHINE_ASM_H
-#define _MACHINE_ASM_H
-
-/* Standard aliases for Alpha register names */
-
-#define v0 $0
-#define t0 $1
-#define t1 $2
-#define t2 $3
-#define t3 $4
-#define t4 $5
-#define t5 $6
-#define t6 $7
-#define t7 $8
-#define s0 $9
-#define s1 $10
-#define s2 $11
-#define s3 $12
-#define s4 $13
-#define s5 $14
-#define fp $15
-#define a0 $16
-#define a1 $17
-#define a2 $18
-#define a3 $19
-#define a4 $20
-#define a5 $21
-#define t8 $22
-#define t9 $23
-#define t10 $24
-#define t11 $25
-#define ra $26
-#define t12 $27 /* t12 and pv are both used for $27 */
-#define pv $27 /* t12 and pv are both used for $27 */
-#define at $28
-#define gp $29
-#define sp $30
-#define zero $31
-
-#endif /* _MACHINE_ASM_H */
diff --git a/klibc/include/arch/arm/klibc/archsetjmp.h b/klibc/include/arch/arm/klibc/archsetjmp.h
deleted file mode 100644
index c956b50a90..0000000000
--- a/klibc/include/arch/arm/klibc/archsetjmp.h
+++ /dev/null
@@ -1,14 +0,0 @@
-/*
- * arch/i386/include/klibc/archsetjmp.h
- */
-
-#ifndef _KLIBC_ARCHSETJMP_H
-#define _KLIBC_ARCHSETJMP_H
-
-struct __jmp_buf {
- unsigned int regs[10];
-};
-
-typedef struct __jmp_buf jmp_buf[1];
-
-#endif /* _SETJMP_H */
diff --git a/klibc/include/arch/arm/klibc/archsignal.h b/klibc/include/arch/arm/klibc/archsignal.h
deleted file mode 100644
index 77685e62f0..0000000000
--- a/klibc/include/arch/arm/klibc/archsignal.h
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * arch/arm/include/klibc/archsignal.h
- *
- * Architecture-specific signal definitions
- *
- */
-
-#ifndef _KLIBC_ARCHSIGNAL_H
-#define _KLIBC_ARCHSIGNAL_H
-
-/* No special stuff for this architecture */
-
-#endif
diff --git a/klibc/include/arch/arm/klibc/archstat.h b/klibc/include/arch/arm/klibc/archstat.h
deleted file mode 100644
index 42b1409f67..0000000000
--- a/klibc/include/arch/arm/klibc/archstat.h
+++ /dev/null
@@ -1,45 +0,0 @@
-#ifndef _KLIBC_ARCHSTAT_H
-#define _KLIBC_ARCHSTAT_H
-
-#include <endian.h>
-
-#define _STATBUF_ST_NSEC
-
-/* This matches struct stat64 in glibc2.1, hence the absolutely
- * insane amounts of padding around dev_t's.
- * Note: The kernel zero's the padded region because glibc might read them
- * in the hope that the kernel has stretched to using larger sizes.
- */
-struct stat {
- unsigned long long st_dev;
- unsigned char __pad0[4];
-
- unsigned long __st_ino;
- unsigned int st_mode;
- unsigned int st_nlink;
-
- unsigned long st_uid;
- unsigned long st_gid;
-
- unsigned long long st_rdev;
- unsigned char __pad3[4];
-
- long long st_size;
- unsigned long st_blksize;
-
-#if __BYTE_ORDER == __BIG_ENDIAN
- unsigned long __pad4; /* Future possible st_blocks hi bits */
- unsigned long st_blocks; /* Number 512-byte blocks allocated. */
-#else /* Must be little */
- unsigned long st_blocks; /* Number 512-byte blocks allocated. */
- unsigned long __pad4; /* Future possible st_blocks hi bits */
-#endif
-
- struct timespec st_atim;
- struct timespec st_mtim;
- struct timespec st_ctim;
-
- unsigned long long st_ino;
-};
-
-#endif
diff --git a/klibc/include/arch/arm/klibc/archsys.h b/klibc/include/arch/arm/klibc/archsys.h
deleted file mode 100644
index dfdc70a6de..0000000000
--- a/klibc/include/arch/arm/klibc/archsys.h
+++ /dev/null
@@ -1,12 +0,0 @@
-/*
- * arch/cris/include/klibc/archsys.h
- *
- * Architecture-specific syscall definitions
- */
-
-#ifndef _KLIBC_ARCHSYS_H
-#define _KLIBC_ARCHSYS_H
-
-/* No special syscall definitions for this architecture */
-
-#endif /* _KLIBC_ARCHSYS_H */
diff --git a/klibc/include/arch/cris/klibc/archsetjmp.h b/klibc/include/arch/cris/klibc/archsetjmp.h
deleted file mode 100644
index 8d20800609..0000000000
--- a/klibc/include/arch/cris/klibc/archsetjmp.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * arch/cris/include/klibc/archsetjmp.h
- */
-
-#ifndef _KLIBC_ARCHSETJMP_H
-#define _KLIBC_ARCHSETJMP_H
-
-struct __jmp_buf {
- unsigned long __r0;
- unsigned long __r1;
- unsigned long __r2;
- unsigned long __r3;
- unsigned long __r4;
- unsigned long __r5;
- unsigned long __r6;
- unsigned long __r7;
- unsigned long __r8;
- unsigned long __sp;
- unsigned long __srp;
-};
-
-typedef struct __jmp_buf jmp_buf[1];
-
-#endif /* _KLIBC_ARCHSETJMP_H */
diff --git a/klibc/include/arch/cris/klibc/archsignal.h b/klibc/include/arch/cris/klibc/archsignal.h
deleted file mode 100644
index 73b2e196c9..0000000000
--- a/klibc/include/arch/cris/klibc/archsignal.h
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * arch/cris/include/klibc/archsignal.h
- *
- * Architecture-specific signal definitions
- *
- */
-
-#ifndef _KLIBC_ARCHSIGNAL_H
-#define _KLIBC_ARCHSIGNAL_H
-
-/* No special stuff for this architecture */
-
-#endif
diff --git a/klibc/include/arch/cris/klibc/archstat.h b/klibc/include/arch/cris/klibc/archstat.h
deleted file mode 100644
index 154820755f..0000000000
--- a/klibc/include/arch/cris/klibc/archstat.h
+++ /dev/null
@@ -1,37 +0,0 @@
-#ifndef _KLIBC_ARCHSTAT_H
-#define _KLIBC_ARCHSTAT_H
-
-#define _STATBUF_ST_NSEC
-
-/* This matches struct stat64 in glibc2.1, hence the absolutely
- * insane amounts of padding around dev_t's.
- */
-struct stat {
- unsigned long long st_dev;
- unsigned char __pad0[4];
-
- unsigned long __st_ino;
-
- unsigned int st_mode;
- unsigned int st_nlink;
-
- unsigned long st_uid;
- unsigned long st_gid;
-
- unsigned long long st_rdev;
- unsigned char __pad3[4];
-
- long long st_size;
- unsigned long st_blksize;
-
- unsigned long st_blocks; /* Number 512-byte blocks allocated. */
- unsigned long __pad4; /* future possible st_blocks high bits */
-
- struct timespec st_atim;
- struct timespec st_mtim;
- struct timespec st_ctim;
-
- unsigned long long st_ino;
-};
-
-#endif
diff --git a/klibc/include/arch/cris/klibc/archsys.h b/klibc/include/arch/cris/klibc/archsys.h
deleted file mode 100644
index dfdc70a6de..0000000000
--- a/klibc/include/arch/cris/klibc/archsys.h
+++ /dev/null
@@ -1,12 +0,0 @@
-/*
- * arch/cris/include/klibc/archsys.h
- *
- * Architecture-specific syscall definitions
- */
-
-#ifndef _KLIBC_ARCHSYS_H
-#define _KLIBC_ARCHSYS_H
-
-/* No special syscall definitions for this architecture */
-
-#endif /* _KLIBC_ARCHSYS_H */
diff --git a/klibc/include/arch/i386/klibc/archsetjmp.h b/klibc/include/arch/i386/klibc/archsetjmp.h
deleted file mode 100644
index db04314b8c..0000000000
--- a/klibc/include/arch/i386/klibc/archsetjmp.h
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * arch/i386/include/klibc/archsetjmp.h
- */
-
-#ifndef _KLIBC_ARCHSETJMP_H
-#define _KLIBC_ARCHSETJMP_H
-
-struct __jmp_buf {
- unsigned int __ebx;
- unsigned int __esp;
- unsigned int __ebp;
- unsigned int __esi;
- unsigned int __edi;
- unsigned int __eip;
-};
-
-typedef struct __jmp_buf jmp_buf[1];
-
-#endif /* _SETJMP_H */
diff --git a/klibc/include/arch/i386/klibc/archsignal.h b/klibc/include/arch/i386/klibc/archsignal.h
deleted file mode 100644
index b092ba6d3a..0000000000
--- a/klibc/include/arch/i386/klibc/archsignal.h
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * arch/i386/include/klibc/archsignal.h
- *
- * Architecture-specific signal definitions
- *
- */
-
-#ifndef _KLIBC_ARCHSIGNAL_H
-#define _KLIBC_ARCHSIGNAL_H
-
-/* No special stuff for this architecture */
-
-#endif
diff --git a/klibc/include/arch/i386/klibc/archstat.h b/klibc/include/arch/i386/klibc/archstat.h
deleted file mode 100644
index 154820755f..0000000000
--- a/klibc/include/arch/i386/klibc/archstat.h
+++ /dev/null
@@ -1,37 +0,0 @@
-#ifndef _KLIBC_ARCHSTAT_H
-#define _KLIBC_ARCHSTAT_H
-
-#define _STATBUF_ST_NSEC
-
-/* This matches struct stat64 in glibc2.1, hence the absolutely
- * insane amounts of padding around dev_t's.
- */
-struct stat {
- unsigned long long st_dev;
- unsigned char __pad0[4];
-
- unsigned long __st_ino;
-
- unsigned int st_mode;
- unsigned int st_nlink;
-
- unsigned long st_uid;
- unsigned long st_gid;
-
- unsigned long long st_rdev;
- unsigned char __pad3[4];
-
- long long st_size;
- unsigned long st_blksize;
-
- unsigned long st_blocks; /* Number 512-byte blocks allocated. */
- unsigned long __pad4; /* future possible st_blocks high bits */
-
- struct timespec st_atim;
- struct timespec st_mtim;
- struct timespec st_ctim;
-
- unsigned long long st_ino;
-};
-
-#endif
diff --git a/klibc/include/arch/i386/klibc/archsys.h b/klibc/include/arch/i386/klibc/archsys.h
deleted file mode 100644
index dfdc70a6de..0000000000
--- a/klibc/include/arch/i386/klibc/archsys.h
+++ /dev/null
@@ -1,12 +0,0 @@
-/*
- * arch/cris/include/klibc/archsys.h
- *
- * Architecture-specific syscall definitions
- */
-
-#ifndef _KLIBC_ARCHSYS_H
-#define _KLIBC_ARCHSYS_H
-
-/* No special syscall definitions for this architecture */
-
-#endif /* _KLIBC_ARCHSYS_H */
diff --git a/klibc/include/arch/i386/klibc/diverr.h b/klibc/include/arch/i386/klibc/diverr.h
deleted file mode 100644
index 410aba06d3..0000000000
--- a/klibc/include/arch/i386/klibc/diverr.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * arch/i386/include/klibc/diverr.h
- */
-
-#ifndef _KLIBC_DIVERR_H
-#define _KLIBC_DIVERR_H
-
-#include <signal.h>
-
-static __inline__ void
-__divide_error(void)
-{
- asm volatile("divl %0" :: "rm" (0) : "eax", "edx");
-}
-
-#endif /* _KLIBC_DIVERR_H */
diff --git a/klibc/include/arch/i386/sys/io.h b/klibc/include/arch/i386/sys/io.h
deleted file mode 100644
index b051464dfc..0000000000
--- a/klibc/include/arch/i386/sys/io.h
+++ /dev/null
@@ -1,126 +0,0 @@
-#ident "$Id: io.h,v 1.2 2004/01/25 07:49:39 hpa Exp $"
-/* ----------------------------------------------------------------------- *
- *
- * Copyright 2004 H. Peter Anvin - All Rights Reserved
- *
- * 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.
- *
- * ----------------------------------------------------------------------- */
-
-/*
- * sys/io.h for the i386 architecture
- *
- * Basic I/O macros
- */
-
-#ifndef _SYS_IO_H
-#define _SYS_IO_H 1
-
-/* I/O-related system calls */
-
-int iopl(int);
-int ioperm(unsigned long, unsigned long, int);
-
-/* Basic I/O macros */
-
-static __inline__ void
-outb(unsigned char __v, unsigned short __p)
-{
- asm volatile("outb %0,%1" : : "a" (__v), "dN" (__p));
-}
-
-static __inline__ void
-outw(unsigned short __v, unsigned short __p)
-{
- asm volatile("outw %0,%1" : : "a" (__v), "dN" (__p));
-}
-
-static __inline__ void
-outl(unsigned int __v, unsigned short __p)
-{
- asm volatile("outl %0,%1" : : "a" (__v), "dN" (__p));
-}
-
-static __inline__ unsigned char
-inb(unsigned short __p)
-{
- unsigned char __v;
- asm volatile("inb %1,%0" : "=a" (__v) : "dN" (__p));
- return __v;
-}
-
-static __inline__ unsigned short
-inw(unsigned short __p)
-{
- unsigned short __v;
- asm volatile("inw %1,%0" : "=a" (__v) : "dN" (__p));
- return __v;
-}
-
-static __inline__ unsigned int
-inl(unsigned short __p)
-{
- unsigned int __v;
- asm volatile("inl %1,%0" : "=a" (__v) : "dN" (__p));
- return __v;
-}
-
-/* String I/O macros */
-
-static __inline__ void
-outsb (unsigned short __p, const void *__d, unsigned long __n)
-{
- asm volatile("cld; rep; outsb" : "+S" (__d), "+c" (__n) : "d" (__p));
-}
-
-static __inline__ void
-outsw (unsigned short __p, const void *__d, unsigned long __n)
-{
- asm volatile("cld; rep; outsw" : "+S" (__d), "+c" (__n) : "d" (__p));
-}
-
-static __inline__ void
-outsl (unsigned short __p, const void *__d, unsigned long __n)
-{
- asm volatile("cld; rep; outsl" : "+S" (__d), "+c" (__n) : "d" (__p));
-}
-
-
-static __inline__ void
-insb (unsigned short __p, void *__d, unsigned long __n)
-{
- asm volatile("cld; rep; insb" : "+D" (__d), "+c" (__n) : "d" (__p));
-}
-
-static __inline__ void
-insw (unsigned short __p, void *__d, unsigned long __n)
-{
- asm volatile("cld; rep; insw" : "+D" (__d), "+c" (__n) : "d" (__p));
-}
-
-static __inline__ void
-insl (unsigned short __p, void *__d, unsigned long __n)
-{
- asm volatile("cld; rep; insl" : "+D" (__d), "+c" (__n) : "d" (__p));
-}
-
-#endif /* _SYS_IO_H */
diff --git a/klibc/include/arch/i386/sys/vm86.h b/klibc/include/arch/i386/sys/vm86.h
deleted file mode 100644
index d3272393dc..0000000000
--- a/klibc/include/arch/i386/sys/vm86.h
+++ /dev/null
@@ -1,41 +0,0 @@
-#ident "$Id: vm86.h,v 1.1 2004/01/25 01:34:28 hpa Exp $"
-/* ----------------------------------------------------------------------- *
- *
- * Copyright 2004 H. Peter Anvin - All Rights Reserved
- *
- * 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.
- *
- * ----------------------------------------------------------------------- */
-
-/*
- * sys/vm86.h for i386
- */
-
-#ifndef _SYS_VM86_H
-#define _SYS_VM86_H 1
-
-#include <asm/vm86.h>
-
-/* Actual system call */
-int vm86(struct vm86_struct *);
-
-#endif
diff --git a/klibc/include/arch/ia64/klibc/archsetjmp.h b/klibc/include/arch/ia64/klibc/archsetjmp.h
deleted file mode 100644
index bd639c0b00..0000000000
--- a/klibc/include/arch/ia64/klibc/archsetjmp.h
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * arch/ia64/include/klibc/archsetjmp.h
- *
- * Code borrowed from the FreeBSD kernel.
- *
- */
-
-#ifndef _KLIBC_ARCHSETJMP_H
-#define _KLIBC_ARCHSETJMP_H
-
-/* User code must not depend on the internal representation of jmp_buf. */
-#define _JBLEN 0x200
-
-/* guaranteed 128-bit alignment! */
-typedef char jmp_buf[_JBLEN] __attribute__ ((aligned (16)));
-
-#endif
diff --git a/klibc/include/arch/ia64/klibc/archsignal.h b/klibc/include/arch/ia64/klibc/archsignal.h
deleted file mode 100644
index 5b01f19bc2..0000000000
--- a/klibc/include/arch/ia64/klibc/archsignal.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * arch/ia64/include/klibc/archsignal.h
- *
- * Architecture-specific signal definitions.
- *
- */
-
-#ifndef _KLIBC_ARCHSIGNAL_H
-#define _KLIBC_ARCHSIGNAL_H
-
-#define _NSIG 64
-#define _NSIG_BPW 64
-#define _NSIG_WORDS (_NSIG / _NSIG_BPW)
-
-typedef struct {
- unsigned long sig[_NSIG_WORDS];
-} sigset_t;
-
-struct sigaction {
- union {
- __sighandler_t _sa_handler;
- void (*_sa_sigaction)(int, struct siginfo *, void *);
- } _u;
- sigset_t sa_mask;
- int sa_flags;
-};
-
-#define sa_handler _u._sa_handler
-#define sa_sigaction _u._sa_sigaction
-
-#endif
diff --git a/klibc/include/arch/ia64/klibc/archstat.h b/klibc/include/arch/ia64/klibc/archstat.h
deleted file mode 100644
index 9475c0b797..0000000000
--- a/klibc/include/arch/ia64/klibc/archstat.h
+++ /dev/null
@@ -1,24 +0,0 @@
-#ifndef _KLIBC_ARCHSTAT_H
-#define _KLIBC_ARCHSTAT_H
-
-#define _STATBUF_ST_NSEC
-
-struct stat {
- unsigned long st_dev;
- unsigned long st_ino;
- unsigned long st_nlink;
- unsigned int st_mode;
- unsigned int st_uid;
- unsigned int st_gid;
- unsigned int __pad0;
- unsigned long st_rdev;
- unsigned long st_size;
- struct timespec st_atim;
- struct timespec st_mtim;
- struct timespec st_ctim;
- unsigned long st_blksize;
- long st_blocks;
- unsigned long __unused[3];
-};
-
-#endif
diff --git a/klibc/include/arch/ia64/klibc/archsys.h b/klibc/include/arch/ia64/klibc/archsys.h
deleted file mode 100644
index 4c795a43ca..0000000000
--- a/klibc/include/arch/ia64/klibc/archsys.h
+++ /dev/null
@@ -1,218 +0,0 @@
-/*
- * arch/ia64/include/klibc/archsys.h
- *
- * Architecture-specific syscall definitions
- */
-
-#ifndef _KLIBC_ARCHSYS_H
-#define _KLIBC_ARCHSYS_H
-
-#define __IA64_BREAK "break 0x100000;;\n\t"
-
-#define _syscall0(type,name) \
-type \
-name (void) \
-{ \
- register long _r8 asm ("r8"); \
- register long _r10 asm ("r10"); \
- register long _r15 asm ("r15") = __NR_##name; \
- long _retval; \
- __asm __volatile (__IA64_BREAK \
- : "=r" (_r8), "=r" (_r10), "=r" (_r15) \
- : "2" (_r15) ASM_ARGS_0 \
- : "memory" ASM_CLOBBERS_0); \
- _retval = _r8; \
- if (_r10 == -1) { \
- errno = (_retval); \
- _retval = -1; \
- } \
- return (type)_retval; \
-}
-
-#define _syscall1(type,name,type1,arg1) \
-type \
-name (type1 arg1) \
-{ \
- register long _r8 asm ("r8"); \
- register long _r10 asm ("r10"); \
- register long _r15 asm ("r15") = __NR_##name; \
- long _retval; \
- LOAD_ARGS_1(arg1); \
- __asm __volatile (__IA64_BREAK \
- : "=r" (_r8), "=r" (_r10), "=r" (_r15), \
- ASM_OUTARGS_1 \
- : "2" (_r15) ASM_ARGS_1 \
- : "memory" ASM_CLOBBERS_1); \
- _retval = _r8; \
- if (_r10 == -1) { \
- errno = (_retval); \
- _retval = -1; \
- } \
- return (type)_retval; \
-}
-
-#define _syscall2(type,name,type1,arg1,type2,arg2) \
-type \
-name (type1 arg1, type2 arg2) \
-{ \
- register long _r8 asm ("r8"); \
- register long _r10 asm ("r10"); \
- register long _r15 asm ("r15") = __NR_##name; \
- long _retval; \
- LOAD_ARGS_2(arg1, arg2); \
- __asm __volatile (__IA64_BREAK \
- : "=r" (_r8), "=r" (_r10), "=r" (_r15), \
- ASM_OUTARGS_2 \
- : "2" (_r15) ASM_ARGS_2 \
- : "memory" ASM_CLOBBERS_2); \
- _retval = _r8; \
- if (_r10 == -1) { \
- errno = (_retval); \
- _retval = -1; \
- } \
- return (type)_retval; \
-}
-
-#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
-type \
-name (type1 arg1, type2 arg2, type3 arg3) \
-{ \
- register long _r8 asm ("r8"); \
- register long _r10 asm ("r10"); \
- register long _r15 asm ("r15") = __NR_##name; \
- long _retval; \
- LOAD_ARGS_3(arg1, arg2, arg3); \
- __asm __volatile (__IA64_BREAK \
- : "=r" (_r8), "=r" (_r10), "=r" (_r15), \
- ASM_OUTARGS_3 \
- : "2" (_r15) ASM_ARGS_3 \
- : "memory" ASM_CLOBBERS_3); \
- _retval = _r8; \
- if (_r10 == -1) { \
- errno = (_retval); \
- _retval = -1; \
- } \
- return (type)_retval; \
-}
-
-#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
-type \
-name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
-{ \
- register long _r8 asm ("r8"); \
- register long _r10 asm ("r10"); \
- register long _r15 asm ("r15") = __NR_##name; \
- long _retval; \
- LOAD_ARGS_4(arg1, arg2, arg3, arg4); \
- __asm __volatile (__IA64_BREAK \
- : "=r" (_r8), "=r" (_r10), "=r" (_r15), \
- ASM_OUTARGS_4 \
- : "2" (_r15) ASM_ARGS_4 \
- : "memory" ASM_CLOBBERS_4); \
- _retval = _r8; \
- if (_r10 == -1) { \
- errno = (_retval); \
- _retval = -1; \
- } \
- return (type)_retval; \
-}
-
-#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \
-type \
-name (type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) \
-{ \
- register long _r8 asm ("r8"); \
- register long _r10 asm ("r10"); \
- register long _r15 asm ("r15") = __NR_##name; \
- long _retval; \
- LOAD_ARGS_5(arg1, arg2, arg3, arg4, arg5); \
- __asm __volatile (__IA64_BREAK \
- : "=r" (_r8), "=r" (_r10), "=r" (_r15), \
- ASM_OUTARGS_5 \
- : "2" (_r15) ASM_ARGS_5 \
- : "memory" ASM_CLOBBERS_5); \
- _retval = _r8; \
- if (_r10 == -1) { \
- errno = (_retval); \
- _retval = -1; \
- } \
- return (type)_retval; \
-}
-
-#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5,type6,arg6) \
-type \
-name (type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6) \
-{ \
- register long _r8 asm ("r8"); \
- register long _r10 asm ("r10"); \
- register long _r15 asm ("r15") = __NR_##name; \
- long _retval; \
- LOAD_ARGS_6(arg1, arg2, arg3, arg4, arg5, arg6); \
- __asm __volatile (__IA64_BREAK \
- : "=r" (_r8), "=r" (_r10), "=r" (_r15), \
- ASM_OUTARGS_6 \
- : "2" (_r15) ASM_ARGS_6 \
- : "memory" ASM_CLOBBERS_6); \
- _retval = _r8; \
- if (_r10 == -1) { \
- errno = (_retval); \
- _retval = -1; \
- } \
- return (type)_retval; \
-}
-
-
-#define LOAD_ARGS_0() do { } while (0)
-#define LOAD_ARGS_1(out0) \
- register long _out0 asm ("out0") = (long) (out0); \
- LOAD_ARGS_0 ()
-#define LOAD_ARGS_2(out0, out1) \
- register long _out1 asm ("out1") = (long) (out1); \
- LOAD_ARGS_1 (out0)
-#define LOAD_ARGS_3(out0, out1, out2) \
- register long _out2 asm ("out2") = (long) (out2); \
- LOAD_ARGS_2 (out0, out1)
-#define LOAD_ARGS_4(out0, out1, out2, out3) \
- register long _out3 asm ("out3") = (long) (out3); \
- LOAD_ARGS_3 (out0, out1, out2)
-#define LOAD_ARGS_5(out0, out1, out2, out3, out4) \
- register long _out4 asm ("out4") = (long) (out4); \
- LOAD_ARGS_4 (out0, out1, out2, out3)
-#define LOAD_ARGS_6(out0, out1, out2, out3, out4, out5) \
- register long _out5 asm ("out5") = (long) (out5); \
- LOAD_ARGS_5 (out0, out1, out2, out3, out4)
-
-#define ASM_OUTARGS_1 "=r" (_out0)
-#define ASM_OUTARGS_2 ASM_OUTARGS_1, "=r" (_out1)
-#define ASM_OUTARGS_3 ASM_OUTARGS_2, "=r" (_out2)
-#define ASM_OUTARGS_4 ASM_OUTARGS_3, "=r" (_out3)
-#define ASM_OUTARGS_5 ASM_OUTARGS_4, "=r" (_out4)
-#define ASM_OUTARGS_6 ASM_OUTARGS_5, "=r" (_out5)
-
-#define ASM_ARGS_0
-#define ASM_ARGS_1 ASM_ARGS_0, "3" (_out0)
-#define ASM_ARGS_2 ASM_ARGS_1, "4" (_out1)
-#define ASM_ARGS_3 ASM_ARGS_2, "5" (_out2)
-#define ASM_ARGS_4 ASM_ARGS_3, "6" (_out3)
-#define ASM_ARGS_5 ASM_ARGS_4, "7" (_out4)
-#define ASM_ARGS_6 ASM_ARGS_5, "8" (_out5)
-
-#define ASM_CLOBBERS_0 ASM_CLOBBERS_1, "out0"
-#define ASM_CLOBBERS_1 ASM_CLOBBERS_2, "out1"
-#define ASM_CLOBBERS_2 ASM_CLOBBERS_3, "out2"
-#define ASM_CLOBBERS_3 ASM_CLOBBERS_4, "out3"
-#define ASM_CLOBBERS_4 ASM_CLOBBERS_5, "out4"
-#define ASM_CLOBBERS_5 ASM_CLOBBERS_6, "out5"
-#define ASM_CLOBBERS_6 , "out6", "out7", \
- /* Non-stacked integer registers, minus r8, r10, r15. */ \
- "r2", "r3", "r9", "r11", "r12", "r13", "r14", "r16", "r17", "r18", \
- "r19", "r20", "r21", "r22", "r23", "r24", "r25", "r26", "r27", \
- "r28", "r29", "r30", "r31", \
- /* Predicate registers. */ \
- "p6", "p7", "p8", "p9", "p10", "p11", "p12", "p13", "p14", "p15", \
- /* Non-rotating fp registers. */ \
- "f6", "f7", "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", \
- /* Branch registers. */ \
- "b6", "b7"
-
-#endif /* _KLIBC_ARCHSYS_H */
diff --git a/klibc/include/arch/m32r/klibc/archsetjmp.h b/klibc/include/arch/m32r/klibc/archsetjmp.h
deleted file mode 100644
index e16a83517a..0000000000
--- a/klibc/include/arch/m32r/klibc/archsetjmp.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * arch/m32r/include/klibc/archsetjmp.h
- */
-
-#ifndef _KLIBC_ARCHSETJMP_H
-#define _KLIBC_ARCHSETJMP_H
-
-struct __jmp_buf {
- unsigned long __r8;
- unsigned long __r9;
- unsigned long __r10;
- unsigned long __r11;
- unsigned long __r12;
- unsigned long __r13;
- unsigned long __r14;
- unsigned long __r15;
-};
-
-typedef struct __jmp_buf jmp_buf[1];
-
-#endif /* _KLIBC_ARCHSETJMP_H */
diff --git a/klibc/include/arch/m32r/klibc/archsignal.h b/klibc/include/arch/m32r/klibc/archsignal.h
deleted file mode 100644
index 02596e9a1c..0000000000
--- a/klibc/include/arch/m32r/klibc/archsignal.h
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * arch/m32r/include/klibc/archsignal.h
- *
- * Architecture-specific signal definitions
- *
- */
-
-#ifndef _KLIBC_ARCHSIGNAL_H
-#define _KLIBC_ARCHSIGNAL_H
-
-/* No special stuff for this architecture */
-
-#endif
diff --git a/klibc/include/arch/m32r/klibc/archstat.h b/klibc/include/arch/m32r/klibc/archstat.h
deleted file mode 100644
index 154820755f..0000000000
--- a/klibc/include/arch/m32r/klibc/archstat.h
+++ /dev/null
@@ -1,37 +0,0 @@
-#ifndef _KLIBC_ARCHSTAT_H
-#define _KLIBC_ARCHSTAT_H
-
-#define _STATBUF_ST_NSEC
-
-/* This matches struct stat64 in glibc2.1, hence the absolutely
- * insane amounts of padding around dev_t's.
- */
-struct stat {
- unsigned long long st_dev;
- unsigned char __pad0[4];
-
- unsigned long __st_ino;
-
- unsigned int st_mode;
- unsigned int st_nlink;
-
- unsigned long st_uid;
- unsigned long st_gid;
-
- unsigned long long st_rdev;
- unsigned char __pad3[4];
-
- long long st_size;
- unsigned long st_blksize;
-
- unsigned long st_blocks; /* Number 512-byte blocks allocated. */
- unsigned long __pad4; /* future possible st_blocks high bits */
-
- struct timespec st_atim;
- struct timespec st_mtim;
- struct timespec st_ctim;
-
- unsigned long long st_ino;
-};
-
-#endif
diff --git a/klibc/include/arch/m32r/klibc/archsys.h b/klibc/include/arch/m32r/klibc/archsys.h
deleted file mode 100644
index 386db8b505..0000000000
--- a/klibc/include/arch/m32r/klibc/archsys.h
+++ /dev/null
@@ -1,12 +0,0 @@
-/*
- * arch/m32r/include/klibc/archsys.h
- *
- * Architecture-specific syscall definitions
- */
-
-#ifndef _KLIBC_ARCHSYS_H
-#define _KLIBC_ARCHSYS_H
-
-/* No special syscall definitions for this architecture */
-
-#endif /* _KLIBC_ARCHSYS_H */
diff --git a/klibc/include/arch/m68k/klibc/archsignal.h b/klibc/include/arch/m68k/klibc/archsignal.h
deleted file mode 100644
index 714527f6b0..0000000000
--- a/klibc/include/arch/m68k/klibc/archsignal.h
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * arch/m68k/include/klibc/archsignal.h
- *
- * Architecture-specific signal definitions
- *
- */
-
-#ifndef _KLIBC_ARCHSIGNAL_H
-#define _KLIBC_ARCHSIGNAL_H
-
-/* No special stuff for this architecture */
-
-#endif
diff --git a/klibc/include/arch/m68k/klibc/archstat.h b/klibc/include/arch/m68k/klibc/archstat.h
deleted file mode 100644
index 9c0a05da09..0000000000
--- a/klibc/include/arch/m68k/klibc/archstat.h
+++ /dev/null
@@ -1,37 +0,0 @@
-#ifndef _KLIBC_ARCHSTAT_H
-#define _KLIBC_ARCHSTAT_H
-
-#define _STATBUF_ST_NSEC
-
-/* This matches struct stat64 in glibc2.1, hence the absolutely
- * insane amounts of padding around dev_t's.
- */
-struct stat {
- unsigned long long st_dev;
- unsigned char __pad1[2];
-
- unsigned long __st_ino;
-
- unsigned int st_mode;
- unsigned int st_nlink;
-
- unsigned long st_uid;
- unsigned long st_gid;
-
- unsigned long long st_rdev;
- unsigned char __pad3[2];
-
- long long st_size;
- unsigned long st_blksize;
-
- unsigned long __pad4; /* future possible st_blocks high bits */
- unsigned long st_blocks; /* Number 512-byte blocks allocated. */
-
- struct timespec st_atim;
- struct timespec st_mtim;
- struct timespec st_ctim;
-
- unsigned long long st_ino;
-};
-
-#endif
diff --git a/klibc/include/arch/m68k/klibc/archsys.h b/klibc/include/arch/m68k/klibc/archsys.h
deleted file mode 100644
index 8f6bed8e94..0000000000
--- a/klibc/include/arch/m68k/klibc/archsys.h
+++ /dev/null
@@ -1,12 +0,0 @@
-/*
- * arch/m68k/include/klibc/archsys.h
- *
- * Architecture-specific syscall definitions
- */
-
-#ifndef _KLIBC_ARCHSYS_H
-#define _KLIBC_ARCHSYS_H
-
-/* No special syscall definitions for this architecture */
-
-#endif /* _KLIBC_ARCHSYS_H */
diff --git a/klibc/include/arch/mips/klibc/archfcntl.h b/klibc/include/arch/mips/klibc/archfcntl.h
deleted file mode 100644
index 54462ea69f..0000000000
--- a/klibc/include/arch/mips/klibc/archfcntl.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * arch/mips/include/klibc/archfcntl.h
- *
- * On MIPS, <asm/fcntl.h> isn't usable (compiling struct stat with
- * the correct definitions doesn't "just work"), so we need to provide
- * our own definitions.
- */
-
-#ifndef _KLIBC_ARCHFCNTL_H
-#define _KLIBC_ARCHFCNTL_H
-
-#ifdef _ASM_FCNTL_H /* We were too late! */
-# error "<asm/fcntl.h> included before <klibc/archfcntl.h>"
-#endif
-#define _ASM_FCNTL_H /* Keep <asm/fcntl.h> from getting included */
-
-#define O_ACCMODE 0x0003
-#define O_RDONLY 0x0000
-#define O_WRONLY 0x0001
-#define O_RDWR 0x0002
-#define O_APPEND 0x0008
-#define O_SYNC 0x0010
-#define O_NONBLOCK 0x0080
-#define O_CREAT 0x0100
-#define O_TRUNC 0x0200
-#define O_EXCL 0x0400
-#define O_NOCTTY 0x0800
-#define FASYNC 0x1000
-#define O_LARGEFILE 0x2000
-#define O_DIRECT 0x8000
-#define O_DIRECTORY 0x10000
-#define O_NOFOLLOW 0x20000
-#define O_NOATIME 0x40000
-
-#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_GETLK 14
-#define F_SETLK 6
-#define F_SETLKW 7
-
-#define F_SETOWN 24
-#define F_GETOWN 23
-#define F_SETSIG 10
-#define F_GETSIG 11
-
-#define F_GETLK64 33
-#define F_SETLK64 34
-#define F_SETLKW64 35
-
-#define FD_CLOEXEC 1
-
-#define F_RDLCK 0
-#define F_WRLCK 1
-#define F_UNLCK 2
-
-#define F_EXLCK 4
-#define F_SHLCK 8
-
-#define F_INPROGRESS 16
-
-#define LOCK_SH 1
-#define LOCK_EX 2
-#define LOCK_NB 4
-#define LOCK_UN 8
-
-#define LOCK_MAND 32
-#define LOCK_READ 64
-#define LOCK_WRITE 128
-#define LOCK_RW 192
-
-typedef struct flock {
- short l_type;
- short l_whence;
- loff_t l_start;
- loff_t l_len;
- pid_t l_pid;
-} flock_t;
-
-#define F_LINUX_SPECIFIC_BASE 1024
-
-#endif /* _KLIBC_ARCHFCNTL_H */
-
diff --git a/klibc/include/arch/mips/klibc/archsetjmp.h b/klibc/include/arch/mips/klibc/archsetjmp.h
deleted file mode 100644
index 40e5be2736..0000000000
--- a/klibc/include/arch/mips/klibc/archsetjmp.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * arch/mips/include/klibc/archsetjmp.h
- */
-
-#ifndef _KLIBC_ARCHSETJMP_H
-#define _KLIBC_ARCHSETJMP_H
-
-struct __jmp_buf {
- unsigned long __s0;
- unsigned long __s1;
- unsigned long __s2;
- unsigned long __s3;
- unsigned long __s4;
- unsigned long __s5;
- unsigned long __s6;
- unsigned long __s7;
- unsigned long __gp;
- unsigned long __sp;
- unsigned long __s8;
- unsigned long __ra;
- unsigned long __f20;
- unsigned long __f21;
- unsigned long __f22;
- unsigned long __f23;
- unsigned long __f24;
- unsigned long __f25;
- unsigned long __f26;
- unsigned long __f27;
- unsigned long __f28;
- unsigned long __f29;
- unsigned long __f30;
- unsigned long __f31;
- unsigned long __fcr31;
- unsigned long __unused;
-} __attribute__((aligned(8)));
-
-typedef struct __jmp_buf jmp_buf[1];
-
-#endif /* _KLIBC_ARCHSETJMP_H */
diff --git a/klibc/include/arch/mips/klibc/archsignal.h b/klibc/include/arch/mips/klibc/archsignal.h
deleted file mode 100644
index 3b72908636..0000000000
--- a/klibc/include/arch/mips/klibc/archsignal.h
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * arch/mips/include/klibc/archsignal.h
- *
- * Architecture-specific signal definitions
- *
- */
-
-#ifndef _KLIBC_ARCHSIGNAL_H
-#define _KLIBC_ARCHSIGNAL_H
-
-/* No special stuff for this architecture */
-
-#endif
diff --git a/klibc/include/arch/mips/klibc/archstat.h b/klibc/include/arch/mips/klibc/archstat.h
deleted file mode 100644
index 612bbfa85b..0000000000
--- a/klibc/include/arch/mips/klibc/archstat.h
+++ /dev/null
@@ -1,39 +0,0 @@
-#ifndef _KLIBC_ARCHSTAT_H
-#define _KLIBC_ARCHSTAT_H
-
-#define _STATBUF_ST_NSEC
-
-/*
- * This matches struct stat64 in glibc2.1, hence the absolutely insane
- * amounts of padding around dev_t's. The memory layout is the same as of
- * struct stat of the 64-bit kernel.
- */
-
-struct stat {
- unsigned long st_dev;
- unsigned long st_pad0[3]; /* Reserved for st_dev expansion */
-
- unsigned long long st_ino;
-
- mode_t st_mode;
- nlink_t st_nlink;
-
- uid_t st_uid;
- gid_t st_gid;
-
- unsigned long st_rdev;
- unsigned long st_pad1[3]; /* Reserved for st_rdev expansion */
-
- long long st_size;
-
- struct timespec st_atim;
- struct timespec st_mtim;
- struct timespec st_ctim;
-
- unsigned long st_blksize;
- unsigned long st_pad2;
-
- long long st_blocks;
-};
-
-#endif
diff --git a/klibc/include/arch/mips/klibc/archsys.h b/klibc/include/arch/mips/klibc/archsys.h
deleted file mode 100644
index f696cdfaa7..0000000000
--- a/klibc/include/arch/mips/klibc/archsys.h
+++ /dev/null
@@ -1,12 +0,0 @@
-/*
- * arch/mips/include/klibc/archsys.h
- *
- * Architecture-specific syscall definitions
- */
-
-#ifndef _KLIBC_ARCHSYS_H
-#define _KLIBC_ARCHSYS_H
-
-/* No special syscall definitions for this architecture */
-
-#endif /* _KLIBC_ARCHSYS_H */
diff --git a/klibc/include/arch/mips/machine/asm.h b/klibc/include/arch/mips/machine/asm.h
deleted file mode 100644
index e5239a6cef..0000000000
--- a/klibc/include/arch/mips/machine/asm.h
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
- * arch/mips/include/machine/asm.h
- */
-
-#ifndef _MACHINE_ASM_H
-#define _MACHINE_ASM_H
-
-#include <asm/regdef.h>
-#include <asm/asm.h>
-
-#endif /* _MACHINE_ASM_H */
diff --git a/klibc/include/arch/mips/sgidefs.h b/klibc/include/arch/mips/sgidefs.h
deleted file mode 100644
index eb103ace2c..0000000000
--- a/klibc/include/arch/mips/sgidefs.h
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * arch/mips/include/sgidefs.h
- */
-
-/* Some ABI constants */
-
-#ifndef _SGIDEFS_H
-#define _SGIDEFS_H
-
-#define _MIPS_ISA_MIPS1 1
-#define _MIPS_ISA_MIPS2 2
-#define _MIPS_ISA_MIPS3 3
-#define _MIPS_ISA_MIPS4 4
-#define _MIPS_ISA_MIPS5 5
-
-#define _MIPS_SIM_ABI32 1
-#define _MIPS_SIM_NABI32 2
-#define _MIPS_SIM_ABI64 3
-
-#endif /* _SGIDEFS_H */
diff --git a/klibc/include/arch/mips/spaces.h b/klibc/include/arch/mips/spaces.h
deleted file mode 100644
index b5f530b753..0000000000
--- a/klibc/include/arch/mips/spaces.h
+++ /dev/null
@@ -1 +0,0 @@
-/* Included by <asm/page.h> but not actually needed */
diff --git a/klibc/include/arch/mips64/klibc/archsignal.h b/klibc/include/arch/mips64/klibc/archsignal.h
deleted file mode 100644
index 56b0fd323e..0000000000
--- a/klibc/include/arch/mips64/klibc/archsignal.h
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * arch/mips64/include/klibc/archsignal.h
- *
- * Architecture-specific signal definitions
- *
- */
-
-#ifndef _KLIBC_ARCHSIGNAL_H
-#define _KLIBC_ARCHSIGNAL_H
-
-/* No special stuff for this architecture */
-
-#endif
diff --git a/klibc/include/arch/mips64/klibc/archstat.h b/klibc/include/arch/mips64/klibc/archstat.h
deleted file mode 100644
index d237e3a3e8..0000000000
--- a/klibc/include/arch/mips64/klibc/archstat.h
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef _KLIBC_ARCHSTAT_H
-#define _KLIBC_ARCHSTAT_H
-
-#define _STATBUF_ST_NSEC
-
-struct stat {
- unsigned int st_dev;
- unsigned int st_pad0[3]; /* Reserved for st_dev expansion */
-
- unsigned long st_ino;
-
- mode_t st_mode;
- nlink_t st_nlink;
-
- uid_t st_uid;
- gid_t st_gid;
-
- unsigned int st_rdev;
- unsigned int st_pad1[3]; /* Reserved for st_rdev expansion */
-
- off_t st_size;
-
- struct timespec st_atim;
- struct timespec st_mtim;
- struct timespec st_ctim;
-
- unsigned int st_blksize;
- unsigned int st_pad2;
-
- unsigned long st_blocks;
-};
-
-#endif
diff --git a/klibc/include/arch/mips64/klibc/archsys.h b/klibc/include/arch/mips64/klibc/archsys.h
deleted file mode 100644
index 81e5106e16..0000000000
--- a/klibc/include/arch/mips64/klibc/archsys.h
+++ /dev/null
@@ -1,12 +0,0 @@
-/*
- * arch/mips64/include/klibc/archsys.h
- *
- * Architecture-specific syscall definitions
- */
-
-#ifndef _KLIBC_ARCHSYS_H
-#define _KLIBC_ARCHSYS_H
-
-/* No special syscall definitions for this architecture */
-
-#endif /* _KLIBC_ARCHSYS_H */
diff --git a/klibc/include/arch/parisc/klibc/archsetjmp.h b/klibc/include/arch/parisc/klibc/archsetjmp.h
deleted file mode 100644
index e7444983ed..0000000000
--- a/klibc/include/arch/parisc/klibc/archsetjmp.h
+++ /dev/null
@@ -1,14 +0,0 @@
-/*
- * arch/parisc/include/klibc/archsetjmp.h
- */
-
-#ifndef _KLIBC_ARCHSETJMP_H
-#define _KLIBC_ARCHSETJMP_H
-
-struct __jmp_buf {
- double regs[21];
-};
-
-typedef struct __jmp_buf jmp_buf[1];
-
-#endif /* _SETJMP_H */
diff --git a/klibc/include/arch/parisc/klibc/archsignal.h b/klibc/include/arch/parisc/klibc/archsignal.h
deleted file mode 100644
index 3190e8528e..0000000000
--- a/klibc/include/arch/parisc/klibc/archsignal.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * arch/parisc/include/klibc/archsignal.h
- *
- * Architecture-specific signal definitions
- *
- */
-
-#ifndef _KLIBC_ARCHSIGNAL_H
-#define _KLIBC_ARCHSIGNAL_H
-
-#define _NSIG 64
-#define _NSIG_SZ (_NSIG / LONG_BIT)
-
-typedef struct {
- unsigned long sig[_NSIG_SZ];
-} sigset_t;
-
-struct sigaction {
- __sighandler_t sa_handler;
- unsigned long sa_flags;
- sigset_t sa_mask;
-};
-
-#endif
diff --git a/klibc/include/arch/parisc/klibc/archstat.h b/klibc/include/arch/parisc/klibc/archstat.h
deleted file mode 100644
index 7d28f459ee..0000000000
--- a/klibc/include/arch/parisc/klibc/archstat.h
+++ /dev/null
@@ -1,27 +0,0 @@
-#ifndef _KLIBC_ARCHSTAT_H
-#define _KLIBC_ARCHSTAT_H
-
-#define _STATBUF_ST_NSEC
-
-struct stat {
- unsigned long long st_dev;
- unsigned int __pad1;
-
- unsigned int __st_ino; /* Not actually filled in */
- unsigned int st_mode;
- unsigned int st_nlink;
- unsigned int st_uid;
- unsigned int st_gid;
- unsigned long long st_rdev;
- unsigned int __pad2;
- signed long long st_size;
- signed int st_blksize;
-
- signed long long st_blocks;
- struct timespec st_atim;
- struct timespec st_mtim;
- struct timespec st_ctim;
- unsigned long long st_ino;
-};
-
-#endif
diff --git a/klibc/include/arch/parisc/klibc/archsys.h b/klibc/include/arch/parisc/klibc/archsys.h
deleted file mode 100644
index 5013ba8794..0000000000
--- a/klibc/include/arch/parisc/klibc/archsys.h
+++ /dev/null
@@ -1,12 +0,0 @@
-/*
- * arch/parisc/include/klibc/archsys.h
- *
- * Architecture-specific syscall definitions
- */
-
-#ifndef _KLIBC_ARCHSYS_H
-#define _KLIBC_ARCHSYS_H
-
-/* No special syscall definitions for this architecture */
-
-#endif /* _KLIBC_ARCHSYS_H */
diff --git a/klibc/include/arch/ppc/klibc/archsetjmp.h b/klibc/include/arch/ppc/klibc/archsetjmp.h
deleted file mode 100644
index 53e2fccc3b..0000000000
--- a/klibc/include/arch/ppc/klibc/archsetjmp.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * arch/ppc/include/klibc/archsetjmp.h
- */
-
-#ifndef _KLIBC_ARCHSETJMP_H
-#define _KLIBC_ARCHSETJMP_H
-
-struct __jmp_buf {
- unsigned long __r2;
- unsigned long __sp;
- unsigned long __lr;
- unsigned long __cr;
- unsigned long __r13;
- unsigned long __r14;
- unsigned long __r15;
- unsigned long __r16;
- unsigned long __r17;
- unsigned long __r18;
- unsigned long __r19;
- unsigned long __r20;
- unsigned long __r21;
- unsigned long __r22;
- unsigned long __r23;
- unsigned long __r24;
- unsigned long __r25;
- unsigned long __r26;
- unsigned long __r27;
- unsigned long __r28;
- unsigned long __r29;
- unsigned long __r30;
- unsigned long __r31;
-};
-
-typedef struct __jmp_buf jmp_buf[1];
-
-#endif /* _SETJMP_H */
diff --git a/klibc/include/arch/ppc/klibc/archsignal.h b/klibc/include/arch/ppc/klibc/archsignal.h
deleted file mode 100644
index 567a547ef9..0000000000
--- a/klibc/include/arch/ppc/klibc/archsignal.h
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * arch/ppc/include/klibc/archsignal.h
- *
- * Architecture-specific signal definitions
- *
- */
-
-#ifndef _KLIBC_ARCHSIGNAL_H
-#define _KLIBC_ARCHSIGNAL_H
-
-/* No special stuff for this architecture */
-
-#endif
diff --git a/klibc/include/arch/ppc/klibc/archstat.h b/klibc/include/arch/ppc/klibc/archstat.h
deleted file mode 100644
index 1d0487b47f..0000000000
--- a/klibc/include/arch/ppc/klibc/archstat.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef _KLIBC_ARCHSTAT_H
-#define _KLIBC_ARCHSTAT_H
-
-#define _STATBUF_ST_NSEC
-
-/* This matches struct stat64 in glibc2.1.
- */
-struct stat {
- unsigned long long st_dev; /* Device. */
- unsigned long long st_ino; /* File serial number. */
- unsigned int st_mode; /* File mode. */
- unsigned int st_nlink; /* Link count. */
- unsigned int st_uid; /* User ID of the file's owner. */
- unsigned int st_gid; /* Group ID of the file's group. */
- unsigned long long st_rdev; /* Device number, if device. */
- unsigned short int __pad2;
- long long st_size; /* Size of file, in bytes. */
- long st_blksize; /* Optimal block size for I/O. */
-
- long long st_blocks; /* Number 512-byte blocks allocated. */
- struct timespec st_atim; /* Time of last access. */
- struct timespec st_mtim; /* Time of last modification. */
- struct timespec st_ctim; /* Time of last status change. */
- unsigned long int __unused4;
- unsigned long int __unused5;
-};
-
-#endif
diff --git a/klibc/include/arch/ppc/klibc/archsys.h b/klibc/include/arch/ppc/klibc/archsys.h
deleted file mode 100644
index 17a28859e5..0000000000
--- a/klibc/include/arch/ppc/klibc/archsys.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * arch/ppc/include/klibc/archsys.h
- *
- * Architecture-specific syscall definitions
- */
-
-#ifndef _KLIBC_ARCHSYS_H
-#define _KLIBC_ARCHSYS_H
-
-/* PowerPC seems to lack _syscall6() in its headers */
-/* This seems to work on both 32- and 64-bit ppc */
-
-#ifndef _syscall6
-
-#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
- type5,arg5,type6,arg6) \
-type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5,type6 arg6) \
-{ \
- unsigned long __sc_ret, __sc_err; \
- { \
- register unsigned long __sc_0 __asm__ ("r0"); \
- register unsigned long __sc_3 __asm__ ("r3"); \
- register unsigned long __sc_4 __asm__ ("r4"); \
- register unsigned long __sc_5 __asm__ ("r5"); \
- register unsigned long __sc_6 __asm__ ("r6"); \
- register unsigned long __sc_7 __asm__ ("r7"); \
- register unsigned long __sc_8 __asm__ ("r8"); \
- \
- __sc_3 = (unsigned long) (arg1); \
- __sc_4 = (unsigned long) (arg2); \
- __sc_5 = (unsigned long) (arg3); \
- __sc_6 = (unsigned long) (arg4); \
- __sc_7 = (unsigned long) (arg5); \
- __sc_8 = (unsigned long) (arg6); \
- __sc_0 = __NR_##name; \
- __asm__ __volatile__ \
- ("sc \n\t" \
- "mfcr %1 " \
- : "+r" (__sc_3), \
- "+r" (__sc_0), \
- "+r" (__sc_4), \
- "+r" (__sc_5), \
- "+r" (__sc_6), \
- "+r" (__sc_7), \
- "+r" (__sc_8) \
- : : "cr0", "ctr", "memory", \
- "r9", "r10", "r11", "r12"); \
- __sc_ret = __sc_3; \
- __sc_err = __sc_0; \
- } \
- if (__sc_err & 0x10000000) \
- { \
- errno = (int)__sc_ret; \
- __sc_ret = -1; \
- } \
- return (type)__sc_ret; \
-}
-
-#endif /* _syscall6() missing */
-
-#endif /* _KLIBC_ARCHSYS_H */
diff --git a/klibc/include/arch/ppc64/klibc/archsetjmp.h b/klibc/include/arch/ppc64/klibc/archsetjmp.h
deleted file mode 100644
index 006a2e27be..0000000000
--- a/klibc/include/arch/ppc64/klibc/archsetjmp.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * arch/ppc64/include/klibc/archsetjmp.h
- */
-
-#ifndef _KLIBC_ARCHSETJMP_H
-#define _KLIBC_ARCHSETJMP_H
-
-struct __jmp_buf {
- unsigned long __r2;
- unsigned long __sp;
- unsigned long __lr;
- unsigned long __cr;
- unsigned long __r13;
- unsigned long __r14;
- unsigned long __r15;
- unsigned long __r16;
- unsigned long __r17;
- unsigned long __r18;
- unsigned long __r19;
- unsigned long __r20;
- unsigned long __r21;
- unsigned long __r22;
- unsigned long __r23;
- unsigned long __r24;
- unsigned long __r25;
- unsigned long __r26;
- unsigned long __r27;
- unsigned long __r28;
- unsigned long __r29;
- unsigned long __r30;
- unsigned long __r31;
-};
-
-typedef struct __jmp_buf jmp_buf[1];
-
-#endif /* _SETJMP_H */
diff --git a/klibc/include/arch/ppc64/klibc/archsignal.h b/klibc/include/arch/ppc64/klibc/archsignal.h
deleted file mode 100644
index 8452f6e4bc..0000000000
--- a/klibc/include/arch/ppc64/klibc/archsignal.h
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * arch/ppc64/include/klibc/archsignal.h
- *
- * Architecture-specific signal definitions
- *
- */
-
-#ifndef _KLIBC_ARCHSIGNAL_H
-#define _KLIBC_ARCHSIGNAL_H
-
-/* No special stuff for this architecture */
-
-#endif
diff --git a/klibc/include/arch/ppc64/klibc/archstat.h b/klibc/include/arch/ppc64/klibc/archstat.h
deleted file mode 100644
index 71f4748690..0000000000
--- a/klibc/include/arch/ppc64/klibc/archstat.h
+++ /dev/null
@@ -1,25 +0,0 @@
-#ifndef _KLIBC_ARCHSTAT_H
-#define _KLIBC_ARCHSTAT_H
-
-#define _STATBUF_ST_NSEC
-
-struct stat {
- unsigned long st_dev;
- ino_t st_ino;
- nlink_t st_nlink;
- mode_t st_mode;
- uid_t st_uid;
- gid_t st_gid;
- unsigned long st_rdev;
- off_t st_size;
- unsigned long st_blksize;
- unsigned long st_blocks;
- struct timespec st_atim; /* Time of last access. */
- struct timespec st_mtim; /* Time of last modification. */
- struct timespec st_ctim; /* Time of last status change. */
- unsigned long __unused4;
- unsigned long __unused5;
- unsigned long __unused6;
-};
-
-#endif
diff --git a/klibc/include/arch/ppc64/klibc/archsys.h b/klibc/include/arch/ppc64/klibc/archsys.h
deleted file mode 100644
index 4f81fee00d..0000000000
--- a/klibc/include/arch/ppc64/klibc/archsys.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * arch/ppc64/include/klibc/archsys.h
- *
- * Architecture-specific syscall definitions
- */
-
-#ifndef _KLIBC_ARCHSYS_H
-#define _KLIBC_ARCHSYS_H
-
-#ifndef _syscall6
-
-#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
- type5,arg5,type6,arg6) \
-type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5,type6 arg6) \
-{ \
- unsigned long __sc_ret, __sc_err; \
- { \
- register unsigned long __sc_0 __asm__ ("r0"); \
- register unsigned long __sc_3 __asm__ ("r3"); \
- register unsigned long __sc_4 __asm__ ("r4"); \
- register unsigned long __sc_5 __asm__ ("r5"); \
- register unsigned long __sc_6 __asm__ ("r6"); \
- register unsigned long __sc_7 __asm__ ("r7"); \
- register unsigned long __sc_8 __asm__ ("r8"); \
- \
- __sc_3 = (unsigned long) (arg1); \
- __sc_4 = (unsigned long) (arg2); \
- __sc_5 = (unsigned long) (arg3); \
- __sc_6 = (unsigned long) (arg4); \
- __sc_7 = (unsigned long) (arg5); \
- __sc_8 = (unsigned long) (arg6); \
- __sc_0 = __NR_##name; \
- __asm__ __volatile__ \
- ("sc \n\t" \
- "mfcr %1 " \
- : "=&r" (__sc_3), "=&r" (__sc_0) \
- : "0" (__sc_3), "1" (__sc_0), \
- "r" (__sc_4), \
- "r" (__sc_5), \
- "r" (__sc_6), \
- "r" (__sc_7), \
- "r" (__sc_8) \
- : __syscall_clobbers); \
- __sc_ret = __sc_3; \
- __sc_err = __sc_0; \
- } \
- __syscall_return (type); \
-}
-
-#endif /* _syscall6() missing */
-
-#endif /* _KLIBC_ARCHSYS_H */
diff --git a/klibc/include/arch/s390/klibc/archsetjmp.h b/klibc/include/arch/s390/klibc/archsetjmp.h
deleted file mode 100644
index 11a641ed5a..0000000000
--- a/klibc/include/arch/s390/klibc/archsetjmp.h
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * arch/s390/include/klibc/archsetjmp.h
- */
-
-#ifndef _KLIBC_ARCHSETJMP_H
-#define _KLIBC_ARCHSETJMP_H
-
-struct __jmp_buf {
- uint32_t __gregs[10]; /* general registers r6-r15 */
- uint64_t __fpregs[2]; /* fp registers f4 and f6 */
-};
-
-typedef struct __jmp_buf jmp_buf[1];
-
-#endif /* _SETJMP_H */
diff --git a/klibc/include/arch/s390/klibc/archsignal.h b/klibc/include/arch/s390/klibc/archsignal.h
deleted file mode 100644
index 1f8de28b4b..0000000000
--- a/klibc/include/arch/s390/klibc/archsignal.h
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * arch/s390/include/klibc/archsignal.h
- *
- * Architecture-specific signal definitions
- *
- */
-
-#ifndef _KLIBC_ARCHSIGNAL_H
-#define _KLIBC_ARCHSIGNAL_H
-
-/* No special stuff for this architecture */
-
-#endif
diff --git a/klibc/include/arch/s390/klibc/archstat.h b/klibc/include/arch/s390/klibc/archstat.h
deleted file mode 100644
index 866c3d4f4c..0000000000
--- a/klibc/include/arch/s390/klibc/archstat.h
+++ /dev/null
@@ -1,31 +0,0 @@
-#ifndef _KLIBC_ARCHSTAT_H
-#define _KLIBC_ARCHSTAT_H
-
-#define _STATBUF_ST_NSEC
-
-/* This matches struct stat64 in glibc2.1, hence the absolutely
- * insane amounts of padding around dev_t's.
- */
-struct stat {
- unsigned long long st_dev;
- unsigned int __pad1;
-#define STAT64_HAS_BROKEN_ST_INO 1
- unsigned long __st_ino;
- unsigned int st_mode;
- unsigned int st_nlink;
- unsigned long st_uid;
- unsigned long st_gid;
- unsigned long long st_rdev;
- unsigned int __pad3;
- long long st_size;
- unsigned long st_blksize;
- unsigned char __pad4[4];
- unsigned long __pad5; /* future possible st_blocks high bits */
- unsigned long st_blocks; /* Number 512-byte blocks allocated. */
- struct timespec st_atim;
- struct timespec st_mtim;
- struct timespec st_ctim;
- unsigned long long st_ino;
-};
-
-#endif
diff --git a/klibc/include/arch/s390/klibc/archsys.h b/klibc/include/arch/s390/klibc/archsys.h
deleted file mode 100644
index 1cd0948f3c..0000000000
--- a/klibc/include/arch/s390/klibc/archsys.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * arch/s390/include/klibc/archsys.h
- *
- * Architecture-specific syscall definitions
- */
-
-#ifndef _KLIBC_ARCHSYS_H
-#define _KLIBC_ARCHSYS_H
-
-/* S/390 only has five syscall parameters, and uses a structure for
- 6-argument syscalls. */
-
-#ifndef _syscall6
-
-#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,\
- type4,arg4,type5,arg5,type6,arg6) \
-type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \
- type5 arg5, type6 arg6) { \
- unsigned long __arg[6] = { \
- (unsigned long) arg1, \
- (unsigned long) arg2, \
- (unsigned long) arg3, \
- (unsigned long) arg4, \
- (unsigned long) arg5, \
- (unsigned long) arg6 \
- }; \
- register void *__argp asm("2") = &__arg; \
- long __res; \
- __asm__ __volatile__ ( \
- " svc %b1\n" \
- " lr %0,2" \
- : "=d" (__res) \
- : "i" (__NR_##name), \
- "d" (__argp) \
- : _svc_clobber); \
- __syscall_return(type, __res); \
-}
-
-#endif /* _syscall6() missing */
-
-#endif /* _KLIBC_ARCHSYS_H */
diff --git a/klibc/include/arch/s390x/klibc/archsetjmp.h b/klibc/include/arch/s390x/klibc/archsetjmp.h
deleted file mode 100644
index dd3ed0d47c..0000000000
--- a/klibc/include/arch/s390x/klibc/archsetjmp.h
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * arch/s390x/include/klibc/archsetjmp.h
- */
-
-#ifndef _KLIBC_ARCHSETJMP_H
-#define _KLIBC_ARCHSETJMP_H
-
-struct __jmp_buf {
- uint64_t __gregs[10]; /* general registers r6-r15 */
- uint64_t __fpregs[4]; /* fp registers f1, f3, f5, f7 */
-};
-
-typedef struct __jmp_buf jmp_buf[1];
-
-#endif /* _SETJMP_H */
diff --git a/klibc/include/arch/s390x/klibc/archsignal.h b/klibc/include/arch/s390x/klibc/archsignal.h
deleted file mode 100644
index 08c9a0073a..0000000000
--- a/klibc/include/arch/s390x/klibc/archsignal.h
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * arch/s390x/include/klibc/archsignal.h
- *
- * Architecture-specific signal definitions
- *
- */
-
-#ifndef _KLIBC_ARCHSIGNAL_H
-#define _KLIBC_ARCHSIGNAL_H
-
-/* No special stuff for this architecture */
-
-#endif
diff --git a/klibc/include/arch/s390x/klibc/archstat.h b/klibc/include/arch/s390x/klibc/archstat.h
deleted file mode 100644
index 0de73cb2b6..0000000000
--- a/klibc/include/arch/s390x/klibc/archstat.h
+++ /dev/null
@@ -1,24 +0,0 @@
-#ifndef _KLIBC_ARCHSTAT_H
-#define _KLIBC_ARCHSTAT_H
-
-#define _STATBUF_ST_NSEC
-
-struct stat {
- unsigned long st_dev;
- unsigned long st_ino;
- unsigned long st_nlink;
- unsigned int st_mode;
- unsigned int st_uid;
- unsigned int st_gid;
- unsigned int __pad1;
- unsigned long st_rdev;
- unsigned long st_size;
- struct timespec st_atim;
- struct timespec st_mtim;
- struct timespec st_ctim;
- unsigned long st_blksize;
- long st_blocks;
- unsigned long __unused[3];
-};
-
-#endif
diff --git a/klibc/include/arch/s390x/klibc/archsys.h b/klibc/include/arch/s390x/klibc/archsys.h
deleted file mode 100644
index 15f7113bb4..0000000000
--- a/klibc/include/arch/s390x/klibc/archsys.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * arch/s390x/include/klibc/archsys.h
- *
- * Architecture-specific syscall definitions
- */
-
-#ifndef _KLIBC_ARCHSYS_H
-#define _KLIBC_ARCHSYS_H
-
-/* S/390X only has five syscall parameters, and uses a structure for
- 6-argument syscalls. */
-
-#ifndef _syscall6
-
-#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,\
- type4,arg4,type5,arg5,type6,arg6) \
-type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \
- type5 arg5, type6 arg6) { \
- unsigned long __arg[6] = { \
- (unsigned long) arg1, \
- (unsigned long) arg2, \
- (unsigned long) arg3, \
- (unsigned long) arg4, \
- (unsigned long) arg5, \
- (unsigned long) arg6 \
- }; \
- register void *__argp asm("2") = &__arg; \
- long __res; \
- __asm__ __volatile__ ( \
- " svc %b1\n" \
- " lgr %0,2" \
- : "=d" (__res) \
- : "i" (__NR_##name), \
- "d" (__argp) \
- : _svc_clobber); \
- __syscall_return(type, __res); \
-}
-
-#endif /* _syscall6() missing */
-
-#endif /* _KLIBC_ARCHSYS_H */
diff --git a/klibc/include/arch/sh/klibc/archsetjmp.h b/klibc/include/arch/sh/klibc/archsetjmp.h
deleted file mode 100644
index 28dd932fbc..0000000000
--- a/klibc/include/arch/sh/klibc/archsetjmp.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * arch/sh/include/klibc/archsetjmp.h
- */
-
-#ifndef _KLIBC_ARCHSETJMP_H
-#define _KLIBC_ARCHSETJMP_H
-
-struct __jmp_buf {
- unsigned long r8;
- unsigned long r9;
- unsigned long r10;
- unsigned long r11;
- unsigned long r12;
- unsigned long r13;
- unsigned long r14;
- unsigned long r15;
- unsigned long pr;
-};
-
-typedef struct __jmp_buf jmp_buf[1];
-
-#endif /* _KLIBC_ARCHSETJMP_H */
diff --git a/klibc/include/arch/sh/klibc/archsignal.h b/klibc/include/arch/sh/klibc/archsignal.h
deleted file mode 100644
index 6c4e5976ad..0000000000
--- a/klibc/include/arch/sh/klibc/archsignal.h
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * arch/sh/include/klibc/archsignal.h
- *
- * Architecture-specific signal definitions
- *
- */
-
-#ifndef _KLIBC_ARCHSIGNAL_H
-#define _KLIBC_ARCHSIGNAL_H
-
-/* No special stuff for this architecture */
-
-#endif
diff --git a/klibc/include/arch/sh/klibc/archstat.h b/klibc/include/arch/sh/klibc/archstat.h
deleted file mode 100644
index 73caceb593..0000000000
--- a/klibc/include/arch/sh/klibc/archstat.h
+++ /dev/null
@@ -1,45 +0,0 @@
-#ifndef _KLIBC_ARCHSTAT_H
-#define _KLIBC_ARCHSTAT_H
-
-#include <endian.h>
-
-#define _STATBUF_ST_NSEC
-
-/* This matches struct stat64 in glibc2.1, hence the absolutely
- * insane amounts of padding around dev_t's.
- */
-struct stat64 {
- unsigned long long st_dev;
- unsigned char __pad0[4];
-
- unsigned long st_ino;
- unsigned int st_mode;
- unsigned int st_nlink;
-
- unsigned long st_uid;
- unsigned long st_gid;
-
- unsigned long long st_rdev;
- unsigned char __pad3[4];
-
- long long st_size;
- unsigned long st_blksize;
-
-#if __BYTE_ORDER == __BIG_ENDIAN
- unsigned long __pad4; /* Future possible st_blocks hi bits */
- unsigned long st_blocks; /* Number 512-byte blocks allocated. */
-#else /* Must be little */
- unsigned long st_blocks; /* Number 512-byte blocks allocated. */
- unsigned long __pad4; /* Future possible st_blocks hi bits */
-#endif
-
- struct timespec st_atim;
- struct timespec st_mtim;
- struct timespec st_ctim;
-
- unsigned long __unused1;
- unsigned long __unused2;
-};
-
-#endif
-
diff --git a/klibc/include/arch/sh/klibc/archsys.h b/klibc/include/arch/sh/klibc/archsys.h
deleted file mode 100644
index 5f8050a536..0000000000
--- a/klibc/include/arch/sh/klibc/archsys.h
+++ /dev/null
@@ -1,12 +0,0 @@
-/*
- * arch/sh/include/klibc/archsys.h
- *
- * Architecture-specific syscall definitions
- */
-
-#ifndef _KLIBC_ARCHSYS_H
-#define _KLIBC_ARCHSYS_H
-
-/* No special syscall definitions for this architecture */
-
-#endif /* _KLIBC_ARCHSYS_H */
diff --git a/klibc/include/arch/sparc/klibc/archsetjmp.h b/klibc/include/arch/sparc/klibc/archsetjmp.h
deleted file mode 100644
index 92c1c74c9d..0000000000
--- a/klibc/include/arch/sparc/klibc/archsetjmp.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * arch/sparc/include/klibc/archsetjmp.h
- */
-
-#ifndef _KLIBC_ARCHSETJMP_H
-#define _KLIBC_ARCHSETJMP_H
-
-struct __jmp_buf {
- unsigned long __sp;
- unsigned long __fp;
- unsigned long __pc;
-};
-
-typedef struct __jmp_buf jmp_buf[1];
-
-#endif /* _SETJMP_H */
diff --git a/klibc/include/arch/sparc/klibc/archsignal.h b/klibc/include/arch/sparc/klibc/archsignal.h
deleted file mode 100644
index 3be67a2158..0000000000
--- a/klibc/include/arch/sparc/klibc/archsignal.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * arch/sparc/include/klibc/archsignal.h
- *
- * Architecture-specific signal definitions
- *
- */
-
-#ifndef _KLIBC_ARCHSIGNAL_H
-#define _KLIBC_ARCHSIGNAL_H
-
-/* Hidden definitions */
-
-struct __new_sigaction {
- __sighandler_t sa_handler;
- unsigned long sa_flags;
- void (*sa_restorer)(void); /* Not used by Linux/SPARC */
- __new_sigset_t sa_mask;
-};
-
-struct k_sigaction {
- struct __new_sigaction sa;
- void __user *ka_restorer;
-};
-
-struct __old_sigaction {
- __sighandler_t sa_handler;
- __old_sigset_t sa_mask;
- unsigned long sa_flags;
- void (*sa_restorer) (void); /* not used by Linux/SPARC */
-};
-
-typedef struct sigaltstack {
- void __user *ss_sp;
- int ss_flags;
- size_t ss_size;
-} stack_t;
-
-#endif
diff --git a/klibc/include/arch/sparc/klibc/archstat.h b/klibc/include/arch/sparc/klibc/archstat.h
deleted file mode 100644
index 0ff68785e5..0000000000
--- a/klibc/include/arch/sparc/klibc/archstat.h
+++ /dev/null
@@ -1,35 +0,0 @@
-#ifndef _KLIBC_ARCHSTAT_H
-#define _KLIBC_ARCHSTAT_H
-
-#define _STATBUF_ST_NSEC
-
-struct stat {
- unsigned long long st_dev;
-
- unsigned long long st_ino;
-
- unsigned int st_mode;
- unsigned int st_nlink;
-
- unsigned int st_uid;
- unsigned int st_gid;
-
- unsigned long long st_rdev;
-
- unsigned char __pad3[8];
-
- long long st_size;
- unsigned int st_blksize;
-
- unsigned char __pad4[8];
- unsigned int st_blocks;
-
- struct timespec st_atim;
- struct timespec st_mtim;
- struct timespec st_ctim;
-
- unsigned int __unused4;
- unsigned int __unused5;
-};
-
-#endif
diff --git a/klibc/include/arch/sparc/klibc/archsys.h b/klibc/include/arch/sparc/klibc/archsys.h
deleted file mode 100644
index 20de8a8b44..0000000000
--- a/klibc/include/arch/sparc/klibc/archsys.h
+++ /dev/null
@@ -1,10 +0,0 @@
-/*
- * arch/sparc/include/klibc/archsys.h
- *
- * Architecture-specific syscall definitions
- */
-
-#ifndef _KLIBC_ARCHSYS_H
-#define _KLIBC_ARCHSYS_H
-
-#endif /* _KLIBC_ARCHSYS_H */
diff --git a/klibc/include/arch/sparc/machine/asm.h b/klibc/include/arch/sparc/machine/asm.h
deleted file mode 100644
index b622bd8cf1..0000000000
--- a/klibc/include/arch/sparc/machine/asm.h
+++ /dev/null
@@ -1,192 +0,0 @@
-/* $NetBSD: asm.h,v 1.14 2002/07/20 08:37:30 mrg Exp $ */
-
-/*
- * Copyright (c) 1994 Allen Briggs
- * All rights reserved.
- *
- * Gleaned from locore.s and sun3 asm.h which had the following copyrights:
- * locore.s:
- * Copyright (c) 1988 University of Utah.
- * Copyright (c) 1982, 1990 The Regents of the University of California.
- * sun3/include/asm.h:
- * Copyright (c) 1993 Adam Glass
- * Copyright (c) 1990 The Regents of the University of California.
- *
- * 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 _ASM_H_
-#define _ASM_H_
-
-/* Pull in CCFSZ, CC64FSZ, and BIAS from frame.h */
-#ifndef _LOCORE
-#define _LOCORE
-#endif
-#include <machine/frame.h>
-
-#ifdef __ELF__
-#define _C_LABEL(name) name
-#else
-#ifdef __STDC__
-#define _C_LABEL(name) _ ## name
-#else
-#define _C_LABEL(name) _/**/name
-#endif
-#endif
-#define _ASM_LABEL(name) name
-
-#ifdef PIC
-/*
- * PIC_PROLOGUE() is akin to the compiler generated function prologue for
- * PIC code. It leaves the address of the Global Offset Table in DEST,
- * clobbering register TMP in the process.
- *
- * We can use two code sequences. We can read the %pc or use the call
- * instruction that saves the pc in %o7. Call requires the branch unit and
- * IEU1, and clobbers %o7 which needs to be restored. This instruction
- * sequence takes about 4 cycles due to instruction interdependence. Reading
- * the pc takes 4 cycles to dispatch and is always dispatched alone. That
- * sequence takes 7 cycles.
- */
-#ifdef __arch64__
-#define PIC_PROLOGUE(dest,tmp) \
- mov %o7, tmp; \
- sethi %hi(_GLOBAL_OFFSET_TABLE_-4),dest; \
- call 0f; \
- or dest,%lo(_GLOBAL_OFFSET_TABLE_+4),dest; \
-0: \
- add dest,%o7,dest; \
- mov tmp, %o7
-#else
-#define PIC_PROLOGUE(dest,tmp) \
- mov %o7,tmp; 3: call 4f; nop; 4: \
- sethi %hi(_C_LABEL(_GLOBAL_OFFSET_TABLE_)-(3b-.)),dest; \
- or dest,%lo(_C_LABEL(_GLOBAL_OFFSET_TABLE_)-(3b-.)),dest; \
- add dest,%o7,dest; mov tmp,%o7
-#endif
-
-/*
- * PICCY_SET() does the equivalent of a `set var, %dest' instruction in
- * a PIC-like way, but without involving the Global Offset Table. This
- * only works for VARs defined in the same file *and* in the text segment.
- */
-#ifdef __arch64__
-#define PICCY_SET(var,dest,tmp) \
- 3: rd %pc, tmp; add tmp,(var-3b),dest
-#else
-#define PICCY_SET(var,dest,tmp) \
- mov %o7,tmp; 3: call 4f; nop; 4: \
- add %o7,(var-3b),dest; mov tmp,%o7
-#endif
-#else
-#define PIC_PROLOGUE(dest,tmp)
-#define PICCY_OFFSET(var,dest,tmp)
-#endif
-
-#define FTYPE(x) .type x,@function
-#define OTYPE(x) .type x,@object
-
-#define _ENTRY(name) \
- .align 4; .globl name; .proc 1; FTYPE(name); name:
-
-#ifdef GPROF
-/* see _MCOUNT_ENTRY in profile.h */
-#ifdef __ELF__
-#ifdef __arch64__
-#define _PROF_PROLOGUE \
- .data; .align 8; 1: .uaword 0; .uaword 0; \
- .text; save %sp,-CC64FSZ,%sp; sethi %hi(1b),%o0; call _mcount; \
- or %o0,%lo(1b),%o0; restore
-#else
-#define _PROF_PROLOGUE \
- .data; .align 4; 1: .long 0; \
- .text; save %sp,-96,%sp; sethi %hi(1b),%o0; call _mcount; \
- or %o0,%lo(1b),%o0; restore
-#endif
-#else
-#ifdef __arch64__
-#define _PROF_PROLOGUE \
- .data; .align 8; 1: .uaword 0; .uaword 0; \
- .text; save %sp,-CC64FSZ,%sp; sethi %hi(1b),%o0; call mcount; \
- or %o0,%lo(1b),%o0; restore
-#else
-#define _PROF_PROLOGUE \
- .data; .align 4; 1: .long 0; \
- .text; save %sp,-96,%sp; sethi %hi(1b),%o0; call mcount; \
- or %o0,%lo(1b),%o0; restore
-#endif
-#endif
-#else
-#define _PROF_PROLOGUE
-#endif
-
-#define ENTRY(name) _ENTRY(_C_LABEL(name)); _PROF_PROLOGUE
-#define ENTRY_NOPROFILE(name) _ENTRY(_C_LABEL(name))
-#define ASENTRY(name) _ENTRY(_ASM_LABEL(name)); _PROF_PROLOGUE
-#define FUNC(name) ASENTRY(name)
-#define RODATA(name) .align 4; .text; .globl _C_LABEL(name); \
- OTYPE(_C_LABEL(name)); _C_LABEL(name):
-
-
-#define ASMSTR .asciz
-
-#define RCSID(name) .asciz name
-
-#ifdef __ELF__
-#define WEAK_ALIAS(alias,sym) \
- .weak alias; \
- alias = sym
-#endif
-
-/*
- * WARN_REFERENCES: create a warning if the specified symbol is referenced.
- */
-#ifdef __ELF__
-#ifdef __STDC__
-#define WARN_REFERENCES(_sym,_msg) \
- .section .gnu.warning. ## _sym ; .ascii _msg ; .text
-#else
-#define WARN_REFERENCES(_sym,_msg) \
- .section .gnu.warning./**/_sym ; .ascii _msg ; .text
-#endif /* __STDC__ */
-#else
-#ifdef __STDC__
-#define __STRING(x) #x
-#define WARN_REFERENCES(sym,msg) \
- .stabs msg ## ,30,0,0,0 ; \
- .stabs __STRING(_ ## sym) ## ,1,0,0,0
-#else
-#define __STRING(x) "x"
-#define WARN_REFERENCES(sym,msg) \
- .stabs msg,30,0,0,0 ; \
- .stabs __STRING(_/**/sym),1,0,0,0
-#endif /* __STDC__ */
-#endif /* __ELF__ */
-
-#endif /* _ASM_H_ */
diff --git a/klibc/include/arch/sparc/machine/frame.h b/klibc/include/arch/sparc/machine/frame.h
deleted file mode 100644
index b09175c7f4..0000000000
--- a/klibc/include/arch/sparc/machine/frame.h
+++ /dev/null
@@ -1,138 +0,0 @@
-/* $NetBSD: frame.h,v 1.4 2001/12/04 00:05:05 darrenr Exp $ */
-
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This software was developed by the Computer Systems Engineering group
- * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
- * contributed to Berkeley.
- *
- * 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, Lawrence Berkeley Laboratory.
- *
- * 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.
- *
- * @(#)frame.h 8.1 (Berkeley) 6/11/93
- */
-
-#if defined(_KERNEL_OPT)
-#include "opt_sparc_arch.h"
-#endif
-
-/*
- * Sparc stack frame format.
- *
- * Note that the contents of each stack frame may be held only in
- * machine register windows. In order to get an accurate picture
- * of the frame, you must first force the kernel to write any such
- * windows to the stack.
- */
-#ifndef _LOCORE
-#ifndef SUN4U
-struct frame {
- int32_t fr_local[8]; /* space to save locals (%l0..%l7) */
- int32_t fr_arg[6]; /* space to save arguments (%i0..%i5) */
- struct frame *fr_fp; /* space to save frame pointer (%i6) */
- int32_t fr_pc; /* space to save return pc (%i7) */
- /*
- * SunOS reserves another 8 words here; this is pointless
- * but we do it for compatibility.
- */
- int32_t fr_xxx; /* `structure return pointer' (unused) */
- int32_t fr_argd[6]; /* `arg dump area' (lunacy) */
- int32_t fr_argx[1]; /* arg extension (args 7..n; variable size) */
-};
-#else
-struct frame32 {
- int32_t fr_local[8]; /* space to save locals (%l0..%l7) */
- int32_t fr_arg[6]; /* space to save arguments (%i0..%i5) */
- u_int32_t fr_fp; /* space to save frame pointer (%i6) */
- u_int32_t fr_pc; /* space to save return pc (%i7) */
- /*
- * SunOS reserves another 8 words here; this is pointless
- * but we do it for compatibility.
- */
- int32_t fr_xxx; /* `structure return pointer' (unused) */
- int32_t fr_argd[6]; /* `arg dump area' (lunacy) */
- int32_t fr_argx[1]; /* arg extension (args 7..n; variable size) */
-};
-#endif
-#endif
-
-/*
- * CCFSZ (C Compiler Frame SiZe) is the size of a stack frame required if
- * a function is to call C code. It should be just 64, but Sun defined
- * their frame with space to hold arguments 0 through 5 (plus some junk),
- * and varargs routines (such as kprintf) demand this, and gcc uses this
- * area at times anyway.
- */
-#define CCFSZ 96
-
-/*
- * Sparc v9 stack frame format.
- *
- * Note that the contents of each stack frame may be held only in
- * machine register windows. In order to get an accurate picture
- * of the frame, you must first force the kernel to write any such
- * windows to the stack.
- *
- * V9 frames have an odd bias, so you can tall a v9 frame from
- * a v8 frame by testing the stack pointer's lsb.
- */
-#if !defined(_LOCORE) && !defined(_LIBC)
-struct frame64 {
- int64_t fr_local[8]; /* space to save locals (%l0..%l7) */
- int64_t fr_arg[6]; /* space to save arguments (%i0..%i5) */
- u_int64_t fr_fp; /* space to save frame pointer (%i6) */
- u_int64_t fr_pc; /* space to save return pc (%i7) */
- /*
- * SVR4 reserves a bunch of extra stuff.
- */
- int64_t fr_argd[6]; /* `register save area' (lunacy) */
- int64_t fr_argx[0]; /* arg extension (args 7..n; variable size) */
-};
-
-#define v9next_frame(f) ((struct frame64*)(f->fr_fp+BIAS))
-#endif
-
-/*
- * CC64FSZ (C Compiler 64-bit Frame SiZe) is the size of a stack frame used
- * by the compiler in 64-bit mode. It is (16)*8; space for 8 ins, 8 outs.
- */
-#define CC64FSZ 176
-
-/*
- * v9 stacks all have a bias of 2047 added to the %sp and %fp, so you can easily
- * detect it by testing the register for an odd value. Why 2K-1 I don't know.
- */
-#define BIAS (2048-1)
-
diff --git a/klibc/include/arch/sparc/machine/trap.h b/klibc/include/arch/sparc/machine/trap.h
deleted file mode 100644
index 42c3ef6ae2..0000000000
--- a/klibc/include/arch/sparc/machine/trap.h
+++ /dev/null
@@ -1,141 +0,0 @@
-/* $NetBSD: trap.h,v 1.11 1999/01/20 00:15:08 pk Exp $ */
-
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This software was developed by the Computer Systems Engineering group
- * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
- * contributed to Berkeley.
- *
- * 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, Lawrence Berkeley Laboratory.
- *
- * 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.
- *
- * @(#)trap.h 8.1 (Berkeley) 6/11/93
- */
-/*
- * Sun4m support by Aaron Brown, Harvard University.
- * Changes Copyright (c) 1995 The President and Fellows of Harvard College.
- * All rights reserved.
- */
-
-#ifndef _MACHINE_TRAP_H
-#define _MACHINE_TRAP_H
-
-/* trap vec (pri) description */
-#define T_RESET 0x00 /* (1) not actually vectored; jumps to 0 */
-#define T_TEXTFAULT 0x01 /* (2) address fault during instr fetch */
-#define T_ILLINST 0x02 /* (3) illegal instruction */
-#define T_PRIVINST 0x03 /* (4) privileged instruction */
-#define T_FPDISABLED 0x04 /* (5) fp instr while fp disabled */
-#define T_WINOF 0x05 /* (6) register window overflow */
-#define T_WINUF 0x06 /* (7) register window underflow */
-#define T_ALIGN 0x07 /* (8) address not properly aligned */
-#define T_FPE 0x08 /* (9) floating point exception */
-#define T_DATAFAULT 0x09 /* (10) address fault during data fetch */
-#define T_TAGOF 0x0a /* (11) tag overflow */
-/* 0x0b unused */
-/* 0x0c unused */
-/* 0x0d unused */
-/* 0x0e unused */
-/* 0x0f unused */
-/* 0x10 unused */
-#define T_L1INT 0x11 /* (27) level 1 interrupt */
-#define T_L2INT 0x12 /* (26) level 2 interrupt */
-#define T_L3INT 0x13 /* (25) level 3 interrupt */
-#define T_L4INT 0x14 /* (24) level 4 interrupt */
-#define T_L5INT 0x15 /* (23) level 5 interrupt */
-#define T_L6INT 0x16 /* (22) level 6 interrupt */
-#define T_L7INT 0x17 /* (21) level 7 interrupt */
-#define T_L8INT 0x18 /* (20) level 8 interrupt */
-#define T_L9INT 0x19 /* (19) level 9 interrupt */
-#define T_L10INT 0x1a /* (18) level 10 interrupt */
-#define T_L11INT 0x1b /* (17) level 11 interrupt */
-#define T_L12INT 0x1c /* (16) level 12 interrupt */
-#define T_L13INT 0x1d /* (15) level 13 interrupt */
-#define T_L14INT 0x1e /* (14) level 14 interrupt */
-#define T_L15INT 0x1f /* (13) level 15 interrupt */
-/* 0x20 unused */
-/* through 0x23 unused */
-#define T_CPDISABLED 0x24 /* (5) coprocessor instr while disabled */
-#define T_UNIMPLFLUSH 0x25 /* Unimplemented FLUSH */
-/* through 0x27 unused */
-#define T_CPEXCEPTION 0x28 /* (9) coprocessor exception */
-/* 0x29 unused */
-#define T_IDIV0 0x2a /* divide by zero (from hw [su]div instr) */
-#define T_STOREBUFFAULT 0x2b /* SuperSPARC: Store buffer copy-back fault */
-/* 0x2c unused */
-/* through 0x7f unused */
-
-/* beginning of `user' vectors (from trap instructions) - all priority 12 */
-#define T_SUN_SYSCALL 0x80 /* system call */
-#define T_BREAKPOINT 0x81 /* breakpoint `instruction' */
-#define T_DIV0 0x82 /* division routine was handed 0 */
-#define T_FLUSHWIN 0x83 /* flush windows */
-#define T_CLEANWIN 0x84 /* provide clean windows */
-#define T_RANGECHECK 0x85 /* ? */
-#define T_FIXALIGN 0x86 /* fix up unaligned accesses */
-#define T_INTOF 0x87 /* integer overflow ? */
-#define T_SVR4_SYSCALL 0x88 /* SVR4 system call */
-#define T_BSD_SYSCALL 0x89 /* BSD system call */
-#define T_KGDB_EXEC 0x8a /* for kernel gdb */
-
-/* 0x8b..0xff are currently unallocated, except the following */
-#define T_SVR4_GETCC 0xa0
-#define T_SVR4_SETCC 0xa1
-#define T_SVR4_GETPSR 0xa2
-#define T_SVR4_SETPSR 0xa3
-#define T_SVR4_GETHRTIME 0xa4
-#define T_SVR4_GETHRVTIME 0xa5
-#define T_SVR4_GETHRESTIME 0xa7
-
-
-#ifdef _KERNEL /* pseudo traps for locore.s */
-#define T_RWRET -1 /* need first user window for trap return */
-#define T_AST -2 /* no-op, just needed reschedule or profile */
-#endif
-
-/* flags to system call (flags in %g1 along with syscall number) */
-#define SYSCALL_G2RFLAG 0x400 /* on success, return to %g2 rather than npc */
-#define SYSCALL_G7RFLAG 0x800 /* use %g7 as above (deprecated) */
-
-/*
- * `software trap' macros to keep people happy (sparc v8 manual says not
- * to set the upper bits).
- */
-#define ST_BREAKPOINT (T_BREAKPOINT & 0x7f)
-#define ST_DIV0 (T_DIV0 & 0x7f)
-#define ST_FLUSHWIN (T_FLUSHWIN & 0x7f)
-#define ST_SYSCALL (T_SUN_SYSCALL & 0x7f)
-
-#endif /* _MACHINE_TRAP_H_ */
diff --git a/klibc/include/arch/sparc64/klibc/archsetjmp.h b/klibc/include/arch/sparc64/klibc/archsetjmp.h
deleted file mode 100644
index 022a31e542..0000000000
--- a/klibc/include/arch/sparc64/klibc/archsetjmp.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * arch/sparc64/include/klibc/archsetjmp.h
- */
-
-#ifndef _KLIBC_ARCHSETJMP_H
-#define _KLIBC_ARCHSETJMP_H
-
-struct __jmp_buf {
- unsigned long __sp;
- unsigned long __fp;
- unsigned long __pc;
-};
-
-typedef struct __jmp_buf jmp_buf[1];
-
-#endif /* _SETJMP_H */
diff --git a/klibc/include/arch/sparc64/klibc/archsignal.h b/klibc/include/arch/sparc64/klibc/archsignal.h
deleted file mode 100644
index f81bd668bb..0000000000
--- a/klibc/include/arch/sparc64/klibc/archsignal.h
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * arch/sparc64/include/klibc/archsignal.h
- *
- * Architecture-specific signal definitions
- *
- */
-
-#ifndef _KLIBC_ARCHSIGNAL_H
-#define _KLIBC_ARCHSIGNAL_H
-
-/* No special stuff for this architecture */
-
-#endif
diff --git a/klibc/include/arch/sparc64/klibc/archstat.h b/klibc/include/arch/sparc64/klibc/archstat.h
deleted file mode 100644
index c22905d30c..0000000000
--- a/klibc/include/arch/sparc64/klibc/archstat.h
+++ /dev/null
@@ -1,22 +0,0 @@
-#ifndef _KLIBC_ARCHSTAT_H
-#define _KLIBC_ARCHSTAT_H
-
-/* No nsec fields?! */
-struct stat {
- unsigned st_dev;
- ino_t st_ino;
- mode_t st_mode;
- short st_nlink;
- uid_t st_uid;
- gid_t st_gid;
- unsigned st_rdev;
- off_t st_size;
- time_t st_atime;
- time_t st_mtime;
- time_t st_ctime;
- off_t st_blksize;
- off_t st_blocks;
- unsigned long __unused4[2];
-};
-
-#endif
diff --git a/klibc/include/arch/sparc64/klibc/archsys.h b/klibc/include/arch/sparc64/klibc/archsys.h
deleted file mode 100644
index 6a3a7b25bc..0000000000
--- a/klibc/include/arch/sparc64/klibc/archsys.h
+++ /dev/null
@@ -1,10 +0,0 @@
-/*
- * arch/sparc64/include/klibc/archsys.h
- *
- * Architecture-specific syscall definitions
- */
-
-#ifndef _KLIBC_ARCHSYS_H
-#define _KLIBC_ARCHSYS_H
-
-#endif /* _KLIBC_ARCHSYS_H */
diff --git a/klibc/include/arch/x86_64/klibc/archsetjmp.h b/klibc/include/arch/x86_64/klibc/archsetjmp.h
deleted file mode 100644
index 90d0a0d263..0000000000
--- a/klibc/include/arch/x86_64/klibc/archsetjmp.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * arch/x86_64/include/klibc/archsetjmp.h
- */
-
-#ifndef _KLIBC_ARCHSETJMP_H
-#define _KLIBC_ARCHSETJMP_H
-
-struct __jmp_buf {
- unsigned long __rbx;
- unsigned long __rsp;
- unsigned long __rbp;
- unsigned long __r12;
- unsigned long __r13;
- unsigned long __r14;
- unsigned long __r15;
- unsigned long __rip;
-};
-
-typedef struct __jmp_buf jmp_buf[1];
-
-#endif /* _SETJMP_H */
diff --git a/klibc/include/arch/x86_64/klibc/archsignal.h b/klibc/include/arch/x86_64/klibc/archsignal.h
deleted file mode 100644
index 527241454e..0000000000
--- a/klibc/include/arch/x86_64/klibc/archsignal.h
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * arch/x86_64/include/klibc/archsignal.h
- *
- * Architecture-specific signal definitions
- *
- */
-
-#ifndef _KLIBC_ARCHSIGNAL_H
-#define _KLIBC_ARCHSIGNAL_H
-
-/* The x86-64 headers defines NSIG 32, but it's actually 64 */
-#undef _NSIG
-#undef NSIG
-#define _NSIG 64
-#define NSIG _NSIG
-
-#endif
diff --git a/klibc/include/arch/x86_64/klibc/archstat.h b/klibc/include/arch/x86_64/klibc/archstat.h
deleted file mode 100644
index 53e141daea..0000000000
--- a/klibc/include/arch/x86_64/klibc/archstat.h
+++ /dev/null
@@ -1,26 +0,0 @@
-#ifndef _KLIBC_ARCHSTAT_H
-#define _KLIBC_ARCHSTAT_H
-
-#define _STATBUF_ST_NSEC
-
-struct stat {
- unsigned long st_dev;
- unsigned long st_ino;
- unsigned long st_nlink;
-
- unsigned int st_mode;
- unsigned int st_uid;
- unsigned int st_gid;
- unsigned int __pad0;
- unsigned long st_rdev;
- long st_size;
- long st_blksize;
- long st_blocks; /* Number 512-byte blocks allocated. */
-
- struct timespec st_atim;
- struct timespec st_mtim;
- struct timespec st_ctim;
- long __unused[3];
-};
-
-#endif
diff --git a/klibc/include/arch/x86_64/klibc/archsys.h b/klibc/include/arch/x86_64/klibc/archsys.h
deleted file mode 100644
index 2ec72cd397..0000000000
--- a/klibc/include/arch/x86_64/klibc/archsys.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * arch/x86_64/include/klibc/archsys.h
- *
- * Architecture-specific syscall definitions
- */
-
-#ifndef _KLIBC_ARCHSYS_H
-#define _KLIBC_ARCHSYS_H
-
-/* The x86-64 syscall headers are needlessly inefficient */
-
-#undef _syscall0
-#undef _syscall1
-#undef _syscall2
-#undef _syscall3
-#undef _syscall4
-#undef _syscall5
-#undef _syscall6
-
-#define _syscall0(type,name) \
-type name (void) \
-{ \
-long __res; \
-__asm__ volatile (__syscall \
- : "=a" (__res) \
- : "0" (__NR_##name) \
- : __syscall_clobber); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall1(type,name,type1,arg1) \
-type name (type1 arg1) \
-{ \
-long __res; \
-__asm__ volatile (__syscall \
- : "=a" (__res) \
- : "0" (__NR_##name),"D" (arg1) \
- : __syscall_clobber); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall2(type,name,type1,arg1,type2,arg2) \
-type name (type1 arg1,type2 arg2) \
-{ \
-long __res; \
-__asm__ volatile (__syscall \
- : "=a" (__res) \
- : "0" (__NR_##name),"D" (arg1),"S" (arg2) \
- : __syscall_clobber); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
-type name (type1 arg1,type2 arg2,type3 arg3) \
-{ \
-long __res; \
-__asm__ volatile (__syscall \
- : "=a" (__res) \
- : "0" (__NR_##name),"D" (arg1),"S" (arg2), \
- "d" (arg3) \
- : __syscall_clobber); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
-type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4) \
-{ \
-long __res; \
-register type4 __r10 asm("%r10") = arg4; \
-__asm__ volatile (__syscall \
- : "=a" (__res) \
- : "0" (__NR_##name),"D" (arg1),"S" (arg2), \
- "d" (arg3),"r" (__r10) \
- : __syscall_clobber); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
- type5,arg5) \
-type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
-{ \
-long __res; \
-register type4 __r10 asm("%r10") = arg4; \
-register type5 __r8 asm("%r8") = arg5; \
-__asm__ volatile (__syscall \
- : "=a" (__res) \
- : "0" (__NR_##name),"D" (arg1),"S" (arg2), \
- "d" (arg3),"r" (__r10),"r" (__r8) \
- : __syscall_clobber); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
- type5,arg5,type6,arg6) \
-type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5,type6 arg6) \
-{ \
-long __res; \
-register type4 __r10 asm("%r10") = arg4; \
-register type5 __r8 asm("%r8") = arg5; \
-register type6 __r9 asm("%r9") = arg6; \
-__asm__ volatile (__syscall \
- : "=a" (__res) \
- : "0" (__NR_##name),"D" (arg1),"S" (arg2), \
- "d" (arg3),"r" (__r10),"r" (__r8), "r" (__r9) \
- : __syscall_clobber); \
-__syscall_return(type,__res); \
-}
-
-#endif /* _KLIBC_ARCHSYS_H */
diff --git a/klibc/include/arch/x86_64/sys/io.h b/klibc/include/arch/x86_64/sys/io.h
deleted file mode 100644
index 4a0ae44985..0000000000
--- a/klibc/include/arch/x86_64/sys/io.h
+++ /dev/null
@@ -1,126 +0,0 @@
-#ident "$Id: io.h,v 1.1 2004/01/25 01:34:29 hpa Exp $"
-/* ----------------------------------------------------------------------- *
- *
- * Copyright 2004 H. Peter Anvin - All Rights Reserved
- *
- * 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.
- *
- * ----------------------------------------------------------------------- */
-
-/*
- * sys/io.h for the i386 architecture
- *
- * Basic I/O macros
- */
-
-#ifndef _SYS_IO_H
-#define _SYS_IO_H 1
-
-/* I/O-related system calls */
-
-int iopl(int);
-int ioperm(unsigned long, unsigned long, int);
-
-/* Basic I/O macros */
-
-static __inline__ void
-outb(unsigned char __v, unsigned short __p)
-{
- asm volatile("outb %0,%1" : : "a" (__v), "dN" (__p));
-}
-
-static __inline__ void
-outw(unsigned short __v, unsigned short __p)
-{
- asm volatile("outw %0,%1" : : "a" (__v), "dN" (__p));
-}
-
-static __inline__ void
-outl(unsigned int __v, unsigned short __p)
-{
- asm volatile("outl %0,%1" : : "a" (__v), "dN" (__p));
-}
-
-static __inline__ unsigned char
-inb(unsigned short __p)
-{
- unsigned char __v;
- asm volatile("inb %1,%0" : "=a" (__v) : "dN" (__p));
- return v;
-}
-
-static __inline__ unsigned short
-inw(unsigned short __p)
-{
- unsigned short __v;
- asm volatile("inw %1,%0" : "=a" (__v) : "dN" (__p));
- return v;
-}
-
-static __inline__ unsigned int
-inl(unsigned short __p)
-{
- unsigned int __v;
- asm volatile("inl %1,%0" : "=a" (__v) : "dN" (__p));
- return v;
-}
-
-/* String I/O macros */
-
-static __inline__ void
-outsb (unsigned short __p, const void *__d, unsigned long __n)
-{
- asm volatile("cld; rep; outsb" : "+S" (__d), "+c" (__n) : "d" (__p));
-}
-
-static __inline__ void
-outsw (unsigned short __p, const void *__d, unsigned long __n)
-{
- asm volatile("cld; rep; outsw" : "+S" (__d), "+c" (__n) : "d" (__p));
-}
-
-static __inline__ void
-outsl (unsigned short __p, const void *__d, unsigned long __n)
-{
- asm volatile("cld; rep; outsl" : "+S" (__d), "+c" (__n) : "d" (__p));
-}
-
-
-static __inline__ void
-insb (unsigned short __p, void *__d, unsigned long __n)
-{
- asm volatile("cld; rep; insb" : "+D" (__d), "+c" (__n) : "d" (__p));
-}
-
-static __inline__ void
-insw (unsigned short __p, void *__d, unsigned long __n)
-{
- asm volatile("cld; rep; insw" : "+D" (__d), "+c" (__n) : "d" (__p));
-}
-
-static __inline__ void
-insl (unsigned short __p, void *__d, unsigned long __n)
-{
- asm volatile("cld; rep; insl" : "+D" (__d), "+c" (__n) : "d" (__p));
-}
-
-#endif /* _SYS_IO_H */
diff --git a/klibc/include/arpa/inet.h b/klibc/include/arpa/inet.h
deleted file mode 100644
index 043b148e17..0000000000
--- a/klibc/include/arpa/inet.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * arpa/inet.h
- */
-
-#ifndef _ARPA_INET_H
-#define _ARPA_INET_H
-
-#include <klibc/extern.h>
-#include <stdint.h>
-#include <sys/types.h>
-#include <netinet/in.h>
-#include <netinet/in6.h>
-
-__extern uint32_t inet_addr(const char *);
-__extern int inet_aton(const char *, struct in_addr *);
-__extern char *inet_ntoa(struct in_addr);
-__extern int inet_pton(int, const char *, void *);
-__extern const char *inet_ntop(int, const void *, char *, size_t);
-__extern unsigned int inet_nsap_addr(const char *, unsigned char *, int);
-__extern char *inet_nsap_ntoa(int, const unsigned char *, char *);
-
-#endif /* _ARPA_INET_H */
-
-
diff --git a/klibc/include/assert.h b/klibc/include/assert.h
deleted file mode 100644
index 58cc37c487..0000000000
--- a/klibc/include/assert.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * assert.h
- */
-
-#ifndef _ASSERT_H
-#define _ASSERT_H
-
-#ifdef NDEBUG
-
-#define assert(x) ((void)(x))
-
-#else
-
-extern void __assert_fail(const char *, const char *,
- unsigned int);
-
-#define assert(x) ((x) ? (void)0 : __assert_fail(#x, __FILE__, __LINE__))
-
-#endif
-
-#endif /* _ASSERT_H */
-
diff --git a/klibc/include/bits32/bitsize.h b/klibc/include/bits32/bitsize.h
deleted file mode 100644
index 06cc885983..0000000000
--- a/klibc/include/bits32/bitsize.h
+++ /dev/null
@@ -1,3 +0,0 @@
-#ifndef _BITSIZE
-#define _BITSIZE 32
-#endif
diff --git a/klibc/include/bits32/bitsize/limits.h b/klibc/include/bits32/bitsize/limits.h
deleted file mode 100644
index f90e524b2b..0000000000
--- a/klibc/include/bits32/bitsize/limits.h
+++ /dev/null
@@ -1,14 +0,0 @@
-/*
- * bits32/limits.h
- */
-
-#ifndef _BITSIZE_LIMITS_H
-#define _BITSIZE_LIMITS_H
-
-#define LONG_BIT 32
-
-#define LONG_MIN (-2147483647L-1)
-#define LONG_MAX 2147483647L
-#define ULONG_MAX 4294967295UL
-
-#endif /* _BITSIZE_LIMITS_H */
diff --git a/klibc/include/bits32/bitsize/stddef.h b/klibc/include/bits32/bitsize/stddef.h
deleted file mode 100644
index c486041fe0..0000000000
--- a/klibc/include/bits32/bitsize/stddef.h
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * bits32/stddef.h
- */
-
-#ifndef _BITSIZE_STDDEF_H
-#define _BITSIZE_STDDEF_H
-
-#define _SIZE_T
-#if defined(__s390__) || defined(__hppa__) || defined(__cris__)
-typedef unsigned long size_t;
-#else
-typedef unsigned int size_t;
-#endif
-
-#define _PTRDIFF_T
-typedef signed int ptrdiff_t;
-
-#endif /* _BITSIZE_STDDEF_H */
diff --git a/klibc/include/bits32/bitsize/stdint.h b/klibc/include/bits32/bitsize/stdint.h
deleted file mode 100644
index 40b464961c..0000000000
--- a/klibc/include/bits32/bitsize/stdint.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * bits32/stdint.h
- */
-
-#ifndef _BITSIZE_STDINT_H
-#define _BITSIZE_STDINT_H
-
-typedef signed char int8_t;
-typedef short int int16_t;
-typedef int int32_t;
-typedef long long int int64_t;
-
-typedef unsigned char uint8_t;
-typedef unsigned short int uint16_t;
-typedef unsigned int uint32_t;
-typedef unsigned long long int uint64_t;
-
-typedef int int_fast16_t;
-typedef int int_fast32_t;
-
-typedef unsigned int uint_fast16_t;
-typedef unsigned int uint_fast32_t;
-
-typedef int intptr_t;
-typedef unsigned int uintptr_t;
-
-#define __INT64_C(c) c ## LL
-#define __UINT64_C(c) c ## ULL
-
-#define __PRI64_RANK "ll"
-#define __PRIFAST_RANK ""
-#define __PRIPTR_RANK ""
-
-#endif /* _BITSIZE_STDINT_H */
diff --git a/klibc/include/bits32/bitsize/stdintconst.h b/klibc/include/bits32/bitsize/stdintconst.h
deleted file mode 100644
index 8157dd06e0..0000000000
--- a/klibc/include/bits32/bitsize/stdintconst.h
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * bits32/stdintconst.h
- */
-
-#ifndef _BITSIZE_STDINTCONST_H
-#define _BITSIZE_STDINTCONST_H
-
-#define INT_FAST16_C(c) INT32_C(c)
-#define INT_FAST32_C(c) INT32_C(c)
-
-#define UINT_FAST16_C(c) UINT32_C(c)
-#define UINT_FAST32_C(c) UINT32_C(c)
-
-#define INTPTR_C(c) INT32_C(c)
-#define UINTPTR_C(c) UINT32_C(c)
-#define PTRDIFF_C(c) INT32_C(c)
-
-#endif /* _BITSIZE_STDINTCONST_H */
diff --git a/klibc/include/bits32/bitsize/stdintlimits.h b/klibc/include/bits32/bitsize/stdintlimits.h
deleted file mode 100644
index b44fe01186..0000000000
--- a/klibc/include/bits32/bitsize/stdintlimits.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * bits32/stdintlimits.h
- */
-
-#ifndef _BITSIZE_STDINTLIMITS_H
-#define _BITSIZE_STDINTLIMITS_H
-
-#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
-
-#endif /* _BITSIZE_STDINTLIMITS_H */
diff --git a/klibc/include/bits64/bitsize.h b/klibc/include/bits64/bitsize.h
deleted file mode 100644
index 54696fd70e..0000000000
--- a/klibc/include/bits64/bitsize.h
+++ /dev/null
@@ -1,3 +0,0 @@
-#ifndef _BITSIZE
-#define _BITSIZE 64
-#endif
diff --git a/klibc/include/bits64/bitsize/limits.h b/klibc/include/bits64/bitsize/limits.h
deleted file mode 100644
index 7b20da085b..0000000000
--- a/klibc/include/bits64/bitsize/limits.h
+++ /dev/null
@@ -1,14 +0,0 @@
-/*
- * bits64/limits.h
- */
-
-#ifndef _BITSIZE_LIMITS_H
-#define _BITSIZE_LIMITS_H
-
-#define LONG_BIT 64
-
-#define LONG_MIN (-9223372036854775807L-1)
-#define LONG_MAX 9223372036854775807L
-#define ULONG_MAX 18446744073709551615UL
-
-#endif /* _BITSIZE_LIMITS_H */
diff --git a/klibc/include/bits64/bitsize/stddef.h b/klibc/include/bits64/bitsize/stddef.h
deleted file mode 100644
index 3e72621862..0000000000
--- a/klibc/include/bits64/bitsize/stddef.h
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * bits64/stddef.h
- */
-
-#ifndef _BITSIZE_STDDEF_H
-#define _BITSIZE_STDDEF_H
-
-#define _SIZE_T
-typedef unsigned long size_t;
-#define _PTRDIFF_T
-typedef signed long ptrdiff_t;
-
-#endif /* _BITSIZE_STDDEF_H */
diff --git a/klibc/include/bits64/bitsize/stdint.h b/klibc/include/bits64/bitsize/stdint.h
deleted file mode 100644
index 8e16cf0909..0000000000
--- a/klibc/include/bits64/bitsize/stdint.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * bits64/stdint.h
- */
-
-#ifndef _BITSIZE_STDINT_H
-#define _BITSIZE_STDINT_H
-
-typedef signed char int8_t;
-typedef short int int16_t;
-typedef int int32_t;
-typedef long int int64_t;
-
-typedef unsigned char uint8_t;
-typedef unsigned short int uint16_t;
-typedef unsigned int uint32_t;
-typedef unsigned long int uint64_t;
-
-typedef long int int_fast16_t;
-typedef long int int_fast32_t;
-
-typedef unsigned long int uint_fast16_t;
-typedef unsigned long int uint_fast32_t;
-
-typedef long int intptr_t;
-typedef unsigned long int uintptr_t;
-
-#define __INT64_C(c) c ## L
-#define __UINT64_C(c) c ## UL
-
-#define __PRI64_RANK "l"
-#define __PRIFAST_RANK "l"
-#define __PRIPTR_RANK "l"
-
-#endif /* _BITSIZE_STDINT_H */
-
-
diff --git a/klibc/include/bits64/bitsize/stdintconst.h b/klibc/include/bits64/bitsize/stdintconst.h
deleted file mode 100644
index 65f2db0501..0000000000
--- a/klibc/include/bits64/bitsize/stdintconst.h
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * bits64/stdintconst.h
- */
-
-#ifndef _BITSIZE_STDINTCONST_H
-#define _BITSIZE_STDINTCONST_H
-
-#define INT_FAST16_C(c) INT64_C(c)
-#define INT_FAST32_C(c) INT64_C(c)
-
-#define UINT_FAST16_C(c) UINT64_C(c)
-#define UINT_FAST32_C(c) UINT64_C(c)
-
-#define INTPTR_C(c) INT64_C(c)
-#define UINTPTR_C(c) UINT64_C(c)
-#define PTRDIFF_C(c) INT64_C(c)
-
-#endif /* _BITSIZE_STDINTCONST_H */
diff --git a/klibc/include/bits64/bitsize/stdintlimits.h b/klibc/include/bits64/bitsize/stdintlimits.h
deleted file mode 100644
index d110d17d2d..0000000000
--- a/klibc/include/bits64/bitsize/stdintlimits.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * bits64/stdintlimits.h
- */
-
-#ifndef _BITSIZE_STDINTLIMITS_H
-#define _BITSIZE_STDINTLIMITS_H
-
-#define INT_FAST16_MIN INT64_MIN
-#define INT_FAST32_MIN INT64_MIN
-#define INT_FAST16_MAX INT64_MAX
-#define INT_FAST32_MAX INT64_MAX
-#define UINT_FAST16_MAX UINT64_MAX
-#define UINT_FAST32_MAX UINT64_MAX
-
-#define INTPTR_MIN INT64_MIN
-#define INTPTR_MAX INT64_MAX
-#define UINTPTR_MAX UINT64_MAX
-
-#define PTRDIFF_MIN INT64_MIN
-#define PTRDIFF_MAX INT64_MAX
-
-#endif /* _BITSIZE_STDINTLIMITS_H */
diff --git a/klibc/include/ctype.h b/klibc/include/ctype.h
deleted file mode 100644
index daa6a8eff4..0000000000
--- a/klibc/include/ctype.h
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * ctype.h
- *
- * This assumes ISO 8859-1, being a reasonable superset of ASCII.
- */
-
-#ifndef _CTYPE_H
-#define _CTYPE_H
-
-#ifndef __CTYPE_NO_INLINE
-# define __ctype_inline extern __inline__
-#else
-# define __ctype_inline
-#endif
-
-/*
- * This relies on the following definitions:
- *
- * cntrl = !print
- * alpha = upper|lower
- * graph = punct|alpha|digit
- * blank = '\t' || ' ' (per POSIX requirement)
- */
-enum {
- __ctype_upper = (1 << 0),
- __ctype_lower = (1 << 1),
- __ctype_digit = (1 << 2),
- __ctype_xdigit = (1 << 3),
- __ctype_space = (1 << 4),
- __ctype_print = (1 << 5),
- __ctype_punct = (1 << 6),
- __ctype_cntrl = (1 << 7),
-};
-
-extern const unsigned char __ctypes[];
-
-__ctype_inline int isalnum(int __c)
-{
- return __ctypes[__c+1] &
- (__ctype_upper|__ctype_lower|__ctype_digit);
-}
-
-__ctype_inline int isalpha(int __c)
-{
- return __ctypes[__c+1] &
- (__ctype_upper|__ctype_lower);
-}
-
-__ctype_inline int isascii(int __c)
-{
- return !(__c & ~0x7f);
-}
-
-__ctype_inline int isblank(int __c)
-{
- return (__c == '\t') || (__c == ' ');
-}
-
-__ctype_inline int iscntrl(int __c)
-{
- return __ctypes[__c+1] & __ctype_cntrl;
-}
-
-__ctype_inline int isdigit(int __c)
-{
- return ((unsigned)__c - '0') <= 9;
-}
-
-__ctype_inline int isgraph(int __c)
-{
- return __ctypes[__c+1] &
- (__ctype_upper|__ctype_lower|__ctype_digit|__ctype_punct);
-}
-
-__ctype_inline int islower(int __c)
-{
- return __ctypes[__c+1] & __ctype_lower;
-}
-
-__ctype_inline int isprint(int __c)
-{
- return __ctypes[__c+1] & __ctype_print;
-}
-
-__ctype_inline int ispunct(int __c)
-{
- return __ctypes[__c+1] & __ctype_punct;
-}
-
-__ctype_inline int isspace(int __c)
-{
- return __ctypes[__c+1] & __ctype_space;
-}
-
-__ctype_inline int isupper(int __c)
-{
- return __ctypes[__c+1] & __ctype_upper;
-}
-
-__ctype_inline int isxdigit(int __c)
-{
- return __ctypes[__c+1] & __ctype_xdigit;
-}
-
-/* Note: this is decimal, not hex, to avoid accidental promotion to unsigned */
-#define _toupper(__c) ((__c) & ~32)
-#define _tolower(__c) ((__c) | 32)
-
-__ctype_inline int toupper(int __c)
-{
- return islower(__c) ? _toupper(__c) : __c;
-}
-
-__ctype_inline int tolower(int __c)
-{
- return isupper(__c) ? _tolower(__c) : __c;
-}
-
-#endif /* _CTYPE_H */
diff --git a/klibc/include/dirent.h b/klibc/include/dirent.h
deleted file mode 100644
index 4db479592b..0000000000
--- a/klibc/include/dirent.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * dirent.h
- */
-
-#ifndef _DIRENT_H
-#define _DIRENT_H
-
-#include <klibc/extern.h>
-#include <sys/dirent.h>
-
-struct _IO_dir {
- int __fd;
-
-#ifdef __KLIBC_DIRENT_INTERNALS
- /* These fields for internal use only */
-
- size_t bytes_left;
- struct dirent *next;
- /* Declaring this as an array of struct enforces correct alignment */
- struct dirent buffer[15]; /* 15 times max dirent size =~ 4K */
-#endif
-};
-typedef struct _IO_dir DIR;
-
-__extern DIR *opendir(const char *);
-__extern struct dirent *readdir(DIR *);
-__extern int closedir(DIR *);
-static __inline__ int dirfd (DIR *__d) {
- return __d->__fd;
-}
-
-#endif /* _DIRENT_H */
diff --git a/klibc/include/elf.h b/klibc/include/elf.h
deleted file mode 100644
index 52f47d042e..0000000000
--- a/klibc/include/elf.h
+++ /dev/null
@@ -1,12 +0,0 @@
-/*
- * elf.h
- */
-
-#ifndef _ELF_H
-#define _ELF_H
-
-#include <sys/elf32.h>
-#include <sys/elf64.h>
-
-#endif /* _ELF_H */
-
diff --git a/klibc/include/endian.h b/klibc/include/endian.h
deleted file mode 100644
index 44f89ccbbc..0000000000
--- a/klibc/include/endian.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * endian.h
- */
-
-#ifndef _ENDIAN_H
-#define _ENDIAN_H
-
-#include <klibc/compiler.h>
-#include <asm/byteorder.h>
-
-/* Linux' asm/byteorder.h defines either __LITTLE_ENDIAN or
- __BIG_ENDIAN, but the glibc/BSD-ish macros expect both to be
- defined with __BYTE_ORDER defining which is actually used... */
-
-#if defined(__LITTLE_ENDIAN)
-# undef __LITTLE_ENDIAN
-# define __LITTLE_ENDIAN 1234
-# define __BIG_ENDIAN 4321
-# define __PDP_ENDIAN 3412
-# define __BYTE_ORDER __LITTLE_ENDIAN
-#elif defined(__BIG_ENDIAN)
-# undef __BIG_ENDIAN
-# define __LITTLE_ENDIAN 1234
-# define __BIG_ENDIAN 4321
-# define __PDP_ENDIAN 3412
-# define __BYTE_ORDER __BIG_ENDIAN
-#elif defined(__PDP_ENDIAN)
-# undef __PDP_ENDIAN
-# define __LITTLE_ENDIAN 1234
-# define __BIG_ENDIAN 4321
-# define __PDP_ENDIAN 3412
-# define __BYTE_ORDER __PDP_ENDIAN
-#else
-# error "Unknown byte order!"
-#endif
-
-#define LITTLE_ENDIAN __LITTLE_ENDIAN
-#define BIG_ENDIAN __BIG_ENDIAN
-#define PDP_ENDIAN __PDP_ENDIAN
-#define BYTE_ORDER __BYTE_ORDER
-
-#endif /* _ENDIAN_H */
diff --git a/klibc/include/errno.h b/klibc/include/errno.h
deleted file mode 100644
index b2e666504d..0000000000
--- a/klibc/include/errno.h
+++ /dev/null
@@ -1,8 +0,0 @@
-/*
- * errno.h
- */
-
-#include <klibc/extern.h>
-#include <asm/errno.h>
-
-__extern int errno;
diff --git a/klibc/include/fcntl.h b/klibc/include/fcntl.h
deleted file mode 100644
index c9650f76b5..0000000000
--- a/klibc/include/fcntl.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * fcntl.h
- */
-
-#ifndef _FCNTL_H
-#define _FCNTL_H
-
-#include <klibc/extern.h>
-#include <klibc/compiler.h>
-#include <sys/types.h>
-#if defined(__mips__) && !defined(__mips64__)
-# include <klibc/archfcntl.h>
-#endif
-#include <linux/fcntl.h>
-
-/* This is ugly, but "struct flock" has actually been defined with
- a long off_t, so it's really "struct flock64". It just happens
- to work. Gag. Barf.
-
- This happens to work on all 32-bit architectures except MIPS. */
-
-#ifdef F_GETLK64
-# undef F_GETLK
-# define F_GETLK F_GETLK64
-#endif
-
-#ifdef F_SETLK64
-# undef F_SETLK
-# define F_SETLK F_SETLK64
-#endif
-
-#ifdef F_SETLKW64
-# undef F_SETLKW
-# define F_SETLKW F_SETLKW64
-#endif
-
-/* This is defined here as well as in <unistd.h> since old-style code
- would still include <fcntl.h> when using open(), and open() being
- a varadic function changes its calling convention on some architectures. */
-#ifndef _KLIBC_IN_OPEN_C
-__extern int open(const char *, int, ...);
-#endif
-
-__extern int fcntl(int, int, ...);
-
-#endif /* _FCNTL_H */
diff --git a/klibc/include/grp.h b/klibc/include/grp.h
deleted file mode 100644
index 03ceb31560..0000000000
--- a/klibc/include/grp.h
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * grp.h
- */
-
-#ifndef _GRP_H
-#define _GRP_H
-
-#include <klibc/extern.h>
-#include <sys/types.h>
-
-__extern int setgroups(size_t, const gid_t *);
-
-#endif /* _GRP_H */
diff --git a/klibc/include/inttypes.h b/klibc/include/inttypes.h
deleted file mode 100644
index e00fa63160..0000000000
--- a/klibc/include/inttypes.h
+++ /dev/null
@@ -1,226 +0,0 @@
-/*
- * inttypes.h
- */
-
-#ifndef _INTTYPES_H
-#define _INTTYPES_H
-
-#include <klibc/extern.h>
-#include <stdint.h>
-#include <stddef.h>
-
-static __inline__ intmax_t imaxabs(intmax_t __n)
-{
- return (__n < (intmax_t)0) ? -__n : __n;
-}
-
-__extern intmax_t strtoimax(const char *, char **, int);
-__extern uintmax_t strtoumax(const char *, char **, int);
-
-/* extensions */
-__extern intmax_t strntoimax(const char *, char **, int, size_t);
-__extern uintmax_t strntoumax(const char *, char **, int, size_t);
-
-#if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS)
-
-#define PRId8 "d"
-#define PRId16 "d"
-#define PRId32 "d"
-#define PRId64 __PRI64_RANK "d"
-
-#define PRIdLEAST8 "d"
-#define PRIdLEAST16 "d"
-#define PRIdLEAST32 "d"
-#define PRIdLEAST64 __PRI64_RANK "d"
-
-#define PRIdFAST8 "d"
-#define PRIdFAST16 __PRIFAST_RANK "d"
-#define PRIdFAST32 __PRIFAST_RANK "d"
-#define PRIdFAST64 __PRI64_RANK "d"
-
-#define PRIdMAX __PRI64_RANK "d"
-#define PRIdPTR __PRIPTR_RANK "d"
-
-#define PRIi8 "i"
-#define PRIi16 "i"
-#define PRIi32 "i"
-#define PRIi64 __PRI64_RANK "i"
-
-#define PRIiLEAST8 "i"
-#define PRIiLEAST16 "i"
-#define PRIiLEAST32 "i"
-#define PRIiLEAST64 __PRI64_RANK "i"
-
-#define PRIiFAST8 "i"
-#define PRIiFAST16 __PRIFAST_RANK "i"
-#define PRIiFAST32 __PRIFAST_RANK "i"
-#define PRIiFAST64 __PRI64_RANK "i"
-
-#define PRIiMAX __PRI64_RANK "i"
-#define PRIiPTR __PRIPTR_RANK "i"
-
-#define PRIo8 "o"
-#define PRIo16 "o"
-#define PRIo32 "o"
-#define PRIo64 __PRI64_RANK "o"
-
-#define PRIoLEAST8 "o"
-#define PRIoLEAST16 "o"
-#define PRIoLEAST32 "o"
-#define PRIoLEAST64 __PRI64_RANK "o"
-
-#define PRIoFAST8 "o"
-#define PRIoFAST16 __PRIFAST_RANK "o"
-#define PRIoFAST32 __PRIFAST_RANK "o"
-#define PRIoFAST64 __PRI64_RANK "o"
-
-#define PRIoMAX __PRI64_RANK "o"
-#define PRIoPTR __PRIPTR_RANK "o"
-
-#define PRIu8 "u"
-#define PRIu16 "u"
-#define PRIu32 "u"
-#define PRIu64 __PRI64_RANK "u"
-
-#define PRIuLEAST8 "u"
-#define PRIuLEAST16 "u"
-#define PRIuLEAST32 "u"
-#define PRIuLEAST64 __PRI64_RANK "u"
-
-#define PRIuFAST8 "u"
-#define PRIuFAST16 __PRIFAST_RANK "u"
-#define PRIuFAST32 __PRIFAST_RANK "u"
-#define PRIuFAST64 __PRI64_RANK "u"
-
-#define PRIuMAX __PRI64_RANK "u"
-#define PRIuPTR __PRIPTR_RANK "u"
-
-#define PRIx8 "x"
-#define PRIx16 "x"
-#define PRIx32 "x"
-#define PRIx64 __PRI64_RANK "x"
-
-#define PRIxLEAST8 "x"
-#define PRIxLEAST16 "x"
-#define PRIxLEAST32 "x"
-#define PRIxLEAST64 __PRI64_RANK "x"
-
-#define PRIxFAST8 "x"
-#define PRIxFAST16 __PRIFAST_RANK "x"
-#define PRIxFAST32 __PRIFAST_RANK "x"
-#define PRIxFAST64 __PRI64_RANK "x"
-
-#define PRIxMAX __PRI64_RANK "x"
-#define PRIxPTR __PRIPTR_RANK "x"
-
-#define PRIX8 "X"
-#define PRIX16 "X"
-#define PRIX32 "X"
-#define PRIX64 __PRI64_RANK "X"
-
-#define PRIXLEAST8 "X"
-#define PRIXLEAST16 "X"
-#define PRIXLEAST32 "X"
-#define PRIXLEAST64 __PRI64_RANK "X"
-
-#define PRIXFAST8 "X"
-#define PRIXFAST16 __PRIFAST_RANK "X"
-#define PRIXFAST32 __PRIFAST_RANK "X"
-#define PRIXFAST64 __PRI64_RANK "X"
-
-#define PRIXMAX __PRI64_RANK "X"
-#define PRIXPTR __PRIPTR_RANK "X"
-
-#define SCNd8 "hhd"
-#define SCNd16 "hd"
-#define SCNd32 "d"
-#define SCNd64 __PRI64_RANK "d"
-
-#define SCNdLEAST8 "hhd"
-#define SCNdLEAST16 "hd"
-#define SCNdLEAST32 "d"
-#define SCNdLEAST64 __PRI64_RANK "d"
-
-#define SCNdFAST8 "hhd"
-#define SCNdFAST16 __PRIFAST_RANK "d"
-#define SCNdFAST32 __PRIFAST_RANK "d"
-#define SCNdFAST64 __PRI64_RANK "d"
-
-#define SCNdMAX __PRI64_RANK "d"
-#define SCNdPTR __PRIPTR_RANK "d"
-
-#define SCNi8 "hhi"
-#define SCNi16 "hi"
-#define SCNi32 "i"
-#define SCNi64 __PRI64_RANK "i"
-
-#define SCNiLEAST8 "hhi"
-#define SCNiLEAST16 "hi"
-#define SCNiLEAST32 "i"
-#define SCNiLEAST64 __PRI64_RANK "i"
-
-#define SCNiFAST8 "hhi"
-#define SCNiFAST16 __PRIFAST_RANK "i"
-#define SCNiFAST32 __PRIFAST_RANK "i"
-#define SCNiFAST64 __PRI64_RANK "i"
-
-#define SCNiMAX __PRI64_RANK "i"
-#define SCNiPTR __PRIPTR_RANK "i"
-
-#define SCNo8 "hho"
-#define SCNo16 "ho"
-#define SCNo32 "o"
-#define SCNo64 __PRI64_RANK "o"
-
-#define SCNoLEAST8 "hho"
-#define SCNoLEAST16 "ho"
-#define SCNoLEAST32 "o"
-#define SCNoLEAST64 __PRI64_RANK "o"
-
-#define SCNoFAST8 "hho"
-#define SCNoFAST16 __PRIFAST_RANK "o"
-#define SCNoFAST32 __PRIFAST_RANK "o"
-#define SCNoFAST64 __PRI64_RANK "o"
-
-#define SCNoMAX __PRI64_RANK "o"
-#define SCNoPTR __PRIPTR_RANK "o"
-
-#define SCNu8 "hhu"
-#define SCNu16 "hu"
-#define SCNu32 "u"
-#define SCNu64 __PRI64_RANK "u"
-
-#define SCNuLEAST8 "hhu"
-#define SCNuLEAST16 "hu"
-#define SCNuLEAST32 "u"
-#define SCNuLEAST64 __PRI64_RANK "u"
-
-#define SCNuFAST8 "hhu"
-#define SCNuFAST16 __PRIFAST_RANK "u"
-#define SCNuFAST32 __PRIFAST_RANK "u"
-#define SCNuFAST64 __PRI64_RANK "u"
-
-#define SCNuMAX __PRI64_RANK "u"
-#define SCNuPTR __PRIPTR_RANK "u"
-
-#define SCNx8 "hhx"
-#define SCNx16 "hx"
-#define SCNx32 "x"
-#define SCNx64 __PRI64_RANK "x"
-
-#define SCNxLEAST8 "hhx"
-#define SCNxLEAST16 "hx"
-#define SCNxLEAST32 "x"
-#define SCNxLEAST64 __PRI64_RANK "x"
-
-#define SCNxFAST8 "hhx"
-#define SCNxFAST16 __PRIFAST_RANK "x"
-#define SCNxFAST32 __PRIFAST_RANK "x"
-#define SCNxFAST64 __PRI64_RANK "x"
-
-#define SCNxMAX __PRI64_RANK "x"
-#define SCNxPTR __PRIPTR_RANK "x"
-
-#endif
-
-#endif /* _INTTYPES_H */
diff --git a/klibc/include/klibc/compiler.h b/klibc/include/klibc/compiler.h
deleted file mode 100644
index 7ff6ff7d51..0000000000
--- a/klibc/include/klibc/compiler.h
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * klibc/compiler.h
- *
- * Various compiler features
- */
-
-#ifndef _KLIBC_COMPILER_H
-#define _KLIBC_COMPILER_H
-
-/* Specific calling conventions */
-/* __cdecl is used when we want varadic and non-varadic functions to have
- the same binary calling convention. */
-#ifdef __i386__
-# ifdef __GNUC__
-# define __cdecl __attribute__((cdecl,regparm(0)))
-# else
- /* Most other C compilers have __cdecl as a keyword */
-# endif
-#else
-# define __cdecl /* Meaningless on non-i386 */
-#endif
-
-/* How to declare a function that *must* be inlined */
-#ifdef __GNUC__
-# if __GNUC__ >= 3
-# define __must_inline static __inline__ __attribute__((always_inline))
-# else
-# define __must_inline extern __inline__
-# endif
-#else
-# define __must_inline inline /* Just hope this works... */
-#endif
-
-/* How to declare a function that does not return */
-#ifdef __GNUC__
-# define __noreturn void __attribute__((noreturn))
-#else
-# define __noreturn void
-#endif
-
-/* "const" function:
-
- Many functions do not examine any values except their arguments,
- and have no effects except the return value. Basically this is
- just slightly more strict class than the `pure' attribute above,
- since function is not allowed to read global memory.
-
- Note that a function that has pointer arguments and examines the
- data pointed to must _not_ be declared `const'. Likewise, a
- function that calls a non-`const' function usually must not be
- `const'. It does not make sense for a `const' function to return
- `void'.
-*/
-#ifdef __GNUC__
-# define __constfunc __attribute__((const))
-#else
-# define __constfunc
-#endif
-#undef __attribute_const__
-#define __attribute_const__ __constfunc
-
-/* "pure" function:
-
- Many functions have no effects except the return value and their
- return value depends only on the parameters and/or global
- variables. Such a function can be subject to common subexpression
- elimination and loop optimization just as an arithmetic operator
- would be. These functions should be declared with the attribute
- `pure'.
-*/
-#ifdef __GNUC__
-# define __purefunc __attribute__((pure))
-#else
-# define __purefunc
-#endif
-#undef __attribute_pure__
-#define __attribute_pure__ __purefunc
-
-/* Format attribute */
-#ifdef __GNUC__
-# define __formatfunc(t,f,a) __attribute__((format(t,f,a)))
-#else
-# define __formatfunc(t,f,a)
-#endif
-
-/* malloc() function (returns unaliased pointer) */
-#if defined(__GNUC__) && (__GNUC__ >= 3)
-# define __mallocfunc __attribute__((malloc))
-#else
-# define __mallocfunc
-#endif
-
-/* likely/unlikely */
-#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95))
-# define __likely(x) __builtin_expect((x), 1)
-# define __unlikely(x) __builtin_expect((x), 0)
-#else
-# define __likely(x) (x)
-# define __unlikely(x) (x)
-#endif
-
-/* Possibly unused function */
-#ifdef __GNUC__
-# define __unusedfunc __attribute__((unused))
-#else
-# define __unusedfunc
-#endif
-
-/* It's all user space... */
-#define __user
-
-/* The bitwise attribute: disallow arithmetric operations */
-#ifdef __CHECKER__ /* sparse only */
-# define __bitwise __attribute__((bitwise))
-#else
-# define __bitwise
-#endif
-
-/* Compiler pragma to make an alias symbol */
-#define __ALIAS(__t, __f, __p, __a) \
- __t __f __p __attribute__((weak, alias(#__a)));
-
-#endif
diff --git a/klibc/include/klibc/diverr.h b/klibc/include/klibc/diverr.h
deleted file mode 100644
index 4d8c8d36c2..0000000000
--- a/klibc/include/klibc/diverr.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * klibc/diverr.h
- */
-
-#ifndef _KLIBC_DIVERR_H
-#define _KLIBC_DIVERR_H
-
-#include <signal.h>
-
-static __inline__ void
-__divide_error(void)
-{
- raise(SIGFPE);
-}
-
-#endif /* _KLIBC_DIVERR_H */
diff --git a/klibc/include/klibc/extern.h b/klibc/include/klibc/extern.h
deleted file mode 100644
index 8a73d19358..0000000000
--- a/klibc/include/klibc/extern.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * klibc/extern.h
- */
-
-#ifndef _KLIBC_EXTERN_H
-#define _KLIBC_EXTERN_H
-
-#ifdef __cplusplus
-#define __extern extern "C"
-#else
-#define __extern extern
-#endif
-
-#define __alias(x) __attribute__((weak, alias(x)))
-
-#endif /* _KLIBC_EXTERN_H */
diff --git a/klibc/include/klibc/sysconfig.h b/klibc/include/klibc/sysconfig.h
deleted file mode 100644
index ce01c23593..0000000000
--- a/klibc/include/klibc/sysconfig.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * klibc/sysconfig.h
- *
- * Allows for definitions of some things which may be system-dependent
- */
-
-#ifndef _KLIBC_SYSCONFIG_H
-#define _KLIBC_SYSCONFIG_H
-
-/*
- * Define this to obtain memory using sbrk() instead
- * of mmap(). This should make it friendlier on
- * non-MMU architectures. This should become a
- * per-architecture configurable.
- */
-#undef MALLOC_USING_SBRK
-
-/*
- * This is the minimum chunk size we will ask the kernel for using
- * malloc(); this should be a multiple of the page size on all
- * architectures.
- */
-#define MALLOC_CHUNK_SIZE 65536
-#define MALLOC_CHUNK_MASK (MALLOC_CHUNK_SIZE-1)
-
-/*
- * This is the minimum alignment for the memory returned by sbrk().
- * It must be a power of 2. If MALLOC_USING_SBRK is defined it should
- * be no smaller than the size of struct arena_header in malloc.h (4
- * pointers.)
- */
-#define SBRK_ALIGNMENT 32
-
-#endif /* _KLIBC_SYSCONFIG_H */
diff --git a/klibc/include/limits.h b/klibc/include/limits.h
deleted file mode 100644
index f1532e5323..0000000000
--- a/klibc/include/limits.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * limits.h
- */
-
-#ifndef _LIMITS_H
-#define _LIMITS_H
-
-#define CHAR_BIT 8
-#define SHRT_BIT 16
-#define INT_BIT 32
-#define LONGLONG_BIT 64
-
-#define SCHAR_MIN (-128)
-#define SCHAR_MAX 127
-#define UCHAR_MAX 255
-
-#ifdef __CHAR_UNSIGNED__
-# define CHAR_MIN 0
-# define CHAR_MAX UCHAR_MAX
-#else
-# define CHAR_MIN SCHAR_MIN
-# define CHAR_MAX SCHAR_MAX
-#endif
-
-#define SHRT_MIN (-32768)
-#define SHRT_MAX 32767
-#define USHRT_MAX 65535
-
-#define INT_MIN (-2147483647-1)
-#define INT_MAX 2147483647
-#define UINT_MAX 4294967295U
-
-#define LONGLONG_MIN (-9223372036854775807LL-1)
-#define LONGLONG_MAX 9223372036854775807LL
-#define ULONGLONG_MAX 18446744073709551615ULL
-
-#include <bitsize/limits.h>
-#include <linux/limits.h>
-
-#endif /* _LIMITS_H */
diff --git a/klibc/include/malloc.h b/klibc/include/malloc.h
deleted file mode 100644
index 5beca8d068..0000000000
--- a/klibc/include/malloc.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * malloc.h
- *
- * Apparently people haven't caught on to use <stdlib.h>, which is the
- * standard place for this crap since the 1980's...
- */
-
-#ifndef _MALLOC_H
-#define _MALLOC_H
-
-#include <klibc/extern.h>
-#include <klibc/compiler.h>
-#include <stddef.h>
-
-__extern void free(void *);
-
-__extern __mallocfunc void *malloc(size_t);
-__extern __mallocfunc void *calloc(size_t, size_t);
-__extern __mallocfunc void *realloc(void *, size_t);
-
-#endif /* _MALLOC_H */
diff --git a/klibc/include/net/if.h b/klibc/include/net/if.h
deleted file mode 100644
index 1aa8e7b90c..0000000000
--- a/klibc/include/net/if.h
+++ /dev/null
@@ -1 +0,0 @@
-#include <linux/if.h>
diff --git a/klibc/include/net/if_arp.h b/klibc/include/net/if_arp.h
deleted file mode 100644
index a25f1b4759..0000000000
--- a/klibc/include/net/if_arp.h
+++ /dev/null
@@ -1 +0,0 @@
-#include <linux/if_arp.h>
diff --git a/klibc/include/net/if_packet.h b/klibc/include/net/if_packet.h
deleted file mode 100644
index b5e8e0e11f..0000000000
--- a/klibc/include/net/if_packet.h
+++ /dev/null
@@ -1 +0,0 @@
-#include <linux/if_packet.h>
diff --git a/klibc/include/net/route.h b/klibc/include/net/route.h
deleted file mode 100644
index a60df24c0a..0000000000
--- a/klibc/include/net/route.h
+++ /dev/null
@@ -1 +0,0 @@
-#include <linux/route.h>
diff --git a/klibc/include/netinet/if_ether.h b/klibc/include/netinet/if_ether.h
deleted file mode 100644
index 060ef22070..0000000000
--- a/klibc/include/netinet/if_ether.h
+++ /dev/null
@@ -1 +0,0 @@
-#include <linux/if_ether.h>
diff --git a/klibc/include/netinet/in.h b/klibc/include/netinet/in.h
deleted file mode 100644
index 27b778700e..0000000000
--- a/klibc/include/netinet/in.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * netinet/in.h
- */
-
-#ifndef _NETINET_IN_H
-#define _NETINET_IN_H
-
-/* added this include by Mats Petersson */
-#include <linux/socket.h>
-
-#include <klibc/extern.h>
-#include <stdint.h>
-#include <endian.h> /* Must be included *before* <linux/in.h> */
-#include <linux/in.h>
-
-#ifndef htons
-# define htons(x) __cpu_to_be16(x)
-#endif
-#ifndef ntohs
-# define ntohs(x) __be16_to_cpu(x)
-#endif
-#ifndef htonl
-# define htonl(x) __cpu_to_be32(x)
-#endif
-#ifndef ntohl
-# define ntohl(x) __be32_to_cpu(x)
-#endif
-#ifndef htonq
-# define htonq(x) __cpu_to_be64(x)
-#endif
-#ifndef ntohq
-# define ntohq(x) __be64_to_cpu(x)
-#endif
-
-#define IPPORT_RESERVED 1024
-
-__extern int bindresvport (int sd, struct sockaddr_in *sin);
-
-#endif /* _NETINET_IN_H */
diff --git a/klibc/include/netinet/in6.h b/klibc/include/netinet/in6.h
deleted file mode 100644
index 46584ca627..0000000000
--- a/klibc/include/netinet/in6.h
+++ /dev/null
@@ -1,10 +0,0 @@
-/*
- * netinet/in6.h
- */
-
-#ifndef _NETINET_IN6_H
-#define _NETINET_IN6_H
-
-#include <linux/in6.h>
-
-#endif /* _NETINET_IN6_H */
diff --git a/klibc/include/netinet/ip.h b/klibc/include/netinet/ip.h
deleted file mode 100644
index 8aecbe66a3..0000000000
--- a/klibc/include/netinet/ip.h
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * netinet/ip.h
- */
-
-#ifndef _NETINET_IP_H
-#define _NETINET_IP_H
-
-#include <endian.h>
-#include <linux/ip.h>
-
-#define IP_DF 0x4000 /* Flag: "Don't Fragment" */
-
-#endif /* _NETINET_IP_H */
diff --git a/klibc/include/netinet/tcp.h b/klibc/include/netinet/tcp.h
deleted file mode 100644
index bb5d307e98..0000000000
--- a/klibc/include/netinet/tcp.h
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
- * netinet/tcp.h
- */
-
-#ifndef _NETINET_TCP_H
-#define _NETINET_TCP_H
-
-#include <endian.h> /* Include *before* linux/tcp.h */
-#include <linux/tcp.h>
-
-#endif /* _NETINET_TCP_H */
diff --git a/klibc/include/netinet/udp.h b/klibc/include/netinet/udp.h
deleted file mode 100644
index b809b4ee6e..0000000000
--- a/klibc/include/netinet/udp.h
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * netinet/udp.h
- */
-
-#ifndef _NETINET_UDP_H
-#define _NETINET_UDP_H
-
-/*
- * We would include linux/udp.h, but it brings in too much other stuff
- */
-
-struct udphdr {
- __u16 source;
- __u16 dest;
- __u16 len;
- __u16 check;
-};
-
-#endif /* _NETINET_UDP_H */
diff --git a/klibc/include/netpacket/packet.h b/klibc/include/netpacket/packet.h
deleted file mode 100644
index b5e8e0e11f..0000000000
--- a/klibc/include/netpacket/packet.h
+++ /dev/null
@@ -1 +0,0 @@
-#include <linux/if_packet.h>
diff --git a/klibc/include/paths.h b/klibc/include/paths.h
deleted file mode 100644
index a87831e74a..0000000000
--- a/klibc/include/paths.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 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.
- *
- * @(#)paths.h 8.1 (Berkeley) 6/2/93
- */
-
-#ifndef _PATHS_H_
-#define _PATHS_H_
-
-/* Default search path. */
-#define _PATH_DEFPATH "/usr/bin:/bin"
-/* All standard utilities path. */
-#define _PATH_STDPATH \
- "/usr/bin:/bin:/usr/sbin:/sbin"
-
-#define _PATH_BSHELL "/bin/sh"
-#define _PATH_CONSOLE "/dev/console"
-#define _PATH_CSHELL "/bin/csh"
-#define _PATH_DEVDB "/var/run/dev.db"
-#define _PATH_DEVNULL "/dev/null"
-#define _PATH_DRUM "/dev/drum"
-#define _PATH_KLOG "/proc/kmsg"
-#define _PATH_KMEM "/dev/kmem"
-#define _PATH_LASTLOG "/var/log/lastlog"
-#define _PATH_MAILDIR "/var/mail"
-#define _PATH_MAN "/usr/share/man"
-#define _PATH_MEM "/dev/mem"
-#define _PATH_MNTTAB "/etc/fstab"
-#define _PATH_MOUNTED "/etc/mtab"
-#define _PATH_NOLOGIN "/etc/nologin"
-#define _PATH_PRESERVE "/var/lib"
-#define _PATH_RWHODIR "/var/spool/rwho"
-#define _PATH_SENDMAIL "/usr/sbin/sendmail"
-#define _PATH_SHADOW "/etc/shadow"
-#define _PATH_SHELLS "/etc/shells"
-#define _PATH_TTY "/dev/tty"
-#define _PATH_UNIX "/boot/vmlinux"
-#define _PATH_UTMP "/var/run/utmp"
-#define _PATH_VI "/bin/vi"
-#define _PATH_WTMP "/var/log/wtmp"
-
-/* Provide trailing slash, since mostly used for building pathnames. */
-#define _PATH_DEV "/dev/"
-#define _PATH_TMP "/tmp/"
-#define _PATH_VARDB "/var/db/"
-#define _PATH_VARRUN "/var/run/"
-#define _PATH_VARTMP "/var/tmp/"
-
-#endif /* !_PATHS_H_ */
diff --git a/klibc/include/poll.h b/klibc/include/poll.h
deleted file mode 100644
index 8710d92ebd..0000000000
--- a/klibc/include/poll.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * poll.h
- */
-
-#ifndef _POLL_H
-#define _POLL_H
-
-#include <klibc/extern.h>
-#include <linux/poll.h>
-
-/* POSIX specifies "int" for the timeout, Linux seems to use long... */
-
-typedef unsigned int nfds_t;
-__extern int poll(struct pollfd *, nfds_t, long);
-
-#endif /* _POLL_H */
diff --git a/klibc/include/sched.h b/klibc/include/sched.h
deleted file mode 100644
index 3465b5705c..0000000000
--- a/klibc/include/sched.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * sched.h
- */
-
-#ifndef _SCHED_H
-#define _SCHED_H
-
-#include <klibc/extern.h>
-
-/* linux/sched.h is unusable; put the declarations we need here... */
-
-#define SCHED_NORMAL 0
-#define SCHED_FIFO 1
-#define SCHED_RR 2
-
-struct sched_param {
- int sched_priority;
-};
-
-__extern int sched_setscheduler(pid_t, int, const struct sched_param *);
-__extern int sched_yield(void);
-
-/* Raw interfaces to clone(2); only actually usable for non-VM-cloning */
-#ifdef __ia64__
-__extern pid_t __clone2(int, void *, void *);
-static __inline__ pid_t __clone(int _f, void *_sp)
-{
- /* If this is used with _sp != 0 it will have the effect of the sp
- and rsp growing away from a single point in opposite directions. */
- return __clone2(_f, _sp, _sp);
-}
-#else
-__extern pid_t __clone(int, void *);
-#endif
-
-#endif /* _SCHED_H */
diff --git a/klibc/include/setjmp.h b/klibc/include/setjmp.h
deleted file mode 100644
index b504eb6d08..0000000000
--- a/klibc/include/setjmp.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * setjmp.h
- */
-
-#ifndef _SETJMP_H
-#define _SETJMP_H
-
-#include <klibc/extern.h>
-#include <klibc/compiler.h>
-#include <stddef.h>
-#include <signal.h>
-
-#include <klibc/archsetjmp.h>
-
-__extern int setjmp(jmp_buf);
-__extern __noreturn longjmp(jmp_buf, int);
-
-/*
- Whose bright idea was it to add unrelated functionality to just about
- the only function in the standard C library (setjmp) which cannot be
- wrapped by an ordinary function wrapper? Anyway, the damage is done,
- and therefore, this wrapper *must* be inline. However, gcc will
- complain if this is an inline function for unknown reason, and
- therefore sigsetjmp() needs to be a macro.
-*/
-
-struct __sigjmp_buf {
- jmp_buf __jmpbuf;
- sigset_t __sigs;
-};
-
-typedef struct __sigjmp_buf sigjmp_buf[1];
-
-#define sigsetjmp(__env, __save) \
-({ \
- struct __sigjmp_buf *__e = (__env); \
- sigprocmask(0, NULL, &__e->__sigs); \
- setjmp(__e->__jmpbuf); \
-})
-
-__extern __noreturn siglongjmp(sigjmp_buf, int);
-
-#endif /* _SETJMP_H */
diff --git a/klibc/include/signal.h b/klibc/include/signal.h
deleted file mode 100644
index 05930bdea1..0000000000
--- a/klibc/include/signal.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * signal.h
- */
-
-#ifndef _SIGNAL_H
-#define _SIGNAL_H
-
-#include <klibc/compiler.h>
-#include <klibc/extern.h>
-#include <string.h> /* For memset() */
-#include <limits.h> /* For LONG_BIT */
-#include <sys/types.h>
-#include <asm/signal.h>
-
-#include <klibc/archsignal.h>
-
-/* glibc seems to use sig_atomic_t as "int" pretty much on all architectures.
- Do the same, but allow the architecture to override. */
-#ifndef _KLIBC_HAS_ARCH_SIG_ATOMIC_T
-typedef int sig_atomic_t;
-#endif
-
-/* Some architectures don't define these */
-#ifndef SA_RESETHAND
-# define SA_RESETHAND SA_ONESHOT
-#endif
-#ifndef SA_NODEFER
-# define SA_NODEFER SA_NOMASK
-#endif
-/* Some architectures define NSIG and not _NSIG or vice versa */
-#ifndef NSIG
-# define NSIG _NSIG
-#endif
-#ifndef _NSIG
-# define _NSIG NSIG
-#endif
-
-/* If we don't have any real-time signals available to userspace,
- hide them all */
-#if SIGRTMAX <= SIGRTMIN
-# undef SIGRTMIN
-# undef SIGRTMAX
-#endif
-
-__extern const char * const sys_siglist[];
-
-/* This assumes sigset_t is either an unsigned long or an array of such,
- and that _NSIG_BPW in the kernel is always LONG_BIT */
-
-static __inline__ int sigemptyset(sigset_t *__set)
-{
- memset(__set, 0, sizeof *__set);
- return 0;
-}
-static __inline__ int sigfillset(sigset_t *__set)
-{
- memset(__set, ~0, sizeof *__set);
- return 0;
-}
-static __inline__ int sigaddset(sigset_t *__set, int __signum)
-{
- unsigned long *__lset = (unsigned long *)__set;
- __lset[__signum/LONG_BIT] |= 1UL << (__signum%LONG_BIT);
- return 0;
-}
-static __inline__ int sigdelset(sigset_t *__set, int __signum)
-{
- unsigned long *__lset = (unsigned long *)__set;
- __lset[__signum/LONG_BIT] &= ~(1UL << (__signum%LONG_BIT));
- return 0;
-}
-static __inline__ int sigismember(sigset_t *__set, int __signum)
-{
- unsigned long *__lset = (unsigned long *)__set;
- return (int)((__lset[__signum/LONG_BIT] >> (__signum%LONG_BIT)) & 1);
-}
-
-__extern __sighandler_t __signal(int, __sighandler_t, int);
-__extern __sighandler_t sysv_signal(int, __sighandler_t);
-__extern __sighandler_t bsd_signal(int, __sighandler_t);
-__extern int sigaction(int, const struct sigaction *, struct sigaction *);
-__extern int sigprocmask(int, const sigset_t *, sigset_t *);
-__extern int sigpending(sigset_t *);
-__extern int sigsuspend(const sigset_t *);
-__extern int raise(int);
-__extern int kill(pid_t, int);
-
-#endif /* _SIGNAL_H */
diff --git a/klibc/include/stdarg.h b/klibc/include/stdarg.h
deleted file mode 100644
index cc324b825d..0000000000
--- a/klibc/include/stdarg.h
+++ /dev/null
@@ -1,14 +0,0 @@
-/*
- * stdarg.h
- *
- * This is just a wrapper for the gcc one, but defines va_copy()
- * even if gcc doesn't.
- */
-
-/* Note: the _STDARG_H macro belongs to the gcc header... */
-#include_next <stdarg.h>
-
-/* Older gcc considers this an extension, so it's double underbar only */
-#ifndef va_copy
-#define va_copy(d,s) __va_copy(d,s)
-#endif
diff --git a/klibc/include/stddef.h b/klibc/include/stddef.h
deleted file mode 100644
index e96f28c446..0000000000
--- a/klibc/include/stddef.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * stddef.h
- */
-
-#ifndef _STDDEF_H
-#define _STDDEF_H
-
-#ifndef __KLIBC__
-# error "__KLIBC__ not defined, compiler invocation error!"
-#endif
-
-#include <bitsize/stddef.h>
-
-#undef NULL
-#ifdef __cplusplus
-# define NULL 0
-#else
-# define NULL ((void *)0)
-#endif
-
-#undef offsetof
-#define offsetof(t,m) ((size_t)&((t *)0)->m)
-
-#endif /* _STDDEF_H */
diff --git a/klibc/include/stdint.h b/klibc/include/stdint.h
deleted file mode 100644
index 47fec18594..0000000000
--- a/klibc/include/stdint.h
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * stdint.h
- */
-
-#ifndef _STDINT_H
-#define _STDINT_H
-
-#include <bitsize/stdint.h>
-
-typedef int8_t int_least8_t;
-typedef int16_t int_least16_t;
-typedef int32_t int_least32_t;
-typedef int64_t int_least64_t;
-
-typedef uint8_t uint_least8_t;
-typedef uint16_t uint_least16_t;
-typedef uint32_t uint_least32_t;
-typedef uint64_t uint_least64_t;
-
-typedef int8_t int_fast8_t;
-typedef int64_t int_fast64_t;
-
-typedef uint8_t uint_fast8_t;
-typedef uint64_t uint_fast64_t;
-
-typedef int64_t intmax_t;
-typedef uint64_t uintmax_t;
-
-#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS)
-
-#define INT8_MIN (-128)
-#define INT16_MIN (-32768)
-#define INT32_MIN (-2147483647-1)
-#define INT64_MIN (__INT64_C(-9223372036854775807)-1)
-
-#define INT8_MAX (127)
-#define INT16_MAX (32767)
-#define INT32_MAX (2147483647)
-#define INT64_MAX (__INT64_C(9223372036854775807))
-
-#define UINT8_MAX (255U)
-#define UINT16_MAX (65535U)
-#define UINT32_MAX (4294967295U)
-#define UINT64_MAX (__UINT64_C(18446744073709551615))
-
-#define INT_LEAST8_MIN INT8_MIN
-#define INT_LEAST16_MIN INT16_MIN
-#define INT_LEAST32_MIN INT32_MIN
-#define INT_LEAST64_MIN INT64_MIN
-
-#define INT_LEAST8_MAX INT8_MAX
-#define INT_LEAST16_MAX INT16_MAX
-#define INT_LEAST32_MAX INT32_MAX
-#define INT_LEAST64_MAX INT64_MAX
-
-#define UINT_LEAST8_MAX UINT8_MAX
-#define UINT_LEAST16_MAX UINT16_MAX
-#define UINT_LEAST32_MAX UINT32_MAX
-#define UINT_LEAST64_MAX UINT64_MAX
-
-#define INT_FAST8_MIN INT8_MIN
-#define INT_FAST64_MIN INT64_MIN
-
-#define INT_FAST8_MAX INT8_MAX
-#define INT_FAST64_MAX INT64_MAX
-
-#define UINT_FAST8_MAX UINT8_MAX
-#define UINT_FAST64_MAX UINT64_MAX
-
-#define INTMAX_MIN INT64_MIN
-#define INTMAX_MAX INT64_MAX
-#define UINTMAX_MAX UINT64_MAX
-
-#include <bitsize/stdintlimits.h>
-
-#endif
-
-#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS)
-
-#define INT8_C(c) c
-#define INT16_C(c) c
-#define INT32_C(c) c
-#define INT64_C(c) __INT64_C(c)
-
-#define UINT8_C(c) c ## U
-#define UINT16_C(c) c ## U
-#define UINT32_C(c) c ## U
-#define UINT64_C(c) __UINT64_C(c)
-
-#define INT_LEAST8_C(c) INT8_C(c)
-#define INT_LEAST16_C(c) INT16_C(c)
-#define INT_LEAST32_C(c) INT32_C(c)
-#define INT_LEAST64_C(c) INT64_C(c)
-
-#define UINT_LEAST8_C(c) UINT8_C(c)
-#define UINT_LEAST16_C(c) UINT16_C(c)
-#define UINT_LEAST32_C(c) UINT32_C(c)
-#define UINT_LEAST64_C(c) UINT64_C(c)
-
-#define INT_FAST8_C(c) INT8_C(c)
-#define INT_FAST64_C(c) INT64_C(c)
-
-#define UINT_FAST8_C(c) UINT8_C(c)
-#define UINT_FAST64_C(c) UINT64_C(c)
-
-#define INTMAX_C(c) INT64_C(c)
-#define UINTMAX_C(c) UINT64_C(c)
-
-#include <bitsize/stdintconst.h>
-
-#endif
-
-/* Keep the kernel from trying to define these types... */
-#define __BIT_TYPES_DEFINED__
-
-#endif /* _STDINT_H */
diff --git a/klibc/include/stdio.h b/klibc/include/stdio.h
deleted file mode 100644
index d30622cfb2..0000000000
--- a/klibc/include/stdio.h
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * stdio.h
- */
-
-#ifndef _STDIO_H
-#define _STDIO_H
-
-#include <klibc/extern.h>
-#include <stdarg.h>
-#include <stddef.h>
-#include <unistd.h>
-
-/* This structure doesn't really exist, but it gives us something
- to define FILE * with */
-struct _IO_file;
-typedef struct _IO_file FILE;
-
-#ifndef EOF
-# define EOF (-1)
-#endif
-
-#ifndef BUFSIZ
-# define BUFSIZ 4096
-#endif
-
-#define SEEK_SET 0
-#define SEEK_CUR 1
-#define SEEK_END 2
-
-/*
- * Convert between a FILE * and a file descriptor. We don't actually
- * have any in-memory data, so we just abuse the pointer itself to
- * hold the data. Note, however, that for file descriptors, -1 is
- * error and 0 is a valid value; for FILE *, NULL (0) is error and
- * non-NULL are valid.
- */
-static __inline__ int fileno(FILE *__f)
-{
- /* This should really be intptr_t, but size_t should be the same size */
- return (int)(size_t)__f - 1;
-}
-
-/* This is a macro so it can be used as initializer */
-#define __create_file(__fd) ((FILE *)(size_t)((__fd) + 1))
-
-#define stdin __create_file(0)
-#define stdout __create_file(1)
-#define stderr __create_file(2)
-
-__extern FILE *fopen(const char *, const char *);
-
-static __inline__ FILE *fdopen(int __fd, const char *__m)
-{
- (void)__m; return __create_file(__fd);
-}
-static __inline__ int fclose(FILE *__f)
-{
- extern int close(int);
- return close(fileno(__f));
-}
-static __inline__ int fseek(FILE *__f, off_t __o, int __w)
-{
- extern off_t lseek(int, off_t, int);
- return (lseek(fileno(__f), __o, __w) == (off_t)-1) ? -1 : 0;
-}
-static __inline__ off_t ftell(FILE *__f)
-{
- extern off_t lseek(int, off_t, int);
- return lseek(fileno(__f), 0, SEEK_CUR);
-}
-
-__extern int fputs(const char *, FILE *);
-__extern int puts(const char *);
-__extern int fputc(int, FILE *);
-#define putc(c,f) fputc((c),(f))
-#define putchar(c) fputc((c),stdout)
-
-__extern int fgetc(FILE *);
-__extern char * fgets(char *, int, FILE *);
-#define getc(f) fgetc(f)
-
-__extern size_t _fread(void *, size_t, FILE *);
-__extern size_t _fwrite(const void *, size_t, FILE *);
-
-#ifndef __NO_FREAD_FWRITE_INLINES
-extern __inline__ size_t
-fread(void *__p, size_t __s, size_t __n, FILE *__f)
-{
- return _fread(__p, __s*__n, __f)/__s;
-}
-
-extern __inline__ size_t
-fwrite(const void *__p, size_t __s, size_t __n, FILE *__f)
-{
- return _fwrite(__p, __s*__n, __f)/__s;
-}
-#endif
-
-__extern int printf(const char *, ...);
-__extern int vprintf(const char *, va_list);
-__extern int fprintf(FILE *, const char *, ...);
-__extern int vfprintf(FILE *, const char *, va_list);
-__extern int sprintf(char *, const char *, ...);
-__extern int vsprintf(char *, const char *, va_list);
-__extern int snprintf(char *, size_t n, const char *, ...);
-__extern int vsnprintf(char *, size_t n, const char *, va_list);
-__extern int asprintf(char **, const char *, ...);
-__extern int vasprintf(char **, const char *, va_list);
-
-/* No buffering, so no flushing needed */
-extern __inline__ int
-fflush(FILE *__f)
-{
- (void)__f;
- return 0;
-}
-
-__extern int sscanf(const char *, const char *, ...);
-__extern int vsscanf(const char *, const char *, va_list);
-
-__extern void perror(const char *);
-
-__extern int rename(const char *, const char *);
-
-#endif /* _STDIO_H */
diff --git a/klibc/include/stdlib.h b/klibc/include/stdlib.h
deleted file mode 100644
index 17efc30e5a..0000000000
--- a/klibc/include/stdlib.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * stdlib.h
- */
-
-#ifndef _STDLIB_H
-#define _STDLIB_H
-
-#include <klibc/extern.h>
-#include <klibc/compiler.h>
-#include <stddef.h>
-
-#include <malloc.h>
-
-#define EXIT_FAILURE 1
-#define EXIT_SUCCESS 0
-
-static __inline__ __noreturn _Exit(int __n) {
- __extern __noreturn _exit(int);
- _exit(__n);
- for(;;); /* Some gcc versions are stupid */
-}
-__extern __noreturn abort(void);
-static __inline__ int abs(int __n) {
- return (__n < 0) ? -__n : __n;
-}
-__extern int system(const char * string);
-__extern int atexit(void (*)(void));
-__extern int on_exit(void (*)(int, void *), void *);
-__extern int atoi(const char *);
-__extern long atol(const char *);
-__extern long long atoll(const char *);
-__extern __noreturn exit(int);
-static __inline__ long labs(long __n) {
- return (__n < 0L) ? -__n : __n;
-}
-
-static __inline__ long long llabs(long long __n) {
- return (__n < 0LL) ? -__n : __n;
-}
-
-__extern long strtol(const char *, char **, int);
-__extern long long strtoll(const char *, char **, int);
-__extern unsigned long strtoul(const char *, char **, int);
-__extern unsigned long long strtoull(const char *, char **, int);
-
-__extern char *getenv(const char *);
-__extern int putenv(const char *);
-__extern int setenv(const char *, const char *, int);
-__extern int unsetenv(const char *);
-
-__extern void qsort(void *, size_t, size_t, int (*)(const void *, const void *));
-
-
-__extern long jrand48(unsigned short *);
-__extern long mrand48(void);
-__extern long nrand48(unsigned short *);
-__extern long lrand48(void);
-__extern unsigned short *seed48(const unsigned short *);
-__extern void srand48(long);
-
-#define RAND_MAX 0x7fffffff
-static __inline__ int rand(void) {
- return (int)lrand48();
-}
-static __inline__ void srand(unsigned int __s) {
- srand48(__s);
-}
-static __inline__ long random(void)
-{
- return lrand48();
-}
-static __inline__ void srandom(unsigned int __s)
-{
- srand48(__s);
-}
-
-/* Basic PTY functions. These only work if devpts is mounted! */
-
-__extern int unlockpt(int);
-__extern char *ptsname(int);
-__extern int getpt(void);
-
-static __inline__ int grantpt(int __fd)
-{
- (void)__fd;
- return 0; /* devpts does this all for us! */
-}
-
-#endif /* _STDLIB_H */
diff --git a/klibc/include/string.h b/klibc/include/string.h
deleted file mode 100644
index 319be4eb85..0000000000
--- a/klibc/include/string.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * string.h
- */
-
-#ifndef _STRING_H
-#define _STRING_H
-
-#include <klibc/extern.h>
-#include <stddef.h>
-
-__extern void *memccpy(void *, const void *, int, size_t);
-__extern void *memchr(const void *, int, size_t);
-__extern void *memrchr(const void *, int, size_t);
-__extern int memcmp(const void *, const void *, size_t);
-__extern void *memcpy(void *, const void *, size_t);
-__extern void *memmove(void *, const void *, size_t);
-__extern void *memset(void *, int, size_t);
-__extern void *memmem(const void *, size_t, const void *, size_t);
-__extern void memswap(void *, void *, size_t);
-__extern int strcasecmp(const char *, const char *);
-__extern int strncasecmp(const char *, const char *, size_t);
-__extern char *strcat(char *, const char *);
-__extern char *strchr(const char *, int);
-__extern char *index(const char *, int);
-__extern char *strrchr(const char *, int);
-__extern char *rindex(const char *, int);
-__extern int strcmp(const char *, const char *);
-__extern char *strcpy(char *, const char *);
-__extern size_t strcspn(const char *, const char *);
-__extern char *strdup(const char *);
-__extern char *strndup(const char *, size_t);
-__extern char *strerror(int);
-__extern size_t strlen(const char *);
-__extern size_t strnlen(const char *, size_t);
-__extern char *strncat(char *, const char *, size_t);
-__extern size_t strlcat(char *, const char *, size_t);
-__extern int strncmp(const char *, const char *, size_t);
-__extern char *strncpy(char *, const char *, size_t);
-__extern size_t strlcpy(char *, const char *, size_t);
-__extern char *strpbrk(const char *, const char *);
-__extern char *strsep(char **, const char *);
-__extern size_t strspn(const char *, const char *);
-__extern char *strstr(const char *, const char *);
-__extern char *strtok(char *, const char *);
-
-#endif /* _STRING_H */
diff --git a/klibc/include/sys/dirent.h b/klibc/include/sys/dirent.h
deleted file mode 100644
index eec470ce1a..0000000000
--- a/klibc/include/sys/dirent.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * sys/dirent.h
- */
-
-#ifndef _SYS_DIRENT_H
-#define _SYS_DIRENT_H
-
-#include <stdint.h>
-
-/* The kernel calls this struct dirent64 */
-struct dirent {
- uint64_t d_ino;
- int64_t d_off;
- unsigned short d_reclen;
- unsigned char d_type;
- char d_name[256];
-};
-
-__extern int getdents(unsigned int, struct dirent *, unsigned int);
-
-#endif /* _SYS_DIRENT_H */
diff --git a/klibc/include/sys/elf32.h b/klibc/include/sys/elf32.h
deleted file mode 100644
index 652de5bc5f..0000000000
--- a/klibc/include/sys/elf32.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * sys/elf32.h
- */
-
-#ifndef _SYS_ELF32_H
-#define _SYS_ELF32_H
-
-#include <sys/elfcommon.h>
-
-/* ELF standard typedefs (yet more proof that <stdint.h> was way overdue) */
-typedef uint16_t Elf32_Half;
-typedef int16_t Elf32_SHalf;
-typedef uint32_t Elf32_Word;
-typedef int32_t Elf32_Sword;
-typedef uint64_t Elf32_Xword;
-typedef int64_t Elf32_Sxword;
-
-typedef uint32_t Elf32_Off;
-typedef uint32_t Elf32_Addr;
-typedef uint16_t Elf32_Section;
-
-/* Dynamic header */
-
-typedef struct elf32_dyn {
- Elf32_Sword d_tag;
- union{
- Elf32_Sword d_val;
- Elf32_Addr d_ptr;
- } d_un;
-} Elf32_Dyn;
-
-/* Relocations */
-
-#define ELF32_R_SYM(x) ((x) >> 8)
-#define ELF32_R_TYPE(x) ((x) & 0xff)
-
-typedef struct elf32_rel {
- Elf32_Addr r_offset;
- Elf32_Word r_info;
-} Elf32_Rel;
-
-typedef struct elf32_rela {
- Elf32_Addr r_offset;
- Elf32_Word r_info;
- Elf32_Sword r_addend;
-} Elf32_Rela;
-
-/* Symbol */
-
-typedef struct elf32_sym {
- Elf32_Word st_name;
- Elf32_Addr st_value;
- Elf32_Word st_size;
- unsigned char st_info;
- unsigned char st_other;
- Elf32_Half st_shndx;
-} Elf32_Sym;
-
-/* Main file header */
-
-typedef struct elf32_hdr {
- 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;
-
-/* Program header */
-
-typedef struct elf32_phdr {
- 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;
-
-
-/* Section header */
-
-typedef struct elf32_shdr {
- 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;
-
-/* Note header */
-typedef struct elf32_note {
- Elf32_Word n_namesz; /* Name size */
- Elf32_Word n_descsz; /* Content size */
- Elf32_Word n_type; /* Content type */
-} Elf32_Nhdr;
-
-#endif /* _SYS_ELF32_H */
-
diff --git a/klibc/include/sys/elf64.h b/klibc/include/sys/elf64.h
deleted file mode 100644
index 750ddac4d9..0000000000
--- a/klibc/include/sys/elf64.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * sys/elf64.h
- */
-
-#ifndef _SYS_ELF64_H
-#define _SYS_ELF64_H
-
-#include <sys/elfcommon.h>
-
-/* ELF standard typedefs (yet more proof that <stdint.h> was way overdue) */
-typedef uint16_t Elf64_Half;
-typedef int16_t Elf64_SHalf;
-typedef uint32_t Elf64_Word;
-typedef int32_t Elf64_Sword;
-typedef uint64_t Elf64_Xword;
-typedef int64_t Elf64_Sxword;
-
-typedef uint64_t Elf64_Off;
-typedef uint64_t Elf64_Addr;
-typedef uint16_t Elf64_Section;
-
-/* Dynamic header */
-
-typedef struct elf64_dyn {
- Elf64_Sxword d_tag;
- union{
- Elf64_Xword d_val;
- Elf64_Addr d_ptr;
- } d_un;
-} Elf64_Dyn;
-
-/* Relocations */
-
-#define ELF64_R_SYM(x) ((x) >> 32)
-#define ELF64_R_TYPE(x) ((x) & 0xffffffff)
-
-typedef struct elf64_rel {
- Elf64_Addr r_offset;
- Elf64_Xword r_info;
-} Elf64_Rel;
-
-typedef struct elf64_rela {
- Elf64_Addr r_offset;
- Elf64_Xword r_info;
- Elf64_Sxword r_addend;
-} Elf64_Rela;
-
-/* Symbol */
-
-typedef struct elf64_sym {
- Elf64_Word st_name;
- unsigned char st_info;
- unsigned char st_other;
- Elf64_Half st_shndx;
- Elf64_Addr st_value;
- Elf64_Xword st_size;
-} Elf64_Sym;
-
-/* Main file header */
-
-typedef struct elf64_hdr {
- 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;
-
-/* Program header */
-
-typedef struct elf64_phdr {
- 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;
-
-
-/* Section header */
-
-typedef struct elf64_shdr {
- 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;
-
-/* Note header */
-typedef struct elf64_note {
- Elf64_Word n_namesz; /* Name size */
- Elf64_Word n_descsz; /* Content size */
- Elf64_Word n_type; /* Content type */
-} Elf64_Nhdr;
-
-#endif /* _SYS_ELF64_H */
-
diff --git a/klibc/include/sys/elfcommon.h b/klibc/include/sys/elfcommon.h
deleted file mode 100644
index d25804e483..0000000000
--- a/klibc/include/sys/elfcommon.h
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * sys/elfcommon.h
- */
-
-#ifndef _SYS_ELFCOMMON_H
-#define _SYS_ELFCOMMON_H
-
-#include <stdint.h>
-
-/* Segment types */
-#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_LOOS 0x60000000
-#define PT_HIOS 0x6fffffff
-#define PT_LOPROC 0x70000000
-#define PT_HIPROC 0x7fffffff
-#define PT_GNU_EH_FRAME 0x6474e550 /* Extension, eh? */
-
-/* ELF file types */
-#define ET_NONE 0
-#define ET_REL 1
-#define ET_EXEC 2
-#define ET_DYN 3
-#define ET_CORE 4
-#define ET_LOPROC 0xff00
-#define ET_HIPROC 0xffff
-
-/* ELF machine types */
-#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_486 6 /* Not used in Linux at least */
-#define EM_860 7
-#define EM_MIPS 8 /* R3k, bigendian(?) */
-#define EM_MIPS_RS4_BE 10 /* R4k BE */
-#define EM_PARISC 15
-#define EM_SPARC32PLUS 18
-#define EM_PPC 20
-#define EM_PPC64 21
-#define EM_S390 22
-#define EM_SH 42
-#define EM_SPARCV9 43 /* v9 = SPARC64 */
-#define EM_H8_300H 47
-#define EM_H8S 48
-#define EM_IA_64 50 /* Itanic */
-#define EM_X86_64 62
-#define EM_CRIS 76
-#define EM_V850 87
-#define EM_ALPHA 0x9026 /* Interrim Alpha that stuck around */
-#define EM_CYGNUS_V850 0x9080 /* Old v850 ID used by Cygnus */
-#define EM_S390_OLD 0xA390 /* Obsolete interrim value for S/390 */
-
-/* Dynamic type values */
-#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_LOPROC 0x70000000
-#define DT_HIPROC 0x7fffffff
-
-/* Auxilliary table entries */
-#define AT_NULL 0 /* end of vector */
-#define AT_IGNORE 1 /* entry should be ignored */
-#define AT_EXECFD 2 /* file descriptor of program */
-#define AT_PHDR 3 /* program headers for program */
-#define AT_PHENT 4 /* size of program header entry */
-#define AT_PHNUM 5 /* number of program headers */
-#define AT_PAGESZ 6 /* system page size */
-#define AT_BASE 7 /* base address of interpreter */
-#define AT_FLAGS 8 /* flags */
-#define AT_ENTRY 9 /* entry point of program */
-#define AT_NOTELF 10 /* program is not ELF */
-#define AT_UID 11 /* real uid */
-#define AT_EUID 12 /* effective uid */
-#define AT_GID 13 /* real gid */
-#define AT_EGID 14 /* effective gid */
-#define AT_PLATFORM 15 /* string identifying CPU for optimizations */
-#define AT_HWCAP 16 /* arch dependent hints at CPU capabilities */
-#define AT_CLKTCK 17 /* frequency at which times() increments */
-/* 18..22 = ? */
-#define AT_SECURE 23 /* secure mode boolean */
-
-/* Program header permission flags */
-#define PF_X 0x1
-#define PF_W 0x2
-#define PF_R 0x4
-
-/* Section header types */
-#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_NUM 12
-#define SHT_LOPROC 0x70000000
-#define SHT_HIPROC 0x7fffffff
-#define SHT_LOUSER 0x80000000
-#define SHT_HIUSER 0xffffffff
-
-/* Section header flags */
-#define SHF_WRITE 0x1
-#define SHF_ALLOC 0x2
-#define SHF_EXECINSTR 0x4
-#define SHF_MASKPROC 0xf0000000
-
-/* Special section numbers */
-#define SHN_UNDEF 0
-#define SHN_LORESERVE 0xff00
-#define SHN_LOPROC 0xff00
-#define SHN_HIPROC 0xff1f
-#define SHN_ABS 0xfff1
-#define SHN_COMMON 0xfff2
-#define SHN_HIRESERVE 0xffff
-
-/* Lenght of magic at the start of a file */
-#define EI_NIDENT 16
-
-/* Magic number constants... */
-#define EI_MAG0 0 /* e_ident[] indexes */
-#define EI_MAG1 1
-#define EI_MAG2 2
-#define EI_MAG3 3
-#define EI_CLASS 4
-#define EI_DATA 5
-#define EI_VERSION 6
-#define EI_OSABI 7
-#define EI_PAD 8
-
-#define ELFMAG0 0x7f /* EI_MAG */
-#define ELFMAG1 'E'
-#define ELFMAG2 'L'
-#define ELFMAG3 'F'
-#define ELFMAG "\177ELF"
-#define SELFMAG 4
-
-#define ELFCLASSNONE 0 /* EI_CLASS */
-#define ELFCLASS32 1
-#define ELFCLASS64 2
-#define ELFCLASSNUM 3
-
-#define ELFDATANONE 0 /* e_ident[EI_DATA] */
-#define ELFDATA2LSB 1
-#define ELFDATA2MSB 2
-
-#define EV_NONE 0 /* e_version, EI_VERSION */
-#define EV_CURRENT 1
-#define EV_NUM 2
-
-#define ELFOSABI_NONE 0
-#define ELFOSABI_LINUX 3
-
-#endif /* _SYS_ELFCOMMON_H */
-
diff --git a/klibc/include/sys/fsuid.h b/klibc/include/sys/fsuid.h
deleted file mode 100644
index 823486b776..0000000000
--- a/klibc/include/sys/fsuid.h
+++ /dev/null
@@ -1,14 +0,0 @@
-/*
- * sys/fsuid.h
- */
-
-#ifndef _SYS_FSUID_H
-#define _SYS_FSUID_H
-
-#include <klibc/extern.h>
-#include <sys/types.h>
-
-__extern int setfsuid(uid_t);
-__extern int setfsgid(gid_t);
-
-#endif /* _SYS_FSUID_H */
diff --git a/klibc/include/sys/inotify.h b/klibc/include/sys/inotify.h
deleted file mode 100644
index 74fc714190..0000000000
--- a/klibc/include/sys/inotify.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * sys/inotify.h
- */
-
-#ifndef _SYS_INOTIFY_H
-#define _SYS_INOTIFY_H
-
-#include <sys/types.h>
-#include <linux/inotify.h>
-#include <klibc/extern.h>
-
-__extern int inotify_init(void);
-__extern int inotify_add_watch(int, const char *, __u32);
-__extern int inotify_rm_watch(int, __u32);
-
-#endif /* _SYS_INOTIFY_H */
diff --git a/klibc/include/sys/ioctl.h b/klibc/include/sys/ioctl.h
deleted file mode 100644
index b0cee4c02c..0000000000
--- a/klibc/include/sys/ioctl.h
+++ /dev/null
@@ -1,14 +0,0 @@
-/*
- * sys/ioctl.h
- */
-
-#ifndef _SYS_IOCTL_H
-#define _SYS_IOCTL_H
-
-#include <klibc/extern.h>
-#include <linux/ioctl.h>
-#include <asm/ioctls.h>
-
-__extern int ioctl(int, int, void *);
-
-#endif /* _SYS_IOCTL_H */
diff --git a/klibc/include/sys/klog.h b/klibc/include/sys/klog.h
deleted file mode 100644
index 0fc5f5d945..0000000000
--- a/klibc/include/sys/klog.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * sys/klog.h
- */
-
-#ifndef _SYS_KLOG_H
-#define _SYS_KLOG_H
-
-#include <klibc/extern.h>
-
-#define KLOG_CLOSE 0
-#define KLOG_OPEN 1
-#define KLOG_READ 2
-#define KLOG_READ_ALL 3
-#define KLOG_READ_CLEAR 4
-#define KLOG_CLEAR 5
-#define KLOG_DISABLE 6
-#define KLOG_ENABLE 7
-#define KLOG_SETLEVEL 8
-#define KLOG_UNREADSIZE 9
-#define KLOG_WRITE 10
-
-__extern int klogctl(int, char *, int);
-
-#endif /* _SYS_KLOG_H */
diff --git a/klibc/include/sys/mman.h b/klibc/include/sys/mman.h
deleted file mode 100644
index 7f8f3e2f96..0000000000
--- a/klibc/include/sys/mman.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * sys/mman.h
- */
-
-#ifndef _SYS_MMAN_H
-#define _SYS_MMAN_H
-
-#include <klibc/extern.h>
-#include <sys/types.h>
-#include <asm/mman.h>
-#include <asm/page.h> /* For PAGE_SIZE */
-
-#define MAP_FAILED ((void *)-1)
-
-__extern void *mmap(void *, size_t, int, int, int, off_t);
-__extern int munmap(void *, size_t);
-__extern void *mremap(void *, size_t, size_t, unsigned long);
-__extern int msync(const void *, size_t, int);
-__extern int mprotect(const void *, size_t, int);
-__extern int mlockall(int);
-__extern int munlockall(void);
-__extern int mlock(const void *, size_t);
-__extern int munlock(const void *, size_t);
-
-#endif /* _SYS_MMAN_H */
diff --git a/klibc/include/sys/mount.h b/klibc/include/sys/mount.h
deleted file mode 100644
index 0e1bce49bf..0000000000
--- a/klibc/include/sys/mount.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * sys/mount.h
- */
-
-#ifndef _SYS_MOUNT_H
-#define _SYS_MOUNT_H
-
-#include <klibc/extern.h>
-#include <sys/ioctl.h>
-
-/*
- * These are the fs-independent mount-flags: up to 32 flags are supported
- */
-#define MS_RDONLY 1 /* Mount read-only */
-#define MS_NOSUID 2 /* Ignore suid and sgid bits */
-#define MS_NODEV 4 /* Disallow access to device special files */
-#define MS_NOEXEC 8 /* Disallow program execution */
-#define MS_SYNCHRONOUS 16 /* Writes are synced at once */
-#define MS_REMOUNT 32 /* Alter flags of a mounted FS */
-#define MS_MANDLOCK 64 /* Allow mandatory locks on an FS */
-#define MS_DIRSYNC 128 /* Directory modifications are synchronous */
-#define MS_NOATIME 1024 /* Do not update access times. */
-#define MS_NODIRATIME 2048 /* Do not update directory access times */
-#define MS_BIND 4096
-#define MS_MOVE 8192
-#define MS_REC 16384
-#define MS_VERBOSE 32768
-#define MS_POSIXACL (1<<16) /* VFS does not apply the umask */
-#define MS_ONE_SECOND (1<<17) /* fs has 1 sec a/m/ctime resolution */
-#define MS_ACTIVE (1<<30)
-#define MS_NOUSER (1<<31)
-
-/*
- * Superblock flags that can be altered by MS_REMOUNT
- */
-#define MS_RMT_MASK (MS_RDONLY|MS_SYNCHRONOUS|MS_MANDLOCK|MS_NOATIME|MS_NODIRATIME)
-
-/*
- * Old magic mount flag and mask
- */
-#define MS_MGC_VAL 0xC0ED0000
-#define MS_MGC_MSK 0xffff0000
-
-/*
- * umount2() flags
- */
-#define MNT_FORCE 1 /* Forcibly unmount */
-#define MNT_DETACH 2 /* Detach from tree only */
-#define MNT_EXPIRE 4 /* Mark for expiry */
-
-/*
- * Block device ioctls
- */
-#define BLKROSET _IO(0x12, 93) /* Set device read-only (0 = read-write). */
-#define BLKROGET _IO(0x12, 94) /* Get read-only status (0 = read_write). */
-#define BLKRRPART _IO(0x12, 95) /* Re-read partition table. */
-#define BLKGETSIZE _IO(0x12, 96) /* Return device size. */
-#define BLKFLSBUF _IO(0x12, 97) /* Flush buffer cache. */
-#define BLKRASET _IO(0x12, 98) /* Set read ahead for block device. */
-#define BLKRAGET _IO(0x12, 99) /* Get current read ahead setting. */
-
-/*
- * Prototypes
- */
-__extern int mount(const char *, const char *,
- const char *, unsigned long,
- const void *);
-__extern int umount(const char *);
-__extern int umount2(const char *, int);
-__extern int pivot_root(const char *, const char *);
-
-#endif /* _SYS_MOUNT_H */
diff --git a/klibc/include/sys/param.h b/klibc/include/sys/param.h
deleted file mode 100644
index 63a0661f43..0000000000
--- a/klibc/include/sys/param.h
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
- * sys/param.h
- */
-
-#ifndef _SYS_PARAM_H
-#define _SYS_PARAM_H
-
-#include <limits.h>
-#include <linux/param.h>
-
-#endif /* _SYS_PARAM_H */
diff --git a/klibc/include/sys/reboot.h b/klibc/include/sys/reboot.h
deleted file mode 100644
index eaf56610d7..0000000000
--- a/klibc/include/sys/reboot.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * sys/reboot.h
- */
-
-#ifndef _SYS_REBOOT_H
-#define _SYS_REBOOT_H
-
-#include <klibc/extern.h>
-#include <linux/reboot.h>
-
-/* glibc names these constants differently; allow both versions */
-
-#define RB_AUTOBOOT LINUX_REBOOT_CMD_RESTART
-#define RB_HALT_SYSTEM LINUX_REBOOT_CMD_HALT
-#define RB_ENABLE_CAD LINUX_REBOOT_CMD_CAD_ON
-#define RB_DISABLE_CAD LINUX_REBOOT_CMD_CAD_OFF
-#define RB_POWER_OFF LINUX_REBOOT_CMD_POWER_OFF
-
-/* glibc-ish one-argument version */
-__extern int reboot(int);
-
-/* Native four-argument system call */
-__extern int __reboot(int, int, int, void *);
-
-#endif /* _SYS_REBOOT_H */
diff --git a/klibc/include/sys/resource.h b/klibc/include/sys/resource.h
deleted file mode 100644
index ef14bde9f6..0000000000
--- a/klibc/include/sys/resource.h
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * sys/resource.h
- */
-
-#ifndef _SYS_RESOURCE_H
-#define _SYS_RESOURCE_H
-
-#include <klibc/extern.h>
-#include <sys/types.h> /* MUST be included before linux/resource.h */
-#include <linux/resource.h>
-
-__extern int getpriority(int, int);
-__extern int setpriority(int, int, int);
-
-#endif /* _SYS_RESOURCE_H */
diff --git a/klibc/include/sys/select.h b/klibc/include/sys/select.h
deleted file mode 100644
index 361a1a53b0..0000000000
--- a/klibc/include/sys/select.h
+++ /dev/null
@@ -1,14 +0,0 @@
-/*
- * sys/select.h
- */
-
-#ifndef _SYS_SELECT_H
-#define _SYS_SELECT_H
-
-#include <klibc/extern.h>
-#include <sys/time.h>
-#include <sys/types.h>
-
-__extern int select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
-
-#endif /* _SYS_SELECT_H */
diff --git a/klibc/include/sys/socket.h b/klibc/include/sys/socket.h
deleted file mode 100644
index cbc2b89591..0000000000
--- a/klibc/include/sys/socket.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * sys/socket.h
- */
-
-#ifndef _SYS_SOCKET_H
-#define _SYS_SOCKET_H
-
-#include <klibc/extern.h>
-#include <klibc/compiler.h>
-#include <linux/socket.h>
-
-/* For some reason these may be protected by __KERNEL__ in asm/socket.h */
-#ifndef SOCK_STREAM
-# define SOCK_STREAM 1
-# define SOCK_DGRAM 2
-# define SOCK_RAW 3
-# define SOCK_RDM 4
-# define SOCK_SEQPACKET 5
-# define SOCK_PACKET 10
-#endif
-
-#ifdef __i386__
-# define __socketcall __extern __cdecl
-#else
-# define __socketcall __extern
-#endif
-
-typedef int socklen_t;
-
-__socketcall int socket(int, int, int);
-__socketcall int bind(int, struct sockaddr *, int);
-__socketcall int connect(int, struct sockaddr *, socklen_t);
-__socketcall int listen(int, int);
-__socketcall int accept(int, struct sockaddr *, socklen_t *);
-__socketcall int getsockname(int, struct sockaddr *, socklen_t *);
-__socketcall int getpeername(int, struct sockaddr *, socklen_t *);
-__socketcall int socketpair(int, int, int, int *);
-__extern int send(int, const void *, size_t, unsigned int);
-__socketcall int sendto(int, const void *, size_t, int, const struct sockaddr *, socklen_t);
-__extern int recv(int, void *, size_t, unsigned int);
-__socketcall int recvfrom(int, void *, size_t, unsigned int, struct sockaddr *, socklen_t *);
-__socketcall int shutdown(int, int);
-__socketcall int setsockopt(int, int, int, const void *, socklen_t);
-__socketcall int getsockopt(int, int, int, void *, socklen_t *);
-__socketcall int sendmsg(int, const struct msghdr *, unsigned int);
-__socketcall int recvmsg(int, struct msghdr *, unsigned int);
-
-#undef __socketcall
-
-#endif /* _SYS_SOCKET_H */
diff --git a/klibc/include/sys/socketcalls.h b/klibc/include/sys/socketcalls.h
deleted file mode 100644
index dac9f9aab6..0000000000
--- a/klibc/include/sys/socketcalls.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * sys/socketcalls.h
- */
-
-#ifndef _SYS_SOCKETCALLS_H
-#define _SYS_SOCKETCALLS_H
-
-/* socketcalls by number, since <linux/net.h> isn't usable for assembly */
-
-#define SYS_SOCKET 1 /* sys_socket(2) */
-#define SYS_BIND 2 /* sys_bind(2) */
-#define SYS_CONNECT 3 /* sys_connect(2) */
-#define SYS_LISTEN 4 /* sys_listen(2) */
-#define SYS_ACCEPT 5 /* sys_accept(2) */
-#define SYS_GETSOCKNAME 6 /* sys_getsockname(2) */
-#define SYS_GETPEERNAME 7 /* sys_getpeername(2) */
-#define SYS_SOCKETPAIR 8 /* sys_socketpair(2) */
-#define SYS_SEND 9 /* sys_send(2) */
-#define SYS_RECV 10 /* sys_recv(2) */
-#define SYS_SENDTO 11 /* sys_sendto(2) */
-#define SYS_RECVFROM 12 /* sys_recvfrom(2) */
-#define SYS_SHUTDOWN 13 /* sys_shutdown(2) */
-#define SYS_SETSOCKOPT 14 /* sys_setsockopt(2) */
-#define SYS_GETSOCKOPT 15 /* sys_getsockopt(2) */
-#define SYS_SENDMSG 16 /* sys_sendmsg(2) */
-#define SYS_RECVMSG 17 /* sys_recvmsg(2) */
-
-#endif /* _SYS_SOCKETCALLS_H */
diff --git a/klibc/include/sys/stat.h b/klibc/include/sys/stat.h
deleted file mode 100644
index 1bf6a75f79..0000000000
--- a/klibc/include/sys/stat.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * sys/stat.h
- */
-
-#ifndef _SYS_STAT_H
-#define _SYS_STAT_H
-
-#include <klibc/extern.h>
-#include <sys/types.h>
-#include <sys/time.h> /* For struct timespec */
-#include <klibc/archstat.h>
-#include <linux/stat.h>
-
-#ifdef _STATBUF_ST_NSEC
- /* struct stat has struct timespec instead of time_t */
-# define st_atime st_atim.tv_sec
-# define st_mtime st_mtim.tv_sec
-# define st_ctime st_ctim.tv_sec
-#endif
-
-__extern int stat(const char *, struct stat *);
-__extern int fstat(int, struct stat *);
-__extern int lstat(const char *, struct stat *);
-__extern mode_t umask(mode_t);
-__extern int mknod(const char *, mode_t, dev_t);
-static __inline__ int mkfifo(const char *__p, mode_t __m)
-{
- return mknod(__p, (__m & ~S_IFMT) | S_IFIFO, (dev_t)0);
-}
-
-#endif /* _SYS_STAT_H */
diff --git a/klibc/include/sys/statfs.h b/klibc/include/sys/statfs.h
deleted file mode 100644
index 53b3b5e4da..0000000000
--- a/klibc/include/sys/statfs.h
+++ /dev/null
@@ -1 +0,0 @@
-#include <sys/vfs.h>
diff --git a/klibc/include/sys/syscall.h b/klibc/include/sys/syscall.h
deleted file mode 100644
index c2c7684c4a..0000000000
--- a/klibc/include/sys/syscall.h
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * sys/syscall.h
- *
- * Generic system call interface macros
- */
-#ifndef _SYS_SYSCALL_H
-#define _SYS_SYSCALL_H
-
-#include <errno.h>
-#include <sys/types.h>
-#include <asm/unistd.h>
-
-/* Many architectures have incomplete, defective or non-applicable
- syscall macros */
-#include <klibc/archsys.h>
-
-#endif /* _SYS_SYSCALL_H */
diff --git a/klibc/include/sys/sysinfo.h b/klibc/include/sys/sysinfo.h
deleted file mode 100644
index 4051c6897a..0000000000
--- a/klibc/include/sys/sysinfo.h
+++ /dev/null
@@ -1,12 +0,0 @@
-/*
- * sys/sysinfo.h
- */
-
-#ifndef _SYS_SYSINFO_H
-#define _SYS_SYSINFO_H
-
-#include <linux/kernel.h>
-
-extern int sysinfo (struct sysinfo *info);
-
-#endif /* _SYS_SYSINFO_H */
diff --git a/klibc/include/sys/sysmacros.h b/klibc/include/sys/sysmacros.h
deleted file mode 100644
index 7f1e0822b3..0000000000
--- a/klibc/include/sys/sysmacros.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * sys/sysmacros.h
- *
- * Constructs to create and pick apart dev_t. This applies to the Linux 2.6
- * 32-bit dev_t format.
- */
-
-#ifndef _SYS_SYSMACROS_H
-#define _SYS_SYSMACROS_H
-
-#ifndef _SYS_TYPES_H
-# include <sys/types.h>
-#endif
-
-static __inline__ int major(dev_t __d)
-{
- return (__d >> 8) & 0xfff;
-}
-
-static __inline__ int minor(dev_t __d)
-{
- return (__d & 0xff) | ((__d >> 12) & 0xfff00);
-}
-
-static __inline__ dev_t makedev(int __ma, int __mi)
-{
- return ((__ma & 0xfff) << 8) | (__mi & 0xff) | ((__mi & 0xfff00) << 12);
-}
-
-#endif /* _SYS_SYSMACROS_H */
-
diff --git a/klibc/include/sys/time.h b/klibc/include/sys/time.h
deleted file mode 100644
index 2767a1bce3..0000000000
--- a/klibc/include/sys/time.h
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * sys/time.h
- */
-
-#ifndef _SYS_TIME_H
-#define _SYS_TIME_H
-
-#include <klibc/extern.h>
-#include <sys/types.h>
-#include <linux/time.h>
-
-__extern int gettimeofday(struct timeval *, struct timezone *);
-__extern int settimeofday(const struct timeval *, const struct timezone *);
-__extern int getitimer(int, struct itimerval *);
-__extern int setitimer(int, const struct itimerval *, struct itimerval *);
-__extern int utimes(const char *, const struct timeval *);
-
-#endif /* _SYS_TIME_H */
diff --git a/klibc/include/sys/times.h b/klibc/include/sys/times.h
deleted file mode 100644
index dd86531669..0000000000
--- a/klibc/include/sys/times.h
+++ /dev/null
@@ -1,14 +0,0 @@
-/*
- * sys/times.h
- */
-
-#ifndef _SYS_TIMES_H
-#define _SYS_TIMES_H
-
-#include <klibc/extern.h>
-#include <sys/types.h>
-#include <linux/times.h>
-
-__extern clock_t times(struct tms *);
-
-#endif /* _SYS_TIMES_H */
diff --git a/klibc/include/sys/types.h b/klibc/include/sys/types.h
deleted file mode 100644
index ddec242922..0000000000
--- a/klibc/include/sys/types.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * sys/types.h
- */
-
-#ifndef _SYS_TYPES_H
-#define _SYS_TYPES_H
-
-#include <klibc/compiler.h>
-#include <stddef.h>
-#include <stdint.h>
-
-#define _SSIZE_T
-typedef ptrdiff_t ssize_t;
-
-#include <linux/posix_types.h>
-#include <asm/types.h>
-
-/* Keeps linux/types.h from getting included elsewhere */
-#define _LINUX_TYPES_H
-
-typedef __kernel_fd_set fd_set;
-typedef uint32_t dev_t;
-typedef __kernel_ino_t ino_t;
-typedef __kernel_mode_t mode_t;
-typedef __kernel_nlink_t nlink_t;
-typedef __kernel_loff_t off_t;
-typedef __kernel_loff_t loff_t;
-typedef __kernel_pid_t pid_t;
-typedef __kernel_daddr_t daddr_t;
-typedef __kernel_key_t key_t;
-typedef __kernel_suseconds_t suseconds_t;
-/* typedef __kernel_timer_t timer_t; */
-typedef int timer_t;
-
-typedef __kernel_uid32_t uid_t;
-typedef __kernel_gid32_t gid_t;
-
-typedef __kernel_fsid_t fsid_t;
-
-/*
- * The following typedefs are also protected by individual ifdefs for
- * historical reasons:
- */
-#ifndef _SIZE_T
-#define _SIZE_T
-typedef __kernel_size_t size_t;
-#endif
-
-#ifndef _SSIZE_T
-#define _SSIZE_T
-typedef __kernel_ssize_t ssize_t;
-#endif
-
-#ifndef _PTRDIFF_T
-#define _PTRDIFF_T
-typedef __kernel_ptrdiff_t ptrdiff_t;
-#endif
-
-#ifndef _TIME_T
-#define _TIME_T
-typedef __kernel_time_t time_t;
-#endif
-
-#ifndef _CLOCK_T
-#define _CLOCK_T
-typedef __kernel_clock_t clock_t;
-#endif
-
-#ifndef _CADDR_T
-#define _CADDR_T
-typedef __kernel_caddr_t caddr_t;
-#endif
-
-/* bsd */
-typedef unsigned char u_char;
-typedef unsigned short u_short;
-typedef unsigned int u_int;
-typedef unsigned long u_long;
-
-/* sysv */
-typedef unsigned char unchar;
-typedef unsigned short ushort;
-typedef unsigned int uint;
-typedef unsigned long ulong;
-
-/* Linux-specific? */
-typedef uint8_t u_int8_t;
-typedef uint16_t u_int16_t;
-typedef uint32_t u_int32_t;
-typedef uint64_t u_int64_t;
-
-typedef uint16_t __bitwise __le16;
-typedef uint16_t __bitwise __be16;
-typedef uint32_t __bitwise __le32;
-typedef uint32_t __bitwise __be32;
-typedef uint64_t __bitwise __le64;
-typedef uint64_t __bitwise __be64;
-
-/*
- * Some apps want this in <sys/types.h>
- */
-#include <sys/sysmacros.h>
-
-#endif
diff --git a/klibc/include/sys/uio.h b/klibc/include/sys/uio.h
deleted file mode 100644
index fc2525d11a..0000000000
--- a/klibc/include/sys/uio.h
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * sys/uio.h
- */
-
-#ifndef _SYS_UIO_H
-#define _SYS_UIO_H
-
-#include <klibc/extern.h>
-#include <sys/types.h>
-#include <linux/uio.h>
-
-__extern int readv(int, const struct iovec *, int);
-__extern int writev(int, const struct iovec *, int);
-
-#endif /* _SYS_UIO_H */
diff --git a/klibc/include/sys/un.h b/klibc/include/sys/un.h
deleted file mode 100644
index df42d719f7..0000000000
--- a/klibc/include/sys/un.h
+++ /dev/null
@@ -1,10 +0,0 @@
-/*
- * <sys/un.h>
- */
-
-#ifndef _SYS_UN_H
-#define _SYS_UN_H
-
-#include <linux/un.h>
-
-#endif /* _SYS_UN_H */
diff --git a/klibc/include/sys/utime.h b/klibc/include/sys/utime.h
deleted file mode 100644
index d1d635d242..0000000000
--- a/klibc/include/sys/utime.h
+++ /dev/null
@@ -1,10 +0,0 @@
-/*
- * sys/utime.h
- */
-
-#ifndef _SYS_UTIME_H
-#define _SYS_UTIME_H
-
-#include <linux/utime.h>
-
-#endif /* _SYS_UTIME_H */
diff --git a/klibc/include/sys/utsname.h b/klibc/include/sys/utsname.h
deleted file mode 100644
index f2990f5711..0000000000
--- a/klibc/include/sys/utsname.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * sys/utsname.h
- */
-
-#ifndef _SYS_UTSNAME_H
-#define _SYS_UTSNAME_H
-
-#include <klibc/extern.h>
-
-#define SYS_NMLN 65
-
-struct utsname {
- char sysname[SYS_NMLN];
- char nodename[SYS_NMLN];
- char release[SYS_NMLN];
- char version[SYS_NMLN];
- char machine[SYS_NMLN];
- char domainname[SYS_NMLN];
-};
-
-__extern int uname(struct utsname *);
-
-#endif /* _SYS_UTSNAME_H */
diff --git a/klibc/include/sys/vfs.h b/klibc/include/sys/vfs.h
deleted file mode 100644
index cf5aaf9107..0000000000
--- a/klibc/include/sys/vfs.h
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * sys/vfs.h
- */
-
-#ifndef _SYS_VFS_H
-#define _SYS_VFS_H
-
-#include <stdint.h>
-#include <klibc/extern.h>
-#include <sys/types.h>
-#include <bitsize.h>
-
-/* struct statfs64 -- there seems to be two standards -
- one for 32 and one for 64 bits, and they're incompatible... */
-
-#if _BITSIZE == 32 || defined(__s390__)
-
-struct statfs {
- uint32_t f_type;
- uint32_t f_bsize;
- uint64_t f_blocks;
- uint64_t f_bfree;
- uint64_t f_bavail;
- uint64_t f_files;
- uint64_t f_ffree;
- __kernel_fsid_t f_fsid;
- uint32_t f_namelen;
- uint32_t f_frsize;
- uint32_t f_spare[5];
-};
-
-#else /* _BITSIZE == 64 */
-
-struct statfs {
- uint64_t f_type;
- uint64_t f_bsize;
- uint64_t f_blocks;
- uint64_t f_bfree;
- uint64_t f_bavail;
- uint64_t f_files;
- uint64_t f_ffree;
- __kernel_fsid_t f_fsid;
- uint64_t f_namelen;
- uint64_t f_frsize;
- uint64_t f_spare[5];
-};
-
-#endif /* _BITSIZE */
-
-__extern int statfs(const char *, struct statfs *);
-__extern int fstatfs(int, struct statfs *);
-
-/* Various filesystem types */
-#define ADFS_SUPER_MAGIC 0xadf5
-#define AFFS_SUPER_MAGIC 0xadff
-#define AFS_FS_MAGIC 0x6B414653 /* 'kAFS' */
-#define AUTOFS_SUPER_MAGIC 0x0187
-#define BFS_MAGIC 0x1BADFACE
-#define CAPIFS_SUPER_MAGIC 0x434e
-#define CIFS_MAGIC_NUMBER 0xFF534D42
-#define CODA_SUPER_MAGIC 0x73757245
-#define CRAMFS_MAGIC 0x28cd3d45
-#define DEVFS_SUPER_MAGIC 0x1373
-#define DEVPTS_SUPER_MAGIC 0x1cd1
-#define EFS_SUPER_MAGIC 0x414A53
-#define EVENTPOLLFS_MAGIC 0x03111965
-#define EXT2_SUPER_MAGIC 0xEF53
-#define EXT3_SUPER_MAGIC 0xEF53
-#define GADGETFS_MAGIC 0xaee71ee7
-#define HFSPLUS_SUPER_MAGIC 0x482b
-#define HFS_MFS_SUPER_MAGIC 0xD2D7 /* MFS MDB (super block) */
-#define HFS_SUPER_MAGIC 0x4244 /* "BD": HFS MDB (super block) */
-#define HPFS_SUPER_MAGIC 0xf995e849
-#define HUGETLBFS_MAGIC 0x958458f6
-#define HWGFS_MAGIC 0x12061983
-#define IBMASMFS_MAGIC 0x66726f67
-#define ISOFS_SUPER_MAGIC 0x9660
-#define JFFS2_SUPER_MAGIC 0x72b6
-#define JFFS_MAGIC_BITMASK 0x34383931 /* "1984" */
-#define JFFS_MAGIC_SB_BITMASK 0x07c0 /* 1984 */
-#define JFS_SUPER_MAGIC 0x3153464a /* "JFS1" */
-#define MINIX2_SUPER_MAGIC 0x2468 /* minix V2 fs */
-#define MINIX2_SUPER_MAGIC2 0x2478 /* minix V2 fs, 30 char names */
-#define MINIX_SUPER_MAGIC 0x137F /* original minix fs */
-#define MINIX_SUPER_MAGIC2 0x138F /* minix fs, 30 char names */
-#define MSDOS_SUPER_MAGIC 0x4d44 /* MD */
-#define NCP_SUPER_MAGIC 0x564c
-#define NFS_SUPER_MAGIC 0x6969
-#define NFS_SUPER_MAGIC 0x6969
-#define OPENPROM_SUPER_MAGIC 0x9fa1
-#define OPROFILEFS_MAGIC 0x6f70726f
-#define PFMFS_MAGIC 0xa0b4d889
-#define PIPEFS_MAGIC 0x50495045
-#define PROC_SUPER_MAGIC 0x9fa0
-#define QNX4_SUPER_MAGIC 0x002f /* qnx4 fs detection */
-#define RAMFS_MAGIC 0x858458f6
-#define REISERFS_SUPER_MAGIC 0x52654973
-#define ROMFS_MAGIC 0x7275
-#define SMB_SUPER_MAGIC 0x517B
-#define SOCKFS_MAGIC 0x534F434B
-#define SYSFS_MAGIC 0x62656572
-#define TMPFS_MAGIC 0x01021994
-#define UDF_SUPER_MAGIC 0x15013346
-#define UFS_MAGIC 0x00011954
-#define UFS_MAGIC_4GB 0x05231994 /* fs > 4 GB && fs_featurebits */
-#define UFS_MAGIC_FEA 0x00195612 /* fs_featurebits supported */
-#define UFS_MAGIC_LFN 0x00095014 /* fs supports filenames > 14 chars */
-#define UFS_MAGIC_SEC 0x00612195 /* B1 security fs */
-#define USBDEVICE_SUPER_MAGIC 0x9fa2
-#define VXFS_SUPER_MAGIC 0xa501FCF5
-
-#endif /* _SYS_VFS_H */
diff --git a/klibc/include/sys/wait.h b/klibc/include/sys/wait.h
deleted file mode 100644
index 4cfafc9408..0000000000
--- a/klibc/include/sys/wait.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * sys/wait.h
- */
-
-#ifndef _SYS_WAIT_H
-#define _SYS_WAIT_H
-
-#include <klibc/extern.h>
-#include <sys/types.h>
-#include <sys/resource.h>
-
-#include <linux/wait.h>
-
-#define WEXITSTATUS(s) (((s) & 0xff00) >> 8)
-#define WTERMSIG(s) ((s) & 0x7f)
-#define WIFEXITED(s) (WTERMSIG(s) == 0)
-#define WIFSTOPPED(s) (WTERMSIG(s) == 0x7f)
-/* Ugly hack to avoid multiple evaluation of "s" */
-#define WIFSIGNALED(s) (WTERMSIG((s)+1) >= 2)
-#define WCOREDUMP(s) ((s) & 0x80)
-#define WSTOPSIG(s) WEXITSTATUS(s)
-
-__extern pid_t wait(int *);
-__extern pid_t waitpid(pid_t, int *, int);
-__extern pid_t wait3(int *, int, struct rusage *);
-__extern pid_t wait4(pid_t, int *, int, struct rusage *);
-
-#endif /* _SYS_WAIT_H */
diff --git a/klibc/include/syslog.h b/klibc/include/syslog.h
deleted file mode 100644
index 061dbcd5a7..0000000000
--- a/klibc/include/syslog.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * syslog.h
- */
-
-#ifndef _SYSLOG_H
-#define _SYSLOG_H
-
-#include <stdio.h>
-#include <klibc/extern.h>
-
-/* Alert levels */
-#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(x) ((x) & LOG_PRIMASK)
-
-
-/* Facilities; not actually used */
-#define LOG_KERN 0000
-#define LOG_USER 0010
-#define LOG_MAIL 0020
-#define LOG_DAEMON 0030
-#define LOG_AUTH 0040
-#define LOG_SYSLOG 0050
-#define LOG_LPR 0060
-#define LOG_NEWS 0070
-#define LOG_UUCP 0100
-#define LOG_CRON 0110
-#define LOG_AUTHPRIV 0120
-#define LOG_FTP 0130
-#define LOG_LOCAL0 0200
-#define LOG_LOCAL1 0210
-#define LOG_LOCAL2 0220
-#define LOG_LOCAL3 0230
-#define LOG_LOCAL4 0240
-#define LOG_LOCAL5 0250
-#define LOG_LOCAL6 0260
-#define LOG_LOCAL7 0270
-
-#define LOG_FACMASK 01770
-#define LOG_FAC(x) (((x) >> 3) & (LOG_FACMASK >> 3))
-
-/* openlog() flags; only LOG_PID and LOG_PERROR supported */
-#define LOG_PID 0x01 /* include pid with message */
-#define LOG_CONS 0x02 /* write to console on logger error */
-#define LOG_ODELAY 0x04 /* delay connection until syslog() */
-#define LOG_NDELAY 0x08 /* open connection immediately */
-#define LOG_NOWAIT 0x10 /* wait for child processes (unused on linux) */
-#define LOG_PERROR 0x20 /* additional logging to stderr */
-
-
-__extern void openlog(const char *, int, int);
-__extern void syslog(int, const char *, ...);
-__extern void vsyslog(int, const char *, va_list);
-__extern void closelog(void);
-
-#endif /* _SYSLOG_H */
diff --git a/klibc/include/termios.h b/klibc/include/termios.h
deleted file mode 100644
index 08a5e56855..0000000000
--- a/klibc/include/termios.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * termios.h
- */
-
-#ifndef _TERMIOS_H
-#define _TERMIOS_H
-
-#include <klibc/extern.h>
-#include <stdint.h>
-#include <sys/ioctl.h>
-#include <sys/types.h>
-#include <linux/termios.h>
-
-/* Redefine these so the magic constants == the ioctl number to use. */
-#undef TCSANOW
-#undef TCSADRAIN
-#undef TCSAFLUSH
-#define TCSANOW TCSETS
-#define TCSADRAIN TCSETSW
-#define TCSAFLUSH TCSETSF
-
-static __inline__ int tcgetattr(int __fd, struct termios *__s)
-{
- return ioctl(__fd, TCGETS, __s);
-}
-
-static __inline__ int tcsetattr(int __fd, int __opt, const struct termios *__s)
-{
- return ioctl(__fd, __opt, (void *)__s);
-}
-
-static __inline__ int tcflow(int __fd, int __action)
-{
- return ioctl(__fd, TCXONC, (void *)(intptr_t)__action);
-}
-
-static __inline__ int tcflush(int __fd, int __queue)
-{
- return ioctl(__fd, TCFLSH, (void *)(intptr_t)__queue);
-}
-
-static __inline__ pid_t tcgetpgrp(int __fd)
-{
- pid_t __p;
- return ioctl(__fd, TIOCGPGRP, &__p) ? (pid_t)-1 : __p;
-}
-
-static __inline__ pid_t tcgetsid(int __fd)
-{
- pid_t __p;
- return ioctl(__fd, TIOCGSID, &__p) ? (pid_t)-1 : __p;
-}
-
-static __inline__ int tcsendbreak(int __fd, int __duration)
-{
- return ioctl(__fd, TCSBRKP, (void *)(uintptr_t)__duration);
-}
-
-static __inline__ int tcsetpgrp(int __fd, pid_t __p)
-{
- return ioctl(__fd, TIOCSPGRP, &__p);
-}
-
-static __inline__ speed_t cfgetospeed(const struct termios *__s)
-{
- return (speed_t)(__s->c_cflag & CBAUD);
-}
-
-static __inline__ speed_t cfgetispeed(const struct termios *__s)
-{
- return (speed_t)(__s->c_cflag & CBAUD);
-}
-
-static __inline__ int cfsetospeed(struct termios *__s, speed_t __v)
-{
- __s->c_cflag = (__s->c_cflag & ~CBAUD) | (__v & CBAUD);
- return 0;
-}
-
-static __inline__ int cfsetispeed(struct termios *__s, speed_t __v)
-{
- __s->c_cflag = (__s->c_cflag & ~CBAUD) | (__v & CBAUD);
- return 0;
-}
-
-#endif /* _TERMIOS_H */
diff --git a/klibc/include/time.h b/klibc/include/time.h
deleted file mode 100644
index 0f094c2806..0000000000
--- a/klibc/include/time.h
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * time.h
- */
-
-#ifndef _TIME_H
-#define _TIME_H
-
-#include <klibc/extern.h>
-#include <sys/time.h>
-
-__extern time_t time(time_t *);
-__extern int nanosleep(const struct timespec *, struct timespec *);
-
-/* klibc-specific but useful since we don't have floating point */
-__extern char *strtotimeval(const char *str, struct timeval *tv);
-__extern char *strtotimespec(const char *str, struct timespec *tv);
-
-#endif /* _TIME_H */
diff --git a/klibc/include/unistd.h b/klibc/include/unistd.h
deleted file mode 100644
index 51fd7b769e..0000000000
--- a/klibc/include/unistd.h
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * unistd.h
- */
-
-#ifndef _UNISTD_H
-#define _UNISTD_H
-
-#include <klibc/extern.h>
-#include <klibc/compiler.h>
-#include <stddef.h>
-#include <sys/types.h>
-#include <sys/select.h>
-
-__extern char **environ;
-__extern __noreturn _exit(int);
-
-__extern pid_t fork(void);
-__extern pid_t vfork(void);
-__extern pid_t getpid(void);
-__extern pid_t getpgid(pid_t);
-__extern int setpgid(pid_t, pid_t);
-__extern pid_t getppid(void);
-__extern pid_t getpgrp(void);
-__extern int setpgrp(void);
-__extern pid_t setsid(void);
-__extern pid_t getsid(pid_t);
-__extern int execv(const char *, char * const *);
-__extern int execvp(const char *, char * const *);
-__extern int execve(const char *, char * const *, char * const *);
-__extern int execvpe(const char *, char * const *, char * const *);
-__extern int execl(const char *, const char *, ...);
-__extern int execlp(const char *, const char *, ...);
-__extern int execle(const char *, const char *, ...);
-__extern int execlpe(const char *, const char *, ...);
-
-__extern int setuid(uid_t);
-__extern uid_t getuid(void);
-__extern int seteuid(uid_t);
-__extern uid_t geteuid(void);
-__extern int setgid(gid_t);
-__extern gid_t getgid(void);
-__extern int setegid(gid_t);
-__extern gid_t getegid(void);
-__extern int getgroups(int, gid_t *);
-__extern int setgroups(size_t, const gid_t *);
-__extern int setreuid(uid_t, uid_t);
-__extern int setregid(gid_t, gid_t);
-__extern int setresuid(uid_t, uid_t, uid_t);
-__extern int setresgid(gid_t, gid_t, gid_t);
-__extern int getfsuid(uid_t);
-__extern int setfsuid(uid_t);
-
-/* Macros for access() */
-#define R_OK 4 /* Read */
-#define W_OK 2 /* Write */
-#define X_OK 1 /* Execute */
-#define F_OK 0 /* Existence */
-
-__extern int access(const char *, int);
-__extern int link(const char *, const char *);
-__extern int unlink(const char *);
-__extern int chdir(const char *);
-__extern int fchdir(int);
-__extern int chmod(const char *, mode_t);
-__extern int fchmod(int, mode_t);
-__extern int mkdir(const char *, mode_t);
-__extern int rmdir(const char *);
-__extern int pipe(int *);
-__extern int chroot(const char *);
-__extern int symlink(const char *, const char *);
-__extern int readlink(const char *, char *, size_t);
-__extern int chown(const char *, uid_t, gid_t);
-__extern int fchown(int, uid_t, gid_t);
-__extern int lchown(const char *, uid_t, gid_t);
-__extern char *getcwd(char *, size_t);
-
-__extern int sync(void);
-
-/* Also in <fcntl.h> */
-#ifndef _KLIBC_IN_OPEN_C
-__extern int open(const char *, int, ...);
-#endif
-__extern int close(int);
-__extern off_t lseek(int, off_t, int);
-/* off_t is 64 bits now even on 32-bit platforms; see llseek.c */
-static __inline__ off_t llseek(int __f, off_t __o, int __w) {
- return lseek(__f, __o, __w);
-}
-
-__extern ssize_t read(int, void *, size_t);
-__extern ssize_t write(int, const void *, size_t);
-__extern ssize_t pread(int, void *, size_t, off_t);
-__extern ssize_t pwrite(int, void *, size_t, off_t);
-
-__extern int dup(int);
-__extern int dup2(int, int);
-__extern int fcntl(int, int, ...);
-__extern int ioctl(int, int, void *);
-__extern int flock(int, int);
-__extern int fsync(int);
-__extern int fdatasync(int);
-__extern int ftruncate(int, off_t);
-
-__extern int pause(void);
-__extern unsigned int alarm(unsigned int);
-__extern unsigned int sleep(unsigned int);
-__extern void usleep(unsigned long);
-
-__extern int gethostname(char *, size_t);
-__extern int sethostname(const char *, size_t);
-__extern int getdomainname(char *, size_t);
-__extern int setdomainname(const char *, size_t);
-
-__extern void *__brk(void *);
-__extern int brk(void *);
-__extern void *sbrk(ptrdiff_t);
-
-__extern int getopt(int, char * const *, const char *);
-__extern char *optarg;
-__extern int optind, opterr, optopt;
-
-__extern int isatty(int);
-
-static __inline__ int getpagesize(void) {
- extern unsigned int __page_size;
- return __page_size;
-}
-static __inline__ int __getpageshift(void) {
- extern unsigned int __page_shift;
- return __page_shift;
-}
-
-__extern int daemon(int, int);
-
-/* Standard file descriptor numbers. */
-#define STDIN_FILENO 0
-#define STDOUT_FILENO 1
-#define STDERR_FILENO 2
-
-#endif /* _UNISTD_H */
diff --git a/klibc/include/utime.h b/klibc/include/utime.h
deleted file mode 100644
index 3dfa03a14a..0000000000
--- a/klibc/include/utime.h
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * utime.h
- */
-
-#ifndef _UTIME_H
-#define _UTIME_H
-
-#include <klibc/extern.h>
-#include <sys/types.h>
-#include <linux/utime.h>
-
-__extern int utime(const char *, const struct utimbuf *);
-
-#endif /* _UTIME_H */
-
diff --git a/klibc/klcc.1 b/klibc/klcc.1
deleted file mode 100644
index 76334a3a54..0000000000
--- a/klibc/klcc.1
+++ /dev/null
@@ -1,116 +0,0 @@
-.\" $Id: klcc.1,v 1.3 2005/04/19 23:27:46 hpa Exp $
-.\" -----------------------------------------------------------------------
-.\"
-.\" Copyright 2005 H. Peter Anvin - All Rights Reserved
-.\"
-.\" 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.
-.\"
-.\" -----------------------------------------------------------------------
-
-.TH klcc "1" "1 March 2005" "klibc" "H. Peter Anvin"
-.SH NAME
-klcc \- compile a program against klibc
-.SH SYNOPSIS
-.B klcc
-[\fIgcc options\fP]
-[\fB\-o\fP \fIoutfile\fP]
-\fIinfile...\fP
-.SH DESCRIPTION
-.PP
-.B klcc
-is a wrapper around
-.BR gcc (1)
-and
-.BR ld (1)
-which compiles and links a program against the
-.B klibc
-tiny C library. It supports most
-.B gcc
-options.
-.PP
-Unlike
-.BR gcc ,
-.B klcc
-compiles with optimization on by default. Furthermore, the
-optimization level used depends on whether or not
-.B \-g
-is specified, since
-.B klcc
-frequently uses options in the normal case which makes debugging
-impossible. Therefore, compile without
-.BR \-g ,
-.BR \-O ,
-.B \-f
-or
-.B \-m
-option to use the default optimization level; this will generally
-result in the smallest binaries. You may want to use
-.B \-s
-when linking, however. Use
-.B \-O0
-to compile without any optimization whatsoever; this may not work depending
-on the version of
-.B gcc
-used.
-.PP
-Use the
-.B \-shared
-or
-.B \-static
-option to compile for and link against shared or static klibc. Note
-that shared klibc only supports running against the exact same klibc
-binary as the binary was linked with.
-.PP
-In addition to standard
-.B gcc
-options,
-.B klcc
-supports options of the form \fB\-print-klibc-\fP\fIoption\fP,
-which prints the corresponding klibc configuration option.
-.SH AUTHOR
-Written by H. Peter Anvin <hpa@zytor.com>.
-.SH COPYRIGHT
-Copyright \(co 2005 H. Peter Anvin \- All Rights Reserved
-.PP
-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:
-.PP
-The above copyright notice and this permission notice shall
-be included in all copies or substantial portions of the Software.
-.PP
-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.
-.SH "SEE ALSO"
-.BR gcc (1)
-
diff --git a/klibc/klcc.in b/klibc/klcc.in
deleted file mode 100644
index 5629f24f1c..0000000000
--- a/klibc/klcc.in
+++ /dev/null
@@ -1,258 +0,0 @@
-# -*- perl -*-
-
-use IPC::Open3;
-
-# Standard includes
-@includes = ("-I${prefix}/${KCROSS}include/arch/${ARCH}",
- "-I${prefix}/${KCROSS}include/bits${BITSIZE}",
- "-I${prefix}/${KCROSS}include");
-
-# Default optimization options (for compiles without -g)
-@optopt = @OPTFLAGS;
-@goptopt = ('-O');
-
-# Standard library directories
-@stdlibpath = ("-L${prefix}/${KCROSS}lib");
-
-# Options and libraries to pass to ld; shared versus static
-@staticopt = ("${prefix}/${KCROSS}lib/crt0.o");
-@staticlib = ("${prefix}/${KCROSS}lib/libc.a");
-@sharedopt = (@EMAIN, "${prefix}/${KCROSS}lib/interp.o");
-@sharedlib = ('-R', "${prefix}/${KCROSS}lib/libc.so");
-
-# Returns the language (-x option string) for a specific extension.
-sub filename2lang($) {
- my ($file) = @_;
-
- return 'c' if ( $file =~ /\.c$/ );
- return 'c-header' if ( $file =~ /\.h$/ );
- return 'cpp-output' if ( $file =~ /\.i$/ );
- return 'c++-cpp-output' if ( $file =~ /\.ii$/ );
- return 'objective-c' if ( $file =~ /\.m$/ );
- return 'objc-cpp-output' if ( $file =~ /\.mi$/ );
- return 'c++' if ( $file =~/\.(cc|cp|cxx|cpp|CPP|c\+\+|C)$/ );
- return 'c++-header' if ( $file =~ /\.(hh|H)$/ );
- return 'f77' if ( $file =~ /\.(f|for|FOR)$/ );
- return 'f77-cpp-input' if ( $file =~ /\.(F|fpp|FPP)$/ );
- return 'ratfor' if ( $file =~ /\.r$/ );
-
- # Is this correct?
- return 'ada' if ( $file =~ /\.(ads|adb)$/ );
-
- return 'assembler' if ( $file =~ /\.s$/ );
- return 'assembler-with-cpp' if ( $file =~/ \.S$/ );
-
- # Linker file; there is no option to gcc to assume something
- # is a linker file, so we make up our own...
- return 'obj';
-}
-
-# Produces a series of -x options and files
-sub files_with_lang($$) {
- my($files, $flang) = @_;
- my(@as) = ();
- my($xopt) = 'none';
- my($need);
-
- foreach $f ( @{$files} ) {
- $need = ${$flang}{$f};
-
- # Skip object files
- if ( $need ne 'obj' ) {
- unless ( $xopt eq $need || $need eq 'stdin') {
- push(@as, '-x', $need);
- $xopt = $need;
- }
- push(@as, $f);
- }
- }
-
- return @as;
-}
-
-# Convert a return value from system() to an exit() code
-sub syserr($) {
- my($e) = @_;
-
- return ($e & 0x7f) | 0x80 if ( $e & 0xff );
- return $e >> 8;
-}
-
-# Run a program; printing out the command line if $verbose is set
-sub mysystem(@) {
- print STDERR join(' ', @_), "\n" if ( $verbose );
- my $cmd = shift;
- open(INPUT, "<&STDIN"); # dup STDIN filehandle to INPUT
- my $childpid = open3("<&INPUT", ">&STDOUT", ">&STDERR", $cmd, @_);
- waitpid ($childpid, 0);
- return $?;
-}
-
-#
-# Initialization
-#
-open(NULL, '+<', '/dev/null') or die "$0: cannot open /dev/null\n";
-
-#
-# Begin parsing options.
-#
-
-@ccopt = ();
-@ldopt = ();
-@libs = ();
-
-@files = (); # List of files
-%flang = (); # Languages for files
-
-# This is 'c' for compile only, 'E' for preprocess only,
-# 'S' for compile to assembly.
-$operation = ''; # Compile and link
-
-# Current -x option. If undefined, it means autodetect.
-undef $lang;
-
-$save_temps = 0; # The -save-temps option
-$verbose = 0; # The -v option
-$shared = 0; # Are we compiling shared?
-$debugging = 0; # -g or -p option present?
-$strip = 0; # -s option present?
-undef $output; # -o option present?
-
-while ( defined($a = shift(@ARGV)) ) {
- if ( $a !~ /^\-/ ) {
- # Not an option. Must be a filename then.
- push(@files, $a);
- $flang{$a} = $lang || filename2lang($a);
- } elsif ( $a eq '-' ) {
- # gcc gets its input from stdin
- push(@files, $a);
- # prevent setting -x
- $flang{$a} = 'stdin'
- } elsif ( $a =~ /^-print-klibc-(.*)$/ ) {
- # This test must precede -print
- if ( defined($conf{$1}) ) {
- print ${$conf{$1}}, "\n";
- exit 0;
- } else {
- die "$0: unknown option: $a\n";
- }
- } elsif ( $a =~ /^(-print|-dump|--help|--version)/ ) {
- # These share prefixes with some other options, so put this test early!
- # Pseudo-operations; just pass to gcc and don't do anything else
- push(@ccopt, $a);
- $operation = 'c' if ( $operation eq '' );
- } elsif ( $a =~ /^-Wl,(.*)$/ ) {
- # -Wl used to pass options to the linker
- push(@ldopt, split(/,/, $1));
- } elsif ( $a =~ /^-([fmwWQdO]|std=|ansi|pedantic|M[GPD]|MMD)/ ) {
- # Options to gcc
- push(@ccopt, $a);
- } elsif ( $a =~ /^-([DUI]|M[FQT])(.*)$/ ) {
- # Options to gcc, which can take either a conjoined argument
- # (-DFOO) or a disjoint argument (-D FOO)
- push(@ccopt, $a);
- push(@ccopt, shift(@ARGV)) if ( $2 eq '' );
- } elsif ( $a eq '-include' ) {
- # Options to gcc which always take a disjoint argument
- push(@ccopt, $a, shift(@ARGV));
- } elsif ( $a eq '-M' || $a eq '-MM' ) {
- # gcc options, that force preprocessing mode
- push(@ccopt, $a);
- $operation = 'E';
- } elsif ( $a =~ /^-[gp]/ || $a eq '-p' ) {
- # Debugging options to gcc
- push(@ccopt, $a);
- $debugging = 1;
- } elsif ( $a eq '-v' ) {
- push(@ccopt, $a);
- $verbose = 1;
- } elsif ( $a eq '-save-temps' ) {
- push(@ccopt, $a);
- $save_temps = 1;
- } elsif ( $a =~ '^-([cSE])$' ) {
- push(@ccopt, $a);
- $operation = $1;
- } elsif ( $a eq '-shared' ) {
- $shared = 1;
- } elsif ( $a eq '-static' ) {
- $shared = 0;
- } elsif ( $a eq '-s' ) {
- $strip = 1;
- } elsif ( $a eq '-o' ) {
- $output = shift(@ARGV);
- } elsif ( $a eq '-x' ) {
- $lang = shift(@ARGV);
- } elsif ( $a eq '-nostdinc' ) {
- push(@ccopt, $a);
- @includes = ();
- } elsif ( $a =~ /^-([lL])(.*)$/ ) {
- # Libraries
- push(@libs, $a);
- push(@libs, shift(@ARGV)) if ( $2 eq '' );
- } else {
- die "$0: unknown option: $a\n";
- }
-}
-
-if ( $debugging ) {
- @ccopt = (@REQFLAGS, @includes, @goptopt, @ccopt);
-} else {
- @ccopt = (@REQFLAGS, @includes, @optopt, @ccopt);
-}
-
-if ( $operation ne '' ) {
- # Just run gcc with the appropriate options
- @outopt = ('-o', $output) if ( defined($output) );
- $rv = mysystem($CC, @ccopt, @outopt, files_with_lang(\@files, \%flang));
-} else {
- if ( scalar(@files) == 0 ) {
- die "$0: No input files!\n";
- }
-
- @outopt = ('-o', $output || 'a.out');
-
- @objs = ();
- @rmobjs = ();
-
- foreach $f ( @files ) {
- if ( $flang{$f} eq 'obj' ) {
- push(@objs, $f);
- } else {
- $fo = $f;
- $fo =~ s/\.[^\/.]+$/\.o/;
-
- die if ( $f eq $fo ); # safety check
-
- push(@objs, $fo);
- push(@rmobjs, $fo) unless ( $save_temps );
-
- $rv = mysystem($CC, @ccopt, '-c', '-o', $fo, '-x', $flang{$f}, $f);
-
- if ( $rv ) {
- unlink(@rmobjs);
- exit syserr($rv);
- }
- }
- }
-
- # Get the libgcc pathname for the *current* gcc
- open(LIBGCC, '-|', $CC, @ccopt, '-print-libgcc-file-name')
- or die "$0: cannot get libgcc filename\n";
- $libgcc = <LIBGCC>;
- chomp $libgcc;
- close(LIBGCC);
-
- if ( $shared ) {
- $rv = mysystem($LD, @LDFLAGS, @sharedopt, @ldopt, @outopt, @objs, @libs, @stdlibpath, @sharedlib, $libgcc);
- } else {
- $rv = mysystem($LD, @LDFLAGS, @staticopt, @ldopt, @outopt, @objs, @libs, @stdlibpath, @staticlib, $libgcc);
- }
-
- unlink(@rmobjs);
-
- if ( $strip && !$rv ) {
- $rv = mysystem($STRIP, @STRIPFLAGS, $output);
- }
-}
-
-exit syserr($rv);
diff --git a/klibc/klibc.spec.in b/klibc/klibc.spec.in
deleted file mode 100644
index eef5dbf9d3..0000000000
--- a/klibc/klibc.spec.in
+++ /dev/null
@@ -1,126 +0,0 @@
-Summary: A minimal libc subset for use with initramfs.
-Name: klibc
-Version: @@VERSION@@
-Release: 1
-License: BSD/GPL
-Group: Development/Libraries
-URL: http://www.zytor.com/mailman/listinfo/klibc
-Source: http://www.kernel.org/pub/linux/libs/klibc-%{version}.tar.gz
-BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
-BuildRequires: kernel >= 2.6.0, kernel-devel
-Packager: H. Peter Anvin <hpa@zytor.com>
-Prefix: /usr
-Vendor: Starving Linux Artists
-
-%define klibcdir %{_prefix}/lib/klibc
-%define libdocdir %{_docdir}/%{name}-%{version}-%{release}
-%define bindocdir %{_docdir}/%{name}-utils-%{version}-%{release}
-
-%description
-%{name} is intended to be a minimalistic libc subset for use with
-initramfs. It is deliberately written for small size, minimal
-entanglement, and portability, not speed.
-
-%package devel
-Summary: Libraries and tools needed to compile applications against klibc.
-Group: Development/Libraries
-Requires: klibc = %{version}-%{release}
-
-%description devel
-This package contains the link libraries, header files, and gcc
-wrapper scripts needed to compile applications against klibc.
-
-%package utils
-Summary: Small utilities built with klibc.
-Group: Utilities/System
-Requires: klibc = %{version}-%{release}
-
-%description utils
-This package contains a collection of programs that are linked against
-klibc. These duplicate some of the functionality of a regular Linux
-toolset, but are typically much smaller than their full-function
-counterparts. They are intended for inclusion in initramfs images and
-embedded systems.
-
-%prep
-%setup -q
-cp -dRs /lib/modules/`uname -r`/build/ ./linux
-# Shouldn't need this when getting the build tree from /lib/modules
-# make -C linux defconfig ARCH=%{_target_cpu}
-# make -C linux prepare ARCH=%{_target_cpu}
-# Deal with braindamage in RedHat's kernel-source RPM
-rm -f linux/include/linux/config.h
-cat <<EOF > linux/include/linux/config.h
-#ifndef _LINUX_CONFIG_H
-#define _LINUX_CONFIG_H
-
-#include <linux/autoconf.h>
-
-#endif
-EOF
-mkdir -p %{buildroot}
-
-%build
-make ARCH=%{_target_cpu} prefix=%{_prefix} bindir=%{_bindir} \
- INSTALLDIR=%{klibcdir} mandir=%{_mandir} INSTALLROOT=%{buildroot}
-
-%install
-rm -rf %{buildroot}
-make ARCH=%{_target_cpu} prefix=%{_prefix} bindir=%{_bindir} \
- INSTALLDIR=%{klibcdir} mandir=%{_mandir} INSTALLROOT=%{buildroot} \
- install
-
-# Make the .so file in /lib a hardlink (they will be expanded as two
-# files automatically if it crosses filesystems when extracted.)
-ln -f %{buildroot}%{klibcdir}/lib/klibc-*.so %{buildroot}/lib
-
-# Install the docs
-mkdir -p %{buildroot}%{bindocdir} %{buildroot}%{libdocdir}
-install -m 444 README %{buildroot}%{libdocdir}
-install -m 444 klibc/README %{buildroot}%{libdocdir}/README.klibc
-install -m 444 klibc/arch/README %{buildroot}%{libdocdir}/README.klibc.arch
-
-install -m 444 gzip/COPYING %{buildroot}%{bindocdir}/COPYING.gzip
-install -m 444 gzip/README %{buildroot}%{bindocdir}/README.gzip
-install -m 444 ipconfig/README %{buildroot}%{bindocdir}/README.ipconfig
-install -m 444 kinit/README %{buildroot}%{bindocdir}/README.kinit
-
-%clean
-rm -rf $RPM_BUILD_ROOT
-
-#
-# Note: libc.so and interp.o are technically -devel files, but
-# put them in this package until we can make really, really sure
-# the dependency system can avoid confusion. (In fact, it would be
-# good to eventually get them out of here, so that multiple runtimes
-# can be installed should it be necessary.)
-#
-%files
-%defattr(-,root,root,-)
-/lib/klibc-*.so
-%{klibcdir}/lib/*.so
-%{klibcdir}/lib/interp.o
-
-%files devel
-%defattr(-,root,root,-)
-%{klibcdir}/include
-%{klibcdir}/lib/*.a
-%{klibcdir}/lib/crt0.o
-%{_bindir}/klcc
-%doc %{_mandir}/man1/*
-%doc %{libdocdir}/*
-
-%files utils
-%defattr(-,root,root,-)
-%{klibcdir}/bin
-%doc %{bindocdir}/*
-
-%changelog
-* Tue Mar 1 2005 H. Peter Anvin <hpa@zytor.com>
-- New "make install" scheme, klcc
-
-* Tue Jul 6 2004 H. Peter Anvin <hpa@zytor.com>
-- Update to use kernel-source RPM for the kernel symlink.
-
-* Sat Nov 29 2003 Bryan O'Sullivan <bos@serpentine.com> -
-- Initial build.
diff --git a/klibc/klibc/CAVEATS b/klibc/klibc/CAVEATS
deleted file mode 100644
index 5bc11e4179..0000000000
--- a/klibc/klibc/CAVEATS
+++ /dev/null
@@ -1,61 +0,0 @@
- -------------------------------------------------
- Please note the following caveats to using klibc:
- -------------------------------------------------
-
-optimization:
--------------
-
-Compiling with -O0 is not supported. It may or may not work; please
-use -O1 if you want to do maximize debuggability.
-
-Compiling with -O0 is more likely to work on gcc 3.
-
-
-setjmp()/longjmp():
--------------------
-
-setjmp() and longjmp() *do not* save signal state. sigsetjmp() and
-siglongjmp() *do* save the signal mask -- regardless of the value of
-the extra argument.
-
-The standards actually state that if you pass longjmp() a final value
-of zero the library should change that to a 1! Presumably the reason
-is so people who write broken code can get away with writing
-longjmp(buf); or something equally bad. If you pass longjmp() a final
-value of 0 you get what you deserve -- setjmp() will happily return 0.
-
-
-stdio:
-------
-
-Only a small subset of the stdio functions are implemented. Those
-that are implemented do not buffer, although they *do* trap EINTR or
-short read/writes and iterate.
-
-_fread() and _fwrite(), which take only one size argument (like
-read/write), but do handle EINTR/short return are also available.
-
-
-namespaces:
------------
-
-klibc frequently includes headers in other headers in a way that
-exposes more symbols than POSIX says they should. "Live with it."
-
-
-theading:
----------
-
-klibc is not thread-safe. Consequently, clone() or any of the
-pthreads functions are not included.
-
-
-bsd_signal vs sysv_signal:
---------------------------
-
-There is no signal() call, because you never know if you want
-Linux/SysV semantics (SA_RESETHAND) or GNU/BSD semantics (SA_RESTART).
-The best, in *any* circumstances, is to never use signal() and instead
-use sigaction(), but in order to simplify porting you can use either
-sysv_signal() or bsd_signal(), depending on what you actually want.
-
diff --git a/klibc/klibc/Kbuild b/klibc/klibc/Kbuild
deleted file mode 100644
index be239a6647..0000000000
--- a/klibc/klibc/Kbuild
+++ /dev/null
@@ -1,149 +0,0 @@
-#
-# Kbuild file for klibc
-#
-
-libc-y := vsnprintf.o snprintf.o vsprintf.o sprintf.o \
- asprintf.o vasprintf.o \
- vsscanf.o sscanf.o ctypes.o \
- strntoumax.o strntoimax.o \
- atoi.o atol.o atoll.o \
- strtol.o strtoll.o strtoul.o strtoull.o \
- strtoimax.o strtoumax.o \
- globals.o exitc.o atexit.o onexit.o \
- execl.o execle.o execv.o execvpe.o execvp.o execlp.o execlpe.o \
- fork.o wait.o wait3.o waitpid.o system.o setpgrp.o getpgrp.o \
- daemon.o \
- printf.o vprintf.o fprintf.o vfprintf.o perror.o \
- statfs.o fstatfs.o umount.o \
- open.o fopen.o fread.o fread2.o fgetc.o fgets.o \
- fwrite.o fwrite2.o fputc.o fputs.o puts.o putchar.o \
- sleep.o usleep.o strtotimespec.o strtotimeval.o \
- raise.o abort.o assert.o alarm.o pause.o \
- __signal.o sysv_signal.o bsd_signal.o siglist.o siglongjmp.o \
- sigaction.o sigpending.o sigprocmask.o sigsuspend.o \
- brk.o sbrk.o malloc.o realloc.o calloc.o mmap.o \
- memcpy.o memcmp.o memset.o memccpy.o memmem.o memswap.o \
- memmove.o memchr.o memrchr.o \
- strcasecmp.o strncasecmp.o strndup.o strerror.o \
- strcat.o strchr.o strcmp.o strcpy.o strdup.o strlen.o strnlen.o \
- strncat.o strlcpy.o strlcat.o \
- strstr.o strncmp.o strncpy.o strrchr.o \
- strxspn.o strspn.o strcspn.o strpbrk.o strsep.o strtok.o \
- gethostname.o getdomainname.o getcwd.o \
- seteuid.o setegid.o \
- getenv.o setenv.o putenv.o __put_env.o unsetenv.o \
- getopt.o readdir.o \
- syslog.o closelog.o pty.o getpt.o isatty.o reboot.o \
- time.o utime.o llseek.o nice.o getpriority.o \
- qsort.o \
- lrand48.o jrand48.o mrand48.o nrand48.o srand48.o seed48.o \
- inet/inet_ntoa.o inet/inet_aton.o inet/inet_addr.o \
- inet/inet_ntop.o inet/inet_pton.o inet/bindresvport.o \
- send.o recv.o
-
-libc-$(CONFIG_KLIBC_ERRLIST) += errlist.o
-
-libc-$(CONFIG_KLIBC_ZLIB) += \
- zlib/adler32.o zlib/compress.o zlib/crc32.o zlib/gzio.o \
- zlib/uncompr.o zlib/deflate.o zlib/trees.o zlib/zutil.o \
- zlib/inflate.o zlib/infback.o zlib/inftrees.o zlib/inffast.o
-
-#####
-# Add any architecture-specific rules
-include $(obj)/arch/$(ARCH)/Makefile.inc
-
-#####
-# Shared definitions
-LIB := libc.a
-SOLIB := libc.so
-SOHASH := klibc.so
-CRT0 := arch/$(ARCH)/crt0.o
-INTERP_O := interp.o
-
-always := $(CRT0) $(LIB) $(SOLIB) $(SOHASH) $(INTERP_O)
-LIB := $(call objectify,$(LIB))
-SOLIB := $(call objectify,$(SOLIB))
-SOHASH := $(call objectify,$(SOHASH))
-CRT0 := $(call objectify,$(CRT0))
-INTERP_O := $(call objectify,$(INTERP_O))
-
-targets := arch/$(ARCH)/crt0.o
-targets += $(libc-y) $(ARCHOBJS)
-
-# Generate syscall stubs
-subdir-y += syscalls
-# Generate socket calls stubs
-subdir-y += socketcalls
-
-# Tell make to descend before building libs
-$(obj)/syscalls/syscalls.o: $(obj)/syscalls
-$(obj)/socketcalls/socketcalls.o: $(obj)/socketcalls
-
-#####
-# Readable errormessages extracted from src..
-targets += errlist.c
-quiet_cmd_errlist = GEN $@
- cmd_errlist = $(PERL) $< $(LINUXINCLUDE) -errlist > $@ || rm -f $@
-
-$(obj)/errlist.c: $(srctree)/$(src)/makeerrlist.pl
- $(call cmd,errlist)
-
-# full list of dependencies for klibc
-libc-deps = $(call objectify, $(libc-y) $(ARCHOBJS)) \
- $(call objectify, syscalls/syscalls.o socketcalls/socketcalls.o)
-
-######
-# Build static library: libc.a
-targets += libc.a __static_init.o
-quiet_cmd_libc = USERAR $@
- cmd_libc = rm -f $@; \
- $(USERAR) cq $@ $(filter-out FORCE,$^); \
- $(USERRANLIB) $@
-
-$(LIB): $(call objectify,__static_init.o) $(libc-deps) FORCE
- $(call if_changed,libc)
-
-######
-# Build shared library
-targets += libc.so __shared_init.o
-
-quiet_cmd_libcso = LD $@
- cmd_libcso = $(USERLD) $(USERLDFLAGS) $(USERSHAREDFLAGS) \
- -o $@ $(filter-out FORCE,$^) $(USERLIBGCC)
-
-$(SOLIB): $(CRT0) $(call objectify,__shared_init.o) $(libc-deps) FORCE
- $(call if_changed,libcso)
-
-
-#####
-# Build sha1 hash values
-targets += klibc.so libc.so.hash
-hostprogs-y := sha1hash
-
-quiet_cmd_solibhash = HASH $@
- cmd_solibhash = $(USERNM) $< | egrep '^[0-9a-fA-F]+ [ADRTW] ' | \
- sort | $(obj)/sha1hash > $@
-$(SOLIB).hash: $(SOLIB) $(obj)/sha1hash FORCE
- $(call if_changed,solibhash)
-
-quiet_cmd_sohash = GEN $@
- cmd_sohash = cat $< > $@; \
- $(USERSTRIP) $(USERSTRIPFLAGS) $@; \
- rm -f $(obj)/klibc-??????????????????????.so; \
- ln -f $@ $(obj)/klibc-`cat $(SOLIB).hash`.so
-$(SOHASH): $(SOLIB) $(SOLIB).hash
- $(call cmd,sohash)
-
-
-#####
-# build interp.o
-targets += interp.o
-
-quiet_cmd_interp = BUILD $@
- cmd_interp = $(USERCC) $(usercflags) -D__ASSEMBLY__ \
- -DLIBDIR=\"$(SHLIBDIR)\" \
- -DSOHASH=\"`cat $(SOLIB).hash`\" \
- -c -o $@ $<
-
-$(INTERP_O): $(obj)/interp.S $(SOLIB).hash
- $(call if_changed,interp)
diff --git a/klibc/klibc/LICENSE b/klibc/klibc/LICENSE
deleted file mode 100644
index b512ff96bc..0000000000
--- a/klibc/klibc/LICENSE
+++ /dev/null
@@ -1,73 +0,0 @@
-This license applies to all files in directory and its subdirectories,
-unless otherwise noted in individual files.
-
-
-Some files are derived from files derived from the include/ directory
-of the Linux kernel, and are licensed under the terms of the GNU
-General Public License, version 2, as released by the Free Software
-Foundation, Inc.; incorporated herein by reference.
-
- -----
-
-Some files are derived from files copyrighted by the Regents of The
-University of California, and are available under the following
-license:
-
-Note: The advertising clause in the license appearing on BSD Unix
-files was officially rescinded by the Director of the Office of
-Technology Licensing of the University of California on July 22
-1999. He states that clause 3 is "hereby deleted in its entirety."
-
- * Copyright (c)
- * 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.
-
- -----
-
-For all remaining files, the following license applies:
-
- * 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:
- *
- * Any copyright notice(s) 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.
diff --git a/klibc/klibc/MCONFIG b/klibc/klibc/MCONFIG
deleted file mode 100644
index 24af09d8e0..0000000000
--- a/klibc/klibc/MCONFIG
+++ /dev/null
@@ -1,20 +0,0 @@
-# -*- makefile -*-
-#
-# Makefile configuration, without explicit rules
-#
-
-SRCROOT = ..
-include ../MCONFIG
-include ../MRULES
-
-WARNFLAGS = -W -Wall -Wpointer-arith -Wwrite-strings -Wstrict-prototypes -Winline
-
-ifeq ($(ERRLIST),1)
-REQFLAGS += -DWITH_ERRLIST
-endif
-
-CFLAGS = -Wp,-MT,$@,-MD,$(dir $@).$(notdir $@).d $(OPTFLAGS) $(REQFLAGS) $(WARNFLAGS)
-INCLUDE += -I./zlib
-CFLAGS += -DDYNAMIC_CRC_TABLE
-
-SOFLAGS = -fPIC
diff --git a/klibc/klibc/Makefile b/klibc/klibc/Makefile
deleted file mode 100644
index dff813fc59..0000000000
--- a/klibc/klibc/Makefile
+++ /dev/null
@@ -1,192 +0,0 @@
-#
-# Makefile
-#
-# Main makefile
-#
-
-# Include configuration rules
-include MCONFIG
-
-INCLUDE += -I./zlib
-
-TESTS = $(patsubst %.c,%,$(wildcard tests/*.c)) \
- $(patsubst %.c,%.shared,$(wildcard tests/*.c))
-LIBOBJS = vsnprintf.o snprintf.o vsprintf.o sprintf.o \
- asprintf.o vasprintf.o \
- vsscanf.o sscanf.o ctypes.o \
- strntoumax.o strntoimax.o \
- atoi.o atol.o atoll.o \
- strtol.o strtoll.o strtoul.o strtoull.o \
- strtoimax.o strtoumax.o \
- globals.o exitc.o atexit.o onexit.o \
- execl.o execle.o execv.o execvpe.o execvp.o execlp.o execlpe.o \
- fork.o wait.o wait3.o waitpid.o system.o setpgrp.o getpgrp.o \
- daemon.o \
- printf.o vprintf.o fprintf.o vfprintf.o perror.o \
- statfs.o fstatfs.o umount.o \
- open.o fopen.o fread.o fread2.o fgetc.o fgets.o \
- fwrite.o fwrite2.o fputc.o fputs.o puts.o putchar.o \
- sleep.o usleep.o strtotimespec.o strtotimeval.o \
- raise.o abort.o assert.o alarm.o pause.o \
- __signal.o sysv_signal.o bsd_signal.o siglist.o siglongjmp.o \
- sigaction.o sigpending.o sigprocmask.o sigsuspend.o \
- brk.o sbrk.o malloc.o realloc.o calloc.o mmap.o \
- memcpy.o memcmp.o memset.o memccpy.o memmem.o memswap.o \
- memmove.o memchr.o memrchr.o \
- strcasecmp.o strncasecmp.o strndup.o strerror.o \
- strcat.o strchr.o strcmp.o strcpy.o strdup.o strlen.o strnlen.o \
- strncat.o strlcpy.o strlcat.o \
- strstr.o strncmp.o strncpy.o strrchr.o \
- strxspn.o strspn.o strcspn.o strpbrk.o strsep.o strtok.o \
- gethostname.o getdomainname.o getcwd.o \
- seteuid.o setegid.o \
- getenv.o setenv.o putenv.o __put_env.o unsetenv.o \
- getopt.o readdir.o \
- syslog.o closelog.o pty.o getpt.o isatty.o reboot.o \
- time.o utime.o llseek.o nice.o getpriority.o \
- qsort.o \
- lrand48.o jrand48.o mrand48.o nrand48.o srand48.o seed48.o \
- inet/inet_ntoa.o inet/inet_aton.o inet/inet_addr.o \
- inet/inet_ntop.o inet/inet_pton.o inet/bindresvport.o \
- send.o recv.o
-
-ifeq ($(ERRLIST),1)
-LIBOBJS += errlist.o
-endif
-
-ifeq ($(ZLIB),1)
-LIBOBJS += zlib/adler32.o zlib/compress.o zlib/crc32.o zlib/gzio.o \
- zlib/uncompr.o zlib/deflate.o zlib/trees.o zlib/zutil.o \
- zlib/inflate.o zlib/infback.o zlib/inftrees.o zlib/inffast.o
-endif
-
-SOLIB = libc.so
-SOHASH = klibc.so
-
-CRT0 = crt0.o
-LIB = libc.a
-
-INTERP_O = interp.o
-
-all: tests $(CRT0) $(LIB) $(SOLIB) $(SOHASH) $(INTERP_O)
-
-# Add any architecture-specific rules
-include arch/$(ARCH)/Makefile.inc
-EMAIN ?= -e main
-
-tests: $(TESTS)
-
-tests/%.o : tests/%.c
- $(CC) $(CFLAGS) -c -o $@ $<
-
-# This particular file uses a bunch of formats gcc don't know of, in order
-# to test the full range of our vsnprintf() function. This outputs a bunch
-# of useless warnings unless we tell it not to.
-tests/testvsnp.o : tests/testvsnp.c
- $(CC) $(CFLAGS) -Wno-format -c -o $@ $<
-
-tests/% : tests/%.o $(LIB) $(CRT0)
- $(LD) $(LDFLAGS) -o $@ $(CRT0) $< $(LIB) $(LIBGCC)
- cp $@ $@.stripped
- $(STRIPCMD) $@.stripped
-
-tests/%.shared : tests/%.o interp.o $(SOLIB)
- $(LD) $(LDFLAGS) -o $@ $(EMAIN) interp.o tests/$*.o -R $(SOLIB) $(LIBGCC)
- cp $@ $@.stripped
- $(STRIPCMD) $@.stripped
-
-$(LIB): __static_init.o $(LIBOBJS) $(ARCHOBJS) syscalls/static.obj socketcalls/static.obj
- rm -f $(LIB)
- $(AR) cq $(LIB) __static_init.o $(LIBOBJS) $(ARCHOBJS) \
- $(wildcard syscalls/*.o) $(wildcard socketcalls/*.o)
- $(RANLIB) $(LIB)
-
-$(SOLIB): $(CRT0) __shared_init.o $(LIBOBJS) $(ARCHOBJS) syscalls/static.obj socketcalls/static.obj
- $(LD) $(LDFLAGS) $(SHAREDFLAGS) -o $@ \
- $(CRT0) __shared_init.o $(LIBOBJS) $(ARCHOBJS) \
- $(wildcard syscalls/*.o) $(wildcard socketcalls/*.o) \
- $(LIBGCC)
-
-sha1hash: sha1hash.c
- $(HOST_CC) $(HOST_CFLAGS) $(HOST_LDFLAGS) -o $@ $<
-
-$(SOLIB).hash: $(SOLIB) sha1hash
- $(NM) $(SOLIB) | \
- egrep '^[0-9a-fA-F]+ [ADRTW] ' | sort | ./sha1hash > $@
-
-$(SOHASH): $(SOLIB) $(SOLIB).hash
- cp -f $(SOLIB) $@
- $(STRIPCMD) $@
- rm -f klibc-??????????????????????.so
- ln -f $@ klibc-`cat $(SOLIB).hash`.so
-
-$(INTERP_O): interp.S $(SOLIB).hash
- $(CC) $(CFLAGS) -D__ASSEMBLY__ -DLIBDIR=\"$(SHLIBDIR)\" \
- -DSOHASH=\"`cat $(SOLIB).hash`\" \
- -c -o $@ $<
-
-crt0.o: arch/$(ARCH)/crt0.o
- cp arch/$(ARCH)/crt0.o .
-
-errlist.c:
- $(PERL) makeerrlist.pl -q $(INCLUDE) -errlist > $@ || rm -f $@
-
-# We pass -ansi to keep cpp from define e.g. "i386" as well as "__i386__"
-SYSCALLS.i: SYSCALLS.def
- $(CC) $(CFLAGS) -D__ASSEMBLY__ -ansi -x assembler-with-cpp -E -o $@ $<
-
-syscalls.nrs: ../include/sys/syscall.h
- $(CC) $(CFLAGS) -Wp,-dM -x c -E -o $@ $<
-
-syscalls.dir: SYSCALLS.i syscalls.pl arch/$(ARCH)/sysstub.ph syscommon.h syscalls.nrs
- rm -f syscalls/*.[Ssco] syscalls/*.obj
- mkdir -p syscalls
- $(PERL) syscalls.pl SYSCALLS.i arch/$(ARCH)/sysstub.ph $(ARCH) \
- $(BITSIZE) syscalls.nrs \
- syscalls ../include/klibc/havesyscall.h
- touch $@
-
-../include/klibc/havesyscall.h: syscalls.dir
- : Generated by side effect
-
-socketcalls.dir: SOCKETCALLS.def socketcalls.pl socketcommon.h
- rm -f socketcalls/*.[Ssco] socketcalls/*.obj
- mkdir -p socketcalls
- $(PERL) socketcalls.pl SOCKETCALLS.def $(ARCH) socketcalls
- touch $@
-
-%/static.obj: %.dir
- $(MAKE) objects-$(basename $(notdir $@)) DIR=$*/
-
-STATIC = $(addsuffix .o,$(basename $(wildcard $(DIR)*.[cS])))
-
-objects-static: $(STATIC)
- touch $(DIR)static.obj
-
-clean: archclean
- find . -type f -a \( -name \*.[isoa] -o -name \*.l[iso] \) -print0 | xargs -0rt rm -f
- rm -f *.a *.so *.hash *.syms *.stripped
- rm -f $(TESTS) tests/*.stripped
- rm -f syscalls/*.[Ssco] syscalls/*.obj syscalls.dir
- rm -f socketcalls/*.[Ssco] socketcalls/*.obj socketcalls.dir
- rm -f sha1hash errlist.c
-
-spotless: clean
- rm -f ../include/klibc/havesyscall.h syscalls.nrs
- find . \( -name \*~ -o -name '.*.d' \) -not -type d -print0 | \
- xargs -0rt rm -f
-
-bitsize:
- @echo $(BITSIZE)
-
-install: all
- $(INSTALL_DATA) $(LIB) $(SOLIB) $(CRT0) $(INTERP_O) \
- $(INSTALLROOT)$(INSTALLDIR)/$(CROSS)lib
- $(INSTALL_EXEC) klibc-`cat $(SOLIB).hash`.so \
- $(INSTALLROOT)$(INSTALLDIR)/$(CROSS)lib
- $(INSTALL_EXEC) klibc-`cat $(SOLIB).hash`.so \
- $(INSTALLROOT)/$(SHLIBDIR)
-
-ifneq ($(wildcard $(DIR).*.d),)
-include $(wildcard $(DIR).*.d)
-endif
diff --git a/klibc/klibc/README b/klibc/klibc/README
deleted file mode 100644
index 3a53a8809f..0000000000
--- a/klibc/klibc/README
+++ /dev/null
@@ -1,81 +0,0 @@
-This is klibc, what is intended to be a minimalistic libc subset for
-use with initramfs. It is deliberately written for small size,
-minimal entaglement, and portability, not speed. It is definitely a
-work in progress, and a lot of things are still missing.
-
-
-The build procedure is not very polished yet, but it should work like
-this:
-
-a) In the source root directory (the directory above the one in which
- this file is found) create a symlink called "linux" pointing to a
- reasonably recent Linux kernel tree (2.4 or 2.6 should be OK.)
- This tree must have the include/asm symlink set up for the
- architecture you're compiling for, and include/linux/autoconf.h
- must exist. The easiest way to make sure of all of these is to do
- a "make config" or any of its variants on the kernel tree is
- question, followed by a "make dep" (2.4) or "make prepare" (2.6).
-
-b) If you're cross-compiling, change ARCH in the main MCONFIG file to
- the appropriate architecture, and set CROSS to your toolchain
- prefix.
-
- IMPORTANT: if you're on a 64-bit machine with a 32-bit userland
- (ia64, mips64, ppc64 sparc64, s390x or x86_64), and you want to
- build the 32-bit version: you need to set ARCH to the 32-bit
- architecture as well as set up the linux/include/asm symlink to
- point to the 32-bit architecture. Building the 32-bit architecture
- usually (but not always) produces smaller binaries, and is likely
- to be better tested.
-
- If you are on ARM, and want to build a thumb version of the library
- (this is supported), change OPTFLAGS in arch/arm/MCONFIG to build
- thumb code.
-
- The following is the last known status of various architectures:
-
- alpha: Working static, shared untested
- arm-thumb: Untested
- arm26: Not yet ported
- arm: Working
- cris: Working
- h8300: Not yet ported
- i386: Working
- ia64: Working
- m32r: Untested
- m68k: Not yet ported
- mips64: Not yet ported
- mips: Working
- parisc: Untested
- ppc64: Working
- ppc: Working
- s390: Working static, shared untested
- s390x: Working
- sh: Untested
- sparc64: Untested
- sparc: Working
- v850: Not yet ported
- x86-64: Working
-
- Shared library support requires recent binutils on many
- architectures.
-
- "Need sysstub.ph" means the architectural changes first implemented
- in klibc-0.117 has not yet been implemented; klibc-0.116 did,
- however, work. "Not yet ported" means no porting work has been
- done on this architecture.
-
- Note that even the "working" ones likely have bugs. Please report
- them if you run into them.
-
-c) Type "make" and pray...
-
-d) Try the test programs in the tests/ directory. They should run...
-
-Contact the klibc mailing list:
-
- http://www.zytor.com/mailman/listinfo/klibc
-
-... for more info.
-
- -hpa
diff --git a/klibc/klibc/SOCKETCALLS.def b/klibc/klibc/SOCKETCALLS.def
deleted file mode 100644
index e70b3fc16e..0000000000
--- a/klibc/klibc/SOCKETCALLS.def
+++ /dev/null
@@ -1,21 +0,0 @@
-; -*- fundamental -*-
-;
-; These are calls that are invoked via the socketcall mechanism
-; Note that on most architectures this is simply #included into
-; SYSCALLS.def.
-;
-<?> int socket(int, int, int)
-<?> int bind(int, struct sockaddr *, int)
-<?> int connect(int, struct sockaddr *, socklen_t)
-<?> int listen(int, int)
-<?> int accept(int, struct sockaddr *, socklen_t *)
-<?> int getsockname(int, struct sockaddr *, socklen_t *)
-<?> int getpeername(int, struct sockaddr *, socklen_t *)
-<?> int socketpair(int, int, int, int *)
-<?> int sendto(int, const void *, size_t, int, const struct sockaddr *, socklen_t)
-<?> int recvfrom(int, void *, size_t, unsigned int, struct sockaddr *, socklen_t *)
-<?> int shutdown(int, int)
-<?> int setsockopt(int, int, int, const void *, socklen_t)
-<?> int getsockopt(int, int, int, void *, socklen_t *)
-<?> int sendmsg(int, const struct msghdr *, unsigned int)
-<?> int recvmsg(int, struct msghdr *, unsigned int)
diff --git a/klibc/klibc/SYSCALLS.def b/klibc/klibc/SYSCALLS.def
deleted file mode 100644
index b78919b134..0000000000
--- a/klibc/klibc/SYSCALLS.def
+++ /dev/null
@@ -1,231 +0,0 @@
-; -*- fundamental -*-
-;
-; This is a list of system calls we invoke "directly". These
-; are generated into syscall stubs in their own files, so the
-; linker can do its job properly.
-;
-; The full description of a line is:
-; [<[?][!]arch,...>] type [sysname,...][@systype][::funcname](args)
-;
-; ? means only instantiate this system call if present in asm/unistd.h
-;
-
-#include <asm/unistd.h>
-#include <bitsize.h>
-
-;
-; Process-related syscalls
-;
-<!i386,x86_64> void _exit,exit::_exit(int)
-<?!ia64> pid_t clone::__clone(unsigned long, void *)
-<?ia64> pid_t clone::__clone2(unsigned long, void *, void *)
-<?!sparc> pid_t fork()
-<sparc> pid_t fork@forkish()
-<!mips,mips64,sparc,ia64> pid_t vfork()
-<sparc> pid_t vfork@forkish()
-<!alpha> pid_t getpid()
-<alpha> pid_t getxpid@dual0::getpid()
-int setpgid(pid_t, pid_t)
-pid_t getpgid(pid_t)
-<!alpha> pid_t getppid()
-<alpha> pid_t getxpid@dual1::getppid()
-pid_t setsid()
-pid_t getsid(pid_t)
-pid_t wait4(pid_t, int *, int, struct rusage *)
-int execve(const char *, char * const *, char * const *)
-<?> int nice(int)
-<alpha,ia64> int getpriority(int, int)
-<!alpha,ia64> int getpriority::__getpriority(int, int)
-int setpriority(int, int, int)
-int sched_setscheduler(pid_t, int, const struct sched_param *)
-int sched_yield()
-
-;
-; User and group IDs
-;
-int setuid32,setuid::setuid(uid_t)
-int setgid32,setgid::setgid(gid_t)
-<!alpha> uid_t getuid32,getuid::getuid()
-<alpha> uid_t getxuid@dual0::getuid()
-<!alpha> gid_t getgid32,getgid::getgid()
-<alpha> gid_t getxgid@dual0::getgid()
-<!alpha> uid_t geteuid32,geteuid::geteuid()
-<alpha> uid_t getxuid@dual1::geteuid()
-<!alpha> gid_t getegid32,getegid::getegid()
-<alpha> gid_t getxgid@dual1::getegid()
-int getgroups32,getgroups::getgroups(int, gid_t *)
-int setgroups32,setgroups::setgroups(size_t, const gid_t *)
-int setreuid32,setreuid::setreuid(uid_t, uid_t)
-int setregid32,setregid::setregid(gid_t, gid_t)
-int setfsuid32,setfsuid::setfsuid(uid_t)
-int setfsgid32,setfsgid::setfsgid(gid_t)
-int setresuid32,setresuid::setresuid(int, uid_t, uid, uid_t)
-
-;
-; Filesystem-related system calls
-;
-int mount(const char *, const char *, const char *, unsigned long, const void *)
-<!alpha,ia64> int umount2(const char *, int)
-<alpha,ia64> int umount::umount2(const char *, int)
-<?> int pivot_root(const char *, const char *)
-int sync()
-#ifdef __NR_statfs64
-int statfs64::__statfs64(const char *, size_t, struct statfs *)
-#else
-int statfs(const char *, struct statfs *)
-#endif
-#ifdef __NR_fstatfs64
-int fstatfs64::__fstatfs64(int, size_t, struct statfs *)
-#else
-int fstatfs(int, struct statfs *)
-#endif
-int swapon(const char *, int)
-int swapoff(const char *)
-
-;
-; Inode-related system calls
-;
-int access(const char *, int)
-int link(const char *, const char *)
-int unlink(const char *)
-int chdir(const char *)
-int fchdir(int)
-int rename(const char *, const char *)
-int mknod(const char *, mode_t, dev_t)
-int chmod(const char *, mode_t)
-int fchmod(int, mode_t)
-int mkdir(const char *, mode_t)
-int rmdir(const char *)
-<!alpha,ia64,mips,mips64> int pipe(int *)
-mode_t umask(mode_t)
-int chroot(const char *)
-int symlink(const char *, const char *)
-int readlink(const char *, char *, size_t)
-<!ppc64> int stat64,stat::stat(const char *, struct stat *)
-<!ppc64> int lstat64,lstat::lstat(const char *, struct stat *)
-<!ppc64> int fstat64,fstat::fstat(int, struct stat *)
-<ppc64> int stat::stat(const char *, struct stat *)
-<ppc64> int lstat::lstat(const char *, struct stat *)
-<ppc64> int fstat::fstat(int, struct stat *)
-int getdents64,getdents::getdents(unsigned int, struct dirent *, unsigned int)
-int chown32,chown::chown(const char *, uid_t, gid_t)
-int fchown32,fchown::fchown(int, uid_t, gid_t)
-int lchown32,lchown::lchown(const char *, uid_t, gid_t)
-int getcwd::__getcwd(char *, size_t)
-<?> int utime(const char *, const struct utimbuf *)
-<?> int utimes(const char *, const struct timeval *)
-<?> int inotify_init(void)
-<?> int inotify_add_watch(int, const char *, __u32)
-<?> int inotify_rm_watch(int, __u32)
-
-;
-; I/O operations
-;
-<!i386,64> int open::__open(const char *, int, mode_t)
-<64> int open(const char *, int, mode_t)
-ssize_t read(int, void *, size_t)
-ssize_t write(int, const void *, size_t)
-int close(int)
-<64> off_t lseek(int, off_t, int)
-<32> int _llseek::__llseek(int, unsigned long, unsigned long, off_t *, int)
-int dup(int)
-int dup2(int, int)
-<i386> int fcntl64@varadic::fcntl(int, int, unsigned long)
-<ppc64> int fcntl(int, int, unsigned long)
-<!i386,ppc64> int fcntl64,fcntl::fcntl(int, int, unsigned long)
-int ioctl(int, int, void *)
-int flock(int, int)
-int _newselect,select::select(int, fd_set *, fd_set *, fd_set *, struct timeval *)
-int poll(struct pollfd *, nfds_t, long)
-int fsync(int)
-int fdatasync,fsync::fdatasync(int)
-int readv(int, const struct iovec *, int)
-int writev(int, const struct iovec *, int)
-int ftruncate64,ftruncate::ftruncate(int, off_t)
-ssize_t pread64,pread::pread(int, void *, size_t, off_t)
-ssize_t pwrite64,pwrite::pwrite(int, void *, size_t, off_t)
-
-;
-; Signal operations
-;
-; We really should get rid of the non-rt_* of these, but that takes
-; sanitizing <signal.h> for all architectures, sigh.
-#ifdef __NR_sigaction
-int sigaction::__sigaction(int, const struct sigaction *, struct sigaction *)
-#else
-int rt_sigaction::__rt_sigaction(int, const struct sigaction *, struct sigaction *, size_t)
-#endif
-#ifdef __NR_sigsuspend
-int sigsuspend(const sigset_t *)
-#else
-int rt_sigsuspend::__rt_sigsuspend(const sigset_t *, size_t)
-#endif
-#ifdef __NR_sigpending
-int sigpending(sigset_t *)
-#else
-int rt_sigpending::__rt_sigpending(sigset_t *, size_t)
-#endif
-#ifdef __NR_sigprocmask
-int sigprocmask(int, const sigset_t *, sigset_t *)
-#else
-int rt_sigprocmask::__rt_sigprocmask(int, const sigset_t *, sigset_t *, size_t)
-#endif
-int kill(pid_t, int)
-<?> unsigned int alarm(unsigned int)
-int getitimer(int, struct itimerval *)
-int setitimer(int, const struct itimerval *, struct itimerval *)
-
-;
-; Time-related system calls
-;
-<?> time_t time(time_t *)
-clock_t times(struct tms *)
-int gettimeofday(struct timeval *, struct timezone *)
-int settimeofday(const struct timeval *, const struct timezone *)
-int nanosleep(const struct timespec *, struct timespec *)
-<?> int pause()
-
-;
-; Memory
-;
-void * brk::__brk(void *)
-int munmap(void *, size_t)
-void * mremap(void *, size_t, size_t, unsigned long)
-int msync(const void *, size_t, int)
-int mprotect(const void *, size_t, int)
-#if (_BITSIZE == 32 && defined(__NR_mmap2)) || \
- (_BITSIZE == 64 && !defined(__NR_mmap))
-<!s390> void * mmap2::__mmap2(void *, size_t, int, int, int, long)
-#else
-<!s390x> void * mmap(void *, size_t, int, int, int, long)
-#endif
-int mlockall(int)
-int munlockall()
-int mlock(const void *, size_t)
-int munlock(const void *, size_t)
-
-;
-; System stuff
-;
-int uname(struct utsname *)
-int setdomainname(const char *, size_t)
-int sethostname(const char *, size_t)
-long init_module(void *, unsigned long, const char *)
-long delete_module(const char *, unsigned int)
-int reboot::__reboot(int, int, int, void *)
-int syslog::klogctl(int, char *, int)
-int sysinfo(struct sysinfo *)
-
-;
-; Low-level I/O (generally architecture-specific)
-;
-<i386,x86_64> int iopl(int)
-<i386,x86_64> int ioperm(unsigned long, unsigned long, int)
-<i386> int vm86(struct vm86_struct *)
-
-;
-; Most architectures have the socket interfaces using regular
-; system calls.
-;
-<?!i386> long socketcall::__socketcall(int, const unsigned long *)
-#include "SOCKETCALLS.def"
diff --git a/klibc/klibc/__put_env.c b/klibc/klibc/__put_env.c
deleted file mode 100644
index 7e55f2c43b..0000000000
--- a/klibc/klibc/__put_env.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * __put_env.c - common code for putenv() and setenv()
- */
-
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-/* Initialized to zero, meaning "not malloc'd" */
-static size_t __environ_size;
-
-/* str should be a duplicated version of the input string;
- len is the length of the key including the = sign */
-int __put_env(char *str, size_t len, int overwrite)
-{
- char **p, *q;
- char **newenv;
- size_t n;
-
- n = 1; /* Include space for final NULL */
- for ( p = environ ; (q = *p) ; p++ ) {
- n++;
- if ( !strncmp(q,str,len) ) {
- if ( !overwrite )
- free(str);
- else
- *p = str; /* Possible memory leak... */
- return 0;
- }
- }
-
- /* Need to extend the environment */
- if ( n < __environ_size ) {
- p[1] = NULL;
- *p = str;
- return 0;
- } else {
- if ( __environ_size ) {
- newenv = realloc(environ, (__environ_size << 1)*sizeof(char *));
- if ( !newenv )
- return -1;
-
- __environ_size <<= 1;
- } else {
- /* Make a reasonable guess how much more space we need */
- size_t newsize = n+32;
- newenv = malloc(newsize*sizeof(char *));
- if ( !newenv )
- return -1;
-
- memcpy(newenv, environ, n*sizeof(char *));
- __environ_size = newsize;
- }
- newenv[n-1] = str; /* Old NULL position */
- newenv[n] = NULL;
- environ = newenv;
- }
- return 0;
-}
diff --git a/klibc/klibc/__shared_init.c b/klibc/klibc/__shared_init.c
deleted file mode 100644
index 592a3db6f5..0000000000
--- a/klibc/klibc/__shared_init.c
+++ /dev/null
@@ -1,2 +0,0 @@
-#define SHARED 1
-#include "libc_init.c"
diff --git a/klibc/klibc/__signal.c b/klibc/klibc/__signal.c
deleted file mode 100644
index b5081d386b..0000000000
--- a/klibc/klibc/__signal.c
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * __signal.c
- */
-
-#include <signal.h>
-
-__sighandler_t __signal(int signum, __sighandler_t handler, int flags)
-{
- struct sigaction sa;
-
- sa.sa_handler = handler;
- sa.sa_flags = flags;
- sigemptyset(&sa.sa_mask);
-
- if ( sigaction(signum, &sa, &sa) ) {
- return (__sighandler_t)SIG_ERR;
- } else {
- return (__sighandler_t)sa.sa_handler;
- }
-}
-
-
diff --git a/klibc/klibc/__static_init.c b/klibc/klibc/__static_init.c
deleted file mode 100644
index 0b59eedaa7..0000000000
--- a/klibc/klibc/__static_init.c
+++ /dev/null
@@ -1,2 +0,0 @@
-#define SHARED 0
-#include "libc_init.c"
diff --git a/klibc/klibc/abort.c b/klibc/klibc/abort.c
deleted file mode 100644
index 9280d9861b..0000000000
--- a/klibc/klibc/abort.c
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * abort.c
- */
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <signal.h>
-
-void abort(void)
-{
- sigset_t set;
-
- sigemptyset(&set);
- sigaddset(&set, SIGABRT);
- sigprocmask(SIG_UNBLOCK, &set, NULL);
- raise(SIGABRT);
- _exit(255); /* raise() should have killed us */
-}
-
diff --git a/klibc/klibc/alarm.c b/klibc/klibc/alarm.c
deleted file mode 100644
index 40c0969432..0000000000
--- a/klibc/klibc/alarm.c
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * alarm.c
- */
-
-#include <sys/time.h>
-#include <sys/syscall.h>
-
-#ifndef __NR_alarm
-
-/* Emulate alarm() via setitimer() */
-
-unsigned int alarm(unsigned int seconds)
-{
- struct itimerval iv;
-
- iv.it_interval.tv_sec = iv.it_interval.tv_usec = 0;
- iv.it_value.tv_sec = seconds;
- iv.it_value.tv_usec = 0;
-
- setitimer(ITIMER_REAL, &iv, &iv);
-
- return iv.it_value.tv_sec + (iv.it_value.tv_usec ? 1 : 0);
-}
-
-#endif
diff --git a/klibc/klibc/arch/README b/klibc/klibc/arch/README
deleted file mode 100644
index eceb23de4b..0000000000
--- a/klibc/klibc/arch/README
+++ /dev/null
@@ -1,67 +0,0 @@
-To port klibc to a new architecture, you need:
-
-a) A directory structure
-
-Each archtecture has an arch/ directory, which should include an
-MCONFIG and a Makefile.inc file.
-
-b) Startup code (arch/*/crt0.S)
-
-The crt0.S assembly routine typically corresponds to the following
-pseudo-C code. In addition, each architecture needs any support
-routines that gcc-generated code expects to find in the system library
--- Alpha, for example, needs divide subroutines.
-
-The "getenvtest" test program is a very good test for proper crt0.S
-functionality.
-
-
-extern __noreturn __libc_init(void *, void *);
-
-__noreturn _start(void)
-{
- void *elf_data = get_elf_data_address(); /* Usually the stack address */
- void *atexit_ptr = get_atexit_ptr(); /* Usually in a register */
-
- /* Some architectures need this for debugging to work */
- setup_null_stack_frame_if_necessary();
-
- __libc_init(elf_data, atexit_ptr);
-}
-
-
-c) A setenv implementation (arch/*/setjmp.S, arch/*/include/klibc/archsetjmp.h)
-
-On most (but not all!) architectures, this entails creating a setjmp
-buffer big enough to hold all callee-saved registers, plus the stack
-pointer and the return address. In setjmp.S you have:
-
-* A "setjmp" function that writes out the callee-saved registers, the
- stack pointer and the return address to the buffer pointed to by the
- first argument, and then returns zero normally.
-
- On some architectures you need to take some kind of action to make
- sure the contents of the stack is actually manifest in memory and
- not cached in the CPU. In some cases (e.g. on SPARC) this will
- automatically spill the registers onto the stack; then they don't
- need to be spilled into the jmp_buf.
-
-* A "longjmp" function that read back these same registers from the
- jmp_buf pointed to by the first argument, and returns the second
- argument *to the address specified in the jmp_buf*.
-
- On some architectures you need to take some kind of action to flush
- any cached stack data or return stack.
-
-
-d) Any support functions needed by gcc, *unless* they are in libgcc
- *and* libgcc is usable for klibc on your particular platform. If
- libgcc isn't usable for klibc (on MIPS, for example, libgcc is
- compiled in a way that is not compatible with klibc) there are
- reasonably good clones of most of the libgcc functions in the libgcc
- directory. To use them, add them to ARCHOBJS in
- arch/*/Makefile.inc.
-
-
-e) A link location for the shared klibc. This should be specified in
- SHAREDFLAGS in arch/*/MCONFIG.
diff --git a/klibc/klibc/arch/alpha/MCONFIG b/klibc/klibc/arch/alpha/MCONFIG
deleted file mode 100644
index d7ab6c0b82..0000000000
--- a/klibc/klibc/arch/alpha/MCONFIG
+++ /dev/null
@@ -1,17 +0,0 @@
-# -*- makefile -*-
-#
-# arch/alpha/MCONFIG
-#
-# Build configuration for this architecture
-#
-
-OPTFLAGS = -Os
-BITSIZE = 64
-
-# Extra linkflags when building the shared version of the library
-# This address needs to be reachable using normal inter-module
-# calls, and work on the memory models for this architecture
-# 7 GB - normal binaries start at 4.5 GB, and the stack is below
-# the binary.
-SHAREDFLAGS = -Ttext 0x1c0000200
-
diff --git a/klibc/klibc/arch/alpha/Makefile.inc b/klibc/klibc/arch/alpha/Makefile.inc
deleted file mode 100644
index 62fce9dc28..0000000000
--- a/klibc/klibc/arch/alpha/Makefile.inc
+++ /dev/null
@@ -1,95 +0,0 @@
-# -*- makefile -*-
-#
-# arch/alpha/Makefile.inc
-#
-# Special rules for this architecture. Note that this is actually
-# included from the main Makefile, and that pathnames should be
-# accordingly.
-#
-
-# Special CFLAGS for the divide code
-DIVCFLAGS = $(REQFLAGS) \
- -O3 -fomit-frame-pointer -fcall-saved-1 -fcall-saved-2 \
- -fcall-saved-3 -fcall-saved-4 -fcall-saved-5 -fcall-saved-6 \
- -fcall-saved-7 -fcall-saved-8 -ffixed-15 -fcall-saved-16 \
- -fcall-saved-17 -fcall-saved-18 -fcall-saved-19 -fcall-saved-20 \
- -fcall-saved-21 -fcall-saved-22 -ffixed-23 -fcall-saved-24 \
- -ffixed-25 -ffixed-27
-
-ARCHOBJS = \
- arch/$(ARCH)/__divqu.o \
- arch/$(ARCH)/__remqu.o \
- arch/$(ARCH)/__divq.o \
- arch/$(ARCH)/__remq.o \
- arch/$(ARCH)/__divlu.o \
- arch/$(ARCH)/__remlu.o \
- arch/$(ARCH)/__divl.o \
- arch/$(ARCH)/__reml.o \
- arch/$(ARCH)/pipe.o \
- arch/$(ARCH)/setjmp.o \
- arch/$(ARCH)/syscall.o \
- arch/$(ARCH)/sysdual.o
-
-ARCHSOOBJS = $(patsubst %.o,%.lo,$(ARCHOBJS))
-
-arch/$(ARCH)/%.s: arch/$(ARCH)/%.ss
- sed -e 's/\$$0\b/$$27/g' -e 's/\$$24\b/$$99/g' \
- -e 's/\$$16\b/$$24/g' -e 's/\$$17\b/$$25/g' \
- -e 's/\$$26\b/$$23/g' -e 's/\$$99\b/$$16/g' < $< > $@
-
-arch/$(ARCH)/%.ls: arch/$(ARCH)/%.lss
- sed -e 's/\$$0\b/$$27/g' -e 's/\$$24\b/$$99/g' \
- -e 's/\$$16\b/$$24/g' -e 's/\$$17\b/$$25/g' \
- -e 's/\$$26\b/$$23/g' -e 's/\$$99\b/$$16/g' < $< > $@
-
-arch/$(ARCH)/__divqu.ss: arch/$(ARCH)/divide.c
- $(CC) $(DIVCFLAGS) -DSIGNED=0 -DREM=0 -DBITS=64 -DNAME=__divqu -S -o $@ $<
-
-arch/$(ARCH)/__remqu.ss: arch/$(ARCH)/divide.c
- $(CC) $(DIVCFLAGS) -DSIGNED=0 -DREM=1 -DBITS=64 -DNAME=__remqu -S -o $@ $<
-
-arch/$(ARCH)/__divq.ss: arch/$(ARCH)/divide.c
- $(CC) $(DIVCFLAGS) -DSIGNED=1 -DREM=0 -DBITS=64 -DNAME=__divq -S -o $@ $<
-
-arch/$(ARCH)/__remq.ss: arch/$(ARCH)/divide.c
- $(CC) $(DIVCFLAGS) -DSIGNED=1 -DREM=1 -DBITS=64 -DNAME=__remq -S -o $@ $<
-
-arch/$(ARCH)/__divlu.ss: arch/$(ARCH)/divide.c
- $(CC) $(DIVCFLAGS) -DSIGNED=0 -DREM=0 -DBITS=32 -DNAME=__divlu -S -o $@ $<
-
-arch/$(ARCH)/__remlu.ss: arch/$(ARCH)/divide.c
- $(CC) $(DIVCFLAGS) -DSIGNED=0 -DREM=1 -DBITS=32 -DNAME=__remlu -S -o $@ $<
-
-arch/$(ARCH)/__divl.ss: arch/$(ARCH)/divide.c
- $(CC) $(DIVCFLAGS) -DSIGNED=1 -DREM=0 -DBITS=32 -DNAME=__divl -S -o $@ $<
-
-arch/$(ARCH)/__reml.ss: arch/$(ARCH)/divide.c
- $(CC) $(DIVCFLAGS) -DSIGNED=1 -DREM=1 -DBITS=32 -DNAME=__reml -S -o $@ $<
-
-arch/$(ARCH)/__divqu.lss: arch/$(ARCH)/divide.c
- $(CC) $(DIVCFLAGS) -fPIC -DSIGNED=0 -DREM=0 -DBITS=64 -DNAME=__divqu -S -o $@ $<
-
-arch/$(ARCH)/__remqu.lss: arch/$(ARCH)/divide.c
- $(CC) $(DIVCFLAGS) -fPIC -DSIGNED=0 -DREM=1 -DBITS=64 -DNAME=__remqu -S -o $@ $<
-
-arch/$(ARCH)/__divq.lss: arch/$(ARCH)/divide.c
- $(CC) $(DIVCFLAGS) -fPIC -DSIGNED=1 -DREM=0 -DBITS=64 -DNAME=__divq -S -o $@ $<
-
-arch/$(ARCH)/__remq.lss: arch/$(ARCH)/divide.c
- $(CC) $(DIVCFLAGS) -fPIC -DSIGNED=1 -DREM=1 -DBITS=64 -DNAME=__remq -S -o $@ $<
-
-arch/$(ARCH)/__divlu.lss: arch/$(ARCH)/divide.c
- $(CC) $(DIVCFLAGS) -fPIC -DSIGNED=0 -DREM=0 -DBITS=32 -DNAME=__divlu -S -o $@ $<
-
-arch/$(ARCH)/__remlu.lss: arch/$(ARCH)/divide.c
- $(CC) $(DIVCFLAGS) -fPIC -DSIGNED=0 -DREM=1 -DBITS=32 -DNAME=__remlu -S -o $@ $<
-
-arch/$(ARCH)/__divl.lss: arch/$(ARCH)/divide.c
- $(CC) $(DIVCFLAGS) -fPIC -DSIGNED=1 -DREM=0 -DBITS=32 -DNAME=__divl -S -o $@ $<
-
-arch/$(ARCH)/__reml.lss: arch/$(ARCH)/divide.c
- $(CC) $(DIVCFLAGS) -fPIC -DSIGNED=1 -DREM=1 -DBITS=32 -DNAME=__reml -S -o $@ $<
-
-archclean:
- rm -f arch/$(ARCH)/*.ss arch/$(ARCH)/*.lss
-
diff --git a/klibc/klibc/arch/alpha/README-gcc b/klibc/klibc/arch/alpha/README-gcc
deleted file mode 100644
index 9aaba72837..0000000000
--- a/klibc/klibc/arch/alpha/README-gcc
+++ /dev/null
@@ -1,23 +0,0 @@
- The current Alpha chips don't provide hardware for integer
- division. The C compiler expects the functions
-
- __divqu: 64-bit unsigned long divide
- __remqu: 64-bit unsigned long remainder
- __divq/__remq: signed 64-bit
- __divlu/__remlu: unsigned 32-bit
- __divl/__reml: signed 32-bit
-
- These are not normal C functions: instead of the normal calling
- sequence, these expect their arguments in registers t10 and t11, and
- return the result in t12 (aka pv). Register AT may be clobbered
- (assembly temporary), anything else must be saved.
-
- Furthermore, the return address is in t9 instead of ra.
-
- Normal function Divide functions
- --------------- ----------------
- v0 ($0) t12/pv ($27)
- a0 ($16) t10 ($24)
- a1 ($17) t11 ($25)
- ra ($26) t9 ($23)
-
diff --git a/klibc/klibc/arch/alpha/crt0.S b/klibc/klibc/arch/alpha/crt0.S
deleted file mode 100644
index 904b539741..0000000000
--- a/klibc/klibc/arch/alpha/crt0.S
+++ /dev/null
@@ -1,22 +0,0 @@
-#
-# arch/alpha/crt0.S
-#
-
- .text
- .type _start,@function
- .ent _start, 0
- .globl _start
-_start:
- .frame $30, 0, $26, 0
- mov $31, $15
- br $29, 1f
-1: ldgp $29, 0($29)
- .prologue 0
-
- lda $16, 0($30) # ELF data structure
- lda $17, 0($0) # atexit pointer
-
- jsr $26, __libc_init
-
- .size _start,.-_start
- .end _start
diff --git a/klibc/klibc/arch/alpha/divide.c b/klibc/klibc/arch/alpha/divide.c
deleted file mode 100644
index 49d77cd5dc..0000000000
--- a/klibc/klibc/arch/alpha/divide.c
+++ /dev/null
@@ -1,57 +0,0 @@
-#include <stdint.h>
-#include <asm/gentrap.h>
-#include <asm/pal.h>
-
-#if BITS == 64
-typedef uint64_t uint;
-typedef int64_t sint;
-#else
-typedef uint32_t uint;
-typedef int32_t sint;
-#endif
-
-#ifdef SIGNED
-typedef sint xint;
-#else
-typedef uint xint;
-#endif
-
-xint NAME (uint num, uint den)
-{
- uint quot = 0, qbit = 1;
- int minus = 0;
- xint v;
-
- if ( den == 0 ) {
- /* This is really $16, but $16 and $24 are exchanged by a script */
- register unsigned long cause asm("$24") = GEN_INTDIV;
- asm volatile("call_pal %0" :: "i" (PAL_gentrap), "r" (cause));
- return 0; /* If trap returns... */
- }
-
-#if SIGNED
- if ( (sint)(num^den) < 0 )
- minus = 1;
- if ( (sint)num < 0 ) num = -num;
- if ( (sint)den < 0 ) den = -den;
-#endif
-
- /* Left-justify denominator and count shift */
- while ( (sint)den >= 0 ) {
- den <<= 1;
- qbit <<= 1;
- }
-
- while ( qbit ) {
- if ( den <= num ) {
- num -= den;
- quot += qbit;
- }
- den >>= 1;
- qbit >>= 1;
- }
-
- v = (xint)(REM ? num : quot);
- if ( minus ) v = -v;
- return v;
-}
diff --git a/klibc/klibc/arch/alpha/pipe.c b/klibc/klibc/arch/alpha/pipe.c
deleted file mode 100644
index 5aee9edbab..0000000000
--- a/klibc/klibc/arch/alpha/pipe.c
+++ /dev/null
@@ -1,28 +0,0 @@
-#include <unistd.h>
-#include <sys/syscall.h>
-
-/* pipe() on alpha returns both file descriptors in registers --
- $0 and $20 respectively. This is unlike any other system call,
- as far as I can tell. */
-
-int pipe(int *fds)
-{
- register long sc_0 __asm__("$0");
- register long sc_19 __asm__("$19");
- register long sc_20 __asm__("$20");
-
- sc_0 = __NR_pipe;
- asm volatile("callsys" : "=r" (sc_0), "=r" (sc_19), "=r" (sc_20)
- : "0" (sc_0)
- : _syscall_clobbers);
-
- if ( sc_19 ) {
- errno = sc_19;
- return -1;
- }
-
- fds[0] = sc_0;
- fds[1] = sc_20;
-
- return 0;
-}
diff --git a/klibc/klibc/arch/alpha/setjmp.S b/klibc/klibc/arch/alpha/setjmp.S
deleted file mode 100644
index 5d915f2dbe..0000000000
--- a/klibc/klibc/arch/alpha/setjmp.S
+++ /dev/null
@@ -1,77 +0,0 @@
-#
-# setjmp.S
-#
-
-#
-# The jmp_buf looks like:
-#
-# s0..5
-# fp
-# ra
-# gp
-# sp
-#
-
-#include <machine/asm.h>
-
- .text
- .align 3
- .type setjmp,@function
- .ent setjmp, 0
- .globl setjmp
-setjmp:
- lda v0, 0(zero)
- stq s0, 0(a0)
- stq s1, 8(a0)
- stq s2, 16(a0)
- stq s3, 24(a0)
- stq s4, 32(a0)
- stq s5, 40(a0)
- stq fp, 48(a0)
- stq ra, 56(a0)
- stq gp, 64(a0)
- stq sp, 72(a0)
- stt $f2, 80(a0)
- stt $f3, 88(a0)
- stt $f4, 96(a0)
- stt $f5, 104(a0)
- stt $f6, 112(a0)
- stt $f7, 120(a0)
- stt $f8, 128(a0)
- stt $f9, 136(a0)
- ret zero,(ra),1
-
- .size setjmp,.-setjmp
- .end setjmp
-
- .type longjmp,@function
- .ent longjmp, 0
- .globl longjmp
-longjmp:
- mov a1, v0
- ldq s0, 0(a0)
- ldq s1, 8(a0)
- ldq s2, 16(a0)
- ldq s3, 24(a0)
- ldq s4, 32(a0)
- ldq s5, 40(a0)
- ldq fp, 48(a0)
- ldq ra, 56(a0)
- ldq gp, 64(a0)
- ldq sp, 72(a0)
- ldt $f2, 80(a0)
- ldt $f3, 88(a0)
- ldt $f4, 96(a0)
- ldt $f5, 104(a0)
- ldt $f6, 112(a0)
- ldt $f7, 120(a0)
- ldt $f8, 128(a0)
- ldt $f9, 136(a0)
- /* We're bound to get a mispredict here, but at least give us
- a chance to get the return stack back in sync... */
- ret zero,(ra),1
-
- .size longjmp,.-longjmp
- .end longjmp
-
-
diff --git a/klibc/klibc/arch/alpha/syscall.S b/klibc/klibc/arch/alpha/syscall.S
deleted file mode 100644
index 0c87414b1a..0000000000
--- a/klibc/klibc/arch/alpha/syscall.S
+++ /dev/null
@@ -1,26 +0,0 @@
-#
-# arch/alpha/syscall.S
-#
-
-#include <machine/asm.h>
-
- .text
- .align 3
- .type __syscall_common,@function
- .ent __syscall_common, 0
- .globl __syscall_common
-__syscall_common:
- .frame sp,0,ra,0
- callsys
- beq a3, 1f
- br pv, 2f # pv <- pc
-2:
- ldgp gp, 0(pv)
- lda a1, errno
- lda v0, -1(zero)
- stl a3, 0(a1)
-1:
- ret zero,(ra),1
-
- .size __syscall_common,.-__syscall_common
- .end __syscall_common
diff --git a/klibc/klibc/arch/alpha/sysdual.S b/klibc/klibc/arch/alpha/sysdual.S
deleted file mode 100644
index c00db88960..0000000000
--- a/klibc/klibc/arch/alpha/sysdual.S
+++ /dev/null
@@ -1,33 +0,0 @@
-#
-# arch/alpha/sysdual.S
-#
-
-#
-# Some system calls have an alternate return value in r20 (a4).
-# This system call stub is for system calls where that is
-# the "real" return value.
-#
-
-#include <machine/asm.h>
-
- .text
- .align 3
- .type __syscall_dual1,@function
- .ent __syscall_dual1, 0
- .globl __syscall_dual1
-__syscall_dual1:
- .frame sp,0,ra,0
- callsys
- mov v0, a4
- beq a3, 1f
- br pv, 2f # pv <- pc
-2:
- ldgp gp, 0(pv)
- lda a1, errno
- lda v0, -1(zero)
- stl a3, 0(a1)
-1:
- ret zero,(ra),1
-
- .size __syscall_dual1,.-__syscall_dual1
- .end __syscall_dual1
diff --git a/klibc/klibc/arch/alpha/sysstub.ph b/klibc/klibc/arch/alpha/sysstub.ph
deleted file mode 100644
index 08b97e807e..0000000000
--- a/klibc/klibc/arch/alpha/sysstub.ph
+++ /dev/null
@@ -1,37 +0,0 @@
-# -*- perl -*-
-#
-# arch/alpha/sysstub.ph
-#
-# Script to generate system call stubs
-#
-
-# On Alpha, most system calls follow the standard convention, with the
-# system call number in r0 (v0), return an error value in r19 (a3) as
-# well as the return value in r0 (v0).
-#
-# A few system calls are dual-return with the second return value in
-# r20 (a4).
-
-sub make_sysstub($$$$$@) {
- my($outputdir, $fname, $type, $sname, $stype, @args) = @_;
-
- $stype = $stype || 'common';
- $stype = 'common' if ( $stype eq 'dual0' );
-
- open(OUT, '>', "${outputdir}/${fname}.S");
- print OUT "#include <asm/unistd.h>\n";
- print OUT "#include <machine/asm.h>\n";
- print OUT "\n";
- print OUT "\t.text\n";
- print OUT "\t.type ${fname},\@function\n";
- print OUT "\t.ent\t${fname}, 0\n"; # What is this?
- print OUT "\t.globl ${fname}\n";
- print OUT "${fname}:\n";
- print OUT "\tlda\tv0, __NR_${sname}(zero)\n";
- print OUT "\tbr __syscall_${stype}\n";
- print OUT "\t.size\t${fname},.-${fname}\n";
- print OUT "\t.end\t${fname}\n";
- close(OUT);
-}
-
-1;
diff --git a/klibc/klibc/arch/arm/MCONFIG b/klibc/klibc/arch/arm/MCONFIG
deleted file mode 100644
index fe26b996a7..0000000000
--- a/klibc/klibc/arch/arm/MCONFIG
+++ /dev/null
@@ -1,26 +0,0 @@
-# -*- makefile -*-
-#
-# arch/arm/MCONFIG
-#
-# Special rules for this architecture. Note that this is actually
-# included from the main Makefile, and that pathnames should be
-# accordingly.
-#
-
-THUMB = n
-CPU_ARCH := armv4
-CPU_TUNE := strongarm
-
-OPTFLAGS = -Os -march=$(CPU_ARCH) -mtune=$(CPU_TUNE)
-BITSIZE = 32
-
-ifeq ($(THUMB),y)
-CPU_ARCH := $(CPU_ARCH)t
-OPTFLAGS += -mthumb
-LDFLAGS += --thumb-entry _start
-endif
-
-# Extra linkflags when building the shared version of the library
-# This address needs to be reachable using normal inter-module
-# calls, and work on the memory models for this architecture
-SHAREDFLAGS = -Ttext 0x01000200
diff --git a/klibc/klibc/arch/arm/Makefile.inc b/klibc/klibc/arch/arm/Makefile.inc
deleted file mode 100644
index 0603d850bd..0000000000
--- a/klibc/klibc/arch/arm/Makefile.inc
+++ /dev/null
@@ -1,43 +0,0 @@
-# -*- makefile -*-
-#
-# arch/arm/Makefile.inc
-#
-# Special rules for this architecture. Note that this is actually
-# included from the main Makefile, and that pathnames should be
-# accordingly.
-#
-
-ARCHOBJS = \
- libgcc/__divsi3.o \
- libgcc/__modsi3.o \
- libgcc/__udivsi3.o \
- libgcc/__umodsi3.o \
- libgcc/__udivmodsi4.o \
- libgcc/__divdi3.o \
- libgcc/__moddi3.o \
- libgcc/__udivdi3.o \
- libgcc/__umoddi3.o \
- libgcc/__udivmoddi4.o \
- arch/arm/syscall.o
-
-ifeq ($(THUMB),y)
-ARCHOBJS += arch/arm/setjmp-thumb.o
-LIBGCC =
-else
-ARCHOBJS += arch/arm/setjmp-arm.o
-endif
-
-arch/arm/sysstubs.a: arch/arm/sysstubs.pl
- mkdir -p arch/arm/sysstubs
- $(PERL) $< arch/arm/sysstubs
- $(MAKE) $(patsubst %.S,%.o,$(wildcard arch/arm/sysstubs/*.S))
- -rm -f $@
- $(AR) cq $@ arch/arm/sysstubs/*.o
- $(RANLIB) $@
-
-
-ARCHSOOBJS = $(patsubst %.o,%.lo,$(ARCHOBJS))
-
-archclean:
- -rm -rf arch/arm/sysstubs
- -rm -f arch/arm/sysstubs.a
diff --git a/klibc/klibc/arch/arm/crt0.S b/klibc/klibc/arch/arm/crt0.S
deleted file mode 100644
index fc1104ef0e..0000000000
--- a/klibc/klibc/arch/arm/crt0.S
+++ /dev/null
@@ -1,23 +0,0 @@
-#
-# arch/arm/crt0.S
-#
-# void _start(void)
-# {
-# __libc_init(elf_structure, atexit_ptr);
-# }
-#
-
- .text
- .align 4
- .type _start,#function
- .globl _start
-
-#ifdef __thumb__
- .thumb_func
-#endif
-
-_start: mov r0, sp
- mov r1, #0
- bl __libc_init
-
- .size _start,.-_start
diff --git a/klibc/klibc/arch/arm/setjmp-arm.S b/klibc/klibc/arch/arm/setjmp-arm.S
deleted file mode 100644
index 1a29ee7f71..0000000000
--- a/klibc/klibc/arch/arm/setjmp-arm.S
+++ /dev/null
@@ -1,39 +0,0 @@
-#
-# arch/arm/setjmp.S
-#
-# setjmp/longjmp for the ARM architecture
-#
-
-#
-# The jmp_buf is assumed to contain the following, in order:
-# r4
-# r5
-# r6
-# r7
-# r8
-# r9
-# r10
-# fp
-# sp
-# lr
-#
-
- .text
- .align 4
- .globl setjmp
- .type setjmp, #function
-setjmp:
- stmia r0, {r4, r5, r6, r7, r8, r9, r10, fp, sp, lr}
- mov r0, #0
- mov pc, lr
- .size setjmp,.-setjmp
-
- .text
- .align 4
- .globl longjmp
- .type longjmp, #function
-longjmp:
- ldmia r0, {r4, r5, r6, r7, r8, r9, r10, fp, sp, lr}
- mov r0, r1
- mov pc, lr
- .size longjmp,.-longjmp
diff --git a/klibc/klibc/arch/arm/setjmp-thumb.S b/klibc/klibc/arch/arm/setjmp-thumb.S
deleted file mode 100644
index b581c5f7ad..0000000000
--- a/klibc/klibc/arch/arm/setjmp-thumb.S
+++ /dev/null
@@ -1,58 +0,0 @@
-#
-# arch/arm/setjmp-thumb.S
-#
-# setjmp/longjmp for the ARM/thumb architecture
-#
-
-#
-# The jmp_buf is assumed to contain the following, in order:
-# lr
-# r4
-# r5
-# r6
-# r7
-# r8
-# r9
-# r10
-# fp
-# sp
-#
-
- .text
- .align 4
- .globl setjmp
- .type setjmp, #function
- .thumb_func
-setjmp:
- mov r3, lr
- stmia r0!, {r3, r4, r5, r6, r7}
- mov r3, r8
- mov r4, r9
- mov r5, r10
- mov r6, fp
- mov r7, sp
- stmia r0!, {r3, r4, r5, r6, r7}
- mov r0, #0
- mov pc, lr
- .size setjmp,.-setjmp
-
- .text
- .align 4
- .globl longjmp
- .type longjmp, #function
- .thumb_func
-longjmp:
- mov r2, r0
- add r0, #5*4
- ldmia r0!, {r3, r4, r5, r6, r7}
- mov r8, r3
- mov r9, r4
- mov r10, r5
- mov fp, r6
- mov sp, r7
- ldmia r2!, {r3, r4, r5, r6, r7}
- mov r0, r1
- bne 1f
- mov r0, #1
-1: mov pc, r3
- .size longjmp,.-longjmp
diff --git a/klibc/klibc/arch/arm/syscall.S b/klibc/klibc/arch/arm/syscall.S
deleted file mode 100644
index 0e73f68ed0..0000000000
--- a/klibc/klibc/arch/arm/syscall.S
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * arch/arm/syscall.S
- *
- * System call common handling
- */
-
- .type __syscall_common,#function
- .globl __syscall_common
-#ifndef __thumb__
- /* ARM version - this is executed after the swi */
-
- .align 4
-__syscall_common:
- cmn r0, #4096
- rsbcs r2, r0, #0
- ldrcs r3, 1f
- mvncs r0, #0
- strcs r2, [r3]
- ldmfd sp!,{r4,r5,pc}
-
- .align 4
-1:
- .word errno
-
-#else
- /* Thumb version - must still load r4 and r5 and run swi */
-
- .thumb_func
- .align 2
-__syscall_common:
- ldr r4, [sp #12]
- ldr r5, [sp #16]
- swi 0
- ldr r1, 2f
- cmp r0, r1
- bcc 1f
- ldr r1, 3f
- neg r2, r0
- mvn r0, #0
- str r2, [r1]
-1:
- pop {r4,r5,r7,pc}
-
- .align 4
-2:
- .word #-4095
-3:
- .word errno
-
-#endif
diff --git a/klibc/klibc/arch/arm/sysstub.ph b/klibc/klibc/arch/arm/sysstub.ph
deleted file mode 100644
index 256ea3d534..0000000000
--- a/klibc/klibc/arch/arm/sysstub.ph
+++ /dev/null
@@ -1,44 +0,0 @@
-# -*- perl -*-
-#
-# arch/arm/sysstub.ph
-#
-# Script to generate system call stubs
-#
-
-
-sub make_sysstub($$$$$@) {
- my($outputdir, $fname, $type, $sname, $stype, @args) = @_;
-
- open(OUT, '>', "${outputdir}/${fname}.S");
- print OUT "#include <asm/unistd.h>\n";
-
- print OUT "\t.text\n";
- print OUT "\t.type\t${fname}, #function\n";
- print OUT "\t.globl ${fname}\n";
- print OUT "\t.align\t4\n";
-
- print OUT "#ifndef __thumb__\n";
-
- # ARM version first
- print OUT "${fname}:\n";
- print OUT "\tstmfd\tsp!,{r4,r5,lr}\n";
- print OUT "\tldr\tr4,[sp,#12]\n";
- print OUT "\tldr\tr5,[sp,#16]\n";
- print OUT "\tswi\t# __NR_${sname}\n";
- print OUT "\tb\t__syscall_common\n";
-
- print OUT "#else\n";
-
- # Thumb version
- print OUT "\t.thumb_func\n";
- print OUT "${fname}:\n";
- print OUT "\tpush\t{r4,r5,r7,pc}\n";
- print OUT "\tmov\tr7, # __NR_${sname}\n";
- print OUT "\tb\t__syscall_common\n";
-
- print OUT "#endif\n";
-
- print OUT "\t.size\t__syscall${i},.-__syscall${i}\n";
-}
-
-1;
diff --git a/klibc/klibc/arch/cris/MCONFIG b/klibc/klibc/arch/cris/MCONFIG
deleted file mode 100644
index 2762494a30..0000000000
--- a/klibc/klibc/arch/cris/MCONFIG
+++ /dev/null
@@ -1,26 +0,0 @@
-# -*- makefile -*-
-#
-# arch/cris/MCONFIG
-#
-# Special rules for this architecture. Note that this is actually
-# included from the main Makefile, and that pathnames should be
-# accordingly.
-#
-
-OPTFLAGS = -Os -fomit-frame-pointer
-BITSIZE = 32
-
-# Extra linkflags when building the shared version of the library
-# This address needs to be reachable using normal inter-module
-# calls, and work on the memory models for this architecture
-# 224 MB - normal binaries start at 0
-# (lib?)gcc on cris seems to insist on producing .init and .fini sections
-SHAREDFLAGS = --section-start .init=0x0e000100
-
-# The CRIS compiler needs an -iprefix to find libgcc includes when
-# nostdinc is used. It also needs -mlinux to compile linux applications.
-INCLUDE_PREFIX = $(shell $(CC) -print-libgcc-file-name | sed -e s/libgcc.a//)
-ARCHREQFLAGS = -iprefix $(INCLUDE_PREFIX) -mlinux
-
-# Special flags needed for linking
-LDFLAGS += -mcrislinux
diff --git a/klibc/klibc/arch/cris/Makefile.inc b/klibc/klibc/arch/cris/Makefile.inc
deleted file mode 100644
index 75fa17ba99..0000000000
--- a/klibc/klibc/arch/cris/Makefile.inc
+++ /dev/null
@@ -1,33 +0,0 @@
-# -*- makefile -*-
-#
-# arch/cris/Makefile.inc
-#
-# Special rules for this architecture. Note that this is actually
-# included from the main Makefile, and that pathnames should be
-# accordingly.
-#
-
-ARCHOBJS = \
- arch/$(ARCH)/__Umod.o \
- arch/$(ARCH)/__Udiv.o \
- arch/$(ARCH)/__Mod.o \
- arch/$(ARCH)/__Div.o \
- arch/$(ARCH)/__negdi2.o \
- arch/$(ARCH)/setjmp.o \
- arch/$(ARCH)/syscall.o \
- libgcc/__divdi3.o \
- libgcc/__moddi3.o \
- libgcc/__udivdi3.o \
- libgcc/__umoddi3.o \
- libgcc/__udivmoddi4.o
-
-arch/$(ARCH)/__Umod.o: arch/$(ARCH)/divide.c
- $(CC) $(CFLAGS) -DSIGNED=0 -DREM=1 -DBITS=32 -DNAME=__Umod -c -o $@ $<
-arch/$(ARCH)/__Udiv.o: arch/$(ARCH)/divide.c
- $(CC) $(CFLAGS) -DSIGNED=0 -DREM=0 -DBITS=32 -DNAME=__Udiv -c -o $@ $<
-arch/$(ARCH)/__Mod.o: arch/$(ARCH)/divide.c
- $(CC) $(CFLAGS) -DSIGNED=1 -DREM=1 -DBITS=32 -DNAME=__Mod -c -o $@ $<
-arch/$(ARCH)/__Div.o: arch/$(ARCH)/divide.c
- $(CC) $(CFLAGS) -DSIGNED=1 -DREM=0 -DBITS=32 -DNAME=__Div -c -o $@ $<
-
-archclean:
diff --git a/klibc/klibc/arch/cris/__negdi2.S b/klibc/klibc/arch/cris/__negdi2.S
deleted file mode 100644
index 3cca9edfa8..0000000000
--- a/klibc/klibc/arch/cris/__negdi2.S
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * arch/cris/__negdi2.c
- */
-
-/*
- * In 2's complement arithmetric, -x == (~x + 1), so
- * -{h,l} = (~{h,l} + {0,1)
- * -{h,l} = {~h,~l} + {0,1}
- * -{h,l} = {~h + cy, ~l + 1}
- * ... where cy = (l == 0)
- * -{h,l} = {~h + cy, -l}
- */
-
- .text
- .balign 4
- .type __negdi2,@function
- .globl __negdi2
-__negdi2:
- neg.d $r10,$r10
- seq $r12
- not $r11
- ret
- add.d $r12,$r11
-
- .size __negdi2, .-__negdi2
diff --git a/klibc/klibc/arch/cris/crt0.S b/klibc/klibc/arch/cris/crt0.S
deleted file mode 100644
index 989c82b2ba..0000000000
--- a/klibc/klibc/arch/cris/crt0.S
+++ /dev/null
@@ -1,28 +0,0 @@
-#
-# arch/cris/crt0.S
-#
-# Does arch-specific initialization and invokes __libc_init
-# with the appropriate arguments.
-#
-# See __static_init.c or __shared_init.c for the expected
-# arguments.
-#
-
- .text
- .balign 4
- .type _start,@function
- .globl _start
-_start:
- /* Save the address of the ELF argument array */
- move.d $sp,$r10 /* Address of ELF arguments */
-
- /* atexit() function (assume null) */
- moveq 0,$r11
-
- /* Set up a dummy stack frame to keep gcc from getting confused */
- push $r11
- push $r11
- jump __libc_init
-
- .size _start, .-_start
-
diff --git a/klibc/klibc/arch/cris/divide.c b/klibc/klibc/arch/cris/divide.c
deleted file mode 100644
index 29081dc953..0000000000
--- a/klibc/klibc/arch/cris/divide.c
+++ /dev/null
@@ -1,92 +0,0 @@
-#include <stdint.h>
-#include <signal.h>
-
-#if BITS == 64
-typedef uint64_t unum;
-typedef int64_t snum;
-#else
-typedef uint32_t unum;
-typedef int32_t snum;
-#endif
-
-#ifdef SIGNED
-typedef snum xnum;
-#else
-typedef unum xnum;
-#endif
-
-#ifdef __cris__
-static inline unum __attribute__((const)) dstep(unum rs, unum rd) {
- asm("dstep %1,%0" : "+r" (rd) : "r" (rs));
- return rd;
-}
-
-static inline unum __attribute__((const)) lz(unum rs) {
- unum rd;
- asm("lz %1,%0" : "=r" (rd) : "r" (rs));
- return rd;
-}
-
-#else
-/* For testing */
-static inline unum __attribute__ ((const)) dstep(unum rs, unum rd) {
- rd <<= 1;
- if ( rd >= rs )
- rd -= rs;
-
- return rd;
-}
-
-static inline unum __attribute__((const)) lz(unum rs) {
- unum rd = 0;
- while ( rs >= 0x7fffffff ) {
- rd++;
- rs <<= 1;
- }
- return rd;
-}
-
-#endif
-
-xnum NAME (unum num, unum den)
-{
- unum quot = 0, qbit = 1;
- int minus = 0;
- xnum v;
-
- if ( den == 0 ) {
- raise(SIGFPE);
- return 0; /* If signal ignored... */
- }
-
- if (den == 1) return (xnum)(REM ? 0 : num);
-
-#if SIGNED
- if ( (snum)(num^den) < 0 )
- minus = 1;
- if ( (snum)num < 0 ) num = -num;
- if ( (snum)den < 0 ) den = -den;
-#endif
-
- den--;
-
-
- /* Left-justify denominator and count shift */
- while ( (snum)den >= 0 ) {
- den <<= 1;
- qbit <<= 1;
- }
-
- while ( qbit ) {
- if ( den <= num ) {
- num -= den;
- quot += qbit;
- }
- den >>= 1;
- qbit >>= 1;
- }
-
- v = (xnum)(REM ? num : quot);
- if ( minus ) v = -v;
- return v;
-}
diff --git a/klibc/klibc/arch/cris/setjmp.S b/klibc/klibc/arch/cris/setjmp.S
deleted file mode 100644
index 43162418af..0000000000
--- a/klibc/klibc/arch/cris/setjmp.S
+++ /dev/null
@@ -1,37 +0,0 @@
-#
-# arch/cris/setjmp.S
-#
-# setjmp/longjmp for the cris architecture
-#
-
-#
-# The jmp_buf is assumed to contain the following, in order:
-# $r8..$r0 (in that order)
-# $sp ($r14)
-# return address
-#
-
- .text
- .balign 4
- .globl setjmp
- .type setjmp, @function
-setjmp:
- movem $r8,[$r10+] /* Save $r8..$r0 at $r10... */
- move.d $sp,[$r10+]
- move $srp,[$r10]
- ret
- moveq 0,$r10
-
- .size setjmp,.-setjmp
-
- .text
- .balign 4
- .globl longjmp
- .type longjmp, @function
-longjmp:
- movem [$r10+],$r8 /* Load $r8..$r0 from $r10... */
- move.d [$r10+],$sp
- jump [$r10]
- move.d $r11,$r10
-
- .size longjmp,.-longjmp
diff --git a/klibc/klibc/arch/cris/syscall.S b/klibc/klibc/arch/cris/syscall.S
deleted file mode 100644
index d71495aba2..0000000000
--- a/klibc/klibc/arch/cris/syscall.S
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * arch/cris/syscall.S
- *
- * On cris, r9 contains the syscall number (set by generated stub);
- * r10..r13 contain arguments 0-3 per the standard calling convention,
- * and arguments 4-5 are passed in $mof and $srp; however, we have
- * to save $srp around the system call.
- */
-
- .section ".text","ax"
- .balign 4
- .globl __syscall_common
- .type __syscall_common,@function
-__syscall_common:
- push $srp
- move [$sp+4],$mof
- move [$sp+8],$srp
- break 13
-
- cmps.w -4096,$r10
- blo 1f
- neg.d $r10,$r11
- move.d $r11,[errno]
- moveq -1,$r10
-1:
- pop $srp
- ret
- nop
-
- .size __syscall_common,.-__syscall_common
diff --git a/klibc/klibc/arch/cris/sysstub.ph b/klibc/klibc/arch/cris/sysstub.ph
deleted file mode 100644
index 182ad73f8c..0000000000
--- a/klibc/klibc/arch/cris/sysstub.ph
+++ /dev/null
@@ -1,29 +0,0 @@
-# -*- perl -*-
-#
-# arch/cris/sysstub.ph
-#
-# Script to generate system call stubs
-#
-
-sub make_sysstub($$$$$@) {
- my($outputdir, $fname, $type, $sname, $stype, @args) = @_;
-
- open(OUT, '>', "${outputdir}/${fname}.S");
- print OUT "#include <asm/unistd.h>\n";
- print OUT "\n";
- print OUT "\t.text\n";
- print OUT "\t.type\t${fname},\@function\n";
- print OUT "\t.globl\t${fname}\n";
- print OUT "\t.balign\t4\n";
- print OUT "${fname}:\n";
- print OUT "#if __NR_${sname} <= 31\n";
- print OUT "\t moveq\t__NR_${sname}, \$r9\n";
- print OUT "#else\n";
- print OUT "\t move.d\t__NR_${sname}, \$r9\n";
- print OUT "#endif\n";
- print OUT "\tjump\t__syscall_common\n";
- print OUT "\t.size ${fname},.-${fname}\n";
- close(OUT);
-}
-
-1;
diff --git a/klibc/klibc/arch/i386/MCONFIG b/klibc/klibc/arch/i386/MCONFIG
deleted file mode 100644
index ecd1307d7f..0000000000
--- a/klibc/klibc/arch/i386/MCONFIG
+++ /dev/null
@@ -1,33 +0,0 @@
-# -*- makefile -*-
-#
-# arch/i386/MCONFIG
-#
-# Special rules for this architecture. Note that this is actually
-# included from the main Makefile, and that pathnames should be
-# accordingly.
-#
-
-# Enable this to compile with register parameters; only safe for
-# gcc >= 3
-REGPARM_OPT := -mregparm=3 -D_REGPARM=3
-
-gcc_major := $(shell echo __GNUC__ | $(CC) -E -xc - | tail -n 1)
-
-OPTFLAGS = -march=i386 -Os -g -fomit-frame-pointer
-LDFLAGS = -m elf_i386
-
-ifneq ($(gcc_major),2)
-REQFLAGS += $(REGPARM_OPT)
-OPTFLAGS += -falign-functions=0 -falign-jumps=0 -falign-loops=0
-ARCHREQFLAGS += -m32
-else
-OPTFLAGS += -malign-functions=0 -malign-jumps=0 -malign-loops=0
-endif
-
-BITSIZE = 32
-
-# Extra linkflags when building the shared version of the library
-# This address needs to be reachable using normal inter-module
-# calls, and work on the memory models for this architecture
-# 96 MB - normal binaries start at 128 MB
-SHAREDFLAGS = -Ttext 0x06000200
diff --git a/klibc/klibc/arch/i386/Makefile.inc b/klibc/klibc/arch/i386/Makefile.inc
deleted file mode 100644
index 80344bd0a5..0000000000
--- a/klibc/klibc/arch/i386/Makefile.inc
+++ /dev/null
@@ -1,28 +0,0 @@
-# -*- makefile -*-
-#
-# arch/i386/Makefile.inc
-#
-# Special rules for this architecture. Note that this is actually
-# included from the main Makefile, and that pathnames should be
-# accordingly.
-#
-
-ARCHOBJS = \
- arch/$(ARCH)/exits.o \
- arch/$(ARCH)/socketcall.o \
- arch/$(ARCH)/setjmp.o \
- arch/$(ARCH)/syscall.o \
- arch/$(ARCH)/open.o \
- arch/$(ARCH)/sigreturn.o \
- arch/$(ARCH)/libgcc/__ashldi3.o \
- arch/$(ARCH)/libgcc/__ashrdi3.o \
- arch/$(ARCH)/libgcc/__lshrdi3.o \
- arch/$(ARCH)/libgcc/__muldi3.o \
- arch/$(ARCH)/libgcc/__negdi2.o \
- libgcc/__divdi3.o \
- libgcc/__moddi3.o \
- libgcc/__udivdi3.o \
- libgcc/__umoddi3.o \
- libgcc/__udivmoddi4.o
-
-archclean:
diff --git a/klibc/klibc/arch/i386/crt0.S b/klibc/klibc/arch/i386/crt0.S
deleted file mode 100644
index fb02c694c0..0000000000
--- a/klibc/klibc/arch/i386/crt0.S
+++ /dev/null
@@ -1,32 +0,0 @@
-#
-# arch/i386/crt0.S
-#
-# Does arch-specific initialization and invokes __libc_init
-# with the appropriate arguments.
-#
-# See __static_init.c or __shared_init.c for the expected
-# arguments.
-#
-
- .text
- .align 4
- .type _start,@function
- .globl _start
-_start:
- # Save the address of the ELF argument array
- movl %esp,%eax # Address of ELF arguments
- # Set up a faux stack frame for the benefit of gdb
- xorl %ebp,%ebp
- push %ebp # Keep gdb from getting confused
- push %ebp # Keep gdb from getting confused
- # Push the arguments and called __libc_init()
-#ifndef _REGPARM
- push %edx # atexit() function
- push %eax # ELF array
-#endif
- call __libc_init
- # If __libc_init returns, problem...
- hlt
-
- .size _start, .-_start
-
diff --git a/klibc/klibc/arch/i386/exits.S b/klibc/klibc/arch/i386/exits.S
deleted file mode 100644
index ed23d98bcb..0000000000
--- a/klibc/klibc/arch/i386/exits.S
+++ /dev/null
@@ -1,45 +0,0 @@
-#
-# exit and _exit get included in *every* program, and gcc generates
-# horrible code for them. Yes, this only saves a few bytes, but
-# it does it in every program.
-#
-
-#include <asm/unistd.h>
-
- .data
- .align 4
- .globl __exit_handler
- .type __exit_handler,@object
-__exit_handler:
- .long _exit
- .size __exit_handler,4
-
- .text
- .align 4
- .globl exit
- .type exit,@function
-exit:
- jmp *(__exit_handler)
- .size exit,.-exit
-
- /* No need to save any registers... we're exiting! */
- .text
- .align 4
- .globl _exit
- .type _exit,@function
-_exit:
-#ifdef _REGPARM
- movl %eax,%ebx
-#else
- popl %ebx
- popl %ebx
-#endif
-#if __NR_exit == 1
- xorl %eax,%eax
- incl %eax
-#else
- movl $__NR_exit,%eax
-#endif
- int $0x80
- hlt
- .size _exit,.-exit
diff --git a/klibc/klibc/arch/i386/libgcc/__ashldi3.S b/klibc/klibc/arch/i386/libgcc/__ashldi3.S
deleted file mode 100644
index 61982eb0eb..0000000000
--- a/klibc/klibc/arch/i386/libgcc/__ashldi3.S
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * arch/i386/libgcc/__ashldi3.S
- *
- * 64-bit shl
- */
- .text
- .align 4
- .globl __ashldi3
- .type __ashldi3,@function
-__ashldi3:
-#ifndef _REGPARM
- movl 4(%esp),%eax
- movl 8(%esp),%edx
- movb 12(%esp),%cl
-#endif
- cmpb $32,%cl
- jae 1f
-
- shldl %cl,%eax,%edx
- shl %cl,%eax
- ret
-
-1:
- xorl %edx,%edx
- shl %cl,%eax
- xchgl %edx,%eax
- ret
-
- .size __ashldi3,.-__ashldi3
diff --git a/klibc/klibc/arch/i386/libgcc/__ashrdi3.S b/klibc/klibc/arch/i386/libgcc/__ashrdi3.S
deleted file mode 100644
index 4ac2af69a1..0000000000
--- a/klibc/klibc/arch/i386/libgcc/__ashrdi3.S
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * arch/i386/libgcc/__ashrdi3.S
- *
- * 64-bit sar
- */
- .text
- .align 4
- .globl __ashrdi3
- .type __ashrdi3,@function
-__ashrdi3:
-#ifndef _REGPARM
- movl 4(%esp),%eax
- movl 8(%esp),%edx
- movb 12(%esp),%cl
-#endif
- cmpb $32,%cl
- jae 1f
-
- shrdl %cl,%edx,%eax
- sarl %cl,%edx
- ret
-
-1:
- sarl %cl,%edx
- movl %edx,%eax
- cdq
- ret
-
- .size __ashrdi3,.-__ashrdi3
diff --git a/klibc/klibc/arch/i386/libgcc/__lshrdi3.S b/klibc/klibc/arch/i386/libgcc/__lshrdi3.S
deleted file mode 100644
index 730ee43178..0000000000
--- a/klibc/klibc/arch/i386/libgcc/__lshrdi3.S
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * arch/i386/libgcc/__lshrdi3.S
- *
- * 64-bit shr
- */
- .text
- .align 4
- .globl __lshrdi3
- .type __lshrdi3,@function
-__lshrdi3:
-#ifndef _REGPARM
- movl 4(%esp),%eax
- movl 8(%esp),%edx
- movb 12(%esp),%cl
-#endif
- cmpb $32,%cl
- jae 1f
-
- shrdl %cl,%edx,%eax
- shrl %cl,%edx
- ret
-
-1:
- shrl %cl,%edx
- xorl %eax,%eax
- xchgl %edx,%eax
- ret
-
- .size __lshrdi3,.-__lshrdi3
diff --git a/klibc/klibc/arch/i386/libgcc/__muldi3.S b/klibc/klibc/arch/i386/libgcc/__muldi3.S
deleted file mode 100644
index 81e23b190e..0000000000
--- a/klibc/klibc/arch/i386/libgcc/__muldi3.S
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * arch/i386/libgcc/__muldi3.S
- *
- * 64*64 = 64 bit unsigned multiplication
- */
-
- .text
- .align 4
- .globl __muldi3
- .type __muldi3,@function
-__muldi3:
- push %esi
-#ifndef _REGPARM
- movl 8(%esp),%eax
- movl %eax,%esi
- movl 16(%esp),%ecx
- mull %ecx
- imull 12(%esp),%ecx
- imull 20(%esp),%esi
- addl %ecx,%edx
- addl %esi,%edx
-#else
- movl %eax,%esi
- push %edx
- mull %ecx
- imull 8(%esp),%esi
- addl %esi,%edx
- pop %esi
- imull %esi,%ecx
- addl %ecx,%edx
-#endif
- pop %esi
- ret
- .size __muldi3,.-__muldi3
diff --git a/klibc/klibc/arch/i386/libgcc/__negdi2.S b/klibc/klibc/arch/i386/libgcc/__negdi2.S
deleted file mode 100644
index c4f2cd517e..0000000000
--- a/klibc/klibc/arch/i386/libgcc/__negdi2.S
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * arch/i386/libgcc/__negdi2.S
- *
- * 64-bit negation
- */
-
- .text
- .align 4
- .globl __negdi2
- .type __negdi2,@function
-__negdi2:
-#ifndef _REGPARM
- movl 4(%esp),%eax
- movl 8(%esp),%edx
-#endif
- negl %edx
- negl %eax
- sbbl $0,%edx
- ret
-
- .size __negdi2,.-__negdi2
diff --git a/klibc/klibc/arch/i386/open.S b/klibc/klibc/arch/i386/open.S
deleted file mode 100644
index 54dd6151d1..0000000000
--- a/klibc/klibc/arch/i386/open.S
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * arch/i386/open.S
- *
- * Handle the open() system call - oddball due to the varadic
- * prototype, which forces the use of the cdecl calling convention,
- * and the need for O_LARGEFILE.
- */
-
-#include <asm/unistd.h>
-
-/* <asm/fcntl.h>, despite the name, isn't assembly-safe */
-#define O_LARGEFILE 0100000
-
- .globl open
- .type open,@function
-
-open:
-#ifdef _REGPARM
- movl 4(%esp),%eax
- movl 8(%esp),%edx
- movl 12(%esp),%ecx
- orl $O_LARGEFILE,%edx
-#else
- orl $O_LARGEFILE,8(%esp)
-#endif
- pushl $__NR_open
- jmp __syscall_common
-
- .size open,.-open
diff --git a/klibc/klibc/arch/i386/setjmp.S b/klibc/klibc/arch/i386/setjmp.S
deleted file mode 100644
index 2f3033f5bd..0000000000
--- a/klibc/klibc/arch/i386/setjmp.S
+++ /dev/null
@@ -1,58 +0,0 @@
-#
-# arch/i386/setjmp.S
-#
-# setjmp/longjmp for the i386 architecture
-#
-
-#
-# The jmp_buf is assumed to contain the following, in order:
-# %ebx
-# %esp
-# %ebp
-# %esi
-# %edi
-# <return address>
-#
-
- .text
- .align 4
- .globl setjmp
- .type setjmp, @function
-setjmp:
-#ifdef _REGPARM
- movl %eax,%edx
-#else
- movl 4(%esp),%edx
-#endif
- popl %ecx # Return address, and adjust the stack
- xorl %eax,%eax # Return value
- movl %ebx,(%edx)
- movl %esp,4(%edx) # Post-return %esp!
- pushl %ecx # Make the call/return stack happy
- movl %ebp,8(%edx)
- movl %esi,12(%edx)
- movl %edi,16(%edx)
- movl %ecx,20(%edx) # Return address
- ret
-
- .size setjmp,.-setjmp
-
- .text
- .align 4
- .globl longjmp
- .type longjmp, @function
-longjmp:
-#ifdef _REGPARM
- xchgl %eax,%edx
-#else
- movl 4(%esp),%edx # jmp_ptr address
- movl 8(%esp),%eax # Return value
-#endif
- movl (%edx),%ebx
- movl 4(%edx),%esp
- movl 8(%edx),%ebp
- movl 12(%edx),%esi
- movl 16(%edx),%edi
- jmp *20(%edx)
-
- .size longjmp,.-longjmp
diff --git a/klibc/klibc/arch/i386/sigreturn.S b/klibc/klibc/arch/i386/sigreturn.S
deleted file mode 100644
index f2a32419d3..0000000000
--- a/klibc/klibc/arch/i386/sigreturn.S
+++ /dev/null
@@ -1,15 +0,0 @@
-#
-# arch/i386/sigreturn.S
-#
-
-#include <asm/unistd.h>
-
- .text
- .align 4
- .globl __sigreturn
- .type __sigreturn,@function
-__sigreturn:
- pop %eax # Have no idea why this is needed...
- movl $__NR_sigreturn,%eax
- int $0x80
- .size __sigreturn,.-__sigreturn
diff --git a/klibc/klibc/arch/i386/socketcall.S b/klibc/klibc/arch/i386/socketcall.S
deleted file mode 100644
index b13d204c32..0000000000
--- a/klibc/klibc/arch/i386/socketcall.S
+++ /dev/null
@@ -1,42 +0,0 @@
-#
-# socketcall.S
-#
-# On i386, the main (only?) user of socketcall(2), the memory array
-# socketcall(2) needs is conveniently already assembled for us on
-# the stack. Capitalize on that to make a common socketcall stub.
-#
-
-#include <asm/unistd.h>
-
-#ifdef __i386__
-
- .text
- .align 4
- .globl __socketcall_common
- .type __socketcall_common, @function
-
-__socketcall_common:
- pushl %ebx
-
- movzbl %al,%ebx # The socketcall number is passed in in %al
- leal 8(%esp),%ecx # Argument pointer
- movl $__NR_socketcall,%eax
- int $0x80
-
- cmpl $-4096,%eax # Error return?
-
- popl %ebx
-
- jb 1f
-
- negl %eax
- movl %eax,errno
- orl $-1,%eax # Return -1
-1:
- ret
-
- .size __socketcall_common,.-__socketcall_common
-
-#endif
-
-
diff --git a/klibc/klibc/arch/i386/syscall.S b/klibc/klibc/arch/i386/syscall.S
deleted file mode 100644
index 0634e8208a..0000000000
--- a/klibc/klibc/arch/i386/syscall.S
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * arch/i386/syscall.S
- *
- * Common tail-handling code for system calls. Because of __syscalldecl
- * we are using the stack even on if we are compiling with regparm.
- *
- * The arguments are on the stack; the system call number in %eax.
- */
-
-#define ARG(n) (4*n+20)(%esp)
-
- .text
- .align 4
- .globl __syscall_common
- .type __syscall_common,@function
-__syscall_common:
-#ifdef _REGPARM
- xchgl %ebx,(%esp)
-#else
- popl %eax
- pushl %ebx
-#endif
- pushl %esi
- pushl %edi
- pushl %ebp
-
-#ifdef _REGPARM
- xchgl %eax,%ebx
- xchgl %ecx,%edx
- movl ARG(0),%esi
- movl ARG(1),%edi
- movl ARG(2),%ebp
-#else
- movl ARG(0),%ebx # Syscall arguments
- movl ARG(1),%ecx
- movl ARG(2),%edx
- movl ARG(3),%esi
- movl ARG(4),%edi
- movl ARG(5),%ebp
-#endif
- int $0x80
-
- cmpl $-4096,%eax
-
- popl %ebp
- popl %edi
- popl %esi
- popl %ebx
-
- jb 1f
-
- # Error return, must set errno
- negl %eax
- movl %eax,errno
- orl $-1,%eax # Return -1
-
-1:
- ret
-
- .size __syscall_common,.-__syscall_common
diff --git a/klibc/klibc/arch/i386/sysstub.ph b/klibc/klibc/arch/i386/sysstub.ph
deleted file mode 100644
index e2649e283e..0000000000
--- a/klibc/klibc/arch/i386/sysstub.ph
+++ /dev/null
@@ -1,32 +0,0 @@
-# -*- perl -*-
-#
-# arch/i386/sysstub.ph
-#
-# Script to generate system call stubs
-#
-
-sub make_sysstub($$$$$@) {
- my($outputdir, $fname, $type, $sname, $stype, @args) = @_;
-
- open(OUT, '>', "${outputdir}/${fname}.S");
- print OUT "#include <asm/unistd.h>\n";
- print OUT "\n";
- print OUT "\t.type ${fname},\@function\n";
- print OUT "\t.globl ${fname}\n";
- print OUT "${fname}:\n";
-
- if ( $stype eq 'varadic' ) {
- print OUT "#ifdef _REGPARM\n";
- print OUT "\tmovl 4(%esp),%eax\n";
- print OUT "\tmovl 8(%esp),%edx\n";
- print OUT "\tmovl 12(%esp),%ecx\n";
- print OUT "#endif\n";
- }
-
- print OUT "\tpushl \$__NR_${sname}\n";
- print OUT "\tjmp __syscall_common\n";
- print OUT "\t.size ${fname},.-${fname}\n";
- close(OUT);
-}
-
-1;
diff --git a/klibc/klibc/arch/ia64/MCONFIG b/klibc/klibc/arch/ia64/MCONFIG
deleted file mode 100644
index 36b30ffb81..0000000000
--- a/klibc/klibc/arch/ia64/MCONFIG
+++ /dev/null
@@ -1,11 +0,0 @@
-# -*- makefile -*-
-#
-# arch/ia64/MCONFIG
-#
-# Special rules for this architecture. Note that this is actually
-# included from the main Makefile, and that pathnames should be
-# accordingly.
-#
-
-OPTFLAGS = -Os
-BITSIZE = 64
diff --git a/klibc/klibc/arch/ia64/Makefile.inc b/klibc/klibc/arch/ia64/Makefile.inc
deleted file mode 100644
index 6363c1f948..0000000000
--- a/klibc/klibc/arch/ia64/Makefile.inc
+++ /dev/null
@@ -1,26 +0,0 @@
-# -*- makefile -*-
-#
-# arch/ia64/Makefile.inc
-#
-# Special rules for this architecture. Note that this is actually
-# included from the main Makefile, and that pathnames should be
-# accordingly.
-#
-
-ARCHOBJS = \
- arch/$(ARCH)/vfork.o \
- arch/$(ARCH)/setjmp.o \
- arch/$(ARCH)/pipe.o \
- arch/$(ARCH)/syscall.o \
- libgcc/__divdi3.o \
- libgcc/__divsi3.o \
- libgcc/__udivdi3.o \
- libgcc/__udivsi3.o \
- libgcc/__umodsi3.o \
- libgcc/__umoddi3.o \
- libgcc/__udivmodsi4.o \
- libgcc/__udivmoddi4.o
-
-ARCHSOOBJS = $(patsubst %o,%.lo,%(ARCHOBJS))
-
-archclean:
diff --git a/klibc/klibc/arch/ia64/crt0.S b/klibc/klibc/arch/ia64/crt0.S
deleted file mode 100644
index 4b128154e8..0000000000
--- a/klibc/klibc/arch/ia64/crt0.S
+++ /dev/null
@@ -1,27 +0,0 @@
-
-#include <asm/fpu.h>
-
- .align 32
- .global _start
-
- .proc _start
- .type _start,@function
-_start:
- .prologue
- .save rp, r0
-
- alloc r2 = ar.pfs,0,0,2,0
- movl r3 = FPSR_DEFAULT
- ;;
- adds out0= 16,sp /* argc pointer */
- movl gp = @gprel(0f)
-0: mov r9 = ip
- ;;
- sub gp = r9, gp /* back-compute gp value */
-
- .body
- br.call.sptk.few rp = __libc_init
- ;;
- break 0 /* break miserably if we ever return */
-
- .endp _start
diff --git a/klibc/klibc/arch/ia64/pipe.c b/klibc/klibc/arch/ia64/pipe.c
deleted file mode 100644
index 87a6981e55..0000000000
--- a/klibc/klibc/arch/ia64/pipe.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * pipe.c
- */
-
-#include <sys/syscall.h>
-#include <klibc/archsys.h>
-
-#define ASM_CLOBBERS ,"out2", "out3", "out4", "out5", "out6", "out7", \
- /* Non-stacked integer registers, minus r8, r9, r10, r15. */ \
- "r2", "r3", "r11", "r12", "r13", "r14", "r16", "r17", "r18", \
- "r19", "r20", "r21", "r22", "r23", "r24", "r25", "r26", "r27", \
- "r28", "r29", "r30", "r31", \
- /* Predicate registers. */ \
- "p6", "p7", "p8", "p9", "p10", "p11", "p12", "p13", "p14", "p15", \
- /* Non-rotating fp registers. */ \
- "f6", "f7", "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", \
- /* Branch registers. */ \
- "b6", "b7"
-
-int pipe(int *filedes)
-{
- register long _r8 asm("r8");
- register long _r9 asm("r9");
- register long _r10 asm("r10");
- register long _r15 asm("r15") = __NR_pipe;
- register long _out0 asm ("out0") = (long)filedes;
- long _retval;
- __asm __volatile (__IA64_BREAK
- : "=r" (_r8), "=r" (_r10), "=r" (_r15),
- "=r" (_out0), "=r" (_r9)
- : "2" (_r15), "3" (_out0)
- : "memory" ASM_CLOBBERS);
- if (_r10 == -1) {
- errno = _r8;
- _retval = -1;
- } else {
- filedes[0] = _r8;
- filedes[1] = _r9;
- _retval = 0;
- }
- return _retval;
-}
diff --git a/klibc/klibc/arch/ia64/setjmp.S b/klibc/klibc/arch/ia64/setjmp.S
deleted file mode 100644
index 7859ba4143..0000000000
--- a/klibc/klibc/arch/ia64/setjmp.S
+++ /dev/null
@@ -1,343 +0,0 @@
-/*
- * IA-64 specific setjmp/longjmp routines
- *
- * Inspired by setjmp.s from the FreeBSD kernel.
- */
-
-#define J_UNAT 0
-#define J_NATS 0x8
-#define J_PFS 0x10
-#define J_BSP 0x18
-#define J_RNAT 0x20
-#define J_PREDS 0x28
-#define J_LC 0x30
-#define J_R4 0x38
-#define J_R5 0x40
-#define J_R6 0x48
-#define J_R7 0x50
-#define J_SP 0x58
-#define J_F2 0x60
-#define J_F3 0x70
-#define J_F4 0x80
-#define J_F5 0x90
-#define J_F16 0xa0
-#define J_F17 0xb0
-#define J_F18 0xc0
-#define J_F19 0xd0
-#define J_F20 0xe0
-#define J_F21 0xf0
-#define J_F22 0x100
-#define J_F23 0x110
-#define J_F24 0x120
-#define J_F25 0x130
-#define J_F26 0x140
-#define J_F27 0x150
-#define J_F28 0x160
-#define J_F29 0x170
-#define J_F30 0x180
-#define J_F31 0x190
-#define J_FPSR 0x1a0
-#define J_B0 0x1a8
-#define J_B1 0x1b0
-#define J_B2 0x1b8
-#define J_B3 0x1c0
-#define J_B4 0x1c8
-#define J_B5 0x1d0
-#define J_SIGMASK 0x1d8
-#define J_SIGSET 0x1e0
-#define J_GP 0x1f0
-
-// int setjmp(struct jmp_buffer *)
-//
-// Setup a non-local goto.
-//
-// Description:
-//
-// SetJump stores the current register set in the area pointed to
-// by "save". It returns zero. Subsequent calls to "LongJump" will
-// restore the registers and return non-zero to the same location.
-//
-// On entry, r32 contains the pointer to the jmp_buffer
-//
- .align 32
- .global setjmp
- .proc setjmp
-setjmp:
- //
- // Make sure buffer is aligned at 16byte boundary
- //
- add r10 = -0x10,r0 ;; // mask the lower 4 bits
- and r32 = r32, r10;;
- add r32 = 0x10, r32;; // move to next 16 byte boundary
-
- add r10 = J_PREDS, r32 // skip Unats & pfs save area
- add r11 = J_BSP, r32
- //
- // save immediate context
- //
- mov r2 = ar.bsp // save backing store pointer
- mov r3 = pr // save predicates
- flushrs
- ;;
- //
- // save user Unat register
- //
- mov r16 = ar.lc // save loop count register
- mov r14 = ar.unat // save user Unat register
-
- st8 [r10] = r3, J_LC-J_PREDS
- st8 [r11] = r2, J_R4-J_BSP
- ;;
- st8 [r10] = r16, J_R5-J_LC
- st8 [r32] = r14, J_NATS // Note: Unat at the
- // beginning of the save area
- mov r15 = ar.pfs
- ;;
- //
- // save preserved general registers & NaT's
- //
- st8.spill [r11] = r4, J_R6-J_R4
- ;;
- st8.spill [r10] = r5, J_R7-J_R5
- ;;
- st8.spill [r11] = r6, J_SP-J_R6
- ;;
- st8.spill [r10] = r7, J_F3-J_R7
- ;;
- st8.spill [r11] = sp, J_F2-J_SP
- ;;
- //
- // save spilled Unat and pfs registers
- //
- mov r2 = ar.unat // save Unat register after spill
- ;;
- st8 [r32] = r2, J_PFS-J_NATS // save unat for spilled regs
- ;;
- st8 [r32] = r15 // save pfs
- //
- // save floating registers
- //
- stf.spill [r11] = f2, J_F4-J_F2
- stf.spill [r10] = f3, J_F5-J_F3
- ;;
- stf.spill [r11] = f4, J_F16-J_F4
- stf.spill [r10] = f5, J_F17-J_F5
- ;;
- stf.spill [r11] = f16, J_F18-J_F16
- stf.spill [r10] = f17, J_F19-J_F17
- ;;
- stf.spill [r11] = f18, J_F20-J_F18
- stf.spill [r10] = f19, J_F21-J_F19
- ;;
- stf.spill [r11] = f20, J_F22-J_F20
- stf.spill [r10] = f21, J_F23-J_F21
- ;;
- stf.spill [r11] = f22, J_F24-J_F22
- stf.spill [r10] = f23, J_F25-J_F23
- ;;
- stf.spill [r11] = f24, J_F26-J_F24
- stf.spill [r10] = f25, J_F27-J_F25
- ;;
- stf.spill [r11] = f26, J_F28-J_F26
- stf.spill [r10] = f27, J_F29-J_F27
- ;;
- stf.spill [r11] = f28, J_F30-J_F28
- stf.spill [r10] = f29, J_F31-J_F29
- ;;
- stf.spill [r11] = f30, J_FPSR-J_F30
- stf.spill [r10] = f31, J_B0-J_F31 // size of f31 + fpsr
- //
- // save FPSR register & branch registers
- //
- mov r2 = ar.fpsr // save fpsr register
- mov r3 = b0
- ;;
- st8 [r11] = r2, J_B1-J_FPSR
- st8 [r10] = r3, J_B2-J_B0
- mov r2 = b1
- mov r3 = b2
- ;;
- st8 [r11] = r2, J_B3-J_B1
- st8 [r10] = r3, J_B4-J_B2
- mov r2 = b3
- mov r3 = b4
- ;;
- st8 [r11] = r2, J_B5-J_B3
- st8 [r10] = r3
- mov r2 = b5
- ;;
- st8 [r11] = r2
- ;;
- //
- // return
- //
- mov r8 = r0 // return 0 from setjmp
- mov ar.unat = r14 // restore unat
- br.ret.sptk b0
- .endp setjmp
-
-//
-// void longjmp(struct jmp_buffer *, int val)
-//
-// Perform a non-local goto.
-//
-// Description:
-//
-// LongJump initializes the register set to the values saved by a
-// previous 'SetJump' and jumps to the return location saved by that
-// 'SetJump'. This has the effect of unwinding the stack and returning
-// for a second time to the 'SetJump'.
-//
-
- .align 32
- .global longjmp
- .proc longjmp
-longjmp:
- //
- // Make sure buffer is aligned at 16byte boundary
- //
- add r10 = -0x10,r0 ;; // mask the lower 4 bits
- and r32 = r32, r10;;
- add r32 = 0x10, r32;; // move to next 16 byte boundary
-
- //
- // caching the return value as we do invala in the end
- //
- mov r8 = r33 // return value
-
- //
- // get immediate context
- //
- mov r14 = ar.rsc // get user RSC conf
- add r10 = J_PFS, r32 // get address of pfs
- add r11 = J_NATS, r32
- ;;
- ld8 r15 = [r10], J_BSP-J_PFS // get pfs
- ld8 r2 = [r11], J_LC-J_NATS // get unat for spilled regs
- ;;
- mov ar.unat = r2
- ;;
- ld8 r16 = [r10], J_PREDS-J_BSP // get backing store pointer
- mov ar.rsc = r0 // put RSE in enforced lazy
- mov ar.pfs = r15
- ;;
-
- //
- // while returning from longjmp the BSPSTORE and BSP needs to be
- // same and discard all the registers allocated after we did
- // setjmp. Also, we need to generate the RNAT register since we
- // did not flushed the RSE on setjmp.
- //
- mov r17 = ar.bspstore // get current BSPSTORE
- ;;
- cmp.ltu p6,p7 = r17, r16 // is it less than BSP of
-(p6) br.spnt.few .flush_rse
- mov r19 = ar.rnat // get current RNAT
- ;;
- loadrs // invalidate dirty regs
- br.sptk.many .restore_rnat // restore RNAT
-
-.flush_rse:
- flushrs
- ;;
- mov r19 = ar.rnat // get current RNAT
- mov r17 = r16 // current BSPSTORE
- ;;
-.restore_rnat:
- //
- // check if RNAT is saved between saved BSP and curr BSPSTORE
- //
- mov r18 = 0x3f
- ;;
- dep r18 = r18,r16,3,6 // get RNAT address
- ;;
- cmp.ltu p8,p9 = r18, r17 // RNAT saved on RSE
- ;;
-(p8) ld8 r19 = [r18] // get RNAT from RSE
- ;;
- mov ar.bspstore = r16 // set new BSPSTORE
- ;;
- mov ar.rnat = r19 // restore RNAT
- mov ar.rsc = r14 // restore RSC conf
-
-
- ld8 r3 = [r11], J_R4-J_LC // get lc register
- ld8 r2 = [r10], J_R5-J_PREDS // get predicates
- ;;
- mov pr = r2, -1
- mov ar.lc = r3
- //
- // restore preserved general registers & NaT's
- //
- ld8.fill r4 = [r11], J_R6-J_R4
- ;;
- ld8.fill r5 = [r10], J_R7-J_R5
- ld8.fill r6 = [r11], J_SP-J_R6
- ;;
- ld8.fill r7 = [r10], J_F2-J_R7
- ld8.fill sp = [r11], J_F3-J_SP
- ;;
- //
- // restore floating registers
- //
- ldf.fill f2 = [r10], J_F4-J_F2
- ldf.fill f3 = [r11], J_F5-J_F3
- ;;
- ldf.fill f4 = [r10], J_F16-J_F4
- ldf.fill f5 = [r11], J_F17-J_F5
- ;;
- ldf.fill f16 = [r10], J_F18-J_F16
- ldf.fill f17 = [r11], J_F19-J_F17
- ;;
- ldf.fill f18 = [r10], J_F20-J_F18
- ldf.fill f19 = [r11], J_F21-J_F19
- ;;
- ldf.fill f20 = [r10], J_F22-J_F20
- ldf.fill f21 = [r11], J_F23-J_F21
- ;;
- ldf.fill f22 = [r10], J_F24-J_F22
- ldf.fill f23 = [r11], J_F25-J_F23
- ;;
- ldf.fill f24 = [r10], J_F26-J_F24
- ldf.fill f25 = [r11], J_F27-J_F25
- ;;
- ldf.fill f26 = [r10], J_F28-J_F26
- ldf.fill f27 = [r11], J_F29-J_F27
- ;;
- ldf.fill f28 = [r10], J_F30-J_F28
- ldf.fill f29 = [r11], J_F31-J_F29
- ;;
- ldf.fill f30 = [r10], J_FPSR-J_F30
- ldf.fill f31 = [r11], J_B0-J_F31 ;;
-
- //
- // restore branch registers and fpsr
- //
- ld8 r16 = [r10], J_B1-J_FPSR // get fpsr
- ld8 r17 = [r11], J_B2-J_B0 // get return pointer
- ;;
- mov ar.fpsr = r16
- mov b0 = r17
- ld8 r2 = [r10], J_B3-J_B1
- ld8 r3 = [r11], J_B4-J_B2
- ;;
- mov b1 = r2
- mov b2 = r3
- ld8 r2 = [r10], J_B5-J_B3
- ld8 r3 = [r11]
- ;;
- mov b3 = r2
- mov b4 = r3
- ld8 r2 = [r10]
- ld8 r21 = [r32] // get user unat
- ;;
- mov b5 = r2
- mov ar.unat = r21
-
- //
- // invalidate ALAT
- //
- invala ;;
-
- br.ret.sptk b0
- .endp longjmp
diff --git a/klibc/klibc/arch/ia64/syscall.S b/klibc/klibc/arch/ia64/syscall.S
deleted file mode 100644
index e3f264c0e4..0000000000
--- a/klibc/klibc/arch/ia64/syscall.S
+++ /dev/null
@@ -1,20 +0,0 @@
-#
-# arch/ia64/syscall.S
-#
-
-#include <asm/unistd.h>
-
- .text
- .align 32
- .proc __syscall_error
- .globl __syscall_error
-__syscall_error:
- addl r2 = @ltoffx(errno),gp
- ;;
- ld8.mov r3 = [r2],errno
- ;;
- st4 [r3] = r8
- mov r8 = -1
- br.ret.sptk.many b0
- .size __syscall_error, .-__syscall_error
- .endp __syscall_error
diff --git a/klibc/klibc/arch/ia64/sysstub.ph b/klibc/klibc/arch/ia64/sysstub.ph
deleted file mode 100644
index 8e686c68a3..0000000000
--- a/klibc/klibc/arch/ia64/sysstub.ph
+++ /dev/null
@@ -1,29 +0,0 @@
-# -*- perl -*-
-#
-# arch/ia64/sysstub.ph
-#
-# Script to generate system call stubs
-#
-
-sub make_sysstub($$$$$@) {
- my($outputdir, $fname, $type, $sname, $stype, @args) = @_;
-
- open(OUT, '>', "${outputdir}/${fname}.S");
- print OUT "#include <asm/unistd.h>\n";
- print OUT "\n";
- print OUT "\t.text\n";
- print OUT "\t.align 32\n";
- print OUT "\t.proc ${fname}\n";
- print OUT "\t.globl ${fname}\n";
- print OUT "${fname}:\n";
- print OUT "\tmov\tr15 = __NR_${sname}\n";
- print OUT "\tbreak __BREAK_SYSCALL\n";
- print OUT "\tcmp.eq p6,p0 = -1,r10\n";
- print OUT "(p6)\tbr.few __syscall_error\n";
- print OUT "\tbr.ret.sptk.many b0\n";
- print OUT "\t.size\t${fname},.-${fname}\n";
- print OUT "\t.endp\t${fname}\n";
- close(OUT);
-}
-
-1;
diff --git a/klibc/klibc/arch/ia64/vfork.S b/klibc/klibc/arch/ia64/vfork.S
deleted file mode 100644
index f79bdc8234..0000000000
--- a/klibc/klibc/arch/ia64/vfork.S
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * ia64 specific vfork syscall
- *
- * Written By: Martin Hicks <mort@wildopensource.com>
- *
- */
-
-/* This syscall is a special case of the clone syscall */
-#include <asm/unistd.h>
-#include <asm/signal.h>
-#include <klibc/archsys.h>
-
-/* These are redefined here because linux/sched.h isn't safe for
- * inclusion in asm.
- */
-#define CLONE_VM 0x00000100 /* set if VM shared between processes */
-#define CLONE_VFORK 0x00004000 /* set if parent wants the child to wake it up on exit */
-
-/* pid_t vfork(void) */
-/* Implemented as clone(CLONE_VFORK | CLONE_VM | SIGCHLD, 0) */
-
- .align 32
- .proc vfork
- .global vfork
-vfork:
- alloc r2=ar.pfs,0,0,2,0
- mov r15=__NR_clone
- mov out0=CLONE_VM|CLONE_VFORK|SIGCHLD
- mov out1=0
- ;;
- break 0x100000 // Do the syscall
- ;;
- addl r15=0,r1
- cmp.eq p7,p6 = -1,r10
- ;;
- ld8 r14=[r15]
- ;;
-(p7) st4 [r14]=r8
- ;;
-(p7) mov r8=-1
- br.ret.sptk.many b0
- .endp vfork
diff --git a/klibc/klibc/arch/m32r/MCONFIG b/klibc/klibc/arch/m32r/MCONFIG
deleted file mode 100644
index 2673090fce..0000000000
--- a/klibc/klibc/arch/m32r/MCONFIG
+++ /dev/null
@@ -1,18 +0,0 @@
-# -*- makefile -*-
-#
-# arch/m32r/MCONFIG
-#
-# Special rules for this architecture. Note that this is actually
-# included from the main Makefile, and that pathnames should be
-# accordingly.
-#
-
-OPTFLAGS = -Os
-BITSIZE = 32
-
-# Extra linkflags when building the shared version of the library
-# This address needs to be reachable using normal inter-module
-# calls, and work on the memory models for this architecture
-# 224 MB - normal binaries start at 0 (?)
-# (lib?)gcc on cris seems to insist on producing .init and .fini sections
-SHAREDFLAGS = --section-start .init=0x0e000100
diff --git a/klibc/klibc/arch/m32r/Makefile.inc b/klibc/klibc/arch/m32r/Makefile.inc
deleted file mode 100644
index 43cb44ef8f..0000000000
--- a/klibc/klibc/arch/m32r/Makefile.inc
+++ /dev/null
@@ -1,19 +0,0 @@
-# -*- makefile -*-
-#
-# arch/m32r/Makefile.inc
-#
-# Special rules for this architecture. Note that this is actually
-# included from the main Makefile, and that pathnames should be
-# accordingly.
-#
-
-ARCHOBJS = \
- arch/$(ARCH)/setjmp.o \
- arch/$(ARCH)/syscall.o \
- libgcc/__divdi3.o \
- libgcc/__moddi3.o \
- libgcc/__udivdi3.o \
- libgcc/__umoddi3.o \
- libgcc/__udivmoddi4.o
-
-archclean:
diff --git a/klibc/klibc/arch/m32r/crt0.S b/klibc/klibc/arch/m32r/crt0.S
deleted file mode 100644
index 1589a774a2..0000000000
--- a/klibc/klibc/arch/m32r/crt0.S
+++ /dev/null
@@ -1,25 +0,0 @@
-#
-# arch/m32r/crt0.S
-#
-# Does arch-specific initialization and invokes __libc_init
-# with the appropriate arguments.
-#
-# See __static_init.c or __shared_init.c for the expected
-# arguments.
-#
-
- .text
- .balign 4
- .type _start,@function
- .globl _start
-_start:
- /* Save the address of the ELF argument array */
- mv r0, sp
-
- /* atexit() function (assume null) */
- xor r1, r1
-
- bl __libc_init
-
- .size _start, .-_start
-
diff --git a/klibc/klibc/arch/m32r/setjmp.S b/klibc/klibc/arch/m32r/setjmp.S
deleted file mode 100644
index 14ef7e3577..0000000000
--- a/klibc/klibc/arch/m32r/setjmp.S
+++ /dev/null
@@ -1,47 +0,0 @@
-#
-# arch/m32r/setjmp.S
-#
-# setjmp/longjmp for the M32R architecture
-#
-
-#
-# The jmp_buf is assumed to contain the following, in order:
-# r8-r15
-#
-# Note that r14 is the return address register and
-# r15 is the stack pointer.
-#
-
- .text
- .balign 4
- .globl setjmp
- .type setjmp, @function
-setjmp:
- st r8, @r0
- st r9, @+r0
- st r10, @+r0
- st r11, @+r0
- st r12, @+r0
- st r13, @+r0
- st r14, @+r0
- st r15, @+r0
- xor r0, r0
- jmp r14
- .size setjmp,.-setjmp
-
- .text
- .balign 4
- .globl longjmp
- .type longjmp, @function
-longjmp:
- ld r8, @r0+
- ld r9, @r0+
- ld r10, @r0+
- ld r11, @r0+
- ld r12, @r0+
- ld r13, @r0+
- ld r14, @r0+
- ld r15, @r0
- mv r0, r1
- jmp r14
- .size longjmp,.-longjmp
diff --git a/klibc/klibc/arch/m32r/syscall.S b/klibc/klibc/arch/m32r/syscall.S
deleted file mode 100644
index a20a33667f..0000000000
--- a/klibc/klibc/arch/m32r/syscall.S
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * arch/m32r/syscall.S
- *
- * r7 contains the syscall number (set by stub);
- * r0..r3 contains arguments 0-3 per standard calling convention;
- * r4..r5 contains arguments 4-5, but we have to get those from
- * the stack.
- */
-
- .section ".text","ax"
- .balign 4
- .globl __syscall_common
- .type __syscall_common,@function
-__syscall_common:
- ld r4,@sp
- ld r5,@(4,sp)
- trap #2
- cmpi r0, #-4096
- bnc 1f
- jmp r14
-1:
- seth r2,#high(errno)
- or3 r2,r2,#low(errno)
- neg r1,r0
- st r1,@r7
- ldi r0,#-1
- jmp r14
-
- .size __syscall_common,.-__syscall_common
diff --git a/klibc/klibc/arch/m32r/sysstub.ph b/klibc/klibc/arch/m32r/sysstub.ph
deleted file mode 100644
index 98dfb9d0a8..0000000000
--- a/klibc/klibc/arch/m32r/sysstub.ph
+++ /dev/null
@@ -1,25 +0,0 @@
-# -*- perl -*-
-#
-# arch/m32r/sysstub.ph
-#
-# Script to generate system call stubs
-#
-
-sub make_sysstub($$$$$@) {
- my($outputdir, $fname, $type, $sname, $stype, @args) = @_;
-
- open(OUT, '>', "${outputdir}/${fname}.S");
- print OUT "#include <asm/unistd.h>\n";
- print OUT "\n";
- print OUT "\t.text\n";
- print OUT "\t.type\t${fname},\@function\n";
- print OUT "\t.globl\t${fname}\n";
- print OUT "\t.balign\t4\n";
- print OUT "${fname}:\n";
- print OUT "\tldi\tr7,#__NR_${sname}\n";
- print OUT "\tbra\t__syscall_common\n";
- print OUT "\t.size ${fname},.-${fname}\n";
- close(OUT);
-}
-
-1;
diff --git a/klibc/klibc/arch/m68k/MCONFIG b/klibc/klibc/arch/m68k/MCONFIG
deleted file mode 100644
index 2ba69b3178..0000000000
--- a/klibc/klibc/arch/m68k/MCONFIG
+++ /dev/null
@@ -1,11 +0,0 @@
-# -*- makefile -*-
-#
-# arch/m68k/MCONFIG
-#
-# Special rules for this architecture. Note that this is actually
-# included from the main Makefile, and that pathnames should be
-# accordingly.
-#
-
-OPTFLAGS = -Os -fomit-frame-pointer
-BITSIZE = 32
diff --git a/klibc/klibc/arch/m68k/Makefile.inc b/klibc/klibc/arch/m68k/Makefile.inc
deleted file mode 100644
index 9abec14db1..0000000000
--- a/klibc/klibc/arch/m68k/Makefile.inc
+++ /dev/null
@@ -1,10 +0,0 @@
-# -*- makefile -*-
-#
-# arch/m68k/Makefile.inc
-#
-# Special rules for this architecture. Note that this is actually
-# included from the main Makefile, and that pathnames should be
-# accordingly.
-#
-
-archclean:
diff --git a/klibc/klibc/arch/mips/MCONFIG b/klibc/klibc/arch/mips/MCONFIG
deleted file mode 100644
index 0a98918987..0000000000
--- a/klibc/klibc/arch/mips/MCONFIG
+++ /dev/null
@@ -1,15 +0,0 @@
-# -*- makefile -*-
-#
-# arch/mips/MCONFIG
-#
-# Special rules for this architecture. Note that this is actually
-# included from the main Makefile, and that pathnames should be
-# accordingly.
-#
-
-ARCHREQFLAGS = -fno-pic -mno-abicalls -G 0
-OPTFLAGS = -Os
-BITSIZE = 32
-
-# Extra linkflags when building the shared version of the library
-SHAREDFLAGS = -T arch/$(ARCH)/klibc.ld
diff --git a/klibc/klibc/arch/mips/Makefile.inc b/klibc/klibc/arch/mips/Makefile.inc
deleted file mode 100644
index e257023f34..0000000000
--- a/klibc/klibc/arch/mips/Makefile.inc
+++ /dev/null
@@ -1,25 +0,0 @@
-# -*- makefile -*-
-#
-# arch/mips/Makefile.inc
-#
-# Special rules for this architecture. Note that this is actually
-# included from the main Makefile, and that pathnames should be
-# accordingly.
-#
-
-ARCHOBJS = \
- arch/$(ARCH)/pipe.o \
- arch/$(ARCH)/vfork.o \
- arch/$(ARCH)/setjmp.o \
- arch/$(ARCH)/syscall.o \
- libgcc/__divdi3.o \
- libgcc/__moddi3.o \
- libgcc/__udivdi3.o \
- libgcc/__umoddi3.o \
- libgcc/__udivmoddi4.o
-
-
-ARCHSOOBJS = $(patsubst %.o,%.lo,$(ARCHOBJS))
-
-
-archclean:
diff --git a/klibc/klibc/arch/mips/crt0.S b/klibc/klibc/arch/mips/crt0.S
deleted file mode 100644
index 42d9dd5e38..0000000000
--- a/klibc/klibc/arch/mips/crt0.S
+++ /dev/null
@@ -1,25 +0,0 @@
-#
-# arch/mips/crt0.S
-#
-# Does arch-specific initialization and invokes __libc_init
-# with the appropriate arguments.
-#
-# See __static_init.c or __shared_init.c for the expected
-# arguments.
-#
-
-#include <machine/asm.h>
-
-NESTED(__start, 32, sp)
- subu sp, 32
- sw zero, 16(sp)
-
- lui gp, %hi(_gp) # Initialize gp
- addiu gp, gp, _gp
-
- addiu a0, sp, 32 # Pointer to ELF entry structure
- move a1, v0 # Kernel-provided atexit() pointer
-
- jal __libc_init
-
- END(__start)
diff --git a/klibc/klibc/arch/mips/klibc.ld b/klibc/klibc/arch/mips/klibc.ld
deleted file mode 100644
index d75c9de70c..0000000000
--- a/klibc/klibc/arch/mips/klibc.ld
+++ /dev/null
@@ -1,217 +0,0 @@
-/* Linker script for klibc.so, needed because of the the damned
- GNU ld script headers problem */
-
-OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips",
- "elf32-tradlittlemips")
-OUTPUT_ARCH(mips)
-ENTRY(__start)
-SECTIONS
-{
- /* Read-only sections, merged into text segment: */
- /* This address needs to be reachable using normal inter-module
- calls, and work on the memory models for this architecture */
- /* 2 MB -- the normal starting point for text is 4 MB */
- . = 0x00200400;
- .interp : { *(.interp) }
- .reginfo : { *(.reginfo) }
- .dynamic : { *(.dynamic) }
- .hash : { *(.hash) }
- .dynsym : { *(.dynsym) }
- .dynstr : { *(.dynstr) }
- .gnu.version : { *(.gnu.version) }
- .gnu.version_d : { *(.gnu.version_d) }
- .gnu.version_r : { *(.gnu.version_r) }
- .rel.dyn :
- {
- *(.rel.init)
- *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*)
- *(.rel.fini)
- *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*)
- *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*)
- *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*)
- *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*)
- *(.rel.ctors)
- *(.rel.dtors)
- *(.rel.got)
- *(.rel.sdata .rel.sdata.* .rel.gnu.linkonce.s.*)
- *(.rel.sbss .rel.sbss.* .rel.gnu.linkonce.sb.*)
- *(.rel.sdata2 .rel.sdata2.* .rel.gnu.linkonce.s2.*)
- *(.rel.sbss2 .rel.sbss2.* .rel.gnu.linkonce.sb2.*)
- *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*)
- }
- .rela.dyn :
- {
- *(.rela.init)
- *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*)
- *(.rela.fini)
- *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*)
- *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*)
- *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*)
- *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*)
- *(.rela.ctors)
- *(.rela.dtors)
- *(.rela.got)
- *(.rela.sdata .rela.sdata.* .rela.gnu.linkonce.s.*)
- *(.rela.sbss .rela.sbss.* .rela.gnu.linkonce.sb.*)
- *(.rela.sdata2 .rela.sdata2.* .rela.gnu.linkonce.s2.*)
- *(.rela.sbss2 .rela.sbss2.* .rela.gnu.linkonce.sb2.*)
- *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*)
- }
- .rel.plt : { *(.rel.plt) }
- .rela.plt : { *(.rela.plt) }
- .init :
- {
- KEEP (*(.init))
- } =0
- .plt : { *(.plt) }
- .text :
- {
- _ftext = . ;
- *(.text .stub .text.* .gnu.linkonce.t.*)
- /* .gnu.warning sections are handled specially by elf32.em. */
- *(.gnu.warning)
- *(.mips16.fn.*) *(.mips16.call.*)
- } =0
- .fini :
- {
- KEEP (*(.fini))
- } =0
- PROVIDE (__etext = .);
- PROVIDE (_etext = .);
- PROVIDE (etext = .);
- .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
- .rodata1 : { *(.rodata1) }
- .sdata2 : { *(.sdata2 .sdata2.* .gnu.linkonce.s2.*) }
- .sbss2 : { *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*) }
- .eh_frame_hdr : { *(.eh_frame_hdr) }
- /* Adjust the address for the data segment. We want to adjust up to
- the same address within the page on the next page up. */
- . = ALIGN(8192);
- /* Ensure the __preinit_array_start label is properly aligned. We
- could instead move the label definition inside the section, but
- the linker would then create the section even if it turns out to
- be empty, which isn't pretty. */
- . = ALIGN(32 / 8);
- PROVIDE (__preinit_array_start = .);
- .preinit_array : { *(.preinit_array) }
- PROVIDE (__preinit_array_end = .);
- PROVIDE (__init_array_start = .);
- .init_array : { *(.init_array) }
- PROVIDE (__init_array_end = .);
- PROVIDE (__fini_array_start = .);
- .fini_array : { *(.fini_array) }
- PROVIDE (__fini_array_end = .);
- .data :
- {
- _fdata = . ;
- *(.data .data.* .gnu.linkonce.d.*)
- SORT(CONSTRUCTORS)
- }
- .data1 : { *(.data1) }
- .tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
- .tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
- .eh_frame : { KEEP (*(.eh_frame)) }
- .gcc_except_table : { *(.gcc_except_table) }
- .ctors :
- {
- /* gcc uses crtbegin.o to find the start of
- the constructors, so we make sure it is
- first. Because this is a wildcard, it
- doesn't matter if the user does not
- actually link against crtbegin.o; the
- linker won't look for a file to match a
- wildcard. The wildcard also means that it
- doesn't matter which directory crtbegin.o
- is in. */
- KEEP (*crtbegin*.o(.ctors))
- /* We don't want to include the .ctor section from
- from the crtend.o file until after the sorted ctors.
- The .ctor section from the crtend file contains the
- end of ctors marker and it must be last */
- KEEP (*(EXCLUDE_FILE (*crtend*.o ) .ctors))
- KEEP (*(SORT(.ctors.*)))
- KEEP (*(.ctors))
- }
- .dtors :
- {
- KEEP (*crtbegin*.o(.dtors))
- KEEP (*(EXCLUDE_FILE (*crtend*.o ) .dtors))
- KEEP (*(SORT(.dtors.*)))
- KEEP (*(.dtors))
- }
- .jcr : { KEEP (*(.jcr)) }
- _gp = ALIGN(16) + 0x7ff0;
- .got : { *(.got.plt) *(.got) }
- /* We want the small data sections together, so single-instruction offsets
- can access them all, and initialized data all before uninitialized, so
- we can shorten the on-disk segment size. */
- .sdata :
- {
- *(.sdata .sdata.* .gnu.linkonce.s.*)
- }
- .lit8 : { *(.lit8) }
- .lit4 : { *(.lit4) }
- _edata = .;
- PROVIDE (edata = .);
- __bss_start = .;
- _fbss = .;
- .sbss :
- {
- PROVIDE (__sbss_start = .);
- PROVIDE (___sbss_start = .);
- *(.dynsbss)
- *(.sbss .sbss.* .gnu.linkonce.sb.*)
- *(.scommon)
- PROVIDE (__sbss_end = .);
- PROVIDE (___sbss_end = .);
- }
- .bss :
- {
- *(.dynbss)
- *(.bss .bss.* .gnu.linkonce.b.*)
- *(COMMON)
- /* Align here to ensure that the .bss section occupies space up to
- _end. Align after .bss to ensure correct alignment even if the
- .bss section disappears because there are no input sections. */
- . = ALIGN(32 / 8);
- }
- . = ALIGN(32 / 8);
- _end = .;
- PROVIDE (end = .);
- /* Stabs debugging sections. */
- .stab 0 : { *(.stab) }
- .stabstr 0 : { *(.stabstr) }
- .stab.excl 0 : { *(.stab.excl) }
- .stab.exclstr 0 : { *(.stab.exclstr) }
- .stab.index 0 : { *(.stab.index) }
- .stab.indexstr 0 : { *(.stab.indexstr) }
- .comment 0 : { *(.comment) }
- /* DWARF debug sections.
- Symbols in the DWARF debugging sections are relative to the beginning
- of the section so we begin them at 0. */
- /* DWARF 1 */
- .debug 0 : { *(.debug) }
- .line 0 : { *(.line) }
- /* GNU DWARF 1 extensions */
- .debug_srcinfo 0 : { *(.debug_srcinfo) }
- .debug_sfnames 0 : { *(.debug_sfnames) }
- /* DWARF 1.1 and DWARF 2 */
- .debug_aranges 0 : { *(.debug_aranges) }
- .debug_pubnames 0 : { *(.debug_pubnames) }
- /* DWARF 2 */
- .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
- .debug_abbrev 0 : { *(.debug_abbrev) }
- .debug_line 0 : { *(.debug_line) }
- .debug_frame 0 : { *(.debug_frame) }
- .debug_str 0 : { *(.debug_str) }
- .debug_loc 0 : { *(.debug_loc) }
- .debug_macinfo 0 : { *(.debug_macinfo) }
- /* SGI/MIPS DWARF 2 extensions */
- .debug_weaknames 0 : { *(.debug_weaknames) }
- .debug_funcnames 0 : { *(.debug_funcnames) }
- .debug_typenames 0 : { *(.debug_typenames) }
- .debug_varnames 0 : { *(.debug_varnames) }
- .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) }
- .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) }
- /DISCARD/ : { *(.note.GNU-stack) }
-}
diff --git a/klibc/klibc/arch/mips/pipe.S b/klibc/klibc/arch/mips/pipe.S
deleted file mode 100644
index d79f614025..0000000000
--- a/klibc/klibc/arch/mips/pipe.S
+++ /dev/null
@@ -1,16 +0,0 @@
-#include <asm/asm.h>
-#include <asm/regdef.h>
-#include <asm/unistd.h>
-
-LEAF(pipe)
- li v0, __NR_pipe
- syscall
- bnez a3, 1f
- sw v0, (a0)
- sw v1, (a1)
- li v0, 0
- b 2f
-1: sw v0, errno
- li v0, -1
-2: jr ra
- END(pipe)
diff --git a/klibc/klibc/arch/mips/setjmp.S b/klibc/klibc/arch/mips/setjmp.S
deleted file mode 100644
index 4d293757ec..0000000000
--- a/klibc/klibc/arch/mips/setjmp.S
+++ /dev/null
@@ -1,82 +0,0 @@
-#
-# arch/mips/setjmp.S
-#
-# setjmp/longjmp for the MIPS architecture
-#
-# The jmp_buf is assumed to contain the following, in order:
-# s0..s7
-# gp
-# sp
-# s8
-# ra
-# f20..f31
-# fcr31
-#
-
-#include <machine/asm.h>
-
-LEAF(setjmp)
- sw s0, 0(a0)
- sw s1, 4(a0)
- sw s2, 8(a0)
- sw s3, 12(a0)
- sw s4, 16(a0)
- sw s5, 20(a0)
- sw s6, 24(a0)
- sw s7, 28(a0)
- sw gp, 32(a0)
- sw sp, 36(a0)
- sw s8, 40(a0)
- sw ra, 44(a0)
- cfc1 t0,$31
- swc1 $f20,48(a0)
- swc1 $f21,52(a0)
- swc1 $f22,56(a0)
- swc1 $f23,60(a0)
- swc1 $f24,64(a0)
- swc1 $f25,68(a0)
- swc1 $f26,72(a0)
- swc1 $f27,76(a0)
- swc1 $f28,80(a0)
- swc1 $f29,84(a0)
- swc1 $f30,88(a0)
- swc1 $f31,92(a0)
- sw t0,96(a0)
- move v0,zero
- jr ra
-
- END(setjmp)
-
-LEAF(longjmp)
- lw s0, 0(a0)
- lw s1, 4(a0)
- lw s2, 8(a0)
- lw s3, 12(a0)
- lw s4, 16(a0)
- lw s5, 20(a0)
- lw s6, 24(a0)
- lw s7, 28(a0)
- lw gp, 32(a0)
- lw sp, 36(a0)
- lw s8, 40(a0)
- lw ra, 44(a0)
- lw t0, 96(a0)
- lwc1 $f20,48(a0)
- lwc1 $f21,52(a0)
- lwc1 $f22,56(a0)
- lwc1 $f23,60(a0)
- lwc1 $f24,64(a0)
- lwc1 $f25,68(a0)
- lwc1 $f26,72(a0)
- lwc1 $f27,76(a0)
- lwc1 $f28,80(a0)
- lwc1 $f29,84(a0)
- lwc1 $f30,88(a0)
- lwc1 $f31,92(a0)
- ctc1 t0,$31
- move v0,a1
- jr ra
-
- END(longjmp)
-
- \ No newline at end of file
diff --git a/klibc/klibc/arch/mips/syscall.S b/klibc/klibc/arch/mips/syscall.S
deleted file mode 100644
index d5c1fe1c7d..0000000000
--- a/klibc/klibc/arch/mips/syscall.S
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <asm/asm.h>
-#include <asm/regdef.h>
-#include <asm/unistd.h>
-
- .set noreorder
-
-LEAF(__syscall_common)
- syscall
- beqz a3, 1f
- # sw is actually two instructions; the first one goes
- # in the branch delay slot
- sw v0, errno
- li v0, -1
-1: jr ra
- END(__syscall_common)
diff --git a/klibc/klibc/arch/mips/sysstub.ph b/klibc/klibc/arch/mips/sysstub.ph
deleted file mode 100644
index a71d5d02ef..0000000000
--- a/klibc/klibc/arch/mips/sysstub.ph
+++ /dev/null
@@ -1,30 +0,0 @@
-# -*- perl -*-
-#
-# arch/mips/sysstub.ph
-#
-# Script to generate system call stubs
-#
-
-# On MIPS, most system calls follow the standard convention, with the
-# system call number in r0 (v0), return an error value in r19 (a3) as
-# well as the return value in r0 (v0).
-
-sub make_sysstub($$$$$@) {
- my($outputdir, $fname, $type, $sname, $stype, @args) = @_;
-
- $stype = $stype || 'common';
- open(OUT, '>', "${outputdir}/${fname}.S");
- print OUT "#include <asm/asm.h>\n";
- print OUT "#include <asm/regdef.h>\n";
- print OUT "#include <asm/unistd.h>\n";
- print OUT "\n";
- print OUT "\t.set noreorder\n";
- print OUT "\n";
- print OUT "LEAF(${fname})\n";
- print OUT "\tj\t__syscall_${stype}\n";
- print OUT "\t li\tv0, __NR_${sname}\n";
- print OUT "\tEND(${fname})\n";
- close(OUT);
-}
-
-1;
diff --git a/klibc/klibc/arch/mips/vfork.S b/klibc/klibc/arch/mips/vfork.S
deleted file mode 100644
index 9829867fab..0000000000
--- a/klibc/klibc/arch/mips/vfork.S
+++ /dev/null
@@ -1,16 +0,0 @@
-#include <asm/asm.h>
-#include <asm/regdef.h>
-#include <asm/unistd.h>
-
-#define CLONE_VM 0x00000100
-#define CLONE_VFORK 0x00004000
-#define SIGCHLD 18
-
- .set noreorder
-
-LEAF(vfork)
- li a0, CLONE_VFORK | CLONE_VM | SIGCHLD
- li a1, 0
- j __syscall_common
- li v0, __NR_clone
- END(vfork)
diff --git a/klibc/klibc/arch/mips64/MCONFIG b/klibc/klibc/arch/mips64/MCONFIG
deleted file mode 100644
index 66405e4373..0000000000
--- a/klibc/klibc/arch/mips64/MCONFIG
+++ /dev/null
@@ -1,11 +0,0 @@
-# -*- makefile -*-
-#
-# arch/mips64/MCONFIG
-#
-# Special rules for this architecture. Note that this is actually
-# included from the main Makefile, and that pathnames should be
-# accordingly.
-#
-
-OPTFLAGS = -Os
-BITSIZE = 64
diff --git a/klibc/klibc/arch/mips64/Makefile.inc b/klibc/klibc/arch/mips64/Makefile.inc
deleted file mode 100644
index 4a9529adca..0000000000
--- a/klibc/klibc/arch/mips64/Makefile.inc
+++ /dev/null
@@ -1,10 +0,0 @@
-# -*- makefile -*-
-#
-# arch/mips64/Makefile.inc
-#
-# Special rules for this architecture. Note that this is actually
-# included from the main Makefile, and that pathnames should be
-# accordingly.
-#
-
-archclean:
diff --git a/klibc/klibc/arch/parisc/MCONFIG b/klibc/klibc/arch/parisc/MCONFIG
deleted file mode 100644
index 93a31707c6..0000000000
--- a/klibc/klibc/arch/parisc/MCONFIG
+++ /dev/null
@@ -1,11 +0,0 @@
-# -*- makefile -*-
-#
-# arch/parisc/MCONFIG
-#
-# Special rules for this architecture. Note that this is actually
-# included from the main Makefile, and that pathnames should be
-# accordingly.
-#
-
-OPTFLAGS = -Os -fomit-frame-pointer
-BITSIZE = 32
diff --git a/klibc/klibc/arch/parisc/Makefile.inc b/klibc/klibc/arch/parisc/Makefile.inc
deleted file mode 100644
index 980a543ed2..0000000000
--- a/klibc/klibc/arch/parisc/Makefile.inc
+++ /dev/null
@@ -1,19 +0,0 @@
-# -*- makefile -*-
-#
-# arch/parisc/Makefile.inc
-#
-# Special rules for this architecture. Note that this is actually
-# included from the main Makefile, and that pathnames should be
-# accordingly.
-#
-
-ARCHOBJS = \
- arch/$(ARCH)/setjmp.o \
- arch/$(ARCH)/syscall.o
-
-ARCHOOBJS = $(patsubst %o,%.lo,%(ARCHOBJS))
-
-archclean:
-
-arch/$(ARCH)/syscall.o: arch/$(ARCH)/syscall.c
- $(CC) $(CFLAGS) -ffixed-r20 -c -o $@ $<
diff --git a/klibc/klibc/arch/parisc/crt0.S b/klibc/klibc/arch/parisc/crt0.S
deleted file mode 100644
index fb0bd373ee..0000000000
--- a/klibc/klibc/arch/parisc/crt0.S
+++ /dev/null
@@ -1,34 +0,0 @@
- .align 4
-
- .import $global$, data
- .import __libc_init, code
-
- .global _start
- .export _start, ENTRY
- .type _start,@function
-
- .proc
- .callinfo
-
-_start:
-/* extend the stack by 64-bytes */
- ldo 64(%sp), %sp
-
-/* %r25 = argc
- * %r24 = argv
- * envp = argv + (argc + 1)
- * elfdata = (argv - 4)
- */
- ldo -4(%r24), %r26
-
-/* load global data */
- ldil L%$global$, %dp
- ldo R%$global$(%dp), %dp
-
-/* branch to __libc_init */
- bl __libc_init,%r2
- nop
-/* break miserably if we ever return */
- iitlbp %r0,(%r0) /* illegal instruction */
- nop
- .procend
diff --git a/klibc/klibc/arch/parisc/setjmp.S b/klibc/klibc/arch/parisc/setjmp.S
deleted file mode 100644
index aebe03a5ed..0000000000
--- a/klibc/klibc/arch/parisc/setjmp.S
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * parisc specific setjmp/longjmp routines
- *
- */
-
- .text
- .align 4
- .global setjmp
- .export setjmp, code
- .proc
- .callinfo
-setjmp:
- stw %r3,0(%r26)
- stw %r4,8(%r26)
- stw %r5,12(%r26)
- stw %r6,16(%r26)
- stw %r7,20(%r26)
- stw %r8,24(%r26)
- stw %r9,28(%r26)
- stw %r10,32(%r26)
- stw %r11,36(%r26)
- stw %r12,40(%r26)
- stw %r13,44(%r26)
- stw %r14,48(%r26)
- stw %r15,52(%r26)
- stw %r16,56(%r26)
- stw %r17,60(%r26)
- stw %r18,64(%r26)
- stw %r19,68(%r26)
- stw %r27,72(%r26)
- stw %r30,76(%r26)
- stw %rp,80(%r26)
- ldo 88(%r26),%r19
- fstd,ma %fr12,8(%r19)
- fstd,ma %fr13,8(%r19)
- fstd,ma %fr14,8(%r19)
- fstd,ma %fr15,8(%r19)
- fstd,ma %fr16,8(%r19)
- fstd,ma %fr17,8(%r19)
- fstd,ma %fr18,8(%r19)
- fstd,ma %fr19,8(%r19)
- fstd,ma %fr20,8(%r19)
- fstd %fr21,0(%r19)
- bv %r0(%rp)
- copy %r0,%r28
- .procend
-
- .text
- .align 4
- .global longjmp
- .export longjmp, code
- .proc
- .callinfo
-longjmp:
- ldw 0(%r26),%r3
- ldw 8(%r26),%r4
- ldw 12(%r26),%r5
- ldw 16(%r26),%r6
- ldw 20(%r26),%r7
- ldw 24(%r26),%r8
- ldw 28(%r26),%r9
- ldw 32(%r26),%r10
- ldw 36(%r26),%r11
- ldw 40(%r26),%r12
- ldw 44(%r26),%r13
- ldw 48(%r26),%r14
- ldw 52(%r26),%r15
- ldw 56(%r26),%r16
- ldw 60(%r26),%r17
- ldw 64(%r26),%r18
- ldw 68(%r26),%r19
- ldw 72(%r26),%r27
- ldw 76(%r26),%r30
- ldw 80(%r26),%rp
- ldo 88(%r26),%r20
- fldd,ma 8(%r20),%fr12
- fldd,ma 8(%r20),%fr13
- fldd,ma 8(%r20),%fr14
- fldd,ma 8(%r20),%fr15
- fldd,ma 8(%r20),%fr16
- fldd,ma 8(%r20),%fr17
- fldd,ma 8(%r20),%fr18
- fldd,ma 8(%r20),%fr19
- fldd,ma 8(%r20),%fr20
- fldd 0(%r20),%fr21
- bv %r0(%rp)
- copy %r25,%r28
- .procend
diff --git a/klibc/klibc/arch/parisc/syscall.c b/klibc/klibc/arch/parisc/syscall.c
deleted file mode 100644
index 99ef5fe103..0000000000
--- a/klibc/klibc/arch/parisc/syscall.c
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * arch/parisc/syscall.c
- *
- * This function is called from a stub with %r20 already set up.
- * Compile this function with -ffixed-r20 so that it doesn't clobber
- * this register by mistake.
- */
-
-#include <klibc/compiler.h>
-#include <errno.h>
-
-long __syscall_common(long a0, long a1, long a2, long a3, long a4, long a5)
-{
- register unsigned long rv asm ("r28");
-
- asm volatile("\tble 0x100(%%sr2, %%r0)\n"
- : "=r" (rv)
- : "r" (a0), "r" (a1), "r" (a2), "r" (a3), "r" (a4), "r" (a5)
- : "%r1", "%r2", "%r29", "%r31");
-
- if ( __unlikely(rv >= -4095UL) ) {
- errno = -rv;
- return -1L;
- } else {
- return (long)rv;
- }
-}
-
-
diff --git a/klibc/klibc/arch/parisc/sysstub.ph b/klibc/klibc/arch/parisc/sysstub.ph
deleted file mode 100644
index e2196acaf3..0000000000
--- a/klibc/klibc/arch/parisc/sysstub.ph
+++ /dev/null
@@ -1,28 +0,0 @@
-# -*- perl -*-
-#
-# arch/parisc/sysstub.ph
-#
-# Script to generate system call stubs
-#
-
-sub make_sysstub($$$$$@) {
- my($outputdir, $fname, $type, $sname, $stype, @args) = @_;
-
- open(OUT, '>', "${outputdir}/${fname}.S");
- print OUT "#include <asm/unistd.h>\n";
- print OUT "\n";
- print OUT "\t.text\n";
- print OUT "\t.align 4\n";
- print OUT "\t.import __syscall_common, code\n";
- print OUT "\t.global ${fname}\n";
- print OUT "\t.export ${fname}, code\n";
- print OUT "\t.proc\n";
- print OUT "\.callinfo\n";
- print OUT "${fname}:\n";
- print OUT "\tb\t__syscall_common\n";
- print OUT "\t ldo\t__NR_${sname}(%r0),%r20\n";
- print OUT "\t.procend\n";
- close(OUT);
-}
-
-1;
diff --git a/klibc/klibc/arch/ppc/MCONFIG b/klibc/klibc/arch/ppc/MCONFIG
deleted file mode 100644
index 82c7107013..0000000000
--- a/klibc/klibc/arch/ppc/MCONFIG
+++ /dev/null
@@ -1,18 +0,0 @@
-# -*- makefile -*-
-#
-# arch/ppc/MCONFIG
-#
-# Special rules for this architecture. Note that this is actually
-# included from the main Makefile, and that pathnames should be
-# accordingly.
-#
-
-OPTFLAGS = -Os
-BITSIZE = 32
-
-# Extra linkflags when building the shared version of the library
-# This address needs to be reachable using normal inter-module
-# calls, and work on the memory models for this architecture
-# 256-16 MB - normal binaries start at 256 MB, and jumps are limited
-# to +/- 16 MB
-SHAREDFLAGS = -Ttext 0x0f000200
diff --git a/klibc/klibc/arch/ppc/Makefile.inc b/klibc/klibc/arch/ppc/Makefile.inc
deleted file mode 100644
index c6bb975f0f..0000000000
--- a/klibc/klibc/arch/ppc/Makefile.inc
+++ /dev/null
@@ -1,22 +0,0 @@
-# -*- makefile -*-
-#
-# arch/ppc/Makefile.inc
-#
-# Special rules for this architecture. Note that this is actually
-# included from the main Makefile, and that pathnames should be
-# accordingly.
-#
-
-ARCHOBJS = \
- arch/$(ARCH)/setjmp.o \
- arch/$(ARCH)/syscall.o \
- libgcc/__divdi3.o \
- libgcc/__moddi3.o \
- libgcc/__udivdi3.o \
- libgcc/__umoddi3.o \
- libgcc/__udivmoddi4.o
-
-
-ARCHSOOBJS = $(patsubst %.o,%.lo,$(ARCHOBJS))
-
-archclean:
diff --git a/klibc/klibc/arch/ppc/crt0.S b/klibc/klibc/arch/ppc/crt0.S
deleted file mode 100644
index 282f8411e4..0000000000
--- a/klibc/klibc/arch/ppc/crt0.S
+++ /dev/null
@@ -1,20 +0,0 @@
-#
-# arch/ppc/crt0.S
-#
-
- .text
- .align 4
- .type _start,@function
- .globl _start
-_start:
- stwu 1,-16(1)
- addi 3,1,16
- /*
- * the SVR4abippc.pdf specifies r7 as a pointer to
- * a termination function pointer.
- * It is unused on Linux.
- */
- mr 4,7
- bl __libc_init
-
- .size _start,.-_start
diff --git a/klibc/klibc/arch/ppc/setjmp.S b/klibc/klibc/arch/ppc/setjmp.S
deleted file mode 100644
index 3012de3ea6..0000000000
--- a/klibc/klibc/arch/ppc/setjmp.S
+++ /dev/null
@@ -1,35 +0,0 @@
-#
-# arch/ppc/setjmp.S
-#
-# Basic setjmp/longjmp implementation
-# This file was derived from the equivalent file in NetBSD
-#
-
- .text
- .align 4
- .type setjmp,@function
- .globl setjmp
-setjmp:
- mflr %r11 /* save return address */
- mfcr %r12 /* save condition register */
- mr %r10,%r1 /* save stack pointer */
- mr %r9,%r2 /* save GPR2 (not needed) */
- stmw %r9,0(%r3) /* save r9..r31 */
- li %r3,0 /* indicate success */
- blr /* return */
-
- .size setjmp,.-setjmp
-
- .type longjmp,@function
- .globl longjmp
-longjmp:
- lmw %r9,0(%r3) /* save r9..r31 */
- mtlr %r11 /* restore LR */
- mtcr %r12 /* restore CR */
- mr %r2,%r9 /* restore GPR2 (not needed) */
- mr %r1,%r10 /* restore stack */
- mr %r3,%r4 /* get return value */
- blr /* return */
-
- .size longjmp,.-longjmp
-
diff --git a/klibc/klibc/arch/ppc/syscall.S b/klibc/klibc/arch/ppc/syscall.S
deleted file mode 100644
index 0a7c37c903..0000000000
--- a/klibc/klibc/arch/ppc/syscall.S
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * arch/ppc/syscall.S
- *
- * Common error-handling path for system calls.
- */
-
- .text
- .align 2
- .globl __syscall_error
- .type __syscall_error,@function
-__syscall_error:
- lis 9,errno@ha
- stw 3,errno@l(9)
- li 3,-1
- blr
- .size __syscall_error,.-__syscall_error
diff --git a/klibc/klibc/arch/ppc/sysstub.ph b/klibc/klibc/arch/ppc/sysstub.ph
deleted file mode 100644
index 3b3916c726..0000000000
--- a/klibc/klibc/arch/ppc/sysstub.ph
+++ /dev/null
@@ -1,25 +0,0 @@
-# -*- perl -*-
-#
-# arch/ppc/sysstub.ph
-#
-# Script to generate system call stubs
-#
-
-sub make_sysstub($$$$$@) {
- my($outputdir, $fname, $type, $sname, $stype, @args) = @_;
-
- open(OUT, '>', "${outputdir}/${fname}.S");
- print OUT "#include <asm/unistd.h>\n";
- print OUT "\n";
- print OUT "\t.type ${fname},\@function\n";
- print OUT "\t.globl ${fname}\n";
- print OUT "${fname}:\n";
- print OUT "\tli 0,__NR_${sname}\n";
- print OUT "\tsc\n";
- print OUT "\tbnslr\n";
- print OUT "\tb __syscall_error\n";
- print OUT "\t.size ${fname},.-${fname}\n";
- close(OUT);
-}
-
-1;
diff --git a/klibc/klibc/arch/ppc64/MCONFIG b/klibc/klibc/arch/ppc64/MCONFIG
deleted file mode 100644
index 9aba2ddbb6..0000000000
--- a/klibc/klibc/arch/ppc64/MCONFIG
+++ /dev/null
@@ -1,20 +0,0 @@
-# -*- makefile -*-
-#
-# arch/ppc64/MCONFIG
-#
-# Special rules for this architecture. Note that this is actually
-# included from the main Makefile, and that pathnames should be
-# accordingly.
-#
-
-ARCHREQFLAGS = -m64 -mcall-aixdesc
-OPTFLAGS = -Os
-BITSIZE = 64
-LDFLAGS = -m elf64ppc
-
-# Extra linkflags when building the shared version of the library
-# This address needs to be reachable using normal inter-module
-# calls, and work on the memory models for this architecture
-# 256-16 MB - normal binaries start at 256 MB, and jumps are limited
-# to +/- 16 MB
-SHAREDFLAGS = -Ttext 0x0f000200
diff --git a/klibc/klibc/arch/ppc64/Makefile.inc b/klibc/klibc/arch/ppc64/Makefile.inc
deleted file mode 100644
index d1e128fdce..0000000000
--- a/klibc/klibc/arch/ppc64/Makefile.inc
+++ /dev/null
@@ -1,25 +0,0 @@
-# -*- makefile -*-
-#
-# arch/ppc64/Makefile.inc
-#
-# Special rules for this architecture. Note that this is actually
-# included from the main Makefile, and that pathnames should be
-# accordingly.
-#
-
-ARCHOBJS = \
- arch/$(ARCH)/setjmp.o \
- arch/$(ARCH)/syscall.o
-
-ARCHSOOBJS = $(patsubst %.o,%.lo,$(ARCHOBJS))
-
-INTERP_O = interp1.o
-
-interp.o: interp1.o klibc.got
- $(LD) $(LDFLAGS) -r -o $@ interp1.o klibc.got
-
-klibc.got: $(SOHASH)
- $(OBJCOPY) -j .got $< $@
-
-archclean:
- rm -f klibc.got
diff --git a/klibc/klibc/arch/ppc64/crt0.S b/klibc/klibc/arch/ppc64/crt0.S
deleted file mode 100644
index 872d2a0791..0000000000
--- a/klibc/klibc/arch/ppc64/crt0.S
+++ /dev/null
@@ -1,32 +0,0 @@
-#
-# arch/ppc64/crt0.S
-#
-# void _start(void)
-# {
-# /* Divine up argc, argv, and envp */
-# environ = envp;
-# exit(main(argc, argv, envp));
-# }
-#
-
- .section ".toc","aw"
-.LC0: .tc environ[TC],environ
-
- .section ".opd","aw"
- .align 3
- .globl _start
-_start:
- .quad ._start
- .quad .TOC.@tocbase, 0
-
- .text
- .globl ._start
- .type ._start,@function
-._start:
- stdu %r1,-32(%r1)
- addi %r3,%r1,32
- mr %r4,%r7 /* fini */
- b .__libc_init
- nop
-
- .size _start,.-_start
diff --git a/klibc/klibc/arch/ppc64/setjmp.S b/klibc/klibc/arch/ppc64/setjmp.S
deleted file mode 100644
index 30db419140..0000000000
--- a/klibc/klibc/arch/ppc64/setjmp.S
+++ /dev/null
@@ -1,85 +0,0 @@
-#
-# arch/ppc64/setjmp.S
-#
-# Basic setjmp/longjmp implementation
-#
-
- .text
- .align 4
-
- .section ".opd","aw"
-setjmp:
- .quad .setjmp,.TOC.@tocbase,0
- .previous
- .size setjmp,24
- .type .setjmp,@function
- .globl setjmp
- .globl .setjmp
-.setjmp:
- mflr %r11 /* save return address */
- mfcr %r12 /* save condition register */
- std %r2,0(%r3) /* save TOC pointer (not needed) */
- stdu %r1,8(%r3) /* save stack pointer */
- stdu %r11,8(%r3)
- stdu %r12,8(%r3)
- stdu %r13,8(%r3) /* save caller saved regs */
- stdu %r14,8(%r3)
- stdu %r15,8(%r3)
- stdu %r16,8(%r3)
- stdu %r17,8(%r3)
- stdu %r18,8(%r3)
- stdu %r19,8(%r3)
- stdu %r20,8(%r3)
- stdu %r21,8(%r3)
- stdu %r22,8(%r3)
- stdu %r23,8(%r3)
- stdu %r24,8(%r3)
- stdu %r25,8(%r3)
- stdu %r26,8(%r3)
- stdu %r27,8(%r3)
- stdu %r28,8(%r3)
- stdu %r29,8(%r3)
- stdu %r30,8(%r3)
- std %r31,8(%r3)
- li %r3,0 /* indicate success */
- blr /* return */
-
- .size .setjmp,.-.setjmp
- .section ".opd","aw"
-longjmp:
- .quad .longjmp,.TOC.@tocbase,0
- .previous
- .size longjmp,24
- .type .longjmp,@function
- .globl longjmp
- .globl .longjmp
-.longjmp:
- ld %r2,0(%r3) /* restore TOC pointer (not needed) */
- ldu %r1,8(%r3) /* restore stack */
- ldu %r11,8(%r3)
- ldu %r12,8(%r3)
- ldu %r13,8(%r3) /* restore caller saved regs */
- ldu %r14,8(%r3)
- ldu %r15,8(%r3)
- ldu %r16,8(%r3)
- ldu %r17,8(%r3)
- ldu %r18,8(%r3)
- ldu %r19,8(%r3)
- ldu %r20,8(%r3)
- ldu %r21,8(%r3)
- ldu %r22,8(%r3)
- ldu %r23,8(%r3)
- ldu %r24,8(%r3)
- ldu %r25,8(%r3)
- ldu %r26,8(%r3)
- ldu %r27,8(%r3)
- ldu %r28,8(%r3)
- ldu %r29,8(%r3)
- ldu %r30,8(%r3)
- ld %r31,8(%r3)
- mtlr %r11 /* restore LR */
- mtcr %r12 /* restore CR */
- mr %r3,%r4 /* get return value */
- blr /* return */
-
- .size .longjmp,.-.longjmp
diff --git a/klibc/klibc/arch/ppc64/syscall.c b/klibc/klibc/arch/ppc64/syscall.c
deleted file mode 100644
index a5895fe88e..0000000000
--- a/klibc/klibc/arch/ppc64/syscall.c
+++ /dev/null
@@ -1,14 +0,0 @@
-/*
- * arch/ppc64/syscall.c
- *
- * Common error-handling path for system calls.
- * The return value from __syscall_error becomes the
- * return value from the system call.
- */
-#include <errno.h>
-
-long int __syscall_error(long int err)
-{
- errno = err;
- return -1;
-}
diff --git a/klibc/klibc/arch/ppc64/sysstub.ph b/klibc/klibc/arch/ppc64/sysstub.ph
deleted file mode 100644
index 9ee93701f6..0000000000
--- a/klibc/klibc/arch/ppc64/sysstub.ph
+++ /dev/null
@@ -1,31 +0,0 @@
-# -*- perl -*-
-#
-# arch/ppc64/sysstub.ph
-#
-# Script to generate system call stubs
-#
-
-sub make_sysstub($$$$$@) {
- my($outputdir, $fname, $type, $sname, $stype, @args) = @_;
-
- open(OUT, '>', "${outputdir}/${fname}.S");
- print OUT "#include <asm/unistd.h>\n";
- print OUT "\n";
- print OUT "\t.globl ${fname}\n";
- print OUT "\t.section \".opd\",\"aw\"\n";
- print OUT "\t.align 3\n";
- print OUT "${fname}:\n";
- print OUT "\t.quad .${fname},.TOC.\@tocbase,0\n";
- print OUT "\t.text\n";
- print OUT "\t.type .${fname},\@function\n";
- print OUT "\t.globl .${fname}\n";
- print OUT ".${fname}:\n";
- print OUT "\tli 0,__NR_${sname}\n";
- print OUT "\tsc\n";
- print OUT "\tbnslr\n";
- print OUT "\tb .__syscall_error\n";
- print OUT "\t.size .${fname},.-.${fname}\n";
- close(OUT);
-}
-
-1;
diff --git a/klibc/klibc/arch/s390/MCONFIG b/klibc/klibc/arch/s390/MCONFIG
deleted file mode 100644
index 640b395b54..0000000000
--- a/klibc/klibc/arch/s390/MCONFIG
+++ /dev/null
@@ -1,13 +0,0 @@
-# -*- makefile -*-
-#
-# arch/s390/MCONFIG
-#
-# Special rules for this architecture. Note that this is actually
-# included from the main Makefile, and that pathnames should be
-# accordingly.
-#
-
-OPTFLAGS = -Os
-BITSIZE = 32
-
-SHAREDFLAGS = -Ttext 0x40000200
diff --git a/klibc/klibc/arch/s390/Makefile.inc b/klibc/klibc/arch/s390/Makefile.inc
deleted file mode 100644
index 49b64ddbc6..0000000000
--- a/klibc/klibc/arch/s390/Makefile.inc
+++ /dev/null
@@ -1,23 +0,0 @@
-# -*- makefile -*-
-#
-# arch/s390/Makefile.inc
-#
-# Special rules for this architecture. Note that this is actually
-# included from the main Makefile, and that pathnames should be
-# accordingly.
-#
-
-ARCHOBJS = \
- arch/$(ARCH)/setjmp.o \
- arch/$(ARCH)/mmap.o \
- arch/$(ARCH)/syscall.o \
- libgcc/__divdi3.o \
- libgcc/__moddi3.o \
- libgcc/__udivdi3.o \
- libgcc/__umoddi3.o \
- libgcc/__udivmoddi4.o
-
-ARCHSOOBJS = $(patsubst %.o,%.lo,$(ARCHOBJS))
-
-
-archclean:
diff --git a/klibc/klibc/arch/s390/crt0.S b/klibc/klibc/arch/s390/crt0.S
deleted file mode 100644
index 49c3e7ebc7..0000000000
--- a/klibc/klibc/arch/s390/crt0.S
+++ /dev/null
@@ -1,25 +0,0 @@
-#
-# arch/s390/crt0.S
-#
-# Does arch-specific initialization and invokes __libc_init
-# with the appropriate arguments.
-#
-# See __static_init.c or __shared_init.c for the expected
-# arguments.
-#
- .text
- .align 4
- .type _start,@function
- .globl _start
-_start:
- lr %r2,%r15
- lhi %r3,0
- ahi %r15,-96
- bras %r1,.L0
-.L0:
- l %r1,.L1-.L0(%r1)
- br %r1
-.L1:
- .long __libc_init
-
- .size _start,.-_start
diff --git a/klibc/klibc/arch/s390/mmap.c b/klibc/klibc/arch/s390/mmap.c
deleted file mode 100644
index 51ff07f44c..0000000000
--- a/klibc/klibc/arch/s390/mmap.c
+++ /dev/null
@@ -1,41 +0,0 @@
-#include <sys/types.h>
-#include <linux/unistd.h>
-
-struct mmap_arg_struct {
- unsigned long addr;
- unsigned long len;
- unsigned long prot;
- unsigned long flags;
- unsigned long fd;
- unsigned long offset;
-};
-
-void * __mmap2(void * addr, size_t len, int prot, int flags,
- int fd, long offset)
-{
- struct mmap_arg_struct args = {
- (unsigned long) addr,
- (unsigned long) len,
- (unsigned long) prot,
- (unsigned long) flags,
- (unsigned long) fd,
- (unsigned long) offset,
- };
-
- register struct mmap_arg_struct *__arg1 asm("2") = &args;
- register long __svcres asm("2");
- unsigned long __res;
-
- __asm__ __volatile__ (
- " svc %b1\n"
- : "=d" (__svcres)
- : "i" (__NR_mmap2),
- "0" (__arg1)
- : "1", "cc", "memory");
- __res = __svcres;
- if (__res >= (unsigned long)-125) {
- errno = -__res;
- __res = -1;
- }
- return (void *)__res;
-}
diff --git a/klibc/klibc/arch/s390/setjmp.S b/klibc/klibc/arch/s390/setjmp.S
deleted file mode 100644
index 97132680ae..0000000000
--- a/klibc/klibc/arch/s390/setjmp.S
+++ /dev/null
@@ -1,32 +0,0 @@
-#
-# arch/s390/setjmp.S
-#
-# setjmp/longjmp for the s390 architecture
-#
-
- .text
- .align 4
- .globl setjmp
- .type setjmp, @function
-setjmp:
- stm %r6,%r15,0(%r2) # save all general registers
- std %f4,40(%r2) # save fp registers f4 and f6
- std %f6,48(%r2)
- lhi %r2,0 # return 0
- br %r14
-
- .size setjmp,.-setjmp
-
- .text
- .align 4
- .globl longjmp
- .type longjmp, @function
-longjmp:
- lr %r1,%r2 # jmp_buf
- lr %r2,%r3 # return value
- ld %f6,48(%r1) # restore all saved registers
- ld %f4,40(%r1)
- lm %r6,%r15,0(%r1)
- br %r14 # return to restored address
-
- .size longjmp,.-longjmp
diff --git a/klibc/klibc/arch/s390/syscall.c b/klibc/klibc/arch/s390/syscall.c
deleted file mode 100644
index c0f17c453c..0000000000
--- a/klibc/klibc/arch/s390/syscall.c
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * arch/s390/syscall.c
- *
- * Common error-handling path for system calls.
- * The return value from __syscall_common becomes the
- * return value from the system call.
- */
-#include <errno.h>
-
-long int __syscall_common(long int err)
-{
- if ((unsigned long)(err) < (unsigned long)(-125))
- return err;
- errno = err;
- return -1;
-}
diff --git a/klibc/klibc/arch/s390/sysstub.ph b/klibc/klibc/arch/s390/sysstub.ph
deleted file mode 100644
index 35f40a0865..0000000000
--- a/klibc/klibc/arch/s390/sysstub.ph
+++ /dev/null
@@ -1,31 +0,0 @@
-# -*- perl -*-
-#
-# arch/s390/sysstub.ph
-#
-# Script to generate system call stubs
-#
-
-sub make_sysstub($$$$$@) {
- my($outputdir, $fname, $type, $sname, $stype, @args) = @_;
-
- open(OUT, '>', "${outputdir}/${fname}.S");
- print OUT "#include <asm/unistd.h>\n";
- print OUT "\n";
- print OUT "\t.type ${fname},\@function\n";
- print OUT "\t.globl ${fname}\n";
- print OUT "${fname}:\n";
- print OUT ".if __NR_${sname} < 256\n";
- print OUT "\tsvc __NR_${sname}\n";
- print OUT ".else\n";
- print OUT "\tlhi %r1,__NR_${sname}\n";
- print OUT "\tsvc 0\n";
- print OUT ".endif\n";
- print OUT "\tbras %r3,1f\n";
- print OUT "\t.long __syscall_common\n";
- print OUT "1:\tl %r3,0(%r3)\n";
- print OUT "\tbr %r3\n";
- print OUT "\t.size ${fname},.-${fname}\n";
- close(OUT);
-}
-
-1;
diff --git a/klibc/klibc/arch/s390x/MCONFIG b/klibc/klibc/arch/s390x/MCONFIG
deleted file mode 100644
index 081a0bbb52..0000000000
--- a/klibc/klibc/arch/s390x/MCONFIG
+++ /dev/null
@@ -1,13 +0,0 @@
-# -*- makefile -*-
-#
-# arch/s390x/MCONFIG
-#
-# Special rules for this architecture. Note that this is actually
-# included from the main Makefile, and that pathnames should be
-# accordingly.
-#
-
-OPTFLAGS = -Os
-BITSIZE = 64
-
-SHAREDFLAGS = -Ttext 0x40000200
diff --git a/klibc/klibc/arch/s390x/Makefile.inc b/klibc/klibc/arch/s390x/Makefile.inc
deleted file mode 100644
index 9d614e07b2..0000000000
--- a/klibc/klibc/arch/s390x/Makefile.inc
+++ /dev/null
@@ -1,18 +0,0 @@
-# -*- makefile -*-
-#
-# arch/s390x/Makefile.inc
-#
-# Special rules for this architecture. Note that this is actually
-# included from the main Makefile, and that pathnames should be
-# accordingly.
-#
-
-ARCHOBJS = \
- arch/$(ARCH)/setjmp.o \
- arch/$(ARCH)/mmap.o \
- arch/$(ARCH)/syscall.o
-
-ARCHSOOBJS = $(patsubst %.o,%.lo,$(ARCHOBJS))
-
-
-archclean:
diff --git a/klibc/klibc/arch/s390x/crt0.S b/klibc/klibc/arch/s390x/crt0.S
deleted file mode 100644
index de35664904..0000000000
--- a/klibc/klibc/arch/s390x/crt0.S
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# arch/s390/crt0.S
-#
-# Does arch-specific initialization and invokes __libc_init
-# with the appropriate arguments.
-#
-# See __static_init.c or __shared_init.c for the expected
-# arguments.
-#
-
- .text
- .align 4
- .type _start,@function
- .globl _start
-_start:
- lgr %r2,%r15
- lghi %r3,0
- aghi %r15,-160
- jg __libc_init
-
- .size _start,.-_start
diff --git a/klibc/klibc/arch/s390x/mmap.c b/klibc/klibc/arch/s390x/mmap.c
deleted file mode 100644
index 158f0933a4..0000000000
--- a/klibc/klibc/arch/s390x/mmap.c
+++ /dev/null
@@ -1,41 +0,0 @@
-#include <sys/types.h>
-#include <linux/unistd.h>
-
-struct mmap_arg_struct {
- unsigned long addr;
- unsigned long len;
- unsigned long prot;
- unsigned long flags;
- unsigned long fd;
- unsigned long offset;
-};
-
-void * mmap(void * addr, size_t len, int prot, int flags,
- int fd, off_t offset)
-{
- struct mmap_arg_struct args = {
- (unsigned long) addr,
- (unsigned long) len,
- (unsigned long) prot,
- (unsigned long) flags,
- (unsigned long) fd,
- (unsigned long) offset,
- };
-
- register struct mmap_arg_struct *__arg1 asm("2") = &args;
- register long __svcres asm("2");
- unsigned long __res;
-
- __asm__ __volatile__ (
- " svc %b1\n"
- : "=d" (__svcres)
- : "i" (__NR_mmap),
- "0" (__arg1)
- : "1", "cc", "memory");
- __res = __svcres;
- if (__res >= (unsigned long)-125) {
- errno = -__res;
- __res = -1;
- }
- return (void *)__res;
-}
diff --git a/klibc/klibc/arch/s390x/setjmp.S b/klibc/klibc/arch/s390x/setjmp.S
deleted file mode 100644
index 251c57d43a..0000000000
--- a/klibc/klibc/arch/s390x/setjmp.S
+++ /dev/null
@@ -1,36 +0,0 @@
-#
-# arch/s390x/setjmp.S
-#
-# setjmp/longjmp for the s390x architecture
-#
-
- .text
- .align 4
- .globl setjmp
- .type setjmp, @function
-setjmp:
- stmg %r6,%r15,0(%r2) # save all general registers
- std %f1,80(%r2) # save fp registers f4 and f6
- std %f3,88(%r2)
- std %f5,96(%r2)
- std %f7,104(%r2)
- lghi %r2,0 # return 0
- br %r14
-
- .size setjmp,.-setjmp
-
- .text
- .align 4
- .globl longjmp
- .type longjmp, @function
-longjmp:
- lgr %r1,%r2 # jmp_buf
- lgr %r2,%r3 # return value
- ld %f7,104(%r1) # restore all saved registers
- ld %f5,96(%r1)
- ld %f3,88(%r1)
- ld %f1,80(%r1)
- lmg %r6,%r15,0(%r1)
- br %r14 # return to restored address
-
- .size longjmp,.-longjmp
diff --git a/klibc/klibc/arch/s390x/syscall.c b/klibc/klibc/arch/s390x/syscall.c
deleted file mode 100644
index c0f17c453c..0000000000
--- a/klibc/klibc/arch/s390x/syscall.c
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * arch/s390/syscall.c
- *
- * Common error-handling path for system calls.
- * The return value from __syscall_common becomes the
- * return value from the system call.
- */
-#include <errno.h>
-
-long int __syscall_common(long int err)
-{
- if ((unsigned long)(err) < (unsigned long)(-125))
- return err;
- errno = err;
- return -1;
-}
diff --git a/klibc/klibc/arch/s390x/sysstub.ph b/klibc/klibc/arch/s390x/sysstub.ph
deleted file mode 100644
index 55c721b558..0000000000
--- a/klibc/klibc/arch/s390x/sysstub.ph
+++ /dev/null
@@ -1,28 +0,0 @@
-# -*- perl -*-
-#
-# arch/s390x/sysstub.ph
-#
-# Script to generate system call stubs
-#
-
-sub make_sysstub($$$$$@) {
- my($outputdir, $fname, $type, $sname, $stype, @args) = @_;
-
- open(OUT, '>', "${outputdir}/${fname}.S");
- print OUT "#include <asm/unistd.h>\n";
- print OUT "\n";
- print OUT "\t.type ${fname},\@function\n";
- print OUT "\t.globl ${fname}\n";
- print OUT "${fname}:\n";
- print OUT ".if __NR_${sname} < 256\n";
- print OUT "\tsvc __NR_${sname}\n";
- print OUT ".else\n";
- print OUT "\tlghi %r1,__NR_${sname}\n";
- print OUT "\tsvc 0\n";
- print OUT ".endif\n";
- print OUT "\tbrasl %r3,__syscall_common\n";
- print OUT "\t.size ${fname},.-${fname}\n";
- close(OUT);
-}
-
-1;
diff --git a/klibc/klibc/arch/sh/MCONFIG b/klibc/klibc/arch/sh/MCONFIG
deleted file mode 100644
index 6cd4e5c839..0000000000
--- a/klibc/klibc/arch/sh/MCONFIG
+++ /dev/null
@@ -1,19 +0,0 @@
-# -*- makefile -*-
-#
-# arch/sh/MCONFIG
-#
-# Special rules for this architecture. Note that this is actually
-# included from the main Makefile, and that pathnames should be
-# accordingly.
-#
-
-ARCHREGFLAGS = -m4 -mno-implicit-fp
-OPTFLAGS = -Os -fomit-frame-pointer
-BITSIZE = 32
-
-# Extra linkflags when building the shared version of the library
-# This address needs to be reachable using normal inter-module
-# calls, and work on the memory models for this architecture
-# 2 MB -- the normal starting point for text is 4 MB.
-SHAREDFLAGS = -Ttext 0x00200200
-
diff --git a/klibc/klibc/arch/sh/Makefile.inc b/klibc/klibc/arch/sh/Makefile.inc
deleted file mode 100644
index ccabfa496b..0000000000
--- a/klibc/klibc/arch/sh/Makefile.inc
+++ /dev/null
@@ -1,15 +0,0 @@
-# -*- makefile -*-
-#
-# arch/sh/Makefile.inc
-#
-# Special rules for this architecture. Note that this is actually
-# included from the main Makefile, and that pathnames should be
-# accordingly.
-#
-
-ARCHOBJS = arch/sh/setjmp.o \
- arch/sh/syscall.o
-
-ARCHSOOBJS = $(patsubst %.o,%.lo,$(ARCHOBJS))
-
-archclean:
diff --git a/klibc/klibc/arch/sh/crt0.S b/klibc/klibc/arch/sh/crt0.S
deleted file mode 100644
index 21a37655f2..0000000000
--- a/klibc/klibc/arch/sh/crt0.S
+++ /dev/null
@@ -1,27 +0,0 @@
-#
-# arch/sh/crt0.S
-#
-# Does arch-specific initialization and invokes __libc_init
-# with the appropriate arguments.
-#
-# See __static_init.c or __shared_init.c for the expected
-# arguments.
-#
-
- .text
- .align 2
- .type _start,#function
- .globl _start
-
-_start:
- mov r15, r4
- mov #0, r5
- mov.l 1f, r0
-
- jsr @r0
- nop
-
- .align 2
-1: .long __libc_init
-
- .size _start,.-_start
diff --git a/klibc/klibc/arch/sh/setjmp.S b/klibc/klibc/arch/sh/setjmp.S
deleted file mode 100644
index 63f760283f..0000000000
--- a/klibc/klibc/arch/sh/setjmp.S
+++ /dev/null
@@ -1,65 +0,0 @@
-#
-# arch/sh/setjmp.S
-#
-# setjmp/longjmp for the SuperH architecture
-#
-
-#
-# The jmp_buf is assumed to contain the following, in order:
-#
-# r8
-# r9
-# r10
-# r11
-# r12
-# r13
-# r14
-# r15
-# pr
-#
-
- .text
- .align 2
-
- .globl setjmp
- .type setjmp, #function
-
-setjmp:
- add #(9*4), r4
- sts.l pr, @-r4
- mov.l r15, @-r4
- mov.l r14, @-r4
- mov.l r13, @-r4
- mov.l r12, @-r4
- mov.l r11, @-r4
- mov.l r10, @-r4
- mov.l r9, @-r4
- mov.l r8, @-r4
- rts
- mov #0, r0
-
- .size setjmp,.-setjmp
-
- .align 2
- .globl longjmp
- .type setjmp, #function
-
-longjmp:
- mov.l @r4+, r8
- mov.l @r4+, r9
- mov.l @r4+, r10
- mov.l @r4+, r11
- mov.l @r4+, r12
- mov.l @r4+, r13
- mov.l @r4+, r14
- mov.l @r4+, r15
- lds.l @r4+, pr
- mov r5, r0
- tst r0, r0
- bf 1f
- mov #1, r0 ! in case val==0
-1: rts
- nop
-
- .size longjmp,.-longjmp
-
diff --git a/klibc/klibc/arch/sh/syscall.S b/klibc/klibc/arch/sh/syscall.S
deleted file mode 100644
index 41a0486679..0000000000
--- a/klibc/klibc/arch/sh/syscall.S
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * arch/sh/syscall.S
- *
- * On sh, r3 contains the syscall number (set by generated stub);
- * r4..r7 contain arguments 0-3 per the standard calling convention,
- * and arguments 4-5 are passed in r0 and r1.
- *
- * The return value is in r3 rather than standard r0.
- */
-
- .section ".text.syscall","ax"
- .align 2
- .globl ___syscall_common
- .type ___syscall_common,@function
-___syscall_common:
- mov.l @(sp),r0
- mov.l @(4,sp),r1
- trapa #0x15
- mov.l 1f,r0
- cmp/hs r0,r3
- bt/s 3f
- neg r3,r4
- mov.l 2f,r5
- mov.l r4,@r5
- rts
- mov #-1,r0
-3:
- rts
- mov r3,r0
-
- .align 2
-1: .long -4096 /* Errno limit */
-2: .long errno
-
- .size ___syscall_common,.-___syscall_common
diff --git a/klibc/klibc/arch/sh/sysstub.ph b/klibc/klibc/arch/sh/sysstub.ph
deleted file mode 100644
index ce04b739e9..0000000000
--- a/klibc/klibc/arch/sh/sysstub.ph
+++ /dev/null
@@ -1,34 +0,0 @@
-# -*- perl -*-
-#
-# arch/sh/sysstub.ph
-#
-# Script to generate system call stubs
-#
-
-sub make_sysstub($$$$$@) {
- my($outputdir, $fname, $type, $sname, $stype, @args) = @_;
-
- open(OUT, '>', "${outputdir}/${fname}.S");
- print OUT "#include <asm/unistd.h>\n";
- print OUT "\n";
- print OUT "\t.section\t\".text.syscall\",\"ax\"\n";
- print OUT "\t.type\t${fname},\#function\n";
- print OUT "\t.globl\t${fname}\n";
- print OUT "\t.align\t2\n";
- print OUT "${fname}:\n";
- print OUT "\tbra\t__syscall_common\n";
- print OUT "#if __NR_${sname} >= 128\n";
- print OUT "\t mov.l\t1f, r3\n";
- print OUT "#else\n";
- print OUT "\t mov\t# __NR_${sname}, r3\n";
- print OUT "#endif\n";
- print OUT "\t.size ${fname},.-${fname}\n";
- print OUT "\n";
- print OUT "#if __NR_${sname} >= 128\n";
- print OUT "\t.align\t2\n";
- print OUT "1:\t.long\t__NR_${sname}\n";
- print OUT "#endif\n";
- close(OUT);
-}
-
-1;
diff --git a/klibc/klibc/arch/sparc/MCONFIG b/klibc/klibc/arch/sparc/MCONFIG
deleted file mode 100644
index 3a5cbaa2e7..0000000000
--- a/klibc/klibc/arch/sparc/MCONFIG
+++ /dev/null
@@ -1,18 +0,0 @@
-# -*- makefile -*-
-#
-# arch/sparc/MCONFIG
-#
-# Special rules for this architecture. Note that this is actually
-# included from the main Makefile, and that pathnames should be
-# accordingly.
-#
-
-OPTFLAGS = -Os -m32 -mptr32
-BITSIZE = 32
-
-# Extra linkflags when building the shared version of the library
-# This address needs to be reachable using normal inter-module
-# calls, and work on the memory models for this architecture
-# Normal binaries start at 64K; the linker wants 64K alignment,
-# and call instructions have a 30-bit signed offset, << 2.
-SHAREDFLAGS = -Ttext 0x40000100
diff --git a/klibc/klibc/arch/sparc/Makefile.inc b/klibc/klibc/arch/sparc/Makefile.inc
deleted file mode 100644
index bea1dbc94e..0000000000
--- a/klibc/klibc/arch/sparc/Makefile.inc
+++ /dev/null
@@ -1,51 +0,0 @@
-# -*- makefile -*-
-#
-# arch/sparc/Makefile.inc
-#
-# Special rules for this architecture. Note that this is actually
-# included from the main Makefile, and that pathnames should be
-# accordingly.
-#
-
-ARCHOBJS = \
- arch/$(ARCH)/sdiv.o \
- arch/$(ARCH)/udiv.o \
- arch/$(ARCH)/srem.o \
- arch/$(ARCH)/urem.o \
- arch/$(ARCH)/smul.o \
- arch/$(ARCH)/umul.o \
- arch/$(ARCH)/setjmp.o \
- arch/$(ARCH)/syscall.o \
- arch/$(ARCH)/sysfork.o \
- libgcc/__divdi3.o \
- libgcc/__moddi3.o \
- libgcc/__udivdi3.o \
- libgcc/__umoddi3.o \
- libgcc/__udivmoddi4.o
-
-arch/$(ARCH)/sdiv.S: arch/$(ARCH)/divrem.m4
- @echo 'building $@ from $^'
- @(echo "define(NAME,\`.div')define(OP,\`div')define(S,\`true')"; \
- cat $^) | m4 > $@
- @chmod 444 $@
-
-arch/$(ARCH)/udiv.S: arch/$(ARCH)/divrem.m4
- @echo 'building $@ from $^'
- @(echo "define(NAME,\`.udiv')define(OP,\`div')define(S,\`false')"; \
- cat $^) | m4 > $@
- @chmod 444 $@
-
-arch/$(ARCH)/srem.S: arch/$(ARCH)/divrem.m4
- @echo 'building $@ from $^'
- @(echo "define(NAME,\`.rem')define(OP,\`rem')define(S,\`true')"; \
- cat $^) | m4 > $@
- @chmod 444 $@
-
-arch/$(ARCH)/urem.S: arch/$(ARCH)/divrem.m4
- @echo 'building $@ from $^'
- @(echo "define(NAME,\`.urem')define(OP,\`rem')define(S,\`false')"; \
- cat $^) | m4 > $@
- @chmod 444 $@
-
-archclean:
- rm -f arch/$(ARCH)/?div.S arch/$(ARCH)/?rem.S
diff --git a/klibc/klibc/arch/sparc/crt0.S b/klibc/klibc/arch/sparc/crt0.S
deleted file mode 100644
index 63db188961..0000000000
--- a/klibc/klibc/arch/sparc/crt0.S
+++ /dev/null
@@ -1,2 +0,0 @@
-#define TARGET_PTR_SIZE 32
-#include "crt0i.S"
diff --git a/klibc/klibc/arch/sparc/crt0i.S b/klibc/klibc/arch/sparc/crt0i.S
deleted file mode 100644
index 97652a3090..0000000000
--- a/klibc/klibc/arch/sparc/crt0i.S
+++ /dev/null
@@ -1,100 +0,0 @@
-! This file derived from the equivalent in newlib
-!
-! C run time start off
-
-! This file supports:
-!
-! - both 32bit pointer and 64bit pointer environments (at compile time)
-! - an imposed stack bias (of 2047) (at run time)
-! - medium/low and medium/anywhere code models (at run time)
-
-! Initial stack setup:
-!
-! bottom of stack (higher memory address)
-! ...
-! text of environment strings
-! text of argument strings
-! envp[envc] = 0 (4/8 bytes)
-! ...
-! env[0] (4/8 bytes)
-! argv[argc] = 0 (4/8 bytes)
-! ...
-! argv[0] (4/8 bytes)
-! argc (4/8 bytes)
-! register save area (64 bits by 16 registers = 128 bytes)
-! top of stack (%sp)
-
-! Stack Bias:
-!
-! It is the responsibility of the o/s to set this up.
-! We handle both a 0 and 2047 value for the stack bias.
-
-! Medium/Anywhere code model support:
-!
-! In this model %g4 points to the start of the data segment.
-! The text segment can go anywhere, but %g4 points to the *data* segment.
-! It is up to the compiler/linker to get this right.
-!
-! Since this model is statically linked the start of the data segment
-! is known at link time. Eg:
-!
-! sethi %hh(data_start), %g1
-! sethi %lm(data_start), %g4
-! or %g1, %hm(data_start), %g1
-! or %g4, %lo(data_start), %g4
-! sllx %g1, 32, %g1
-! or %g4, %g1, %g4
-!
-! FIXME: For now we just assume 0.
-
-! FIXME: if %g1 contains a non-zero value, atexit() should be invoked
-! with this value.
-
-
- .text
- .align 4
- .globl _start
- .type _start, @function
-_start:
- clr %fp
-
-! We use %g4 even if the code model is Medium/Low (simplifies the code).
-
- clr %g4 ! Medium/Anywhere base reg
-
-! If there is a stack bias in effect, account for it in %g5. Then always
-! add %g5 to stack references below. This way the code can be used with
-! or without an imposed bias.
-
- andcc %sp, 1, %g5
- bz,a .LNoBias
- nop
- mov 2047, %g5
-.LNoBias:
- add %sp, %g5, %g5
-
-! On entry, the kernel leaves room for one register frame, but
-! the C API wants more free space. Thus, we need to drop the stack
-! pointer additionally.
-
-#if TARGET_PTR_SIZE == 32
- sub %sp, 32, %sp ! make room for incoming arguments
-#else /* TARGET_PTR_SIZE == 64 */
- sub %sp, 64, %sp ! make room for incoming arguments
-#endif
-
-! Set up pointers to the ELF data structure (argc, argv, ...)
-! Pass as the first argument to __libc_init
-#if TARGET_PTR_SIZE == 32
- add %g5, 0x40, %o0
-#else /* TARGET_PTR_SIZE == 64 */
- add %g5, 0x80, %o0
-#endif
-
- call __libc_init
- mov %g1, %o1 ! This is the "atexit" pointer;
- ! pass as the second argument to __libc_init
-
-! If __libc_init returns, something is hosed. Try an illegal insn.
-! If that does not work, the o/s is hosed more than we are.
- .long 0
diff --git a/klibc/klibc/arch/sparc/divrem.m4 b/klibc/klibc/arch/sparc/divrem.m4
deleted file mode 100644
index aa4171dd88..0000000000
--- a/klibc/klibc/arch/sparc/divrem.m4
+++ /dev/null
@@ -1,276 +0,0 @@
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This software was developed by the Computer Systems Engineering group
- * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
- * contributed to Berkeley.
- *
- * 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.
- *
- * from: Header: divrem.m4,v 1.4 92/06/25 13:23:57 torek Exp
- * $NetBSD: divrem.m4,v 1.4 1997/10/09 10:07:54 lukem Exp $
- */
-
-/*
- * Division and remainder, from Appendix E of the Sparc Version 8
- * Architecture Manual, with fixes from Gordon Irlam.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
- .asciz "@(#)divrem.m4 8.1 (Berkeley) 6/4/93"
-#endif /* LIBC_SCCS and not lint */
-
-/*
- * Input: dividend and divisor in %o0 and %o1 respectively.
- *
- * m4 parameters:
- * NAME name of function to generate
- * OP OP=div => %o0 / %o1; OP=rem => %o0 % %o1
- * S S=true => signed; S=false => unsigned
- *
- * Algorithm parameters:
- * N how many bits per iteration we try to get (4)
- * WORDSIZE total number of bits (32)
- *
- * Derived constants:
- * TWOSUPN 2^N, for label generation (m4 exponentiation currently broken)
- * TOPBITS number of bits in the top `decade' of a number
- *
- * Important variables:
- * Q the partial quotient under development (initially 0)
- * R the remainder so far, initially the dividend
- * ITER number of main division loop iterations required;
- * equal to ceil(log2(quotient) / N). Note that this
- * is the log base (2^N) of the quotient.
- * V the current comparand, initially divisor*2^(ITER*N-1)
- *
- * Cost:
- * Current estimate for non-large dividend is
- * ceil(log2(quotient) / N) * (10 + 7N/2) + C
- * A large dividend is one greater than 2^(31-TOPBITS) and takes a
- * different path, as the upper bits of the quotient must be developed
- * one bit at a time.
- */
-
-define(N, `4')
-define(TWOSUPN, `16')
-define(WORDSIZE, `32')
-define(TOPBITS, eval(WORDSIZE - N*((WORDSIZE-1)/N)))
-
-define(dividend, `%o0')
-define(divisor, `%o1')
-define(Q, `%o2')
-define(R, `%o3')
-define(ITER, `%o4')
-define(V, `%o5')
-
-/* m4 reminder: ifelse(a,b,c,d) => if a is b, then c, else d */
-define(T, `%g1')
-define(SC, `%g7')
-ifelse(S, `true', `define(SIGN, `%g6')')
-
-/*
- * This is the recursive definition for developing quotient digits.
- *
- * Parameters:
- * $1 the current depth, 1 <= $1 <= N
- * $2 the current accumulation of quotient bits
- * N max depth
- *
- * We add a new bit to $2 and either recurse or insert the bits in
- * the quotient. R, Q, and V are inputs and outputs as defined above;
- * the condition codes are expected to reflect the input R, and are
- * modified to reflect the output R.
- */
-define(DEVELOP_QUOTIENT_BITS,
-` ! depth $1, accumulated bits $2
- bl L.$1.eval(TWOSUPN+$2)
- srl V,1,V
- ! remainder is positive
- subcc R,V,R
- ifelse($1, N,
- ` b 9f
- add Q, ($2*2+1), Q
- ', ` DEVELOP_QUOTIENT_BITS(incr($1), `eval(2*$2+1)')')
-L.$1.eval(TWOSUPN+$2):
- ! remainder is negative
- addcc R,V,R
- ifelse($1, N,
- ` b 9f
- add Q, ($2*2-1), Q
- ', ` DEVELOP_QUOTIENT_BITS(incr($1), `eval(2*$2-1)')')
- ifelse($1, 1, `9:')')
-
-#include <machine/asm.h>
-#include <machine/trap.h>
-
-FUNC(NAME)
-ifelse(S, `true',
-` ! compute sign of result; if neither is negative, no problem
- orcc divisor, dividend, %g0 ! either negative?
- bge 2f ! no, go do the divide
- ifelse(OP, `div',
- `xor divisor, dividend, SIGN',
- `mov dividend, SIGN') ! compute sign in any case
- tst divisor
- bge 1f
- tst dividend
- ! divisor is definitely negative; dividend might also be negative
- bge 2f ! if dividend not negative...
- neg divisor ! in any case, make divisor nonneg
-1: ! dividend is negative, divisor is nonnegative
- neg dividend ! make dividend nonnegative
-2:
-')
- ! Ready to divide. Compute size of quotient; scale comparand.
- orcc divisor, %g0, V
- bnz 1f
- mov dividend, R
-
- ! Divide by zero trap. If it returns, return 0 (about as
- ! wrong as possible, but that is what SunOS does...).
- t ST_DIV0
- retl
- clr %o0
-
-1:
- cmp R, V ! if divisor exceeds dividend, done
- blu Lgot_result ! (and algorithm fails otherwise)
- clr Q
- sethi %hi(1 << (WORDSIZE - TOPBITS - 1)), T
- cmp R, T
- blu Lnot_really_big
- clr ITER
-
- ! `Here the dividend is >= 2^(31-N) or so. We must be careful here,
- ! as our usual N-at-a-shot divide step will cause overflow and havoc.
- ! The number of bits in the result here is N*ITER+SC, where SC <= N.
- ! Compute ITER in an unorthodox manner: know we need to shift V into
- ! the top decade: so do not even bother to compare to R.'
- 1:
- cmp V, T
- bgeu 3f
- mov 1, SC
- sll V, N, V
- b 1b
- inc ITER
-
- ! Now compute SC.
- 2: addcc V, V, V
- bcc Lnot_too_big
- inc SC
-
- ! We get here if the divisor overflowed while shifting.
- ! This means that R has the high-order bit set.
- ! Restore V and subtract from R.
- sll T, TOPBITS, T ! high order bit
- srl V, 1, V ! rest of V
- add V, T, V
- b Ldo_single_div
- dec SC
-
- Lnot_too_big:
- 3: cmp V, R
- blu 2b
- nop
- be Ldo_single_div
- nop
- /* NB: these are commented out in the V8-Sparc manual as well */
- /* (I do not understand this) */
- ! V > R: went too far: back up 1 step
- ! srl V, 1, V
- ! dec SC
- ! do single-bit divide steps
- !
- ! We have to be careful here. We know that R >= V, so we can do the
- ! first divide step without thinking. BUT, the others are conditional,
- ! and are only done if R >= 0. Because both R and V may have the high-
- ! order bit set in the first step, just falling into the regular
- ! division loop will mess up the first time around.
- ! So we unroll slightly...
- Ldo_single_div:
- deccc SC
- bl Lend_regular_divide
- nop
- sub R, V, R
- mov 1, Q
- b Lend_single_divloop
- nop
- Lsingle_divloop:
- sll Q, 1, Q
- bl 1f
- srl V, 1, V
- ! R >= 0
- sub R, V, R
- b 2f
- inc Q
- 1: ! R < 0
- add R, V, R
- dec Q
- 2:
- Lend_single_divloop:
- deccc SC
- bge Lsingle_divloop
- tst R
- b,a Lend_regular_divide
-
-Lnot_really_big:
-1:
- sll V, N, V
- cmp V, R
- bleu 1b
- inccc ITER
- be Lgot_result
- dec ITER
-
- tst R ! set up for initial iteration
-Ldivloop:
- sll Q, N, Q
- DEVELOP_QUOTIENT_BITS(1, 0)
-Lend_regular_divide:
- deccc ITER
- bge Ldivloop
- tst R
- bl,a Lgot_result
- ! non-restoring fixup here (one instruction only!)
-ifelse(OP, `div',
-` dec Q
-', ` add R, divisor, R
-')
-
-Lgot_result:
-ifelse(S, `true',
-` ! check to see if answer should be < 0
- tst SIGN
- bl,a 1f
- ifelse(OP, `div', `neg Q', `neg R')
-1:')
- retl
- ifelse(OP, `div', `mov Q, %o0', `mov R, %o0')
diff --git a/klibc/klibc/arch/sparc/setjmp.S b/klibc/klibc/arch/sparc/setjmp.S
deleted file mode 100644
index f41ee2bf12..0000000000
--- a/klibc/klibc/arch/sparc/setjmp.S
+++ /dev/null
@@ -1,38 +0,0 @@
-!
-! setjmp.S
-!
-! Basic setjmp/longjmp
-!
-! This code was based on the equivalent code in NetBSD
-!
-
-#include <machine/asm.h>
-#include <machine/trap.h>
-
-!
-! The jmp_buf contains the following entries:
-! sp
-! fp
-! pc
-!
-ENTRY(setjmp)
- st %sp,[%o0+0] ! Callers stack pointer
- st %o7,[%o0+4] ! Return pc
- st %fp,[%o0+8] ! Frame pointer
- retl ! Return
- clr %o0 ! ...0
-
-ENTRY(longjmp)
- sub %sp, 64, %sp ! set up a local stack frame
-0:
- t ST_FLUSHWIN ! flush register windows out to memory
- !
- ! We restore the saved stack pointer to %fp, then issue
- ! a restore instruction which will reload the register
- ! window from the stack.
- !
- ld [%o0+4], %o7 /* restore return pc */
- ld [%o0+0], %fp /* and stack pointer */
-
- retl ! success, return %g6
- restore %o1, 0, %o0
diff --git a/klibc/klibc/arch/sparc/smul.S b/klibc/klibc/arch/sparc/smul.S
deleted file mode 100644
index 0eb218bbe8..0000000000
--- a/klibc/klibc/arch/sparc/smul.S
+++ /dev/null
@@ -1,160 +0,0 @@
-/* $NetBSD: mul.S,v 1.3 1997/07/16 14:37:42 christos Exp $ */
-
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This software was developed by the Computer Systems Engineering group
- * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
- * contributed to Berkeley.
- *
- * 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.
- *
- * from: Header: mul.s,v 1.5 92/06/25 13:24:03 torek Exp
- */
-
-#include <machine/asm.h>
-#if defined(LIBC_SCCS) && !defined(lint)
-#if 0
- .asciz "@(#)mul.s 8.1 (Berkeley) 6/4/93"
-#else
- RCSID("$NetBSD: mul.S,v 1.3 1997/07/16 14:37:42 christos Exp $")
-#endif
-#endif /* LIBC_SCCS and not lint */
-
-/*
- * Signed multiply, from Appendix E of the Sparc Version 8
- * Architecture Manual.
- *
- * Returns %o0 * %o1 in %o1%o0 (i.e., %o1 holds the upper 32 bits of
- * the 64-bit product).
- *
- * This code optimizes short (less than 13-bit) multiplies.
- */
-
-FUNC(.mul)
- mov %o0, %y ! multiplier -> Y
- andncc %o0, 0xfff, %g0 ! test bits 12..31
- be Lmul_shortway ! if zero, can do it the short way
- andcc %g0, %g0, %o4 ! zero the partial product and clear N and V
-
- /*
- * Long multiply. 32 steps, followed by a final shift step.
- */
- mulscc %o4, %o1, %o4 ! 1
- mulscc %o4, %o1, %o4 ! 2
- mulscc %o4, %o1, %o4 ! 3
- mulscc %o4, %o1, %o4 ! 4
- mulscc %o4, %o1, %o4 ! 5
- mulscc %o4, %o1, %o4 ! 6
- mulscc %o4, %o1, %o4 ! 7
- mulscc %o4, %o1, %o4 ! 8
- mulscc %o4, %o1, %o4 ! 9
- mulscc %o4, %o1, %o4 ! 10
- mulscc %o4, %o1, %o4 ! 11
- mulscc %o4, %o1, %o4 ! 12
- mulscc %o4, %o1, %o4 ! 13
- mulscc %o4, %o1, %o4 ! 14
- mulscc %o4, %o1, %o4 ! 15
- mulscc %o4, %o1, %o4 ! 16
- mulscc %o4, %o1, %o4 ! 17
- mulscc %o4, %o1, %o4 ! 18
- mulscc %o4, %o1, %o4 ! 19
- mulscc %o4, %o1, %o4 ! 20
- mulscc %o4, %o1, %o4 ! 21
- mulscc %o4, %o1, %o4 ! 22
- mulscc %o4, %o1, %o4 ! 23
- mulscc %o4, %o1, %o4 ! 24
- mulscc %o4, %o1, %o4 ! 25
- mulscc %o4, %o1, %o4 ! 26
- mulscc %o4, %o1, %o4 ! 27
- mulscc %o4, %o1, %o4 ! 28
- mulscc %o4, %o1, %o4 ! 29
- mulscc %o4, %o1, %o4 ! 30
- mulscc %o4, %o1, %o4 ! 31
- mulscc %o4, %o1, %o4 ! 32
- mulscc %o4, %g0, %o4 ! final shift
-
- ! If %o0 was negative, the result is
- ! (%o0 * %o1) + (%o1 << 32))
- ! We fix that here.
-
- tst %o0
- bge 1f
- rd %y, %o0
-
- ! %o0 was indeed negative; fix upper 32 bits of result by subtracting
- ! %o1 (i.e., return %o4 - %o1 in %o1).
- retl
- sub %o4, %o1, %o1
-
-1:
- retl
- mov %o4, %o1
-
-Lmul_shortway:
- /*
- * Short multiply. 12 steps, followed by a final shift step.
- * The resulting bits are off by 12 and (32-12) = 20 bit positions,
- * but there is no problem with %o0 being negative (unlike above).
- */
- mulscc %o4, %o1, %o4 ! 1
- mulscc %o4, %o1, %o4 ! 2
- mulscc %o4, %o1, %o4 ! 3
- mulscc %o4, %o1, %o4 ! 4
- mulscc %o4, %o1, %o4 ! 5
- mulscc %o4, %o1, %o4 ! 6
- mulscc %o4, %o1, %o4 ! 7
- mulscc %o4, %o1, %o4 ! 8
- mulscc %o4, %o1, %o4 ! 9
- mulscc %o4, %o1, %o4 ! 10
- mulscc %o4, %o1, %o4 ! 11
- mulscc %o4, %o1, %o4 ! 12
- mulscc %o4, %g0, %o4 ! final shift
-
- /*
- * %o4 has 20 of the bits that should be in the low part of the
- * result; %y has the bottom 12 (as %y's top 12). That is:
- *
- * %o4 %y
- * +----------------+----------------+
- * | -12- | -20- | -12- | -20- |
- * +------(---------+------)---------+
- * --hi-- ----low-part----
- *
- * The upper 12 bits of %o4 should be sign-extended to form the
- * high part of the product (i.e., highpart = %o4 >> 20).
- */
-
- rd %y, %o5
- sll %o4, 12, %o0 ! shift middle bits left 12
- srl %o5, 20, %o5 ! shift low bits right 20, zero fill at left
- or %o5, %o0, %o0 ! construct low part of result
- retl
- sra %o4, 20, %o1 ! ... and extract high part of result
diff --git a/klibc/klibc/arch/sparc/syscall.S b/klibc/klibc/arch/sparc/syscall.S
deleted file mode 100644
index c0273f77ca..0000000000
--- a/klibc/klibc/arch/sparc/syscall.S
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * arch/sparc/syscall.S
- *
- * Common system-call stub; %g1 already set to syscall number
- */
-
- .globl __syscall_common
- .type __syscall_common,#function
- .align 4
-__syscall_common:
- t 0x10
- bcc 1f
- sethi %hi(errno), %g4
- or %g4, %lo(errno), %g4
- st %o0,[%g4]
- mov -1, %o0
-1:
- retl
- nop
diff --git a/klibc/klibc/arch/sparc/sysfork.S b/klibc/klibc/arch/sparc/sysfork.S
deleted file mode 100644
index a66c76e9db..0000000000
--- a/klibc/klibc/arch/sparc/sysfork.S
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * arch/sparc/sysfork.S
- *
- * The fork and vfork system calls are special on sparc[64]:
- * they return the "other process" pid in %o0 and the
- * "is child" flag in %o1
- *
- * Common system-call stub; %g1 already set to syscall number
- */
-
- .globl __syscall_forkish
- .type __syscall_forkish,#function
- .align 4
-__syscall_forkish:
- t 0x10
- sub %o1, 1, %o1
- bcc,a 1f
- and %o0, %o1, %o0
- sethi %hi(errno), %g4
- or %g4, %lo(errno), %g4
- st %o0,[%g4]
- mov -1, %o0
-1:
- retl
- nop
diff --git a/klibc/klibc/arch/sparc/sysstub.ph b/klibc/klibc/arch/sparc/sysstub.ph
deleted file mode 100644
index d8cedb5ae5..0000000000
--- a/klibc/klibc/arch/sparc/sysstub.ph
+++ /dev/null
@@ -1,25 +0,0 @@
-# -*- perl -*-
-#
-# arch/sparc32/sysstub.ph
-#
-# Script to generate system call stubs
-#
-
-sub make_sysstub($$$$$@) {
- my($outputdir, $fname, $type, $sname, $stype, @args) = @_;
-
- $stype = $stype || 'common';
-
- open(OUT, '>', "${outputdir}/${fname}.S");
- print OUT "#include <asm/unistd.h>\n";
- print OUT "\n";
- print OUT "\t.type ${fname},\@function\n";
- print OUT "\t.globl ${fname}\n";
- print OUT "${fname}:\n";
- print OUT "\tb __syscall_${stype}\n";
- print OUT "\t mov\t__NR_${sname}, %g1\n";
- print OUT "\t.size ${fname},.-${fname}\n";
- close(OUT);
-}
-
-1;
diff --git a/klibc/klibc/arch/sparc/umul.S b/klibc/klibc/arch/sparc/umul.S
deleted file mode 100644
index 6a7193d217..0000000000
--- a/klibc/klibc/arch/sparc/umul.S
+++ /dev/null
@@ -1,193 +0,0 @@
-/* $NetBSD: umul.S,v 1.3 1997/07/16 14:37:44 christos Exp $ */
-
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This software was developed by the Computer Systems Engineering group
- * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
- * contributed to Berkeley.
- *
- * 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.
- *
- * from: Header: umul.s,v 1.4 92/06/25 13:24:05 torek Exp
- */
-
-#include <machine/asm.h>
-#if defined(LIBC_SCCS) && !defined(lint)
-#if 0
- .asciz "@(#)umul.s 8.1 (Berkeley) 6/4/93"
-#else
- RCSID("$NetBSD: umul.S,v 1.3 1997/07/16 14:37:44 christos Exp $")
-#endif
-#endif /* LIBC_SCCS and not lint */
-
-/*
- * Unsigned multiply. Returns %o0 * %o1 in %o1%o0 (i.e., %o1 holds the
- * upper 32 bits of the 64-bit product).
- *
- * This code optimizes short (less than 13-bit) multiplies. Short
- * multiplies require 25 instruction cycles, and long ones require
- * 45 instruction cycles.
- *
- * On return, overflow has occurred (%o1 is not zero) if and only if
- * the Z condition code is clear, allowing, e.g., the following:
- *
- * call .umul
- * nop
- * bnz overflow (or tnz)
- */
-
-FUNC(.umul)
- or %o0, %o1, %o4
- mov %o0, %y ! multiplier -> Y
- andncc %o4, 0xfff, %g0 ! test bits 12..31 of *both* args
- be Lmul_shortway ! if zero, can do it the short way
- andcc %g0, %g0, %o4 ! zero the partial product and clear N and V
-
- /*
- * Long multiply. 32 steps, followed by a final shift step.
- */
- mulscc %o4, %o1, %o4 ! 1
- mulscc %o4, %o1, %o4 ! 2
- mulscc %o4, %o1, %o4 ! 3
- mulscc %o4, %o1, %o4 ! 4
- mulscc %o4, %o1, %o4 ! 5
- mulscc %o4, %o1, %o4 ! 6
- mulscc %o4, %o1, %o4 ! 7
- mulscc %o4, %o1, %o4 ! 8
- mulscc %o4, %o1, %o4 ! 9
- mulscc %o4, %o1, %o4 ! 10
- mulscc %o4, %o1, %o4 ! 11
- mulscc %o4, %o1, %o4 ! 12
- mulscc %o4, %o1, %o4 ! 13
- mulscc %o4, %o1, %o4 ! 14
- mulscc %o4, %o1, %o4 ! 15
- mulscc %o4, %o1, %o4 ! 16
- mulscc %o4, %o1, %o4 ! 17
- mulscc %o4, %o1, %o4 ! 18
- mulscc %o4, %o1, %o4 ! 19
- mulscc %o4, %o1, %o4 ! 20
- mulscc %o4, %o1, %o4 ! 21
- mulscc %o4, %o1, %o4 ! 22
- mulscc %o4, %o1, %o4 ! 23
- mulscc %o4, %o1, %o4 ! 24
- mulscc %o4, %o1, %o4 ! 25
- mulscc %o4, %o1, %o4 ! 26
- mulscc %o4, %o1, %o4 ! 27
- mulscc %o4, %o1, %o4 ! 28
- mulscc %o4, %o1, %o4 ! 29
- mulscc %o4, %o1, %o4 ! 30
- mulscc %o4, %o1, %o4 ! 31
- mulscc %o4, %o1, %o4 ! 32
- mulscc %o4, %g0, %o4 ! final shift
-
-
- /*
- * Normally, with the shift-and-add approach, if both numbers are
- * positive you get the correct result. WIth 32-bit two's-complement
- * numbers, -x is represented as
- *
- * x 32
- * ( 2 - ------ ) mod 2 * 2
- * 32
- * 2
- *
- * (the `mod 2' subtracts 1 from 1.bbbb). To avoid lots of 2^32s,
- * we can treat this as if the radix point were just to the left
- * of the sign bit (multiply by 2^32), and get
- *
- * -x = (2 - x) mod 2
- *
- * Then, ignoring the `mod 2's for convenience:
- *
- * x * y = xy
- * -x * y = 2y - xy
- * x * -y = 2x - xy
- * -x * -y = 4 - 2x - 2y + xy
- *
- * For signed multiplies, we subtract (x << 32) from the partial
- * product to fix this problem for negative multipliers (see mul.s).
- * Because of the way the shift into the partial product is calculated
- * (N xor V), this term is automatically removed for the multiplicand,
- * so we don't have to adjust.
- *
- * But for unsigned multiplies, the high order bit wasn't a sign bit,
- * and the correction is wrong. So for unsigned multiplies where the
- * high order bit is one, we end up with xy - (y << 32). To fix it
- * we add y << 32.
- */
- tst %o1
- bl,a 1f ! if %o1 < 0 (high order bit = 1),
- add %o4, %o0, %o4 ! %o4 += %o0 (add y to upper half)
-1: rd %y, %o0 ! get lower half of product
- retl
- addcc %o4, %g0, %o1 ! put upper half in place and set Z for %o1==0
-
-Lmul_shortway:
- /*
- * Short multiply. 12 steps, followed by a final shift step.
- * The resulting bits are off by 12 and (32-12) = 20 bit positions,
- * but there is no problem with %o0 being negative (unlike above),
- * and overflow is impossible (the answer is at most 24 bits long).
- */
- mulscc %o4, %o1, %o4 ! 1
- mulscc %o4, %o1, %o4 ! 2
- mulscc %o4, %o1, %o4 ! 3
- mulscc %o4, %o1, %o4 ! 4
- mulscc %o4, %o1, %o4 ! 5
- mulscc %o4, %o1, %o4 ! 6
- mulscc %o4, %o1, %o4 ! 7
- mulscc %o4, %o1, %o4 ! 8
- mulscc %o4, %o1, %o4 ! 9
- mulscc %o4, %o1, %o4 ! 10
- mulscc %o4, %o1, %o4 ! 11
- mulscc %o4, %o1, %o4 ! 12
- mulscc %o4, %g0, %o4 ! final shift
-
- /*
- * %o4 has 20 of the bits that should be in the result; %y has
- * the bottom 12 (as %y's top 12). That is:
- *
- * %o4 %y
- * +----------------+----------------+
- * | -12- | -20- | -12- | -20- |
- * +------(---------+------)---------+
- * -----result-----
- *
- * The 12 bits of %o4 left of the `result' area are all zero;
- * in fact, all top 20 bits of %o4 are zero.
- */
-
- rd %y, %o5
- sll %o4, 12, %o0 ! shift middle bits left 12
- srl %o5, 20, %o5 ! shift low bits right 20
- or %o5, %o0, %o0
- retl
- addcc %g0, %g0, %o1 ! %o1 = zero, and set Z
diff --git a/klibc/klibc/arch/sparc64/MCONFIG b/klibc/klibc/arch/sparc64/MCONFIG
deleted file mode 100644
index a8a742412e..0000000000
--- a/klibc/klibc/arch/sparc64/MCONFIG
+++ /dev/null
@@ -1,21 +0,0 @@
-# -*- makefile -*-
-#
-# arch/sparc64/MCONFIG
-#
-# Special rules for this architecture. Note that this is actually
-# included from the main Makefile, and that pathnames should be
-# accordingly.
-#
-
-ARCHREQFLAGS = -m64 -mptr64
-OPTFLAGS = -Os
-BITSIZE = 64
-
-LDFLAGS = -m elf64_sparc
-
-# Extra linkflags when building the shared version of the library
-# This address needs to be reachable using normal inter-module
-# calls, and work on the memory models for this architecture
-# Normal binaries start at 1 MB; the linker wants 1 MB alignment,
-# and call instructions have a 30-bit signed offset, << 2.
-SHAREDFLAGS = -Ttext 0x80000200
diff --git a/klibc/klibc/arch/sparc64/Makefile.inc b/klibc/klibc/arch/sparc64/Makefile.inc
deleted file mode 100644
index 06b79537a3..0000000000
--- a/klibc/klibc/arch/sparc64/Makefile.inc
+++ /dev/null
@@ -1,15 +0,0 @@
-# -*- makefile -*-
-#
-# arch/sparc64/Makefile.inc
-#
-# Special rules for this architecture. Note that this is actually
-# included from the main Makefile, and that pathnames should be
-# accordingly.
-#
-
-ARCHOBJS = \
- arch/$(ARCH)/setjmp.o \
- arch/$(ARCH)/syscall.o \
- arch/$(ARCH)/sysfork.o
-
-archclean:
diff --git a/klibc/klibc/arch/sparc64/crt0.S b/klibc/klibc/arch/sparc64/crt0.S
deleted file mode 100644
index 5faee7c6be..0000000000
--- a/klibc/klibc/arch/sparc64/crt0.S
+++ /dev/null
@@ -1,2 +0,0 @@
-#define TARGET_PTR_SIZE 64
-#include "../sparc/crt0i.S"
diff --git a/klibc/klibc/arch/sparc64/setjmp.S b/klibc/klibc/arch/sparc64/setjmp.S
deleted file mode 100644
index b04d47faab..0000000000
--- a/klibc/klibc/arch/sparc64/setjmp.S
+++ /dev/null
@@ -1,55 +0,0 @@
-!
-! setjmp.S
-!
-! Basic setjmp/longjmp
-!
-! This code was based on the equivalent code in NetBSD
-!
-
-!
-! The jmp_buf contains the following entries:
-! sp
-! fp
-! pc
-!
- .text
- .align 4
- .global setjmp
- .type setjmp, @function
-setjmp:
- stx %sp,[%o0+0] ! Callers stack pointer
- stx %o7,[%o0+8] ! Return pc
- stx %fp,[%o0+16] ! Frame pointer
- retl ! Return
- clr %o0 ! ...0
-
- .size setjmp,.-setjmp
-
-
- .globl longjmp
- .type longjmp, @function
-longjmp:
- mov %o1, %g4 ! save return value
- mov %o0, %g1 ! save target
- ldx [%g1+16],%g5 ! get callers frame
-1:
- cmp %fp, %g5 ! compare against desired frame
- bl,a 1b ! if below...
- restore ! pop frame and loop
- be,a 2f ! if there...
- ldx [%g1+0],%o2 ! fetch return %sp
-
-.Lbotch:
- unimp 0 ! ... error ...
-
-2:
- cmp %o2, %sp ! %sp must not decrease
- bl .Lbotch
- nop
- mov %o2, %sp ! it is OK, put it in place
-
- ldx [%g1+8],%o3 ! fetch %pc
- jmp %o3 + 8 ! if sucess...
- mov %g4,%o0 ! return %g4
-
- .size longjmp,.-longjmp
diff --git a/klibc/klibc/arch/sparc64/syscall.S b/klibc/klibc/arch/sparc64/syscall.S
deleted file mode 100644
index 7ab9d95f11..0000000000
--- a/klibc/klibc/arch/sparc64/syscall.S
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * arch/sparc64/syscall.S
- *
- * Common system-call stub; %g1 already set to syscall number
- */
-
- .globl __syscall_common
- .type __syscall_common,#function
- .align 4
-__syscall_common:
- t 0x6d
- bcc %xcc, 1f
- sethi %hi(errno), %g4
- or %g4, %lo(errno), %g4
- st %o0,[%g4]
-1:
- retl
- movcs %xcc, -1, %o0
diff --git a/klibc/klibc/arch/sparc64/sysfork.S b/klibc/klibc/arch/sparc64/sysfork.S
deleted file mode 100644
index 739c35ede3..0000000000
--- a/klibc/klibc/arch/sparc64/sysfork.S
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * arch/sparc64/sysfork.S
- *
- * The fork and vfork system calls are special on sparc[64]:
- * they return the "other process" pid in %o0 and the
- * "is child" flag in %o1
- *
- * Common system-call stub; %g1 already set to syscall number
- *
- * IS THIS CORRECT FOR SPARC64?
- */
-
- .globl __syscall_forkish
- .type __syscall_forkish,#function
- .align 4
-__syscall_forkish:
- t 0x6d
- sub %o1, 1, %o1
- bcc,a %xcc, 1f
- and %o0, %o1, %o0
- sethi %hi(errno), %g4
- or %g4, %lo(errno), %g4
- st %o0,[%g4]
-1:
- retl
- movcs %xcc, -1, %o0
diff --git a/klibc/klibc/arch/sparc64/sysstub.ph b/klibc/klibc/arch/sparc64/sysstub.ph
deleted file mode 100644
index deeb88ce07..0000000000
--- a/klibc/klibc/arch/sparc64/sysstub.ph
+++ /dev/null
@@ -1,25 +0,0 @@
-# -*- perl -*-
-#
-# arch/sparc64/sysstub.ph
-#
-# Script to generate system call stubs
-#
-
-sub make_sysstub($$$$$@) {
- my($outputdir, $fname, $type, $sname, $stype, @args) = @_;
-
- $stype = $stype || 'common';
-
- open(OUT, '>', "${outputdir}/${fname}.S");
- print OUT "#include <asm/unistd.h>\n";
- print OUT "\n";
- print OUT "\t.type ${fname},\@function\n";
- print OUT "\t.globl ${fname}\n";
- print OUT "${fname}:\n";
- print OUT "\tb __syscall_${stype}\n";
- print OUT "\t mov\t__NR_${sname}, %g1\n";
- print OUT "\t.size ${fname},.-${fname}\n";
- close(OUT);
-}
-
-1;
diff --git a/klibc/klibc/arch/x86_64/MCONFIG b/klibc/klibc/arch/x86_64/MCONFIG
deleted file mode 100644
index c9b5da8bd6..0000000000
--- a/klibc/klibc/arch/x86_64/MCONFIG
+++ /dev/null
@@ -1,36 +0,0 @@
-# -*- makefile -*-
-#
-# arch/x86-64/MCONFIG
-#
-# Special rules for this architecture. Note that this is actually
-# included from the main Makefile, and that pathnames should be
-# accordingly.
-#
-# Blatantly copied and modified from i386 version by Mats Petersson, AMD.
-#
-
-#
-# NOTE: -fno-asynchronous-unwind-tables produce significantly smaller
-# binaries (20% smaller), but makes the code completely useless for
-# debugging using gdb.
-#
-ARCHREQFLAGS = -m64
-ifeq ($(DEBUG),y)
-OPTFLAGS = -Os -fomit-frame-pointer \
- -falign-functions=0 -falign-jumps=0 -falign-loops=0
-else
-OPTFLAGS = -Os -fno-asynchronous-unwind-tables -fomit-frame-pointer \
- -falign-functions=0 -falign-jumps=0 -falign-loops=0
-endif
-BITSIZE = 64
-LDFLAGS = -m elf_x86_64
-
-# Extra linkflags when building the shared version of the library
-# This address needs to be reachable using normal inter-module
-# calls, and work on the memory models for this architecture
-# 2 MB - normal binaries start at 4 MB
-SHAREDFLAGS = -Ttext 0x00200200
-
-# Additional asm- directories needed during installation
-ASMARCH = asm-i386
-
diff --git a/klibc/klibc/arch/x86_64/Makefile.inc b/klibc/klibc/arch/x86_64/Makefile.inc
deleted file mode 100644
index 26d880d7c7..0000000000
--- a/klibc/klibc/arch/x86_64/Makefile.inc
+++ /dev/null
@@ -1,18 +0,0 @@
-# -*- makefile -*-
-#
-# arch/x86_64/Makefile.inc
-#
-# Special rules for this architecture. Note that this is actually
-# included from the main Makefile, and that pathnames should be
-# accordingly.
-#
-
-ARCHOBJS = \
- arch/$(ARCH)/exits.o \
- arch/$(ARCH)/setjmp.o \
- arch/$(ARCH)/syscall.o \
- arch/$(ARCH)/sigreturn.o
-
-ARCHSOOBJS = $(patsubst %.o,%.lo,$(ARCHOBJS))
-
-archclean:
diff --git a/klibc/klibc/arch/x86_64/crt0.S b/klibc/klibc/arch/x86_64/crt0.S
deleted file mode 100644
index c562708d0f..0000000000
--- a/klibc/klibc/arch/x86_64/crt0.S
+++ /dev/null
@@ -1,22 +0,0 @@
-#
-# arch/x86_64/crt0.S
-#
-# Does arch-specific initialization and invokes __libc_init
-# with the appropriate arguments.
-#
-# See __static_init.c or __shared_init.c for the expected
-# arguments.
-#
-
- .text
- .align 4
- .type _start,@function
- .globl _start
-_start:
- movq %rsp,%rdi # Offset of the ELF data structure
- movq %rdx,%rsi # The atexit() pointer (if any)
- call __libc_init
- # We should never get here...
- hlt
-
- .size _start,.-_start
diff --git a/klibc/klibc/arch/x86_64/exits.S b/klibc/klibc/arch/x86_64/exits.S
deleted file mode 100644
index 618f4fb585..0000000000
--- a/klibc/klibc/arch/x86_64/exits.S
+++ /dev/null
@@ -1,35 +0,0 @@
-#
-# exit and _exit get included in *every* program, and gcc generates
-# horrible code for them. Yes, this only saves a few bytes, but
-# it does it in every program.
-#
-
-#include <asm/unistd.h>
-
- .data
- .align 8
- .globl __exit_handler
- .type __exit_handler,@object
-__exit_handler:
- .quad _exit
- .size __exit_handler,8
-
- .text
- .align 8
- .globl exit
- .type exit,@function
-exit:
- jmp *(__exit_handler)
- .size exit,.-exit
-
- /* No need to save any registers... we're exiting! */
- .text
- .align 4
- .globl _exit
- .type _exit,@function
-_exit:
- movl $__NR_exit,%eax
- /* The argument is already in %rdi */
- syscall
- .size _exit,.-exit
-
diff --git a/klibc/klibc/arch/x86_64/setjmp.S b/klibc/klibc/arch/x86_64/setjmp.S
deleted file mode 100644
index 45f547b404..0000000000
--- a/klibc/klibc/arch/x86_64/setjmp.S
+++ /dev/null
@@ -1,54 +0,0 @@
-#
-# arch/x86_64/setjmp.S
-#
-# setjmp/longjmp for the x86-64 architecture
-#
-
-#
-# The jmp_buf is assumed to contain the following, in order:
-# %rbx
-# %rsp (post-return)
-# %rbp
-# %r12
-# %r13
-# %r14
-# %r15
-# <return address>
-#
-
- .text
- .align 4
- .globl setjmp
- .type setjmp, @function
-setjmp:
- pop %rsi # Return address, and adjust the stack
- xorl %eax,%eax # Return value
- movq %rbx,(%rdi)
- movq %rsp,8(%rdi) # Post-return %rsp!
- push %rsi # Make the call/return stack happy
- movq %rbp,16(%rdi)
- movq %r12,24(%rdi)
- movq %r13,32(%rdi)
- movq %r14,40(%rdi)
- movq %r15,48(%rdi)
- movq %rsi,56(%rdi) # Return address
- ret
-
- .size setjmp,.-setjmp
-
- .text
- .align 4
- .globl longjmp
- .type longjmp, @function
-longjmp:
- movl %esi,%eax # Return value (int)
- movq (%rdi),%rbx
- movq 8(%rdi),%rsp
- movq 16(%rdi),%rbp
- movq 24(%rdi),%r12
- movq 32(%rdi),%r13
- movq 40(%rdi),%r14
- movq 48(%rdi),%r15
- jmp *56(%rdi)
-
- .size longjmp,.-longjmp
diff --git a/klibc/klibc/arch/x86_64/sigreturn.S b/klibc/klibc/arch/x86_64/sigreturn.S
deleted file mode 100644
index 66e7152344..0000000000
--- a/klibc/klibc/arch/x86_64/sigreturn.S
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * arch/x86_64/sigreturn.S
- */
-
-#include <asm/unistd.h>
-
- .text
- .align 4
- .globl __sigreturn
- .type __sigreturn,@function
-__sigreturn:
- movl $__NR_rt_sigreturn,%eax
- syscall
-
- .size __sigreturn,.-__sigreturn
diff --git a/klibc/klibc/arch/x86_64/syscall.S b/klibc/klibc/arch/x86_64/syscall.S
deleted file mode 100644
index 17977978b9..0000000000
--- a/klibc/klibc/arch/x86_64/syscall.S
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * arch/x86-64/syscall.S
- *
- * Common tail-handling code for system calls.
- *
- * The arguments are in the standard argument registers; the system
- * call number in %eax.
- */
- .text
- .align 4
- .globl __syscall_common
- .type __syscall_common,@function
-__syscall_common:
- movq %rcx,%r10 # The kernel uses %r10 istf %rcx
- syscall
-
- cmpq $-4095,%rax
- jnb 1f
- ret
-
- # Error return, must set errno
-1:
- negl %eax
- movl %eax,errno(%rip) # errno is type int, so 32 bits
- orq $-1,%rax # orq $-1 smaller than movq $-1
- ret
-
- .size __syscall_common,.-__syscall_common
diff --git a/klibc/klibc/arch/x86_64/sysstub.ph b/klibc/klibc/arch/x86_64/sysstub.ph
deleted file mode 100644
index e2d797b166..0000000000
--- a/klibc/klibc/arch/x86_64/sysstub.ph
+++ /dev/null
@@ -1,23 +0,0 @@
-# -*- perl -*-
-#
-# arch/x86_64/sysstub.ph
-#
-# Script to generate system call stubs
-#
-
-sub make_sysstub($$$$$@) {
- my($outputdir, $fname, $type, $sname, $stype, @args) = @_;
-
- open(OUT, '>', "${outputdir}/${fname}.S");
- print OUT "#include <asm/unistd.h>\n";
- print OUT "\n";
- print OUT "\t.type ${fname},\@function\n";
- print OUT "\t.globl ${fname}\n";
- print OUT "${fname}:\n";
- print OUT "\tmovl \$__NR_${sname},%eax\n"; # Zero-extends to 64 bits
- print OUT "\tjmp __syscall_common\n";
- print OUT "\t.size ${fname},.-${fname}\n";
- close(OUT);
-}
-
-1;
diff --git a/klibc/klibc/asprintf.c b/klibc/klibc/asprintf.c
deleted file mode 100644
index 6002b576e1..0000000000
--- a/klibc/klibc/asprintf.c
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * asprintf.c
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-
-int asprintf(char **bufp, const char *format, ...)
-{
- va_list ap, ap1;
- int rv;
- int bytes;
- char *p;
-
- va_start(ap, format);
- va_copy(ap1, ap);
-
- bytes = vsnprintf(NULL, 0, format, ap1) + 1;
- va_end(ap1);
-
- *bufp = p = malloc(bytes);
- if ( !p )
- return -1;
-
- rv = vsnprintf(p, bytes, format, ap);
- va_end(ap);
-
- return rv;
-}
diff --git a/klibc/klibc/assert.c b/klibc/klibc/assert.c
deleted file mode 100644
index 6d3ff238c9..0000000000
--- a/klibc/klibc/assert.c
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * assert.c
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <assert.h>
-
-void __assert_fail(const char *expr, const char *file, unsigned int line)
-{
- printf("Assertion %s failed, file %s, line %u\n", expr, file, line);
- abort();
-}
diff --git a/klibc/klibc/atexit.c b/klibc/klibc/atexit.c
deleted file mode 100644
index 078dd8b211..0000000000
--- a/klibc/klibc/atexit.c
+++ /dev/null
@@ -1,10 +0,0 @@
-/*
- * atexit.c
- */
-
-#include <stdlib.h>
-
-int atexit(void (*fctn)(void))
-{
- return on_exit((void (*)(int, void *))fctn, NULL);
-}
diff --git a/klibc/klibc/atexit.h b/klibc/klibc/atexit.h
deleted file mode 100644
index 792141def5..0000000000
--- a/klibc/klibc/atexit.h
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * atexit.h
- *
- * atexit()/on_exit() internal definitions
- */
-
-#ifndef ATEXIT_H
-#define ATEXIT_H
-
-struct atexit {
- void (*fctn)(int, void *);
- void *arg; /* on_exit() parameter */
- struct atexit *next;
-};
-
-#endif /* ATEXIT_H */
-
diff --git a/klibc/klibc/atoi.c b/klibc/klibc/atoi.c
deleted file mode 100644
index a6ec0bf778..0000000000
--- a/klibc/klibc/atoi.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#define TYPE int
-#define NAME atoi
-#include "atox.c"
diff --git a/klibc/klibc/atol.c b/klibc/klibc/atol.c
deleted file mode 100644
index e65484e7f1..0000000000
--- a/klibc/klibc/atol.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#define TYPE long
-#define NAME atol
-#include "atox.c"
diff --git a/klibc/klibc/atoll.c b/klibc/klibc/atoll.c
deleted file mode 100644
index 25df79e1bf..0000000000
--- a/klibc/klibc/atoll.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#define TYPE long long
-#define NAME atoll
-#include "atox.c"
diff --git a/klibc/klibc/atox.c b/klibc/klibc/atox.c
deleted file mode 100644
index 56f8d93b40..0000000000
--- a/klibc/klibc/atox.c
+++ /dev/null
@@ -1,14 +0,0 @@
-/*
- * atox.c
- *
- * atoi(), atol(), atoll()
- */
-
-#include <inttypes.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-TYPE NAME (const char *nptr)
-{
- return (TYPE) strntoumax(nptr, (char **)NULL, 10, ~(size_t)0);
-}
diff --git a/klibc/klibc/brk.c b/klibc/klibc/brk.c
deleted file mode 100644
index 0a08c4e1c5..0000000000
--- a/klibc/klibc/brk.c
+++ /dev/null
@@ -1,24 +0,0 @@
-/* brk.c - Change data segment size */
-
-/* Written 2000 by Werner Almesberger */
-
-
-#include <stddef.h>
-#include <unistd.h>
-#include <sys/types.h>
-
-char *__current_brk; /* Common with sbrk.c */
-
-/*
- * The Linux brk() isn't what most people expect, so we call the
- * system call __brk() and provide a wrapper.
- */
-int brk(void *end_data_segment)
-{
- char *new_brk;
-
- new_brk = __brk(end_data_segment);
- if (new_brk != end_data_segment) return -1;
- __current_brk = new_brk;
- return 0;
-}
diff --git a/klibc/klibc/bsd_signal.c b/klibc/klibc/bsd_signal.c
deleted file mode 100644
index 9acc867a36..0000000000
--- a/klibc/klibc/bsd_signal.c
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
- * bsd_signal.c
- */
-
-#include <signal.h>
-
-__sighandler_t bsd_signal(int signum, __sighandler_t handler)
-{
- /* BSD signal() semantics */
- return __signal(signum, handler, SA_RESTART);
-}
diff --git a/klibc/klibc/calloc.c b/klibc/klibc/calloc.c
deleted file mode 100644
index 228a1b70e4..0000000000
--- a/klibc/klibc/calloc.c
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * calloc.c
- */
-
-#include <stdlib.h>
-#include <string.h>
-
-/* FIXME: This should look for multiplication overflow */
-
-void *calloc(size_t nmemb, size_t size)
-{
- void *ptr;
-
- size *= nmemb;
- ptr = malloc(size);
- if ( ptr )
- memset(ptr, 0, size);
-
- return ptr;
-}
-
diff --git a/klibc/klibc/closelog.c b/klibc/klibc/closelog.c
deleted file mode 100644
index 2359d4f92b..0000000000
--- a/klibc/klibc/closelog.c
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * closelog.c
- */
-
-#include <syslog.h>
-#include <unistd.h>
-
-extern int __syslog_fd;
-
-void closelog(void)
-{
- int logfd = __syslog_fd;
-
- if ( logfd != -1 ) {
- close(logfd);
- __syslog_fd = -1;
- }
-}
diff --git a/klibc/klibc/creat.c b/klibc/klibc/creat.c
deleted file mode 100644
index 9bd22172d4..0000000000
--- a/klibc/klibc/creat.c
+++ /dev/null
@@ -1,12 +0,0 @@
-/*
- * creat.c
- */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-
-int creat(const char *pathname, mode_t mode)
-{
- return open(pathname, O_CREAT|O_WRONLY|O_TRUNC, mode);
-}
diff --git a/klibc/klibc/ctypes.c b/klibc/klibc/ctypes.c
deleted file mode 100644
index acfa05ab65..0000000000
--- a/klibc/klibc/ctypes.c
+++ /dev/null
@@ -1,284 +0,0 @@
-/*
- * ctypes.c
- *
- * This is the array that defines <ctype.h> classes.
- * This assumes ISO 8859-1.
- */
-
-#include <ctype.h>
-
-const unsigned char __ctypes[257] = {
- 0, /* EOF */
-
- __ctype_cntrl, /* control character */
- __ctype_cntrl, /* control character */
- __ctype_cntrl, /* control character */
- __ctype_cntrl, /* control character */
- __ctype_cntrl, /* control character */
- __ctype_cntrl, /* control character */
- __ctype_cntrl, /* control character */
- __ctype_cntrl, /* control character */
- __ctype_cntrl|__ctype_space, /* BS */
- __ctype_cntrl|__ctype_space, /* TAB */
- __ctype_cntrl|__ctype_space, /* LF */
- __ctype_cntrl|__ctype_space, /* VT */
- __ctype_cntrl|__ctype_space, /* FF */
- __ctype_cntrl|__ctype_space, /* CR */
- __ctype_cntrl, /* control character */
-
- __ctype_cntrl, /* control character */
- __ctype_cntrl, /* control character */
- __ctype_cntrl, /* control character */
- __ctype_cntrl, /* control character */
- __ctype_cntrl, /* control character */
- __ctype_cntrl, /* control character */
- __ctype_cntrl, /* control character */
- __ctype_cntrl, /* control character */
- __ctype_cntrl, /* control character */
- __ctype_cntrl, /* control character */
- __ctype_cntrl, /* control character */
- __ctype_cntrl, /* control character */
- __ctype_cntrl, /* control character */
- __ctype_cntrl, /* control character */
- __ctype_cntrl, /* control character */
- __ctype_cntrl, /* control character */
- __ctype_cntrl, /* control character */
-
- __ctype_print|__ctype_space, /* space */
- __ctype_print|__ctype_punct, /* punctuation */
- __ctype_print|__ctype_punct, /* punctuation */
- __ctype_print|__ctype_punct, /* punctuation */
- __ctype_print|__ctype_punct, /* punctuation */
- __ctype_print|__ctype_punct, /* punctuation */
- __ctype_print|__ctype_punct, /* punctuation */
- __ctype_print|__ctype_punct, /* punctuation */
- __ctype_print|__ctype_punct, /* punctuation */
- __ctype_print|__ctype_punct, /* punctuation */
- __ctype_print|__ctype_punct, /* punctuation */
- __ctype_print|__ctype_punct, /* punctuation */
- __ctype_print|__ctype_punct, /* punctuation */
- __ctype_print|__ctype_punct, /* punctuation */
- __ctype_print|__ctype_punct, /* punctuation */
- __ctype_print|__ctype_punct, /* punctuation */
-
- __ctype_print|__ctype_digit|__ctype_xdigit, /* digit */
- __ctype_print|__ctype_digit|__ctype_xdigit, /* digit */
- __ctype_print|__ctype_digit|__ctype_xdigit, /* digit */
- __ctype_print|__ctype_digit|__ctype_xdigit, /* digit */
- __ctype_print|__ctype_digit|__ctype_xdigit, /* digit */
- __ctype_print|__ctype_digit|__ctype_xdigit, /* digit */
- __ctype_print|__ctype_digit|__ctype_xdigit, /* digit */
- __ctype_print|__ctype_digit|__ctype_xdigit, /* digit */
- __ctype_print|__ctype_digit|__ctype_xdigit, /* digit */
- __ctype_print|__ctype_digit|__ctype_xdigit, /* digit */
- __ctype_print|__ctype_punct, /* punctuation */
- __ctype_print|__ctype_punct, /* punctuation */
- __ctype_print|__ctype_punct, /* punctuation */
- __ctype_print|__ctype_punct, /* punctuation */
- __ctype_print|__ctype_punct, /* punctuation */
- __ctype_print|__ctype_punct, /* punctuation */
-
- __ctype_print|__ctype_punct, /* punctuation */
- __ctype_print|__ctype_upper|__ctype_xdigit, /* A-F */
- __ctype_print|__ctype_upper|__ctype_xdigit, /* A-F */
- __ctype_print|__ctype_upper|__ctype_xdigit, /* A-F */
- __ctype_print|__ctype_upper|__ctype_xdigit, /* A-F */
- __ctype_print|__ctype_upper|__ctype_xdigit, /* A-F */
- __ctype_print|__ctype_upper|__ctype_xdigit, /* A-F */
- __ctype_print|__ctype_upper, /* G-Z */
- __ctype_print|__ctype_upper, /* G-Z */
- __ctype_print|__ctype_upper, /* G-Z */
- __ctype_print|__ctype_upper, /* G-Z */
- __ctype_print|__ctype_upper, /* G-Z */
- __ctype_print|__ctype_upper, /* G-Z */
- __ctype_print|__ctype_upper, /* G-Z */
- __ctype_print|__ctype_upper, /* G-Z */
- __ctype_print|__ctype_upper, /* G-Z */
-
- __ctype_print|__ctype_upper, /* G-Z */
- __ctype_print|__ctype_upper, /* G-Z */
- __ctype_print|__ctype_upper, /* G-Z */
- __ctype_print|__ctype_upper, /* G-Z */
- __ctype_print|__ctype_upper, /* G-Z */
- __ctype_print|__ctype_upper, /* G-Z */
- __ctype_print|__ctype_upper, /* G-Z */
- __ctype_print|__ctype_upper, /* G-Z */
- __ctype_print|__ctype_upper, /* G-Z */
- __ctype_print|__ctype_upper, /* G-Z */
- __ctype_print|__ctype_upper, /* G-Z */
- __ctype_print|__ctype_punct, /* punctuation */
- __ctype_print|__ctype_punct, /* punctuation */
- __ctype_print|__ctype_punct, /* punctuation */
- __ctype_print|__ctype_punct, /* punctuation */
- __ctype_print|__ctype_punct, /* punctuation */
-
- __ctype_print|__ctype_punct, /* punctuation */
- __ctype_print|__ctype_lower|__ctype_xdigit, /* a-f */
- __ctype_print|__ctype_lower|__ctype_xdigit, /* a-f */
- __ctype_print|__ctype_lower|__ctype_xdigit, /* a-f */
- __ctype_print|__ctype_lower|__ctype_xdigit, /* a-f */
- __ctype_print|__ctype_lower|__ctype_xdigit, /* a-f */
- __ctype_print|__ctype_lower|__ctype_xdigit, /* a-f */
- __ctype_print|__ctype_lower, /* g-z */
- __ctype_print|__ctype_lower, /* g-z */
- __ctype_print|__ctype_lower, /* g-z */
- __ctype_print|__ctype_lower, /* g-z */
- __ctype_print|__ctype_lower, /* g-z */
- __ctype_print|__ctype_lower, /* g-z */
- __ctype_print|__ctype_lower, /* g-z */
- __ctype_print|__ctype_lower, /* g-z */
- __ctype_print|__ctype_lower, /* g-z */
-
- __ctype_print|__ctype_lower, /* g-z */
- __ctype_print|__ctype_lower, /* g-z */
- __ctype_print|__ctype_lower, /* g-z */
- __ctype_print|__ctype_lower, /* g-z */
- __ctype_print|__ctype_lower, /* g-z */
- __ctype_print|__ctype_lower, /* g-z */
- __ctype_print|__ctype_lower, /* g-z */
- __ctype_print|__ctype_lower, /* g-z */
- __ctype_print|__ctype_lower, /* g-z */
- __ctype_print|__ctype_lower, /* g-z */
- __ctype_print|__ctype_lower, /* g-z */
- __ctype_print|__ctype_punct, /* punctuation */
- __ctype_print|__ctype_punct, /* punctuation */
- __ctype_print|__ctype_punct, /* punctuation */
- __ctype_print|__ctype_punct, /* punctuation */
- __ctype_cntrl, /* control character */
-
- __ctype_cntrl, /* control character */
- __ctype_cntrl, /* control character */
- __ctype_cntrl, /* control character */
- __ctype_cntrl, /* control character */
- __ctype_cntrl, /* control character */
- __ctype_cntrl, /* control character */
- __ctype_cntrl, /* control character */
- __ctype_cntrl, /* control character */
- __ctype_cntrl, /* control character */
- __ctype_cntrl, /* control character */
- __ctype_cntrl, /* control character */
- __ctype_cntrl, /* control character */
- __ctype_cntrl, /* control character */
- __ctype_cntrl, /* control character */
- __ctype_cntrl, /* control character */
- __ctype_cntrl, /* control character */
-
- __ctype_cntrl, /* control character */
- __ctype_cntrl, /* control character */
- __ctype_cntrl, /* control character */
- __ctype_cntrl, /* control character */
- __ctype_cntrl, /* control character */
- __ctype_cntrl, /* control character */
- __ctype_cntrl, /* control character */
- __ctype_cntrl, /* control character */
- __ctype_cntrl, /* control character */
- __ctype_cntrl, /* control character */
- __ctype_cntrl, /* control character */
- __ctype_cntrl, /* control character */
- __ctype_cntrl, /* control character */
- __ctype_cntrl, /* control character */
- __ctype_cntrl, /* control character */
- __ctype_cntrl, /* control character */
-
- __ctype_print|__ctype_space, /* NBSP */
- __ctype_print|__ctype_punct, /* punctuation */
- __ctype_print|__ctype_punct, /* punctuation */
- __ctype_print|__ctype_punct, /* punctuation */
- __ctype_print|__ctype_punct, /* punctuation */
- __ctype_print|__ctype_punct, /* punctuation */
- __ctype_print|__ctype_punct, /* punctuation */
- __ctype_print|__ctype_punct, /* punctuation */
- __ctype_print|__ctype_punct, /* punctuation */
- __ctype_print|__ctype_punct, /* punctuation */
- __ctype_print|__ctype_punct, /* punctuation */
- __ctype_print|__ctype_punct, /* punctuation */
- __ctype_print|__ctype_punct, /* punctuation */
- __ctype_print|__ctype_punct, /* punctuation */
- __ctype_print|__ctype_punct, /* punctuation */
- __ctype_print|__ctype_punct, /* punctuation */
-
- __ctype_print|__ctype_punct, /* punctuation */
- __ctype_print|__ctype_punct, /* punctuation */
- __ctype_print|__ctype_punct, /* punctuation */
- __ctype_print|__ctype_punct, /* punctuation */
- __ctype_print|__ctype_punct, /* punctuation */
- __ctype_print|__ctype_punct, /* punctuation */
- __ctype_print|__ctype_punct, /* punctuation */
- __ctype_print|__ctype_punct, /* punctuation */
- __ctype_print|__ctype_punct, /* punctuation */
- __ctype_print|__ctype_punct, /* punctuation */
- __ctype_print|__ctype_punct, /* punctuation */
- __ctype_print|__ctype_punct, /* punctuation */
- __ctype_print|__ctype_punct, /* punctuation */
- __ctype_print|__ctype_punct, /* punctuation */
- __ctype_print|__ctype_punct, /* punctuation */
- __ctype_print|__ctype_punct, /* punctuation */
-
- __ctype_print|__ctype_upper, /* upper accented */
- __ctype_print|__ctype_upper, /* upper accented */
- __ctype_print|__ctype_upper, /* upper accented */
- __ctype_print|__ctype_upper, /* upper accented */
- __ctype_print|__ctype_upper, /* upper accented */
- __ctype_print|__ctype_upper, /* upper accented */
- __ctype_print|__ctype_upper, /* upper accented */
- __ctype_print|__ctype_upper, /* upper accented */
- __ctype_print|__ctype_upper, /* upper accented */
- __ctype_print|__ctype_upper, /* upper accented */
- __ctype_print|__ctype_upper, /* upper accented */
- __ctype_print|__ctype_upper, /* upper accented */
- __ctype_print|__ctype_upper, /* upper accented */
- __ctype_print|__ctype_upper, /* upper accented */
- __ctype_print|__ctype_upper, /* upper accented */
- __ctype_print|__ctype_upper, /* upper accented */
-
- __ctype_print|__ctype_upper, /* upper accented */
- __ctype_print|__ctype_upper, /* upper accented */
- __ctype_print|__ctype_upper, /* upper accented */
- __ctype_print|__ctype_upper, /* upper accented */
- __ctype_print|__ctype_upper, /* upper accented */
- __ctype_print|__ctype_upper, /* upper accented */
- __ctype_print|__ctype_upper, /* upper accented */
- __ctype_print|__ctype_punct, /* punctuation */
- __ctype_print|__ctype_upper, /* upper accented */
- __ctype_print|__ctype_upper, /* upper accented */
- __ctype_print|__ctype_upper, /* upper accented */
- __ctype_print|__ctype_upper, /* upper accented */
- __ctype_print|__ctype_upper, /* upper accented */
- __ctype_print|__ctype_upper, /* upper accented */
- __ctype_print|__ctype_upper, /* upper accented */
- __ctype_print|__ctype_lower, /* lower accented */
-
- __ctype_print|__ctype_lower, /* lower accented */
- __ctype_print|__ctype_lower, /* lower accented */
- __ctype_print|__ctype_lower, /* lower accented */
- __ctype_print|__ctype_lower, /* lower accented */
- __ctype_print|__ctype_lower, /* lower accented */
- __ctype_print|__ctype_lower, /* lower accented */
- __ctype_print|__ctype_lower, /* lower accented */
- __ctype_print|__ctype_lower, /* lower accented */
- __ctype_print|__ctype_lower, /* lower accented */
- __ctype_print|__ctype_lower, /* lower accented */
- __ctype_print|__ctype_lower, /* lower accented */
- __ctype_print|__ctype_lower, /* lower accented */
- __ctype_print|__ctype_lower, /* lower accented */
- __ctype_print|__ctype_lower, /* lower accented */
- __ctype_print|__ctype_lower, /* lower accented */
- __ctype_print|__ctype_lower, /* lower accented */
-
- __ctype_print|__ctype_lower, /* lower accented */
- __ctype_print|__ctype_lower, /* lower accented */
- __ctype_print|__ctype_lower, /* lower accented */
- __ctype_print|__ctype_lower, /* lower accented */
- __ctype_print|__ctype_lower, /* lower accented */
- __ctype_print|__ctype_lower, /* lower accented */
- __ctype_print|__ctype_lower, /* lower accented */
- __ctype_print|__ctype_punct, /* punctuation */
- __ctype_print|__ctype_lower, /* lower accented */
- __ctype_print|__ctype_lower, /* lower accented */
- __ctype_print|__ctype_lower, /* lower accented */
- __ctype_print|__ctype_lower, /* lower accented */
- __ctype_print|__ctype_lower, /* lower accented */
- __ctype_print|__ctype_lower, /* lower accented */
- __ctype_print|__ctype_lower, /* lower accented */
- __ctype_print|__ctype_lower, /* lower accented */
-};
diff --git a/klibc/klibc/daemon.c b/klibc/klibc/daemon.c
deleted file mode 100644
index 75d7146205..0000000000
--- a/klibc/klibc/daemon.c
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * daemon.c - "daemonize" a process
- */
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <fcntl.h>
-
-int daemon(int nochdir, int noclose)
-{
- int nullfd;
- pid_t f;
-
- if ( !nochdir ) {
- if ( chdir("/") )
- return -1;
- }
-
- if ( !noclose ) {
- if ( (nullfd = open("/dev/null", O_RDWR)) < 0 ||
- dup2(nullfd, 0) < 0 ||
- dup2(nullfd, 1) < 0 ||
- dup2(nullfd, 2) < 0 )
- return -1;
- close(nullfd);
- }
-
- f = fork();
- if ( f < 0 )
- return -1;
- else if ( f > 0 )
- _exit(0);
-
-
- return setsid();
-}
-
-
diff --git a/klibc/klibc/exec_l.c b/klibc/klibc/exec_l.c
deleted file mode 100644
index cdae11e981..0000000000
--- a/klibc/klibc/exec_l.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * exec_l.c
- *
- * Common implementation of execl() execle() execlp()
- */
-
-#include <stdarg.h>
-#include <alloca.h>
-#include <unistd.h>
-
-int NAME (const char *path, const char *arg0, ...)
-{
- va_list ap, cap;
- int argc = 1, rv;
- const char **argv, **argp;
- const char *arg;
-#if EXEC_E
- char * const * envp;
-#else
-#define envp environ
-#endif
-
- va_start(ap, arg0);
- va_copy(cap, ap);
-
- /* Count the number of arguments */
- do {
- arg = va_arg(cap, const char *);
- argc++;
- } while ( arg );
-
- va_end(cap);
-
- /* Allocate memory for the pointer array */
- argp = argv = alloca(argc*sizeof(const char *));
- if ( !argv ) {
- va_end(ap);
- return -1;
- }
-
- /* Copy the list into an array */
- *argp++ = arg0;
- do {
- *argp++ = arg = va_arg(ap, const char *);
- } while ( arg );
-
-#if EXEC_E
- /* execle() takes one more argument for the environment pointer */
- envp = va_arg(ap, char * const *);
-#endif
-
- rv = (EXEC_P ? execvpe : execve)(path, (char * const *)argv, envp);
-
- va_end(ap);
-
- return rv;
-}
diff --git a/klibc/klibc/execl.c b/klibc/klibc/execl.c
deleted file mode 100644
index 4581113ba5..0000000000
--- a/klibc/klibc/execl.c
+++ /dev/null
@@ -1,8 +0,0 @@
-/*
- * execl.c
- */
-
-#define NAME execl
-#define EXEC_P 0
-#define EXEC_E 0
-#include "exec_l.c"
diff --git a/klibc/klibc/execle.c b/klibc/klibc/execle.c
deleted file mode 100644
index b073988835..0000000000
--- a/klibc/klibc/execle.c
+++ /dev/null
@@ -1,8 +0,0 @@
-/*
- * execle.c
- */
-
-#define NAME execle
-#define EXEC_P 0
-#define EXEC_E 1
-#include "exec_l.c"
diff --git a/klibc/klibc/execlp.c b/klibc/klibc/execlp.c
deleted file mode 100644
index 65c9aa4a7a..0000000000
--- a/klibc/klibc/execlp.c
+++ /dev/null
@@ -1,8 +0,0 @@
-/*
- * execlp.c
- */
-
-#define NAME execlp
-#define EXEC_P 1
-#define EXEC_E 0
-#include "exec_l.c"
diff --git a/klibc/klibc/execlpe.c b/klibc/klibc/execlpe.c
deleted file mode 100644
index fef972fcb3..0000000000
--- a/klibc/klibc/execlpe.c
+++ /dev/null
@@ -1,8 +0,0 @@
-/*
- * execlpe.c
- */
-
-#define NAME execlpe
-#define EXEC_P 1
-#define EXEC_E 1
-#include "exec_l.c"
diff --git a/klibc/klibc/execv.c b/klibc/klibc/execv.c
deleted file mode 100644
index 9856b76d87..0000000000
--- a/klibc/klibc/execv.c
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * execv.c
- */
-
-#include <stdarg.h>
-#include <unistd.h>
-
-int execv(const char *path, char * const * argv)
-{
- return execve(path, argv, environ);
-}
-
-
diff --git a/klibc/klibc/execvp.c b/klibc/klibc/execvp.c
deleted file mode 100644
index b1065ee47e..0000000000
--- a/klibc/klibc/execvp.c
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * execvp.c
- */
-
-#include <stdarg.h>
-#include <unistd.h>
-
-int execvp(const char *path, char * const * argv)
-{
- return execvpe(path, argv, environ);
-}
-
-
diff --git a/klibc/klibc/execvpe.c b/klibc/klibc/execvpe.c
deleted file mode 100644
index fcd5b6fd4a..0000000000
--- a/klibc/klibc/execvpe.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * execvpe.c
- *
- * execvpe() function (from which we build execlp, execlpe, execvp).
- *
- * This version of execvpe() will *not* spawn /bin/sh if the command
- * return ENOEXEC. That's what #! is for, folks!
- *
- * Since execlpe() and execvpe() aren't in POSIX, nor in glibc,
- * I have followed QNX precedent in the implementation of the PATH:
- * the PATH that is used is the one in the current environment, not
- * in the new environment. Otherwise it would be impossible to pass
- * a different PATH to the new process than the one one would want to
- * use to search.
- */
-
-#include <errno.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <limits.h>
-
-#define DEFAULT_PATH "/bin:/usr/bin:."
-
-int execvpe(const char *file, char * const *argv, char * const *envp)
-{
- char path[PATH_MAX];
- const char *searchpath, *esp;
- size_t prefixlen, filelen, totallen;
-
- if ( strchr(file, '/') ) /* Specific path */
- return execve(file, argv, envp);
-
- filelen = strlen(file);
-
- searchpath = getenv("PATH");
- if ( !searchpath )
- searchpath = DEFAULT_PATH;
-
- errno = ENOENT; /* Default errno, if execve() doesn't change it */
-
- do {
- esp = strchr(searchpath, ':');
- if ( esp )
- prefixlen = esp-searchpath;
- else
- prefixlen = strlen(searchpath);
-
- if ( prefixlen == 0 || searchpath[prefixlen-1] == '/' ) {
- totallen = prefixlen+filelen;
- if ( totallen >= PATH_MAX )
- continue;
- memcpy(path, searchpath, prefixlen);
- memcpy(path+prefixlen, file, filelen);
- } else {
- totallen = prefixlen+filelen+1;
- if ( totallen >= PATH_MAX )
- continue;
- memcpy(path, searchpath, prefixlen);
- path[prefixlen] = '/';
- memcpy(path+prefixlen+1, file, filelen);
- }
- path[totallen] = '\0';
-
- execve(path, argv, envp);
- if ( errno == E2BIG || errno == ENOEXEC ||
- errno == ENOMEM || errno == ETXTBSY )
- break; /* Report this as an error, no more search */
-
- searchpath = esp+1;
- } while ( esp );
-
- return -1;
-}
-
diff --git a/klibc/klibc/exitc.c b/klibc/klibc/exitc.c
deleted file mode 100644
index 8819737fb7..0000000000
--- a/klibc/klibc/exitc.c
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * exit.c
- *
- * Implement exit()
- */
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/syscall.h>
-
-/* We have an assembly version for i386 and x86-64 */
-
-#if !defined(__i386__) && !defined(__x86_64__)
-
-/* This allows atexit/on_exit to install a hook */
-__noreturn (*__exit_handler)(int) = _exit;
-
-__noreturn exit(int rv)
-{
- __exit_handler(rv);
-}
-
-#endif
diff --git a/klibc/klibc/fgetc.c b/klibc/klibc/fgetc.c
deleted file mode 100644
index 83eee16f61..0000000000
--- a/klibc/klibc/fgetc.c
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * fgetc.c
- *
- * Extremely slow fgetc implementation, using _fread(). If people
- * actually need character-oriented input to be fast, we may actually
- * have to implement buffering. Sigh.
- */
-
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <errno.h>
-
-int fgetc(FILE *f)
-{
- unsigned char ch;
-
- return (_fread(&ch, 1, f) == 1) ? (int)ch : EOF;
-}
-
diff --git a/klibc/klibc/fgets.c b/klibc/klibc/fgets.c
deleted file mode 100644
index 72f8a13cf1..0000000000
--- a/klibc/klibc/fgets.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * fgets.c
- *
- * This will be very slow due to the implementation of getc(),
- * but we can't afford to drain characters we don't need from
- * the input.
- */
-
-#include <stdio.h>
-
-char *fgets(char *s, int n, FILE *f)
-{
- int ch;
- char *p = s;
-
- while ( n > 1 ) {
- ch = getc(f);
- if ( ch == EOF ) {
- *p = '\0';
- return NULL;
- }
- *p++ = ch;
- n--;
- if ( ch == '\n' )
- break;
- }
- if ( n )
- *p = '\0';
-
- return s;
-}
-
-
-
diff --git a/klibc/klibc/fopen.c b/klibc/klibc/fopen.c
deleted file mode 100644
index ee62c68bd7..0000000000
--- a/klibc/klibc/fopen.c
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * fopen.c
- */
-
-#include <stdio.h>
-#include <unistd.h>
-#include <fcntl.h>
-
-/* This depends on O_RDONLY == 0, O_WRONLY == 1, O_RDWR == 2 */
-
-
-FILE *fopen(const char *file, const char *mode)
-{
- int flags = O_RDONLY;
- int plus = 0;
-
- while ( *mode ) {
- switch ( *mode++ ) {
- case 'r':
- flags = O_RDONLY;
- break;
- case 'w':
- flags = O_WRONLY|O_CREAT|O_TRUNC;
- break;
- case 'a':
- flags = O_WRONLY|O_CREAT|O_APPEND;
- break;
- case '+':
- plus = 1;
- break;
- }
- }
-
- if ( plus ) {
- flags = (flags & ~(O_RDONLY|O_WRONLY)) | O_RDWR;
- }
-
- /* Note: __create_file(-1) == NULL, so this is safe */
- return __create_file(open(file, flags, 0666));
-}
diff --git a/klibc/klibc/fork.c b/klibc/klibc/fork.c
deleted file mode 100644
index fcd73bd60b..0000000000
--- a/klibc/klibc/fork.c
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * fork.c
- *
- * This is normally just a syscall stub, but at least one system
- * doesn't have sys_fork, only sys_clone...
- */
-
-#include <sys/syscall.h>
-#include <signal.h>
-#include <unistd.h>
-#include <sched.h>
-
-#ifndef __NR_fork
-
-pid_t fork(void)
-{
- return __clone(SIGCHLD, 0);
-}
-
-#endif /* __NR_fork */
diff --git a/klibc/klibc/fprintf.c b/klibc/klibc/fprintf.c
deleted file mode 100644
index df3823eac3..0000000000
--- a/klibc/klibc/fprintf.c
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * fprintf.c
- */
-
-#include <stdio.h>
-#include <stdarg.h>
-
-#define BUFFER_SIZE 16384
-
-int fprintf(FILE *file, const char *format, ...)
-{
- va_list ap;
- int rv;
-
- va_start(ap, format);
- rv = vfprintf(file, format, ap);
- va_end(ap);
- return rv;
-}
diff --git a/klibc/klibc/fputc.c b/klibc/klibc/fputc.c
deleted file mode 100644
index 61aff1644b..0000000000
--- a/klibc/klibc/fputc.c
+++ /dev/null
@@ -1,14 +0,0 @@
-/*
- * fputc.c
- *
- * gcc "printf decompilation" expects this to exist...
- */
-
-#include <stdio.h>
-
-int fputc(int c, FILE *f)
-{
- unsigned char ch = c;
-
- return _fwrite(&ch, 1, f) == 1 ? ch : EOF;
-}
diff --git a/klibc/klibc/fputs.c b/klibc/klibc/fputs.c
deleted file mode 100644
index 4b68f96886..0000000000
--- a/klibc/klibc/fputs.c
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * fputs.c
- *
- * This isn't quite fputs() in the stdio sense, since we don't
- * have stdio, but it takes a file descriptor argument instead
- * of the FILE *.
- */
-
-#include <stdio.h>
-#include <string.h>
-
-int fputs(const char *s, FILE *file)
-{
- return _fwrite(s, strlen(s), file);
-}
diff --git a/klibc/klibc/fread.c b/klibc/klibc/fread.c
deleted file mode 100644
index a49f0d8210..0000000000
--- a/klibc/klibc/fread.c
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * fread.c
- */
-
-#include <errno.h>
-#include <unistd.h>
-#include <stdio.h>
-
-size_t _fread(void *buf, size_t count, FILE *f)
-{
- size_t bytes = 0;
- ssize_t rv;
- char *p = buf;
-
- while ( count ) {
- rv = read(fileno(f), p, count);
- if ( rv == -1 ) {
- if ( errno == EINTR ) {
- errno = 0;
- continue;
- } else
- break;
- } else if ( rv == 0 ) {
- break;
- }
-
- p += rv;
- bytes += rv;
- count -= rv;
- }
-
- return bytes;
-}
-
-
-
diff --git a/klibc/klibc/fread2.c b/klibc/klibc/fread2.c
deleted file mode 100644
index 9e5ac81fc2..0000000000
--- a/klibc/klibc/fread2.c
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * fread2.c
- *
- * The actual fread() function as a non-inline
- */
-
-#define __NO_FREAD_FWRITE_INLINES
-#include <stdio.h>
-
-size_t fread(void *ptr, size_t size, size_t nmemb, FILE *f)
-{
- return _fread(ptr, size*nmemb, f)/size;
-}
diff --git a/klibc/klibc/fstatfs.c b/klibc/klibc/fstatfs.c
deleted file mode 100644
index 09e4674947..0000000000
--- a/klibc/klibc/fstatfs.c
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * fstatfs.c
- *
- * On architectures which do fstatfs64, wrap the system call
- */
-
-#include <sys/syscall.h>
-#include <sys/vfs.h>
-
-#ifdef __NR_fstatfs64
-
-extern int __fstatfs64(int, size_t, struct statfs *);
-
-int fstatfs(int fd, struct statfs *buf)
-{
- return __fstatfs64(fd, sizeof *buf, buf);
-}
-
-#endif
diff --git a/klibc/klibc/fwrite.c b/klibc/klibc/fwrite.c
deleted file mode 100644
index ad61c86b88..0000000000
--- a/klibc/klibc/fwrite.c
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * fwrite.c
- */
-
-#include <errno.h>
-#include <unistd.h>
-#include <stdio.h>
-
-size_t _fwrite(const void *buf, size_t count, FILE *f)
-{
- size_t bytes = 0;
- ssize_t rv;
- const char *p = buf;
-
- while ( count ) {
- rv = write(fileno(f), p, count);
- if ( rv == -1 ) {
- if ( errno == EINTR ) {
- errno = 0;
- continue;
- } else
- break;
- } else if ( rv == 0 ) {
- break;
- }
-
- p += rv;
- bytes += rv;
- count -= rv;
- }
-
- return bytes;
-}
-
-
-
diff --git a/klibc/klibc/fwrite2.c b/klibc/klibc/fwrite2.c
deleted file mode 100644
index 82ec832be4..0000000000
--- a/klibc/klibc/fwrite2.c
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * fwrite2.c
- *
- * The actual fwrite() function as a non-inline
- */
-
-#define __NO_FREAD_FWRITE_INLINES
-#include <stdio.h>
-
-size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *f)
-{
- return _fwrite(ptr, size*nmemb, f)/size;
-}
diff --git a/klibc/klibc/getcwd.c b/klibc/klibc/getcwd.c
deleted file mode 100644
index 613ca0529c..0000000000
--- a/klibc/klibc/getcwd.c
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * getcwd.c
- *
- * The system call behaves differently than the library function.
- */
-
-#include <unistd.h>
-#include <sys/syscall.h>
-
-extern int __getcwd(char * buf, size_t size);
-
-char *getcwd(char *buf, size_t size)
-{
- return ( __getcwd(buf, size) < 0 ) ? NULL : buf;
-}
-
diff --git a/klibc/klibc/getdomainname.c b/klibc/klibc/getdomainname.c
deleted file mode 100644
index 4cd68a3cb5..0000000000
--- a/klibc/klibc/getdomainname.c
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * getdomainname.c
- */
-
-#include <errno.h>
-#include <unistd.h>
-#include <string.h>
-#include <sys/utsname.h>
-
-int getdomainname(char *name, size_t len)
-{
- struct utsname un;
-
- if ( !uname(&un) )
- return -1;
-
- if ( len < strlen(un.domainname)+1 ) {
- errno = EINVAL;
- return -1;
- }
-
- strcpy(name, un.domainname);
-
- return 0;
-}
diff --git a/klibc/klibc/getenv.c b/klibc/klibc/getenv.c
deleted file mode 100644
index 84fc94c00e..0000000000
--- a/klibc/klibc/getenv.c
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * getenv.c
- */
-
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-char *getenv(const char *name)
-{
- char **p, *q;
- int len = strlen(name);
-
- for ( p = environ ; (q = *p) ; p++ ) {
- if ( !strncmp(name, q, len) && q[len] == '=' ) {
- return q+(len+1);
- }
- }
-
- return NULL;
-}
-
diff --git a/klibc/klibc/gethostname.c b/klibc/klibc/gethostname.c
deleted file mode 100644
index 6c5062e816..0000000000
--- a/klibc/klibc/gethostname.c
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * gethostname.c
- */
-
-#include <errno.h>
-#include <unistd.h>
-#include <string.h>
-#include <sys/utsname.h>
-
-int gethostname(char *name, size_t len)
-{
- struct utsname un;
-
- if ( !uname(&un) )
- return -1;
-
- if ( len < strlen(un.nodename)+1 ) {
- errno = EINVAL;
- return -1;
- }
-
- strcpy(name, un.nodename);
-
- return 0;
-}
diff --git a/klibc/klibc/getopt.c b/klibc/klibc/getopt.c
deleted file mode 100644
index cd534bf304..0000000000
--- a/klibc/klibc/getopt.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * getopt.c
- *
- * Simple POSIX getopt(), no GNU extensions...
- */
-
-#include <stdint.h>
-#include <unistd.h>
-#include <string.h>
-
-char *optarg;
-int optind = 1;
-int opterr, optopt;
-static const char *__optptr;
-
-int getopt(int argc, char * const *argv, const char *optstring)
-{
- const char *carg = argv[optind];
- const char *osptr;
- int opt;
-
- /* We don't actually need argc */
- (void)argc;
-
- /* First, eliminate all non-option cases */
-
- if ( !carg || carg[0] != '-' || !carg[1] ) {
- return -1;
- }
-
- if ( carg[1] == '-' && !carg[2] ) {
- optind++;
- return -1;
- }
-
- if ( (uintptr_t)(__optptr-carg) > (uintptr_t)strlen(carg) )
- __optptr = carg+1; /* Someone frobbed optind, change to new opt. */
-
- opt = *__optptr++;
-
- if ( opt != ':' && (osptr = strchr(optstring, opt)) ) {
- if ( osptr[1] == ':' ) {
- if ( *__optptr ) {
- /* Argument-taking option with attached argument */
- optarg = (char *)__optptr;
- optind++;
- } else {
- /* Argument-taking option with non-attached argument */
- if ( argv[optind+1] ) {
- optarg = (char *)argv[optind+1];
- optind += 2;
- } else {
- /* Missing argument */
- optind++;
- return (optstring[0] == ':') ? ':' : '?';
- }
- }
- return opt;
- } else {
- /* Non-argument-taking option */
- /* __optptr will remember the exact position to resume at */
- if ( ! *__optptr )
- optind++;
- return opt;
- }
- } else {
- /* Unknown option */
- optopt = opt;
- if ( ! *__optptr )
- optind++;
- return '?';
- }
-}
-
-
diff --git a/klibc/klibc/getpgrp.c b/klibc/klibc/getpgrp.c
deleted file mode 100644
index c92369807b..0000000000
--- a/klibc/klibc/getpgrp.c
+++ /dev/null
@@ -1,9 +0,0 @@
-/*
- * getpgrp.c
- */
-
-#include <unistd.h>
-
-pid_t getpgrp(void) {
- return getpgid(0);
-}
diff --git a/klibc/klibc/getpriority.c b/klibc/klibc/getpriority.c
deleted file mode 100644
index 4ea630487d..0000000000
--- a/klibc/klibc/getpriority.c
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * getpriority.c
- *
- * Needs to do some post-syscall mangling to distinguish error returns...
- * but only on some platforms. Sigh.
- */
-
-#include <unistd.h>
-#include <sys/time.h>
-#include <sys/resource.h>
-#include <sys/syscall.h>
-
-#if !defined(__alpha__) && !defined(__ia64__)
-
-extern int __getpriority(int, int);
-
-int getpriority(int which, int who)
-{
- int rv = __getpriority(which, who);
- return ( rv < 0 ) ? rv : 20-rv;
-}
-
-#endif
diff --git a/klibc/klibc/getpt.c b/klibc/klibc/getpt.c
deleted file mode 100644
index a05903062c..0000000000
--- a/klibc/klibc/getpt.c
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * getpt.c
- *
- * GNU extension to the standard Unix98 pty suite
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <termios.h>
-#include <fcntl.h>
-#include <sys/ioctl.h>
-
-int getpt(void)
-{
- return open("/dev/ptmx", O_RDWR|O_NOCTTY);
-}
diff --git a/klibc/klibc/globals.c b/klibc/klibc/globals.c
deleted file mode 100644
index 72ae91fbad..0000000000
--- a/klibc/klibc/globals.c
+++ /dev/null
@@ -1,10 +0,0 @@
-/*
- * globals.c
- *
- * These have to be defined somewhere...
- */
-#include <errno.h>
-#include <unistd.h>
-
-int errno;
-char **environ;
diff --git a/klibc/klibc/inet/bindresvport.c b/klibc/klibc/inet/bindresvport.c
deleted file mode 100644
index 750bd709c4..0000000000
--- a/klibc/klibc/inet/bindresvport.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * inet/bindresvport.c
- */
-
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <string.h>
-#include <unistd.h>
-
-#define START_PORT 768
-#define END_PORT IPPORT_RESERVED
-#define NUM_PORTS (END_PORT - START_PORT)
-
-int bindresvport(int sd, struct sockaddr_in *sin)
-{
- struct sockaddr_in me;
- static short port;
- int ret = 0;
- int i;
-
- if (sin == NULL) {
- memset(&me, 0, sizeof(me));
- sin = &me;
- sin->sin_family = AF_INET;
- } else if (sin->sin_family != AF_INET) {
- errno = EPFNOSUPPORT;
- return -1;
- }
-
- if (port == 0) {
- port = START_PORT + (getpid() % NUM_PORTS);
- }
-
- for (i = 0; i < NUM_PORTS; i++, port++) {
- if (port == END_PORT)
- port = START_PORT;
- sin->sin_port = htons(port);
- if ((ret = bind(sd, (struct sockaddr *)sin, sizeof(*sin))) != -1)
- break;
- }
-
- return ret;
-}
diff --git a/klibc/klibc/inet/inet_addr.c b/klibc/klibc/inet/inet_addr.c
deleted file mode 100644
index e04a4d0214..0000000000
--- a/klibc/klibc/inet/inet_addr.c
+++ /dev/null
@@ -1,14 +0,0 @@
-/*
- * inet/inet_addr.c
- */
-
-#include <arpa/inet.h>
-#include <stdio.h>
-
-uint32_t inet_addr(const char *str)
-{
- struct in_addr a;
- int rv = inet_aton(str, &a);
-
- return rv ? INADDR_NONE : a.s_addr;
-}
diff --git a/klibc/klibc/inet/inet_aton.c b/klibc/klibc/inet/inet_aton.c
deleted file mode 100644
index e581b492ad..0000000000
--- a/klibc/klibc/inet/inet_aton.c
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * inet/inet_aton.c
- */
-
-#include <arpa/inet.h>
-#include <stdio.h>
-
-int inet_aton(const char *str, struct in_addr *addr)
-{
- union {
- uint8_t b[4];
- uint32_t l;
- } a;
-
- if ( sscanf(str, "%hhu.%hhu.%hhu.%hhu", &a.b[0], &a.b[1], &a.b[2], &a.b[3]) == 4 ) {
- addr->s_addr = a.l; /* Always in network byte order */
- return 1;
- } else {
- return 0;
- }
-}
-
-
diff --git a/klibc/klibc/inet/inet_ntoa.c b/klibc/klibc/inet/inet_ntoa.c
deleted file mode 100644
index 5340aa622a..0000000000
--- a/klibc/klibc/inet/inet_ntoa.c
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * inet/inet_ntoa.c
- */
-
-#include <arpa/inet.h>
-#include <stdio.h>
-
-char *inet_ntoa(struct in_addr addr)
-{
- static char name[16];
- union {
- uint8_t b[4];
- uint32_t l;
- } a;
- a.l = addr.s_addr;
-
- sprintf(name, "%u.%u.%u.%u", a.b[0], a.b[1], a.b[2], a.b[3]);
- return name;
-}
diff --git a/klibc/klibc/inet/inet_ntop.c b/klibc/klibc/inet/inet_ntop.c
deleted file mode 100644
index 377bab7bf2..0000000000
--- a/klibc/klibc/inet/inet_ntop.c
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * inet/inet_ntop.c
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <arpa/inet.h>
-#include <netinet/in6.h>
-
-const char *inet_ntop(int af, const void *cp, char *buf, size_t len)
-{
- size_t xlen;
-
- switch ( af ) {
- case AF_INET:
- {
- union {
- uint8_t b[4];
- uint32_t l;
- } a;
- a.l = ((const struct in_addr *)cp)->s_addr;
-
- xlen = snprintf(buf, len, "%u.%u.%u.%u", a.b[0], a.b[1], a.b[2], a.b[3]);
- }
- break;
-
- case AF_INET6:
- {
- const struct in6_addr *s = (const struct in6_addr *)cp;
-
- xlen = snprintf(buf, len, "%x:%x:%x:%x:%x:%x:%x:%x",
- ntohs(s->s6_addr16[0]), ntohs(s->s6_addr16[1]),
- ntohs(s->s6_addr16[2]), ntohs(s->s6_addr16[3]),
- ntohs(s->s6_addr16[4]), ntohs(s->s6_addr16[5]),
- ntohs(s->s6_addr16[6]), ntohs(s->s6_addr16[7]));
- }
- break;
-
- default:
- errno = EAFNOSUPPORT;
- return NULL;
- }
-
- if ( xlen > len ) {
- errno = ENOSPC;
- return NULL;
- }
-
- return buf;
-}
-
diff --git a/klibc/klibc/inet/inet_pton.c b/klibc/klibc/inet/inet_pton.c
deleted file mode 100644
index 6c14b3cfb6..0000000000
--- a/klibc/klibc/inet/inet_pton.c
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * inet/inet_pton.c
- */
-
-#include <stdio.h>
-#include <stdint.h>
-#include <errno.h>
-#include <ctype.h>
-#include <string.h>
-#include <arpa/inet.h>
-#include <netinet/in6.h>
-
-static inline int hexval(int ch)
-{
- if ( ch >= '0' && ch <= '9' ) {
- return ch-'0';
- } else if ( ch >= 'A' && ch <= 'F' ) {
- return ch-'A'+10;
- } else if ( ch >= 'a' && ch <= 'f' ) {
- return ch-'a'+10;
- } else {
- return -1;
- }
-}
-
-int inet_pton(int af, const char *src, void *dst)
-{
- switch ( af ) {
- case AF_INET:
- return inet_aton(src, (struct in_addr *)dst);
-
- case AF_INET6:
- {
- struct in6_addr *d = (struct in6_addr *)dst;
- int colons = 0, dcolons = 0;
- int i;
- const char *p;
-
- /* A double colon will increment colons by 2, dcolons by 1 */
- for ( p = dst ; *p ; p++ ) {
- if ( p[0] == ':' ) {
- colons++;
- if ( p[1] == ':' )
- dcolons++;
- } else if ( !isxdigit(*p) )
- return 0; /* Not a valid address */
- }
-
- if ( colons > 7 || dcolons > 1 || (!dcolons && colons != 7) )
- return 0; /* Not a valid address */
-
- memset(d, 0, sizeof(struct in6_addr));
-
- i = 0;
- for ( p = dst ; *p ; p++ ) {
- if ( *p == ':' ) {
- if ( p[1] == ':' ) {
- i += (8-colons);
- } else {
- i++;
- }
- } else {
- d->s6_addr16[i] = htons((ntohs(d->s6_addr16[i]) << 4) + hexval(*p));
- }
- }
-
- return 1;
- }
-
- default:
- errno = EAFNOSUPPORT;
- return -1;
- }
-}
diff --git a/klibc/klibc/interp.S b/klibc/klibc/interp.S
deleted file mode 100644
index b1a2701999..0000000000
--- a/klibc/klibc/interp.S
+++ /dev/null
@@ -1,13 +0,0 @@
-#
-# This is a hack to generate the .intrp section, which then
-# ld turns into an PT_INTERP header.
-#
-# NOTE: The .interp section needs to be "a", or it doesnt work...
-#
-
- .section ".interp","a"
- .ascii LIBDIR
- .ascii "/klibc-"
- .ascii SOHASH
- .ascii ".so"
- .byte 0
diff --git a/klibc/klibc/isatty.c b/klibc/klibc/isatty.c
deleted file mode 100644
index ff5e1ff748..0000000000
--- a/klibc/klibc/isatty.c
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * isatty.c
- */
-
-#include <unistd.h>
-#include <termios.h>
-#include <errno.h>
-
-int isatty(int fd)
-{
- int old_errno = errno;
- int istty;
- pid_t dummy;
-
- /* All ttys support TIOCGPGRP */
- istty = !ioctl(fd, TIOCGPGRP, &dummy);
- errno = old_errno;
-
- return istty;
-}
-
diff --git a/klibc/klibc/jrand48.c b/klibc/klibc/jrand48.c
deleted file mode 100644
index 660a6e5a71..0000000000
--- a/klibc/klibc/jrand48.c
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * jrand48.c
- */
-
-#include <stdlib.h>
-#include <stdint.h>
-
-long jrand48(unsigned short xsubi[3])
-{
- uint64_t x;
-
- /* The xsubi[] array is littleendian by spec */
- x = (uint64_t)(uint16_t)xsubi[0] +
- ((uint64_t)(uint16_t)xsubi[1] << 16) +
- ((uint64_t)(uint16_t)xsubi[2] << 32);
-
- x = (0x5deece66dULL * x) + 0xb;
-
- xsubi[0] = (unsigned short)(uint16_t)x;
- xsubi[1] = (unsigned short)(uint16_t)(x >> 16);
- xsubi[2] = (unsigned short)(uint16_t)(x >> 32);
-
- return (long)(int32_t)(x >> 16);
-}
diff --git a/klibc/klibc/libc_init.c b/klibc/klibc/libc_init.c
deleted file mode 100644
index e91edc44a3..0000000000
--- a/klibc/klibc/libc_init.c
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * libc_init.c
- *
- * This function takes the raw data block set up by the ELF loader
- * in the kernel and parses it. It is invoked by crt0.S which makes
- * any necessary adjustments and passes calls this function using
- * the standard C calling convention.
- *
- * The arguments are:
- * uintptr_t *elfdata -- The ELF loader data block; usually from the stack.
- * Basically a pointer to argc.
- * void (*onexit)(void) -- Function to install into onexit
- */
-
-#include <stddef.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <klibc/compiler.h>
-#include <elf.h>
-
-/* This file is included from __static_init.c or __shared_init.c */
-#ifndef SHARED
-# error "SHARED should be defined to 0 or 1"
-#endif
-
-char **environ;
-unsigned int __page_size, __page_shift;
-
-struct auxentry {
- uintptr_t type;
- uintptr_t v;
-};
-
-__noreturn __libc_init(uintptr_t *elfdata, void (*onexit)(void))
-{
- int argc;
- char **argv, **envp, **envend;
- struct auxentry *auxentry;
-#if SHARED
- typedef int (*main_t)(int, char **, char **);
- main_t MAIN = NULL;
-#else
- extern int main(int, char **, char **);
-#define MAIN main
-#endif
- unsigned int page_size = 0, page_shift = 0;
-
- (void)onexit; /* For now, we ignore this... */
-
- argc = (int)*elfdata++;
- argv = (char **)elfdata;
- envp = argv+(argc+1);
-
- /* The auxillary entry vector is after all the environment vars */
- for ( envend = envp ; *envend ; envend++ );
- auxentry = (struct auxentry *)(envend+1);
-
- while ( auxentry->type ) {
- switch ( auxentry->type ) {
-#if SHARED
- case AT_ENTRY:
- MAIN = (main_t)(auxentry->v);
- break;
-#endif
- case AT_PAGESZ:
- page_size = (int)(auxentry->v);
- break;
- }
- auxentry++;
- }
-
- __page_size = page_size;
-
-#if defined(__i386__) || defined(__x86_64__)
- asm("bsrl %1,%0" : "=r" (page_shift) : "rm" (page_size));
-#else
- while ( page_size > 1 ) {
- page_shift++;
- page_size >>= 1;
- }
-#endif
- __page_shift = page_shift;
-
- environ = envp;
- exit(MAIN(argc, argv, envp));
-}
diff --git a/klibc/klibc/libgcc/__divdi3.c b/klibc/klibc/libgcc/__divdi3.c
deleted file mode 100644
index be13caed7e..0000000000
--- a/klibc/klibc/libgcc/__divdi3.c
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * arch/i386/libgcc/__divdi3.c
- */
-
-#include <stdint.h>
-#include <stddef.h>
-
-extern uint64_t __udivmoddi4(uint64_t num, uint64_t den, uint64_t *rem);
-
-int64_t __divdi3(int64_t num, int64_t den)
-{
- int minus = 0;
- int64_t v;
-
- if ( num < 0 ) {
- num = -num;
- minus = 1;
- }
- if ( den < 0 ) {
- den = -den;
- minus ^= 1;
- }
-
- v = __udivmoddi4(num, den, NULL);
- if ( minus )
- v = -v;
-
- return v;
-}
diff --git a/klibc/klibc/libgcc/__divsi3.c b/klibc/klibc/libgcc/__divsi3.c
deleted file mode 100644
index 24a7e044c8..0000000000
--- a/klibc/klibc/libgcc/__divsi3.c
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * libgcc/__divsi3.c
- */
-
-#include <stdint.h>
-#include <stddef.h>
-
-extern uint32_t __udivmodsi4(uint32_t num, uint32_t den, uint32_t *rem);
-
-int32_t __divsi3(int32_t num, int32_t den)
-{
- int minus = 0;
- int32_t v;
-
- if ( num < 0 ) {
- num = -num;
- minus = 1;
- }
- if ( den < 0 ) {
- den = -den;
- minus ^= 1;
- }
-
- v = __udivmodsi4(num, den, NULL);
- if ( minus )
- v = -v;
-
- return v;
-}
diff --git a/klibc/klibc/libgcc/__moddi3.c b/klibc/klibc/libgcc/__moddi3.c
deleted file mode 100644
index 3e613654e4..0000000000
--- a/klibc/klibc/libgcc/__moddi3.c
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * arch/i386/libgcc/__moddi3.c
- */
-
-#include <stdint.h>
-#include <stddef.h>
-
-extern uint64_t __udivmoddi4(uint64_t num, uint64_t den, uint64_t *rem);
-
-int64_t __moddi3(int64_t num, int64_t den)
-{
- int minus = 0;
- int64_t v;
-
- if ( num < 0 ) {
- num = -num;
- minus = 1;
- }
- if ( den < 0 ) {
- den = -den;
- minus ^= 1;
- }
-
- (void) __udivmoddi4(num, den, &v);
- if ( minus )
- v = -v;
-
- return v;
-}
diff --git a/klibc/klibc/libgcc/__modsi3.c b/klibc/klibc/libgcc/__modsi3.c
deleted file mode 100644
index cf62b8b556..0000000000
--- a/klibc/klibc/libgcc/__modsi3.c
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * libgcc/__modsi3.c
- */
-
-#include <stdint.h>
-#include <stddef.h>
-
-extern uint32_t __udivmodsi4(uint32_t num, uint32_t den, uint32_t *rem);
-
-int32_t __modsi3(int32_t num, int32_t den)
-{
- int minus = 0;
- int32_t v;
-
- if ( num < 0 ) {
- num = -num;
- minus = 1;
- }
- if ( den < 0 ) {
- den = -den;
- minus ^= 1;
- }
-
- (void) __udivmodsi4(num, den, &v);
- if ( minus )
- v = -v;
-
- return v;
-}
diff --git a/klibc/klibc/libgcc/__udivdi3.c b/klibc/klibc/libgcc/__udivdi3.c
deleted file mode 100644
index 901ce2aea6..0000000000
--- a/klibc/klibc/libgcc/__udivdi3.c
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * arch/i386/libgcc/__divdi3.c
- */
-
-#include <stdint.h>
-#include <stddef.h>
-
-extern uint64_t __udivmoddi4(uint64_t num, uint64_t den, uint64_t *rem);
-
-uint64_t __udivdi3(uint64_t num, uint64_t den)
-{
- return __udivmoddi4(num, den, NULL);
-}
diff --git a/klibc/klibc/libgcc/__udivmoddi4.c b/klibc/klibc/libgcc/__udivmoddi4.c
deleted file mode 100644
index 1c456543be..0000000000
--- a/klibc/klibc/libgcc/__udivmoddi4.c
+++ /dev/null
@@ -1,32 +0,0 @@
-#include <klibc/diverr.h>
-#include <stdint.h>
-
-uint64_t __udivmoddi4(uint64_t num, uint64_t den, uint64_t *rem_p)
-{
- uint64_t quot = 0, qbit = 1;
-
- if ( den == 0 ) {
- __divide_error();
- return 0; /* If trap returns... */
- }
-
- /* Left-justify denominator and count shift */
- while ( (int64_t)den >= 0 ) {
- den <<= 1;
- qbit <<= 1;
- }
-
- while ( qbit ) {
- if ( den <= num ) {
- num -= den;
- quot += qbit;
- }
- den >>= 1;
- qbit >>= 1;
- }
-
- if ( rem_p )
- *rem_p = num;
-
- return quot;
-}
diff --git a/klibc/klibc/libgcc/__udivmodsi4.c b/klibc/klibc/libgcc/__udivmodsi4.c
deleted file mode 100644
index 61f6bef0a4..0000000000
--- a/klibc/klibc/libgcc/__udivmodsi4.c
+++ /dev/null
@@ -1,32 +0,0 @@
-#include <klibc/diverr.h>
-#include <stdint.h>
-
-uint32_t __udivmodsi4(uint32_t num, uint32_t den, uint32_t *rem_p)
-{
- uint32_t quot = 0, qbit = 1;
-
- if ( den == 0 ) {
- __divide_error();
- return 0; /* If trap returns... */
- }
-
- /* Left-justify denominator and count shift */
- while ( (int32_t)den >= 0 ) {
- den <<= 1;
- qbit <<= 1;
- }
-
- while ( qbit ) {
- if ( den <= num ) {
- num -= den;
- quot += qbit;
- }
- den >>= 1;
- qbit >>= 1;
- }
-
- if ( rem_p )
- *rem_p = num;
-
- return quot;
-}
diff --git a/klibc/klibc/libgcc/__udivsi3.c b/klibc/klibc/libgcc/__udivsi3.c
deleted file mode 100644
index cba6f8f03d..0000000000
--- a/klibc/klibc/libgcc/__udivsi3.c
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * libgcc/__divsi3.c
- */
-
-#include <stdint.h>
-#include <stddef.h>
-
-extern uint32_t __udivmodsi4(uint32_t num, uint32_t den, uint32_t *rem);
-
-uint32_t __udivsi3(uint32_t num, uint32_t den)
-{
- return __udivmodsi4(num, den, NULL);
-}
diff --git a/klibc/klibc/libgcc/__umoddi3.c b/klibc/klibc/libgcc/__umoddi3.c
deleted file mode 100644
index c007d4859f..0000000000
--- a/klibc/klibc/libgcc/__umoddi3.c
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * arch/i386/libgcc/__umoddi3.c
- */
-
-#include <stdint.h>
-#include <stddef.h>
-
-extern uint64_t __udivmoddi4(uint64_t num, uint64_t den, uint64_t *rem);
-
-uint64_t __umoddi3(uint64_t num, uint64_t den)
-{
- uint64_t v;
-
- (void) __udivmoddi4(num, den, &v);
- return v;
-}
diff --git a/klibc/klibc/libgcc/__umodsi3.c b/klibc/klibc/libgcc/__umodsi3.c
deleted file mode 100644
index e3db972c4e..0000000000
--- a/klibc/klibc/libgcc/__umodsi3.c
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * libgcc/__umodsi3.c
- */
-
-#include <stdint.h>
-#include <stddef.h>
-
-extern uint32_t __udivmodsi4(uint32_t num, uint32_t den, uint32_t *rem);
-
-uint32_t __umodsi3(uint32_t num, uint32_t den)
-{
- uint32_t v;
-
- (void) __udivmodsi4(num, den, &v);
- return v;
-}
diff --git a/klibc/klibc/llseek.c b/klibc/klibc/llseek.c
deleted file mode 100644
index 857490b378..0000000000
--- a/klibc/klibc/llseek.c
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * llseek.c
- *
- * On 32-bit platforms, we need to use the _llseek() system call
- * rather than lseek(), to be able to handle large disks. _llseek()
- * isn't just a normal syscall which takes a 64-bit argument; it needs
- * to return a 64-bit value and so takes an extra pointer.
- */
-
-#include <unistd.h>
-#include <sys/syscall.h>
-#include <bitsize.h>
-
-#if _BITSIZE == 32
-
-extern int __llseek(int fd, unsigned long hi, unsigned long lo, off_t *res, int whence);
-
-off_t lseek(int fd, off_t offset, int whence)
-{
- off_t result;
- int rv;
-
- rv = __llseek(fd, (unsigned long)(offset >> 32), (unsigned long)offset,
- &result, whence);
-
- return rv ? (off_t)-1 : result;
-}
-
-#endif
-
diff --git a/klibc/klibc/lrand48.c b/klibc/klibc/lrand48.c
deleted file mode 100644
index 8c0a3de176..0000000000
--- a/klibc/klibc/lrand48.c
+++ /dev/null
@@ -1,14 +0,0 @@
-/*
- * lrand48.c
- */
-
-#include <stdlib.h>
-#include <stdint.h>
-
-unsigned short __rand48_seed[3]; /* Common with mrand48.c, srand48.c */
-
-long lrand48(void)
-{
- return (uint32_t)jrand48(__rand48_seed) >> 1;
-}
-
diff --git a/klibc/klibc/makeerrlist.pl b/klibc/klibc/makeerrlist.pl
deleted file mode 100644
index 14498d880a..0000000000
--- a/klibc/klibc/makeerrlist.pl
+++ /dev/null
@@ -1,100 +0,0 @@
-#!/usr/bin/perl
-#
-# This creates sys_errlist from <asm/errno.h> through somewhat
-# heuristic matching. It presumes the relevant entries are of the form
-# #define Exxxx <integer> /* comment */
-#
-
-use FileHandle;
-
-%errors = ();
-%errmsg = ();
-$maxerr = -1;
-@includelist = (); # Include directories
-
-sub parse_file($) {
- my($file) = @_;
- my($fh) = new FileHandle;
- my($line, $error, $msg);
- my($kernelonly) = 0;
- my($root);
-
- print STDERR "opening $file\n" unless ( $quiet );
-
- $ok = 0;
- foreach $root ( @includelist ) {
- if ( $fh->open($root.'//'.$file, '<') ) {
- $ok = 1;
- last;
- }
- }
-
- if ( ! $ok ) {
- die "$0: Cannot find file $file\n";
- }
-
- while ( defined($line = <$fh>) ) {
- if ( $kernelonly ) {
- if ( $line =~ /^\#\s*endif/ ) {
- $kernelonly--;
- } elsif ( $line =~ /^\#\sif/ ) {
- $kernelonly++;
- }
- } else {
- if ( $line =~ /^\#\s*define\s+([A-Z0-9_]+)\s+([0-9]+)\s*\/\*\s*(.*\S)\s*\*\// ) {
- $error = $1;
- $errno = $2+0;
- $msg = $3;
- print STDERR "$error ($errno) => \"$msg\"\n" unless ( $quiet );
- $errors{$errno} = $error;
- $errmsg{$errno} = $msg;
- $maxerr = $errno if ( $errno > $maxerr );
- } elsif ( $line =~ /^\#\s*include\s+[\<\"](.*)[\>\"]/ ) {
- parse_file($1);
- } elsif ( $line =~ /^\#\s*ifdef\s+__KERNEL__/ ) {
- $kernelonly++;
- }
- }
- }
- close($fh);
- print STDERR "closing $file\n" unless ( $quiet );
-}
-
-$v = $ENV{'KBUILD_VERBOSE'};
-$quiet = defined($v) ? !$v : 0;
-
-foreach $arg ( @ARGV ) {
- if ( $arg eq '-q' ) {
- $quiet = 1;
- } elsif ( $arg =~ /^-(errlist|errnos|maxerr)$/ ) {
- $type = $arg;
- } elsif ( $arg =~ '^\-I' ) {
- push(@includelist, "$'");
- } else {
- die "$0: Unknown option: $arg\n";
- }
-}
-
-parse_file('linux/errno.h');
-
-if ( $type eq '-errlist' ) {
- print "#include <errno.h>\n";
- printf "const int sys_nerr = %d;\n", $maxerr+1;
- printf "const char * const sys_errlist[%d] = {\n", $maxerr+1;
- foreach $e ( sort(keys(%errors)) ) {
- printf " [%s] = \"%s\",\n", $errors{$e}, $errmsg{$e};
- }
- print "};\n";
-} elsif ( $type eq '-errnos' ) {
- print "#include <errno.h>\n";
- printf "const int sys_nerr = %d;\n", $maxerr+1;
- printf "const char * const sys_errlist[%d] = {\n", $maxerr+1;
- foreach $e ( sort(keys(%errors)) ) {
- printf " [%s] = \"%s\",\n", $errors{$e}, $errors{$e};
- }
- print "};\n";
-} elsif ( $type eq '-maxerr' ) {
- print $maxerr, "\n";
-}
-
-
diff --git a/klibc/klibc/malloc.c b/klibc/klibc/malloc.c
deleted file mode 100644
index 976353c201..0000000000
--- a/klibc/klibc/malloc.c
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- * malloc.c
- *
- * Very simple linked-list based malloc()/free().
- */
-
-#include <stdlib.h>
-#include <sys/mman.h>
-#include "malloc.h"
-
-struct free_arena_header __malloc_head =
-{
- {
- ARENA_TYPE_HEAD,
- 0,
- &__malloc_head,
- &__malloc_head,
- },
- &__malloc_head,
- &__malloc_head
-};
-
-static void *__malloc_from_block(struct free_arena_header *fp, size_t size)
-{
- size_t fsize;
- struct free_arena_header *nfp, *na;
-
- fsize = fp->a.size;
-
- /* We need the 2* to account for the larger requirements of a free block */
- if ( fsize >= size+2*sizeof(struct arena_header) ) {
- /* Bigger block than required -- split block */
- nfp = (struct free_arena_header *)((char *)fp + size);
- na = fp->a.next;
-
- nfp->a.type = ARENA_TYPE_FREE;
- nfp->a.size = fsize-size;
- fp->a.type = ARENA_TYPE_USED;
- fp->a.size = size;
-
- /* Insert into all-block chain */
- nfp->a.prev = fp;
- nfp->a.next = na;
- na->a.prev = nfp;
- fp->a.next = nfp;
-
- /* Replace current block on free chain */
- nfp->next_free = fp->next_free;
- nfp->prev_free = fp->prev_free;
- fp->next_free->prev_free = nfp;
- fp->prev_free->next_free = nfp;
- } else {
- /* Allocate the whole block */
- fp->a.type = ARENA_TYPE_USED;
-
- /* Remove from free chain */
- fp->next_free->prev_free = fp->prev_free;
- fp->prev_free->next_free = fp->next_free;
- }
-
- return (void *)(&fp->a + 1);
-}
-
-static struct free_arena_header *
-__free_block(struct free_arena_header *ah)
-{
- struct free_arena_header *pah, *nah;
-
- pah = ah->a.prev;
- nah = ah->a.next;
- if ( pah->a.type == ARENA_TYPE_FREE &&
- (char *)pah+pah->a.size == (char *)ah ) {
- /* Coalesce into the previous block */
- pah->a.size += ah->a.size;
- pah->a.next = nah;
- nah->a.prev = pah;
-
-#ifdef DEBUG_MALLOC
- ah->a.type = ARENA_TYPE_DEAD;
-#endif
-
- ah = pah;
- pah = ah->a.prev;
- } else {
- /* Need to add this block to the free chain */
- ah->a.type = ARENA_TYPE_FREE;
-
- ah->next_free = __malloc_head.next_free;
- ah->prev_free = &__malloc_head;
- __malloc_head.next_free = ah;
- ah->next_free->prev_free = ah;
- }
-
- /* In either of the previous cases, we might be able to merge
- with the subsequent block... */
- if ( nah->a.type == ARENA_TYPE_FREE &&
- (char *)ah+ah->a.size == (char *)nah ) {
- ah->a.size += nah->a.size;
-
- /* Remove the old block from the chains */
- nah->next_free->prev_free = nah->prev_free;
- nah->prev_free->next_free = nah->next_free;
- ah->a.next = nah->a.next;
- nah->a.next->a.prev = ah;
-
-#ifdef DEBUG_MALLOC
- nah->a.type = ARENA_TYPE_DEAD;
-#endif
- }
-
- /* Return the block that contains the called block */
- return ah;
-}
-
-void *malloc(size_t size)
-{
- struct free_arena_header *fp;
- struct free_arena_header *pah;
- size_t fsize;
-
- if ( size == 0 )
- return NULL;
-
- /* Add the obligatory arena header, and round up */
- size = (size+2*sizeof(struct arena_header)-1) & ARENA_SIZE_MASK;
-
- for ( fp = __malloc_head.next_free ; fp->a.type != ARENA_TYPE_HEAD ;
- fp = fp->next_free ) {
- if ( fp->a.size >= size ) {
- /* Found fit -- allocate out of this block */
- return __malloc_from_block(fp, size);
- }
- }
-
- /* Nothing found... need to request a block from the kernel */
- fsize = (size+MALLOC_CHUNK_MASK) & ~MALLOC_CHUNK_MASK;
-
-#ifdef MALLOC_USING_SBRK
- fp = (struct free_arena_header *) sbrk(fsize);
-#else
- fp = (struct free_arena_header *)
- mmap(NULL, fsize, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
-#endif
-
- if ( fp == (struct free_arena_header *)MAP_FAILED ) {
- return NULL; /* Failed to get a block */
- }
-
- /* Insert the block into the management chains. We need to set
- up the size and the main block list pointer, the rest of
- the work is logically identical to free(). */
- fp->a.type = ARENA_TYPE_FREE;
- fp->a.size = fsize;
-
- /* We need to insert this into the main block list in the proper
- place -- this list is required to be sorted. Since we most likely
- get memory assignments in ascending order, search backwards for
- the proper place. */
- for ( pah = __malloc_head.a.prev ; pah->a.type != ARENA_TYPE_HEAD ;
- pah = pah->a.prev ) {
- if ( pah < fp )
- break;
- }
-
- /* Now pah points to the node that should be the predecessor of
- the new node */
- fp->a.next = pah->a.next;
- fp->a.prev = pah;
- pah->a.next = fp;
- fp->a.next->a.prev = fp;
-
-
- /* Insert into the free chain and coalesce with adjacent blocks */
- fp = __free_block(fp);
-
- /* Now we can allocate from this block */
- return __malloc_from_block(fp, size);
-}
-
-void free(void *ptr)
-{
- struct free_arena_header *ah;
-
- if ( !ptr )
- return;
-
- ah = (struct free_arena_header *)
- ((struct arena_header *)ptr - 1);
-
-#ifdef DEBUG_MALLOC
- assert( ah->a.type == ARENA_TYPE_USED );
-#endif
-
- __free_block(ah);
-
- /* Here we could insert code to return memory to the system. */
-}
diff --git a/klibc/klibc/malloc.h b/klibc/klibc/malloc.h
deleted file mode 100644
index 456295069a..0000000000
--- a/klibc/klibc/malloc.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * malloc.h
- *
- * Internals for the memory allocator
- */
-
-#include <stdint.h>
-#include <stddef.h>
-#include <klibc/sysconfig.h>
-
-/*
- * This structure should be a power of two. This becomes the
- * alignment unit.
- */
-struct free_arena_header;
-
-struct arena_header {
- size_t type;
- size_t size; /* Also gives the location of the next entry */
- struct free_arena_header *next, *prev;
-};
-
-#ifdef DEBUG_MALLOC
-#define ARENA_TYPE_USED 0x64e69c70
-#define ARENA_TYPE_FREE 0x012d610a
-#define ARENA_TYPE_HEAD 0x971676b5
-#define ARENA_TYPE_DEAD 0xeeeeeeee
-#else
-#define ARENA_TYPE_USED 0
-#define ARENA_TYPE_FREE 1
-#define ARENA_TYPE_HEAD 2
-#endif
-
-#define ARENA_SIZE_MASK (~(sizeof(struct arena_header)-1))
-
-/*
- * This structure should be no more than twice the size of the
- * previous structure.
- */
-struct free_arena_header {
- struct arena_header a;
- struct free_arena_header *next_free, *prev_free;
-};
-
-extern struct free_arena_header __malloc_head;
diff --git a/klibc/klibc/memccpy.c b/klibc/klibc/memccpy.c
deleted file mode 100644
index 22f68deaad..0000000000
--- a/klibc/klibc/memccpy.c
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * memccpy.c
- *
- * memccpy()
- */
-
-#include <stddef.h>
-#include <string.h>
-
-void *memccpy(void *dst, const void *src, int c, size_t n)
-{
- char *q = dst;
- const char *p = src;
- char ch;
-
- while ( n-- ) {
- *q++ = ch = *p++;
- if ( ch == (char)c )
- return q;
- }
-
- return NULL; /* No instance of "c" found */
-}
diff --git a/klibc/klibc/memchr.c b/klibc/klibc/memchr.c
deleted file mode 100644
index 2e5e4cc7f2..0000000000
--- a/klibc/klibc/memchr.c
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * memchr.c
- */
-
-#include <stddef.h>
-#include <string.h>
-
-void *memchr(const void *s, int c, size_t n)
-{
- const unsigned char *sp = s;
-
- while ( n-- ) {
- if ( *sp == (unsigned char)c )
- return (void *)sp;
- sp++;
- }
-
- return NULL;
-}
diff --git a/klibc/klibc/memcmp.c b/klibc/klibc/memcmp.c
deleted file mode 100644
index f6bc17286f..0000000000
--- a/klibc/klibc/memcmp.c
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * memcmp.c
- */
-
-#include <string.h>
-
-int memcmp(const void *s1, const void *s2, size_t n)
-{
- const unsigned char *c1 = s1, *c2 = s2;
- int d = 0;
-
- while ( n-- ) {
- d = (int)*c1++ - (int)*c2++;
- if ( d )
- break;
- }
-
- return d;
-}
diff --git a/klibc/klibc/memcpy.c b/klibc/klibc/memcpy.c
deleted file mode 100644
index b9171c300d..0000000000
--- a/klibc/klibc/memcpy.c
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * memcpy.c
- */
-
-#include <string.h>
-#include <stdint.h>
-
-void *memcpy(void *dst, const void *src, size_t n)
-{
- const char *p = src;
- char *q = dst;
-#if defined(__i386__)
- size_t nl = n >> 2;
- asm volatile("cld ; rep ; movsl ; movl %3,%0 ; rep ; movsb"
- : "+c" (nl), "+S" (p), "+D" (q)
- : "r" (n & 3));
-#elif defined(__x86_64__)
- size_t nq = n >> 3;
- asm volatile("cld ; rep ; movsq ; movl %3,%%ecx ; rep ; movsb"
- : "+c" (nq), "+S" (p), "+D" (q)
- : "r" ((uint32_t)(n & 7)));
-#else
- while ( n-- ) {
- *q++ = *p++;
- }
-#endif
-
- return dst;
-}
diff --git a/klibc/klibc/memmem.c b/klibc/klibc/memmem.c
deleted file mode 100644
index 8b5faa0014..0000000000
--- a/klibc/klibc/memmem.c
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * memmem.c
- *
- * Find a byte string inside a longer byte string
- *
- * This uses the "Not So Naive" algorithm, a very simple but
- * usually effective algorithm, see:
- *
- * http://www-igm.univ-mlv.fr/~lecroq/string/
- */
-
-#include <string.h>
-
-void *memmem(const void *haystack, size_t n, const void *needle, size_t m)
-{
- const unsigned char *y = (const unsigned char *)haystack;
- const unsigned char *x = (const unsigned char *)needle;
-
- size_t j, k, l;
-
- if (m > n || !m || !n)
- return NULL;
-
- if (1 != m) {
- if (x[0] == x[1]) {
- k = 2;
- l = 1;
- } else {
- k = 1;
- l = 2;
- }
-
- j = 0;
- while (j <= n - m) {
- if (x[1] != y[j + 1]) {
- j += k;
- } else {
- if (!memcmp(x + 2, y + j + 2, m - 2)
- && x[0] == y[j])
- return (void *)&y[j];
- j += l;
- }
- }
- } else
- do {
- if (*y == *x)
- return (void *)y;
- y++;
- } while (--n);
-
- return NULL;
-}
diff --git a/klibc/klibc/memmove.c b/klibc/klibc/memmove.c
deleted file mode 100644
index c1f042af39..0000000000
--- a/klibc/klibc/memmove.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * memmove.c
- */
-
-#include <string.h>
-
-void *memmove(void *dst, const void *src, size_t n)
-{
- const char *p = src;
- char *q = dst;
-#if defined(__i386__) || defined(__x86_64__)
- if ( q < p ) {
- asm volatile("cld ; rep ; movsb" : "+c" (n), "+S" (p), "+D" (q));
- } else {
- p += (n-1);
- q += (n-1);
- asm volatile("std ; rep ; movsb" : "+c" (n), "+S" (p), "+D" (q));
- }
-#else
- if ( q < p ) {
- while ( n-- ) {
- *q++ = *p++;
- }
- } else {
- p += n;
- q += n;
- while ( n-- ) {
- *--q = *--p;
- }
- }
-#endif
-
- return dst;
-}
diff --git a/klibc/klibc/memrchr.c b/klibc/klibc/memrchr.c
deleted file mode 100644
index 10d9c29851..0000000000
--- a/klibc/klibc/memrchr.c
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * memrchr.c
- */
-
-#include <stddef.h>
-#include <string.h>
-
-void *memrchr(const void *s, int c, size_t n)
-{
- const unsigned char *sp =
- (const unsigned char *)s + n - 1;
-
- while ( n-- ) {
- if ( *sp == (unsigned char)c )
- return (void *)sp;
- sp--;
- }
-
- return NULL;
-}
diff --git a/klibc/klibc/memset.c b/klibc/klibc/memset.c
deleted file mode 100644
index 522cc59a1e..0000000000
--- a/klibc/klibc/memset.c
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * memset.c
- */
-
-#include <string.h>
-#include <stdint.h>
-
-void *memset(void *dst, int c, size_t n)
-{
- char *q = dst;
-
-#if defined(__i386__)
- size_t nl = n >> 2;
- asm volatile("cld ; rep ; stosl ; movl %3,%0 ; rep ; stosb"
- : "+c" (nl), "+D" (q)
- : "a" ((unsigned char)c * 0x01010101U), "r" (n & 3));
-#elif defined(__x86_64__)
- size_t nq = n >> 3;
- asm volatile("cld ; rep ; stosq ; movl %3,%%ecx ; rep ; stosb"
- : "+c" (nq), "+D" (q)
- : "a" ((unsigned char)c * 0x0101010101010101U),
- "r" ((uint32_t)n & 7));
-#else
- while ( n-- ) {
- *q++ = c;
- }
-#endif
-
- return dst;
-}
diff --git a/klibc/klibc/memswap.c b/klibc/klibc/memswap.c
deleted file mode 100644
index 10440e3499..0000000000
--- a/klibc/klibc/memswap.c
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * memswap()
- *
- * Swaps the contents of two nonoverlapping memory areas.
- * This really could be done faster...
- */
-
-#include <string.h>
-
-void memswap(void *m1, void *m2, size_t n)
-{
- char *p = m1;
- char *q = m2;
- char tmp;
-
- while ( n-- ) {
- tmp = *p;
- *p = *q;
- *q = tmp;
-
- p++; q++;
- }
-}
diff --git a/klibc/klibc/mmap.c b/klibc/klibc/mmap.c
deleted file mode 100644
index 11c540aed6..0000000000
--- a/klibc/klibc/mmap.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * mmap.c
- */
-
-#include <stdint.h>
-#include <errno.h>
-#include <sys/syscall.h>
-#include <sys/mman.h>
-#include <unistd.h>
-#include <asm/page.h> /* For PAGE_SHIFT */
-#include <bitsize.h>
-
-/*
- * MMAP2_SHIFT is definitely *NOT* equal to getpageshift() for
- * many 32-bit architectures. Supposedly this is fixed to 12
- * for all 32-bit architectures. CHECK THIS!!!
- */
-# define MMAP2_SHIFT 12 /* Fixed by syscall definition */
-
-/*
- * Set in SYSCALLS whether or not we should use an unadorned mmap() system
- * call (typical on 64-bit architectures).
- */
-#if (_BITSIZE == 32 && defined(__NR_mmap2)) || (_BITSIZE == 64 && !defined(__NR_mmap))
-
-/* This architecture uses mmap2(). The Linux mmap2() system call takes
- a page offset as the offset argument. We need to make sure we have
- the proper conversion in place. */
-
-extern void *__mmap2(void *, size_t, int, int, int, size_t);
-
-void *mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset)
-{
- const int mmap2_shift = MMAP2_SHIFT;
- const unsigned long mmap2_mask = (1UL << mmap2_shift) - 1;
-
- if ( offset & mmap2_mask ) {
- errno = EINVAL;
- return MAP_FAILED;
- }
-
- return __mmap2(start, length, prot, flags, fd, (size_t)offset >> mmap2_shift);
-}
-
-#endif
-
-
-
-
diff --git a/klibc/klibc/mrand48.c b/klibc/klibc/mrand48.c
deleted file mode 100644
index 886ae9f03c..0000000000
--- a/klibc/klibc/mrand48.c
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * mrand48.c
- */
-
-#include <stdlib.h>
-#include <stdint.h>
-
-unsigned short __rand48_seed[3]; /* Common with lrand48.c, srand48.c */
-
-long mrand48(void)
-{
- return jrand48(__rand48_seed);
-}
diff --git a/klibc/klibc/nice.c b/klibc/klibc/nice.c
deleted file mode 100644
index 5a18de9091..0000000000
--- a/klibc/klibc/nice.c
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * nice.c
- */
-
-#include <unistd.h>
-#include <sched.h>
-#include <sys/resource.h>
-#include <sys/syscall.h>
-
-#ifndef __NR_nice
-
-int nice(int inc)
-{
- pid_t me = getpid();
- return setpriority(me, PRIO_PROCESS, getpriority(me, PRIO_PROCESS)+inc);
-}
-
-#endif
diff --git a/klibc/klibc/nrand48.c b/klibc/klibc/nrand48.c
deleted file mode 100644
index fb7c5772fd..0000000000
--- a/klibc/klibc/nrand48.c
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
- * nrand48.c
- */
-
-#include <stdlib.h>
-#include <stdint.h>
-
-long nrand48(unsigned short xsubi[3])
-{
- return (long)((uint32_t)jrand48(xsubi) >> 1);
-}
diff --git a/klibc/klibc/onexit.c b/klibc/klibc/onexit.c
deleted file mode 100644
index 70a9c01f61..0000000000
--- a/klibc/klibc/onexit.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * onexit.c
- */
-
-#include <stdlib.h>
-#include <unistd.h>
-#include "atexit.h"
-
-extern __noreturn (*__exit_handler)(int);
-static struct atexit *__atexit_list;
-
-static __noreturn on_exit_exit(int rv)
-{
- struct atexit *ap;
-
- for ( ap = __atexit_list ; ap ; ap = ap->next ) {
- ap->fctn(rv, ap->arg); /* This assumes extra args are harmless */
- }
-
- _exit(rv);
-}
-
-int on_exit(void (*fctn)(int, void *), void *arg)
-{
- struct atexit *as = malloc(sizeof(struct atexit));
-
- if ( !as )
- return -1;
-
- as->fctn = fctn;
- as->arg = arg;
-
- as->next = __atexit_list;
- __atexit_list = as;
-
- __exit_handler = on_exit_exit;
-
- return 0;
-}
diff --git a/klibc/klibc/open.c b/klibc/klibc/open.c
deleted file mode 100644
index cb1f5195db..0000000000
--- a/klibc/klibc/open.c
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * open.c
- *
- * On 32-bit platforms we need to pass O_LARGEFILE to the open()
- * system call, to indicate that we're 64-bit safe.
- */
-
-#define _KLIBC_IN_OPEN_C
-#include <unistd.h>
-#include <fcntl.h>
-#include <bitsize.h>
-
-#if _BITSIZE == 32 && !defined(__i386__)
-
-extern int __open(const char *, int, mode_t);
-
-int open(const char *pathname, int flags, mode_t mode)
-{
- return __open(pathname, flags|O_LARGEFILE, mode);
-}
-
-#endif
diff --git a/klibc/klibc/pause.c b/klibc/klibc/pause.c
deleted file mode 100644
index 1f7b9342de..0000000000
--- a/klibc/klibc/pause.c
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * pause.c
- */
-
-#include <stddef.h>
-#include <unistd.h>
-#include <sys/time.h>
-#include <sys/syscall.h>
-
-#ifndef __NR_pause
-
-int pause(void)
-{
- return select(0,NULL,NULL,NULL,NULL);
-}
-
-#endif
diff --git a/klibc/klibc/perror.c b/klibc/klibc/perror.c
deleted file mode 100644
index 26f8ce8f6d..0000000000
--- a/klibc/klibc/perror.c
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * perror.c
- */
-
-#include <errno.h>
-#include <stdio.h>
-#include <string.h>
-
-void perror(const char *s)
-{
- int e = errno;
- fprintf(stderr, "%s: %s\n", s, strerror(e));
-}
diff --git a/klibc/klibc/printf.c b/klibc/klibc/printf.c
deleted file mode 100644
index 34237592d6..0000000000
--- a/klibc/klibc/printf.c
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * printf.c
- */
-
-#include <stdio.h>
-#include <stdarg.h>
-
-#define BUFFER_SIZE 16384
-
-int printf(const char *format, ...)
-{
- va_list ap;
- int rv;
-
- va_start(ap, format);
- rv = vfprintf(stdout, format, ap);
- va_end(ap);
- return rv;
-}
diff --git a/klibc/klibc/pty.c b/klibc/klibc/pty.c
deleted file mode 100644
index 2fe01ab204..0000000000
--- a/klibc/klibc/pty.c
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * pty.c
- *
- * Basic Unix98 PTY functionality; assumes devpts mounted on /dev/pts
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <termios.h>
-#include <sys/ioctl.h>
-
-char *ptsname(int fd)
-{
- static char buffer[32]; /* Big enough to hold even a 64-bit pts no */
- unsigned int ptyno;
-
- if ( ioctl(fd, TIOCGPTN, &ptyno) )
- return NULL;
-
- snprintf(buffer, sizeof buffer, "/dev/pts/%u", ptyno);
-
- return buffer;
-}
-
-int unlockpt(int fd)
-{
- int unlock = 0;
-
- return ioctl(fd, TIOCSPTLCK, &unlock);
-}
diff --git a/klibc/klibc/putchar.c b/klibc/klibc/putchar.c
deleted file mode 100644
index 0e35adda17..0000000000
--- a/klibc/klibc/putchar.c
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * putchar.c
- *
- * - gcc wants this
- */
-
-#include <stdio.h>
-
-#undef putchar /* Defined as a macro */
-int putchar(int);
-
-int putchar(int c)
-{
- return fputc(c, stdout);
-}
diff --git a/klibc/klibc/putenv.c b/klibc/klibc/putenv.c
deleted file mode 100644
index 8138c653b4..0000000000
--- a/klibc/klibc/putenv.c
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * putenv.c
- */
-
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-/* str should be a duplicated version of the input string;
- len is the length of the key including the = sign */
-int __put_env(char *str, size_t len, int overwrite);
-
-int putenv(const char *str)
-{
- char *s;
- const char *e, *z;
-
- if ( !str ) {
- errno = EINVAL;
- return -1;
- }
-
- e = NULL;
- for ( z = str ; *z ; z++ ) {
- if ( *z == '=' )
- e = z;
- }
-
- if ( !e ) {
- errno = EINVAL;
- return -1;
- }
-
- s = strdup(str);
- if ( !s )
- return -1;
-
- return __put_env(s, e-str, 1);
-}
diff --git a/klibc/klibc/puts.c b/klibc/klibc/puts.c
deleted file mode 100644
index ecebf275da..0000000000
--- a/klibc/klibc/puts.c
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * puts.c
- */
-
-#include <stdio.h>
-
-int puts(const char *s)
-{
- if ( fputs(s, stdout) < 0 )
- return -1;
-
- return _fwrite("\n", 1, stdout);
-}
diff --git a/klibc/klibc/qsort.c b/klibc/klibc/qsort.c
deleted file mode 100644
index 185f4dac69..0000000000
--- a/klibc/klibc/qsort.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * qsort.c
- *
- * This is actually combsort. It's an O(n log n) algorithm with
- * simplicity/small code size being its main virtue.
- */
-
-#include <stddef.h>
-#include <string.h>
-
-static inline size_t newgap(size_t gap)
-{
- gap = (gap*10)/13;
- if ( gap == 9 || gap == 10 )
- gap = 11;
-
- if ( gap < 1 )
- gap = 1;
- return gap;
-}
-
-void qsort(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *))
-{
- size_t gap = nmemb;
- size_t i, j;
- char *p1, *p2;
- int swapped;
-
- do {
- gap = newgap(gap);
- swapped = 0;
-
- for ( i = 0, p1 = base ; i < nmemb-gap ; i++, p1 += size ) {
- j = i+gap;
- if ( compar(p1, p2 = (char *)base+j*size) > 0 ) {
- memswap(p1, p2, size);
- swapped = 1;
- }
- }
- } while ( gap > 1 || swapped );
-}
-
diff --git a/klibc/klibc/raise.c b/klibc/klibc/raise.c
deleted file mode 100644
index dcbb9c9c6c..0000000000
--- a/klibc/klibc/raise.c
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
- * raise.c
- */
-
-#include <unistd.h>
-#include <signal.h>
-
-int raise(int signal)
-{
- return kill(getpid(), signal);
-}
diff --git a/klibc/klibc/readdir.c b/klibc/klibc/readdir.c
deleted file mode 100644
index acfe588713..0000000000
--- a/klibc/klibc/readdir.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * readdir.c: opendir/readdir/closedir
- */
-
-#include <unistd.h>
-#include <fcntl.h>
-#include <stdlib.h>
-
-#define __KLIBC_DIRENT_INTERNALS
-#include <dirent.h>
-
-DIR *opendir(const char *name)
-{
- DIR *dp = malloc(sizeof(DIR));
-
- if ( !dp )
- return NULL;
-
- dp->__fd = open(name, O_DIRECTORY|O_RDONLY);
-
- if ( dp->__fd < 0 ) {
- free(dp);
- return NULL;
- }
-
- dp->bytes_left = 0;
-
- return dp;
-}
-
-struct dirent *readdir(DIR *dir)
-{
- struct dirent *dent;
- int rv;
-
- if ( !dir->bytes_left ) {
- rv = getdents(dir->__fd, dir->buffer, sizeof(dir->buffer));
- if ( rv <= 0 )
- return NULL;
- dir->bytes_left = rv;
- dir->next = dir->buffer;
- }
-
- dent = dir->next;
- dir->next = (struct dirent *)((char *)dir->next + dent->d_reclen);
- dir->bytes_left -= dent->d_reclen;
-
- return dent;
-}
-
-int closedir(DIR *dir)
-{
- int rv;
- rv = close(dir->__fd);
- free(dir);
- return rv;
-}
diff --git a/klibc/klibc/realloc.c b/klibc/klibc/realloc.c
deleted file mode 100644
index 577c2001a5..0000000000
--- a/klibc/klibc/realloc.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * realloc.c
- */
-
-#include <stdlib.h>
-#include <string.h>
-
-#include "malloc.h"
-
-/* FIXME: This is cheesy, it should be fixed later */
-
-void *realloc(void *ptr, size_t size)
-{
- struct free_arena_header *ah;
- void *newptr;
- size_t oldsize;
-
- if ( !ptr )
- return malloc(size);
-
- if ( size == 0 ) {
- free(ptr);
- return NULL;
- }
-
- /* Add the obligatory arena header, and round up */
- size = (size+2*sizeof(struct arena_header)-1) & ARENA_SIZE_MASK;
-
- ah = (struct free_arena_header *)
- ((struct arena_header *)ptr - 1);
-
- if ( ah->a.size >= size && size >= (ah->a.size >> 2) ) {
- /* This field is a good size already. */
- return ptr;
- } else {
- /* Make me a new block. This is kind of bogus; we should
- be checking the adjacent blocks to see if we can do an
- in-place adjustment... fix that later. */
-
- oldsize = ah->a.size - sizeof(struct arena_header);
-
- newptr = malloc(size);
- memcpy(newptr, ptr, (size < oldsize) ? size : oldsize);
- free(ptr);
-
- return newptr;
- }
-}
-
diff --git a/klibc/klibc/reboot.c b/klibc/klibc/reboot.c
deleted file mode 100644
index 772c85910e..0000000000
--- a/klibc/klibc/reboot.c
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * reboot.c
- */
-
-#include <unistd.h>
-#include <sys/reboot.h>
-#include <sys/syscall.h>
-
-/* This provides the one-argument glibc-ish version of reboot.
- The full four-argument system call is available as __reboot(). */
-
-int reboot(int flag)
-{
- return __reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, flag, NULL);
-}
diff --git a/klibc/klibc/recv.c b/klibc/klibc/recv.c
deleted file mode 100644
index 4d30610cee..0000000000
--- a/klibc/klibc/recv.c
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
- * recv.c
- */
-
-#include <stddef.h>
-#include <sys/socket.h>
-
-int recv(int s, void *buf, size_t len, unsigned int flags)
-{
- return recvfrom(s, buf, len, flags, NULL, 0);
-}
diff --git a/klibc/klibc/sbrk.c b/klibc/klibc/sbrk.c
deleted file mode 100644
index cb0efb21b9..0000000000
--- a/klibc/klibc/sbrk.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/* sbrk.c - Change data segment size */
-
-/* Written 2000 by Werner Almesberger */
-/* Modified 2003-2004 for klibc by H. Peter Anvin */
-
-#include <stddef.h>
-#include <unistd.h>
-#include <inttypes.h>
-#include <errno.h>
-#include "malloc.h"
-
-char *__current_brk; /* Common with brk.c */
-
-/* p is an address, a is alignment; must be a power of 2 */
-static inline void *align_up(void *p, uintptr_t a)
-{
- return (void *) (((uintptr_t)p + a-1) & ~(a-1));
-}
-
-void *sbrk(ptrdiff_t increment)
-{
- char *start, *end, *new_brk;
-
- if (!__current_brk)
- __current_brk = __brk(NULL);
-
- start = align_up(__current_brk, SBRK_ALIGNMENT);
- end = start + increment;
-
- new_brk = __brk(end);
-
- if (new_brk == (void *)-1)
- return (void *)-1;
- else if (new_brk < end) {
- errno = ENOMEM;
- return (void *) -1;
- }
-
- __current_brk = new_brk;
- return start;
-}
diff --git a/klibc/klibc/seed48.c b/klibc/klibc/seed48.c
deleted file mode 100644
index ac916d6165..0000000000
--- a/klibc/klibc/seed48.c
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * seed48.c
- */
-
-#include <stdlib.h>
-#include <stdint.h>
-#include <string.h>
-
-unsigned short __rand48_seed[3];
-
-unsigned short *seed48(const unsigned short xsubi[3])
-{
- static unsigned short oldseed[3];
- memcpy(oldseed, __rand48_seed, sizeof __rand48_seed);
- memcpy(__rand48_seed, xsubi, sizeof __rand48_seed);
-
- return oldseed;
-}
-
diff --git a/klibc/klibc/send.c b/klibc/klibc/send.c
deleted file mode 100644
index 8c53d0f764..0000000000
--- a/klibc/klibc/send.c
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
- * send.c
- */
-
-#include <stddef.h>
-#include <sys/socket.h>
-
-int send(int s, const void *buf, size_t len, unsigned int flags)
-{
- return sendto(s, buf, len, flags, NULL, 0);
-}
diff --git a/klibc/klibc/setegid.c b/klibc/klibc/setegid.c
deleted file mode 100644
index 09f2416e43..0000000000
--- a/klibc/klibc/setegid.c
+++ /dev/null
@@ -1,10 +0,0 @@
-/*
- * setegid.c
- */
-
-#include <unistd.h>
-
-int setegid(gid_t egid)
-{
- return setregid(-1, egid);
-}
diff --git a/klibc/klibc/setenv.c b/klibc/klibc/setenv.c
deleted file mode 100644
index d4ada53d74..0000000000
--- a/klibc/klibc/setenv.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * setenv.c
- */
-
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-/* str should be a duplicated version of the input string;
- len is the length of the key including the = sign */
-int __put_env(char *str, size_t len, int overwrite);
-
-int setenv(const char *name, const char *val, int overwrite)
-{
- const char *z;
- char *s;
- size_t l1, l2;
-
- if ( !name || !name[0] ) {
- errno = EINVAL;
- return -1;
- }
-
- l1 = 0;
- for ( z = name ; *z ; z++ ) {
- l1++;
- if ( *z == '=' ) {
- errno = EINVAL;
- return -1;
- }
- }
-
- l2 = strlen(val);
-
- s = malloc(l1+l2+2);
- if ( !s )
- return -1;
-
- memcpy(s, name, l1);
- s[l1] = '=';
- memcpy(s+l1+1, val, l2+1);
-
- return __put_env(s, l1+1, overwrite);
-}
diff --git a/klibc/klibc/seteuid.c b/klibc/klibc/seteuid.c
deleted file mode 100644
index 6d1ac3922a..0000000000
--- a/klibc/klibc/seteuid.c
+++ /dev/null
@@ -1,10 +0,0 @@
-/*
- * seteuid.c
- */
-
-#include <unistd.h>
-
-int seteuid(uid_t euid)
-{
- return setreuid(-1, euid);
-}
diff --git a/klibc/klibc/setpgrp.c b/klibc/klibc/setpgrp.c
deleted file mode 100644
index 001dd0435d..0000000000
--- a/klibc/klibc/setpgrp.c
+++ /dev/null
@@ -1,10 +0,0 @@
-/*
- * setpgrp.c
- */
-
-#include <unistd.h>
-
-int setpgrp(void)
-{
- return setpgid(0,0);
-}
diff --git a/klibc/klibc/sha1hash.c b/klibc/klibc/sha1hash.c
deleted file mode 100644
index 28e3399967..0000000000
--- a/klibc/klibc/sha1hash.c
+++ /dev/null
@@ -1,317 +0,0 @@
-/*
-SHA-1 in C
-By Steve Reid <sreid@sea-to-sky.net>
-100% Public Domain
-
------------------
-Modified 7/98
-By James H. Brown <jbrown@burgoyne.com>
-Still 100% Public Domain
-
-Corrected a problem which generated improper hash values on 16 bit machines
-Routine SHA1Update changed from
- void SHA1Update(SHA1_CTX* context, unsigned char* data, unsigned int
-len)
-to
- void SHA1Update(SHA1_CTX* context, unsigned char* data, unsigned
-long len)
-
-The 'len' parameter was declared an int which works fine on 32 bit machines.
-However, on 16 bit machines an int is too small for the shifts being done
-against
-it. This caused the hash function to generate incorrect values if len was
-greater than 8191 (8K - 1) due to the 'len << 3' on line 3 of SHA1Update().
-
-Since the file IO in main() reads 16K at a time, any file 8K or larger would
-be guaranteed to generate the wrong hash (e.g. Test Vector #3, a million
-"a"s).
-
-I also changed the declaration of variables i & j in SHA1Update to
-unsigned long from unsigned int for the same reason.
-
-These changes should make no difference to any 32 bit implementations since
-an
-int and a long are the same size in those environments.
-
---
-I also corrected a few compiler warnings generated by Borland C.
-1. Added #include <process.h> for exit() prototype
-2. Removed unused variable 'j' in SHA1Final
-3. Changed exit(0) to return(0) at end of main.
-
-ALL changes I made can be located by searching for comments containing 'JHB'
------------------
-Modified 8/98
-By Steve Reid <sreid@sea-to-sky.net>
-Still 100% public domain
-
-1- Removed #include <process.h> and used return() instead of exit()
-2- Fixed overwriting of finalcount in SHA1Final() (discovered by Chris Hall)
-3- Changed email address from steve@edmweb.com to sreid@sea-to-sky.net
-
------------------
-Modified 4/01
-By Saul Kravitz <Saul.Kravitz@celera.com>
-Still 100% PD
-Modified to run on Compaq Alpha hardware.
-
------------------
-Modified 2/03
-By H. Peter Anvin <hpa@zytor.com>
-Still 100% PD
-Modified to run on any hardware with <inttypes.h> and <netinet/in.h>
-Changed the driver program
-
-*/
-
-/*
-Test Vectors (from FIPS PUB 180-1)
-"abc"
- A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D
-"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
- 84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1
-A million repetitions of "a"
- 34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F
-*/
-
-/* #define SHA1HANDSOFF */
-
-#include <stdio.h>
-#include <string.h>
-#include <inttypes.h>
-#include <netinet/in.h> /* For htonl/ntohl/htons/ntohs */
-
-/* #include <process.h> */ /* prototype for exit() - JHB */
-/* Using return() instead of exit() - SWR */
-
-typedef struct {
- uint32_t state[5];
- uint32_t count[2];
- unsigned char buffer[64];
-} SHA1_CTX;
-
-void SHA1Transform(uint32_t state[5], unsigned char buffer[64]);
-void SHA1Init(SHA1_CTX* context);
-void SHA1Update(SHA1_CTX* context, unsigned char* data, uint32_t len); /*
-JHB */
-void SHA1Final(unsigned char digest[20], SHA1_CTX* context);
-
-#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
-
-/* blk0() and blk() perform the initial expand. */
-/* I got the idea of expanding during the round function from SSLeay */
-#define blk0(i) (block->l[i] = ntohl(block->l[i]))
-#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
- ^block->l[(i+2)&15]^block->l[i&15],1))
-
-/* (R0+R1), R2, R3, R4 are the different operations used in SHA1 */
-#define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
-#define R1(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30);
-#define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
-#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
-#define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
-
-
-#ifdef VERBOSE /* SAK */
-void SHAPrintContext(SHA1_CTX *context, char *msg){
- printf("%s (%d,%d) %x %x %x %x %x\n",
- msg,
- context->count[0], context->count[1],
- context->state[0],
- context->state[1],
- context->state[2],
- context->state[3],
- context->state[4]);
-}
-#endif
-
-/* Hash a single 512-bit block. This is the core of the algorithm. */
-
-void SHA1Transform(uint32_t state[5], unsigned char buffer[64])
-{
-uint32_t a, b, c, d, e;
-typedef union {
- unsigned char c[64];
- uint32_t l[16];
-} CHAR64LONG16;
-CHAR64LONG16* block;
-#ifdef SHA1HANDSOFF
-static unsigned char workspace[64];
- block = (CHAR64LONG16*)workspace;
- memcpy(block, buffer, 64);
-#else
- block = (CHAR64LONG16*)buffer;
-#endif
- /* Copy context->state[] to working vars */
- a = state[0];
- b = state[1];
- c = state[2];
- d = state[3];
- e = state[4];
- /* 4 rounds of 20 operations each. Loop unrolled. */
- R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2); R0(c,d,e,a,b, 3);
- R0(b,c,d,e,a, 4); R0(a,b,c,d,e, 5); R0(e,a,b,c,d, 6); R0(d,e,a,b,c, 7);
- R0(c,d,e,a,b, 8); R0(b,c,d,e,a, 9); R0(a,b,c,d,e,10); R0(e,a,b,c,d,11);
- R0(d,e,a,b,c,12); R0(c,d,e,a,b,13); R0(b,c,d,e,a,14); R0(a,b,c,d,e,15);
- R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19);
- R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23);
- R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27);
- R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31);
- R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35);
- R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39);
- R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43);
- R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47);
- R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51);
- R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55);
- R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59);
- R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63);
- R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67);
- R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71);
- R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75);
- R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79);
- /* Add the working vars back into context.state[] */
- state[0] += a;
- state[1] += b;
- state[2] += c;
- state[3] += d;
- state[4] += e;
- /* Wipe variables */
- a = b = c = d = e = 0;
-}
-
-
-/* SHA1Init - Initialize new context */
-
-void SHA1Init(SHA1_CTX* context)
-{
- /* SHA1 initialization constants */
- context->state[0] = 0x67452301;
- context->state[1] = 0xEFCDAB89;
- context->state[2] = 0x98BADCFE;
- context->state[3] = 0x10325476;
- context->state[4] = 0xC3D2E1F0;
- context->count[0] = context->count[1] = 0;
-}
-
-
-/* Run your data through this. */
-
-void SHA1Update(SHA1_CTX* context, unsigned char* data, uint32_t len) /*
-JHB */
-{
-uint32_t i, j; /* JHB */
-
-#ifdef VERBOSE
- SHAPrintContext(context, "before");
-#endif
- j = (context->count[0] >> 3) & 63;
- if ((context->count[0] += len << 3) < (len << 3)) context->count[1]++;
- context->count[1] += (len >> 29);
- if ((j + len) > 63) {
- memcpy(&context->buffer[j], data, (i = 64-j));
- SHA1Transform(context->state, context->buffer);
- for ( ; i + 63 < len; i += 64) {
- SHA1Transform(context->state, &data[i]);
- }
- j = 0;
- }
- else i = 0;
- memcpy(&context->buffer[j], &data[i], len - i);
-#ifdef VERBOSE
- SHAPrintContext(context, "after ");
-#endif
-}
-
-
-/* Add padding and return the message digest. */
-
-void SHA1Final(unsigned char digest[20], SHA1_CTX* context)
-{
-uint32_t i; /* JHB */
-unsigned char finalcount[8];
-
- for (i = 0; i < 8; i++) {
- finalcount[i] = (unsigned char)((context->count[(i >= 4 ? 0 : 1)]
- >> ((3-(i & 3)) * 8) ) & 255); /* Endian independent */
- }
- SHA1Update(context, (unsigned char *)"\200", 1);
- while ((context->count[0] & 504) != 448) {
- SHA1Update(context, (unsigned char *)"\0", 1);
- }
- SHA1Update(context, finalcount, 8); /* Should cause a SHA1Transform()
-*/
- for (i = 0; i < 20; i++) {
- digest[i] = (unsigned char)
- ((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255);
- }
- /* Wipe variables */
- i = 0; /* JHB */
- memset(context->buffer, 0, 64);
- memset(context->state, 0, 20);
- memset(context->count, 0, 8);
- memset(finalcount, 0, 8); /* SWR */
-#ifdef SHA1HANDSOFF /* make SHA1Transform overwrite it's own static vars */
- SHA1Transform(context->state, context->buffer);
-#endif
-}
-
-/*************************************************************/
-
-/* This is not quite the MIME base64 algorithm: it uses _ instead of /,
- and instead of padding the output with = characters we just make the
- output shorter. */
-char *mybase64(uint8_t digest[20])
-{
- static const char charz[] =
- "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
- uint8_t input[21];
- static char output[28];
- int i, j;
- uint8_t *p;
- char *q;
- uint32_t bv;
-
- memcpy(input, digest, 20);
- input[20] = 0; /* Pad to multiple of 3 bytes */
-
- p = input; q = output;
- for ( i = 0 ; i < 7 ; i++ ) {
- bv = (p[0] << 16) | (p[1] << 8) | p[2];
- p += 3;
- for ( j = 0 ; j < 4 ; j++ ) {
- *q++ = charz[(bv >> 18) & 0x3f];
- bv <<= 6;
- }
- }
- *--q = '\0'; /* The last character is not significant */
- return output;
-}
-
-int main(int argc, char** argv)
-{
- int i;
- SHA1_CTX context;
- uint8_t digest[20], buffer[16384];
- FILE* file;
-
- if (argc < 2) {
- file = stdin;
- }
- else {
- if (!(file = fopen(argv[1], "rb"))) {
- fputs("Unable to open file.", stderr);
- return(-1);
- }
- }
- SHA1Init(&context);
- while (!feof(file)) { /* note: what if ferror(file) */
- i = fread(buffer, 1, 16384, file);
- SHA1Update(&context, buffer, i);
- }
- SHA1Final(digest, &context);
- fclose(file);
-
- puts(mybase64(digest));
-
- return 0;
-}
diff --git a/klibc/klibc/sigaction.c b/klibc/klibc/sigaction.c
deleted file mode 100644
index 85f42a244c..0000000000
--- a/klibc/klibc/sigaction.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * sigaction.c
- */
-
-#include <signal.h>
-#include <sys/syscall.h>
-
-__extern void __sigreturn(void);
-__extern int __sigaction(int, const struct sigaction *, struct sigaction *);
-__extern int __rt_sigaction(int, const struct sigaction *, struct sigaction *, size_t);
-
-int sigaction(int sig, const struct sigaction *act, struct sigaction *oact)
-{
- int rv;
-
-#if defined(__i386__) || defined(__x86_64__)
- /* x86-64, and the Fedora i386 kernel, are broken without SA_RESTORER */
- struct sigaction sa;
-
- if ( act && !(act->sa_flags & SA_RESTORER) ) {
- sa = *act;
- act = &sa;
-
- /* The kernel can't be trusted to have a valid default restorer */
- sa.sa_flags |= SA_RESTORER;
- sa.sa_restorer = &__sigreturn;
- }
-#endif
-
-#ifdef __NR_sigaction
- rv = __sigaction(sig, act, oact);
-#else
- rv = __rt_sigaction(sig, act, oact, sizeof(sigset_t));
-#endif
-
-
-#if defined(__i386__) || defined(__x86_64__)
- if ( oact && (oact->sa_restorer == &__sigreturn) ) {
- oact->sa_flags &= ~SA_RESTORER;
- }
-#endif
-
- return rv;
-}
diff --git a/klibc/klibc/siglist.c b/klibc/klibc/siglist.c
deleted file mode 100644
index dce7355079..0000000000
--- a/klibc/klibc/siglist.c
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * siglist.h
- *
- * Construct the signal list
- */
-
-#include <signal.h>
-#include <unistd.h>
-
-const char * const sys_siglist[NSIG] = {
-#ifdef SIGABRT
- [SIGABRT] = "Aborted",
-#endif
-#ifdef SIGALRM
- [SIGALRM] = "Alarm clock",
-#endif
-#ifdef SIGBUS
- [SIGBUS] = "Bus error",
-#endif
-#ifdef SIGCHLD
- [SIGCHLD] = "Child exited",
-#endif
-#if defined(SIGCLD) && (SIGCHLD != SIGCLD)
- [SIGCLD] = "Child exited",
-#endif
-#ifdef SIGEMT
- [SIGEMT] = "Emulation trap",
-#endif
-#ifdef SIGFPE
- [SIGFPE] = "Floating point exception",
-#endif
-#ifdef SIGHUP
- [SIGHUP] = "Hangup",
-#endif
-#ifdef SIGILL
- [SIGILL] = "Illegal instruction",
-#endif
- /* SIGINFO == SIGPWR */
-#ifdef SIGINT
- [SIGINT] = "Interrupt",
-#endif
-#ifdef SIGIO
- [SIGIO] = "I/O possible",
-#endif
-#if defined(SIGIOT) && (SIGIOT != SIGABRT)
- [SIGIOT] = "I/O trap",
-#endif
-#ifdef SIGKILL
- [SIGKILL] = "Killed",
-#endif
-#if defined(SIGLOST) && (SIGLOST != SIGIO) && (SIGLOST != SIGPWR)
- [SIGLOST] = "Lock lost",
-#endif
-#ifdef SIGPIPE
- [SIGPIPE] = "Broken pipe",
-#endif
-#if defined(SIGPOLL) && (SIGPOLL != SIGIO)
- [SIGPOLL] = "Pollable event",
-#endif
-#ifdef SIGPROF
- [SIGPROF] = "Profiling timer expired",
-#endif
-#ifdef SIGPWR
- [SIGPWR] = "Power failure",
-#endif
-#ifdef SIGQUIT
- [SIGQUIT] = "Quit",
-#endif
- /* SIGRESERVE == SIGUNUSED */
-#ifdef SIGSEGV
- [SIGSEGV] = "Segment violation",
-#endif
-#ifdef SIGSTKFLT
- [SIGSTKFLT] = "Stack fault",
-#endif
-#ifdef SIGSTOP
- [SIGSTOP] = "Stopped (signal)",
-#endif
-#ifdef SIGSYS
- [SIGSYS] = "Bad system call",
-#endif
-#ifdef SIGTERM
- [SIGTERM] = "Terminated",
-#endif
-#ifdef SIGTSTP
- [SIGTSTP] = "Stopped",
-#endif
-#ifdef SIGTTIN
- [SIGTTIN] = "Stopped (tty input)",
-#endif
-#ifdef SIGTTOU
- [SIGTTOU] = "Stopped (tty output)",
-#endif
-#ifdef SIGURG
- [SIGURG] = "Urgent I/O condition",
-#endif
-#ifdef SIGUSR1
- [SIGUSR1] = "User signal 1",
-#endif
-#ifdef SIGUSR2
- [SIGUSR2] = "User signal 2",
-#endif
-#ifdef SIGVTALRM
- [SIGVTALRM] = "Virtual timer expired",
-#endif
-#ifdef SIGWINCH
- [SIGWINCH] = "Window size changed",
-#endif
-#ifdef SIGXCPU
- [SIGXCPU] = "CPU time limit exceeded",
-#endif
-#ifdef SIGXFSZ
- [SIGXFSZ] = "File size limit exceeded",
-#endif
-};
diff --git a/klibc/klibc/siglongjmp.c b/klibc/klibc/siglongjmp.c
deleted file mode 100644
index 2ba1239b6b..0000000000
--- a/klibc/klibc/siglongjmp.c
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * siglongjmp.c
- *
- * sigsetjmp() is a macro, by necessity (it's either that or write
- * it in assembly), but siglongjmp() is a normal function.
- */
-
-#include <setjmp.h>
-#include <signal.h>
-
-__noreturn siglongjmp(sigjmp_buf buf, int retval)
-{
- sigprocmask(SIG_SETMASK, &buf->__sigs, NULL);
- longjmp(buf->__jmpbuf, retval);
-}
-
diff --git a/klibc/klibc/sigpending.c b/klibc/klibc/sigpending.c
deleted file mode 100644
index decfe32b1b..0000000000
--- a/klibc/klibc/sigpending.c
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * sigpending.c
- */
-
-#include <signal.h>
-#include <sys/syscall.h>
-
-#ifndef __NR_sigpending
-
-__extern __rt_sigpending(sigset_t *, size_t);
-
-int sigpending(sigset_t *set)
-{
- return __rt_sigpending(set, sizeof(sigset_t));
-}
-
-#endif
diff --git a/klibc/klibc/sigprocmask.c b/klibc/klibc/sigprocmask.c
deleted file mode 100644
index 372e0fd90d..0000000000
--- a/klibc/klibc/sigprocmask.c
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * sigprocmask.c
- */
-
-#include <signal.h>
-#include <sys/syscall.h>
-
-#ifndef __NR_sigprocmask
-
-__extern __rt_sigprocmask(int, const sigset_t *, sigset_t *, size_t);
-
-int sigprocmask(int how, const sigset_t *set, sigset_t *oset)
-{
- return __rt_sigprocmask(how, set, oset, sizeof(sigset_t));
-}
-
-#endif
diff --git a/klibc/klibc/sigsuspend.c b/klibc/klibc/sigsuspend.c
deleted file mode 100644
index 22f9a46681..0000000000
--- a/klibc/klibc/sigsuspend.c
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * sigsuspend.c
- */
-
-#include <signal.h>
-#include <sys/syscall.h>
-
-#ifndef __NR_sigsuspend
-
-__extern int __rt_sigsuspend(const sigset_t *, size_t);
-
-int sigsuspend(const sigset_t *mask)
-{
- return __rt_sigsuspend(mask, sizeof *mask);
-}
-
-#endif
diff --git a/klibc/klibc/sleep.c b/klibc/klibc/sleep.c
deleted file mode 100644
index eb3777e8a6..0000000000
--- a/klibc/klibc/sleep.c
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * sleep.c
- */
-
-#include <errno.h>
-#include <time.h>
-
-unsigned int sleep(unsigned int seconds)
-{
- struct timespec ts;
-
- ts.tv_sec = seconds;
- ts.tv_nsec = 0;
- if ( !nanosleep(&ts,&ts) )
- return 0;
- else if ( errno == EINTR )
- return ts.tv_sec;
- else
- return -1;
-}
diff --git a/klibc/klibc/snprintf.c b/klibc/klibc/snprintf.c
deleted file mode 100644
index c642851b2f..0000000000
--- a/klibc/klibc/snprintf.c
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * snprintf.c
- */
-
-#include <stdio.h>
-
-int snprintf(char *buffer, size_t n, const char *format, ...)
-{
- va_list ap;
- int rv;
-
- va_start(ap, format);
- rv = vsnprintf(buffer, n, format, ap);
- va_end(ap);
- return rv;
-}
diff --git a/klibc/klibc/socketcalls.pl b/klibc/klibc/socketcalls.pl
deleted file mode 100644
index 68f0fa164b..0000000000
--- a/klibc/klibc/socketcalls.pl
+++ /dev/null
@@ -1,88 +0,0 @@
-#!/usr/bin/perl
-
-$v = $ENV{'KBUILD_VERBOSE'};
-$quiet = defined($v) ? !$v : 0;
-
-@args = ();
-for $arg ( @ARGV ) {
- if ( $arg =~ /^-/ ) {
- if ( $arg eq '-q' ) {
- $quiet = 1;
- } else {
- die "$0: Unknown option: $arg\n";
- }
- } else {
- push(@args, $arg);
- }
-}
-($file, $arch, $outputdir) = @args;
-
-if (!open(FILE, "< $file")) {
- die "$file: $!\n";
-}
-
-print "socketcall-objs := ";
-while ( defined($line = <FILE>) ) {
- chomp $line;
- $line =~ s/\s*[\#\;].*$//; # Strip comments and trailing blanks
- next unless $line;
-
- if ( $line =~ /^\s*\<\?\>\s*(.*)\s+([_a-zA-Z][_a-zA-Z0-9]+)\s*\((.*)\)$/ ) {
- $type = $1;
- $name = $2;
- $argv = $3;
-
- @args = split(/\s*\,\s*/, $argv);
- @cargs = ();
-
- $i = 0;
- for $arg ( @args ) {
- push(@cargs, "$arg a".$i++);
- }
- $nargs = $i;
- print " \\\n\t${name}.o";
-
- if ( $arch eq 'i386' ) {
- open(OUT, '>', "${outputdir}/${name}.S")
- or die "$0: Cannot open ${outputdir}/${name}.S\n";
-
- print OUT "#include <sys/socketcalls.h>\n";
- print OUT "\n";
- print OUT "\t.text\n";
- print OUT "\t.align 4\n";
- print OUT "\t.globl ${name}\n";
- print OUT "\t.type ${name},\@function\n";
- print OUT "${name}:\n";
- print OUT "\tmovb \$SYS_\U${name}\E,%al\n";
- print OUT "\tjmp __socketcall_common\n";
- print OUT "\t.size ${name},.-${name}\n";
- close(OUT);
- } else {
- open(OUT, '>', "${outputdir}/${name}.c")
- or die "$0: Cannot open ${outputdir}/${name}.c\n";
-
- print OUT "#include \"../socketcommon.h\"\n";
- print OUT "\n";
- print OUT "#ifndef __NR_${name}\n\n";
-
- print OUT "extern long __socketcall(int, const unsigned long *);\n\n";
-
- print OUT "$type $name (", join(', ', @cargs), ")\n";
- print OUT "{\n";
- print OUT " unsigned long args[$nargs];\n";
- for ( $i = 0 ; $i < $nargs ; $i++ ) {
- print OUT " args[$i] = (unsigned long)a$i;\n";
- }
- print OUT " return ($type) __socketcall(SYS_\U${name}\E, args);\n";
- print OUT "}\n\n";
-
- print OUT "#endif\n";
-
- close(OUT);
- }
- } else {
- die "$file:$.: Could not parse input\n";
- }
-}
-
-print "\n";
diff --git a/klibc/klibc/socketcommon.h b/klibc/klibc/socketcommon.h
deleted file mode 100644
index 9c4b11fab8..0000000000
--- a/klibc/klibc/socketcommon.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * socketcommon.h
- *
- * Common header file for socketcall stubs
- */
-
-#define __IN_SYS_COMMON
-#include <errno.h>
-#include <signal.h>
-#include <sys/types.h>
-#include <sys/syscall.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <sys/socket.h>
-#include <linux/net.h>
-#include <sys/socketcalls.h>
diff --git a/klibc/klibc/sprintf.c b/klibc/klibc/sprintf.c
deleted file mode 100644
index 31f28af005..0000000000
--- a/klibc/klibc/sprintf.c
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * sprintf.c
- */
-
-#include <stdio.h>
-#include <unistd.h>
-
-int sprintf(char *buffer, const char *format, ...)
-{
- va_list ap;
- int rv;
-
- va_start(ap, format);
- rv = vsnprintf(buffer, ~(size_t)0, format, ap);
- va_end(ap);
-
- return rv;
-}
diff --git a/klibc/klibc/srand48.c b/klibc/klibc/srand48.c
deleted file mode 100644
index 5f201d2047..0000000000
--- a/klibc/klibc/srand48.c
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * srand48.c
- */
-
-#include <stdlib.h>
-#include <stdint.h>
-
-unsigned short __rand48_seed[3]; /* Common with mrand48.c, lrand48.c */
-
-void srand48(long seedval)
-{
- __rand48_seed[0] = 0x330e;
- __rand48_seed[1] = (unsigned short)seedval;
- __rand48_seed[2] = (unsigned short)((uint32_t)seedval >> 16);
-}
diff --git a/klibc/klibc/sscanf.c b/klibc/klibc/sscanf.c
deleted file mode 100644
index 81aab9e05b..0000000000
--- a/klibc/klibc/sscanf.c
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * sscanf()
- */
-
-#include <stdio.h>
-
-int sscanf(const char *str, const char *format, ...)
-{
- va_list ap;
- int rv;
-
- va_start(ap, format);
- rv = vsscanf(str, format, ap);
- va_end(ap);
-
- return rv;
-}
diff --git a/klibc/klibc/statfs.c b/klibc/klibc/statfs.c
deleted file mode 100644
index 60e9188a09..0000000000
--- a/klibc/klibc/statfs.c
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * statfs.c
- *
- * On architectures which do statfs64, wrap the system call
- */
-
-#include <sys/syscall.h>
-#include <sys/vfs.h>
-
-#ifdef __NR_statfs64
-
-extern int __statfs64(const char *, size_t, struct statfs *);
-
-int statfs(const char *path, struct statfs *buf)
-{
- return __statfs64(path, sizeof *buf, buf);
-}
-
-#endif
diff --git a/klibc/klibc/strcasecmp.c b/klibc/klibc/strcasecmp.c
deleted file mode 100644
index 12aef40d93..0000000000
--- a/klibc/klibc/strcasecmp.c
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * strcasecmp.c
- */
-
-#include <string.h>
-#include <ctype.h>
-
-int strcasecmp(const char *s1, const char *s2)
-{
- const unsigned char *c1 = s1, *c2 = s2;
- unsigned char ch;
- int d = 0;
-
- while ( 1 ) {
- /* toupper() expects an unsigned char (implicitly cast to int)
- as input, and returns an int, which is exactly what we want. */
- d = toupper(ch = *c1++) - toupper(*c2++);
- if ( d || !ch )
- break;
- }
-
- return d;
-}
diff --git a/klibc/klibc/strcat.c b/klibc/klibc/strcat.c
deleted file mode 100644
index a5f9477866..0000000000
--- a/klibc/klibc/strcat.c
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
- * strcat.c
- */
-
-#include <string.h>
-
-char *strcat(char *dst, const char *src)
-{
- strcpy(strchr(dst, '\0'), src);
- return dst;
-}
diff --git a/klibc/klibc/strchr.c b/klibc/klibc/strchr.c
deleted file mode 100644
index f657095c6b..0000000000
--- a/klibc/klibc/strchr.c
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * strchr.c
- */
-
-#include <string.h>
-#include <klibc/compiler.h>
-
-char *strchr(const char *s, int c)
-{
- while ( *s != (char)c ) {
- if ( ! *s )
- return NULL;
- s++;
- }
-
- return (char *)s;
-}
-
-__ALIAS(char *, index, (const char *, int), strchr)
diff --git a/klibc/klibc/strcmp.c b/klibc/klibc/strcmp.c
deleted file mode 100644
index f44774f443..0000000000
--- a/klibc/klibc/strcmp.c
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * strcmp.c
- */
-
-#include <string.h>
-
-int strcmp(const char *s1, const char *s2)
-{
- const unsigned char *c1 = s1, *c2 = s2;
- unsigned char ch;
- int d = 0;
-
- while ( 1 ) {
- d = (int)(ch = *c1++) - (int)*c2++;
- if ( d || !ch )
- break;
- }
-
- return d;
-}
diff --git a/klibc/klibc/strcpy.c b/klibc/klibc/strcpy.c
deleted file mode 100644
index 8372eba50b..0000000000
--- a/klibc/klibc/strcpy.c
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * strcpy.c
- *
- * strcpy()
- */
-
-#include <string.h>
-
-char *strcpy(char *dst, const char *src)
-{
- char *q = dst;
- const char *p = src;
- char ch;
-
- do {
- *q++ = ch = *p++;
- } while ( ch );
-
- return dst;
-}
diff --git a/klibc/klibc/strcspn.c b/klibc/klibc/strcspn.c
deleted file mode 100644
index 87d644551e..0000000000
--- a/klibc/klibc/strcspn.c
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
- * strcspn
- */
-
-#include "strxspn.h"
-
-size_t
-strcspn(const char *s, const char *reject)
-{
- return __strxspn(s, reject, 1);
-}
diff --git a/klibc/klibc/strdup.c b/klibc/klibc/strdup.c
deleted file mode 100644
index eb170c2645..0000000000
--- a/klibc/klibc/strdup.c
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * strdup.c
- */
-
-#include <string.h>
-#include <stdlib.h>
-
-char *strdup(const char *s)
-{
- int l = strlen(s)+1;
- char *d = malloc(l);
-
- if ( d )
- memcpy(d, s, l);
-
- return d;
-}
diff --git a/klibc/klibc/strerror.c b/klibc/klibc/strerror.c
deleted file mode 100644
index c8e3eac793..0000000000
--- a/klibc/klibc/strerror.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * strerror.c
- */
-
-#include <string.h>
-
-char *strerror(int errnum)
-{
- static char message[32] = "error "; /* enough for error 2^63-1 */
- char numbuf[32];
- char *p;
- unsigned int e = (unsigned int)errnum;
-
-#ifdef WITH_ERRLIST
- extern const int sys_nerr;
- extern const char * const sys_errlist[];
-
- if ( e < (unsigned int)sys_nerr && sys_errlist[e] )
- return (char *)sys_errlist[e];
-#endif
-
- p = numbuf+sizeof numbuf;
- *--p = '\0';
-
- do {
- *--p = (e % 10) + '0';
- e /= 10;
- } while ( e );
-
- memcpy(message+6, p, (numbuf+sizeof numbuf)-p);
-
- return message;
-}
-
diff --git a/klibc/klibc/strlcat.c b/klibc/klibc/strlcat.c
deleted file mode 100644
index f397857e76..0000000000
--- a/klibc/klibc/strlcat.c
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * strlcat.c
- */
-
-#include <string.h>
-#include <klibc/compiler.h>
-
-size_t strlcat(char *dst, const char *src, size_t size)
-{
- size_t bytes = 0;
- char *q = dst;
- const char *p = src;
- char ch;
-
- while ( bytes < size && *q ) {
- q++;
- bytes++;
- }
- if (bytes == size)
- return (bytes + strlen(src));
-
- while ( (ch = *p++) ) {
- if ( bytes+1 < size )
- *q++ = ch;
-
- bytes++;
- }
-
- *q = '\0';
- return bytes;
-}
-
-
diff --git a/klibc/klibc/strlcpy.c b/klibc/klibc/strlcpy.c
deleted file mode 100644
index e6937445cd..0000000000
--- a/klibc/klibc/strlcpy.c
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * strlcpy.c
- */
-
-#include <string.h>
-#include <klibc/compiler.h>
-
-size_t strlcpy(char *dst, const char *src, size_t size)
-{
- size_t bytes = 0;
- char *q = dst;
- const char *p = src;
- char ch;
-
- while ( (ch = *p++) ) {
- if ( bytes+1 < size )
- *q++ = ch;
-
- bytes++;
- }
-
- /* If size == 0 there is no space for a final null... */
- if ( size )
- *q = '\0';
-
- return bytes;
-}
-
-
diff --git a/klibc/klibc/strlen.c b/klibc/klibc/strlen.c
deleted file mode 100644
index 4d773f9a05..0000000000
--- a/klibc/klibc/strlen.c
+++ /dev/null
@@ -1,14 +0,0 @@
-/*
- * strlen()
- */
-
-#include <string.h>
-
-size_t strlen(const char *s)
-{
- const char *ss = s;
- while ( *ss )
- ss++;
- return ss-s;
-}
-
diff --git a/klibc/klibc/strncasecmp.c b/klibc/klibc/strncasecmp.c
deleted file mode 100644
index 3309d1a7fe..0000000000
--- a/klibc/klibc/strncasecmp.c
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * strncasecmp.c
- */
-
-#include <string.h>
-#include <ctype.h>
-
-int strncasecmp(const char *s1, const char *s2, size_t n)
-{
- const unsigned char *c1 = s1, *c2 = s2;
- unsigned char ch;
- int d = 0;
-
- while ( n-- ) {
- /* toupper() expects an unsigned char (implicitly cast to int)
- as input, and returns an int, which is exactly what we want. */
- d = toupper(ch = *c1++) - toupper(*c2++);
- if ( d || !ch )
- break;
- }
-
- return d;
-}
diff --git a/klibc/klibc/strncat.c b/klibc/klibc/strncat.c
deleted file mode 100644
index 78223152c4..0000000000
--- a/klibc/klibc/strncat.c
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * strncat.c
- */
-
-#include <string.h>
-#include <klibc/compiler.h>
-
-char *strncat(char *dst, const char *src, size_t n)
-{
- char *q = strchr(dst, '\0');
- const char *p = src;
- char ch;
-
- while (n--) {
- *q++ = ch = *p++;
- if ( !ch )
- return dst;
- }
- *q = '\0';
-
- return dst;
-}
diff --git a/klibc/klibc/strncmp.c b/klibc/klibc/strncmp.c
deleted file mode 100644
index 4dbde1389f..0000000000
--- a/klibc/klibc/strncmp.c
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * strncmp.c
- */
-
-#include <string.h>
-
-int strncmp(const char *s1, const char *s2, size_t n)
-{
- const unsigned char *c1 = s1, *c2 = s2;
- unsigned char ch;
- int d = 0;
-
- while ( n-- ) {
- d = (int)(ch = *c1++) - (int)*c2++;
- if ( d || !ch )
- break;
- }
-
- return d;
-}
diff --git a/klibc/klibc/strncpy.c b/klibc/klibc/strncpy.c
deleted file mode 100644
index 06964f31d6..0000000000
--- a/klibc/klibc/strncpy.c
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * strncpy.c
- */
-
-#include <string.h>
-
-char *strncpy(char *dst, const char *src, size_t n)
-{
- char *q = dst;
- const char *p = src;
- char ch;
-
- while (n) {
- n--;
- *q++ = ch = *p++;
- if ( !ch )
- break;
- }
-
- /* The specs say strncpy() fills the entire buffer with NUL. Sigh. */
- memset(q, 0, n);
-
- return dst;
-}
diff --git a/klibc/klibc/strndup.c b/klibc/klibc/strndup.c
deleted file mode 100644
index 1b44e6f99a..0000000000
--- a/klibc/klibc/strndup.c
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * strndup.c
- */
-
-#include <string.h>
-#include <stdlib.h>
-
-char *strndup(const char *s, size_t n)
-{
- int l = n > strlen(s) ? strlen(s)+1 : n+1;
- char *d = malloc(l);
-
- if (d)
- memcpy(d, s, l);
- d[n] = '\0';
- return d;
-}
diff --git a/klibc/klibc/strnlen.c b/klibc/klibc/strnlen.c
deleted file mode 100644
index 06b54c3189..0000000000
--- a/klibc/klibc/strnlen.c
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * strnlen()
- */
-
-#include <string.h>
-
-size_t strnlen(const char *s, size_t maxlen)
-{
- const char *ss = s;
-
- /* Important: the maxlen test must precede the reference through ss;
- since the byte beyond the maximum may segfault */
- while ((maxlen > 0) && *ss) {
- ss++;
- maxlen--;
- }
- return ss-s;
-}
-
diff --git a/klibc/klibc/strntoimax.c b/klibc/klibc/strntoimax.c
deleted file mode 100644
index f53a266dba..0000000000
--- a/klibc/klibc/strntoimax.c
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * strntoimax.c
- *
- * strntoimax()
- */
-
-#include <stddef.h>
-#include <inttypes.h>
-
-intmax_t strntoimax(const char *nptr, char **endptr, int base, size_t n)
-{
- return (intmax_t) strntoumax(nptr, endptr, base, n);
-}
diff --git a/klibc/klibc/strntoumax.c b/klibc/klibc/strntoumax.c
deleted file mode 100644
index 4c47fe8662..0000000000
--- a/klibc/klibc/strntoumax.c
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * strntoumax.c
- *
- * The strntoumax() function and associated
- */
-
-#include <stddef.h>
-#include <stdint.h>
-#include <ctype.h>
-
-static inline int digitval(int ch)
-{
- if ( ch >= '0' && ch <= '9' ) {
- return ch-'0';
- } else if ( ch >= 'A' && ch <= 'Z' ) {
- return ch-'A'+10;
- } else if ( ch >= 'a' && ch <= 'z' ) {
- return ch-'a'+10;
- } else {
- return -1;
- }
-}
-
-uintmax_t strntoumax(const char *nptr, char **endptr, int base, size_t n)
-{
- int minus = 0;
- uintmax_t v = 0;
- int d;
-
- while ( n && isspace((unsigned char)*nptr) ) {
- nptr++;
- n--;
- }
-
- /* Single optional + or - */
- if ( n ) {
- char c = *nptr;
- if ( c == '-' || c == '+' ) {
- minus = (c == '-');
- nptr++;
- n--;
- }
- }
-
- if ( base == 0 ) {
- if ( n >= 2 && nptr[0] == '0' &&
- (nptr[1] == 'x' || nptr[1] == 'X') ) {
- n -= 2;
- nptr += 2;
- base = 16;
- } else if ( n >= 1 && nptr[0] == '0' ) {
- n--;
- nptr++;
- base = 8;
- } else {
- base = 10;
- }
- } else if ( base == 16 ) {
- if ( n >= 2 && nptr[0] == '0' &&
- (nptr[1] == 'x' || nptr[1] == 'X') ) {
- n -= 2;
- nptr += 2;
- }
- }
-
- while ( n && (d = digitval(*nptr)) >= 0 && d < base ) {
- v = v*base + d;
- n--;
- nptr++;
- }
-
- if ( endptr )
- *endptr = (char *)nptr;
-
- return minus ? -v : v;
-}
diff --git a/klibc/klibc/strpbrk.c b/klibc/klibc/strpbrk.c
deleted file mode 100644
index 86ea236308..0000000000
--- a/klibc/klibc/strpbrk.c
+++ /dev/null
@@ -1,14 +0,0 @@
-/*
- * strpbrk
- */
-
-#include "strxspn.h"
-
-char *
-strpbrk(const char *s, const char *accept)
-{
- const char *ss = s+__strxspn(s, accept, 1);
-
- return *ss ? (char *)ss : NULL;
-}
-
diff --git a/klibc/klibc/strrchr.c b/klibc/klibc/strrchr.c
deleted file mode 100644
index 5a0cbe386e..0000000000
--- a/klibc/klibc/strrchr.c
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * strrchr.c
- */
-
-#include <string.h>
-#include <klibc/compiler.h>
-
-char *strrchr(const char *s, int c)
-{
- const char *found = NULL;
-
- while ( *s ) {
- if ( *s == (char) c )
- found = s;
- s++;
- }
-
- return (char *)found;
-}
-
-__ALIAS(char *, rindex, (const char *, int), strrchr)
diff --git a/klibc/klibc/strsep.c b/klibc/klibc/strsep.c
deleted file mode 100644
index 58a7a07773..0000000000
--- a/klibc/klibc/strsep.c
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * strsep.c
- */
-
-#include <string.h>
-
-char *strsep(char **stringp, const char *delim)
-{
- char *s = *stringp;
- char *e;
-
- if ( !s )
- return NULL;
-
- e = strpbrk(s, delim);
- if (e)
- *e++ = '\0';
-
- *stringp = e;
- return s;
-}
diff --git a/klibc/klibc/strspn.c b/klibc/klibc/strspn.c
deleted file mode 100644
index 10b1dfc5fa..0000000000
--- a/klibc/klibc/strspn.c
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
- * strspn
- */
-
-#include "strxspn.h"
-
-size_t
-strspn(const char *s, const char *accept)
-{
- return __strxspn(s, accept, 0);
-}
diff --git a/klibc/klibc/strstr.c b/klibc/klibc/strstr.c
deleted file mode 100644
index 10222dfd30..0000000000
--- a/klibc/klibc/strstr.c
+++ /dev/null
@@ -1,10 +0,0 @@
-/*
- * strstr.c
- */
-
-#include <string.h>
-
-char *strstr(const char *haystack, const char *needle)
-{
- return (char *)memmem(haystack, strlen(haystack), needle, strlen(needle));
-}
diff --git a/klibc/klibc/strtoimax.c b/klibc/klibc/strtoimax.c
deleted file mode 100644
index 0cdd088e51..0000000000
--- a/klibc/klibc/strtoimax.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#define TYPE intmax_t
-#define NAME strtoimax
-#include "strtox.c"
diff --git a/klibc/klibc/strtok.c b/klibc/klibc/strtok.c
deleted file mode 100644
index 6e84f1dff3..0000000000
--- a/klibc/klibc/strtok.c
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * strtok.c
- */
-
-#include <string.h>
-
-char *strtok(char *s, const char *delim)
-{
- static char *holder;
-
- if ( s )
- holder = s;
-
- return strsep(&holder, delim);
-}
-
diff --git a/klibc/klibc/strtol.c b/klibc/klibc/strtol.c
deleted file mode 100644
index 9efc8b9e4a..0000000000
--- a/klibc/klibc/strtol.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#define TYPE signed long
-#define NAME strtol
-#include "strtox.c"
diff --git a/klibc/klibc/strtoll.c b/klibc/klibc/strtoll.c
deleted file mode 100644
index a9428c7f14..0000000000
--- a/klibc/klibc/strtoll.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#define TYPE signed long long
-#define NAME strtoll
-#include "strtox.c"
diff --git a/klibc/klibc/strtotimespec.c b/klibc/klibc/strtotimespec.c
deleted file mode 100644
index b426bf8d0f..0000000000
--- a/klibc/klibc/strtotimespec.c
+++ /dev/null
@@ -1,5 +0,0 @@
-#define NAME strtotimespec
-#define TIMEX struct timespec
-#define FSEC tv_nsec
-#define DECIMALS 9
-#include "strtotimex.c"
diff --git a/klibc/klibc/strtotimeval.c b/klibc/klibc/strtotimeval.c
deleted file mode 100644
index 280d4bcd3a..0000000000
--- a/klibc/klibc/strtotimeval.c
+++ /dev/null
@@ -1,5 +0,0 @@
-#define NAME strtotimeval
-#define TIMEX struct timeval
-#define FSEC tv_usec
-#define DECIMALS 6
-#include "strtotimex.c"
diff --git a/klibc/klibc/strtotimex.c b/klibc/klibc/strtotimex.c
deleted file mode 100644
index 0f6c2f9181..0000000000
--- a/klibc/klibc/strtotimex.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * strtotimex.c
- *
- * Nonstandard function which takes a string and converts it to a
- * struct timespec/timeval. Returns a pointer to the first non-numeric
- * character in the string.
- *
- */
-
-#include <ctype.h>
-#include <inttypes.h>
-#include <stdlib.h>
-#include <sys/time.h>
-
-char * NAME (const char *str, TIMEX *ts)
-{
- int n;
- char *s, *s0;
- __typeof__(ts->FSEC) fs; /* Fractional seconds */
-
- ts->tv_sec = strntoumax(str, &s, 10, ~(size_t)0);
- fs = 0;
-
- if ( *s == '.' ) {
- s0 = s+1;
-
- fs = strntoumax(s0, &s, 10, DECIMALS);
- n = s-s0;
-
- while ( isdigit(*s) )
- s++;
-
- for ( ; n < DECIMALS ; n++ )
- fs *= 10;
- }
-
- ts->FSEC = fs;
- return s;
-}
diff --git a/klibc/klibc/strtoul.c b/klibc/klibc/strtoul.c
deleted file mode 100644
index 3189aaa7ce..0000000000
--- a/klibc/klibc/strtoul.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#define TYPE unsigned long
-#define NAME strtoul
-#include "strtox.c"
diff --git a/klibc/klibc/strtoull.c b/klibc/klibc/strtoull.c
deleted file mode 100644
index 83c14e9128..0000000000
--- a/klibc/klibc/strtoull.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#define TYPE unsigned long long
-#define NAME strtoull
-#include "strtox.c"
diff --git a/klibc/klibc/strtoumax.c b/klibc/klibc/strtoumax.c
deleted file mode 100644
index a3797105e8..0000000000
--- a/klibc/klibc/strtoumax.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#define TYPE uintmax_t
-#define NAME strtoumax
-#include "strtox.c"
diff --git a/klibc/klibc/strtox.c b/klibc/klibc/strtox.c
deleted file mode 100644
index 7c228b6fa4..0000000000
--- a/klibc/klibc/strtox.c
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * strtox.c
- *
- * strto...() functions, by macro definition
- */
-
-#include <stddef.h>
-#include <inttypes.h>
-
-TYPE NAME (const char *nptr, char **endptr, int base)
-{
- return (TYPE) strntoumax(nptr, endptr, base, ~(size_t)0);
-}
diff --git a/klibc/klibc/strxspn.c b/klibc/klibc/strxspn.c
deleted file mode 100644
index 618c0bcdb5..0000000000
--- a/klibc/klibc/strxspn.c
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * strpbrk
- */
-
-#include <string.h>
-#include <stddef.h>
-#include <inttypes.h>
-#include <limits.h>
-#include "strxspn.h"
-
-size_t
-__strxspn(const char *s, const char *map, int parity)
-{
- char matchmap[UCHAR_MAX+1];
- size_t n = 0;
-
- /* Create bitmap */
- memset(matchmap, 0, sizeof matchmap);
- while ( *map )
- matchmap[(unsigned char) *map++] = 1;
-
- /* Make sure the null character never matches */
- matchmap[0] = parity;
-
- /* Calculate span length */
- while ( matchmap[(unsigned char) *s++] ^ parity )
- n++;
-
- return n;
-}
diff --git a/klibc/klibc/strxspn.h b/klibc/klibc/strxspn.h
deleted file mode 100644
index 5e1a21922f..0000000000
--- a/klibc/klibc/strxspn.h
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * strxspn.h
- */
-
-#ifndef STRXSPN_H
-#define STRXSPN_H
-
-#include <stddef.h>
-
-extern size_t
-__strxspn(const char *s, const char *map, int parity);
-
-#endif
diff --git a/klibc/klibc/syscalls.pl b/klibc/klibc/syscalls.pl
deleted file mode 100644
index 0575fa6648..0000000000
--- a/klibc/klibc/syscalls.pl
+++ /dev/null
@@ -1,120 +0,0 @@
-#!/usr/bin/perl
-#
-# Script to parse the SYSCALLS file and generate appropriate
-# stubs.
-
-$v = $ENV{'KBUILD_VERBOSE'};
-$quiet = defined($v) ? !$v : 0;
-
-@args = ();
-for $arg ( @ARGV ) {
- if ( $arg =~ /^-/ ) {
- if ( $arg eq '-q' ) {
- $quiet = 1;
- } else {
- die "$0: Unknown option: $arg\n";
- }
- } else {
- push(@args, $arg);
- }
-}
-($file, $sysstub, $arch, $bits, $unistd, $outputdir, $havesyscall) = @args;
-
-require "$sysstub";
-
-if (!open(UNISTD, '<', $unistd)) {
- die "$0: $unistd: $!\n";
-}
-
-while ( defined($line = <UNISTD>) ) {
- chomp $line;
-
- if ( $line =~ /^\#\s*define\s+__NR_([A-Za-z0-9_]+)\s+(.*\S)\s*$/ ) {
- $syscalls{$1} = $2;
- print STDERR "SYSCALL FOUND: $1\n" unless ( $quiet );
- }
-}
-close(UNISTD);
-
-if (!open(HAVESYS, '>', $havesyscall)) {
- die "$0: $havesyscall: $!\n";
-}
-
-print HAVESYS "#ifndef _KLIBC_HAVESYSCALL_H\n";
-print HAVESYS "#define _KLIBC_HAVESYSCALL_H 1\n\n";
-
-if (!open(FILE, '<', $file)) {
- die "$0: $file: $!\n";
-}
-
-print "syscall-objs := ";
-
-while ( defined($line = <FILE>) ) {
- chomp $line;
- $line =~ s/\s*(|[\#;].*)$//; # Strip comments and trailing blanks
- next unless $line;
-
- if ( $line =~ /^\s*(\<[^\>]+\>\s+|)([A-Za-z0-9_\*\s]+)\s+([A-Za-z0-9_,]+)(|\@[A-Za-z0-9_]+)(|\:\:[A-Za-z0-9_]+)\s*\(([^\:\)]*)\)\s*$/ ) {
- $archs = $1;
- $type = $2;
- $snames = $3;
- $stype = $4;
- $fname = $5;
- $argv = $6;
-
- $doit = 1;
- $maybe = 0;
- if ( $archs ne '' ) {
- die "$file:$.: Invalid architecture spec: <$archs>\n"
- unless ( $archs =~ /^\<(|\?)(|\!)([^\>\!\?]*)\>/ );
- $maybe = $1 ne '';
- $not = $2 ne '';
- $list = $3;
-
- $doit = $not || ($list eq '');
-
- @list = split(/,/, $list);
- foreach $a ( @list ) {
- if ( $a eq $arch || $a eq $bits ) {
- $doit = !$not;
- last;
- }
- }
- }
- next if ( ! $doit );
-
- undef $sname;
- foreach $sn ( split(/,/, $snames) ) {
- if ( defined $syscalls{$sn} ) {
- $sname = $sn;
- last;
- }
- }
- if ( !defined($sname) ) {
- next if ( $maybe );
- die "$file:$.: Undefined system call: $snames\n";
- }
-
- $type =~ s/\s*$//;
- $stype =~ s/^\@//;
-
- if ( $fname eq '' ) {
- $fname = $sname;
- } else {
- $fname =~ s/^\:\://;
- }
-
- @args = split(/\s*\,\s*/, $argv);
-
- print HAVESYS "#define _KLIBC_HAVE_SYSCALL_${fname} ${sname}\n";
- print " \\\n\t${fname}.o";
- make_sysstub($outputdir, $fname, $type, $sname, $stype, @args);
- } else {
- die "$file:$.: Could not parse input: \"$line\"\n";
- }
-}
-
-print "\n";
-
-print HAVESYS "\n#endif\n";
-close(HAVESYS);
diff --git a/klibc/klibc/syscommon.h b/klibc/klibc/syscommon.h
deleted file mode 100644
index 429025279e..0000000000
--- a/klibc/klibc/syscommon.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * syscommon.h
- *
- * Common header file for system call stubs
- */
-
-#define __IN_SYS_COMMON
-#include <errno.h>
-#include <signal.h>
-#include <sys/types.h>
-#include <sys/syscall.h>
-
-#include <poll.h>
-#include <sched.h>
-#include <sys/dirent.h>
-#include <sys/klog.h>
-#include <sys/mman.h>
-#include <sys/resource.h>
-#include <sys/select.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <sys/times.h>
-#include <sys/uio.h>
-#include <sys/utime.h>
-#include <sys/utsname.h>
-#include <sys/vfs.h>
-#include <sys/wait.h>
-#include <unistd.h>
-
-#ifdef __i386__
-# include <sys/vm86.h>
-#endif
diff --git a/klibc/klibc/syslog.c b/klibc/klibc/syslog.c
deleted file mode 100644
index 0cd296ab85..0000000000
--- a/klibc/klibc/syslog.c
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * syslog.c
- *
- * Issue syslog messages via the kernel printk queue.
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <stdarg.h>
-#include <syslog.h>
-#include <unistd.h>
-#include <fcntl.h>
-
-/* Maximum size for a kernel message */
-#define BUFLEN 1024
-
-/* Logging node */
-#define LOGDEV "/dev/kmsg"
-
-/* Max length of ID string */
-#define MAXID 31 /* MAXID+5 must be < BUFLEN */
-
-int __syslog_fd = -1;
-static char id[MAXID+1];
-static int syslog_flags = 0;
-
-void openlog(const char *ident, int option, int facility)
-{
- int fd;
-
- (void)option; (void)facility; /* Unused */
-
- if ( __syslog_fd == -1 ) {
- __syslog_fd = fd = open(LOGDEV, O_WRONLY);
- if ( fd == -1 )
- return;
- fcntl(fd, F_SETFD, (long)FD_CLOEXEC);
- }
-
- syslog_flags = option;
-
- strncpy(id, ident?ident:"", MAXID);
-}
-
-void vsyslog(int prio, const char *format, va_list ap)
-{
- char buf[BUFLEN];
- int len;
- int fd;
-
- if ( __syslog_fd == -1 )
- openlog(NULL, 0, 0);
-
- buf[0] = '<';
- buf[1] = LOG_PRI(prio)+'0';
- buf[2] = '>';
- len = 3;
-
- if ( syslog_flags & LOG_PID )
- len += sprintf(buf+3, "%s[%u]: ", id, getpid());
- else if ( *id )
- len += sprintf(buf+3, "%s: ", id);
-
- len += vsnprintf(buf+len, BUFLEN-len, format, ap);
-
- if ( len > BUFLEN-1 ) len = BUFLEN-1;
- if (buf[len-1] != '\n')
- buf[len++] = '\n';
-
- fd = __syslog_fd;
- if ( fd == -1 )
- fd = 2; /* Failed to open log, write to stderr */
-
- write(fd, buf, len);
-
- if ( syslog_flags & LOG_PERROR )
- _fwrite(buf+3, len-3, stderr);
-}
-
-void syslog(int prio, const char *format, ...)
-{
- va_list ap;
-
- va_start(ap, format);
- vsyslog(prio, format, ap);
- va_end(ap);
-}
diff --git a/klibc/klibc/system.c b/klibc/klibc/system.c
deleted file mode 100644
index 643bf5e1cc..0000000000
--- a/klibc/klibc/system.c
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * system.c
- *
- * The system() function. If this turns out to actually be *used*,
- * we may want to try to detect the very simple cases (no shell magic)
- * and handle them internally, instead of requiring that /bin/sh be
- * present.
- */
-
-#include <errno.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <signal.h>
-#include <sys/wait.h>
-
-int system(const char *string)
-{
- pid_t pid;
- struct sigaction ignore, old_int, old_quit;
- sigset_t masked, oldmask;
- static const char *argv[] = { "/bin/sh", "-c", NULL, NULL };
- int status;
-
- /* Block SIGCHLD and ignore SIGINT and SIGQUIT */
- /* Do this before the fork() to avoid races */
-
- ignore.sa_handler = SIG_IGN;
- sigemptyset(&ignore.sa_mask);
- ignore.sa_flags = 0;
- sigaction(SIGINT, &ignore, &old_int);
- sigaction(SIGQUIT, &ignore, &old_quit);
-
- sigemptyset(&masked);
- sigaddset(&masked, SIGCHLD);
- sigprocmask(SIG_BLOCK, &masked, &oldmask);
-
- pid = fork();
-
- if ( pid < 0 )
- return -1;
- else if ( pid == 0 ) {
- sigaction(SIGINT, &old_int, NULL);
- sigaction(SIGQUIT, &old_quit, NULL);
- sigprocmask(SIG_SETMASK, &oldmask, NULL);
-
- argv[2] = string;
-
- execve(argv[0], (char * const *)argv, (char * const *)environ);
- _exit(127);
- }
-
- /* else... */
-
- waitpid(pid, &status, 0);
-
- sigaction(SIGINT, &old_int, NULL);
- sigaction(SIGQUIT, &old_quit, NULL);
- sigprocmask(SIG_SETMASK, &oldmask, NULL);
-
- return status;
-}
diff --git a/klibc/klibc/sysv_signal.c b/klibc/klibc/sysv_signal.c
deleted file mode 100644
index 3e55a02bb5..0000000000
--- a/klibc/klibc/sysv_signal.c
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
- * sysv_signal.c
- */
-
-#include <signal.h>
-
-__sighandler_t sysv_signal(int signum, __sighandler_t handler)
-{
- /* Linux/SysV signal() semantics */
- return __signal(signum, handler, SA_RESETHAND);
-}
diff --git a/klibc/klibc/time.c b/klibc/klibc/time.c
deleted file mode 100644
index 92f82ccee0..0000000000
--- a/klibc/klibc/time.c
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * time.c
- */
-
-#include <time.h>
-#include <sys/time.h>
-#include <sys/syscall.h>
-
-#ifndef __NR_time
-
-time_t time(time_t *t)
-{
- struct timeval tv;
-
- gettimeofday(&tv, NULL);
-
- if ( t )
- *t = (time_t)tv.tv_sec;
-
- return (time_t)tv.tv_sec;
-}
-
-#endif
diff --git a/klibc/klibc/umount.c b/klibc/klibc/umount.c
deleted file mode 100644
index 9a8e62a779..0000000000
--- a/klibc/klibc/umount.c
+++ /dev/null
@@ -1,12 +0,0 @@
-/*
- * umount.c
- *
- * Single-argument form of umount
- */
-
-#include <sys/mount.h>
-
-int umount(const char *dir)
-{
- return umount2(dir, 0);
-}
diff --git a/klibc/klibc/unsetenv.c b/klibc/klibc/unsetenv.c
deleted file mode 100644
index 5f39f3d8f9..0000000000
--- a/klibc/klibc/unsetenv.c
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * unsetenv.c
- */
-
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-int unsetenv(const char *name)
-{
- size_t len;
- char **p, *q;
- const char *z;
-
- if ( !name || !name[0] ) {
- errno = EINVAL;
- return -1;
- }
-
- len = 0;
- for ( z = name ; *z ; z++ ) {
- len++;
- if ( *z == '=' ) {
- errno = EINVAL;
- return -1;
- }
- }
-
- for ( p = environ ; (q = *p) ; p++ ) {
- if ( !strncmp(name,q,len) && q[len] == '=' )
- break;
- }
-
- for ( ; (q = *p) ; p++ ) {
- p[0] = p[1];
- }
-
- return 0;
-}
diff --git a/klibc/klibc/usleep.c b/klibc/klibc/usleep.c
deleted file mode 100644
index b63352eebf..0000000000
--- a/klibc/klibc/usleep.c
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * usleep.c
- */
-
-#include <errno.h>
-#include <time.h>
-
-void usleep(unsigned long usec)
-{
- struct timespec ts;
-
- ts.tv_sec = usec/1000000UL;
- ts.tv_nsec = (usec%1000000UL) * 1000;
- while ( nanosleep(&ts,&ts) == -1 && errno == EINTR );
-}
diff --git a/klibc/klibc/utime.c b/klibc/klibc/utime.c
deleted file mode 100644
index 2c8607756a..0000000000
--- a/klibc/klibc/utime.c
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * utime.c
- */
-
-#include <utime.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/syscall.h>
-
-#ifndef __NR_utime
-
-int utime(const char *filename, const struct utimbuf *buf)
-{
- struct timeval tvp[2];
-
- tvp[0].tv_sec = buf->actime;
- tvp[0].tv_usec = 0;
- tvp[1].tv_sec = buf->modtime;
- tvp[1].tv_usec = 0;
-
- return utimes(filename, tvp);
-}
-
-#endif
diff --git a/klibc/klibc/vasprintf.c b/klibc/klibc/vasprintf.c
deleted file mode 100644
index 657bfdc3ef..0000000000
--- a/klibc/klibc/vasprintf.c
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * vasprintf.c
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-
-int vasprintf(char **bufp, const char *format, va_list ap)
-{
- va_list ap1;
- int bytes;
- char *p;
-
- va_copy(ap1, ap);
-
- bytes = vsnprintf(NULL, 0, format, ap1) + 1;
- va_end(ap1);
-
- *bufp = p = malloc(bytes);
- if ( !p )
- return -1;
-
- return vsnprintf(p, bytes, format, ap);
-}
diff --git a/klibc/klibc/vfprintf.c b/klibc/klibc/vfprintf.c
deleted file mode 100644
index 39cf9838f6..0000000000
--- a/klibc/klibc/vfprintf.c
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * vfprintf.c
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <stdarg.h>
-#include <unistd.h>
-
-#define BUFFER_SIZE 32768
-
-int vfprintf(FILE *file, const char *format, va_list ap)
-{
- int rv;
- char buffer[BUFFER_SIZE];
-
- rv = vsnprintf(buffer, BUFFER_SIZE, format, ap);
-
- if ( rv < 0 )
- return rv;
-
- if ( rv > BUFFER_SIZE-1 )
- rv = BUFFER_SIZE-1;
-
- return _fwrite(buffer, rv, file);
-}
diff --git a/klibc/klibc/vprintf.c b/klibc/klibc/vprintf.c
deleted file mode 100644
index 7d6066586f..0000000000
--- a/klibc/klibc/vprintf.c
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
- * vprintf.c
- */
-
-#include <stdio.h>
-#include <stdarg.h>
-
-int vprintf(const char *format, va_list ap)
-{
- return vfprintf(stdout, format, ap);
-}
diff --git a/klibc/klibc/vsnprintf.c b/klibc/klibc/vsnprintf.c
deleted file mode 100644
index 5cb9331954..0000000000
--- a/klibc/klibc/vsnprintf.c
+++ /dev/null
@@ -1,433 +0,0 @@
-/*
- * vsnprintf.c
- *
- * vsnprintf(), from which the rest of the printf()
- * family is built
- */
-
-#include <stdarg.h>
-#include <stddef.h>
-#include <inttypes.h>
-#include <string.h>
-#include <limits.h>
-#include <stdio.h>
-
-enum flags {
- FL_ZERO = 0x01, /* Zero modifier */
- FL_MINUS = 0x02, /* Minus modifier */
- FL_PLUS = 0x04, /* Plus modifier */
- FL_TICK = 0x08, /* ' modifier */
- FL_SPACE = 0x10, /* Space modifier */
- FL_HASH = 0x20, /* # modifier */
- FL_SIGNED = 0x40, /* Number is signed */
- FL_UPPER = 0x80 /* Upper case digits */
-};
-
-/* These may have to be adjusted on certain implementations */
-enum ranks {
- rank_char = -2,
- rank_short = -1,
- rank_int = 0,
- rank_long = 1,
- rank_longlong = 2
-};
-
-#define MIN_RANK rank_char
-#define MAX_RANK rank_longlong
-
-#define INTMAX_RANK rank_longlong
-#define SIZE_T_RANK rank_long
-#define PTRDIFF_T_RANK rank_long
-
-#define EMIT(x) ({ if (o<n){*q++ = (x);} o++; })
-
-static size_t
-format_int(char *q, size_t n, uintmax_t val, enum flags flags,
- int base, int width, int prec)
-{
- char *qq;
- size_t o = 0, oo;
- static const char lcdigits[] = "0123456789abcdef";
- static const char ucdigits[] = "0123456789ABCDEF";
- const char *digits;
- uintmax_t tmpval;
- int minus = 0;
- int ndigits = 0, nchars;
- int tickskip, b4tick;
-
- /* Select type of digits */
- digits = (flags & FL_UPPER) ? ucdigits : lcdigits;
-
- /* If signed, separate out the minus */
- if ( flags & FL_SIGNED && (intmax_t)val < 0 ) {
- minus = 1;
- val = (uintmax_t)(-(intmax_t)val);
- }
-
- /* Count the number of digits needed. This returns zero for 0. */
- tmpval = val;
- while ( tmpval ) {
- tmpval /= base;
- ndigits++;
- }
-
- /* Adjust ndigits for size of output */
-
- if ( flags & FL_HASH && base == 8 ) {
- if ( prec < ndigits+1 )
- prec = ndigits+1;
- }
-
- if ( ndigits < prec ) {
- ndigits = prec; /* Mandatory number padding */
- } else if ( val == 0 ) {
- ndigits = 1; /* Zero still requires space */
- }
-
- /* For ', figure out what the skip should be */
- if ( flags & FL_TICK ) {
- tickskip = (base == 16) ? 4 : 3;
- } else {
- tickskip = ndigits; /* No tick marks */
- }
-
- /* Tick marks aren't digits, but generated by the number converter */
- ndigits += (ndigits-1)/tickskip;
-
- /* Now compute the number of nondigits */
- nchars = ndigits;
-
- if ( minus || (flags & (FL_PLUS|FL_SPACE)) )
- nchars++; /* Need space for sign */
- if ( (flags & FL_HASH) && base == 16 ) {
- nchars += 2; /* Add 0x for hex */
- }
-
- /* Emit early space padding */
- if ( !(flags & (FL_MINUS|FL_ZERO)) && width > nchars ) {
- while ( width > nchars ) {
- EMIT(' ');
- width--;
- }
- }
-
- /* Emit nondigits */
- if ( minus )
- EMIT('-');
- else if ( flags & FL_PLUS )
- EMIT('+');
- else if ( flags & FL_SPACE )
- EMIT(' ');
-
- if ( (flags & FL_HASH) && base == 16 ) {
- EMIT('0');
- EMIT((flags & FL_UPPER) ? 'X' : 'x');
- }
-
- /* Emit zero padding */
- if ( (flags & (FL_MINUS|FL_ZERO)) == FL_ZERO && width > ndigits ) {
- while ( width > nchars ) {
- EMIT('0');
- width--;
- }
- }
-
- /* Generate the number. This is done from right to left. */
- q += ndigits; /* Advance the pointer to end of number */
- o += ndigits;
- qq = q; oo = o; /* Temporary values */
-
- b4tick = tickskip;
- while ( ndigits > 0 ) {
- if ( !b4tick-- ) {
- qq--; oo--; ndigits--;
- if ( oo < n ) *qq = '_';
- b4tick = tickskip-1;
- }
- qq--; oo--; ndigits--;
- if ( oo < n ) *qq = digits[val%base];
- val /= base;
- }
-
- /* Emit late space padding */
- while ( (flags & FL_MINUS) && width > nchars ) {
- EMIT(' ');
- width--;
- }
-
- return o;
-}
-
-
-int vsnprintf(char *buffer, size_t n, const char *format, va_list ap)
-{
- const char *p = format;
- char ch;
- char *q = buffer;
- size_t o = 0; /* Number of characters output */
- uintmax_t val = 0;
- int rank = rank_int; /* Default rank */
- int width = 0;
- int prec = -1;
- int base;
- size_t sz;
- enum flags flags = 0;
- enum {
- st_normal, /* Ground state */
- st_flags, /* Special flags */
- st_width, /* Field width */
- st_prec, /* Field precision */
- st_modifiers /* Length or conversion modifiers */
- } state = st_normal;
- const char *sarg; /* %s string argument */
- char carg; /* %c char argument */
- int slen; /* String length */
-
- while ( (ch = *p++) ) {
- switch ( state ) {
- case st_normal:
- if ( ch == '%' ) {
- state = st_flags;
- flags = 0; rank = rank_int; width = 0; prec = -1;
- } else {
- EMIT(ch);
- }
- break;
-
- case st_flags:
- switch ( ch ) {
- case '-':
- flags |= FL_MINUS;
- break;
- case '+':
- flags |= FL_PLUS;
- break;
- case '\'':
- flags |= FL_TICK;
- break;
- case ' ':
- flags |= FL_SPACE;
- break;
- case '#':
- flags |= FL_HASH;
- break;
- case '0':
- flags |= FL_ZERO;
- break;
- default:
- state = st_width;
- p--; /* Process this character again */
- break;
- }
- break;
-
- case st_width:
- if ( ch >= '0' && ch <= '9' ) {
- width = width*10+(ch-'0');
- } else if ( ch == '*' ) {
- width = va_arg(ap, int);
- if ( width < 0 ) {
- width = -width;
- flags |= FL_MINUS;
- }
- } else if ( ch == '.' ) {
- prec = 0; /* Precision given */
- state = st_prec;
- } else {
- state = st_modifiers;
- p--; /* Process this character again */
- }
- break;
-
- case st_prec:
- if ( ch >= '0' && ch <= '9' ) {
- prec = prec*10+(ch-'0');
- } else if ( ch == '*' ) {
- prec = va_arg(ap, int);
- if ( prec < 0 )
- prec = -1;
- } else {
- state = st_modifiers;
- p--; /* Process this character again */
- }
- break;
-
- case st_modifiers:
- switch ( ch ) {
- /* Length modifiers - nonterminal sequences */
- case 'h':
- rank--; /* Shorter rank */
- break;
- case 'l':
- rank++; /* Longer rank */
- break;
- case 'j':
- rank = INTMAX_RANK;
- break;
- case 'z':
- rank = SIZE_T_RANK;
- break;
- case 't':
- rank = PTRDIFF_T_RANK;
- break;
- case 'L':
- case 'q':
- rank += 2;
- break;
- default:
- /* Output modifiers - terminal sequences */
- state = st_normal; /* Next state will be normal */
- if ( rank < MIN_RANK ) /* Canonicalize rank */
- rank = MIN_RANK;
- else if ( rank > MAX_RANK )
- rank = MAX_RANK;
-
- switch ( ch ) {
- case 'P': /* Upper case pointer */
- flags |= FL_UPPER;
- /* fall through */
- case 'p': /* Pointer */
- base = 16;
- prec = (CHAR_BIT*sizeof(void *)+3)/4;
- flags |= FL_HASH;
- val = (uintmax_t)(uintptr_t)va_arg(ap, void *);
- goto is_integer;
-
- case 'd': /* Signed decimal output */
- case 'i':
- base = 10;
- flags |= FL_SIGNED;
- switch (rank) {
- case rank_char:
- /* Yes, all these casts are needed... */
- val = (uintmax_t)(intmax_t)(signed char)va_arg(ap, signed int);
- break;
- case rank_short:
- val = (uintmax_t)(intmax_t)(signed short)va_arg(ap, signed int);
- break;
- case rank_int:
- val = (uintmax_t)(intmax_t)va_arg(ap, signed int);
- break;
- case rank_long:
- val = (uintmax_t)(intmax_t)va_arg(ap, signed long);
- break;
- case rank_longlong:
- val = (uintmax_t)(intmax_t)va_arg(ap, signed long long);
- break;
- }
- goto is_integer;
- case 'o': /* Octal */
- base = 8;
- goto is_unsigned;
- case 'u': /* Unsigned decimal */
- base = 10;
- goto is_unsigned;
- case 'X': /* Upper case hexadecimal */
- flags |= FL_UPPER;
- /* fall through */
- case 'x': /* Hexadecimal */
- base = 16;
- goto is_unsigned;
-
- is_unsigned:
- switch (rank) {
- case rank_char:
- val = (uintmax_t)(unsigned char)va_arg(ap, unsigned int);
- break;
- case rank_short:
- val = (uintmax_t)(unsigned short)va_arg(ap, unsigned int);
- break;
- case rank_int:
- val = (uintmax_t)va_arg(ap, unsigned int);
- break;
- case rank_long:
- val = (uintmax_t)va_arg(ap, unsigned long);
- break;
- case rank_longlong:
- val = (uintmax_t)va_arg(ap, unsigned long long);
- break;
- }
- /* fall through */
-
- is_integer:
- sz = format_int(q, (o<n) ? n-o : 0, val, flags, base, width, prec);
- q += sz; o += sz;
- break;
-
- case 'c': /* Character */
- carg = (char)va_arg(ap, int);
- sarg = &carg;
- slen = 1;
- goto is_string;
- case 's': /* String */
- sarg = va_arg(ap, const char *);
- sarg = sarg ? sarg : "(null)";
- slen = strlen(sarg);
- goto is_string;
-
- is_string:
- {
- char sch;
- int i;
-
- if ( prec != -1 && slen > prec )
- slen = prec;
-
- if ( width > slen && !(flags & FL_MINUS) ) {
- char pad = (flags & FL_ZERO) ? '0' : ' ';
- while ( width > slen ) {
- EMIT(pad);
- width--;
- }
- }
- for ( i = slen ; i ; i-- ) {
- sch = *sarg++;
- EMIT(sch);
- }
- if ( width > slen && (flags & FL_MINUS) ) {
- while ( width > slen ) {
- EMIT(' ');
- width--;
- }
- }
- }
- break;
-
- case 'n': /* Output the number of characters written */
- {
- switch (rank) {
- case rank_char:
- *va_arg(ap, signed char *) = o;
- break;
- case rank_short:
- *va_arg(ap, signed short *) = o;
- break;
- case rank_int:
- *va_arg(ap, signed int *) = o;
- break;
- case rank_long:
- *va_arg(ap, signed long *) = o;
- break;
- case rank_longlong:
- *va_arg(ap, signed long long *) = o;
- break;
- }
- }
- break;
-
- default: /* Anything else, including % */
- EMIT(ch);
- break;
- }
- }
- }
- }
-
- /* Null-terminate the string */
- if ( o<n )
- *q = '\0'; /* No overflow */
- else if ( n>0 )
- buffer[n-1] = '\0'; /* Overflow - terminate at end of buffer */
-
- return o;
-}
diff --git a/klibc/klibc/vsprintf.c b/klibc/klibc/vsprintf.c
deleted file mode 100644
index 4a6100e70c..0000000000
--- a/klibc/klibc/vsprintf.c
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
- * vsprintf.c
- */
-
-#include <stdio.h>
-#include <unistd.h>
-
-int vsprintf(char *buffer, const char *format, va_list ap)
-{
- return vsnprintf(buffer, ~(size_t)0, format, ap);
-}
diff --git a/klibc/klibc/vsscanf.c b/klibc/klibc/vsscanf.c
deleted file mode 100644
index 12a82b2747..0000000000
--- a/klibc/klibc/vsscanf.c
+++ /dev/null
@@ -1,365 +0,0 @@
-/*
- * vsscanf.c
- *
- * vsscanf(), from which the rest of the scanf()
- * family is built
- */
-
-#include <ctype.h>
-#include <stdarg.h>
-#include <stddef.h>
-#include <inttypes.h>
-#include <string.h>
-#include <limits.h>
-#include <stdio.h>
-
-#ifndef LONG_BIT
-#define LONG_BIT (CHAR_BIT*sizeof(long))
-#endif
-
-enum flags {
- FL_SPLAT = 0x01, /* Drop the value, do not assign */
- FL_INV = 0x02, /* Character-set with inverse */
- FL_WIDTH = 0x04, /* Field width specified */
- FL_MINUS = 0x08, /* Negative number */
-};
-
-enum ranks {
- rank_char = -2,
- rank_short = -1,
- rank_int = 0,
- rank_long = 1,
- rank_longlong = 2,
- rank_ptr = INT_MAX /* Special value used for pointers */
-};
-
-#define MIN_RANK rank_char
-#define MAX_RANK rank_longlong
-
-#define INTMAX_RANK rank_longlong
-#define SIZE_T_RANK rank_long
-#define PTRDIFF_T_RANK rank_long
-
-enum bail {
- bail_none = 0, /* No error condition */
- bail_eof, /* Hit EOF */
- bail_err /* Conversion mismatch */
-};
-
-static inline const char *
-skipspace(const char *p)
-{
- while ( isspace((unsigned char)*p) ) p++;
- return p;
-}
-
-#undef set_bit
-static inline void
-set_bit(unsigned long *bitmap, unsigned int bit)
-{
- bitmap[bit/LONG_BIT] |= 1UL << (bit%LONG_BIT);
-}
-
-#undef test_bit
-static inline int
-test_bit(unsigned long *bitmap, unsigned int bit)
-{
- return (int)(bitmap[bit/LONG_BIT] >> (bit%LONG_BIT)) & 1;
-}
-
-int vsscanf(const char *buffer, const char *format, va_list ap)
-{
- const char *p = format;
- char ch;
- const char *q = buffer;
- const char *qq;
- uintmax_t val = 0;
- int rank = rank_int; /* Default rank */
- unsigned int width = UINT_MAX;
- int base;
- enum flags flags = 0;
- enum {
- st_normal, /* Ground state */
- st_flags, /* Special flags */
- st_width, /* Field width */
- st_modifiers, /* Length or conversion modifiers */
- st_match_init, /* Initial state of %[ sequence */
- st_match, /* Main state of %[ sequence */
- st_match_range, /* After - in a %[ sequence */
- } state = st_normal;
- char *sarg = NULL; /* %s %c or %[ string argument */
- enum bail bail = bail_none;
- int sign;
- int converted = 0; /* Successful conversions */
- unsigned long matchmap[((1 << CHAR_BIT)+(LONG_BIT-1))/LONG_BIT];
- int matchinv = 0; /* Is match map inverted? */
- unsigned char range_start = 0;
-
- while ( (ch = *p++) && !bail ) {
- switch ( state ) {
- case st_normal:
- if ( ch == '%' ) {
- state = st_flags;
- flags = 0; rank = rank_int; width = UINT_MAX;
- } else if ( isspace((unsigned char)ch) ) {
- q = skipspace(q);
- } else {
- if ( *q == ch )
- q++;
- else
- bail = bail_err; /* Match failure */
- }
- break;
-
- case st_flags:
- switch ( ch ) {
- case '*':
- flags |= FL_SPLAT;
- break;
- case '0' ... '9':
- width = (ch-'0');
- state = st_width;
- flags |= FL_WIDTH;
- break;
- default:
- state = st_modifiers;
- p--; /* Process this character again */
- break;
- }
- break;
-
- case st_width:
- if ( ch >= '0' && ch <= '9' ) {
- width = width*10+(ch-'0');
- } else {
- state = st_modifiers;
- p--; /* Process this character again */
- }
- break;
-
- case st_modifiers:
- switch ( ch ) {
- /* Length modifiers - nonterminal sequences */
- case 'h':
- rank--; /* Shorter rank */
- break;
- case 'l':
- rank++; /* Longer rank */
- break;
- case 'j':
- rank = INTMAX_RANK;
- break;
- case 'z':
- rank = SIZE_T_RANK;
- break;
- case 't':
- rank = PTRDIFF_T_RANK;
- break;
- case 'L':
- case 'q':
- rank = rank_longlong; /* long double/long long */
- break;
-
- default:
- /* Output modifiers - terminal sequences */
- state = st_normal; /* Next state will be normal */
- if ( rank < MIN_RANK ) /* Canonicalize rank */
- rank = MIN_RANK;
- else if ( rank > MAX_RANK )
- rank = MAX_RANK;
-
- switch ( ch ) {
- case 'P': /* Upper case pointer */
- case 'p': /* Pointer */
-#if 0 /* Enable this to allow null pointers by name */
- q = skipspace(q);
- if ( !isdigit((unsigned char)*q) ) {
- static const char * const nullnames[] =
- { "null", "nul", "nil", "(null)", "(nul)", "(nil)", 0 };
- const char * const *np;
-
- /* Check to see if it's a null pointer by name */
- for ( np = nullnames ; *np ; np++ ) {
- if ( !strncasecmp(q, *np, strlen(*np)) ) {
- val = (uintmax_t)((void *)NULL);
- goto set_integer;
- }
- }
- /* Failure */
- bail = bail_err;
- break;
- }
- /* else */
-#endif
- rank = rank_ptr;
- base = 0; sign = 0;
- goto scan_int;
-
- case 'i': /* Base-independent integer */
- base = 0; sign = 1;
- goto scan_int;
-
- case 'd': /* Decimal integer */
- base = 10; sign = 1;
- goto scan_int;
-
- case 'o': /* Octal integer */
- base = 8; sign = 0;
- goto scan_int;
-
- case 'u': /* Unsigned decimal integer */
- base = 10; sign = 0;
- goto scan_int;
-
- case 'x': /* Hexadecimal integer */
- case 'X':
- base = 16; sign = 0;
- goto scan_int;
-
- case 'n': /* Number of characters consumed */
- val = (q-buffer);
- goto set_integer;
-
- scan_int:
- q = skipspace(q);
- if ( !*q ) {
- bail = bail_eof;
- break;
- }
- val = strntoumax(q, (char **)&qq, base, width);
- if ( qq == q ) {
- bail = bail_err;
- break;
- }
- q = qq;
- converted++;
- /* fall through */
-
- set_integer:
- if ( !(flags & FL_SPLAT) ) {
- switch(rank) {
- case rank_char:
- *va_arg(ap, unsigned char *) = (unsigned char)val;
- break;
- case rank_short:
- *va_arg(ap, unsigned short *) = (unsigned short)val;
- break;
- case rank_int:
- *va_arg(ap, unsigned int *) = (unsigned int)val;
- break;
- case rank_long:
- *va_arg(ap, unsigned long *) = (unsigned long)val;
- break;
- case rank_longlong:
- *va_arg(ap, unsigned long long *) = (unsigned long long)val;
- break;
- case rank_ptr:
- *va_arg(ap, void **) = (void *)(uintptr_t)val;
- break;
- }
- }
- break;
-
- case 'c': /* Character */
- width = (flags & FL_WIDTH) ? width : 1; /* Default width == 1 */
- sarg = va_arg(ap, char *);
- while ( width-- ) {
- if ( !*q ) {
- bail = bail_eof;
- break;
- }
- *sarg++ = *q++;
- }
- if ( !bail )
- converted++;
- break;
-
- case 's': /* String */
- {
- char *sp;
- sp = sarg = va_arg(ap, char *);
- while ( width-- && *q && !isspace((unsigned char)*q) ) {
- *sp++ = *q++;
- }
- if ( sarg != sp ) {
- *sp = '\0'; /* Terminate output */
- converted++;
- } else {
- bail = bail_eof;
- }
- }
- break;
-
- case '[': /* Character range */
- sarg = va_arg(ap, char *);
- state = st_match_init;
- matchinv = 0;
- memset(matchmap, 0, sizeof matchmap);
- break;
-
- case '%': /* %% sequence */
- if ( *q == '%' )
- q++;
- else
- bail = bail_err;
- break;
-
- default: /* Anything else */
- bail = bail_err; /* Unknown sequence */
- break;
- }
- }
- break;
-
- case st_match_init: /* Initial state for %[ match */
- if ( ch == '^' && !(flags & FL_INV) ) {
- matchinv = 1;
- } else {
- set_bit(matchmap, (unsigned char)ch);
- state = st_match;
- }
- break;
-
- case st_match: /* Main state for %[ match */
- if ( ch == ']' ) {
- goto match_run;
- } else if ( ch == '-' ) {
- range_start = (unsigned char)ch;
- state = st_match_range;
- } else {
- set_bit(matchmap, (unsigned char)ch);
- }
- break;
-
- case st_match_range: /* %[ match after - */
- if ( ch == ']' ) {
- set_bit(matchmap, (unsigned char)'-'); /* - was last character */
- goto match_run;
- } else {
- int i;
- for ( i = range_start ; i < (unsigned char)ch ; i++ )
- set_bit(matchmap, i);
- state = st_match;
- }
- break;
-
- match_run: /* Match expression finished */
- qq = q;
- while ( width && *q && test_bit(matchmap, (unsigned char)*q)^matchinv ) {
- *sarg++ = *q++;
- }
- if ( q != qq ) {
- *sarg = '\0';
- converted++;
- } else {
- bail = *q ? bail_err : bail_eof;
- }
- break;
- }
- }
-
- if ( bail == bail_eof && !converted )
- converted = -1; /* Return EOF (-1) */
-
- return converted;
-}
diff --git a/klibc/klibc/wait.c b/klibc/klibc/wait.c
deleted file mode 100644
index 5e0bbe29c5..0000000000
--- a/klibc/klibc/wait.c
+++ /dev/null
@@ -1,12 +0,0 @@
-/*
- * wait.c
- */
-
-#include <stdlib.h>
-#include <sys/wait.h>
-#include <sys/types.h>
-
-pid_t wait(int *status)
-{
- return wait4((pid_t)-1, status, 0, NULL);
-}
diff --git a/klibc/klibc/wait3.c b/klibc/klibc/wait3.c
deleted file mode 100644
index 48840ad155..0000000000
--- a/klibc/klibc/wait3.c
+++ /dev/null
@@ -1,12 +0,0 @@
-/*
- * wait3.c
- */
-
-#include <sys/types.h>
-#include <sys/resource.h>
-#include <sys/wait.h>
-
-pid_t wait3(int *status, int options, struct rusage *rusage)
-{
- return wait4((pid_t)-1, status, options, rusage);
-}
diff --git a/klibc/klibc/waitpid.c b/klibc/klibc/waitpid.c
deleted file mode 100644
index f7c5cbfbc0..0000000000
--- a/klibc/klibc/waitpid.c
+++ /dev/null
@@ -1,12 +0,0 @@
-/*
- * waitpid.c
- */
-
-#include <sys/types.h>
-#include <sys/resource.h>
-#include <sys/wait.h>
-
-pid_t waitpid(pid_t pid, int *status, int options)
-{
- return wait4(pid, status, options, NULL);
-}
diff --git a/klibc/klibc/zlib/FAQ b/klibc/klibc/zlib/FAQ
deleted file mode 100644
index 7115ec38d6..0000000000
--- a/klibc/klibc/zlib/FAQ
+++ /dev/null
@@ -1,315 +0,0 @@
-
- Frequently Asked Questions about zlib
-
-
-If your question is not there, please check the zlib home page
-http://www.zlib.org which may have more recent information.
-The lastest zlib FAQ is at http://www.gzip.org/zlib/zlib_faq.html
-
-
- 1. Is zlib Y2K-compliant?
-
- Yes. zlib doesn't handle dates.
-
- 2. Where can I get a Windows DLL version?
-
- The zlib sources can be compiled without change to produce a DLL.
- See the file win32/DLL_FAQ.txt in the zlib distribution.
- Pointers to the precompiled DLL are found in the zlib web site at
- http://www.zlib.org.
-
- 3. Where can I get a Visual Basic interface to zlib?
-
- See
- * http://www.winimage.com/zLibDll/
- * http://www.dogma.net/markn/articles/zlibtool/zlibtool.htm
- * contrib/visual-basic.txt in the zlib distribution
-
- 4. compress() returns Z_BUF_ERROR
-
- Make sure that before the call of compress, the length of the compressed
- buffer is equal to the total size of the compressed buffer and not
- zero. For Visual Basic, check that this parameter is passed by reference
- ("as any"), not by value ("as long").
-
- 5. deflate() or inflate() returns Z_BUF_ERROR
-
- Before making the call, make sure that avail_in and avail_out are not
- zero. When setting the parameter flush equal to Z_FINISH, also make sure
- that avail_out is big enough to allow processing all pending input.
- Note that a Z_BUF_ERROR is not fatal--another call to deflate() or
- inflate() can be made with more input or output space. A Z_BUF_ERROR
- may in fact be unavoidable depending on how the functions are used, since
- it is not possible to tell whether or not there is more output pending
- when strm.avail_out returns with zero.
-
- 6. Where's the zlib documentation (man pages, etc.)?
-
- It's in zlib.h for the moment, and Francis S. Lin has converted it to a
- web page zlib.html. Volunteers to transform this to Unix-style man pages,
- please contact Jean-loup Gailly (jloup@gzip.org). Examples of zlib usage
- are in the files example.c and minigzip.c.
-
- 7. Why don't you use GNU autoconf or libtool or ...?
-
- Because we would like to keep zlib as a very small and simple
- package. zlib is rather portable and doesn't need much configuration.
-
- 8. I found a bug in zlib.
-
- Most of the time, such problems are due to an incorrect usage of
- zlib. Please try to reproduce the problem with a small program and send
- the corresponding source to us at zlib@gzip.org . Do not send
- multi-megabyte data files without prior agreement.
-
- 9. Why do I get "undefined reference to gzputc"?
-
- If "make test" produces something like
-
- example.o(.text+0x154): undefined reference to `gzputc'
-
- check that you don't have old files libz.* in /usr/lib, /usr/local/lib or
- /usr/X11R6/lib. Remove any old versions, then do "make install".
-
-10. I need a Delphi interface to zlib.
-
- See the contrib/delphi directory in the zlib distribution.
-
-11. Can zlib handle .zip archives?
-
- See the directory contrib/minizip in the zlib distribution.
-
-12. Can zlib handle .Z files?
-
- No, sorry. You have to spawn an uncompress or gunzip subprocess, or adapt
- the code of uncompress on your own.
-
-13. How can I make a Unix shared library?
-
- make clean
- ./configure -s
- make
-
-14. How do I install a shared zlib library on Unix?
-
- make install
-
- However, many flavors of Unix come with a shared zlib already installed.
- Before going to the trouble of compiling a shared version of zlib and
- trying to install it, you may want to check if it's already there! If you
- can #include <zlib.h>, it's there. The -lz option will probably link to it.
-
-15. I have a question about OttoPDF
-
- We are not the authors of OttoPDF. The real author is on the OttoPDF web
- site Joel Hainley jhainley@myndkryme.com.
-
-16. Why does gzip give an error on a file I make with compress/deflate?
-
- The compress and deflate functions produce data in the zlib format, which
- is different and incompatible with the gzip format. The gz* functions in
- zlib on the other hand use the gzip format. Both the zlib and gzip
- formats use the same compressed data format internally, but have different
- headers and trailers around the compressed data.
-
-17. Ok, so why are there two different formats?
-
- The gzip format was designed to retain the directory information about
- a single file, such as the name and last modification date. The zlib
- format on the other hand was designed for in-memory and communication
- channel applications, and has a much more compact header and trailer and
- uses a faster integrity check than gzip.
-
-18. Well that's nice, but how do I make a gzip file in memory?
-
- You can request that deflate write the gzip format instead of the zlib
- format using deflateInit2(). You can also request that inflate decode
- the gzip format using inflateInit2(). Read zlib.h for more details.
-
- Note that you cannot specify special gzip header contents (e.g. a file
- name or modification date), nor will inflate tell you what was in the
- gzip header. If you need to customize the header or see what's in it,
- you can use the raw deflate and inflate operations and the crc32()
- function and roll your own gzip encoding and decoding. Read the gzip
- RFC 1952 for details of the header and trailer format.
-
-19. Is zlib thread-safe?
-
- Yes. However any library routines that zlib uses and any application-
- provided memory allocation routines must also be thread-safe. zlib's gz*
- functions use stdio library routines, and most of zlib's functions use the
- library memory allocation routines by default. zlib's Init functions allow
- for the application to provide custom memory allocation routines.
-
- Of course, you should only operate on any given zlib or gzip stream from a
- single thread at a time.
-
-20. Can I use zlib in my commercial application?
-
- Yes. Please read the license in zlib.h.
-
-21. Is zlib under the GNU license?
-
- No. Please read the license in zlib.h.
-
-22. The license says that altered source versions must be "plainly marked". So
- what exactly do I need to do to meet that requirement?
-
- You need to change the ZLIB_VERSION and ZLIB_VERNUM #defines in zlib.h. In
- particular, the final version number needs to be changed to "f", and an
- identification string should be appended to ZLIB_VERSION. Version numbers
- x.x.x.f are reserved for modifications to zlib by others than the zlib
- maintainers. For example, if the version of the base zlib you are altering
- is "1.2.3.4", then in zlib.h you should change ZLIB_VERNUM to 0x123f, and
- ZLIB_VERSION to something like "1.2.3.f-zachary-mods-v3". You can also
- update the version strings in deflate.c and inftrees.c.
-
- For altered source distributions, you should also note the origin and
- nature of the changes in zlib.h, as well as in ChangeLog and README, along
- with the dates of the alterations. The origin should include at least your
- name (or your company's name), and an email address to contact for help or
- issues with the library.
-
- Note that distributing a compiled zlib library along with zlib.h and
- zconf.h is also a source distribution, and so you should change
- ZLIB_VERSION and ZLIB_VERNUM and note the origin and nature of the changes
- in zlib.h as you would for a full source distribution.
-
-23. Will zlib work on a big-endian or little-endian architecture, and can I
- exchange compressed data between them?
-
- Yes and yes.
-
-24. Will zlib work on a 64-bit machine?
-
- It should. It has been tested on 64-bit machines, and has no dependence
- on any data types being limited to 32-bits in length. If you have any
- difficulties, please provide a complete problem report to zlib@gzip.org
-
-25. Will zlib decompress data from the PKWare Data Compression Library?
-
- No. The PKWare DCL uses a completely different compressed data format
- than does PKZIP and zlib. However, you can look in zlib's contrib/blast
- directory for a possible solution to your problem.
-
-26. Can I access data randomly in a compressed stream?
-
- No, not without some preparation. If when compressing you periodically
- use Z_FULL_FLUSH, carefully write all the pending data at those points,
- and keep an index of those locations, then you can start decompression
- at those points. You have to be careful to not use Z_FULL_FLUSH too
- often, since it can significantly degrade compression.
-
-27. Does zlib work on MVS, OS/390, CICS, etc.?
-
- We don't know for sure. We have heard occasional reports of success on
- these systems. If you do use it on one of these, please provide us with
- a report, instructions, and patches that we can reference when we get
- these questions. Thanks.
-
-28. Is there some simpler, easier to read version of inflate I can look at
- to understand the deflate format?
-
- First off, you should read RFC 1951. Second, yes. Look in zlib's
- contrib/puff directory.
-
-29. Does zlib infringe on any patents?
-
- As far as we know, no. In fact, that was originally the whole point behind
- zlib. Look here for some more information:
-
- http://www.gzip.org/#faq11
-
-30. Can zlib work with greater than 4 GB of data?
-
- Yes. inflate() and deflate() will process any amount of data correctly.
- Each call of inflate() or deflate() is limited to input and output chunks
- of the maximum value that can be stored in the compiler's "unsigned int"
- type, but there is no limit to the number of chunks. Note however that the
- strm.total_in and strm_total_out counters may be limited to 4 GB. These
- counters are provided as a convenience and are not used internally by
- inflate() or deflate(). The application can easily set up its own counters
- updated after each call of inflate() or deflate() to count beyond 4 GB.
- compress() and uncompress() may be limited to 4 GB, since they operate in a
- single call. gzseek() and gztell() may be limited to 4 GB depending on how
- zlib is compiled. See the zlibCompileFlags() function in zlib.h.
-
- The word "may" appears several times above since there is a 4 GB limit
- only if the compiler's "long" type is 32 bits. If the compiler's "long"
- type is 64 bits, then the limit is 16 exabytes.
-
-31. Does zlib have any security vulnerabilities?
-
- The only one that we are aware of is potentially in gzprintf(). If zlib
- is compiled to use sprintf() or vsprintf(), then there is no protection
- against a buffer overflow of a 4K string space, other than the caller of
- gzprintf() assuring that the output will not exceed 4K. On the other
- hand, if zlib is compiled to use snprintf() or vsnprintf(), which should
- normally be the case, then there is no vulnerability. The ./configure
- script will display warnings if an insecure variation of sprintf() will
- be used by gzprintf(). Also the zlibCompileFlags() function will return
- information on what variant of sprintf() is used by gzprintf().
-
- If you don't have snprintf() or vsnprintf() and would like one, you can
- find a portable implementation here:
-
- http://www.ijs.si/software/snprintf/
-
- Note that you should be using the most recent version of zlib. Versions
- 1.1.3 and before were subject to a double-free vulnerability.
-
-32. Is there a Java version of zlib?
-
- Probably what you want is to use zlib in Java. zlib is already included
- as part of the Java SDK in the java.util.zip package. If you really want
- a version of zlib written in the Java language, look on the zlib home
- page for links: http://www.zlib.org/
-
-33. I get this or that compiler or source-code scanner warning when I crank it
- up to maximally-pendantic. Can't you guys write proper code?
-
- Many years ago, we gave up attempting to avoid warnings on every compiler
- in the universe. It just got to be a waste of time, and some compilers
- were downright silly. So now, we simply make sure that the code always
- works.
-
-34. Will zlib read the (insert any ancient or arcane format here) compressed
- data format?
-
- Probably not. Look in the comp.compression FAQ for pointers to various
- formats and associated software.
-
-35. How can I encrypt/decrypt zip files with zlib?
-
- zlib doesn't support encryption. The original PKZIP encryption is very weak
- and can be broken with freely available programs. To get strong encryption,
- use gpg ( http://www.gnupg.org/ ) which already includes zlib compression.
- For PKZIP compatible "encryption", look at http://www.info-zip.org/
-
-36. What's the difference between the "gzip" and "deflate" HTTP 1.1 encodings?
-
- "gzip" is the gzip format, and "deflate" is the zlib format. They should
- probably have called the second one "zlib" instead to avoid confusion
- with the raw deflate compressed data format. While the HTTP 1.1 RFC 2616
- correctly points to the zlib specification in RFC 1950 for the "deflate"
- transfer encoding, there have been reports of servers and browsers that
- incorrectly produce or expect raw deflate data per the deflate
- specficiation in RFC 1951, most notably Microsoft. So even though the
- "deflate" transfer encoding using the zlib format would be the more
- efficient approach (and in fact exactly what the zlib format was designed
- for), using the "gzip" transfer encoding is probably more reliable due to
- an unfortunate choice of name on the part of the HTTP 1.1 authors.
-
- Bottom line: use the gzip format for HTTP 1.1 encoding.
-
-37. Does zlib support the new "Deflate64" format introduced by PKWare?
-
- No. PKWare has apparently decided to keep that format proprietary, since
- they have not documented it as they have previous compression formats.
- In any case, the compression improvements are so modest compared to other
- more modern approaches, that it's not worth the effort to implement.
-
-38. Can you please sign these lengthy legal documents and fax them back to us
- so that we can use your software in our product?
-
- No. Go away. Shoo.
diff --git a/klibc/klibc/zlib/INDEX b/klibc/klibc/zlib/INDEX
deleted file mode 100644
index a9de7844d1..0000000000
--- a/klibc/klibc/zlib/INDEX
+++ /dev/null
@@ -1,48 +0,0 @@
-ChangeLog history of changes
-FAQ Frequently Asked Questions about zlib
-INDEX this file
-Makefile makefile for Unix (generated by configure)
-Makefile.in makefile for Unix (template for configure)
-README guess what
-algorithm.txt description of the (de)compression algorithm
-configure configure script for Unix
-zconf.in.h template for zconf.h (used by configure)
-
-msdos/ makefiles for MSDOS
-old/ makefiles for various architectures and zlib documentation
- files that have not yet been updated for zlib 1.2.x
-qnx/ makefiles for QNX
-win32/ makefiles for Windows
-
- zlib public header files (must be kept):
-zconf.h
-zlib.h
-
- private source files used to build the zlib library:
-adler32.c
-compress.c
-crc32.c
-crc32.h
-deflate.c
-deflate.h
-gzio.c
-infback.c
-inffast.c
-inffast.h
-inffixed.h
-inflate.c
-inflate.h
-inftrees.c
-inftrees.h
-trees.c
-trees.h
-uncompr.c
-zutil.c
-zutil.h
-
- source files for sample programs:
-example.c
-minigzip.c
-
- unsupported contribution by third parties
-See contrib/README.contrib
diff --git a/klibc/klibc/zlib/README b/klibc/klibc/zlib/README
deleted file mode 100644
index 0f1205481c..0000000000
--- a/klibc/klibc/zlib/README
+++ /dev/null
@@ -1,126 +0,0 @@
-ZLIB DATA COMPRESSION LIBRARY
-
-zlib 1.2.1 is a general purpose data compression library. All the code is
-thread safe. The data format used by the zlib library is described by RFCs
-(Request for Comments) 1950 to 1952 in the files
-http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format)
-and rfc1952.txt (gzip format). These documents are also available in other
-formats from ftp://ftp.uu.net/graphics/png/documents/zlib/zdoc-index.html
-
-All functions of the compression library are documented in the file zlib.h
-(volunteer to write man pages welcome, contact zlib@gzip.org). A usage example
-of the library is given in the file example.c which also tests that the library
-is working correctly. Another example is given in the file minigzip.c. The
-compression library itself is composed of all source files except example.c and
-minigzip.c.
-
-To compile all files and run the test program, follow the instructions given at
-the top of Makefile. In short "make test; make install" should work for most
-machines. For Unix: "./configure; make test; make install" For MSDOS, use one
-of the special makefiles such as Makefile.msc. For VMS, use Make_vms.com or
-descrip.mms.
-
-Questions about zlib should be sent to <zlib@gzip.org>, or to Gilles Vollant
-<info@winimage.com> for the Windows DLL version. The zlib home page is
-http://www.zlib.org or http://www.gzip.org/zlib/ Before reporting a problem,
-please check this site to verify that you have the latest version of zlib;
-otherwise get the latest version and check whether the problem still exists or
-not.
-
-PLEASE read the zlib FAQ http://www.gzip.org/zlib/zlib_faq.html before asking
-for help.
-
-Mark Nelson <markn@ieee.org> wrote an article about zlib for the Jan. 1997
-issue of Dr. Dobb's Journal; a copy of the article is available in
-http://dogma.net/markn/articles/zlibtool/zlibtool.htm
-
-The changes made in version 1.2.1 are documented in the file ChangeLog.
-
-Unsupported third party contributions are provided in directory "contrib".
-
-A Java implementation of zlib is available in the Java Development Kit
-http://java.sun.com/j2se/1.4.2/docs/api/java/util/zip/package-summary.html
-See the zlib home page http://www.zlib.org for details.
-
-A Perl interface to zlib written by Paul Marquess <pmqs@cpan.org> is in the
-CPAN (Comprehensive Perl Archive Network) sites
-http://www.cpan.org/modules/by-module/Compress/
-
-A Python interface to zlib written by A.M. Kuchling <amk@magnet.com> is
-available in Python 1.5 and later versions, see
-http://www.python.org/doc/lib/module-zlib.html
-
-A zlib binding for TCL written by Andreas Kupries <a.kupries@westend.com> is
-availlable at http://www.oche.de/~akupries/soft/trf/trf_zip.html
-
-An experimental package to read and write files in .zip format, written on top
-of zlib by Gilles Vollant <info@winimage.com>, is available in the
-contrib/minizip directory of zlib.
-
-
-Notes for some targets:
-
-- For Windows DLL versions, please see win32/DLL_FAQ.txt
-
-- For 64-bit Irix, deflate.c must be compiled without any optimization. With
- -O, one libpng test fails. The test works in 32 bit mode (with the -n32
- compiler flag). The compiler bug has been reported to SGI.
-
-- zlib doesn't work with gcc 2.6.3 on a DEC 3000/300LX under OSF/1 2.1 it works
- when compiled with cc.
-
-- On Digital Unix 4.0D (formely OSF/1) on AlphaServer, the cc option -std1 is
- necessary to get gzprintf working correctly. This is done by configure.
-
-- zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works with
- other compilers. Use "make test" to check your compiler.
-
-- gzdopen is not supported on RISCOS, BEOS and by some Mac compilers.
-
-- For PalmOs, see http://palmzlib.sourceforge.net/
-
-- When building a shared, i.e. dynamic library on Mac OS X, the library must be
- installed before testing (do "make install" before "make test"), since the
- library location is specified in the library.
-
-
-Acknowledgments:
-
- The deflate format used by zlib was defined by Phil Katz. The deflate
- and zlib specifications were written by L. Peter Deutsch. Thanks to all the
- people who reported problems and suggested various improvements in zlib;
- they are too numerous to cite here.
-
-Copyright notice:
-
- (C) 1995-2003 Jean-loup Gailly and Mark Adler
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-
- Jean-loup Gailly Mark Adler
- jloup@gzip.org madler@alumni.caltech.edu
-
-If you use the zlib library in a product, we would appreciate *not*
-receiving lengthy legal documents to sign. The sources are provided
-for free but without warranty of any kind. The library has been
-entirely written by Jean-loup Gailly and Mark Adler; it does not
-include third-party code.
-
-If you redistribute modified sources, we would appreciate that you include
-in the file ChangeLog history information documenting your changes. Please
-read the FAQ for more information on the distribution of modified source
-versions.
diff --git a/klibc/klibc/zlib/adler32.c b/klibc/klibc/zlib/adler32.c
deleted file mode 100644
index 48c08f094a..0000000000
--- a/klibc/klibc/zlib/adler32.c
+++ /dev/null
@@ -1,74 +0,0 @@
-/* adler32.c -- compute the Adler-32 checksum of a data stream
- * Copyright (C) 1995-2003 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* @(#) $Id: adler32.c,v 1.1 2005/02/27 23:15:39 hpa Exp $ */
-
-#define ZLIB_INTERNAL
-#include "zlib.h"
-
-#define BASE 65521UL /* largest prime smaller than 65536 */
-#define NMAX 5552
-/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
-
-#define DO1(buf,i) {s1 += buf[i]; s2 += s1;}
-#define DO2(buf,i) DO1(buf,i); DO1(buf,i+1);
-#define DO4(buf,i) DO2(buf,i); DO2(buf,i+2);
-#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4);
-#define DO16(buf) DO8(buf,0); DO8(buf,8);
-
-#ifdef NO_DIVIDE
-# define MOD(a) \
- do { \
- if (a >= (BASE << 16)) a -= (BASE << 16); \
- if (a >= (BASE << 15)) a -= (BASE << 15); \
- if (a >= (BASE << 14)) a -= (BASE << 14); \
- if (a >= (BASE << 13)) a -= (BASE << 13); \
- if (a >= (BASE << 12)) a -= (BASE << 12); \
- if (a >= (BASE << 11)) a -= (BASE << 11); \
- if (a >= (BASE << 10)) a -= (BASE << 10); \
- if (a >= (BASE << 9)) a -= (BASE << 9); \
- if (a >= (BASE << 8)) a -= (BASE << 8); \
- if (a >= (BASE << 7)) a -= (BASE << 7); \
- if (a >= (BASE << 6)) a -= (BASE << 6); \
- if (a >= (BASE << 5)) a -= (BASE << 5); \
- if (a >= (BASE << 4)) a -= (BASE << 4); \
- if (a >= (BASE << 3)) a -= (BASE << 3); \
- if (a >= (BASE << 2)) a -= (BASE << 2); \
- if (a >= (BASE << 1)) a -= (BASE << 1); \
- if (a >= BASE) a -= BASE; \
- } while (0)
-#else
-# define MOD(a) a %= BASE
-#endif
-
-/* ========================================================================= */
-uLong ZEXPORT adler32(adler, buf, len)
- uLong adler;
- const Bytef *buf;
- uInt len;
-{
- unsigned long s1 = adler & 0xffff;
- unsigned long s2 = (adler >> 16) & 0xffff;
- int k;
-
- if (buf == Z_NULL) return 1L;
-
- while (len > 0) {
- k = len < NMAX ? (int)len : NMAX;
- len -= k;
- while (k >= 16) {
- DO16(buf);
- buf += 16;
- k -= 16;
- }
- if (k != 0) do {
- s1 += *buf++;
- s2 += s1;
- } while (--k);
- MOD(s1);
- MOD(s2);
- }
- return (s2 << 16) | s1;
-}
diff --git a/klibc/klibc/zlib/algorithm.txt b/klibc/klibc/zlib/algorithm.txt
deleted file mode 100644
index b022dde312..0000000000
--- a/klibc/klibc/zlib/algorithm.txt
+++ /dev/null
@@ -1,209 +0,0 @@
-1. Compression algorithm (deflate)
-
-The deflation algorithm used by gzip (also zip and zlib) is a variation of
-LZ77 (Lempel-Ziv 1977, see reference below). It finds duplicated strings in
-the input data. The second occurrence of a string is replaced by a
-pointer to the previous string, in the form of a pair (distance,
-length). Distances are limited to 32K bytes, and lengths are limited
-to 258 bytes. When a string does not occur anywhere in the previous
-32K bytes, it is emitted as a sequence of literal bytes. (In this
-description, `string' must be taken as an arbitrary sequence of bytes,
-and is not restricted to printable characters.)
-
-Literals or match lengths are compressed with one Huffman tree, and
-match distances are compressed with another tree. The trees are stored
-in a compact form at the start of each block. The blocks can have any
-size (except that the compressed data for one block must fit in
-available memory). A block is terminated when deflate() determines that
-it would be useful to start another block with fresh trees. (This is
-somewhat similar to the behavior of LZW-based _compress_.)
-
-Duplicated strings are found using a hash table. All input strings of
-length 3 are inserted in the hash table. A hash index is computed for
-the next 3 bytes. If the hash chain for this index is not empty, all
-strings in the chain are compared with the current input string, and
-the longest match is selected.
-
-The hash chains are searched starting with the most recent strings, to
-favor small distances and thus take advantage of the Huffman encoding.
-The hash chains are singly linked. There are no deletions from the
-hash chains, the algorithm simply discards matches that are too old.
-
-To avoid a worst-case situation, very long hash chains are arbitrarily
-truncated at a certain length, determined by a runtime option (level
-parameter of deflateInit). So deflate() does not always find the longest
-possible match but generally finds a match which is long enough.
-
-deflate() also defers the selection of matches with a lazy evaluation
-mechanism. After a match of length N has been found, deflate() searches for
-a longer match at the next input byte. If a longer match is found, the
-previous match is truncated to a length of one (thus producing a single
-literal byte) and the process of lazy evaluation begins again. Otherwise,
-the original match is kept, and the next match search is attempted only N
-steps later.
-
-The lazy match evaluation is also subject to a runtime parameter. If
-the current match is long enough, deflate() reduces the search for a longer
-match, thus speeding up the whole process. If compression ratio is more
-important than speed, deflate() attempts a complete second search even if
-the first match is already long enough.
-
-The lazy match evaluation is not performed for the fastest compression
-modes (level parameter 1 to 3). For these fast modes, new strings
-are inserted in the hash table only when no match was found, or
-when the match is not too long. This degrades the compression ratio
-but saves time since there are both fewer insertions and fewer searches.
-
-
-2. Decompression algorithm (inflate)
-
-2.1 Introduction
-
-The key question is how to represent a Huffman code (or any prefix code) so
-that you can decode fast. The most important characteristic is that shorter
-codes are much more common than longer codes, so pay attention to decoding the
-short codes fast, and let the long codes take longer to decode.
-
-inflate() sets up a first level table that covers some number of bits of
-input less than the length of longest code. It gets that many bits from the
-stream, and looks it up in the table. The table will tell if the next
-code is that many bits or less and how many, and if it is, it will tell
-the value, else it will point to the next level table for which inflate()
-grabs more bits and tries to decode a longer code.
-
-How many bits to make the first lookup is a tradeoff between the time it
-takes to decode and the time it takes to build the table. If building the
-table took no time (and if you had infinite memory), then there would only
-be a first level table to cover all the way to the longest code. However,
-building the table ends up taking a lot longer for more bits since short
-codes are replicated many times in such a table. What inflate() does is
-simply to make the number of bits in the first table a variable, and then
-to set that variable for the maximum speed.
-
-For inflate, which has 286 possible codes for the literal/length tree, the size
-of the first table is nine bits. Also the distance trees have 30 possible
-values, and the size of the first table is six bits. Note that for each of
-those cases, the table ended up one bit longer than the ``average'' code
-length, i.e. the code length of an approximately flat code which would be a
-little more than eight bits for 286 symbols and a little less than five bits
-for 30 symbols.
-
-
-2.2 More details on the inflate table lookup
-
-Ok, you want to know what this cleverly obfuscated inflate tree actually
-looks like. You are correct that it's not a Huffman tree. It is simply a
-lookup table for the first, let's say, nine bits of a Huffman symbol. The
-symbol could be as short as one bit or as long as 15 bits. If a particular
-symbol is shorter than nine bits, then that symbol's translation is duplicated
-in all those entries that start with that symbol's bits. For example, if the
-symbol is four bits, then it's duplicated 32 times in a nine-bit table. If a
-symbol is nine bits long, it appears in the table once.
-
-If the symbol is longer than nine bits, then that entry in the table points
-to another similar table for the remaining bits. Again, there are duplicated
-entries as needed. The idea is that most of the time the symbol will be short
-and there will only be one table look up. (That's whole idea behind data
-compression in the first place.) For the less frequent long symbols, there
-will be two lookups. If you had a compression method with really long
-symbols, you could have as many levels of lookups as is efficient. For
-inflate, two is enough.
-
-So a table entry either points to another table (in which case nine bits in
-the above example are gobbled), or it contains the translation for the symbol
-and the number of bits to gobble. Then you start again with the next
-ungobbled bit.
-
-You may wonder: why not just have one lookup table for how ever many bits the
-longest symbol is? The reason is that if you do that, you end up spending
-more time filling in duplicate symbol entries than you do actually decoding.
-At least for deflate's output that generates new trees every several 10's of
-kbytes. You can imagine that filling in a 2^15 entry table for a 15-bit code
-would take too long if you're only decoding several thousand symbols. At the
-other extreme, you could make a new table for every bit in the code. In fact,
-that's essentially a Huffman tree. But then you spend two much time
-traversing the tree while decoding, even for short symbols.
-
-So the number of bits for the first lookup table is a trade of the time to
-fill out the table vs. the time spent looking at the second level and above of
-the table.
-
-Here is an example, scaled down:
-
-The code being decoded, with 10 symbols, from 1 to 6 bits long:
-
-A: 0
-B: 10
-C: 1100
-D: 11010
-E: 11011
-F: 11100
-G: 11101
-H: 11110
-I: 111110
-J: 111111
-
-Let's make the first table three bits long (eight entries):
-
-000: A,1
-001: A,1
-010: A,1
-011: A,1
-100: B,2
-101: B,2
-110: -> table X (gobble 3 bits)
-111: -> table Y (gobble 3 bits)
-
-Each entry is what the bits decode as and how many bits that is, i.e. how
-many bits to gobble. Or the entry points to another table, with the number of
-bits to gobble implicit in the size of the table.
-
-Table X is two bits long since the longest code starting with 110 is five bits
-long:
-
-00: C,1
-01: C,1
-10: D,2
-11: E,2
-
-Table Y is three bits long since the longest code starting with 111 is six
-bits long:
-
-000: F,2
-001: F,2
-010: G,2
-011: G,2
-100: H,2
-101: H,2
-110: I,3
-111: J,3
-
-So what we have here are three tables with a total of 20 entries that had to
-be constructed. That's compared to 64 entries for a single table. Or
-compared to 16 entries for a Huffman tree (six two entry tables and one four
-entry table). Assuming that the code ideally represents the probability of
-the symbols, it takes on the average 1.25 lookups per symbol. That's compared
-to one lookup for the single table, or 1.66 lookups per symbol for the
-Huffman tree.
-
-There, I think that gives you a picture of what's going on. For inflate, the
-meaning of a particular symbol is often more than just a letter. It can be a
-byte (a "literal"), or it can be either a length or a distance which
-indicates a base value and a number of bits to fetch after the code that is
-added to the base value. Or it might be the special end-of-block code. The
-data structures created in inftrees.c try to encode all that information
-compactly in the tables.
-
-
-Jean-loup Gailly Mark Adler
-jloup@gzip.org madler@alumni.caltech.edu
-
-
-References:
-
-[LZ77] Ziv J., Lempel A., ``A Universal Algorithm for Sequential Data
-Compression,'' IEEE Transactions on Information Theory, Vol. 23, No. 3,
-pp. 337-343.
-
-``DEFLATE Compressed Data Format Specification'' available in
-http://www.ietf.org/rfc/rfc1951.txt
diff --git a/klibc/klibc/zlib/compress.c b/klibc/klibc/zlib/compress.c
deleted file mode 100644
index 3f4b44266a..0000000000
--- a/klibc/klibc/zlib/compress.c
+++ /dev/null
@@ -1,79 +0,0 @@
-/* compress.c -- compress a memory buffer
- * Copyright (C) 1995-2002 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* @(#) $Id: compress.c,v 1.1 2005/02/27 23:15:39 hpa Exp $ */
-
-#define ZLIB_INTERNAL
-#include "zlib.h"
-
-/* ===========================================================================
- Compresses the source buffer into the destination buffer. The level
- parameter has the same meaning as in deflateInit. sourceLen is the byte
- length of the source buffer. Upon entry, destLen is the total size of the
- destination buffer, which must be at least 0.1% larger than sourceLen plus
- 12 bytes. Upon exit, destLen is the actual size of the compressed buffer.
-
- compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
- memory, Z_BUF_ERROR if there was not enough room in the output buffer,
- Z_STREAM_ERROR if the level parameter is invalid.
-*/
-int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
- Bytef *dest;
- uLongf *destLen;
- const Bytef *source;
- uLong sourceLen;
- int level;
-{
- z_stream stream;
- int err;
-
- stream.next_in = (Bytef*)source;
- stream.avail_in = (uInt)sourceLen;
-#ifdef MAXSEG_64K
- /* Check for source > 64K on 16-bit machine: */
- if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
-#endif
- stream.next_out = dest;
- stream.avail_out = (uInt)*destLen;
- if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
-
- stream.zalloc = (alloc_func)0;
- stream.zfree = (free_func)0;
- stream.opaque = (voidpf)0;
-
- err = deflateInit(&stream, level);
- if (err != Z_OK) return err;
-
- err = deflate(&stream, Z_FINISH);
- if (err != Z_STREAM_END) {
- deflateEnd(&stream);
- return err == Z_OK ? Z_BUF_ERROR : err;
- }
- *destLen = stream.total_out;
-
- err = deflateEnd(&stream);
- return err;
-}
-
-/* ===========================================================================
- */
-int ZEXPORT compress (dest, destLen, source, sourceLen)
- Bytef *dest;
- uLongf *destLen;
- const Bytef *source;
- uLong sourceLen;
-{
- return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
-}
-
-/* ===========================================================================
- If the default memLevel or windowBits for deflateInit() is changed, then
- this function needs to be updated.
- */
-uLong ZEXPORT compressBound (sourceLen)
- uLong sourceLen;
-{
- return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + 11;
-}
diff --git a/klibc/klibc/zlib/crc32.c b/klibc/klibc/zlib/crc32.c
deleted file mode 100644
index 0bb9c49ab1..0000000000
--- a/klibc/klibc/zlib/crc32.c
+++ /dev/null
@@ -1,311 +0,0 @@
-/* crc32.c -- compute the CRC-32 of a data stream
- * Copyright (C) 1995-2003 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- *
- * Thanks to Rodney Brown <rbrown64@csc.com.au> for his contribution of faster
- * CRC methods: exclusive-oring 32 bits of data at a time, and pre-computing
- * tables for updating the shift register in one step with three exclusive-ors
- * instead of four steps with four exclusive-ors. This results about a factor
- * of two increase in speed on a Power PC G4 (PPC7455) using gcc -O3.
- */
-
-/* @(#) $Id: crc32.c,v 1.1 2005/02/27 23:15:39 hpa Exp $ */
-
-#ifdef MAKECRCH
-# include <stdio.h>
-# ifndef DYNAMIC_CRC_TABLE
-# define DYNAMIC_CRC_TABLE
-# endif /* !DYNAMIC_CRC_TABLE */
-#endif /* MAKECRCH */
-
-#include "zutil.h" /* for STDC and FAR definitions */
-
-#define local static
-
-/* Find a four-byte integer type for crc32_little() and crc32_big(). */
-#ifndef NOBYFOUR
-# ifdef STDC /* need ANSI C limits.h to determine sizes */
-# include <limits.h>
-# define BYFOUR
-# if (UINT_MAX == 0xffffffffUL)
- typedef unsigned int u4;
-# else
-# if (ULONG_MAX == 0xffffffffUL)
- typedef unsigned long u4;
-# else
-# if (USHRT_MAX == 0xffffffffUL)
- typedef unsigned short u4;
-# else
-# undef BYFOUR /* can't find a four-byte integer type! */
-# endif
-# endif
-# endif
-# endif /* STDC */
-#endif /* !NOBYFOUR */
-
-/* Definitions for doing the crc four data bytes at a time. */
-#ifdef BYFOUR
-# define REV(w) (((w)>>24)+(((w)>>8)&0xff00)+ \
- (((w)&0xff00)<<8)+(((w)&0xff)<<24))
- local unsigned long crc32_little OF((unsigned long,
- const unsigned char FAR *, unsigned));
- local unsigned long crc32_big OF((unsigned long,
- const unsigned char FAR *, unsigned));
-# define TBLS 8
-#else
-# define TBLS 1
-#endif /* BYFOUR */
-
-#ifdef DYNAMIC_CRC_TABLE
-
-local int crc_table_empty = 1;
-local unsigned long FAR crc_table[TBLS][256];
-local void make_crc_table OF((void));
-#ifdef MAKECRCH
- local void write_table OF((FILE *, const unsigned long FAR *));
-#endif /* MAKECRCH */
-
-/*
- Generate tables for a byte-wise 32-bit CRC calculation on the polynomial:
- x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1.
-
- Polynomials over GF(2) are represented in binary, one bit per coefficient,
- with the lowest powers in the most significant bit. Then adding polynomials
- is just exclusive-or, and multiplying a polynomial by x is a right shift by
- one. If we call the above polynomial p, and represent a byte as the
- polynomial q, also with the lowest power in the most significant bit (so the
- byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p,
- where a mod b means the remainder after dividing a by b.
-
- This calculation is done using the shift-register method of multiplying and
- taking the remainder. The register is initialized to zero, and for each
- incoming bit, x^32 is added mod p to the register if the bit is a one (where
- x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by
- x (which is shifting right by one and adding x^32 mod p if the bit shifted
- out is a one). We start with the highest power (least significant bit) of
- q and repeat for all eight bits of q.
-
- The first table is simply the CRC of all possible eight bit values. This is
- all the information needed to generate CRCs on data a byte at a time for all
- combinations of CRC register values and incoming bytes. The remaining tables
- allow for word-at-a-time CRC calculation for both big-endian and little-
- endian machines, where a word is four bytes.
-*/
-local void make_crc_table()
-{
- unsigned long c;
- int n, k;
- unsigned long poly; /* polynomial exclusive-or pattern */
- /* terms of polynomial defining this crc (except x^32): */
- static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26};
-
- /* make exclusive-or pattern from polynomial (0xedb88320UL) */
- poly = 0UL;
- for (n = 0; n < sizeof(p)/sizeof(unsigned char); n++)
- poly |= 1UL << (31 - p[n]);
-
- /* generate a crc for every 8-bit value */
- for (n = 0; n < 256; n++) {
- c = (unsigned long)n;
- for (k = 0; k < 8; k++)
- c = c & 1 ? poly ^ (c >> 1) : c >> 1;
- crc_table[0][n] = c;
- }
-
-#ifdef BYFOUR
- /* generate crc for each value followed by one, two, and three zeros, and
- then the byte reversal of those as well as the first table */
- for (n = 0; n < 256; n++) {
- c = crc_table[0][n];
- crc_table[4][n] = REV(c);
- for (k = 1; k < 4; k++) {
- c = crc_table[0][c & 0xff] ^ (c >> 8);
- crc_table[k][n] = c;
- crc_table[k + 4][n] = REV(c);
- }
- }
-#endif /* BYFOUR */
-
- crc_table_empty = 0;
-
-#ifdef MAKECRCH
- /* write out CRC tables to crc32.h */
- {
- FILE *out;
-
- out = fopen("crc32.h", "w");
- if (out == NULL) return;
- fprintf(out, "/* crc32.h -- tables for rapid CRC calculation\n");
- fprintf(out, " * Generated automatically by crc32.c\n */\n\n");
- fprintf(out, "local const unsigned long FAR ");
- fprintf(out, "crc_table[TBLS][256] =\n{\n {\n");
- write_table(out, crc_table[0]);
-# ifdef BYFOUR
- fprintf(out, "#ifdef BYFOUR\n");
- for (k = 1; k < 8; k++) {
- fprintf(out, " },\n {\n");
- write_table(out, crc_table[k]);
- }
- fprintf(out, "#endif\n");
-# endif /* BYFOUR */
- fprintf(out, " }\n};\n");
- fclose(out);
- }
-#endif /* MAKECRCH */
-}
-
-#ifdef MAKECRCH
-local void write_table(out, table)
- FILE *out;
- const unsigned long FAR *table;
-{
- int n;
-
- for (n = 0; n < 256; n++)
- fprintf(out, "%s0x%08lxUL%s", n % 5 ? "" : " ", table[n],
- n == 255 ? "\n" : (n % 5 == 4 ? ",\n" : ", "));
-}
-#endif /* MAKECRCH */
-
-#else /* !DYNAMIC_CRC_TABLE */
-/* ========================================================================
- * Tables of CRC-32s of all single-byte values, made by make_crc_table().
- */
-#include "crc32.h"
-#endif /* DYNAMIC_CRC_TABLE */
-
-/* =========================================================================
- * This function can be used by asm versions of crc32()
- */
-const unsigned long FAR * ZEXPORT get_crc_table()
-{
-#ifdef DYNAMIC_CRC_TABLE
- if (crc_table_empty) make_crc_table();
-#endif /* DYNAMIC_CRC_TABLE */
- return (const unsigned long FAR *)crc_table;
-}
-
-/* ========================================================================= */
-#define DO1 crc = crc_table[0][((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8)
-#define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1
-
-/* ========================================================================= */
-unsigned long ZEXPORT crc32(crc, buf, len)
- unsigned long crc;
- const unsigned char FAR *buf;
- unsigned len;
-{
- if (buf == Z_NULL) return 0UL;
-
-#ifdef DYNAMIC_CRC_TABLE
- if (crc_table_empty)
- make_crc_table();
-#endif /* DYNAMIC_CRC_TABLE */
-
-#ifdef BYFOUR
- if (sizeof(void *) == sizeof(ptrdiff_t)) {
- u4 endian;
-
- endian = 1;
- if (*((unsigned char *)(&endian)))
- return crc32_little(crc, buf, len);
- else
- return crc32_big(crc, buf, len);
- }
-#endif /* BYFOUR */
- crc = crc ^ 0xffffffffUL;
- while (len >= 8) {
- DO8;
- len -= 8;
- }
- if (len) do {
- DO1;
- } while (--len);
- return crc ^ 0xffffffffUL;
-}
-
-#ifdef BYFOUR
-
-/* ========================================================================= */
-#define DOLIT4 c ^= *buf4++; \
- c = crc_table[3][c & 0xff] ^ crc_table[2][(c >> 8) & 0xff] ^ \
- crc_table[1][(c >> 16) & 0xff] ^ crc_table[0][c >> 24]
-#define DOLIT32 DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4
-
-/* ========================================================================= */
-local unsigned long crc32_little(crc, buf, len)
- unsigned long crc;
- const unsigned char FAR *buf;
- unsigned len;
-{
- register u4 c;
- register const u4 FAR *buf4;
-
- c = (u4)crc;
- c = ~c;
- while (len && ((ptrdiff_t)buf & 3)) {
- c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8);
- len--;
- }
-
- buf4 = (const u4 FAR *)buf;
- while (len >= 32) {
- DOLIT32;
- len -= 32;
- }
- while (len >= 4) {
- DOLIT4;
- len -= 4;
- }
- buf = (const unsigned char FAR *)buf4;
-
- if (len) do {
- c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8);
- } while (--len);
- c = ~c;
- return (unsigned long)c;
-}
-
-/* ========================================================================= */
-#define DOBIG4 c ^= *++buf4; \
- c = crc_table[4][c & 0xff] ^ crc_table[5][(c >> 8) & 0xff] ^ \
- crc_table[6][(c >> 16) & 0xff] ^ crc_table[7][c >> 24]
-#define DOBIG32 DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4
-
-/* ========================================================================= */
-local unsigned long crc32_big(crc, buf, len)
- unsigned long crc;
- const unsigned char FAR *buf;
- unsigned len;
-{
- register u4 c;
- register const u4 FAR *buf4;
-
- c = REV((u4)crc);
- c = ~c;
- while (len && ((ptrdiff_t)buf & 3)) {
- c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);
- len--;
- }
-
- buf4 = (const u4 FAR *)buf;
- buf4--;
- while (len >= 32) {
- DOBIG32;
- len -= 32;
- }
- while (len >= 4) {
- DOBIG4;
- len -= 4;
- }
- buf4++;
- buf = (const unsigned char FAR *)buf4;
-
- if (len) do {
- c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);
- } while (--len);
- c = ~c;
- return (unsigned long)(REV(c));
-}
-
-#endif /* BYFOUR */
diff --git a/klibc/klibc/zlib/crc32.h b/klibc/klibc/zlib/crc32.h
deleted file mode 100644
index 8053b6117c..0000000000
--- a/klibc/klibc/zlib/crc32.h
+++ /dev/null
@@ -1,441 +0,0 @@
-/* crc32.h -- tables for rapid CRC calculation
- * Generated automatically by crc32.c
- */
-
-local const unsigned long FAR crc_table[TBLS][256] =
-{
- {
- 0x00000000UL, 0x77073096UL, 0xee0e612cUL, 0x990951baUL, 0x076dc419UL,
- 0x706af48fUL, 0xe963a535UL, 0x9e6495a3UL, 0x0edb8832UL, 0x79dcb8a4UL,
- 0xe0d5e91eUL, 0x97d2d988UL, 0x09b64c2bUL, 0x7eb17cbdUL, 0xe7b82d07UL,
- 0x90bf1d91UL, 0x1db71064UL, 0x6ab020f2UL, 0xf3b97148UL, 0x84be41deUL,
- 0x1adad47dUL, 0x6ddde4ebUL, 0xf4d4b551UL, 0x83d385c7UL, 0x136c9856UL,
- 0x646ba8c0UL, 0xfd62f97aUL, 0x8a65c9ecUL, 0x14015c4fUL, 0x63066cd9UL,
- 0xfa0f3d63UL, 0x8d080df5UL, 0x3b6e20c8UL, 0x4c69105eUL, 0xd56041e4UL,
- 0xa2677172UL, 0x3c03e4d1UL, 0x4b04d447UL, 0xd20d85fdUL, 0xa50ab56bUL,
- 0x35b5a8faUL, 0x42b2986cUL, 0xdbbbc9d6UL, 0xacbcf940UL, 0x32d86ce3UL,
- 0x45df5c75UL, 0xdcd60dcfUL, 0xabd13d59UL, 0x26d930acUL, 0x51de003aUL,
- 0xc8d75180UL, 0xbfd06116UL, 0x21b4f4b5UL, 0x56b3c423UL, 0xcfba9599UL,
- 0xb8bda50fUL, 0x2802b89eUL, 0x5f058808UL, 0xc60cd9b2UL, 0xb10be924UL,
- 0x2f6f7c87UL, 0x58684c11UL, 0xc1611dabUL, 0xb6662d3dUL, 0x76dc4190UL,
- 0x01db7106UL, 0x98d220bcUL, 0xefd5102aUL, 0x71b18589UL, 0x06b6b51fUL,
- 0x9fbfe4a5UL, 0xe8b8d433UL, 0x7807c9a2UL, 0x0f00f934UL, 0x9609a88eUL,
- 0xe10e9818UL, 0x7f6a0dbbUL, 0x086d3d2dUL, 0x91646c97UL, 0xe6635c01UL,
- 0x6b6b51f4UL, 0x1c6c6162UL, 0x856530d8UL, 0xf262004eUL, 0x6c0695edUL,
- 0x1b01a57bUL, 0x8208f4c1UL, 0xf50fc457UL, 0x65b0d9c6UL, 0x12b7e950UL,
- 0x8bbeb8eaUL, 0xfcb9887cUL, 0x62dd1ddfUL, 0x15da2d49UL, 0x8cd37cf3UL,
- 0xfbd44c65UL, 0x4db26158UL, 0x3ab551ceUL, 0xa3bc0074UL, 0xd4bb30e2UL,
- 0x4adfa541UL, 0x3dd895d7UL, 0xa4d1c46dUL, 0xd3d6f4fbUL, 0x4369e96aUL,
- 0x346ed9fcUL, 0xad678846UL, 0xda60b8d0UL, 0x44042d73UL, 0x33031de5UL,
- 0xaa0a4c5fUL, 0xdd0d7cc9UL, 0x5005713cUL, 0x270241aaUL, 0xbe0b1010UL,
- 0xc90c2086UL, 0x5768b525UL, 0x206f85b3UL, 0xb966d409UL, 0xce61e49fUL,
- 0x5edef90eUL, 0x29d9c998UL, 0xb0d09822UL, 0xc7d7a8b4UL, 0x59b33d17UL,
- 0x2eb40d81UL, 0xb7bd5c3bUL, 0xc0ba6cadUL, 0xedb88320UL, 0x9abfb3b6UL,
- 0x03b6e20cUL, 0x74b1d29aUL, 0xead54739UL, 0x9dd277afUL, 0x04db2615UL,
- 0x73dc1683UL, 0xe3630b12UL, 0x94643b84UL, 0x0d6d6a3eUL, 0x7a6a5aa8UL,
- 0xe40ecf0bUL, 0x9309ff9dUL, 0x0a00ae27UL, 0x7d079eb1UL, 0xf00f9344UL,
- 0x8708a3d2UL, 0x1e01f268UL, 0x6906c2feUL, 0xf762575dUL, 0x806567cbUL,
- 0x196c3671UL, 0x6e6b06e7UL, 0xfed41b76UL, 0x89d32be0UL, 0x10da7a5aUL,
- 0x67dd4accUL, 0xf9b9df6fUL, 0x8ebeeff9UL, 0x17b7be43UL, 0x60b08ed5UL,
- 0xd6d6a3e8UL, 0xa1d1937eUL, 0x38d8c2c4UL, 0x4fdff252UL, 0xd1bb67f1UL,
- 0xa6bc5767UL, 0x3fb506ddUL, 0x48b2364bUL, 0xd80d2bdaUL, 0xaf0a1b4cUL,
- 0x36034af6UL, 0x41047a60UL, 0xdf60efc3UL, 0xa867df55UL, 0x316e8eefUL,
- 0x4669be79UL, 0xcb61b38cUL, 0xbc66831aUL, 0x256fd2a0UL, 0x5268e236UL,
- 0xcc0c7795UL, 0xbb0b4703UL, 0x220216b9UL, 0x5505262fUL, 0xc5ba3bbeUL,
- 0xb2bd0b28UL, 0x2bb45a92UL, 0x5cb36a04UL, 0xc2d7ffa7UL, 0xb5d0cf31UL,
- 0x2cd99e8bUL, 0x5bdeae1dUL, 0x9b64c2b0UL, 0xec63f226UL, 0x756aa39cUL,
- 0x026d930aUL, 0x9c0906a9UL, 0xeb0e363fUL, 0x72076785UL, 0x05005713UL,
- 0x95bf4a82UL, 0xe2b87a14UL, 0x7bb12baeUL, 0x0cb61b38UL, 0x92d28e9bUL,
- 0xe5d5be0dUL, 0x7cdcefb7UL, 0x0bdbdf21UL, 0x86d3d2d4UL, 0xf1d4e242UL,
- 0x68ddb3f8UL, 0x1fda836eUL, 0x81be16cdUL, 0xf6b9265bUL, 0x6fb077e1UL,
- 0x18b74777UL, 0x88085ae6UL, 0xff0f6a70UL, 0x66063bcaUL, 0x11010b5cUL,
- 0x8f659effUL, 0xf862ae69UL, 0x616bffd3UL, 0x166ccf45UL, 0xa00ae278UL,
- 0xd70dd2eeUL, 0x4e048354UL, 0x3903b3c2UL, 0xa7672661UL, 0xd06016f7UL,
- 0x4969474dUL, 0x3e6e77dbUL, 0xaed16a4aUL, 0xd9d65adcUL, 0x40df0b66UL,
- 0x37d83bf0UL, 0xa9bcae53UL, 0xdebb9ec5UL, 0x47b2cf7fUL, 0x30b5ffe9UL,
- 0xbdbdf21cUL, 0xcabac28aUL, 0x53b39330UL, 0x24b4a3a6UL, 0xbad03605UL,
- 0xcdd70693UL, 0x54de5729UL, 0x23d967bfUL, 0xb3667a2eUL, 0xc4614ab8UL,
- 0x5d681b02UL, 0x2a6f2b94UL, 0xb40bbe37UL, 0xc30c8ea1UL, 0x5a05df1bUL,
- 0x2d02ef8dUL
-#ifdef BYFOUR
- },
- {
- 0x00000000UL, 0x191b3141UL, 0x32366282UL, 0x2b2d53c3UL, 0x646cc504UL,
- 0x7d77f445UL, 0x565aa786UL, 0x4f4196c7UL, 0xc8d98a08UL, 0xd1c2bb49UL,
- 0xfaefe88aUL, 0xe3f4d9cbUL, 0xacb54f0cUL, 0xb5ae7e4dUL, 0x9e832d8eUL,
- 0x87981ccfUL, 0x4ac21251UL, 0x53d92310UL, 0x78f470d3UL, 0x61ef4192UL,
- 0x2eaed755UL, 0x37b5e614UL, 0x1c98b5d7UL, 0x05838496UL, 0x821b9859UL,
- 0x9b00a918UL, 0xb02dfadbUL, 0xa936cb9aUL, 0xe6775d5dUL, 0xff6c6c1cUL,
- 0xd4413fdfUL, 0xcd5a0e9eUL, 0x958424a2UL, 0x8c9f15e3UL, 0xa7b24620UL,
- 0xbea97761UL, 0xf1e8e1a6UL, 0xe8f3d0e7UL, 0xc3de8324UL, 0xdac5b265UL,
- 0x5d5daeaaUL, 0x44469febUL, 0x6f6bcc28UL, 0x7670fd69UL, 0x39316baeUL,
- 0x202a5aefUL, 0x0b07092cUL, 0x121c386dUL, 0xdf4636f3UL, 0xc65d07b2UL,
- 0xed705471UL, 0xf46b6530UL, 0xbb2af3f7UL, 0xa231c2b6UL, 0x891c9175UL,
- 0x9007a034UL, 0x179fbcfbUL, 0x0e848dbaUL, 0x25a9de79UL, 0x3cb2ef38UL,
- 0x73f379ffUL, 0x6ae848beUL, 0x41c51b7dUL, 0x58de2a3cUL, 0xf0794f05UL,
- 0xe9627e44UL, 0xc24f2d87UL, 0xdb541cc6UL, 0x94158a01UL, 0x8d0ebb40UL,
- 0xa623e883UL, 0xbf38d9c2UL, 0x38a0c50dUL, 0x21bbf44cUL, 0x0a96a78fUL,
- 0x138d96ceUL, 0x5ccc0009UL, 0x45d73148UL, 0x6efa628bUL, 0x77e153caUL,
- 0xbabb5d54UL, 0xa3a06c15UL, 0x888d3fd6UL, 0x91960e97UL, 0xded79850UL,
- 0xc7cca911UL, 0xece1fad2UL, 0xf5facb93UL, 0x7262d75cUL, 0x6b79e61dUL,
- 0x4054b5deUL, 0x594f849fUL, 0x160e1258UL, 0x0f152319UL, 0x243870daUL,
- 0x3d23419bUL, 0x65fd6ba7UL, 0x7ce65ae6UL, 0x57cb0925UL, 0x4ed03864UL,
- 0x0191aea3UL, 0x188a9fe2UL, 0x33a7cc21UL, 0x2abcfd60UL, 0xad24e1afUL,
- 0xb43fd0eeUL, 0x9f12832dUL, 0x8609b26cUL, 0xc94824abUL, 0xd05315eaUL,
- 0xfb7e4629UL, 0xe2657768UL, 0x2f3f79f6UL, 0x362448b7UL, 0x1d091b74UL,
- 0x04122a35UL, 0x4b53bcf2UL, 0x52488db3UL, 0x7965de70UL, 0x607eef31UL,
- 0xe7e6f3feUL, 0xfefdc2bfUL, 0xd5d0917cUL, 0xcccba03dUL, 0x838a36faUL,
- 0x9a9107bbUL, 0xb1bc5478UL, 0xa8a76539UL, 0x3b83984bUL, 0x2298a90aUL,
- 0x09b5fac9UL, 0x10aecb88UL, 0x5fef5d4fUL, 0x46f46c0eUL, 0x6dd93fcdUL,
- 0x74c20e8cUL, 0xf35a1243UL, 0xea412302UL, 0xc16c70c1UL, 0xd8774180UL,
- 0x9736d747UL, 0x8e2de606UL, 0xa500b5c5UL, 0xbc1b8484UL, 0x71418a1aUL,
- 0x685abb5bUL, 0x4377e898UL, 0x5a6cd9d9UL, 0x152d4f1eUL, 0x0c367e5fUL,
- 0x271b2d9cUL, 0x3e001cddUL, 0xb9980012UL, 0xa0833153UL, 0x8bae6290UL,
- 0x92b553d1UL, 0xddf4c516UL, 0xc4eff457UL, 0xefc2a794UL, 0xf6d996d5UL,
- 0xae07bce9UL, 0xb71c8da8UL, 0x9c31de6bUL, 0x852aef2aUL, 0xca6b79edUL,
- 0xd37048acUL, 0xf85d1b6fUL, 0xe1462a2eUL, 0x66de36e1UL, 0x7fc507a0UL,
- 0x54e85463UL, 0x4df36522UL, 0x02b2f3e5UL, 0x1ba9c2a4UL, 0x30849167UL,
- 0x299fa026UL, 0xe4c5aeb8UL, 0xfdde9ff9UL, 0xd6f3cc3aUL, 0xcfe8fd7bUL,
- 0x80a96bbcUL, 0x99b25afdUL, 0xb29f093eUL, 0xab84387fUL, 0x2c1c24b0UL,
- 0x350715f1UL, 0x1e2a4632UL, 0x07317773UL, 0x4870e1b4UL, 0x516bd0f5UL,
- 0x7a468336UL, 0x635db277UL, 0xcbfad74eUL, 0xd2e1e60fUL, 0xf9ccb5ccUL,
- 0xe0d7848dUL, 0xaf96124aUL, 0xb68d230bUL, 0x9da070c8UL, 0x84bb4189UL,
- 0x03235d46UL, 0x1a386c07UL, 0x31153fc4UL, 0x280e0e85UL, 0x674f9842UL,
- 0x7e54a903UL, 0x5579fac0UL, 0x4c62cb81UL, 0x8138c51fUL, 0x9823f45eUL,
- 0xb30ea79dUL, 0xaa1596dcUL, 0xe554001bUL, 0xfc4f315aUL, 0xd7626299UL,
- 0xce7953d8UL, 0x49e14f17UL, 0x50fa7e56UL, 0x7bd72d95UL, 0x62cc1cd4UL,
- 0x2d8d8a13UL, 0x3496bb52UL, 0x1fbbe891UL, 0x06a0d9d0UL, 0x5e7ef3ecUL,
- 0x4765c2adUL, 0x6c48916eUL, 0x7553a02fUL, 0x3a1236e8UL, 0x230907a9UL,
- 0x0824546aUL, 0x113f652bUL, 0x96a779e4UL, 0x8fbc48a5UL, 0xa4911b66UL,
- 0xbd8a2a27UL, 0xf2cbbce0UL, 0xebd08da1UL, 0xc0fdde62UL, 0xd9e6ef23UL,
- 0x14bce1bdUL, 0x0da7d0fcUL, 0x268a833fUL, 0x3f91b27eUL, 0x70d024b9UL,
- 0x69cb15f8UL, 0x42e6463bUL, 0x5bfd777aUL, 0xdc656bb5UL, 0xc57e5af4UL,
- 0xee530937UL, 0xf7483876UL, 0xb809aeb1UL, 0xa1129ff0UL, 0x8a3fcc33UL,
- 0x9324fd72UL
- },
- {
- 0x00000000UL, 0x01c26a37UL, 0x0384d46eUL, 0x0246be59UL, 0x0709a8dcUL,
- 0x06cbc2ebUL, 0x048d7cb2UL, 0x054f1685UL, 0x0e1351b8UL, 0x0fd13b8fUL,
- 0x0d9785d6UL, 0x0c55efe1UL, 0x091af964UL, 0x08d89353UL, 0x0a9e2d0aUL,
- 0x0b5c473dUL, 0x1c26a370UL, 0x1de4c947UL, 0x1fa2771eUL, 0x1e601d29UL,
- 0x1b2f0bacUL, 0x1aed619bUL, 0x18abdfc2UL, 0x1969b5f5UL, 0x1235f2c8UL,
- 0x13f798ffUL, 0x11b126a6UL, 0x10734c91UL, 0x153c5a14UL, 0x14fe3023UL,
- 0x16b88e7aUL, 0x177ae44dUL, 0x384d46e0UL, 0x398f2cd7UL, 0x3bc9928eUL,
- 0x3a0bf8b9UL, 0x3f44ee3cUL, 0x3e86840bUL, 0x3cc03a52UL, 0x3d025065UL,
- 0x365e1758UL, 0x379c7d6fUL, 0x35dac336UL, 0x3418a901UL, 0x3157bf84UL,
- 0x3095d5b3UL, 0x32d36beaUL, 0x331101ddUL, 0x246be590UL, 0x25a98fa7UL,
- 0x27ef31feUL, 0x262d5bc9UL, 0x23624d4cUL, 0x22a0277bUL, 0x20e69922UL,
- 0x2124f315UL, 0x2a78b428UL, 0x2bbade1fUL, 0x29fc6046UL, 0x283e0a71UL,
- 0x2d711cf4UL, 0x2cb376c3UL, 0x2ef5c89aUL, 0x2f37a2adUL, 0x709a8dc0UL,
- 0x7158e7f7UL, 0x731e59aeUL, 0x72dc3399UL, 0x7793251cUL, 0x76514f2bUL,
- 0x7417f172UL, 0x75d59b45UL, 0x7e89dc78UL, 0x7f4bb64fUL, 0x7d0d0816UL,
- 0x7ccf6221UL, 0x798074a4UL, 0x78421e93UL, 0x7a04a0caUL, 0x7bc6cafdUL,
- 0x6cbc2eb0UL, 0x6d7e4487UL, 0x6f38fadeUL, 0x6efa90e9UL, 0x6bb5866cUL,
- 0x6a77ec5bUL, 0x68315202UL, 0x69f33835UL, 0x62af7f08UL, 0x636d153fUL,
- 0x612bab66UL, 0x60e9c151UL, 0x65a6d7d4UL, 0x6464bde3UL, 0x662203baUL,
- 0x67e0698dUL, 0x48d7cb20UL, 0x4915a117UL, 0x4b531f4eUL, 0x4a917579UL,
- 0x4fde63fcUL, 0x4e1c09cbUL, 0x4c5ab792UL, 0x4d98dda5UL, 0x46c49a98UL,
- 0x4706f0afUL, 0x45404ef6UL, 0x448224c1UL, 0x41cd3244UL, 0x400f5873UL,
- 0x4249e62aUL, 0x438b8c1dUL, 0x54f16850UL, 0x55330267UL, 0x5775bc3eUL,
- 0x56b7d609UL, 0x53f8c08cUL, 0x523aaabbUL, 0x507c14e2UL, 0x51be7ed5UL,
- 0x5ae239e8UL, 0x5b2053dfUL, 0x5966ed86UL, 0x58a487b1UL, 0x5deb9134UL,
- 0x5c29fb03UL, 0x5e6f455aUL, 0x5fad2f6dUL, 0xe1351b80UL, 0xe0f771b7UL,
- 0xe2b1cfeeUL, 0xe373a5d9UL, 0xe63cb35cUL, 0xe7fed96bUL, 0xe5b86732UL,
- 0xe47a0d05UL, 0xef264a38UL, 0xeee4200fUL, 0xeca29e56UL, 0xed60f461UL,
- 0xe82fe2e4UL, 0xe9ed88d3UL, 0xebab368aUL, 0xea695cbdUL, 0xfd13b8f0UL,
- 0xfcd1d2c7UL, 0xfe976c9eUL, 0xff5506a9UL, 0xfa1a102cUL, 0xfbd87a1bUL,
- 0xf99ec442UL, 0xf85cae75UL, 0xf300e948UL, 0xf2c2837fUL, 0xf0843d26UL,
- 0xf1465711UL, 0xf4094194UL, 0xf5cb2ba3UL, 0xf78d95faUL, 0xf64fffcdUL,
- 0xd9785d60UL, 0xd8ba3757UL, 0xdafc890eUL, 0xdb3ee339UL, 0xde71f5bcUL,
- 0xdfb39f8bUL, 0xddf521d2UL, 0xdc374be5UL, 0xd76b0cd8UL, 0xd6a966efUL,
- 0xd4efd8b6UL, 0xd52db281UL, 0xd062a404UL, 0xd1a0ce33UL, 0xd3e6706aUL,
- 0xd2241a5dUL, 0xc55efe10UL, 0xc49c9427UL, 0xc6da2a7eUL, 0xc7184049UL,
- 0xc25756ccUL, 0xc3953cfbUL, 0xc1d382a2UL, 0xc011e895UL, 0xcb4dafa8UL,
- 0xca8fc59fUL, 0xc8c97bc6UL, 0xc90b11f1UL, 0xcc440774UL, 0xcd866d43UL,
- 0xcfc0d31aUL, 0xce02b92dUL, 0x91af9640UL, 0x906dfc77UL, 0x922b422eUL,
- 0x93e92819UL, 0x96a63e9cUL, 0x976454abUL, 0x9522eaf2UL, 0x94e080c5UL,
- 0x9fbcc7f8UL, 0x9e7eadcfUL, 0x9c381396UL, 0x9dfa79a1UL, 0x98b56f24UL,
- 0x99770513UL, 0x9b31bb4aUL, 0x9af3d17dUL, 0x8d893530UL, 0x8c4b5f07UL,
- 0x8e0de15eUL, 0x8fcf8b69UL, 0x8a809decUL, 0x8b42f7dbUL, 0x89044982UL,
- 0x88c623b5UL, 0x839a6488UL, 0x82580ebfUL, 0x801eb0e6UL, 0x81dcdad1UL,
- 0x8493cc54UL, 0x8551a663UL, 0x8717183aUL, 0x86d5720dUL, 0xa9e2d0a0UL,
- 0xa820ba97UL, 0xaa6604ceUL, 0xaba46ef9UL, 0xaeeb787cUL, 0xaf29124bUL,
- 0xad6fac12UL, 0xacadc625UL, 0xa7f18118UL, 0xa633eb2fUL, 0xa4755576UL,
- 0xa5b73f41UL, 0xa0f829c4UL, 0xa13a43f3UL, 0xa37cfdaaUL, 0xa2be979dUL,
- 0xb5c473d0UL, 0xb40619e7UL, 0xb640a7beUL, 0xb782cd89UL, 0xb2cddb0cUL,
- 0xb30fb13bUL, 0xb1490f62UL, 0xb08b6555UL, 0xbbd72268UL, 0xba15485fUL,
- 0xb853f606UL, 0xb9919c31UL, 0xbcde8ab4UL, 0xbd1ce083UL, 0xbf5a5edaUL,
- 0xbe9834edUL
- },
- {
- 0x00000000UL, 0xb8bc6765UL, 0xaa09c88bUL, 0x12b5afeeUL, 0x8f629757UL,
- 0x37def032UL, 0x256b5fdcUL, 0x9dd738b9UL, 0xc5b428efUL, 0x7d084f8aUL,
- 0x6fbde064UL, 0xd7018701UL, 0x4ad6bfb8UL, 0xf26ad8ddUL, 0xe0df7733UL,
- 0x58631056UL, 0x5019579fUL, 0xe8a530faUL, 0xfa109f14UL, 0x42acf871UL,
- 0xdf7bc0c8UL, 0x67c7a7adUL, 0x75720843UL, 0xcdce6f26UL, 0x95ad7f70UL,
- 0x2d111815UL, 0x3fa4b7fbUL, 0x8718d09eUL, 0x1acfe827UL, 0xa2738f42UL,
- 0xb0c620acUL, 0x087a47c9UL, 0xa032af3eUL, 0x188ec85bUL, 0x0a3b67b5UL,
- 0xb28700d0UL, 0x2f503869UL, 0x97ec5f0cUL, 0x8559f0e2UL, 0x3de59787UL,
- 0x658687d1UL, 0xdd3ae0b4UL, 0xcf8f4f5aUL, 0x7733283fUL, 0xeae41086UL,
- 0x525877e3UL, 0x40edd80dUL, 0xf851bf68UL, 0xf02bf8a1UL, 0x48979fc4UL,
- 0x5a22302aUL, 0xe29e574fUL, 0x7f496ff6UL, 0xc7f50893UL, 0xd540a77dUL,
- 0x6dfcc018UL, 0x359fd04eUL, 0x8d23b72bUL, 0x9f9618c5UL, 0x272a7fa0UL,
- 0xbafd4719UL, 0x0241207cUL, 0x10f48f92UL, 0xa848e8f7UL, 0x9b14583dUL,
- 0x23a83f58UL, 0x311d90b6UL, 0x89a1f7d3UL, 0x1476cf6aUL, 0xaccaa80fUL,
- 0xbe7f07e1UL, 0x06c36084UL, 0x5ea070d2UL, 0xe61c17b7UL, 0xf4a9b859UL,
- 0x4c15df3cUL, 0xd1c2e785UL, 0x697e80e0UL, 0x7bcb2f0eUL, 0xc377486bUL,
- 0xcb0d0fa2UL, 0x73b168c7UL, 0x6104c729UL, 0xd9b8a04cUL, 0x446f98f5UL,
- 0xfcd3ff90UL, 0xee66507eUL, 0x56da371bUL, 0x0eb9274dUL, 0xb6054028UL,
- 0xa4b0efc6UL, 0x1c0c88a3UL, 0x81dbb01aUL, 0x3967d77fUL, 0x2bd27891UL,
- 0x936e1ff4UL, 0x3b26f703UL, 0x839a9066UL, 0x912f3f88UL, 0x299358edUL,
- 0xb4446054UL, 0x0cf80731UL, 0x1e4da8dfUL, 0xa6f1cfbaUL, 0xfe92dfecUL,
- 0x462eb889UL, 0x549b1767UL, 0xec277002UL, 0x71f048bbUL, 0xc94c2fdeUL,
- 0xdbf98030UL, 0x6345e755UL, 0x6b3fa09cUL, 0xd383c7f9UL, 0xc1366817UL,
- 0x798a0f72UL, 0xe45d37cbUL, 0x5ce150aeUL, 0x4e54ff40UL, 0xf6e89825UL,
- 0xae8b8873UL, 0x1637ef16UL, 0x048240f8UL, 0xbc3e279dUL, 0x21e91f24UL,
- 0x99557841UL, 0x8be0d7afUL, 0x335cb0caUL, 0xed59b63bUL, 0x55e5d15eUL,
- 0x47507eb0UL, 0xffec19d5UL, 0x623b216cUL, 0xda874609UL, 0xc832e9e7UL,
- 0x708e8e82UL, 0x28ed9ed4UL, 0x9051f9b1UL, 0x82e4565fUL, 0x3a58313aUL,
- 0xa78f0983UL, 0x1f336ee6UL, 0x0d86c108UL, 0xb53aa66dUL, 0xbd40e1a4UL,
- 0x05fc86c1UL, 0x1749292fUL, 0xaff54e4aUL, 0x322276f3UL, 0x8a9e1196UL,
- 0x982bbe78UL, 0x2097d91dUL, 0x78f4c94bUL, 0xc048ae2eUL, 0xd2fd01c0UL,
- 0x6a4166a5UL, 0xf7965e1cUL, 0x4f2a3979UL, 0x5d9f9697UL, 0xe523f1f2UL,
- 0x4d6b1905UL, 0xf5d77e60UL, 0xe762d18eUL, 0x5fdeb6ebUL, 0xc2098e52UL,
- 0x7ab5e937UL, 0x680046d9UL, 0xd0bc21bcUL, 0x88df31eaUL, 0x3063568fUL,
- 0x22d6f961UL, 0x9a6a9e04UL, 0x07bda6bdUL, 0xbf01c1d8UL, 0xadb46e36UL,
- 0x15080953UL, 0x1d724e9aUL, 0xa5ce29ffUL, 0xb77b8611UL, 0x0fc7e174UL,
- 0x9210d9cdUL, 0x2aacbea8UL, 0x38191146UL, 0x80a57623UL, 0xd8c66675UL,
- 0x607a0110UL, 0x72cfaefeUL, 0xca73c99bUL, 0x57a4f122UL, 0xef189647UL,
- 0xfdad39a9UL, 0x45115eccUL, 0x764dee06UL, 0xcef18963UL, 0xdc44268dUL,
- 0x64f841e8UL, 0xf92f7951UL, 0x41931e34UL, 0x5326b1daUL, 0xeb9ad6bfUL,
- 0xb3f9c6e9UL, 0x0b45a18cUL, 0x19f00e62UL, 0xa14c6907UL, 0x3c9b51beUL,
- 0x842736dbUL, 0x96929935UL, 0x2e2efe50UL, 0x2654b999UL, 0x9ee8defcUL,
- 0x8c5d7112UL, 0x34e11677UL, 0xa9362eceUL, 0x118a49abUL, 0x033fe645UL,
- 0xbb838120UL, 0xe3e09176UL, 0x5b5cf613UL, 0x49e959fdUL, 0xf1553e98UL,
- 0x6c820621UL, 0xd43e6144UL, 0xc68bceaaUL, 0x7e37a9cfUL, 0xd67f4138UL,
- 0x6ec3265dUL, 0x7c7689b3UL, 0xc4caeed6UL, 0x591dd66fUL, 0xe1a1b10aUL,
- 0xf3141ee4UL, 0x4ba87981UL, 0x13cb69d7UL, 0xab770eb2UL, 0xb9c2a15cUL,
- 0x017ec639UL, 0x9ca9fe80UL, 0x241599e5UL, 0x36a0360bUL, 0x8e1c516eUL,
- 0x866616a7UL, 0x3eda71c2UL, 0x2c6fde2cUL, 0x94d3b949UL, 0x090481f0UL,
- 0xb1b8e695UL, 0xa30d497bUL, 0x1bb12e1eUL, 0x43d23e48UL, 0xfb6e592dUL,
- 0xe9dbf6c3UL, 0x516791a6UL, 0xccb0a91fUL, 0x740cce7aUL, 0x66b96194UL,
- 0xde0506f1UL
- },
- {
- 0x00000000UL, 0x96300777UL, 0x2c610eeeUL, 0xba510999UL, 0x19c46d07UL,
- 0x8ff46a70UL, 0x35a563e9UL, 0xa395649eUL, 0x3288db0eUL, 0xa4b8dc79UL,
- 0x1ee9d5e0UL, 0x88d9d297UL, 0x2b4cb609UL, 0xbd7cb17eUL, 0x072db8e7UL,
- 0x911dbf90UL, 0x6410b71dUL, 0xf220b06aUL, 0x4871b9f3UL, 0xde41be84UL,
- 0x7dd4da1aUL, 0xebe4dd6dUL, 0x51b5d4f4UL, 0xc785d383UL, 0x56986c13UL,
- 0xc0a86b64UL, 0x7af962fdUL, 0xecc9658aUL, 0x4f5c0114UL, 0xd96c0663UL,
- 0x633d0ffaUL, 0xf50d088dUL, 0xc8206e3bUL, 0x5e10694cUL, 0xe44160d5UL,
- 0x727167a2UL, 0xd1e4033cUL, 0x47d4044bUL, 0xfd850dd2UL, 0x6bb50aa5UL,
- 0xfaa8b535UL, 0x6c98b242UL, 0xd6c9bbdbUL, 0x40f9bcacUL, 0xe36cd832UL,
- 0x755cdf45UL, 0xcf0dd6dcUL, 0x593dd1abUL, 0xac30d926UL, 0x3a00de51UL,
- 0x8051d7c8UL, 0x1661d0bfUL, 0xb5f4b421UL, 0x23c4b356UL, 0x9995bacfUL,
- 0x0fa5bdb8UL, 0x9eb80228UL, 0x0888055fUL, 0xb2d90cc6UL, 0x24e90bb1UL,
- 0x877c6f2fUL, 0x114c6858UL, 0xab1d61c1UL, 0x3d2d66b6UL, 0x9041dc76UL,
- 0x0671db01UL, 0xbc20d298UL, 0x2a10d5efUL, 0x8985b171UL, 0x1fb5b606UL,
- 0xa5e4bf9fUL, 0x33d4b8e8UL, 0xa2c90778UL, 0x34f9000fUL, 0x8ea80996UL,
- 0x18980ee1UL, 0xbb0d6a7fUL, 0x2d3d6d08UL, 0x976c6491UL, 0x015c63e6UL,
- 0xf4516b6bUL, 0x62616c1cUL, 0xd8306585UL, 0x4e0062f2UL, 0xed95066cUL,
- 0x7ba5011bUL, 0xc1f40882UL, 0x57c40ff5UL, 0xc6d9b065UL, 0x50e9b712UL,
- 0xeab8be8bUL, 0x7c88b9fcUL, 0xdf1ddd62UL, 0x492dda15UL, 0xf37cd38cUL,
- 0x654cd4fbUL, 0x5861b24dUL, 0xce51b53aUL, 0x7400bca3UL, 0xe230bbd4UL,
- 0x41a5df4aUL, 0xd795d83dUL, 0x6dc4d1a4UL, 0xfbf4d6d3UL, 0x6ae96943UL,
- 0xfcd96e34UL, 0x468867adUL, 0xd0b860daUL, 0x732d0444UL, 0xe51d0333UL,
- 0x5f4c0aaaUL, 0xc97c0dddUL, 0x3c710550UL, 0xaa410227UL, 0x10100bbeUL,
- 0x86200cc9UL, 0x25b56857UL, 0xb3856f20UL, 0x09d466b9UL, 0x9fe461ceUL,
- 0x0ef9de5eUL, 0x98c9d929UL, 0x2298d0b0UL, 0xb4a8d7c7UL, 0x173db359UL,
- 0x810db42eUL, 0x3b5cbdb7UL, 0xad6cbac0UL, 0x2083b8edUL, 0xb6b3bf9aUL,
- 0x0ce2b603UL, 0x9ad2b174UL, 0x3947d5eaUL, 0xaf77d29dUL, 0x1526db04UL,
- 0x8316dc73UL, 0x120b63e3UL, 0x843b6494UL, 0x3e6a6d0dUL, 0xa85a6a7aUL,
- 0x0bcf0ee4UL, 0x9dff0993UL, 0x27ae000aUL, 0xb19e077dUL, 0x44930ff0UL,
- 0xd2a30887UL, 0x68f2011eUL, 0xfec20669UL, 0x5d5762f7UL, 0xcb676580UL,
- 0x71366c19UL, 0xe7066b6eUL, 0x761bd4feUL, 0xe02bd389UL, 0x5a7ada10UL,
- 0xcc4add67UL, 0x6fdfb9f9UL, 0xf9efbe8eUL, 0x43beb717UL, 0xd58eb060UL,
- 0xe8a3d6d6UL, 0x7e93d1a1UL, 0xc4c2d838UL, 0x52f2df4fUL, 0xf167bbd1UL,
- 0x6757bca6UL, 0xdd06b53fUL, 0x4b36b248UL, 0xda2b0dd8UL, 0x4c1b0aafUL,
- 0xf64a0336UL, 0x607a0441UL, 0xc3ef60dfUL, 0x55df67a8UL, 0xef8e6e31UL,
- 0x79be6946UL, 0x8cb361cbUL, 0x1a8366bcUL, 0xa0d26f25UL, 0x36e26852UL,
- 0x95770cccUL, 0x03470bbbUL, 0xb9160222UL, 0x2f260555UL, 0xbe3bbac5UL,
- 0x280bbdb2UL, 0x925ab42bUL, 0x046ab35cUL, 0xa7ffd7c2UL, 0x31cfd0b5UL,
- 0x8b9ed92cUL, 0x1daede5bUL, 0xb0c2649bUL, 0x26f263ecUL, 0x9ca36a75UL,
- 0x0a936d02UL, 0xa906099cUL, 0x3f360eebUL, 0x85670772UL, 0x13570005UL,
- 0x824abf95UL, 0x147ab8e2UL, 0xae2bb17bUL, 0x381bb60cUL, 0x9b8ed292UL,
- 0x0dbed5e5UL, 0xb7efdc7cUL, 0x21dfdb0bUL, 0xd4d2d386UL, 0x42e2d4f1UL,
- 0xf8b3dd68UL, 0x6e83da1fUL, 0xcd16be81UL, 0x5b26b9f6UL, 0xe177b06fUL,
- 0x7747b718UL, 0xe65a0888UL, 0x706a0fffUL, 0xca3b0666UL, 0x5c0b0111UL,
- 0xff9e658fUL, 0x69ae62f8UL, 0xd3ff6b61UL, 0x45cf6c16UL, 0x78e20aa0UL,
- 0xeed20dd7UL, 0x5483044eUL, 0xc2b30339UL, 0x612667a7UL, 0xf71660d0UL,
- 0x4d476949UL, 0xdb776e3eUL, 0x4a6ad1aeUL, 0xdc5ad6d9UL, 0x660bdf40UL,
- 0xf03bd837UL, 0x53aebca9UL, 0xc59ebbdeUL, 0x7fcfb247UL, 0xe9ffb530UL,
- 0x1cf2bdbdUL, 0x8ac2bacaUL, 0x3093b353UL, 0xa6a3b424UL, 0x0536d0baUL,
- 0x9306d7cdUL, 0x2957de54UL, 0xbf67d923UL, 0x2e7a66b3UL, 0xb84a61c4UL,
- 0x021b685dUL, 0x942b6f2aUL, 0x37be0bb4UL, 0xa18e0cc3UL, 0x1bdf055aUL,
- 0x8def022dUL
- },
- {
- 0x00000000UL, 0x41311b19UL, 0x82623632UL, 0xc3532d2bUL, 0x04c56c64UL,
- 0x45f4777dUL, 0x86a75a56UL, 0xc796414fUL, 0x088ad9c8UL, 0x49bbc2d1UL,
- 0x8ae8effaUL, 0xcbd9f4e3UL, 0x0c4fb5acUL, 0x4d7eaeb5UL, 0x8e2d839eUL,
- 0xcf1c9887UL, 0x5112c24aUL, 0x1023d953UL, 0xd370f478UL, 0x9241ef61UL,
- 0x55d7ae2eUL, 0x14e6b537UL, 0xd7b5981cUL, 0x96848305UL, 0x59981b82UL,
- 0x18a9009bUL, 0xdbfa2db0UL, 0x9acb36a9UL, 0x5d5d77e6UL, 0x1c6c6cffUL,
- 0xdf3f41d4UL, 0x9e0e5acdUL, 0xa2248495UL, 0xe3159f8cUL, 0x2046b2a7UL,
- 0x6177a9beUL, 0xa6e1e8f1UL, 0xe7d0f3e8UL, 0x2483dec3UL, 0x65b2c5daUL,
- 0xaaae5d5dUL, 0xeb9f4644UL, 0x28cc6b6fUL, 0x69fd7076UL, 0xae6b3139UL,
- 0xef5a2a20UL, 0x2c09070bUL, 0x6d381c12UL, 0xf33646dfUL, 0xb2075dc6UL,
- 0x715470edUL, 0x30656bf4UL, 0xf7f32abbUL, 0xb6c231a2UL, 0x75911c89UL,
- 0x34a00790UL, 0xfbbc9f17UL, 0xba8d840eUL, 0x79dea925UL, 0x38efb23cUL,
- 0xff79f373UL, 0xbe48e86aUL, 0x7d1bc541UL, 0x3c2ade58UL, 0x054f79f0UL,
- 0x447e62e9UL, 0x872d4fc2UL, 0xc61c54dbUL, 0x018a1594UL, 0x40bb0e8dUL,
- 0x83e823a6UL, 0xc2d938bfUL, 0x0dc5a038UL, 0x4cf4bb21UL, 0x8fa7960aUL,
- 0xce968d13UL, 0x0900cc5cUL, 0x4831d745UL, 0x8b62fa6eUL, 0xca53e177UL,
- 0x545dbbbaUL, 0x156ca0a3UL, 0xd63f8d88UL, 0x970e9691UL, 0x5098d7deUL,
- 0x11a9ccc7UL, 0xd2fae1ecUL, 0x93cbfaf5UL, 0x5cd76272UL, 0x1de6796bUL,
- 0xdeb55440UL, 0x9f844f59UL, 0x58120e16UL, 0x1923150fUL, 0xda703824UL,
- 0x9b41233dUL, 0xa76bfd65UL, 0xe65ae67cUL, 0x2509cb57UL, 0x6438d04eUL,
- 0xa3ae9101UL, 0xe29f8a18UL, 0x21cca733UL, 0x60fdbc2aUL, 0xafe124adUL,
- 0xeed03fb4UL, 0x2d83129fUL, 0x6cb20986UL, 0xab2448c9UL, 0xea1553d0UL,
- 0x29467efbUL, 0x687765e2UL, 0xf6793f2fUL, 0xb7482436UL, 0x741b091dUL,
- 0x352a1204UL, 0xf2bc534bUL, 0xb38d4852UL, 0x70de6579UL, 0x31ef7e60UL,
- 0xfef3e6e7UL, 0xbfc2fdfeUL, 0x7c91d0d5UL, 0x3da0cbccUL, 0xfa368a83UL,
- 0xbb07919aUL, 0x7854bcb1UL, 0x3965a7a8UL, 0x4b98833bUL, 0x0aa99822UL,
- 0xc9fab509UL, 0x88cbae10UL, 0x4f5def5fUL, 0x0e6cf446UL, 0xcd3fd96dUL,
- 0x8c0ec274UL, 0x43125af3UL, 0x022341eaUL, 0xc1706cc1UL, 0x804177d8UL,
- 0x47d73697UL, 0x06e62d8eUL, 0xc5b500a5UL, 0x84841bbcUL, 0x1a8a4171UL,
- 0x5bbb5a68UL, 0x98e87743UL, 0xd9d96c5aUL, 0x1e4f2d15UL, 0x5f7e360cUL,
- 0x9c2d1b27UL, 0xdd1c003eUL, 0x120098b9UL, 0x533183a0UL, 0x9062ae8bUL,
- 0xd153b592UL, 0x16c5f4ddUL, 0x57f4efc4UL, 0x94a7c2efUL, 0xd596d9f6UL,
- 0xe9bc07aeUL, 0xa88d1cb7UL, 0x6bde319cUL, 0x2aef2a85UL, 0xed796bcaUL,
- 0xac4870d3UL, 0x6f1b5df8UL, 0x2e2a46e1UL, 0xe136de66UL, 0xa007c57fUL,
- 0x6354e854UL, 0x2265f34dUL, 0xe5f3b202UL, 0xa4c2a91bUL, 0x67918430UL,
- 0x26a09f29UL, 0xb8aec5e4UL, 0xf99fdefdUL, 0x3accf3d6UL, 0x7bfde8cfUL,
- 0xbc6ba980UL, 0xfd5ab299UL, 0x3e099fb2UL, 0x7f3884abUL, 0xb0241c2cUL,
- 0xf1150735UL, 0x32462a1eUL, 0x73773107UL, 0xb4e17048UL, 0xf5d06b51UL,
- 0x3683467aUL, 0x77b25d63UL, 0x4ed7facbUL, 0x0fe6e1d2UL, 0xccb5ccf9UL,
- 0x8d84d7e0UL, 0x4a1296afUL, 0x0b238db6UL, 0xc870a09dUL, 0x8941bb84UL,
- 0x465d2303UL, 0x076c381aUL, 0xc43f1531UL, 0x850e0e28UL, 0x42984f67UL,
- 0x03a9547eUL, 0xc0fa7955UL, 0x81cb624cUL, 0x1fc53881UL, 0x5ef42398UL,
- 0x9da70eb3UL, 0xdc9615aaUL, 0x1b0054e5UL, 0x5a314ffcUL, 0x996262d7UL,
- 0xd85379ceUL, 0x174fe149UL, 0x567efa50UL, 0x952dd77bUL, 0xd41ccc62UL,
- 0x138a8d2dUL, 0x52bb9634UL, 0x91e8bb1fUL, 0xd0d9a006UL, 0xecf37e5eUL,
- 0xadc26547UL, 0x6e91486cUL, 0x2fa05375UL, 0xe836123aUL, 0xa9070923UL,
- 0x6a542408UL, 0x2b653f11UL, 0xe479a796UL, 0xa548bc8fUL, 0x661b91a4UL,
- 0x272a8abdUL, 0xe0bccbf2UL, 0xa18dd0ebUL, 0x62defdc0UL, 0x23efe6d9UL,
- 0xbde1bc14UL, 0xfcd0a70dUL, 0x3f838a26UL, 0x7eb2913fUL, 0xb924d070UL,
- 0xf815cb69UL, 0x3b46e642UL, 0x7a77fd5bUL, 0xb56b65dcUL, 0xf45a7ec5UL,
- 0x370953eeUL, 0x763848f7UL, 0xb1ae09b8UL, 0xf09f12a1UL, 0x33cc3f8aUL,
- 0x72fd2493UL
- },
- {
- 0x00000000UL, 0x376ac201UL, 0x6ed48403UL, 0x59be4602UL, 0xdca80907UL,
- 0xebc2cb06UL, 0xb27c8d04UL, 0x85164f05UL, 0xb851130eUL, 0x8f3bd10fUL,
- 0xd685970dUL, 0xe1ef550cUL, 0x64f91a09UL, 0x5393d808UL, 0x0a2d9e0aUL,
- 0x3d475c0bUL, 0x70a3261cUL, 0x47c9e41dUL, 0x1e77a21fUL, 0x291d601eUL,
- 0xac0b2f1bUL, 0x9b61ed1aUL, 0xc2dfab18UL, 0xf5b56919UL, 0xc8f23512UL,
- 0xff98f713UL, 0xa626b111UL, 0x914c7310UL, 0x145a3c15UL, 0x2330fe14UL,
- 0x7a8eb816UL, 0x4de47a17UL, 0xe0464d38UL, 0xd72c8f39UL, 0x8e92c93bUL,
- 0xb9f80b3aUL, 0x3cee443fUL, 0x0b84863eUL, 0x523ac03cUL, 0x6550023dUL,
- 0x58175e36UL, 0x6f7d9c37UL, 0x36c3da35UL, 0x01a91834UL, 0x84bf5731UL,
- 0xb3d59530UL, 0xea6bd332UL, 0xdd011133UL, 0x90e56b24UL, 0xa78fa925UL,
- 0xfe31ef27UL, 0xc95b2d26UL, 0x4c4d6223UL, 0x7b27a022UL, 0x2299e620UL,
- 0x15f32421UL, 0x28b4782aUL, 0x1fdeba2bUL, 0x4660fc29UL, 0x710a3e28UL,
- 0xf41c712dUL, 0xc376b32cUL, 0x9ac8f52eUL, 0xada2372fUL, 0xc08d9a70UL,
- 0xf7e75871UL, 0xae591e73UL, 0x9933dc72UL, 0x1c259377UL, 0x2b4f5176UL,
- 0x72f11774UL, 0x459bd575UL, 0x78dc897eUL, 0x4fb64b7fUL, 0x16080d7dUL,
- 0x2162cf7cUL, 0xa4748079UL, 0x931e4278UL, 0xcaa0047aUL, 0xfdcac67bUL,
- 0xb02ebc6cUL, 0x87447e6dUL, 0xdefa386fUL, 0xe990fa6eUL, 0x6c86b56bUL,
- 0x5bec776aUL, 0x02523168UL, 0x3538f369UL, 0x087faf62UL, 0x3f156d63UL,
- 0x66ab2b61UL, 0x51c1e960UL, 0xd4d7a665UL, 0xe3bd6464UL, 0xba032266UL,
- 0x8d69e067UL, 0x20cbd748UL, 0x17a11549UL, 0x4e1f534bUL, 0x7975914aUL,
- 0xfc63de4fUL, 0xcb091c4eUL, 0x92b75a4cUL, 0xa5dd984dUL, 0x989ac446UL,
- 0xaff00647UL, 0xf64e4045UL, 0xc1248244UL, 0x4432cd41UL, 0x73580f40UL,
- 0x2ae64942UL, 0x1d8c8b43UL, 0x5068f154UL, 0x67023355UL, 0x3ebc7557UL,
- 0x09d6b756UL, 0x8cc0f853UL, 0xbbaa3a52UL, 0xe2147c50UL, 0xd57ebe51UL,
- 0xe839e25aUL, 0xdf53205bUL, 0x86ed6659UL, 0xb187a458UL, 0x3491eb5dUL,
- 0x03fb295cUL, 0x5a456f5eUL, 0x6d2fad5fUL, 0x801b35e1UL, 0xb771f7e0UL,
- 0xeecfb1e2UL, 0xd9a573e3UL, 0x5cb33ce6UL, 0x6bd9fee7UL, 0x3267b8e5UL,
- 0x050d7ae4UL, 0x384a26efUL, 0x0f20e4eeUL, 0x569ea2ecUL, 0x61f460edUL,
- 0xe4e22fe8UL, 0xd388ede9UL, 0x8a36abebUL, 0xbd5c69eaUL, 0xf0b813fdUL,
- 0xc7d2d1fcUL, 0x9e6c97feUL, 0xa90655ffUL, 0x2c101afaUL, 0x1b7ad8fbUL,
- 0x42c49ef9UL, 0x75ae5cf8UL, 0x48e900f3UL, 0x7f83c2f2UL, 0x263d84f0UL,
- 0x115746f1UL, 0x944109f4UL, 0xa32bcbf5UL, 0xfa958df7UL, 0xcdff4ff6UL,
- 0x605d78d9UL, 0x5737bad8UL, 0x0e89fcdaUL, 0x39e33edbUL, 0xbcf571deUL,
- 0x8b9fb3dfUL, 0xd221f5ddUL, 0xe54b37dcUL, 0xd80c6bd7UL, 0xef66a9d6UL,
- 0xb6d8efd4UL, 0x81b22dd5UL, 0x04a462d0UL, 0x33cea0d1UL, 0x6a70e6d3UL,
- 0x5d1a24d2UL, 0x10fe5ec5UL, 0x27949cc4UL, 0x7e2adac6UL, 0x494018c7UL,
- 0xcc5657c2UL, 0xfb3c95c3UL, 0xa282d3c1UL, 0x95e811c0UL, 0xa8af4dcbUL,
- 0x9fc58fcaUL, 0xc67bc9c8UL, 0xf1110bc9UL, 0x740744ccUL, 0x436d86cdUL,
- 0x1ad3c0cfUL, 0x2db902ceUL, 0x4096af91UL, 0x77fc6d90UL, 0x2e422b92UL,
- 0x1928e993UL, 0x9c3ea696UL, 0xab546497UL, 0xf2ea2295UL, 0xc580e094UL,
- 0xf8c7bc9fUL, 0xcfad7e9eUL, 0x9613389cUL, 0xa179fa9dUL, 0x246fb598UL,
- 0x13057799UL, 0x4abb319bUL, 0x7dd1f39aUL, 0x3035898dUL, 0x075f4b8cUL,
- 0x5ee10d8eUL, 0x698bcf8fUL, 0xec9d808aUL, 0xdbf7428bUL, 0x82490489UL,
- 0xb523c688UL, 0x88649a83UL, 0xbf0e5882UL, 0xe6b01e80UL, 0xd1dadc81UL,
- 0x54cc9384UL, 0x63a65185UL, 0x3a181787UL, 0x0d72d586UL, 0xa0d0e2a9UL,
- 0x97ba20a8UL, 0xce0466aaUL, 0xf96ea4abUL, 0x7c78ebaeUL, 0x4b1229afUL,
- 0x12ac6fadUL, 0x25c6adacUL, 0x1881f1a7UL, 0x2feb33a6UL, 0x765575a4UL,
- 0x413fb7a5UL, 0xc429f8a0UL, 0xf3433aa1UL, 0xaafd7ca3UL, 0x9d97bea2UL,
- 0xd073c4b5UL, 0xe71906b4UL, 0xbea740b6UL, 0x89cd82b7UL, 0x0cdbcdb2UL,
- 0x3bb10fb3UL, 0x620f49b1UL, 0x55658bb0UL, 0x6822d7bbUL, 0x5f4815baUL,
- 0x06f653b8UL, 0x319c91b9UL, 0xb48adebcUL, 0x83e01cbdUL, 0xda5e5abfUL,
- 0xed3498beUL
- },
- {
- 0x00000000UL, 0x6567bcb8UL, 0x8bc809aaUL, 0xeeafb512UL, 0x5797628fUL,
- 0x32f0de37UL, 0xdc5f6b25UL, 0xb938d79dUL, 0xef28b4c5UL, 0x8a4f087dUL,
- 0x64e0bd6fUL, 0x018701d7UL, 0xb8bfd64aUL, 0xddd86af2UL, 0x3377dfe0UL,
- 0x56106358UL, 0x9f571950UL, 0xfa30a5e8UL, 0x149f10faUL, 0x71f8ac42UL,
- 0xc8c07bdfUL, 0xada7c767UL, 0x43087275UL, 0x266fcecdUL, 0x707fad95UL,
- 0x1518112dUL, 0xfbb7a43fUL, 0x9ed01887UL, 0x27e8cf1aUL, 0x428f73a2UL,
- 0xac20c6b0UL, 0xc9477a08UL, 0x3eaf32a0UL, 0x5bc88e18UL, 0xb5673b0aUL,
- 0xd00087b2UL, 0x6938502fUL, 0x0c5fec97UL, 0xe2f05985UL, 0x8797e53dUL,
- 0xd1878665UL, 0xb4e03addUL, 0x5a4f8fcfUL, 0x3f283377UL, 0x8610e4eaUL,
- 0xe3775852UL, 0x0dd8ed40UL, 0x68bf51f8UL, 0xa1f82bf0UL, 0xc49f9748UL,
- 0x2a30225aUL, 0x4f579ee2UL, 0xf66f497fUL, 0x9308f5c7UL, 0x7da740d5UL,
- 0x18c0fc6dUL, 0x4ed09f35UL, 0x2bb7238dUL, 0xc518969fUL, 0xa07f2a27UL,
- 0x1947fdbaUL, 0x7c204102UL, 0x928ff410UL, 0xf7e848a8UL, 0x3d58149bUL,
- 0x583fa823UL, 0xb6901d31UL, 0xd3f7a189UL, 0x6acf7614UL, 0x0fa8caacUL,
- 0xe1077fbeUL, 0x8460c306UL, 0xd270a05eUL, 0xb7171ce6UL, 0x59b8a9f4UL,
- 0x3cdf154cUL, 0x85e7c2d1UL, 0xe0807e69UL, 0x0e2fcb7bUL, 0x6b4877c3UL,
- 0xa20f0dcbUL, 0xc768b173UL, 0x29c70461UL, 0x4ca0b8d9UL, 0xf5986f44UL,
- 0x90ffd3fcUL, 0x7e5066eeUL, 0x1b37da56UL, 0x4d27b90eUL, 0x284005b6UL,
- 0xc6efb0a4UL, 0xa3880c1cUL, 0x1ab0db81UL, 0x7fd76739UL, 0x9178d22bUL,
- 0xf41f6e93UL, 0x03f7263bUL, 0x66909a83UL, 0x883f2f91UL, 0xed589329UL,
- 0x546044b4UL, 0x3107f80cUL, 0xdfa84d1eUL, 0xbacff1a6UL, 0xecdf92feUL,
- 0x89b82e46UL, 0x67179b54UL, 0x027027ecUL, 0xbb48f071UL, 0xde2f4cc9UL,
- 0x3080f9dbUL, 0x55e74563UL, 0x9ca03f6bUL, 0xf9c783d3UL, 0x176836c1UL,
- 0x720f8a79UL, 0xcb375de4UL, 0xae50e15cUL, 0x40ff544eUL, 0x2598e8f6UL,
- 0x73888baeUL, 0x16ef3716UL, 0xf8408204UL, 0x9d273ebcUL, 0x241fe921UL,
- 0x41785599UL, 0xafd7e08bUL, 0xcab05c33UL, 0x3bb659edUL, 0x5ed1e555UL,
- 0xb07e5047UL, 0xd519ecffUL, 0x6c213b62UL, 0x094687daUL, 0xe7e932c8UL,
- 0x828e8e70UL, 0xd49eed28UL, 0xb1f95190UL, 0x5f56e482UL, 0x3a31583aUL,
- 0x83098fa7UL, 0xe66e331fUL, 0x08c1860dUL, 0x6da63ab5UL, 0xa4e140bdUL,
- 0xc186fc05UL, 0x2f294917UL, 0x4a4ef5afUL, 0xf3762232UL, 0x96119e8aUL,
- 0x78be2b98UL, 0x1dd99720UL, 0x4bc9f478UL, 0x2eae48c0UL, 0xc001fdd2UL,
- 0xa566416aUL, 0x1c5e96f7UL, 0x79392a4fUL, 0x97969f5dUL, 0xf2f123e5UL,
- 0x05196b4dUL, 0x607ed7f5UL, 0x8ed162e7UL, 0xebb6de5fUL, 0x528e09c2UL,
- 0x37e9b57aUL, 0xd9460068UL, 0xbc21bcd0UL, 0xea31df88UL, 0x8f566330UL,
- 0x61f9d622UL, 0x049e6a9aUL, 0xbda6bd07UL, 0xd8c101bfUL, 0x366eb4adUL,
- 0x53090815UL, 0x9a4e721dUL, 0xff29cea5UL, 0x11867bb7UL, 0x74e1c70fUL,
- 0xcdd91092UL, 0xa8beac2aUL, 0x46111938UL, 0x2376a580UL, 0x7566c6d8UL,
- 0x10017a60UL, 0xfeaecf72UL, 0x9bc973caUL, 0x22f1a457UL, 0x479618efUL,
- 0xa939adfdUL, 0xcc5e1145UL, 0x06ee4d76UL, 0x6389f1ceUL, 0x8d2644dcUL,
- 0xe841f864UL, 0x51792ff9UL, 0x341e9341UL, 0xdab12653UL, 0xbfd69aebUL,
- 0xe9c6f9b3UL, 0x8ca1450bUL, 0x620ef019UL, 0x07694ca1UL, 0xbe519b3cUL,
- 0xdb362784UL, 0x35999296UL, 0x50fe2e2eUL, 0x99b95426UL, 0xfcdee89eUL,
- 0x12715d8cUL, 0x7716e134UL, 0xce2e36a9UL, 0xab498a11UL, 0x45e63f03UL,
- 0x208183bbUL, 0x7691e0e3UL, 0x13f65c5bUL, 0xfd59e949UL, 0x983e55f1UL,
- 0x2106826cUL, 0x44613ed4UL, 0xaace8bc6UL, 0xcfa9377eUL, 0x38417fd6UL,
- 0x5d26c36eUL, 0xb389767cUL, 0xd6eecac4UL, 0x6fd61d59UL, 0x0ab1a1e1UL,
- 0xe41e14f3UL, 0x8179a84bUL, 0xd769cb13UL, 0xb20e77abUL, 0x5ca1c2b9UL,
- 0x39c67e01UL, 0x80fea99cUL, 0xe5991524UL, 0x0b36a036UL, 0x6e511c8eUL,
- 0xa7166686UL, 0xc271da3eUL, 0x2cde6f2cUL, 0x49b9d394UL, 0xf0810409UL,
- 0x95e6b8b1UL, 0x7b490da3UL, 0x1e2eb11bUL, 0x483ed243UL, 0x2d596efbUL,
- 0xc3f6dbe9UL, 0xa6916751UL, 0x1fa9b0ccUL, 0x7ace0c74UL, 0x9461b966UL,
- 0xf10605deUL
-#endif
- }
-};
diff --git a/klibc/klibc/zlib/deflate.c b/klibc/klibc/zlib/deflate.c
deleted file mode 100644
index fe07dcb673..0000000000
--- a/klibc/klibc/zlib/deflate.c
+++ /dev/null
@@ -1,1502 +0,0 @@
-/* deflate.c -- compress data using the deflation algorithm
- * Copyright (C) 1995-2003 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/*
- * ALGORITHM
- *
- * The "deflation" process depends on being able to identify portions
- * of the input text which are identical to earlier input (within a
- * sliding window trailing behind the input currently being processed).
- *
- * The most straightforward technique turns out to be the fastest for
- * most input files: try all possible matches and select the longest.
- * The key feature of this algorithm is that insertions into the string
- * dictionary are very simple and thus fast, and deletions are avoided
- * completely. Insertions are performed at each input character, whereas
- * string matches are performed only when the previous match ends. So it
- * is preferable to spend more time in matches to allow very fast string
- * insertions and avoid deletions. The matching algorithm for small
- * strings is inspired from that of Rabin & Karp. A brute force approach
- * is used to find longer strings when a small match has been found.
- * A similar algorithm is used in comic (by Jan-Mark Wams) and freeze
- * (by Leonid Broukhis).
- * A previous version of this file used a more sophisticated algorithm
- * (by Fiala and Greene) which is guaranteed to run in linear amortized
- * time, but has a larger average cost, uses more memory and is patented.
- * However the F&G algorithm may be faster for some highly redundant
- * files if the parameter max_chain_length (described below) is too large.
- *
- * ACKNOWLEDGEMENTS
- *
- * The idea of lazy evaluation of matches is due to Jan-Mark Wams, and
- * I found it in 'freeze' written by Leonid Broukhis.
- * Thanks to many people for bug reports and testing.
- *
- * REFERENCES
- *
- * Deutsch, L.P.,"DEFLATE Compressed Data Format Specification".
- * Available in http://www.ietf.org/rfc/rfc1951.txt
- *
- * A description of the Rabin and Karp algorithm is given in the book
- * "Algorithms" by R. Sedgewick, Addison-Wesley, p252.
- *
- * Fiala,E.R., and Greene,D.H.
- * Data Compression with Finite Windows, Comm.ACM, 32,4 (1989) 490-595
- *
- */
-
-/* @(#) $Id: deflate.c,v 1.1 2005/02/27 23:15:39 hpa Exp $ */
-
-#include "deflate.h"
-
-const char deflate_copyright[] =
- " deflate 1.2.1 Copyright 1995-2003 Jean-loup Gailly ";
-/*
- If you use the zlib library in a product, an acknowledgment is welcome
- in the documentation of your product. If for some reason you cannot
- include such an acknowledgment, I would appreciate that you keep this
- copyright string in the executable of your product.
- */
-
-/* ===========================================================================
- * Function prototypes.
- */
-typedef enum {
- need_more, /* block not completed, need more input or more output */
- block_done, /* block flush performed */
- finish_started, /* finish started, need only more output at next deflate */
- finish_done /* finish done, accept no more input or output */
-} block_state;
-
-typedef block_state (*compress_func) OF((deflate_state *s, int flush));
-/* Compression function. Returns the block state after the call. */
-
-local void fill_window OF((deflate_state *s));
-local block_state deflate_stored OF((deflate_state *s, int flush));
-local block_state deflate_fast OF((deflate_state *s, int flush));
-#ifndef FASTEST
-local block_state deflate_slow OF((deflate_state *s, int flush));
-#endif
-local void lm_init OF((deflate_state *s));
-local void putShortMSB OF((deflate_state *s, uInt b));
-local void flush_pending OF((z_streamp strm));
-local int read_buf OF((z_streamp strm, Bytef *buf, unsigned size));
-#ifndef FASTEST
-#ifdef ASMV
- void match_init OF((void)); /* asm code initialization */
- uInt longest_match OF((deflate_state *s, IPos cur_match));
-#else
-local uInt longest_match OF((deflate_state *s, IPos cur_match));
-#endif
-#endif
-local uInt longest_match_fast OF((deflate_state *s, IPos cur_match));
-
-#ifdef DEBUG
-local void check_match OF((deflate_state *s, IPos start, IPos match,
- int length));
-#endif
-
-/* ===========================================================================
- * Local data
- */
-
-#define NIL 0
-/* Tail of hash chains */
-
-#ifndef TOO_FAR
-# define TOO_FAR 4096
-#endif
-/* Matches of length 3 are discarded if their distance exceeds TOO_FAR */
-
-#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1)
-/* Minimum amount of lookahead, except at the end of the input file.
- * See deflate.c for comments about the MIN_MATCH+1.
- */
-
-/* Values for max_lazy_match, good_match and max_chain_length, depending on
- * the desired pack level (0..9). The values given below have been tuned to
- * exclude worst case performance for pathological files. Better values may be
- * found for specific files.
- */
-typedef struct config_s {
- ush good_length; /* reduce lazy search above this match length */
- ush max_lazy; /* do not perform lazy search above this match length */
- ush nice_length; /* quit search above this match length */
- ush max_chain;
- compress_func func;
-} config;
-
-#ifdef FASTEST
-local const config configuration_table[2] = {
-/* good lazy nice chain */
-/* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */
-/* 1 */ {4, 4, 8, 4, deflate_fast}}; /* max speed, no lazy matches */
-#else
-local const config configuration_table[10] = {
-/* good lazy nice chain */
-/* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */
-/* 1 */ {4, 4, 8, 4, deflate_fast}, /* max speed, no lazy matches */
-/* 2 */ {4, 5, 16, 8, deflate_fast},
-/* 3 */ {4, 6, 32, 32, deflate_fast},
-
-/* 4 */ {4, 4, 16, 16, deflate_slow}, /* lazy matches */
-/* 5 */ {8, 16, 32, 32, deflate_slow},
-/* 6 */ {8, 16, 128, 128, deflate_slow},
-/* 7 */ {8, 32, 128, 256, deflate_slow},
-/* 8 */ {32, 128, 258, 1024, deflate_slow},
-/* 9 */ {32, 258, 258, 4096, deflate_slow}}; /* max compression */
-#endif
-
-/* Note: the deflate() code requires max_lazy >= MIN_MATCH and max_chain >= 4
- * For deflate_fast() (levels <= 3) good is ignored and lazy has a different
- * meaning.
- */
-
-#define EQUAL 0
-/* result of memcmp for equal strings */
-
-#ifndef NO_DUMMY_DECL
-struct static_tree_desc_s {int dummy;}; /* for buggy compilers */
-#endif
-
-/* ===========================================================================
- * Update a hash value with the given input byte
- * IN assertion: all calls to to UPDATE_HASH are made with consecutive
- * input characters, so that a running hash key can be computed from the
- * previous key instead of complete recalculation each time.
- */
-#define UPDATE_HASH(s,h,c) (h = (((h)<<s->hash_shift) ^ (c)) & s->hash_mask)
-
-
-/* ===========================================================================
- * Insert string str in the dictionary and set match_head to the previous head
- * of the hash chain (the most recent string with same hash key). Return
- * the previous length of the hash chain.
- * If this file is compiled with -DFASTEST, the compression level is forced
- * to 1, and no hash chains are maintained.
- * IN assertion: all calls to to INSERT_STRING are made with consecutive
- * input characters and the first MIN_MATCH bytes of str are valid
- * (except for the last MIN_MATCH-1 bytes of the input file).
- */
-#ifdef FASTEST
-#define INSERT_STRING(s, str, match_head) \
- (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \
- match_head = s->head[s->ins_h], \
- s->head[s->ins_h] = (Pos)(str))
-#else
-#define INSERT_STRING(s, str, match_head) \
- (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \
- match_head = s->prev[(str) & s->w_mask] = s->head[s->ins_h], \
- s->head[s->ins_h] = (Pos)(str))
-#endif
-
-/* ===========================================================================
- * Initialize the hash table (avoiding 64K overflow for 16 bit systems).
- * prev[] will be initialized on the fly.
- */
-#define CLEAR_HASH(s) \
- s->head[s->hash_size-1] = NIL; \
- zmemzero((Bytef *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head));
-
-/* ========================================================================= */
-int ZEXPORT deflateInit_(strm, level, version, stream_size)
- z_streamp strm;
- int level;
- const char *version;
- int stream_size;
-{
- return deflateInit2_(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL,
- Z_DEFAULT_STRATEGY, version, stream_size);
- /* To do: ignore strm->next_in if we use it as window */
-}
-
-/* ========================================================================= */
-int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
- version, stream_size)
- z_streamp strm;
- int level;
- int method;
- int windowBits;
- int memLevel;
- int strategy;
- const char *version;
- int stream_size;
-{
- deflate_state *s;
- int wrap = 1;
- static const char my_version[] = ZLIB_VERSION;
-
- ushf *overlay;
- /* We overlay pending_buf and d_buf+l_buf. This works since the average
- * output size for (length,distance) codes is <= 24 bits.
- */
-
- if (version == Z_NULL || version[0] != my_version[0] ||
- stream_size != sizeof(z_stream)) {
- return Z_VERSION_ERROR;
- }
- if (strm == Z_NULL) return Z_STREAM_ERROR;
-
- strm->msg = Z_NULL;
- if (strm->zalloc == (alloc_func)0) {
- strm->zalloc = zcalloc;
- strm->opaque = (voidpf)0;
- }
- if (strm->zfree == (free_func)0) strm->zfree = zcfree;
-
-#ifdef FASTEST
- if (level != 0) level = 1;
-#else
- if (level == Z_DEFAULT_COMPRESSION) level = 6;
-#endif
-
- if (windowBits < 0) { /* suppress zlib wrapper */
- wrap = 0;
- windowBits = -windowBits;
- }
-#ifdef GZIP
- else if (windowBits > 15) {
- wrap = 2; /* write gzip wrapper instead */
- windowBits -= 16;
- }
-#endif
- if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED ||
- windowBits < 8 || windowBits > 15 || level < 0 || level > 9 ||
- strategy < 0 || strategy > Z_RLE) {
- return Z_STREAM_ERROR;
- }
- if (windowBits == 8) windowBits = 9; /* until 256-byte window bug fixed */
- s = (deflate_state *) ZALLOC(strm, 1, sizeof(deflate_state));
- if (s == Z_NULL) return Z_MEM_ERROR;
- strm->state = (struct internal_state FAR *)s;
- s->strm = strm;
-
- s->wrap = wrap;
- s->w_bits = windowBits;
- s->w_size = 1 << s->w_bits;
- s->w_mask = s->w_size - 1;
-
- s->hash_bits = memLevel + 7;
- s->hash_size = 1 << s->hash_bits;
- s->hash_mask = s->hash_size - 1;
- s->hash_shift = ((s->hash_bits+MIN_MATCH-1)/MIN_MATCH);
-
- s->window = (Bytef *) ZALLOC(strm, s->w_size, 2*sizeof(Byte));
- s->prev = (Posf *) ZALLOC(strm, s->w_size, sizeof(Pos));
- s->head = (Posf *) ZALLOC(strm, s->hash_size, sizeof(Pos));
-
- s->lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */
-
- overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2);
- s->pending_buf = (uchf *) overlay;
- s->pending_buf_size = (ulg)s->lit_bufsize * (sizeof(ush)+2L);
-
- if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL ||
- s->pending_buf == Z_NULL) {
- s->status = FINISH_STATE;
- strm->msg = (char*)ERR_MSG(Z_MEM_ERROR);
- deflateEnd (strm);
- return Z_MEM_ERROR;
- }
- s->d_buf = overlay + s->lit_bufsize/sizeof(ush);
- s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize;
-
- s->level = level;
- s->strategy = strategy;
- s->method = (Byte)method;
-
- return deflateReset(strm);
-}
-
-/* ========================================================================= */
-int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength)
- z_streamp strm;
- const Bytef *dictionary;
- uInt dictLength;
-{
- deflate_state *s;
- uInt length = dictLength;
- uInt n;
- IPos hash_head = 0;
-
- if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL ||
- strm->state->wrap == 2 ||
- (strm->state->wrap == 1 && strm->state->status != INIT_STATE))
- return Z_STREAM_ERROR;
-
- s = strm->state;
- if (s->wrap)
- strm->adler = adler32(strm->adler, dictionary, dictLength);
-
- if (length < MIN_MATCH) return Z_OK;
- if (length > MAX_DIST(s)) {
- length = MAX_DIST(s);
-#ifndef USE_DICT_HEAD
- dictionary += dictLength - length; /* use the tail of the dictionary */
-#endif
- }
- zmemcpy(s->window, dictionary, length);
- s->strstart = length;
- s->block_start = (long)length;
-
- /* Insert all strings in the hash table (except for the last two bytes).
- * s->lookahead stays null, so s->ins_h will be recomputed at the next
- * call of fill_window.
- */
- s->ins_h = s->window[0];
- UPDATE_HASH(s, s->ins_h, s->window[1]);
- for (n = 0; n <= length - MIN_MATCH; n++) {
- INSERT_STRING(s, n, hash_head);
- }
- if (hash_head) hash_head = 0; /* to make compiler happy */
- return Z_OK;
-}
-
-/* ========================================================================= */
-int ZEXPORT deflateReset (strm)
- z_streamp strm;
-{
- deflate_state *s;
-
- if (strm == Z_NULL || strm->state == Z_NULL ||
- strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) {
- return Z_STREAM_ERROR;
- }
-
- strm->total_in = strm->total_out = 0;
- strm->msg = Z_NULL; /* use zfree if we ever allocate msg dynamically */
- strm->data_type = Z_UNKNOWN;
-
- s = (deflate_state *)strm->state;
- s->pending = 0;
- s->pending_out = s->pending_buf;
-
- if (s->wrap < 0) {
- s->wrap = -s->wrap; /* was made negative by deflate(..., Z_FINISH); */
- }
- s->status = s->wrap ? INIT_STATE : BUSY_STATE;
- strm->adler =
-#ifdef GZIP
- s->wrap == 2 ? crc32(0L, Z_NULL, 0) :
-#endif
- adler32(0L, Z_NULL, 0);
- s->last_flush = Z_NO_FLUSH;
-
- _tr_init(s);
- lm_init(s);
-
- return Z_OK;
-}
-
-/* ========================================================================= */
-int ZEXPORT deflatePrime (strm, bits, value)
- z_streamp strm;
- int bits;
- int value;
-{
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
- strm->state->bi_valid = bits;
- strm->state->bi_buf = (ush)(value & ((1 << bits) - 1));
- return Z_OK;
-}
-
-/* ========================================================================= */
-int ZEXPORT deflateParams(strm, level, strategy)
- z_streamp strm;
- int level;
- int strategy;
-{
- deflate_state *s;
- compress_func func;
- int err = Z_OK;
-
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
- s = strm->state;
-
-#ifdef FASTEST
- if (level != 0) level = 1;
-#else
- if (level == Z_DEFAULT_COMPRESSION) level = 6;
-#endif
- if (level < 0 || level > 9 || strategy < 0 || strategy > Z_RLE) {
- return Z_STREAM_ERROR;
- }
- func = configuration_table[s->level].func;
-
- if (func != configuration_table[level].func && strm->total_in != 0) {
- /* Flush the last buffer: */
- err = deflate(strm, Z_PARTIAL_FLUSH);
- }
- if (s->level != level) {
- s->level = level;
- s->max_lazy_match = configuration_table[level].max_lazy;
- s->good_match = configuration_table[level].good_length;
- s->nice_match = configuration_table[level].nice_length;
- s->max_chain_length = configuration_table[level].max_chain;
- }
- s->strategy = strategy;
- return err;
-}
-
-/* =========================================================================
- * For the default windowBits of 15 and memLevel of 8, this function returns
- * a close to exact, as well as small, upper bound on the compressed size.
- * They are coded as constants here for a reason--if the #define's are
- * changed, then this function needs to be changed as well. The return
- * value for 15 and 8 only works for those exact settings.
- *
- * For any setting other than those defaults for windowBits and memLevel,
- * the value returned is a conservative worst case for the maximum expansion
- * resulting from using fixed blocks instead of stored blocks, which deflate
- * can emit on compressed data for some combinations of the parameters.
- *
- * This function could be more sophisticated to provide closer upper bounds
- * for every combination of windowBits and memLevel, as well as wrap.
- * But even the conservative upper bound of about 14% expansion does not
- * seem onerous for output buffer allocation.
- */
-uLong ZEXPORT deflateBound(strm, sourceLen)
- z_streamp strm;
- uLong sourceLen;
-{
- deflate_state *s;
- uLong destLen;
-
- /* conservative upper bound */
- destLen = sourceLen +
- ((sourceLen + 7) >> 3) + ((sourceLen + 63) >> 6) + 11;
-
- /* if can't get parameters, return conservative bound */
- if (strm == Z_NULL || strm->state == Z_NULL)
- return destLen;
-
- /* if not default parameters, return conservative bound */
- s = strm->state;
- if (s->w_bits != 15 || s->hash_bits != 8 + 7)
- return destLen;
-
- /* default settings: return tight bound for that case */
- return compressBound(sourceLen);
-}
-
-/* =========================================================================
- * Put a short in the pending buffer. The 16-bit value is put in MSB order.
- * IN assertion: the stream state is correct and there is enough room in
- * pending_buf.
- */
-local void putShortMSB (s, b)
- deflate_state *s;
- uInt b;
-{
- put_byte(s, (Byte)(b >> 8));
- put_byte(s, (Byte)(b & 0xff));
-}
-
-/* =========================================================================
- * Flush as much pending output as possible. All deflate() output goes
- * through this function so some applications may wish to modify it
- * to avoid allocating a large strm->next_out buffer and copying into it.
- * (See also read_buf()).
- */
-local void flush_pending(strm)
- z_streamp strm;
-{
- unsigned len = strm->state->pending;
-
- if (len > strm->avail_out) len = strm->avail_out;
- if (len == 0) return;
-
- zmemcpy(strm->next_out, strm->state->pending_out, len);
- strm->next_out += len;
- strm->state->pending_out += len;
- strm->total_out += len;
- strm->avail_out -= len;
- strm->state->pending -= len;
- if (strm->state->pending == 0) {
- strm->state->pending_out = strm->state->pending_buf;
- }
-}
-
-/* ========================================================================= */
-int ZEXPORT deflate (strm, flush)
- z_streamp strm;
- int flush;
-{
- int old_flush; /* value of flush param for previous deflate call */
- deflate_state *s;
-
- if (strm == Z_NULL || strm->state == Z_NULL ||
- flush > Z_FINISH || flush < 0) {
- return Z_STREAM_ERROR;
- }
- s = strm->state;
-
- if (strm->next_out == Z_NULL ||
- (strm->next_in == Z_NULL && strm->avail_in != 0) ||
- (s->status == FINISH_STATE && flush != Z_FINISH)) {
- ERR_RETURN(strm, Z_STREAM_ERROR);
- }
- if (strm->avail_out == 0) ERR_RETURN(strm, Z_BUF_ERROR);
-
- s->strm = strm; /* just in case */
- old_flush = s->last_flush;
- s->last_flush = flush;
-
- /* Write the header */
- if (s->status == INIT_STATE) {
-#ifdef GZIP
- if (s->wrap == 2) {
- put_byte(s, 31);
- put_byte(s, 139);
- put_byte(s, 8);
- put_byte(s, 0);
- put_byte(s, 0);
- put_byte(s, 0);
- put_byte(s, 0);
- put_byte(s, 0);
- put_byte(s, s->level == 9 ? 2 :
- (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?
- 4 : 0));
- put_byte(s, 255);
- s->status = BUSY_STATE;
- strm->adler = crc32(0L, Z_NULL, 0);
- }
- else
-#endif
- {
- uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8;
- uInt level_flags;
-
- if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2)
- level_flags = 0;
- else if (s->level < 6)
- level_flags = 1;
- else if (s->level == 6)
- level_flags = 2;
- else
- level_flags = 3;
- header |= (level_flags << 6);
- if (s->strstart != 0) header |= PRESET_DICT;
- header += 31 - (header % 31);
-
- s->status = BUSY_STATE;
- putShortMSB(s, header);
-
- /* Save the adler32 of the preset dictionary: */
- if (s->strstart != 0) {
- putShortMSB(s, (uInt)(strm->adler >> 16));
- putShortMSB(s, (uInt)(strm->adler & 0xffff));
- }
- strm->adler = adler32(0L, Z_NULL, 0);
- }
- }
-
- /* Flush as much pending output as possible */
- if (s->pending != 0) {
- flush_pending(strm);
- if (strm->avail_out == 0) {
- /* Since avail_out is 0, deflate will be called again with
- * more output space, but possibly with both pending and
- * avail_in equal to zero. There won't be anything to do,
- * but this is not an error situation so make sure we
- * return OK instead of BUF_ERROR at next call of deflate:
- */
- s->last_flush = -1;
- return Z_OK;
- }
-
- /* Make sure there is something to do and avoid duplicate consecutive
- * flushes. For repeated and useless calls with Z_FINISH, we keep
- * returning Z_STREAM_END instead of Z_BUF_ERROR.
- */
- } else if (strm->avail_in == 0 && flush <= old_flush &&
- flush != Z_FINISH) {
- ERR_RETURN(strm, Z_BUF_ERROR);
- }
-
- /* User must not provide more input after the first FINISH: */
- if (s->status == FINISH_STATE && strm->avail_in != 0) {
- ERR_RETURN(strm, Z_BUF_ERROR);
- }
-
- /* Start a new block or continue the current one.
- */
- if (strm->avail_in != 0 || s->lookahead != 0 ||
- (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) {
- block_state bstate;
-
- bstate = (*(configuration_table[s->level].func))(s, flush);
-
- if (bstate == finish_started || bstate == finish_done) {
- s->status = FINISH_STATE;
- }
- if (bstate == need_more || bstate == finish_started) {
- if (strm->avail_out == 0) {
- s->last_flush = -1; /* avoid BUF_ERROR next call, see above */
- }
- return Z_OK;
- /* If flush != Z_NO_FLUSH && avail_out == 0, the next call
- * of deflate should use the same flush parameter to make sure
- * that the flush is complete. So we don't have to output an
- * empty block here, this will be done at next call. This also
- * ensures that for a very small output buffer, we emit at most
- * one empty block.
- */
- }
- if (bstate == block_done) {
- if (flush == Z_PARTIAL_FLUSH) {
- _tr_align(s);
- } else { /* FULL_FLUSH or SYNC_FLUSH */
- _tr_stored_block(s, (char*)0, 0L, 0);
- /* For a full flush, this empty block will be recognized
- * as a special marker by inflate_sync().
- */
- if (flush == Z_FULL_FLUSH) {
- CLEAR_HASH(s); /* forget history */
- }
- }
- flush_pending(strm);
- if (strm->avail_out == 0) {
- s->last_flush = -1; /* avoid BUF_ERROR at next call, see above */
- return Z_OK;
- }
- }
- }
- Assert(strm->avail_out > 0, "bug2");
-
- if (flush != Z_FINISH) return Z_OK;
- if (s->wrap <= 0) return Z_STREAM_END;
-
- /* Write the trailer */
-#ifdef GZIP
- if (s->wrap == 2) {
- put_byte(s, (Byte)(strm->adler & 0xff));
- put_byte(s, (Byte)((strm->adler >> 8) & 0xff));
- put_byte(s, (Byte)((strm->adler >> 16) & 0xff));
- put_byte(s, (Byte)((strm->adler >> 24) & 0xff));
- put_byte(s, (Byte)(strm->total_in & 0xff));
- put_byte(s, (Byte)((strm->total_in >> 8) & 0xff));
- put_byte(s, (Byte)((strm->total_in >> 16) & 0xff));
- put_byte(s, (Byte)((strm->total_in >> 24) & 0xff));
- }
- else
-#endif
- {
- putShortMSB(s, (uInt)(strm->adler >> 16));
- putShortMSB(s, (uInt)(strm->adler & 0xffff));
- }
- flush_pending(strm);
- /* If avail_out is zero, the application will call deflate again
- * to flush the rest.
- */
- if (s->wrap > 0) s->wrap = -s->wrap; /* write the trailer only once! */
- return s->pending != 0 ? Z_OK : Z_STREAM_END;
-}
-
-/* ========================================================================= */
-int ZEXPORT deflateEnd (strm)
- z_streamp strm;
-{
- int status;
-
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
-
- status = strm->state->status;
- if (status != INIT_STATE && status != BUSY_STATE &&
- status != FINISH_STATE) {
- return Z_STREAM_ERROR;
- }
-
- /* Deallocate in reverse order of allocations: */
- TRY_FREE(strm, strm->state->pending_buf);
- TRY_FREE(strm, strm->state->head);
- TRY_FREE(strm, strm->state->prev);
- TRY_FREE(strm, strm->state->window);
-
- ZFREE(strm, strm->state);
- strm->state = Z_NULL;
-
- return status == BUSY_STATE ? Z_DATA_ERROR : Z_OK;
-}
-
-/* =========================================================================
- * Copy the source state to the destination state.
- * To simplify the source, this is not supported for 16-bit MSDOS (which
- * doesn't have enough memory anyway to duplicate compression states).
- */
-int ZEXPORT deflateCopy (dest, source)
- z_streamp dest;
- z_streamp source;
-{
-#ifdef MAXSEG_64K
- return Z_STREAM_ERROR;
-#else
- deflate_state *ds;
- deflate_state *ss;
- ushf *overlay;
-
-
- if (source == Z_NULL || dest == Z_NULL || source->state == Z_NULL) {
- return Z_STREAM_ERROR;
- }
-
- ss = source->state;
-
- *dest = *source;
-
- ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state));
- if (ds == Z_NULL) return Z_MEM_ERROR;
- dest->state = (struct internal_state FAR *) ds;
- *ds = *ss;
- ds->strm = dest;
-
- ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte));
- ds->prev = (Posf *) ZALLOC(dest, ds->w_size, sizeof(Pos));
- ds->head = (Posf *) ZALLOC(dest, ds->hash_size, sizeof(Pos));
- overlay = (ushf *) ZALLOC(dest, ds->lit_bufsize, sizeof(ush)+2);
- ds->pending_buf = (uchf *) overlay;
-
- if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL ||
- ds->pending_buf == Z_NULL) {
- deflateEnd (dest);
- return Z_MEM_ERROR;
- }
- /* following zmemcpy do not work for 16-bit MSDOS */
- zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte));
- zmemcpy(ds->prev, ss->prev, ds->w_size * sizeof(Pos));
- zmemcpy(ds->head, ss->head, ds->hash_size * sizeof(Pos));
- zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size);
-
- ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf);
- ds->d_buf = overlay + ds->lit_bufsize/sizeof(ush);
- ds->l_buf = ds->pending_buf + (1+sizeof(ush))*ds->lit_bufsize;
-
- ds->l_desc.dyn_tree = ds->dyn_ltree;
- ds->d_desc.dyn_tree = ds->dyn_dtree;
- ds->bl_desc.dyn_tree = ds->bl_tree;
-
- return Z_OK;
-#endif /* MAXSEG_64K */
-}
-
-/* ===========================================================================
- * Read a new buffer from the current input stream, update the adler32
- * and total number of bytes read. All deflate() input goes through
- * this function so some applications may wish to modify it to avoid
- * allocating a large strm->next_in buffer and copying from it.
- * (See also flush_pending()).
- */
-local int read_buf(strm, buf, size)
- z_streamp strm;
- Bytef *buf;
- unsigned size;
-{
- unsigned len = strm->avail_in;
-
- if (len > size) len = size;
- if (len == 0) return 0;
-
- strm->avail_in -= len;
-
- if (strm->state->wrap == 1) {
- strm->adler = adler32(strm->adler, strm->next_in, len);
- }
-#ifdef GZIP
- else if (strm->state->wrap == 2) {
- strm->adler = crc32(strm->adler, strm->next_in, len);
- }
-#endif
- zmemcpy(buf, strm->next_in, len);
- strm->next_in += len;
- strm->total_in += len;
-
- return (int)len;
-}
-
-/* ===========================================================================
- * Initialize the "longest match" routines for a new zlib stream
- */
-local void lm_init (s)
- deflate_state *s;
-{
- s->window_size = (ulg)2L*s->w_size;
-
- CLEAR_HASH(s);
-
- /* Set the default configuration parameters:
- */
- s->max_lazy_match = configuration_table[s->level].max_lazy;
- s->good_match = configuration_table[s->level].good_length;
- s->nice_match = configuration_table[s->level].nice_length;
- s->max_chain_length = configuration_table[s->level].max_chain;
-
- s->strstart = 0;
- s->block_start = 0L;
- s->lookahead = 0;
- s->match_length = s->prev_length = MIN_MATCH-1;
- s->match_available = 0;
- s->ins_h = 0;
-#ifdef ASMV
- match_init(); /* initialize the asm code */
-#endif
-}
-
-#ifndef FASTEST
-/* ===========================================================================
- * Set match_start to the longest match starting at the given string and
- * return its length. Matches shorter or equal to prev_length are discarded,
- * in which case the result is equal to prev_length and match_start is
- * garbage.
- * IN assertions: cur_match is the head of the hash chain for the current
- * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1
- * OUT assertion: the match length is not greater than s->lookahead.
- */
-#ifndef ASMV
-/* For 80x86 and 680x0, an optimized version will be provided in match.asm or
- * match.S. The code will be functionally equivalent.
- */
-local uInt longest_match(s, cur_match)
- deflate_state *s;
- IPos cur_match; /* current match */
-{
- unsigned chain_length = s->max_chain_length;/* max hash chain length */
- register Bytef *scan = s->window + s->strstart; /* current string */
- register Bytef *match; /* matched string */
- register int len; /* length of current match */
- int best_len = s->prev_length; /* best match length so far */
- int nice_match = s->nice_match; /* stop if match long enough */
- IPos limit = s->strstart > (IPos)MAX_DIST(s) ?
- s->strstart - (IPos)MAX_DIST(s) : NIL;
- /* Stop when cur_match becomes <= limit. To simplify the code,
- * we prevent matches with the string of window index 0.
- */
- Posf *prev = s->prev;
- uInt wmask = s->w_mask;
-
-#ifdef UNALIGNED_OK
- /* Compare two bytes at a time. Note: this is not always beneficial.
- * Try with and without -DUNALIGNED_OK to check.
- */
- register Bytef *strend = s->window + s->strstart + MAX_MATCH - 1;
- register ush scan_start = *(ushf*)scan;
- register ush scan_end = *(ushf*)(scan+best_len-1);
-#else
- register Bytef *strend = s->window + s->strstart + MAX_MATCH;
- register Byte scan_end1 = scan[best_len-1];
- register Byte scan_end = scan[best_len];
-#endif
-
- /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.
- * It is easy to get rid of this optimization if necessary.
- */
- Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever");
-
- /* Do not waste too much time if we already have a good match: */
- if (s->prev_length >= s->good_match) {
- chain_length >>= 2;
- }
- /* Do not look for matches beyond the end of the input. This is necessary
- * to make deflate deterministic.
- */
- if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead;
-
- Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead");
-
- do {
- Assert(cur_match < s->strstart, "no future");
- match = s->window + cur_match;
-
- /* Skip to next match if the match length cannot increase
- * or if the match length is less than 2:
- */
-#if (defined(UNALIGNED_OK) && MAX_MATCH == 258)
- /* This code assumes sizeof(unsigned short) == 2. Do not use
- * UNALIGNED_OK if your compiler uses a different size.
- */
- if (*(ushf*)(match+best_len-1) != scan_end ||
- *(ushf*)match != scan_start) continue;
-
- /* It is not necessary to compare scan[2] and match[2] since they are
- * always equal when the other bytes match, given that the hash keys
- * are equal and that HASH_BITS >= 8. Compare 2 bytes at a time at
- * strstart+3, +5, ... up to strstart+257. We check for insufficient
- * lookahead only every 4th comparison; the 128th check will be made
- * at strstart+257. If MAX_MATCH-2 is not a multiple of 8, it is
- * necessary to put more guard bytes at the end of the window, or
- * to check more often for insufficient lookahead.
- */
- Assert(scan[2] == match[2], "scan[2]?");
- scan++, match++;
- do {
- } while (*(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
- *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
- *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
- *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
- scan < strend);
- /* The funny "do {}" generates better code on most compilers */
-
- /* Here, scan <= window+strstart+257 */
- Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
- if (*scan == *match) scan++;
-
- len = (MAX_MATCH - 1) - (int)(strend-scan);
- scan = strend - (MAX_MATCH-1);
-
-#else /* UNALIGNED_OK */
-
- if (match[best_len] != scan_end ||
- match[best_len-1] != scan_end1 ||
- *match != *scan ||
- *++match != scan[1]) continue;
-
- /* The check at best_len-1 can be removed because it will be made
- * again later. (This heuristic is not always a win.)
- * It is not necessary to compare scan[2] and match[2] since they
- * are always equal when the other bytes match, given that
- * the hash keys are equal and that HASH_BITS >= 8.
- */
- scan += 2, match++;
- Assert(*scan == *match, "match[2]?");
-
- /* We check for insufficient lookahead only every 8th comparison;
- * the 256th check will be made at strstart+258.
- */
- do {
- } while (*++scan == *++match && *++scan == *++match &&
- *++scan == *++match && *++scan == *++match &&
- *++scan == *++match && *++scan == *++match &&
- *++scan == *++match && *++scan == *++match &&
- scan < strend);
-
- Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
-
- len = MAX_MATCH - (int)(strend - scan);
- scan = strend - MAX_MATCH;
-
-#endif /* UNALIGNED_OK */
-
- if (len > best_len) {
- s->match_start = cur_match;
- best_len = len;
- if (len >= nice_match) break;
-#ifdef UNALIGNED_OK
- scan_end = *(ushf*)(scan+best_len-1);
-#else
- scan_end1 = scan[best_len-1];
- scan_end = scan[best_len];
-#endif
- }
- } while ((cur_match = prev[cur_match & wmask]) > limit
- && --chain_length != 0);
-
- if ((uInt)best_len <= s->lookahead) return (uInt)best_len;
- return s->lookahead;
-}
-#endif /* ASMV */
-#endif /* FASTEST */
-
-/* ---------------------------------------------------------------------------
- * Optimized version for level == 1 or strategy == Z_RLE only
- */
-local uInt longest_match_fast(s, cur_match)
- deflate_state *s;
- IPos cur_match; /* current match */
-{
- register Bytef *scan = s->window + s->strstart; /* current string */
- register Bytef *match; /* matched string */
- register int len; /* length of current match */
- register Bytef *strend = s->window + s->strstart + MAX_MATCH;
-
- /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.
- * It is easy to get rid of this optimization if necessary.
- */
- Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever");
-
- Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead");
-
- Assert(cur_match < s->strstart, "no future");
-
- match = s->window + cur_match;
-
- /* Return failure if the match length is less than 2:
- */
- if (match[0] != scan[0] || match[1] != scan[1]) return MIN_MATCH-1;
-
- /* The check at best_len-1 can be removed because it will be made
- * again later. (This heuristic is not always a win.)
- * It is not necessary to compare scan[2] and match[2] since they
- * are always equal when the other bytes match, given that
- * the hash keys are equal and that HASH_BITS >= 8.
- */
- scan += 2, match += 2;
- Assert(*scan == *match, "match[2]?");
-
- /* We check for insufficient lookahead only every 8th comparison;
- * the 256th check will be made at strstart+258.
- */
- do {
- } while (*++scan == *++match && *++scan == *++match &&
- *++scan == *++match && *++scan == *++match &&
- *++scan == *++match && *++scan == *++match &&
- *++scan == *++match && *++scan == *++match &&
- scan < strend);
-
- Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
-
- len = MAX_MATCH - (int)(strend - scan);
-
- if (len < MIN_MATCH) return MIN_MATCH - 1;
-
- s->match_start = cur_match;
- return (uInt)len <= s->lookahead ? (uInt)len : s->lookahead;
-}
-
-#ifdef DEBUG
-/* ===========================================================================
- * Check that the match at match_start is indeed a match.
- */
-local void check_match(s, start, match, length)
- deflate_state *s;
- IPos start, match;
- int length;
-{
- /* check that the match is indeed a match */
- if (zmemcmp(s->window + match,
- s->window + start, length) != EQUAL) {
- fprintf(stderr, " start %u, match %u, length %d\n",
- start, match, length);
- do {
- fprintf(stderr, "%c%c", s->window[match++], s->window[start++]);
- } while (--length != 0);
- z_error("invalid match");
- }
- if (z_verbose > 1) {
- fprintf(stderr,"\\[%d,%d]", start-match, length);
- do { putc(s->window[start++], stderr); } while (--length != 0);
- }
-}
-#else
-# define check_match(s, start, match, length)
-#endif /* DEBUG */
-
-/* ===========================================================================
- * Fill the window when the lookahead becomes insufficient.
- * Updates strstart and lookahead.
- *
- * IN assertion: lookahead < MIN_LOOKAHEAD
- * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD
- * At least one byte has been read, or avail_in == 0; reads are
- * performed for at least two bytes (required for the zip translate_eol
- * option -- not supported here).
- */
-local void fill_window(s)
- deflate_state *s;
-{
- register unsigned n, m;
- register Posf *p;
- unsigned more; /* Amount of free space at the end of the window. */
- uInt wsize = s->w_size;
-
- do {
- more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart);
-
- /* Deal with !@#$% 64K limit: */
- if (sizeof(int) <= 2) {
- if (more == 0 && s->strstart == 0 && s->lookahead == 0) {
- more = wsize;
-
- } else if (more == (unsigned)(-1)) {
- /* Very unlikely, but possible on 16 bit machine if
- * strstart == 0 && lookahead == 1 (input done a byte at time)
- */
- more--;
- }
- }
-
- /* If the window is almost full and there is insufficient lookahead,
- * move the upper half to the lower one to make room in the upper half.
- */
- if (s->strstart >= wsize+MAX_DIST(s)) {
-
- zmemcpy(s->window, s->window+wsize, (unsigned)wsize);
- s->match_start -= wsize;
- s->strstart -= wsize; /* we now have strstart >= MAX_DIST */
- s->block_start -= (long) wsize;
-
- /* Slide the hash table (could be avoided with 32 bit values
- at the expense of memory usage). We slide even when level == 0
- to keep the hash table consistent if we switch back to level > 0
- later. (Using level 0 permanently is not an optimal usage of
- zlib, so we don't care about this pathological case.)
- */
- n = s->hash_size;
- p = &s->head[n];
- do {
- m = *--p;
- *p = (Pos)(m >= wsize ? m-wsize : NIL);
- } while (--n);
-
- n = wsize;
-#ifndef FASTEST
- p = &s->prev[n];
- do {
- m = *--p;
- *p = (Pos)(m >= wsize ? m-wsize : NIL);
- /* If n is not on any hash chain, prev[n] is garbage but
- * its value will never be used.
- */
- } while (--n);
-#endif
- more += wsize;
- }
- if (s->strm->avail_in == 0) return;
-
- /* If there was no sliding:
- * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 &&
- * more == window_size - lookahead - strstart
- * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1)
- * => more >= window_size - 2*WSIZE + 2
- * In the BIG_MEM or MMAP case (not yet supported),
- * window_size == input_size + MIN_LOOKAHEAD &&
- * strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD.
- * Otherwise, window_size == 2*WSIZE so more >= 2.
- * If there was sliding, more >= WSIZE. So in all cases, more >= 2.
- */
- Assert(more >= 2, "more < 2");
-
- n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more);
- s->lookahead += n;
-
- /* Initialize the hash value now that we have some input: */
- if (s->lookahead >= MIN_MATCH) {
- s->ins_h = s->window[s->strstart];
- UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]);
-#if MIN_MATCH != 3
- Call UPDATE_HASH() MIN_MATCH-3 more times
-#endif
- }
- /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage,
- * but this is not important since only literal bytes will be emitted.
- */
-
- } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0);
-}
-
-/* ===========================================================================
- * Flush the current block, with given end-of-file flag.
- * IN assertion: strstart is set to the end of the current match.
- */
-#define FLUSH_BLOCK_ONLY(s, eof) { \
- _tr_flush_block(s, (s->block_start >= 0L ? \
- (charf *)&s->window[(unsigned)s->block_start] : \
- (charf *)Z_NULL), \
- (ulg)((long)s->strstart - s->block_start), \
- (eof)); \
- s->block_start = s->strstart; \
- flush_pending(s->strm); \
- Tracev((stderr,"[FLUSH]")); \
-}
-
-/* Same but force premature exit if necessary. */
-#define FLUSH_BLOCK(s, eof) { \
- FLUSH_BLOCK_ONLY(s, eof); \
- if (s->strm->avail_out == 0) return (eof) ? finish_started : need_more; \
-}
-
-/* ===========================================================================
- * Copy without compression as much as possible from the input stream, return
- * the current block state.
- * This function does not insert new strings in the dictionary since
- * uncompressible data is probably not useful. This function is used
- * only for the level=0 compression option.
- * NOTE: this function should be optimized to avoid extra copying from
- * window to pending_buf.
- */
-local block_state deflate_stored(s, flush)
- deflate_state *s;
- int flush;
-{
- /* Stored blocks are limited to 0xffff bytes, pending_buf is limited
- * to pending_buf_size, and each stored block has a 5 byte header:
- */
- ulg max_block_size = 0xffff;
- ulg max_start;
-
- if (max_block_size > s->pending_buf_size - 5) {
- max_block_size = s->pending_buf_size - 5;
- }
-
- /* Copy as much as possible from input to output: */
- for (;;) {
- /* Fill the window as much as possible: */
- if (s->lookahead <= 1) {
-
- Assert(s->strstart < s->w_size+MAX_DIST(s) ||
- s->block_start >= (long)s->w_size, "slide too late");
-
- fill_window(s);
- if (s->lookahead == 0 && flush == Z_NO_FLUSH) return need_more;
-
- if (s->lookahead == 0) break; /* flush the current block */
- }
- Assert(s->block_start >= 0L, "block gone");
-
- s->strstart += s->lookahead;
- s->lookahead = 0;
-
- /* Emit a stored block if pending_buf will be full: */
- max_start = s->block_start + max_block_size;
- if (s->strstart == 0 || (ulg)s->strstart >= max_start) {
- /* strstart == 0 is possible when wraparound on 16-bit machine */
- s->lookahead = (uInt)(s->strstart - max_start);
- s->strstart = (uInt)max_start;
- FLUSH_BLOCK(s, 0);
- }
- /* Flush if we may have to slide, otherwise block_start may become
- * negative and the data will be gone:
- */
- if (s->strstart - (uInt)s->block_start >= MAX_DIST(s)) {
- FLUSH_BLOCK(s, 0);
- }
- }
- FLUSH_BLOCK(s, flush == Z_FINISH);
- return flush == Z_FINISH ? finish_done : block_done;
-}
-
-/* ===========================================================================
- * Compress as much as possible from the input stream, return the current
- * block state.
- * This function does not perform lazy evaluation of matches and inserts
- * new strings in the dictionary only for unmatched strings or for short
- * matches. It is used only for the fast compression options.
- */
-local block_state deflate_fast(s, flush)
- deflate_state *s;
- int flush;
-{
- IPos hash_head = NIL; /* head of the hash chain */
- int bflush; /* set if current block must be flushed */
-
- for (;;) {
- /* Make sure that we always have enough lookahead, except
- * at the end of the input file. We need MAX_MATCH bytes
- * for the next match, plus MIN_MATCH bytes to insert the
- * string following the next match.
- */
- if (s->lookahead < MIN_LOOKAHEAD) {
- fill_window(s);
- if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {
- return need_more;
- }
- if (s->lookahead == 0) break; /* flush the current block */
- }
-
- /* Insert the string window[strstart .. strstart+2] in the
- * dictionary, and set hash_head to the head of the hash chain:
- */
- if (s->lookahead >= MIN_MATCH) {
- INSERT_STRING(s, s->strstart, hash_head);
- }
-
- /* Find the longest match, discarding those <= prev_length.
- * At this point we have always match_length < MIN_MATCH
- */
- if (hash_head != NIL && s->strstart - hash_head <= MAX_DIST(s)) {
- /* To simplify the code, we prevent matches with the string
- * of window index 0 (in particular we have to avoid a match
- * of the string with itself at the start of the input file).
- */
-#ifdef FASTEST
- if ((s->strategy < Z_HUFFMAN_ONLY) ||
- (s->strategy == Z_RLE && s->strstart - hash_head == 1)) {
- s->match_length = longest_match_fast (s, hash_head);
- }
-#else
- if (s->strategy < Z_HUFFMAN_ONLY) {
- s->match_length = longest_match (s, hash_head);
- } else if (s->strategy == Z_RLE && s->strstart - hash_head == 1) {
- s->match_length = longest_match_fast (s, hash_head);
- }
-#endif
- /* longest_match() or longest_match_fast() sets match_start */
- }
- if (s->match_length >= MIN_MATCH) {
- check_match(s, s->strstart, s->match_start, s->match_length);
-
- _tr_tally_dist(s, s->strstart - s->match_start,
- s->match_length - MIN_MATCH, bflush);
-
- s->lookahead -= s->match_length;
-
- /* Insert new strings in the hash table only if the match length
- * is not too large. This saves time but degrades compression.
- */
-#ifndef FASTEST
- if (s->match_length <= s->max_insert_length &&
- s->lookahead >= MIN_MATCH) {
- s->match_length--; /* string at strstart already in table */
- do {
- s->strstart++;
- INSERT_STRING(s, s->strstart, hash_head);
- /* strstart never exceeds WSIZE-MAX_MATCH, so there are
- * always MIN_MATCH bytes ahead.
- */
- } while (--s->match_length != 0);
- s->strstart++;
- } else
-#endif
- {
- s->strstart += s->match_length;
- s->match_length = 0;
- s->ins_h = s->window[s->strstart];
- UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]);
-#if MIN_MATCH != 3
- Call UPDATE_HASH() MIN_MATCH-3 more times
-#endif
- /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not
- * matter since it will be recomputed at next deflate call.
- */
- }
- } else {
- /* No match, output a literal byte */
- Tracevv((stderr,"%c", s->window[s->strstart]));
- _tr_tally_lit (s, s->window[s->strstart], bflush);
- s->lookahead--;
- s->strstart++;
- }
- if (bflush) FLUSH_BLOCK(s, 0);
- }
- FLUSH_BLOCK(s, flush == Z_FINISH);
- return flush == Z_FINISH ? finish_done : block_done;
-}
-
-#ifndef FASTEST
-/* ===========================================================================
- * Same as above, but achieves better compression. We use a lazy
- * evaluation for matches: a match is finally adopted only if there is
- * no better match at the next window position.
- */
-local block_state deflate_slow(s, flush)
- deflate_state *s;
- int flush;
-{
- IPos hash_head = NIL; /* head of hash chain */
- int bflush; /* set if current block must be flushed */
-
- /* Process the input block. */
- for (;;) {
- /* Make sure that we always have enough lookahead, except
- * at the end of the input file. We need MAX_MATCH bytes
- * for the next match, plus MIN_MATCH bytes to insert the
- * string following the next match.
- */
- if (s->lookahead < MIN_LOOKAHEAD) {
- fill_window(s);
- if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {
- return need_more;
- }
- if (s->lookahead == 0) break; /* flush the current block */
- }
-
- /* Insert the string window[strstart .. strstart+2] in the
- * dictionary, and set hash_head to the head of the hash chain:
- */
- if (s->lookahead >= MIN_MATCH) {
- INSERT_STRING(s, s->strstart, hash_head);
- }
-
- /* Find the longest match, discarding those <= prev_length.
- */
- s->prev_length = s->match_length, s->prev_match = s->match_start;
- s->match_length = MIN_MATCH-1;
-
- if (hash_head != NIL && s->prev_length < s->max_lazy_match &&
- s->strstart - hash_head <= MAX_DIST(s)) {
- /* To simplify the code, we prevent matches with the string
- * of window index 0 (in particular we have to avoid a match
- * of the string with itself at the start of the input file).
- */
- if (s->strategy < Z_HUFFMAN_ONLY) {
- s->match_length = longest_match (s, hash_head);
- } else if (s->strategy == Z_RLE && s->strstart - hash_head == 1) {
- s->match_length = longest_match_fast (s, hash_head);
- }
- /* longest_match() or longest_match_fast() sets match_start */
-
- if (s->match_length <= 5 && (s->strategy == Z_FILTERED
-#if TOO_FAR <= 32767
- || (s->match_length == MIN_MATCH &&
- s->strstart - s->match_start > TOO_FAR)
-#endif
- )) {
-
- /* If prev_match is also MIN_MATCH, match_start is garbage
- * but we will ignore the current match anyway.
- */
- s->match_length = MIN_MATCH-1;
- }
- }
- /* If there was a match at the previous step and the current
- * match is not better, output the previous match:
- */
- if (s->prev_length >= MIN_MATCH && s->match_length <= s->prev_length) {
- uInt max_insert = s->strstart + s->lookahead - MIN_MATCH;
- /* Do not insert strings in hash table beyond this. */
-
- check_match(s, s->strstart-1, s->prev_match, s->prev_length);
-
- _tr_tally_dist(s, s->strstart -1 - s->prev_match,
- s->prev_length - MIN_MATCH, bflush);
-
- /* Insert in hash table all strings up to the end of the match.
- * strstart-1 and strstart are already inserted. If there is not
- * enough lookahead, the last two strings are not inserted in
- * the hash table.
- */
- s->lookahead -= s->prev_length-1;
- s->prev_length -= 2;
- do {
- if (++s->strstart <= max_insert) {
- INSERT_STRING(s, s->strstart, hash_head);
- }
- } while (--s->prev_length != 0);
- s->match_available = 0;
- s->match_length = MIN_MATCH-1;
- s->strstart++;
-
- if (bflush) FLUSH_BLOCK(s, 0);
-
- } else if (s->match_available) {
- /* If there was no match at the previous position, output a
- * single literal. If there was a match but the current match
- * is longer, truncate the previous match to a single literal.
- */
- Tracevv((stderr,"%c", s->window[s->strstart-1]));
- _tr_tally_lit(s, s->window[s->strstart-1], bflush);
- if (bflush) {
- FLUSH_BLOCK_ONLY(s, 0);
- }
- s->strstart++;
- s->lookahead--;
- if (s->strm->avail_out == 0) return need_more;
- } else {
- /* There is no previous match to compare with, wait for
- * the next step to decide.
- */
- s->match_available = 1;
- s->strstart++;
- s->lookahead--;
- }
- }
- Assert (flush != Z_NO_FLUSH, "no flush?");
- if (s->match_available) {
- Tracevv((stderr,"%c", s->window[s->strstart-1]));
- _tr_tally_lit(s, s->window[s->strstart-1], bflush);
- s->match_available = 0;
- }
- FLUSH_BLOCK(s, flush == Z_FINISH);
- return flush == Z_FINISH ? finish_done : block_done;
-}
-#endif /* FASTEST */
diff --git a/klibc/klibc/zlib/deflate.h b/klibc/klibc/zlib/deflate.h
deleted file mode 100644
index bc79532e59..0000000000
--- a/klibc/klibc/zlib/deflate.h
+++ /dev/null
@@ -1,326 +0,0 @@
-/* deflate.h -- internal compression state
- * Copyright (C) 1995-2002 Jean-loup Gailly
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* WARNING: this file should *not* be used by applications. It is
- part of the implementation of the compression library and is
- subject to change. Applications should only use zlib.h.
- */
-
-/* @(#) $Id: deflate.h,v 1.1 2005/02/27 23:15:39 hpa Exp $ */
-
-#ifndef DEFLATE_H
-#define DEFLATE_H
-
-#include "zutil.h"
-
-/* define NO_GZIP when compiling if you want to disable gzip header and
- trailer creation by deflate(). NO_GZIP would be used to avoid linking in
- the crc code when it is not needed. For shared libraries, gzip encoding
- should be left enabled. */
-#ifndef NO_GZIP
-# define GZIP
-#endif
-
-/* ===========================================================================
- * Internal compression state.
- */
-
-#define LENGTH_CODES 29
-/* number of length codes, not counting the special END_BLOCK code */
-
-#define LITERALS 256
-/* number of literal bytes 0..255 */
-
-#define L_CODES (LITERALS+1+LENGTH_CODES)
-/* number of Literal or Length codes, including the END_BLOCK code */
-
-#define D_CODES 30
-/* number of distance codes */
-
-#define BL_CODES 19
-/* number of codes used to transfer the bit lengths */
-
-#define HEAP_SIZE (2*L_CODES+1)
-/* maximum heap size */
-
-#define MAX_BITS 15
-/* All codes must not exceed MAX_BITS bits */
-
-#define INIT_STATE 42
-#define BUSY_STATE 113
-#define FINISH_STATE 666
-/* Stream status */
-
-
-/* Data structure describing a single value and its code string. */
-typedef struct ct_data_s {
- union {
- ush freq; /* frequency count */
- ush code; /* bit string */
- } fc;
- union {
- ush dad; /* father node in Huffman tree */
- ush len; /* length of bit string */
- } dl;
-} FAR ct_data;
-
-#define Freq fc.freq
-#define Code fc.code
-#define Dad dl.dad
-#define Len dl.len
-
-typedef struct static_tree_desc_s static_tree_desc;
-
-typedef struct tree_desc_s {
- ct_data *dyn_tree; /* the dynamic tree */
- int max_code; /* largest code with non zero frequency */
- static_tree_desc *stat_desc; /* the corresponding static tree */
-} FAR tree_desc;
-
-typedef ush Pos;
-typedef Pos FAR Posf;
-typedef unsigned IPos;
-
-/* A Pos is an index in the character window. We use short instead of int to
- * save space in the various tables. IPos is used only for parameter passing.
- */
-
-typedef struct internal_state {
- z_streamp strm; /* pointer back to this zlib stream */
- int status; /* as the name implies */
- Bytef *pending_buf; /* output still pending */
- ulg pending_buf_size; /* size of pending_buf */
- Bytef *pending_out; /* next pending byte to output to the stream */
- int pending; /* nb of bytes in the pending buffer */
- int wrap; /* bit 0 true for zlib, bit 1 true for gzip */
- Byte data_type; /* UNKNOWN, BINARY or ASCII */
- Byte method; /* STORED (for zip only) or DEFLATED */
- int last_flush; /* value of flush param for previous deflate call */
-
- /* used by deflate.c: */
-
- uInt w_size; /* LZ77 window size (32K by default) */
- uInt w_bits; /* log2(w_size) (8..16) */
- uInt w_mask; /* w_size - 1 */
-
- Bytef *window;
- /* Sliding window. Input bytes are read into the second half of the window,
- * and move to the first half later to keep a dictionary of at least wSize
- * bytes. With this organization, matches are limited to a distance of
- * wSize-MAX_MATCH bytes, but this ensures that IO is always
- * performed with a length multiple of the block size. Also, it limits
- * the window size to 64K, which is quite useful on MSDOS.
- * To do: use the user input buffer as sliding window.
- */
-
- ulg window_size;
- /* Actual size of window: 2*wSize, except when the user input buffer
- * is directly used as sliding window.
- */
-
- Posf *prev;
- /* Link to older string with same hash index. To limit the size of this
- * array to 64K, this link is maintained only for the last 32K strings.
- * An index in this array is thus a window index modulo 32K.
- */
-
- Posf *head; /* Heads of the hash chains or NIL. */
-
- uInt ins_h; /* hash index of string to be inserted */
- uInt hash_size; /* number of elements in hash table */
- uInt hash_bits; /* log2(hash_size) */
- uInt hash_mask; /* hash_size-1 */
-
- uInt hash_shift;
- /* Number of bits by which ins_h must be shifted at each input
- * step. It must be such that after MIN_MATCH steps, the oldest
- * byte no longer takes part in the hash key, that is:
- * hash_shift * MIN_MATCH >= hash_bits
- */
-
- long block_start;
- /* Window position at the beginning of the current output block. Gets
- * negative when the window is moved backwards.
- */
-
- uInt match_length; /* length of best match */
- IPos prev_match; /* previous match */
- int match_available; /* set if previous match exists */
- uInt strstart; /* start of string to insert */
- uInt match_start; /* start of matching string */
- uInt lookahead; /* number of valid bytes ahead in window */
-
- uInt prev_length;
- /* Length of the best match at previous step. Matches not greater than this
- * are discarded. This is used in the lazy match evaluation.
- */
-
- uInt max_chain_length;
- /* To speed up deflation, hash chains are never searched beyond this
- * length. A higher limit improves compression ratio but degrades the
- * speed.
- */
-
- uInt max_lazy_match;
- /* Attempt to find a better match only when the current match is strictly
- * smaller than this value. This mechanism is used only for compression
- * levels >= 4.
- */
-# define max_insert_length max_lazy_match
- /* Insert new strings in the hash table only if the match length is not
- * greater than this length. This saves time but degrades compression.
- * max_insert_length is used only for compression levels <= 3.
- */
-
- int level; /* compression level (1..9) */
- int strategy; /* favor or force Huffman coding*/
-
- uInt good_match;
- /* Use a faster search when the previous match is longer than this */
-
- int nice_match; /* Stop searching when current match exceeds this */
-
- /* used by trees.c: */
- /* Didn't use ct_data typedef below to supress compiler warning */
- struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */
- struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */
- struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */
-
- struct tree_desc_s l_desc; /* desc. for literal tree */
- struct tree_desc_s d_desc; /* desc. for distance tree */
- struct tree_desc_s bl_desc; /* desc. for bit length tree */
-
- ush bl_count[MAX_BITS+1];
- /* number of codes at each bit length for an optimal tree */
-
- int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */
- int heap_len; /* number of elements in the heap */
- int heap_max; /* element of largest frequency */
- /* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used.
- * The same heap array is used to build all trees.
- */
-
- uch depth[2*L_CODES+1];
- /* Depth of each subtree used as tie breaker for trees of equal frequency
- */
-
- uchf *l_buf; /* buffer for literals or lengths */
-
- uInt lit_bufsize;
- /* Size of match buffer for literals/lengths. There are 4 reasons for
- * limiting lit_bufsize to 64K:
- * - frequencies can be kept in 16 bit counters
- * - if compression is not successful for the first block, all input
- * data is still in the window so we can still emit a stored block even
- * when input comes from standard input. (This can also be done for
- * all blocks if lit_bufsize is not greater than 32K.)
- * - if compression is not successful for a file smaller than 64K, we can
- * even emit a stored file instead of a stored block (saving 5 bytes).
- * This is applicable only for zip (not gzip or zlib).
- * - creating new Huffman trees less frequently may not provide fast
- * adaptation to changes in the input data statistics. (Take for
- * example a binary file with poorly compressible code followed by
- * a highly compressible string table.) Smaller buffer sizes give
- * fast adaptation but have of course the overhead of transmitting
- * trees more frequently.
- * - I can't count above 4
- */
-
- uInt last_lit; /* running index in l_buf */
-
- ushf *d_buf;
- /* Buffer for distances. To simplify the code, d_buf and l_buf have
- * the same number of elements. To use different lengths, an extra flag
- * array would be necessary.
- */
-
- ulg opt_len; /* bit length of current block with optimal trees */
- ulg static_len; /* bit length of current block with static trees */
- uInt matches; /* number of string matches in current block */
- int last_eob_len; /* bit length of EOB code for last block */
-
-#ifdef DEBUG
- ulg compressed_len; /* total bit length of compressed file mod 2^32 */
- ulg bits_sent; /* bit length of compressed data sent mod 2^32 */
-#endif
-
- ush bi_buf;
- /* Output buffer. bits are inserted starting at the bottom (least
- * significant bits).
- */
- int bi_valid;
- /* Number of valid bits in bi_buf. All bits above the last valid bit
- * are always zero.
- */
-
-} FAR deflate_state;
-
-/* Output a byte on the stream.
- * IN assertion: there is enough room in pending_buf.
- */
-#define put_byte(s, c) {s->pending_buf[s->pending++] = (c);}
-
-
-#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1)
-/* Minimum amount of lookahead, except at the end of the input file.
- * See deflate.c for comments about the MIN_MATCH+1.
- */
-
-#define MAX_DIST(s) ((s)->w_size-MIN_LOOKAHEAD)
-/* In order to simplify the code, particularly on 16 bit machines, match
- * distances are limited to MAX_DIST instead of WSIZE.
- */
-
- /* in trees.c */
-void _tr_init OF((deflate_state *s));
-int _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc));
-void _tr_flush_block OF((deflate_state *s, charf *buf, ulg stored_len,
- int eof));
-void _tr_align OF((deflate_state *s));
-void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len,
- int eof));
-
-#define d_code(dist) \
- ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)])
-/* Mapping from a distance to a distance code. dist is the distance - 1 and
- * must not have side effects. _dist_code[256] and _dist_code[257] are never
- * used.
- */
-
-#ifndef DEBUG
-/* Inline versions of _tr_tally for speed: */
-
-#if defined(GEN_TREES_H) || !defined(STDC)
- extern uch _length_code[];
- extern uch _dist_code[];
-#else
- extern const uch _length_code[];
- extern const uch _dist_code[];
-#endif
-
-# define _tr_tally_lit(s, c, flush) \
- { uch cc = (c); \
- s->d_buf[s->last_lit] = 0; \
- s->l_buf[s->last_lit++] = cc; \
- s->dyn_ltree[cc].Freq++; \
- flush = (s->last_lit == s->lit_bufsize-1); \
- }
-# define _tr_tally_dist(s, distance, length, flush) \
- { uch len = (length); \
- ush dist = (distance); \
- s->d_buf[s->last_lit] = dist; \
- s->l_buf[s->last_lit++] = len; \
- dist--; \
- s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \
- s->dyn_dtree[d_code(dist)].Freq++; \
- flush = (s->last_lit == s->lit_bufsize-1); \
- }
-#else
-# define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c)
-# define _tr_tally_dist(s, distance, length, flush) \
- flush = _tr_tally(s, distance, length)
-#endif
-
-#endif /* DEFLATE_H */
diff --git a/klibc/klibc/zlib/gzio.c b/klibc/klibc/zlib/gzio.c
deleted file mode 100644
index cb56b8d381..0000000000
--- a/klibc/klibc/zlib/gzio.c
+++ /dev/null
@@ -1,1008 +0,0 @@
-/* gzio.c -- IO on .gz files
- * Copyright (C) 1995-2003 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
- *
- * Compile this file with -DNO_GZCOMPRESS to avoid the compression code.
- */
-
-/* @(#) $Id: gzio.c,v 1.1 2005/02/27 23:15:39 hpa Exp $ */
-
-#include <stdio.h>
-
-#include "zutil.h"
-
-#ifdef NO_DEFLATE /* for compatiblity with old definition */
-# define NO_GZCOMPRESS
-#endif
-
-#ifndef NO_DUMMY_DECL
-struct internal_state {int dummy;}; /* for buggy compilers */
-#endif
-
-#ifndef Z_BUFSIZE
-# ifdef MAXSEG_64K
-# define Z_BUFSIZE 4096 /* minimize memory usage for 16-bit DOS */
-# else
-# define Z_BUFSIZE 16384
-# endif
-#endif
-#ifndef Z_PRINTF_BUFSIZE
-# define Z_PRINTF_BUFSIZE 4096
-#endif
-
-#ifdef __MVS__
-# pragma map (fdopen , "\174\174FDOPEN")
- FILE *fdopen(int, const char *);
-#endif
-
-#ifndef STDC
-extern voidp malloc OF((uInt size));
-extern void free OF((voidpf ptr));
-#endif
-
-#define ALLOC(size) malloc(size)
-#define TRYFREE(p) {if (p) free(p);}
-
-static int const gz_magic[2] = {0x1f, 0x8b}; /* gzip magic header */
-
-/* gzip flag byte */
-#define ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */
-#define HEAD_CRC 0x02 /* bit 1 set: header CRC present */
-#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */
-#define ORIG_NAME 0x08 /* bit 3 set: original file name present */
-#define COMMENT 0x10 /* bit 4 set: file comment present */
-#define RESERVED 0xE0 /* bits 5..7: reserved */
-
-typedef struct gz_stream {
- z_stream stream;
- int z_err; /* error code for last stream operation */
- int z_eof; /* set if end of input file */
- FILE *file; /* .gz file */
- Byte *inbuf; /* input buffer */
- Byte *outbuf; /* output buffer */
- uLong crc; /* crc32 of uncompressed data */
- char *msg; /* error message */
- char *path; /* path name for debugging only */
- int transparent; /* 1 if input file is not a .gz file */
- char mode; /* 'w' or 'r' */
- z_off_t start; /* start of compressed data in file (header skipped) */
- z_off_t in; /* bytes into deflate or inflate */
- z_off_t out; /* bytes out of deflate or inflate */
- int back; /* one character push-back */
- int last; /* true if push-back is last character */
-} gz_stream;
-
-
-local gzFile gz_open OF((const char *path, const char *mode, int fd));
-local int do_flush OF((gzFile file, int flush));
-local int get_byte OF((gz_stream *s));
-local void check_header OF((gz_stream *s));
-local int destroy OF((gz_stream *s));
-local void putLong OF((FILE *file, uLong x));
-local uLong getLong OF((gz_stream *s));
-
-/* ===========================================================================
- Opens a gzip (.gz) file for reading or writing. The mode parameter
- is as in fopen ("rb" or "wb"). The file is given either by file descriptor
- or path name (if fd == -1).
- gz_open returns NULL if the file could not be opened or if there was
- insufficient memory to allocate the (de)compression state; errno
- can be checked to distinguish the two cases (if errno is zero, the
- zlib error is Z_MEM_ERROR).
-*/
-local gzFile gz_open (path, mode, fd)
- const char *path;
- const char *mode;
- int fd;
-{
- int err;
- int level = Z_DEFAULT_COMPRESSION; /* compression level */
- int strategy = Z_DEFAULT_STRATEGY; /* compression strategy */
- char *p = (char*)mode;
- gz_stream *s;
- char fmode[80]; /* copy of mode, without the compression level */
- char *m = fmode;
-
- if (!path || !mode) return Z_NULL;
-
- s = (gz_stream *)ALLOC(sizeof(gz_stream));
- if (!s) return Z_NULL;
-
- s->stream.zalloc = (alloc_func)0;
- s->stream.zfree = (free_func)0;
- s->stream.opaque = (voidpf)0;
- s->stream.next_in = s->inbuf = Z_NULL;
- s->stream.next_out = s->outbuf = Z_NULL;
- s->stream.avail_in = s->stream.avail_out = 0;
- s->file = NULL;
- s->z_err = Z_OK;
- s->z_eof = 0;
- s->in = 0;
- s->out = 0;
- s->back = EOF;
- s->crc = crc32(0L, Z_NULL, 0);
- s->msg = NULL;
- s->transparent = 0;
-
- s->path = (char*)ALLOC(strlen(path)+1);
- if (s->path == NULL) {
- return destroy(s), (gzFile)Z_NULL;
- }
- strcpy(s->path, path); /* do this early for debugging */
-
- s->mode = '\0';
- do {
- if (*p == 'r') s->mode = 'r';
- if (*p == 'w' || *p == 'a') s->mode = 'w';
- if (*p >= '0' && *p <= '9') {
- level = *p - '0';
- } else if (*p == 'f') {
- strategy = Z_FILTERED;
- } else if (*p == 'h') {
- strategy = Z_HUFFMAN_ONLY;
- } else if (*p == 'R') {
- strategy = Z_RLE;
- } else {
- *m++ = *p; /* copy the mode */
- }
- } while (*p++ && m != fmode + sizeof(fmode));
- if (s->mode == '\0') return destroy(s), (gzFile)Z_NULL;
-
- if (s->mode == 'w') {
-#ifdef NO_GZCOMPRESS
- err = Z_STREAM_ERROR;
-#else
- err = deflateInit2(&(s->stream), level,
- Z_DEFLATED, -MAX_WBITS, DEF_MEM_LEVEL, strategy);
- /* windowBits is passed < 0 to suppress zlib header */
-
- s->stream.next_out = s->outbuf = (Byte*)ALLOC(Z_BUFSIZE);
-#endif
- if (err != Z_OK || s->outbuf == Z_NULL) {
- return destroy(s), (gzFile)Z_NULL;
- }
- } else {
- s->stream.next_in = s->inbuf = (Byte*)ALLOC(Z_BUFSIZE);
-
- err = inflateInit2(&(s->stream), -MAX_WBITS);
- /* windowBits is passed < 0 to tell that there is no zlib header.
- * Note that in this case inflate *requires* an extra "dummy" byte
- * after the compressed stream in order to complete decompression and
- * return Z_STREAM_END. Here the gzip CRC32 ensures that 4 bytes are
- * present after the compressed stream.
- */
- if (err != Z_OK || s->inbuf == Z_NULL) {
- return destroy(s), (gzFile)Z_NULL;
- }
- }
- s->stream.avail_out = Z_BUFSIZE;
-
- errno = 0;
- s->file = fd < 0 ? F_OPEN(path, fmode) : (FILE*)fdopen(fd, fmode);
-
- if (s->file == NULL) {
- return destroy(s), (gzFile)Z_NULL;
- }
- if (s->mode == 'w') {
- /* Write a very simple .gz header:
- */
- fprintf(s->file, "%c%c%c%c%c%c%c%c%c%c", gz_magic[0], gz_magic[1],
- Z_DEFLATED, 0 /*flags*/, 0,0,0,0 /*time*/, 0 /*xflags*/, OS_CODE);
- s->start = 10L;
- /* We use 10L instead of ftell(s->file) to because ftell causes an
- * fflush on some systems. This version of the library doesn't use
- * start anyway in write mode, so this initialization is not
- * necessary.
- */
- } else {
- check_header(s); /* skip the .gz header */
- s->start = ftell(s->file) - s->stream.avail_in;
- }
-
- return (gzFile)s;
-}
-
-/* ===========================================================================
- Opens a gzip (.gz) file for reading or writing.
-*/
-gzFile ZEXPORT gzopen (path, mode)
- const char *path;
- const char *mode;
-{
- return gz_open (path, mode, -1);
-}
-
-/* ===========================================================================
- Associate a gzFile with the file descriptor fd. fd is not dup'ed here
- to mimic the behavio(u)r of fdopen.
-*/
-gzFile ZEXPORT gzdopen (fd, mode)
- int fd;
- const char *mode;
-{
- char name[20];
-
- if (fd < 0) return (gzFile)Z_NULL;
- sprintf(name, "<fd:%d>", fd); /* for debugging */
-
- return gz_open (name, mode, fd);
-}
-
-/* ===========================================================================
- * Update the compression level and strategy
- */
-int ZEXPORT gzsetparams (file, level, strategy)
- gzFile file;
- int level;
- int strategy;
-{
- gz_stream *s = (gz_stream*)file;
-
- if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR;
-
- /* Make room to allow flushing */
- if (s->stream.avail_out == 0) {
-
- s->stream.next_out = s->outbuf;
- if (fwrite(s->outbuf, 1, Z_BUFSIZE, s->file) != Z_BUFSIZE) {
- s->z_err = Z_ERRNO;
- }
- s->stream.avail_out = Z_BUFSIZE;
- }
-
- return deflateParams (&(s->stream), level, strategy);
-}
-
-/* ===========================================================================
- Read a byte from a gz_stream; update next_in and avail_in. Return EOF
- for end of file.
- IN assertion: the stream s has been sucessfully opened for reading.
-*/
-local int get_byte(s)
- gz_stream *s;
-{
- if (s->z_eof) return EOF;
- if (s->stream.avail_in == 0) {
- errno = 0;
- s->stream.avail_in = fread(s->inbuf, 1, Z_BUFSIZE, s->file);
- if (s->stream.avail_in == 0) {
- s->z_eof = 1;
- /* klibc hack */
- if (errno) s->z_err = Z_ERRNO;
- return EOF;
- }
- s->stream.next_in = s->inbuf;
- }
- s->stream.avail_in--;
- return *(s->stream.next_in)++;
-}
-
-/* ===========================================================================
- Check the gzip header of a gz_stream opened for reading. Set the stream
- mode to transparent if the gzip magic header is not present; set s->err
- to Z_DATA_ERROR if the magic header is present but the rest of the header
- is incorrect.
- IN assertion: the stream s has already been created sucessfully;
- s->stream.avail_in is zero for the first time, but may be non-zero
- for concatenated .gz files.
-*/
-local void check_header(s)
- gz_stream *s;
-{
- int method; /* method byte */
- int flags; /* flags byte */
- uInt len;
- int c;
-
- /* Assure two bytes in the buffer so we can peek ahead -- handle case
- where first byte of header is at the end of the buffer after the last
- gzip segment */
- len = s->stream.avail_in;
- if (len < 2) {
- if (len) s->inbuf[0] = s->stream.next_in[0];
- errno = 0;
- len = fread(s->inbuf + len, 1, Z_BUFSIZE >> len, s->file);
- /* klibc hack */
- if (len == 0 && errno) s->z_err = Z_ERRNO;
- s->stream.avail_in += len;
- s->stream.next_in = s->inbuf;
- if (s->stream.avail_in < 2) {
- s->transparent = s->stream.avail_in;
- return;
- }
- }
-
- /* Peek ahead to check the gzip magic header */
- if (s->stream.next_in[0] != gz_magic[0] ||
- s->stream.next_in[1] != gz_magic[1]) {
- s->transparent = 1;
- return;
- }
- s->stream.avail_in -= 2;
- s->stream.next_in += 2;
-
- /* Check the rest of the gzip header */
- method = get_byte(s);
- flags = get_byte(s);
- if (method != Z_DEFLATED || (flags & RESERVED) != 0) {
- s->z_err = Z_DATA_ERROR;
- return;
- }
-
- /* Discard time, xflags and OS code: */
- for (len = 0; len < 6; len++) (void)get_byte(s);
-
- if ((flags & EXTRA_FIELD) != 0) { /* skip the extra field */
- len = (uInt)get_byte(s);
- len += ((uInt)get_byte(s))<<8;
- /* len is garbage if EOF but the loop below will quit anyway */
- while (len-- != 0 && get_byte(s) != EOF) ;
- }
- if ((flags & ORIG_NAME) != 0) { /* skip the original file name */
- while ((c = get_byte(s)) != 0 && c != EOF) ;
- }
- if ((flags & COMMENT) != 0) { /* skip the .gz file comment */
- while ((c = get_byte(s)) != 0 && c != EOF) ;
- }
- if ((flags & HEAD_CRC) != 0) { /* skip the header crc */
- for (len = 0; len < 2; len++) (void)get_byte(s);
- }
- s->z_err = s->z_eof ? Z_DATA_ERROR : Z_OK;
-}
-
- /* ===========================================================================
- * Cleanup then free the given gz_stream. Return a zlib error code.
- Try freeing in the reverse order of allocations.
- */
-local int destroy (s)
- gz_stream *s;
-{
- int err = Z_OK;
-
- if (!s) return Z_STREAM_ERROR;
-
- TRYFREE(s->msg);
-
- if (s->stream.state != NULL) {
- if (s->mode == 'w') {
-#ifdef NO_GZCOMPRESS
- err = Z_STREAM_ERROR;
-#else
- err = deflateEnd(&(s->stream));
-#endif
- } else if (s->mode == 'r') {
- err = inflateEnd(&(s->stream));
- }
- }
- if (s->file != NULL && fclose(s->file)) {
-#ifdef ESPIPE
- if (errno != ESPIPE) /* fclose is broken for pipes in HP/UX */
-#endif
- err = Z_ERRNO;
- }
- if (s->z_err < 0) err = s->z_err;
-
- TRYFREE(s->inbuf);
- TRYFREE(s->outbuf);
- TRYFREE(s->path);
- TRYFREE(s);
- return err;
-}
-
-/* ===========================================================================
- Reads the given number of uncompressed bytes from the compressed file.
- gzread returns the number of bytes actually read (0 for end of file).
-*/
-int ZEXPORT gzread (file, buf, len)
- gzFile file;
- voidp buf;
- unsigned len;
-{
- gz_stream *s = (gz_stream*)file;
- Bytef *start = (Bytef*)buf; /* starting point for crc computation */
- Byte *next_out; /* == stream.next_out but not forced far (for MSDOS) */
-
- if (s == NULL || s->mode != 'r') return Z_STREAM_ERROR;
-
- if (s->z_err == Z_DATA_ERROR || s->z_err == Z_ERRNO) return -1;
- if (s->z_err == Z_STREAM_END) return 0; /* EOF */
-
- next_out = (Byte*)buf;
- s->stream.next_out = (Bytef*)buf;
- s->stream.avail_out = len;
-
- if (s->stream.avail_out && s->back != EOF) {
- *next_out++ = s->back;
- s->stream.next_out++;
- s->stream.avail_out--;
- s->back = EOF;
- s->out++;
- if (s->last) {
- s->z_err = Z_STREAM_END;
- return 1;
- }
- }
-
- while (s->stream.avail_out != 0) {
-
- if (s->transparent) {
- /* Copy first the lookahead bytes: */
- uInt n = s->stream.avail_in;
- if (n > s->stream.avail_out) n = s->stream.avail_out;
- if (n > 0) {
- zmemcpy(s->stream.next_out, s->stream.next_in, n);
- next_out += n;
- s->stream.next_out = next_out;
- s->stream.next_in += n;
- s->stream.avail_out -= n;
- s->stream.avail_in -= n;
- }
- if (s->stream.avail_out > 0) {
- s->stream.avail_out -= fread(next_out, 1, s->stream.avail_out,
- s->file);
- }
- len -= s->stream.avail_out;
- s->in += len;
- s->out += len;
- if (len == 0) s->z_eof = 1;
- return (int)len;
- }
- if (s->stream.avail_in == 0 && !s->z_eof) {
-
- errno = 0;
- s->stream.avail_in = fread(s->inbuf, 1, Z_BUFSIZE, s->file);
- if (s->stream.avail_in == 0) {
- s->z_eof = 1;
- if (errno) {
- s->z_err = Z_ERRNO;
- break;
- }
- }
- s->stream.next_in = s->inbuf;
- }
- s->in += s->stream.avail_in;
- s->out += s->stream.avail_out;
- s->z_err = inflate(&(s->stream), Z_NO_FLUSH);
- s->in -= s->stream.avail_in;
- s->out -= s->stream.avail_out;
-
- if (s->z_err == Z_STREAM_END) {
- /* Check CRC and original size */
- s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start));
- start = s->stream.next_out;
-
- if (getLong(s) != s->crc) {
- s->z_err = Z_DATA_ERROR;
- } else {
- (void)getLong(s);
- /* The uncompressed length returned by above getlong() may be
- * different from s->out in case of concatenated .gz files.
- * Check for such files:
- */
- check_header(s);
- if (s->z_err == Z_OK) {
- inflateReset(&(s->stream));
- s->crc = crc32(0L, Z_NULL, 0);
- }
- }
- }
- if (s->z_err != Z_OK || s->z_eof) break;
- }
- s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start));
-
- return (int)(len - s->stream.avail_out);
-}
-
-
-/* ===========================================================================
- Reads one byte from the compressed file. gzgetc returns this byte
- or -1 in case of end of file or error.
-*/
-int ZEXPORT gzgetc(file)
- gzFile file;
-{
- unsigned char c;
-
- return gzread(file, &c, 1) == 1 ? c : -1;
-}
-
-
-/* ===========================================================================
- Push one byte back onto the stream.
-*/
-int ZEXPORT gzungetc(c, file)
- int c;
- gzFile file;
-{
- gz_stream *s = (gz_stream*)file;
-
- if (s == NULL || s->mode != 'r' || c == EOF || s->back != EOF) return EOF;
- s->back = c;
- s->out--;
- s->last = (s->z_err == Z_STREAM_END);
- if (s->last) s->z_err = Z_OK;
- s->z_eof = 0;
- return c;
-}
-
-
-/* ===========================================================================
- Reads bytes from the compressed file until len-1 characters are
- read, or a newline character is read and transferred to buf, or an
- end-of-file condition is encountered. The string is then terminated
- with a null character.
- gzgets returns buf, or Z_NULL in case of error.
-
- The current implementation is not optimized at all.
-*/
-char * ZEXPORT gzgets(file, buf, len)
- gzFile file;
- char *buf;
- int len;
-{
- char *b = buf;
- if (buf == Z_NULL || len <= 0) return Z_NULL;
-
- while (--len > 0 && gzread(file, buf, 1) == 1 && *buf++ != '\n') ;
- *buf = '\0';
- return b == buf && len > 0 ? Z_NULL : b;
-}
-
-
-#ifndef NO_GZCOMPRESS
-/* ===========================================================================
- Writes the given number of uncompressed bytes into the compressed file.
- gzwrite returns the number of bytes actually written (0 in case of error).
-*/
-int ZEXPORT gzwrite (file, buf, len)
- gzFile file;
- voidpc buf;
- unsigned len;
-{
- gz_stream *s = (gz_stream*)file;
-
- if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR;
-
- s->stream.next_in = (Bytef*)buf;
- s->stream.avail_in = len;
-
- while (s->stream.avail_in != 0) {
-
- if (s->stream.avail_out == 0) {
-
- s->stream.next_out = s->outbuf;
- if (fwrite(s->outbuf, 1, Z_BUFSIZE, s->file) != Z_BUFSIZE) {
- s->z_err = Z_ERRNO;
- break;
- }
- s->stream.avail_out = Z_BUFSIZE;
- }
- s->in += s->stream.avail_in;
- s->out += s->stream.avail_out;
- s->z_err = deflate(&(s->stream), Z_NO_FLUSH);
- s->in -= s->stream.avail_in;
- s->out -= s->stream.avail_out;
- if (s->z_err != Z_OK) break;
- }
- s->crc = crc32(s->crc, (const Bytef *)buf, len);
-
- return (int)(len - s->stream.avail_in);
-}
-
-
-/* ===========================================================================
- Converts, formats, and writes the args to the compressed file under
- control of the format string, as in fprintf. gzprintf returns the number of
- uncompressed bytes actually written (0 in case of error).
-*/
-#ifdef STDC
-#include <stdarg.h>
-
-int ZEXPORTVA gzprintf (gzFile file, const char *format, /* args */ ...)
-{
- char buf[Z_PRINTF_BUFSIZE];
- va_list va;
- int len;
-
- buf[sizeof(buf) - 1] = 0;
- va_start(va, format);
-#ifdef NO_vsnprintf
-# ifdef HAS_vsprintf_void
- (void)vsprintf(buf, format, va);
- va_end(va);
- for (len = 0; len < sizeof(buf); len++)
- if (buf[len] == 0) break;
-# else
- len = vsprintf(buf, format, va);
- va_end(va);
-# endif
-#else
-# ifdef HAS_vsnprintf_void
- (void)vsnprintf(buf, sizeof(buf), format, va);
- va_end(va);
- len = strlen(buf);
-# else
- len = vsnprintf(buf, sizeof(buf), format, va);
- va_end(va);
-# endif
-#endif
- if (len <= 0 || len >= (int)sizeof(buf) || buf[sizeof(buf) - 1] != 0)
- return 0;
- return gzwrite(file, buf, (unsigned)len);
-}
-#else /* not ANSI C */
-
-int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
- a11, a12, a13, a14, a15, a16, a17, a18, a19, a20)
- gzFile file;
- const char *format;
- int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
- a11, a12, a13, a14, a15, a16, a17, a18, a19, a20;
-{
- char buf[Z_PRINTF_BUFSIZE];
- int len;
-
- buf[sizeof(buf) - 1] = 0;
-#ifdef NO_snprintf
-# ifdef HAS_sprintf_void
- sprintf(buf, format, a1, a2, a3, a4, a5, a6, a7, a8,
- a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
- for (len = 0; len < sizeof(buf); len++)
- if (buf[len] == 0) break;
-# else
- len = sprintf(buf, format, a1, a2, a3, a4, a5, a6, a7, a8,
- a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
-# endif
-#else
-# ifdef HAS_snprintf_void
- snprintf(buf, sizeof(buf), format, a1, a2, a3, a4, a5, a6, a7, a8,
- a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
- len = strlen(buf);
-# else
- len = snprintf(buf, sizeof(buf), format, a1, a2, a3, a4, a5, a6, a7, a8,
- a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
-# endif
-#endif
- if (len <= 0 || len >= sizeof(buf) || buf[sizeof(buf) - 1] != 0)
- return 0;
- return gzwrite(file, buf, len);
-}
-#endif
-
-/* ===========================================================================
- Writes c, converted to an unsigned char, into the compressed file.
- gzputc returns the value that was written, or -1 in case of error.
-*/
-int ZEXPORT gzputc(file, c)
- gzFile file;
- int c;
-{
- unsigned char cc = (unsigned char) c; /* required for big endian systems */
-
- return gzwrite(file, &cc, 1) == 1 ? (int)cc : -1;
-}
-
-
-/* ===========================================================================
- Writes the given null-terminated string to the compressed file, excluding
- the terminating null character.
- gzputs returns the number of characters written, or -1 in case of error.
-*/
-int ZEXPORT gzputs(file, s)
- gzFile file;
- const char *s;
-{
- return gzwrite(file, (char*)s, (unsigned)strlen(s));
-}
-
-
-/* ===========================================================================
- Flushes all pending output into the compressed file. The parameter
- flush is as in the deflate() function.
-*/
-local int do_flush (file, flush)
- gzFile file;
- int flush;
-{
- uInt len;
- int done = 0;
- gz_stream *s = (gz_stream*)file;
-
- if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR;
-
- s->stream.avail_in = 0; /* should be zero already anyway */
-
- for (;;) {
- len = Z_BUFSIZE - s->stream.avail_out;
-
- if (len != 0) {
- if ((uInt)fwrite(s->outbuf, 1, len, s->file) != len) {
- s->z_err = Z_ERRNO;
- return Z_ERRNO;
- }
- s->stream.next_out = s->outbuf;
- s->stream.avail_out = Z_BUFSIZE;
- }
- if (done) break;
- s->out += s->stream.avail_out;
- s->z_err = deflate(&(s->stream), flush);
- s->out -= s->stream.avail_out;
-
- /* Ignore the second of two consecutive flushes: */
- if (len == 0 && s->z_err == Z_BUF_ERROR) s->z_err = Z_OK;
-
- /* deflate has finished flushing only when it hasn't used up
- * all the available space in the output buffer:
- */
- done = (s->stream.avail_out != 0 || s->z_err == Z_STREAM_END);
-
- if (s->z_err != Z_OK && s->z_err != Z_STREAM_END) break;
- }
- return s->z_err == Z_STREAM_END ? Z_OK : s->z_err;
-}
-
-int ZEXPORT gzflush (file, flush)
- gzFile file;
- int flush;
-{
- gz_stream *s = (gz_stream*)file;
- int err = do_flush (file, flush);
-
- if (err) return err;
- fflush(s->file);
- return s->z_err == Z_STREAM_END ? Z_OK : s->z_err;
-}
-#endif /* NO_GZCOMPRESS */
-
-/* ===========================================================================
- Sets the starting position for the next gzread or gzwrite on the given
- compressed file. The offset represents a number of bytes in the
- gzseek returns the resulting offset location as measured in bytes from
- the beginning of the uncompressed stream, or -1 in case of error.
- SEEK_END is not implemented, returns error.
- In this version of the library, gzseek can be extremely slow.
-*/
-z_off_t ZEXPORT gzseek (file, offset, whence)
- gzFile file;
- z_off_t offset;
- int whence;
-{
- gz_stream *s = (gz_stream*)file;
-
- if (s == NULL || whence == SEEK_END ||
- s->z_err == Z_ERRNO || s->z_err == Z_DATA_ERROR) {
- return -1L;
- }
-
- if (s->mode == 'w') {
-#ifdef NO_GZCOMPRESS
- return -1L;
-#else
- if (whence == SEEK_SET) {
- offset -= s->in;
- }
- if (offset < 0) return -1L;
-
- /* At this point, offset is the number of zero bytes to write. */
- if (s->inbuf == Z_NULL) {
- s->inbuf = (Byte*)ALLOC(Z_BUFSIZE); /* for seeking */
- if (s->inbuf == Z_NULL) return -1L;
- zmemzero(s->inbuf, Z_BUFSIZE);
- }
- while (offset > 0) {
- uInt size = Z_BUFSIZE;
- if (offset < Z_BUFSIZE) size = (uInt)offset;
-
- size = gzwrite(file, s->inbuf, size);
- if (size == 0) return -1L;
-
- offset -= size;
- }
- return s->in;
-#endif
- }
- /* Rest of function is for reading only */
-
- /* compute absolute position */
- if (whence == SEEK_CUR) {
- offset += s->out;
- }
- if (offset < 0) return -1L;
-
- if (s->transparent) {
- /* map to fseek */
- s->back = EOF;
- s->stream.avail_in = 0;
- s->stream.next_in = s->inbuf;
- if (fseek(s->file, offset, SEEK_SET) < 0) return -1L;
-
- s->in = s->out = offset;
- return offset;
- }
-
- /* For a negative seek, rewind and use positive seek */
- if (offset >= s->out) {
- offset -= s->out;
- } else if (gzrewind(file) < 0) {
- return -1L;
- }
- /* offset is now the number of bytes to skip. */
-
- if (offset != 0 && s->outbuf == Z_NULL) {
- s->outbuf = (Byte*)ALLOC(Z_BUFSIZE);
- if (s->outbuf == Z_NULL) return -1L;
- }
- if (offset && s->back != EOF) {
- s->back = EOF;
- s->out++;
- offset--;
- if (s->last) s->z_err = Z_STREAM_END;
- }
- while (offset > 0) {
- int size = Z_BUFSIZE;
- if (offset < Z_BUFSIZE) size = (int)offset;
-
- size = gzread(file, s->outbuf, (uInt)size);
- if (size <= 0) return -1L;
- offset -= size;
- }
- return s->out;
-}
-
-/* ===========================================================================
- Rewinds input file.
-*/
-int ZEXPORT gzrewind (file)
- gzFile file;
-{
- gz_stream *s = (gz_stream*)file;
-
- if (s == NULL || s->mode != 'r') return -1;
-
- s->z_err = Z_OK;
- s->z_eof = 0;
- s->back = EOF;
- s->stream.avail_in = 0;
- s->stream.next_in = s->inbuf;
- s->crc = crc32(0L, Z_NULL, 0);
- if (!s->transparent) (void)inflateReset(&s->stream);
- s->in = 0;
- s->out = 0;
- return fseek(s->file, s->start, SEEK_SET);
-}
-
-/* ===========================================================================
- Returns the starting position for the next gzread or gzwrite on the
- given compressed file. This position represents a number of bytes in the
- uncompressed data stream.
-*/
-z_off_t ZEXPORT gztell (file)
- gzFile file;
-{
- return gzseek(file, 0L, SEEK_CUR);
-}
-
-/* ===========================================================================
- Returns 1 when EOF has previously been detected reading the given
- input stream, otherwise zero.
-*/
-int ZEXPORT gzeof (file)
- gzFile file;
-{
- gz_stream *s = (gz_stream*)file;
-
- /* With concatenated compressed files that can have embedded
- * crc trailers, z_eof is no longer the only/best indicator of EOF
- * on a gz_stream. Handle end-of-stream error explicitly here.
- */
- if (s == NULL || s->mode != 'r') return 0;
- if (s->z_eof) return 1;
- return s->z_err == Z_STREAM_END;
-}
-
-/* ===========================================================================
- Outputs a long in LSB order to the given file
-*/
-local void putLong (file, x)
- FILE *file;
- uLong x;
-{
- int n;
- for (n = 0; n < 4; n++) {
- fputc((int)(x & 0xff), file);
- x >>= 8;
- }
-}
-
-/* ===========================================================================
- Reads a long in LSB order from the given gz_stream. Sets z_err in case
- of error.
-*/
-local uLong getLong (s)
- gz_stream *s;
-{
- uLong x = (uLong)get_byte(s);
- int c;
-
- x += ((uLong)get_byte(s))<<8;
- x += ((uLong)get_byte(s))<<16;
- c = get_byte(s);
- if (c == EOF) s->z_err = Z_DATA_ERROR;
- x += ((uLong)c)<<24;
- return x;
-}
-
-/* ===========================================================================
- Flushes all pending output if necessary, closes the compressed file
- and deallocates all the (de)compression state.
-*/
-int ZEXPORT gzclose (file)
- gzFile file;
-{
- int err;
- gz_stream *s = (gz_stream*)file;
-
- if (s == NULL) return Z_STREAM_ERROR;
-
- if (s->mode == 'w') {
-#ifdef NO_GZCOMPRESS
- return Z_STREAM_ERROR;
-#else
- err = do_flush (file, Z_FINISH);
- if (err != Z_OK) return destroy((gz_stream*)file);
-
- putLong (s->file, s->crc);
- putLong (s->file, (uLong)(s->in & 0xffffffff));
-#endif
- }
- return destroy((gz_stream*)file);
-}
-
-/* ===========================================================================
- Returns the error message for the last error which occured on the
- given compressed file. errnum is set to zlib error number. If an
- error occured in the file system and not in the compression library,
- errnum is set to Z_ERRNO and the application may consult errno
- to get the exact error code.
-*/
-const char * ZEXPORT gzerror (file, errnum)
- gzFile file;
- int *errnum;
-{
- char *m;
- gz_stream *s = (gz_stream*)file;
-
- if (s == NULL) {
- *errnum = Z_STREAM_ERROR;
- return (const char*)ERR_MSG(Z_STREAM_ERROR);
- }
- *errnum = s->z_err;
- if (*errnum == Z_OK) return (const char*)"";
-
- m = (char*)(*errnum == Z_ERRNO ? zstrerror(errno) : s->stream.msg);
-
- if (m == NULL || *m == '\0') m = (char*)ERR_MSG(s->z_err);
-
- TRYFREE(s->msg);
- s->msg = (char*)ALLOC(strlen(s->path) + strlen(m) + 3);
- if (s->msg == Z_NULL) return (const char*)ERR_MSG(Z_MEM_ERROR);
- strcpy(s->msg, s->path);
- strcat(s->msg, ": ");
- strcat(s->msg, m);
- return (const char*)s->msg;
-}
-
-/* ===========================================================================
- Clear the error and end-of-file flags, and do the same for the real file.
-*/
-void ZEXPORT gzclearerr (file)
- gzFile file;
-{
- gz_stream *s = (gz_stream*)file;
-
- if (s == NULL) return;
- if (s->z_err != Z_STREAM_END) s->z_err = Z_OK;
- s->z_eof = 0;
- /* klibc hack */
- /* clearerr(s->file); */
-}
diff --git a/klibc/klibc/zlib/infback.c b/klibc/klibc/zlib/infback.c
deleted file mode 100644
index 110b03b857..0000000000
--- a/klibc/klibc/zlib/infback.c
+++ /dev/null
@@ -1,619 +0,0 @@
-/* infback.c -- inflate using a call-back interface
- * Copyright (C) 1995-2003 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/*
- This code is largely copied from inflate.c. Normally either infback.o or
- inflate.o would be linked into an application--not both. The interface
- with inffast.c is retained so that optimized assembler-coded versions of
- inflate_fast() can be used with either inflate.c or infback.c.
- */
-
-#include "zutil.h"
-#include "inftrees.h"
-#include "inflate.h"
-#include "inffast.h"
-
-/* function prototypes */
-local void fixedtables OF((struct inflate_state FAR *state));
-
-/*
- strm provides memory allocation functions in zalloc and zfree, or
- Z_NULL to use the library memory allocation functions.
-
- windowBits is in the range 8..15, and window is a user-supplied
- window and output buffer that is 2**windowBits bytes.
- */
-int ZEXPORT inflateBackInit_(strm, windowBits, window, version, stream_size)
-z_stream FAR *strm;
-int windowBits;
-unsigned char FAR *window;
-const char *version;
-int stream_size;
-{
- struct inflate_state FAR *state;
-
- if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
- stream_size != (int)(sizeof(z_stream)))
- return Z_VERSION_ERROR;
- if (strm == Z_NULL || window == Z_NULL ||
- windowBits < 8 || windowBits > 15)
- return Z_STREAM_ERROR;
- strm->msg = Z_NULL; /* in case we return an error */
- if (strm->zalloc == (alloc_func)0) {
- strm->zalloc = zcalloc;
- strm->opaque = (voidpf)0;
- }
- if (strm->zfree == (free_func)0) strm->zfree = zcfree;
- state = (struct inflate_state FAR *)ZALLOC(strm, 1,
- sizeof(struct inflate_state));
- if (state == Z_NULL) return Z_MEM_ERROR;
- Tracev((stderr, "inflate: allocated\n"));
- strm->state = (voidpf)state;
- state->wbits = windowBits;
- state->wsize = 1U << windowBits;
- state->window = window;
- state->write = 0;
- state->whave = 0;
- return Z_OK;
-}
-
-/*
- Return state with length and distance decoding tables and index sizes set to
- fixed code decoding. Normally this returns fixed tables from inffixed.h.
- If BUILDFIXED is defined, then instead this routine builds the tables the
- first time it's called, and returns those tables the first time and
- thereafter. This reduces the size of the code by about 2K bytes, in
- exchange for a little execution time. However, BUILDFIXED should not be
- used for threaded applications, since the rewriting of the tables and virgin
- may not be thread-safe.
- */
-local void fixedtables(state)
-struct inflate_state FAR *state;
-{
-#ifdef BUILDFIXED
- static int virgin = 1;
- static code *lenfix, *distfix;
- static code fixed[544];
-
- /* build fixed huffman tables if first call (may not be thread safe) */
- if (virgin) {
- unsigned sym, bits;
- static code *next;
-
- /* literal/length table */
- sym = 0;
- while (sym < 144) state->lens[sym++] = 8;
- while (sym < 256) state->lens[sym++] = 9;
- while (sym < 280) state->lens[sym++] = 7;
- while (sym < 288) state->lens[sym++] = 8;
- next = fixed;
- lenfix = next;
- bits = 9;
- inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work);
-
- /* distance table */
- sym = 0;
- while (sym < 32) state->lens[sym++] = 5;
- distfix = next;
- bits = 5;
- inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work);
-
- /* do this just once */
- virgin = 0;
- }
-#else /* !BUILDFIXED */
-# include "inffixed.h"
-#endif /* BUILDFIXED */
- state->lencode = lenfix;
- state->lenbits = 9;
- state->distcode = distfix;
- state->distbits = 5;
-}
-
-/* Macros for inflateBack(): */
-
-/* Load returned state from inflate_fast() */
-#define LOAD() \
- do { \
- put = strm->next_out; \
- left = strm->avail_out; \
- next = strm->next_in; \
- have = strm->avail_in; \
- hold = state->hold; \
- bits = state->bits; \
- } while (0)
-
-/* Set state from registers for inflate_fast() */
-#define RESTORE() \
- do { \
- strm->next_out = put; \
- strm->avail_out = left; \
- strm->next_in = next; \
- strm->avail_in = have; \
- state->hold = hold; \
- state->bits = bits; \
- } while (0)
-
-/* Clear the input bit accumulator */
-#define INITBITS() \
- do { \
- hold = 0; \
- bits = 0; \
- } while (0)
-
-/* Assure that some input is available. If input is requested, but denied,
- then return a Z_BUF_ERROR from inflateBack(). */
-#define PULL() \
- do { \
- if (have == 0) { \
- have = in(in_desc, &next); \
- if (have == 0) { \
- next = Z_NULL; \
- ret = Z_BUF_ERROR; \
- goto inf_leave; \
- } \
- } \
- } while (0)
-
-/* Get a byte of input into the bit accumulator, or return from inflateBack()
- with an error if there is no input available. */
-#define PULLBYTE() \
- do { \
- PULL(); \
- have--; \
- hold += (unsigned long)(*next++) << bits; \
- bits += 8; \
- } while (0)
-
-/* Assure that there are at least n bits in the bit accumulator. If there is
- not enough available input to do that, then return from inflateBack() with
- an error. */
-#define NEEDBITS(n) \
- do { \
- while (bits < (unsigned)(n)) \
- PULLBYTE(); \
- } while (0)
-
-/* Return the low n bits of the bit accumulator (n < 16) */
-#define BITS(n) \
- ((unsigned)hold & ((1U << (n)) - 1))
-
-/* Remove n bits from the bit accumulator */
-#define DROPBITS(n) \
- do { \
- hold >>= (n); \
- bits -= (unsigned)(n); \
- } while (0)
-
-/* Remove zero to seven bits as needed to go to a byte boundary */
-#define BYTEBITS() \
- do { \
- hold >>= bits & 7; \
- bits -= bits & 7; \
- } while (0)
-
-/* Assure that some output space is available, by writing out the window
- if it's full. If the write fails, return from inflateBack() with a
- Z_BUF_ERROR. */
-#define ROOM() \
- do { \
- if (left == 0) { \
- put = state->window; \
- left = state->wsize; \
- state->whave = left; \
- if (out(out_desc, put, left)) { \
- ret = Z_BUF_ERROR; \
- goto inf_leave; \
- } \
- } \
- } while (0)
-
-/*
- strm provides the memory allocation functions and window buffer on input,
- and provides information on the unused input on return. For Z_DATA_ERROR
- returns, strm will also provide an error message.
-
- in() and out() are the call-back input and output functions. When
- inflateBack() needs more input, it calls in(). When inflateBack() has
- filled the window with output, or when it completes with data in the
- window, it calls out() to write out the data. The application must not
- change the provided input until in() is called again or inflateBack()
- returns. The application must not change the window/output buffer until
- inflateBack() returns.
-
- in() and out() are called with a descriptor parameter provided in the
- inflateBack() call. This parameter can be a structure that provides the
- information required to do the read or write, as well as accumulated
- information on the input and output such as totals and check values.
-
- in() should return zero on failure. out() should return non-zero on
- failure. If either in() or out() fails, than inflateBack() returns a
- Z_BUF_ERROR. strm->next_in can be checked for Z_NULL to see whether it
- was in() or out() that caused in the error. Otherwise, inflateBack()
- returns Z_STREAM_END on success, Z_DATA_ERROR for an deflate format
- error, or Z_MEM_ERROR if it could not allocate memory for the state.
- inflateBack() can also return Z_STREAM_ERROR if the input parameters
- are not correct, i.e. strm is Z_NULL or the state was not initialized.
- */
-int ZEXPORT inflateBack(strm, in, in_desc, out, out_desc)
-z_stream FAR *strm;
-in_func in;
-void FAR *in_desc;
-out_func out;
-void FAR *out_desc;
-{
- struct inflate_state FAR *state;
- unsigned char FAR *next; /* next input */
- unsigned char FAR *put; /* next output */
- unsigned have, left; /* available input and output */
- unsigned long hold; /* bit buffer */
- unsigned bits; /* bits in bit buffer */
- unsigned copy; /* number of stored or match bytes to copy */
- unsigned char FAR *from; /* where to copy match bytes from */
- code this; /* current decoding table entry */
- code last; /* parent table entry */
- unsigned len; /* length to copy for repeats, bits to drop */
- int ret; /* return code */
- static const unsigned short order[19] = /* permutation of code lengths */
- {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
-
- /* Check that the strm exists and that the state was initialized */
- if (strm == Z_NULL || strm->state == Z_NULL)
- return Z_STREAM_ERROR;
- state = (struct inflate_state FAR *)strm->state;
-
- /* Reset the state */
- strm->msg = Z_NULL;
- state->mode = TYPE;
- state->last = 0;
- state->whave = 0;
- next = strm->next_in;
- have = next != Z_NULL ? strm->avail_in : 0;
- hold = 0;
- bits = 0;
- put = state->window;
- left = state->wsize;
-
- /* Inflate until end of block marked as last */
- for (;;)
- switch (state->mode) {
- case TYPE:
- /* determine and dispatch block type */
- if (state->last) {
- BYTEBITS();
- state->mode = DONE;
- break;
- }
- NEEDBITS(3);
- state->last = BITS(1);
- DROPBITS(1);
- switch (BITS(2)) {
- case 0: /* stored block */
- Tracev((stderr, "inflate: stored block%s\n",
- state->last ? " (last)" : ""));
- state->mode = STORED;
- break;
- case 1: /* fixed block */
- fixedtables(state);
- Tracev((stderr, "inflate: fixed codes block%s\n",
- state->last ? " (last)" : ""));
- state->mode = LEN; /* decode codes */
- break;
- case 2: /* dynamic block */
- Tracev((stderr, "inflate: dynamic codes block%s\n",
- state->last ? " (last)" : ""));
- state->mode = TABLE;
- break;
- case 3:
- strm->msg = (char *)"invalid block type";
- state->mode = BAD;
- }
- DROPBITS(2);
- break;
-
- case STORED:
- /* get and verify stored block length */
- BYTEBITS(); /* go to byte boundary */
- NEEDBITS(32);
- if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {
- strm->msg = (char *)"invalid stored block lengths";
- state->mode = BAD;
- break;
- }
- state->length = (unsigned)hold & 0xffff;
- Tracev((stderr, "inflate: stored length %u\n",
- state->length));
- INITBITS();
-
- /* copy stored block from input to output */
- while (state->length != 0) {
- copy = state->length;
- PULL();
- ROOM();
- if (copy > have) copy = have;
- if (copy > left) copy = left;
- zmemcpy(put, next, copy);
- have -= copy;
- next += copy;
- left -= copy;
- put += copy;
- state->length -= copy;
- }
- Tracev((stderr, "inflate: stored end\n"));
- state->mode = TYPE;
- break;
-
- case TABLE:
- /* get dynamic table entries descriptor */
- NEEDBITS(14);
- state->nlen = BITS(5) + 257;
- DROPBITS(5);
- state->ndist = BITS(5) + 1;
- DROPBITS(5);
- state->ncode = BITS(4) + 4;
- DROPBITS(4);
-#ifndef PKZIP_BUG_WORKAROUND
- if (state->nlen > 286 || state->ndist > 30) {
- strm->msg = (char *)"too many length or distance symbols";
- state->mode = BAD;
- break;
- }
-#endif
- Tracev((stderr, "inflate: table sizes ok\n"));
-
- /* get code length code lengths (not a typo) */
- state->have = 0;
- while (state->have < state->ncode) {
- NEEDBITS(3);
- state->lens[order[state->have++]] = (unsigned short)BITS(3);
- DROPBITS(3);
- }
- while (state->have < 19)
- state->lens[order[state->have++]] = 0;
- state->next = state->codes;
- state->lencode = (code const FAR *)(state->next);
- state->lenbits = 7;
- ret = inflate_table(CODES, state->lens, 19, &(state->next),
- &(state->lenbits), state->work);
- if (ret) {
- strm->msg = (char *)"invalid code lengths set";
- state->mode = BAD;
- break;
- }
- Tracev((stderr, "inflate: code lengths ok\n"));
-
- /* get length and distance code code lengths */
- state->have = 0;
- while (state->have < state->nlen + state->ndist) {
- for (;;) {
- this = state->lencode[BITS(state->lenbits)];
- if ((unsigned)(this.bits) <= bits) break;
- PULLBYTE();
- }
- if (this.val < 16) {
- NEEDBITS(this.bits);
- DROPBITS(this.bits);
- state->lens[state->have++] = this.val;
- }
- else {
- if (this.val == 16) {
- NEEDBITS(this.bits + 2);
- DROPBITS(this.bits);
- if (state->have == 0) {
- strm->msg = (char *)"invalid bit length repeat";
- state->mode = BAD;
- break;
- }
- len = (unsigned)(state->lens[state->have - 1]);
- copy = 3 + BITS(2);
- DROPBITS(2);
- }
- else if (this.val == 17) {
- NEEDBITS(this.bits + 3);
- DROPBITS(this.bits);
- len = 0;
- copy = 3 + BITS(3);
- DROPBITS(3);
- }
- else {
- NEEDBITS(this.bits + 7);
- DROPBITS(this.bits);
- len = 0;
- copy = 11 + BITS(7);
- DROPBITS(7);
- }
- if (state->have + copy > state->nlen + state->ndist) {
- strm->msg = (char *)"invalid bit length repeat";
- state->mode = BAD;
- break;
- }
- while (copy--)
- state->lens[state->have++] = (unsigned short)len;
- }
- }
-
- /* build code tables */
- state->next = state->codes;
- state->lencode = (code const FAR *)(state->next);
- state->lenbits = 9;
- ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
- &(state->lenbits), state->work);
- if (ret) {
- strm->msg = (char *)"invalid literal/lengths set";
- state->mode = BAD;
- break;
- }
- state->distcode = (code const FAR *)(state->next);
- state->distbits = 6;
- ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
- &(state->next), &(state->distbits), state->work);
- if (ret) {
- strm->msg = (char *)"invalid distances set";
- state->mode = BAD;
- break;
- }
- Tracev((stderr, "inflate: codes ok\n"));
- state->mode = LEN;
-
- case LEN:
- /* use inflate_fast() if we have enough input and output */
- if (have >= 6 && left >= 258) {
- RESTORE();
- if (state->whave < state->wsize)
- state->whave = state->wsize - left;
- inflate_fast(strm, state->wsize);
- LOAD();
- break;
- }
-
- /* get a literal, length, or end-of-block code */
- for (;;) {
- this = state->lencode[BITS(state->lenbits)];
- if ((unsigned)(this.bits) <= bits) break;
- PULLBYTE();
- }
- if (this.op && (this.op & 0xf0) == 0) {
- last = this;
- for (;;) {
- this = state->lencode[last.val +
- (BITS(last.bits + last.op) >> last.bits)];
- if ((unsigned)(last.bits + this.bits) <= bits) break;
- PULLBYTE();
- }
- DROPBITS(last.bits);
- }
- DROPBITS(this.bits);
- state->length = (unsigned)this.val;
-
- /* process literal */
- if (this.op == 0) {
- Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ?
- "inflate: literal '%c'\n" :
- "inflate: literal 0x%02x\n", this.val));
- ROOM();
- *put++ = (unsigned char)(state->length);
- left--;
- state->mode = LEN;
- break;
- }
-
- /* process end of block */
- if (this.op & 32) {
- Tracevv((stderr, "inflate: end of block\n"));
- state->mode = TYPE;
- break;
- }
-
- /* invalid code */
- if (this.op & 64) {
- strm->msg = (char *)"invalid literal/length code";
- state->mode = BAD;
- break;
- }
-
- /* length code -- get extra bits, if any */
- state->extra = (unsigned)(this.op) & 15;
- if (state->extra != 0) {
- NEEDBITS(state->extra);
- state->length += BITS(state->extra);
- DROPBITS(state->extra);
- }
- Tracevv((stderr, "inflate: length %u\n", state->length));
-
- /* get distance code */
- for (;;) {
- this = state->distcode[BITS(state->distbits)];
- if ((unsigned)(this.bits) <= bits) break;
- PULLBYTE();
- }
- if ((this.op & 0xf0) == 0) {
- last = this;
- for (;;) {
- this = state->distcode[last.val +
- (BITS(last.bits + last.op) >> last.bits)];
- if ((unsigned)(last.bits + this.bits) <= bits) break;
- PULLBYTE();
- }
- DROPBITS(last.bits);
- }
- DROPBITS(this.bits);
- if (this.op & 64) {
- strm->msg = (char *)"invalid distance code";
- state->mode = BAD;
- break;
- }
- state->offset = (unsigned)this.val;
-
- /* get distance extra bits, if any */
- state->extra = (unsigned)(this.op) & 15;
- if (state->extra != 0) {
- NEEDBITS(state->extra);
- state->offset += BITS(state->extra);
- DROPBITS(state->extra);
- }
- if (state->offset > state->wsize - (state->whave < state->wsize ?
- left : 0)) {
- strm->msg = (char *)"invalid distance too far back";
- state->mode = BAD;
- break;
- }
- Tracevv((stderr, "inflate: distance %u\n", state->offset));
-
- /* copy match from window to output */
- do {
- ROOM();
- copy = state->wsize - state->offset;
- if (copy < left) {
- from = put + copy;
- copy = left - copy;
- }
- else {
- from = put - state->offset;
- copy = left;
- }
- if (copy > state->length) copy = state->length;
- state->length -= copy;
- left -= copy;
- do {
- *put++ = *from++;
- } while (--copy);
- } while (state->length != 0);
- break;
-
- case DONE:
- /* inflate stream terminated properly -- write leftover output */
- ret = Z_STREAM_END;
- if (left < state->wsize) {
- if (out(out_desc, state->window, state->wsize - left))
- ret = Z_BUF_ERROR;
- }
- goto inf_leave;
-
- case BAD:
- ret = Z_DATA_ERROR;
- goto inf_leave;
-
- default: /* can't happen, but makes compilers happy */
- ret = Z_STREAM_ERROR;
- goto inf_leave;
- }
-
- /* Return unused input */
- inf_leave:
- strm->next_in = next;
- strm->avail_in = have;
- return ret;
-}
-
-int ZEXPORT inflateBackEnd(strm)
-z_stream FAR *strm;
-{
- if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
- return Z_STREAM_ERROR;
- ZFREE(strm, strm->state);
- strm->state = Z_NULL;
- Tracev((stderr, "inflate: end\n"));
- return Z_OK;
-}
diff --git a/klibc/klibc/zlib/inffast.c b/klibc/klibc/zlib/inffast.c
deleted file mode 100644
index c716440a92..0000000000
--- a/klibc/klibc/zlib/inffast.c
+++ /dev/null
@@ -1,305 +0,0 @@
-/* inffast.c -- fast decoding
- * Copyright (C) 1995-2003 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-#include "zutil.h"
-#include "inftrees.h"
-#include "inflate.h"
-#include "inffast.h"
-
-#ifndef ASMINF
-
-/* Allow machine dependent optimization for post-increment or pre-increment.
- Based on testing to date,
- Pre-increment preferred for:
- - PowerPC G3 (Adler)
- - MIPS R5000 (Randers-Pehrson)
- Post-increment preferred for:
- - none
- No measurable difference:
- - Pentium III (Anderson)
- - 68060 (Nikl)
- */
-#ifdef POSTINC
-# define OFF 0
-# define PUP(a) *(a)++
-#else
-# define OFF 1
-# define PUP(a) *++(a)
-#endif
-
-/*
- Decode literal, length, and distance codes and write out the resulting
- literal and match bytes until either not enough input or output is
- available, an end-of-block is encountered, or a data error is encountered.
- When large enough input and output buffers are supplied to inflate(), for
- example, a 16K input buffer and a 64K output buffer, more than 95% of the
- inflate execution time is spent in this routine.
-
- Entry assumptions:
-
- state->mode == LEN
- strm->avail_in >= 6
- strm->avail_out >= 258
- start >= strm->avail_out
- state->bits < 8
-
- On return, state->mode is one of:
-
- LEN -- ran out of enough output space or enough available input
- TYPE -- reached end of block code, inflate() to interpret next block
- BAD -- error in block data
-
- Notes:
-
- - The maximum input bits used by a length/distance pair is 15 bits for the
- length code, 5 bits for the length extra, 15 bits for the distance code,
- and 13 bits for the distance extra. This totals 48 bits, or six bytes.
- Therefore if strm->avail_in >= 6, then there is enough input to avoid
- checking for available input while decoding.
-
- - The maximum bytes that a single length/distance pair can output is 258
- bytes, which is the maximum length that can be coded. inflate_fast()
- requires strm->avail_out >= 258 for each loop to avoid checking for
- output space.
- */
-void inflate_fast(strm, start)
-z_streamp strm;
-unsigned start; /* inflate()'s starting value for strm->avail_out */
-{
- struct inflate_state FAR *state;
- unsigned char FAR *in; /* local strm->next_in */
- unsigned char FAR *last; /* while in < last, enough input available */
- unsigned char FAR *out; /* local strm->next_out */
- unsigned char FAR *beg; /* inflate()'s initial strm->next_out */
- unsigned char FAR *end; /* while out < end, enough space available */
- unsigned wsize; /* window size or zero if not using window */
- unsigned whave; /* valid bytes in the window */
- unsigned write; /* window write index */
- unsigned char FAR *window; /* allocated sliding window, if wsize != 0 */
- unsigned long hold; /* local strm->hold */
- unsigned bits; /* local strm->bits */
- code const FAR *lcode; /* local strm->lencode */
- code const FAR *dcode; /* local strm->distcode */
- unsigned lmask; /* mask for first level of length codes */
- unsigned dmask; /* mask for first level of distance codes */
- code this; /* retrieved table entry */
- unsigned op; /* code bits, operation, extra bits, or */
- /* window position, window bytes to copy */
- unsigned len; /* match length, unused bytes */
- unsigned dist; /* match distance */
- unsigned char FAR *from; /* where to copy match from */
-
- /* copy state to local variables */
- state = (struct inflate_state FAR *)strm->state;
- in = strm->next_in - OFF;
- last = in + (strm->avail_in - 5);
- out = strm->next_out - OFF;
- beg = out - (start - strm->avail_out);
- end = out + (strm->avail_out - 257);
- wsize = state->wsize;
- whave = state->whave;
- write = state->write;
- window = state->window;
- hold = state->hold;
- bits = state->bits;
- lcode = state->lencode;
- dcode = state->distcode;
- lmask = (1U << state->lenbits) - 1;
- dmask = (1U << state->distbits) - 1;
-
- /* decode literals and length/distances until end-of-block or not enough
- input data or output space */
- do {
- if (bits < 15) {
- hold += (unsigned long)(PUP(in)) << bits;
- bits += 8;
- hold += (unsigned long)(PUP(in)) << bits;
- bits += 8;
- }
- this = lcode[hold & lmask];
- dolen:
- op = (unsigned)(this.bits);
- hold >>= op;
- bits -= op;
- op = (unsigned)(this.op);
- if (op == 0) { /* literal */
- Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ?
- "inflate: literal '%c'\n" :
- "inflate: literal 0x%02x\n", this.val));
- PUP(out) = (unsigned char)(this.val);
- }
- else if (op & 16) { /* length base */
- len = (unsigned)(this.val);
- op &= 15; /* number of extra bits */
- if (op) {
- if (bits < op) {
- hold += (unsigned long)(PUP(in)) << bits;
- bits += 8;
- }
- len += (unsigned)hold & ((1U << op) - 1);
- hold >>= op;
- bits -= op;
- }
- Tracevv((stderr, "inflate: length %u\n", len));
- if (bits < 15) {
- hold += (unsigned long)(PUP(in)) << bits;
- bits += 8;
- hold += (unsigned long)(PUP(in)) << bits;
- bits += 8;
- }
- this = dcode[hold & dmask];
- dodist:
- op = (unsigned)(this.bits);
- hold >>= op;
- bits -= op;
- op = (unsigned)(this.op);
- if (op & 16) { /* distance base */
- dist = (unsigned)(this.val);
- op &= 15; /* number of extra bits */
- if (bits < op) {
- hold += (unsigned long)(PUP(in)) << bits;
- bits += 8;
- if (bits < op) {
- hold += (unsigned long)(PUP(in)) << bits;
- bits += 8;
- }
- }
- dist += (unsigned)hold & ((1U << op) - 1);
- hold >>= op;
- bits -= op;
- Tracevv((stderr, "inflate: distance %u\n", dist));
- op = (unsigned)(out - beg); /* max distance in output */
- if (dist > op) { /* see if copy from window */
- op = dist - op; /* distance back in window */
- if (op > whave) {
- strm->msg = (char *)"invalid distance too far back";
- state->mode = BAD;
- break;
- }
- from = window - OFF;
- if (write == 0) { /* very common case */
- from += wsize - op;
- if (op < len) { /* some from window */
- len -= op;
- do {
- PUP(out) = PUP(from);
- } while (--op);
- from = out - dist; /* rest from output */
- }
- }
- else if (write < op) { /* wrap around window */
- from += wsize + write - op;
- op -= write;
- if (op < len) { /* some from end of window */
- len -= op;
- do {
- PUP(out) = PUP(from);
- } while (--op);
- from = window - OFF;
- if (write < len) { /* some from start of window */
- op = write;
- len -= op;
- do {
- PUP(out) = PUP(from);
- } while (--op);
- from = out - dist; /* rest from output */
- }
- }
- }
- else { /* contiguous in window */
- from += write - op;
- if (op < len) { /* some from window */
- len -= op;
- do {
- PUP(out) = PUP(from);
- } while (--op);
- from = out - dist; /* rest from output */
- }
- }
- while (len > 2) {
- PUP(out) = PUP(from);
- PUP(out) = PUP(from);
- PUP(out) = PUP(from);
- len -= 3;
- }
- if (len) {
- PUP(out) = PUP(from);
- if (len > 1)
- PUP(out) = PUP(from);
- }
- }
- else {
- from = out - dist; /* copy direct from output */
- do { /* minimum length is three */
- PUP(out) = PUP(from);
- PUP(out) = PUP(from);
- PUP(out) = PUP(from);
- len -= 3;
- } while (len > 2);
- if (len) {
- PUP(out) = PUP(from);
- if (len > 1)
- PUP(out) = PUP(from);
- }
- }
- }
- else if ((op & 64) == 0) { /* 2nd level distance code */
- this = dcode[this.val + (hold & ((1U << op) - 1))];
- goto dodist;
- }
- else {
- strm->msg = (char *)"invalid distance code";
- state->mode = BAD;
- break;
- }
- }
- else if ((op & 64) == 0) { /* 2nd level length code */
- this = lcode[this.val + (hold & ((1U << op) - 1))];
- goto dolen;
- }
- else if (op & 32) { /* end-of-block */
- Tracevv((stderr, "inflate: end of block\n"));
- state->mode = TYPE;
- break;
- }
- else {
- strm->msg = (char *)"invalid literal/length code";
- state->mode = BAD;
- break;
- }
- } while (in < last && out < end);
-
- /* return unused bytes (on entry, bits < 8, so in won't go too far back) */
- len = bits >> 3;
- in -= len;
- bits -= len << 3;
- hold &= (1U << bits) - 1;
-
- /* update state and return */
- strm->next_in = in + OFF;
- strm->next_out = out + OFF;
- strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in - last));
- strm->avail_out = (unsigned)(out < end ?
- 257 + (end - out) : 257 - (out - end));
- state->hold = hold;
- state->bits = bits;
- return;
-}
-
-/*
- inflate_fast() speedups that turned out slower (on a PowerPC G3 750CXe):
- - Using bit fields for code structure
- - Different op definition to avoid & for extra bits (do & for table bits)
- - Three separate decoding do-loops for direct, window, and write == 0
- - Special case for distance > 1 copies to do overlapped load and store copy
- - Explicit branch predictions (based on measured branch probabilities)
- - Deferring match copy and interspersed it with decoding subsequent codes
- - Swapping literal/length else
- - Swapping window/direct else
- - Larger unrolled copy loops (three is about right)
- - Moving len -= 3 statement into middle of loop
- */
-
-#endif /* !ASMINF */
diff --git a/klibc/klibc/zlib/inffast.h b/klibc/klibc/zlib/inffast.h
deleted file mode 100644
index 1e88d2d97b..0000000000
--- a/klibc/klibc/zlib/inffast.h
+++ /dev/null
@@ -1,11 +0,0 @@
-/* inffast.h -- header to use inffast.c
- * Copyright (C) 1995-2003 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* WARNING: this file should *not* be used by applications. It is
- part of the implementation of the compression library and is
- subject to change. Applications should only use zlib.h.
- */
-
-void inflate_fast OF((z_streamp strm, unsigned start));
diff --git a/klibc/klibc/zlib/inffixed.h b/klibc/klibc/zlib/inffixed.h
deleted file mode 100644
index 75ed4b5978..0000000000
--- a/klibc/klibc/zlib/inffixed.h
+++ /dev/null
@@ -1,94 +0,0 @@
- /* inffixed.h -- table for decoding fixed codes
- * Generated automatically by makefixed().
- */
-
- /* WARNING: this file should *not* be used by applications. It
- is part of the implementation of the compression library and
- is subject to change. Applications should only use zlib.h.
- */
-
- static const code lenfix[512] = {
- {96,7,0},{0,8,80},{0,8,16},{20,8,115},{18,7,31},{0,8,112},{0,8,48},
- {0,9,192},{16,7,10},{0,8,96},{0,8,32},{0,9,160},{0,8,0},{0,8,128},
- {0,8,64},{0,9,224},{16,7,6},{0,8,88},{0,8,24},{0,9,144},{19,7,59},
- {0,8,120},{0,8,56},{0,9,208},{17,7,17},{0,8,104},{0,8,40},{0,9,176},
- {0,8,8},{0,8,136},{0,8,72},{0,9,240},{16,7,4},{0,8,84},{0,8,20},
- {21,8,227},{19,7,43},{0,8,116},{0,8,52},{0,9,200},{17,7,13},{0,8,100},
- {0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232},{16,7,8},
- {0,8,92},{0,8,28},{0,9,152},{20,7,83},{0,8,124},{0,8,60},{0,9,216},
- {18,7,23},{0,8,108},{0,8,44},{0,9,184},{0,8,12},{0,8,140},{0,8,76},
- {0,9,248},{16,7,3},{0,8,82},{0,8,18},{21,8,163},{19,7,35},{0,8,114},
- {0,8,50},{0,9,196},{17,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2},
- {0,8,130},{0,8,66},{0,9,228},{16,7,7},{0,8,90},{0,8,26},{0,9,148},
- {20,7,67},{0,8,122},{0,8,58},{0,9,212},{18,7,19},{0,8,106},{0,8,42},
- {0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244},{16,7,5},{0,8,86},
- {0,8,22},{64,8,0},{19,7,51},{0,8,118},{0,8,54},{0,9,204},{17,7,15},
- {0,8,102},{0,8,38},{0,9,172},{0,8,6},{0,8,134},{0,8,70},{0,9,236},
- {16,7,9},{0,8,94},{0,8,30},{0,9,156},{20,7,99},{0,8,126},{0,8,62},
- {0,9,220},{18,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142},
- {0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{21,8,131},{18,7,31},
- {0,8,113},{0,8,49},{0,9,194},{16,7,10},{0,8,97},{0,8,33},{0,9,162},
- {0,8,1},{0,8,129},{0,8,65},{0,9,226},{16,7,6},{0,8,89},{0,8,25},
- {0,9,146},{19,7,59},{0,8,121},{0,8,57},{0,9,210},{17,7,17},{0,8,105},
- {0,8,41},{0,9,178},{0,8,9},{0,8,137},{0,8,73},{0,9,242},{16,7,4},
- {0,8,85},{0,8,21},{16,8,258},{19,7,43},{0,8,117},{0,8,53},{0,9,202},
- {17,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133},{0,8,69},
- {0,9,234},{16,7,8},{0,8,93},{0,8,29},{0,9,154},{20,7,83},{0,8,125},
- {0,8,61},{0,9,218},{18,7,23},{0,8,109},{0,8,45},{0,9,186},{0,8,13},
- {0,8,141},{0,8,77},{0,9,250},{16,7,3},{0,8,83},{0,8,19},{21,8,195},
- {19,7,35},{0,8,115},{0,8,51},{0,9,198},{17,7,11},{0,8,99},{0,8,35},
- {0,9,166},{0,8,3},{0,8,131},{0,8,67},{0,9,230},{16,7,7},{0,8,91},
- {0,8,27},{0,9,150},{20,7,67},{0,8,123},{0,8,59},{0,9,214},{18,7,19},
- {0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139},{0,8,75},{0,9,246},
- {16,7,5},{0,8,87},{0,8,23},{64,8,0},{19,7,51},{0,8,119},{0,8,55},
- {0,9,206},{17,7,15},{0,8,103},{0,8,39},{0,9,174},{0,8,7},{0,8,135},
- {0,8,71},{0,9,238},{16,7,9},{0,8,95},{0,8,31},{0,9,158},{20,7,99},
- {0,8,127},{0,8,63},{0,9,222},{18,7,27},{0,8,111},{0,8,47},{0,9,190},
- {0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80},{0,8,16},
- {20,8,115},{18,7,31},{0,8,112},{0,8,48},{0,9,193},{16,7,10},{0,8,96},
- {0,8,32},{0,9,161},{0,8,0},{0,8,128},{0,8,64},{0,9,225},{16,7,6},
- {0,8,88},{0,8,24},{0,9,145},{19,7,59},{0,8,120},{0,8,56},{0,9,209},
- {17,7,17},{0,8,104},{0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72},
- {0,9,241},{16,7,4},{0,8,84},{0,8,20},{21,8,227},{19,7,43},{0,8,116},
- {0,8,52},{0,9,201},{17,7,13},{0,8,100},{0,8,36},{0,9,169},{0,8,4},
- {0,8,132},{0,8,68},{0,9,233},{16,7,8},{0,8,92},{0,8,28},{0,9,153},
- {20,7,83},{0,8,124},{0,8,60},{0,9,217},{18,7,23},{0,8,108},{0,8,44},
- {0,9,185},{0,8,12},{0,8,140},{0,8,76},{0,9,249},{16,7,3},{0,8,82},
- {0,8,18},{21,8,163},{19,7,35},{0,8,114},{0,8,50},{0,9,197},{17,7,11},
- {0,8,98},{0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229},
- {16,7,7},{0,8,90},{0,8,26},{0,9,149},{20,7,67},{0,8,122},{0,8,58},
- {0,9,213},{18,7,19},{0,8,106},{0,8,42},{0,9,181},{0,8,10},{0,8,138},
- {0,8,74},{0,9,245},{16,7,5},{0,8,86},{0,8,22},{64,8,0},{19,7,51},
- {0,8,118},{0,8,54},{0,9,205},{17,7,15},{0,8,102},{0,8,38},{0,9,173},
- {0,8,6},{0,8,134},{0,8,70},{0,9,237},{16,7,9},{0,8,94},{0,8,30},
- {0,9,157},{20,7,99},{0,8,126},{0,8,62},{0,9,221},{18,7,27},{0,8,110},
- {0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253},{96,7,0},
- {0,8,81},{0,8,17},{21,8,131},{18,7,31},{0,8,113},{0,8,49},{0,9,195},
- {16,7,10},{0,8,97},{0,8,33},{0,9,163},{0,8,1},{0,8,129},{0,8,65},
- {0,9,227},{16,7,6},{0,8,89},{0,8,25},{0,9,147},{19,7,59},{0,8,121},
- {0,8,57},{0,9,211},{17,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9},
- {0,8,137},{0,8,73},{0,9,243},{16,7,4},{0,8,85},{0,8,21},{16,8,258},
- {19,7,43},{0,8,117},{0,8,53},{0,9,203},{17,7,13},{0,8,101},{0,8,37},
- {0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235},{16,7,8},{0,8,93},
- {0,8,29},{0,9,155},{20,7,83},{0,8,125},{0,8,61},{0,9,219},{18,7,23},
- {0,8,109},{0,8,45},{0,9,187},{0,8,13},{0,8,141},{0,8,77},{0,9,251},
- {16,7,3},{0,8,83},{0,8,19},{21,8,195},{19,7,35},{0,8,115},{0,8,51},
- {0,9,199},{17,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131},
- {0,8,67},{0,9,231},{16,7,7},{0,8,91},{0,8,27},{0,9,151},{20,7,67},
- {0,8,123},{0,8,59},{0,9,215},{18,7,19},{0,8,107},{0,8,43},{0,9,183},
- {0,8,11},{0,8,139},{0,8,75},{0,9,247},{16,7,5},{0,8,87},{0,8,23},
- {64,8,0},{19,7,51},{0,8,119},{0,8,55},{0,9,207},{17,7,15},{0,8,103},
- {0,8,39},{0,9,175},{0,8,7},{0,8,135},{0,8,71},{0,9,239},{16,7,9},
- {0,8,95},{0,8,31},{0,9,159},{20,7,99},{0,8,127},{0,8,63},{0,9,223},
- {18,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143},{0,8,79},
- {0,9,255}
- };
-
- static const code distfix[32] = {
- {16,5,1},{23,5,257},{19,5,17},{27,5,4097},{17,5,5},{25,5,1025},
- {21,5,65},{29,5,16385},{16,5,3},{24,5,513},{20,5,33},{28,5,8193},
- {18,5,9},{26,5,2049},{22,5,129},{64,5,0},{16,5,2},{23,5,385},
- {19,5,25},{27,5,6145},{17,5,7},{25,5,1537},{21,5,97},{29,5,24577},
- {16,5,4},{24,5,769},{20,5,49},{28,5,12289},{18,5,13},{26,5,3073},
- {22,5,193},{64,5,0}
- };
diff --git a/klibc/klibc/zlib/inflate.c b/klibc/klibc/zlib/inflate.c
deleted file mode 100644
index a53b5c7446..0000000000
--- a/klibc/klibc/zlib/inflate.c
+++ /dev/null
@@ -1,1270 +0,0 @@
-/* inflate.c -- zlib decompression
- * Copyright (C) 1995-2003 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/*
- * Change history:
- *
- * 1.2.beta0 24 Nov 2002
- * - First version -- complete rewrite of inflate to simplify code, avoid
- * creation of window when not needed, minimize use of window when it is
- * needed, make inffast.c even faster, implement gzip decoding, and to
- * improve code readability and style over the previous zlib inflate code
- *
- * 1.2.beta1 25 Nov 2002
- * - Use pointers for available input and output checking in inffast.c
- * - Remove input and output counters in inffast.c
- * - Change inffast.c entry and loop from avail_in >= 7 to >= 6
- * - Remove unnecessary second byte pull from length extra in inffast.c
- * - Unroll direct copy to three copies per loop in inffast.c
- *
- * 1.2.beta2 4 Dec 2002
- * - Change external routine names to reduce potential conflicts
- * - Correct filename to inffixed.h for fixed tables in inflate.c
- * - Make hbuf[] unsigned char to match parameter type in inflate.c
- * - Change strm->next_out[-state->offset] to *(strm->next_out - state->offset)
- * to avoid negation problem on Alphas (64 bit) in inflate.c
- *
- * 1.2.beta3 22 Dec 2002
- * - Add comments on state->bits assertion in inffast.c
- * - Add comments on op field in inftrees.h
- * - Fix bug in reuse of allocated window after inflateReset()
- * - Remove bit fields--back to byte structure for speed
- * - Remove distance extra == 0 check in inflate_fast()--only helps for lengths
- * - Change post-increments to pre-increments in inflate_fast(), PPC biased?
- * - Add compile time option, POSTINC, to use post-increments instead (Intel?)
- * - Make MATCH copy in inflate() much faster for when inflate_fast() not used
- * - Use local copies of stream next and avail values, as well as local bit
- * buffer and bit count in inflate()--for speed when inflate_fast() not used
- *
- * 1.2.beta4 1 Jan 2003
- * - Split ptr - 257 statements in inflate_table() to avoid compiler warnings
- * - Move a comment on output buffer sizes from inffast.c to inflate.c
- * - Add comments in inffast.c to introduce the inflate_fast() routine
- * - Rearrange window copies in inflate_fast() for speed and simplification
- * - Unroll last copy for window match in inflate_fast()
- * - Use local copies of window variables in inflate_fast() for speed
- * - Pull out common write == 0 case for speed in inflate_fast()
- * - Make op and len in inflate_fast() unsigned for consistency
- * - Add FAR to lcode and dcode declarations in inflate_fast()
- * - Simplified bad distance check in inflate_fast()
- * - Added inflateBackInit(), inflateBack(), and inflateBackEnd() in new
- * source file infback.c to provide a call-back interface to inflate for
- * programs like gzip and unzip -- uses window as output buffer to avoid
- * window copying
- *
- * 1.2.beta5 1 Jan 2003
- * - Improved inflateBack() interface to allow the caller to provide initial
- * input in strm.
- * - Fixed stored blocks bug in inflateBack()
- *
- * 1.2.beta6 4 Jan 2003
- * - Added comments in inffast.c on effectiveness of POSTINC
- * - Typecasting all around to reduce compiler warnings
- * - Changed loops from while (1) or do {} while (1) to for (;;), again to
- * make compilers happy
- * - Changed type of window in inflateBackInit() to unsigned char *
- *
- * 1.2.beta7 27 Jan 2003
- * - Changed many types to unsigned or unsigned short to avoid warnings
- * - Added inflateCopy() function
- *
- * 1.2.0 9 Mar 2003
- * - Changed inflateBack() interface to provide separate opaque descriptors
- * for the in() and out() functions
- * - Changed inflateBack() argument and in_func typedef to swap the length
- * and buffer address return values for the input function
- * - Check next_in and next_out for Z_NULL on entry to inflate()
- *
- * The history for versions after 1.2.0 are in ChangeLog in zlib distribution.
- */
-
-#include "zutil.h"
-#include "inftrees.h"
-#include "inflate.h"
-#include "inffast.h"
-
-#ifdef MAKEFIXED
-# ifndef BUILDFIXED
-# define BUILDFIXED
-# endif
-#endif
-
-/* function prototypes */
-local void fixedtables OF((struct inflate_state FAR *state));
-local int updatewindow OF((z_streamp strm, unsigned out));
-#ifdef BUILDFIXED
- void makefixed OF((void));
-#endif
-local unsigned syncsearch OF((unsigned FAR *have, unsigned char FAR *buf,
- unsigned len));
-
-int ZEXPORT inflateReset(strm)
-z_streamp strm;
-{
- struct inflate_state FAR *state;
-
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
- state = (struct inflate_state FAR *)strm->state;
- strm->total_in = strm->total_out = state->total = 0;
- strm->msg = Z_NULL;
- state->mode = HEAD;
- state->last = 0;
- state->havedict = 0;
- state->wsize = 0;
- state->whave = 0;
- state->hold = 0;
- state->bits = 0;
- state->lencode = state->distcode = state->next = state->codes;
- Tracev((stderr, "inflate: reset\n"));
- return Z_OK;
-}
-
-int ZEXPORT inflateInit2_(strm, windowBits, version, stream_size)
-z_streamp strm;
-int windowBits;
-const char *version;
-int stream_size;
-{
- struct inflate_state FAR *state;
-
- if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
- stream_size != (int)(sizeof(z_stream)))
- return Z_VERSION_ERROR;
- if (strm == Z_NULL) return Z_STREAM_ERROR;
- strm->msg = Z_NULL; /* in case we return an error */
- if (strm->zalloc == (alloc_func)0) {
- strm->zalloc = zcalloc;
- strm->opaque = (voidpf)0;
- }
- if (strm->zfree == (free_func)0) strm->zfree = zcfree;
- state = (struct inflate_state FAR *)
- ZALLOC(strm, 1, sizeof(struct inflate_state));
- if (state == Z_NULL) return Z_MEM_ERROR;
- Tracev((stderr, "inflate: allocated\n"));
- strm->state = (voidpf)state;
- if (windowBits < 0) {
- state->wrap = 0;
- windowBits = -windowBits;
- }
- else {
- state->wrap = (windowBits >> 4) + 1;
-#ifdef GUNZIP
- if (windowBits < 48) windowBits &= 15;
-#endif
- }
- if (windowBits < 8 || windowBits > 15) {
- ZFREE(strm, state);
- strm->state = Z_NULL;
- return Z_STREAM_ERROR;
- }
- state->wbits = (unsigned)windowBits;
- state->window = Z_NULL;
- return inflateReset(strm);
-}
-
-int ZEXPORT inflateInit_(strm, version, stream_size)
-z_streamp strm;
-const char *version;
-int stream_size;
-{
- return inflateInit2_(strm, DEF_WBITS, version, stream_size);
-}
-
-/*
- Return state with length and distance decoding tables and index sizes set to
- fixed code decoding. Normally this returns fixed tables from inffixed.h.
- If BUILDFIXED is defined, then instead this routine builds the tables the
- first time it's called, and returns those tables the first time and
- thereafter. This reduces the size of the code by about 2K bytes, in
- exchange for a little execution time. However, BUILDFIXED should not be
- used for threaded applications, since the rewriting of the tables and virgin
- may not be thread-safe.
- */
-local void fixedtables(state)
-struct inflate_state FAR *state;
-{
-#ifdef BUILDFIXED
- static int virgin = 1;
- static code *lenfix, *distfix;
- static code fixed[544];
-
- /* build fixed huffman tables if first call (may not be thread safe) */
- if (virgin) {
- unsigned sym, bits;
- static code *next;
-
- /* literal/length table */
- sym = 0;
- while (sym < 144) state->lens[sym++] = 8;
- while (sym < 256) state->lens[sym++] = 9;
- while (sym < 280) state->lens[sym++] = 7;
- while (sym < 288) state->lens[sym++] = 8;
- next = fixed;
- lenfix = next;
- bits = 9;
- inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work);
-
- /* distance table */
- sym = 0;
- while (sym < 32) state->lens[sym++] = 5;
- distfix = next;
- bits = 5;
- inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work);
-
- /* do this just once */
- virgin = 0;
- }
-#else /* !BUILDFIXED */
-# include "inffixed.h"
-#endif /* BUILDFIXED */
- state->lencode = lenfix;
- state->lenbits = 9;
- state->distcode = distfix;
- state->distbits = 5;
-}
-
-#ifdef MAKEFIXED
-#include <stdio.h>
-
-/*
- Write out the inffixed.h that is #include'd above. Defining MAKEFIXED also
- defines BUILDFIXED, so the tables are built on the fly. makefixed() writes
- those tables to stdout, which would be piped to inffixed.h. A small program
- can simply call makefixed to do this:
-
- void makefixed(void);
-
- int main(void)
- {
- makefixed();
- return 0;
- }
-
- Then that can be linked with zlib built with MAKEFIXED defined and run:
-
- a.out > inffixed.h
- */
-void makefixed()
-{
- unsigned low, size;
- struct inflate_state state;
-
- fixedtables(&state);
- puts(" /* inffixed.h -- table for decoding fixed codes");
- puts(" * Generated automatically by makefixed().");
- puts(" */");
- puts("");
- puts(" /* WARNING: this file should *not* be used by applications.");
- puts(" It is part of the implementation of this library and is");
- puts(" subject to change. Applications should only use zlib.h.");
- puts(" */");
- puts("");
- size = 1U << 9;
- printf(" static const code lenfix[%u] = {", size);
- low = 0;
- for (;;) {
- if ((low % 7) == 0) printf("\n ");
- printf("{%u,%u,%d}", state.lencode[low].op, state.lencode[low].bits,
- state.lencode[low].val);
- if (++low == size) break;
- putchar(',');
- }
- puts("\n };");
- size = 1U << 5;
- printf("\n static const code distfix[%u] = {", size);
- low = 0;
- for (;;) {
- if ((low % 6) == 0) printf("\n ");
- printf("{%u,%u,%d}", state.distcode[low].op, state.distcode[low].bits,
- state.distcode[low].val);
- if (++low == size) break;
- putchar(',');
- }
- puts("\n };");
-}
-#endif /* MAKEFIXED */
-
-/*
- Update the window with the last wsize (normally 32K) bytes written before
- returning. If window does not exist yet, create it. This is only called
- when a window is already in use, or when output has been written during this
- inflate call, but the end of the deflate stream has not been reached yet.
- It is also called to create a window for dictionary data when a dictionary
- is loaded.
-
- Providing output buffers larger than 32K to inflate() should provide a speed
- advantage, since only the last 32K of output is copied to the sliding window
- upon return from inflate(), and since all distances after the first 32K of
- output will fall in the output data, making match copies simpler and faster.
- The advantage may be dependent on the size of the processor's data caches.
- */
-local int updatewindow(strm, out)
-z_streamp strm;
-unsigned out;
-{
- struct inflate_state FAR *state;
- unsigned copy, dist;
-
- state = (struct inflate_state FAR *)strm->state;
-
- /* if it hasn't been done already, allocate space for the window */
- if (state->window == Z_NULL) {
- state->window = (unsigned char FAR *)
- ZALLOC(strm, 1U << state->wbits,
- sizeof(unsigned char));
- if (state->window == Z_NULL) return 1;
- }
-
- /* if window not in use yet, initialize */
- if (state->wsize == 0) {
- state->wsize = 1U << state->wbits;
- state->write = 0;
- state->whave = 0;
- }
-
- /* copy state->wsize or less output bytes into the circular window */
- copy = out - strm->avail_out;
- if (copy >= state->wsize) {
- zmemcpy(state->window, strm->next_out - state->wsize, state->wsize);
- state->write = 0;
- state->whave = state->wsize;
- }
- else {
- dist = state->wsize - state->write;
- if (dist > copy) dist = copy;
- zmemcpy(state->window + state->write, strm->next_out - copy, dist);
- copy -= dist;
- if (copy) {
- zmemcpy(state->window, strm->next_out - copy, copy);
- state->write = copy;
- state->whave = state->wsize;
- }
- else {
- state->write += dist;
- if (state->write == state->wsize) state->write = 0;
- if (state->whave < state->wsize) state->whave += dist;
- }
- }
- return 0;
-}
-
-/* Macros for inflate(): */
-
-/* check function to use adler32() for zlib or crc32() for gzip */
-#ifdef GUNZIP
-# define UPDATE(check, buf, len) \
- (state->flags ? crc32(check, buf, len) : adler32(check, buf, len))
-#else
-# define UPDATE(check, buf, len) adler32(check, buf, len)
-#endif
-
-/* check macros for header crc */
-#ifdef GUNZIP
-# define CRC2(check, word) \
- do { \
- hbuf[0] = (unsigned char)(word); \
- hbuf[1] = (unsigned char)((word) >> 8); \
- check = crc32(check, hbuf, 2); \
- } while (0)
-
-# define CRC4(check, word) \
- do { \
- hbuf[0] = (unsigned char)(word); \
- hbuf[1] = (unsigned char)((word) >> 8); \
- hbuf[2] = (unsigned char)((word) >> 16); \
- hbuf[3] = (unsigned char)((word) >> 24); \
- check = crc32(check, hbuf, 4); \
- } while (0)
-#endif
-
-/* Load registers with state in inflate() for speed */
-#define LOAD() \
- do { \
- put = strm->next_out; \
- left = strm->avail_out; \
- next = strm->next_in; \
- have = strm->avail_in; \
- hold = state->hold; \
- bits = state->bits; \
- } while (0)
-
-/* Restore state from registers in inflate() */
-#define RESTORE() \
- do { \
- strm->next_out = put; \
- strm->avail_out = left; \
- strm->next_in = next; \
- strm->avail_in = have; \
- state->hold = hold; \
- state->bits = bits; \
- } while (0)
-
-/* Clear the input bit accumulator */
-#define INITBITS() \
- do { \
- hold = 0; \
- bits = 0; \
- } while (0)
-
-/* Get a byte of input into the bit accumulator, or return from inflate()
- if there is no input available. */
-#define PULLBYTE() \
- do { \
- if (have == 0) goto inf_leave; \
- have--; \
- hold += (unsigned long)(*next++) << bits; \
- bits += 8; \
- } while (0)
-
-/* Assure that there are at least n bits in the bit accumulator. If there is
- not enough available input to do that, then return from inflate(). */
-#define NEEDBITS(n) \
- do { \
- while (bits < (unsigned)(n)) \
- PULLBYTE(); \
- } while (0)
-
-/* Return the low n bits of the bit accumulator (n < 16) */
-#define BITS(n) \
- ((unsigned)hold & ((1U << (n)) - 1))
-
-/* Remove n bits from the bit accumulator */
-#define DROPBITS(n) \
- do { \
- hold >>= (n); \
- bits -= (unsigned)(n); \
- } while (0)
-
-/* Remove zero to seven bits as needed to go to a byte boundary */
-#define BYTEBITS() \
- do { \
- hold >>= bits & 7; \
- bits -= bits & 7; \
- } while (0)
-
-/* Reverse the bytes in a 32-bit value */
-#define REVERSE(q) \
- ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \
- (((q) & 0xff00) << 8) + (((q) & 0xff) << 24))
-
-/*
- inflate() uses a state machine to process as much input data and generate as
- much output data as possible before returning. The state machine is
- structured roughly as follows:
-
- for (;;) switch (state) {
- ...
- case STATEn:
- if (not enough input data or output space to make progress)
- return;
- ... make progress ...
- state = STATEm;
- break;
- ...
- }
-
- so when inflate() is called again, the same case is attempted again, and
- if the appropriate resources are provided, the machine proceeds to the
- next state. The NEEDBITS() macro is usually the way the state evaluates
- whether it can proceed or should return. NEEDBITS() does the return if
- the requested bits are not available. The typical use of the BITS macros
- is:
-
- NEEDBITS(n);
- ... do something with BITS(n) ...
- DROPBITS(n);
-
- where NEEDBITS(n) either returns from inflate() if there isn't enough
- input left to load n bits into the accumulator, or it continues. BITS(n)
- gives the low n bits in the accumulator. When done, DROPBITS(n) drops
- the low n bits off the accumulator. INITBITS() clears the accumulator
- and sets the number of available bits to zero. BYTEBITS() discards just
- enough bits to put the accumulator on a byte boundary. After BYTEBITS()
- and a NEEDBITS(8), then BITS(8) would return the next byte in the stream.
-
- NEEDBITS(n) uses PULLBYTE() to get an available byte of input, or to return
- if there is no input available. The decoding of variable length codes uses
- PULLBYTE() directly in order to pull just enough bytes to decode the next
- code, and no more.
-
- Some states loop until they get enough input, making sure that enough
- state information is maintained to continue the loop where it left off
- if NEEDBITS() returns in the loop. For example, want, need, and keep
- would all have to actually be part of the saved state in case NEEDBITS()
- returns:
-
- case STATEw:
- while (want < need) {
- NEEDBITS(n);
- keep[want++] = BITS(n);
- DROPBITS(n);
- }
- state = STATEx;
- case STATEx:
-
- As shown above, if the next state is also the next case, then the break
- is omitted.
-
- A state may also return if there is not enough output space available to
- complete that state. Those states are copying stored data, writing a
- literal byte, and copying a matching string.
-
- When returning, a "goto inf_leave" is used to update the total counters,
- update the check value, and determine whether any progress has been made
- during that inflate() call in order to return the proper return code.
- Progress is defined as a change in either strm->avail_in or strm->avail_out.
- When there is a window, goto inf_leave will update the window with the last
- output written. If a goto inf_leave occurs in the middle of decompression
- and there is no window currently, goto inf_leave will create one and copy
- output to the window for the next call of inflate().
-
- In this implementation, the flush parameter of inflate() only affects the
- return code (per zlib.h). inflate() always writes as much as possible to
- strm->next_out, given the space available and the provided input--the effect
- documented in zlib.h of Z_SYNC_FLUSH. Furthermore, inflate() always defers
- the allocation of and copying into a sliding window until necessary, which
- provides the effect documented in zlib.h for Z_FINISH when the entire input
- stream available. So the only thing the flush parameter actually does is:
- when flush is set to Z_FINISH, inflate() cannot return Z_OK. Instead it
- will return Z_BUF_ERROR if it has not reached the end of the stream.
- */
-
-int ZEXPORT inflate(strm, flush)
-z_streamp strm;
-int flush;
-{
- struct inflate_state FAR *state;
- unsigned char FAR *next; /* next input */
- unsigned char FAR *put; /* next output */
- unsigned have, left; /* available input and output */
- unsigned long hold; /* bit buffer */
- unsigned bits; /* bits in bit buffer */
- unsigned in, out; /* save starting available input and output */
- unsigned copy; /* number of stored or match bytes to copy */
- unsigned char FAR *from; /* where to copy match bytes from */
- code this; /* current decoding table entry */
- code last; /* parent table entry */
- unsigned len; /* length to copy for repeats, bits to drop */
- int ret; /* return code */
-#ifdef GUNZIP
- unsigned char hbuf[4]; /* buffer for gzip header crc calculation */
-#endif
- static const unsigned short order[19] = /* permutation of code lengths */
- {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
-
- if (strm == Z_NULL || strm->state == Z_NULL || strm->next_out == Z_NULL ||
- (strm->next_in == Z_NULL && strm->avail_in != 0))
- return Z_STREAM_ERROR;
-
- state = (struct inflate_state FAR *)strm->state;
- if (state->mode == TYPE) state->mode = TYPEDO; /* skip check */
- LOAD();
- in = have;
- out = left;
- ret = Z_OK;
- for (;;)
- switch (state->mode) {
- case HEAD:
- if (state->wrap == 0) {
- state->mode = TYPEDO;
- break;
- }
- NEEDBITS(16);
-#ifdef GUNZIP
- if ((state->wrap & 2) && hold == 0x8b1f) { /* gzip header */
- state->check = crc32(0L, Z_NULL, 0);
- CRC2(state->check, hold);
- INITBITS();
- state->mode = FLAGS;
- break;
- }
- state->flags = 0; /* expect zlib header */
- if (!(state->wrap & 1) || /* check if zlib header allowed */
-#else
- if (
-#endif
- ((BITS(8) << 8) + (hold >> 8)) % 31) {
- strm->msg = (char *)"incorrect header check";
- state->mode = BAD;
- break;
- }
- if (BITS(4) != Z_DEFLATED) {
- strm->msg = (char *)"unknown compression method";
- state->mode = BAD;
- break;
- }
- DROPBITS(4);
- if (BITS(4) + 8 > state->wbits) {
- strm->msg = (char *)"invalid window size";
- state->mode = BAD;
- break;
- }
- Tracev((stderr, "inflate: zlib header ok\n"));
- strm->adler = state->check = adler32(0L, Z_NULL, 0);
- state->mode = hold & 0x200 ? DICTID : TYPE;
- INITBITS();
- break;
-#ifdef GUNZIP
- case FLAGS:
- NEEDBITS(16);
- state->flags = (int)(hold);
- if ((state->flags & 0xff) != Z_DEFLATED) {
- strm->msg = (char *)"unknown compression method";
- state->mode = BAD;
- break;
- }
- if (state->flags & 0xe000) {
- strm->msg = (char *)"unknown header flags set";
- state->mode = BAD;
- break;
- }
- if (state->flags & 0x0200) CRC2(state->check, hold);
- INITBITS();
- state->mode = TIME;
- case TIME:
- NEEDBITS(32);
- if (state->flags & 0x0200) CRC4(state->check, hold);
- INITBITS();
- state->mode = OS;
- case OS:
- NEEDBITS(16);
- if (state->flags & 0x0200) CRC2(state->check, hold);
- INITBITS();
- state->mode = EXLEN;
- case EXLEN:
- if (state->flags & 0x0400) {
- NEEDBITS(16);
- state->length = (unsigned)(hold);
- if (state->flags & 0x0200) CRC2(state->check, hold);
- INITBITS();
- }
- state->mode = EXTRA;
- case EXTRA:
- if (state->flags & 0x0400) {
- copy = state->length;
- if (copy > have) copy = have;
- if (copy) {
- if (state->flags & 0x0200)
- state->check = crc32(state->check, next, copy);
- have -= copy;
- next += copy;
- state->length -= copy;
- }
- if (state->length) goto inf_leave;
- }
- state->mode = NAME;
- case NAME:
- if (state->flags & 0x0800) {
- if (have == 0) goto inf_leave;
- copy = 0;
- do {
- len = (unsigned)(next[copy++]);
- } while (len && copy < have);
- if (state->flags & 0x02000)
- state->check = crc32(state->check, next, copy);
- have -= copy;
- next += copy;
- if (len) goto inf_leave;
- }
- state->mode = COMMENT;
- case COMMENT:
- if (state->flags & 0x1000) {
- if (have == 0) goto inf_leave;
- copy = 0;
- do {
- len = (unsigned)(next[copy++]);
- } while (len && copy < have);
- if (state->flags & 0x02000)
- state->check = crc32(state->check, next, copy);
- have -= copy;
- next += copy;
- if (len) goto inf_leave;
- }
- state->mode = HCRC;
- case HCRC:
- if (state->flags & 0x0200) {
- NEEDBITS(16);
- if (hold != (state->check & 0xffff)) {
- strm->msg = (char *)"header crc mismatch";
- state->mode = BAD;
- break;
- }
- INITBITS();
- }
- strm->adler = state->check = crc32(0L, Z_NULL, 0);
- state->mode = TYPE;
- break;
-#endif
- case DICTID:
- NEEDBITS(32);
- strm->adler = state->check = REVERSE(hold);
- INITBITS();
- state->mode = DICT;
- case DICT:
- if (state->havedict == 0) {
- RESTORE();
- return Z_NEED_DICT;
- }
- strm->adler = state->check = adler32(0L, Z_NULL, 0);
- state->mode = TYPE;
- case TYPE:
- if (flush == Z_BLOCK) goto inf_leave;
- case TYPEDO:
- if (state->last) {
- BYTEBITS();
- state->mode = CHECK;
- break;
- }
- NEEDBITS(3);
- state->last = BITS(1);
- DROPBITS(1);
- switch (BITS(2)) {
- case 0: /* stored block */
- Tracev((stderr, "inflate: stored block%s\n",
- state->last ? " (last)" : ""));
- state->mode = STORED;
- break;
- case 1: /* fixed block */
- fixedtables(state);
- Tracev((stderr, "inflate: fixed codes block%s\n",
- state->last ? " (last)" : ""));
- state->mode = LEN; /* decode codes */
- break;
- case 2: /* dynamic block */
- Tracev((stderr, "inflate: dynamic codes block%s\n",
- state->last ? " (last)" : ""));
- state->mode = TABLE;
- break;
- case 3:
- strm->msg = (char *)"invalid block type";
- state->mode = BAD;
- }
- DROPBITS(2);
- break;
- case STORED:
- BYTEBITS(); /* go to byte boundary */
- NEEDBITS(32);
- if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {
- strm->msg = (char *)"invalid stored block lengths";
- state->mode = BAD;
- break;
- }
- state->length = (unsigned)hold & 0xffff;
- Tracev((stderr, "inflate: stored length %u\n",
- state->length));
- INITBITS();
- state->mode = COPY;
- case COPY:
- copy = state->length;
- if (copy) {
- if (copy > have) copy = have;
- if (copy > left) copy = left;
- if (copy == 0) goto inf_leave;
- zmemcpy(put, next, copy);
- have -= copy;
- next += copy;
- left -= copy;
- put += copy;
- state->length -= copy;
- break;
- }
- Tracev((stderr, "inflate: stored end\n"));
- state->mode = TYPE;
- break;
- case TABLE:
- NEEDBITS(14);
- state->nlen = BITS(5) + 257;
- DROPBITS(5);
- state->ndist = BITS(5) + 1;
- DROPBITS(5);
- state->ncode = BITS(4) + 4;
- DROPBITS(4);
-#ifndef PKZIP_BUG_WORKAROUND
- if (state->nlen > 286 || state->ndist > 30) {
- strm->msg = (char *)"too many length or distance symbols";
- state->mode = BAD;
- break;
- }
-#endif
- Tracev((stderr, "inflate: table sizes ok\n"));
- state->have = 0;
- state->mode = LENLENS;
- case LENLENS:
- while (state->have < state->ncode) {
- NEEDBITS(3);
- state->lens[order[state->have++]] = (unsigned short)BITS(3);
- DROPBITS(3);
- }
- while (state->have < 19)
- state->lens[order[state->have++]] = 0;
- state->next = state->codes;
- state->lencode = (code const FAR *)(state->next);
- state->lenbits = 7;
- ret = inflate_table(CODES, state->lens, 19, &(state->next),
- &(state->lenbits), state->work);
- if (ret) {
- strm->msg = (char *)"invalid code lengths set";
- state->mode = BAD;
- break;
- }
- Tracev((stderr, "inflate: code lengths ok\n"));
- state->have = 0;
- state->mode = CODELENS;
- case CODELENS:
- while (state->have < state->nlen + state->ndist) {
- for (;;) {
- this = state->lencode[BITS(state->lenbits)];
- if ((unsigned)(this.bits) <= bits) break;
- PULLBYTE();
- }
- if (this.val < 16) {
- NEEDBITS(this.bits);
- DROPBITS(this.bits);
- state->lens[state->have++] = this.val;
- }
- else {
- if (this.val == 16) {
- NEEDBITS(this.bits + 2);
- DROPBITS(this.bits);
- if (state->have == 0) {
- strm->msg = (char *)"invalid bit length repeat";
- state->mode = BAD;
- break;
- }
- len = state->lens[state->have - 1];
- copy = 3 + BITS(2);
- DROPBITS(2);
- }
- else if (this.val == 17) {
- NEEDBITS(this.bits + 3);
- DROPBITS(this.bits);
- len = 0;
- copy = 3 + BITS(3);
- DROPBITS(3);
- }
- else {
- NEEDBITS(this.bits + 7);
- DROPBITS(this.bits);
- len = 0;
- copy = 11 + BITS(7);
- DROPBITS(7);
- }
- if (state->have + copy > state->nlen + state->ndist) {
- strm->msg = (char *)"invalid bit length repeat";
- state->mode = BAD;
- break;
- }
- while (copy--)
- state->lens[state->have++] = (unsigned short)len;
- }
- }
-
- /* build code tables */
- state->next = state->codes;
- state->lencode = (code const FAR *)(state->next);
- state->lenbits = 9;
- ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
- &(state->lenbits), state->work);
- if (ret) {
- strm->msg = (char *)"invalid literal/lengths set";
- state->mode = BAD;
- break;
- }
- state->distcode = (code const FAR *)(state->next);
- state->distbits = 6;
- ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
- &(state->next), &(state->distbits), state->work);
- if (ret) {
- strm->msg = (char *)"invalid distances set";
- state->mode = BAD;
- break;
- }
- Tracev((stderr, "inflate: codes ok\n"));
- state->mode = LEN;
- case LEN:
- if (have >= 6 && left >= 258) {
- RESTORE();
- inflate_fast(strm, out);
- LOAD();
- break;
- }
- for (;;) {
- this = state->lencode[BITS(state->lenbits)];
- if ((unsigned)(this.bits) <= bits) break;
- PULLBYTE();
- }
- if (this.op && (this.op & 0xf0) == 0) {
- last = this;
- for (;;) {
- this = state->lencode[last.val +
- (BITS(last.bits + last.op) >> last.bits)];
- if ((unsigned)(last.bits + this.bits) <= bits) break;
- PULLBYTE();
- }
- DROPBITS(last.bits);
- }
- DROPBITS(this.bits);
- state->length = (unsigned)this.val;
- if ((int)(this.op) == 0) {
- Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ?
- "inflate: literal '%c'\n" :
- "inflate: literal 0x%02x\n", this.val));
- state->mode = LIT;
- break;
- }
- if (this.op & 32) {
- Tracevv((stderr, "inflate: end of block\n"));
- state->mode = TYPE;
- break;
- }
- if (this.op & 64) {
- strm->msg = (char *)"invalid literal/length code";
- state->mode = BAD;
- break;
- }
- state->extra = (unsigned)(this.op) & 15;
- state->mode = LENEXT;
- case LENEXT:
- if (state->extra) {
- NEEDBITS(state->extra);
- state->length += BITS(state->extra);
- DROPBITS(state->extra);
- }
- Tracevv((stderr, "inflate: length %u\n", state->length));
- state->mode = DIST;
- case DIST:
- for (;;) {
- this = state->distcode[BITS(state->distbits)];
- if ((unsigned)(this.bits) <= bits) break;
- PULLBYTE();
- }
- if ((this.op & 0xf0) == 0) {
- last = this;
- for (;;) {
- this = state->distcode[last.val +
- (BITS(last.bits + last.op) >> last.bits)];
- if ((unsigned)(last.bits + this.bits) <= bits) break;
- PULLBYTE();
- }
- DROPBITS(last.bits);
- }
- DROPBITS(this.bits);
- if (this.op & 64) {
- strm->msg = (char *)"invalid distance code";
- state->mode = BAD;
- break;
- }
- state->offset = (unsigned)this.val;
- state->extra = (unsigned)(this.op) & 15;
- state->mode = DISTEXT;
- case DISTEXT:
- if (state->extra) {
- NEEDBITS(state->extra);
- state->offset += BITS(state->extra);
- DROPBITS(state->extra);
- }
- if (state->offset > state->whave + out - left) {
- strm->msg = (char *)"invalid distance too far back";
- state->mode = BAD;
- break;
- }
- Tracevv((stderr, "inflate: distance %u\n", state->offset));
- state->mode = MATCH;
- case MATCH:
- if (left == 0) goto inf_leave;
- copy = out - left;
- if (state->offset > copy) { /* copy from window */
- copy = state->offset - copy;
- if (copy > state->write) {
- copy -= state->write;
- from = state->window + (state->wsize - copy);
- }
- else
- from = state->window + (state->write - copy);
- if (copy > state->length) copy = state->length;
- }
- else { /* copy from output */
- from = put - state->offset;
- copy = state->length;
- }
- if (copy > left) copy = left;
- left -= copy;
- state->length -= copy;
- do {
- *put++ = *from++;
- } while (--copy);
- if (state->length == 0) state->mode = LEN;
- break;
- case LIT:
- if (left == 0) goto inf_leave;
- *put++ = (unsigned char)(state->length);
- left--;
- state->mode = LEN;
- break;
- case CHECK:
- if (state->wrap) {
- NEEDBITS(32);
- out -= left;
- strm->total_out += out;
- state->total += out;
- if (out)
- strm->adler = state->check =
- UPDATE(state->check, put - out, out);
- out = left;
- if ((
-#ifdef GUNZIP
- state->flags ? hold :
-#endif
- REVERSE(hold)) != state->check) {
- strm->msg = (char *)"incorrect data check";
- state->mode = BAD;
- break;
- }
- INITBITS();
- Tracev((stderr, "inflate: check matches trailer\n"));
- }
-#ifdef GUNZIP
- state->mode = LENGTH;
- case LENGTH:
- if (state->wrap && state->flags) {
- NEEDBITS(32);
- if (hold != (state->total & 0xffffffffUL)) {
- strm->msg = (char *)"incorrect length check";
- state->mode = BAD;
- break;
- }
- INITBITS();
- Tracev((stderr, "inflate: length matches trailer\n"));
- }
-#endif
- state->mode = DONE;
- case DONE:
- ret = Z_STREAM_END;
- goto inf_leave;
- case BAD:
- ret = Z_DATA_ERROR;
- goto inf_leave;
- case MEM:
- return Z_MEM_ERROR;
- case SYNC:
- default:
- return Z_STREAM_ERROR;
- }
-
- /*
- Return from inflate(), updating the total counts and the check value.
- If there was no progress during the inflate() call, return a buffer
- error. Call updatewindow() to create and/or update the window state.
- Note: a memory error from inflate() is non-recoverable.
- */
- inf_leave:
- RESTORE();
- if (state->wsize || (state->mode < CHECK && out != strm->avail_out))
- if (updatewindow(strm, out)) {
- state->mode = MEM;
- return Z_MEM_ERROR;
- }
- in -= strm->avail_in;
- out -= strm->avail_out;
- strm->total_in += in;
- strm->total_out += out;
- state->total += out;
- if (state->wrap && out)
- strm->adler = state->check =
- UPDATE(state->check, strm->next_out - out, out);
- strm->data_type = state->bits + (state->last ? 64 : 0) +
- (state->mode == TYPE ? 128 : 0);
- if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK)
- ret = Z_BUF_ERROR;
- return ret;
-}
-
-int ZEXPORT inflateEnd(strm)
-z_streamp strm;
-{
- struct inflate_state FAR *state;
- if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
- return Z_STREAM_ERROR;
- state = (struct inflate_state FAR *)strm->state;
- if (state->window != Z_NULL) ZFREE(strm, state->window);
- ZFREE(strm, strm->state);
- strm->state = Z_NULL;
- Tracev((stderr, "inflate: end\n"));
- return Z_OK;
-}
-
-int ZEXPORT inflateSetDictionary(strm, dictionary, dictLength)
-z_streamp strm;
-const Bytef *dictionary;
-uInt dictLength;
-{
- struct inflate_state FAR *state;
- unsigned long id;
-
- /* check state */
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
- state = (struct inflate_state FAR *)strm->state;
- if (state->mode != DICT) return Z_STREAM_ERROR;
-
- /* check for correct dictionary id */
- id = adler32(0L, Z_NULL, 0);
- id = adler32(id, dictionary, dictLength);
- if (id != state->check) return Z_DATA_ERROR;
-
- /* copy dictionary to window */
- if (updatewindow(strm, strm->avail_out)) {
- state->mode = MEM;
- return Z_MEM_ERROR;
- }
- if (dictLength > state->wsize) {
- zmemcpy(state->window, dictionary + dictLength - state->wsize,
- state->wsize);
- state->whave = state->wsize;
- }
- else {
- zmemcpy(state->window + state->wsize - dictLength, dictionary,
- dictLength);
- state->whave = dictLength;
- }
- state->havedict = 1;
- Tracev((stderr, "inflate: dictionary set\n"));
- return Z_OK;
-}
-
-/*
- Search buf[0..len-1] for the pattern: 0, 0, 0xff, 0xff. Return when found
- or when out of input. When called, *have is the number of pattern bytes
- found in order so far, in 0..3. On return *have is updated to the new
- state. If on return *have equals four, then the pattern was found and the
- return value is how many bytes were read including the last byte of the
- pattern. If *have is less than four, then the pattern has not been found
- yet and the return value is len. In the latter case, syncsearch() can be
- called again with more data and the *have state. *have is initialized to
- zero for the first call.
- */
-local unsigned syncsearch(have, buf, len)
-unsigned FAR *have;
-unsigned char FAR *buf;
-unsigned len;
-{
- unsigned got;
- unsigned next;
-
- got = *have;
- next = 0;
- while (next < len && got < 4) {
- if ((int)(buf[next]) == (got < 2 ? 0 : 0xff))
- got++;
- else if (buf[next])
- got = 0;
- else
- got = 4 - got;
- next++;
- }
- *have = got;
- return next;
-}
-
-int ZEXPORT inflateSync(strm)
-z_streamp strm;
-{
- unsigned len; /* number of bytes to look at or looked at */
- unsigned long in, out; /* temporary to save total_in and total_out */
- unsigned char buf[4]; /* to restore bit buffer to byte string */
- struct inflate_state FAR *state;
-
- /* check parameters */
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
- state = (struct inflate_state FAR *)strm->state;
- if (strm->avail_in == 0 && state->bits < 8) return Z_BUF_ERROR;
-
- /* if first time, start search in bit buffer */
- if (state->mode != SYNC) {
- state->mode = SYNC;
- state->hold <<= state->bits & 7;
- state->bits -= state->bits & 7;
- len = 0;
- while (state->bits >= 8) {
- buf[len++] = (unsigned char)(state->hold);
- state->hold >>= 8;
- state->bits -= 8;
- }
- state->have = 0;
- syncsearch(&(state->have), buf, len);
- }
-
- /* search available input */
- len = syncsearch(&(state->have), strm->next_in, strm->avail_in);
- strm->avail_in -= len;
- strm->next_in += len;
- strm->total_in += len;
-
- /* return no joy or set up to restart inflate() on a new block */
- if (state->have != 4) return Z_DATA_ERROR;
- in = strm->total_in; out = strm->total_out;
- inflateReset(strm);
- strm->total_in = in; strm->total_out = out;
- state->mode = TYPE;
- return Z_OK;
-}
-
-/*
- Returns true if inflate is currently at the end of a block generated by
- Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP
- implementation to provide an additional safety check. PPP uses
- Z_SYNC_FLUSH but removes the length bytes of the resulting empty stored
- block. When decompressing, PPP checks that at the end of input packet,
- inflate is waiting for these length bytes.
- */
-int ZEXPORT inflateSyncPoint(strm)
-z_streamp strm;
-{
- struct inflate_state FAR *state;
-
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
- state = (struct inflate_state FAR *)strm->state;
- return state->mode == STORED && state->bits == 0;
-}
-
-int ZEXPORT inflateCopy(dest, source)
-z_streamp dest;
-z_streamp source;
-{
- struct inflate_state FAR *state;
- struct inflate_state FAR *copy;
- unsigned char FAR *window;
-
- /* check input */
- if (dest == Z_NULL || source == Z_NULL || source->state == Z_NULL ||
- source->zalloc == (alloc_func)0 || source->zfree == (free_func)0)
- return Z_STREAM_ERROR;
- state = (struct inflate_state FAR *)source->state;
-
- /* allocate space */
- copy = (struct inflate_state FAR *)
- ZALLOC(source, 1, sizeof(struct inflate_state));
- if (copy == Z_NULL) return Z_MEM_ERROR;
- window = Z_NULL;
- if (state->window != Z_NULL) {
- window = (unsigned char FAR *)
- ZALLOC(source, 1U << state->wbits, sizeof(unsigned char));
- if (window == Z_NULL) {
- ZFREE(source, copy);
- return Z_MEM_ERROR;
- }
- }
-
- /* copy state */
- *dest = *source;
- *copy = *state;
- copy->lencode = copy->codes + (state->lencode - state->codes);
- copy->distcode = copy->codes + (state->distcode - state->codes);
- copy->next = copy->codes + (state->next - state->codes);
- if (window != Z_NULL)
- zmemcpy(window, state->window, 1U << state->wbits);
- copy->window = window;
- dest->state = (voidpf)copy;
- return Z_OK;
-}
diff --git a/klibc/klibc/zlib/inflate.h b/klibc/klibc/zlib/inflate.h
deleted file mode 100644
index 9a12c8fd29..0000000000
--- a/klibc/klibc/zlib/inflate.h
+++ /dev/null
@@ -1,117 +0,0 @@
-/* inflate.h -- internal inflate state definition
- * Copyright (C) 1995-2003 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* WARNING: this file should *not* be used by applications. It is
- part of the implementation of the compression library and is
- subject to change. Applications should only use zlib.h.
- */
-
-/* define NO_GZIP when compiling if you want to disable gzip header and
- trailer decoding by inflate(). NO_GZIP would be used to avoid linking in
- the crc code when it is not needed. For shared libraries, gzip decoding
- should be left enabled. */
-#ifndef NO_GZIP
-# define GUNZIP
-#endif
-
-/* Possible inflate modes between inflate() calls */
-typedef enum {
- HEAD, /* i: waiting for magic header */
-#ifdef GUNZIP
- FLAGS, /* i: waiting for method and flags (gzip) */
- TIME, /* i: waiting for modification time (gzip) */
- OS, /* i: waiting for extra flags and operating system (gzip) */
- EXLEN, /* i: waiting for extra length (gzip) */
- EXTRA, /* i: waiting for extra bytes (gzip) */
- NAME, /* i: waiting for end of file name (gzip) */
- COMMENT, /* i: waiting for end of comment (gzip) */
- HCRC, /* i: waiting for header crc (gzip) */
-#endif
- DICTID, /* i: waiting for dictionary check value */
- DICT, /* waiting for inflateSetDictionary() call */
- TYPE, /* i: waiting for type bits, including last-flag bit */
- TYPEDO, /* i: same, but skip check to exit inflate on new block */
- STORED, /* i: waiting for stored size (length and complement) */
- COPY, /* i/o: waiting for input or output to copy stored block */
- TABLE, /* i: waiting for dynamic block table lengths */
- LENLENS, /* i: waiting for code length code lengths */
- CODELENS, /* i: waiting for length/lit and distance code lengths */
- LEN, /* i: waiting for length/lit code */
- LENEXT, /* i: waiting for length extra bits */
- DIST, /* i: waiting for distance code */
- DISTEXT, /* i: waiting for distance extra bits */
- MATCH, /* o: waiting for output space to copy string */
- LIT, /* o: waiting for output space to write literal */
- CHECK, /* i: waiting for 32-bit check value */
-#ifdef GUNZIP
- LENGTH, /* i: waiting for 32-bit length (gzip) */
-#endif
- DONE, /* finished check, done -- remain here until reset */
- BAD, /* got a data error -- remain here until reset */
- MEM, /* got an inflate() memory error -- remain here until reset */
- SYNC /* looking for synchronization bytes to restart inflate() */
-} inflate_mode;
-
-/*
- State transitions between above modes -
-
- (most modes can go to the BAD or MEM mode -- not shown for clarity)
-
- Process header:
- HEAD -> (gzip) or (zlib)
- (gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME
- NAME -> COMMENT -> HCRC -> TYPE
- (zlib) -> DICTID or TYPE
- DICTID -> DICT -> TYPE
- Read deflate blocks:
- TYPE -> STORED or TABLE or LEN or CHECK
- STORED -> COPY -> TYPE
- TABLE -> LENLENS -> CODELENS -> LEN
- Read deflate codes:
- LEN -> LENEXT or LIT or TYPE
- LENEXT -> DIST -> DISTEXT -> MATCH -> LEN
- LIT -> LEN
- Process trailer:
- CHECK -> LENGTH -> DONE
- */
-
-/* state maintained between inflate() calls. Approximately 7K bytes. */
-struct inflate_state {
- inflate_mode mode; /* current inflate mode */
- int last; /* true if processing last block */
- int wrap; /* bit 0 true for zlib, bit 1 true for gzip */
- int havedict; /* true if dictionary provided */
- int flags; /* gzip header method and flags (0 if zlib) */
- unsigned long check; /* protected copy of check value */
- unsigned long total; /* protected copy of output count */
- /* sliding window */
- unsigned wbits; /* log base 2 of requested window size */
- unsigned wsize; /* window size or zero if not using window */
- unsigned whave; /* valid bytes in the window */
- unsigned write; /* window write index */
- unsigned char FAR *window; /* allocated sliding window, if needed */
- /* bit accumulator */
- unsigned long hold; /* input bit accumulator */
- unsigned bits; /* number of bits in "in" */
- /* for string and stored block copying */
- unsigned length; /* literal or length of data to copy */
- unsigned offset; /* distance back to copy string from */
- /* for table and code decoding */
- unsigned extra; /* extra bits needed */
- /* fixed and dynamic code tables */
- code const FAR *lencode; /* starting table for length/literal codes */
- code const FAR *distcode; /* starting table for distance codes */
- unsigned lenbits; /* index bits for lencode */
- unsigned distbits; /* index bits for distcode */
- /* dynamic table building */
- unsigned ncode; /* number of code length code lengths */
- unsigned nlen; /* number of length code lengths */
- unsigned ndist; /* number of distance code lengths */
- unsigned have; /* number of code lengths in lens[] */
- code FAR *next; /* next available space in codes[] */
- unsigned short lens[320]; /* temporary storage for code lengths */
- unsigned short work[288]; /* work area for code table building */
- code codes[ENOUGH]; /* space for code tables */
-};
diff --git a/klibc/klibc/zlib/inftrees.c b/klibc/klibc/zlib/inftrees.c
deleted file mode 100644
index 3bb56398e1..0000000000
--- a/klibc/klibc/zlib/inftrees.c
+++ /dev/null
@@ -1,321 +0,0 @@
-/* inftrees.c -- generate Huffman trees for efficient decoding
- * Copyright (C) 1995-2003 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-#include "zutil.h"
-#include "inftrees.h"
-
-#define MAXBITS 15
-
-const char inflate_copyright[] =
- " inflate 1.2.1 Copyright 1995-2003 Mark Adler ";
-/*
- If you use the zlib library in a product, an acknowledgment is welcome
- in the documentation of your product. If for some reason you cannot
- include such an acknowledgment, I would appreciate that you keep this
- copyright string in the executable of your product.
- */
-
-/*
- Build a set of tables to decode the provided canonical Huffman code.
- The code lengths are lens[0..codes-1]. The result starts at *table,
- whose indices are 0..2^bits-1. work is a writable array of at least
- lens shorts, which is used as a work area. type is the type of code
- to be generated, CODES, LENS, or DISTS. On return, zero is success,
- -1 is an invalid code, and +1 means that ENOUGH isn't enough. table
- on return points to the next available entry's address. bits is the
- requested root table index bits, and on return it is the actual root
- table index bits. It will differ if the request is greater than the
- longest code or if it is less than the shortest code.
- */
-int inflate_table(type, lens, codes, table, bits, work)
-codetype type;
-unsigned short FAR *lens;
-unsigned codes;
-code FAR * FAR *table;
-unsigned FAR *bits;
-unsigned short FAR *work;
-{
- unsigned len; /* a code's length in bits */
- unsigned sym; /* index of code symbols */
- unsigned min, max; /* minimum and maximum code lengths */
- unsigned root; /* number of index bits for root table */
- unsigned curr; /* number of index bits for current table */
- unsigned drop; /* code bits to drop for sub-table */
- int left; /* number of prefix codes available */
- unsigned used; /* code entries in table used */
- unsigned huff; /* Huffman code */
- unsigned incr; /* for incrementing code, index */
- unsigned fill; /* index for replicating entries */
- unsigned low; /* low bits for current root entry */
- unsigned mask; /* mask for low root bits */
- code this; /* table entry for duplication */
- code FAR *next; /* next available space in table */
- const unsigned short FAR *base; /* base value table to use */
- const unsigned short FAR *extra; /* extra bits table to use */
- int end; /* use base and extra for symbol > end */
- unsigned short count[MAXBITS+1]; /* number of codes of each length */
- unsigned short offs[MAXBITS+1]; /* offsets in table for each length */
- static const unsigned short lbase[31] = { /* Length codes 257..285 base */
- 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
- 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
- static const unsigned short lext[31] = { /* Length codes 257..285 extra */
- 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
- 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 76, 66};
- static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
- 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
- 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
- 8193, 12289, 16385, 24577, 0, 0};
- static const unsigned short dext[32] = { /* Distance codes 0..29 extra */
- 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,
- 23, 23, 24, 24, 25, 25, 26, 26, 27, 27,
- 28, 28, 29, 29, 64, 64};
-
- /*
- Process a set of code lengths to create a canonical Huffman code. The
- code lengths are lens[0..codes-1]. Each length corresponds to the
- symbols 0..codes-1. The Huffman code is generated by first sorting the
- symbols by length from short to long, and retaining the symbol order
- for codes with equal lengths. Then the code starts with all zero bits
- for the first code of the shortest length, and the codes are integer
- increments for the same length, and zeros are appended as the length
- increases. For the deflate format, these bits are stored backwards
- from their more natural integer increment ordering, and so when the
- decoding tables are built in the large loop below, the integer codes
- are incremented backwards.
-
- This routine assumes, but does not check, that all of the entries in
- lens[] are in the range 0..MAXBITS. The caller must assure this.
- 1..MAXBITS is interpreted as that code length. zero means that that
- symbol does not occur in this code.
-
- The codes are sorted by computing a count of codes for each length,
- creating from that a table of starting indices for each length in the
- sorted table, and then entering the symbols in order in the sorted
- table. The sorted table is work[], with that space being provided by
- the caller.
-
- The length counts are used for other purposes as well, i.e. finding
- the minimum and maximum length codes, determining if there are any
- codes at all, checking for a valid set of lengths, and looking ahead
- at length counts to determine sub-table sizes when building the
- decoding tables.
- */
-
- /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */
- for (len = 0; len <= MAXBITS; len++)
- count[len] = 0;
- for (sym = 0; sym < codes; sym++)
- count[lens[sym]]++;
-
- /* bound code lengths, force root to be within code lengths */
- root = *bits;
- for (max = MAXBITS; max >= 1; max--)
- if (count[max] != 0) break;
- if (root > max) root = max;
- if (max == 0) return -1; /* no codes! */
- for (min = 1; min <= MAXBITS; min++)
- if (count[min] != 0) break;
- if (root < min) root = min;
-
- /* check for an over-subscribed or incomplete set of lengths */
- left = 1;
- for (len = 1; len <= MAXBITS; len++) {
- left <<= 1;
- left -= count[len];
- if (left < 0) return -1; /* over-subscribed */
- }
- if (left > 0 && (type == CODES || (codes - count[0] != 1)))
- return -1; /* incomplete set */
-
- /* generate offsets into symbol table for each length for sorting */
- offs[1] = 0;
- for (len = 1; len < MAXBITS; len++)
- offs[len + 1] = offs[len] + count[len];
-
- /* sort symbols by length, by symbol order within each length */
- for (sym = 0; sym < codes; sym++)
- if (lens[sym] != 0) work[offs[lens[sym]]++] = (unsigned short)sym;
-
- /*
- Create and fill in decoding tables. In this loop, the table being
- filled is at next and has curr index bits. The code being used is huff
- with length len. That code is converted to an index by dropping drop
- bits off of the bottom. For codes where len is less than drop + curr,
- those top drop + curr - len bits are incremented through all values to
- fill the table with replicated entries.
-
- root is the number of index bits for the root table. When len exceeds
- root, sub-tables are created pointed to by the root entry with an index
- of the low root bits of huff. This is saved in low to check for when a
- new sub-table should be started. drop is zero when the root table is
- being filled, and drop is root when sub-tables are being filled.
-
- When a new sub-table is needed, it is necessary to look ahead in the
- code lengths to determine what size sub-table is needed. The length
- counts are used for this, and so count[] is decremented as codes are
- entered in the tables.
-
- used keeps track of how many table entries have been allocated from the
- provided *table space. It is checked when a LENS table is being made
- against the space in *table, ENOUGH, minus the maximum space needed by
- the worst case distance code, MAXD. This should never happen, but the
- sufficiency of ENOUGH has not been proven exhaustively, hence the check.
- This assumes that when type == LENS, bits == 9.
-
- sym increments through all symbols, and the loop terminates when
- all codes of length max, i.e. all codes, have been processed. This
- routine permits incomplete codes, so another loop after this one fills
- in the rest of the decoding tables with invalid code markers.
- */
-
- /* set up for code type */
- switch (type) {
- case CODES:
- base = extra = work; /* dummy value--not used */
- end = 19;
- break;
- case LENS:
- base = lbase;
- base -= 257;
- extra = lext;
- extra -= 257;
- end = 256;
- break;
- default: /* DISTS */
- base = dbase;
- extra = dext;
- end = -1;
- }
-
- /* initialize state for loop */
- huff = 0; /* starting code */
- sym = 0; /* starting code symbol */
- len = min; /* starting code length */
- next = *table; /* current table to fill in */
- curr = root; /* current table index bits */
- drop = 0; /* current bits to drop from code for index */
- low = (unsigned)(-1); /* trigger new sub-table when len > root */
- used = 1U << root; /* use root table entries */
- mask = used - 1; /* mask for comparing low */
-
- /* check available table space */
- if (type == LENS && used >= ENOUGH - MAXD)
- return 1;
-
- /* process all codes and make table entries */
- for (;;) {
- /* create table entry */
- this.bits = (unsigned char)(len - drop);
- if ((int)(work[sym]) < end) {
- this.op = (unsigned char)0;
- this.val = work[sym];
- }
- else if ((int)(work[sym]) > end) {
- this.op = (unsigned char)(extra[work[sym]]);
- this.val = base[work[sym]];
- }
- else {
- this.op = (unsigned char)(32 + 64); /* end of block */
- this.val = 0;
- }
-
- /* replicate for those indices with low len bits equal to huff */
- incr = 1U << (len - drop);
- fill = 1U << curr;
- do {
- fill -= incr;
- next[(huff >> drop) + fill] = this;
- } while (fill != 0);
-
- /* backwards increment the len-bit code huff */
- incr = 1U << (len - 1);
- while (huff & incr)
- incr >>= 1;
- if (incr != 0) {
- huff &= incr - 1;
- huff += incr;
- }
- else
- huff = 0;
-
- /* go to next symbol, update count, len */
- sym++;
- if (--(count[len]) == 0) {
- if (len == max) break;
- len = lens[work[sym]];
- }
-
- /* create new sub-table if needed */
- if (len > root && (huff & mask) != low) {
- /* if first time, transition to sub-tables */
- if (drop == 0)
- drop = root;
-
- /* increment past last table */
- next += 1U << curr;
-
- /* determine length of next table */
- curr = len - drop;
- left = (int)(1 << curr);
- while (curr + drop < max) {
- left -= count[curr + drop];
- if (left <= 0) break;
- curr++;
- left <<= 1;
- }
-
- /* check for enough space */
- used += 1U << curr;
- if (type == LENS && used >= ENOUGH - MAXD)
- return 1;
-
- /* point entry in root table to sub-table */
- low = huff & mask;
- (*table)[low].op = (unsigned char)curr;
- (*table)[low].bits = (unsigned char)root;
- (*table)[low].val = (unsigned short)(next - *table);
- }
- }
-
- /*
- Fill in rest of table for incomplete codes. This loop is similar to the
- loop above in incrementing huff for table indices. It is assumed that
- len is equal to curr + drop, so there is no loop needed to increment
- through high index bits. When the current sub-table is filled, the loop
- drops back to the root table to fill in any remaining entries there.
- */
- this.op = (unsigned char)64; /* invalid code marker */
- this.bits = (unsigned char)(len - drop);
- this.val = (unsigned short)0;
- while (huff != 0) {
- /* when done with sub-table, drop back to root table */
- if (drop != 0 && (huff & mask) != low) {
- drop = 0;
- len = root;
- next = *table;
- curr = root;
- this.bits = (unsigned char)len;
- }
-
- /* put invalid code marker in table */
- next[huff >> drop] = this;
-
- /* backwards increment the len-bit code huff */
- incr = 1U << (len - 1);
- while (huff & incr)
- incr >>= 1;
- if (incr != 0) {
- huff &= incr - 1;
- huff += incr;
- }
- else
- huff = 0;
- }
-
- /* set return parameters */
- *table += used;
- *bits = root;
- return 0;
-}
diff --git a/klibc/klibc/zlib/inftrees.h b/klibc/klibc/zlib/inftrees.h
deleted file mode 100644
index 82d365a7e9..0000000000
--- a/klibc/klibc/zlib/inftrees.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/* inftrees.h -- header to use inftrees.c
- * Copyright (C) 1995-2003 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* WARNING: this file should *not* be used by applications. It is
- part of the implementation of the compression library and is
- subject to change. Applications should only use zlib.h.
- */
-
-/* Structure for decoding tables. Each entry provides either the
- information needed to do the operation requested by the code that
- indexed that table entry, or it provides a pointer to another
- table that indexes more bits of the code. op indicates whether
- the entry is a pointer to another table, a literal, a length or
- distance, an end-of-block, or an invalid code. For a table
- pointer, the low four bits of op is the number of index bits of
- that table. For a length or distance, the low four bits of op
- is the number of extra bits to get after the code. bits is
- the number of bits in this code or part of the code to drop off
- of the bit buffer. val is the actual byte to output in the case
- of a literal, the base length or distance, or the offset from
- the current table to the next table. Each entry is four bytes. */
-typedef struct {
- unsigned char op; /* operation, extra bits, table bits */
- unsigned char bits; /* bits in this part of the code */
- unsigned short val; /* offset in table or code value */
-} code;
-
-/* op values as set by inflate_table():
- 00000000 - literal
- 0000tttt - table link, tttt != 0 is the number of table index bits
- 0001eeee - length or distance, eeee is the number of extra bits
- 01100000 - end of block
- 01000000 - invalid code
- */
-
-/* Maximum size of dynamic tree. The maximum found in a long but non-
- exhaustive search was 1004 code structures (850 for length/literals
- and 154 for distances, the latter actually the result of an
- exhaustive search). The true maximum is not known, but the value
- below is more than safe. */
-#define ENOUGH 1440
-#define MAXD 154
-
-/* Type of code to build for inftable() */
-typedef enum {
- CODES,
- LENS,
- DISTS
-} codetype;
-
-extern int inflate_table OF((codetype type, unsigned short FAR *lens,
- unsigned codes, code FAR * FAR *table,
- unsigned FAR *bits, unsigned short FAR *work));
diff --git a/klibc/klibc/zlib/trees.c b/klibc/klibc/zlib/trees.c
deleted file mode 100644
index f7748c4dcc..0000000000
--- a/klibc/klibc/zlib/trees.c
+++ /dev/null
@@ -1,1215 +0,0 @@
-/* trees.c -- output deflated data using Huffman coding
- * Copyright (C) 1995-2003 Jean-loup Gailly
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/*
- * ALGORITHM
- *
- * The "deflation" process uses several Huffman trees. The more
- * common source values are represented by shorter bit sequences.
- *
- * Each code tree is stored in a compressed form which is itself
- * a Huffman encoding of the lengths of all the code strings (in
- * ascending order by source values). The actual code strings are
- * reconstructed from the lengths in the inflate process, as described
- * in the deflate specification.
- *
- * REFERENCES
- *
- * Deutsch, L.P.,"'Deflate' Compressed Data Format Specification".
- * Available in ftp.uu.net:/pub/archiving/zip/doc/deflate-1.1.doc
- *
- * Storer, James A.
- * Data Compression: Methods and Theory, pp. 49-50.
- * Computer Science Press, 1988. ISBN 0-7167-8156-5.
- *
- * Sedgewick, R.
- * Algorithms, p290.
- * Addison-Wesley, 1983. ISBN 0-201-06672-6.
- */
-
-/* @(#) $Id: trees.c,v 1.1 2005/02/27 23:15:39 hpa Exp $ */
-
-/* #define GEN_TREES_H */
-
-#include "deflate.h"
-
-#ifdef DEBUG
-# include <ctype.h>
-#endif
-
-/* ===========================================================================
- * Constants
- */
-
-#define MAX_BL_BITS 7
-/* Bit length codes must not exceed MAX_BL_BITS bits */
-
-#define END_BLOCK 256
-/* end of block literal code */
-
-#define REP_3_6 16
-/* repeat previous bit length 3-6 times (2 bits of repeat count) */
-
-#define REPZ_3_10 17
-/* repeat a zero length 3-10 times (3 bits of repeat count) */
-
-#define REPZ_11_138 18
-/* repeat a zero length 11-138 times (7 bits of repeat count) */
-
-local const int extra_lbits[LENGTH_CODES] /* extra bits for each length code */
- = {0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0};
-
-local const int extra_dbits[D_CODES] /* extra bits for each distance code */
- = {0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13};
-
-local const int extra_blbits[BL_CODES]/* extra bits for each bit length code */
- = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7};
-
-local const uch bl_order[BL_CODES]
- = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15};
-/* The lengths of the bit length codes are sent in order of decreasing
- * probability, to avoid transmitting the lengths for unused bit length codes.
- */
-
-#define Buf_size (8 * 2*sizeof(char))
-/* Number of bits used within bi_buf. (bi_buf might be implemented on
- * more than 16 bits on some systems.)
- */
-
-/* ===========================================================================
- * Local data. These are initialized only once.
- */
-
-#define DIST_CODE_LEN 512 /* see definition of array dist_code below */
-
-#if defined(GEN_TREES_H) || !defined(STDC)
-/* non ANSI compilers may not accept trees.h */
-
-local ct_data static_ltree[L_CODES+2];
-/* The static literal tree. Since the bit lengths are imposed, there is no
- * need for the L_CODES extra codes used during heap construction. However
- * The codes 286 and 287 are needed to build a canonical tree (see _tr_init
- * below).
- */
-
-local ct_data static_dtree[D_CODES];
-/* The static distance tree. (Actually a trivial tree since all codes use
- * 5 bits.)
- */
-
-uch _dist_code[DIST_CODE_LEN];
-/* Distance codes. The first 256 values correspond to the distances
- * 3 .. 258, the last 256 values correspond to the top 8 bits of
- * the 15 bit distances.
- */
-
-uch _length_code[MAX_MATCH-MIN_MATCH+1];
-/* length code for each normalized match length (0 == MIN_MATCH) */
-
-local int base_length[LENGTH_CODES];
-/* First normalized length for each code (0 = MIN_MATCH) */
-
-local int base_dist[D_CODES];
-/* First normalized distance for each code (0 = distance of 1) */
-
-#else
-# include "trees.h"
-#endif /* GEN_TREES_H */
-
-struct static_tree_desc_s {
- const ct_data *static_tree; /* static tree or NULL */
- const intf *extra_bits; /* extra bits for each code or NULL */
- int extra_base; /* base index for extra_bits */
- int elems; /* max number of elements in the tree */
- int max_length; /* max bit length for the codes */
-};
-
-local static_tree_desc static_l_desc =
-{static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS};
-
-local static_tree_desc static_d_desc =
-{static_dtree, extra_dbits, 0, D_CODES, MAX_BITS};
-
-local static_tree_desc static_bl_desc =
-{(const ct_data *)0, extra_blbits, 0, BL_CODES, MAX_BL_BITS};
-
-/* ===========================================================================
- * Local (static) routines in this file.
- */
-
-local void tr_static_init OF((void));
-local void init_block OF((deflate_state *s));
-local void pqdownheap OF((deflate_state *s, ct_data *tree, int k));
-local void gen_bitlen OF((deflate_state *s, tree_desc *desc));
-local void gen_codes OF((ct_data *tree, int max_code, ushf *bl_count));
-local void build_tree OF((deflate_state *s, tree_desc *desc));
-local void scan_tree OF((deflate_state *s, ct_data *tree, int max_code));
-local void send_tree OF((deflate_state *s, ct_data *tree, int max_code));
-local int build_bl_tree OF((deflate_state *s));
-local void send_all_trees OF((deflate_state *s, int lcodes, int dcodes,
- int blcodes));
-local void compress_block OF((deflate_state *s, ct_data *ltree,
- ct_data *dtree));
-local void set_data_type OF((deflate_state *s));
-local unsigned bi_reverse OF((unsigned value, int length));
-local void bi_windup OF((deflate_state *s));
-local void bi_flush OF((deflate_state *s));
-local void copy_block OF((deflate_state *s, charf *buf, unsigned len,
- int header));
-
-#ifdef GEN_TREES_H
-local void gen_trees_header OF((void));
-#endif
-
-#ifndef DEBUG
-# define send_code(s, c, tree) send_bits(s, tree[c].Code, tree[c].Len)
- /* Send a code of the given tree. c and tree must not have side effects */
-
-#else /* DEBUG */
-# define send_code(s, c, tree) \
- { if (z_verbose>2) fprintf(stderr,"\ncd %3d ",(c)); \
- send_bits(s, tree[c].Code, tree[c].Len); }
-#endif
-
-/* ===========================================================================
- * Output a short LSB first on the stream.
- * IN assertion: there is enough room in pendingBuf.
- */
-#define put_short(s, w) { \
- put_byte(s, (uch)((w) & 0xff)); \
- put_byte(s, (uch)((ush)(w) >> 8)); \
-}
-
-/* ===========================================================================
- * Send a value on a given number of bits.
- * IN assertion: length <= 16 and value fits in length bits.
- */
-#ifdef DEBUG
-local void send_bits OF((deflate_state *s, int value, int length));
-
-local void send_bits(s, value, length)
- deflate_state *s;
- int value; /* value to send */
- int length; /* number of bits */
-{
- Tracevv((stderr," l %2d v %4x ", length, value));
- Assert(length > 0 && length <= 15, "invalid length");
- s->bits_sent += (ulg)length;
-
- /* If not enough room in bi_buf, use (valid) bits from bi_buf and
- * (16 - bi_valid) bits from value, leaving (width - (16-bi_valid))
- * unused bits in value.
- */
- if (s->bi_valid > (int)Buf_size - length) {
- s->bi_buf |= (value << s->bi_valid);
- put_short(s, s->bi_buf);
- s->bi_buf = (ush)value >> (Buf_size - s->bi_valid);
- s->bi_valid += length - Buf_size;
- } else {
- s->bi_buf |= value << s->bi_valid;
- s->bi_valid += length;
- }
-}
-#else /* !DEBUG */
-
-#define send_bits(s, value, length) \
-{ int len = length;\
- if (s->bi_valid > (int)Buf_size - len) {\
- int val = value;\
- s->bi_buf |= (val << s->bi_valid);\
- put_short(s, s->bi_buf);\
- s->bi_buf = (ush)val >> (Buf_size - s->bi_valid);\
- s->bi_valid += len - Buf_size;\
- } else {\
- s->bi_buf |= (value) << s->bi_valid;\
- s->bi_valid += len;\
- }\
-}
-#endif /* DEBUG */
-
-
-/* the arguments must not have side effects */
-
-/* ===========================================================================
- * Initialize the various 'constant' tables.
- */
-local void tr_static_init()
-{
-#if defined(GEN_TREES_H) || !defined(STDC)
- static int static_init_done = 0;
- int n; /* iterates over tree elements */
- int bits; /* bit counter */
- int length; /* length value */
- int code; /* code value */
- int dist; /* distance index */
- ush bl_count[MAX_BITS+1];
- /* number of codes at each bit length for an optimal tree */
-
- if (static_init_done) return;
-
- /* For some embedded targets, global variables are not initialized: */
- static_l_desc.static_tree = static_ltree;
- static_l_desc.extra_bits = extra_lbits;
- static_d_desc.static_tree = static_dtree;
- static_d_desc.extra_bits = extra_dbits;
- static_bl_desc.extra_bits = extra_blbits;
-
- /* Initialize the mapping length (0..255) -> length code (0..28) */
- length = 0;
- for (code = 0; code < LENGTH_CODES-1; code++) {
- base_length[code] = length;
- for (n = 0; n < (1<<extra_lbits[code]); n++) {
- _length_code[length++] = (uch)code;
- }
- }
- Assert (length == 256, "tr_static_init: length != 256");
- /* Note that the length 255 (match length 258) can be represented
- * in two different ways: code 284 + 5 bits or code 285, so we
- * overwrite length_code[255] to use the best encoding:
- */
- _length_code[length-1] = (uch)code;
-
- /* Initialize the mapping dist (0..32K) -> dist code (0..29) */
- dist = 0;
- for (code = 0 ; code < 16; code++) {
- base_dist[code] = dist;
- for (n = 0; n < (1<<extra_dbits[code]); n++) {
- _dist_code[dist++] = (uch)code;
- }
- }
- Assert (dist == 256, "tr_static_init: dist != 256");
- dist >>= 7; /* from now on, all distances are divided by 128 */
- for ( ; code < D_CODES; code++) {
- base_dist[code] = dist << 7;
- for (n = 0; n < (1<<(extra_dbits[code]-7)); n++) {
- _dist_code[256 + dist++] = (uch)code;
- }
- }
- Assert (dist == 256, "tr_static_init: 256+dist != 512");
-
- /* Construct the codes of the static literal tree */
- for (bits = 0; bits <= MAX_BITS; bits++) bl_count[bits] = 0;
- n = 0;
- while (n <= 143) static_ltree[n++].Len = 8, bl_count[8]++;
- while (n <= 255) static_ltree[n++].Len = 9, bl_count[9]++;
- while (n <= 279) static_ltree[n++].Len = 7, bl_count[7]++;
- while (n <= 287) static_ltree[n++].Len = 8, bl_count[8]++;
- /* Codes 286 and 287 do not exist, but we must include them in the
- * tree construction to get a canonical Huffman tree (longest code
- * all ones)
- */
- gen_codes((ct_data *)static_ltree, L_CODES+1, bl_count);
-
- /* The static distance tree is trivial: */
- for (n = 0; n < D_CODES; n++) {
- static_dtree[n].Len = 5;
- static_dtree[n].Code = bi_reverse((unsigned)n, 5);
- }
- static_init_done = 1;
-
-# ifdef GEN_TREES_H
- gen_trees_header();
-# endif
-#endif /* defined(GEN_TREES_H) || !defined(STDC) */
-}
-
-/* ===========================================================================
- * Genererate the file trees.h describing the static trees.
- */
-#ifdef GEN_TREES_H
-# ifndef DEBUG
-# include <stdio.h>
-# endif
-
-# define SEPARATOR(i, last, width) \
- ((i) == (last)? "\n};\n\n" : \
- ((i) % (width) == (width)-1 ? ",\n" : ", "))
-
-void gen_trees_header()
-{
- FILE *header = fopen("trees.h", "w");
- int i;
-
- Assert (header != NULL, "Can't open trees.h");
- fprintf(header,
- "/* header created automatically with -DGEN_TREES_H */\n\n");
-
- fprintf(header, "local const ct_data static_ltree[L_CODES+2] = {\n");
- for (i = 0; i < L_CODES+2; i++) {
- fprintf(header, "{{%3u},{%3u}}%s", static_ltree[i].Code,
- static_ltree[i].Len, SEPARATOR(i, L_CODES+1, 5));
- }
-
- fprintf(header, "local const ct_data static_dtree[D_CODES] = {\n");
- for (i = 0; i < D_CODES; i++) {
- fprintf(header, "{{%2u},{%2u}}%s", static_dtree[i].Code,
- static_dtree[i].Len, SEPARATOR(i, D_CODES-1, 5));
- }
-
- fprintf(header, "const uch _dist_code[DIST_CODE_LEN] = {\n");
- for (i = 0; i < DIST_CODE_LEN; i++) {
- fprintf(header, "%2u%s", _dist_code[i],
- SEPARATOR(i, DIST_CODE_LEN-1, 20));
- }
-
- fprintf(header, "const uch _length_code[MAX_MATCH-MIN_MATCH+1]= {\n");
- for (i = 0; i < MAX_MATCH-MIN_MATCH+1; i++) {
- fprintf(header, "%2u%s", _length_code[i],
- SEPARATOR(i, MAX_MATCH-MIN_MATCH, 20));
- }
-
- fprintf(header, "local const int base_length[LENGTH_CODES] = {\n");
- for (i = 0; i < LENGTH_CODES; i++) {
- fprintf(header, "%1u%s", base_length[i],
- SEPARATOR(i, LENGTH_CODES-1, 20));
- }
-
- fprintf(header, "local const int base_dist[D_CODES] = {\n");
- for (i = 0; i < D_CODES; i++) {
- fprintf(header, "%5u%s", base_dist[i],
- SEPARATOR(i, D_CODES-1, 10));
- }
-
- fclose(header);
-}
-#endif /* GEN_TREES_H */
-
-/* ===========================================================================
- * Initialize the tree data structures for a new zlib stream.
- */
-void _tr_init(s)
- deflate_state *s;
-{
- tr_static_init();
-
- s->l_desc.dyn_tree = s->dyn_ltree;
- s->l_desc.stat_desc = &static_l_desc;
-
- s->d_desc.dyn_tree = s->dyn_dtree;
- s->d_desc.stat_desc = &static_d_desc;
-
- s->bl_desc.dyn_tree = s->bl_tree;
- s->bl_desc.stat_desc = &static_bl_desc;
-
- s->bi_buf = 0;
- s->bi_valid = 0;
- s->last_eob_len = 8; /* enough lookahead for inflate */
-#ifdef DEBUG
- s->compressed_len = 0L;
- s->bits_sent = 0L;
-#endif
-
- /* Initialize the first block of the first file: */
- init_block(s);
-}
-
-/* ===========================================================================
- * Initialize a new block.
- */
-local void init_block(s)
- deflate_state *s;
-{
- int n; /* iterates over tree elements */
-
- /* Initialize the trees. */
- for (n = 0; n < L_CODES; n++) s->dyn_ltree[n].Freq = 0;
- for (n = 0; n < D_CODES; n++) s->dyn_dtree[n].Freq = 0;
- for (n = 0; n < BL_CODES; n++) s->bl_tree[n].Freq = 0;
-
- s->dyn_ltree[END_BLOCK].Freq = 1;
- s->opt_len = s->static_len = 0L;
- s->last_lit = s->matches = 0;
-}
-
-#define SMALLEST 1
-/* Index within the heap array of least frequent node in the Huffman tree */
-
-
-/* ===========================================================================
- * Remove the smallest element from the heap and recreate the heap with
- * one less element. Updates heap and heap_len.
- */
-#define pqremove(s, tree, top) \
-{\
- top = s->heap[SMALLEST]; \
- s->heap[SMALLEST] = s->heap[s->heap_len--]; \
- pqdownheap(s, tree, SMALLEST); \
-}
-
-/* ===========================================================================
- * Compares to subtrees, using the tree depth as tie breaker when
- * the subtrees have equal frequency. This minimizes the worst case length.
- */
-#define smaller(tree, n, m, depth) \
- (tree[n].Freq < tree[m].Freq || \
- (tree[n].Freq == tree[m].Freq && depth[n] <= depth[m]))
-
-/* ===========================================================================
- * Restore the heap property by moving down the tree starting at node k,
- * exchanging a node with the smallest of its two sons if necessary, stopping
- * when the heap property is re-established (each father smaller than its
- * two sons).
- */
-local void pqdownheap(s, tree, k)
- deflate_state *s;
- ct_data *tree; /* the tree to restore */
- int k; /* node to move down */
-{
- int v = s->heap[k];
- int j = k << 1; /* left son of k */
- while (j <= s->heap_len) {
- /* Set j to the smallest of the two sons: */
- if (j < s->heap_len &&
- smaller(tree, s->heap[j+1], s->heap[j], s->depth)) {
- j++;
- }
- /* Exit if v is smaller than both sons */
- if (smaller(tree, v, s->heap[j], s->depth)) break;
-
- /* Exchange v with the smallest son */
- s->heap[k] = s->heap[j]; k = j;
-
- /* And continue down the tree, setting j to the left son of k */
- j <<= 1;
- }
- s->heap[k] = v;
-}
-
-/* ===========================================================================
- * Compute the optimal bit lengths for a tree and update the total bit length
- * for the current block.
- * IN assertion: the fields freq and dad are set, heap[heap_max] and
- * above are the tree nodes sorted by increasing frequency.
- * OUT assertions: the field len is set to the optimal bit length, the
- * array bl_count contains the frequencies for each bit length.
- * The length opt_len is updated; static_len is also updated if stree is
- * not null.
- */
-local void gen_bitlen(s, desc)
- deflate_state *s;
- tree_desc *desc; /* the tree descriptor */
-{
- ct_data *tree = desc->dyn_tree;
- int max_code = desc->max_code;
- const ct_data *stree = desc->stat_desc->static_tree;
- const intf *extra = desc->stat_desc->extra_bits;
- int base = desc->stat_desc->extra_base;
- int max_length = desc->stat_desc->max_length;
- int h; /* heap index */
- int n, m; /* iterate over the tree elements */
- int bits; /* bit length */
- int xbits; /* extra bits */
- ush f; /* frequency */
- int overflow = 0; /* number of elements with bit length too large */
-
- for (bits = 0; bits <= MAX_BITS; bits++) s->bl_count[bits] = 0;
-
- /* In a first pass, compute the optimal bit lengths (which may
- * overflow in the case of the bit length tree).
- */
- tree[s->heap[s->heap_max]].Len = 0; /* root of the heap */
-
- for (h = s->heap_max+1; h < HEAP_SIZE; h++) {
- n = s->heap[h];
- bits = tree[tree[n].Dad].Len + 1;
- if (bits > max_length) bits = max_length, overflow++;
- tree[n].Len = (ush)bits;
- /* We overwrite tree[n].Dad which is no longer needed */
-
- if (n > max_code) continue; /* not a leaf node */
-
- s->bl_count[bits]++;
- xbits = 0;
- if (n >= base) xbits = extra[n-base];
- f = tree[n].Freq;
- s->opt_len += (ulg)f * (bits + xbits);
- if (stree) s->static_len += (ulg)f * (stree[n].Len + xbits);
- }
- if (overflow == 0) return;
-
- Trace((stderr,"\nbit length overflow\n"));
- /* This happens for example on obj2 and pic of the Calgary corpus */
-
- /* Find the first bit length which could increase: */
- do {
- bits = max_length-1;
- while (s->bl_count[bits] == 0) bits--;
- s->bl_count[bits]--; /* move one leaf down the tree */
- s->bl_count[bits+1] += 2; /* move one overflow item as its brother */
- s->bl_count[max_length]--;
- /* The brother of the overflow item also moves one step up,
- * but this does not affect bl_count[max_length]
- */
- overflow -= 2;
- } while (overflow > 0);
-
- /* Now recompute all bit lengths, scanning in increasing frequency.
- * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all
- * lengths instead of fixing only the wrong ones. This idea is taken
- * from 'ar' written by Haruhiko Okumura.)
- */
- for (bits = max_length; bits != 0; bits--) {
- n = s->bl_count[bits];
- while (n != 0) {
- m = s->heap[--h];
- if (m > max_code) continue;
- if (tree[m].Len != (unsigned) bits) {
- Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits));
- s->opt_len += ((long)bits - (long)tree[m].Len)
- *(long)tree[m].Freq;
- tree[m].Len = (ush)bits;
- }
- n--;
- }
- }
-}
-
-/* ===========================================================================
- * Generate the codes for a given tree and bit counts (which need not be
- * optimal).
- * IN assertion: the array bl_count contains the bit length statistics for
- * the given tree and the field len is set for all tree elements.
- * OUT assertion: the field code is set for all tree elements of non
- * zero code length.
- */
-local void gen_codes (tree, max_code, bl_count)
- ct_data *tree; /* the tree to decorate */
- int max_code; /* largest code with non zero frequency */
- ushf *bl_count; /* number of codes at each bit length */
-{
- ush next_code[MAX_BITS+1]; /* next code value for each bit length */
- ush code = 0; /* running code value */
- int bits; /* bit index */
- int n; /* code index */
-
- /* The distribution counts are first used to generate the code values
- * without bit reversal.
- */
- for (bits = 1; bits <= MAX_BITS; bits++) {
- next_code[bits] = code = (code + bl_count[bits-1]) << 1;
- }
- /* Check that the bit counts in bl_count are consistent. The last code
- * must be all ones.
- */
- Assert (code + bl_count[MAX_BITS]-1 == (1<<MAX_BITS)-1,
- "inconsistent bit counts");
- Tracev((stderr,"\ngen_codes: max_code %d ", max_code));
-
- for (n = 0; n <= max_code; n++) {
- int len = tree[n].Len;
- if (len == 0) continue;
- /* Now reverse the bits */
- tree[n].Code = bi_reverse(next_code[len]++, len);
-
- Tracecv(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ",
- n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len]-1));
- }
-}
-
-/* ===========================================================================
- * Construct one Huffman tree and assigns the code bit strings and lengths.
- * Update the total bit length for the current block.
- * IN assertion: the field freq is set for all tree elements.
- * OUT assertions: the fields len and code are set to the optimal bit length
- * and corresponding code. The length opt_len is updated; static_len is
- * also updated if stree is not null. The field max_code is set.
- */
-local void build_tree(s, desc)
- deflate_state *s;
- tree_desc *desc; /* the tree descriptor */
-{
- ct_data *tree = desc->dyn_tree;
- const ct_data *stree = desc->stat_desc->static_tree;
- int elems = desc->stat_desc->elems;
- int n, m; /* iterate over heap elements */
- int max_code = -1; /* largest code with non zero frequency */
- int node; /* new node being created */
-
- /* Construct the initial heap, with least frequent element in
- * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1].
- * heap[0] is not used.
- */
- s->heap_len = 0, s->heap_max = HEAP_SIZE;
-
- for (n = 0; n < elems; n++) {
- if (tree[n].Freq != 0) {
- s->heap[++(s->heap_len)] = max_code = n;
- s->depth[n] = 0;
- } else {
- tree[n].Len = 0;
- }
- }
-
- /* The pkzip format requires that at least one distance code exists,
- * and that at least one bit should be sent even if there is only one
- * possible code. So to avoid special checks later on we force at least
- * two codes of non zero frequency.
- */
- while (s->heap_len < 2) {
- node = s->heap[++(s->heap_len)] = (max_code < 2 ? ++max_code : 0);
- tree[node].Freq = 1;
- s->depth[node] = 0;
- s->opt_len--; if (stree) s->static_len -= stree[node].Len;
- /* node is 0 or 1 so it does not have extra bits */
- }
- desc->max_code = max_code;
-
- /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree,
- * establish sub-heaps of increasing lengths:
- */
- for (n = s->heap_len/2; n >= 1; n--) pqdownheap(s, tree, n);
-
- /* Construct the Huffman tree by repeatedly combining the least two
- * frequent nodes.
- */
- node = elems; /* next internal node of the tree */
- do {
- pqremove(s, tree, n); /* n = node of least frequency */
- m = s->heap[SMALLEST]; /* m = node of next least frequency */
-
- s->heap[--(s->heap_max)] = n; /* keep the nodes sorted by frequency */
- s->heap[--(s->heap_max)] = m;
-
- /* Create a new node father of n and m */
- tree[node].Freq = tree[n].Freq + tree[m].Freq;
- s->depth[node] = (uch)((s->depth[n] >= s->depth[m] ?
- s->depth[n] : s->depth[m]) + 1);
- tree[n].Dad = tree[m].Dad = (ush)node;
-#ifdef DUMP_BL_TREE
- if (tree == s->bl_tree) {
- fprintf(stderr,"\nnode %d(%d), sons %d(%d) %d(%d)",
- node, tree[node].Freq, n, tree[n].Freq, m, tree[m].Freq);
- }
-#endif
- /* and insert the new node in the heap */
- s->heap[SMALLEST] = node++;
- pqdownheap(s, tree, SMALLEST);
-
- } while (s->heap_len >= 2);
-
- s->heap[--(s->heap_max)] = s->heap[SMALLEST];
-
- /* At this point, the fields freq and dad are set. We can now
- * generate the bit lengths.
- */
- gen_bitlen(s, (tree_desc *)desc);
-
- /* The field len is now set, we can generate the bit codes */
- gen_codes ((ct_data *)tree, max_code, s->bl_count);
-}
-
-/* ===========================================================================
- * Scan a literal or distance tree to determine the frequencies of the codes
- * in the bit length tree.
- */
-local void scan_tree (s, tree, max_code)
- deflate_state *s;
- ct_data *tree; /* the tree to be scanned */
- int max_code; /* and its largest code of non zero frequency */
-{
- int n; /* iterates over all tree elements */
- int prevlen = -1; /* last emitted length */
- int curlen; /* length of current code */
- int nextlen = tree[0].Len; /* length of next code */
- int count = 0; /* repeat count of the current code */
- int max_count = 7; /* max repeat count */
- int min_count = 4; /* min repeat count */
-
- if (nextlen == 0) max_count = 138, min_count = 3;
- tree[max_code+1].Len = (ush)0xffff; /* guard */
-
- for (n = 0; n <= max_code; n++) {
- curlen = nextlen; nextlen = tree[n+1].Len;
- if (++count < max_count && curlen == nextlen) {
- continue;
- } else if (count < min_count) {
- s->bl_tree[curlen].Freq += count;
- } else if (curlen != 0) {
- if (curlen != prevlen) s->bl_tree[curlen].Freq++;
- s->bl_tree[REP_3_6].Freq++;
- } else if (count <= 10) {
- s->bl_tree[REPZ_3_10].Freq++;
- } else {
- s->bl_tree[REPZ_11_138].Freq++;
- }
- count = 0; prevlen = curlen;
- if (nextlen == 0) {
- max_count = 138, min_count = 3;
- } else if (curlen == nextlen) {
- max_count = 6, min_count = 3;
- } else {
- max_count = 7, min_count = 4;
- }
- }
-}
-
-/* ===========================================================================
- * Send a literal or distance tree in compressed form, using the codes in
- * bl_tree.
- */
-local void send_tree (s, tree, max_code)
- deflate_state *s;
- ct_data *tree; /* the tree to be scanned */
- int max_code; /* and its largest code of non zero frequency */
-{
- int n; /* iterates over all tree elements */
- int prevlen = -1; /* last emitted length */
- int curlen; /* length of current code */
- int nextlen = tree[0].Len; /* length of next code */
- int count = 0; /* repeat count of the current code */
- int max_count = 7; /* max repeat count */
- int min_count = 4; /* min repeat count */
-
- /* tree[max_code+1].Len = -1; */ /* guard already set */
- if (nextlen == 0) max_count = 138, min_count = 3;
-
- for (n = 0; n <= max_code; n++) {
- curlen = nextlen; nextlen = tree[n+1].Len;
- if (++count < max_count && curlen == nextlen) {
- continue;
- } else if (count < min_count) {
- do { send_code(s, curlen, s->bl_tree); } while (--count != 0);
-
- } else if (curlen != 0) {
- if (curlen != prevlen) {
- send_code(s, curlen, s->bl_tree); count--;
- }
- Assert(count >= 3 && count <= 6, " 3_6?");
- send_code(s, REP_3_6, s->bl_tree); send_bits(s, count-3, 2);
-
- } else if (count <= 10) {
- send_code(s, REPZ_3_10, s->bl_tree); send_bits(s, count-3, 3);
-
- } else {
- send_code(s, REPZ_11_138, s->bl_tree); send_bits(s, count-11, 7);
- }
- count = 0; prevlen = curlen;
- if (nextlen == 0) {
- max_count = 138, min_count = 3;
- } else if (curlen == nextlen) {
- max_count = 6, min_count = 3;
- } else {
- max_count = 7, min_count = 4;
- }
- }
-}
-
-/* ===========================================================================
- * Construct the Huffman tree for the bit lengths and return the index in
- * bl_order of the last bit length code to send.
- */
-local int build_bl_tree(s)
- deflate_state *s;
-{
- int max_blindex; /* index of last bit length code of non zero freq */
-
- /* Determine the bit length frequencies for literal and distance trees */
- scan_tree(s, (ct_data *)s->dyn_ltree, s->l_desc.max_code);
- scan_tree(s, (ct_data *)s->dyn_dtree, s->d_desc.max_code);
-
- /* Build the bit length tree: */
- build_tree(s, (tree_desc *)(&(s->bl_desc)));
- /* opt_len now includes the length of the tree representations, except
- * the lengths of the bit lengths codes and the 5+5+4 bits for the counts.
- */
-
- /* Determine the number of bit length codes to send. The pkzip format
- * requires that at least 4 bit length codes be sent. (appnote.txt says
- * 3 but the actual value used is 4.)
- */
- for (max_blindex = BL_CODES-1; max_blindex >= 3; max_blindex--) {
- if (s->bl_tree[bl_order[max_blindex]].Len != 0) break;
- }
- /* Update opt_len to include the bit length tree and counts */
- s->opt_len += 3*(max_blindex+1) + 5+5+4;
- Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld",
- s->opt_len, s->static_len));
-
- return max_blindex;
-}
-
-/* ===========================================================================
- * Send the header for a block using dynamic Huffman trees: the counts, the
- * lengths of the bit length codes, the literal tree and the distance tree.
- * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4.
- */
-local void send_all_trees(s, lcodes, dcodes, blcodes)
- deflate_state *s;
- int lcodes, dcodes, blcodes; /* number of codes for each tree */
-{
- int rank; /* index in bl_order */
-
- Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes");
- Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES,
- "too many codes");
- Tracev((stderr, "\nbl counts: "));
- send_bits(s, lcodes-257, 5); /* not +255 as stated in appnote.txt */
- send_bits(s, dcodes-1, 5);
- send_bits(s, blcodes-4, 4); /* not -3 as stated in appnote.txt */
- for (rank = 0; rank < blcodes; rank++) {
- Tracev((stderr, "\nbl code %2d ", bl_order[rank]));
- send_bits(s, s->bl_tree[bl_order[rank]].Len, 3);
- }
- Tracev((stderr, "\nbl tree: sent %ld", s->bits_sent));
-
- send_tree(s, (ct_data *)s->dyn_ltree, lcodes-1); /* literal tree */
- Tracev((stderr, "\nlit tree: sent %ld", s->bits_sent));
-
- send_tree(s, (ct_data *)s->dyn_dtree, dcodes-1); /* distance tree */
- Tracev((stderr, "\ndist tree: sent %ld", s->bits_sent));
-}
-
-/* ===========================================================================
- * Send a stored block
- */
-void _tr_stored_block(s, buf, stored_len, eof)
- deflate_state *s;
- charf *buf; /* input block */
- ulg stored_len; /* length of input block */
- int eof; /* true if this is the last block for a file */
-{
- send_bits(s, (STORED_BLOCK<<1)+eof, 3); /* send block type */
-#ifdef DEBUG
- s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L;
- s->compressed_len += (stored_len + 4) << 3;
-#endif
- copy_block(s, buf, (unsigned)stored_len, 1); /* with header */
-}
-
-/* ===========================================================================
- * Send one empty static block to give enough lookahead for inflate.
- * This takes 10 bits, of which 7 may remain in the bit buffer.
- * The current inflate code requires 9 bits of lookahead. If the
- * last two codes for the previous block (real code plus EOB) were coded
- * on 5 bits or less, inflate may have only 5+3 bits of lookahead to decode
- * the last real code. In this case we send two empty static blocks instead
- * of one. (There are no problems if the previous block is stored or fixed.)
- * To simplify the code, we assume the worst case of last real code encoded
- * on one bit only.
- */
-void _tr_align(s)
- deflate_state *s;
-{
- send_bits(s, STATIC_TREES<<1, 3);
- send_code(s, END_BLOCK, static_ltree);
-#ifdef DEBUG
- s->compressed_len += 10L; /* 3 for block type, 7 for EOB */
-#endif
- bi_flush(s);
- /* Of the 10 bits for the empty block, we have already sent
- * (10 - bi_valid) bits. The lookahead for the last real code (before
- * the EOB of the previous block) was thus at least one plus the length
- * of the EOB plus what we have just sent of the empty static block.
- */
- if (1 + s->last_eob_len + 10 - s->bi_valid < 9) {
- send_bits(s, STATIC_TREES<<1, 3);
- send_code(s, END_BLOCK, static_ltree);
-#ifdef DEBUG
- s->compressed_len += 10L;
-#endif
- bi_flush(s);
- }
- s->last_eob_len = 7;
-}
-
-/* ===========================================================================
- * Determine the best encoding for the current block: dynamic trees, static
- * trees or store, and output the encoded block to the zip file.
- */
-void _tr_flush_block(s, buf, stored_len, eof)
- deflate_state *s;
- charf *buf; /* input block, or NULL if too old */
- ulg stored_len; /* length of input block */
- int eof; /* true if this is the last block for a file */
-{
- ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */
- int max_blindex = 0; /* index of last bit length code of non zero freq */
-
- /* Build the Huffman trees unless a stored block is forced */
- if (s->level > 0) {
-
- /* Check if the file is ascii or binary */
- if (s->data_type == Z_UNKNOWN) set_data_type(s);
-
- /* Construct the literal and distance trees */
- build_tree(s, (tree_desc *)(&(s->l_desc)));
- Tracev((stderr, "\nlit data: dyn %ld, stat %ld", s->opt_len,
- s->static_len));
-
- build_tree(s, (tree_desc *)(&(s->d_desc)));
- Tracev((stderr, "\ndist data: dyn %ld, stat %ld", s->opt_len,
- s->static_len));
- /* At this point, opt_len and static_len are the total bit lengths of
- * the compressed block data, excluding the tree representations.
- */
-
- /* Build the bit length tree for the above two trees, and get the index
- * in bl_order of the last bit length code to send.
- */
- max_blindex = build_bl_tree(s);
-
- /* Determine the best encoding. Compute the block lengths in bytes. */
- opt_lenb = (s->opt_len+3+7)>>3;
- static_lenb = (s->static_len+3+7)>>3;
-
- Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ",
- opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len,
- s->last_lit));
-
- if (static_lenb <= opt_lenb) opt_lenb = static_lenb;
-
- } else {
- Assert(buf != (char*)0, "lost buf");
- opt_lenb = static_lenb = stored_len + 5; /* force a stored block */
- }
-
-#ifdef FORCE_STORED
- if (buf != (char*)0) { /* force stored block */
-#else
- if (stored_len+4 <= opt_lenb && buf != (char*)0) {
- /* 4: two words for the lengths */
-#endif
- /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE.
- * Otherwise we can't have processed more than WSIZE input bytes since
- * the last block flush, because compression would have been
- * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to
- * transform a block into a stored block.
- */
- _tr_stored_block(s, buf, stored_len, eof);
-
-#ifdef FORCE_STATIC
- } else if (static_lenb >= 0) { /* force static trees */
-#else
- } else if (static_lenb == opt_lenb) {
-#endif
- send_bits(s, (STATIC_TREES<<1)+eof, 3);
- compress_block(s, (ct_data *)static_ltree, (ct_data *)static_dtree);
-#ifdef DEBUG
- s->compressed_len += 3 + s->static_len;
-#endif
- } else {
- send_bits(s, (DYN_TREES<<1)+eof, 3);
- send_all_trees(s, s->l_desc.max_code+1, s->d_desc.max_code+1,
- max_blindex+1);
- compress_block(s, (ct_data *)s->dyn_ltree, (ct_data *)s->dyn_dtree);
-#ifdef DEBUG
- s->compressed_len += 3 + s->opt_len;
-#endif
- }
- Assert (s->compressed_len == s->bits_sent, "bad compressed size");
- /* The above check is made mod 2^32, for files larger than 512 MB
- * and uLong implemented on 32 bits.
- */
- init_block(s);
-
- if (eof) {
- bi_windup(s);
-#ifdef DEBUG
- s->compressed_len += 7; /* align on byte boundary */
-#endif
- }
- Tracev((stderr,"\ncomprlen %lu(%lu) ", s->compressed_len>>3,
- s->compressed_len-7*eof));
-}
-
-/* ===========================================================================
- * Save the match info and tally the frequency counts. Return true if
- * the current block must be flushed.
- */
-int _tr_tally (s, dist, lc)
- deflate_state *s;
- unsigned dist; /* distance of matched string */
- unsigned lc; /* match length-MIN_MATCH or unmatched char (if dist==0) */
-{
- s->d_buf[s->last_lit] = (ush)dist;
- s->l_buf[s->last_lit++] = (uch)lc;
- if (dist == 0) {
- /* lc is the unmatched char */
- s->dyn_ltree[lc].Freq++;
- } else {
- s->matches++;
- /* Here, lc is the match length - MIN_MATCH */
- dist--; /* dist = match distance - 1 */
- Assert((ush)dist < (ush)MAX_DIST(s) &&
- (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) &&
- (ush)d_code(dist) < (ush)D_CODES, "_tr_tally: bad match");
-
- s->dyn_ltree[_length_code[lc]+LITERALS+1].Freq++;
- s->dyn_dtree[d_code(dist)].Freq++;
- }
-
-#ifdef TRUNCATE_BLOCK
- /* Try to guess if it is profitable to stop the current block here */
- if ((s->last_lit & 0x1fff) == 0 && s->level > 2) {
- /* Compute an upper bound for the compressed length */
- ulg out_length = (ulg)s->last_lit*8L;
- ulg in_length = (ulg)((long)s->strstart - s->block_start);
- int dcode;
- for (dcode = 0; dcode < D_CODES; dcode++) {
- out_length += (ulg)s->dyn_dtree[dcode].Freq *
- (5L+extra_dbits[dcode]);
- }
- out_length >>= 3;
- Tracev((stderr,"\nlast_lit %u, in %ld, out ~%ld(%ld%%) ",
- s->last_lit, in_length, out_length,
- 100L - out_length*100L/in_length));
- if (s->matches < s->last_lit/2 && out_length < in_length/2) return 1;
- }
-#endif
- return (s->last_lit == s->lit_bufsize-1);
- /* We avoid equality with lit_bufsize because of wraparound at 64K
- * on 16 bit machines and because stored blocks are restricted to
- * 64K-1 bytes.
- */
-}
-
-/* ===========================================================================
- * Send the block data compressed using the given Huffman trees
- */
-local void compress_block(s, ltree, dtree)
- deflate_state *s;
- ct_data *ltree; /* literal tree */
- ct_data *dtree; /* distance tree */
-{
- unsigned dist; /* distance of matched string */
- int lc; /* match length or unmatched char (if dist == 0) */
- unsigned lx = 0; /* running index in l_buf */
- unsigned code; /* the code to send */
- int extra; /* number of extra bits to send */
-
- if (s->last_lit != 0) do {
- dist = s->d_buf[lx];
- lc = s->l_buf[lx++];
- if (dist == 0) {
- send_code(s, lc, ltree); /* send a literal byte */
- Tracecv(isgraph(lc), (stderr," '%c' ", lc));
- } else {
- /* Here, lc is the match length - MIN_MATCH */
- code = _length_code[lc];
- send_code(s, code+LITERALS+1, ltree); /* send the length code */
- extra = extra_lbits[code];
- if (extra != 0) {
- lc -= base_length[code];
- send_bits(s, lc, extra); /* send the extra length bits */
- }
- dist--; /* dist is now the match distance - 1 */
- code = d_code(dist);
- Assert (code < D_CODES, "bad d_code");
-
- send_code(s, code, dtree); /* send the distance code */
- extra = extra_dbits[code];
- if (extra != 0) {
- dist -= base_dist[code];
- send_bits(s, dist, extra); /* send the extra distance bits */
- }
- } /* literal or match pair ? */
-
- /* Check that the overlay between pending_buf and d_buf+l_buf is ok: */
- Assert((uInt)(s->pending) < s->lit_bufsize + 2*lx,
- "pendingBuf overflow");
-
- } while (lx < s->last_lit);
-
- send_code(s, END_BLOCK, ltree);
- s->last_eob_len = ltree[END_BLOCK].Len;
-}
-
-/* ===========================================================================
- * Set the data type to ASCII or BINARY, using a crude approximation:
- * binary if more than 20% of the bytes are <= 6 or >= 128, ascii otherwise.
- * IN assertion: the fields freq of dyn_ltree are set and the total of all
- * frequencies does not exceed 64K (to fit in an int on 16 bit machines).
- */
-local void set_data_type(s)
- deflate_state *s;
-{
- int n = 0;
- unsigned ascii_freq = 0;
- unsigned bin_freq = 0;
- while (n < 7) bin_freq += s->dyn_ltree[n++].Freq;
- while (n < 128) ascii_freq += s->dyn_ltree[n++].Freq;
- while (n < LITERALS) bin_freq += s->dyn_ltree[n++].Freq;
- s->data_type = (Byte)(bin_freq > (ascii_freq >> 2) ? Z_BINARY : Z_ASCII);
-}
-
-/* ===========================================================================
- * Reverse the first len bits of a code, using straightforward code (a faster
- * method would use a table)
- * IN assertion: 1 <= len <= 15
- */
-local unsigned bi_reverse(code, len)
- unsigned code; /* the value to invert */
- int len; /* its bit length */
-{
- register unsigned res = 0;
- do {
- res |= code & 1;
- code >>= 1, res <<= 1;
- } while (--len > 0);
- return res >> 1;
-}
-
-/* ===========================================================================
- * Flush the bit buffer, keeping at most 7 bits in it.
- */
-local void bi_flush(s)
- deflate_state *s;
-{
- if (s->bi_valid == 16) {
- put_short(s, s->bi_buf);
- s->bi_buf = 0;
- s->bi_valid = 0;
- } else if (s->bi_valid >= 8) {
- put_byte(s, (Byte)s->bi_buf);
- s->bi_buf >>= 8;
- s->bi_valid -= 8;
- }
-}
-
-/* ===========================================================================
- * Flush the bit buffer and align the output on a byte boundary
- */
-local void bi_windup(s)
- deflate_state *s;
-{
- if (s->bi_valid > 8) {
- put_short(s, s->bi_buf);
- } else if (s->bi_valid > 0) {
- put_byte(s, (Byte)s->bi_buf);
- }
- s->bi_buf = 0;
- s->bi_valid = 0;
-#ifdef DEBUG
- s->bits_sent = (s->bits_sent+7) & ~7;
-#endif
-}
-
-/* ===========================================================================
- * Copy a stored block, storing first the length and its
- * one's complement if requested.
- */
-local void copy_block(s, buf, len, header)
- deflate_state *s;
- charf *buf; /* the input data */
- unsigned len; /* its length */
- int header; /* true if block header must be written */
-{
- bi_windup(s); /* align on byte boundary */
- s->last_eob_len = 8; /* enough lookahead for inflate */
-
- if (header) {
- put_short(s, (ush)len);
- put_short(s, (ush)~len);
-#ifdef DEBUG
- s->bits_sent += 2*16;
-#endif
- }
-#ifdef DEBUG
- s->bits_sent += (ulg)len<<3;
-#endif
- while (len--) {
- put_byte(s, *buf++);
- }
-}
diff --git a/klibc/klibc/zlib/trees.h b/klibc/klibc/zlib/trees.h
deleted file mode 100644
index 72facf900f..0000000000
--- a/klibc/klibc/zlib/trees.h
+++ /dev/null
@@ -1,128 +0,0 @@
-/* header created automatically with -DGEN_TREES_H */
-
-local const ct_data static_ltree[L_CODES+2] = {
-{{ 12},{ 8}}, {{140},{ 8}}, {{ 76},{ 8}}, {{204},{ 8}}, {{ 44},{ 8}},
-{{172},{ 8}}, {{108},{ 8}}, {{236},{ 8}}, {{ 28},{ 8}}, {{156},{ 8}},
-{{ 92},{ 8}}, {{220},{ 8}}, {{ 60},{ 8}}, {{188},{ 8}}, {{124},{ 8}},
-{{252},{ 8}}, {{ 2},{ 8}}, {{130},{ 8}}, {{ 66},{ 8}}, {{194},{ 8}},
-{{ 34},{ 8}}, {{162},{ 8}}, {{ 98},{ 8}}, {{226},{ 8}}, {{ 18},{ 8}},
-{{146},{ 8}}, {{ 82},{ 8}}, {{210},{ 8}}, {{ 50},{ 8}}, {{178},{ 8}},
-{{114},{ 8}}, {{242},{ 8}}, {{ 10},{ 8}}, {{138},{ 8}}, {{ 74},{ 8}},
-{{202},{ 8}}, {{ 42},{ 8}}, {{170},{ 8}}, {{106},{ 8}}, {{234},{ 8}},
-{{ 26},{ 8}}, {{154},{ 8}}, {{ 90},{ 8}}, {{218},{ 8}}, {{ 58},{ 8}},
-{{186},{ 8}}, {{122},{ 8}}, {{250},{ 8}}, {{ 6},{ 8}}, {{134},{ 8}},
-{{ 70},{ 8}}, {{198},{ 8}}, {{ 38},{ 8}}, {{166},{ 8}}, {{102},{ 8}},
-{{230},{ 8}}, {{ 22},{ 8}}, {{150},{ 8}}, {{ 86},{ 8}}, {{214},{ 8}},
-{{ 54},{ 8}}, {{182},{ 8}}, {{118},{ 8}}, {{246},{ 8}}, {{ 14},{ 8}},
-{{142},{ 8}}, {{ 78},{ 8}}, {{206},{ 8}}, {{ 46},{ 8}}, {{174},{ 8}},
-{{110},{ 8}}, {{238},{ 8}}, {{ 30},{ 8}}, {{158},{ 8}}, {{ 94},{ 8}},
-{{222},{ 8}}, {{ 62},{ 8}}, {{190},{ 8}}, {{126},{ 8}}, {{254},{ 8}},
-{{ 1},{ 8}}, {{129},{ 8}}, {{ 65},{ 8}}, {{193},{ 8}}, {{ 33},{ 8}},
-{{161},{ 8}}, {{ 97},{ 8}}, {{225},{ 8}}, {{ 17},{ 8}}, {{145},{ 8}},
-{{ 81},{ 8}}, {{209},{ 8}}, {{ 49},{ 8}}, {{177},{ 8}}, {{113},{ 8}},
-{{241},{ 8}}, {{ 9},{ 8}}, {{137},{ 8}}, {{ 73},{ 8}}, {{201},{ 8}},
-{{ 41},{ 8}}, {{169},{ 8}}, {{105},{ 8}}, {{233},{ 8}}, {{ 25},{ 8}},
-{{153},{ 8}}, {{ 89},{ 8}}, {{217},{ 8}}, {{ 57},{ 8}}, {{185},{ 8}},
-{{121},{ 8}}, {{249},{ 8}}, {{ 5},{ 8}}, {{133},{ 8}}, {{ 69},{ 8}},
-{{197},{ 8}}, {{ 37},{ 8}}, {{165},{ 8}}, {{101},{ 8}}, {{229},{ 8}},
-{{ 21},{ 8}}, {{149},{ 8}}, {{ 85},{ 8}}, {{213},{ 8}}, {{ 53},{ 8}},
-{{181},{ 8}}, {{117},{ 8}}, {{245},{ 8}}, {{ 13},{ 8}}, {{141},{ 8}},
-{{ 77},{ 8}}, {{205},{ 8}}, {{ 45},{ 8}}, {{173},{ 8}}, {{109},{ 8}},
-{{237},{ 8}}, {{ 29},{ 8}}, {{157},{ 8}}, {{ 93},{ 8}}, {{221},{ 8}},
-{{ 61},{ 8}}, {{189},{ 8}}, {{125},{ 8}}, {{253},{ 8}}, {{ 19},{ 9}},
-{{275},{ 9}}, {{147},{ 9}}, {{403},{ 9}}, {{ 83},{ 9}}, {{339},{ 9}},
-{{211},{ 9}}, {{467},{ 9}}, {{ 51},{ 9}}, {{307},{ 9}}, {{179},{ 9}},
-{{435},{ 9}}, {{115},{ 9}}, {{371},{ 9}}, {{243},{ 9}}, {{499},{ 9}},
-{{ 11},{ 9}}, {{267},{ 9}}, {{139},{ 9}}, {{395},{ 9}}, {{ 75},{ 9}},
-{{331},{ 9}}, {{203},{ 9}}, {{459},{ 9}}, {{ 43},{ 9}}, {{299},{ 9}},
-{{171},{ 9}}, {{427},{ 9}}, {{107},{ 9}}, {{363},{ 9}}, {{235},{ 9}},
-{{491},{ 9}}, {{ 27},{ 9}}, {{283},{ 9}}, {{155},{ 9}}, {{411},{ 9}},
-{{ 91},{ 9}}, {{347},{ 9}}, {{219},{ 9}}, {{475},{ 9}}, {{ 59},{ 9}},
-{{315},{ 9}}, {{187},{ 9}}, {{443},{ 9}}, {{123},{ 9}}, {{379},{ 9}},
-{{251},{ 9}}, {{507},{ 9}}, {{ 7},{ 9}}, {{263},{ 9}}, {{135},{ 9}},
-{{391},{ 9}}, {{ 71},{ 9}}, {{327},{ 9}}, {{199},{ 9}}, {{455},{ 9}},
-{{ 39},{ 9}}, {{295},{ 9}}, {{167},{ 9}}, {{423},{ 9}}, {{103},{ 9}},
-{{359},{ 9}}, {{231},{ 9}}, {{487},{ 9}}, {{ 23},{ 9}}, {{279},{ 9}},
-{{151},{ 9}}, {{407},{ 9}}, {{ 87},{ 9}}, {{343},{ 9}}, {{215},{ 9}},
-{{471},{ 9}}, {{ 55},{ 9}}, {{311},{ 9}}, {{183},{ 9}}, {{439},{ 9}},
-{{119},{ 9}}, {{375},{ 9}}, {{247},{ 9}}, {{503},{ 9}}, {{ 15},{ 9}},
-{{271},{ 9}}, {{143},{ 9}}, {{399},{ 9}}, {{ 79},{ 9}}, {{335},{ 9}},
-{{207},{ 9}}, {{463},{ 9}}, {{ 47},{ 9}}, {{303},{ 9}}, {{175},{ 9}},
-{{431},{ 9}}, {{111},{ 9}}, {{367},{ 9}}, {{239},{ 9}}, {{495},{ 9}},
-{{ 31},{ 9}}, {{287},{ 9}}, {{159},{ 9}}, {{415},{ 9}}, {{ 95},{ 9}},
-{{351},{ 9}}, {{223},{ 9}}, {{479},{ 9}}, {{ 63},{ 9}}, {{319},{ 9}},
-{{191},{ 9}}, {{447},{ 9}}, {{127},{ 9}}, {{383},{ 9}}, {{255},{ 9}},
-{{511},{ 9}}, {{ 0},{ 7}}, {{ 64},{ 7}}, {{ 32},{ 7}}, {{ 96},{ 7}},
-{{ 16},{ 7}}, {{ 80},{ 7}}, {{ 48},{ 7}}, {{112},{ 7}}, {{ 8},{ 7}},
-{{ 72},{ 7}}, {{ 40},{ 7}}, {{104},{ 7}}, {{ 24},{ 7}}, {{ 88},{ 7}},
-{{ 56},{ 7}}, {{120},{ 7}}, {{ 4},{ 7}}, {{ 68},{ 7}}, {{ 36},{ 7}},
-{{100},{ 7}}, {{ 20},{ 7}}, {{ 84},{ 7}}, {{ 52},{ 7}}, {{116},{ 7}},
-{{ 3},{ 8}}, {{131},{ 8}}, {{ 67},{ 8}}, {{195},{ 8}}, {{ 35},{ 8}},
-{{163},{ 8}}, {{ 99},{ 8}}, {{227},{ 8}}
-};
-
-local const ct_data static_dtree[D_CODES] = {
-{{ 0},{ 5}}, {{16},{ 5}}, {{ 8},{ 5}}, {{24},{ 5}}, {{ 4},{ 5}},
-{{20},{ 5}}, {{12},{ 5}}, {{28},{ 5}}, {{ 2},{ 5}}, {{18},{ 5}},
-{{10},{ 5}}, {{26},{ 5}}, {{ 6},{ 5}}, {{22},{ 5}}, {{14},{ 5}},
-{{30},{ 5}}, {{ 1},{ 5}}, {{17},{ 5}}, {{ 9},{ 5}}, {{25},{ 5}},
-{{ 5},{ 5}}, {{21},{ 5}}, {{13},{ 5}}, {{29},{ 5}}, {{ 3},{ 5}},
-{{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}}
-};
-
-const uch _dist_code[DIST_CODE_LEN] = {
- 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8,
- 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10,
-10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
-11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
-12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13,
-13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
-13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
-14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
-14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
-14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15,
-15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
-15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
-15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 16, 17,
-18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22,
-23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
-24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
-26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
-26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27,
-27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
-27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
-28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
-28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
-28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
-29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
-29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
-29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29
-};
-
-const uch _length_code[MAX_MATCH-MIN_MATCH+1]= {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12,
-13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16,
-17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19,
-19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
-21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22,
-22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23,
-23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
-24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
-25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
-25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26,
-26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
-26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
-27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28
-};
-
-local const int base_length[LENGTH_CODES] = {
-0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56,
-64, 80, 96, 112, 128, 160, 192, 224, 0
-};
-
-local const int base_dist[D_CODES] = {
- 0, 1, 2, 3, 4, 6, 8, 12, 16, 24,
- 32, 48, 64, 96, 128, 192, 256, 384, 512, 768,
- 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576
-};
-
diff --git a/klibc/klibc/zlib/uncompr.c b/klibc/klibc/zlib/uncompr.c
deleted file mode 100644
index debee4385e..0000000000
--- a/klibc/klibc/zlib/uncompr.c
+++ /dev/null
@@ -1,61 +0,0 @@
-/* uncompr.c -- decompress a memory buffer
- * Copyright (C) 1995-2003 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* @(#) $Id: uncompr.c,v 1.1 2005/02/27 23:15:39 hpa Exp $ */
-
-#define ZLIB_INTERNAL
-#include "zlib.h"
-
-/* ===========================================================================
- Decompresses the source buffer into the destination buffer. sourceLen is
- the byte length of the source buffer. Upon entry, destLen is the total
- size of the destination buffer, which must be large enough to hold the
- entire uncompressed data. (The size of the uncompressed data must have
- been saved previously by the compressor and transmitted to the decompressor
- by some mechanism outside the scope of this compression library.)
- Upon exit, destLen is the actual size of the compressed buffer.
- This function can be used to decompress a whole file at once if the
- input file is mmap'ed.
-
- uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
- enough memory, Z_BUF_ERROR if there was not enough room in the output
- buffer, or Z_DATA_ERROR if the input data was corrupted.
-*/
-int ZEXPORT uncompress (dest, destLen, source, sourceLen)
- Bytef *dest;
- uLongf *destLen;
- const Bytef *source;
- uLong sourceLen;
-{
- z_stream stream;
- int err;
-
- stream.next_in = (Bytef*)source;
- stream.avail_in = (uInt)sourceLen;
- /* Check for source > 64K on 16-bit machine: */
- if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
-
- stream.next_out = dest;
- stream.avail_out = (uInt)*destLen;
- if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
-
- stream.zalloc = (alloc_func)0;
- stream.zfree = (free_func)0;
-
- err = inflateInit(&stream);
- if (err != Z_OK) return err;
-
- err = inflate(&stream, Z_FINISH);
- if (err != Z_STREAM_END) {
- inflateEnd(&stream);
- if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0))
- return Z_DATA_ERROR;
- return err;
- }
- *destLen = stream.total_out;
-
- err = inflateEnd(&stream);
- return err;
-}
diff --git a/klibc/klibc/zlib/zconf.h b/klibc/klibc/zlib/zconf.h
deleted file mode 100644
index 9b74ce7bd4..0000000000
--- a/klibc/klibc/zlib/zconf.h
+++ /dev/null
@@ -1,323 +0,0 @@
-/* zconf.h -- configuration of the zlib compression library
- * Copyright (C) 1995-2003 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* @(#) $Id: zconf.h,v 1.1 2005/02/27 23:15:39 hpa Exp $ */
-
-#ifndef ZCONF_H
-#define ZCONF_H
-
-/*
- * If you *really* need a unique prefix for all types and library functions,
- * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
- */
-#ifdef Z_PREFIX
-# define deflateInit_ z_deflateInit_
-# define deflate z_deflate
-# define deflateEnd z_deflateEnd
-# define inflateInit_ z_inflateInit_
-# define inflate z_inflate
-# define inflateEnd z_inflateEnd
-# define deflateInit2_ z_deflateInit2_
-# define deflateSetDictionary z_deflateSetDictionary
-# define deflateCopy z_deflateCopy
-# define deflateReset z_deflateReset
-# define deflatePrime z_deflatePrime
-# define deflateParams z_deflateParams
-# define deflateBound z_deflateBound
-# define inflateInit2_ z_inflateInit2_
-# define inflateSetDictionary z_inflateSetDictionary
-# define inflateSync z_inflateSync
-# define inflateSyncPoint z_inflateSyncPoint
-# define inflateCopy z_inflateCopy
-# define inflateReset z_inflateReset
-# define compress z_compress
-# define compress2 z_compress2
-# define compressBound z_compressBound
-# define uncompress z_uncompress
-# define adler32 z_adler32
-# define crc32 z_crc32
-# define get_crc_table z_get_crc_table
-
-# define Byte z_Byte
-# define uInt z_uInt
-# define uLong z_uLong
-# define Bytef z_Bytef
-# define charf z_charf
-# define intf z_intf
-# define uIntf z_uIntf
-# define uLongf z_uLongf
-# define voidpf z_voidpf
-# define voidp z_voidp
-#endif
-
-#if defined(__MSDOS__) && !defined(MSDOS)
-# define MSDOS
-#endif
-#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2)
-# define OS2
-#endif
-#if defined(_WINDOWS) && !defined(WINDOWS)
-# define WINDOWS
-#endif
-#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32)
-# define WIN32
-#endif
-#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)
-# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)
-# ifndef SYS16BIT
-# define SYS16BIT
-# endif
-# endif
-#endif
-
-/*
- * Compile with -DMAXSEG_64K if the alloc function cannot allocate more
- * than 64k bytes at a time (needed on systems with 16-bit int).
- */
-#ifdef SYS16BIT
-# define MAXSEG_64K
-#endif
-#ifdef MSDOS
-# define UNALIGNED_OK
-#endif
-
-#ifdef __STDC_VERSION__
-# ifndef STDC
-# define STDC
-# endif
-# if __STDC_VERSION__ >= 199901L
-# ifndef STDC99
-# define STDC99
-# endif
-# endif
-#endif
-#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))
-# define STDC
-#endif
-#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))
-# define STDC
-#endif
-#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32))
-# define STDC
-#endif
-#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__))
-# define STDC
-#endif
-
-#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */
-# define STDC
-#endif
-
-#ifndef STDC
-# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
-# define const /* note: need a more gentle solution here */
-# endif
-#endif
-
-/* Some Mac compilers merge all .h files incorrectly: */
-#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__)
-# define NO_DUMMY_DECL
-#endif
-
-/* Maximum value for memLevel in deflateInit2 */
-#ifndef MAX_MEM_LEVEL
-# ifdef MAXSEG_64K
-# define MAX_MEM_LEVEL 8
-# else
-# define MAX_MEM_LEVEL 9
-# endif
-#endif
-
-/* Maximum value for windowBits in deflateInit2 and inflateInit2.
- * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
- * created by gzip. (Files created by minigzip can still be extracted by
- * gzip.)
- */
-#ifndef MAX_WBITS
-# define MAX_WBITS 15 /* 32K LZ77 window */
-#endif
-
-/* The memory requirements for deflate are (in bytes):
- (1 << (windowBits+2)) + (1 << (memLevel+9))
- that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values)
- plus a few kilobytes for small objects. For example, if you want to reduce
- the default memory requirements from 256K to 128K, compile with
- make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
- Of course this will generally degrade compression (there's no free lunch).
-
- The memory requirements for inflate are (in bytes) 1 << windowBits
- that is, 32K for windowBits=15 (default value) plus a few kilobytes
- for small objects.
-*/
-
- /* Type declarations */
-
-#ifndef OF /* function prototypes */
-# ifdef STDC
-# define OF(args) args
-# else
-# define OF(args) ()
-# endif
-#endif
-
-/* The following definitions for FAR are needed only for MSDOS mixed
- * model programming (small or medium model with some far allocations).
- * This was tested only with MSC; for other MSDOS compilers you may have
- * to define NO_MEMCPY in zutil.h. If you don't need the mixed model,
- * just define FAR to be empty.
- */
-#ifdef SYS16BIT
-# if defined(M_I86SM) || defined(M_I86MM)
- /* MSC small or medium model */
-# define SMALL_MEDIUM
-# ifdef _MSC_VER
-# define FAR _far
-# else
-# define FAR far
-# endif
-# endif
-# if (defined(__SMALL__) || defined(__MEDIUM__))
- /* Turbo C small or medium model */
-# define SMALL_MEDIUM
-# ifdef __BORLANDC__
-# define FAR _far
-# else
-# define FAR far
-# endif
-# endif
-#endif
-
-#if defined(WINDOWS) || defined(WIN32)
- /* If building or using zlib as a DLL, define ZLIB_DLL.
- * This is not mandatory, but it offers a little performance increase.
- */
-# ifdef ZLIB_DLL
-# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))
-# ifdef ZLIB_INTERNAL
-# define ZEXTERN extern __declspec(dllexport)
-# else
-# define ZEXTERN extern __declspec(dllimport)
-# endif
-# endif
-# endif /* ZLIB_DLL */
- /* If building or using zlib with the WINAPI/WINAPIV calling convention,
- * define ZLIB_WINAPI.
- * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.
- */
-# ifdef ZLIB_WINAPI
-# ifdef FAR
-# undef FAR
-# endif
-# include <windows.h>
- /* No need for _export, use ZLIB.DEF instead. */
- /* For complete Windows compatibility, use WINAPI, not __stdcall. */
-# define ZEXPORT WINAPI
-# ifdef WIN32
-# define ZEXPORTVA WINAPIV
-# else
-# define ZEXPORTVA FAR CDECL
-# endif
-# endif
-#endif
-
-#if defined (__BEOS__)
-# ifdef ZLIB_DLL
-# ifdef ZLIB_INTERNAL
-# define ZEXPORT __declspec(dllexport)
-# define ZEXPORTVA __declspec(dllexport)
-# else
-# define ZEXPORT __declspec(dllimport)
-# define ZEXPORTVA __declspec(dllimport)
-# endif
-# endif
-#endif
-
-#ifndef ZEXTERN
-# define ZEXTERN extern
-#endif
-#ifndef ZEXPORT
-# define ZEXPORT
-#endif
-#ifndef ZEXPORTVA
-# define ZEXPORTVA
-#endif
-
-#ifndef FAR
-# define FAR
-#endif
-
-#if !defined(__MACTYPES__)
-typedef unsigned char Byte; /* 8 bits */
-#endif
-typedef unsigned int uInt; /* 16 bits or more */
-typedef unsigned long uLong; /* 32 bits or more */
-
-#ifdef SMALL_MEDIUM
- /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
-# define Bytef Byte FAR
-#else
- typedef Byte FAR Bytef;
-#endif
-typedef char FAR charf;
-typedef int FAR intf;
-typedef uInt FAR uIntf;
-typedef uLong FAR uLongf;
-
-#ifdef STDC
- typedef void const *voidpc;
- typedef void FAR *voidpf;
- typedef void *voidp;
-#else
- typedef Byte const *voidpc;
- typedef Byte FAR *voidpf;
- typedef Byte *voidp;
-#endif
-
-#if 0 /* HAVE_UNISTD_H -- this line is updated by ./configure */
-# include <sys/types.h> /* for off_t */
-# include <unistd.h> /* for SEEK_* and off_t */
-# ifdef VMS
-# include <unixio.h> /* for off_t */
-# endif
-# define z_off_t off_t
-#endif
-#ifndef SEEK_SET
-# define SEEK_SET 0 /* Seek from beginning of file. */
-# define SEEK_CUR 1 /* Seek from current position. */
-# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
-#endif
-#ifndef z_off_t
-# define z_off_t long
-#endif
-
-#if defined(__OS400__)
-#define NO_vsnprintf
-#endif
-
-#if defined(__MVS__)
-# define NO_vsnprintf
-# ifdef FAR
-# undef FAR
-# endif
-#endif
-
-/* MVS linker does not support external names larger than 8 bytes */
-#if defined(__MVS__)
-# pragma map(deflateInit_,"DEIN")
-# pragma map(deflateInit2_,"DEIN2")
-# pragma map(deflateEnd,"DEEND")
-# pragma map(deflateBound,"DEBND")
-# pragma map(inflateInit_,"ININ")
-# pragma map(inflateInit2_,"ININ2")
-# pragma map(inflateEnd,"INEND")
-# pragma map(inflateSync,"INSY")
-# pragma map(inflateSetDictionary,"INSEDI")
-# pragma map(compressBound,"CMBND")
-# pragma map(inflate_table,"INTABL")
-# pragma map(inflate_fast,"INFA")
-# pragma map(inflate_copyright,"INCOPY")
-#endif
-
-#endif /* ZCONF_H */
diff --git a/klibc/klibc/zlib/zconf.in.h b/klibc/klibc/zlib/zconf.in.h
deleted file mode 100644
index d96c85955c..0000000000
--- a/klibc/klibc/zlib/zconf.in.h
+++ /dev/null
@@ -1,323 +0,0 @@
-/* zconf.h -- configuration of the zlib compression library
- * Copyright (C) 1995-2003 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* @(#) $Id: zconf.in.h,v 1.1 2005/02/27 23:15:39 hpa Exp $ */
-
-#ifndef ZCONF_H
-#define ZCONF_H
-
-/*
- * If you *really* need a unique prefix for all types and library functions,
- * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
- */
-#ifdef Z_PREFIX
-# define deflateInit_ z_deflateInit_
-# define deflate z_deflate
-# define deflateEnd z_deflateEnd
-# define inflateInit_ z_inflateInit_
-# define inflate z_inflate
-# define inflateEnd z_inflateEnd
-# define deflateInit2_ z_deflateInit2_
-# define deflateSetDictionary z_deflateSetDictionary
-# define deflateCopy z_deflateCopy
-# define deflateReset z_deflateReset
-# define deflatePrime z_deflatePrime
-# define deflateParams z_deflateParams
-# define deflateBound z_deflateBound
-# define inflateInit2_ z_inflateInit2_
-# define inflateSetDictionary z_inflateSetDictionary
-# define inflateSync z_inflateSync
-# define inflateSyncPoint z_inflateSyncPoint
-# define inflateCopy z_inflateCopy
-# define inflateReset z_inflateReset
-# define compress z_compress
-# define compress2 z_compress2
-# define compressBound z_compressBound
-# define uncompress z_uncompress
-# define adler32 z_adler32
-# define crc32 z_crc32
-# define get_crc_table z_get_crc_table
-
-# define Byte z_Byte
-# define uInt z_uInt
-# define uLong z_uLong
-# define Bytef z_Bytef
-# define charf z_charf
-# define intf z_intf
-# define uIntf z_uIntf
-# define uLongf z_uLongf
-# define voidpf z_voidpf
-# define voidp z_voidp
-#endif
-
-#if defined(__MSDOS__) && !defined(MSDOS)
-# define MSDOS
-#endif
-#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2)
-# define OS2
-#endif
-#if defined(_WINDOWS) && !defined(WINDOWS)
-# define WINDOWS
-#endif
-#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32)
-# define WIN32
-#endif
-#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)
-# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)
-# ifndef SYS16BIT
-# define SYS16BIT
-# endif
-# endif
-#endif
-
-/*
- * Compile with -DMAXSEG_64K if the alloc function cannot allocate more
- * than 64k bytes at a time (needed on systems with 16-bit int).
- */
-#ifdef SYS16BIT
-# define MAXSEG_64K
-#endif
-#ifdef MSDOS
-# define UNALIGNED_OK
-#endif
-
-#ifdef __STDC_VERSION__
-# ifndef STDC
-# define STDC
-# endif
-# if __STDC_VERSION__ >= 199901L
-# ifndef STDC99
-# define STDC99
-# endif
-# endif
-#endif
-#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))
-# define STDC
-#endif
-#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))
-# define STDC
-#endif
-#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32))
-# define STDC
-#endif
-#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__))
-# define STDC
-#endif
-
-#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */
-# define STDC
-#endif
-
-#ifndef STDC
-# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
-# define const /* note: need a more gentle solution here */
-# endif
-#endif
-
-/* Some Mac compilers merge all .h files incorrectly: */
-#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__)
-# define NO_DUMMY_DECL
-#endif
-
-/* Maximum value for memLevel in deflateInit2 */
-#ifndef MAX_MEM_LEVEL
-# ifdef MAXSEG_64K
-# define MAX_MEM_LEVEL 8
-# else
-# define MAX_MEM_LEVEL 9
-# endif
-#endif
-
-/* Maximum value for windowBits in deflateInit2 and inflateInit2.
- * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
- * created by gzip. (Files created by minigzip can still be extracted by
- * gzip.)
- */
-#ifndef MAX_WBITS
-# define MAX_WBITS 15 /* 32K LZ77 window */
-#endif
-
-/* The memory requirements for deflate are (in bytes):
- (1 << (windowBits+2)) + (1 << (memLevel+9))
- that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values)
- plus a few kilobytes for small objects. For example, if you want to reduce
- the default memory requirements from 256K to 128K, compile with
- make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
- Of course this will generally degrade compression (there's no free lunch).
-
- The memory requirements for inflate are (in bytes) 1 << windowBits
- that is, 32K for windowBits=15 (default value) plus a few kilobytes
- for small objects.
-*/
-
- /* Type declarations */
-
-#ifndef OF /* function prototypes */
-# ifdef STDC
-# define OF(args) args
-# else
-# define OF(args) ()
-# endif
-#endif
-
-/* The following definitions for FAR are needed only for MSDOS mixed
- * model programming (small or medium model with some far allocations).
- * This was tested only with MSC; for other MSDOS compilers you may have
- * to define NO_MEMCPY in zutil.h. If you don't need the mixed model,
- * just define FAR to be empty.
- */
-#ifdef SYS16BIT
-# if defined(M_I86SM) || defined(M_I86MM)
- /* MSC small or medium model */
-# define SMALL_MEDIUM
-# ifdef _MSC_VER
-# define FAR _far
-# else
-# define FAR far
-# endif
-# endif
-# if (defined(__SMALL__) || defined(__MEDIUM__))
- /* Turbo C small or medium model */
-# define SMALL_MEDIUM
-# ifdef __BORLANDC__
-# define FAR _far
-# else
-# define FAR far
-# endif
-# endif
-#endif
-
-#if defined(WINDOWS) || defined(WIN32)
- /* If building or using zlib as a DLL, define ZLIB_DLL.
- * This is not mandatory, but it offers a little performance increase.
- */
-# ifdef ZLIB_DLL
-# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))
-# ifdef ZLIB_INTERNAL
-# define ZEXTERN extern __declspec(dllexport)
-# else
-# define ZEXTERN extern __declspec(dllimport)
-# endif
-# endif
-# endif /* ZLIB_DLL */
- /* If building or using zlib with the WINAPI/WINAPIV calling convention,
- * define ZLIB_WINAPI.
- * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.
- */
-# ifdef ZLIB_WINAPI
-# ifdef FAR
-# undef FAR
-# endif
-# include <windows.h>
- /* No need for _export, use ZLIB.DEF instead. */
- /* For complete Windows compatibility, use WINAPI, not __stdcall. */
-# define ZEXPORT WINAPI
-# ifdef WIN32
-# define ZEXPORTVA WINAPIV
-# else
-# define ZEXPORTVA FAR CDECL
-# endif
-# endif
-#endif
-
-#if defined (__BEOS__)
-# ifdef ZLIB_DLL
-# ifdef ZLIB_INTERNAL
-# define ZEXPORT __declspec(dllexport)
-# define ZEXPORTVA __declspec(dllexport)
-# else
-# define ZEXPORT __declspec(dllimport)
-# define ZEXPORTVA __declspec(dllimport)
-# endif
-# endif
-#endif
-
-#ifndef ZEXTERN
-# define ZEXTERN extern
-#endif
-#ifndef ZEXPORT
-# define ZEXPORT
-#endif
-#ifndef ZEXPORTVA
-# define ZEXPORTVA
-#endif
-
-#ifndef FAR
-# define FAR
-#endif
-
-#if !defined(__MACTYPES__)
-typedef unsigned char Byte; /* 8 bits */
-#endif
-typedef unsigned int uInt; /* 16 bits or more */
-typedef unsigned long uLong; /* 32 bits or more */
-
-#ifdef SMALL_MEDIUM
- /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
-# define Bytef Byte FAR
-#else
- typedef Byte FAR Bytef;
-#endif
-typedef char FAR charf;
-typedef int FAR intf;
-typedef uInt FAR uIntf;
-typedef uLong FAR uLongf;
-
-#ifdef STDC
- typedef void const *voidpc;
- typedef void FAR *voidpf;
- typedef void *voidp;
-#else
- typedef Byte const *voidpc;
- typedef Byte FAR *voidpf;
- typedef Byte *voidp;
-#endif
-
-#if 0 /* HAVE_UNISTD_H -- this line is updated by ./configure */
-# include <sys/types.h> /* for off_t */
-# include <unistd.h> /* for SEEK_* and off_t */
-# ifdef VMS
-# include <unixio.h> /* for off_t */
-# endif
-# define z_off_t off_t
-#endif
-#ifndef SEEK_SET
-# define SEEK_SET 0 /* Seek from beginning of file. */
-# define SEEK_CUR 1 /* Seek from current position. */
-# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
-#endif
-#ifndef z_off_t
-# define z_off_t long
-#endif
-
-#if defined(__OS400__)
-#define NO_vsnprintf
-#endif
-
-#if defined(__MVS__)
-# define NO_vsnprintf
-# ifdef FAR
-# undef FAR
-# endif
-#endif
-
-/* MVS linker does not support external names larger than 8 bytes */
-#if defined(__MVS__)
-# pragma map(deflateInit_,"DEIN")
-# pragma map(deflateInit2_,"DEIN2")
-# pragma map(deflateEnd,"DEEND")
-# pragma map(deflateBound,"DEBND")
-# pragma map(inflateInit_,"ININ")
-# pragma map(inflateInit2_,"ININ2")
-# pragma map(inflateEnd,"INEND")
-# pragma map(inflateSync,"INSY")
-# pragma map(inflateSetDictionary,"INSEDI")
-# pragma map(compressBound,"CMBND")
-# pragma map(inflate_table,"INTABL")
-# pragma map(inflate_fast,"INFA")
-# pragma map(inflate_copyright,"INCOPY")
-#endif
-
-#endif /* ZCONF_H */
diff --git a/klibc/klibc/zlib/zlib.3 b/klibc/klibc/zlib/zlib.3
deleted file mode 100644
index 890098449d..0000000000
--- a/klibc/klibc/zlib/zlib.3
+++ /dev/null
@@ -1,159 +0,0 @@
-.TH ZLIB 3 "17 November 2003"
-.SH NAME
-zlib \- compression/decompression library
-.SH SYNOPSIS
-[see
-.I zlib.h
-for full description]
-.SH DESCRIPTION
-The
-.I zlib
-library is a general purpose data compression library.
-The code is thread safe.
-It provides in-memory compression and decompression functions,
-including integrity checks of the uncompressed data.
-This version of the library supports only one compression method (deflation)
-but other algorithms will be added later
-and will have the same stream interface.
-.LP
-Compression can be done in a single step if the buffers are large enough
-(for example if an input file is mmap'ed),
-or can be done by repeated calls of the compression function.
-In the latter case,
-the application must provide more input and/or consume the output
-(providing more output space) before each call.
-.LP
-The library also supports reading and writing files in
-.IR gzip (1)
-(.gz) format
-with an interface similar to that of stdio.
-.LP
-The library does not install any signal handler.
-The decoder checks the consistency of the compressed data,
-so the library should never crash even in case of corrupted input.
-.LP
-All functions of the compression library are documented in the file
-.IR zlib.h .
-The distribution source includes examples of use of the library
-in the files
-.I example.c
-and
-.IR minigzip.c .
-.LP
-Changes to this version are documented in the file
-.I ChangeLog
-that accompanies the source,
-and are concerned primarily with bug fixes and portability enhancements.
-.LP
-A Java implementation of
-.I zlib
-is available in the Java Development Kit 1.1:
-.IP
-http://www.javasoft.com/products/JDK/1.1/docs/api/Package-java.util.zip.html
-.LP
-A Perl interface to
-.IR zlib ,
-written by Paul Marquess (pmqs@cpan.org),
-is available at CPAN (Comprehensive Perl Archive Network) sites,
-including:
-.IP
-http://www.cpan.org/modules/by-module/Compress/
-.LP
-A Python interface to
-.IR zlib ,
-written by A.M. Kuchling (amk@magnet.com),
-is available in Python 1.5 and later versions:
-.IP
-http://www.python.org/doc/lib/module-zlib.html
-.LP
-A
-.I zlib
-binding for
-.IR tcl (1),
-written by Andreas Kupries (a.kupries@westend.com),
-is availlable at:
-.IP
-http://www.westend.com/~kupries/doc/trf/man/man.html
-.LP
-An experimental package to read and write files in .zip format,
-written on top of
-.I zlib
-by Gilles Vollant (info@winimage.com),
-is available at:
-.IP
-http://www.winimage.com/zLibDll/unzip.html
-and also in the
-.I contrib/minizip
-directory of the main
-.I zlib
-web site.
-.SH "SEE ALSO"
-The
-.I zlib
-web site can be found at either of these locations:
-.IP
-http://www.zlib.org
-.br
-http://www.gzip.org/zlib/
-.LP
-The data format used by the zlib library is described by RFC
-(Request for Comments) 1950 to 1952 in the files:
-.IP
-http://www.ietf.org/rfc/rfc1950.txt (concerning zlib format)
-.br
-http://www.ietf.org/rfc/rfc1951.txt (concerning deflate format)
-.br
-http://www.ietf.org/rfc/rfc1952.txt (concerning gzip format)
-.LP
-These documents are also available in other formats from:
-.IP
-ftp://ftp.uu.net/graphics/png/documents/zlib/zdoc-index.html
-.LP
-Mark Nelson (markn@ieee.org) wrote an article about
-.I zlib
-for the Jan. 1997 issue of Dr. Dobb's Journal;
-a copy of the article is available at:
-.IP
-http://dogma.net/markn/articles/zlibtool/zlibtool.htm
-.SH "REPORTING PROBLEMS"
-Before reporting a problem,
-please check the
-.I zlib
-web site to verify that you have the latest version of
-.IR zlib ;
-otherwise,
-obtain the latest version and see if the problem still exists.
-Please read the
-.I zlib
-FAQ at:
-.IP
-http://www.gzip.org/zlib/zlib_faq.html
-.LP
-before asking for help.
-Send questions and/or comments to zlib@gzip.org,
-or (for the Windows DLL version) to Gilles Vollant (info@winimage.com).
-.SH AUTHORS
-Version 1.2.1
-Copyright (C) 1995-2003 Jean-loup Gailly (jloup@gzip.org)
-and Mark Adler (madler@alumni.caltech.edu).
-.LP
-This software is provided "as-is,"
-without any express or implied warranty.
-In no event will the authors be held liable for any damages
-arising from the use of this software.
-See the distribution directory with respect to requirements
-governing redistribution.
-The deflate format used by
-.I zlib
-was defined by Phil Katz.
-The deflate and
-.I zlib
-specifications were written by L. Peter Deutsch.
-Thanks to all the people who reported problems and suggested various
-improvements in
-.IR zlib ;
-who are too numerous to cite here.
-.LP
-UNIX manual page by R. P. C. Rodgers,
-U.S. National Library of Medicine (rodgers@nlm.nih.gov).
-.\" end of man page
diff --git a/klibc/klibc/zlib/zlib.h b/klibc/klibc/zlib/zlib.h
deleted file mode 100644
index 92edf96ff3..0000000000
--- a/klibc/klibc/zlib/zlib.h
+++ /dev/null
@@ -1,1200 +0,0 @@
-/* zlib.h -- interface of the 'zlib' general purpose compression library
- version 1.2.1, November 17th, 2003
-
- Copyright (C) 1995-2003 Jean-loup Gailly and Mark Adler
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-
- Jean-loup Gailly Mark Adler
- jloup@gzip.org madler@alumni.caltech.edu
-
-
- The data format used by the zlib library is described by RFCs (Request for
- Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt
- (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format).
-*/
-
-#ifndef ZLIB_H
-#define ZLIB_H
-
-#include "zconf.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define ZLIB_VERSION "1.2.1"
-#define ZLIB_VERNUM 0x1210
-
-/*
- The 'zlib' compression library provides in-memory compression and
- decompression functions, including integrity checks of the uncompressed
- data. This version of the library supports only one compression method
- (deflation) but other algorithms will be added later and will have the same
- stream interface.
-
- Compression can be done in a single step if the buffers are large
- enough (for example if an input file is mmap'ed), or can be done by
- repeated calls of the compression function. In the latter case, the
- application must provide more input and/or consume the output
- (providing more output space) before each call.
-
- The compressed data format used by the in-memory functions is the zlib
- format, which is a zlib wrapper documented in RFC 1950, wrapped around a
- deflate stream, which is itself documented in RFC 1951.
-
- The library also supports reading and writing files in gzip (.gz) format
- with an interface similar to that of stdio using the functions that start
- with "gz". The gzip format is different from the zlib format. gzip is a
- gzip wrapper, documented in RFC 1952, wrapped around a deflate stream.
-
- The zlib format was designed to be compact and fast for use in memory
- and on communications channels. The gzip format was designed for single-
- file compression on file systems, has a larger header than zlib to maintain
- directory information, and uses a different, slower check method than zlib.
-
- This library does not provide any functions to write gzip files in memory.
- However such functions could be easily written using zlib's deflate function,
- the documentation in the gzip RFC, and the examples in gzio.c.
-
- The library does not install any signal handler. The decoder checks
- the consistency of the compressed data, so the library should never
- crash even in case of corrupted input.
-*/
-
-typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size));
-typedef void (*free_func) OF((voidpf opaque, voidpf address));
-
-struct internal_state;
-
-typedef struct z_stream_s {
- Bytef *next_in; /* next input byte */
- uInt avail_in; /* number of bytes available at next_in */
- uLong total_in; /* total nb of input bytes read so far */
-
- Bytef *next_out; /* next output byte should be put there */
- uInt avail_out; /* remaining free space at next_out */
- uLong total_out; /* total nb of bytes output so far */
-
- char *msg; /* last error message, NULL if no error */
- struct internal_state FAR *state; /* not visible by applications */
-
- alloc_func zalloc; /* used to allocate the internal state */
- free_func zfree; /* used to free the internal state */
- voidpf opaque; /* private data object passed to zalloc and zfree */
-
- int data_type; /* best guess about the data type: ascii or binary */
- uLong adler; /* adler32 value of the uncompressed data */
- uLong reserved; /* reserved for future use */
-} z_stream;
-
-typedef z_stream FAR *z_streamp;
-
-/*
- The application must update next_in and avail_in when avail_in has
- dropped to zero. It must update next_out and avail_out when avail_out
- has dropped to zero. The application must initialize zalloc, zfree and
- opaque before calling the init function. All other fields are set by the
- compression library and must not be updated by the application.
-
- The opaque value provided by the application will be passed as the first
- parameter for calls of zalloc and zfree. This can be useful for custom
- memory management. The compression library attaches no meaning to the
- opaque value.
-
- zalloc must return Z_NULL if there is not enough memory for the object.
- If zlib is used in a multi-threaded application, zalloc and zfree must be
- thread safe.
-
- On 16-bit systems, the functions zalloc and zfree must be able to allocate
- exactly 65536 bytes, but will not be required to allocate more than this
- if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS,
- pointers returned by zalloc for objects of exactly 65536 bytes *must*
- have their offset normalized to zero. The default allocation function
- provided by this library ensures this (see zutil.c). To reduce memory
- requirements and avoid any allocation of 64K objects, at the expense of
- compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h).
-
- The fields total_in and total_out can be used for statistics or
- progress reports. After compression, total_in holds the total size of
- the uncompressed data and may be saved for use in the decompressor
- (particularly if the decompressor wants to decompress everything in
- a single step).
-*/
-
- /* constants */
-
-#define Z_NO_FLUSH 0
-#define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */
-#define Z_SYNC_FLUSH 2
-#define Z_FULL_FLUSH 3
-#define Z_FINISH 4
-#define Z_BLOCK 5
-/* Allowed flush values; see deflate() and inflate() below for details */
-
-#define Z_OK 0
-#define Z_STREAM_END 1
-#define Z_NEED_DICT 2
-#define Z_ERRNO (-1)
-#define Z_STREAM_ERROR (-2)
-#define Z_DATA_ERROR (-3)
-#define Z_MEM_ERROR (-4)
-#define Z_BUF_ERROR (-5)
-#define Z_VERSION_ERROR (-6)
-/* Return codes for the compression/decompression functions. Negative
- * values are errors, positive values are used for special but normal events.
- */
-
-#define Z_NO_COMPRESSION 0
-#define Z_BEST_SPEED 1
-#define Z_BEST_COMPRESSION 9
-#define Z_DEFAULT_COMPRESSION (-1)
-/* compression levels */
-
-#define Z_FILTERED 1
-#define Z_HUFFMAN_ONLY 2
-#define Z_RLE 3
-#define Z_DEFAULT_STRATEGY 0
-/* compression strategy; see deflateInit2() below for details */
-
-#define Z_BINARY 0
-#define Z_ASCII 1
-#define Z_UNKNOWN 2
-/* Possible values of the data_type field (though see inflate()) */
-
-#define Z_DEFLATED 8
-/* The deflate compression method (the only one supported in this version) */
-
-#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */
-
-#define zlib_version zlibVersion()
-/* for compatibility with versions < 1.0.2 */
-
- /* basic functions */
-
-ZEXTERN const char * ZEXPORT zlibVersion OF((void));
-/* The application can compare zlibVersion and ZLIB_VERSION for consistency.
- If the first character differs, the library code actually used is
- not compatible with the zlib.h header file used by the application.
- This check is automatically made by deflateInit and inflateInit.
- */
-
-/*
-ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level));
-
- Initializes the internal stream state for compression. The fields
- zalloc, zfree and opaque must be initialized before by the caller.
- If zalloc and zfree are set to Z_NULL, deflateInit updates them to
- use default allocation functions.
-
- The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9:
- 1 gives best speed, 9 gives best compression, 0 gives no compression at
- all (the input data is simply copied a block at a time).
- Z_DEFAULT_COMPRESSION requests a default compromise between speed and
- compression (currently equivalent to level 6).
-
- deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not
- enough memory, Z_STREAM_ERROR if level is not a valid compression level,
- Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible
- with the version assumed by the caller (ZLIB_VERSION).
- msg is set to null if there is no error message. deflateInit does not
- perform any compression: this will be done by deflate().
-*/
-
-
-ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
-/*
- deflate compresses as much data as possible, and stops when the input
- buffer becomes empty or the output buffer becomes full. It may introduce some
- output latency (reading input without producing any output) except when
- forced to flush.
-
- The detailed semantics are as follows. deflate performs one or both of the
- following actions:
-
- - Compress more input starting at next_in and update next_in and avail_in
- accordingly. If not all input can be processed (because there is not
- enough room in the output buffer), next_in and avail_in are updated and
- processing will resume at this point for the next call of deflate().
-
- - Provide more output starting at next_out and update next_out and avail_out
- accordingly. This action is forced if the parameter flush is non zero.
- Forcing flush frequently degrades the compression ratio, so this parameter
- should be set only when necessary (in interactive applications).
- Some output may be provided even if flush is not set.
-
- Before the call of deflate(), the application should ensure that at least
- one of the actions is possible, by providing more input and/or consuming
- more output, and updating avail_in or avail_out accordingly; avail_out
- should never be zero before the call. The application can consume the
- compressed output when it wants, for example when the output buffer is full
- (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK
- and with zero avail_out, it must be called again after making room in the
- output buffer because there might be more output pending.
-
- If the parameter flush is set to Z_SYNC_FLUSH, all pending output is
- flushed to the output buffer and the output is aligned on a byte boundary, so
- that the decompressor can get all input data available so far. (In particular
- avail_in is zero after the call if enough output space has been provided
- before the call.) Flushing may degrade compression for some compression
- algorithms and so it should be used only when necessary.
-
- If flush is set to Z_FULL_FLUSH, all output is flushed as with
- Z_SYNC_FLUSH, and the compression state is reset so that decompression can
- restart from this point if previous compressed data has been damaged or if
- random access is desired. Using Z_FULL_FLUSH too often can seriously degrade
- the compression.
-
- If deflate returns with avail_out == 0, this function must be called again
- with the same value of the flush parameter and more output space (updated
- avail_out), until the flush is complete (deflate returns with non-zero
- avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that
- avail_out is greater than six to avoid repeated flush markers due to
- avail_out == 0 on return.
-
- If the parameter flush is set to Z_FINISH, pending input is processed,
- pending output is flushed and deflate returns with Z_STREAM_END if there
- was enough output space; if deflate returns with Z_OK, this function must be
- called again with Z_FINISH and more output space (updated avail_out) but no
- more input data, until it returns with Z_STREAM_END or an error. After
- deflate has returned Z_STREAM_END, the only possible operations on the
- stream are deflateReset or deflateEnd.
-
- Z_FINISH can be used immediately after deflateInit if all the compression
- is to be done in a single step. In this case, avail_out must be at least
- the value returned by deflateBound (see below). If deflate does not return
- Z_STREAM_END, then it must be called again as described above.
-
- deflate() sets strm->adler to the adler32 checksum of all input read
- so far (that is, total_in bytes).
-
- deflate() may update data_type if it can make a good guess about
- the input data type (Z_ASCII or Z_BINARY). In doubt, the data is considered
- binary. This field is only for information purposes and does not affect
- the compression algorithm in any manner.
-
- deflate() returns Z_OK if some progress has been made (more input
- processed or more output produced), Z_STREAM_END if all input has been
- consumed and all output has been produced (only when flush is set to
- Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example
- if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible
- (for example avail_in or avail_out was zero). Note that Z_BUF_ERROR is not
- fatal, and deflate() can be called again with more input and more output
- space to continue compressing.
-*/
-
-
-ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm));
-/*
- All dynamically allocated data structures for this stream are freed.
- This function discards any unprocessed input and does not flush any
- pending output.
-
- deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the
- stream state was inconsistent, Z_DATA_ERROR if the stream was freed
- prematurely (some input or output was discarded). In the error case,
- msg may be set but then points to a static string (which must not be
- deallocated).
-*/
-
-
-/*
-ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm));
-
- Initializes the internal stream state for decompression. The fields
- next_in, avail_in, zalloc, zfree and opaque must be initialized before by
- the caller. If next_in is not Z_NULL and avail_in is large enough (the exact
- value depends on the compression method), inflateInit determines the
- compression method from the zlib header and allocates all data structures
- accordingly; otherwise the allocation will be deferred to the first call of
- inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to
- use default allocation functions.
-
- inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough
- memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
- version assumed by the caller. msg is set to null if there is no error
- message. inflateInit does not perform any decompression apart from reading
- the zlib header if present: this will be done by inflate(). (So next_in and
- avail_in may be modified, but next_out and avail_out are unchanged.)
-*/
-
-
-ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
-/*
- inflate decompresses as much data as possible, and stops when the input
- buffer becomes empty or the output buffer becomes full. It may introduce
- some output latency (reading input without producing any output) except when
- forced to flush.
-
- The detailed semantics are as follows. inflate performs one or both of the
- following actions:
-
- - Decompress more input starting at next_in and update next_in and avail_in
- accordingly. If not all input can be processed (because there is not
- enough room in the output buffer), next_in is updated and processing
- will resume at this point for the next call of inflate().
-
- - Provide more output starting at next_out and update next_out and avail_out
- accordingly. inflate() provides as much output as possible, until there
- is no more input data or no more space in the output buffer (see below
- about the flush parameter).
-
- Before the call of inflate(), the application should ensure that at least
- one of the actions is possible, by providing more input and/or consuming
- more output, and updating the next_* and avail_* values accordingly.
- The application can consume the uncompressed output when it wants, for
- example when the output buffer is full (avail_out == 0), or after each
- call of inflate(). If inflate returns Z_OK and with zero avail_out, it
- must be called again after making room in the output buffer because there
- might be more output pending.
-
- The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH,
- Z_FINISH, or Z_BLOCK. Z_SYNC_FLUSH requests that inflate() flush as much
- output as possible to the output buffer. Z_BLOCK requests that inflate() stop
- if and when it get to the next deflate block boundary. When decoding the zlib
- or gzip format, this will cause inflate() to return immediately after the
- header and before the first block. When doing a raw inflate, inflate() will
- go ahead and process the first block, and will return when it gets to the end
- of that block, or when it runs out of data.
-
- The Z_BLOCK option assists in appending to or combining deflate streams.
- Also to assist in this, on return inflate() will set strm->data_type to the
- number of unused bits in the last byte taken from strm->next_in, plus 64
- if inflate() is currently decoding the last block in the deflate stream,
- plus 128 if inflate() returned immediately after decoding an end-of-block
- code or decoding the complete header up to just before the first byte of the
- deflate stream. The end-of-block will not be indicated until all of the
- uncompressed data from that block has been written to strm->next_out. The
- number of unused bits may in general be greater than seven, except when
- bit 7 of data_type is set, in which case the number of unused bits will be
- less than eight.
-
- inflate() should normally be called until it returns Z_STREAM_END or an
- error. However if all decompression is to be performed in a single step
- (a single call of inflate), the parameter flush should be set to
- Z_FINISH. In this case all pending input is processed and all pending
- output is flushed; avail_out must be large enough to hold all the
- uncompressed data. (The size of the uncompressed data may have been saved
- by the compressor for this purpose.) The next operation on this stream must
- be inflateEnd to deallocate the decompression state. The use of Z_FINISH
- is never required, but can be used to inform inflate that a faster approach
- may be used for the single inflate() call.
-
- In this implementation, inflate() always flushes as much output as
- possible to the output buffer, and always uses the faster approach on the
- first call. So the only effect of the flush parameter in this implementation
- is on the return value of inflate(), as noted below, or when it returns early
- because Z_BLOCK is used.
-
- If a preset dictionary is needed after this call (see inflateSetDictionary
- below), inflate sets strm-adler to the adler32 checksum of the dictionary
- chosen by the compressor and returns Z_NEED_DICT; otherwise it sets
- strm->adler to the adler32 checksum of all output produced so far (that is,
- total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described
- below. At the end of the stream, inflate() checks that its computed adler32
- checksum is equal to that saved by the compressor and returns Z_STREAM_END
- only if the checksum is correct.
-
- inflate() will decompress and check either zlib-wrapped or gzip-wrapped
- deflate data. The header type is detected automatically. Any information
- contained in the gzip header is not retained, so applications that need that
- information should instead use raw inflate, see inflateInit2() below, or
- inflateBack() and perform their own processing of the gzip header and
- trailer.
-
- inflate() returns Z_OK if some progress has been made (more input processed
- or more output produced), Z_STREAM_END if the end of the compressed data has
- been reached and all uncompressed output has been produced, Z_NEED_DICT if a
- preset dictionary is needed at this point, Z_DATA_ERROR if the input data was
- corrupted (input stream not conforming to the zlib format or incorrect check
- value), Z_STREAM_ERROR if the stream structure was inconsistent (for example
- if next_in or next_out was NULL), Z_MEM_ERROR if there was not enough memory,
- Z_BUF_ERROR if no progress is possible or if there was not enough room in the
- output buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and
- inflate() can be called again with more input and more output space to
- continue decompressing. If Z_DATA_ERROR is returned, the application may then
- call inflateSync() to look for a good compression block if a partial recovery
- of the data is desired.
-*/
-
-
-ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm));
-/*
- All dynamically allocated data structures for this stream are freed.
- This function discards any unprocessed input and does not flush any
- pending output.
-
- inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state
- was inconsistent. In the error case, msg may be set but then points to a
- static string (which must not be deallocated).
-*/
-
- /* Advanced functions */
-
-/*
- The following functions are needed only in some special applications.
-*/
-
-/*
-ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
- int level,
- int method,
- int windowBits,
- int memLevel,
- int strategy));
-
- This is another version of deflateInit with more compression options. The
- fields next_in, zalloc, zfree and opaque must be initialized before by
- the caller.
-
- The method parameter is the compression method. It must be Z_DEFLATED in
- this version of the library.
-
- The windowBits parameter is the base two logarithm of the window size
- (the size of the history buffer). It should be in the range 8..15 for this
- version of the library. Larger values of this parameter result in better
- compression at the expense of memory usage. The default value is 15 if
- deflateInit is used instead.
-
- windowBits can also be -8..-15 for raw deflate. In this case, -windowBits
- determines the window size. deflate() will then generate raw deflate data
- with no zlib header or trailer, and will not compute an adler32 check value.
-
- windowBits can also be greater than 15 for optional gzip encoding. Add
- 16 to windowBits to write a simple gzip header and trailer around the
- compressed data instead of a zlib wrapper. The gzip header will have no
- file name, no extra data, no comment, no modification time (set to zero),
- no header crc, and the operating system will be set to 255 (unknown).
-
- The memLevel parameter specifies how much memory should be allocated
- for the internal compression state. memLevel=1 uses minimum memory but
- is slow and reduces compression ratio; memLevel=9 uses maximum memory
- for optimal speed. The default value is 8. See zconf.h for total memory
- usage as a function of windowBits and memLevel.
-
- The strategy parameter is used to tune the compression algorithm. Use the
- value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a
- filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no
- string match), or Z_RLE to limit match distances to one (run-length
- encoding). Filtered data consists mostly of small values with a somewhat
- random distribution. In this case, the compression algorithm is tuned to
- compress them better. The effect of Z_FILTERED is to force more Huffman
- coding and less string matching; it is somewhat intermediate between
- Z_DEFAULT and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as fast as
- Z_HUFFMAN_ONLY, but give better compression for PNG image data. The strategy
- parameter only affects the compression ratio but not the correctness of the
- compressed output even if it is not set appropriately.
-
- deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
- memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid
- method). msg is set to null if there is no error message. deflateInit2 does
- not perform any compression: this will be done by deflate().
-*/
-
-ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,
- const Bytef *dictionary,
- uInt dictLength));
-/*
- Initializes the compression dictionary from the given byte sequence
- without producing any compressed output. This function must be called
- immediately after deflateInit, deflateInit2 or deflateReset, before any
- call of deflate. The compressor and decompressor must use exactly the same
- dictionary (see inflateSetDictionary).
-
- The dictionary should consist of strings (byte sequences) that are likely
- to be encountered later in the data to be compressed, with the most commonly
- used strings preferably put towards the end of the dictionary. Using a
- dictionary is most useful when the data to be compressed is short and can be
- predicted with good accuracy; the data can then be compressed better than
- with the default empty dictionary.
-
- Depending on the size of the compression data structures selected by
- deflateInit or deflateInit2, a part of the dictionary may in effect be
- discarded, for example if the dictionary is larger than the window size in
- deflate or deflate2. Thus the strings most likely to be useful should be
- put at the end of the dictionary, not at the front.
-
- Upon return of this function, strm->adler is set to the adler32 value
- of the dictionary; the decompressor may later use this value to determine
- which dictionary has been used by the compressor. (The adler32 value
- applies to the whole dictionary even if only a subset of the dictionary is
- actually used by the compressor.) If a raw deflate was requested, then the
- adler32 value is not computed and strm->adler is not set.
-
- deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a
- parameter is invalid (such as NULL dictionary) or the stream state is
- inconsistent (for example if deflate has already been called for this stream
- or if the compression method is bsort). deflateSetDictionary does not
- perform any compression: this will be done by deflate().
-*/
-
-ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest,
- z_streamp source));
-/*
- Sets the destination stream as a complete copy of the source stream.
-
- This function can be useful when several compression strategies will be
- tried, for example when there are several ways of pre-processing the input
- data with a filter. The streams that will be discarded should then be freed
- by calling deflateEnd. Note that deflateCopy duplicates the internal
- compression state which can be quite large, so this strategy is slow and
- can consume lots of memory.
-
- deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
- enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
- (such as zalloc being NULL). msg is left unchanged in both source and
- destination.
-*/
-
-ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm));
-/*
- This function is equivalent to deflateEnd followed by deflateInit,
- but does not free and reallocate all the internal compression state.
- The stream will keep the same compression level and any other attributes
- that may have been set by deflateInit2.
-
- deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
- stream state was inconsistent (such as zalloc or state being NULL).
-*/
-
-ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,
- int level,
- int strategy));
-/*
- Dynamically update the compression level and compression strategy. The
- interpretation of level and strategy is as in deflateInit2. This can be
- used to switch between compression and straight copy of the input data, or
- to switch to a different kind of input data requiring a different
- strategy. If the compression level is changed, the input available so far
- is compressed with the old level (and may be flushed); the new level will
- take effect only at the next call of deflate().
-
- Before the call of deflateParams, the stream state must be set as for
- a call of deflate(), since the currently available input may have to
- be compressed and flushed. In particular, strm->avail_out must be non-zero.
-
- deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source
- stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR
- if strm->avail_out was zero.
-*/
-
-ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm,
- uLong sourceLen));
-/*
- deflateBound() returns an upper bound on the compressed size after
- deflation of sourceLen bytes. It must be called after deflateInit()
- or deflateInit2(). This would be used to allocate an output buffer
- for deflation in a single pass, and so would be called before deflate().
-*/
-
-ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm,
- int bits,
- int value));
-/*
- deflatePrime() inserts bits in the deflate output stream. The intent
- is that this function is used to start off the deflate output with the
- bits leftover from a previous deflate stream when appending to it. As such,
- this function can only be used for raw deflate, and must be used before the
- first deflate() call after a deflateInit2() or deflateReset(). bits must be
- less than or equal to 16, and that many of the least significant bits of
- value will be inserted in the output.
-
- deflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source
- stream state was inconsistent.
-*/
-
-/*
-ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,
- int windowBits));
-
- This is another version of inflateInit with an extra parameter. The
- fields next_in, avail_in, zalloc, zfree and opaque must be initialized
- before by the caller.
-
- The windowBits parameter is the base two logarithm of the maximum window
- size (the size of the history buffer). It should be in the range 8..15 for
- this version of the library. The default value is 15 if inflateInit is used
- instead. windowBits must be greater than or equal to the windowBits value
- provided to deflateInit2() while compressing, or it must be equal to 15 if
- deflateInit2() was not used. If a compressed stream with a larger window
- size is given as input, inflate() will return with the error code
- Z_DATA_ERROR instead of trying to allocate a larger window.
-
- windowBits can also be -8..-15 for raw inflate. In this case, -windowBits
- determines the window size. inflate() will then process raw deflate data,
- not looking for a zlib or gzip header, not generating a check value, and not
- looking for any check values for comparison at the end of the stream. This
- is for use with other formats that use the deflate compressed data format
- such as zip. Those formats provide their own check values. If a custom
- format is developed using the raw deflate format for compressed data, it is
- recommended that a check value such as an adler32 or a crc32 be applied to
- the uncompressed data as is done in the zlib, gzip, and zip formats. For
- most applications, the zlib format should be used as is. Note that comments
- above on the use in deflateInit2() applies to the magnitude of windowBits.
-
- windowBits can also be greater than 15 for optional gzip decoding. Add
- 32 to windowBits to enable zlib and gzip decoding with automatic header
- detection, or add 16 to decode only the gzip format (the zlib format will
- return a Z_DATA_ERROR).
-
- inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
- memory, Z_STREAM_ERROR if a parameter is invalid (such as a negative
- memLevel). msg is set to null if there is no error message. inflateInit2
- does not perform any decompression apart from reading the zlib header if
- present: this will be done by inflate(). (So next_in and avail_in may be
- modified, but next_out and avail_out are unchanged.)
-*/
-
-ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
- const Bytef *dictionary,
- uInt dictLength));
-/*
- Initializes the decompression dictionary from the given uncompressed byte
- sequence. This function must be called immediately after a call of inflate
- if this call returned Z_NEED_DICT. The dictionary chosen by the compressor
- can be determined from the adler32 value returned by this call of
- inflate. The compressor and decompressor must use exactly the same
- dictionary (see deflateSetDictionary).
-
- inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a
- parameter is invalid (such as NULL dictionary) or the stream state is
- inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the
- expected one (incorrect adler32 value). inflateSetDictionary does not
- perform any decompression: this will be done by subsequent calls of
- inflate().
-*/
-
-ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm));
-/*
- Skips invalid compressed data until a full flush point (see above the
- description of deflate with Z_FULL_FLUSH) can be found, or until all
- available input is skipped. No output is provided.
-
- inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR
- if no more input was provided, Z_DATA_ERROR if no flush point has been found,
- or Z_STREAM_ERROR if the stream structure was inconsistent. In the success
- case, the application may save the current current value of total_in which
- indicates where valid compressed data was found. In the error case, the
- application may repeatedly call inflateSync, providing more input each time,
- until success or end of the input data.
-*/
-
-ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest,
- z_streamp source));
-/*
- Sets the destination stream as a complete copy of the source stream.
-
- This function can be useful when randomly accessing a large stream. The
- first pass through the stream can periodically record the inflate state,
- allowing restarting inflate at those points when randomly accessing the
- stream.
-
- inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
- enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
- (such as zalloc being NULL). msg is left unchanged in both source and
- destination.
-*/
-
-ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm));
-/*
- This function is equivalent to inflateEnd followed by inflateInit,
- but does not free and reallocate all the internal decompression state.
- The stream will keep attributes that may have been set by inflateInit2.
-
- inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
- stream state was inconsistent (such as zalloc or state being NULL).
-*/
-
-/*
-ZEXTERN int ZEXPORT inflateBackInit OF((z_stream FAR *strm, int windowBits,
- unsigned char FAR *window));
-
- Initialize the internal stream state for decompression using inflateBack()
- calls. The fields zalloc, zfree and opaque in strm must be initialized
- before the call. If zalloc and zfree are Z_NULL, then the default library-
- derived memory allocation routines are used. windowBits is the base two
- logarithm of the window size, in the range 8..15. window is a caller
- supplied buffer of that size. Except for special applications where it is
- assured that deflate was used with small window sizes, windowBits must be 15
- and a 32K byte window must be supplied to be able to decompress general
- deflate streams.
-
- See inflateBack() for the usage of these routines.
-
- inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of
- the paramaters are invalid, Z_MEM_ERROR if the internal state could not
- be allocated, or Z_VERSION_ERROR if the version of the library does not
- match the version of the header file.
-*/
-
-typedef unsigned (*in_func) OF((void FAR *, unsigned char FAR * FAR *));
-typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned));
-
-ZEXTERN int ZEXPORT inflateBack OF((z_stream FAR *strm,
- in_func in, void FAR *in_desc,
- out_func out, void FAR *out_desc));
-/*
- inflateBack() does a raw inflate with a single call using a call-back
- interface for input and output. This is more efficient than inflate() for
- file i/o applications in that it avoids copying between the output and the
- sliding window by simply making the window itself the output buffer. This
- function trusts the application to not change the output buffer passed by
- the output function, at least until inflateBack() returns.
-
- inflateBackInit() must be called first to allocate the internal state
- and to initialize the state with the user-provided window buffer.
- inflateBack() may then be used multiple times to inflate a complete, raw
- deflate stream with each call. inflateBackEnd() is then called to free
- the allocated state.
-
- A raw deflate stream is one with no zlib or gzip header or trailer.
- This routine would normally be used in a utility that reads zip or gzip
- files and writes out uncompressed files. The utility would decode the
- header and process the trailer on its own, hence this routine expects
- only the raw deflate stream to decompress. This is different from the
- normal behavior of inflate(), which expects either a zlib or gzip header and
- trailer around the deflate stream.
-
- inflateBack() uses two subroutines supplied by the caller that are then
- called by inflateBack() for input and output. inflateBack() calls those
- routines until it reads a complete deflate stream and writes out all of the
- uncompressed data, or until it encounters an error. The function's
- parameters and return types are defined above in the in_func and out_func
- typedefs. inflateBack() will call in(in_desc, &buf) which should return the
- number of bytes of provided input, and a pointer to that input in buf. If
- there is no input available, in() must return zero--buf is ignored in that
- case--and inflateBack() will return a buffer error. inflateBack() will call
- out(out_desc, buf, len) to write the uncompressed data buf[0..len-1]. out()
- should return zero on success, or non-zero on failure. If out() returns
- non-zero, inflateBack() will return with an error. Neither in() nor out()
- are permitted to change the contents of the window provided to
- inflateBackInit(), which is also the buffer that out() uses to write from.
- The length written by out() will be at most the window size. Any non-zero
- amount of input may be provided by in().
-
- For convenience, inflateBack() can be provided input on the first call by
- setting strm->next_in and strm->avail_in. If that input is exhausted, then
- in() will be called. Therefore strm->next_in must be initialized before
- calling inflateBack(). If strm->next_in is Z_NULL, then in() will be called
- immediately for input. If strm->next_in is not Z_NULL, then strm->avail_in
- must also be initialized, and then if strm->avail_in is not zero, input will
- initially be taken from strm->next_in[0 .. strm->avail_in - 1].
-
- The in_desc and out_desc parameters of inflateBack() is passed as the
- first parameter of in() and out() respectively when they are called. These
- descriptors can be optionally used to pass any information that the caller-
- supplied in() and out() functions need to do their job.
-
- On return, inflateBack() will set strm->next_in and strm->avail_in to
- pass back any unused input that was provided by the last in() call. The
- return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR
- if in() or out() returned an error, Z_DATA_ERROR if there was a format
- error in the deflate stream (in which case strm->msg is set to indicate the
- nature of the error), or Z_STREAM_ERROR if the stream was not properly
- initialized. In the case of Z_BUF_ERROR, an input or output error can be
- distinguished using strm->next_in which will be Z_NULL only if in() returned
- an error. If strm->next is not Z_NULL, then the Z_BUF_ERROR was due to
- out() returning non-zero. (in() will always be called before out(), so
- strm->next_in is assured to be defined if out() returns non-zero.) Note
- that inflateBack() cannot return Z_OK.
-*/
-
-ZEXTERN int ZEXPORT inflateBackEnd OF((z_stream FAR *strm));
-/*
- All memory allocated by inflateBackInit() is freed.
-
- inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream
- state was inconsistent.
-*/
-
-ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void));
-/* Return flags indicating compile-time options.
-
- Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other:
- 1.0: size of uInt
- 3.2: size of uLong
- 5.4: size of voidpf (pointer)
- 7.6: size of z_off_t
-
- Compiler, assembler, and debug options:
- 8: DEBUG
- 9: ASMV or ASMINF -- use ASM code
- 10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention
- 11: 0 (reserved)
-
- One-time table building (smaller code, but not thread-safe if true):
- 12: BUILDFIXED -- build static block decoding tables when needed
- 13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed
- 14,15: 0 (reserved)
-
- Library content (indicates missing functionality):
- 16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking
- deflate code when not needed)
- 17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect
- and decode gzip streams (to avoid linking crc code)
- 18-19: 0 (reserved)
-
- Operation variations (changes in library functionality):
- 20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate
- 21: FASTEST -- deflate algorithm with only one, lowest compression level
- 22,23: 0 (reserved)
-
- The sprintf variant used by gzprintf (zero is best):
- 24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format
- 25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure!
- 26: 0 = returns value, 1 = void -- 1 means inferred string length returned
-
- Remainder:
- 27-31: 0 (reserved)
- */
-
-
- /* utility functions */
-
-/*
- The following utility functions are implemented on top of the
- basic stream-oriented functions. To simplify the interface, some
- default options are assumed (compression level and memory usage,
- standard memory allocation functions). The source code of these
- utility functions can easily be modified if you need special options.
-*/
-
-ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen,
- const Bytef *source, uLong sourceLen));
-/*
- Compresses the source buffer into the destination buffer. sourceLen is
- the byte length of the source buffer. Upon entry, destLen is the total
- size of the destination buffer, which must be at least the value returned
- by compressBound(sourceLen). Upon exit, destLen is the actual size of the
- compressed buffer.
- This function can be used to compress a whole file at once if the
- input file is mmap'ed.
- compress returns Z_OK if success, Z_MEM_ERROR if there was not
- enough memory, Z_BUF_ERROR if there was not enough room in the output
- buffer.
-*/
-
-ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen,
- const Bytef *source, uLong sourceLen,
- int level));
-/*
- Compresses the source buffer into the destination buffer. The level
- parameter has the same meaning as in deflateInit. sourceLen is the byte
- length of the source buffer. Upon entry, destLen is the total size of the
- destination buffer, which must be at least the value returned by
- compressBound(sourceLen). Upon exit, destLen is the actual size of the
- compressed buffer.
-
- compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
- memory, Z_BUF_ERROR if there was not enough room in the output buffer,
- Z_STREAM_ERROR if the level parameter is invalid.
-*/
-
-ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen));
-/*
- compressBound() returns an upper bound on the compressed size after
- compress() or compress2() on sourceLen bytes. It would be used before
- a compress() or compress2() call to allocate the destination buffer.
-*/
-
-ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen,
- const Bytef *source, uLong sourceLen));
-/*
- Decompresses the source buffer into the destination buffer. sourceLen is
- the byte length of the source buffer. Upon entry, destLen is the total
- size of the destination buffer, which must be large enough to hold the
- entire uncompressed data. (The size of the uncompressed data must have
- been saved previously by the compressor and transmitted to the decompressor
- by some mechanism outside the scope of this compression library.)
- Upon exit, destLen is the actual size of the compressed buffer.
- This function can be used to decompress a whole file at once if the
- input file is mmap'ed.
-
- uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
- enough memory, Z_BUF_ERROR if there was not enough room in the output
- buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete.
-*/
-
-
-typedef voidp gzFile;
-
-ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));
-/*
- Opens a gzip (.gz) file for reading or writing. The mode parameter
- is as in fopen ("rb" or "wb") but can also include a compression level
- ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for
- Huffman only compression as in "wb1h", or 'R' for run-length encoding
- as in "wb1R". (See the description of deflateInit2 for more information
- about the strategy parameter.)
-
- gzopen can be used to read a file which is not in gzip format; in this
- case gzread will directly read from the file without decompression.
-
- gzopen returns NULL if the file could not be opened or if there was
- insufficient memory to allocate the (de)compression state; errno
- can be checked to distinguish the two cases (if errno is zero, the
- zlib error is Z_MEM_ERROR). */
-
-ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode));
-/*
- gzdopen() associates a gzFile with the file descriptor fd. File
- descriptors are obtained from calls like open, dup, creat, pipe or
- fileno (in the file has been previously opened with fopen).
- The mode parameter is as in gzopen.
- The next call of gzclose on the returned gzFile will also close the
- file descriptor fd, just like fclose(fdopen(fd), mode) closes the file
- descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode).
- gzdopen returns NULL if there was insufficient memory to allocate
- the (de)compression state.
-*/
-
-ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));
-/*
- Dynamically update the compression level or strategy. See the description
- of deflateInit2 for the meaning of these parameters.
- gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not
- opened for writing.
-*/
-
-ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));
-/*
- Reads the given number of uncompressed bytes from the compressed file.
- If the input file was not in gzip format, gzread copies the given number
- of bytes into the buffer.
- gzread returns the number of uncompressed bytes actually read (0 for
- end of file, -1 for error). */
-
-ZEXTERN int ZEXPORT gzwrite OF((gzFile file,
- voidpc buf, unsigned len));
-/*
- Writes the given number of uncompressed bytes into the compressed file.
- gzwrite returns the number of uncompressed bytes actually written
- (0 in case of error).
-*/
-
-ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...));
-/*
- Converts, formats, and writes the args to the compressed file under
- control of the format string, as in fprintf. gzprintf returns the number of
- uncompressed bytes actually written (0 in case of error). The number of
- uncompressed bytes written is limited to 4095. The caller should assure that
- this limit is not exceeded. If it is exceeded, then gzprintf() will return
- return an error (0) with nothing written. In this case, there may also be a
- buffer overflow with unpredictable consequences, which is possible only if
- zlib was compiled with the insecure functions sprintf() or vsprintf()
- because the secure snprintf() or vsnprintf() functions were not available.
-*/
-
-ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s));
-/*
- Writes the given null-terminated string to the compressed file, excluding
- the terminating null character.
- gzputs returns the number of characters written, or -1 in case of error.
-*/
-
-ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len));
-/*
- Reads bytes from the compressed file until len-1 characters are read, or
- a newline character is read and transferred to buf, or an end-of-file
- condition is encountered. The string is then terminated with a null
- character.
- gzgets returns buf, or Z_NULL in case of error.
-*/
-
-ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c));
-/*
- Writes c, converted to an unsigned char, into the compressed file.
- gzputc returns the value that was written, or -1 in case of error.
-*/
-
-ZEXTERN int ZEXPORT gzgetc OF((gzFile file));
-/*
- Reads one byte from the compressed file. gzgetc returns this byte
- or -1 in case of end of file or error.
-*/
-
-ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file));
-/*
- Push one character back onto the stream to be read again later.
- Only one character of push-back is allowed. gzungetc() returns the
- character pushed, or -1 on failure. gzungetc() will fail if a
- character has been pushed but not read yet, or if c is -1. The pushed
- character will be discarded if the stream is repositioned with gzseek()
- or gzrewind().
-*/
-
-ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush));
-/*
- Flushes all pending output into the compressed file. The parameter
- flush is as in the deflate() function. The return value is the zlib
- error number (see function gzerror below). gzflush returns Z_OK if
- the flush parameter is Z_FINISH and all output could be flushed.
- gzflush should be called only when strictly necessary because it can
- degrade compression.
-*/
-
-ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file,
- z_off_t offset, int whence));
-/*
- Sets the starting position for the next gzread or gzwrite on the
- given compressed file. The offset represents a number of bytes in the
- uncompressed data stream. The whence parameter is defined as in lseek(2);
- the value SEEK_END is not supported.
- If the file is opened for reading, this function is emulated but can be
- extremely slow. If the file is opened for writing, only forward seeks are
- supported; gzseek then compresses a sequence of zeroes up to the new
- starting position.
-
- gzseek returns the resulting offset location as measured in bytes from
- the beginning of the uncompressed stream, or -1 in case of error, in
- particular if the file is opened for writing and the new starting position
- would be before the current position.
-*/
-
-ZEXTERN int ZEXPORT gzrewind OF((gzFile file));
-/*
- Rewinds the given file. This function is supported only for reading.
-
- gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)
-*/
-
-ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file));
-/*
- Returns the starting position for the next gzread or gzwrite on the
- given compressed file. This position represents a number of bytes in the
- uncompressed data stream.
-
- gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR)
-*/
-
-ZEXTERN int ZEXPORT gzeof OF((gzFile file));
-/*
- Returns 1 when EOF has previously been detected reading the given
- input stream, otherwise zero.
-*/
-
-ZEXTERN int ZEXPORT gzclose OF((gzFile file));
-/*
- Flushes all pending output if necessary, closes the compressed file
- and deallocates all the (de)compression state. The return value is the zlib
- error number (see function gzerror below).
-*/
-
-ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum));
-/*
- Returns the error message for the last error which occurred on the
- given compressed file. errnum is set to zlib error number. If an
- error occurred in the file system and not in the compression library,
- errnum is set to Z_ERRNO and the application may consult errno
- to get the exact error code.
-*/
-
-ZEXTERN void ZEXPORT gzclearerr OF((gzFile file));
-/*
- Clears the error and end-of-file flags for file. This is analogous to the
- clearerr() function in stdio. This is useful for continuing to read a gzip
- file that is being written concurrently.
-*/
-
- /* checksum functions */
-
-/*
- These functions are not related to compression but are exported
- anyway because they might be useful in applications using the
- compression library.
-*/
-
-ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
-
-/*
- Update a running Adler-32 checksum with the bytes buf[0..len-1] and
- return the updated checksum. If buf is NULL, this function returns
- the required initial value for the checksum.
- An Adler-32 checksum is almost as reliable as a CRC32 but can be computed
- much faster. Usage example:
-
- uLong adler = adler32(0L, Z_NULL, 0);
-
- while (read_buffer(buffer, length) != EOF) {
- adler = adler32(adler, buffer, length);
- }
- if (adler != original_adler) error();
-*/
-
-ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len));
-/*
- Update a running crc with the bytes buf[0..len-1] and return the updated
- crc. If buf is NULL, this function returns the required initial value
- for the crc. Pre- and post-conditioning (one's complement) is performed
- within this function so it shouldn't be done by the application.
- Usage example:
-
- uLong crc = crc32(0L, Z_NULL, 0);
-
- while (read_buffer(buffer, length) != EOF) {
- crc = crc32(crc, buffer, length);
- }
- if (crc != original_crc) error();
-*/
-
-
- /* various hacks, don't look :) */
-
-/* deflateInit and inflateInit are macros to allow checking the zlib version
- * and the compiler's view of z_stream:
- */
-ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level,
- const char *version, int stream_size));
-ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm,
- const char *version, int stream_size));
-ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method,
- int windowBits, int memLevel,
- int strategy, const char *version,
- int stream_size));
-ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits,
- const char *version, int stream_size));
-ZEXTERN int ZEXPORT inflateBackInit_ OF((z_stream FAR *strm, int windowBits,
- unsigned char FAR *window,
- const char *version,
- int stream_size));
-#define deflateInit(strm, level) \
- deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream))
-#define inflateInit(strm) \
- inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream))
-#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \
- deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\
- (strategy), ZLIB_VERSION, sizeof(z_stream))
-#define inflateInit2(strm, windowBits) \
- inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream))
-#define inflateBackInit(strm, windowBits, window) \
- inflateBackInit_((strm), (windowBits), (window), \
- ZLIB_VERSION, sizeof(z_stream))
-
-
-#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL)
- struct internal_state {int dummy;}; /* hack for buggy compilers */
-#endif
-
-ZEXTERN const char * ZEXPORT zError OF((int err));
-ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z));
-ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void));
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* ZLIB_H */
diff --git a/klibc/klibc/zlib/zutil.c b/klibc/klibc/zlib/zutil.c
deleted file mode 100644
index 253a1cc7e1..0000000000
--- a/klibc/klibc/zlib/zutil.c
+++ /dev/null
@@ -1,319 +0,0 @@
-/* zutil.c -- target dependent utility functions for the compression library
- * Copyright (C) 1995-2003 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* @(#) $Id: zutil.c,v 1.1 2005/02/27 23:15:39 hpa Exp $ */
-
-#include "zutil.h"
-
-#ifndef NO_DUMMY_DECL
-struct internal_state {int dummy;}; /* for buggy compilers */
-#endif
-
-#ifndef STDC
-extern void exit OF((int));
-#endif
-
-const char * const z_errmsg[10] = {
-"need dictionary", /* Z_NEED_DICT 2 */
-"stream end", /* Z_STREAM_END 1 */
-"", /* Z_OK 0 */
-"file error", /* Z_ERRNO (-1) */
-"stream error", /* Z_STREAM_ERROR (-2) */
-"data error", /* Z_DATA_ERROR (-3) */
-"insufficient memory", /* Z_MEM_ERROR (-4) */
-"buffer error", /* Z_BUF_ERROR (-5) */
-"incompatible version",/* Z_VERSION_ERROR (-6) */
-""};
-
-
-const char * ZEXPORT zlibVersion()
-{
- return ZLIB_VERSION;
-}
-
-uLong ZEXPORT zlibCompileFlags()
-{
- uLong flags;
-
- flags = 0;
- switch (sizeof(uInt)) {
- case 2: break;
- case 4: flags += 1; break;
- case 8: flags += 2; break;
- default: flags += 3;
- }
- switch (sizeof(uLong)) {
- case 2: break;
- case 4: flags += 1 << 2; break;
- case 8: flags += 2 << 2; break;
- default: flags += 3 << 2;
- }
- switch (sizeof(voidpf)) {
- case 2: break;
- case 4: flags += 1 << 4; break;
- case 8: flags += 2 << 4; break;
- default: flags += 3 << 4;
- }
- switch (sizeof(z_off_t)) {
- case 2: break;
- case 4: flags += 1 << 6; break;
- case 8: flags += 2 << 6; break;
- default: flags += 3 << 6;
- }
-#ifdef DEBUG
- flags += 1 << 8;
-#endif
-#if defined(ASMV) || defined(ASMINF)
- flags += 1 << 9;
-#endif
-#ifdef ZLIB_WINAPI
- flags += 1 << 10;
-#endif
-#ifdef BUILDFIXED
- flags += 1 << 12;
-#endif
-#ifdef DYNAMIC_CRC_TABLE
- flags += 1 << 13;
-#endif
-#ifdef NO_GZCOMPRESS
- flags += 1 << 16;
-#endif
-#ifdef NO_GZIP
- flags += 1 << 17;
-#endif
-#ifdef PKZIP_BUG_WORKAROUND
- flags += 1 << 20;
-#endif
-#ifdef FASTEST
- flags += 1 << 21;
-#endif
-#ifdef STDC
-# ifdef NO_vsnprintf
- flags += 1 << 25;
-# ifdef HAS_vsprintf_void
- flags += 1 << 26;
-# endif
-# else
-# ifdef HAS_vsnprintf_void
- flags += 1 << 26;
-# endif
-# endif
-#else
- flags += 1 << 24;
-# ifdef NO_snprintf
- flags += 1 << 25;
-# ifdef HAS_sprintf_void
- flags += 1 << 26;
-# endif
-# else
-# ifdef HAS_snprintf_void
- flags += 1 << 26;
-# endif
-# endif
-#endif
- return flags;
-}
-
-#ifdef DEBUG
-
-# ifndef verbose
-# define verbose 0
-# endif
-int z_verbose = verbose;
-
-void z_error (m)
- char *m;
-{
- fprintf(stderr, "%s\n", m);
- exit(1);
-}
-#endif
-
-/* exported to allow conversion of error code to string for compress() and
- * uncompress()
- */
-const char * ZEXPORT zError(err)
- int err;
-{
- return ERR_MSG(err);
-}
-
-#if defined(_WIN32_WCE)
- /* does not exist on WCE */
- int errno = 0;
-#endif
-
-#ifndef HAVE_MEMCPY
-
-void zmemcpy(dest, source, len)
- Bytef* dest;
- const Bytef* source;
- uInt len;
-{
- if (len == 0) return;
- do {
- *dest++ = *source++; /* ??? to be unrolled */
- } while (--len != 0);
-}
-
-int zmemcmp(s1, s2, len)
- const Bytef* s1;
- const Bytef* s2;
- uInt len;
-{
- uInt j;
-
- for (j = 0; j < len; j++) {
- if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1;
- }
- return 0;
-}
-
-void zmemzero(dest, len)
- Bytef* dest;
- uInt len;
-{
- if (len == 0) return;
- do {
- *dest++ = 0; /* ??? to be unrolled */
- } while (--len != 0);
-}
-#endif
-
-
-#ifdef SYS16BIT
-
-#ifdef __TURBOC__
-/* Turbo C in 16-bit mode */
-
-# define MY_ZCALLOC
-
-/* Turbo C malloc() does not allow dynamic allocation of 64K bytes
- * and farmalloc(64K) returns a pointer with an offset of 8, so we
- * must fix the pointer. Warning: the pointer must be put back to its
- * original form in order to free it, use zcfree().
- */
-
-#define MAX_PTR 10
-/* 10*64K = 640K */
-
-local int next_ptr = 0;
-
-typedef struct ptr_table_s {
- voidpf org_ptr;
- voidpf new_ptr;
-} ptr_table;
-
-local ptr_table table[MAX_PTR];
-/* This table is used to remember the original form of pointers
- * to large buffers (64K). Such pointers are normalized with a zero offset.
- * Since MSDOS is not a preemptive multitasking OS, this table is not
- * protected from concurrent access. This hack doesn't work anyway on
- * a protected system like OS/2. Use Microsoft C instead.
- */
-
-voidpf zcalloc (voidpf opaque, unsigned items, unsigned size)
-{
- voidpf buf = opaque; /* just to make some compilers happy */
- ulg bsize = (ulg)items*size;
-
- /* If we allocate less than 65520 bytes, we assume that farmalloc
- * will return a usable pointer which doesn't have to be normalized.
- */
- if (bsize < 65520L) {
- buf = farmalloc(bsize);
- if (*(ush*)&buf != 0) return buf;
- } else {
- buf = farmalloc(bsize + 16L);
- }
- if (buf == NULL || next_ptr >= MAX_PTR) return NULL;
- table[next_ptr].org_ptr = buf;
-
- /* Normalize the pointer to seg:0 */
- *((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4;
- *(ush*)&buf = 0;
- table[next_ptr++].new_ptr = buf;
- return buf;
-}
-
-void zcfree (voidpf opaque, voidpf ptr)
-{
- int n;
- if (*(ush*)&ptr != 0) { /* object < 64K */
- farfree(ptr);
- return;
- }
- /* Find the original pointer */
- for (n = 0; n < next_ptr; n++) {
- if (ptr != table[n].new_ptr) continue;
-
- farfree(table[n].org_ptr);
- while (++n < next_ptr) {
- table[n-1] = table[n];
- }
- next_ptr--;
- return;
- }
- ptr = opaque; /* just to make some compilers happy */
- Assert(0, "zcfree: ptr not found");
-}
-
-#endif /* __TURBOC__ */
-
-
-#ifdef M_I86
-/* Microsoft C in 16-bit mode */
-
-# define MY_ZCALLOC
-
-#if (!defined(_MSC_VER) || (_MSC_VER <= 600))
-# define _halloc halloc
-# define _hfree hfree
-#endif
-
-voidpf zcalloc (voidpf opaque, unsigned items, unsigned size)
-{
- if (opaque) opaque = 0; /* to make compiler happy */
- return _halloc((long)items, size);
-}
-
-void zcfree (voidpf opaque, voidpf ptr)
-{
- if (opaque) opaque = 0; /* to make compiler happy */
- _hfree(ptr);
-}
-
-#endif /* M_I86 */
-
-#endif /* SYS16BIT */
-
-
-#ifndef MY_ZCALLOC /* Any system without a special alloc function */
-
-#ifndef STDC
-extern voidp malloc OF((uInt size));
-extern voidp calloc OF((uInt items, uInt size));
-extern void free OF((voidpf ptr));
-#endif
-
-voidpf zcalloc (opaque, items, size)
- voidpf opaque;
- unsigned items;
- unsigned size;
-{
- if (opaque) items += size - size; /* make compiler happy */
- return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) :
- (voidpf)calloc(items, size);
-}
-
-void zcfree (opaque, ptr)
- voidpf opaque;
- voidpf ptr;
-{
- free(ptr);
- if (opaque) return; /* make compiler happy */
-}
-
-#endif /* MY_ZCALLOC */
diff --git a/klibc/klibc/zlib/zutil.h b/klibc/klibc/zlib/zutil.h
deleted file mode 100644
index 129452806b..0000000000
--- a/klibc/klibc/zlib/zutil.h
+++ /dev/null
@@ -1,258 +0,0 @@
-/* zutil.h -- internal interface and configuration of the compression library
- * Copyright (C) 1995-2003 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* WARNING: this file should *not* be used by applications. It is
- part of the implementation of the compression library and is
- subject to change. Applications should only use zlib.h.
- */
-
-/* @(#) $Id: zutil.h,v 1.1 2005/02/27 23:15:39 hpa Exp $ */
-
-#ifndef ZUTIL_H
-#define ZUTIL_H
-
-#define ZLIB_INTERNAL
-#include "zlib.h"
-
-#ifdef STDC
-# include <stddef.h>
-# include <string.h>
-# include <stdlib.h>
-#endif
-#ifdef NO_ERRNO_H
- extern int errno;
-#else
-# include <errno.h>
-#endif
-
-#ifndef local
-# define local static
-#endif
-/* compile with -Dlocal if your debugger can't find static symbols */
-
-typedef unsigned char uch;
-typedef uch FAR uchf;
-typedef unsigned short ush;
-typedef ush FAR ushf;
-typedef unsigned long ulg;
-
-extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
-/* (size given to avoid silly warnings with Visual C++) */
-
-#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
-
-#define ERR_RETURN(strm,err) \
- return (strm->msg = (char*)ERR_MSG(err), (err))
-/* To be used only when the state is known to be valid */
-
- /* common constants */
-
-#ifndef DEF_WBITS
-# define DEF_WBITS MAX_WBITS
-#endif
-/* default windowBits for decompression. MAX_WBITS is for compression only */
-
-#if MAX_MEM_LEVEL >= 8
-# define DEF_MEM_LEVEL 8
-#else
-# define DEF_MEM_LEVEL MAX_MEM_LEVEL
-#endif
-/* default memLevel */
-
-#define STORED_BLOCK 0
-#define STATIC_TREES 1
-#define DYN_TREES 2
-/* The three kinds of block type */
-
-#define MIN_MATCH 3
-#define MAX_MATCH 258
-/* The minimum and maximum match lengths */
-
-#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
-
- /* target dependencies */
-
-#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32))
-# define OS_CODE 0x00
-# if defined(__TURBOC__) || defined(__BORLANDC__)
-# if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
- /* Allow compilation with ANSI keywords only enabled */
- void _Cdecl farfree( void *block );
- void *_Cdecl farmalloc( unsigned long nbytes );
-# else
-# include <alloc.h>
-# endif
-# else /* MSC or DJGPP */
-# include <malloc.h>
-# endif
-#endif
-
-#ifdef AMIGA
-# define OS_CODE 0x01
-#endif
-
-#if defined(VAXC) || defined(VMS)
-# define OS_CODE 0x02
-# define F_OPEN(name, mode) \
- fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
-#endif
-
-#if defined(ATARI) || defined(atarist)
-# define OS_CODE 0x05
-#endif
-
-#ifdef OS2
-# define OS_CODE 0x06
-#endif
-
-#if defined(MACOS) || defined(TARGET_OS_MAC)
-# define OS_CODE 0x07
-# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
-# include <unix.h> /* for fdopen */
-# else
-# ifndef fdopen
-# define fdopen(fd,mode) NULL /* No fdopen() */
-# endif
-# endif
-#endif
-
-#ifdef TOPS20
-# define OS_CODE 0x0a
-#endif
-
-#ifdef WIN32
-# ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */
-# define OS_CODE 0x0b
-# endif
-#endif
-
-#ifdef __50SERIES /* Prime/PRIMOS */
-# define OS_CODE 0x0f
-#endif
-
-#if defined(_BEOS_) || defined(RISCOS)
-# define fdopen(fd,mode) NULL /* No fdopen() */
-#endif
-
-#if (defined(_MSC_VER) && (_MSC_VER > 600))
-# if defined(_WIN32_WCE)
-# define fdopen(fd,mode) NULL /* No fdopen() */
-# ifndef _PTRDIFF_T_DEFINED
- typedef int ptrdiff_t;
-# define _PTRDIFF_T_DEFINED
-# endif
-# else
-# define fdopen(fd,type) _fdopen(fd,type)
-# endif
-#endif
-
- /* common defaults */
-
-#ifndef OS_CODE
-# define OS_CODE 0x03 /* assume Unix */
-#endif
-
-#ifndef F_OPEN
-# define F_OPEN(name, mode) fopen((name), (mode))
-#endif
-
- /* functions */
-
-#if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550)
-# ifndef HAVE_VSNPRINTF
-# define HAVE_VSNPRINTF
-# endif
-#endif
-#if defined(__CYGWIN__)
-# ifndef HAVE_VSNPRINTF
-# define HAVE_VSNPRINTF
-# endif
-#endif
-#ifndef HAVE_VSNPRINTF
-# ifdef MSDOS
- /* vsnprintf may exist on some MS-DOS compilers (DJGPP?),
- but for now we just assume it doesn't. */
-# define NO_vsnprintf
-# endif
-# ifdef __TURBOC__
-# define NO_vsnprintf
-# endif
-# ifdef WIN32
- /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */
-# if !defined(vsnprintf) && !defined(NO_vsnprintf)
-# define vsnprintf _vsnprintf
-# endif
-# endif
-# ifdef __SASC
-# define NO_vsnprintf
-# endif
-#endif
-
-#ifdef HAVE_STRERROR
- extern char *strerror OF((int));
-# define zstrerror(errnum) strerror(errnum)
-#else
-# define zstrerror(errnum) ""
-#endif
-
-#if defined(pyr)
-# define NO_MEMCPY
-#endif
-#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)
- /* Use our own functions for small and medium model with MSC <= 5.0.
- * You may have to use the same strategy for Borland C (untested).
- * The __SC__ check is for Symantec.
- */
-# define NO_MEMCPY
-#endif
-#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
-# define HAVE_MEMCPY
-#endif
-#ifdef HAVE_MEMCPY
-# ifdef SMALL_MEDIUM /* MSDOS small or medium model */
-# define zmemcpy _fmemcpy
-# define zmemcmp _fmemcmp
-# define zmemzero(dest, len) _fmemset(dest, 0, len)
-# else
-# define zmemcpy memcpy
-# define zmemcmp memcmp
-# define zmemzero(dest, len) memset(dest, 0, len)
-# endif
-#else
- extern void zmemcpy OF((Bytef* dest, const Bytef* source, uInt len));
- extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len));
- extern void zmemzero OF((Bytef* dest, uInt len));
-#endif
-
-/* Diagnostic functions */
-#ifdef DEBUG
-# include <stdio.h>
- extern int z_verbose;
- extern void z_error OF((char *m));
-# define Assert(cond,msg) {if(!(cond)) z_error(msg);}
-# define Trace(x) {if (z_verbose>=0) fprintf x ;}
-# define Tracev(x) {if (z_verbose>0) fprintf x ;}
-# define Tracevv(x) {if (z_verbose>1) fprintf x ;}
-# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;}
-# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;}
-#else
-# define Assert(cond,msg)
-# define Trace(x)
-# define Tracev(x)
-# define Tracevv(x)
-# define Tracec(c,x)
-# define Tracecv(c,x)
-#endif
-
-
-voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size));
-void zcfree OF((voidpf opaque, voidpf ptr));
-
-#define ZALLOC(strm, items, size) \
- (*((strm)->zalloc))((strm)->opaque, (items), (size))
-#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
-#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
-
-#endif /* ZUTIL_H */
diff --git a/klibc/makeklcc.pl b/klibc/makeklcc.pl
deleted file mode 100755
index 74045955fd..0000000000
--- a/klibc/makeklcc.pl
+++ /dev/null
@@ -1,55 +0,0 @@
-#!/usr/bin/perl
-#
-# Combine klibc.config, klcc.in to produce a klcc script
-#
-# Usage: makeklcc klcc.in klibc.config perlpath
-#
-
-use File::Spec;
-
-($klccin, $klibcconf, $perlpath) = @ARGV;
-
-sub pathsearch($) {
- my($file) = @_;
- my(@path);
- my($p,$pp);
-
- if ( $file =~ /\// ) {
- return File::Spec->rel2abs($file);
- }
-
- foreach $p ( split(/\:/, $ENV{'PATH'}) ) {
- $pp = File::Spec->rel2abs(File::Spec->catpath(undef, $p, $file));
- return $pp if ( -x $pp );
- }
-
- return undef;
-}
-
-print "#!${perlpath}\n";
-
-open(KLIBCCONF, '<', $klibcconf) or die "$0: cannot open $klibcconf: $!\n";
-while ( defined($l = <KLIBCCONF>) ) {
- chomp $l;
- if ( $l =~ /^([^=]+)\=(.*)$/ ) {
- $n = $1; $s = $2;
-
- if ( $n eq 'CC' || $n eq 'LD' || $n eq 'STRIP' ) {
- $s1 = pathsearch($s);
- die "$0: Cannot find $n: $s\n" unless ( defined($s1) );
- $s = $s1;
- }
-
- print "\$$n = \"\Q$s\E\";\n";
- print "\@$n = qw($s);\n";
- print "\$conf{\'\L$n\E\'} = \\\$$n;\n";
- }
-}
-close(KLIBCCONF);
-
-open(KLCCIN, '<', $klccin) or die "$0: cannot open $klccin: $!\n";
-while ( defined($l = <KLCCIN>) ) {
- print $l;
-}
-close(KLCCIN);
-
diff --git a/klibc/version b/klibc/version
deleted file mode 100644
index 45a1b3f445..0000000000
--- a/klibc/version
+++ /dev/null
@@ -1 +0,0 @@
-1.1.2
diff --git a/test/simple-build-check.sh b/test/simple-build-check.sh
index daf0b75269..d1c28749fb 100755
--- a/test/simple-build-check.sh
+++ b/test/simple-build-check.sh
@@ -12,9 +12,6 @@ EXTRAS="\
extras/run_directory \
extras/firmware"
-[ -z "$KERNEL_DIR" ] && KERNEL_DIR=/lib/modules/`uname -r`/build
-echo KERNEL_DIR: "$KERNEL_DIR"
-
# with debug
make clean EXTRAS="$EXTRAS" >/dev/null
make all -j4 $MAKEOPTS DEBUG=true EXTRAS="$EXTRAS" || exit
@@ -25,10 +22,14 @@ make clean EXTRAS="$EXTRAS" >/dev/null
make all $MAKEOPTS USE_LOG=false EXTRAS="$EXTRAS" || exit
echo -e "\n\n"
-# klibc and debug
-make clean EXTRAS="$EXTRAS" >/dev/null
-make all -j4 $MAKEOPTS USE_KLIBC=true DEBUG=true EXTRAS="$EXTRAS" KERNEL_DIR="$KERNEL_DIR" || exit
-echo -e "\n\n"
+# klibc build
+[ -z "$KLCC" ] && KLCC=/usr/bin/klcc
+if [ -e "$KLCC" ]; then
+ echo KLCC: "$KLCC"
+ make clean EXTRAS="$EXTRAS" >/dev/null
+ make all -j4 $MAKEOPTS USE_KLIBC=true DEBUG=true EXTRAS="$EXTRAS" KLCC="$KLCC" || exit
+ echo -e "\n\n"
+fi
# install in temporary dir and show it
TEMPDIR="`pwd`/.tmp"