summaryrefslogtreecommitdiffstats
path: root/README-autoirpm-icons
Commit message (Expand)AuthorAgeFilesLines
* no_commentPascal Rigaux1999-12-171-0/+3
ve' href='/software/drakx/commit/mdk-stage1?h=17.56&id=4cd6a4a5d7e49d54d53dcf4a6f3393d50bd88e8b'>commitdiffstats
path: root/mdk-stage1
diff options
context:
space:
mode:
authorGwenolé Beauchesne <gbeauchesne@mandriva.org>2003-06-04 18:44:09 +0000
committerGwenolé Beauchesne <gbeauchesne@mandriva.org>2003-06-04 18:44:09 +0000
commit4cd6a4a5d7e49d54d53dcf4a6f3393d50bd88e8b (patch)
treeacd4001a266a8713495af7f1b2102b61e67113b0 /mdk-stage1
parent71b111ec6c4671667a19c6fbe0023d33422535d7 (diff)
downloaddrakx-4cd6a4a5d7e49d54d53dcf4a6f3393d50bd88e8b.tar
drakx-4cd6a4a5d7e49d54d53dcf4a6f3393d50bd88e8b.tar.gz
drakx-4cd6a4a5d7e49d54d53dcf4a6f3393d50bd88e8b.tar.bz2
drakx-4cd6a4a5d7e49d54d53dcf4a6f3393d50bd88e8b.tar.xz
drakx-4cd6a4a5d7e49d54d53dcf4a6f3393d50bd88e8b.zip
Import dietlibc 0.22 + other fixes for AMD64
Diffstat (limited to 'mdk-stage1')
-rw-r--r--mdk-stage1/dietlibc/alpha/__alarm.c13
-rw-r--r--mdk-stage1/dietlibc/alpha/__testandset.S11
-rw-r--r--mdk-stage1/dietlibc/alpha/errlist.S288
-rw-r--r--mdk-stage1/dietlibc/alpha/lseek64.S5
-rw-r--r--mdk-stage1/dietlibc/alpha/n_sigprocmask.S3
-rw-r--r--mdk-stage1/dietlibc/alpha/sigaction.c7
-rw-r--r--mdk-stage1/dietlibc/alpha/socketpair.S3
-rw-r--r--mdk-stage1/dietlibc/alpha/syscalls.h371
-rw-r--r--mdk-stage1/dietlibc/i386/PIC.h82
-rw-r--r--mdk-stage1/dietlibc/i386/__half.S10
-rw-r--r--mdk-stage1/dietlibc/i386/__ten.S9
-rw-r--r--mdk-stage1/dietlibc/i386/accept.S4
-rw-r--r--mdk-stage1/dietlibc/i386/acos.S30
-rw-r--r--mdk-stage1/dietlibc/i386/acosh.S18
-rw-r--r--mdk-stage1/dietlibc/i386/asin.S29
-rw-r--r--mdk-stage1/dietlibc/i386/asinh.S18
-rw-r--r--mdk-stage1/dietlibc/i386/atan.S27
-rw-r--r--mdk-stage1/dietlibc/i386/atan2.S12
-rw-r--r--mdk-stage1/dietlibc/i386/atanh.S19
-rw-r--r--mdk-stage1/dietlibc/i386/atol.S55
-rw-r--r--mdk-stage1/dietlibc/i386/atoll.S64
-rw-r--r--mdk-stage1/dietlibc/i386/bind.S4
-rw-r--r--mdk-stage1/dietlibc/i386/cbrt.S46
-rw-r--r--mdk-stage1/dietlibc/i386/ceil.S44
-rw-r--r--mdk-stage1/dietlibc/i386/connect.S4
-rw-r--r--mdk-stage1/dietlibc/i386/copysign.S18
-rw-r--r--mdk-stage1/dietlibc/i386/cos.S35
-rw-r--r--mdk-stage1/dietlibc/i386/cosh.S29
-rw-r--r--mdk-stage1/dietlibc/i386/dyn_syscalls.S282
-rw-r--r--mdk-stage1/dietlibc/i386/exp.S35
-rw-r--r--mdk-stage1/dietlibc/i386/exp10.S27
-rw-r--r--mdk-stage1/dietlibc/i386/exp2.S18
-rw-r--r--mdk-stage1/dietlibc/i386/expm1.S23
-rw-r--r--mdk-stage1/dietlibc/i386/fabs.S11
-rw-r--r--mdk-stage1/dietlibc/i386/floor.S26
-rw-r--r--mdk-stage1/dietlibc/i386/fmod.S37
-rw-r--r--mdk-stage1/dietlibc/i386/getenv.S48
-rw-r--r--mdk-stage1/dietlibc/i386/getpeername.S4
-rw-r--r--mdk-stage1/dietlibc/i386/getsockname.S4
-rw-r--r--mdk-stage1/dietlibc/i386/getsockopt.S4
-rw-r--r--mdk-stage1/dietlibc/i386/htonl.S13
-rw-r--r--mdk-stage1/dietlibc/i386/htons.S11
-rw-r--r--mdk-stage1/dietlibc/i386/hypot.S15
-rw-r--r--mdk-stage1/dietlibc/i386/ilogb.S23
-rw-r--r--mdk-stage1/dietlibc/i386/ipow.S27
-rw-r--r--mdk-stage1/dietlibc/i386/isleap.S28
-rw-r--r--mdk-stage1/dietlibc/i386/ldexp.S28
-rw-r--r--mdk-stage1/dietlibc/i386/libm2.S643
-rw-r--r--mdk-stage1/dietlibc/i386/listen.S4
-rw-r--r--mdk-stage1/dietlibc/i386/log.S26
-rw-r--r--mdk-stage1/dietlibc/i386/log10.S11
-rw-r--r--mdk-stage1/dietlibc/i386/log1p.S12
-rw-r--r--mdk-stage1/dietlibc/i386/log2.S11
-rw-r--r--mdk-stage1/dietlibc/i386/ltostr.S62
-rw-r--r--mdk-stage1/dietlibc/i386/mcount.S44
-rw-r--r--mdk-stage1/dietlibc/i386/md5asm.S300
-rw-r--r--mdk-stage1/dietlibc/i386/memccpy.S39
-rw-r--r--mdk-stage1/dietlibc/i386/memchr.S24
-rw-r--r--mdk-stage1/dietlibc/i386/memcmp.S26
-rw-r--r--mdk-stage1/dietlibc/i386/memcpy.S16
-rw-r--r--mdk-stage1/dietlibc/i386/memset.S15
-rw-r--r--mdk-stage1/dietlibc/i386/mmap.S14
-rw-r--r--mdk-stage1/dietlibc/i386/mmap64.S63
-rw-r--r--mdk-stage1/dietlibc/i386/poly.S24
-rw-r--r--mdk-stage1/dietlibc/i386/pow.S67
-rw-r--r--mdk-stage1/dietlibc/i386/recv.S4
-rw-r--r--mdk-stage1/dietlibc/i386/recvfrom.S4
-rw-r--r--mdk-stage1/dietlibc/i386/recvmsg.S4
-rw-r--r--mdk-stage1/dietlibc/i386/rint.S23
-rw-r--r--mdk-stage1/dietlibc/i386/send.S4
-rw-r--r--mdk-stage1/dietlibc/i386/sendmsg.S4
-rw-r--r--mdk-stage1/dietlibc/i386/sendto.S4
-rw-r--r--mdk-stage1/dietlibc/i386/setsockopt.S4
-rw-r--r--mdk-stage1/dietlibc/i386/shutdown.S4
-rw-r--r--mdk-stage1/dietlibc/i386/sin.S34
-rw-r--r--mdk-stage1/dietlibc/i386/sincos.S18
-rw-r--r--mdk-stage1/dietlibc/i386/sinh.S29
-rw-r--r--mdk-stage1/dietlibc/i386/sleep.S25
-rw-r--r--mdk-stage1/dietlibc/i386/socket.S4
-rw-r--r--mdk-stage1/dietlibc/i386/socketcall.S17
-rw-r--r--mdk-stage1/dietlibc/i386/socketpair.S4
-rw-r--r--mdk-stage1/dietlibc/i386/sqrt.S23
-rw-r--r--mdk-stage1/dietlibc/i386/sqrtl.S11
-rw-r--r--mdk-stage1/dietlibc/i386/stpcpy.S22
-rw-r--r--mdk-stage1/dietlibc/i386/strcasecmp.S31
-rw-r--r--mdk-stage1/dietlibc/i386/strcat.S29
-rw-r--r--mdk-stage1/dietlibc/i386/strchr.S22
-rw-r--r--mdk-stage1/dietlibc/i386/strcmp.S31
-rw-r--r--mdk-stage1/dietlibc/i386/strcpy.S24
-rw-r--r--mdk-stage1/dietlibc/i386/strlen.S18
-rw-r--r--mdk-stage1/dietlibc/i386/strncmp.S28
-rw-r--r--mdk-stage1/dietlibc/i386/strncpy.S42
-rw-r--r--mdk-stage1/dietlibc/i386/strrchr.S19
-rw-r--r--mdk-stage1/dietlibc/i386/syscalls.h303
-rw-r--r--mdk-stage1/dietlibc/i386/tan.S12
-rw-r--r--mdk-stage1/dietlibc/i386/tanh.S32
-rw-r--r--mdk-stage1/dietlibc/i386/usleep.S31
-rw-r--r--mdk-stage1/dietlibc/i386/vfork.S9
-rw-r--r--mdk-stage1/dietlibc/i386/write12.S37
-rw-r--r--mdk-stage1/dietlibc/ia64/Makefile.add2
-rw-r--r--mdk-stage1/dietlibc/ia64/README4
-rw-r--r--mdk-stage1/dietlibc/ia64/__alarm.c1
-rw-r--r--mdk-stage1/dietlibc/ia64/__longjmp.S1
-rw-r--r--mdk-stage1/dietlibc/ia64/__nice.c6
-rw-r--r--mdk-stage1/dietlibc/ia64/__testandset.S11
-rw-r--r--mdk-stage1/dietlibc/ia64/__time.c14
-rw-r--r--mdk-stage1/dietlibc/ia64/__waitpid.c5
-rw-r--r--mdk-stage1/dietlibc/ia64/accept.S3
-rw-r--r--mdk-stage1/dietlibc/ia64/bind.S3
-rw-r--r--mdk-stage1/dietlibc/ia64/clone.S41
-rw-r--r--mdk-stage1/dietlibc/ia64/connect.S3
-rw-r--r--mdk-stage1/dietlibc/ia64/fork.S8
-rw-r--r--mdk-stage1/dietlibc/ia64/getpeername.S3
-rw-r--r--mdk-stage1/dietlibc/ia64/getsockname.S3
-rw-r--r--mdk-stage1/dietlibc/ia64/getsockopt.S3
-rw-r--r--mdk-stage1/dietlibc/ia64/listen.S3
-rw-r--r--mdk-stage1/dietlibc/ia64/mmap.S3
-rw-r--r--mdk-stage1/dietlibc/ia64/msgctl.S3
-rw-r--r--mdk-stage1/dietlibc/ia64/msgget.S3
-rw-r--r--mdk-stage1/dietlibc/ia64/msgrcv.S3
-rw-r--r--mdk-stage1/dietlibc/ia64/msgsnd.S3
-rw-r--r--mdk-stage1/dietlibc/ia64/pipe.S20
-rw-r--r--mdk-stage1/dietlibc/ia64/recv.S3
-rw-r--r--mdk-stage1/dietlibc/ia64/recvfrom.S3
-rw-r--r--mdk-stage1/dietlibc/ia64/recvmsg.S3
-rw-r--r--mdk-stage1/dietlibc/ia64/semctl.S3
-rw-r--r--mdk-stage1/dietlibc/ia64/semget.S3
-rw-r--r--mdk-stage1/dietlibc/ia64/semop.S3
-rw-r--r--mdk-stage1/dietlibc/ia64/send.S3
-rw-r--r--mdk-stage1/dietlibc/ia64/sendmsg.S3
-rw-r--r--mdk-stage1/dietlibc/ia64/sendto.S3
-rw-r--r--mdk-stage1/dietlibc/ia64/setjmp.S1
-rw-r--r--mdk-stage1/dietlibc/ia64/setsockopt.S3
-rw-r--r--mdk-stage1/dietlibc/ia64/shmat.S3
-rw-r--r--mdk-stage1/dietlibc/ia64/shmctl.S3
-rw-r--r--mdk-stage1/dietlibc/ia64/shmdt.S3
-rw-r--r--mdk-stage1/dietlibc/ia64/shmget.S3
-rw-r--r--mdk-stage1/dietlibc/ia64/shutdown.S3
-rw-r--r--mdk-stage1/dietlibc/ia64/socket.S3
-rw-r--r--mdk-stage1/dietlibc/ia64/socketpair.S3
-rw-r--r--mdk-stage1/dietlibc/ia64/start.S45
-rw-r--r--mdk-stage1/dietlibc/ia64/syscalls.h242
-rw-r--r--mdk-stage1/dietlibc/ia64/unified.S46
-rw-r--r--mdk-stage1/dietlibc/ia64/utime.S3
-rw-r--r--mdk-stage1/dietlibc/ia64/vfork.S8
-rw-r--r--mdk-stage1/dietlibc/include/asm/alpha-sigcontext.h29
-rw-r--r--mdk-stage1/dietlibc/include/asm/arm-sigcontext.h32
-rw-r--r--mdk-stage1/dietlibc/include/asm/i386-sigcontext.h66
-rw-r--r--mdk-stage1/dietlibc/include/asm/ia64-sigcontext.h25
-rw-r--r--mdk-stage1/dietlibc/include/asm/mips-sigcontext.h23
-rw-r--r--mdk-stage1/dietlibc/include/asm/parisc-sigcontext.h16
-rw-r--r--mdk-stage1/dietlibc/include/asm/ppc-sigcontext.h76
-rw-r--r--mdk-stage1/dietlibc/include/asm/sigcontext.h36
-rw-r--r--mdk-stage1/dietlibc/include/asm/sparc-sigcontext.h50
-rw-r--r--mdk-stage1/dietlibc/include/asm/statfs.h1
-rw-r--r--mdk-stage1/dietlibc/include/asm/types.h32
-rw-r--r--mdk-stage1/dietlibc/include/cpio.h27
-rw-r--r--mdk-stage1/dietlibc/include/dietref.h22
-rw-r--r--mdk-stage1/dietlibc/include/float.h96
-rw-r--r--mdk-stage1/dietlibc/include/iconv.h25
-rw-r--r--mdk-stage1/dietlibc/include/libgen.h9
-rw-r--r--mdk-stage1/dietlibc/include/libintl.h23
-rw-r--r--mdk-stage1/dietlibc/include/linux/eventpoll.h17
-rw-r--r--mdk-stage1/dietlibc/include/linux/if_ether.h101
-rw-r--r--mdk-stage1/dietlibc/include/linux/loop.h47
-rw-r--r--mdk-stage1/dietlibc/include/linux/nfs.h88
-rw-r--r--mdk-stage1/dietlibc/include/linux/posix_types.h115
-rw-r--r--mdk-stage1/dietlibc/include/linux/types.h6
-rw-r--r--mdk-stage1/dietlibc/include/md5.h48
-rw-r--r--mdk-stage1/dietlibc/include/net/ethernet.h76
-rw-r--r--mdk-stage1/dietlibc/include/net/if_ether.h74
-rw-r--r--mdk-stage1/dietlibc/include/netinet/ip_icmp.h145
-rw-r--r--mdk-stage1/dietlibc/include/netinet/tcp.h164
-rw-r--r--mdk-stage1/dietlibc/include/netinet/udp.h16
-rw-r--r--mdk-stage1/dietlibc/include/netpacket/packet.h41
-rw-r--r--mdk-stage1/dietlibc/include/pty.h13
-rw-r--r--mdk-stage1/dietlibc/include/stdarg-cruft.h299
-rw-r--r--mdk-stage1/dietlibc/include/stdarg.h24
-rw-r--r--mdk-stage1/dietlibc/include/stddef.h23
-rw-r--r--mdk-stage1/dietlibc/include/sys/alpha-ioctl.h168
-rw-r--r--mdk-stage1/dietlibc/include/sys/arm-ioctl.h149
-rw-r--r--mdk-stage1/dietlibc/include/sys/epoll.h60
-rw-r--r--mdk-stage1/dietlibc/include/sys/fsuid.h12
-rw-r--r--mdk-stage1/dietlibc/include/sys/gmon.h99
-rw-r--r--mdk-stage1/dietlibc/include/sys/gmon_out.h1
-rw-r--r--mdk-stage1/dietlibc/include/sys/hppa-ioctl.h133
-rw-r--r--mdk-stage1/dietlibc/include/sys/i386-ioctl.h141
-rw-r--r--mdk-stage1/dietlibc/include/sys/klog.h8
-rw-r--r--mdk-stage1/dietlibc/include/sys/mips-ioctl.h177
-rw-r--r--mdk-stage1/dietlibc/include/sys/ppc-ioctl.h164
-rw-r--r--mdk-stage1/dietlibc/include/sys/prctl.h8
-rw-r--r--mdk-stage1/dietlibc/include/sys/s390-ioctl.h141
-rw-r--r--mdk-stage1/dietlibc/include/sys/soundcard.h1300
-rw-r--r--mdk-stage1/dietlibc/include/sys/sparc-ioctl.h172
-rw-r--r--mdk-stage1/dietlibc/include/sys/sysmacros.h6
-rw-r--r--mdk-stage1/dietlibc/include/sys/timeb.h13
-rw-r--r--mdk-stage1/dietlibc/include/sys/timex.h50
-rw-r--r--mdk-stage1/dietlibc/include/sys/ucontext.h110
-rw-r--r--mdk-stage1/dietlibc/include/sysexits.h26
-rw-r--r--mdk-stage1/dietlibc/include/tar.h36
-rw-r--r--mdk-stage1/dietlibc/include/termio.h4
-rw-r--r--mdk-stage1/dietlibc/include/write12.h4
-rw-r--r--mdk-stage1/dietlibc/lib/__ftruncate64.c23
-rw-r--r--mdk-stage1/dietlibc/lib/__isinf.c15
-rw-r--r--mdk-stage1/dietlibc/lib/__ptrace.c27
-rw-r--r--mdk-stage1/dietlibc/lib/__stime.c14
-rw-r--r--mdk-stage1/dietlibc/lib/__truncate64.c23
-rw-r--r--mdk-stage1/dietlibc/lib/__v_printf.c300
-rw-r--r--mdk-stage1/dietlibc/lib/__v_scanf.c391
-rw-r--r--mdk-stage1/dietlibc/lib/adjtime.c18
-rw-r--r--mdk-stage1/dietlibc/lib/atoll.c19
-rw-r--r--mdk-stage1/dietlibc/lib/bcd.c185
-rw-r--r--mdk-stage1/dietlibc/lib/binshstr.c5
-rw-r--r--mdk-stage1/dietlibc/lib/cfgetospeed.c8
-rw-r--r--mdk-stage1/dietlibc/lib/cfsetispeed.c22
-rw-r--r--mdk-stage1/dietlibc/lib/cfsetospeed.c14
-rw-r--r--mdk-stage1/dietlibc/lib/errlistu.c6
-rw-r--r--mdk-stage1/dietlibc/lib/execle.c26
-rw-r--r--mdk-stage1/dietlibc/lib/if_nameindex.c40
-rw-r--r--mdk-stage1/dietlibc/lib/ipv6constants.c4
-rw-r--r--mdk-stage1/dietlibc/lib/labs.c6
-rw-r--r--mdk-stage1/dietlibc/lib/llabs.c6
-rw-r--r--mdk-stage1/dietlibc/lib/memmem.c14
-rw-r--r--mdk-stage1/dietlibc/lib/memrchr.c15
-rw-r--r--mdk-stage1/dietlibc/lib/pwrite.c11
-rw-r--r--mdk-stage1/dietlibc/lib/pwrite64.c14
-rw-r--r--mdk-stage1/dietlibc/lib/rand48.c89
-rw-r--r--mdk-stage1/dietlibc/lib/rand_r.c30
-rw-r--r--mdk-stage1/dietlibc/lib/readdir64.c62
-rw-r--r--mdk-stage1/dietlibc/lib/setlinebuf.c12
-rw-r--r--mdk-stage1/dietlibc/lib/sigaction.c11
-rw-r--r--mdk-stage1/dietlibc/lib/siginterrupt.c17
-rw-r--r--mdk-stage1/dietlibc/lib/signal.c12
-rw-r--r--mdk-stage1/dietlibc/lib/sigpending.c7
-rw-r--r--mdk-stage1/dietlibc/lib/sigprocmask.c7
-rw-r--r--mdk-stage1/dietlibc/lib/sigqueueinfo.c7
-rw-r--r--mdk-stage1/dietlibc/lib/sigsuspend.c10
-rw-r--r--mdk-stage1/dietlibc/lib/sigtimedwait.c7
-rw-r--r--mdk-stage1/dietlibc/lib/socketpair.c12
-rw-r--r--mdk-stage1/dietlibc/lib/strtof.c66
-rw-r--r--mdk-stage1/dietlibc/lib/strtold.c66
-rw-r--r--mdk-stage1/dietlibc/lib/strxfrm.c12
-rw-r--r--mdk-stage1/dietlibc/lib/tcflow.c35
-rw-r--r--mdk-stage1/dietlibc/lib/tcsendbreak.c11
-rw-r--r--mdk-stage1/dietlibc/lib/write12.c11
-rw-r--r--mdk-stage1/dietlibc/libcompat/daemon.c29
-rw-r--r--mdk-stage1/dietlibc/libcompat/getdelim.c32
-rw-r--r--mdk-stage1/dietlibc/libcompat/getline.c9
-rw-r--r--mdk-stage1/dietlibc/libcompat/re_bsd.c34
-rw-r--r--mdk-stage1/dietlibc/libcompat/stpcpy.c6
-rw-r--r--mdk-stage1/dietlibc/libcompat/syscall.S70
-rw-r--r--mdk-stage1/dietlibc/libcruft/__end_parse.c10
-rw-r--r--mdk-stage1/dietlibc/libcruft/__parse.c10
-rw-r--r--mdk-stage1/dietlibc/libcruft/__parse_1.c9
-rw-r--r--mdk-stage1/dietlibc/libcruft/__parse_nws.c10
-rw-r--r--mdk-stage1/dietlibc/libcruft/__parse_ws.c11
-rw-r--r--mdk-stage1/dietlibc/libcruft/__prepare_parse.c19
-rw-r--r--mdk-stage1/dietlibc/libcruft/alphasort.c6
-rw-r--r--mdk-stage1/dietlibc/libcruft/alphasort64.c6
-rw-r--r--mdk-stage1/dietlibc/libcruft/bcopy.c11
-rw-r--r--mdk-stage1/dietlibc/libcruft/bzero.c10
-rw-r--r--mdk-stage1/dietlibc/libcruft/clock.c21
-rw-r--r--mdk-stage1/dietlibc/libcruft/dn_expand.c11
-rw-r--r--mdk-stage1/dietlibc/libcruft/dnscruft3.c3
-rw-r--r--mdk-stage1/dietlibc/libcruft/dnscruft4.c11
-rw-r--r--mdk-stage1/dietlibc/libcruft/getgrent.c10
-rw-r--r--mdk-stage1/dietlibc/libcruft/getgrent_r.c78
-rw-r--r--mdk-stage1/dietlibc/libcruft/getgrgid_r.c14
-rw-r--r--mdk-stage1/dietlibc/libcruft/getgrnam_r.c14
-rw-r--r--mdk-stage1/dietlibc/libcruft/gethostbyaddr2_r.c2
-rw-r--r--mdk-stage1/dietlibc/libcruft/getopt_data.c10
-rw-r--r--mdk-stage1/dietlibc/libcruft/getopt_long.c103
-rw-r--r--mdk-stage1/dietlibc/libcruft/getopt_long_only.c108
-rw-r--r--mdk-stage1/dietlibc/libcruft/getpwent.c10
-rw-r--r--mdk-stage1/dietlibc/libcruft/getpwent_r.c65
-rw-r--r--mdk-stage1/dietlibc/libcruft/getpwnam_r.c14
-rw-r--r--mdk-stage1/dietlibc/libcruft/getpwuid_r.c13
-rw-r--r--mdk-stage1/dietlibc/libcruft/getspent.c10
-rw-r--r--mdk-stage1/dietlibc/libcruft/getspent_r.c68
-rw-r--r--mdk-stage1/dietlibc/libcruft/getspnam_r.c14
-rw-r--r--mdk-stage1/dietlibc/libcruft/getusershell.c33
-rw-r--r--mdk-stage1/dietlibc/libcruft/grbuf.c5
-rw-r--r--mdk-stage1/dietlibc/libcruft/herror.c8
-rw-r--r--mdk-stage1/dietlibc/libcruft/hstrerror.c11
-rw-r--r--mdk-stage1/dietlibc/libcruft/killpg.c5
-rw-r--r--mdk-stage1/dietlibc/libcruft/localeconv.c15
-rw-r--r--mdk-stage1/dietlibc/libcruft/mkdtemp.c28
-rw-r--r--mdk-stage1/dietlibc/libcruft/mktemp.c17
-rw-r--r--mdk-stage1/dietlibc/libcruft/pwbuf.c5
-rw-r--r--mdk-stage1/dietlibc/libcruft/res_mkquery.c75
-rw-r--r--mdk-stage1/dietlibc/libcruft/res_query.c95
-rw-r--r--mdk-stage1/dietlibc/libcruft/res_search.c35
-rw-r--r--mdk-stage1/dietlibc/libcruft/scan_ulong.c13
-rw-r--r--mdk-stage1/dietlibc/libcruft/scandir.c47
-rw-r--r--mdk-stage1/dietlibc/libcruft/scandir64.c47
-rw-r--r--mdk-stage1/dietlibc/libcruft/setegid.c11
-rw-r--r--mdk-stage1/dietlibc/libcruft/seteuid.c11
-rw-r--r--mdk-stage1/dietlibc/libcruft/setlocale.c7
-rw-r--r--mdk-stage1/dietlibc/libcruft/spbuf.c5
-rw-r--r--mdk-stage1/dietlibc/libcruft/sysconf.c43
-rw-r--r--mdk-stage1/dietlibc/libcruft/sysconf_cpus.c64
-rw-r--r--mdk-stage1/dietlibc/libcruft/tempnam.c32
-rw-r--r--mdk-stage1/dietlibc/libcruft/tmpnam.c31
-rw-r--r--mdk-stage1/dietlibc/libcrypt/md5.c243
-rw-r--r--mdk-stage1/dietlibc/libcrypt/md5crypt.c157
-rw-r--r--mdk-stage1/dietlibc/libdl/_dl_alloc.c81
-rw-r--r--mdk-stage1/dietlibc/libdl/_dl_load.c401
-rw-r--r--mdk-stage1/dietlibc/libdl/_dl_main.c1059
-rw-r--r--mdk-stage1/dietlibc/libdl/_dl_queue.c39
-rw-r--r--mdk-stage1/dietlibc/libdl/_dl_rel.c42
-rw-r--r--mdk-stage1/dietlibc/libdl/_dl_rel.h25
-rw-r--r--mdk-stage1/dietlibc/libdl/_dl_relocate.c96
-rw-r--r--mdk-stage1/dietlibc/libdl/elf_hash.h10
-rw-r--r--mdk-stage1/dietlibc/libdl/test/test.c20
-rw-r--r--mdk-stage1/dietlibc/libdl/test/test_so.c11
-rw-r--r--mdk-stage1/dietlibc/libm/acosh.c6
-rw-r--r--mdk-stage1/dietlibc/libm/asinh.c6
-rw-r--r--mdk-stage1/dietlibc/libm/atanh.c8
-rw-r--r--mdk-stage1/dietlibc/libm/bessel.c171
-rw-r--r--mdk-stage1/dietlibc/libm/cosh.c9
-rw-r--r--mdk-stage1/dietlibc/libm/erf.c95
-rw-r--r--mdk-stage1/dietlibc/libm/gamma.c98
-rw-r--r--mdk-stage1/dietlibc/libm/ipow.c29
-rw-r--r--mdk-stage1/dietlibc/libm/poly.c41
-rw-r--r--mdk-stage1/dietlibc/libm/pow.c42
-rw-r--r--mdk-stage1/dietlibc/libm/rint.c5
-rw-r--r--mdk-stage1/dietlibc/libm/sinh.c9
-rw-r--r--mdk-stage1/dietlibc/libm/tanh.c7
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_equal.c3
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_errno.c5
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_fdglue2.c16
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_fgetc.c10
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_flockfile.c5
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_fputc.c9
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_funlockfile.c5
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_getschedparam.c22
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_internal.c359
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_key.c48
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_setschedparam.c21
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_sigmask.c8
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_sys_fdatasync.c10
-rw-r--r--mdk-stage1/dietlibc/libshell/basename.c27
-rw-r--r--mdk-stage1/dietlibc/libshell/dirname.c25
-rw-r--r--mdk-stage1/dietlibc/libstdio/fdglue2.c43
-rw-r--r--mdk-stage1/dietlibc/libstdio/fdprintf.c13
-rw-r--r--mdk-stage1/dietlibc/libstdio/fgetc_unlocked.c30
-rw-r--r--mdk-stage1/dietlibc/libstdio/fgetpos.c8
-rw-r--r--mdk-stage1/dietlibc/libstdio/fputc_unlocked.c20
-rw-r--r--mdk-stage1/dietlibc/libstdio/fscanf.c14
-rw-r--r--mdk-stage1/dietlibc/libstdio/fseeko.c10
-rw-r--r--mdk-stage1/dietlibc/libstdio/fseeko64.c12
-rw-r--r--mdk-stage1/dietlibc/libstdio/fsetpos.c7
-rw-r--r--mdk-stage1/dietlibc/libstdio/ftello.c7
-rw-r--r--mdk-stage1/dietlibc/libstdio/ftello64.c9
-rw-r--r--mdk-stage1/dietlibc/libstdio/puts.c16
-rw-r--r--mdk-stage1/dietlibc/libstdio/scanf.c14
-rw-r--r--mdk-stage1/dietlibc/libstdio/tmpfile.c12
-rw-r--r--mdk-stage1/dietlibc/libstdio/vfdprintf.c15
-rw-r--r--mdk-stage1/dietlibc/libstdio/vfprintf.c15
-rw-r--r--mdk-stage1/dietlibc/libstdio/vfscanf.c11
-rw-r--r--mdk-stage1/dietlibc/libstdio/vprintf.c15
-rw-r--r--mdk-stage1/dietlibc/libstdio/vscanf.c10
-rw-r--r--mdk-stage1/dietlibc/libugly/difftime.c8
-rw-r--r--mdk-stage1/dietlibc/libugly/dirfd.c8
-rw-r--r--mdk-stage1/dietlibc/libugly/freeaddrinfo.c11
-rw-r--r--mdk-stage1/dietlibc/libugly/ftime.c15
-rw-r--r--mdk-stage1/dietlibc/libugly/gai_strerror.c13
-rw-r--r--mdk-stage1/dietlibc/libugly/getaddrinfo.c140
-rw-r--r--mdk-stage1/dietlibc/libugly/gethostent.c116
-rw-r--r--mdk-stage1/dietlibc/libugly/getnameinfo.c46
-rw-r--r--mdk-stage1/dietlibc/libugly/getprotobyname.c12
-rw-r--r--mdk-stage1/dietlibc/libugly/getprotobyname_r.c17
-rw-r--r--mdk-stage1/dietlibc/libugly/getprotobynumber.c12
-rw-r--r--mdk-stage1/dietlibc/libugly/getprotobynumber_r.c13
-rw-r--r--mdk-stage1/dietlibc/libugly/getprotoent_r.c78
-rw-r--r--mdk-stage1/dietlibc/libugly/getservbyname.c12
-rw-r--r--mdk-stage1/dietlibc/libugly/getservbyname_r.c18
-rw-r--r--mdk-stage1/dietlibc/libugly/getservbyport.c12
-rw-r--r--mdk-stage1/dietlibc/libugly/getservbyport_r.c13
-rw-r--r--mdk-stage1/dietlibc/libugly/getservent.c10
-rw-r--r--mdk-stage1/dietlibc/libugly/getservent_r.c91
-rw-r--r--mdk-stage1/dietlibc/libugly/grantpt.c13
-rw-r--r--mdk-stage1/dietlibc/libugly/hasmntopt.c18
-rw-r--r--mdk-stage1/dietlibc/libugly/iconv.c71
-rw-r--r--mdk-stage1/dietlibc/libugly/iconv_close.c7
-rw-r--r--mdk-stage1/dietlibc/libugly/iconv_open.c28
-rw-r--r--mdk-stage1/dietlibc/libugly/netent.c130
-rw-r--r--mdk-stage1/dietlibc/libugly/openpty.c54
-rw-r--r--mdk-stage1/dietlibc/libugly/protoent_buf.c5
-rw-r--r--mdk-stage1/dietlibc/libugly/ptsname.c17
-rw-r--r--mdk-stage1/dietlibc/libugly/putpwent.c19
-rw-r--r--mdk-stage1/dietlibc/libugly/servent_buf.c5
-rw-r--r--mdk-stage1/dietlibc/libugly/strndup.c10
-rw-r--r--mdk-stage1/dietlibc/libugly/timezone.c3
-rw-r--r--mdk-stage1/dietlibc/libugly/unlockpt.c10
-rw-r--r--mdk-stage1/dietlibc/libugly/utent.c103
-rw-r--r--mdk-stage1/dietlibc/libugly/wtent.c30
-rw-r--r--mdk-stage1/dietlibc/ppc/clone.S48
-rw-r--r--mdk-stage1/dietlibc/ppc/syscalls.h259
-rw-r--r--mdk-stage1/dietlibc/profiling/PORTING25
-rw-r--r--mdk-stage1/dietlibc/profiling/README37
-rw-r--r--mdk-stage1/dietlibc/profiling/__mcount.c24
-rw-r--r--mdk-stage1/dietlibc/profiling/monitor.c93
-rw-r--r--mdk-stage1/dietlibc/profiling/profil.c75
-rw-r--r--mdk-stage1/dietlibc/sparc/errlist.S280
-rw-r--r--mdk-stage1/dietlibc/sparc/sigaction.c7
-rw-r--r--mdk-stage1/dietlibc/sparc/strlen.S11
-rw-r--r--mdk-stage1/dietlibc/sparc/syscalls.h276
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/__pwrite.S3
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/adjtimex.S3
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/alarm.S4
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/bdflush.S5
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/chown32.S5
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/create_module.S5
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/delete_module.S5
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/environ.S16
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/epoll_create.S5
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/epoll_ctl.S5
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/epoll_wait.S5
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/errlist.S293
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/errno.S8
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/fchown32.S5
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/fdatasync.S6
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/ftruncate64.S10
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/getegid32.S5
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/geteuid32.S5
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/getgid32.S5
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/getgroups32.S5
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/getresgid32.S5
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/getuid32.S5
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/init_module.S5
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/lchown32.S5
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/madvise.S3
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/mlock.S3
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/mmap2.S5
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/msync.S3
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/munlock.S3
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/n_sigaction.S5
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/n_sigpending.S5
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/n_sigprocmask.S5
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/n_sigsuspend.S5
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/pivot_root.S3
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/prctl.S5
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/ptrace.S3
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/rt_sigaction.S3
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/rt_sigpending.S3
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/rt_sigprocmask.S3
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/rt_sigqueueinfo.S3
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/rt_sigsuspend.S3
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/rt_sigtimedwait.S3
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/sendfile64.S8
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/setfsgid.S3
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/setfsgid32.S5
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/setfsuid.S3
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/setfsuid32.S5
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/setgid32.S5
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/setregid32.S5
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/setresgid32.S5
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/setreuid32.S5
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/settimeofday.S3
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/setuid32.S5
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/truncate64.S10
-rw-r--r--mdk-stage1/dietlibc/x86_64/Makefile.add2
-rw-r--r--mdk-stage1/dietlibc/x86_64/__longjmp.S26
-rw-r--r--mdk-stage1/dietlibc/x86_64/__testandset.S12
-rw-r--r--mdk-stage1/dietlibc/x86_64/accept.S3
-rw-r--r--mdk-stage1/dietlibc/x86_64/bind.S3
-rw-r--r--mdk-stage1/dietlibc/x86_64/clone.S64
-rw-r--r--mdk-stage1/dietlibc/x86_64/connect.S3
-rw-r--r--mdk-stage1/dietlibc/x86_64/getpeername.S3
-rw-r--r--mdk-stage1/dietlibc/x86_64/getsockname.S3
-rw-r--r--mdk-stage1/dietlibc/x86_64/getsockopt.S3
-rw-r--r--mdk-stage1/dietlibc/x86_64/listen.S3
-rw-r--r--mdk-stage1/dietlibc/x86_64/mmap.S8
-rw-r--r--mdk-stage1/dietlibc/x86_64/msgctl.S3
-rw-r--r--mdk-stage1/dietlibc/x86_64/msgget.S3
-rw-r--r--mdk-stage1/dietlibc/x86_64/msgrcv.S3
-rw-r--r--mdk-stage1/dietlibc/x86_64/msgsnd.S3
-rw-r--r--mdk-stage1/dietlibc/x86_64/recv.c13
-rw-r--r--mdk-stage1/dietlibc/x86_64/recvfrom.S3
-rw-r--r--mdk-stage1/dietlibc/x86_64/recvmsg.S3
-rw-r--r--mdk-stage1/dietlibc/x86_64/semctl.S3
-rw-r--r--mdk-stage1/dietlibc/x86_64/semget.S3
-rw-r--r--mdk-stage1/dietlibc/x86_64/semop.S3
-rw-r--r--mdk-stage1/dietlibc/x86_64/send.c13
-rw-r--r--mdk-stage1/dietlibc/x86_64/sendmsg.S3
-rw-r--r--mdk-stage1/dietlibc/x86_64/sendto.S3
-rw-r--r--mdk-stage1/dietlibc/x86_64/setjmp.S37
-rw-r--r--mdk-stage1/dietlibc/x86_64/setsockopt.S3
-rw-r--r--mdk-stage1/dietlibc/x86_64/shmat.S3
-rw-r--r--mdk-stage1/dietlibc/x86_64/shmctl.S3
-rw-r--r--mdk-stage1/dietlibc/x86_64/shmdt.S3
-rw-r--r--mdk-stage1/dietlibc/x86_64/shmget.S3
-rw-r--r--mdk-stage1/dietlibc/x86_64/shutdown.S3
-rw-r--r--mdk-stage1/dietlibc/x86_64/sigaction.c26
-rw-r--r--mdk-stage1/dietlibc/x86_64/socket.S3
-rw-r--r--mdk-stage1/dietlibc/x86_64/socketpair.S3
-rw-r--r--mdk-stage1/dietlibc/x86_64/start.S55
-rw-r--r--mdk-stage1/dietlibc/x86_64/syscalls.h282
-rw-r--r--mdk-stage1/dietlibc/x86_64/umount.S9
-rw-r--r--mdk-stage1/dietlibc/x86_64/unified.S32
-rw-r--r--mdk-stage1/dietlibc/x86_64/waitpid.S12
502 files changed, 19926 insertions, 0 deletions
diff --git a/mdk-stage1/dietlibc/alpha/__alarm.c b/mdk-stage1/dietlibc/alpha/__alarm.c
new file mode 100644
index 000000000..7ca35cb78
--- /dev/null
+++ b/mdk-stage1/dietlibc/alpha/__alarm.c
@@ -0,0 +1,13 @@
+#include <unistd.h>
+#include <sys/time.h>
+
+unsigned int alarm(unsigned int seconds) {
+ struct itimerval old, new;
+ unsigned int ret;
+ new.it_interval.tv_usec=0;
+ new.it_interval.tv_sec=0;
+ new.it_value.tv_usec =0;
+ new.it_value.tv_sec =(long)seconds;
+ if (setitimer(ITIMER_REAL,&new,&old)==-1) return 0;
+ return old.it_value.tv_sec+(old.it_value.tv_usec?1:0);
+}
diff --git a/mdk-stage1/dietlibc/alpha/__testandset.S b/mdk-stage1/dietlibc/alpha/__testandset.S
new file mode 100644
index 000000000..c5ef81241
--- /dev/null
+++ b/mdk-stage1/dietlibc/alpha/__testandset.S
@@ -0,0 +1,11 @@
+.text
+.align 2
+.global __testandsets
+.type __testandsets,@function
+__testandset:
+ ldq_l $0, 0($16) /* load lock */
+ bne $0,1f /* ok there is a lock... */
+ lda $0, 1($31) /* load a 1 to register 0 */
+ stq_c $0, 0($16) /* write lock is locked :) */
+ beq $0,__testandset /* oops someone changed MY lock */
+1: ret $31, ($26), 0x01 /* return */
diff --git a/mdk-stage1/dietlibc/alpha/errlist.S b/mdk-stage1/dietlibc/alpha/errlist.S
new file mode 100644
index 000000000..a5956ce05
--- /dev/null
+++ b/mdk-stage1/dietlibc/alpha/errlist.S
@@ -0,0 +1,288 @@
+#ifdef __DYN_LIB
+.section .data
+#else
+.section .rodata
+#endif
+
+.align 8
+.global sys_errlist
+.type sys_errlist,@object
+
+sys_errlist:
+ .quad .LC000
+ .quad .LC001
+ .quad .LC002
+ .quad .LC003
+ .quad .LC004
+ .quad .LC005
+ .quad .LC006
+ .quad .LC007
+ .quad .LC008
+ .quad .LC009
+ .quad .LC010
+ .quad .LC011
+ .quad .LC012
+ .quad .LC013
+ .quad .LC014
+ .quad .LC015
+ .quad .LC016
+ .quad .LC017
+ .quad .LC018
+ .quad .LC019
+ .quad .LC020
+ .quad .LC021
+ .quad .LC022
+ .quad .LC023
+ .quad .LC024
+ .quad .LC025
+ .quad .LC026
+ .quad .LC027
+ .quad .LC028
+ .quad .LC029
+ .quad .LC030
+ .quad .LC031
+ .quad .LC032
+ .quad .LC033
+ .quad .LC034
+ .quad .LC035
+ .quad .LC036
+ .quad .LC037
+ .quad .LC038
+ .quad .LC039
+ .quad .LC040
+ .quad .LC041
+ .quad .LC042
+ .quad .LC043
+ .quad .LC044
+ .quad .LC045
+ .quad .LC046
+ .quad .LC047
+ .quad .LC048
+ .quad .LC049
+ .quad .LC050
+ .quad .LC051
+ .quad .LC052
+ .quad .LC053
+ .quad .LC054
+ .quad .LC055
+ .quad .LC056
+ .quad .LC057
+ .quad .LC058
+ .quad .LC059
+ .quad .LC060
+ .quad .LC061
+ .quad .LC062
+ .quad .LC063
+ .quad .LC064
+ .quad .LC065
+ .quad .LC066
+ .quad .LC067
+ .quad .LC068
+ .quad .LC069
+ .quad .LC070
+ .quad .LC071
+ .quad .LC072
+ .quad .LC073
+ .quad .LC074
+ .quad .LC075
+ .quad .LC076
+ .quad .LC077
+ .quad .LC078
+ .quad .LC079
+ .quad .LC080
+ .quad .LC081
+ .quad .LC082
+ .quad .LC083
+ .quad .LC084
+ .quad .LC085
+ .quad .LC086
+ .quad .LC087
+ .quad .LC088
+ .quad .LC089
+ .quad .LC090
+ .quad .LC091
+ .quad .LC092
+ .quad .LC093
+ .quad .LC094
+ .quad .LC095
+ .quad .LC096
+ .quad .LC097
+ .quad .LC098
+ .quad .LC099
+ .quad .LC100
+ .quad .LC101
+ .quad .LC102
+ .quad .LC103
+ .quad .LC104
+ .quad .LC105
+ .quad .LC106
+ .quad .LC107
+ .quad .LC108
+ .quad .LC109
+ .quad .LC110
+ .quad .LC111
+ .quad .LC112
+ .quad .LC113
+ .quad .LC114
+ .quad .LC115
+ .quad .LC116
+ .quad .LC117
+ .quad .LC118
+ .quad .LC119
+ .quad .LC120
+ .quad .LC121
+ .quad .LC122
+ .quad .LC123
+ .quad .LC124
+ .quad .LC125
+ .quad .LC126
+ .quad .LC127
+ .quad .LC128
+ .quad .LC129
+ .quad .LC130
+ .quad 0
+.size sys_errlist,.-sys_errlist
+
+.align 4
+.global sys_nerr
+.type sys_nerr,@object
+sys_nerr:
+ .long 130
+.size sys_nerr,4
+
+#ifdef __DYN_LIB
+.section .rodata
+#endif
+
+.LC000: .string "Success"
+.LC001: .string "Operation not permitted"
+.LC002: .string "No such file or directory"
+.LC003: .string "No such process"
+.LC004: .string "Interrupted system call"
+.LC005: .string "I/O error"
+.LC006: .string "No such device or address"
+.LC007: .string "Arg list too long"
+.LC008: .string "Exec format error"
+.LC009: .string "Bad file number"
+.LC010: .string "No child processes"
+.LC011: .string "Resource deadlock would occur"
+.LC012: .string "Out of memory"
+.LC013: .string "Permission denied"
+.LC014: .string "Bad address"
+.LC015: .string "Block device required"
+.LC016: .string "Device or resource busy"
+.LC017: .string "File exists"
+.LC018: .string "Cross-device link"
+.LC019: .string "No such device"
+.LC020: .string "Not a directory"
+.LC021: .string "Is a directory"
+.LC022: .string "Invalid argument"
+.LC023: .string "File table overflow"
+.LC024: .string "Too many open files"
+.LC025: .string "Not a typewriter"
+.LC026: .string "Text file busy"
+.LC027: .string "File too large"
+.LC028: .string "No space left on device"
+.LC029: .string "Illegal seek"
+.LC030: .string "Read-only file system"
+.LC031: .string "Too many links"
+.LC032: .string "Broken pipe"
+.LC033: .string "Math argument out of domain of func"
+.LC034: .string "Math result not representable"
+.LC035: .string "Try again"
+.LC036: .string "Operation now in progress"
+.LC037: .string "Operation already in progress"
+.LC038: .string "Socket operation on non-socket"
+.LC039: .string "Destination address required"
+.LC040: .string "Message too long"
+.LC041: .string "Protocol wrong type for socket"
+.LC042: .string "Protocol not available"
+.LC043: .string "Protocol not supported"
+.LC044: .string "Socket type not supported"
+.LC045: .string "Operation not supported on transport endpoint"
+.LC046: .string "Protocol family not supported"
+.LC047: .string "Address family not supported by protocol"
+.LC048: .string "Address already in use"
+.LC049: .string "Cannot assign requested address"
+.LC050: .string "Network is down"
+.LC051: .string "Network is unreachable"
+.LC052: .string "Network dropped connection because of reset"
+.LC053: .string "Software caused connection abort"
+.LC054: .string "Connection reset by peer"
+.LC055: .string "No buffer space available"
+.LC056: .string "Transport endpoint is already connected"
+.LC057: .string "Transport endpoint is not connected"
+.LC058: .string "Cannot send after transport endpoint shutdown"
+.LC059: .string "Too many references: cannot splice"
+.LC060: .string "Connection timed out"
+.LC061: .string "Connection refused"
+.LC062: .string "Too many symbolic links encountered"
+.LC063: .string "File name too long"
+.LC064: .string "Host is down"
+.LC065: .string "No route to host"
+.LC066: .string "Directory not empty"
+.LC067: .string "Error 67"
+.LC068: .string "Too many users"
+.LC069: .string "Quota exceeded"
+.LC070: .string "Stale NFS file handle"
+.LC071: .string "Object is remote"
+.LC072: .string "Error 72"
+.LC073: .string "Error 73"
+.LC074: .string "Error 74"
+.LC075: .string "Error 75"
+.LC076: .string "Error 76"
+.LC077: .string "No record locks available"
+.LC078: .string "Function not implemented"
+.LC079: .string "Error 79"
+.LC080: .string "No message of desired type"
+.LC081: .string "Identifier removed"
+.LC082: .string "Out of streams resources"
+.LC083: .string "Timer expired"
+.LC084: .string "Not a data message"
+.LC085: .string "Protocol error"
+.LC086: .string "No data available"
+.LC087: .string "Device not a stream"
+.LC088: .string "Channel number out of range"
+.LC089: .string "Level 2 not synchronized"
+.LC090: .string "Level 3 halted"
+.LC091: .string "Level 3 reset"
+.LC092: .string "Package not installed"
+.LC093: .string "Link number out of range"
+.LC094: .string "Protocol driver not attached"
+.LC095: .string "No CSI structure available"
+.LC096: .string "Level 2 halted"
+.LC097: .string "Invalid exchange"
+.LC098: .string "Invalid request descriptor"
+.LC099: .string "Exchange full"
+.LC100: .string "No anode"
+.LC101: .string "Invalid request code"
+.LC102: .string "Invalid slot"
+.LC103: .string "Error 103"
+.LC104: .string "Bad font file format"
+.LC105: .string "Machine is not on the network"
+.LC106: .string "Link has been severed"
+.LC107: .string "Advertise error"
+.LC108: .string "Srmount error"
+.LC109: .string "Communication error on send"
+.LC110: .string "Multihop attempted"
+.LC111: .string "RFS specific error"
+.LC112: .string "Value too large for defined data type"
+.LC113: .string "Name not unique on network"
+.LC114: .string "File descriptor in bad state"
+.LC115: .string "Remote address changed"
+.LC116: .string "Illegal byte sequence"
+.LC117: .string "Structure needs cleaning"
+.LC118: .string "Not a XENIX named type file"
+.LC119: .string "No XENIX semaphores available"
+.LC120: .string "Is a named type file"
+.LC121: .string "Remote I/O error"
+.LC122: .string "Can not access a needed shared library"
+.LC123: .string "Accessing a corrupted shared library"
+.LC124: .string ".lib section in a.out corrupted"
+.LC125: .string "Attempting to link in too many shared libraries"
+.LC126: .string "Cannot exec a shared library directly"
+.LC127: .string "Interrupted system call should be restarted"
+.LC128: .string "Streams pipe error"
+.LC129: .string "No medium found"
+.LC130: .string "Wrong medium type"
+
diff --git a/mdk-stage1/dietlibc/alpha/lseek64.S b/mdk-stage1/dietlibc/alpha/lseek64.S
new file mode 100644
index 000000000..f051e734d
--- /dev/null
+++ b/mdk-stage1/dietlibc/alpha/lseek64.S
@@ -0,0 +1,5 @@
+#include "syscalls.h"
+
+.global lseek64
+lseek64:
+ br lseek
diff --git a/mdk-stage1/dietlibc/alpha/n_sigprocmask.S b/mdk-stage1/dietlibc/alpha/n_sigprocmask.S
new file mode 100644
index 000000000..55f9fde28
--- /dev/null
+++ b/mdk-stage1/dietlibc/alpha/n_sigprocmask.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall_weak(osf_sigprocmask,__old_sigprocmask,__n_sigprocmask)
diff --git a/mdk-stage1/dietlibc/alpha/sigaction.c b/mdk-stage1/dietlibc/alpha/sigaction.c
new file mode 100644
index 000000000..f6c3ada7d
--- /dev/null
+++ b/mdk-stage1/dietlibc/alpha/sigaction.c
@@ -0,0 +1,7 @@
+#include <signal.h>
+
+int __rt_sigaction(int signum, const struct sigaction *act, struct sigaction *oldact, long nr, void* restorer);
+
+int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact) {
+ return __rt_sigaction(signum, act, oldact, _NSIG/8, 0);
+}
diff --git a/mdk-stage1/dietlibc/alpha/socketpair.S b/mdk-stage1/dietlibc/alpha/socketpair.S
new file mode 100644
index 000000000..06956a7ce
--- /dev/null
+++ b/mdk-stage1/dietlibc/alpha/socketpair.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall(socketpair,socketpair)
diff --git a/mdk-stage1/dietlibc/alpha/syscalls.h b/mdk-stage1/dietlibc/alpha/syscalls.h
new file mode 100644
index 000000000..5c654b4bf
--- /dev/null
+++ b/mdk-stage1/dietlibc/alpha/syscalls.h
@@ -0,0 +1,371 @@
+
+#define __NR_osf_syscall 0 /* not implemented */
+#define __NR_exit 1
+#define __NR_fork 2
+#define __NR_read 3
+#define __NR_write 4
+#define __NR_osf_old_open 5 /* not implemented */
+#define __NR_close 6
+#define __NR_osf_wait4 7
+#define __NR_osf_old_creat 8 /* not implemented */
+#define __NR_link 9
+#define __NR_unlink 10
+#define __NR_osf_execve 11 /* not implemented */
+#define __NR_chdir 12
+#define __NR_fchdir 13
+#define __NR_mknod 14
+#define __NR_chmod 15
+#define __NR_chown 16
+#define __NR_brk 17
+#define __NR_osf_getfsstat 18 /* not implemented */
+#define __NR_lseek 19
+#define __NR_getxpid 20
+#define __NR_osf_mount 21
+#define __NR_umount 22
+#define __NR_setuid 23
+#define __NR_getxuid 24
+#define __NR_exec_with_loader 25 /* not implemented */
+#define __NR_ptrace 26
+#define __NR_osf_nrecvmsg 27 /* not implemented */
+#define __NR_osf_nsendmsg 28 /* not implemented */
+#define __NR_osf_nrecvfrom 29 /* not implemented */
+#define __NR_osf_naccept 30 /* not implemented */
+#define __NR_osf_ngetpeername 31 /* not implemented */
+#define __NR_osf_ngetsockname 32 /* not implemented */
+#define __NR_access 33
+#define __NR_osf_chflags 34 /* not implemented */
+#define __NR_osf_fchflags 35 /* not implemented */
+#define __NR_sync 36
+#define __NR_kill 37
+#define __NR_osf_old_stat 38 /* not implemented */
+#define __NR_setpgid 39
+#define __NR_osf_old_lstat 40 /* not implemented */
+#define __NR_dup 41
+#define __NR_pipe 42
+#define __NR_osf_set_program_attributes 43
+#define __NR_osf_profil 44 /* not implemented */
+#define __NR_open 45
+#define __NR_osf_old_sigaction 46 /* not implemented */
+#define __NR_getxgid 47
+#define __NR_osf_sigprocmask 48
+#define __NR_osf_getlogin 49 /* not implemented */
+#define __NR_osf_setlogin 50 /* not implemented */
+#define __NR_acct 51
+#define __NR_sigpending 52
+
+#define __NR_ioctl 54
+#define __NR_osf_reboot 55 /* not implemented */
+#define __NR_osf_revoke 56 /* not implemented */
+#define __NR_symlink 57
+#define __NR_readlink 58
+#define __NR_execve 59
+#define __NR_umask 60
+#define __NR_chroot 61
+#define __NR_osf_old_fstat 62 /* not implemented */
+#define __NR_getpgrp 63
+#define __NR_getpagesize 64
+#define __NR_osf_mremap 65 /* not implemented */
+#define __NR_vfork 66
+#define __NR_stat 67
+#define __NR_lstat 68
+#define __NR_osf_sbrk 69 /* not implemented */
+#define __NR_osf_sstk 70 /* not implemented */
+#define __NR_mmap 71 /* OSF/1 mmap is superset of Linux */
+#define __NR_osf_old_vadvise 72 /* not implemented */
+#define __NR_munmap 73
+#define __NR_mprotect 74
+#define __NR_madvise 75
+#define __NR_vhangup 76
+#define __NR_osf_kmodcall 77 /* not implemented */
+#define __NR_osf_mincore 78 /* not implemented */
+#define __NR_getgroups 79
+#define __NR_setgroups 80
+#define __NR_osf_old_getpgrp 81 /* not implemented */
+#define __NR_setpgrp 82 /* BSD alias for setpgid */
+#define __NR_osf_setitimer 83
+#define __NR_osf_old_wait 84 /* not implemented */
+#define __NR_osf_table 85 /* not implemented */
+#define __NR_osf_getitimer 86
+#define __NR_gethostname 87
+#define __NR_sethostname 88
+#define __NR_getdtablesize 89
+#define __NR_dup2 90
+#define __NR_fstat 91
+#define __NR_fcntl 92
+#define __NR_osf_select 93
+#define __NR_poll 94
+#define __NR_fsync 95
+#define __NR_setpriority 96
+#define __NR_socket 97
+#define __NR_connect 98
+#define __NR_accept 99
+#define __NR_getpriority 100
+#define __NR_send 101
+#define __NR_recv 102
+#define __NR_sigreturn 103
+#define __NR_bind 104
+#define __NR_setsockopt 105
+#define __NR_listen 106
+#define __NR_osf_plock 107 /* not implemented */
+#define __NR_osf_old_sigvec 108 /* not implemented */
+#define __NR_osf_old_sigblock 109 /* not implemented */
+#define __NR_osf_old_sigsetmask 110 /* not implemented */
+#define __NR_sigsuspend 111
+#define __NR_osf_sigstack 112
+#define __NR_recvmsg 113
+#define __NR_sendmsg 114
+#define __NR_osf_old_vtrace 115 /* not implemented */
+#define __NR_osf_gettimeofday 116
+#define __NR_osf_getrusage 117
+#define __NR_getsockopt 118
+
+#define __NR_readv 120
+#define __NR_writev 121
+#define __NR_osf_settimeofday 122
+#define __NR_fchown 123
+#define __NR_fchmod 124
+#define __NR_recvfrom 125
+#define __NR_setreuid 126
+#define __NR_setregid 127
+#define __NR_rename 128
+#define __NR_truncate 129
+#define __NR_ftruncate 130
+#define __NR_flock 131
+#define __NR_setgid 132
+#define __NR_sendto 133
+#define __NR_shutdown 134
+#define __NR_socketpair 135
+#define __NR_mkdir 136
+#define __NR_rmdir 137
+#define __NR_osf_utimes 138
+#define __NR_osf_old_sigreturn 139 /* not implemented */
+#define __NR_osf_adjtime 140 /* not implemented */
+#define __NR_getpeername 141
+#define __NR_osf_gethostid 142 /* not implemented */
+#define __NR_osf_sethostid 143 /* not implemented */
+#define __NR_getrlimit 144
+#define __NR_setrlimit 145
+#define __NR_osf_old_killpg 146 /* not implemented */
+#define __NR_setsid 147
+#define __NR_quotactl 148
+#define __NR_osf_oldquota 149 /* not implemented */
+#define __NR_getsockname 150
+
+#define __NR_osf_pid_block 153 /* not implemented */
+#define __NR_osf_pid_unblock 154 /* not implemented */
+
+#define __NR_sigaction 156
+#define __NR_osf_sigwaitprim 157 /* not implemented */
+#define __NR_osf_nfssvc 158 /* not implemented */
+#define __NR_osf_getdirentries 159
+#define __NR_osf_statfs 160
+#define __NR_osf_fstatfs 161
+
+#define __NR_osf_asynch_daemon 163 /* not implemented */
+#define __NR_osf_getfh 164 /* not implemented */
+#define __NR_osf_getdomainname 165
+#define __NR_setdomainname 166
+
+#define __NR_osf_exportfs 169 /* not implemented */
+
+#define __NR_osf_alt_plock 181 /* not implemented */
+
+#define __NR_osf_getmnt 184 /* not implemented */
+
+#define __NR_osf_alt_sigpending 187 /* not implemented */
+#define __NR_osf_alt_setsid 188 /* not implemented */
+
+#define __NR_osf_swapon 199
+#define __NR_msgctl 200
+#define __NR_msgget 201
+#define __NR_msgrcv 202
+#define __NR_msgsnd 203
+#define __NR_semctl 204
+#define __NR_semget 205
+#define __NR_semop 206
+#define __NR_osf_utsname 207
+#define __NR_lchown 208
+#define __NR_osf_shmat 209
+#define __NR_shmctl 210
+#define __NR_shmdt 211
+#define __NR_shmget 212
+#define __NR_osf_mvalid 213 /* not implemented */
+#define __NR_osf_getaddressconf 214 /* not implemented */
+#define __NR_osf_msleep 215 /* not implemented */
+#define __NR_osf_mwakeup 216 /* not implemented */
+#define __NR_msync 217
+#define __NR_osf_signal 218 /* not implemented */
+#define __NR_osf_utc_gettime 219 /* not implemented */
+#define __NR_osf_utc_adjtime 220 /* not implemented */
+
+#define __NR_osf_security 222 /* not implemented */
+#define __NR_osf_kloadcall 223 /* not implemented */
+
+#define __NR_getpgid 233
+#define __NR_getsid 234
+#define __NR_sigaltstack 235
+#define __NR_osf_waitid 236 /* not implemented */
+#define __NR_osf_priocntlset 237 /* not implemented */
+#define __NR_osf_sigsendset 238 /* not implemented */
+#define __NR_osf_set_speculative 239 /* not implemented */
+#define __NR_osf_msfs_syscall 240 /* not implemented */
+#define __NR_osf_sysinfo 241
+#define __NR_osf_uadmin 242 /* not implemented */
+#define __NR_osf_fuser 243 /* not implemented */
+#define __NR_osf_proplist_syscall 244
+#define __NR_osf_ntp_adjtime 245 /* not implemented */
+#define __NR_osf_ntp_gettime 246 /* not implemented */
+#define __NR_osf_pathconf 247 /* not implemented */
+#define __NR_osf_fpathconf 248 /* not implemented */
+
+#define __NR_osf_uswitch 250 /* not implemented */
+#define __NR_osf_usleep_thread 251
+#define __NR_osf_audcntl 252 /* not implemented */
+#define __NR_osf_audgen 253 /* not implemented */
+#define __NR_sysfs 254
+#define __NR_osf_subsys_info 255 /* not implemented */
+#define __NR_osf_getsysinfo 256
+#define __NR_osf_setsysinfo 257
+#define __NR_osf_afs_syscall 258 /* not implemented */
+#define __NR_osf_swapctl 259 /* not implemented */
+#define __NR_osf_memcntl 260 /* not implemented */
+#define __NR_osf_fdatasync 261 /* not implemented */
+
+
+/*
+ * Linux-specific system calls begin at 300
+ */
+#define __NR_bdflush 300
+#define __NR_sethae 301
+#define __NR_mount 302
+#define __NR_old_adjtimex 303
+#define __NR_swapoff 304
+#define __NR_getdents 305
+#define __NR_create_module 306
+#define __NR_init_module 307
+#define __NR_delete_module 308
+#define __NR_get_kernel_syms 309
+#define __NR_syslog 310
+#define __NR_reboot 311
+#define __NR_clone 312
+#define __NR_uselib 313
+#define __NR_mlock 314
+#define __NR_munlock 315
+#define __NR_mlockall 316
+#define __NR_munlockall 317
+#define __NR_sysinfo 318
+#define __NR__sysctl 319
+/* 320 was sys_idle. */
+#define __NR_oldumount 321
+#define __NR_swapon 322
+#define __NR_times 323
+#define __NR_personality 324
+#define __NR_setfsuid 325
+#define __NR_setfsgid 326
+#define __NR_ustat 327
+#define __NR_statfs 328
+#define __NR_fstatfs 329
+#define __NR_sched_setparam 330
+#define __NR_sched_getparam 331
+#define __NR_sched_setscheduler 332
+#define __NR_sched_getscheduler 333
+#define __NR_sched_yield 334
+#define __NR_sched_get_priority_max 335
+#define __NR_sched_get_priority_min 336
+#define __NR_sched_rr_get_interval 337
+#define __NR_afs_syscall 338
+#define __NR_uname 339
+#define __NR_nanosleep 340
+#define __NR_mremap 341
+#define __NR_nfsservctl 342
+#define __NR_setresuid 343
+#define __NR_getresuid 344
+#define __NR_pciconfig_read 345
+#define __NR_pciconfig_write 346
+#define __NR_query_module 347
+#define __NR_prctl 348
+#define __NR_pread 349
+#define __NR_pwrite 350
+#define __NR_rt_sigreturn 351
+#define __NR_rt_sigaction 352
+#define __NR_rt_sigprocmask 353
+#define __NR_rt_sigpending 354
+#define __NR_rt_sigtimedwait 355
+#define __NR_rt_sigqueueinfo 356
+#define __NR_rt_sigsuspend 357
+#define __NR_select 358
+#define __NR_gettimeofday 359
+#define __NR_settimeofday 360
+#define __NR_getitimer 361
+#define __NR_setitimer 362
+#define __NR_utimes 363
+#define __NR_getrusage 364
+#define __NR_wait4 365
+#define __NR_adjtimex 366
+#define __NR_getcwd 367
+#define __NR_capget 368
+#define __NR_capset 369
+#define __NR_sendfile 370
+#define __NR_setresgid 371
+#define __NR_getresgid 372
+#define __NR_dipc 373
+#define __NR_pivot_root 374
+#define __NR_mincore 375
+#define __NR_pciconfig_iobase 376
+#define __NR_getdents64 377
+#define __NR_gettid 378
+#define __NR_readahead 379
+#define __NR_security 380 /* syscall for security modules */
+#define __NR_tkill 381
+#define __NR_setxattr 382
+#define __NR_lsetxattr 383
+#define __NR_fsetxattr 384
+#define __NR_getxattr 385
+#define __NR_lgetxattr 386
+#define __NR_fgetxattr 387
+#define __NR_listxattr 388
+#define __NR_llistxattr 389
+#define __NR_flistxattr 390
+#define __NR_removexattr 391
+#define __NR_lremovexattr 392
+#define __NR_fremovexattr 393
+#define __NR_futex 394
+#define __NR_sched_setaffinity 395
+#define __NR_sched_getaffinity 396
+#define __NR_tuxcall 397
+#define __NR_io_setup 398
+#define __NR_io_destroy 399
+#define __NR_io_getevents 400
+#define __NR_io_submit 401
+#define __NR_io_cancel 402
+#define __NR_alloc_hugepages 403
+#define __NR_free_hugepages 404
+#define __NR_exit_group 405
+#define __NR_lookup_dcookie 406
+#define __NR_sys_epoll_create 407
+#define __NR_sys_epoll_ctl 408
+#define __NR_sys_epoll_wait 409
+#define __NR_remap_file_pages 410
+#define __NR_set_tid_address 411
+
+#define syscall_weak(name,wsym,sym) \
+.text ; \
+.align 2 ; \
+.weak wsym; \
+.type wsym,@function ; \
+wsym: ; \
+.global sym ; \
+.type sym,@function ; \
+sym: ; \
+ lda $0, __NR_##name($31) ; \
+ br __unified_syscall
+
+#define syscall(name,sym) \
+.text ; \
+.align 2 ; \
+.global sym ; \
+.type sym,@function ; \
+sym: ; \
+ lda $0, __NR_##name($31) ; \
+ br __unified_syscall
+
diff --git a/mdk-stage1/dietlibc/i386/PIC.h b/mdk-stage1/dietlibc/i386/PIC.h
new file mode 100644
index 000000000..45ddeb446
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/PIC.h
@@ -0,0 +1,82 @@
+#ifndef __I386_PIC_H__
+#define __I386_PIC_H__
+#ifdef __DYN_LIB
+
+#if 1
+/* don't trash the athlon return stack */
+.text
+.Lgetpic:
+ mov (%esp),%ebx
+ ret
+
+.macro PIC_INIT
+ call .Lgetpic
+ addl $_GLOBAL_OFFSET_TABLE_, %ebx
+.endm
+#else
+/* standard code for PIC init */
+.macro PIC_INIT
+ call 0f
+0: popl %ebx
+ addl $_GLOBAL_OFFSET_TABLE_+[.-0b], %ebx
+.endm
+#endif
+
+#define PIC_SAVE pushl %ebx
+#define PIC_RESTORE popl %ebx
+
+
+/* get memory variable (var) in register (reg) */
+.macro GET_VAR var reg
+ movl \var@GOT(%ebx), \reg
+ movl (\reg), \reg
+.endm
+
+/* put register (reg) into memory variable (var) TRASH register (tmp) */
+.macro PUT_VAR reg var tmp
+ movl \var@GOT(%ebx), \tmp
+ movl \reg, (\tmp)
+.endm
+
+/* get memory variable (var) in register (reg)
+ * IF no more PIC-code is needed */
+.macro GET_1VAR var reg
+ PIC_SAVE
+ PIC_INIT
+ GET_VAR \var, \reg
+ PIC_RESTORE
+.endm
+
+/* put register (reg) into memory variable (var)
+ * IF no more PIC-code is needed */
+.macro PUT_1VAR reg var
+ PIC_SAVE
+ PIC_INIT
+ PUT_VAR \reg, \var, %ebx
+ PIC_RESTORE
+.endm
+
+#else
+
+#define PIC_SAVE
+#define PIC_RESTORE
+#define PIC_INIT
+
+.macro GET_VAR var reg
+ movl \var, \reg
+.endm
+
+.macro PUT_VAR reg var tmp
+ movl \reg, \var
+.endm
+
+.macro GET_1VAR var reg
+ GET_VAR \var, \reg
+.endm
+
+.macro PUT_1VAR reg var
+ PUT_VAR \reg, \var, none
+.endm
+
+#endif
+#endif
diff --git a/mdk-stage1/dietlibc/i386/__half.S b/mdk-stage1/dietlibc/i386/__half.S
new file mode 100644
index 000000000..6355c93e4
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/__half.S
@@ -0,0 +1,10 @@
+#
+# Definiert Konstante (float)0.5 unter dem Namen __half
+# Wird von etlichen Funktionen benutzt (sinh, cosh, atanh)
+#
+
+.global __half
+.data
+.type __half,@object
+.size __half,4
+__half: .long 0x3f000000
diff --git a/mdk-stage1/dietlibc/i386/__ten.S b/mdk-stage1/dietlibc/i386/__ten.S
new file mode 100644
index 000000000..47b9431f4
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/__ten.S
@@ -0,0 +1,9 @@
+#
+# Definiert Konstante (float)10. unter dem Namen __ten
+#
+
+.global __ten
+.data
+.type __ten,@object
+.size __ten,4
+__ten: .long 0x41200000
diff --git a/mdk-stage1/dietlibc/i386/accept.S b/mdk-stage1/dietlibc/i386/accept.S
new file mode 100644
index 000000000..d8be36a54
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/accept.S
@@ -0,0 +1,4 @@
+#include <linuxnet.h>
+#include <syscalls.h>
+
+__socketcall(accept,ACCEPT)
diff --git a/mdk-stage1/dietlibc/i386/acos.S b/mdk-stage1/dietlibc/i386/acos.S
new file mode 100644
index 000000000..baabf9f04
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/acos.S
@@ -0,0 +1,30 @@
+
+.text
+
+.global acosf,acos,acosl # ,__acos
+ .type acosf,@function
+ .type acos,@function
+ .type acosl,@function
+# .type __acos,@function
+acosf:
+ flds 4(%esp)
+ jmp __acos
+acosl:
+ fldt 4(%esp)
+ jmp __acos
+acos:
+ fldl 4(%esp)
+__acos:
+ fld %st
+ fmul %st
+ fld1
+ fsubp
+ fsqrt
+ fxch %st(1)
+ fpatan
+ ret
+
+.ende:
+.size acos,.ende-acos
+.size acosf,.ende-acosf
+.size acosl,.ende-acosl
diff --git a/mdk-stage1/dietlibc/i386/acosh.S b/mdk-stage1/dietlibc/i386/acosh.S
new file mode 100644
index 000000000..0611c9d31
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/acosh.S
@@ -0,0 +1,18 @@
+.text
+.global acosh
+.type acosh,@function
+
+acosh:
+ fldln2
+ fldl 4(%esp)
+ fld %st(0)
+ fmul %st(0),%st(0)
+ fld1
+ fsubrp %st(0),%st(1)
+ fsqrt
+ faddp %st(0),%st(1)
+ fyl2x
+ ret
+
+.Lende:
+ .size acosh,.Lende-acosh
diff --git a/mdk-stage1/dietlibc/i386/asin.S b/mdk-stage1/dietlibc/i386/asin.S
new file mode 100644
index 000000000..7b0c31407
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/asin.S
@@ -0,0 +1,29 @@
+
+.text
+
+.global asinf,asin,asinl # ,__asin
+ .type asinf,@function
+ .type asin,@function
+ .type asinl,@function
+# .type __asin,@function
+asinf:
+ flds 4(%esp)
+ jmp __asin
+asinl:
+ fldt 4(%esp)
+ jmp __asin
+asin:
+ fldl 4(%esp)
+__asin:
+ fld %st
+ fmul %st
+ fld1
+ fsubp
+ fsqrt
+ fpatan
+ ret
+
+.ende:
+.size asin,.ende-asin
+.size asinf,.ende-asinf
+.size asinl,.ende-asinl
diff --git a/mdk-stage1/dietlibc/i386/asinh.S b/mdk-stage1/dietlibc/i386/asinh.S
new file mode 100644
index 000000000..8c3964392
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/asinh.S
@@ -0,0 +1,18 @@
+.text
+.global asinh
+.type asinh,@function
+
+asinh:
+ fldln2
+ fldl 4(%esp)
+ fld %st(0)
+ fmul %st(0),%st(0)
+ fld1
+ faddp %st(0),%st(1)
+ fsqrt
+ faddp %st(0),%st(1)
+ fyl2x
+ ret
+
+.Lende:
+ .size asinh,.Lende-asinh
diff --git a/mdk-stage1/dietlibc/i386/atan.S b/mdk-stage1/dietlibc/i386/atan.S
new file mode 100644
index 000000000..76513f928
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/atan.S
@@ -0,0 +1,27 @@
+
+.text
+
+.global atanf,atan,atanl
+ .type atanf,@function
+ .type atan,@function
+ .type atanl,@function
+atanf:
+ flds 4(%esp)
+ fld1
+ fpatan
+ ret
+atan:
+ fldl 4(%esp)
+ fld1
+ fpatan
+ ret
+atanl:
+ fldt 4(%esp)
+ fld1
+ fpatan
+ ret
+
+.ende:
+.size atan,.ende-atan
+.size atanf,.ende-atanf
+.size atanl,.ende-atanl
diff --git a/mdk-stage1/dietlibc/i386/atan2.S b/mdk-stage1/dietlibc/i386/atan2.S
new file mode 100644
index 000000000..acf6e03ae
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/atan2.S
@@ -0,0 +1,12 @@
+
+.text
+.type atan2,@function
+.global atan2
+atan2:
+ fldl 4(%esp)
+ fldl 12(%esp)
+ fpatan
+ ret
+
+.ende:
+.size atan2,.ende-atan2
diff --git a/mdk-stage1/dietlibc/i386/atanh.S b/mdk-stage1/dietlibc/i386/atanh.S
new file mode 100644
index 000000000..b75f0fa8e
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/atanh.S
@@ -0,0 +1,19 @@
+.text
+.global atanh
+.type atanh,@function
+
+atanh:
+ fldln2
+ fldl 4(%esp)
+ fld1
+ fld %st(1)
+ fadd %st(1),%st(0)
+ fxch %st(1)
+ fsubp %st(0),%st(2)
+ fdivp %st(0),%st(1)
+ fyl2x
+ fmuls __half
+ ret
+
+.Lende:
+ .size atanh,.Lende-atanh
diff --git a/mdk-stage1/dietlibc/i386/atol.S b/mdk-stage1/dietlibc/i386/atol.S
new file mode 100644
index 000000000..5bd7f2c24
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/atol.S
@@ -0,0 +1,55 @@
+/*
+ Copyright (C) 2001, 2002 Thomas M. Ogrisegg
+
+ This is free software. You can redistribute and
+ modify it under the terms of the GNU General Public
+ Public License.
+
+ atol.S
+ i386 assembler implementation of atoi(3) & atol(3)
+*/
+
+.text
+.globl atoi
+.globl atol
+.type atoi,@function
+.type atol,@function
+
+atoi:
+atol:
+ pushl %esi
+ movl 0x8(%esp), %esi
+ xorl %eax, %eax
+ xorl %edx, %edx
+ xorb %cl, %cl
+.LSpace:
+ lodsb
+ cmpb $0x21, %al
+ jng .LSpace
+ cmpb $'+', %al
+ jz .Lfe5
+ cmpb $'-', %al
+ jnz .Lfe3
+ inc %cl
+ jmp .Lfe5
+.Lfe2:
+ imul $0xa, %edx
+ addl %eax, %edx
+.Lfe5:
+ lodsb
+.Lfe3:
+ cmpb $47, %al
+ jng .Lout
+ subb $('0'), %al
+ cmpb $9, %al
+ jng .Lfe2
+.Lout:
+ movl %edx, %eax
+ or %cl, %cl
+ jz .Lreturn
+ negl %eax
+.Lreturn:
+ popl %esi
+ ret
+.size atoi, . - atoi
+.size atol, . - atol
diff --git a/mdk-stage1/dietlibc/i386/atoll.S b/mdk-stage1/dietlibc/i386/atoll.S
new file mode 100644
index 000000000..093bf762a
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/atoll.S
@@ -0,0 +1,64 @@
+
+.text
+.type atoll,@function
+.global atoll
+
+atoll:
+ movl 4(%esp),%ecx
+ push %edi
+
+ xorl %edi,%edi # sign = 0
+
+ decl %ecx
+.Lspaces:
+ incl %ecx # while ( isspace(*p) ) p++;
+ movb (%ecx),%al
+ cmpb $' ',%al
+ je .Lspaces
+ subb $9,%al
+ cmpb $5,%al
+ jc .Lspaces # c = *p - 9;
+
+ cmpb $'+'-9,%al # if ( c == '+' - 9 ) p++;
+ je .Lpos
+ cmpb $'-'-9,%al # else if ( c == '-' - 9 ) sign = -sign, p++;
+ jne .Lnosign
+ decl %edi
+.Lpos: incl %ecx
+.Lnosign:
+
+ push %ebx
+ push %esi
+ push %ebp
+ movl $10,%ebp
+
+ xorl %esi,%esi # Hi(value) = 0;
+ xorl %eax,%eax # Lo(value) = 0;
+.Lcont: movzbl (%ecx),%ebx # while ( (unsigned) (*p - '0') < 10 )
+ inc %ecx
+ subl $'0',%ebx
+ cmpl %ebp,%ebx
+ jnc .Lfini
+ imull %ebp,%esi # value *= 10,
+ mull %ebp
+ addl %edx,%esi
+ addl %ebx,%eax # value += (*p - '0');
+ adcl $0,%esi
+ jmp .Lcont
+
+.Lfini: xchg %edx,%esi # return sign== 0 ? +value
+ xorl %edi,%eax # sign==-1 ? -value
+ xorl %edi,%edx
+ subl %edi,%eax
+ sbbl %edi,%edx
+
+ pop %ebp
+ pop %esi
+ pop %ebx
+ pop %edi
+ ret
+
+.Lende:
+
+.size atoll,.Lende-atoll
+
diff --git a/mdk-stage1/dietlibc/i386/bind.S b/mdk-stage1/dietlibc/i386/bind.S
new file mode 100644
index 000000000..caff9bb8b
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/bind.S
@@ -0,0 +1,4 @@
+#include <linuxnet.h>
+#include <syscalls.h>
+
+__socketcall(bind,BIND)
diff --git a/mdk-stage1/dietlibc/i386/cbrt.S b/mdk-stage1/dietlibc/i386/cbrt.S
new file mode 100644
index 000000000..9d8aebd1e
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/cbrt.S
@@ -0,0 +1,46 @@
+.text
+
+tab: .byte 0, 0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4
+ .byte 4, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9
+ .byte 10,10,11,11,12,12,12,13,13,14,14,14,15,15,15,16
+
+_3: .long 0x40400000
+
+
+.global cbrt
+cbrt:
+ fldl 4(%esp)
+ movw 10(%esp),%ax
+ movb %ah,%ch
+ andw $0x7FFF,%ax
+ jz zero /* cbrt(0) = 0 */
+ pushl %ebx
+ cwd
+ movl $16*3,%ebx /* AX 3FE0 3FF0 4000 4010 */
+ divw %bx /* AX 154 155 155 155 */
+ /* DX 20 0 10 20 */
+ shlw $5,%ax
+ addb %ch,%ch
+ rcrw %ax /* AX 1540 1550 1550 1550 */
+ addw $0x3FF0-0x1550,%ax /* AX 3FE0 3FF0 3FF0 3FF0 */
+ movw %dx,%bx
+ addb tab(%ebx),%al
+ adcb $0,%ah
+ popl %ebx
+ movw %ax,10(%esp)
+ fldl 4(%esp) /* y x */
+
+ movl $4,%ecx
+lop:
+ fld %st(0) /* y y x */
+ fmul %st(0),%st(0) /* y^2 y x */
+ fdivr %st(2),%st(0) /* x/y^2 y x */
+ fadd %st(1),%st(0) /* x/y^2+y y x */
+ faddp /* x/y^2+2y x */
+ fdivs _3 /* y' x */
+ loop lop
+
+ fstp %st(1) /* y' */
+zero:
+ ret
+
diff --git a/mdk-stage1/dietlibc/i386/ceil.S b/mdk-stage1/dietlibc/i386/ceil.S
new file mode 100644
index 000000000..e6a4e989c
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/ceil.S
@@ -0,0 +1,44 @@
+.text
+
+.global ceilf,ceil,ceill,__flcetr
+ .type ceilf,@function
+ .type ceil,@function
+ .type ceill,@function
+ .type __flcetr,@function
+
+ceilf:
+ flds 4(%esp)
+ movb $0x08,%ah
+ jmp __flcetr
+
+ceill:
+ fldt 4(%esp)
+ movb $0x08,%ah
+ jmp __flcetr
+
+ceil:
+ fldl 4(%esp)
+ movb $0x08,%ah
+
+# Wspolny kod dla funkcji floor, ceil i trunc
+# W ah maska bitow 11 i 10 rejestru sterowania koprocesora
+__flcetr:
+ xorl %ecx,%ecx # wyzerowanie rejestru
+ movb %ah,%ch # i utworzenie maski w cx
+ pushl %eax # krotsze niz subl $4,%esp
+ fstcw (%esp)
+ movw (%esp),%ax
+ andb $0x03,%ah # wyzerowanie bitow 11 i 10
+ orl %ecx,%eax # ustawienie bitow z maski
+ movw %ax,2(%esp)
+ fldcw 2(%esp)
+ frndint
+ fldcw (%esp) # odtworzenie rejestru sterowania
+ popl %eax # i polozenia stosu
+ ret
+
+.Lende:
+.size ceil,.Lende-ceil
+.size ceill,.Lende-ceill
+.size ceilf,.Lende-ceilf
+.size flcetr,.Lende-__flcetr
diff --git a/mdk-stage1/dietlibc/i386/connect.S b/mdk-stage1/dietlibc/i386/connect.S
new file mode 100644
index 000000000..a295a8814
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/connect.S
@@ -0,0 +1,4 @@
+#include <linuxnet.h>
+#include <syscalls.h>
+
+__socketcall(connect,CONNECT)
diff --git a/mdk-stage1/dietlibc/i386/copysign.S b/mdk-stage1/dietlibc/i386/copysign.S
new file mode 100644
index 000000000..3a495efee
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/copysign.S
@@ -0,0 +1,18 @@
+
+.text
+.type copysign,@function
+.global copysign
+
+# double copysign ( double value, double sign );
+
+copysign:
+ movb 12+7(%esp),%al
+ movb 4+7(%esp),%ah
+ andw $0x7F80,%ax
+ orb %ah,%al
+ movb 4+7(%esp),%al
+ fldl 4(%esp)
+ ret
+
+.ende:
+.size copysign,.ende-copysign
diff --git a/mdk-stage1/dietlibc/i386/cos.S b/mdk-stage1/dietlibc/i386/cos.S
new file mode 100644
index 000000000..f95c81ca7
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/cos.S
@@ -0,0 +1,35 @@
+.text
+
+.global cosf,cos,cosl
+.type cosf,@function
+.type cos,@function
+.type cosl,@function
+
+cosf:
+ flds 4(%esp)
+ jmp 1f
+cos:
+ fldl 4(%esp)
+1:
+ fcos
+ fnstsw %ax
+ testb $0x04, %ah
+ je 3f
+ fldpi
+ fadd %st
+ fxch %st(1)
+2: fprem1
+ fnstsw %ax
+ testb $0x04, %ah
+ jne 2b
+ fstp %st(1)
+ fcos
+3: ret
+cosl:
+ fldt 4(%esp)
+ jmp 1b
+
+.Lende:
+.size cos,.Lende-cos
+.size cosl,.Lende-cosl
+.size cosf,.Lende-cosf
diff --git a/mdk-stage1/dietlibc/i386/cosh.S b/mdk-stage1/dietlibc/i386/cosh.S
new file mode 100644
index 000000000..f6a33704d
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/cosh.S
@@ -0,0 +1,29 @@
+
+.text
+.type cosh,@function
+.global cosh
+
+cosh: # note: exp(x) = 2^(x*log2(e))
+ fldl2e
+ fmull 4(%esp) # x*log2(e)
+ fld %st(0) # x*log2(e) x*log2(e)
+ frndint # int(x*log2(e)) x*log2(e)
+ fxch # x*log2(e) int(x*log2(e))
+ fsub %st(1),%st(0) # frac(x*log2(e)) int(x*log2(e))
+ f2xm1 # 2^(fract(x*log2(e)))-1 int(x*log2(e))
+ fld1 # 1 2^(fract(x*log2(e)))-1 int(x*log2(e))
+ faddp %st(0),%st(1) # 2^(fract(x*log2(e))) int(x*log2(e))
+ fscale # 2^(x*log2(e)) int(x*log2(e))
+ fstp %st(1) # 2^(x*log2(e))
+
+# now we have y = exp(x), but cosh(x) = (y + 1/y) * 0.5
+
+ fld1
+ fdiv %st(1),%st(0)
+ faddp
+ fmuls __half
+ ret
+
+.Lende:
+
+.size cosh,.ende-cosh
diff --git a/mdk-stage1/dietlibc/i386/dyn_syscalls.S b/mdk-stage1/dietlibc/i386/dyn_syscalls.S
new file mode 100644
index 000000000..c4fd2fff5
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/dyn_syscalls.S
@@ -0,0 +1,282 @@
+/*
+ * dynamic unified-syscalls
+ * Olaf Dreesen
+ */
+
+#include "../syscalls.s/environ.S"
+#include "../syscalls.s/errno.S"
+
+#include <dietfeatures.h>
+#include "syscalls.h"
+#include "PIC.h"
+
+/* ok now include all syscalls.s (*.S) and sysdep *.S */
+
+#include "mmap.S"
+
+/* here on i386 I had split them some pre- some post-unified-syscall,
+ * because the jumps pre-u.s.c. have only a 1 byte displacement. the first
+ * post-u.s.c. have also 1 byte dsplacement the rest a 4 byte.
+ * this pre/post split saves about 250 byte of code ....
+ *
+ * Please put additional syscalls AFTER the post-u.s.c.
+ * or try to not break the savings :) */
+
+#include "select.S"
+
+#include "../syscalls.s/fork.S"
+#include "../syscalls.s/read.S"
+#include "../syscalls.s/write.S"
+#include "../syscalls.s/open.S"
+#include "../syscalls.s/close.S"
+#include "../syscalls.s/waitpid.S"
+
+#include "../syscalls.s/getgid.S"
+#include "../syscalls.s/getpgid.S"
+#include "../syscalls.s/getpid.S"
+#include "../syscalls.s/getppid.S"
+#include "../syscalls.s/getuid.S"
+#include "../syscalls.s/kill.S"
+#include "../syscalls.s/ioctl.S"
+#include "../syscalls.s/_llseek.S"
+#include "../syscalls.s/lseek.S"
+#include "../syscalls.s/lstat.S"
+#include "../syscalls.s/lstat64.S"
+#include "../syscalls.s/mkdir.S"
+#include "../syscalls.s/mprotect.S"
+#include "../syscalls.s/nanosleep.S"
+#include "../syscalls.s/pipe.S"
+#include "../syscalls.s/poll.S"
+#include "../syscalls.s/readv.S"
+#include "../syscalls.s/stat.S"
+#include "../syscalls.s/stat64.S"
+#include "../syscalls.s/truncate.S"
+#include "../syscalls.s/umask.S"
+#include "../syscalls.s/wait4.S"
+#include "../syscalls.s/writev.S"
+#include "../syscalls.s/__getpagesize.S"
+
+/* OK this is basicaly unified.S */
+.text
+.type __unified_syscall_256,@function
+__unified_syscall_256:
+ movzwl %ax, %eax
+ jmp .L23
+.L22:
+.size __unified_syscall_256,.L22-__unified_syscall_256
+.type exit,@function
+.weak exit
+exit:
+.type _exit,@function
+.global _exit
+_exit:
+__exit:
+ mov $__NR_exit, %al
+__unified_syscall:
+ movzbl %al, %eax
+.L23:
+ push %edi
+ push %esi
+ push %ebx
+ movl %esp,%edi
+ movl 0x10(%edi),%ebx
+ movl 0x14(%edi),%ecx
+ movl 0x18(%edi),%edx
+ movl 0x1c(%edi),%esi
+ movl 0x20(%edi),%edi
+ int $0x80
+ cmp $-124,%eax
+ jbe .Lnoerror
+ neg %eax
+
+ /* PIC-code Ohhhhh My. */
+ push %eax
+ PIC_INIT
+ call __errno_location@PLT
+ popl %ebx
+ movl %ebx,(%eax)
+ orl $-1,%eax
+.Lnoerror:
+ pop %ebx
+ pop %esi
+ pop %edi
+#include "dietuglyweaks.h"
+ ret
+
+#include "../syscalls.s/__pread.S"
+#include "../syscalls.s/__pwrite.S"
+#include "../syscalls.s/__reboot.S"
+#include "../syscalls.s/access.S"
+#include "../syscalls.s/adjtimex.S"
+#include "../syscalls.s/brk.S"
+#include "../syscalls.s/chdir.S"
+#include "../syscalls.s/chmod.S"
+#include "../syscalls.s/chown.S"
+#include "../syscalls.s/chroot.S"
+#include "../syscalls.s/dup.S"
+#include "../syscalls.s/dup2.S"
+#include "../syscalls.s/execve.S"
+#include "../syscalls.s/fchdir.S"
+#include "../syscalls.s/fchmod.S"
+#include "../syscalls.s/fchown.S"
+#include "../syscalls.s/fcntl.S"
+#include "../syscalls.s/flock.S"
+#include "../syscalls.s/fstat.S"
+#include "../syscalls.s/fstat64.S"
+#include "../syscalls.s/fstatfs.S"
+#include "../syscalls.s/fsync.S"
+#include "../syscalls.s/fdatasync.S"
+#include "../syscalls.s/ftruncate.S"
+#include "../syscalls.s/getcwd.S"
+#include "../syscalls.s/getdents.S"
+#include "../syscalls.s/getdents64.S"
+#include "../syscalls.s/getegid.S"
+#include "../syscalls.s/geteuid.S"
+#include "../syscalls.s/getgroups.S"
+#include "../syscalls.s/getitimer.S"
+#include "../syscalls.s/getpriority.S"
+#include "../syscalls.s/getresgid.S"
+#include "../syscalls.s/getresuid.S"
+#include "../syscalls.s/getrlimit.S"
+#include "../syscalls.s/getrusage.S"
+#include "../syscalls.s/getsid.S"
+#include "../syscalls.s/gettimeofday.S"
+#include "../syscalls.s/ioperm.S"
+#include "../syscalls.s/iopl.S"
+#include "../syscalls.s/ipc.S"
+#include "../syscalls.s/lchown.S"
+#include "../syscalls.s/link.S"
+#include "../syscalls.s/mknod.S"
+#include "../syscalls.s/mlock.S"
+#include "../syscalls.s/mlockall.S"
+#include "../syscalls.s/mount.S"
+#include "../syscalls.s/mremap.S"
+#include "../syscalls.s/munlockall.S"
+#include "../syscalls.s/munmap.S"
+#include "../syscalls.s/n_sigaction.S"
+#include "../syscalls.s/n_sigpending.S"
+#include "../syscalls.s/n_sigprocmask.S"
+#include "../syscalls.s/n_sigsuspend.S"
+#include "../syscalls.s/nice.S"
+#include "../syscalls.s/pause.S"
+#include "../syscalls.s/personality.S"
+#include "../syscalls.s/query_module.S"
+#include "../syscalls.s/init_module.S"
+#include "../syscalls.s/delete_module.S"
+#include "../syscalls.s/create_module.S"
+#include "../syscalls.s/readlink.S"
+#include "../syscalls.s/rename.S"
+#include "../syscalls.s/rmdir.S"
+#include "../syscalls.s/rt_sigaction.S"
+#include "../syscalls.s/rt_sigpending.S"
+#include "../syscalls.s/rt_sigprocmask.S"
+#include "../syscalls.s/rt_sigqueueinfo.S"
+#include "../syscalls.s/rt_sigsuspend.S"
+#include "../syscalls.s/rt_sigtimedwait.S"
+#include "../syscalls.s/sched_get_priority_max.S"
+#include "../syscalls.s/sched_get_priority_min.S"
+#include "../syscalls.s/sched_getparam.S"
+#include "../syscalls.s/sched_getscheduler.S"
+#include "../syscalls.s/sched_rr_get_interval.S"
+#include "../syscalls.s/sched_setparam.S"
+#include "../syscalls.s/sched_setscheduler.S"
+#include "../syscalls.s/sched_yield.S"
+#include "../syscalls.s/sendfile.S"
+#include "../syscalls.s/setdomainname.S"
+#include "../syscalls.s/setfsgid.S"
+#include "../syscalls.s/setfsuid.S"
+#include "../syscalls.s/setgid.S"
+#include "../syscalls.s/setgroups.S"
+#include "../syscalls.s/sethostname.S"
+#include "../syscalls.s/setitimer.S"
+#include "../syscalls.s/setpgid.S"
+#include "../syscalls.s/setpriority.S"
+#include "../syscalls.s/setregid.S"
+#include "../syscalls.s/setresgid.S"
+#include "../syscalls.s/setresuid.S"
+#include "../syscalls.s/setreuid.S"
+#include "../syscalls.s/setrlimit.S"
+#include "../syscalls.s/setsid.S"
+#include "../syscalls.s/setuid.S"
+#include "../syscalls.s/sigaltstack.S"
+#include "../syscalls.s/statfs.S"
+#include "../syscalls.s/stime.S"
+#include "../syscalls.s/swapoff.S"
+#include "../syscalls.s/swapon.S"
+#include "../syscalls.s/symlink.S"
+#include "../syscalls.s/sync.S"
+#include "../syscalls.s/sysctl.S"
+#include "../syscalls.s/sysinfo.S"
+#include "../syscalls.s/syslog.S"
+#include "../syscalls.s/time.S"
+#include "../syscalls.s/times.S"
+#include "../syscalls.s/umount.S"
+#include "../syscalls.s/umount2.S"
+#include "../syscalls.s/uname.S"
+#include "../syscalls.s/unlink.S"
+#include "../syscalls.s/utime.S"
+#include "../syscalls.s/vhangup.S"
+
+#include "../syscalls.s/chown32.S"
+#include "../syscalls.s/fchown32.S"
+#include "../syscalls.s/getegid32.S"
+#include "../syscalls.s/geteuid32.S"
+#include "../syscalls.s/getgid32.S"
+#include "../syscalls.s/getgroups32.S"
+#include "../syscalls.s/getresgid32.S"
+#include "../syscalls.s/getuid32.S"
+#include "../syscalls.s/lchown32.S"
+#include "../syscalls.s/setfsgid32.S"
+#include "../syscalls.s/setfsuid32.S"
+#include "../syscalls.s/setgid32.S"
+#include "../syscalls.s/setregid32.S"
+#include "../syscalls.s/setresgid32.S"
+#include "../syscalls.s/setreuid32.S"
+#include "../syscalls.s/setuid32.S"
+#include "../syscalls.s/alarm.S"
+#include "../syscalls.s/ptrace.S"
+#include "../syscalls.s/truncate64.S"
+#include "../syscalls.s/ftruncate64.S"
+#include "../syscalls.s/epoll_create.S"
+#include "../syscalls.s/epoll_ctl.S"
+#include "../syscalls.s/epoll_wait.S"
+
+#undef __PIC__
+#undef __socketcall
+/* oh what a kludge! */
+#define socketcall .Lsocketcall
+#include "../i386/send.S"
+#include "../i386/recv.S"
+#include "../i386/socket.S"
+#include "../i386/accept.S"
+#include "../i386/shutdown.S"
+#include "../i386/socketpair.S"
+#include "../i386/setsockopt.S"
+#include "../i386/sendto.S"
+#include "../i386/sendmsg.S"
+#include "../i386/recvmsg.S"
+#include "../i386/recvfrom.S"
+#include "../i386/listen.S"
+#include "../i386/getsockopt.S"
+#include "../i386/getsockname.S"
+#include "../i386/getpeername.S"
+#include "../i386/connect.S"
+#include "../i386/bind.S"
+#undef socketcall
+.Lsocketcall:
+#include "../i386/socketcall.S"
+#define __PIC__
+#undef __socketcall
+
+
+/* so now this was the last u.s.c. */
+
+/* other asm-files ... */
+#define PIC
+
+#define _exit __exit
+#include "clone.S"
+#undef _exit
+
+#include "__longjmp.S"
+#include "setjmp.S"
diff --git a/mdk-stage1/dietlibc/i386/exp.S b/mdk-stage1/dietlibc/i386/exp.S
new file mode 100644
index 000000000..6c82128e4
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/exp.S
@@ -0,0 +1,35 @@
+.text
+
+.global expf,exp,expl,__finexp
+ .type expf,@function
+ .type exp,@function
+ .type expl,@function
+ .type __finexp,@function
+expf:
+ fldl2e
+ fmuls 4(%esp)
+ jmp __finexp
+expl:
+ fldl2e
+ fldt 4(%esp)
+ fmulp
+ jmp __finexp
+exp:
+ fldl2e
+ fmull 4(%esp)
+__finexp:
+ fst %st(1)
+ frndint
+ fst %st(2)
+ fsubrp
+ f2xm1
+ fld1
+ faddp
+ fscale
+ ret
+
+.Lende:
+.size exp,.Lende-exp
+.size expl,.Lende-expl
+.size expf,.Lende-expf
+.size __finexp,.Lende-__finexp
diff --git a/mdk-stage1/dietlibc/i386/exp10.S b/mdk-stage1/dietlibc/i386/exp10.S
new file mode 100644
index 000000000..6223e5f85
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/exp10.S
@@ -0,0 +1,27 @@
+
+.text
+.type exp10,@function
+.global exp10
+.type pow10,@function
+.global pow10
+
+
+pow10:
+exp10: # note: 10^(x) = 2^(x*log2(10))
+ fldl2t
+ fmull 4(%esp) # x*log2(10)
+ fld %st(0) # x*log2(10) x*log2(10)
+ frndint # int(x*log2(10)) x*log2(10)
+ fxch # x*log2(10) int(x*log2(10))
+ fsub %st(1),%st(0) # frac(x*log2(10)) int(x*log2(10))
+ f2xm1 # 2^(fract(x*log2(10)))-1 int(x*log2(10))
+ fld1 # 1 2^(fract(x*log2(10)))-1 int(x*log2(10))
+ faddp %st(0),%st(1) # 2^(fract(x*log2(10))) int(x*log2(10))
+ fscale # 2^(x*log2(10)) int(x*log2(10))
+ fstp %st(1) # 2^(x*log2(10))
+ ret
+
+.ende:
+
+.size exp10,.ende-exp10
+.size pow10,.ende-pow10
diff --git a/mdk-stage1/dietlibc/i386/exp2.S b/mdk-stage1/dietlibc/i386/exp2.S
new file mode 100644
index 000000000..d5389a22e
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/exp2.S
@@ -0,0 +1,18 @@
+.text
+.type exp2,@function
+.global exp2
+exp2: # note: exp2(x) = 2^x
+ fldl 4(%esp) # x
+ fld %st(0) # x x
+ frndint # int(x) x
+ fxch # x int(x)
+ fsub %st(1),%st(0) # frac(x) int(x)
+ f2xm1 # 2^(fract(x))-1 int(x)
+ fld1 # 1 2^(fract(x))-1 int(x)
+ faddp %st(0),%st(1) # 2^(fract(x)) int(x)
+ fscale # 2^x int(x)
+ fstp %st(1) # 2^x
+ ret
+
+.ende:
+.size exp2,.ende-exp2
diff --git a/mdk-stage1/dietlibc/i386/expm1.S b/mdk-stage1/dietlibc/i386/expm1.S
new file mode 100644
index 000000000..677f4723f
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/expm1.S
@@ -0,0 +1,23 @@
+.text
+.type expm1,@function
+.global expm1
+expm1: # note: exp(x) = 2^(x*log2(e))
+ fldl2e
+ fmull 4(%esp) # x*log2(e)
+ fld %st(0) # x*log2(e) x*log2(e)
+ frndint # int(x*log2(e)) x*log2(e)
+ fxch # x*log2(e) int(x*log2(e))
+ fsub %st(1),%st(0) # frac(x*log2(e)) int(x*log2(e))
+ f2xm1 # 2^(fract(x*log2(e)))-1 int(x*log2(e))
+ fscale # 2^(x*log2(e))-2^int(x*log2(e)) int(x*log2(e))
+ fxch # int(x*log2(e)) 2^(x*log2(e))-2^int(x*log2(e))
+ fld1 # 1 int(x*log2(e)) 2^(x*log2(e))-2^int(x*log2(e))
+ fscale # 2^int(x*log2(e)) int(x*log2(e)) 2^(x*log2(e))-2^int(x*log2(e))
+ fstp %st(1) # 2^int(x*log2(e)) 2^(x*log2(e))-2^int(x*log2(e))
+ fld1 # 1 2^int(x*log2(e)) 2^(x*log2(e))-2^int(x*log2(e))
+ fsubrp %st(1) # 2^int(x*log2(e))-1 2^(x*log2(e))-2^int(x*log2(e))
+ faddp %st(1)
+ ret
+
+.ende:
+.size expm1,.ende-expm1
diff --git a/mdk-stage1/dietlibc/i386/fabs.S b/mdk-stage1/dietlibc/i386/fabs.S
new file mode 100644
index 000000000..d9c1c2212
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/fabs.S
@@ -0,0 +1,11 @@
+
+.text
+.type fabs,@function
+.global fabs
+fabs:
+ fldl 4(%esp)
+ fabs
+ ret
+
+.ende:
+.size fabs,.ende-fabs
diff --git a/mdk-stage1/dietlibc/i386/floor.S b/mdk-stage1/dietlibc/i386/floor.S
new file mode 100644
index 000000000..af26d0c94
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/floor.S
@@ -0,0 +1,26 @@
+.text
+
+.global floorf,floor,floorl
+ .type floorf,@function
+ .type floor,@function
+ .type floorf,@function
+
+floorf:
+ flds 4(%esp)
+ movb $0x04,%ah
+ jmp __flcetr
+
+floor:
+ fldl 4(%esp)
+ movb $0x04,%ah
+ jmp __flcetr
+
+floorl:
+ fldt 4(%esp)
+ movb $0x04,%ah
+ jmp __flcetr
+
+.Lende:
+.size floor,.Lende-floor
+.size floorl,.Lende-floorl
+.size floorf,.Lende-floorf
diff --git a/mdk-stage1/dietlibc/i386/fmod.S b/mdk-stage1/dietlibc/i386/fmod.S
new file mode 100644
index 000000000..5bf4c06ab
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/fmod.S
@@ -0,0 +1,37 @@
+.text
+.type fmod,@function
+.type fmodf,@function
+.type fmodl,@function
+.type __fmod2pi,@function
+.global fmod, fmodl, fmodf, __fmod2pi
+
+__fmod2pi:
+ fldpi
+ fadd %st(0)
+ fxch
+ jmp .Lfmod
+
+fmodf:
+ flds 8(%esp) # y
+ flds 4(%esp) # x
+ jmp .Lfmod
+fmod:
+ fldl 12(%esp)
+ fldl 4(%esp)
+.Lfmod:
+ fprem
+ fstsw %ax
+ sahf
+ jp .Lfmod
+ ret
+
+fmodl:
+ fldt 16(%esp)
+ fldt 4(%esp)
+ jmp .Lfmod
+
+
+.ende:
+.size fmod,.ende-fmod
+.size fmodl,.ende-fmodl
+.size fmodf,.ende-fmodf
diff --git a/mdk-stage1/dietlibc/i386/getenv.S b/mdk-stage1/dietlibc/i386/getenv.S
new file mode 100644
index 000000000..dafbf37ee
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/getenv.S
@@ -0,0 +1,48 @@
+#include "PIC.h"
+
+.text
+.global getenv
+.type getenv,@function
+getenv:
+ pushl %esi
+ pushl %edi
+ movl 0xc(%esp), %edi
+ cld
+ movl %edi, %edx
+ xorl %eax, %eax
+ leal -1(%eax), %ecx
+ repnz scasb
+ not %ecx
+ dec %ecx
+ pushl %ecx
+ movl (%edx), %ecx
+
+ GET_1VAR environ, %esi # non-PIC: movl environ, %esi
+ jmp .Lloop
+
+.Lprepare:
+ movl (%edx), %ecx
+ movl %eax, %esi
+.Lloop:
+ lodsl
+ or %eax, %eax
+ jz .Lout
+ cmpb %cl, (%eax)
+ jnz .Lloop
+
+ movl %edx, %edi
+ xchg %esi, %eax
+ movl (%esp), %ecx
+ repz cmpsb
+ jne .Lprepare
+ or %ecx, %ecx
+ jnz .Lprepare
+ cmpb $'=', (%esi)
+ jne .Lprepare
+ leal 0x1(%esi), %eax
+.Lout:
+ popl %ecx
+ popl %edi
+ popl %esi
+ ret
+.size getenv, . - getenv
diff --git a/mdk-stage1/dietlibc/i386/getpeername.S b/mdk-stage1/dietlibc/i386/getpeername.S
new file mode 100644
index 000000000..833322941
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/getpeername.S
@@ -0,0 +1,4 @@
+#include <linuxnet.h>
+#include <syscalls.h>
+
+__socketcall(getpeername,GETPEERNAME)
diff --git a/mdk-stage1/dietlibc/i386/getsockname.S b/mdk-stage1/dietlibc/i386/getsockname.S
new file mode 100644
index 000000000..f0618481c
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/getsockname.S
@@ -0,0 +1,4 @@
+#include <linuxnet.h>
+#include <syscalls.h>
+
+__socketcall(getsockname,GETSOCKNAME)
diff --git a/mdk-stage1/dietlibc/i386/getsockopt.S b/mdk-stage1/dietlibc/i386/getsockopt.S
new file mode 100644
index 000000000..23d7c2470
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/getsockopt.S
@@ -0,0 +1,4 @@
+#include <linuxnet.h>
+#include <syscalls.h>
+
+__socketcall(getsockopt,GETSOCKOPT)
diff --git a/mdk-stage1/dietlibc/i386/htonl.S b/mdk-stage1/dietlibc/i386/htonl.S
new file mode 100644
index 000000000..f3732d16a
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/htonl.S
@@ -0,0 +1,13 @@
+.text
+.global htonl
+.type htonl,@function
+.global ntohl
+.type ntohl,@function
+
+htonl:
+ntohl:
+ movl 4(%esp),%eax
+ xchgb %al,%ah
+ rorl $16,%eax
+ xchgb %al,%ah
+ ret
diff --git a/mdk-stage1/dietlibc/i386/htons.S b/mdk-stage1/dietlibc/i386/htons.S
new file mode 100644
index 000000000..367d6d03c
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/htons.S
@@ -0,0 +1,11 @@
+.text
+.global htons
+.type htons,@function
+.global ntohs
+.type ntohs,@function
+
+htons:
+ntohs:
+ movzwl 4(%esp),%eax
+ xchgb %al,%ah
+ ret
diff --git a/mdk-stage1/dietlibc/i386/hypot.S b/mdk-stage1/dietlibc/i386/hypot.S
new file mode 100644
index 000000000..730b2c5c9
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/hypot.S
@@ -0,0 +1,15 @@
+
+.text
+.type hypot,@function
+.global hypot
+hypot:
+ fldl 4(%esp)
+ fmul %st(0),%st(0)
+ fldl 12(%esp)
+ fmul %st(0),%st(0)
+ faddp
+ fsqrt
+ ret
+
+.ende:
+.size hypot,.ende-hypot
diff --git a/mdk-stage1/dietlibc/i386/ilogb.S b/mdk-stage1/dietlibc/i386/ilogb.S
new file mode 100644
index 000000000..3bebd88ba
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/ilogb.S
@@ -0,0 +1,23 @@
+#
+# int ilogb ( double x );
+#
+# returns (int) log2 (fabs(x)) for x!=0
+# returns MIN_INT for x==0
+#
+
+.text
+.global ilogb
+.type ilogb,@function
+
+ilogb:
+ movl 8(%esp),%eax
+ addl %eax,%eax
+ jz .Lzero
+ shrl $21,%eax
+ subl $1023,%eax
+ ret
+
+.Lzero:
+ stc
+ rcrl %eax
+ ret
diff --git a/mdk-stage1/dietlibc/i386/ipow.S b/mdk-stage1/dietlibc/i386/ipow.S
new file mode 100644
index 000000000..cca6a0ce1
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/ipow.S
@@ -0,0 +1,27 @@
+#
+# This is not standard, but often you only need such this function
+# which is much shorter than the generic pow() function.
+#
+# double ipow ( double mant, int expo );
+#
+
+.text
+.global ipow
+.type ipow,@function
+
+ipow: fld1
+ movl 12(%esp),%ecx
+ fldl 4(%esp)
+ and %ecx,%ecx
+ jns .Lstart
+ negl %ecx
+ fdivr %st(1),%st(0)
+ jmp .Lstart
+
+.Lnext: fmul %st(0),%st(0)
+.Lstart:shrl %ecx
+ jnc .Lnomul
+ fmul %st(0),%st(1)
+.Lnomul:jnz .Lnext
+ fcomp
+ ret
diff --git a/mdk-stage1/dietlibc/i386/isleap.S b/mdk-stage1/dietlibc/i386/isleap.S
new file mode 100644
index 000000000..28d1ee0ce
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/isleap.S
@@ -0,0 +1,28 @@
+.text
+.globl __isleap
+.type __isleap,@function
+
+__isleap:
+ movl 4(%esp),%eax
+ testb $3,%al
+ jne .Lretzero
+#if 1
+ movb $100,%cl /* this works only for 0 a.D. ... 25599 a.C. */
+ divb %cl
+ andb %ah,%ah
+#else
+ cltd /* This works for 2147483648 b.C. ... 2147483647 a.C. */
+ movl $100,%ecx
+ divl %ecx
+ andl %edx,%edx
+#endif
+ jne .Lretone
+ testb $3,%al
+ jne .Lretzero
+.Lretone: xorl %eax,%eax
+ incl %eax
+ ret
+
+.Lretzero:xorl %eax,%eax
+ ret
+
diff --git a/mdk-stage1/dietlibc/i386/ldexp.S b/mdk-stage1/dietlibc/i386/ldexp.S
new file mode 100644
index 000000000..51d9bae89
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/ldexp.S
@@ -0,0 +1,28 @@
+.text
+.global ldexpf,ldexp,ldexpl
+ .type ldexpf,@function
+ .type ldexp,@function
+ .type ldexpl,@function
+
+ldexpf:
+ fildl 8(%esp)
+ flds 4(%esp)
+ fscale
+ ret
+
+ldexp:
+ fildl 12(%esp)
+ fldl 4(%esp)
+ fscale
+ ret
+
+ldexpl:
+ fildl 16(%esp)
+ fldt 4(%esp)
+ fscale
+ ret
+
+.ende:
+.size ldexpl,.ende-ldexpl
+.size ldexp,ldexpl-ldexp
+.size ldexpf,ldexp-ldexpf
diff --git a/mdk-stage1/dietlibc/i386/libm2.S b/mdk-stage1/dietlibc/i386/libm2.S
new file mode 100644
index 000000000..91c4437cd
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/libm2.S
@@ -0,0 +1,643 @@
+.text
+#d.half:
+# .long 0x3f000000 # 1/2
+#d.log1p:
+# .long 0x3ed413cc # < sqrt(2)-1-2^(-25)
+
+.global fabsf,fabs,fabsl
+ .type fabsf,@function
+ .type fabs,@function
+ .type fabsl,@function
+fabsf:
+ flds 4(%esp)
+ fabs
+ ret
+fabs:
+ fldl 4(%esp)
+ fabs
+ ret
+fabsl:
+ fldt 4(%esp)
+ fabs
+ ret
+
+.global sincosf,sincos,sincosl
+.type sincosf,@function
+.type sincos,@function
+.type sincosl,@function
+# void sincos ( double x, double* sinx, double* cosx );
+
+sincosf:
+ flds 4(%esp)
+ call __fmod2pi
+ movl 12(%esp),%eax
+ movl 8(%esp),%ecx
+ fsincos
+ fstps (%eax)
+ fstps (%ecx)
+ ret
+sincos:
+ fldl 4(%esp)
+ call __fmod2pi
+ movl 16(%esp),%eax
+ movl 12(%esp),%ecx
+ fsincos
+ fstpl (%eax)
+ fstpl (%ecx)
+ ret
+sincosl:
+ fldt 4(%esp)
+ call __fmod2pi
+ movl 20(%esp),%eax
+ movl 16(%esp),%ecx
+ fsincos
+ fstpt (%eax)
+ fstpt (%ecx)
+ ret
+
+.global tanf,tan,tanl
+.type tanf,@function
+.type tan,@function
+.type tanl,@function
+tanf:
+ flds 4(%esp)
+ jmp __tan
+tan:
+ fldl 4(%esp)
+__tan:
+ call __fmod2pi
+ fsincos
+ fdivrp
+ ret
+tanl:
+ fldt 4(%esp)
+ jmp __tan
+
+.global atan2f,atan2,atan2l
+ .type atan2f,@function
+ .type atan2,@function
+ .type atan2l,@function
+atan2f:
+ flds 4(%esp)
+ flds 8(%esp)
+ fpatan
+ ret
+atan2l:
+ fldt 4(%esp)
+ fldt 16(%esp)
+ fpatan
+ ret
+atan2:
+ fldl 4(%esp)
+ fldl 12(%esp)
+ fpatan
+ ret
+
+.global cbrtf,cbrt,cbrtl
+ .type cbrtf,@function
+ .type cbrt,@function
+ .type cbrtl,@function
+cbrtf:
+ flds 4(%esp)
+ jmp __cbrt
+cbrtl:
+ fldt 4(%esp)
+ jmp __cbrt
+cbrt:
+ fldl 4(%esp)
+# fldt 1/3
+__cbrt:
+ pushl $0x00003ffd # yes, this method of loading 1/3
+ pushl $0xaaaaaaaa # is shorter than keeping the data
+ pushl $0xaaaaaaab # separate
+ fldt (%esp)
+ addl $12,%esp
+ fxch # st(0)=x, st(1)=1/3
+ ftst
+ fstsw %ax
+ sahf
+ jz 1f
+ jnc finpow
+ fchs
+ call finpow
+ fchs
+1: ret
+
+# x^y; st(0)=x, st(1)=y (x > 0)
+finpow:
+ fyl2x
+ jmp __finexp
+
+.global exp2f,exp2,exp2l
+ .type exp2f,@function
+ .type exp2,@function
+ .type exp2l,@function
+exp2f:
+ flds 4(%esp)
+ jmp __finexp
+exp2:
+ fldl 4(%esp)
+ jmp __finexp
+exp2l:
+ fldt 4(%esp)
+ jmp __finexp
+
+.global exp10f,exp10,exp10l #,pow10f,pow10,pow10l
+ .type exp10f,@function
+ .type exp10,@function
+ .type exp10l,@function
+# .type pow10f,@function
+# .type pow10,@function
+# .type pow10l,@function
+exp10f:
+#pow10f:
+ fldl2t
+ fmuls 4(%esp)
+ jmp __finexp
+exp10:
+#pow10:
+ fldl2t
+ fmull 4(%esp)
+ jmp __finexp
+exp10l:
+#pow10l:
+ fldl2t
+ fldt 4(%esp)
+ fmulp
+ jmp __finexp
+
+# exp(x)-1
+.global expm1f,expm1,expm1l
+ .type expm1f,@function
+ .type expm1,@function
+ .type expm1l,@function
+expm1f:
+ fldl2e
+ fmuls 4(%esp)
+ jmp finem1
+expm1l:
+ fldl2e
+ fldt 4(%esp)
+ fmulp
+ jmp finem1
+expm1:
+ fldl2e
+ fmull 4(%esp)
+# -1 <= st <= 1 ?
+finem1:
+ fst %st(1) # st(1)=st(0)
+ fabs
+ fld1
+ fcompp
+ fstsw %ax
+ sahf
+# |x| >= 1
+ jc 1f
+ f2xm1
+ ret
+1: call __finexp
+ fld1
+ fsubrp
+ ret
+
+# sinh(x)=(exp(x)-exp(-x))/2
+# cosh(x)=(exp(x)+exp(-x))/2
+# tanh(x)=sinh(x)/cosh(x)
+.global sinhf,sinh,sinhl
+ .type sinhf,@function
+ .type sinh,@function
+ .type sinhl,@function
+sinhf:
+ fldl2e
+ fmuls 4(%esp)
+ jmp finsinh
+sinh:
+ fldl2e
+ fmull 4(%esp)
+finsinh:
+ call __finexp
+ fld1
+ fdiv %st(1),%st(0) # st(0)=1/exp(x), st(1)=exp(x)
+ fsubrp %st(0),%st(1)
+ pushl $0x3f000000 # 1/2
+ flds (%esp)
+ popl %eax
+ fmulp
+ ret
+
+sinhl:
+ fldl2e
+ fldt 4(%esp)
+ fmulp
+ jmp finsinh
+
+.global coshf,cosh,coshl
+ .type coshf,@function
+ .type cosh,@function
+ .type coshl,@function
+coshf:
+ fldl2e
+ fmuls 4(%esp)
+ jmp fincosh
+cosh:
+ fldl2e
+ fmull 4(%esp)
+fincosh:
+ call __finexp
+ fld1
+ fdiv %st(1),%st(0) # st(0)=1/exp(x), st(1)=exp(x)
+ faddp %st,%st(1)
+ pushl $0x3f000000 # 1/2
+ flds (%esp)
+ popl %eax
+ fmulp
+ ret
+
+coshl:
+ fldl2e
+ fldt 4(%esp)
+ fmulp
+ jmp fincosh
+
+.global tanhf,tanh,tanhl
+ .type tanhf,@function
+ .type tanh,@function
+ .type tanhl,@function
+tanhf:
+ fldl2e
+ fmuls 4(%esp)
+ call __finexp
+ jmp fintanh
+tanh:
+ fldl2e
+ fmull 4(%esp)
+ call __finexp
+fintanh:
+ fld1
+ fdiv %st(1),%st # st(0)=1/exp(x), st(1)=exp(x)
+ fst %st(2) # st(2)=1/exp(x)
+ fadd %st(1),%st(0)
+ fstp %st(3) # st(2)=exp(x)+exp(-x), st(1)=exp(-x), st(0)=exp(x)
+ fsubp # st(1)=exp(x)+exp(-x), st(0)=exp(x)-exp(-x)
+ fdivp
+ ret
+
+tanhl:
+ fldl2e
+ fldt 4(%esp)
+ fmulp
+ call __finexp
+ jmp fintanh
+
+.global hypotf,hypot,hypotl # ,__hypot
+ .type hypotf,@function
+ .type hypot,@function
+ .type hypotl,@function
+# .type __hypot,@function
+hypotf:
+ flds 8(%esp)
+ flds 4(%esp)
+ jmp __hypot
+hypotl:
+ fldt 16(%esp)
+ fldt 4(%esp)
+ jmp __hypot
+hypot:
+ fldl 12(%esp)
+ fldl 4(%esp)
+__hypot:
+ fmul %st(0),%st(0)
+ fxch
+ fmul %st(0),%st(0)
+ faddp
+ fsqrt
+ ret
+
+.global log1pf,log1p,log1pl
+ .type log1pf,@function
+ .type log1p,@function
+ .type log1pl,@function
+log1pf:
+ flds 4(%esp)
+ jmp __log1p
+log1pl:
+ fldt 4(%esp)
+ jmp __log1p
+log1p:
+ fldl 4(%esp)
+__log1p:
+# Sprawdzenie zakresu parametru
+ fst %st(1)
+ pushl $0x3ed413cc # sqrt(2)-1-2^(-25)
+ fabs
+ flds (%esp)
+ popl %eax
+ fcompp # porownanie
+ fstsw %ax
+ fldln2
+ fxch
+ sahf
+# |x| >= sqrt(2)-1
+ jc 1f
+ fyl2xp1
+ ret
+1: fld1 # x = x + 1
+ faddp
+ fyl2x
+ ret
+
+.global log10f,log10,log10l
+ .type log10f,@function
+ .type log10,@function
+ .type log10l,@function
+log10f:
+ fldlg2
+ flds 4(%esp)
+ fyl2x
+ ret
+log10l:
+ fldlg2
+ fldt 4(%esp)
+ fyl2x
+ ret
+log10:
+ fldlg2
+ fldl 4(%esp)
+ fyl2x
+ ret
+
+.global log2f,log2,log2l
+ .type log2f,@function
+ .type log2,@function
+ .type log2l,@function
+log2f:
+ fld1
+ flds 4(%esp)
+ fyl2x
+ ret
+log2l:
+ fld1
+ fldt 4(%esp)
+ fyl2x
+ ret
+log2:
+ fld1
+ fldl 4(%esp)
+ fyl2x
+ ret
+
+.global fmaf,fma,fmal
+ .type fmaf,@function
+ .type fma,@function
+ .type fmal,@function
+fmaf:
+ flds 4(%esp)
+ fmuls 8(%esp)
+ fadds 12(%esp)
+ ret
+fma:
+ fldl 4(%esp)
+ fmull 12(%esp)
+ faddl 20(%esp)
+ ret
+fmal:
+ fldt 4(%esp)
+ fldt 16(%esp)
+ fmulp %st,%st(1)
+ fldt 28(%esp)
+ faddp %st,%st(1)
+ ret
+
+.global asinhf,asinh,asinhl
+ .type asinhf,@function
+ .type asinh,@function
+ .type asinhl,@function
+asinhf:
+ flds 4(%esp)
+ jmp __asinh
+asinh:
+ fldl 4(%esp)
+__asinh:
+ fld %st(0)
+ fmul %st(0),%st(0)
+ fld1
+ faddp %st(0),%st(1)
+finasch:
+ fsqrt
+ faddp %st(0),%st(1)
+ fldln2
+ fxch
+ fyl2x
+ ret
+asinhl:
+ fldt 4(%esp)
+ jmp __asinh
+
+.global acoshf,acosh,acoshl
+ .type acoshf,@function
+ .type acosh,@function
+ .type acoshl,@function
+acoshf:
+ flds 4(%esp)
+ jmp __acosh
+acosh:
+ fldl 4(%esp)
+__acosh:
+ fld %st(0)
+ fmul %st(0),%st(0)
+ fld1
+ fsubrp %st(0),%st(1) # st1=st1-st0; pop
+ jmp finasch
+acoshl:
+ fldt 4(%esp)
+ jmp __acosh
+
+.global atanhf,atanh,atanhl
+ .type atanhf,@function
+ .type atanh,@function
+ .type atanhl,@function
+atanhf:
+ flds 4(%esp)
+ jmp __atanh
+atanh:
+ fldl 4(%esp)
+__atanh:
+ fst %st(1)
+ fld1 # st0=1, st1=x, st2=x
+ fadd %st(0),%st(2) # st0=1, st1=x, st2=x+1
+ fsubp %st(0),%st(1) # st0=1-x, st1=x+1
+ fdivrp %st(0),%st(1)
+ fsqrt
+ fldln2
+ fxch
+ fyl2x
+ ret
+atanhl:
+ fldt 4(%esp)
+ jmp __atanh
+
+.global dremf,drem,dreml
+ .type dremf,@function
+ .type drem,@function
+ .type dreml,@function
+dremf:
+ flds 8(%esp) # y
+ flds 4(%esp) # x
+ jmp __drem
+drem:
+ fldl 12(%esp)
+ fldl 4(%esp)
+__drem:
+ fprem1
+ fstsw %ax
+ sahf
+ jp __drem
+ ret
+
+dreml:
+ fldt 16(%esp)
+ fldt 4(%esp)
+ jmp __drem
+
+# |ret| = |x|, sign(ret) = sign(y)
+.global copysignf,copysign,copysignl
+ .type copysignf,@function
+ .type copysign,@function
+ .type copysignl,@function
+copysignf:
+ flds 4(%esp) # x
+ flds 8(%esp) # y
+ jmp __copysign
+copysign:
+ fldl 4(%esp)
+ fldl 12(%esp)
+__copysign:
+ fmul %st(1),%st # st = x*y
+ ftst
+ fstsw %ax
+ fincstp
+ sahf
+ jnc 1f
+ fchs
+1: ret
+
+copysignl:
+ fldt 4(%esp)
+ fldt 16(%esp)
+ jmp __copysign
+
+.global fdimf,fdim,fdiml
+ .type fdimf,@function
+ .type fdim,@function
+ .type fdiml,@function
+fdimf:
+ flds 4(%esp)
+ fsubl 12(%esp)
+ jmp __fdim
+fdim:
+ fldl 4(%esp)
+ fsubl 12(%esp)
+__fdim:
+ fstsw %ax
+ sahf
+ jnc 1f
+ fldz
+1: ret
+fdiml:
+ fldt 4(%esp)
+ fldt 16(%esp)
+ fsubp
+ jmp __fdim
+
+
+.global truncf,trunc,truncl
+ .type truncf,@function
+ .type trunc,@function
+ .type truncl,@function
+
+truncf:
+ flds 4(%esp)
+ movb $0x0c,%ah
+ jmp __flcetr
+
+trunc:
+ fldl 4(%esp)
+ movb $0x0c,%ah
+ jmp __flcetr
+
+truncl:
+ fldt 4(%esp)
+ movb $0x0c,%ah
+ jmp __flcetr
+
+.global frexpf,frexp,frexpl
+ .type frexpf,@function
+ .type frexp,@function
+ .type frexpl,@function
+
+frexpf:
+ flds 4(%esp)
+ movl 8(%esp),%eax
+ jmp __frexp
+
+frexp:
+ fldl 4(%esp)
+ movl 12(%esp),%eax
+__frexp:
+ fxtract
+ fxch
+ fistpl (%eax)
+ pushl $0x3f000000 # 1/2
+ fmuls (%esp)
+ incl (%eax)
+ popl %eax
+ ret
+
+frexpl:
+ fldt 4(%esp)
+ movl 16(%esp),%eax
+ jmp __frexp
+
+.global logbf,logb,logbl
+ .type logbf,@function
+ .type logb,@function
+ .type logbl,@function
+
+#logbf: flds 4(%esp)
+# fxtract
+# fxch
+# ret
+
+#logb: fldl 4(%esp)
+# fxtract
+# fxch
+# ret
+
+#logbl: fldt 4(%esp)
+# fxtract
+# fxch
+# ret
+
+.global ilogbf,ilogb,ilogbl
+ .type ilogbf,@function
+ .type ilogb,@function
+ .type ilogbl,@function
+
+logbf:
+ilogbf: flds 4(%esp)
+ jmp __ilogb
+
+logb:
+ilogb: fldl 4(%esp)
+__ilogb:
+ fxtract
+ pushl %eax
+ fxch
+ fistl (%esp)
+ popl %eax
+ ret
+
+logbl:
+ilogbl: fldt 4(%esp)
+ jmp __ilogb
+
diff --git a/mdk-stage1/dietlibc/i386/listen.S b/mdk-stage1/dietlibc/i386/listen.S
new file mode 100644
index 000000000..a0879be37
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/listen.S
@@ -0,0 +1,4 @@
+#include <linuxnet.h>
+#include <syscalls.h>
+
+__socketcall(listen,LISTEN)
diff --git a/mdk-stage1/dietlibc/i386/log.S b/mdk-stage1/dietlibc/i386/log.S
new file mode 100644
index 000000000..0d42c9297
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/log.S
@@ -0,0 +1,26 @@
+.text
+
+.global logf,log,logl
+ .type logf,@function
+ .type log,@function
+ .type logl,@function
+logf:
+ fldln2
+ flds 4(%esp)
+ fyl2x
+ ret
+logl:
+ fldln2
+ fldt 4(%esp)
+ fyl2x
+ ret
+log:
+ fldln2
+ fldl 4(%esp)
+ fyl2x
+ ret
+
+.Lende:
+.size log,.Lende-log
+.size logl,.Lende-logl
+.size logf,.Lende-logf
diff --git a/mdk-stage1/dietlibc/i386/log10.S b/mdk-stage1/dietlibc/i386/log10.S
new file mode 100644
index 000000000..dcd08cc3f
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/log10.S
@@ -0,0 +1,11 @@
+.text
+.type log10,@function
+.global log10
+log10:
+ fldlg2
+ fldl 4(%esp)
+ fyl2x
+ ret
+
+.ende:
+.size log10,.ende-log10
diff --git a/mdk-stage1/dietlibc/i386/log1p.S b/mdk-stage1/dietlibc/i386/log1p.S
new file mode 100644
index 000000000..4dd2d58b4
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/log1p.S
@@ -0,0 +1,12 @@
+.text
+.type log1p,@function
+.global log1p
+log1p:
+ fldln2
+ fldl 4(%esp)
+ fyl2xp1
+ ret
+
+.ende:
+.size log1p,.ende-log1p
+
diff --git a/mdk-stage1/dietlibc/i386/log2.S b/mdk-stage1/dietlibc/i386/log2.S
new file mode 100644
index 000000000..80e99a8c9
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/log2.S
@@ -0,0 +1,11 @@
+.text
+.type log2,@function
+.global log2
+log2:
+ fld1
+ fldl 4(%esp)
+ fyl2x
+ ret
+
+.ende:
+.size log2,.ende-log2
diff --git a/mdk-stage1/dietlibc/i386/ltostr.S b/mdk-stage1/dietlibc/i386/ltostr.S
new file mode 100644
index 000000000..ddf85a4f6
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/ltostr.S
@@ -0,0 +1,62 @@
+/*
+ Copyright (C) 2002 Thomas M. Ogrisegg
+
+ __ltostr.S -- convert an integer into a string
+
+ %eax = dividend
+ %ebx = divisor
+ %ecx = size of output-buffer
+ %edi = output-buffer
+ %ebp = if uppercase is set, then %ebp is 'A'-10 else %ebp is 'a'-10
+
+*/
+
+.text
+.globl __ltostr
+__ltostr:
+ pushl %esi
+ pushl %edi # destination
+ pushl %ebp
+ pushl %ebx
+ movl %esp, %eax
+ movl 0x14(%eax), %edi
+ movl 0x18(%eax), %ecx # size
+ movl 0x20(%eax), %ebx # divisor
+ movl 0x1c(%eax), %eax # dividend
+ decl %ecx
+ movl %ecx, %esi
+ movl $('A'-0xa), %ebp
+ xorl %edx, %edx # must be 0 -- used by idiv
+ cmpl $0x0, 36(%esp) # check for uppercase
+ jnz .Lnext
+ addl $0x20, %ebp # set lowercase
+.Lnext:
+ idiv %ebx, %eax
+ cmpb $0x9, %dl
+ jg .Lnext2
+ addb $'0', %dl
+ jmp .Lstos
+.Lnext2:
+ addl %ebp, %edx
+.Lstos:
+ movb %dl, (%edi, %ecx)
+ xorl %edx, %edx
+ decl %ecx
+ jz .Lout
+ orl %eax, %eax
+ jnz .Lnext
+.Lout:
+ cld
+ movl %esi, %ebx
+ leal 1(%edi, %ecx), %esi
+ subl %ebx, %ecx
+ negl %ecx
+ movl %ecx, %eax
+ repnz movsb
+ movb $0x0, (%edi)
+ popl %ebx
+ popl %ebp
+ popl %edi
+ popl %esi
+ ret
+.size __ltostr, . - __ltostr
diff --git a/mdk-stage1/dietlibc/i386/mcount.S b/mdk-stage1/dietlibc/i386/mcount.S
new file mode 100644
index 000000000..11feed5e0
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/mcount.S
@@ -0,0 +1,44 @@
+/*
+ Copyright (C) 2001, 2002 Thomas M. Ogrisegg
+
+ This is free software. You can redistribute and
+ modify it under the terms of the GNU General Public
+ Public License.
+
+ mcount.S
+ i386 assembler implementation of mcount
+*/
+
+/* .section ".profile" */
+.text
+.globl mcount
+.type mcount,@function
+mcount:
+/*
+ save all generic registers which
+ might be used by __mcount, but aren't
+ automatically saved
+ */
+ pushl %eax
+ pushl %ecx
+ pushl %edx
+
+/* push the instruction pointer of the calling function */
+ pushl 0xc(%esp)
+
+/* push the instruction pointer of the
+ function that called the calling function */
+ pushl 0x4(%ebp)
+
+ call __mcount
+
+/* clean up stack */
+ addl $0x8, %esp
+
+/* restore the previously saved registers */
+ popl %edx
+ popl %ecx
+ popl %eax
+ ret
+
+.size mcount,.-mcount
diff --git a/mdk-stage1/dietlibc/i386/md5asm.S b/mdk-stage1/dietlibc/i386/md5asm.S
new file mode 100644
index 000000000..a99a92934
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/md5asm.S
@@ -0,0 +1,300 @@
+#define S11 7
+#define S12 12
+#define S13 17
+#define S14 22
+#define S21 5
+#define S22 9
+#define S23 14
+#define S24 20
+#define S31 4
+#define S32 11
+#define S33 16
+#define S34 23
+#define S41 6
+#define S42 10
+#define S43 15
+#define S44 21
+
+
+// #define F(x, y, z) (x & y) + (~x & z) = x&y + (z - z&x) = z + y&x - z&x
+//#define F(x, y, z) movl x,%ebx; movl x,%eax; notl %ebx; andl y,%eax; andl z,%ebx; addl %ebx,%eax
+#define F(x, y, z) movl y,%eax; movl z,%ebx; andl x,%eax; andl x,%ebx; addl z,%eax; subl %ebx,%eax
+
+// #define G(x, y, z) (x & z) + (y & ~z) = x&z + (y - y&z) = y + x&z - y&z
+#define G(x, y, z) movl z,%ebx; movl z,%eax; notl %ebx; andl x,%eax; andl y,%ebx; addl %ebx,%eax
+//#define G(x, y, z) movl x,%eax; movl y,%ebx; andl z,%eax; andl z,%ebx; addl y,%eax; subl %ebx,%eax
+//#define G(x, y, z) movl z,%eax; movl z,%ebx; andl x,%eax; andl y,%ebx; addl y,%eax; subl %ebx,%eax
+
+// #define H(x, y, z) x ^ y ^ z
+#define H(x, y, z) movl z,%eax; xorl y,%eax; xorl x,%eax
+
+// #define I(x, y, z) y ^ (x | ~z)
+#define I(x, y, z) movl z,%eax; notl %eax; orl x,%eax; xorl y,%eax
+
+
+// #define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
+#define ROTATE_LEFT(x, n) roll $n,x
+
+// #define FF(a, b, c, d, x, s, ac) { (a) += F (b, c, d) + (x) + (word)(ac); (a) = ROTATE_LEFT (a, s); (a) += (b); }
+// #define GG(a, b, c, d, x, s, ac) { (a) += G (b, c, d) + (x) + (word)(ac); (a) = ROTATE_LEFT (a, s); (a) += (b); }
+// #define HH(a, b, c, d, x, s, ac) { (a) += H (b, c, d) + (x) + (word)(ac); (a) = ROTATE_LEFT (a, s); (a) += (b); }
+// #define II(a, b, c, d, x, s, ac) { (a) += I (b, c, d) + (x) + (word)(ac); (a) = ROTATE_LEFT (a, s); (a) += (b); }
+
+#define FF(a, b, c, d, x, s, ac) addl x, a; addl $ac,a; F (b, c, d); addl %eax,a; roll $s,a; addl b,a
+#define GG(a, b, c, d, x, s, ac) addl x, a; addl $ac,a; G (b, c, d); addl %eax,a; roll $s,a; addl b,a
+#define HH(a, b, c, d, x, s, ac) addl x, a; addl $ac,a; H (b, c, d); addl %eax,a; roll $s,a; addl b,a
+#define II(a, b, c, d, x, s, ac) addl x, a; addl $ac,a; I (b, c, d); addl %eax,a; roll $s,a; addl b,a
+
+
+// // x is ecx
+// word a = state [0]; // a is edx
+// word b = state [1]; // b is esi
+// word c = state [2]; // c is edi
+// word d = state [3]; // d is ebp
+
+#define X(n) 4*(n)(%ecx)
+#define X0 (%ecx)
+#define a %edx
+#define b %esi
+#define c %edi
+#define d %ebp
+
+
+
+/* MD5 basic transformation: Transforms state based on data block */
+
+// void __MD5Transform ( word state[4], const word* x, size_t repeat )
+
+.text
+.type __MD5Transform, @function
+.align 32
+.global __MD5Transform
+
+ .align 32
+.Lrepeat:
+
+ /* Round 1 */
+ FF (a, b, c, d, X0 , S11, 0xd76aa478); /* 1 */
+ FF (d, a, b, c, X( 1), S12, 0xe8c7b756); /* 2 */
+ FF (c, d, a, b, X( 2), S13, 0x242070db); /* 3 */
+ FF (b, c, d, a, X( 3), S14, 0xc1bdceee); /* 4 */
+ FF (a, b, c, d, X( 4), S11, 0xf57c0faf); /* 5 */
+ FF (d, a, b, c, X( 5), S12, 0x4787c62a); /* 6 */
+ FF (c, d, a, b, X( 6), S13, 0xa8304613); /* 7 */
+ FF (b, c, d, a, X( 7), S14, 0xfd469501); /* 8 */
+ FF (a, b, c, d, X( 8), S11, 0x698098d8); /* 9 */
+ FF (d, a, b, c, X( 9), S12, 0x8b44f7af); /* 10 */
+ FF (c, d, a, b, X(10), S13, 0xffff5bb1); /* 11 */
+ FF (b, c, d, a, X(11), S14, 0x895cd7be); /* 12 */
+ FF (a, b, c, d, X(12), S11, 0x6b901122); /* 13 */
+ FF (d, a, b, c, X(13), S12, 0xfd987193); /* 14 */
+ FF (c, d, a, b, X(14), S13, 0xa679438e); /* 15 */
+ FF (b, c, d, a, X(15), S14, 0x49b40821); /* 16 */
+
+ /* Round 2 */
+ GG (a, b, c, d, X( 1), S21, 0xf61e2562); /* 17 */
+ GG (d, a, b, c, X( 6), S22, 0xc040b340); /* 18 */
+ GG (c, d, a, b, X(11), S23, 0x265e5a51); /* 19 */
+ GG (b, c, d, a, X0 , S24, 0xe9b6c7aa); /* 20 */
+ GG (a, b, c, d, X( 5), S21, 0xd62f105d); /* 21 */
+ GG (d, a, b, c, X(10), S22, 0x02441453); /* 22 */
+ GG (c, d, a, b, X(15), S23, 0xd8a1e681); /* 23 */
+ GG (b, c, d, a, X( 4), S24, 0xe7d3fbc8); /* 24 */
+ GG (a, b, c, d, X( 9), S21, 0x21e1cde6); /* 25 */
+ GG (d, a, b, c, X(14), S22, 0xc33707d6); /* 26 */
+ GG (c, d, a, b, X( 3), S23, 0xf4d50d87); /* 27 */
+ GG (b, c, d, a, X( 8), S24, 0x455a14ed); /* 28 */
+ GG (a, b, c, d, X(13), S21, 0xa9e3e905); /* 29 */
+ GG (d, a, b, c, X( 2), S22, 0xfcefa3f8); /* 30 */
+ GG (c, d, a, b, X( 7), S23, 0x676f02d9); /* 31 */
+ GG (b, c, d, a, X(12), S24, 0x8d2a4c8a); /* 32 */
+
+ /* Round 3 */
+ HH (a, b, c, d, X( 5), S31, 0xfffa3942); /* 33 */
+ HH (d, a, b, c, X( 8), S32, 0x8771f681); /* 34 */
+ HH (c, d, a, b, X(11), S33, 0x6d9d6122); /* 35 */
+ HH (b, c, d, a, X(14), S34, 0xfde5380c); /* 36 */
+ HH (a, b, c, d, X( 1), S31, 0xa4beea44); /* 37 */
+ HH (d, a, b, c, X( 4), S32, 0x4bdecfa9); /* 38 */
+ HH (c, d, a, b, X( 7), S33, 0xf6bb4b60); /* 39 */
+ HH (b, c, d, a, X(10), S34, 0xbebfbc70); /* 40 */
+ HH (a, b, c, d, X(13), S31, 0x289b7ec6); /* 41 */
+ HH (d, a, b, c, X0 , S32, 0xeaa127fa); /* 42 */
+ HH (c, d, a, b, X( 3), S33, 0xd4ef3085); /* 43 */
+ HH (b, c, d, a, X( 6), S34, 0x04881d05); /* 44 */
+ HH (a, b, c, d, X( 9), S31, 0xd9d4d039); /* 45 */
+ HH (d, a, b, c, X(12), S32, 0xe6db99e5); /* 46 */
+ HH (c, d, a, b, X(15), S33, 0x1fa27cf8); /* 47 */
+ HH (b, c, d, a, X( 2), S34, 0xc4ac5665); /* 48 */
+
+ /* Round 4 */
+ II (a, b, c, d, X0 , S41, 0xf4292244); /* 49 */
+ II (d, a, b, c, X( 7), S42, 0x432aff97); /* 50 */
+ II (c, d, a, b, X(14), S43, 0xab9423a7); /* 51 */
+ II (b, c, d, a, X( 5), S44, 0xfc93a039); /* 52 */
+ II (a, b, c, d, X(12), S41, 0x655b59c3); /* 53 */
+ II (d, a, b, c, X( 3), S42, 0x8f0ccc92); /* 54 */
+ II (c, d, a, b, X(10), S43, 0xffeff47d); /* 55 */
+ II (b, c, d, a, X( 1), S44, 0x85845dd1); /* 56 */
+ II (a, b, c, d, X( 8), S41, 0x6fa87e4f); /* 57 */
+ II (d, a, b, c, X(15), S42, 0xfe2ce6e0); /* 58 */
+ II (c, d, a, b, X( 6), S43, 0xa3014314); /* 59 */
+ II (b, c, d, a, X(13), S44, 0x4e0811a1); /* 60 */
+ II (a, b, c, d, X( 4), S41, 0xf7537e82); /* 61 */
+ II (d, a, b, c, X(11), S42, 0xbd3af235); /* 62 */
+ II (c, d, a, b, X( 2), S43, 0x2ad7d2bb); /* 63 */
+ II (b, c, d, a, X( 9), S44, 0xeb86d391); /* 64 */
+
+// state [0] += a;
+// state [1] += b;
+// state [2] += c;
+// state [3] += d;
+
+ addl $64,%ecx
+
+ movl 4+32(%esp),%eax // state
+ addl (%eax),a
+ addl 4(%eax),b
+ addl 8(%eax),c
+ addl 12(%eax),d
+ movl a, (%eax)
+ movl b, 4(%eax)
+ movl c, 8(%eax)
+ movl d,12(%eax)
+
+.Lstart:
+ decl 12+32(%esp)
+ jns .Lrepeat
+
+ popal
+ ret
+
+__MD5Transform:
+__MD5TransformLocal:
+ pushal
+ movl 8+32(%esp),%ecx // x
+ movl 4+32(%esp),%eax // state
+ movl (%eax),a
+ movl 4(%eax),b
+ movl 8(%eax),c
+ movl 12(%eax),d
+ jmp .Lstart
+
+.Lende:
+.size __MD5Transform, .Lende-__MD5Transform
+
+.type MD5Init,@function
+.global MD5Init
+
+MD5Init:
+ movl 4(%esp), %ecx
+ xorl %eax,%eax
+ movl $0x67452301, (%ecx)
+ movl $0xefcdab89, 4(%ecx)
+ movl $0x98badcfe, 8(%ecx)
+ movl $0x10325476, 12(%ecx)
+ movl %eax, 16(%ecx)
+ movl %eax, 20(%ecx)
+ ret
+
+
+.global MD5Update
+.type MD5Update,@function
+
+
+// void MD5Update ( MD5_CTX* context, const byte* input, size_t inputBytes )
+
+#define CONTEXT 4+32(%esp)
+#define INPUT 8+32(%esp)
+#define INPUTBYTES 12+32(%esp)
+
+#define COUNT 16(%ebx)
+#define BUFFER 24(%ebx)
+
+
+MD5Update:
+ pushal
+ cld
+ movl CONTEXT, %ebx
+
+// ByteIndex = (context->count[0] >> 3) & 0x3F;
+
+ movl COUNT, %ebp
+ shrl $3, %ebp
+ andl $63,%ebp // ebp = ByteIndex
+
+// if ( (context->count[0] += inputBytes << 3 ) < (inputBytes << 3) )
+// context->count[1]++;
+// context->count[1] += inputBytes >> (32-3);
+
+ movl $8, %eax
+ mull INPUTBYTES
+ addl %eax, 0+COUNT
+ adcl %edx, 4+COUNT
+
+// partLen = 64 - ByteIndex;
+
+ movl $64, %eax
+ subl %ebp, %eax // eax = partLen
+
+// i = 0;
+// if ( partLen <= inputBytes ) {
+
+ xorl %ecx,%ecx // ecx = i
+ cmpl INPUTBYTES, %eax
+ ja .Lende2
+
+// memcpy ( context->buffer + ByteIndex, input, partLen );
+
+ leal 24(%ebx,%ebp,1), %edi
+ movl INPUT, %esi
+ movl %eax, %ecx
+ rep movsb
+
+// MD5Transform ( context->state, context->buffer, 1 );
+
+ pushl $1
+ leal BUFFER, %ecx
+ pushl %ecx
+ push %ebx
+ call __MD5TransformLocal
+
+// len = (inputBytes - partLen) / 64;
+
+ movl 12+INPUTBYTES, %ecx
+ subl %eax, %ecx
+ shrl $6, %ecx
+
+// MD5Transform ( context->state, input+partLen, len );
+
+ pushl %ecx
+ pushl %esi
+ pushl %ebx
+ call __MD5TransformLocal
+ addl $24,%esp
+
+// i = partLen + 64 * len;
+// ByteIndex = 0;
+
+ shll $6, %ecx
+ addl %eax, %ecx
+ xorl %ebp, %ebp
+
+.Lende2:
+
+// }
+// memcpy ( context->buffer + ByteIndex, input + i, inputBytes - i );
+
+ movl INPUT, %esi
+ addl %ecx, %esi
+
+ negl %ecx
+ addl INPUTBYTES, %ecx
+
+ leal 24(%ebx,%ebp,1), %edi
+ rep movsb
+
+ popal
+ ret
+
+
diff --git a/mdk-stage1/dietlibc/i386/memccpy.S b/mdk-stage1/dietlibc/i386/memccpy.S
new file mode 100644
index 000000000..0b7dce49e
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/memccpy.S
@@ -0,0 +1,39 @@
+/*
+ Copyright (C) 2002 Thomas M. Ogrisegg
+
+ This is free software. You can redistribute and
+ modify it under the terms of the GNU General Public
+ Public License.
+
+ memccpy.S
+ i386 assembler implementation of memccpy(3)
+*/
+
+.text
+.global memccpy
+.type memccpy,@function
+memccpy:
+ pushl %esi
+ pushl %edi
+
+ movl %esp, %ecx
+ movl 0x0c(%ecx), %edi
+ movl 0x10(%ecx), %esi
+ movb 0x14(%ecx), %dl
+ movl 0x18(%ecx), %ecx
+ cld
+.Lloop:
+ lodsb
+ stosb
+ cmp %al, %dl
+ jz .Lout
+ decl %ecx
+ jnz .Lloop
+ xorl %edi, %edi
+.Lout:
+ movl %edi, %eax
+ popl %edi
+ popl %esi
+ ret
+.Lende:
+.size memccpy,.Lende-memccpy
diff --git a/mdk-stage1/dietlibc/i386/memchr.S b/mdk-stage1/dietlibc/i386/memchr.S
new file mode 100644
index 000000000..7d04f990b
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/memchr.S
@@ -0,0 +1,24 @@
+.text
+.align 0
+.global memchr
+.type memchr,@function
+memchr:
+ pushl %edi
+ movl 8(%esp),%edi
+ movl 12(%esp),%eax
+ movl 16(%esp),%ecx
+ cld
+ jecxz .Lnotfound
+
+ repne scasb
+
+ je .Lfound
+.Lnotfound:
+ xorl %edi, %edi
+ incl %edi
+.Lfound:
+ movl %edi, %eax
+ decl %eax
+
+ popl %edi
+ ret
diff --git a/mdk-stage1/dietlibc/i386/memcmp.S b/mdk-stage1/dietlibc/i386/memcmp.S
new file mode 100644
index 000000000..aa6d55f23
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/memcmp.S
@@ -0,0 +1,26 @@
+.text
+.align 0
+.global memcmp
+.type memcmp,@function
+memcmp:
+ xorl %eax,%eax
+ orl 12(%esp),%eax
+ jz .Lempty
+ pushl %esi
+ pushl %edi
+ movl 12(%esp),%esi
+ movl 16(%esp),%edi
+ movl %eax,%ecx
+
+ rep cmpsb
+
+ decl %esi
+ decl %edi
+ lodsb
+ subb (%edi), %al
+ movsx %al, %eax
+
+ popl %edi
+ popl %esi
+.Lempty:
+ ret
diff --git a/mdk-stage1/dietlibc/i386/memcpy.S b/mdk-stage1/dietlibc/i386/memcpy.S
new file mode 100644
index 000000000..cbe74459f
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/memcpy.S
@@ -0,0 +1,16 @@
+.text
+.align 0
+.global memcpy
+.type memcpy,@function
+memcpy:
+ pushl %esi
+ pushl %edi
+ movl 12(%esp),%edi
+ movl 16(%esp),%esi
+ movl 20(%esp),%ecx
+ movl %edi, %eax
+ cld
+ rep movsb
+ popl %edi
+ popl %esi
+ ret
diff --git a/mdk-stage1/dietlibc/i386/memset.S b/mdk-stage1/dietlibc/i386/memset.S
new file mode 100644
index 000000000..472390b84
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/memset.S
@@ -0,0 +1,15 @@
+.text
+.align 0
+.global memset
+.type memset,@function
+memset:
+ pushl %edi
+ movl 8(%esp),%edi
+ movl 12(%esp),%eax
+ movl 16(%esp),%ecx
+ cld
+ pushl %edi
+ rep stosb
+ popl %eax
+ popl %edi
+ ret
diff --git a/mdk-stage1/dietlibc/i386/mmap.S b/mdk-stage1/dietlibc/i386/mmap.S
new file mode 100644
index 000000000..c824aa037
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/mmap.S
@@ -0,0 +1,14 @@
+#include "syscalls.h"
+
+.text
+.global mmap
+.type mmap,@function
+mmap:
+ mov $__NR_mmap,%al
+ lea 0x4(%esp,1),%edx
+ push %edx
+ call __unified_syscall
+ pop %ecx
+ ret
+.Lende3:
+.size mmap,.Lende3-mmap
diff --git a/mdk-stage1/dietlibc/i386/mmap64.S b/mdk-stage1/dietlibc/i386/mmap64.S
new file mode 100644
index 000000000..421325260
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/mmap64.S
@@ -0,0 +1,63 @@
+#include <dietfeatures.h>
+#include <syscalls.h>
+#include <errno.h>
+
+#ifdef __DYN_LIB
+#ifndef WANT_THREAD_SAFE
+#define WANT_THREAD_SAFE
+#endif
+#endif
+
+.text
+.global mmap64
+.type mmap64,@function
+mmap64:
+/* man is this ugly! */
+ push %ebp
+ push %edi
+ push %esi
+ push %ebx
+ movl %esp, %edi
+ movl 0x28(%edi), %eax
+ movl 0x2c(%edi), %edx
+ testl $0xfff, %eax /* offset in pages */
+ jnz .Leinval
+ shrdl $12, %edx, %eax
+ shrl $12, %edx
+ jnz .Leinval
+ movl %eax, %ebp
+ movl 0x14(%edi),%ebx
+ movl 0x18(%edi),%ecx
+ movl 0x1c(%edi),%edx
+ movl 0x20(%edi),%esi
+ movl 0x24(%edi),%edi
+ movl $__NR_mmap2,%eax
+ int $0x80
+ cmp $-124,%eax
+ jbe .Lnoerror
+ neg %eax
+.Lerror:
+#ifdef WANT_THREAD_SAFE
+ movl %eax,%ebx
+#ifdef __DYN_LIB
+ call __errno_location@PLT
+#else
+ call __errno_location
+#endif
+ movl %ebx,(%eax)
+ orl $-1,%eax
+#else
+ mov %eax,errno
+ sbb %eax,%eax # eax = eax - eax - CY = -1
+#endif
+.Lnoerror:
+ pop %ebx
+ pop %esi
+ pop %edi
+ pop %ebp
+ ret
+.Leinval:
+ movl $EINVAL,%eax
+ jmp .Lerror
+.Lende2:
+.size mmap64,.Lende2-mmap64
diff --git a/mdk-stage1/dietlibc/i386/poly.S b/mdk-stage1/dietlibc/i386/poly.S
new file mode 100644
index 000000000..d8be7d7f5
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/poly.S
@@ -0,0 +1,24 @@
+
+.text
+.global __poly
+.type __poly,@function
+
+
+#
+# double __poly ( double x, int n, const double* c );
+#
+
+__poly:
+ movl 16(%esp),%eax
+ movl 12(%esp),%ecx
+ leal (%eax,%ecx,8),%eax
+ fldl 4(%esp)
+ fldz
+.Lloop:
+ fmul %st(1),%st(0)
+ faddl (%eax)
+ addl $-8,%eax
+ decl %ecx
+ jns .Lloop
+ fstp %st(1)
+ ret
diff --git a/mdk-stage1/dietlibc/i386/pow.S b/mdk-stage1/dietlibc/i386/pow.S
new file mode 100644
index 000000000..46562a299
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/pow.S
@@ -0,0 +1,67 @@
+.text
+.global pow
+.type pow,@function
+
+# pow(x,y)
+.global powf,pow,powl
+ .type powf,@function
+ .type pow,@function
+ .type powl,@function
+powf:
+ flds 4(%esp) # x
+ flds 8(%esp) # y
+ jmp .L__pow
+powl:
+ fldt 4(%esp)
+ fldt 16(%esp)
+ jmp .L__pow
+pow:
+ fldl 4(%esp)
+ fldl 12(%esp)
+# x^y; st(0)=y, st(1)=x
+.L__pow:
+ ftst # y = 0 ?
+ fstsw %ax
+ fld1 # st(0)=1, st(1)=y, st(2)=x
+ sahf
+ jz 1f # return 1
+ fcomp %st(1) # y = 1 ?
+ fstsw %ax
+ fxch # st(0)=x, st(1)=y
+ sahf
+ jz 1f # return x
+ ftst # x = 0 ?
+ fstsw %ax
+ sahf
+ jz 1f
+ jnc .Lfinpow # x > 0
+ fxch # st(0)=y, st(1)=x
+ fld %st(0) # st(0)=y, st(1)=y, st(2)=x
+ frndint # st(0)=int(y)
+ fcomp %st(1) # y = int(y)?
+ fstsw %ax
+ fxch
+ sahf
+ jnz .Lfinpow # fyl2x -> st(0) = NaN
+# y even or odd ?
+ fld1
+ fadd %st(0) # st(0) = 2
+ fdivr %st(2),%st(0) # st(0)=st(2)/2
+ frndint
+ fadd %st(0),%st(0)
+ fcomp %st(2) # st(0) = x, st(1) = y
+ fstsw %ax
+ fchs # st(0) = -x
+ sahf
+ jz .Lfinpow # y even
+ call .Lfinpow # y odd
+ fchs
+1: ret
+.Lfinpow:
+ fyl2x
+ jmp __finexp
+
+.Lende:
+.size pow,.Lende-pow
+.size powf,.Lende-powf
+.size powl,.Lende-powl
diff --git a/mdk-stage1/dietlibc/i386/recv.S b/mdk-stage1/dietlibc/i386/recv.S
new file mode 100644
index 000000000..215343ccc
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/recv.S
@@ -0,0 +1,4 @@
+#include <linuxnet.h>
+#include <syscalls.h>
+
+__socketcall(recv,RECV)
diff --git a/mdk-stage1/dietlibc/i386/recvfrom.S b/mdk-stage1/dietlibc/i386/recvfrom.S
new file mode 100644
index 000000000..a9dde840d
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/recvfrom.S
@@ -0,0 +1,4 @@
+#include <linuxnet.h>
+#include <syscalls.h>
+
+__socketcall(recvfrom,RECVFROM)
diff --git a/mdk-stage1/dietlibc/i386/recvmsg.S b/mdk-stage1/dietlibc/i386/recvmsg.S
new file mode 100644
index 000000000..cb26e2f08
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/recvmsg.S
@@ -0,0 +1,4 @@
+#include <linuxnet.h>
+#include <syscalls.h>
+
+__socketcall(recvmsg,RECVMSG)
diff --git a/mdk-stage1/dietlibc/i386/rint.S b/mdk-stage1/dietlibc/i386/rint.S
new file mode 100644
index 000000000..f56ab1f93
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/rint.S
@@ -0,0 +1,23 @@
+.text
+
+.global rintf,rint,rintl
+ .type rintf,@function
+ .type rint,@function
+ .type rintl,@function
+rintf:
+ flds 4(%esp)
+ frndint
+ ret
+rint:
+ fldl 4(%esp)
+ frndint
+ ret
+rintl:
+ fldt 4(%esp)
+ frndint
+ ret
+
+.Lende:
+.size rint,.Lende-rint
+.size rintl,.Lende-rintl
+.size rintf,.Lende-rintf
diff --git a/mdk-stage1/dietlibc/i386/send.S b/mdk-stage1/dietlibc/i386/send.S
new file mode 100644
index 000000000..f2dd7e3d5
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/send.S
@@ -0,0 +1,4 @@
+#include <linuxnet.h>
+#include <syscalls.h>
+
+__socketcall(send,SEND)
diff --git a/mdk-stage1/dietlibc/i386/sendmsg.S b/mdk-stage1/dietlibc/i386/sendmsg.S
new file mode 100644
index 000000000..484d62e50
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/sendmsg.S
@@ -0,0 +1,4 @@
+#include <linuxnet.h>
+#include <syscalls.h>
+
+__socketcall(sendmsg,SENDMSG)
diff --git a/mdk-stage1/dietlibc/i386/sendto.S b/mdk-stage1/dietlibc/i386/sendto.S
new file mode 100644
index 000000000..04270f0f0
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/sendto.S
@@ -0,0 +1,4 @@
+#include <linuxnet.h>
+#include <syscalls.h>
+
+__socketcall(sendto,SENDTO)
diff --git a/mdk-stage1/dietlibc/i386/setsockopt.S b/mdk-stage1/dietlibc/i386/setsockopt.S
new file mode 100644
index 000000000..6a81aec82
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/setsockopt.S
@@ -0,0 +1,4 @@
+#include <linuxnet.h>
+#include <syscalls.h>
+
+__socketcall(setsockopt,SETSOCKOPT)
diff --git a/mdk-stage1/dietlibc/i386/shutdown.S b/mdk-stage1/dietlibc/i386/shutdown.S
new file mode 100644
index 000000000..f9dc707e8
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/shutdown.S
@@ -0,0 +1,4 @@
+#include <linuxnet.h>
+#include <syscalls.h>
+
+__socketcall(shutdown,SHUTDOWN)
diff --git a/mdk-stage1/dietlibc/i386/sin.S b/mdk-stage1/dietlibc/i386/sin.S
new file mode 100644
index 000000000..404bf5eed
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/sin.S
@@ -0,0 +1,34 @@
+
+.text
+
+.global sinf,sin,sinl
+.type sinf,@function
+.type sin,@function
+.type sinl,@function
+sinf:
+ flds 4(%esp)
+ jmp 1f
+sin:
+ fldl 4(%esp)
+1: fsin
+ fnstsw %ax
+ testb $0x04, %ah
+ je 3f
+ fldpi
+ fadd %st
+ fxch %st(1)
+2: fprem1
+ fnstsw %ax
+ testb $0x04, %ah
+ jne 2b
+ fstp %st(1)
+ fsin
+3: ret
+sinl:
+ fldt 4(%esp)
+ jmp 1b
+
+.ende:
+.size sin,.ende-sin
+.size sinf,.ende-sinf
+.size sinl,.ende-sinl
diff --git a/mdk-stage1/dietlibc/i386/sincos.S b/mdk-stage1/dietlibc/i386/sincos.S
new file mode 100644
index 000000000..7395075f3
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/sincos.S
@@ -0,0 +1,18 @@
+
+.text
+.type sincos,@function
+.global sincos
+
+# void sincos ( double x, double* sinx, double* cosx );
+
+sincos:
+ fldl 4(%esp)
+ fsincos
+ movl 16(%esp),%eax
+ movl 12(%esp),%ecx
+ fstpl (%eax)
+ fstpl (%ecx)
+ ret
+
+.ende:
+.size sincos,.ende-sincos
diff --git a/mdk-stage1/dietlibc/i386/sinh.S b/mdk-stage1/dietlibc/i386/sinh.S
new file mode 100644
index 000000000..98f7ee752
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/sinh.S
@@ -0,0 +1,29 @@
+
+.text
+.type sinh,@function
+.global sinh
+
+sinh: # note: exp(x) = 2^(x*log2(e))
+ fldl2e
+ fmull 4(%esp) # x*log2(e)
+ fld %st(0) # x*log2(e) x*log2(e)
+ frndint # int(x*log2(e)) x*log2(e)
+ fxch # x*log2(e) int(x*log2(e))
+ fsub %st(1),%st(0) # frac(x*log2(e)) int(x*log2(e))
+ f2xm1 # 2^(fract(x*log2(e)))-1 int(x*log2(e))
+ fld1 # 1 2^(fract(x*log2(e)))-1 int(x*log2(e))
+ faddp %st(0),%st(1) # 2^(fract(x*log2(e))) int(x*log2(e))
+ fscale # 2^(x*log2(e)) int(x*log2(e))
+ fstp %st(1) # 2^(x*log2(e))
+
+# now we have y = exp(x), but sinh(x) = (y - 1/y) * 0.5
+
+ fld1
+ fdiv %st(1),%st(0)
+ fsubrp
+ fmuls __half
+ ret
+
+.Lende:
+
+.size sinh,.ende-sinh
diff --git a/mdk-stage1/dietlibc/i386/sleep.S b/mdk-stage1/dietlibc/i386/sleep.S
new file mode 100644
index 000000000..356552dc2
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/sleep.S
@@ -0,0 +1,25 @@
+#include "PIC.h"
+
+.text
+.global sleep
+.type sleep,@function
+
+sleep:
+ movl 4(%esp),%eax # Argument holen
+ PIC_SAVE # non-PIC: empty line
+ PIC_INIT # non-PIC: empty line
+ pushl $0 # 0 ns
+ pushl %eax # 'x' µs warten
+ movl %esp,%eax
+ pushl %eax # zweimal ein Zeiger auf das Stackobjekt
+ pushl %eax # ptr ptr sec nsec return arg
+#ifdef __DYN_LIB
+ call nanosleep@PLT
+#else
+ call nanosleep
+#endif
+ movl 20(%esp),%eax # 'x' holen
+ subl 8(%esp),%eax # schon abgelaufende Zeit subtrahieren
+ addl $16,%esp
+ PIC_RESTORE # non-PIC: empty line
+ ret
diff --git a/mdk-stage1/dietlibc/i386/socket.S b/mdk-stage1/dietlibc/i386/socket.S
new file mode 100644
index 000000000..bc8cbe536
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/socket.S
@@ -0,0 +1,4 @@
+#include <linuxnet.h>
+#include <syscalls.h>
+
+__socketcall(socket,SOCKET)
diff --git a/mdk-stage1/dietlibc/i386/socketcall.S b/mdk-stage1/dietlibc/i386/socketcall.S
new file mode 100644
index 000000000..4e8019ec2
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/socketcall.S
@@ -0,0 +1,17 @@
+#include <syscalls.h>
+
+.text
+.global socketcall
+.type socketcall,@function
+socketcall:
+ leal 4(%esp), %ecx
+ pushl %ecx
+ movzbl %al,%eax
+ pushl %eax
+ movb $__NR_socketcall,%al
+ call __unified_syscall
+ popl %ecx
+ popl %ecx
+ retl
+.Lende:
+.size socketcall,.Lende-socketcall
diff --git a/mdk-stage1/dietlibc/i386/socketpair.S b/mdk-stage1/dietlibc/i386/socketpair.S
new file mode 100644
index 000000000..a5de65f25
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/socketpair.S
@@ -0,0 +1,4 @@
+#include <linuxnet.h>
+#include <syscalls.h>
+
+__socketcall(socketpair,SOCKETPAIR)
diff --git a/mdk-stage1/dietlibc/i386/sqrt.S b/mdk-stage1/dietlibc/i386/sqrt.S
new file mode 100644
index 000000000..5e4527612
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/sqrt.S
@@ -0,0 +1,23 @@
+.text
+
+.global sqrtf,sqrt,sqrtl
+ .type sqrtf,@function
+ .type sqrt,@function
+ .type sqrtl,@function
+sqrtf:
+ flds 4(%esp)
+ fsqrt
+ ret
+sqrt:
+ fldl 4(%esp)
+ fsqrt
+ ret
+sqrtl:
+ fldt 4(%esp)
+ fsqrt
+ ret
+
+.ende:
+.size sqrt,.ende-sqrt
+.size sqrtf,.ende-sqrtf
+.size sqrtl,.ende-sqrtl
diff --git a/mdk-stage1/dietlibc/i386/sqrtl.S b/mdk-stage1/dietlibc/i386/sqrtl.S
new file mode 100644
index 000000000..c1a931fd8
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/sqrtl.S
@@ -0,0 +1,11 @@
+.text
+.type sqrtl,@function
+.global sqrtl
+sqrtl:
+ fldt 4(%esp)
+ fsqrt
+ ret
+
+.ende:
+.size sqrtl,.ende-sqrtl
+
diff --git a/mdk-stage1/dietlibc/i386/stpcpy.S b/mdk-stage1/dietlibc/i386/stpcpy.S
new file mode 100644
index 000000000..1cb74b2ea
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/stpcpy.S
@@ -0,0 +1,22 @@
+.text
+.global stpcpy
+.type stpcpy,@function
+stpcpy:
+ pushl %edi
+ pushl %esi
+ movl 0xc(%esp), %edi
+ movl 0x10(%esp), %esi
+
+.Lcopy:
+ lodsb
+ stosb
+ testb %al, %al
+ jnz .Lcopy
+
+ movl %edi, %eax
+ decl %eax
+ popl %esi
+ popl %edi
+ ret
+.Lende:
+.size stpcpy,.Lende-stpcpy
diff --git a/mdk-stage1/dietlibc/i386/strcasecmp.S b/mdk-stage1/dietlibc/i386/strcasecmp.S
new file mode 100644
index 000000000..a836680db
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/strcasecmp.S
@@ -0,0 +1,31 @@
+.text
+.globl strcasecmp
+
+strcasecmp:
+ pushl %esi
+ movl 0x8(%esp), %esi
+ movl 0xc(%esp), %edx
+ xorl %eax, %eax
+ xorl %ecx, %ecx
+ cld
+.Lloop:
+ lodsb
+ movb (%edx), %cl
+ incl %edx
+ or %al, %al
+ jz .Lfinifirst
+ cmp $'A', %al
+ jnge .Lcmp
+ cmp $'z', %al
+ jg .Lcmp
+ or $0x20, %al
+ or $0x20, %cl
+.Lcmp:
+ subl %ecx, %eax
+ jz .Lloop
+.Lret:
+ popl %esi
+ ret
+.Lfinifirst:
+ subl %ecx, %eax
+ jmp .Lret
diff --git a/mdk-stage1/dietlibc/i386/strcat.S b/mdk-stage1/dietlibc/i386/strcat.S
new file mode 100644
index 000000000..e7d74ef13
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/strcat.S
@@ -0,0 +1,29 @@
+.text
+.align 0
+.global strcat
+.type strcat,@function
+strcat:
+ pushl %edi
+ pushl %esi
+
+ movl 12(%esp), %edi
+ movl 16(%esp), %esi
+
+ pushl %edi
+
+ xorl %eax, %eax
+ xorl %ecx, %ecx
+ decl %ecx
+ repne scasb
+ decl %edi
+
+.Lloop:
+ lodsb
+ stosb
+ testb %al, %al
+ jnz .Lloop
+
+ popl %eax
+ popl %esi
+ popl %edi
+ ret
diff --git a/mdk-stage1/dietlibc/i386/strchr.S b/mdk-stage1/dietlibc/i386/strchr.S
new file mode 100644
index 000000000..4515d9835
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/strchr.S
@@ -0,0 +1,22 @@
+
+.text
+.type strchr,@function
+.global strchr
+.weak index
+.type index,@function
+
+index:
+strchr:
+ movl 4(%esp),%ecx
+ movb 8(%esp),%dl
+.Lloop:
+ movb (%ecx),%al
+ cmpb %al,%dl
+ jz .Lfound
+ incl %ecx
+ testb %al,%al
+ jnz .Lloop
+ xorl %ecx,%ecx
+.Lfound:
+ movl %ecx,%eax
+ ret
diff --git a/mdk-stage1/dietlibc/i386/strcmp.S b/mdk-stage1/dietlibc/i386/strcmp.S
new file mode 100644
index 000000000..e01064ffb
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/strcmp.S
@@ -0,0 +1,31 @@
+.text
+.global strcmp
+.type strcmp,@function
+.weak strcoll
+.type strcoll,@function
+
+#ifdef HIGH_PERFORMANCE
+.align 16
+#endif
+
+.Ldiff:
+ movzbl (%edx), %ecx
+ subl %ecx, %eax # (unsigned char)*p - (unsigned char)*q, so wie die Original libc
+ ret # und ohne Überlaufprobleme:
+ # (int) ((signed char)c - (signed char)d) != (int)(signed char) ((unsigned char)c - (unsigned char)d)
+ # c = 'ä', d = 'e': left expression: -129, right expression: 127
+
+strcoll:
+strcmp:
+ movl 4(%esp), %ecx
+ movl 8(%esp), %edx
+ xorl %eax, %eax
+.Lloop: # Schleifenanfang liegt genau auf Modulanfang + 0x10, damit alignbar
+ movb (%ecx), %al
+ cmpb (%edx), %al
+ jnz .Ldiff
+ incl %edx
+ incl %ecx
+ testb %al, %al
+ jnz .Lloop
+ ret
diff --git a/mdk-stage1/dietlibc/i386/strcpy.S b/mdk-stage1/dietlibc/i386/strcpy.S
new file mode 100644
index 000000000..a597436bc
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/strcpy.S
@@ -0,0 +1,24 @@
+
+.text
+.align 0
+.global strcpy
+.type strcpy,@function
+strcpy:
+ pushl %esi
+ pushl %edi
+
+ movl 12(%esp), %edx
+ movl 16(%esp), %esi
+ movl %edx, %edi
+ cld
+
+.Lloop:
+ lodsb
+ stosb
+ orb %al, %al
+ jnz .Lloop
+
+ popl %edi
+ popl %esi
+ movl %edx,%eax
+ ret
diff --git a/mdk-stage1/dietlibc/i386/strlen.S b/mdk-stage1/dietlibc/i386/strlen.S
new file mode 100644
index 000000000..66f8ee553
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/strlen.S
@@ -0,0 +1,18 @@
+
+.text
+.type strlen,@function
+.global strlen
+
+strlen:
+ movl 4(%esp),%ecx
+ xorl %eax,%eax
+ jecxz .Lnull
+ decl %eax
+.Llbl: incl %eax
+ cmpb $0,(%ecx, %eax)
+ jne .Llbl
+.Lnull: ret
+
+.Lende:
+
+.size strlen,.Lende-strlen
diff --git a/mdk-stage1/dietlibc/i386/strncmp.S b/mdk-stage1/dietlibc/i386/strncmp.S
new file mode 100644
index 000000000..bf07b07d0
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/strncmp.S
@@ -0,0 +1,28 @@
+.text
+.align 0
+.global strncmp
+.type strncmp,@function
+strncmp:
+ push %ebx
+ movl %esp,%ebx
+ movl 12(%ebx),%edx
+ movl 16(%ebx),%ecx
+ movl 8(%ebx),%ebx
+.Lloop:
+ jecxz .Ldone
+ decl %ecx
+ movb (%ebx),%al
+ incl %edx
+ incl %ebx
+ movb %al,%ah
+ subb -1(%edx),%al
+ jnz .Lnotequal
+ testb %ah,%ah
+ jnz .Lloop
+
+.Ldone:
+ xorl %eax,%eax
+.Lnotequal:
+ movsx %al, %eax
+ popl %ebx
+ ret
diff --git a/mdk-stage1/dietlibc/i386/strncpy.S b/mdk-stage1/dietlibc/i386/strncpy.S
new file mode 100644
index 000000000..837b43c41
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/strncpy.S
@@ -0,0 +1,42 @@
+/*
+ Copyright (C) 2002 Thomas M. Ogrisegg
+
+ This is free software. You can redistribute and
+ modify it under the terms of the GNU General Public
+ Public License.
+
+ strncpy.S
+ i386 assembler implementation of strncpy(3)
+*/
+
+#include "dietfeatures.h"
+
+.text
+.globl strncpy
+.type strncpy,@function
+
+strncpy:
+ pushl %esi
+ pushl %edi
+ movl %esp, %ecx
+ movl 0x0c(%ecx), %edi
+ movl 0x10(%ecx), %esi
+ movl 0x14(%ecx), %ecx
+
+ movl %edi, %edx
+
+.Lloop:
+ dec %ecx
+ js .Lout
+ lodsb
+ stosb
+ or %al, %al
+ jnz .Lloop
+#ifdef WANT_FULL_POSIX_COMPAT
+ repnz stosb
+#endif
+.Lout:
+ movl %edx, %eax
+ popl %edi
+ popl %esi
+ ret
diff --git a/mdk-stage1/dietlibc/i386/strrchr.S b/mdk-stage1/dietlibc/i386/strrchr.S
new file mode 100644
index 000000000..9fd6e8b32
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/strrchr.S
@@ -0,0 +1,19 @@
+.text
+.globl strrchr
+.type strrchr,@function
+
+strrchr:
+ movl 0x4(%esp), %edx
+ movb 0x8(%esp), %cl
+ xorl %eax, %eax
+ decl %edx
+.Lloop:
+ incl %edx
+ cmpb $0x0,(%edx)
+ jz .Lret
+ cmpb %cl, (%edx)
+ jnz .Lloop
+ movl %edx, %eax
+ jmp .Lloop
+.Lret:
+ ret
diff --git a/mdk-stage1/dietlibc/i386/syscalls.h b/mdk-stage1/dietlibc/i386/syscalls.h
new file mode 100644
index 000000000..3cbf7b605
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/syscalls.h
@@ -0,0 +1,303 @@
+
+#define __NR_exit 1
+#define __NR_fork 2
+#define __NR_read 3
+#define __NR_write 4
+#define __NR_open 5
+#define __NR_close 6
+#define __NR_waitpid 7
+#define __NR_creat 8
+#define __NR_link 9
+#define __NR_unlink 10
+#define __NR_execve 11
+#define __NR_chdir 12
+#define __NR_time 13
+#define __NR_mknod 14
+#define __NR_chmod 15
+#define __NR_lchown 16
+#define __NR_break 17
+#define __NR_oldstat 18
+#define __NR_lseek 19
+#define __NR_getpid 20
+#define __NR_mount 21
+#define __NR_umount 22
+#define __NR_setuid 23
+#define __NR_getuid 24
+#define __NR_stime 25
+#define __NR_ptrace 26
+#define __NR_alarm 27
+#define __NR_oldfstat 28
+#define __NR_pause 29
+#define __NR_utime 30
+#define __NR_stty 31
+#define __NR_gtty 32
+#define __NR_access 33
+#define __NR_nice 34
+#define __NR_ftime 35
+#define __NR_sync 36
+#define __NR_kill 37
+#define __NR_rename 38
+#define __NR_mkdir 39
+#define __NR_rmdir 40
+#define __NR_dup 41
+#define __NR_pipe 42
+#define __NR_times 43
+#define __NR_prof 44
+#define __NR_brk 45
+#define __NR_setgid 46
+#define __NR_getgid 47
+#define __NR_signal 48
+#define __NR_geteuid 49
+#define __NR_getegid 50
+#define __NR_acct 51
+#define __NR_umount2 52
+#define __NR_lock 53
+#define __NR_ioctl 54
+#define __NR_fcntl 55
+#define __NR_mpx 56
+#define __NR_setpgid 57
+#define __NR_ulimit 58
+#define __NR_oldolduname 59
+#define __NR_umask 60
+#define __NR_chroot 61
+#define __NR_ustat 62
+#define __NR_dup2 63
+#define __NR_getppid 64
+#define __NR_getpgrp 65
+#define __NR_setsid 66
+#define __NR_sigaction 67
+#define __NR_sgetmask 68
+#define __NR_ssetmask 69
+#define __NR_setreuid 70
+#define __NR_setregid 71
+#define __NR_sigsuspend 72
+#define __NR_sigpending 73
+#define __NR_sethostname 74
+#define __NR_setrlimit 75
+#define __NR_getrlimit 76 /* Back compatible 2Gig limited rlimit */
+#define __NR_getrusage 77
+#define __NR_gettimeofday 78
+#define __NR_settimeofday 79
+#define __NR_getgroups 80
+#define __NR_setgroups 81
+#define __NR_select 82
+#define __NR_symlink 83
+#define __NR_oldlstat 84
+#define __NR_readlink 85
+#define __NR_uselib 86
+#define __NR_swapon 87
+#define __NR_reboot 88
+#define __NR_readdir 89
+#define __NR_mmap 90
+#define __NR_munmap 91
+#define __NR_truncate 92
+#define __NR_ftruncate 93
+#define __NR_fchmod 94
+#define __NR_fchown 95
+#define __NR_getpriority 96
+#define __NR_setpriority 97
+#define __NR_profil 98
+#define __NR_statfs 99
+#define __NR_fstatfs 100
+#define __NR_ioperm 101
+#define __NR_socketcall 102
+#define __NR_syslog 103
+#define __NR_setitimer 104
+#define __NR_getitimer 105
+#define __NR_stat 106
+#define __NR_lstat 107
+#define __NR_fstat 108
+#define __NR_olduname 109
+#define __NR_iopl 110
+#define __NR_vhangup 111
+#define __NR_idle 112
+#define __NR_vm86old 113
+#define __NR_wait4 114
+#define __NR_swapoff 115
+#define __NR_sysinfo 116
+#define __NR_ipc 117
+#define __NR_fsync 118
+#define __NR_sigreturn 119
+#define __NR_clone 120
+#define __NR_setdomainname 121
+#define __NR_uname 122
+#define __NR_modify_ldt 123
+#define __NR_adjtimex 124
+#define __NR_mprotect 125
+#define __NR_sigprocmask 126
+#define __NR_create_module 127
+#define __NR_init_module 128
+#define __NR_delete_module 129
+#define __NR_get_kernel_syms 130
+#define __NR_quotactl 131
+#define __NR_getpgid 132
+#define __NR_fchdir 133
+#define __NR_bdflush 134
+#define __NR_sysfs 135
+#define __NR_personality 136
+#define __NR_afs_syscall 137 /* Syscall for Andrew File System */
+#define __NR_setfsuid 138
+#define __NR_setfsgid 139
+#define __NR__llseek 140
+#define __NR_getdents 141
+#define __NR__newselect 142
+#define __NR_flock 143
+#define __NR_msync 144
+#define __NR_readv 145
+#define __NR_writev 146
+#define __NR_getsid 147
+#define __NR_fdatasync 148
+#define __NR__sysctl 149
+#define __NR_mlock 150
+#define __NR_munlock 151
+#define __NR_mlockall 152
+#define __NR_munlockall 153
+#define __NR_sched_setparam 154
+#define __NR_sched_getparam 155
+#define __NR_sched_setscheduler 156
+#define __NR_sched_getscheduler 157
+#define __NR_sched_yield 158
+#define __NR_sched_get_priority_max 159
+#define __NR_sched_get_priority_min 160
+#define __NR_sched_rr_get_interval 161
+#define __NR_nanosleep 162
+#define __NR_mremap 163
+#define __NR_setresuid 164
+#define __NR_getresuid 165
+#define __NR_vm86 166
+#define __NR_query_module 167
+#define __NR_poll 168
+#define __NR_nfsservctl 169
+#define __NR_setresgid 170
+#define __NR_getresgid 171
+#define __NR_prctl 172
+#define __NR_rt_sigreturn 173
+#define __NR_rt_sigaction 174
+#define __NR_rt_sigprocmask 175
+#define __NR_rt_sigpending 176
+#define __NR_rt_sigtimedwait 177
+#define __NR_rt_sigqueueinfo 178
+#define __NR_rt_sigsuspend 179
+#define __NR_pread 180
+#define __NR_pwrite 181
+#define __NR_chown 182
+#define __NR_getcwd 183
+#define __NR_capget 184
+#define __NR_capset 185
+#define __NR_sigaltstack 186
+#define __NR_sendfile 187
+#define __NR_getpmsg 188 /* some people actually want streams */
+#define __NR_putpmsg 189 /* some people actually want streams */
+#define __NR_vfork 190
+#define __NR_ugetrlimit 191 /* SuS compliant getrlimit */
+#define __NR_mmap2 192
+#define __NR_truncate64 193
+#define __NR_ftruncate64 194
+#define __NR_stat64 195
+#define __NR_lstat64 196
+#define __NR_fstat64 197
+#define __NR_lchown32 198
+#define __NR_getuid32 199
+#define __NR_getgid32 200
+#define __NR_geteuid32 201
+#define __NR_getegid32 202
+#define __NR_setreuid32 203
+#define __NR_setregid32 204
+#define __NR_getgroups32 205
+#define __NR_setgroups32 206
+#define __NR_fchown32 207
+#define __NR_setresuid32 208
+#define __NR_getresuid32 209
+#define __NR_setresgid32 210
+#define __NR_getresgid32 211
+#define __NR_chown32 212
+#define __NR_setuid32 213
+#define __NR_setgid32 214
+#define __NR_setfsuid32 215
+#define __NR_setfsgid32 216
+#define __NR_pivot_root 217
+#define __NR_mincore 218
+#define __NR_madvise 219
+#define __NR_madvise1 219 /* delete when C lib stub is removed */
+#define __NR_getdents64 220
+#define __NR_fcntl64 221
+#define __NR_security 223 /* syscall for security modules */
+#define __NR_gettid 224
+#define __NR_readahead 225
+#define __NR_setxattr 226
+#define __NR_lsetxattr 227
+#define __NR_fsetxattr 228
+#define __NR_getxattr 229
+#define __NR_lgetxattr 230
+#define __NR_fgetxattr 231
+#define __NR_listxattr 232
+#define __NR_llistxattr 233
+#define __NR_flistxattr 234
+#define __NR_removexattr 235
+#define __NR_lremovexattr 236
+#define __NR_fremovexattr 237
+#define __NR_tkill 238
+#define __NR_sendfile64 239
+#define __NR_futex 240
+#define __NR_sched_setaffinity 241
+#define __NR_sched_getaffinity 242
+#define __NR_set_thread_area 243
+#define __NR_get_thread_area 244
+#define __NR_io_setup 245
+#define __NR_io_destroy 246
+#define __NR_io_getevents 247
+#define __NR_io_submit 248
+#define __NR_io_cancel 249
+#define __NR_alloc_hugepages 250
+#define __NR_free_hugepages 251
+#define __NR_exit_group 252
+#define __NR_lookup_dcookie 253
+#define __NR_sys_epoll_create 254
+#define __NR_sys_epoll_ctl 255
+#define __NR_sys_epoll_wait 256
+#define __NR_remap_file_pages 257
+#define __NR_set_tid_address 258
+
+#define syscall_weak(name,wsym,sym) \
+.text; \
+.type wsym,@function; \
+.weak wsym; \
+wsym: ; \
+.type sym,@function; \
+.global sym; \
+sym: \
+ movb $__NR_##name,%al; \
+ jmp __unified_syscall; \
+.Lend##sym: ; \
+.size sym,.Lend##sym-sym
+
+#define syscall(name,sym) \
+.text; \
+.type sym,@function; \
+.global sym; \
+sym: \
+.ifle __NR_##name-255; \
+ movb $__NR_##name,%al; \
+ jmp __unified_syscall; \
+.else; \
+ movw $__NR_##name,%ax; \
+ jmp __unified_syscall_256; \
+.endif; \
+.Lend##sym: ; \
+.size sym,.Lend##sym-sym
+
+#ifndef __PIC__
+#define __socketcall(name,NAME) \
+.text; \
+.type name,@function; \
+.weak name; \
+name: ; \
+.global __libc_##name; \
+__libc_##name: ; \
+ movb $SYS_##NAME,%al; \
+ jmp socketcall; \
+.Lend##name:; \
+.size name,.Lend##name-name
+#else
+#define __socketcall(name,NAME)
+#endif
diff --git a/mdk-stage1/dietlibc/i386/tan.S b/mdk-stage1/dietlibc/i386/tan.S
new file mode 100644
index 000000000..4904c2d59
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/tan.S
@@ -0,0 +1,12 @@
+
+.text
+.type tan,@function
+.global tan
+tan:
+ fldl 4(%esp)
+ fsincos
+ fdivrp
+ ret
+
+.Lende:
+.size tan,.Lende-tan
diff --git a/mdk-stage1/dietlibc/i386/tanh.S b/mdk-stage1/dietlibc/i386/tanh.S
new file mode 100644
index 000000000..61d3f3376
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/tanh.S
@@ -0,0 +1,32 @@
+
+.text
+.type tanh,@function
+.global tanh
+
+tanh: # note: exp(x) = 2^(x*log2(e))
+ fldl2e
+ fmull 4(%esp) # x*log2(e)
+ fld %st(0) # x*log2(e) x*log2(e)
+ frndint # int(x*log2(e)) x*log2(e)
+ fxch # x*log2(e) int(x*log2(e))
+ fsub %st(1),%st(0) # frac(x*log2(e)) int(x*log2(e))
+ f2xm1 # 2^(fract(x*log2(e)))-1 int(x*log2(e))
+ fld1 # 1 2^(fract(x*log2(e)))-1 int(x*log2(e))
+ faddp %st(0),%st(1) # 2^(fract(x*log2(e))) int(x*log2(e))
+ fscale # 2^(x*log2(e)) int(x*log2(e))
+ fstp %st(1) # 2^(x*log2(e))
+
+# now we have y = exp(x), but tanh(x) = (y - 1/y) / (y + 1/y)
+
+ fld1
+ fdiv %st(1),%st(0) # 1/y y
+ fld %st(0) # 1/y 1/y y
+ fadd %st(2) # y+1/y 1/y y
+ fxch %st(2) # y 1/y y+1/y
+ fsubp # y-1/y y+1/y
+ fdivp # (y-1/y)/(y+1/y)
+ ret
+
+.Lende:
+
+.size tanh,.ende-tanh
diff --git a/mdk-stage1/dietlibc/i386/usleep.S b/mdk-stage1/dietlibc/i386/usleep.S
new file mode 100644
index 000000000..7c0cc6ce7
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/usleep.S
@@ -0,0 +1,31 @@
+#include "PIC.h"
+
+.text
+.global usleep
+.type usleep,@function
+
+usleep:
+ movl 4(%esp),%eax
+ PIC_SAVE # non-PIC: empty line
+ PIC_INIT # non-PIC: empty line
+ xorl %edx,%edx
+ movl $1000000,%ecx
+ divl %ecx
+ imull $1000,%edx
+ pushl %edx
+ pushl %eax
+ movl %esp,%eax
+ pushl %eax
+ pushl %eax
+#ifdef __DYN_LIB
+ call nanosleep@PLT
+#else
+ call nanosleep
+#endif
+ addl $16,%esp
+ PIC_RESTORE # non-PIC: empty line
+ ret
+
+.Lende:
+.size usleep,.Lende-usleep
+
diff --git a/mdk-stage1/dietlibc/i386/vfork.S b/mdk-stage1/dietlibc/i386/vfork.S
new file mode 100644
index 000000000..c07c5f6af
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/vfork.S
@@ -0,0 +1,9 @@
+.text
+.globl vfork
+vfork:
+ popl %edx
+ xorl %eax,%eax
+ movb $190, %al
+ int $0x80
+ jmpl *%edx
+.size vfork, . - vfork
diff --git a/mdk-stage1/dietlibc/i386/write12.S b/mdk-stage1/dietlibc/i386/write12.S
new file mode 100644
index 000000000..a40f63a86
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/write12.S
@@ -0,0 +1,37 @@
+#include "PIC.h"
+
+.text
+
+.global __write1
+.type __write1,@function
+
+.global __write2
+.type __write2,@function
+
+ # regparm=1, daher Stringadresse in %eax
+__write2:
+ clc # CY = 0
+ .byte 0xB2 # zusammen mit nächstem Byte: mov dl,0xF9
+__write1:
+ stc # CY = 1
+ sbbl %ecx,%ecx # __write2: ecx=0, __write1: ecx=-1
+ incl %ecx
+ incl %ecx # __write2: ecx=2, __write1: ecx=1
+ xorl %edx,%edx
+ decl %edx
+.Lnext: incl %edx
+ cmpb %ch,(%edx,%eax) # ch=0, da bei beiden Filedescriptoren Bits 15:8 0 sind
+ jnz .Lnext # Stringlänge in edx, ohne eax zerstört zu haben
+ PIC_SAVE # non-PIC: empty line
+ PIC_INIT # non-PIC: empty line
+ pushl %edx
+ pushl %eax
+ pushl %ecx
+#ifdef __DYN_LIB
+ call write@PLT
+#else
+ call write # alles ruf uf dn Stack und ab damit
+#endif
+ addl $12,%esp # und das leidvolle Putzen
+ PIC_RESTORE # non-PIC: empty line
+ ret
diff --git a/mdk-stage1/dietlibc/ia64/Makefile.add b/mdk-stage1/dietlibc/ia64/Makefile.add
new file mode 100644
index 000000000..f660930af
--- /dev/null
+++ b/mdk-stage1/dietlibc/ia64/Makefile.add
@@ -0,0 +1,2 @@
+VPATH:=ia64:syscalls.s:$(VPATH)
+LIBOBJ+=$(OBJDIR)/__time.o $(OBJDIR)/__waitpid.o $(OBJDIR)/__nice.o $(OBJDIR)/__alarm.o
diff --git a/mdk-stage1/dietlibc/ia64/README b/mdk-stage1/dietlibc/ia64/README
new file mode 100644
index 000000000..684364d93
--- /dev/null
+++ b/mdk-stage1/dietlibc/ia64/README
@@ -0,0 +1,4 @@
+A Port for IA64.
+
+Does not yet support: clone, FPU and profiling. And includes
+some subtle bugs which will hopefully be fixed later.
diff --git a/mdk-stage1/dietlibc/ia64/__alarm.c b/mdk-stage1/dietlibc/ia64/__alarm.c
new file mode 100644
index 000000000..e2c499f2c
--- /dev/null
+++ b/mdk-stage1/dietlibc/ia64/__alarm.c
@@ -0,0 +1 @@
+#include "alpha/__alarm.c"
diff --git a/mdk-stage1/dietlibc/ia64/__longjmp.S b/mdk-stage1/dietlibc/ia64/__longjmp.S
new file mode 100644
index 000000000..698bda528
--- /dev/null
+++ b/mdk-stage1/dietlibc/ia64/__longjmp.S
@@ -0,0 +1 @@
+/* No longjmp yet */
diff --git a/mdk-stage1/dietlibc/ia64/__nice.c b/mdk-stage1/dietlibc/ia64/__nice.c
new file mode 100644
index 000000000..012ea2628
--- /dev/null
+++ b/mdk-stage1/dietlibc/ia64/__nice.c
@@ -0,0 +1,6 @@
+#include <sys/resource.h>
+
+int nice(int x) {
+ if (setpriority(PRIO_PROCESS,0,x)) return -1;
+ return getpriority(PRIO_PROCESS,0);
+}
diff --git a/mdk-stage1/dietlibc/ia64/__testandset.S b/mdk-stage1/dietlibc/ia64/__testandset.S
new file mode 100644
index 000000000..d462e3c58
--- /dev/null
+++ b/mdk-stage1/dietlibc/ia64/__testandset.S
@@ -0,0 +1,11 @@
+.text
+.globl __testandset
+.proc __testandset
+__testandset:
+ mov ar.ccv = r0
+ mov r29 = 1
+ ld8 r3 = [r32]
+ cmpxchg8.acq r8 = [r32], r29, ar.ccv /* cmpxchg is atomic */
+ br.ret.sptk.clr b0
+.endp __testandset
+.size __testandset, . - __testandset
diff --git a/mdk-stage1/dietlibc/ia64/__time.c b/mdk-stage1/dietlibc/ia64/__time.c
new file mode 100644
index 000000000..7547acb1d
--- /dev/null
+++ b/mdk-stage1/dietlibc/ia64/__time.c
@@ -0,0 +1,14 @@
+#include <time.h>
+#include <sys/time.h>
+
+time_t time(time_t*t) {
+ struct timeval tv;
+ time_t ret;
+ if (gettimeofday(&tv,0)) {
+ ret=(time_t)-1;
+ } else {
+ ret=(time_t)tv.tv_sec;
+ }
+ if (t) *t=ret;
+ return ret;
+}
diff --git a/mdk-stage1/dietlibc/ia64/__waitpid.c b/mdk-stage1/dietlibc/ia64/__waitpid.c
new file mode 100644
index 000000000..8c228f375
--- /dev/null
+++ b/mdk-stage1/dietlibc/ia64/__waitpid.c
@@ -0,0 +1,5 @@
+#include <sys/types.h>
+
+pid_t waitpid(int pid, int * wait_stat, int flags) {
+ return wait4(pid, wait_stat, flags, 0);
+}
diff --git a/mdk-stage1/dietlibc/ia64/accept.S b/mdk-stage1/dietlibc/ia64/accept.S
new file mode 100644
index 000000000..7bdc38c7e
--- /dev/null
+++ b/mdk-stage1/dietlibc/ia64/accept.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall(accept, accept);
diff --git a/mdk-stage1/dietlibc/ia64/bind.S b/mdk-stage1/dietlibc/ia64/bind.S
new file mode 100644
index 000000000..05849d470
--- /dev/null
+++ b/mdk-stage1/dietlibc/ia64/bind.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall(bind, bind);
diff --git a/mdk-stage1/dietlibc/ia64/clone.S b/mdk-stage1/dietlibc/ia64/clone.S
new file mode 100644
index 000000000..ba768141c
--- /dev/null
+++ b/mdk-stage1/dietlibc/ia64/clone.S
@@ -0,0 +1,41 @@
+/* This is untested code which probably won´t work out of the box! */
+
+#include "syscalls.h"
+#include <errno.h>
+
+.text
+.globl __clone
+.proc __clone
+.weak __clone2
+__clone2:
+__clone:
+ mov r8 = EINVAL
+ cmp.eq p6,p0=0,r32
+(p6) br.cond.spnt.few __error_unified_syscall
+ cmp.eq p6,p0=0,r33
+(p6) br.cond.spnt.few __error_unified_syscall
+ flushrs
+
+ mov.m r17 = ar.rsc
+ mov r14 = r32
+ mov r18 = r33
+ mov r16 = r36;;
+ mov r15 = __NR_clone2
+ break 0x100000
+ cmp.eq p6,p0=-1,r10
+(p6) br.cond.spnt.few __error_unified_syscall
+ cmp.eq p6,p7=0,r8
+(p6) ld8 r34=[r14],8
+(p6) mov.m ar.bspstore=r18
+(p6) mov r32 = r16
+ mov.m ar.rsc = r17
+(p7) br.ret.sptk b0
+ ld8 r1 = [r14]
+ mov b6 = r34
+ br.call.dptk.few b0=b6
+ mov r32 = r8
+ br.call.dptk.few b0=__error_unified_syscall
+ br.ret.sptk.few b0
+.endp __clone
+.endp __clone2
+.size __clone, . - __clone
diff --git a/mdk-stage1/dietlibc/ia64/connect.S b/mdk-stage1/dietlibc/ia64/connect.S
new file mode 100644
index 000000000..5fbd151ae
--- /dev/null
+++ b/mdk-stage1/dietlibc/ia64/connect.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall(connect, connect);
diff --git a/mdk-stage1/dietlibc/ia64/fork.S b/mdk-stage1/dietlibc/ia64/fork.S
new file mode 100644
index 000000000..3b253a80b
--- /dev/null
+++ b/mdk-stage1/dietlibc/ia64/fork.S
@@ -0,0 +1,8 @@
+#include "syscalls.h"
+
+.text
+.globl fork
+fork:
+ mov r15 = __NR_clone
+ mov r32 = 17
+ br __unified_syscall
diff --git a/mdk-stage1/dietlibc/ia64/getpeername.S b/mdk-stage1/dietlibc/ia64/getpeername.S
new file mode 100644
index 000000000..fdaa1038a
--- /dev/null
+++ b/mdk-stage1/dietlibc/ia64/getpeername.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall(getpeername, getpeername);
diff --git a/mdk-stage1/dietlibc/ia64/getsockname.S b/mdk-stage1/dietlibc/ia64/getsockname.S
new file mode 100644
index 000000000..1ea0bc000
--- /dev/null
+++ b/mdk-stage1/dietlibc/ia64/getsockname.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall(getsockname, getsockname);
diff --git a/mdk-stage1/dietlibc/ia64/getsockopt.S b/mdk-stage1/dietlibc/ia64/getsockopt.S
new file mode 100644
index 000000000..465c4e08e
--- /dev/null
+++ b/mdk-stage1/dietlibc/ia64/getsockopt.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall(getsockopt, getsockopt);
diff --git a/mdk-stage1/dietlibc/ia64/listen.S b/mdk-stage1/dietlibc/ia64/listen.S
new file mode 100644
index 000000000..66a3fe376
--- /dev/null
+++ b/mdk-stage1/dietlibc/ia64/listen.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall(listen, listen);
diff --git a/mdk-stage1/dietlibc/ia64/mmap.S b/mdk-stage1/dietlibc/ia64/mmap.S
new file mode 100644
index 000000000..cca4bbdbb
--- /dev/null
+++ b/mdk-stage1/dietlibc/ia64/mmap.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall (mmap, mmap)
diff --git a/mdk-stage1/dietlibc/ia64/msgctl.S b/mdk-stage1/dietlibc/ia64/msgctl.S
new file mode 100644
index 000000000..d7caed2cc
--- /dev/null
+++ b/mdk-stage1/dietlibc/ia64/msgctl.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall(msgctl,msgctl)
diff --git a/mdk-stage1/dietlibc/ia64/msgget.S b/mdk-stage1/dietlibc/ia64/msgget.S
new file mode 100644
index 000000000..518d67ac4
--- /dev/null
+++ b/mdk-stage1/dietlibc/ia64/msgget.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall(msgget,msgget)
diff --git a/mdk-stage1/dietlibc/ia64/msgrcv.S b/mdk-stage1/dietlibc/ia64/msgrcv.S
new file mode 100644
index 000000000..ab62e6c30
--- /dev/null
+++ b/mdk-stage1/dietlibc/ia64/msgrcv.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall(msgrcv,msgrcv)
diff --git a/mdk-stage1/dietlibc/ia64/msgsnd.S b/mdk-stage1/dietlibc/ia64/msgsnd.S
new file mode 100644
index 000000000..890a996a2
--- /dev/null
+++ b/mdk-stage1/dietlibc/ia64/msgsnd.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall(msgsnd,msgsnd)
diff --git a/mdk-stage1/dietlibc/ia64/pipe.S b/mdk-stage1/dietlibc/ia64/pipe.S
new file mode 100644
index 000000000..c3bf4570b
--- /dev/null
+++ b/mdk-stage1/dietlibc/ia64/pipe.S
@@ -0,0 +1,20 @@
+#include "syscalls.h"
+
+.text
+.globl pipe
+.proc pipe
+
+pipe:
+ st8 [r12] = r32
+ mov r15 = __NR_pipe
+ break.i 0x100000
+ ld8 r2 = [r12]
+ cmp.eq p7,p6=-1,r10
+(p6) st4 [r2] = r8,4
+ mov r8 = r0
+(p7) br.cond.spnt.few __error_unified_syscall
+(p6) st4 [r2] = r9
+(p6) br.ret.sptk.few b0
+
+.endp pipe
+.size pipe, . - pipe
diff --git a/mdk-stage1/dietlibc/ia64/recv.S b/mdk-stage1/dietlibc/ia64/recv.S
new file mode 100644
index 000000000..1f1640390
--- /dev/null
+++ b/mdk-stage1/dietlibc/ia64/recv.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall(recv, recv);
diff --git a/mdk-stage1/dietlibc/ia64/recvfrom.S b/mdk-stage1/dietlibc/ia64/recvfrom.S
new file mode 100644
index 000000000..d3c2e602f
--- /dev/null
+++ b/mdk-stage1/dietlibc/ia64/recvfrom.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall(recvfrom, recvfrom);
diff --git a/mdk-stage1/dietlibc/ia64/recvmsg.S b/mdk-stage1/dietlibc/ia64/recvmsg.S
new file mode 100644
index 000000000..cfbbafdc1
--- /dev/null
+++ b/mdk-stage1/dietlibc/ia64/recvmsg.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall(recvmsg, recvmsg);
diff --git a/mdk-stage1/dietlibc/ia64/semctl.S b/mdk-stage1/dietlibc/ia64/semctl.S
new file mode 100644
index 000000000..e215ed955
--- /dev/null
+++ b/mdk-stage1/dietlibc/ia64/semctl.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall(semctl,semctl)
diff --git a/mdk-stage1/dietlibc/ia64/semget.S b/mdk-stage1/dietlibc/ia64/semget.S
new file mode 100644
index 000000000..67f488546
--- /dev/null
+++ b/mdk-stage1/dietlibc/ia64/semget.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall(semget,semget)
diff --git a/mdk-stage1/dietlibc/ia64/semop.S b/mdk-stage1/dietlibc/ia64/semop.S
new file mode 100644
index 000000000..81b6fc606
--- /dev/null
+++ b/mdk-stage1/dietlibc/ia64/semop.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall(semop,semop)
diff --git a/mdk-stage1/dietlibc/ia64/send.S b/mdk-stage1/dietlibc/ia64/send.S
new file mode 100644
index 000000000..38f47f398
--- /dev/null
+++ b/mdk-stage1/dietlibc/ia64/send.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall(send, send);
diff --git a/mdk-stage1/dietlibc/ia64/sendmsg.S b/mdk-stage1/dietlibc/ia64/sendmsg.S
new file mode 100644
index 000000000..c2bc80f72
--- /dev/null
+++ b/mdk-stage1/dietlibc/ia64/sendmsg.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall(sendmsg, sendmsg);
diff --git a/mdk-stage1/dietlibc/ia64/sendto.S b/mdk-stage1/dietlibc/ia64/sendto.S
new file mode 100644
index 000000000..1579a3b45
--- /dev/null
+++ b/mdk-stage1/dietlibc/ia64/sendto.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall(sendto, sendto);
diff --git a/mdk-stage1/dietlibc/ia64/setjmp.S b/mdk-stage1/dietlibc/ia64/setjmp.S
new file mode 100644
index 000000000..f0f5bc431
--- /dev/null
+++ b/mdk-stage1/dietlibc/ia64/setjmp.S
@@ -0,0 +1 @@
+/* No, I am not going to save 128 registers */
diff --git a/mdk-stage1/dietlibc/ia64/setsockopt.S b/mdk-stage1/dietlibc/ia64/setsockopt.S
new file mode 100644
index 000000000..45fcfbb6c
--- /dev/null
+++ b/mdk-stage1/dietlibc/ia64/setsockopt.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall(setsockopt, setsockopt);
diff --git a/mdk-stage1/dietlibc/ia64/shmat.S b/mdk-stage1/dietlibc/ia64/shmat.S
new file mode 100644
index 000000000..51248173d
--- /dev/null
+++ b/mdk-stage1/dietlibc/ia64/shmat.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall(shmat,shmat)
diff --git a/mdk-stage1/dietlibc/ia64/shmctl.S b/mdk-stage1/dietlibc/ia64/shmctl.S
new file mode 100644
index 000000000..d56caace4
--- /dev/null
+++ b/mdk-stage1/dietlibc/ia64/shmctl.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall(shmctl,shmctl)
diff --git a/mdk-stage1/dietlibc/ia64/shmdt.S b/mdk-stage1/dietlibc/ia64/shmdt.S
new file mode 100644
index 000000000..d9812a799
--- /dev/null
+++ b/mdk-stage1/dietlibc/ia64/shmdt.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall(shmdt,shmdt)
diff --git a/mdk-stage1/dietlibc/ia64/shmget.S b/mdk-stage1/dietlibc/ia64/shmget.S
new file mode 100644
index 000000000..82914223f
--- /dev/null
+++ b/mdk-stage1/dietlibc/ia64/shmget.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall(shmget,shmget)
diff --git a/mdk-stage1/dietlibc/ia64/shutdown.S b/mdk-stage1/dietlibc/ia64/shutdown.S
new file mode 100644
index 000000000..024e99e18
--- /dev/null
+++ b/mdk-stage1/dietlibc/ia64/shutdown.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall(shutdown, shutdown);
diff --git a/mdk-stage1/dietlibc/ia64/socket.S b/mdk-stage1/dietlibc/ia64/socket.S
new file mode 100644
index 000000000..cc453881f
--- /dev/null
+++ b/mdk-stage1/dietlibc/ia64/socket.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall(socket, socket);
diff --git a/mdk-stage1/dietlibc/ia64/socketpair.S b/mdk-stage1/dietlibc/ia64/socketpair.S
new file mode 100644
index 000000000..d92eaa4d8
--- /dev/null
+++ b/mdk-stage1/dietlibc/ia64/socketpair.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall(socketpair, socketpair);
diff --git a/mdk-stage1/dietlibc/ia64/start.S b/mdk-stage1/dietlibc/ia64/start.S
new file mode 100644
index 000000000..dbacb25f6
--- /dev/null
+++ b/mdk-stage1/dietlibc/ia64/start.S
@@ -0,0 +1,45 @@
+/*
+ Copyright (C) 2002 Thomas M. Ogrisegg
+
+ This is free software. You can redistribute and
+ modify it under the terms of the GNU General Public
+ Public License.
+
+ This file is part of the IA64-Port of the dietlibc
+
+ start.S
+ Implemenation of the _start startup function
+*/
+
+.psr abi64
+.psr lsb
+.lsb
+
+.text
+.globl _start
+.proc _start
+
+_start:
+ alloc r2 = ar.pfs,0,0,7,0
+ adds out1 = 16, sp /* base arguments */
+ movl gp = @gprel(0f) /* base offset */
+ ;;
+0:
+ ld8 out0 = [out1], 8 /* load argc and set argv */
+ mov r9 = ip
+ ;;
+ shladd out2=out0,3,out1 /* envp = argv+8*argc */
+ sub gp = r9, gp /* subtract program counter */
+ ;;
+ addl r15 = @ltoff(environ#), gp /* offset to environ */
+ adds out2 = 8, out2 /* envp += 8 */
+ ;;
+ ld8 r14 = [r15]
+ ;;
+ st8 [r14] = out2 /* store envp in environ */
+ br.call.sptk.few rp = main /* call main */
+ ;;
+ mov r32 = r8 /* store return code */
+ br _exit /* branch to _exit */
+.endp _start
+.size _start, . - _start
diff --git a/mdk-stage1/dietlibc/ia64/syscalls.h b/mdk-stage1/dietlibc/ia64/syscalls.h
new file mode 100644
index 000000000..65eda0ed2
--- /dev/null
+++ b/mdk-stage1/dietlibc/ia64/syscalls.h
@@ -0,0 +1,242 @@
+#ifndef __DLIBC_SYSCALL_H_
+#define __DLIBC_SYSCALL_H_
+
+#define __NR_ni_syscall 1024
+#define __NR_exit 1025
+#define __NR_read 1026
+#define __NR_write 1027
+#define __NR_open 1028
+#define __NR_close 1029
+#define __NR_creat 1030
+#define __NR_link 1031
+#define __NR_unlink 1032
+#define __NR_execve 1033
+#define __NR_chdir 1034
+#define __NR_fchdir 1035
+#define __NR_utimes 1036
+#define __NR_mknod 1037
+#define __NR_chmod 1038
+#define __NR_chown 1039
+#define __NR_lseek 1040
+#define __NR_getpid 1041
+#define __NR_getppid 1042
+#define __NR_mount 1043
+#define __NR_umount 1044
+#define __NR_setuid 1045
+#define __NR_getuid 1046
+#define __NR_geteuid 1047
+#define __NR_ptrace 1048
+#define __NR_access 1049
+#define __NR_sync 1050
+#define __NR_fsync 1051
+#define __NR_fdatasync 1052
+#define __NR_kill 1053
+#define __NR_rename 1054
+#define __NR_mkdir 1055
+#define __NR_rmdir 1056
+#define __NR_dup 1057
+#define __NR_pipe 1058
+#define __NR_times 1059
+#define __NR_brk 1060
+#define __NR_setgid 1061
+#define __NR_getgid 1062
+#define __NR_getegid 1063
+#define __NR_acct 1064
+#define __NR_ioctl 1065
+#define __NR_fcntl 1066
+#define __NR_umask 1067
+#define __NR_chroot 1068
+#define __NR_ustat 1069
+#define __NR_dup2 1070
+#define __NR_setreuid 1071
+#define __NR_setregid 1072
+#define __NR_getresuid 1073
+#define __NR_setresuid 1074
+#define __NR_getresgid 1075
+#define __NR_setresgid 1076
+#define __NR_getgroups 1077
+#define __NR_setgroups 1078
+#define __NR_getpgid 1079
+#define __NR_setpgid 1080
+#define __NR_setsid 1081
+#define __NR_getsid 1082
+#define __NR_sethostname 1083
+#define __NR_setrlimit 1084
+#define __NR_getrlimit 1085
+#define __NR_getrusage 1086
+#define __NR_gettimeofday 1087
+#define __NR_settimeofday 1088
+#define __NR_select 1089
+#define __NR_poll 1090
+#define __NR_symlink 1091
+#define __NR_readlink 1092
+#define __NR_uselib 1093
+#define __NR_swapon 1094
+#define __NR_swapoff 1095
+#define __NR_reboot 1096
+#define __NR_truncate 1097
+#define __NR_ftruncate 1098
+#define __NR_fchmod 1099
+#define __NR_fchown 1100
+#define __NR_getpriority 1101
+#define __NR_setpriority 1102
+#define __NR_statfs 1103
+#define __NR_fstatfs 1104
+#define __NR_gettid 1105
+#define __NR_semget 1106
+#define __NR_semop 1107
+#define __NR_semctl 1108
+#define __NR_msgget 1109
+#define __NR_msgsnd 1110
+#define __NR_msgrcv 1111
+#define __NR_msgctl 1112
+#define __NR_shmget 1113
+#define __NR_shmat 1114
+#define __NR_shmdt 1115
+#define __NR_shmctl 1116
+#define __NR_syslog 1117
+#define __NR_setitimer 1118
+#define __NR_getitimer 1119
+#define __NR_old_stat 1120
+#define __NR_old_lstat 1121
+#define __NR_old_fstat 1122
+#define __NR_vhangup 1123
+#define __NR_lchown 1124
+#define __NR_vm86 1125
+#define __NR_wait4 1126
+#define __NR_sysinfo 1127
+#define __NR_clone 1128
+#define __NR_setdomainname 1129
+#define __NR_uname 1130
+#define __NR_adjtimex 1131
+#define __NR_create_module 1132
+#define __NR_init_module 1133
+#define __NR_delete_module 1134
+#define __NR_get_kernel_syms 1135
+#define __NR_query_module 1136
+#define __NR_quotactl 1137
+#define __NR_bdflush 1138
+#define __NR_sysfs 1139
+#define __NR_personality 1140
+#define __NR_afs_syscall 1141
+#define __NR_setfsuid 1142
+#define __NR_setfsgid 1143
+#define __NR_getdents 1144
+#define __NR_flock 1145
+#define __NR_readv 1146
+#define __NR_writev 1147
+#define __NR_pread 1148
+#define __NR_pwrite 1149
+#define __NR__sysctl 1150
+#define __NR_mmap 1151
+#define __NR_munmap 1152
+#define __NR_mlock 1153
+#define __NR_mlockall 1154
+#define __NR_mprotect 1155
+#define __NR_mremap 1156
+#define __NR_msync 1157
+#define __NR_munlock 1158
+#define __NR_munlockall 1159
+#define __NR_sched_getparam 1160
+#define __NR_sched_setparam 1161
+#define __NR_sched_getscheduler 1162
+#define __NR_sched_setscheduler 1163
+#define __NR_sched_yield 1164
+#define __NR_sched_get_priority_max 1165
+#define __NR_sched_get_priority_min 1166
+#define __NR_sched_rr_get_interval 1167
+#define __NR_nanosleep 1168
+#define __NR_nfsservctl 1169
+#define __NR_prctl 1170
+#define __NR_mmap2 1172
+#define __NR_pciconfig_read 1173
+#define __NR_pciconfig_write 1174
+#define __NR_perfmonctl 1175
+#define __NR_sigaltstack 1176
+#define __NR_rt_sigaction 1177
+#define __NR_rt_sigpending 1178
+#define __NR_rt_sigprocmask 1179
+#define __NR_rt_sigqueueinfo 1180
+#define __NR_rt_sigreturn 1181
+#define __NR_rt_sigsuspend 1182
+#define __NR_rt_sigtimedwait 1183
+#define __NR_getcwd 1184
+#define __NR_capget 1185
+#define __NR_capset 1186
+#define __NR_sendfile 1187
+#define __NR_getpmsg 1188
+#define __NR_putpmsg 1189
+#define __NR_socket 1190
+#define __NR_bind 1191
+#define __NR_connect 1192
+#define __NR_listen 1193
+#define __NR_accept 1194
+#define __NR_getsockname 1195
+#define __NR_getpeername 1196
+#define __NR_socketpair 1197
+#define __NR_send 1198
+#define __NR_sendto 1199
+#define __NR_recv 1200
+#define __NR_recvfrom 1201
+#define __NR_shutdown 1202
+#define __NR_setsockopt 1203
+#define __NR_getsockopt 1204
+#define __NR_sendmsg 1205
+#define __NR_recvmsg 1206
+#define __NR_pivot_root 1207
+#define __NR_mincore 1208
+#define __NR_madvise 1209
+#define __NR_stat 1210
+#define __NR_lstat 1211
+#define __NR_fstat 1212
+#define __NR_clone2 1213
+#define __NR_getdents64 1214
+#define __NR_getunwind 1215
+#define __NR_readahead 1216
+#define __NR_setxattr 1217
+#define __NR_lsetxattr 1218
+#define __NR_fsetxattr 1219
+#define __NR_getxattr 1220
+#define __NR_lgetxattr 1221
+#define __NR_fgetxattr 1222
+#define __NR_listxattr 1223
+#define __NR_llistxattr 1224
+#define __NR_flistxattr 1225
+#define __NR_removexattr 1226
+#define __NR_lremovexattr 1227
+#define __NR_fremovexattr 1228
+#define __NR_tkill 1229
+#define __NR_futex 1230
+#define __NR_sched_setaffinity 1231
+#define __NR_sched_getaffinity 1232
+#define __NR_security 1233
+#define __NR_alloc_hugepages 1234
+#define __NR_free_hugepages 1235
+#define __NR_exit_group 1236
+#define __NR_lookup_dcookie 1237
+#define __NR_io_setup 1238
+#define __NR_io_destroy 1239
+#define __NR_io_getevents 1240
+#define __NR_io_submit 1241
+#define __NR_io_cancel 1242
+#define __NR_epoll_create 1243
+#define __NR_epoll_ctl 1244
+#define __NR_epoll_wait 1245
+
+#define syscall(name, sym) \
+.text; \
+.globl sym; \
+sym: \
+ mov r15 = __NR_##name; \
+ br __unified_syscall;
+
+#define syscall_weak(name, sym, wsym) \
+.text; \
+.weak wsym; \
+wsym: \
+.globl sym; \
+sym: \
+ mov r15 = __NR_##name; \
+ br __unified_syscall;
+
+#endif
diff --git a/mdk-stage1/dietlibc/ia64/unified.S b/mdk-stage1/dietlibc/ia64/unified.S
new file mode 100644
index 000000000..998fba75e
--- /dev/null
+++ b/mdk-stage1/dietlibc/ia64/unified.S
@@ -0,0 +1,46 @@
+/*
+ Copyright (C) 2002 Thomas M. Ogrisegg
+
+ This is free software. You can redistribute and
+ modify it under the terms of the GNU General Public
+ Public License.
+
+ This file is part of the ia64-Port of dietlibc
+
+ unified.S
+ General system-call interface
+*/
+
+.lsb
+
+.text
+
+.globl __unified_syscall
+.proc __unified_syscall
+.globl __error_unified_syscall
+.proc __error_unified_syscall
+.globl _exit
+.proc _exit
+
+_exit:
+ mov r15 = 1025
+.endp _exit
+.size _exit, . - _exit
+
+__unified_syscall:
+ break.i 0x100000
+ movl r2=errno
+ cmp.eq p6,p0=-1,r10
+ ;;
+__error_unified_syscall:
+(p6) st4 [r2]=r8
+(p6) mov r8=-1
+
+#include "dietuglyweaks.h"
+
+ br.ret.sptk.few rp
+
+.endp __unified_syscall
+.endp __error_unified_syscall
+.size __unified_syscall, __error_unified_syscall - __unified_syscall
+.size __error_unified_syscall, . - __error_unified_syscall
diff --git a/mdk-stage1/dietlibc/ia64/utime.S b/mdk-stage1/dietlibc/ia64/utime.S
new file mode 100644
index 000000000..a9a8aada6
--- /dev/null
+++ b/mdk-stage1/dietlibc/ia64/utime.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall(utimes,utime)
diff --git a/mdk-stage1/dietlibc/ia64/vfork.S b/mdk-stage1/dietlibc/ia64/vfork.S
new file mode 100644
index 000000000..e59f04364
--- /dev/null
+++ b/mdk-stage1/dietlibc/ia64/vfork.S
@@ -0,0 +1,8 @@
+#include "syscalls.h"
+
+.text
+.globl vfork
+vfork:
+ mov r15 = __NR_clone
+ mov r32 = 16657
+ br __unified_syscall
diff --git a/mdk-stage1/dietlibc/include/asm/alpha-sigcontext.h b/mdk-stage1/dietlibc/include/asm/alpha-sigcontext.h
new file mode 100644
index 000000000..13faab0b5
--- /dev/null
+++ b/mdk-stage1/dietlibc/include/asm/alpha-sigcontext.h
@@ -0,0 +1,29 @@
+struct sigcontext {
+ /*
+ * What should we have here? I'd probably better use the same
+ * stack layout as OSF/1, just in case we ever want to try
+ * running their binaries..
+ *
+ * This is the basic layout, but I don't know if we'll ever
+ * actually fill in all the values..
+ */
+ long sc_onstack;
+ long sc_mask;
+ long sc_pc;
+ long sc_ps;
+ long sc_regs[32];
+ long sc_ownedfp;
+ long sc_fpregs[32];
+ unsigned long sc_fpcr;
+ unsigned long sc_fp_control;
+ unsigned long sc_reserved1, sc_reserved2;
+ unsigned long sc_ssize;
+ char * sc_sbase;
+ unsigned long sc_traparg_a0;
+ unsigned long sc_traparg_a1;
+ unsigned long sc_traparg_a2;
+ unsigned long sc_fp_trap_pc;
+ unsigned long sc_fp_trigger_sum;
+ unsigned long sc_fp_trigger_inst;
+};
+
diff --git a/mdk-stage1/dietlibc/include/asm/arm-sigcontext.h b/mdk-stage1/dietlibc/include/asm/arm-sigcontext.h
new file mode 100644
index 000000000..26fa04e64
--- /dev/null
+++ b/mdk-stage1/dietlibc/include/asm/arm-sigcontext.h
@@ -0,0 +1,32 @@
+
+#define PC(ctx) (ctx.arm_pc)
+
+/*
+ * Signal context structure - contains all info to do with the state
+ * before the signal handler was invoked. Note: only add new entries
+ * to the end of the structure.
+ */
+struct sigcontext {
+ unsigned long trap_no;
+ unsigned long error_code;
+ unsigned long oldmask;
+ unsigned long arm_r0;
+ unsigned long arm_r1;
+ unsigned long arm_r2;
+ unsigned long arm_r3;
+ unsigned long arm_r4;
+ unsigned long arm_r5;
+ unsigned long arm_r6;
+ unsigned long arm_r7;
+ unsigned long arm_r8;
+ unsigned long arm_r9;
+ unsigned long arm_r10;
+ unsigned long arm_fp;
+ unsigned long arm_ip;
+ unsigned long arm_sp;
+ unsigned long arm_lr;
+ unsigned long arm_pc;
+ unsigned long arm_cpsr;
+ unsigned long fault_address;
+};
+
diff --git a/mdk-stage1/dietlibc/include/asm/i386-sigcontext.h b/mdk-stage1/dietlibc/include/asm/i386-sigcontext.h
new file mode 100644
index 000000000..e830b9b97
--- /dev/null
+++ b/mdk-stage1/dietlibc/include/asm/i386-sigcontext.h
@@ -0,0 +1,66 @@
+
+struct _fpreg {
+ unsigned short significand[4];
+ unsigned short exponent;
+};
+
+struct _fpxreg {
+ unsigned short significand[4];
+ unsigned short exponent;
+ unsigned short padding[3];
+};
+
+struct _xmmreg {
+ unsigned long element[4];
+};
+
+struct _fpstate {
+ /* Regular FPU environment */
+ unsigned long cw;
+ unsigned long sw;
+ unsigned long tag;
+ unsigned long ipoff;
+ unsigned long cssel;
+ unsigned long dataoff;
+ unsigned long datasel;
+ struct _fpreg _st[8];
+ unsigned short status;
+ unsigned short magic; /* 0xffff = regular FPU data only */
+
+ /* FXSR FPU environment */
+ unsigned long _fxsr_env[6]; /* FXSR FPU env is ignored */
+ unsigned long mxcsr;
+ unsigned long reserved;
+ struct _fpxreg _fxsr_st[8]; /* FXSR FPU reg data is ignored */
+ struct _xmmreg _xmm[8];
+ unsigned long padding[56];
+};
+
+#define X86_FXSR_MAGIC 0x0000
+#define PC(ctx) (ctx.eip)
+
+struct sigcontext {
+ unsigned short gs, __gsh;
+ unsigned short fs, __fsh;
+ unsigned short es, __esh;
+ unsigned short ds, __dsh;
+ unsigned long edi;
+ unsigned long esi;
+ unsigned long ebp;
+ unsigned long esp;
+ unsigned long ebx;
+ unsigned long edx;
+ unsigned long ecx;
+ unsigned long eax;
+ unsigned long trapno;
+ unsigned long err;
+ unsigned long eip;
+ unsigned short cs, __csh;
+ unsigned long eflags;
+ unsigned long esp_at_signal;
+ unsigned short ss, __ssh;
+ struct _fpstate * fpstate;
+ unsigned long oldmask;
+ unsigned long cr2;
+};
+
diff --git a/mdk-stage1/dietlibc/include/asm/ia64-sigcontext.h b/mdk-stage1/dietlibc/include/asm/ia64-sigcontext.h
new file mode 100644
index 000000000..ebab3c8f4
--- /dev/null
+++ b/mdk-stage1/dietlibc/include/asm/ia64-sigcontext.h
@@ -0,0 +1,25 @@
+#include <sys/ptrace.h>
+
+#define PC(ctx) (ctx.sc_ip)
+
+struct sigcontext {
+ unsigned long sc_flags;
+ unsigned long sc_nat;
+ stack_t sc_stack;
+ unsigned long sc_ip;
+ unsigned long sc_cfm;
+ unsigned long sc_um;
+ unsigned long sc_ar_rsc;
+ unsigned long sc_ar_bsp;
+ unsigned long sc_ar_rnat;
+ unsigned long sc_ar_ccv;
+ unsigned long sc_ar_unat;
+ unsigned long sc_ar_fpsr;
+ unsigned long sc_ar_pfs;
+ unsigned long sc_ar_lc;
+ unsigned long sc_pr;
+ unsigned long sc_br[8];
+ unsigned long sc_gr[32];
+ struct ia64_fpreg sc_fr[128];
+ sigset_t sc_mask;
+};
diff --git a/mdk-stage1/dietlibc/include/asm/mips-sigcontext.h b/mdk-stage1/dietlibc/include/asm/mips-sigcontext.h
new file mode 100644
index 000000000..1210abf31
--- /dev/null
+++ b/mdk-stage1/dietlibc/include/asm/mips-sigcontext.h
@@ -0,0 +1,23 @@
+
+/*
+ * Keep this struct definition in sync with the sigcontext fragment
+ * in arch/mips/tools/offset.c
+ */
+struct sigcontext {
+ unsigned int sc_regmask; /* Unused */
+ unsigned int sc_status;
+ unsigned long long sc_pc;
+ unsigned long long sc_regs[32];
+ unsigned long long sc_fpregs[32]; /* Unused */
+ unsigned int sc_ownedfp;
+ unsigned int sc_fpc_csr; /* Unused */
+ unsigned int sc_fpc_eir; /* Unused */
+ unsigned int sc_ssflags; /* Unused */
+ unsigned long long sc_mdhi;
+ unsigned long long sc_mdlo;
+
+ unsigned int sc_cause; /* Unused */
+ unsigned int sc_badvaddr; /* Unused */
+
+ unsigned long sc_sigset[4]; /* kernel's sigset_t */
+};
diff --git a/mdk-stage1/dietlibc/include/asm/parisc-sigcontext.h b/mdk-stage1/dietlibc/include/asm/parisc-sigcontext.h
new file mode 100644
index 000000000..9428dd3e5
--- /dev/null
+++ b/mdk-stage1/dietlibc/include/asm/parisc-sigcontext.h
@@ -0,0 +1,16 @@
+
+#define PARISC_SC_FLAG_ONSTACK 1<<0
+#define PARISC_SC_FLAG_IN_SYSCALL 1<<1
+
+/* We will add more stuff here as it becomes necessary, until we know
+ it works. */
+struct sigcontext {
+ unsigned long sc_flags;
+
+ unsigned long sc_gr[32]; /* PSW in sc_gr[0] */
+ unsigned long long sc_fr[32]; /* FIXME, do we need other state info? */
+ unsigned long sc_iasq[2];
+ unsigned long sc_iaoq[2];
+ unsigned long sc_sar; /* cr11 */
+};
+
diff --git a/mdk-stage1/dietlibc/include/asm/ppc-sigcontext.h b/mdk-stage1/dietlibc/include/asm/ppc-sigcontext.h
new file mode 100644
index 000000000..1d9704f3a
--- /dev/null
+++ b/mdk-stage1/dietlibc/include/asm/ppc-sigcontext.h
@@ -0,0 +1,76 @@
+
+struct pt_regs {
+ unsigned long gpr[32];
+ unsigned long nip;
+ unsigned long msr;
+ unsigned long orig_gpr3; /* Used for restarting system calls */
+ unsigned long ctr;
+ unsigned long link;
+ unsigned long xer;
+ unsigned long ccr;
+ unsigned long mq; /* 601 only (not used at present) */
+ /* Used on APUS to hold IPL value. */
+ unsigned long trap; /* Reason for being here */
+ unsigned long dar; /* Fault registers */
+ unsigned long dsisr;
+ unsigned long result; /* Result of a system call */
+};
+
+/*
+ * Offsets used by 'ptrace' system call interface.
+ * These can't be changed without breaking binary compatibility
+ * with MkLinux, etc.
+ */
+#define PT_R0 0
+#define PT_R1 1
+#define PT_R2 2
+#define PT_R3 3
+#define PT_R4 4
+#define PT_R5 5
+#define PT_R6 6
+#define PT_R7 7
+#define PT_R8 8
+#define PT_R9 9
+#define PT_R10 10
+#define PT_R11 11
+#define PT_R12 12
+#define PT_R13 13
+#define PT_R14 14
+#define PT_R15 15
+#define PT_R16 16
+#define PT_R17 17
+#define PT_R18 18
+#define PT_R19 19
+#define PT_R20 20
+#define PT_R21 21
+#define PT_R22 22
+#define PT_R23 23
+#define PT_R24 24
+#define PT_R25 25
+#define PT_R26 26
+#define PT_R27 27
+#define PT_R28 28
+#define PT_R29 29
+#define PT_R30 30
+#define PT_R31 31
+
+#define PT_NIP 32
+#define PT_MSR 33
+#define PT_CTR 35
+#define PT_LNK 36
+#define PT_XER 37
+#define PT_CCR 38
+#define PT_MQ 39
+
+#define PT_FPR0 48 /* each FP reg occupies 2 slots in this space */
+#define PT_FPR31 (PT_FPR0 + 2*31)
+#define PT_FPSCR (PT_FPR0 + 2*32 + 1)
+
+#define sigcontext_struct sigcontext
+struct sigcontext {
+ unsigned long _unused[4];
+ int signal;
+ unsigned long handler;
+ unsigned long oldmask;
+ struct pt_regs *regs;
+};
diff --git a/mdk-stage1/dietlibc/include/asm/sigcontext.h b/mdk-stage1/dietlibc/include/asm/sigcontext.h
new file mode 100644
index 000000000..c4a720cc0
--- /dev/null
+++ b/mdk-stage1/dietlibc/include/asm/sigcontext.h
@@ -0,0 +1,36 @@
+#ifndef _ASM_SIGCONTEXT_H
+#define _ASM_SIGCONTEXT_H
+
+#if defined(__i386__) || defined(__x86_64__)
+#include <asm/i386-sigcontext.h>
+#endif
+
+#ifdef __sparc__
+#include <asm/sparc-sigcontext.h>
+#endif
+
+#ifdef __mips__
+#include <asm/mips-sigcontext.h>
+#endif
+
+#ifdef __powerpc__
+#include <asm/ppc-sigcontext.h>
+#endif
+
+#ifdef __alpha__
+#include <asm/alpha-sigcontext.h>
+#endif
+
+#ifdef __arm__
+#include <asm/arm-sigcontext.h>
+#endif
+
+#ifdef __hppa__
+#include <asm/parisc-sigcontext.h>
+#endif
+
+#ifdef __ia64__
+#include <asm/ia64-sigcontext.h>
+#endif
+
+#endif
diff --git a/mdk-stage1/dietlibc/include/asm/sparc-sigcontext.h b/mdk-stage1/dietlibc/include/asm/sparc-sigcontext.h
new file mode 100644
index 000000000..98e4e09ce
--- /dev/null
+++ b/mdk-stage1/dietlibc/include/asm/sparc-sigcontext.h
@@ -0,0 +1,50 @@
+
+#define __SUNOS_MAXWIN 31
+
+/* This is what SunOS does, so shall I. */
+struct sigcontext {
+ int sigc_onstack; /* state to restore */
+ int sigc_mask; /* sigmask to restore */
+ int sigc_sp; /* stack pointer */
+ int sigc_pc; /* program counter */
+ int sigc_npc; /* next program counter */
+ int sigc_psr; /* for condition codes etc */
+ int sigc_g1; /* User uses these two registers */
+ int sigc_o0; /* within the trampoline code. */
+
+ /* Now comes information regarding the users window set
+ * at the time of the signal.
+ */
+ int sigc_oswins; /* outstanding windows */
+
+ /* stack ptrs for each regwin buf */
+ char *sigc_spbuf[__SUNOS_MAXWIN];
+
+ /* Windows to restore after signal */
+ struct {
+ unsigned long locals[8];
+ unsigned long ins[8];
+ } sigc_wbuf[__SUNOS_MAXWIN];
+};
+
+typedef struct {
+ struct {
+ unsigned long psr;
+ unsigned long pc;
+ unsigned long npc;
+ unsigned long y;
+ unsigned long u_regs[16]; /* globals and ins */
+ } si_regs;
+ int si_mask;
+} __siginfo_t;
+
+typedef struct {
+ unsigned long si_float_regs [32];
+ unsigned long si_fsr;
+ unsigned long si_fpqdepth;
+ struct {
+ unsigned long *insn_addr;
+ unsigned long insn;
+ } si_fpqueue [16];
+} __siginfo_fpu_t;
+
diff --git a/mdk-stage1/dietlibc/include/asm/statfs.h b/mdk-stage1/dietlibc/include/asm/statfs.h
new file mode 100644
index 000000000..53b3b5e4d
--- /dev/null
+++ b/mdk-stage1/dietlibc/include/asm/statfs.h
@@ -0,0 +1 @@
+#include <sys/vfs.h>
diff --git a/mdk-stage1/dietlibc/include/asm/types.h b/mdk-stage1/dietlibc/include/asm/types.h
new file mode 100644
index 000000000..aafa80f16
--- /dev/null
+++ b/mdk-stage1/dietlibc/include/asm/types.h
@@ -0,0 +1,32 @@
+#ifndef _ASM_TYPES_H
+#define _ASM_TYPES_H
+
+#include <sys/types.h>
+
+#ifdef __alpha__
+typedef unsigned int umode_t;
+#else
+typedef unsigned short umode_t;
+#endif
+
+typedef uint8_t __u8;
+typedef uint16_t __u16;
+typedef uint32_t __u32;
+#ifndef __STRICT_ANSI__
+typedef uint64_t __u64;
+#endif
+
+typedef int8_t __s8;
+typedef int16_t __s16;
+typedef int32_t __s32;
+#ifndef __STRICT_ANSI__
+typedef int64_t __s64;
+#endif
+
+#if defined(__alpha__)
+typedef unsigned long __kernel_size_t;
+#else
+typedef unsigned int __kernel_size_t;
+#endif
+
+#endif
diff --git a/mdk-stage1/dietlibc/include/cpio.h b/mdk-stage1/dietlibc/include/cpio.h
new file mode 100644
index 000000000..a18c2fbb6
--- /dev/null
+++ b/mdk-stage1/dietlibc/include/cpio.h
@@ -0,0 +1,27 @@
+#ifndef _CPIO_H_
+#define _CPIO_H_
+
+#define C_IRUSR 0000400
+#define C_IWUSR 0000200
+#define C_IXUSR 0000100
+#define C_IRGRP 0000040
+#define C_IWGRP 0000020
+#define C_IXGRP 0000010
+#define C_IROTH 0000004
+#define C_IWOTH 0000002
+#define C_IXOTH 0000001
+#define C_ISUID 0004000
+#define C_ISGID 0002000
+#define C_ISVTX 0001000
+#define C_ISDIR 0040000
+#define C_ISFIFO 0010000
+#define C_ISREG 0100000
+#define C_ISBLK 0060000
+#define C_ISCHR 0020000
+#define C_ISCTG 0110000
+#define C_ISLNK 0120000
+#define C_ISSOCK 0140000
+
+#define MAGIC "070707"
+
+#endif /* _CPIO_H_ */
diff --git a/mdk-stage1/dietlibc/include/dietref.h b/mdk-stage1/dietlibc/include/dietref.h
new file mode 100644
index 000000000..99d446300
--- /dev/null
+++ b/mdk-stage1/dietlibc/include/dietref.h
@@ -0,0 +1,22 @@
+/* diet includes this file to create linker dependencies on the diet
+ * libc, so trying to link an object file compiled with diet against
+ * glibc will fail. */
+
+#ifndef NODIETREF
+#include <endian.h>
+#ifdef __ASSEMBLER__
+.section .note
+#if (__WORDSIZE == 64)
+.quad __you_tried_to_link_a_dietlibc_object_against_glibc
+#else
+.long __you_tried_to_link_a_dietlibc_object_against_glibc
+#endif
+.previous
+#else
+#if (__WORDSIZE == 64)
+__asm__ (".section .note\n\t.quad __you_tried_to_link_a_dietlibc_object_against_glibc\n\t.previous");
+#else
+__asm__ (".section .note\n\t.long __you_tried_to_link_a_dietlibc_object_against_glibc\n\t.previous");
+#endif
+#endif
+#endif
diff --git a/mdk-stage1/dietlibc/include/float.h b/mdk-stage1/dietlibc/include/float.h
new file mode 100644
index 000000000..9c9c85a3a
--- /dev/null
+++ b/mdk-stage1/dietlibc/include/float.h
@@ -0,0 +1,96 @@
+#ifndef _FLOAT_H
+#define _FLOAT_H
+
+/* blatantly copied from gcc headers for sparc */
+
+ /* Radix of exponent representation */
+#undef FLT_RADIX
+#define FLT_RADIX 2
+ /* Number of base-FLT_RADIX digits in the significand of a float */
+#undef FLT_MANT_DIG
+#define FLT_MANT_DIG 24
+ /* Number of decimal digits of precision in a float */
+#undef FLT_DIG
+#define FLT_DIG 6
+ /* Addition rounds to 0: zero, 1: nearest, 2: +inf, 3: -inf, -1: unknown */
+#undef FLT_ROUNDS
+#define FLT_ROUNDS 1
+ /* Difference between 1.0 and the minimum float greater than 1.0 */
+#undef FLT_EPSILON
+#define FLT_EPSILON 1.19209290e-07F
+ /* Minimum int x such that FLT_RADIX**(x-1) is a normalised float */
+#undef FLT_MIN_EXP
+#define FLT_MIN_EXP (-125)
+ /* Minimum normalised float */
+#undef FLT_MIN
+#define FLT_MIN 1.17549435e-38F
+ /* Minimum int x such that 10**x is a normalised float */
+#undef FLT_MIN_10_EXP
+#define FLT_MIN_10_EXP (-37)
+ /* Maximum int x such that FLT_RADIX**(x-1) is a representable float */
+#undef FLT_MAX_EXP
+#define FLT_MAX_EXP 128
+ /* Maximum float */
+#undef FLT_MAX
+#define FLT_MAX 3.40282347e+38F
+ /* Maximum int x such that 10**x is a representable float */
+#undef FLT_MAX_10_EXP
+#define FLT_MAX_10_EXP 38
+
+ /* Number of base-FLT_RADIX digits in the significand of a double */
+#undef DBL_MANT_DIG
+#define DBL_MANT_DIG 53
+ /* Number of decimal digits of precision in a double */
+#undef DBL_DIG
+#define DBL_DIG 15
+ /* Difference between 1.0 and the minimum double greater than 1.0 */
+#undef DBL_EPSILON
+#define DBL_EPSILON 2.2204460492503131e-16
+ /* Minimum int x such that FLT_RADIX**(x-1) is a normalised double */
+#undef DBL_MIN_EXP
+#define DBL_MIN_EXP (-1021)
+ /* Minimum normalised double */
+#undef DBL_MIN
+#define DBL_MIN 2.2250738585072014e-308
+ /* Minimum int x such that 10**x is a normalised double */
+#undef DBL_MIN_10_EXP
+#define DBL_MIN_10_EXP (-307)
+ /* Maximum int x such that FLT_RADIX**(x-1) is a representable double */
+#undef DBL_MAX_EXP
+#define DBL_MAX_EXP 1024
+ /* Maximum double */
+#undef DBL_MAX
+#define DBL_MAX 1.7976931348623157e+308
+ /* Maximum int x such that 10**x is a representable double */
+#undef DBL_MAX_10_EXP
+#define DBL_MAX_10_EXP 308
+
+ /* Number of base-FLT_RADIX digits in the significand of a long double */
+#undef LDBL_MANT_DIG
+#define LDBL_MANT_DIG 53
+ /* Number of decimal digits of precision in a long double */
+#undef LDBL_DIG
+#define LDBL_DIG 15
+ /* Difference between 1.0 and the minimum long double greater than 1.0 */
+#undef LDBL_EPSILON
+#define LDBL_EPSILON 2.2204460492503131e-16L
+ /* Minimum int x such that FLT_RADIX**(x-1) is a normalised long double */
+#undef LDBL_MIN_EXP
+#define LDBL_MIN_EXP (-1021)
+ /* Minimum normalised long double */
+#undef LDBL_MIN
+#define LDBL_MIN 2.2250738585072014e-308L
+ /* Minimum int x such that 10**x is a normalised long double */
+#undef LDBL_MIN_10_EXP
+#define LDBL_MIN_10_EXP (-307)
+ /* Maximum int x such that FLT_RADIX**(x-1) is a representable long double */
+#undef LDBL_MAX_EXP
+#define LDBL_MAX_EXP 1024
+ /* Maximum long double */
+#undef LDBL_MAX
+#define LDBL_MAX 1.7976931348623157e+308L
+ /* Maximum int x such that 10**x is a representable long double */
+#undef LDBL_MAX_10_EXP
+#define LDBL_MAX_10_EXP 308
+
+#endif
diff --git a/mdk-stage1/dietlibc/include/iconv.h b/mdk-stage1/dietlibc/include/iconv.h
new file mode 100644
index 000000000..1205994ca
--- /dev/null
+++ b/mdk-stage1/dietlibc/include/iconv.h
@@ -0,0 +1,25 @@
+#ifndef _ICONV_H
+#define _ICONV_H
+
+#include <sys/cdefs.h>
+#include <sys/types.h>
+
+/* Identifier for conversion method from one codeset to another. */
+typedef unsigned int iconv_t;
+
+/* Allocate descriptor for code conversion from codeset FROMCODE to
+ codeset TOCODE. */
+extern iconv_t iconv_open (const char *tocode, const char *fromcode) __THROW;
+
+/* Convert at most *INBYTESLEFT bytes from *INBUF according to the
+ code conversion algorithm specified by CD and place up to
+ *OUTBYTESLEFT bytes in buffer at *OUTBUF. */
+extern size_t iconv (iconv_t cd, const char** inbuf,
+ size_t* inbytesleft,
+ char** outbuf,
+ size_t* outbytesleft) __THROW;
+
+/* Free resources allocated for descriptor CD for code conversion. */
+extern int iconv_close (iconv_t cd) __THROW;
+
+#endif /* iconv.h */
diff --git a/mdk-stage1/dietlibc/include/libgen.h b/mdk-stage1/dietlibc/include/libgen.h
new file mode 100644
index 000000000..ab13b0a30
--- /dev/null
+++ b/mdk-stage1/dietlibc/include/libgen.h
@@ -0,0 +1,9 @@
+#ifndef _LIBGEN_H
+#define _LIBGEN_H
+
+#include <sys/cdefs.h>
+
+char *dirname(char *path) __THROW;
+char *basename(char *path) __THROW;
+
+#endif
diff --git a/mdk-stage1/dietlibc/include/libintl.h b/mdk-stage1/dietlibc/include/libintl.h
new file mode 100644
index 000000000..20873f55f
--- /dev/null
+++ b/mdk-stage1/dietlibc/include/libintl.h
@@ -0,0 +1,23 @@
+#ifndef _LIBINTL_H
+#define _LIBINTL_H
+
+#include <sys/cdefs.h>
+#include <sys/types.h>
+#include <locale.h>
+
+#define gettext(msgid) dgettext(0,msgid)
+#define dgettext(domainname,msgid) dcgettext(domainname,msgid,LC_MESSAGES)
+
+#define ngettext(msgid1,msgid2,n) dngettext(0,msgid1,msgid2,n)
+#define dngettext(dn,msgid1,msgid2,n) dngettext(dn,msgid1,msgid2,n,LC_MESSAGES)
+
+char* dcgettext(const char *domainname, const char *msgid, int category) __THROW;
+char* dcngettext(const char *domainname,
+ const char *msgid1, const char *msgid2,
+ unsigned long int n, int __category) __THROW;
+
+char* textdomain(const char *domainname) __THROW;
+char* bindtextdomain(const char *domainname, const char *dirname) __THROW;
+char* bind_textdomain_codeset(const char *domainname, const char *codeset) __THROW;
+
+#endif
diff --git a/mdk-stage1/dietlibc/include/linux/eventpoll.h b/mdk-stage1/dietlibc/include/linux/eventpoll.h
new file mode 100644
index 000000000..19990ac2a
--- /dev/null
+++ b/mdk-stage1/dietlibc/include/linux/eventpoll.h
@@ -0,0 +1,17 @@
+#ifndef _LINUX_EVENTPOLL_H
+#define _LINUX_EVENTPOLL_H
+
+#include <sys/ioctl.h>
+#include <sys/poll.h>
+#include <sys/shm.h>
+
+#define POLLFD_X_PAGE (PAGE_SIZE / sizeof(struct pollfd))
+#define EP_FDS_PAGES(n) (((n) + POLLFD_X_PAGE - 1) / POLLFD_X_PAGE)
+#define EP_MAP_SIZE(n) (EP_FDS_PAGES(n) * PAGE_SIZE * 2)
+
+struct evpoll {
+ int ep_timeout;
+ unsigned long ep_resoff;
+};
+
+#endif
diff --git a/mdk-stage1/dietlibc/include/linux/if_ether.h b/mdk-stage1/dietlibc/include/linux/if_ether.h
new file mode 100644
index 000000000..dbeb3728e
--- /dev/null
+++ b/mdk-stage1/dietlibc/include/linux/if_ether.h
@@ -0,0 +1,101 @@
+/*
+ * INET An implementation of the TCP/IP protocol suite for the LINUX
+ * operating system. INET is implemented using the BSD Socket
+ * interface as the means of communication with the user level.
+ *
+ * Global definitions for the Ethernet IEEE 802.3 interface.
+ *
+ * Version: @(#)if_ether.h 1.0.1a 02/08/94
+ *
+ * Author: Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
+ * Donald Becker, <becker@super.org>
+ * Alan Cox, <alan@redhat.com>
+ * Steve Whitehouse, <gw7rrm@eeshack3.swan.ac.uk>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+#ifndef _LINUX_IF_ETHER_H
+#define _LINUX_IF_ETHER_H
+
+/*
+ * IEEE 802.3 Ethernet magic constants. The frame sizes omit the preamble
+ * and FCS/CRC (frame check sequence).
+ */
+
+#define ETH_ALEN 6 /* Octets in one ethernet addr */
+#define ETH_HLEN 14 /* Total octets in header. */
+#define ETH_ZLEN 60 /* Min. octets in frame sans FCS */
+#define ETH_DATA_LEN 1500 /* Max. octets in payload */
+#define ETH_FRAME_LEN 1514 /* Max. octets in frame sans FCS */
+
+/*
+ * These are the defined Ethernet Protocol ID's.
+ */
+
+#define ETH_P_LOOP 0x0060 /* Ethernet Loopback packet */
+#define ETH_P_PUP 0x0200 /* Xerox PUP packet */
+#define ETH_P_PUPAT 0x0201 /* Xerox PUP Addr Trans packet */
+#define ETH_P_IP 0x0800 /* Internet Protocol packet */
+#define ETH_P_X25 0x0805 /* CCITT X.25 */
+#define ETH_P_ARP 0x0806 /* Address Resolution packet */
+#define ETH_P_BPQ 0x08FF /* G8BPQ AX.25 Ethernet Packet [ NOT AN OFFICIALLY REGISTERED ID ] */
+#define ETH_P_IEEEPUP 0x0a00 /* Xerox IEEE802.3 PUP packet */
+#define ETH_P_IEEEPUPAT 0x0a01 /* Xerox IEEE802.3 PUP Addr Trans packet */
+#define ETH_P_DEC 0x6000 /* DEC Assigned proto */
+#define ETH_P_DNA_DL 0x6001 /* DEC DNA Dump/Load */
+#define ETH_P_DNA_RC 0x6002 /* DEC DNA Remote Console */
+#define ETH_P_DNA_RT 0x6003 /* DEC DNA Routing */
+#define ETH_P_LAT 0x6004 /* DEC LAT */
+#define ETH_P_DIAG 0x6005 /* DEC Diagnostics */
+#define ETH_P_CUST 0x6006 /* DEC Customer use */
+#define ETH_P_SCA 0x6007 /* DEC Systems Comms Arch */
+#define ETH_P_RARP 0x8035 /* Reverse Addr Res packet */
+#define ETH_P_ATALK 0x809B /* Appletalk DDP */
+#define ETH_P_AARP 0x80F3 /* Appletalk AARP */
+#define ETH_P_8021Q 0x8100 /* 802.1Q VLAN Extended Header */
+#define ETH_P_IPX 0x8137 /* IPX over DIX */
+#define ETH_P_IPV6 0x86DD /* IPv6 over bluebook */
+#define ETH_P_PPP_DISC 0x8863 /* PPPoE discovery messages */
+#define ETH_P_PPP_SES 0x8864 /* PPPoE session messages */
+#define ETH_P_ATMMPOA 0x884c /* MultiProtocol Over ATM */
+#define ETH_P_ATMFATE 0x8884 /* Frame-based ATM Transport
+ * over Ethernet
+ */
+
+/*
+ * Non DIX types. Won't clash for 1500 types.
+ */
+
+#define ETH_P_802_3 0x0001 /* Dummy type for 802.3 frames */
+#define ETH_P_AX25 0x0002 /* Dummy protocol id for AX.25 */
+#define ETH_P_ALL 0x0003 /* Every packet (be careful!!!) */
+#define ETH_P_802_2 0x0004 /* 802.2 frames */
+#define ETH_P_SNAP 0x0005 /* Internal only */
+#define ETH_P_DDCMP 0x0006 /* DEC DDCMP: Internal only */
+#define ETH_P_WAN_PPP 0x0007 /* Dummy type for WAN PPP frames*/
+#define ETH_P_PPP_MP 0x0008 /* Dummy type for PPP MP frames */
+#define ETH_P_LOCALTALK 0x0009 /* Localtalk pseudo type */
+#define ETH_P_PPPTALK 0x0010 /* Dummy type for Atalk over PPP*/
+#define ETH_P_TR_802_2 0x0011 /* 802.2 frames */
+#define ETH_P_MOBITEX 0x0015 /* Mobitex (kaz@cafe.net) */
+#define ETH_P_CONTROL 0x0016 /* Card specific control frames */
+#define ETH_P_IRDA 0x0017 /* Linux-IrDA */
+#define ETH_P_ECONET 0x0018 /* Acorn Econet */
+#define ETH_P_HDLC 0x0019 /* HDLC frames */
+
+/*
+ * This is an Ethernet frame header.
+ */
+
+struct ethhdr
+{
+ unsigned char h_dest[ETH_ALEN]; /* destination eth addr */
+ unsigned char h_source[ETH_ALEN]; /* source ether addr */
+ unsigned short h_proto; /* packet type ID field */
+};
+
+#endif /* _LINUX_IF_ETHER_H */
diff --git a/mdk-stage1/dietlibc/include/linux/loop.h b/mdk-stage1/dietlibc/include/linux/loop.h
new file mode 100644
index 000000000..1366f1877
--- /dev/null
+++ b/mdk-stage1/dietlibc/include/linux/loop.h
@@ -0,0 +1,47 @@
+#ifndef _LINUX_LOOP_H
+#define _LINUX_LOOP_H
+
+/* stolen form kernel */
+
+#define LO_NAME_SIZE 64
+#define LO_KEY_SIZE 32
+
+/* Loop flags */
+#define LO_FLAGS_DO_BMAP 1
+#define LO_FLAGS_READ_ONLY 2
+#define LO_FLAGS_BH_REMAP 4
+
+struct loop_info {
+ int lo_number; /* ioctl r/o */
+ dev_t lo_device; /* ioctl r/o */
+ unsigned long lo_inode; /* ioctl r/o */
+ dev_t lo_rdevice; /* ioctl r/o */
+ int lo_offset;
+ int lo_encrypt_type;
+ int lo_encrypt_key_size; /* ioctl w/o */
+ int lo_flags; /* ioctl r/o */
+ char lo_name[LO_NAME_SIZE];
+ unsigned char lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */
+ unsigned long lo_init[2];
+ char reserved[4];
+};
+
+/* Loop filter types */
+#define LO_CRYPT_NONE 0
+#define LO_CRYPT_XOR 1
+#define LO_CRYPT_DES 2
+#define LO_CRYPT_FISH2 3 /* Brand new Twofish encryption */
+#define LO_CRYPT_BLOW 4
+#define LO_CRYPT_CAST128 5
+#define LO_CRYPT_IDEA 6
+#define LO_CRYPT_DUMMY 9
+#define LO_CRYPT_SKIPJACK 10
+#define MAX_LO_CRYPT 20
+
+/* IOCTL commands --- we will commandeer 0x4C ('L') */
+#define LOOP_SET_FD 0x4C00
+#define LOOP_CLR_FD 0x4C01
+#define LOOP_SET_STATUS 0x4C02
+#define LOOP_GET_STATUS 0x4C03
+
+#endif
diff --git a/mdk-stage1/dietlibc/include/linux/nfs.h b/mdk-stage1/dietlibc/include/linux/nfs.h
new file mode 100644
index 000000000..9be6db37e
--- /dev/null
+++ b/mdk-stage1/dietlibc/include/linux/nfs.h
@@ -0,0 +1,88 @@
+/*
+ * NFS protocol definitions
+ *
+ * This file contains constants mostly for Version 2 of the protocol,
+ * but also has a couple of NFSv3 bits in (notably the error codes).
+ */
+#ifndef _LINUX_NFS_H
+#define _LINUX_NFS_H
+
+#define NFS_PROGRAM 100003
+#define NFS_PORT 2049
+#define NFS_MAXDATA 8192
+#define NFS_MAXPATHLEN 1024
+#define NFS_MAXNAMLEN 255
+#define NFS_MAXGROUPS 16
+#define NFS_FHSIZE 32
+#define NFS_COOKIESIZE 4
+#define NFS_FIFO_DEV (-1)
+#define NFSMODE_FMT 0170000
+#define NFSMODE_DIR 0040000
+#define NFSMODE_CHR 0020000
+#define NFSMODE_BLK 0060000
+#define NFSMODE_REG 0100000
+#define NFSMODE_LNK 0120000
+#define NFSMODE_SOCK 0140000
+#define NFSMODE_FIFO 0010000
+
+#define NFS_MNT_PROGRAM 100005
+#define NFS_MNT_PORT 627
+
+/*
+ * NFS stats. The good thing with these values is that NFSv3 errors are
+ * a superset of NFSv2 errors (with the exception of NFSERR_WFLUSH which
+ * no-one uses anyway), so we can happily mix code as long as we make sure
+ * no NFSv3 errors are returned to NFSv2 clients.
+ * Error codes that have a `--' in the v2 column are not part of the
+ * standard, but seem to be widely used nevertheless.
+ */
+ enum nfs_stat {
+ NFS_OK = 0, /* v2 v3 */
+ NFSERR_PERM = 1, /* v2 v3 */
+ NFSERR_NOENT = 2, /* v2 v3 */
+ NFSERR_IO = 5, /* v2 v3 */
+ NFSERR_NXIO = 6, /* v2 v3 */
+ NFSERR_EAGAIN = 11, /* v2 v3 */
+ NFSERR_ACCES = 13, /* v2 v3 */
+ NFSERR_EXIST = 17, /* v2 v3 */
+ NFSERR_XDEV = 18, /* v3 */
+ NFSERR_NODEV = 19, /* v2 v3 */
+ NFSERR_NOTDIR = 20, /* v2 v3 */
+ NFSERR_ISDIR = 21, /* v2 v3 */
+ NFSERR_INVAL = 22, /* v2 v3 that Sun forgot */
+ NFSERR_FBIG = 27, /* v2 v3 */
+ NFSERR_NOSPC = 28, /* v2 v3 */
+ NFSERR_ROFS = 30, /* v2 v3 */
+ NFSERR_MLINK = 31, /* v3 */
+ NFSERR_OPNOTSUPP = 45, /* v2 v3 */
+ NFSERR_NAMETOOLONG = 63, /* v2 v3 */
+ NFSERR_NOTEMPTY = 66, /* v2 v3 */
+ NFSERR_DQUOT = 69, /* v2 v3 */
+ NFSERR_STALE = 70, /* v2 v3 */
+ NFSERR_REMOTE = 71, /* v2 v3 */
+ NFSERR_WFLUSH = 99, /* v2 */
+ NFSERR_BADHANDLE = 10001, /* v3 */
+ NFSERR_NOT_SYNC = 10002, /* v3 */
+ NFSERR_BAD_COOKIE = 10003, /* v3 */
+ NFSERR_NOTSUPP = 10004, /* v3 */
+ NFSERR_TOOSMALL = 10005, /* v3 */
+ NFSERR_SERVERFAULT = 10006, /* v3 */
+ NFSERR_BADTYPE = 10007, /* v3 */
+ NFSERR_JUKEBOX = 10008 /* v3 */
+ };
+
+/* NFSv2 file types - beware, these are not the same in NFSv3 */
+
+enum nfs_ftype {
+ NFNON = 0,
+ NFREG = 1,
+ NFDIR = 2,
+ NFBLK = 3,
+ NFCHR = 4,
+ NFLNK = 5,
+ NFSOCK = 6,
+ NFBAD = 7,
+ NFFIFO = 8
+};
+
+#endif /* _LINUX_NFS_H */
diff --git a/mdk-stage1/dietlibc/include/linux/posix_types.h b/mdk-stage1/dietlibc/include/linux/posix_types.h
new file mode 100644
index 000000000..0d494a1f6
--- /dev/null
+++ b/mdk-stage1/dietlibc/include/linux/posix_types.h
@@ -0,0 +1,115 @@
+#ifndef _LINUX_POSIX_TYPES_H
+#define _LINUX_POSIX_TYPES_H
+
+/*
+ * This allows for 1024 file descriptors: if NR_OPEN is ever grown
+ * beyond that you'll have to change this too. But 1024 fd's seem to be
+ * enough even for such "real" unices like OSF/1, so hopefully this is
+ * one limit that doesn't have to be changed [again].
+ *
+ * Note that POSIX wants the FD_CLEAR(fd,fdsetp) defines to be in
+ * <sys/time.h> (and thus <linux/time.h>) - but this is a more logical
+ * place for them. Solved by having dummy defines in <sys/time.h>.
+ */
+
+/*
+ * Those macros may have been defined in <gnu/types.h>. But we always
+ * use the ones here.
+ */
+#undef __NFDBITS
+#define __NFDBITS (8 * sizeof(unsigned long))
+
+#undef __FD_SETSIZE
+#define __FD_SETSIZE 1024
+
+#undef __FDSET_LONGS
+#define __FDSET_LONGS (__FD_SETSIZE/__NFDBITS)
+
+#undef __FDELT
+#define __FDELT(d) ((d) / __NFDBITS)
+
+#undef __FDMASK
+#define __FDMASK(d) (1UL << ((d) % __NFDBITS))
+
+typedef struct {
+ unsigned long fds_bits [__FDSET_LONGS];
+} __kernel_fd_set;
+
+#ifndef __KERNEL_STRICT_NAMES
+typedef __kernel_fd_set fd_set;
+#endif
+
+#if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2)
+
+#undef __FD_SET
+static __inline__ void __FD_SET(unsigned long fd, __kernel_fd_set *fdsetp)
+{
+ unsigned long _tmp = fd / __NFDBITS;
+ unsigned long _rem = fd % __NFDBITS;
+ fdsetp->fds_bits[_tmp] |= (1UL<<_rem);
+}
+
+#undef __FD_CLR
+static __inline__ void __FD_CLR(unsigned long fd, __kernel_fd_set *fdsetp)
+{
+ unsigned long _tmp = fd / __NFDBITS;
+ unsigned long _rem = fd % __NFDBITS;
+ fdsetp->fds_bits[_tmp] &= ~(1UL<<_rem);
+}
+
+#undef __FD_ISSET
+static __inline__ int __FD_ISSET(unsigned long fd, __const__ __kernel_fd_set *p)
+{
+ unsigned long _tmp = fd / __NFDBITS;
+ unsigned long _rem = fd % __NFDBITS;
+ return (p->fds_bits[_tmp] & (1UL<<_rem)) != 0;
+}
+
+/*
+ * This will unroll the loop for the normal constant cases (8 or 32 longs,
+ * for 256 and 1024-bit fd_sets respectively)
+ */
+#undef __FD_ZERO
+static __inline__ void __FD_ZERO(__kernel_fd_set *p)
+{
+ unsigned long *tmp = p->fds_bits;
+ int i;
+
+ if (__builtin_constant_p(__FDSET_LONGS)) {
+ switch (__FDSET_LONGS) {
+ case 32:
+ tmp[ 0] = 0; tmp[ 1] = 0; tmp[ 2] = 0; tmp[ 3] = 0;
+ tmp[ 4] = 0; tmp[ 5] = 0; tmp[ 6] = 0; tmp[ 7] = 0;
+ tmp[ 8] = 0; tmp[ 9] = 0; tmp[10] = 0; tmp[11] = 0;
+ tmp[12] = 0; tmp[13] = 0; tmp[14] = 0; tmp[15] = 0;
+ tmp[16] = 0; tmp[17] = 0; tmp[18] = 0; tmp[19] = 0;
+ tmp[20] = 0; tmp[21] = 0; tmp[22] = 0; tmp[23] = 0;
+ tmp[24] = 0; tmp[25] = 0; tmp[26] = 0; tmp[27] = 0;
+ tmp[28] = 0; tmp[29] = 0; tmp[30] = 0; tmp[31] = 0;
+ return;
+ case 16:
+ tmp[ 0] = 0; tmp[ 1] = 0; tmp[ 2] = 0; tmp[ 3] = 0;
+ tmp[ 4] = 0; tmp[ 5] = 0; tmp[ 6] = 0; tmp[ 7] = 0;
+ tmp[ 8] = 0; tmp[ 9] = 0; tmp[10] = 0; tmp[11] = 0;
+ tmp[12] = 0; tmp[13] = 0; tmp[14] = 0; tmp[15] = 0;
+ return;
+ case 8:
+ tmp[ 0] = 0; tmp[ 1] = 0; tmp[ 2] = 0; tmp[ 3] = 0;
+ tmp[ 4] = 0; tmp[ 5] = 0; tmp[ 6] = 0; tmp[ 7] = 0;
+ return;
+ case 4:
+ tmp[ 0] = 0; tmp[ 1] = 0; tmp[ 2] = 0; tmp[ 3] = 0;
+ return;
+ }
+ }
+ i = __FDSET_LONGS;
+ while (i) {
+ i--;
+ *tmp = 0;
+ tmp++;
+ }
+}
+
+#endif /* defined(__KERNEL__) */
+
+#endif /* _LINUX_POSIX_TYPES_H */
diff --git a/mdk-stage1/dietlibc/include/linux/types.h b/mdk-stage1/dietlibc/include/linux/types.h
new file mode 100644
index 000000000..1cd33bd41
--- /dev/null
+++ b/mdk-stage1/dietlibc/include/linux/types.h
@@ -0,0 +1,6 @@
+#ifndef _LINUX_TYPES_H
+#define _LINUX_TYPES_H
+
+#include <asm/types.h>
+
+#endif
diff --git a/mdk-stage1/dietlibc/include/md5.h b/mdk-stage1/dietlibc/include/md5.h
new file mode 100644
index 000000000..7cbc0e8f3
--- /dev/null
+++ b/mdk-stage1/dietlibc/include/md5.h
@@ -0,0 +1,48 @@
+/*
+ Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
+ rights reserved.
+
+ License to copy and use this software is granted provided that it
+ is identified as the "RSA Data Security, Inc. MD5 Message-Digest
+ Algorithm" in all material mentioning or referencing this software
+ or this function.
+
+ License is also granted to make and use derivative works provided
+ that such works are identified as "derived from the RSA Data
+ Security, Inc. MD5 Message-Digest Algorithm" in all material
+ mentioning or referencing the derived work.
+
+ RSA Data Security, Inc. makes no representations concerning either
+ the merchantability of this software or the suitability of this
+ software for any particular purpose. It is provided "as is"
+ without express or implied warranty of any kind.
+ These notices must be retained in any copies of any part of this
+ documentation and/or software.
+*/
+
+#ifndef _MD5_H
+#define _MD5_H
+
+#include <sys/types.h>
+
+/*
+ Define the MD5 context structure.
+ Please DO NOT change the order or contents of the structure as
+ various assembler files depend on it !!
+*/
+typedef struct
+{
+ uint32_t state[4]; /* state (ABCD) */
+ uint32_t count[2]; /* number of bits, modulo 2^64 (least sig word first) */
+ uint8_t buffer[64]; /* input buffer for incomplete buffer data */
+}
+MD5_CTX;
+
+void MD5Init (MD5_CTX* ctx);
+void MD5Update (MD5_CTX* ctx, const uint8_t* buf, size_t len);
+void MD5Final (uint8_t digest[16], MD5_CTX* ctx);
+
+char* md5crypt (const char* pw, const char* salt);
+
+#endif
+
diff --git a/mdk-stage1/dietlibc/include/net/ethernet.h b/mdk-stage1/dietlibc/include/net/ethernet.h
new file mode 100644
index 000000000..900ffd536
--- /dev/null
+++ b/mdk-stage1/dietlibc/include/net/ethernet.h
@@ -0,0 +1,76 @@
+/* Copyright (C) 1997, 1999, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* Based on the FreeBSD version of this file. Curiously, that file
+ lacks a copyright in the header. */
+
+#ifndef __NET_ETHERNET_H
+#define __NET_ETHERNET_H 1
+
+#include <sys/cdefs.h>
+#include <sys/types.h>
+#include <linux/if_ether.h> /* IEEE 802.3 Ethernet constants */
+
+__BEGIN_DECLS
+
+/* This is a name for the 48 bit ethernet address available on many
+ systems. */
+struct ether_addr
+{
+ uint8_t ether_addr_octet[ETH_ALEN];
+} __attribute__ ((__packed__));
+
+/* 10Mb/s ethernet header */
+struct ether_header
+{
+ uint8_t ether_dhost[ETH_ALEN]; /* destination eth addr */
+ uint8_t ether_shost[ETH_ALEN]; /* source ether addr */
+ uint16_t ether_type; /* packet type ID field */
+} __attribute__ ((__packed__));
+
+/* Ethernet protocol ID's */
+#define ETHERTYPE_PUP 0x0200 /* Xerox PUP */
+#define ETHERTYPE_IP 0x0800 /* IP */
+#define ETHERTYPE_ARP 0x0806 /* Address resolution */
+#define ETHERTYPE_REVARP 0x8035 /* Reverse ARP */
+
+#define ETHER_ADDR_LEN ETH_ALEN /* size of ethernet addr */
+#define ETHER_TYPE_LEN 2 /* bytes in type field */
+#define ETHER_CRC_LEN 4 /* bytes in CRC field */
+#define ETHER_HDR_LEN ETH_HLEN /* total octets in header */
+#define ETHER_MIN_LEN (ETH_ZLEN + ETHER_CRC_LEN) /* min packet length */
+#define ETHER_MAX_LEN (ETH_FRAME_LEN + ETHER_CRC_LEN) /* max packet length */
+
+/* make sure ethenet length is valid */
+#define ETHER_IS_VALID_LEN(foo) \
+ ((foo) >= ETHER_MIN_LEN && (foo) <= ETHER_MAX_LEN)
+
+/*
+ * The ETHERTYPE_NTRAILER packet types starting at ETHERTYPE_TRAIL have
+ * (type-ETHERTYPE_TRAIL)*512 bytes of data followed
+ * by an ETHER type (as given above) and then the (variable-length) header.
+ */
+#define ETHERTYPE_TRAIL 0x1000 /* Trailer packet */
+#define ETHERTYPE_NTRAILER 16
+
+#define ETHERMTU ETH_DATA_LEN
+#define ETHERMIN (ETHER_MIN_LEN - ETHER_HDR_LEN - ETHER_CRC_LEN)
+
+__END_DECLS
+
+#endif /* net/ethernet.h */
diff --git a/mdk-stage1/dietlibc/include/net/if_ether.h b/mdk-stage1/dietlibc/include/net/if_ether.h
new file mode 100644
index 000000000..7451a6dc6
--- /dev/null
+++ b/mdk-stage1/dietlibc/include/net/if_ether.h
@@ -0,0 +1,74 @@
+#ifndef _NET_IF_ETHER_H
+#define _NET_IF_ETHER_H
+
+/* taken from <linux/if_ether.h> */
+
+#define ETH_ALEN 6 /* Octets in one ethernet addr */
+#define ETH_HLEN 14 /* Total octets in header. */
+#define ETH_ZLEN 60 /* Min. octets in frame sans FCS */
+#define ETH_DATA_LEN 1500 /* Max. octets in payload */
+#define ETH_FRAME_LEN 1514 /* Max. octets in frame sans FCS */
+
+/*
+ * These are the defined Ethernet Protocol ID's.
+ */
+
+#define ETH_P_LOOP 0x0060 /* Ethernet Loopback packet */
+#define ETH_P_PUP 0x0200 /* Xerox PUP packet */
+#define ETH_P_PUPAT 0x0201 /* Xerox PUP Addr Trans packet */
+#define ETH_P_IP 0x0800 /* Internet Protocol packet */
+#define ETH_P_X25 0x0805 /* CCITT X.25 */
+#define ETH_P_ARP 0x0806 /* Address Resolution packet */
+#define ETH_P_BPQ 0x08FF /* G8BPQ AX.25 Ethernet Packet [ NOT AN OFFICIALLY REGISTERED ID ] */
+#define ETH_P_IEEEPUP 0x0a00 /* Xerox IEEE802.3 PUP packet */
+#define ETH_P_IEEEPUPAT 0x0a01 /* Xerox IEEE802.3 PUP Addr Trans packet */
+#define ETH_P_DEC 0x6000 /* DEC Assigned proto */
+#define ETH_P_DNA_DL 0x6001 /* DEC DNA Dump/Load */
+#define ETH_P_DNA_RC 0x6002 /* DEC DNA Remote Console */
+#define ETH_P_DNA_RT 0x6003 /* DEC DNA Routing */
+#define ETH_P_LAT 0x6004 /* DEC LAT */
+#define ETH_P_DIAG 0x6005 /* DEC Diagnostics */
+#define ETH_P_CUST 0x6006 /* DEC Customer use */
+#define ETH_P_SCA 0x6007 /* DEC Systems Comms Arch */
+#define ETH_P_RARP 0x8035 /* Reverse Addr Res packet */
+#define ETH_P_ATALK 0x809B /* Appletalk DDP */
+#define ETH_P_AARP 0x80F3 /* Appletalk AARP */
+#define ETH_P_8021Q 0x8100 /* 802.1Q VLAN Extended Header */
+#define ETH_P_IPX 0x8137 /* IPX over DIX */
+#define ETH_P_IPV6 0x86DD /* IPv6 over bluebook */
+#define ETH_P_PPP_DISC 0x8863 /* PPPoE discovery messages */
+#define ETH_P_PPP_SES 0x8864 /* PPPoE session messages */
+#define ETH_P_ATMMPOA 0x884c /* MultiProtocol Over ATM */
+#define ETH_P_ATMFATE 0x8884 /* Frame-based ATM Transport over Ethernet */
+
+/*
+ * Non DIX types. Won't clash for 1500 types.
+ */
+
+#define ETH_P_802_3 0x0001 /* Dummy type for 802.3 frames */
+#define ETH_P_AX25 0x0002 /* Dummy protocol id for AX.25 */
+#define ETH_P_ALL 0x0003 /* Every packet (be careful!!!) */
+#define ETH_P_802_2 0x0004 /* 802.2 frames */
+#define ETH_P_SNAP 0x0005 /* Internal only */
+#define ETH_P_DDCMP 0x0006 /* DEC DDCMP: Internal only */
+#define ETH_P_WAN_PPP 0x0007 /* Dummy type for WAN PPP frames*/
+#define ETH_P_PPP_MP 0x0008 /* Dummy type for PPP MP frames */
+#define ETH_P_LOCALTALK 0x0009 /* Localtalk pseudo type */
+#define ETH_P_PPPTALK 0x0010 /* Dummy type for Atalk over PPP*/
+#define ETH_P_TR_802_2 0x0011 /* 802.2 frames */
+#define ETH_P_MOBITEX 0x0015 /* Mobitex (kaz@cafe.net) */
+#define ETH_P_CONTROL 0x0016 /* Card specific control frames */
+#define ETH_P_IRDA 0x0017 /* Linux-IrDA */
+#define ETH_P_ECONET 0x0018 /* Acorn Econet */
+
+/*
+ * This is an Ethernet frame header.
+ */
+
+struct ethhdr {
+ unsigned char h_dest[ETH_ALEN]; /* destination eth addr */
+ unsigned char h_source[ETH_ALEN]; /* source ether addr */
+ unsigned short h_proto; /* packet type ID field */
+};
+
+#endif
diff --git a/mdk-stage1/dietlibc/include/netinet/ip_icmp.h b/mdk-stage1/dietlibc/include/netinet/ip_icmp.h
new file mode 100644
index 000000000..cf8e016f7
--- /dev/null
+++ b/mdk-stage1/dietlibc/include/netinet/ip_icmp.h
@@ -0,0 +1,145 @@
+#ifndef NETINET_IP_ICMP_H
+#define NETINET_IP_ICMP_H
+
+#include <sys/cdefs.h>
+#include <inttypes.h>
+#include <netinet/ip.h>
+
+struct icmphdr {
+ uint8_t type; /* message type */
+ uint8_t code; /* type sub-code */
+ uint16_t checksum;
+ union {
+ struct {
+ uint16_t id;
+ uint16_t sequence;
+ } echo; /* echo datagram */
+ uint32_t gateway; /* gateway address */
+ struct {
+ uint16_t __unused;
+ uint16_t mtu;
+ } frag; /* path mtu discovery */
+ } un;
+};
+
+#define ICMP_ECHOREPLY 0 /* Echo Reply */
+#define ICMP_DEST_UNREACH 3 /* Destination Unreachable */
+#define ICMP_SOURCE_QUENCH 4 /* Source Quench */
+#define ICMP_REDIRECT 5 /* Redirect (change route) */
+#define ICMP_ECHO 8 /* Echo Request */
+#define ICMP_TIME_EXCEEDED 11 /* Time Exceeded */
+#define ICMP_PARAMETERPROB 12 /* Parameter Problem */
+#define ICMP_TIMESTAMP 13 /* Timestamp Request */
+#define ICMP_TIMESTAMPREPLY 14 /* Timestamp Reply */
+#define ICMP_INFO_REQUEST 15 /* Information Request */
+#define ICMP_INFO_REPLY 16 /* Information Reply */
+#define ICMP_ADDRESS 17 /* Address Mask Request */
+#define ICMP_ADDRESSREPLY 18 /* Address Mask Reply */
+#define NR_ICMP_TYPES 18
+
+
+/* Codes for UNREACH. */
+#define ICMP_NET_UNREACH 0 /* Network Unreachable */
+#define ICMP_HOST_UNREACH 1 /* Host Unreachable */
+#define ICMP_PROT_UNREACH 2 /* Protocol Unreachable */
+#define ICMP_PORT_UNREACH 3 /* Port Unreachable */
+#define ICMP_FRAG_NEEDED 4 /* Fragmentation Needed/DF set */
+#define ICMP_SR_FAILED 5 /* Source Route failed */
+#define ICMP_NET_UNKNOWN 6
+#define ICMP_HOST_UNKNOWN 7
+#define ICMP_HOST_ISOLATED 8
+#define ICMP_NET_ANO 9
+#define ICMP_HOST_ANO 10
+#define ICMP_NET_UNR_TOS 11
+#define ICMP_HOST_UNR_TOS 12
+#define ICMP_PKT_FILTERED 13 /* Packet filtered */
+#define ICMP_PREC_VIOLATION 14 /* Precedence violation */
+#define ICMP_PREC_CUTOFF 15 /* Precedence cut off */
+#define NR_ICMP_UNREACH 15 /* instead of hardcoding immediate value */
+
+/* Codes for REDIRECT. */
+#define ICMP_REDIR_NET 0 /* Redirect Net */
+#define ICMP_REDIR_HOST 1 /* Redirect Host */
+#define ICMP_REDIR_NETTOS 2 /* Redirect Net for TOS */
+#define ICMP_REDIR_HOSTTOS 3 /* Redirect Host for TOS */
+
+/* Codes for TIME_EXCEEDED. */
+#define ICMP_EXC_TTL 0 /* TTL count exceeded */
+#define ICMP_EXC_FRAGTIME 1 /* Fragment Reass time exceeded */
+
+/*
+ * Lower bounds on packet lengths for various types.
+ * For the error advice packets must first insure that the
+ * packet is large enough to contain the returned ip header.
+ * Only then can we do the check to see if 64 bits of packet
+ * data have been returned, since we need to check the returned
+ * ip header length.
+ */
+#define ICMP_MINLEN 8 /* abs minimum */
+#define ICMP_TSLEN (8 + 3 * sizeof (n_time)) /* timestamp */
+#define ICMP_MASKLEN 12 /* address mask */
+#define ICMP_ADVLENMIN (8 + sizeof (struct ip) + 8) /* min */
+#ifndef _IP_VHL
+#define ICMP_ADVLEN(p) (8 + ((p)->icmp_ip.ip_hl << 2) + 8)
+ /* N.B.: must separately check that ip_hl >= 5 */
+#else
+#define ICMP_ADVLEN(p) (8 + (IP_VHL_HL((p)->icmp_ip.ip_vhl) << 2) + 8)
+ /* N.B.: must separately check that header length >= 5 */
+#endif
+
+/* Definition of type and code fields. */
+/* defined above: ICMP_ECHOREPLY, ICMP_REDIRECT, ICMP_ECHO */
+#define ICMP_UNREACH 3 /* dest unreachable, codes: */
+#define ICMP_SOURCEQUENCH 4 /* packet lost, slow down */
+#define ICMP_ROUTERADVERT 9 /* router advertisement */
+#define ICMP_ROUTERSOLICIT 10 /* router solicitation */
+#define ICMP_TIMXCEED 11 /* time exceeded, code: */
+#define ICMP_PARAMPROB 12 /* ip header bad */
+#define ICMP_TSTAMP 13 /* timestamp request */
+#define ICMP_TSTAMPREPLY 14 /* timestamp reply */
+#define ICMP_IREQ 15 /* information request */
+#define ICMP_IREQREPLY 16 /* information reply */
+#define ICMP_MASKREQ 17 /* address mask request */
+#define ICMP_MASKREPLY 18 /* address mask reply */
+
+#define ICMP_MAXTYPE 18
+
+/* UNREACH codes */
+#define ICMP_UNREACH_NET 0 /* bad net */
+#define ICMP_UNREACH_HOST 1 /* bad host */
+#define ICMP_UNREACH_PROTOCOL 2 /* bad protocol */
+#define ICMP_UNREACH_PORT 3 /* bad port */
+#define ICMP_UNREACH_NEEDFRAG 4 /* IP_DF caused drop */
+#define ICMP_UNREACH_SRCFAIL 5 /* src route failed */
+#define ICMP_UNREACH_NET_UNKNOWN 6 /* unknown net */
+#define ICMP_UNREACH_HOST_UNKNOWN 7 /* unknown host */
+#define ICMP_UNREACH_ISOLATED 8 /* src host isolated */
+#define ICMP_UNREACH_NET_PROHIB 9 /* net denied */
+#define ICMP_UNREACH_HOST_PROHIB 10 /* host denied */
+#define ICMP_UNREACH_TOSNET 11 /* bad tos for net */
+#define ICMP_UNREACH_TOSHOST 12 /* bad tos for host */
+#define ICMP_UNREACH_FILTER_PROHIB 13 /* admin prohib */
+#define ICMP_UNREACH_HOST_PRECEDENCE 14 /* host prec vio. */
+#define ICMP_UNREACH_PRECEDENCE_CUTOFF 15 /* prec cutoff */
+
+/* REDIRECT codes */
+#define ICMP_REDIRECT_NET 0 /* for network */
+#define ICMP_REDIRECT_HOST 1 /* for host */
+#define ICMP_REDIRECT_TOSNET 2 /* for tos and net */
+#define ICMP_REDIRECT_TOSHOST 3 /* for tos and host */
+
+/* TIMEXCEED codes */
+#define ICMP_TIMXCEED_INTRANS 0 /* ttl==0 in transit */
+#define ICMP_TIMXCEED_REASS 1 /* ttl==0 in reass */
+
+/* PARAMPROB code */
+#define ICMP_PARAMPROB_OPTABSENT 1 /* req. opt. absent */
+
+#define ICMP_INFOTYPE(type) \
+ ((type) == ICMP_ECHOREPLY || (type) == ICMP_ECHO || \
+ (type) == ICMP_ROUTERADVERT || (type) == ICMP_ROUTERSOLICIT || \
+ (type) == ICMP_TSTAMP || (type) == ICMP_TSTAMPREPLY || \
+ (type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || \
+ (type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY)
+
+#endif
diff --git a/mdk-stage1/dietlibc/include/netinet/tcp.h b/mdk-stage1/dietlibc/include/netinet/tcp.h
new file mode 100644
index 000000000..e47f24dff
--- /dev/null
+++ b/mdk-stage1/dietlibc/include/netinet/tcp.h
@@ -0,0 +1,164 @@
+#ifndef _NETINET_TCP_H
+#define _NETINET_TCP_H
+
+#include <inttypes.h>
+#include <endian.h>
+
+struct tcphdr { /* size 20/0x14 40/0x28 with IP header */
+ uint16_t source; /* offset 0 20/0x14 */
+ uint16_t dest; /* offset 2 22/0x16 */
+ uint32_t seq; /* offset 4 24/0x18 */
+ uint32_t ack_seq; /* offset 8 28/0x1c */
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+ uint16_t res1:4, doff:4, fin:1, syn:1, rst:1, psh:1, ack:1, urg:1, ece:1, cwr:1;
+#else
+ uint16_t doff:4, res1:4, cwr:1, ece:1, urg:1, ack:1, psh:1, rst:1, syn:1, fin:1;
+#endif
+ /* offset 12/0xc 32/0x20 */
+ uint16_t window; /* offset 14/0xe 34/0x22 */
+ uint16_t check; /* offset 16/0x10 36/0x24 */
+ uint16_t urg_ptr; /* offset 18/0x12 38/0x26 */
+};
+
+
+enum {
+ TCP_ESTABLISHED = 1,
+ TCP_SYN_SENT,
+ TCP_SYN_RECV,
+ TCP_FIN_WAIT1,
+ TCP_FIN_WAIT2,
+ TCP_TIME_WAIT,
+ TCP_CLOSE,
+ TCP_CLOSE_WAIT,
+ TCP_LAST_ACK,
+ TCP_LISTEN,
+ TCP_CLOSING, /* now a valid state */
+
+ TCP_MAX_STATES /* Leave at the end! */
+};
+
+#define TCP_STATE_MASK 0xF
+#define TCP_ACTION_FIN (1 << 7)
+
+enum {
+ TCPF_ESTABLISHED = (1 << 1),
+ TCPF_SYN_SENT = (1 << 2),
+ TCPF_SYN_RECV = (1 << 3),
+ TCPF_FIN_WAIT1 = (1 << 4),
+ TCPF_FIN_WAIT2 = (1 << 5),
+ TCPF_TIME_WAIT = (1 << 6),
+ TCPF_CLOSE = (1 << 7),
+ TCPF_CLOSE_WAIT = (1 << 8),
+ TCPF_LAST_ACK = (1 << 9),
+ TCPF_LISTEN = (1 << 10),
+ TCPF_CLOSING = (1 << 11)
+};
+
+/*
+ * The union cast uses a gcc extension to avoid aliasing problems
+ * (union is compatible to any of its members)
+ * This means this part of the code is -fstrict-aliasing safe now.
+ */
+union tcp_word_hdr {
+ struct tcphdr hdr;
+ uint32_t words[5];
+};
+
+#define tcp_flag_word(tp) ( ((union tcp_word_hdr *)(tp))->words [3])
+
+enum {
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+ TCP_FLAG_CWR = 0x00008000,
+ TCP_FLAG_ECE = 0x00004000,
+ TCP_FLAG_URG = 0x00002000,
+ TCP_FLAG_ACK = 0x00001000,
+ TCP_FLAG_PSH = 0x00000800,
+ TCP_FLAG_RST = 0x00000400,
+ TCP_FLAG_SYN = 0x00000200,
+ TCP_FLAG_FIN = 0x00000100,
+ TCP_RESERVED_BITS = 0x0000C00F,
+ TCP_DATA_OFFSET = 0x000000F0
+#else
+ TCP_FLAG_CWR = 0x00800000,
+ TCP_FLAG_ECE = 0x00400000,
+ TCP_FLAG_URG = 0x00200000,
+ TCP_FLAG_ACK = 0x00100000,
+ TCP_FLAG_PSH = 0x00080000,
+ TCP_FLAG_RST = 0x00040000,
+ TCP_FLAG_SYN = 0x00020000,
+ TCP_FLAG_FIN = 0x00010000,
+ TCP_RESERVED_BITS = 0x0FC00000,
+ TCP_DATA_OFFSET = 0xF0000000
+#endif
+};
+
+/* TCP socket options */
+#define TCP_NODELAY 1 /* Turn off Nagle's algorithm. */
+#define TCP_MAXSEG 2 /* Limit MSS */
+#define TCP_CORK 3 /* Never send partially complete segments */
+#define TCP_KEEPIDLE 4 /* Start keeplives after this period */
+#define TCP_KEEPINTVL 5 /* Interval between keepalives */
+#define TCP_KEEPCNT 6 /* Number of keepalives before death */
+#define TCP_SYNCNT 7 /* Number of SYN retransmits */
+#define TCP_LINGER2 8 /* Life time of orphaned FIN-WAIT-2 state */
+#define TCP_DEFER_ACCEPT 9 /* Wake up listener only when data arrive */
+#define TCP_WINDOW_CLAMP 10 /* Bound advertised window */
+#define TCP_INFO 11 /* Information about this connection. */
+#define TCP_QUICKACK 12 /* Block/reenable quick acks */
+
+#define TCPI_OPT_TIMESTAMPS 1
+#define TCPI_OPT_SACK 2
+#define TCPI_OPT_WSCALE 4
+#define TCPI_OPT_ECN 8
+
+enum tcp_ca_state {
+ TCP_CA_Open = 0,
+#define TCPF_CA_Open (1<<TCP_CA_Open)
+ TCP_CA_Disorder = 1,
+#define TCPF_CA_Disorder (1<<TCP_CA_Disorder)
+ TCP_CA_CWR = 2,
+#define TCPF_CA_CWR (1<<TCP_CA_CWR)
+ TCP_CA_Recovery = 3,
+#define TCPF_CA_Recovery (1<<TCP_CA_Recovery)
+ TCP_CA_Loss = 4
+#define TCPF_CA_Loss (1<<TCP_CA_Loss)
+};
+
+struct tcp_info {
+ uint8_t tcpi_state;
+ uint8_t tcpi_ca_state;
+ uint8_t tcpi_retransmits;
+ uint8_t tcpi_probes;
+ uint8_t tcpi_backoff;
+ uint8_t tcpi_options;
+ uint8_t tcpi_snd_wscale : 4, tcpi_rcv_wscale : 4;
+
+ uint32_t tcpi_rto;
+ uint32_t tcpi_ato;
+ uint32_t tcpi_snd_mss;
+ uint32_t tcpi_rcv_mss;
+
+ uint32_t tcpi_unacked;
+ uint32_t tcpi_sacked;
+ uint32_t tcpi_lost;
+ uint32_t tcpi_retrans;
+ uint32_t tcpi_fackets;
+
+ /* Times. */
+ uint32_t tcpi_last_data_sent;
+ uint32_t tcpi_last_ack_sent; /* Not remembered, sorry. */
+ uint32_t tcpi_last_data_recv;
+ uint32_t tcpi_last_ack_recv;
+
+ /* Metrics. */
+ uint32_t tcpi_pmtu;
+ uint32_t tcpi_rcv_ssthresh;
+ uint32_t tcpi_rtt;
+ uint32_t tcpi_rttvar;
+ uint32_t tcpi_snd_ssthresh;
+ uint32_t tcpi_snd_cwnd;
+ uint32_t tcpi_advmss;
+ uint32_t tcpi_reordering;
+};
+
+#endif
diff --git a/mdk-stage1/dietlibc/include/netinet/udp.h b/mdk-stage1/dietlibc/include/netinet/udp.h
new file mode 100644
index 000000000..3c5e9524e
--- /dev/null
+++ b/mdk-stage1/dietlibc/include/netinet/udp.h
@@ -0,0 +1,16 @@
+#ifndef _NETINET_UDP_H
+#define _NETINET_UDP_H
+
+#include <sys/cdefs.h>
+#include <sys/types.h>
+
+struct udphdr { /* size 8 28/0x1c with IP header */
+ uint16_t source; /* offset 0 20/0x14 */
+ uint16_t dest; /* offset 2 22/0x16 */
+ uint16_t len; /* offset 4 24/0x18 */
+ uint16_t check; /* offset 6 26/0x1a */
+};
+
+#define SOL_UDP 17 /* sockopt level for UDP */
+
+#endif
diff --git a/mdk-stage1/dietlibc/include/netpacket/packet.h b/mdk-stage1/dietlibc/include/netpacket/packet.h
new file mode 100644
index 000000000..b265094c6
--- /dev/null
+++ b/mdk-stage1/dietlibc/include/netpacket/packet.h
@@ -0,0 +1,41 @@
+#ifndef __NETPACKET_PACKET_H
+#define __NETPACKET_PACKET_H
+
+struct sockaddr_ll {
+ unsigned short int sll_family;
+ unsigned short int sll_protocol;
+ int sll_ifindex;
+ unsigned short int sll_hatype;
+ unsigned char sll_pkttype;
+ unsigned char sll_halen;
+ unsigned char sll_addr[8];
+};
+
+#define PACKET_HOST 0 /* To us. */
+#define PACKET_BROADCAST 1 /* To all. */
+#define PACKET_MULTICAST 2 /* To group. */
+#define PACKET_OTHERHOST 3 /* To someone else. */
+#define PACKET_OUTGOING 4 /* Originated by us. */
+#define PACKET_LOOPBACK 5
+#define PACKET_FASTROUTE 6
+
+/* Packet socket options. */
+
+#define PACKET_ADD_MEMBERSHIP 1
+#define PACKET_DROP_MEMBERSHIP 2
+#define PACKET_RECV_OUTPUT 3
+#define PACKET_RX_RING 5
+#define PACKET_STATISTICS 6
+
+struct packet_mreq {
+ int mr_ifindex;
+ unsigned short int mr_type;
+ unsigned short int mr_alen;
+ unsigned char mr_address[8];
+};
+
+#define PACKET_MR_MULTICAST 0
+#define PACKET_MR_PROMISC 1
+#define PACKET_MR_ALLMULTI 2
+
+#endif
diff --git a/mdk-stage1/dietlibc/include/pty.h b/mdk-stage1/dietlibc/include/pty.h
new file mode 100644
index 000000000..fa53d9934
--- /dev/null
+++ b/mdk-stage1/dietlibc/include/pty.h
@@ -0,0 +1,13 @@
+#ifndef _PTY_H
+#define _PTY_H
+
+#include <sys/cdefs.h>
+#include <termios.h>
+
+/* Create pseudo tty master slave pair with NAME and set terminal
+ * attributes according to TERMP and WINP and return handles for both
+ * ends in AMASTER and ASLAVE. */
+extern int openpty (int *__amaster, int *__aslave, char *__name, struct
+ termios *__termp, struct winsize *__winp) __THROW;
+
+#endif
diff --git a/mdk-stage1/dietlibc/include/stdarg-cruft.h b/mdk-stage1/dietlibc/include/stdarg-cruft.h
new file mode 100644
index 000000000..fbd9e0ca4
--- /dev/null
+++ b/mdk-stage1/dietlibc/include/stdarg-cruft.h
@@ -0,0 +1,299 @@
+#if defined(__sparc__) || defined(__alpha__) || defined(__mips__)
+enum {
+ __no_type_class = -1,
+ __void_type_class,
+ __integer_type_class,
+ __char_type_class,
+ __enumeral_type_class,
+ __boolean_type_class,
+ __pointer_type_class,
+ __reference_type_class,
+ __offset_type_class,
+ __real_type_class,
+ __complex_type_class,
+ __function_type_class,
+ __method_type_class,
+ __record_type_class,
+ __union_type_class,
+ __array_type_class,
+ __string_type_class,
+ __set_type_class,
+ __file_type_class,
+ __lang_type_class
+};
+#endif
+
+#if defined(__sparc__)
+
+typedef char* va_list;
+#define va_end(ap) ap=0
+
+#define va_start(AP, LASTARG) \
+ (__builtin_next_arg (LASTARG), AP = (char *) __builtin_saveregs ())
+
+#define __va_rounded_size(TYPE) \
+ (((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))
+
+/* We don't declare the union member `d' to have type TYPE
+ because that would lose in C++ if TYPE has a constructor. */
+/* We cast to void * and then to TYPE * because this avoids
+ a warning about increasing the alignment requirement.
+ The casts to char * avoid warnings about invalid pointer arithmetic. */
+#define va_arg(pvar,TYPE) \
+__extension__ \
+(*({((__builtin_classify_type (*(TYPE*) 0) >= __record_type_class \
+ || (__builtin_classify_type (*(TYPE*) 0) == __real_type_class \
+ && sizeof (TYPE) == 16)) \
+ ? ((pvar) = (char *)(pvar) + __va_rounded_size (TYPE *), \
+ *(TYPE **) (void *) ((char *)(pvar) - __va_rounded_size (TYPE *))) \
+ : __va_rounded_size (TYPE) == 8 \
+ ? ({ union {char __d[sizeof (TYPE)]; int __i[2];} __u; \
+ __u.__i[0] = ((int *) (void *) (pvar))[0]; \
+ __u.__i[1] = ((int *) (void *) (pvar))[1]; \
+ (pvar) = (char *)(pvar) + 8; \
+ (TYPE *) (void *) __u.__d; }) \
+ : ((pvar) = (char *)(pvar) + __va_rounded_size (TYPE), \
+ ((TYPE *) (void *) ((char *)(pvar) - __va_rounded_size (TYPE)))));}))
+
+
+#elif defined(__mips__)
+
+typedef char * va_list;
+
+#ifdef __mips64
+#define __va_rounded_size(__TYPE) \
+ (((sizeof (__TYPE) + 8 - 1) / 8) * 8)
+#else
+#define __va_rounded_size(__TYPE) \
+ (((sizeof (__TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))
+#endif
+#ifdef __mips64
+#define __va_reg_size 8
+#else
+#define __va_reg_size 4
+#endif
+
+#define va_start(__AP, __LASTARG) \
+ (__AP = (va_list) __builtin_next_arg (__LASTARG))
+
+#ifdef __mips64
+#ifdef __MIPSEB__
+#define va_arg(__AP, __type) \
+ ((__type *) (void *) (__AP = (char *) \
+ ((((__PTRDIFF_TYPE__)__AP + 8 - 1) & -8) \
+ + __va_rounded_size (__type))))[-1]
+#else
+#define va_arg(__AP, __type) \
+ ((__AP = (char *) ((((__PTRDIFF_TYPE__)__AP + 8 - 1) & -8) \
+ + __va_rounded_size (__type))), \
+ *(__type *) (void *) (__AP - __va_rounded_size (__type)))
+#endif
+
+#else /* not __mips64 */
+
+#ifdef __MIPSEB__
+/* For big-endian machines. */
+#define va_arg(__AP, __type) \
+ ((__AP = (char *) ((__alignof__ (__type) > 4 \
+ ? ((__PTRDIFF_TYPE__)__AP + 8 - 1) & -8 \
+ : ((__PTRDIFF_TYPE__)__AP + 4 - 1) & -4) \
+ + __va_rounded_size (__type))), \
+ *(__type *) (void *) (__AP - __va_rounded_size (__type)))
+#else
+/* For little-endian machines. */
+#define va_arg(__AP, __type) \
+ ((__type *) (void *) (__AP = (char *) ((__alignof__(__type) > 4 \
+ ? ((__PTRDIFF_TYPE__)__AP + 8 - 1) & -8 \
+ : ((__PTRDIFF_TYPE__)__AP + 4 - 1) & -4) \
+ + __va_rounded_size(__type))))[-1]
+#endif
+#endif
+
+#elif defined(__powerpc__)
+
+typedef struct __va_list_tag {
+ unsigned char gpr; /* index into the array of 8 GPRs stored in the
+ register save area gpr=0 corresponds to r3,
+ gpr=1 to r4, etc. */
+ unsigned char fpr; /* index into the array of 8 FPRs stored in the
+ register save area fpr=0 corresponds to f1,
+ fpr=1 to f2, etc. */
+ char *overflow_arg_area; /* location on stack that holds the next
+ overflow argument */
+ char *reg_save_area; /* where r3:r10 and f1:f8, if saved are stored */
+} va_list[1];
+
+#define __va_overflow(AP) (AP)->overflow_arg_area
+#ifdef __OPTIMIZE__
+extern void __va_arg_type_violation(void) __attribute__((__noreturn__));
+#else
+#define __va_arg_type_violation()
+#endif
+
+typedef struct {
+ long __gp_save[8]; /* save area for GP registers */
+ double __fp_save[8]; /* save area for FP registers */
+} __va_regsave_t;
+
+/* Macros to access the register save area */
+/* We cast to void * and then to TYPE * because this avoids
+ a warning about increasing the alignment requirement. */
+#define __VA_FP_REGSAVE(AP,OFS,TYPE) \
+ ((TYPE *) (void *) (&(((__va_regsave_t *) \
+ (AP)->reg_save_area)->__fp_save[OFS])))
+
+#define __VA_GP_REGSAVE(AP,OFS,TYPE) \
+ ((TYPE *) (void *) (&(((__va_regsave_t *) \
+ (AP)->reg_save_area)->__gp_save[OFS])))
+
+#define __va_start_common(AP, FAKE) \
+ __builtin_memcpy ((AP), __builtin_saveregs (), sizeof(va_list))
+
+#define va_start(AP,LASTARG) \
+ (__builtin_next_arg (LASTARG), __va_start_common (AP, 0))
+
+#ifdef _SOFT_FLOAT
+#define __va_float_p(TYPE) 0
+#else
+#define __va_float_p(TYPE) (__builtin_classify_type(*(TYPE *)0) == 8)
+#endif
+
+#define __va_aggregate_p(TYPE) (__builtin_classify_type(*(TYPE *)0) >= 12)
+#define __va_size(TYPE) ((sizeof(TYPE) + sizeof (long) - 1) / sizeof (long))
+
+#define va_arg(AP,TYPE) \
+__extension__ (*({ \
+ register TYPE *__ptr; \
+ \
+ if (__va_float_p (TYPE) && sizeof (TYPE) < 16) \
+ { \
+ unsigned char __fpr = (AP)->fpr; \
+ if (__fpr < 8) \
+ { \
+ __ptr = __VA_FP_REGSAVE (AP, __fpr, TYPE); \
+ (AP)->fpr = __fpr + 1; \
+ } \
+ else if (sizeof (TYPE) == 8) \
+ { \
+ unsigned long __addr = (unsigned long) (__va_overflow (AP)); \
+ __ptr = (TYPE *)((__addr + 7) & -8); \
+ __va_overflow (AP) = (char *)(__ptr + 1); \
+ } \
+ else \
+ { \
+ /* float is promoted to double. */ \
+ __va_arg_type_violation (); \
+ } \
+ } \
+ \
+ /* Aggregates and long doubles are passed by reference. */ \
+ else if (__va_aggregate_p (TYPE) || __va_float_p (TYPE)) \
+ { \
+ unsigned char __gpr = (AP)->gpr; \
+ if (__gpr < 8) \
+ { \
+ __ptr = * __VA_GP_REGSAVE (AP, __gpr, TYPE *); \
+ (AP)->gpr = __gpr + 1; \
+ } \
+ else \
+ { \
+ TYPE **__pptr = (TYPE **) (__va_overflow (AP)); \
+ __ptr = * __pptr; \
+ __va_overflow (AP) = (char *) (__pptr + 1); \
+ } \
+ } \
+ \
+ /* Only integrals remaining. */ \
+ else \
+ { \
+ /* longlong is aligned. */ \
+ if (sizeof (TYPE) == 8) \
+ { \
+ unsigned char __gpr = (AP)->gpr; \
+ if (__gpr < 7) \
+ { \
+ __gpr += __gpr & 1; \
+ __ptr = __VA_GP_REGSAVE (AP, __gpr, TYPE); \
+ (AP)->gpr = __gpr + 2; \
+ } \
+ else \
+ { \
+ unsigned long __addr = (unsigned long) (__va_overflow (AP)); \
+ __ptr = (TYPE *)((__addr + 7) & -8); \
+ (AP)->gpr = 8; \
+ __va_overflow (AP) = (char *)(__ptr + 1); \
+ } \
+ } \
+ else if (sizeof (TYPE) == 4) \
+ { \
+ unsigned char __gpr = (AP)->gpr; \
+ if (__gpr < 8) \
+ { \
+ __ptr = __VA_GP_REGSAVE (AP, __gpr, TYPE); \
+ (AP)->gpr = __gpr + 1; \
+ } \
+ else \
+ { \
+ __ptr = (TYPE *) __va_overflow (AP); \
+ __va_overflow (AP) = (char *)(__ptr + 1); \
+ } \
+ } \
+ else \
+ { \
+ /* Everything else was promoted to int. */ \
+ __va_arg_type_violation (); \
+ } \
+ } \
+ __ptr; \
+}))
+
+#define va_end(AP) ((void)0)
+
+/* Copy va_list into another variable of this type. */
+#define __va_copy(dest, src) *(dest) = *(src)
+
+#elif defined(__alpha__)
+
+typedef struct {
+ char *__base; /* Pointer to first integer register. */
+ int __offset; /* Byte offset of args so far. */
+} va_list;
+
+#define va_start(pvar, firstarg) \
+ (__builtin_next_arg (firstarg), \
+ (pvar) = *(va_list *) __builtin_saveregs ())
+#define va_end(__va) ((void) 0)
+
+#define __va_tsize(__type) \
+ (((sizeof (__type) + __extension__ sizeof (long long) - 1) \
+ / __extension__ sizeof (long long)) * __extension__ sizeof (long long))
+
+#define va_arg(__va, __type) \
+(*(((__va).__offset += __va_tsize (__type)), \
+ (__type *)(void *)((__va).__base + (__va).__offset \
+ - (((__builtin_classify_type (* (__type *) 0) \
+ == __real_type_class) && (__va).__offset <= (6 * 8)) \
+ ? (6 * 8) + 8 : __va_tsize (__type)))))
+
+#else /* !__sparc__ && !__powerpc__ && !__mips__ && !__alpha__*/
+
+typedef char* va_list;
+
+/* this only works when everything is passed on the stack (i.e. x86) */
+#if __WORDSIZE == 64
+#define va_start(ap,argn) ap=((char*)&argn)+8
+#else
+#define va_start(ap,argn) ap=((char*)&argn)+4
+#endif
+#define va_arg(ap,type) (ap+=sizeof(type), *(type*)((void*)ap-sizeof(type)))
+
+#endif
+
+#ifndef __va_copy
+#define __va_copy(x,y) x=y
+#endif
+
+#ifndef va_end
+#define va_end(ap) ((void)0)
+#endif
+
diff --git a/mdk-stage1/dietlibc/include/stdarg.h b/mdk-stage1/dietlibc/include/stdarg.h
new file mode 100644
index 000000000..3a21bdb56
--- /dev/null
+++ b/mdk-stage1/dietlibc/include/stdarg.h
@@ -0,0 +1,24 @@
+#ifndef _STDARG_H
+#define _STDARG_H
+
+#include <endian.h>
+
+#if (__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 96))
+
+typedef __builtin_va_list va_list;
+#define va_start(v,l) __builtin_stdarg_start((v),l)
+#define va_end __builtin_va_end
+#define va_arg __builtin_va_arg
+#define __va_copy(d,s) __builtin_va_copy((d),(s))
+
+#endif
+
+#ifndef va_end
+#include <stdarg-cruft.h>
+#endif
+
+#if !defined(__STRICT_ANSI__) || __STDC_VERSION__ + 0 >= 199900L
+#define va_copy(d,s) __va_copy(d,s)
+#endif
+
+#endif
diff --git a/mdk-stage1/dietlibc/include/stddef.h b/mdk-stage1/dietlibc/include/stddef.h
new file mode 100644
index 000000000..cdf54ec1e
--- /dev/null
+++ b/mdk-stage1/dietlibc/include/stddef.h
@@ -0,0 +1,23 @@
+#ifndef _STDDEF_H
+#define _STDDEF_H
+
+/* ugh. This is normally provided by gcc. */
+
+#ifdef __GNUC__
+typedef __PTRDIFF_TYPE__ ptrdiff_t;
+typedef __SIZE_TYPE__ size_t;
+typedef __WCHAR_TYPE__ wchar_t;
+#else
+typedef signed long ptrdiff_t;
+typedef unsigned long size_t;
+typedef int wchar_t;
+#endif
+
+#ifndef NULL
+#define NULL (void*)0
+#endif
+
+#undef offsetof
+#define offsetof(type,member) ((size_t) &((type*)0)->member)
+
+#endif
diff --git a/mdk-stage1/dietlibc/include/sys/alpha-ioctl.h b/mdk-stage1/dietlibc/include/sys/alpha-ioctl.h
new file mode 100644
index 000000000..f1bde3bbb
--- /dev/null
+++ b/mdk-stage1/dietlibc/include/sys/alpha-ioctl.h
@@ -0,0 +1,168 @@
+#define _IOC_NRBITS 8
+#define _IOC_TYPEBITS 8
+#define _IOC_SIZEBITS 13
+#define _IOC_DIRBITS 3
+
+#define _IOC_NRMASK ((1 << _IOC_NRBITS)-1)
+#define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1)
+#define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1)
+#define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1)
+
+#define _IOC_NRSHIFT 0
+#define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS)
+#define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS)
+#define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS)
+
+/*
+ * Direction bits _IOC_NONE could be 0, but OSF/1 gives it a bit.
+ * And this turns out useful to catch old ioctl numbers in header
+ * files for us.
+ */
+#define _IOC_NONE 1U
+#define _IOC_READ 2U
+#define _IOC_WRITE 4U
+
+#define _IOC(dir,type,nr,size) \
+ ((unsigned int) \
+ (((dir) << _IOC_DIRSHIFT) | \
+ ((type) << _IOC_TYPESHIFT) | \
+ ((nr) << _IOC_NRSHIFT) | \
+ ((size) << _IOC_SIZESHIFT)))
+
+/* used to create numbers */
+#define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0)
+#define _IOR(type,nr,size) _IOC(_IOC_READ,(type),(nr),sizeof(size))
+#define _IOW(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),sizeof(size))
+#define _IOWR(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size))
+
+/* used to decode them.. */
+#define _IOC_DIR(nr) (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK)
+#define _IOC_TYPE(nr) (((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK)
+#define _IOC_NR(nr) (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK)
+#define _IOC_SIZE(nr) (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK)
+
+/* ...and for the drivers/sound files... */
+
+#define IOC_IN (_IOC_WRITE << _IOC_DIRSHIFT)
+#define IOC_OUT (_IOC_READ << _IOC_DIRSHIFT)
+#define IOC_INOUT ((_IOC_WRITE|_IOC_READ) << _IOC_DIRSHIFT)
+#define IOCSIZE_MASK (_IOC_SIZEMASK << _IOC_SIZESHIFT)
+#define IOCSIZE_SHIFT (_IOC_SIZESHIFT)
+
+#define FIOCLEX _IO('f', 1)
+#define FIONCLEX _IO('f', 2)
+#define FIOASYNC _IOW('f', 125, int)
+#define FIONBIO _IOW('f', 126, int)
+#define FIONREAD _IOR('f', 127, int)
+#define TIOCINQ FIONREAD
+#define FIOQSIZE _IOR('f', 128, loff_t)
+
+#define TIOCGETP _IOR('t', 8, struct sgttyb)
+#define TIOCSETP _IOW('t', 9, struct sgttyb)
+#define TIOCSETN _IOW('t', 10, struct sgttyb) /* TIOCSETP wo flush */
+
+#define TIOCSETC _IOW('t', 17, struct tchars)
+#define TIOCGETC _IOR('t', 18, struct tchars)
+#define TCGETS _IOR('t', 19, struct termios)
+#define TCSETS _IOW('t', 20, struct termios)
+#define TCSETSW _IOW('t', 21, struct termios)
+#define TCSETSF _IOW('t', 22, struct termios)
+
+#define TCGETA _IOR('t', 23, struct termio)
+#define TCSETA _IOW('t', 24, struct termio)
+#define TCSETAW _IOW('t', 25, struct termio)
+#define TCSETAF _IOW('t', 28, struct termio)
+
+#define TCSBRK _IO('t', 29)
+#define TCXONC _IO('t', 30)
+#define TCFLSH _IO('t', 31)
+
+#define TIOCSWINSZ _IOW('t', 103, struct winsize)
+#define TIOCGWINSZ _IOR('t', 104, struct winsize)
+#define TIOCSTART _IO('t', 110) /* start output, like ^Q */
+#define TIOCSTOP _IO('t', 111) /* stop output, like ^S */
+#define TIOCOUTQ _IOR('t', 115, int) /* output queue size */
+
+#define TIOCGLTC _IOR('t', 116, struct ltchars)
+#define TIOCSLTC _IOW('t', 117, struct ltchars)
+#define TIOCSPGRP _IOW('t', 118, int)
+#define TIOCGPGRP _IOR('t', 119, int)
+
+#define TIOCEXCL 0x540C
+#define TIOCNXCL 0x540D
+#define TIOCSCTTY 0x540E
+
+#define TIOCSTI 0x5412
+#define TIOCMGET 0x5415
+#define TIOCMBIS 0x5416
+#define TIOCMBIC 0x5417
+#define TIOCMSET 0x5418
+# define TIOCM_LE 0x001
+# define TIOCM_DTR 0x002
+# define TIOCM_RTS 0x004
+# define TIOCM_ST 0x008
+# define TIOCM_SR 0x010
+# define TIOCM_CTS 0x020
+# define TIOCM_CAR 0x040
+# define TIOCM_RNG 0x080
+# define TIOCM_DSR 0x100
+# define TIOCM_CD TIOCM_CAR
+# define TIOCM_RI TIOCM_RNG
+# define TIOCM_OUT1 0x2000
+# define TIOCM_OUT2 0x4000
+# define TIOCM_LOOP 0x8000
+
+#define TIOCGSOFTCAR 0x5419
+#define TIOCSSOFTCAR 0x541A
+#define TIOCLINUX 0x541C
+#define TIOCCONS 0x541D
+#define TIOCGSERIAL 0x541E
+#define TIOCSSERIAL 0x541F
+#define TIOCPKT 0x5420
+# define TIOCPKT_DATA 0
+# define TIOCPKT_FLUSHREAD 1
+# define TIOCPKT_FLUSHWRITE 2
+# define TIOCPKT_STOP 4
+# define TIOCPKT_START 8
+# define TIOCPKT_NOSTOP 16
+# define TIOCPKT_DOSTOP 32
+
+
+#define TIOCNOTTY 0x5422
+#define TIOCSETD 0x5423
+#define TIOCGETD 0x5424
+#define TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */
+#define TIOCTTYGSTRUCT 0x5426 /* For debugging only */
+#define TIOCSBRK 0x5427 /* BSD compatibility */
+#define TIOCCBRK 0x5428 /* BSD compatibility */
+#define TIOCGSID 0x5429 /* Return the session ID of FD */
+#define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
+#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */
+
+#define TIOCSERCONFIG 0x5453
+#define TIOCSERGWILD 0x5454
+#define TIOCSERSWILD 0x5455
+#define TIOCGLCKTRMIOS 0x5456
+#define TIOCSLCKTRMIOS 0x5457
+#define TIOCSERGSTRUCT 0x5458 /* For debugging only */
+#define TIOCSERGETLSR 0x5459 /* Get line status register */
+ /* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */
+# define TIOCSER_TEMT 0x01 /* Transmitter physically empty */
+#define TIOCSERGETMULTI 0x545A /* Get multiport config */
+#define TIOCSERSETMULTI 0x545B /* Set multiport config */
+
+#define TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */
+#define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */
+#define TIOCGHAYESESP 0x545E /* Get Hayes ESP configuration */
+#define TIOCSHAYESESP 0x545F /* Set Hayes ESP configuration */
+
+/* Socket-level I/O control calls. */
+
+#define FIOGETOWN _IOR('f', 123, int)
+#define FIOSETOWN _IOW('f', 124, int)
+
+#define SIOCATMARK _IOR('s', 7, int)
+#define SIOCSPGRP _IOW('s', 8, pid_t)
+#define SIOCGPGRP _IOR('s', 9, pid_t)
+
+#define SIOCGSTAMP 0x8906 /* Get stamp - linux-specific */
diff --git a/mdk-stage1/dietlibc/include/sys/arm-ioctl.h b/mdk-stage1/dietlibc/include/sys/arm-ioctl.h
new file mode 100644
index 000000000..ab8b844a5
--- /dev/null
+++ b/mdk-stage1/dietlibc/include/sys/arm-ioctl.h
@@ -0,0 +1,149 @@
+
+/* ioctl command encoding: 32 bits total, command in lower 16 bits,
+ * size of the parameter structure in the lower 14 bits of the
+ * upper 16 bits.
+ * Encoding the size of the parameter structure in the ioctl request
+ * is useful for catching programs compiled with old versions
+ * and to avoid overwriting user space outside the user buffer area.
+ * The highest 2 bits are reserved for indicating the ``access mode''.
+ * NOTE: This limits the max parameter size to 16kB -1 !
+ */
+
+/*
+ * The following is for compatibility across the various Linux
+ * platforms. The i386 ioctl numbering scheme doesn't really enforce
+ * a type field. De facto, however, the top 8 bits of the lower 16
+ * bits are indeed used as a type field, so we might just as well make
+ * this explicit here. Please be sure to use the decoding macros
+ * below from now on.
+ */
+#define _IOC_NRBITS 8
+#define _IOC_TYPEBITS 8
+#define _IOC_SIZEBITS 14
+#define _IOC_DIRBITS 2
+
+#define _IOC_NRMASK ((1 << _IOC_NRBITS)-1)
+#define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1)
+#define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1)
+#define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1)
+
+#define _IOC_NRSHIFT 0
+#define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS)
+#define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS)
+#define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS)
+
+/*
+ * Direction bits.
+ */
+#define _IOC_NONE 0U
+#define _IOC_WRITE 1U
+#define _IOC_READ 2U
+
+#define _IOC(dir,type,nr,size) \
+ (((dir) << _IOC_DIRSHIFT) | \
+ ((type) << _IOC_TYPESHIFT) | \
+ ((nr) << _IOC_NRSHIFT) | \
+ ((size) << _IOC_SIZESHIFT))
+
+/* used to create numbers */
+#define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0)
+#define _IOR(type,nr,size) _IOC(_IOC_READ,(type),(nr),sizeof(size))
+#define _IOW(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),sizeof(size))
+#define _IOWR(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size))
+
+/* used to decode ioctl numbers.. */
+#define _IOC_DIR(nr) (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK)
+#define _IOC_TYPE(nr) (((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK)
+#define _IOC_NR(nr) (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK)
+#define _IOC_SIZE(nr) (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK)
+
+/* ...and for the drivers/sound files... */
+
+#define IOC_IN (_IOC_WRITE << _IOC_DIRSHIFT)
+#define IOC_OUT (_IOC_READ << _IOC_DIRSHIFT)
+#define IOC_INOUT ((_IOC_WRITE|_IOC_READ) << _IOC_DIRSHIFT)
+#define IOCSIZE_MASK (_IOC_SIZEMASK << _IOC_SIZESHIFT)
+#define IOCSIZE_SHIFT (_IOC_SIZESHIFT)
+
+/* 0x54 is just a magic number to make these relatively unique ('T') */
+
+#define TCGETS 0x5401
+#define TCSETS 0x5402
+#define TCSETSW 0x5403
+#define TCSETSF 0x5404
+#define TCGETA 0x5405
+#define TCSETA 0x5406
+#define TCSETAW 0x5407
+#define TCSETAF 0x5408
+#define TCSBRK 0x5409
+#define TCXONC 0x540A
+#define TCFLSH 0x540B
+#define TIOCEXCL 0x540C
+#define TIOCNXCL 0x540D
+#define TIOCSCTTY 0x540E
+#define TIOCGPGRP 0x540F
+#define TIOCSPGRP 0x5410
+#define TIOCOUTQ 0x5411
+#define TIOCSTI 0x5412
+#define TIOCGWINSZ 0x5413
+#define TIOCSWINSZ 0x5414
+#define TIOCMGET 0x5415
+#define TIOCMBIS 0x5416
+#define TIOCMBIC 0x5417
+#define TIOCMSET 0x5418
+#define TIOCGSOFTCAR 0x5419
+#define TIOCSSOFTCAR 0x541A
+#define FIONREAD 0x541B
+#define TIOCINQ FIONREAD
+#define TIOCLINUX 0x541C
+#define TIOCCONS 0x541D
+#define TIOCGSERIAL 0x541E
+#define TIOCSSERIAL 0x541F
+#define TIOCPKT 0x5420
+#define FIONBIO 0x5421
+#define TIOCNOTTY 0x5422
+#define TIOCSETD 0x5423
+#define TIOCGETD 0x5424
+#define TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */
+#define TIOCTTYGSTRUCT 0x5426 /* For debugging only */
+#define TIOCSBRK 0x5427 /* BSD compatibility */
+#define TIOCCBRK 0x5428 /* BSD compatibility */
+#define TIOCGSID 0x5429 /* Return the session ID of FD */
+#define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
+#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */
+
+#define FIONCLEX 0x5450 /* these numbers need to be adjusted. */
+#define FIOCLEX 0x5451
+#define FIOASYNC 0x5452
+#define TIOCSERCONFIG 0x5453
+#define TIOCSERGWILD 0x5454
+#define TIOCSERSWILD 0x5455
+#define TIOCGLCKTRMIOS 0x5456
+#define TIOCSLCKTRMIOS 0x5457
+#define TIOCSERGSTRUCT 0x5458 /* For debugging only */
+#define TIOCSERGETLSR 0x5459 /* Get line status register */
+#define TIOCSERGETMULTI 0x545A /* Get multiport config */
+#define TIOCSERSETMULTI 0x545B /* Set multiport config */
+
+#define TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */
+#define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */
+#define FIOQSIZE 0x545E
+
+/* Used for packet mode */
+#define TIOCPKT_DATA 0
+#define TIOCPKT_FLUSHREAD 1
+#define TIOCPKT_FLUSHWRITE 2
+#define TIOCPKT_STOP 4
+#define TIOCPKT_START 8
+#define TIOCPKT_NOSTOP 16
+#define TIOCPKT_DOSTOP 32
+
+#define TIOCSER_TEMT 0x01 /* Transmitter physically empty */
+
+/* Socket-level I/O control calls. */
+#define FIOSETOWN 0x8901
+#define SIOCSPGRP 0x8902
+#define FIOGETOWN 0x8903
+#define SIOCGPGRP 0x8904
+#define SIOCATMARK 0x8905
+#define SIOCGSTAMP 0x8906 /* Get stamp */
diff --git a/mdk-stage1/dietlibc/include/sys/epoll.h b/mdk-stage1/dietlibc/include/sys/epoll.h
new file mode 100644
index 000000000..d65d5465f
--- /dev/null
+++ b/mdk-stage1/dietlibc/include/sys/epoll.h
@@ -0,0 +1,60 @@
+#ifndef _SYS_EPOLL_H
+#define _SYS_EPOLL_H
+
+#include <sys/cdefs.h>
+#include <sys/types.h>
+#include <sys/poll.h>
+
+/* Valid opcodes ( "op" parameter ) to issue to epoll_ctl() */
+#define EPOLL_CTL_ADD 1 /* Add a file decriptor to the interface */
+#define EPOLL_CTL_DEL 2 /* Remove a file decriptor from the interface */
+#define EPOLL_CTL_MOD 3 /* Change file decriptor epoll_event structure */
+
+enum EPOLL_EVENTS {
+ EPOLLIN = 0x001,
+#define EPOLLIN EPOLLIN
+ EPOLLPRI = 0x002,
+#define EPOLLPRI EPOLLPRI
+ EPOLLOUT = 0x004,
+#define EPOLLOUT EPOLLOUT
+
+#ifdef __USE_XOPEN
+ EPOLLRDNORM = 0x040,
+#define EPOLLRDNORM EPOLLRDNORM
+ EPOLLRDBAND = 0x080,
+#define EPOLLRDBAND EPOLLRDBAND
+ EPOLLWRNORM = 0x100,
+#define EPOLLWRNORM EPOLLWRNORM
+ EPOLLWRBAND = 0x200,
+#define EPOLLWRBAND EPOLLWRBAND
+#endif /* #ifdef __USE_XOPEN */
+
+#ifdef __USE_GNU
+ EPOLLMSG = 0x400,
+#define EPOLLMSG EPOLLMSG
+#endif /* #ifdef __USE_GNU */
+
+ EPOLLERR = 0x008,
+#define EPOLLERR EPOLLERR
+ EPOLLHUP = 0x010
+#define EPOLLHUP EPOLLHUP
+};
+
+typedef union epoll_data {
+ void *ptr;
+ int fd;
+ uint32_t u32;
+ uint64_t u64;
+} epoll_data_t;
+
+struct epoll_event {
+ uint32_t events;
+ epoll_data_t data;
+};
+
+int epoll_create(int size) __THROW;
+int epoll_ctl(int epfd, int op, int fd, struct epoll_event* event) __THROW;
+int epoll_wait(int epfd, struct epoll_event *events, int maxevents,
+ int timeout) __THROW;
+
+#endif
diff --git a/mdk-stage1/dietlibc/include/sys/fsuid.h b/mdk-stage1/dietlibc/include/sys/fsuid.h
new file mode 100644
index 000000000..538070451
--- /dev/null
+++ b/mdk-stage1/dietlibc/include/sys/fsuid.h
@@ -0,0 +1,12 @@
+#ifndef __FSUID_H
+#define __FSUID_H 1
+
+#include <sys/types.h>
+
+/* Linux only: */
+int setfsuid(uid_t uid);
+int setfsgid(gid_t gid);
+int setfsuid32(uid32_t fsuid) __THROW;
+int setfsgid32(gid32_t fsgid) __THROW;
+
+#endif
diff --git a/mdk-stage1/dietlibc/include/sys/gmon.h b/mdk-stage1/dietlibc/include/sys/gmon.h
new file mode 100644
index 000000000..50aae3028
--- /dev/null
+++ b/mdk-stage1/dietlibc/include/sys/gmon.h
@@ -0,0 +1,99 @@
+#ifndef __DLC_GMON_H_
+#define __DLC_GMON_H_
+
+# define HISTCOUNTER unsigned short
+# define HISTFRACTION 2
+# define HASHFRACTION 2
+# define ARCDENSITY 2
+# define MINARCS 50
+# define MAXARCS (( 1 << (8 * sizeof(HISTCOUNTER))) - 2)
+
+# define ROUNDDOWN(x,y) (((x)/(y))*y)
+# define ROUNDUP(x,y) ((((x)+(y)-1)/(y))*y)
+
+# define PROF_SECTION __attribute__ ((section (".profile")))
+
+struct tostruct {
+ unsigned long selfpc;
+ signed long count;
+ unsigned short link;
+ unsigned short pad;
+};
+
+struct rawarc {
+ unsigned long raw_frompc;
+ unsigned long raw_selfpc;
+ signed long raw_count;
+};
+
+struct monparam {
+ unsigned short *kcount;
+ unsigned long kcountsize;
+ struct rawarc *arcs;
+ unsigned long arcnum;
+ unsigned long lowpc;
+ unsigned long highpc;
+ unsigned long textsize;
+};
+
+struct gmonparam {
+ long state;
+ unsigned short *kcount;
+ unsigned long kcountsize;
+ unsigned short *froms;
+ unsigned long fromsize;
+ struct tostruct *tos;
+ unsigned long tossize;
+ long tolimit;
+ unsigned long lowpc;
+ unsigned long highpc;
+ unsigned long textsize;
+ unsigned long hashfraction;
+ unsigned long log_hashfraction;
+};
+
+struct gmon_hdr {
+ char cookie[4];
+ long version;
+ char spare[12];
+};
+
+struct gmon_hist_hdr {
+ long low_pc;
+ long high_pc;
+ long hist_size;
+ long prof_rate;
+ char dimen[15];
+ char dimen_abbrev;
+};
+
+struct gmon_cg_arc_record {
+ long from_pc;
+ long self_pc;
+ long count;
+};
+
+struct __bb {
+ long zero_word;
+ char *filename;
+ long *counts;
+ long ncounts;
+ struct __bb *next;
+ unsigned long *addresses;
+};
+
+typedef enum {
+ GMON_TAG_TIME_HIST, GMON_TAG_CG_ARC, GMON_TAG_BB_COUNT
+} GMON_Record_Tag;
+
+enum { GMON_PROF_ON, GMON_PROF_BUSY, GMON_PROF_ERROR, GMON_PROF_OFF };
+enum { GPROF_STATE, GPROF_COUNT, GPROF_FROMS, GPROF_TOS, GPROF_GMONPARAM };
+
+extern struct gmonparam gmparam;
+extern struct __bb * __bb_head;
+
+extern void __monstartup(unsigned long, unsigned long);
+extern void monstartup(unsigned long, unsigned long);
+extern void _mcleanup(void);
+
+#endif
diff --git a/mdk-stage1/dietlibc/include/sys/gmon_out.h b/mdk-stage1/dietlibc/include/sys/gmon_out.h
new file mode 100644
index 000000000..31566b999
--- /dev/null
+++ b/mdk-stage1/dietlibc/include/sys/gmon_out.h
@@ -0,0 +1 @@
+#include <sys/gmon.h>
diff --git a/mdk-stage1/dietlibc/include/sys/hppa-ioctl.h b/mdk-stage1/dietlibc/include/sys/hppa-ioctl.h
new file mode 100644
index 000000000..62b6f1cf9
--- /dev/null
+++ b/mdk-stage1/dietlibc/include/sys/hppa-ioctl.h
@@ -0,0 +1,133 @@
+#ifndef __ARCH_PARISC_IOCTLS_H__
+#define __ARCH_PARISC_IOCTLS_H__
+
+#ifndef _ASM_PARISC_IOCTL_H
+#define _ASM_PARISC_IOCTL_H
+
+#define _IOC_NRBITS 8
+#define _IOC_TYPEBITS 8
+#define _IOC_SIZEBITS 14
+#define _IOC_DIRBITS 2
+
+#define _IOC_NRMASK ((1 << _IOC_NRBITS)-1)
+#define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1)
+#define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1)
+#define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1)
+
+#define _IOC_NRSHIFT 0
+#define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS)
+#define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS)
+#define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS)
+
+/*
+ * Direction bits.
+ */
+#define _IOC_NONE 0U
+#define _IOC_WRITE 2U
+#define _IOC_READ 1U
+
+#define _IOC(dir,type,nr,size) \
+ (((dir) << _IOC_DIRSHIFT) | \
+ ((type) << _IOC_TYPESHIFT) | \
+ ((nr) << _IOC_NRSHIFT) | \
+ ((size) << _IOC_SIZESHIFT))
+
+/* used to create numbers */
+#define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0)
+#define _IOR(type,nr,size) _IOC(_IOC_READ,(type),(nr),sizeof(size))
+#define _IOW(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),sizeof(size))
+#define _IOWR(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size))
+
+/* used to decode ioctl numbers.. */
+#define _IOC_DIR(nr) (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK)
+#define _IOC_TYPE(nr) (((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK)
+#define _IOC_NR(nr) (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK)
+#define _IOC_SIZE(nr) (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK)
+
+/* ...and for the drivers/sound files... */
+
+#define IOC_IN (_IOC_WRITE << _IOC_DIRSHIFT)
+#define IOC_OUT (_IOC_READ << _IOC_DIRSHIFT)
+#define IOC_INOUT ((_IOC_WRITE|_IOC_READ) << _IOC_DIRSHIFT)
+#define IOCSIZE_MASK (_IOC_SIZEMASK << _IOC_SIZESHIFT)
+#define IOCSIZE_SHIFT (_IOC_SIZESHIFT)
+
+#endif /* _ASM_PARISC_IOCTL_H */
+/* 0x54 is just a magic number to make these relatively unique ('T') */
+
+#define TCGETS _IOR('T', 16, struct termios) /* TCGETATTR */
+#define TCSETS _IOW('T', 17, struct termios) /* TCSETATTR */
+#define TCSETSW _IOW('T', 18, struct termios) /* TCSETATTRD */
+#define TCSETSF _IOW('T', 19, struct termios) /* TCSETATTRF */
+#define TCGETA _IOR('T', 1, struct termio)
+#define TCSETA _IOW('T', 2, struct termio)
+#define TCSETAW _IOW('T', 3, struct termio)
+#define TCSETAF _IOW('T', 4, struct termio)
+#define TCSBRK _IO('T', 5)
+#define TCXONC _IO('T', 6)
+#define TCFLSH _IO('T', 7)
+#define TIOCEXCL 0x540C
+#define TIOCNXCL 0x540D
+#define TIOCSCTTY 0x540E
+#define TIOCGPGRP _IOR('T', 30, int)
+#define TIOCSPGRP _IOW('T', 29, int)
+#define TIOCOUTQ 0x5411
+#define TIOCSTI 0x5412
+#define TIOCGWINSZ 0x5413
+#define TIOCSWINSZ 0x5414
+#define TIOCMGET 0x5415
+#define TIOCMBIS 0x5416
+#define TIOCMBIC 0x5417
+#define TIOCMSET 0x5418
+#define TIOCGSOFTCAR 0x5419
+#define TIOCSSOFTCAR 0x541A
+#define FIONREAD 0x541B
+#define TIOCINQ FIONREAD
+#define TIOCLINUX 0x541C
+#define TIOCCONS 0x541D
+#define TIOCGSERIAL 0x541E
+#define TIOCSSERIAL 0x541F
+#define TIOCPKT 0x5420
+#define FIONBIO 0x5421
+#define TIOCNOTTY 0x5422
+#define TIOCSETD 0x5423
+#define TIOCGETD 0x5424
+#define TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */
+#define TIOCTTYGSTRUCT 0x5426 /* For debugging only */
+#define TIOCSBRK 0x5427 /* BSD compatibility */
+#define TIOCCBRK 0x5428 /* BSD compatibility */
+#define TIOCGSID _IOR('T', 20, int) /* Return the session ID of FD */
+#define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
+#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */
+
+#define FIONCLEX 0x5450 /* these numbers need to be adjusted. */
+#define FIOCLEX 0x5451
+#define FIOASYNC 0x5452
+#define TIOCSERCONFIG 0x5453
+#define TIOCSERGWILD 0x5454
+#define TIOCSERSWILD 0x5455
+#define TIOCGLCKTRMIOS 0x5456
+#define TIOCSLCKTRMIOS 0x5457
+#define TIOCSERGSTRUCT 0x5458 /* For debugging only */
+#define TIOCSERGETLSR 0x5459 /* Get line status register */
+#define TIOCSERGETMULTI 0x545A /* Get multiport config */
+#define TIOCSERSETMULTI 0x545B /* Set multiport config */
+
+#define TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */
+#define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */
+#define TIOCGHAYESESP 0x545E /* Get Hayes ESP configuration */
+#define TIOCSHAYESESP 0x545F /* Set Hayes ESP configuration */
+#define FIOQSIZE 0x5460 /* Get exact space used by quota */
+
+/* Used for packet mode */
+#define TIOCPKT_DATA 0
+#define TIOCPKT_FLUSHREAD 1
+#define TIOCPKT_FLUSHWRITE 2
+#define TIOCPKT_STOP 4
+#define TIOCPKT_START 8
+#define TIOCPKT_NOSTOP 16
+#define TIOCPKT_DOSTOP 32
+
+#define TIOCSER_TEMT 0x01 /* Transmitter physically empty */
+
+#endif /* _ASM_PARISC_IOCTLS_H */
diff --git a/mdk-stage1/dietlibc/include/sys/i386-ioctl.h b/mdk-stage1/dietlibc/include/sys/i386-ioctl.h
new file mode 100644
index 000000000..c9aa270d6
--- /dev/null
+++ b/mdk-stage1/dietlibc/include/sys/i386-ioctl.h
@@ -0,0 +1,141 @@
+
+/*
+ * The following is for compatibility across the various Linux
+ * platforms. The i386 ioctl numbering scheme doesn't really enforce
+ * a type field. De facto, however, the top 8 bits of the lower 16
+ * bits are indeed used as a type field, so we might just as well make
+ * this explicit here. Please be sure to use the decoding macros
+ * below from now on.
+ */
+#define _IOC_NRBITS 8
+#define _IOC_TYPEBITS 8
+#define _IOC_SIZEBITS 14
+#define _IOC_DIRBITS 2
+
+#define _IOC_NRMASK ((1 << _IOC_NRBITS)-1)
+#define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1)
+#define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1)
+#define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1)
+
+#define _IOC_NRSHIFT 0
+#define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS)
+#define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS)
+#define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS)
+
+/*
+ * Direction bits.
+ */
+#define _IOC_NONE 0U
+#define _IOC_WRITE 1U
+#define _IOC_READ 2U
+
+#define _IOC(dir,type,nr,size) \
+ (((dir) << _IOC_DIRSHIFT) | \
+ ((type) << _IOC_TYPESHIFT) | \
+ ((nr) << _IOC_NRSHIFT) | \
+ ((size) << _IOC_SIZESHIFT))
+
+/* used to create numbers */
+#define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0)
+#define _IOR(type,nr,size) _IOC(_IOC_READ,(type),(nr),sizeof(size))
+#define _IOW(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),sizeof(size))
+#define _IOWR(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size))
+
+/* used to decode ioctl numbers.. */
+#define _IOC_DIR(nr) (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK)
+#define _IOC_TYPE(nr) (((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK)
+#define _IOC_NR(nr) (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK)
+#define _IOC_SIZE(nr) (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK)
+
+/* ...and for the drivers/sound files... */
+
+#define IOC_IN (_IOC_WRITE << _IOC_DIRSHIFT)
+#define IOC_OUT (_IOC_READ << _IOC_DIRSHIFT)
+#define IOC_INOUT ((_IOC_WRITE|_IOC_READ) << _IOC_DIRSHIFT)
+#define IOCSIZE_MASK (_IOC_SIZEMASK << _IOC_SIZESHIFT)
+#define IOCSIZE_SHIFT (_IOC_SIZESHIFT)
+
+/* 0x54 is just a magic number to make these relatively unique ('T') */
+
+#define TCGETS 0x5401
+#define TCSETS 0x5402
+#define TCSETSW 0x5403
+#define TCSETSF 0x5404
+#define TCGETA 0x5405
+#define TCSETA 0x5406
+#define TCSETAW 0x5407
+#define TCSETAF 0x5408
+#define TCSBRK 0x5409
+#define TCXONC 0x540A
+#define TCFLSH 0x540B
+#define TIOCEXCL 0x540C
+#define TIOCNXCL 0x540D
+#define TIOCSCTTY 0x540E
+#define TIOCGPGRP 0x540F
+#define TIOCSPGRP 0x5410
+#define TIOCOUTQ 0x5411
+#define TIOCSTI 0x5412
+#define TIOCGWINSZ 0x5413
+#define TIOCSWINSZ 0x5414
+#define TIOCMGET 0x5415
+#define TIOCMBIS 0x5416
+#define TIOCMBIC 0x5417
+#define TIOCMSET 0x5418
+#define TIOCGSOFTCAR 0x5419
+#define TIOCSSOFTCAR 0x541A
+#define FIONREAD 0x541B
+#define TIOCINQ FIONREAD
+#define TIOCLINUX 0x541C
+#define TIOCCONS 0x541D
+#define TIOCGSERIAL 0x541E
+#define TIOCSSERIAL 0x541F
+#define TIOCPKT 0x5420
+#define FIONBIO 0x5421
+#define TIOCNOTTY 0x5422
+#define TIOCSETD 0x5423
+#define TIOCGETD 0x5424
+#define TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */
+#define TIOCTTYGSTRUCT 0x5426 /* For debugging only */
+#define TIOCSBRK 0x5427 /* BSD compatibility */
+#define TIOCCBRK 0x5428 /* BSD compatibility */
+#define TIOCGSID 0x5429 /* Return the session ID of FD */
+#define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
+#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */
+
+#define FIONCLEX 0x5450 /* these numbers need to be adjusted. */
+#define FIOCLEX 0x5451
+#define FIOASYNC 0x5452
+#define TIOCSERCONFIG 0x5453
+#define TIOCSERGWILD 0x5454
+#define TIOCSERSWILD 0x5455
+#define TIOCGLCKTRMIOS 0x5456
+#define TIOCSLCKTRMIOS 0x5457
+#define TIOCSERGSTRUCT 0x5458 /* For debugging only */
+#define TIOCSERGETLSR 0x5459 /* Get line status register */
+#define TIOCSERGETMULTI 0x545A /* Get multiport config */
+#define TIOCSERSETMULTI 0x545B /* Set multiport config */
+
+#define TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */
+#define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */
+#define TIOCGHAYESESP 0x545E /* Get Hayes ESP configuration */
+#define TIOCSHAYESESP 0x545F /* Set Hayes ESP configuration */
+#define FIOQSIZE 0x5460
+
+/* Used for packet mode */
+#define TIOCPKT_DATA 0
+#define TIOCPKT_FLUSHREAD 1
+#define TIOCPKT_FLUSHWRITE 2
+#define TIOCPKT_STOP 4
+#define TIOCPKT_START 8
+#define TIOCPKT_NOSTOP 16
+#define TIOCPKT_DOSTOP 32
+
+#define TIOCSER_TEMT 0x01 /* Transmitter physically empty */
+
+/* Socket-level I/O control calls. */
+#define FIOSETOWN 0x8901
+#define SIOCSPGRP 0x8902
+#define FIOGETOWN 0x8903
+#define SIOCGPGRP 0x8904
+#define SIOCATMARK 0x8905
+#define SIOCGSTAMP 0x8906 /* Get stamp */
diff --git a/mdk-stage1/dietlibc/include/sys/klog.h b/mdk-stage1/dietlibc/include/sys/klog.h
new file mode 100644
index 000000000..abacfef9c
--- /dev/null
+++ b/mdk-stage1/dietlibc/include/sys/klog.h
@@ -0,0 +1,8 @@
+#ifndef _SYS_KLOG_H
+#define _SYS_KLOG_H
+
+#include <sys/cdefs.h>
+
+extern int klogctl (int __type, char *__bufp, int __len) __THROW;
+
+#endif
diff --git a/mdk-stage1/dietlibc/include/sys/mips-ioctl.h b/mdk-stage1/dietlibc/include/sys/mips-ioctl.h
new file mode 100644
index 000000000..889ac83ae
--- /dev/null
+++ b/mdk-stage1/dietlibc/include/sys/mips-ioctl.h
@@ -0,0 +1,177 @@
+#define _IOC_NRBITS 8
+#define _IOC_TYPEBITS 8
+#define _IOC_SIZEBITS 13
+#define _IOC_DIRBITS 3
+
+#define _IOC_NRMASK ((1 << _IOC_NRBITS)-1)
+#define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1)
+#define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1)
+#define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1)
+
+#define _IOC_NRSHIFT 0
+#define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS)
+#define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS)
+#define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS)
+
+/*
+ * We to additionally limit parameters to a maximum 255 bytes.
+ */
+#define _IOC_SLMASK 0xff
+
+/*
+ * Direction bits _IOC_NONE could be 0, but OSF/1 gives it a bit.
+ * And this turns out useful to catch old ioctl numbers in header
+ * files for us.
+ */
+#define _IOC_NONE 1U
+#define _IOC_READ 2U
+#define _IOC_WRITE 4U
+
+/*
+ * The following are included for compatibility
+ */
+#define _IOC_VOID 0x20000000
+#define _IOC_OUT 0x40000000
+#define _IOC_IN 0x80000000
+#define _IOC_INOUT (IOC_IN|IOC_OUT)
+
+#define _IOC(dir,type,nr,size) \
+ (((dir) << _IOC_DIRSHIFT) | \
+ ((type) << _IOC_TYPESHIFT) | \
+ ((nr) << _IOC_NRSHIFT) | \
+ (((size) & _IOC_SLMASK) << _IOC_SIZESHIFT))
+
+/* used to create numbers */
+#define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0)
+#define _IOR(type,nr,size) _IOC(_IOC_READ,(type),(nr),sizeof(size))
+#define _IOW(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),sizeof(size))
+#define _IOWR(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size))
+
+/* used to decode them.. */
+#define _IOC_DIR(nr) (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK)
+#define _IOC_TYPE(nr) (((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK)
+#define _IOC_NR(nr) (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK)
+#define _IOC_SIZE(nr) (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK)
+
+/* ...and for the drivers/sound files... */
+
+#define IOC_IN (_IOC_WRITE << _IOC_DIRSHIFT)
+#define IOC_OUT (_IOC_READ << _IOC_DIRSHIFT)
+#define IOC_INOUT ((_IOC_WRITE|_IOC_READ) << _IOC_DIRSHIFT)
+#define IOCSIZE_MASK (_IOC_SIZEMASK << _IOC_SIZESHIFT)
+#define IOCSIZE_SHIFT (_IOC_SIZESHIFT)
+
+#if defined(__USE_MISC) || defined (__KERNEL__)
+#define tIOC ('t' << 8)
+#endif
+
+#define TCGETA 0x5401
+#define TCSETA 0x5402
+#define TCSETAW 0x5403
+#define TCSETAF 0x5404
+
+#define TCSBRK 0x5405
+#define TCXONC 0x5406
+#define TCFLSH 0x5407
+
+#define TCGETS 0x540d
+#define TCSETS 0x540e
+#define TCSETSW 0x540f
+#define TCSETSF 0x5410
+
+#define TIOCEXCL 0x740d /* set exclusive use of tty */
+#define TIOCNXCL 0x740e /* reset exclusive use of tty */
+#define TIOCOUTQ 0x7472 /* output queue size */
+#define TIOCSTI 0x5472 /* simulate terminal input */
+#define TIOCMGET 0x741d /* get all modem bits */
+#define TIOCMBIS 0x741b /* bis modem bits */
+#define TIOCMBIC 0x741c /* bic modem bits */
+#define TIOCMSET 0x741a /* set all modem bits */
+#define TIOCPKT 0x5470 /* pty: set/clear packet mode */
+#define TIOCPKT_DATA 0x00 /* data packet */
+#define TIOCPKT_FLUSHREAD 0x01 /* flush packet */
+#define TIOCPKT_FLUSHWRITE 0x02 /* flush packet */
+#define TIOCPKT_STOP 0x04 /* stop output */
+#define TIOCPKT_START 0x08 /* start output */
+#define TIOCPKT_NOSTOP 0x10 /* no more ^S, ^Q */
+#define TIOCPKT_DOSTOP 0x20 /* now do ^S ^Q */
+#if 0
+#define TIOCPKT_IOCTL 0x40 /* state change of pty driver */
+#endif
+#define TIOCSWINSZ _IOW('t', 103, struct winsize) /* set window size */
+#define TIOCGWINSZ _IOR('t', 104, struct winsize) /* get window size */
+#define TIOCNOTTY 0x5471 /* void tty association */
+#define TIOCSETD (tIOC | 1)
+#define TIOCGETD (tIOC | 0)
+
+#define FIOCLEX 0x6601
+#define FIONCLEX 0x6602 /* these numbers need to be adjusted. */
+#define FIOASYNC 0x667d
+#define FIONBIO 0x667e
+#define FIOQSIZE 0x667f
+
+#if defined(__USE_MISC) || defined (__KERNEL__)
+#define TIOCGLTC (tIOC | 116) /* get special local chars */
+#define TIOCSLTC (tIOC | 117) /* set special local chars */
+#endif
+#define TIOCSPGRP _IOW('t', 118, int) /* set pgrp of tty */
+#define TIOCGPGRP _IOR('t', 119, int) /* get pgrp of tty */
+#define TIOCCONS _IOW('t', 120, int) /* become virtual console */
+
+#define FIONREAD 0x467f
+#define TIOCINQ FIONREAD
+
+#if defined(__USE_MISC) || defined (__KERNEL__)
+#define TIOCGETP (tIOC | 8)
+#define TIOCSETP (tIOC | 9)
+#define TIOCSETN (tIOC | 10) /* TIOCSETP wo flush */
+#endif
+
+#if 0
+#define TIOCSETA _IOW('t', 20, struct termios) /* set termios struct */
+#define TIOCSETAW _IOW('t', 21, struct termios) /* drain output, set */
+#define TIOCSETAF _IOW('t', 22, struct termios) /* drn out, fls in, set */
+#define TIOCGETD _IOR('t', 26, int) /* get line discipline */
+#define TIOCSETD _IOW('t', 27, int) /* set line discipline */
+ /* 127-124 compat */
+#endif
+
+/* I hope the range from 0x5480 on is free ... */
+#define TIOCSCTTY 0x5480 /* become controlling tty */
+#define TIOCGSOFTCAR 0x5481
+#define TIOCSSOFTCAR 0x5482
+#define TIOCLINUX 0x5483
+#define TIOCGSERIAL 0x5484
+#define TIOCSSERIAL 0x5485
+
+#define TCSBRKP 0x5486 /* Needed for POSIX tcsendbreak() */
+#define TIOCTTYGSTRUCT 0x5487 /* For debugging only */
+#define TIOCSBRK 0x5427 /* BSD compatibility */
+#define TIOCCBRK 0x5428 /* BSD compatibility */
+#define TIOCGSID 0x7416 /* Return the session ID of FD */
+#define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
+#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */
+
+#define TIOCSERCONFIG 0x5488
+#define TIOCSERGWILD 0x5489
+#define TIOCSERSWILD 0x548a
+#define TIOCGLCKTRMIOS 0x548b
+#define TIOCSLCKTRMIOS 0x548c
+#define TIOCSERGSTRUCT 0x548d /* For debugging only */
+#define TIOCSERGETLSR 0x548e /* Get line status register */
+#define TIOCSERGETMULTI 0x548f /* Get multiport config */
+#define TIOCSERSETMULTI 0x5490 /* Set multiport config */
+#define TIOCMIWAIT 0x5491 /* wait for a change on serial input line(s) */
+#define TIOCGICOUNT 0x5492 /* read serial port inline interrupt counts */
+#define TIOCGHAYESESP 0x5493 /* Get Hayes ESP configuration */
+#define TIOCSHAYESESP 0x5494 /* Set Hayes ESP configuration */
+
+/* Socket-level I/O control calls. */
+#define FIOGETOWN _IOR('f', 123, int)
+#define FIOSETOWN _IOW('f', 124, int)
+
+#define SIOCATMARK _IOR('s', 7, int)
+#define SIOCSPGRP _IOW('s', 8, pid_t)
+#define SIOCGPGRP _IOR('s', 9, pid_t)
+
+#define SIOCGSTAMP 0x8906 /* Get stamp - linux-specific */
diff --git a/mdk-stage1/dietlibc/include/sys/ppc-ioctl.h b/mdk-stage1/dietlibc/include/sys/ppc-ioctl.h
new file mode 100644
index 000000000..c3de6d254
--- /dev/null
+++ b/mdk-stage1/dietlibc/include/sys/ppc-ioctl.h
@@ -0,0 +1,164 @@
+
+#define _IOC_NRBITS 8
+#define _IOC_TYPEBITS 8
+#define _IOC_SIZEBITS 13
+#define _IOC_DIRBITS 3
+
+#define _IOC_NRMASK ((1 << _IOC_NRBITS)-1)
+#define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1)
+#define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1)
+#define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1)
+
+#define _IOC_NRSHIFT 0
+#define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS)
+#define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS)
+#define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS)
+
+/*
+ * Direction bits _IOC_NONE could be 0, but OSF/1 gives it a bit.
+ * And this turns out useful to catch old ioctl numbers in header
+ * files for us.
+ */
+#define _IOC_NONE 1U
+#define _IOC_READ 2U
+#define _IOC_WRITE 4U
+
+#define _IOC(dir,type,nr,size) \
+ (((dir) << _IOC_DIRSHIFT) | \
+ ((type) << _IOC_TYPESHIFT) | \
+ ((nr) << _IOC_NRSHIFT) | \
+ ((size) << _IOC_SIZESHIFT))
+
+/* used to create numbers */
+#define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0)
+#define _IOR(type,nr,size) _IOC(_IOC_READ,(type),(nr),sizeof(size))
+#define _IOW(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),sizeof(size))
+#define _IOWR(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size))
+
+/* used to decode them.. */
+#define _IOC_DIR(nr) (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK)
+#define _IOC_TYPE(nr) (((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK)
+#define _IOC_NR(nr) (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK)
+#define _IOC_SIZE(nr) (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK)
+
+/* various drivers, such as the pcmcia stuff, need these... */
+#define IOC_IN (_IOC_WRITE << _IOC_DIRSHIFT)
+#define IOC_OUT (_IOC_READ << _IOC_DIRSHIFT)
+#define IOC_INOUT ((_IOC_WRITE|_IOC_READ) << _IOC_DIRSHIFT)
+#define IOCSIZE_MASK (_IOC_SIZEMASK << _IOC_SIZESHIFT)
+#define IOCSIZE_SHIFT (_IOC_SIZESHIFT)
+
+#define FIOCLEX _IO('f', 1)
+#define FIONCLEX _IO('f', 2)
+#define FIOASYNC _IOW('f', 125, int)
+#define FIONBIO _IOW('f', 126, int)
+#define FIONREAD _IOR('f', 127, int)
+#define TIOCINQ FIONREAD
+#define FIOQSIZE _IOR('f', 128, loff_t)
+
+#define TIOCGETP _IOR('t', 8, struct sgttyb)
+#define TIOCSETP _IOW('t', 9, struct sgttyb)
+#define TIOCSETN _IOW('t', 10, struct sgttyb) /* TIOCSETP wo flush */
+
+#define TIOCSETC _IOW('t', 17, struct tchars)
+#define TIOCGETC _IOR('t', 18, struct tchars)
+#define TCGETS _IOR('t', 19, struct termios)
+#define TCSETS _IOW('t', 20, struct termios)
+#define TCSETSW _IOW('t', 21, struct termios)
+#define TCSETSF _IOW('t', 22, struct termios)
+
+#define TCGETA _IOR('t', 23, struct termio)
+#define TCSETA _IOW('t', 24, struct termio)
+#define TCSETAW _IOW('t', 25, struct termio)
+#define TCSETAF _IOW('t', 28, struct termio)
+
+#define TCSBRK _IO('t', 29)
+#define TCXONC _IO('t', 30)
+#define TCFLSH _IO('t', 31)
+
+#define TIOCSWINSZ _IOW('t', 103, struct winsize)
+#define TIOCGWINSZ _IOR('t', 104, struct winsize)
+#define TIOCSTART _IO('t', 110) /* start output, like ^Q */
+#define TIOCSTOP _IO('t', 111) /* stop output, like ^S */
+#define TIOCOUTQ _IOR('t', 115, int) /* output queue size */
+
+#define TIOCGLTC _IOR('t', 116, struct ltchars)
+#define TIOCSLTC _IOW('t', 117, struct ltchars)
+#define TIOCSPGRP _IOW('t', 118, int)
+#define TIOCGPGRP _IOR('t', 119, int)
+
+#define TIOCEXCL 0x540C
+#define TIOCNXCL 0x540D
+#define TIOCSCTTY 0x540E
+
+#define TIOCSTI 0x5412
+#define TIOCMGET 0x5415
+#define TIOCMBIS 0x5416
+#define TIOCMBIC 0x5417
+#define TIOCMSET 0x5418
+# define TIOCM_LE 0x001
+# define TIOCM_DTR 0x002
+# define TIOCM_RTS 0x004
+# define TIOCM_ST 0x008
+# define TIOCM_SR 0x010
+# define TIOCM_CTS 0x020
+# define TIOCM_CAR 0x040
+# define TIOCM_RNG 0x080
+# define TIOCM_DSR 0x100
+# define TIOCM_CD TIOCM_CAR
+# define TIOCM_RI TIOCM_RNG
+
+#define TIOCGSOFTCAR 0x5419
+#define TIOCSSOFTCAR 0x541A
+#define TIOCLINUX 0x541C
+#define TIOCCONS 0x541D
+#define TIOCGSERIAL 0x541E
+#define TIOCSSERIAL 0x541F
+#define TIOCPKT 0x5420
+# define TIOCPKT_DATA 0
+# define TIOCPKT_FLUSHREAD 1
+# define TIOCPKT_FLUSHWRITE 2
+# define TIOCPKT_STOP 4
+# define TIOCPKT_START 8
+# define TIOCPKT_NOSTOP 16
+# define TIOCPKT_DOSTOP 32
+
+
+#define TIOCNOTTY 0x5422
+#define TIOCSETD 0x5423
+#define TIOCGETD 0x5424
+#define TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */
+#define TIOCTTYGSTRUCT 0x5426 /* For debugging only */
+#define TIOCSBRK 0x5427 /* BSD compatibility */
+#define TIOCCBRK 0x5428 /* BSD compatibility */
+#define TIOCGSID 0x5429 /* Return the session ID of FD */
+#define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
+#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */
+
+#define TIOCSERCONFIG 0x5453
+#define TIOCSERGWILD 0x5454
+#define TIOCSERSWILD 0x5455
+#define TIOCGLCKTRMIOS 0x5456
+#define TIOCSLCKTRMIOS 0x5457
+#define TIOCSERGSTRUCT 0x5458 /* For debugging only */
+#define TIOCSERGETLSR 0x5459 /* Get line status register */
+ /* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */
+# define TIOCSER_TEMT 0x01 /* Transmitter physically empty */
+#define TIOCSERGETMULTI 0x545A /* Get multiport config */
+#define TIOCSERSETMULTI 0x545B /* Set multiport config */
+
+#define TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */
+#define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */
+
+#if 0 /* These are defined this way on Alpha - maybe later. */
+/* Socket-level I/O control calls. */
+
+#define FIOGETOWN _IOR('f', 123, int)
+#define FIOSETOWN _IOW('f', 124, int)
+
+#define SIOCATMARK _IOR('s', 7, int)
+#define SIOCSPGRP _IOW('s', 8, pid_t)
+#define SIOCGPGRP _IOR('s', 9, pid_t)
+
+#define SIOCGSTAMP 0x8906 /* Get stamp - linux-specific */
+#endif
diff --git a/mdk-stage1/dietlibc/include/sys/prctl.h b/mdk-stage1/dietlibc/include/sys/prctl.h
new file mode 100644
index 000000000..26749cbd4
--- /dev/null
+++ b/mdk-stage1/dietlibc/include/sys/prctl.h
@@ -0,0 +1,8 @@
+#ifndef _SYS_PRCTL_H
+#define _SYS_PRCTL_H
+
+#include <sys/cdefs.h>
+
+int prctl(int option, unsigned long arg2, unsigned long arg3 , unsigned long arg4, unsigned long arg5) __THROW;
+
+#endif
diff --git a/mdk-stage1/dietlibc/include/sys/s390-ioctl.h b/mdk-stage1/dietlibc/include/sys/s390-ioctl.h
new file mode 100644
index 000000000..4682a0fda
--- /dev/null
+++ b/mdk-stage1/dietlibc/include/sys/s390-ioctl.h
@@ -0,0 +1,141 @@
+
+/* ioctl command encoding: 32 bits total, command in lower 16 bits,
+ * size of the parameter structure in the lower 14 bits of the
+ * upper 16 bits.
+ * Encoding the size of the parameter structure in the ioctl request
+ * is useful for catching programs compiled with old versions
+ * and to avoid overwriting user space outside the user buffer area.
+ * The highest 2 bits are reserved for indicating the ``access mode''.
+ * NOTE: This limits the max parameter size to 16kB -1 !
+ */
+
+/*
+ * The following is for compatibility across the various Linux
+ * platforms. The i386 ioctl numbering scheme doesn't really enforce
+ * a type field. De facto, however, the top 8 bits of the lower 16
+ * bits are indeed used as a type field, so we might just as well make
+ * this explicit here. Please be sure to use the decoding macros
+ * below from now on.
+ */
+#define _IOC_NRBITS 8
+#define _IOC_TYPEBITS 8
+#define _IOC_SIZEBITS 14
+#define _IOC_DIRBITS 2
+
+#define _IOC_NRMASK ((1 << _IOC_NRBITS)-1)
+#define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1)
+#define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1)
+#define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1)
+
+#define _IOC_NRSHIFT 0
+#define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS)
+#define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS)
+#define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS)
+
+/*
+ * Direction bits.
+ */
+#define _IOC_NONE 0U
+#define _IOC_WRITE 1U
+#define _IOC_READ 2U
+
+#define _IOC(dir,type,nr,size) \
+ (((dir) << _IOC_DIRSHIFT) | \
+ ((type) << _IOC_TYPESHIFT) | \
+ ((nr) << _IOC_NRSHIFT) | \
+ ((size) << _IOC_SIZESHIFT))
+
+/* used to create numbers */
+#define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0)
+#define _IOR(type,nr,size) _IOC(_IOC_READ,(type),(nr),sizeof(size))
+#define _IOW(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),sizeof(size))
+#define _IOWR(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size))
+
+/* used to decode ioctl numbers.. */
+#define _IOC_DIR(nr) (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK)
+#define _IOC_TYPE(nr) (((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK)
+#define _IOC_NR(nr) (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK)
+#define _IOC_SIZE(nr) (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK)
+
+/* ...and for the drivers/sound files... */
+
+#define IOC_IN (_IOC_WRITE << _IOC_DIRSHIFT)
+#define IOC_OUT (_IOC_READ << _IOC_DIRSHIFT)
+#define IOC_INOUT ((_IOC_WRITE|_IOC_READ) << _IOC_DIRSHIFT)
+#define IOCSIZE_MASK (_IOC_SIZEMASK << _IOC_SIZESHIFT)
+#define IOCSIZE_SHIFT (_IOC_SIZESHIFT)
+
+/* 0x54 is just a magic number to make these relatively unique ('T') */
+
+#define TCGETS 0x5401
+#define TCSETS 0x5402
+#define TCSETSW 0x5403
+#define TCSETSF 0x5404
+#define TCGETA 0x5405
+#define TCSETA 0x5406
+#define TCSETAW 0x5407
+#define TCSETAF 0x5408
+#define TCSBRK 0x5409
+#define TCXONC 0x540A
+#define TCFLSH 0x540B
+#define TIOCEXCL 0x540C
+#define TIOCNXCL 0x540D
+#define TIOCSCTTY 0x540E
+#define TIOCGPGRP 0x540F
+#define TIOCSPGRP 0x5410
+#define TIOCOUTQ 0x5411
+#define TIOCSTI 0x5412
+#define TIOCGWINSZ 0x5413
+#define TIOCSWINSZ 0x5414
+#define TIOCMGET 0x5415
+#define TIOCMBIS 0x5416
+#define TIOCMBIC 0x5417
+#define TIOCMSET 0x5418
+#define TIOCGSOFTCAR 0x5419
+#define TIOCSSOFTCAR 0x541A
+#define FIONREAD 0x541B
+#define TIOCINQ FIONREAD
+#define TIOCLINUX 0x541C
+#define TIOCCONS 0x541D
+#define TIOCGSERIAL 0x541E
+#define TIOCSSERIAL 0x541F
+#define TIOCPKT 0x5420
+#define FIONBIO 0x5421
+#define TIOCNOTTY 0x5422
+#define TIOCSETD 0x5423
+#define TIOCGETD 0x5424
+#define TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */
+#define TIOCTTYGSTRUCT 0x5426 /* For debugging only */
+#define TIOCSBRK 0x5427 /* BSD compatibility */
+#define TIOCCBRK 0x5428 /* BSD compatibility */
+#define TIOCGSID 0x5429 /* Return the session ID of FD */
+#define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
+#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */
+
+#define FIONCLEX 0x5450 /* these numbers need to be adjusted. */
+#define FIOCLEX 0x5451
+#define FIOASYNC 0x5452
+#define TIOCSERCONFIG 0x5453
+#define TIOCSERGWILD 0x5454
+#define TIOCSERSWILD 0x5455
+#define TIOCGLCKTRMIOS 0x5456
+#define TIOCSLCKTRMIOS 0x5457
+#define TIOCSERGSTRUCT 0x5458 /* For debugging only */
+#define TIOCSERGETLSR 0x5459 /* Get line status register */
+#define TIOCSERGETMULTI 0x545A /* Get multiport config */
+#define TIOCSERSETMULTI 0x545B /* Set multiport config */
+
+#define TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */
+#define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */
+#define FIOQSIZE 0x545E
+
+/* Used for packet mode */
+#define TIOCPKT_DATA 0
+#define TIOCPKT_FLUSHREAD 1
+#define TIOCPKT_FLUSHWRITE 2
+#define TIOCPKT_STOP 4
+#define TIOCPKT_START 8
+#define TIOCPKT_NOSTOP 16
+#define TIOCPKT_DOSTOP 32
+
+#define TIOCSER_TEMT 0x01 /* Transmitter physically empty */
diff --git a/mdk-stage1/dietlibc/include/sys/soundcard.h b/mdk-stage1/dietlibc/include/sys/soundcard.h
new file mode 100644
index 000000000..e8766499a
--- /dev/null
+++ b/mdk-stage1/dietlibc/include/sys/soundcard.h
@@ -0,0 +1,1300 @@
+#ifndef _SYS_SOUNDCARD_H
+#define _SYS_SOUNDCARD_H
+
+/*
+ * Copyright by Hannu Savolainen 1993-1997
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer. 2.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+
+/*
+ * OSS interface version. With versions earlier than 3.6 this value is
+ * an integer with value less than 361. In versions 3.6 and later
+ * it's a six digit hexadecimal value. For example value
+ * of 0x030600 represents OSS version 3.6.0.
+ * Use ioctl(fd, OSS_GETVERSION, &int) to get the version number of
+ * the currently active driver.
+ */
+#define SOUND_VERSION 0x030802
+#define OPEN_SOUND_SYSTEM
+
+/* In Linux we need to be prepared for cross compiling */
+#include <sys/ioctl.h>
+
+/*
+ * Supported card ID numbers (Should be somewhere else?)
+ */
+
+#define SNDCARD_ADLIB 1
+#define SNDCARD_SB 2
+#define SNDCARD_PAS 3
+#define SNDCARD_GUS 4
+#define SNDCARD_MPU401 5
+#define SNDCARD_SB16 6
+#define SNDCARD_SB16MIDI 7
+#define SNDCARD_UART6850 8
+#define SNDCARD_GUS16 9
+#define SNDCARD_MSS 10
+#define SNDCARD_PSS 11
+#define SNDCARD_SSCAPE 12
+#define SNDCARD_PSS_MPU 13
+#define SNDCARD_PSS_MSS 14
+#define SNDCARD_SSCAPE_MSS 15
+#define SNDCARD_TRXPRO 16
+#define SNDCARD_TRXPRO_SB 17
+#define SNDCARD_TRXPRO_MPU 18
+#define SNDCARD_MAD16 19
+#define SNDCARD_MAD16_MPU 20
+#define SNDCARD_CS4232 21
+#define SNDCARD_CS4232_MPU 22
+#define SNDCARD_MAUI 23
+#define SNDCARD_PSEUDO_MSS 24
+#define SNDCARD_GUSPNP 25
+#define SNDCARD_UART401 26
+/* Sound card numbers 27 to N are reserved. Don't add more numbers here. */
+
+/***********************************
+ * IOCTL Commands for /dev/sequencer
+ */
+
+#ifndef _SIOWR
+#if defined(_IOWR) && (defined(_AIX) || (!defined(sun) && !defined(sparc) && !defined(__sparc__) && !defined(__INCioctlh) && !defined(__Lynx__)))
+/* Use already defined ioctl defines if they exist (except with Sun or Sparc) */
+#define SIOCPARM_MASK IOCPARM_MASK
+#define SIOC_VOID IOC_VOID
+#define SIOC_OUT IOC_OUT
+#define SIOC_IN IOC_IN
+#define SIOC_INOUT IOC_INOUT
+#define _SIOC_SIZE _IOC_SIZE
+#define _SIOC_DIR _IOC_DIR
+#define _SIOC_NONE _IOC_NONE
+#define _SIOC_READ _IOC_READ
+#define _SIOC_WRITE _IOC_WRITE
+#define _SIO _IO
+#define _SIOR _IOR
+#define _SIOW _IOW
+#define _SIOWR _IOWR
+#else
+
+/* Ioctl's have the command encoded in the lower word,
+ * and the size of any in or out parameters in the upper
+ * word. The high 2 bits of the upper word are used
+ * to encode the in/out status of the parameter; for now
+ * we restrict parameters to at most 8191 bytes.
+ */
+/* #define SIOCTYPE (0xff<<8) */
+#define SIOCPARM_MASK 0x1fff /* parameters must be < 8192 bytes */
+#define SIOC_VOID 0x00000000 /* no parameters */
+#define SIOC_OUT 0x20000000 /* copy out parameters */
+#define SIOC_IN 0x40000000 /* copy in parameters */
+#define SIOC_INOUT (SIOC_IN|SIOC_OUT)
+/* the 0x20000000 is so we can distinguish new ioctl's from old */
+#define _SIO(x,y) ((int)(SIOC_VOID|(x<<8)|y))
+#define _SIOR(x,y,t) ((int)(SIOC_OUT|((sizeof(t)&SIOCPARM_MASK)<<16)|(x<<8)|y))
+#define _SIOW(x,y,t) ((int)(SIOC_IN|((sizeof(t)&SIOCPARM_MASK)<<16)|(x<<8)|y))
+/* this should be _SIORW, but stdio got there first */
+#define _SIOWR(x,y,t) ((int)(SIOC_INOUT|((sizeof(t)&SIOCPARM_MASK)<<16)|(x<<8)|y))
+#define _SIOC_SIZE(x) ((x>>16)&SIOCPARM_MASK)
+#define _SIOC_DIR(x) (x & 0xf0000000)
+#define _SIOC_NONE SIOC_VOID
+#define _SIOC_READ SIOC_OUT
+#define _SIOC_WRITE SIOC_IN
+# endif /* _IOWR */
+#endif /* !_SIOWR */
+
+#define SNDCTL_SEQ_RESET _SIO ('Q', 0)
+#define SNDCTL_SEQ_SYNC _SIO ('Q', 1)
+#define SNDCTL_SYNTH_INFO _SIOWR('Q', 2, struct synth_info)
+#define SNDCTL_SEQ_CTRLRATE _SIOWR('Q', 3, int) /* Set/get timer resolution (HZ) */
+#define SNDCTL_SEQ_GETOUTCOUNT _SIOR ('Q', 4, int)
+#define SNDCTL_SEQ_GETINCOUNT _SIOR ('Q', 5, int)
+#define SNDCTL_SEQ_PERCMODE _SIOW ('Q', 6, int)
+#define SNDCTL_FM_LOAD_INSTR _SIOW ('Q', 7, struct sbi_instrument) /* Obsolete. Don't use!!!!!! */
+#define SNDCTL_SEQ_TESTMIDI _SIOW ('Q', 8, int)
+#define SNDCTL_SEQ_RESETSAMPLES _SIOW ('Q', 9, int)
+#define SNDCTL_SEQ_NRSYNTHS _SIOR ('Q',10, int)
+#define SNDCTL_SEQ_NRMIDIS _SIOR ('Q',11, int)
+#define SNDCTL_MIDI_INFO _SIOWR('Q',12, struct midi_info)
+#define SNDCTL_SEQ_THRESHOLD _SIOW ('Q',13, int)
+#define SNDCTL_SYNTH_MEMAVL _SIOWR('Q',14, int) /* in=dev#, out=memsize */
+#define SNDCTL_FM_4OP_ENABLE _SIOW ('Q',15, int) /* in=dev# */
+#define SNDCTL_SEQ_PANIC _SIO ('Q',17)
+#define SNDCTL_SEQ_OUTOFBAND _SIOW ('Q',18, struct seq_event_rec)
+#define SNDCTL_SEQ_GETTIME _SIOR ('Q',19, int)
+#define SNDCTL_SYNTH_ID _SIOWR('Q',20, struct synth_info)
+#define SNDCTL_SYNTH_CONTROL _SIOWR('Q',21, struct synth_control)
+#define SNDCTL_SYNTH_REMOVESAMPLE _SIOWR('Q',22, struct remove_sample)
+
+typedef struct synth_control
+{
+ int devno; /* Synthesizer # */
+ char data[4000]; /* Device spesific command/data record */
+}synth_control;
+
+typedef struct remove_sample
+{
+ int devno; /* Synthesizer # */
+ int bankno; /* MIDI bank # (0=General MIDI) */
+ int instrno; /* MIDI instrument number */
+} remove_sample;
+
+typedef struct seq_event_rec {
+ unsigned char arr[8];
+} seq_event_rec;
+
+#define SNDCTL_TMR_TIMEBASE _SIOWR('T', 1, int)
+#define SNDCTL_TMR_START _SIO ('T', 2)
+#define SNDCTL_TMR_STOP _SIO ('T', 3)
+#define SNDCTL_TMR_CONTINUE _SIO ('T', 4)
+#define SNDCTL_TMR_TEMPO _SIOWR('T', 5, int)
+#define SNDCTL_TMR_SOURCE _SIOWR('T', 6, int)
+# define TMR_INTERNAL 0x00000001
+# define TMR_EXTERNAL 0x00000002
+# define TMR_MODE_MIDI 0x00000010
+# define TMR_MODE_FSK 0x00000020
+# define TMR_MODE_CLS 0x00000040
+# define TMR_MODE_SMPTE 0x00000080
+#define SNDCTL_TMR_METRONOME _SIOW ('T', 7, int)
+#define SNDCTL_TMR_SELECT _SIOW ('T', 8, int)
+
+/*
+ * Some big endian/little endian handling macros
+ */
+
+#if defined(_AIX) || defined(AIX) || defined(sparc) || defined(__sparc__) || defined(HPPA) || defined(PPC)
+/* Big endian machines */
+# define _PATCHKEY(id) (0xfd00|id)
+# define AFMT_S16_NE AFMT_S16_BE
+#else
+# define _PATCHKEY(id) ((id<<8)|0xfd)
+# define AFMT_S16_NE AFMT_S16_LE
+#endif
+
+/*
+ * Sample loading mechanism for internal synthesizers (/dev/sequencer)
+ * The following patch_info structure has been designed to support
+ * Gravis UltraSound. It tries to be universal format for uploading
+ * sample based patches but is probably too limited.
+ *
+ * (PBD) As Hannu guessed, the GUS structure is too limited for
+ * the WaveFront, but this is the right place for a constant definition.
+ */
+
+struct patch_info {
+ unsigned short key; /* Use WAVE_PATCH here */
+#define WAVE_PATCH _PATCHKEY(0x04)
+#define GUS_PATCH WAVE_PATCH
+#define WAVEFRONT_PATCH _PATCHKEY(0x06)
+
+ short device_no; /* Synthesizer number */
+ short instr_no; /* Midi pgm# */
+
+ unsigned int mode;
+/*
+ * The least significant byte has the same format than the GUS .PAT
+ * files
+ */
+#define WAVE_16_BITS 0x01 /* bit 0 = 8 or 16 bit wave data. */
+#define WAVE_UNSIGNED 0x02 /* bit 1 = Signed - Unsigned data. */
+#define WAVE_LOOPING 0x04 /* bit 2 = looping enabled-1. */
+#define WAVE_BIDIR_LOOP 0x08 /* bit 3 = Set is bidirectional looping. */
+#define WAVE_LOOP_BACK 0x10 /* bit 4 = Set is looping backward. */
+#define WAVE_SUSTAIN_ON 0x20 /* bit 5 = Turn sustaining on. (Env. pts. 3)*/
+#define WAVE_ENVELOPES 0x40 /* bit 6 = Enable envelopes - 1 */
+#define WAVE_FAST_RELEASE 0x80 /* bit 7 = Shut off immediately after note off */
+ /* (use the env_rate/env_offs fields). */
+/* Linux specific bits */
+#define WAVE_VIBRATO 0x00010000 /* The vibrato info is valid */
+#define WAVE_TREMOLO 0x00020000 /* The tremolo info is valid */
+#define WAVE_SCALE 0x00040000 /* The scaling info is valid */
+#define WAVE_FRACTIONS 0x00080000 /* Fraction information is valid */
+/* Reserved bits */
+#define WAVE_ROM 0x40000000 /* For future use */
+#define WAVE_MULAW 0x20000000 /* For future use */
+/* Other bits must be zeroed */
+
+ int len; /* Size of the wave data in bytes */
+ int loop_start, loop_end; /* Byte offsets from the beginning */
+
+/*
+ * The base_freq and base_note fields are used when computing the
+ * playback speed for a note. The base_note defines the tone frequency
+ * which is heard if the sample is played using the base_freq as the
+ * playback speed.
+ *
+ * The low_note and high_note fields define the minimum and maximum note
+ * frequencies for which this sample is valid. It is possible to define
+ * more than one samples for an instrument number at the same time. The
+ * low_note and high_note fields are used to select the most suitable one.
+ *
+ * The fields base_note, high_note and low_note should contain
+ * the note frequency multiplied by 1000. For example value for the
+ * middle A is 440*1000.
+ */
+
+ unsigned int base_freq;
+ unsigned int base_note;
+ unsigned int high_note;
+ unsigned int low_note;
+ int panning; /* -128=left, 127=right */
+ int detuning;
+
+/* New fields introduced in version 1.99.5 */
+
+ /* Envelope. Enabled by mode bit WAVE_ENVELOPES */
+ unsigned char env_rate[ 6 ]; /* GUS HW ramping rate */
+ unsigned char env_offset[ 6 ]; /* 255 == 100% */
+
+ /*
+ * The tremolo, vibrato and scale info are not supported yet.
+ * Enable by setting the mode bits WAVE_TREMOLO, WAVE_VIBRATO or
+ * WAVE_SCALE
+ */
+
+ unsigned char tremolo_sweep;
+ unsigned char tremolo_rate;
+ unsigned char tremolo_depth;
+
+ unsigned char vibrato_sweep;
+ unsigned char vibrato_rate;
+ unsigned char vibrato_depth;
+
+ int scale_frequency;
+ unsigned int scale_factor; /* from 0 to 2048 or 0 to 2 */
+
+ int volume;
+ int fractions;
+ int reserved1;
+ int spare[2];
+ char data[1]; /* The waveform data starts here */
+ };
+
+struct sysex_info {
+ short key; /* Use SYSEX_PATCH or MAUI_PATCH here */
+#define SYSEX_PATCH _PATCHKEY(0x05)
+#define MAUI_PATCH _PATCHKEY(0x06)
+ short device_no; /* Synthesizer number */
+ int len; /* Size of the sysex data in bytes */
+ unsigned char data[1]; /* Sysex data starts here */
+ };
+
+/*
+ * /dev/sequencer input events.
+ *
+ * The data written to the /dev/sequencer is a stream of events. Events
+ * are records of 4 or 8 bytes. The first byte defines the size.
+ * Any number of events can be written with a write call. There
+ * is a set of macros for sending these events. Use these macros if you
+ * want to maximize portability of your program.
+ *
+ * Events SEQ_WAIT, SEQ_MIDIPUTC and SEQ_ECHO. Are also input events.
+ * (All input events are currently 4 bytes long. Be prepared to support
+ * 8 byte events also. If you receive any event having first byte >= 128,
+ * it's a 8 byte event.
+ *
+ * The events are documented at the end of this file.
+ *
+ * Normal events (4 bytes)
+ * There is also a 8 byte version of most of the 4 byte events. The
+ * 8 byte one is recommended.
+ */
+#define SEQ_NOTEOFF 0
+#define SEQ_FMNOTEOFF SEQ_NOTEOFF /* Just old name */
+#define SEQ_NOTEON 1
+#define SEQ_FMNOTEON SEQ_NOTEON
+#define SEQ_WAIT TMR_WAIT_ABS
+#define SEQ_PGMCHANGE 3
+#define SEQ_FMPGMCHANGE SEQ_PGMCHANGE
+#define SEQ_SYNCTIMER TMR_START
+#define SEQ_MIDIPUTC 5
+#define SEQ_DRUMON 6 /*** OBSOLETE ***/
+#define SEQ_DRUMOFF 7 /*** OBSOLETE ***/
+#define SEQ_ECHO TMR_ECHO /* For synching programs with output */
+#define SEQ_AFTERTOUCH 9
+#define SEQ_CONTROLLER 10
+
+/*******************************************
+ * Midi controller numbers
+ *******************************************
+ * Controllers 0 to 31 (0x00 to 0x1f) and
+ * 32 to 63 (0x20 to 0x3f) are continuous
+ * controllers.
+ * In the MIDI 1.0 these controllers are sent using
+ * two messages. Controller numbers 0 to 31 are used
+ * to send the MSB and the controller numbers 32 to 63
+ * are for the LSB. Note that just 7 bits are used in MIDI bytes.
+ */
+
+#define CTL_BANK_SELECT 0x00
+#define CTL_MODWHEEL 0x01
+#define CTL_BREATH 0x02
+/* undefined 0x03 */
+#define CTL_FOOT 0x04
+#define CTL_PORTAMENTO_TIME 0x05
+#define CTL_DATA_ENTRY 0x06
+#define CTL_MAIN_VOLUME 0x07
+#define CTL_BALANCE 0x08
+/* undefined 0x09 */
+#define CTL_PAN 0x0a
+#define CTL_EXPRESSION 0x0b
+/* undefined 0x0c */
+/* undefined 0x0d */
+/* undefined 0x0e */
+/* undefined 0x0f */
+#define CTL_GENERAL_PURPOSE1 0x10
+#define CTL_GENERAL_PURPOSE2 0x11
+#define CTL_GENERAL_PURPOSE3 0x12
+#define CTL_GENERAL_PURPOSE4 0x13
+/* undefined 0x14 - 0x1f */
+
+/* undefined 0x20 */
+/* The controller numbers 0x21 to 0x3f are reserved for the */
+/* least significant bytes of the controllers 0x00 to 0x1f. */
+/* These controllers are not recognised by the driver. */
+
+/* Controllers 64 to 69 (0x40 to 0x45) are on/off switches. */
+/* 0=OFF and 127=ON (intermediate values are possible) */
+#define CTL_DAMPER_PEDAL 0x40
+#define CTL_SUSTAIN 0x40 /* Alias */
+#define CTL_HOLD 0x40 /* Alias */
+#define CTL_PORTAMENTO 0x41
+#define CTL_SOSTENUTO 0x42
+#define CTL_SOFT_PEDAL 0x43
+/* undefined 0x44 */
+#define CTL_HOLD2 0x45
+/* undefined 0x46 - 0x4f */
+
+#define CTL_GENERAL_PURPOSE5 0x50
+#define CTL_GENERAL_PURPOSE6 0x51
+#define CTL_GENERAL_PURPOSE7 0x52
+#define CTL_GENERAL_PURPOSE8 0x53
+/* undefined 0x54 - 0x5a */
+#define CTL_EXT_EFF_DEPTH 0x5b
+#define CTL_TREMOLO_DEPTH 0x5c
+#define CTL_CHORUS_DEPTH 0x5d
+#define CTL_DETUNE_DEPTH 0x5e
+#define CTL_CELESTE_DEPTH 0x5e /* Alias for the above one */
+#define CTL_PHASER_DEPTH 0x5f
+#define CTL_DATA_INCREMENT 0x60
+#define CTL_DATA_DECREMENT 0x61
+#define CTL_NONREG_PARM_NUM_LSB 0x62
+#define CTL_NONREG_PARM_NUM_MSB 0x63
+#define CTL_REGIST_PARM_NUM_LSB 0x64
+#define CTL_REGIST_PARM_NUM_MSB 0x65
+/* undefined 0x66 - 0x78 */
+/* reserved 0x79 - 0x7f */
+
+/* Pseudo controllers (not midi compatible) */
+#define CTRL_PITCH_BENDER 255
+#define CTRL_PITCH_BENDER_RANGE 254
+#define CTRL_EXPRESSION 253 /* Obsolete */
+#define CTRL_MAIN_VOLUME 252 /* Obsolete */
+#define SEQ_BALANCE 11
+#define SEQ_VOLMODE 12
+
+/*
+ * Volume mode decides how volumes are used
+ */
+
+#define VOL_METHOD_ADAGIO 1
+#define VOL_METHOD_LINEAR 2
+
+/*
+ * Note! SEQ_WAIT, SEQ_MIDIPUTC and SEQ_ECHO are used also as
+ * input events.
+ */
+
+/*
+ * Event codes 0xf0 to 0xfc are reserved for future extensions.
+ */
+
+#define SEQ_FULLSIZE 0xfd /* Long events */
+/*
+ * SEQ_FULLSIZE events are used for loading patches/samples to the
+ * synthesizer devices. These events are passed directly to the driver
+ * of the associated synthesizer device. There is no limit to the size
+ * of the extended events. These events are not queued but executed
+ * immediately when the write() is called (execution can take several
+ * seconds of time).
+ *
+ * When a SEQ_FULLSIZE message is written to the device, it must
+ * be written using exactly one write() call. Other events cannot
+ * be mixed to the same write.
+ *
+ * For FM synths (YM3812/OPL3) use struct sbi_instrument and write it to the
+ * /dev/sequencer. Don't write other data together with the instrument structure
+ * Set the key field of the structure to FM_PATCH. The device field is used to
+ * route the patch to the corresponding device.
+ *
+ * For wave table use struct patch_info. Initialize the key field
+ * to WAVE_PATCH.
+ */
+#define SEQ_PRIVATE 0xfe /* Low level HW dependent events (8 bytes) */
+#define SEQ_EXTENDED 0xff /* Extended events (8 bytes) OBSOLETE */
+
+/*
+ * Record for FM patches
+ */
+
+typedef unsigned char sbi_instr_data[32];
+
+struct sbi_instrument {
+ unsigned short key; /* FM_PATCH or OPL3_PATCH */
+#define FM_PATCH _PATCHKEY(0x01)
+#define OPL3_PATCH _PATCHKEY(0x03)
+ short device; /* Synth# (0-4) */
+ int channel; /* Program# to be initialized */
+ sbi_instr_data operators; /* Register settings for operator cells (.SBI format) */
+ };
+
+struct synth_info { /* Read only */
+ char name[30];
+ int device; /* 0-N. INITIALIZE BEFORE CALLING */
+ int synth_type;
+#define SYNTH_TYPE_FM 0
+#define SYNTH_TYPE_SAMPLE 1
+#define SYNTH_TYPE_MIDI 2 /* Midi interface */
+
+ int synth_subtype;
+#define FM_TYPE_ADLIB 0x00
+#define FM_TYPE_OPL3 0x01
+#define MIDI_TYPE_MPU401 0x401
+
+#define SAMPLE_TYPE_BASIC 0x10
+#define SAMPLE_TYPE_GUS SAMPLE_TYPE_BASIC
+#define SAMPLE_TYPE_WAVEFRONT 0x11
+
+ int perc_mode; /* No longer supported */
+ int nr_voices;
+ int nr_drums; /* Obsolete field */
+ int instr_bank_size;
+ unsigned int capabilities;
+#define SYNTH_CAP_PERCMODE 0x00000001 /* No longer used */
+#define SYNTH_CAP_OPL3 0x00000002 /* Set if OPL3 supported */
+#define SYNTH_CAP_INPUT 0x00000004 /* Input (MIDI) device */
+ int dummies[19]; /* Reserve space */
+ };
+
+struct sound_timer_info {
+ char name[32];
+ int caps;
+ };
+
+#define MIDI_CAP_MPU401 1 /* MPU-401 intelligent mode */
+
+struct midi_info {
+ char name[30];
+ int device; /* 0-N. INITIALIZE BEFORE CALLING */
+ unsigned int capabilities; /* To be defined later */
+ int dev_type;
+ int dummies[18]; /* Reserve space */
+ };
+
+/********************************************
+ * ioctl commands for the /dev/midi##
+ */
+typedef struct {
+ unsigned char cmd;
+ char nr_args, nr_returns;
+ unsigned char data[30];
+ } mpu_command_rec;
+
+#define SNDCTL_MIDI_PRETIME _SIOWR('m', 0, int)
+#define SNDCTL_MIDI_MPUMODE _SIOWR('m', 1, int)
+#define SNDCTL_MIDI_MPUCMD _SIOWR('m', 2, mpu_command_rec)
+
+/********************************************
+ * IOCTL commands for /dev/dsp and /dev/audio
+ */
+
+#define SNDCTL_DSP_RESET _SIO ('P', 0)
+#define SNDCTL_DSP_SYNC _SIO ('P', 1)
+#define SNDCTL_DSP_SPEED _SIOWR('P', 2, int)
+#define SNDCTL_DSP_STEREO _SIOWR('P', 3, int)
+#define SNDCTL_DSP_GETBLKSIZE _SIOWR('P', 4, int)
+#define SNDCTL_DSP_SAMPLESIZE SNDCTL_DSP_SETFMT
+#define SNDCTL_DSP_CHANNELS _SIOWR('P', 6, int)
+#define SOUND_PCM_WRITE_CHANNELS SNDCTL_DSP_CHANNELS
+#define SOUND_PCM_WRITE_FILTER _SIOWR('P', 7, int)
+#define SNDCTL_DSP_POST _SIO ('P', 8)
+#define SNDCTL_DSP_SUBDIVIDE _SIOWR('P', 9, int)
+#define SNDCTL_DSP_SETFRAGMENT _SIOWR('P',10, int)
+
+/* Audio data formats (Note! U8=8 and S16_LE=16 for compatibility) */
+#define SNDCTL_DSP_GETFMTS _SIOR ('P',11, int) /* Returns a mask */
+#define SNDCTL_DSP_SETFMT _SIOWR('P',5, int) /* Selects ONE fmt*/
+# define AFMT_QUERY 0x00000000 /* Return current fmt */
+# define AFMT_MU_LAW 0x00000001
+# define AFMT_A_LAW 0x00000002
+# define AFMT_IMA_ADPCM 0x00000004
+# define AFMT_U8 0x00000008
+# define AFMT_S16_LE 0x00000010 /* Little endian signed 16*/
+# define AFMT_S16_BE 0x00000020 /* Big endian signed 16 */
+# define AFMT_S8 0x00000040
+# define AFMT_U16_LE 0x00000080 /* Little endian U16 */
+# define AFMT_U16_BE 0x00000100 /* Big endian U16 */
+# define AFMT_MPEG 0x00000200 /* MPEG (2) audio */
+# define AFMT_AC3 0x00000400 /* Dolby Digital AC3 */
+
+/*
+ * Buffer status queries.
+ */
+typedef struct audio_buf_info {
+ int fragments; /* # of available fragments (partially usend ones not counted) */
+ int fragstotal; /* Total # of fragments allocated */
+ int fragsize; /* Size of a fragment in bytes */
+
+ int bytes; /* Available space in bytes (includes partially used fragments) */
+ /* Note! 'bytes' could be more than fragments*fragsize */
+ } audio_buf_info;
+
+#define SNDCTL_DSP_GETOSPACE _SIOR ('P',12, audio_buf_info)
+#define SNDCTL_DSP_GETISPACE _SIOR ('P',13, audio_buf_info)
+#define SNDCTL_DSP_NONBLOCK _SIO ('P',14)
+#define SNDCTL_DSP_GETCAPS _SIOR ('P',15, int)
+# define DSP_CAP_REVISION 0x000000ff /* Bits for revision level (0 to 255) */
+# define DSP_CAP_DUPLEX 0x00000100 /* Full duplex record/playback */
+# define DSP_CAP_REALTIME 0x00000200 /* Real time capability */
+# define DSP_CAP_BATCH 0x00000400 /* Device has some kind of */
+ /* internal buffers which may */
+ /* cause some delays and */
+ /* decrease precision of timing */
+# define DSP_CAP_COPROC 0x00000800 /* Has a coprocessor */
+ /* Sometimes it's a DSP */
+ /* but usually not */
+# define DSP_CAP_TRIGGER 0x00001000 /* Supports SETTRIGGER */
+# define DSP_CAP_MMAP 0x00002000 /* Supports mmap() */
+# define DSP_CAP_MULTI 0x00004000 /* support multiple open */
+# define DSP_CAP_BIND 0x00008000 /* channel binding to front/rear/cneter/lfe */
+
+
+#define SNDCTL_DSP_GETTRIGGER _SIOR ('P',16, int)
+#define SNDCTL_DSP_SETTRIGGER _SIOW ('P',16, int)
+# define PCM_ENABLE_INPUT 0x00000001
+# define PCM_ENABLE_OUTPUT 0x00000002
+
+typedef struct count_info {
+ int bytes; /* Total # of bytes processed */
+ int blocks; /* # of fragment transitions since last time */
+ int ptr; /* Current DMA pointer value */
+ } count_info;
+
+#define SNDCTL_DSP_GETIPTR _SIOR ('P',17, count_info)
+#define SNDCTL_DSP_GETOPTR _SIOR ('P',18, count_info)
+
+typedef struct buffmem_desc {
+ unsigned *buffer;
+ int size;
+ } buffmem_desc;
+#define SNDCTL_DSP_MAPINBUF _SIOR ('P', 19, buffmem_desc)
+#define SNDCTL_DSP_MAPOUTBUF _SIOR ('P', 20, buffmem_desc)
+#define SNDCTL_DSP_SETSYNCRO _SIO ('P', 21)
+#define SNDCTL_DSP_SETDUPLEX _SIO ('P', 22)
+#define SNDCTL_DSP_GETODELAY _SIOR ('P', 23, int)
+
+#define SNDCTL_DSP_GETCHANNELMASK _SIOWR('P', 64, int)
+#define SNDCTL_DSP_BIND_CHANNEL _SIOWR('P', 65, int)
+# define DSP_BIND_QUERY 0x00000000
+# define DSP_BIND_FRONT 0x00000001
+# define DSP_BIND_SURR 0x00000002
+# define DSP_BIND_CENTER_LFE 0x00000004
+# define DSP_BIND_HANDSET 0x00000008
+# define DSP_BIND_MIC 0x00000010
+# define DSP_BIND_MODEM1 0x00000020
+# define DSP_BIND_MODEM2 0x00000040
+# define DSP_BIND_I2S 0x00000080
+# define DSP_BIND_SPDIF 0x00000100
+
+#define SNDCTL_DSP_SETSPDIF _SIOW ('P', 66, int)
+#define SNDCTL_DSP_GETSPDIF _SIOR ('P', 67, int)
+# define SPDIF_PRO 0x0001
+# define SPDIF_N_AUD 0x0002
+# define SPDIF_COPY 0x0004
+# define SPDIF_PRE 0x0008
+# define SPDIF_CC 0x07f0
+# define SPDIF_L 0x0800
+# define SPDIF_DRS 0x4000
+# define SPDIF_V 0x8000
+
+/*
+ * Application's profile defines the way how playback underrun situations should be handled.
+ *
+ * APF_NORMAL (the default) and APF_NETWORK make the driver to cleanup the
+ * playback buffer whenever an underrun occurs. This consumes some time
+ * prevents looping the existing buffer.
+ * APF_CPUINTENS is intended to be set by CPU intensive applications which
+ * are likely to run out of time occasionally. In this mode the buffer cleanup is
+ * disabled which saves CPU time but also let's the previous buffer content to
+ * be played during the "pause" after the underrun.
+ */
+#define SNDCTL_DSP_PROFILE _SIOW ('P', 23, int)
+#define APF_NORMAL 0 /* Normal applications */
+#define APF_NETWORK 1 /* Underruns probably caused by an "external" delay */
+#define APF_CPUINTENS 2 /* Underruns probably caused by "overheating" the CPU */
+
+#define SOUND_PCM_READ_RATE _SIOR ('P', 2, int)
+#define SOUND_PCM_READ_CHANNELS _SIOR ('P', 6, int)
+#define SOUND_PCM_READ_BITS _SIOR ('P', 5, int)
+#define SOUND_PCM_READ_FILTER _SIOR ('P', 7, int)
+
+/* Some alias names */
+#define SOUND_PCM_WRITE_BITS SNDCTL_DSP_SETFMT
+#define SOUND_PCM_WRITE_RATE SNDCTL_DSP_SPEED
+#define SOUND_PCM_POST SNDCTL_DSP_POST
+#define SOUND_PCM_RESET SNDCTL_DSP_RESET
+#define SOUND_PCM_SYNC SNDCTL_DSP_SYNC
+#define SOUND_PCM_SUBDIVIDE SNDCTL_DSP_SUBDIVIDE
+#define SOUND_PCM_SETFRAGMENT SNDCTL_DSP_SETFRAGMENT
+#define SOUND_PCM_GETFMTS SNDCTL_DSP_GETFMTS
+#define SOUND_PCM_SETFMT SNDCTL_DSP_SETFMT
+#define SOUND_PCM_GETOSPACE SNDCTL_DSP_GETOSPACE
+#define SOUND_PCM_GETISPACE SNDCTL_DSP_GETISPACE
+#define SOUND_PCM_NONBLOCK SNDCTL_DSP_NONBLOCK
+#define SOUND_PCM_GETCAPS SNDCTL_DSP_GETCAPS
+#define SOUND_PCM_GETTRIGGER SNDCTL_DSP_GETTRIGGER
+#define SOUND_PCM_SETTRIGGER SNDCTL_DSP_SETTRIGGER
+#define SOUND_PCM_SETSYNCRO SNDCTL_DSP_SETSYNCRO
+#define SOUND_PCM_GETIPTR SNDCTL_DSP_GETIPTR
+#define SOUND_PCM_GETOPTR SNDCTL_DSP_GETOPTR
+#define SOUND_PCM_MAPINBUF SNDCTL_DSP_MAPINBUF
+#define SOUND_PCM_MAPOUTBUF SNDCTL_DSP_MAPOUTBUF
+
+/*
+ * ioctl calls to be used in communication with coprocessors and
+ * DSP chips.
+ */
+
+typedef struct copr_buffer {
+ int command; /* Set to 0 if not used */
+ int flags;
+#define CPF_NONE 0x0000
+#define CPF_FIRST 0x0001 /* First block */
+#define CPF_LAST 0x0002 /* Last block */
+ int len;
+ int offs; /* If required by the device (0 if not used) */
+
+ unsigned char data[4000]; /* NOTE! 4000 is not 4k */
+ } copr_buffer;
+
+typedef struct copr_debug_buf {
+ int command; /* Used internally. Set to 0 */
+ int parm1;
+ int parm2;
+ int flags;
+ int len; /* Length of data in bytes */
+ } copr_debug_buf;
+
+typedef struct copr_msg {
+ int len;
+ unsigned char data[4000];
+ } copr_msg;
+
+#define SNDCTL_COPR_RESET _SIO ('C', 0)
+#define SNDCTL_COPR_LOAD _SIOWR('C', 1, copr_buffer)
+#define SNDCTL_COPR_RDATA _SIOWR('C', 2, copr_debug_buf)
+#define SNDCTL_COPR_RCODE _SIOWR('C', 3, copr_debug_buf)
+#define SNDCTL_COPR_WDATA _SIOW ('C', 4, copr_debug_buf)
+#define SNDCTL_COPR_WCODE _SIOW ('C', 5, copr_debug_buf)
+#define SNDCTL_COPR_RUN _SIOWR('C', 6, copr_debug_buf)
+#define SNDCTL_COPR_HALT _SIOWR('C', 7, copr_debug_buf)
+#define SNDCTL_COPR_SENDMSG _SIOWR('C', 8, copr_msg)
+#define SNDCTL_COPR_RCVMSG _SIOR ('C', 9, copr_msg)
+
+/*********************************************
+ * IOCTL commands for /dev/mixer
+ */
+
+/*
+ * Mixer devices
+ *
+ * There can be up to 20 different analog mixer channels. The
+ * SOUND_MIXER_NRDEVICES gives the currently supported maximum.
+ * The SOUND_MIXER_READ_DEVMASK returns a bitmask which tells
+ * the devices supported by the particular mixer.
+ */
+
+#define SOUND_MIXER_NRDEVICES 25
+#define SOUND_MIXER_VOLUME 0
+#define SOUND_MIXER_BASS 1
+#define SOUND_MIXER_TREBLE 2
+#define SOUND_MIXER_SYNTH 3
+#define SOUND_MIXER_PCM 4
+#define SOUND_MIXER_SPEAKER 5
+#define SOUND_MIXER_LINE 6
+#define SOUND_MIXER_MIC 7
+#define SOUND_MIXER_CD 8
+#define SOUND_MIXER_IMIX 9 /* Recording monitor */
+#define SOUND_MIXER_ALTPCM 10
+#define SOUND_MIXER_RECLEV 11 /* Recording level */
+#define SOUND_MIXER_IGAIN 12 /* Input gain */
+#define SOUND_MIXER_OGAIN 13 /* Output gain */
+/*
+ * The AD1848 codec and compatibles have three line level inputs
+ * (line, aux1 and aux2). Since each card manufacturer have assigned
+ * different meanings to these inputs, it's inpractical to assign
+ * specific meanings (line, cd, synth etc.) to them.
+ */
+#define SOUND_MIXER_LINE1 14 /* Input source 1 (aux1) */
+#define SOUND_MIXER_LINE2 15 /* Input source 2 (aux2) */
+#define SOUND_MIXER_LINE3 16 /* Input source 3 (line) */
+#define SOUND_MIXER_DIGITAL1 17 /* Digital (input) 1 */
+#define SOUND_MIXER_DIGITAL2 18 /* Digital (input) 2 */
+#define SOUND_MIXER_DIGITAL3 19 /* Digital (input) 3 */
+#define SOUND_MIXER_PHONEIN 20 /* Phone input */
+#define SOUND_MIXER_PHONEOUT 21 /* Phone output */
+#define SOUND_MIXER_VIDEO 22 /* Video/TV (audio) in */
+#define SOUND_MIXER_RADIO 23 /* Radio in */
+#define SOUND_MIXER_MONITOR 24 /* Monitor (usually mic) volume */
+
+/* Some on/off settings (SOUND_SPECIAL_MIN - SOUND_SPECIAL_MAX) */
+/* Not counted to SOUND_MIXER_NRDEVICES, but use the same number space */
+#define SOUND_ONOFF_MIN 28
+#define SOUND_ONOFF_MAX 30
+
+/* Note! Number 31 cannot be used since the sign bit is reserved */
+#define SOUND_MIXER_NONE 31
+
+/*
+ * The following unsupported macros are no longer functional.
+ * Use SOUND_MIXER_PRIVATE# macros in future.
+ */
+#define SOUND_MIXER_ENHANCE SOUND_MIXER_NONE
+#define SOUND_MIXER_MUTE SOUND_MIXER_NONE
+#define SOUND_MIXER_LOUD SOUND_MIXER_NONE
+
+
+#define SOUND_DEVICE_LABELS {"Vol ", "Bass ", "Trebl", "Synth", "Pcm ", "Spkr ", "Line ", \
+ "Mic ", "CD ", "Mix ", "Pcm2 ", "Rec ", "IGain", "OGain", \
+ "Line1", "Line2", "Line3", "Digital1", "Digital2", "Digital3", \
+ "PhoneIn", "PhoneOut", "Video", "Radio", "Monitor"}
+
+#define SOUND_DEVICE_NAMES {"vol", "bass", "treble", "synth", "pcm", "speaker", "line", \
+ "mic", "cd", "mix", "pcm2", "rec", "igain", "ogain", \
+ "line1", "line2", "line3", "dig1", "dig2", "dig3", \
+ "phin", "phout", "video", "radio", "monitor"}
+
+/* Device bitmask identifiers */
+
+#define SOUND_MIXER_RECSRC 0xff /* Arg contains a bit for each recording source */
+#define SOUND_MIXER_DEVMASK 0xfe /* Arg contains a bit for each supported device */
+#define SOUND_MIXER_RECMASK 0xfd /* Arg contains a bit for each supported recording source */
+#define SOUND_MIXER_CAPS 0xfc
+# define SOUND_CAP_EXCL_INPUT 0x00000001 /* Only one recording source at a time */
+#define SOUND_MIXER_STEREODEVS 0xfb /* Mixer channels supporting stereo */
+#define SOUND_MIXER_OUTSRC 0xfa /* Arg contains a bit for each input source to output */
+#define SOUND_MIXER_OUTMASK 0xf9 /* Arg contains a bit for each supported input source to output */
+
+/* Device mask bits */
+
+#define SOUND_MASK_VOLUME (1 << SOUND_MIXER_VOLUME)
+#define SOUND_MASK_BASS (1 << SOUND_MIXER_BASS)
+#define SOUND_MASK_TREBLE (1 << SOUND_MIXER_TREBLE)
+#define SOUND_MASK_SYNTH (1 << SOUND_MIXER_SYNTH)
+#define SOUND_MASK_PCM (1 << SOUND_MIXER_PCM)
+#define SOUND_MASK_SPEAKER (1 << SOUND_MIXER_SPEAKER)
+#define SOUND_MASK_LINE (1 << SOUND_MIXER_LINE)
+#define SOUND_MASK_MIC (1 << SOUND_MIXER_MIC)
+#define SOUND_MASK_CD (1 << SOUND_MIXER_CD)
+#define SOUND_MASK_IMIX (1 << SOUND_MIXER_IMIX)
+#define SOUND_MASK_ALTPCM (1 << SOUND_MIXER_ALTPCM)
+#define SOUND_MASK_RECLEV (1 << SOUND_MIXER_RECLEV)
+#define SOUND_MASK_IGAIN (1 << SOUND_MIXER_IGAIN)
+#define SOUND_MASK_OGAIN (1 << SOUND_MIXER_OGAIN)
+#define SOUND_MASK_LINE1 (1 << SOUND_MIXER_LINE1)
+#define SOUND_MASK_LINE2 (1 << SOUND_MIXER_LINE2)
+#define SOUND_MASK_LINE3 (1 << SOUND_MIXER_LINE3)
+#define SOUND_MASK_DIGITAL1 (1 << SOUND_MIXER_DIGITAL1)
+#define SOUND_MASK_DIGITAL2 (1 << SOUND_MIXER_DIGITAL2)
+#define SOUND_MASK_DIGITAL3 (1 << SOUND_MIXER_DIGITAL3)
+#define SOUND_MASK_PHONEIN (1 << SOUND_MIXER_PHONEIN)
+#define SOUND_MASK_PHONEOUT (1 << SOUND_MIXER_PHONEOUT)
+#define SOUND_MASK_RADIO (1 << SOUND_MIXER_RADIO)
+#define SOUND_MASK_VIDEO (1 << SOUND_MIXER_VIDEO)
+#define SOUND_MASK_MONITOR (1 << SOUND_MIXER_MONITOR)
+
+/* Obsolete macros */
+#define SOUND_MASK_MUTE (1 << SOUND_MIXER_MUTE)
+#define SOUND_MASK_ENHANCE (1 << SOUND_MIXER_ENHANCE)
+#define SOUND_MASK_LOUD (1 << SOUND_MIXER_LOUD)
+
+#define MIXER_READ(dev) _SIOR('M', dev, int)
+#define SOUND_MIXER_READ_VOLUME MIXER_READ(SOUND_MIXER_VOLUME)
+#define SOUND_MIXER_READ_BASS MIXER_READ(SOUND_MIXER_BASS)
+#define SOUND_MIXER_READ_TREBLE MIXER_READ(SOUND_MIXER_TREBLE)
+#define SOUND_MIXER_READ_SYNTH MIXER_READ(SOUND_MIXER_SYNTH)
+#define SOUND_MIXER_READ_PCM MIXER_READ(SOUND_MIXER_PCM)
+#define SOUND_MIXER_READ_SPEAKER MIXER_READ(SOUND_MIXER_SPEAKER)
+#define SOUND_MIXER_READ_LINE MIXER_READ(SOUND_MIXER_LINE)
+#define SOUND_MIXER_READ_MIC MIXER_READ(SOUND_MIXER_MIC)
+#define SOUND_MIXER_READ_CD MIXER_READ(SOUND_MIXER_CD)
+#define SOUND_MIXER_READ_IMIX MIXER_READ(SOUND_MIXER_IMIX)
+#define SOUND_MIXER_READ_ALTPCM MIXER_READ(SOUND_MIXER_ALTPCM)
+#define SOUND_MIXER_READ_RECLEV MIXER_READ(SOUND_MIXER_RECLEV)
+#define SOUND_MIXER_READ_IGAIN MIXER_READ(SOUND_MIXER_IGAIN)
+#define SOUND_MIXER_READ_OGAIN MIXER_READ(SOUND_MIXER_OGAIN)
+#define SOUND_MIXER_READ_LINE1 MIXER_READ(SOUND_MIXER_LINE1)
+#define SOUND_MIXER_READ_LINE2 MIXER_READ(SOUND_MIXER_LINE2)
+#define SOUND_MIXER_READ_LINE3 MIXER_READ(SOUND_MIXER_LINE3)
+
+/* Obsolete macros */
+#define SOUND_MIXER_READ_MUTE MIXER_READ(SOUND_MIXER_MUTE)
+#define SOUND_MIXER_READ_ENHANCE MIXER_READ(SOUND_MIXER_ENHANCE)
+#define SOUND_MIXER_READ_LOUD MIXER_READ(SOUND_MIXER_LOUD)
+
+#define SOUND_MIXER_READ_RECSRC MIXER_READ(SOUND_MIXER_RECSRC)
+#define SOUND_MIXER_READ_DEVMASK MIXER_READ(SOUND_MIXER_DEVMASK)
+#define SOUND_MIXER_READ_RECMASK MIXER_READ(SOUND_MIXER_RECMASK)
+#define SOUND_MIXER_READ_STEREODEVS MIXER_READ(SOUND_MIXER_STEREODEVS)
+#define SOUND_MIXER_READ_CAPS MIXER_READ(SOUND_MIXER_CAPS)
+
+#define MIXER_WRITE(dev) _SIOWR('M', dev, int)
+#define SOUND_MIXER_WRITE_VOLUME MIXER_WRITE(SOUND_MIXER_VOLUME)
+#define SOUND_MIXER_WRITE_BASS MIXER_WRITE(SOUND_MIXER_BASS)
+#define SOUND_MIXER_WRITE_TREBLE MIXER_WRITE(SOUND_MIXER_TREBLE)
+#define SOUND_MIXER_WRITE_SYNTH MIXER_WRITE(SOUND_MIXER_SYNTH)
+#define SOUND_MIXER_WRITE_PCM MIXER_WRITE(SOUND_MIXER_PCM)
+#define SOUND_MIXER_WRITE_SPEAKER MIXER_WRITE(SOUND_MIXER_SPEAKER)
+#define SOUND_MIXER_WRITE_LINE MIXER_WRITE(SOUND_MIXER_LINE)
+#define SOUND_MIXER_WRITE_MIC MIXER_WRITE(SOUND_MIXER_MIC)
+#define SOUND_MIXER_WRITE_CD MIXER_WRITE(SOUND_MIXER_CD)
+#define SOUND_MIXER_WRITE_IMIX MIXER_WRITE(SOUND_MIXER_IMIX)
+#define SOUND_MIXER_WRITE_ALTPCM MIXER_WRITE(SOUND_MIXER_ALTPCM)
+#define SOUND_MIXER_WRITE_RECLEV MIXER_WRITE(SOUND_MIXER_RECLEV)
+#define SOUND_MIXER_WRITE_IGAIN MIXER_WRITE(SOUND_MIXER_IGAIN)
+#define SOUND_MIXER_WRITE_OGAIN MIXER_WRITE(SOUND_MIXER_OGAIN)
+#define SOUND_MIXER_WRITE_LINE1 MIXER_WRITE(SOUND_MIXER_LINE1)
+#define SOUND_MIXER_WRITE_LINE2 MIXER_WRITE(SOUND_MIXER_LINE2)
+#define SOUND_MIXER_WRITE_LINE3 MIXER_WRITE(SOUND_MIXER_LINE3)
+
+/* Obsolete macros */
+#define SOUND_MIXER_WRITE_MUTE MIXER_WRITE(SOUND_MIXER_MUTE)
+#define SOUND_MIXER_WRITE_ENHANCE MIXER_WRITE(SOUND_MIXER_ENHANCE)
+#define SOUND_MIXER_WRITE_LOUD MIXER_WRITE(SOUND_MIXER_LOUD)
+
+#define SOUND_MIXER_WRITE_RECSRC MIXER_WRITE(SOUND_MIXER_RECSRC)
+
+typedef struct mixer_info
+{
+ char id[16];
+ char name[32];
+ int modify_counter;
+ int fillers[10];
+} mixer_info;
+
+typedef struct _old_mixer_info /* Obsolete */
+{
+ char id[16];
+ char name[32];
+} _old_mixer_info;
+
+#define SOUND_MIXER_INFO _SIOR ('M', 101, mixer_info)
+#define SOUND_OLD_MIXER_INFO _SIOR ('M', 101, _old_mixer_info)
+
+/*
+ * A mechanism for accessing "proprietary" mixer features. This method
+ * permits passing 128 bytes of arbitrary data between a mixer application
+ * and the mixer driver. Interpretation of the record is defined by
+ * the particular mixer driver.
+ */
+typedef unsigned char mixer_record[128];
+
+#define SOUND_MIXER_ACCESS _SIOWR('M', 102, mixer_record)
+
+/*
+ * Two ioctls for special souncard function
+ */
+#define SOUND_MIXER_AGC _SIOWR('M', 103, int)
+#define SOUND_MIXER_3DSE _SIOWR('M', 104, int)
+
+/*
+ * The SOUND_MIXER_PRIVATE# commands can be redefined by low level drivers.
+ * These features can be used when accessing device specific features.
+ */
+#define SOUND_MIXER_PRIVATE1 _SIOWR('M', 111, int)
+#define SOUND_MIXER_PRIVATE2 _SIOWR('M', 112, int)
+#define SOUND_MIXER_PRIVATE3 _SIOWR('M', 113, int)
+#define SOUND_MIXER_PRIVATE4 _SIOWR('M', 114, int)
+#define SOUND_MIXER_PRIVATE5 _SIOWR('M', 115, int)
+
+/*
+ * SOUND_MIXER_GETLEVELS and SOUND_MIXER_SETLEVELS calls can be used
+ * for querying current mixer settings from the driver and for loading
+ * default volume settings _prior_ activating the mixer (loading
+ * doesn't affect current state of the mixer hardware). These calls
+ * are for internal use only.
+ */
+
+typedef struct mixer_vol_table {
+ int num; /* Index to volume table */
+ char name[32];
+ int levels[32];
+} mixer_vol_table;
+
+#define SOUND_MIXER_GETLEVELS _SIOWR('M', 116, mixer_vol_table)
+#define SOUND_MIXER_SETLEVELS _SIOWR('M', 117, mixer_vol_table)
+
+/*
+ * An ioctl for identifying the driver version. It will return value
+ * of the SOUND_VERSION macro used when compiling the driver.
+ * This call was introduced in OSS version 3.6 and it will not work
+ * with earlier versions (returns EINVAL).
+ */
+#define OSS_GETVERSION _SIOR ('M', 118, int)
+
+/*
+ * Level 2 event types for /dev/sequencer
+ */
+
+/*
+ * The 4 most significant bits of byte 0 specify the class of
+ * the event:
+ *
+ * 0x8X = system level events,
+ * 0x9X = device/port specific events, event[1] = device/port,
+ * The last 4 bits give the subtype:
+ * 0x02 = Channel event (event[3] = chn).
+ * 0x01 = note event (event[4] = note).
+ * (0x01 is not used alone but always with bit 0x02).
+ * event[2] = MIDI message code (0x80=note off etc.)
+ *
+ */
+
+#define EV_SEQ_LOCAL 0x80
+#define EV_TIMING 0x81
+#define EV_CHN_COMMON 0x92
+#define EV_CHN_VOICE 0x93
+#define EV_SYSEX 0x94
+/*
+ * Event types 200 to 220 are reserved for application use.
+ * These numbers will not be used by the driver.
+ */
+
+/*
+ * Events for event type EV_CHN_VOICE
+ */
+
+#define MIDI_NOTEOFF 0x80
+#define MIDI_NOTEON 0x90
+#define MIDI_KEY_PRESSURE 0xA0
+
+/*
+ * Events for event type EV_CHN_COMMON
+ */
+
+#define MIDI_CTL_CHANGE 0xB0
+#define MIDI_PGM_CHANGE 0xC0
+#define MIDI_CHN_PRESSURE 0xD0
+#define MIDI_PITCH_BEND 0xE0
+
+#define MIDI_SYSTEM_PREFIX 0xF0
+
+/*
+ * Timer event types
+ */
+#define TMR_WAIT_REL 1 /* Time relative to the prev time */
+#define TMR_WAIT_ABS 2 /* Absolute time since TMR_START */
+#define TMR_STOP 3
+#define TMR_START 4
+#define TMR_CONTINUE 5
+#define TMR_TEMPO 6
+#define TMR_ECHO 8
+#define TMR_CLOCK 9 /* MIDI clock */
+#define TMR_SPP 10 /* Song position pointer */
+#define TMR_TIMESIG 11 /* Time signature */
+
+/*
+ * Local event types
+ */
+#define LOCL_STARTAUDIO 1
+
+#if (!defined(__KERNEL__) && !defined(KERNEL) && !defined(INKERNEL) && !defined(_KERNEL)) || defined(USE_SEQ_MACROS)
+/*
+ * Some convenience macros to simplify programming of the
+ * /dev/sequencer interface
+ *
+ * These macros define the API which should be used when possible.
+ */
+#define SEQ_DECLAREBUF() SEQ_USE_EXTBUF()
+
+void seqbuf_dump(void); /* This function must be provided by programs */
+
+extern int OSS_init(int seqfd, int buflen);
+extern void OSS_seqbuf_dump(int fd, unsigned char *buf, int buflen);
+extern void OSS_seq_advbuf(int len, int fd, unsigned char *buf, int buflen);
+extern void OSS_seq_needbuf(int len, int fd, unsigned char *buf, int buflen);
+extern void OSS_patch_caching(int dev, int chn, int patch,
+ int fd, unsigned char *buf, int buflen);
+extern void OSS_drum_caching(int dev, int chn, int patch,
+ int fd, unsigned char *buf, int buflen);
+extern void OSS_write_patch(int fd, unsigned char *buf, int len);
+extern int OSS_write_patch2(int fd, unsigned char *buf, int len);
+
+#define SEQ_PM_DEFINES int __foo_bar___
+#ifdef OSSLIB
+# define SEQ_USE_EXTBUF() \
+ extern unsigned char *_seqbuf; \
+ extern int _seqbuflen;extern int _seqbufptr
+# define SEQ_DEFINEBUF(len) SEQ_USE_EXTBUF();static int _requested_seqbuflen=len
+# define _SEQ_ADVBUF(len) OSS_seq_advbuf(len, seqfd, _seqbuf, _seqbuflen)
+# define _SEQ_NEEDBUF(len) OSS_seq_needbuf(len, seqfd, _seqbuf, _seqbuflen)
+# define SEQ_DUMPBUF() OSS_seqbuf_dump(seqfd, _seqbuf, _seqbuflen)
+
+# define SEQ_LOAD_GMINSTR(dev, instr) \
+ OSS_patch_caching(dev, -1, instr, seqfd, _seqbuf, _seqbuflen)
+# define SEQ_LOAD_GMDRUM(dev, drum) \
+ OSS_drum_caching(dev, -1, drum, seqfd, _seqbuf, _seqbuflen)
+#else /* !OSSLIB */
+
+# define SEQ_LOAD_GMINSTR(dev, instr)
+# define SEQ_LOAD_GMDRUM(dev, drum)
+
+# define SEQ_USE_EXTBUF() \
+ extern unsigned char _seqbuf[]; \
+ extern int _seqbuflen;extern int _seqbufptr
+
+#ifndef USE_SIMPLE_MACROS
+/* Sample seqbuf_dump() implementation:
+ *
+ * SEQ_DEFINEBUF (2048); -- Defines a buffer for 2048 bytes
+ *
+ * int seqfd; -- The file descriptor for /dev/sequencer.
+ *
+ * void
+ * seqbuf_dump ()
+ * {
+ * if (_seqbufptr)
+ * if (write (seqfd, _seqbuf, _seqbufptr) == -1)
+ * {
+ * perror ("write /dev/sequencer");
+ * exit (-1);
+ * }
+ * _seqbufptr = 0;
+ * }
+ */
+
+#define SEQ_DEFINEBUF(len) unsigned char _seqbuf[len]; int _seqbuflen = len;int _seqbufptr = 0
+#define _SEQ_NEEDBUF(len) if ((_seqbufptr+(len)) > _seqbuflen) seqbuf_dump()
+#define _SEQ_ADVBUF(len) _seqbufptr += len
+#define SEQ_DUMPBUF seqbuf_dump
+#else
+/*
+ * This variation of the sequencer macros is used just to format one event
+ * using fixed buffer.
+ *
+ * The program using the macro library must define the following macros before
+ * using this library.
+ *
+ * #define _seqbuf name of the buffer (unsigned char[])
+ * #define _SEQ_ADVBUF(len) If the applic needs to know the exact
+ * size of the event, this macro can be used.
+ * Otherwise this must be defined as empty.
+ * #define _seqbufptr Define the name of index variable or 0 if
+ * not required.
+ */
+#define _SEQ_NEEDBUF(len) /* empty */
+#endif
+#endif /* !OSSLIB */
+
+#define SEQ_VOLUME_MODE(dev, mode) {_SEQ_NEEDBUF(8);\
+ _seqbuf[_seqbufptr] = SEQ_EXTENDED;\
+ _seqbuf[_seqbufptr+1] = SEQ_VOLMODE;\
+ _seqbuf[_seqbufptr+2] = (dev);\
+ _seqbuf[_seqbufptr+3] = (mode);\
+ _seqbuf[_seqbufptr+4] = 0;\
+ _seqbuf[_seqbufptr+5] = 0;\
+ _seqbuf[_seqbufptr+6] = 0;\
+ _seqbuf[_seqbufptr+7] = 0;\
+ _SEQ_ADVBUF(8);}
+
+/*
+ * Midi voice messages
+ */
+
+#define _CHN_VOICE(dev, event, chn, note, parm) \
+ {_SEQ_NEEDBUF(8);\
+ _seqbuf[_seqbufptr] = EV_CHN_VOICE;\
+ _seqbuf[_seqbufptr+1] = (dev);\
+ _seqbuf[_seqbufptr+2] = (event);\
+ _seqbuf[_seqbufptr+3] = (chn);\
+ _seqbuf[_seqbufptr+4] = (note);\
+ _seqbuf[_seqbufptr+5] = (parm);\
+ _seqbuf[_seqbufptr+6] = (0);\
+ _seqbuf[_seqbufptr+7] = 0;\
+ _SEQ_ADVBUF(8);}
+
+#define SEQ_START_NOTE(dev, chn, note, vol) \
+ _CHN_VOICE(dev, MIDI_NOTEON, chn, note, vol)
+
+#define SEQ_STOP_NOTE(dev, chn, note, vol) \
+ _CHN_VOICE(dev, MIDI_NOTEOFF, chn, note, vol)
+
+#define SEQ_KEY_PRESSURE(dev, chn, note, pressure) \
+ _CHN_VOICE(dev, MIDI_KEY_PRESSURE, chn, note, pressure)
+
+/*
+ * Midi channel messages
+ */
+
+#define _CHN_COMMON(dev, event, chn, p1, p2, w14) \
+ {_SEQ_NEEDBUF(8);\
+ _seqbuf[_seqbufptr] = EV_CHN_COMMON;\
+ _seqbuf[_seqbufptr+1] = (dev);\
+ _seqbuf[_seqbufptr+2] = (event);\
+ _seqbuf[_seqbufptr+3] = (chn);\
+ _seqbuf[_seqbufptr+4] = (p1);\
+ _seqbuf[_seqbufptr+5] = (p2);\
+ *(short *)&_seqbuf[_seqbufptr+6] = (w14);\
+ _SEQ_ADVBUF(8);}
+/*
+ * SEQ_SYSEX permits sending of sysex messages. (It may look that it permits
+ * sending any MIDI bytes but it's absolutely not possible. Trying to do
+ * so _will_ cause problems with MPU401 intelligent mode).
+ *
+ * Sysex messages are sent in blocks of 1 to 6 bytes. Longer messages must be
+ * sent by calling SEQ_SYSEX() several times (there must be no other events
+ * between them). First sysex fragment must have 0xf0 in the first byte
+ * and the last byte (buf[len-1] of the last fragment must be 0xf7. No byte
+ * between these sysex start and end markers cannot be larger than 0x7f. Also
+ * lengths of each fragments (except the last one) must be 6.
+ *
+ * Breaking the above rules may work with some MIDI ports but is likely to
+ * cause fatal problems with some other devices (such as MPU401).
+ */
+#define SEQ_SYSEX(dev, buf, len) \
+ {int ii, ll=(len); \
+ unsigned char *bufp=buf;\
+ if (ll>6)ll=6;\
+ _SEQ_NEEDBUF(8);\
+ _seqbuf[_seqbufptr] = EV_SYSEX;\
+ _seqbuf[_seqbufptr+1] = (dev);\
+ for(ii=0;ii<ll;ii++)\
+ _seqbuf[_seqbufptr+ii+2] = bufp[ii];\
+ for(ii=ll;ii<6;ii++)\
+ _seqbuf[_seqbufptr+ii+2] = 0xff;\
+ _SEQ_ADVBUF(8);}
+
+#define SEQ_CHN_PRESSURE(dev, chn, pressure) \
+ _CHN_COMMON(dev, MIDI_CHN_PRESSURE, chn, pressure, 0, 0)
+
+#define SEQ_SET_PATCH SEQ_PGM_CHANGE
+#ifdef OSSLIB
+# define SEQ_PGM_CHANGE(dev, chn, patch) \
+ {OSS_patch_caching(dev, chn, patch, seqfd, _seqbuf, _seqbuflen); \
+ _CHN_COMMON(dev, MIDI_PGM_CHANGE, chn, patch, 0, 0);}
+#else
+# define SEQ_PGM_CHANGE(dev, chn, patch) \
+ _CHN_COMMON(dev, MIDI_PGM_CHANGE, chn, patch, 0, 0)
+#endif
+
+#define SEQ_CONTROL(dev, chn, controller, value) \
+ _CHN_COMMON(dev, MIDI_CTL_CHANGE, chn, controller, 0, value)
+
+#define SEQ_BENDER(dev, chn, value) \
+ _CHN_COMMON(dev, MIDI_PITCH_BEND, chn, 0, 0, value)
+
+
+#define SEQ_V2_X_CONTROL(dev, voice, controller, value) {_SEQ_NEEDBUF(8);\
+ _seqbuf[_seqbufptr] = SEQ_EXTENDED;\
+ _seqbuf[_seqbufptr+1] = SEQ_CONTROLLER;\
+ _seqbuf[_seqbufptr+2] = (dev);\
+ _seqbuf[_seqbufptr+3] = (voice);\
+ _seqbuf[_seqbufptr+4] = (controller);\
+ _seqbuf[_seqbufptr+5] = ((value)&0xff);\
+ _seqbuf[_seqbufptr+6] = ((value>>8)&0xff);\
+ _seqbuf[_seqbufptr+7] = 0;\
+ _SEQ_ADVBUF(8);}
+/*
+ * The following 5 macros are incorrectly implemented and obsolete.
+ * Use SEQ_BENDER and SEQ_CONTROL (with proper controller) instead.
+ */
+#define SEQ_PITCHBEND(dev, voice, value) SEQ_V2_X_CONTROL(dev, voice, CTRL_PITCH_BENDER, value)
+#define SEQ_BENDER_RANGE(dev, voice, value) SEQ_V2_X_CONTROL(dev, voice, CTRL_PITCH_BENDER_RANGE, value)
+#define SEQ_EXPRESSION(dev, voice, value) SEQ_CONTROL(dev, voice, CTL_EXPRESSION, value*128)
+#define SEQ_MAIN_VOLUME(dev, voice, value) SEQ_CONTROL(dev, voice, CTL_MAIN_VOLUME, (value*16383)/100)
+#define SEQ_PANNING(dev, voice, pos) SEQ_CONTROL(dev, voice, CTL_PAN, (pos+128) / 2)
+
+/*
+ * Timing and syncronization macros
+ */
+
+#define _TIMER_EVENT(ev, parm) {_SEQ_NEEDBUF(8);\
+ _seqbuf[_seqbufptr+0] = EV_TIMING; \
+ _seqbuf[_seqbufptr+1] = (ev); \
+ _seqbuf[_seqbufptr+2] = 0;\
+ _seqbuf[_seqbufptr+3] = 0;\
+ *(unsigned int *)&_seqbuf[_seqbufptr+4] = (parm); \
+ _SEQ_ADVBUF(8);}
+
+#define SEQ_START_TIMER() _TIMER_EVENT(TMR_START, 0)
+#define SEQ_STOP_TIMER() _TIMER_EVENT(TMR_STOP, 0)
+#define SEQ_CONTINUE_TIMER() _TIMER_EVENT(TMR_CONTINUE, 0)
+#define SEQ_WAIT_TIME(ticks) _TIMER_EVENT(TMR_WAIT_ABS, ticks)
+#define SEQ_DELTA_TIME(ticks) _TIMER_EVENT(TMR_WAIT_REL, ticks)
+#define SEQ_ECHO_BACK(key) _TIMER_EVENT(TMR_ECHO, key)
+#define SEQ_SET_TEMPO(value) _TIMER_EVENT(TMR_TEMPO, value)
+#define SEQ_SONGPOS(pos) _TIMER_EVENT(TMR_SPP, pos)
+#define SEQ_TIME_SIGNATURE(sig) _TIMER_EVENT(TMR_TIMESIG, sig)
+
+/*
+ * Local control events
+ */
+
+#define _LOCAL_EVENT(ev, parm) {_SEQ_NEEDBUF(8);\
+ _seqbuf[_seqbufptr+0] = EV_SEQ_LOCAL; \
+ _seqbuf[_seqbufptr+1] = (ev); \
+ _seqbuf[_seqbufptr+2] = 0;\
+ _seqbuf[_seqbufptr+3] = 0;\
+ *(unsigned int *)&_seqbuf[_seqbufptr+4] = (parm); \
+ _SEQ_ADVBUF(8);}
+
+#define SEQ_PLAYAUDIO(devmask) _LOCAL_EVENT(LOCL_STARTAUDIO, devmask)
+/*
+ * Events for the level 1 interface only
+ */
+
+#define SEQ_MIDIOUT(device, byte) {_SEQ_NEEDBUF(4);\
+ _seqbuf[_seqbufptr] = SEQ_MIDIPUTC;\
+ _seqbuf[_seqbufptr+1] = (byte);\
+ _seqbuf[_seqbufptr+2] = (device);\
+ _seqbuf[_seqbufptr+3] = 0;\
+ _SEQ_ADVBUF(4);}
+
+/*
+ * Patch loading.
+ */
+#ifdef OSSLIB
+# define SEQ_WRPATCH(patchx, len) \
+ OSS_write_patch(seqfd, (char*)(patchx), len)
+# define SEQ_WRPATCH2(patchx, len) \
+ OSS_write_patch2(seqfd, (char*)(patchx), len)
+#else
+# define SEQ_WRPATCH(patchx, len) \
+ {if (_seqbufptr) SEQ_DUMPBUF();\
+ if (write(seqfd, (char*)(patchx), len)==-1) \
+ perror("Write patch: /dev/sequencer");}
+# define SEQ_WRPATCH2(patchx, len) \
+ (SEQ_DUMPBUF(), write(seqfd, (char*)(patchx), len))
+#endif
+
+#endif
+
+#endif
diff --git a/mdk-stage1/dietlibc/include/sys/sparc-ioctl.h b/mdk-stage1/dietlibc/include/sys/sparc-ioctl.h
new file mode 100644
index 000000000..07b502465
--- /dev/null
+++ b/mdk-stage1/dietlibc/include/sys/sparc-ioctl.h
@@ -0,0 +1,172 @@
+#define _IOC_NRBITS 8
+#define _IOC_TYPEBITS 8
+#define _IOC_SIZEBITS 8
+#define _IOC_RESVBITS 5
+#define _IOC_DIRBITS 3
+
+#define _IOC_NRMASK ((1 << _IOC_NRBITS)-1)
+#define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1)
+#define _IOC_RESVMASK ((1 << _IOC_RESVBITS)-1)
+#define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1)
+#define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1)
+
+#define _IOC_NRSHIFT 0
+#define _IOC_TYPESHIFT (_IOC_NRSHIFT + _IOC_NRBITS)
+#define _IOC_SIZESHIFT (_IOC_TYPESHIFT + _IOC_TYPEBITS)
+#define _IOC_RESVSHIFT (_IOC_SIZESHIFT + _IOC_SIZEBITS)
+#define _IOC_DIRSHIFT (_IOC_RESVSHIFT + _IOC_RESVBITS)
+
+#define _IOC_NONE 1U
+#define _IOC_READ 2U
+#define _IOC_WRITE 4U
+
+#define _IOC(dir,type,nr,size) \
+ (((dir) << _IOC_DIRSHIFT) | \
+ ((type) << _IOC_TYPESHIFT) | \
+ ((nr) << _IOC_NRSHIFT) | \
+ ((size) << _IOC_SIZESHIFT))
+
+#define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0)
+#define _IOR(type,nr,size) _IOC(_IOC_READ,(type),(nr),sizeof(size))
+#define _IOW(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),sizeof(size))
+#define _IOWR(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size))
+
+#define _IOC_DIR(nr) (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK)
+#define _IOC_TYPE(nr) (((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK)
+#define _IOC_NR(nr) (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK)
+#define _IOC_SIZE(nr) (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK)
+
+/* ...and for the PCMCIA... */
+
+#define IOC_IN (_IOC_WRITE << _IOC_DIRSHIFT)
+#define IOC_OUT (_IOC_READ << _IOC_DIRSHIFT)
+#define IOC_INOUT ((_IOC_WRITE|_IOC_READ) << _IOC_DIRSHIFT)
+#define IOCSIZE_MASK (_IOC_SIZEMASK << _IOC_SIZESHIFT)
+#define IOCSIZE_SHIFT (_IOC_SIZESHIFT)
+
+/* Big T */
+#define TCGETA _IOR('T', 1, struct termio)
+#define TCSETA _IOW('T', 2, struct termio)
+#define TCSETAW _IOW('T', 3, struct termio)
+#define TCSETAF _IOW('T', 4, struct termio)
+#define TCSBRK _IO('T', 5)
+#define TCXONC _IO('T', 6)
+#define TCFLSH _IO('T', 7)
+#define TCGETS _IOR('T', 8, struct termios)
+#define TCSETS _IOW('T', 9, struct termios)
+#define TCSETSW _IOW('T', 10, struct termios)
+#define TCSETSF _IOW('T', 11, struct termios)
+
+/* Note that all the ioctls that are not available in Linux have a
+ * double underscore on the front to: a) avoid some programs to
+ * thing we support some ioctls under Linux (autoconfiguration stuff)
+ */
+/* Little t */
+#define TIOCGETD _IOR('t', 0, int)
+#define TIOCSETD _IOW('t', 1, int)
+#define __TIOCHPCL _IO('t', 2) /* SunOS Specific */
+#define __TIOCMODG _IOR('t', 3, int) /* SunOS Specific */
+#define __TIOCMODS _IOW('t', 4, int) /* SunOS Specific */
+#define __TIOCGETP _IOR('t', 8, struct sgttyb) /* SunOS Specific */
+#define __TIOCSETP _IOW('t', 9, struct sgttyb) /* SunOS Specific */
+#define __TIOCSETN _IOW('t', 10, struct sgttyb) /* SunOS Specific */
+#define TIOCEXCL _IO('t', 13)
+#define TIOCNXCL _IO('t', 14)
+#define __TIOCFLUSH _IOW('t', 16, int) /* SunOS Specific */
+#define __TIOCSETC _IOW('t', 17, struct tchars) /* SunOS Specific */
+#define __TIOCGETC _IOR('t', 18, struct tchars) /* SunOS Specific */
+#define __TIOCTCNTL _IOW('t', 32, int) /* SunOS Specific */
+#define __TIOCSIGNAL _IOW('t', 33, int) /* SunOS Specific */
+#define __TIOCSETX _IOW('t', 34, int) /* SunOS Specific */
+#define __TIOCGETX _IOR('t', 35, int) /* SunOS Specific */
+#define TIOCCONS _IO('t', 36)
+#define __TIOCSSIZE _IOW('t', 37, struct sunos_ttysize) /* SunOS Specific */
+#define __TIOCGSIZE _IOR('t', 38, struct sunos_ttysize) /* SunOS Specific */
+#define TIOCGSOFTCAR _IOR('t', 100, int)
+#define TIOCSSOFTCAR _IOW('t', 101, int)
+#define __TIOCUCNTL _IOW('t', 102, int) /* SunOS Specific */
+#define TIOCSWINSZ _IOW('t', 103, struct winsize)
+#define TIOCGWINSZ _IOR('t', 104, struct winsize)
+#define __TIOCREMOTE _IOW('t', 105, int) /* SunOS Specific */
+#define TIOCMGET _IOR('t', 106, int)
+#define TIOCMBIC _IOW('t', 107, int)
+#define TIOCMBIS _IOW('t', 108, int)
+#define TIOCMSET _IOW('t', 109, int)
+#define __TIOCSTART _IO('t', 110) /* SunOS Specific */
+#define __TIOCSTOP _IO('t', 111) /* SunOS Specific */
+#define TIOCPKT _IOW('t', 112, int)
+#define TIOCNOTTY _IO('t', 113)
+#define TIOCSTI _IOW('t', 114, char)
+#define TIOCOUTQ _IOR('t', 115, int)
+#define __TIOCGLTC _IOR('t', 116, struct ltchars) /* SunOS Specific */
+#define __TIOCSLTC _IOW('t', 117, struct ltchars) /* SunOS Specific */
+/* 118 is the non-posix setpgrp tty ioctl */
+/* 119 is the non-posix getpgrp tty ioctl */
+#define __TIOCCDTR _IO('t', 120) /* SunOS Specific */
+#define __TIOCSDTR _IO('t', 121) /* SunOS Specific */
+#define TIOCCBRK _IO('t', 122)
+#define TIOCSBRK _IO('t', 123)
+#define __TIOCLGET _IOW('t', 124, int) /* SunOS Specific */
+#define __TIOCLSET _IOW('t', 125, int) /* SunOS Specific */
+#define __TIOCLBIC _IOW('t', 126, int) /* SunOS Specific */
+#define __TIOCLBIS _IOW('t', 127, int) /* SunOS Specific */
+#define __TIOCISPACE _IOR('t', 128, int) /* SunOS Specific */
+#define __TIOCISIZE _IOR('t', 129, int) /* SunOS Specific */
+#define TIOCSPGRP _IOW('t', 130, int)
+#define TIOCGPGRP _IOR('t', 131, int)
+#define TIOCSCTTY _IO('t', 132)
+#define TIOCGSID _IOR('t', 133, int)
+/* Get minor device of a pty master's FD -- Solaris equiv is ISPTM */
+#define TIOCGPTN _IOR('t', 134, unsigned int) /* Get Pty Number */
+#define TIOCSPTLCK _IOW('t', 135, int) /* Lock/unlock PTY */
+
+/* Little f */
+#define FIOCLEX _IO('f', 1)
+#define FIONCLEX _IO('f', 2)
+#define FIOASYNC _IOW('f', 125, int)
+#define FIONBIO _IOW('f', 126, int)
+#define FIONREAD _IOR('f', 127, int)
+#define TIOCINQ FIONREAD
+#define FIOQSIZE _IOR('f', 128, loff_t)
+
+/* SCARY Rutgers local SunOS kernel hackery, perhaps I will support it
+ * someday. This is completely bogus, I know...
+ */
+#define __TCGETSTAT _IO('T', 200) /* Rutgers specific */
+#define __TCSETSTAT _IO('T', 201) /* Rutgers specific */
+
+/* Linux specific, no SunOS equivalent. */
+#define TIOCLINUX 0x541C
+#define TIOCGSERIAL 0x541E
+#define TIOCSSERIAL 0x541F
+#define TCSBRKP 0x5425
+#define TIOCTTYGSTRUCT 0x5426
+#define TIOCSERCONFIG 0x5453
+#define TIOCSERGWILD 0x5454
+#define TIOCSERSWILD 0x5455
+#define TIOCGLCKTRMIOS 0x5456
+#define TIOCSLCKTRMIOS 0x5457
+#define TIOCSERGSTRUCT 0x5458 /* For debugging only */
+#define TIOCSERGETLSR 0x5459 /* Get line status register */
+#define TIOCSERGETMULTI 0x545A /* Get multiport config */
+#define TIOCSERSETMULTI 0x545B /* Set multiport config */
+#define TIOCMIWAIT 0x545C /* Wait input */
+#define TIOCGICOUNT 0x545D /* Read serial port inline interrupt counts */
+
+/* Used for packet mode */
+#define TIOCPKT_DATA 0
+#define TIOCPKT_FLUSHREAD 1
+#define TIOCPKT_FLUSHWRITE 2
+#define TIOCPKT_STOP 4
+#define TIOCPKT_START 8
+#define TIOCPKT_NOSTOP 16
+#define TIOCPKT_DOSTOP 32
+
+/* Socket-level I/O control calls. */
+#define FIOSETOWN 0x8901
+#define SIOCSPGRP 0x8902
+#define FIOGETOWN 0x8903
+#define SIOCGPGRP 0x8904
+#define SIOCATMARK 0x8905
+#define SIOCGSTAMP 0x8906 /* Get stamp */
+
diff --git a/mdk-stage1/dietlibc/include/sys/sysmacros.h b/mdk-stage1/dietlibc/include/sys/sysmacros.h
new file mode 100644
index 000000000..8a8124131
--- /dev/null
+++ b/mdk-stage1/dietlibc/include/sys/sysmacros.h
@@ -0,0 +1,6 @@
+#ifndef _SYSMACROS_H
+#define _SYSMACROS_H
+
+#include <sys/stat.h>
+
+#endif
diff --git a/mdk-stage1/dietlibc/include/sys/timeb.h b/mdk-stage1/dietlibc/include/sys/timeb.h
new file mode 100644
index 000000000..ceed377e7
--- /dev/null
+++ b/mdk-stage1/dietlibc/include/sys/timeb.h
@@ -0,0 +1,13 @@
+#ifndef __SYS_TIMEB_H
+#define __SYS_TIMEB_H 1
+
+struct timeb {
+ time_t time;
+ unsigned short millitm;
+ short timezone;
+ short dstflag;
+};
+
+int ftime(struct timeb *tp);
+
+#endif
diff --git a/mdk-stage1/dietlibc/include/sys/timex.h b/mdk-stage1/dietlibc/include/sys/timex.h
new file mode 100644
index 000000000..cf024e009
--- /dev/null
+++ b/mdk-stage1/dietlibc/include/sys/timex.h
@@ -0,0 +1,50 @@
+#ifndef _SYS_TIMEX_H
+#define _SYS_TIMEX_H
+
+struct timex {
+ unsigned int modes; /* mode selector */
+ long int offset; /* time offset (usec) */
+ long int freq; /* frequency offset (scaled ppm) */
+ long int maxerror; /* maximum error (usec) */
+ long int esterror; /* estimated error (usec) */
+ int status; /* clock command/status */
+ long int constant; /* pll time constant */
+ long int precision; /* clock precision (usec) (read only) */
+ long int tolerance; /* clock frequency tolerance (ppm) (read only) */
+ struct timeval time; /* (read only) */
+ long int tick; /* (modified) usecs between clock ticks */
+
+ long int ppsfreq; /* pps frequency (scaled ppm) (ro) */
+ long int jitter; /* pps jitter (us) (ro) */
+ int shift; /* interval duration (s) (shift) (ro) */
+ long int stabil; /* pps stability (scaled ppm) (ro) */
+ long int jitcnt; /* jitter limit exceeded (ro) */
+ long int calcnt; /* calibration intervals (ro) */
+ long int errcnt; /* calibration errors (ro) */
+ long int stbcnt; /* stability limit exceeded (ro) */
+
+ /* ??? */
+ int :32; int :32; int :32; int :32;
+ int :32; int :32; int :32; int :32;
+ int :32; int :32; int :32; int :32;
+};
+
+#define ADJ_OFFSET 0x0001 /* time offset */
+#define ADJ_FREQUENCY 0x0002 /* frequency offset */
+#define ADJ_MAXERROR 0x0004 /* maximum time error */
+#define ADJ_ESTERROR 0x0008 /* estimated time error */
+#define ADJ_STATUS 0x0010 /* clock status */
+#define ADJ_TIMECONST 0x0020 /* pll time constant */
+#define ADJ_TICK 0x4000 /* tick value */
+#define ADJ_OFFSET_SINGLESHOT 0x8001 /* old-fashioned adjtime */
+
+#define TIME_OK 0 /* clock synchronized */
+#define TIME_INS 1 /* insert leap second */
+#define TIME_DEL 2 /* delete leap second */
+#define TIME_OOP 3 /* leap second in progress */
+#define TIME_WAIT 4 /* leap second has occurred */
+#define TIME_BAD 5 /* clock not synchronized */
+
+int adjtimex(struct timex *buf);
+
+#endif
diff --git a/mdk-stage1/dietlibc/include/sys/ucontext.h b/mdk-stage1/dietlibc/include/sys/ucontext.h
new file mode 100644
index 000000000..573c6c7fb
--- /dev/null
+++ b/mdk-stage1/dietlibc/include/sys/ucontext.h
@@ -0,0 +1,110 @@
+#ifndef _SYS_UCONTEXT_H
+#define _SYS_UCONTEXT_H
+
+#include <asm/sigcontext.h>
+#include <signal.h>
+
+typedef struct sigcontext mcontext_t;
+
+#if defined(__i386__) || defined(__arm__) || defined(__mips__) || defined(__mips64__) || defined(__powerpc__) || defined(__hppa__)
+struct ucontext {
+ unsigned long uc_flags;
+ struct ucontext *uc_link;
+ stack_t uc_stack;
+ struct sigcontext uc_mcontext;
+ sigset_t uc_sigmask; /* mask last for extensibility */
+};
+#elif defined(__alpha__)
+struct ucontext {
+ unsigned long uc_flags;
+ struct ucontext *uc_link;
+ unsigned long uc_osf_sigmask;
+ stack_t uc_stack;
+ struct sigcontext uc_mcontext;
+ sigset_t uc_sigmask; /* mask last for extensibility */
+};
+#elif defined(__sparc__) || defined(__sparc64__)
+
+#define MC_TSTATE 0
+#define MC_PC 1
+#define MC_NPC 2
+#define MC_Y 3
+#define MC_G1 4
+#define MC_G2 5
+#define MC_G3 6
+#define MC_G4 7
+#define MC_G5 8
+#define MC_G6 9
+#define MC_G7 10
+#define MC_O0 11
+#define MC_O1 12
+#define MC_O2 13
+#define MC_O3 14
+#define MC_O4 15
+#define MC_O5 16
+#define MC_O6 17
+#define MC_O7 18
+#define MC_NGREG 19
+
+typedef unsigned long mc_greg_t;
+typedef mc_greg_t mc_gregset_t[MC_NGREG];
+
+#define MC_MAXFPQ 16
+struct mc_fq {
+ unsigned long *mcfq_addr;
+ unsigned int mcfq_insn;
+};
+
+typedef struct mc_fpu {
+ union {
+ unsigned int sregs[32];
+ unsigned long dregs[32];
+ long double qregs[16];
+ } mcfpu_fregs;
+ unsigned long mcfpu_fsr;
+ unsigned long mcfpu_fprs;
+ unsigned long mcfpu_gsr;
+ struct mc_fq *mcfpu_fq;
+ unsigned char mcfpu_qcnt;
+ unsigned char mcfpu_qentsz;
+ unsigned char mcfpu_enab;
+} mc_fpu_t;
+
+typedef struct {
+ mc_gregset_t mc_gregs;
+ mc_greg_t mc_fp;
+ mc_greg_t mc_i7;
+ mc_fpu_t mc_fpregs;
+} mcontext_t;
+
+struct ucontext {
+ struct ucontext *uc_link;
+ unsigned long uc_flags;
+ sigset_t uc_sigmask;
+ mcontext_t uc_mcontext;
+};
+#elif defined(__s390__)
+struct ucontext {
+ unsigned long uc_flags;
+ struct ucontext *uc_link;
+ stack_t uc_stack;
+ _sigregs uc_mcontext;
+ sigset_t uc_sigmask; /* mask last for extensibility */
+};
+#elif defined(__ia64__)
+
+/* oh my god is this ugly! --fefe*/
+struct ucontext {
+ struct sigcontext uc_mcontext;
+};
+
+#define uc_link uc_mcontext.sc_gr[0] /* wrong type; nobody cares */
+#define uc_sigmask uc_mcontext.sc_sigmask
+#define uc_stack uc_mcontext.sc_stack
+#else
+#error NEED TO PORT <sys/sigcontext.h>!
+#endif
+
+typedef struct ucontext ucontext_t;
+
+#endif
diff --git a/mdk-stage1/dietlibc/include/sysexits.h b/mdk-stage1/dietlibc/include/sysexits.h
new file mode 100644
index 000000000..5540795ff
--- /dev/null
+++ b/mdk-stage1/dietlibc/include/sysexits.h
@@ -0,0 +1,26 @@
+#ifndef _SYSEXITS_H
+#define _SYSEXITS_H 1
+
+#define EX_OK 0
+
+#define EX__BASE 64
+
+#define EX_USAGE 64
+#define EX_DATAERR 65
+#define EX_NOINPUT 66
+#define EX_NOUSER 67
+#define EX_NOHOST 68
+#define EX_UNAVAILABLE 69
+#define EX_SOFTWARE 70
+#define EX_OSERR 71
+#define EX_OSFILE 72
+#define EX_CANTCREAT 73
+#define EX_IOERR 74
+#define EX_TEMPFAIL 75
+#define EX_PROTOCOL 76
+#define EX_NOPERM 77
+#define EX_CONFIG 78
+
+#define EX__MAX 78
+
+#endif
diff --git a/mdk-stage1/dietlibc/include/tar.h b/mdk-stage1/dietlibc/include/tar.h
new file mode 100644
index 000000000..a78bbce54
--- /dev/null
+++ b/mdk-stage1/dietlibc/include/tar.h
@@ -0,0 +1,36 @@
+#ifndef _TAR_H_
+#define _TAR_H_
+
+#define TMAGIC "ustar"
+#define TVERSION "00"
+
+#define TMAGLEN 6
+#define TVERSLEN 2
+
+#define REGTYPE '0'
+#define AREGTYPE '\0'
+#define LNKTYPE '1'
+#define SYMTYPE '2'
+#define CHRTYPE '3'
+#define BLKTYPE '4'
+#define DIRTYPE '5'
+#define FIFOTYPE '6'
+#define CONTTYPE '7'
+
+#define TSUID 04000
+#define TSGID 02000
+#define TSVTX 01000
+
+#define TUREAD 00400
+#define TUWRITE 00200
+#define TUEXEC 00100
+
+#define TGREAD 00040
+#define TGWRITE 00020
+#define TGEXEC 00010
+
+#define TOREAD 00004
+#define TOWRITE 00002
+#define TOEXEC 00001
+
+#endif /* _TAR_H_ */
diff --git a/mdk-stage1/dietlibc/include/termio.h b/mdk-stage1/dietlibc/include/termio.h
new file mode 100644
index 000000000..55d1f242b
--- /dev/null
+++ b/mdk-stage1/dietlibc/include/termio.h
@@ -0,0 +1,4 @@
+/* this looks horribly wrong, but glibc does it like that */
+
+#include <termios.h>
+#include <sys/ioctl.h>
diff --git a/mdk-stage1/dietlibc/include/write12.h b/mdk-stage1/dietlibc/include/write12.h
new file mode 100644
index 000000000..960b4b722
--- /dev/null
+++ b/mdk-stage1/dietlibc/include/write12.h
@@ -0,0 +1,4 @@
+#include <sys/cdefs.h>
+
+int __write1 ( const char* s ) __attribute__ (( regparm(1) ));
+int __write2 ( const char* s ) __attribute__ (( regparm(1) ));
diff --git a/mdk-stage1/dietlibc/lib/__ftruncate64.c b/mdk-stage1/dietlibc/lib/__ftruncate64.c
new file mode 100644
index 000000000..e0ea8c98a
--- /dev/null
+++ b/mdk-stage1/dietlibc/lib/__ftruncate64.c
@@ -0,0 +1,23 @@
+#include <errno.h>
+#include "dietfeatures.h"
+#ifdef WANT_LARGEFILE_BACKCOMPAT
+#include <sys/stat.h>
+#include "syscalls.h"
+#include <unistd.h>
+#ifndef __NO_STAT64
+#ifdef __NR_ftruncate64
+
+extern int __dietlibc_ftruncate64(int fd, loff_t o);
+
+int ftruncate64(int fd, loff_t o) {
+ int tmp;
+ if ((tmp=__dietlibc_ftruncate64(fd,o))==-1) {
+ if (errno!=ENOSYS) return -1;
+ if (o>0x7fffffff) { errno=EOVERFLOW; return -1; }
+ return ftruncate(fd,o);
+ }
+ return tmp;
+}
+#endif
+#endif
+#endif
diff --git a/mdk-stage1/dietlibc/lib/__isinf.c b/mdk-stage1/dietlibc/lib/__isinf.c
new file mode 100644
index 000000000..359bd2709
--- /dev/null
+++ b/mdk-stage1/dietlibc/lib/__isinf.c
@@ -0,0 +1,15 @@
+#include <math.h>
+
+int isinf(double d) {
+ unsigned long long *x=(unsigned long long *)&d;
+ return (*x==0x7FF0000000000000ll?1:*x==0xFFF0000000000000?-1:0);
+}
+int __isinf(double d) __attribute__((alias("isinf")));
+
+#if 0
+TestFromIeeeExtended("7FFF0000000000000000"); /* +infinity */
+TestFromIeeeExtended("FFFF0000000000000000"); /* -infinity */
+TestFromIeeeExtended("7FFF8001000000000000"); /* Quiet NaN(1) */
+TestFromIeeeExtended("7FFF0001000000000000"); /* Signalling NaN(1) */
+TestFromIeeeExtended("3FFFFEDCBA9876543210"); /* accuracy test */
+#endif
diff --git a/mdk-stage1/dietlibc/lib/__ptrace.c b/mdk-stage1/dietlibc/lib/__ptrace.c
new file mode 100644
index 000000000..bd14a0351
--- /dev/null
+++ b/mdk-stage1/dietlibc/lib/__ptrace.c
@@ -0,0 +1,27 @@
+/* we need this because we need to use the glibc prototype which uses
+ * varargs :-( */
+#define ptrace fnord
+#include <sys/ptrace.h>
+#undef ptrace
+#include <sys/types.h>
+#include <unistd.h>
+
+extern int __diet_ptrace(int request, pid_t pid, void *addr, void *data);
+int ptrace(int request, pid_t pid, void *addr, void *data);
+
+int ptrace(int request, pid_t pid, void *addr, void *data) {
+ switch (request) {
+ case PTRACE_TRACEME: case PTRACE_KILL: case PTRACE_ATTACH:
+ case PTRACE_DETACH:
+ return (__diet_ptrace (request, pid, NULL, NULL));
+ case PTRACE_PEEKDATA: case PTRACE_PEEKUSER: case PTRACE_PEEKTEXT:
+ {
+ long result;
+ if (__diet_ptrace (request, pid, addr, &result) == -1)
+ return (-1);
+ return (result);
+ }
+ default:
+ return (__diet_ptrace (request, pid, addr, data));
+ }
+}
diff --git a/mdk-stage1/dietlibc/lib/__stime.c b/mdk-stage1/dietlibc/lib/__stime.c
new file mode 100644
index 000000000..7b2c77729
--- /dev/null
+++ b/mdk-stage1/dietlibc/lib/__stime.c
@@ -0,0 +1,14 @@
+#include <errno.h>
+#include <sys/time.h>
+#include <time.h>
+#include <syscalls.h>
+
+#ifndef __NR_stime
+int stime(time_t *when)
+{
+ struct timeval tv;
+ tv.tv_sec = *when;
+ tv.tv_usec = 0;
+ return settimeofday(&tv, (struct timezone *)0);
+}
+#endif
diff --git a/mdk-stage1/dietlibc/lib/__truncate64.c b/mdk-stage1/dietlibc/lib/__truncate64.c
new file mode 100644
index 000000000..ccb3e7f64
--- /dev/null
+++ b/mdk-stage1/dietlibc/lib/__truncate64.c
@@ -0,0 +1,23 @@
+#include "dietfeatures.h"
+#include <errno.h>
+#ifdef WANT_LARGEFILE_BACKCOMPAT
+#include <sys/stat.h>
+#include "syscalls.h"
+#include <unistd.h>
+#ifndef __NO_STAT64
+#ifdef __NR_truncate64
+
+extern int __dietlibc_truncate64(const char* f, loff_t o);
+
+int truncate64(const char* f, loff_t o) {
+ int tmp;
+ if ((tmp=__dietlibc_truncate64(f,o))==-1) {
+ if (errno!=ENOSYS) return -1;
+ if (o>0x7fffffff) { errno=EOVERFLOW; return -1; }
+ return truncate(f,o);
+ }
+ return tmp;
+}
+#endif
+#endif
+#endif
diff --git a/mdk-stage1/dietlibc/lib/__v_printf.c b/mdk-stage1/dietlibc/lib/__v_printf.c
new file mode 100644
index 000000000..15011cdd8
--- /dev/null
+++ b/mdk-stage1/dietlibc/lib/__v_printf.c
@@ -0,0 +1,300 @@
+#include "dietfeatures.h"
+#include <stdarg.h>
+#include <sys/types.h>
+#include <stdlib.h>
+#include <string.h>
+#include "dietstdio.h"
+#include "dietwarning.h"
+
+static inline unsigned int skip_to(const unsigned char *format) {
+ unsigned int nr;
+ for (nr=0; format[nr] && (format[nr]!='%'); ++nr);
+ return nr;
+}
+
+#define A_WRITE(fn,buf,sz) ((fn)->put((void*)(buf),(sz),(fn)->data))
+
+static const char pad_line[2][16]= { " ", "0000000000000000", };
+static inline int write_pad(struct arg_printf* fn, int len, int padwith) {
+ int nr=0;
+ for (;len>15;len-=16,nr+=16) {
+ A_WRITE(fn,pad_line[(padwith=='0')?1:0],16);
+ }
+ if (len>0) {
+ A_WRITE(fn,pad_line[(padwith=='0')?1:0],(unsigned int)len); nr+=len;
+ }
+ return nr;
+}
+
+int __v_printf(struct arg_printf* fn, const unsigned char *format, va_list arg_ptr)
+{
+ int len=0;
+
+ while (*format) {
+ unsigned int sz = skip_to(format);
+ if (sz) {
+ A_WRITE(fn,format,sz); len+=sz;
+ format+=sz;
+ }
+ if (*format=='%') {
+ char buf[128];
+
+ unsigned char ch, *s, padwith=' ';
+
+ char flag_in_sign=0;
+ char flag_upcase=0;
+ char flag_hash=0;
+ char flag_left=0;
+ char flag_space=0;
+ char flag_sign=0;
+ char flag_dot=0;
+ signed char flag_long=0;
+
+ unsigned int base;
+ unsigned int width=0, preci=0;
+
+ long number=0;
+#ifdef WANT_LONGLONG_PRINTF
+ long long llnumber=0;
+#endif
+
+ ++format;
+inn_printf:
+ switch(ch=*format++) {
+ case 0:
+ return -1;
+ break;
+
+ /* FLAGS */
+ case '#':
+ flag_hash=-1;
+ case 'z':
+ goto inn_printf;
+
+ case 'h':
+ --flag_long;
+ goto inn_printf;
+ case 'L':
+ ++flag_long; /* fall through */
+ case 'l':
+ ++flag_long;
+ goto inn_printf;
+
+ case '0':
+ padwith='0';
+ goto inn_printf;
+
+ case '-':
+ flag_left=1;
+ goto inn_printf;
+
+ case ' ':
+ flag_space=1;
+ goto inn_printf;
+
+ case '+':
+ flag_sign=1;
+ goto inn_printf;
+
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ if(flag_dot) return -1;
+ width=strtoul(format-1,(char**)&s,10);
+ format=s;
+ goto inn_printf;
+
+ case '*':
+ width=va_arg(arg_ptr,int);
+ goto inn_printf;
+
+ case '.':
+ flag_dot=1;
+ if (*format=='*') {
+ preci=va_arg(arg_ptr,int);
+ ++format;
+ } else {
+ long int tmp=strtol(format,(char**)&s,10);
+ preci=tmp<0?0:tmp;
+ format=s;
+ }
+ goto inn_printf;
+
+ /* print a char or % */
+ case 'c':
+ ch=(char)va_arg(arg_ptr,int);
+ case '%':
+ A_WRITE(fn,&ch,1); ++len;
+ break;
+
+ /* print a string */
+ case 's':
+ s=va_arg(arg_ptr,char *);
+#ifdef WANT_NULL_PRINTF
+ if (!s) s="(null)";
+#endif
+ sz = strlen(s);
+ if (flag_dot && sz>preci) sz=preci;
+ flag_dot^=flag_dot;
+
+print_out:
+ if (width && (!flag_left)) {
+ if (flag_in_sign) {
+ A_WRITE(fn,s,1); ++len;
+ ++s; --sz;
+ --width;
+ }
+ if (flag_hash>0) {
+ A_WRITE(fn,s,flag_hash); len+=flag_hash;
+ s+=flag_hash; sz-=flag_hash;
+ width-=flag_hash;
+ }
+// len+=write_pad(fn,(signed int)width-(signed int)sz,padwith);
+ if (flag_dot) {
+ len+=write_pad(fn,(signed int)width-(signed int)preci,padwith);
+ len+=write_pad(fn,(signed int)preci-(signed int)sz,'0');
+ } else
+ len+=write_pad(fn,(signed int)width-(signed int)sz,padwith);
+ }
+ A_WRITE(fn,s,sz); len+=sz;
+ if (width && (flag_left)) {
+ len+=write_pad(fn,(signed int)width-(signed int)sz,' ');
+ }
+ break;
+
+ /* print an integer value */
+ case 'b':
+ base=2;
+ sz=0;
+ goto num_printf;
+ case 'p':
+ flag_hash=2;
+ flag_long=1;
+ ch='x';
+ case 'X':
+ flag_upcase=(ch=='X');
+ case 'x':
+ base=16;
+ sz=0;
+ if (flag_dot) width=preci;
+ if (flag_hash) {
+ buf[1]='0';
+ buf[2]=ch;
+ flag_hash=2;
+ sz=2;
+ }
+ goto num_printf;
+ case 'd':
+ case 'i':
+ flag_in_sign=1;
+ case 'u':
+ base=10;
+ sz=0;
+ goto num_printf;
+ case 'o':
+ base=8;
+ sz=0;
+ if (flag_hash) {
+ buf[1]='0';
+ flag_hash=1;
+ ++sz;
+ }
+
+num_printf:
+ s=buf+1;
+
+ if (flag_long>0) {
+#ifdef WANT_LONGLONG_PRINTF
+ if (flag_long>1)
+ llnumber=va_arg(arg_ptr,long long);
+ else
+#endif
+ number=va_arg(arg_ptr,long);
+ }
+ else
+ number=va_arg(arg_ptr,int);
+
+ if (flag_in_sign) {
+#ifdef WANT_LONGLONG_PRINTF
+ if ((flag_long>1)&&(llnumber<0)) {
+ llnumber=-llnumber;
+ flag_in_sign=2;
+ } else
+#endif
+ if (number<0) {
+ number=-number;
+ flag_in_sign=2;
+ }
+ }
+ if (flag_long<0) number&=0xffff;
+ if (flag_long<-1) number&=0xff;
+#ifdef WANT_LONGLONG_PRINTF
+ if (flag_long>1)
+ sz += __lltostr(s+sz,sizeof(buf)-5,(unsigned long long) llnumber,base,flag_upcase);
+ else
+#endif
+ sz += __ltostr(s+sz,sizeof(buf)-5,(unsigned long) number,base,flag_upcase);
+
+ if (flag_in_sign==2) {
+ *(--s)='-';
+ ++sz;
+ } else if ((flag_in_sign)&&(flag_sign || flag_space)) {
+ *(--s)=(flag_sign)?'+':' ';
+ ++sz;
+ } else flag_in_sign=0;
+
+ goto print_out;
+
+#ifdef WANT_FLOATING_POINT_IN_PRINTF
+ /* print a floating point value */
+ case 'f':
+ case 'g':
+ {
+ int g=(ch=='g');
+ double d=va_arg(arg_ptr,double);
+ if (width==0) width=1;
+ if (!flag_dot) preci=6;
+ sz=__dtostr(d,buf,sizeof(buf),width,preci);
+ if (flag_dot) {
+ char *tmp;
+ if ((tmp=strchr(buf,'.'))) {
+ ++tmp;
+ while (preci>0 && *++tmp) --preci;
+ *tmp=0;
+ }
+ }
+ if (g) {
+ char *tmp,*tmp1; /* boy, is _this_ ugly! */
+ if ((tmp=strchr(buf,'.'))) {
+ tmp1=strchr(tmp,'e');
+ while (*tmp) ++tmp;
+ if (tmp1) tmp=tmp1;
+ while (*--tmp=='0') ;
+ if (*tmp!='.') ++tmp;
+ *tmp=0;
+ if (tmp1) strcpy(tmp,tmp1);
+ }
+ }
+ preci=strlen(buf);
+ s=buf;
+
+ goto print_out;
+ }
+#endif
+
+ default:
+ break;
+ }
+ }
+ }
+ return len;
+}
+
+link_warning("__v_printf","warning: the printf functions add several kilobytes of bloat.")
+
diff --git a/mdk-stage1/dietlibc/lib/__v_scanf.c b/mdk-stage1/dietlibc/lib/__v_scanf.c
new file mode 100644
index 000000000..6db51db59
--- /dev/null
+++ b/mdk-stage1/dietlibc/lib/__v_scanf.c
@@ -0,0 +1,391 @@
+#include "dietfeatures.h"
+#include <stdarg.h>
+#include <sys/types.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
+#include <limits.h>
+
+#include "dietstdio.h"
+#include "dietwarning.h"
+
+#define A_GETC(fn) (++consumed,(fn)->getch((fn)->data))
+#define A_PUTC(c,fn) (--consumed,(fn)->putch((c),(fn)->data))
+
+int __v_scanf(struct arg_scanf* fn, const unsigned char *format, va_list arg_ptr)
+{
+ unsigned int ch; /* format act. char */
+ int n=0;
+
+ /* arg_ptr tmps */
+#ifdef WANT_FLOATING_POINT_IN_SCANF
+ double *pd;
+ float *pf;
+#endif
+#ifdef WANT_LONGLONG_SCANF
+ long long *pll;
+#endif
+ long *pl;
+ short *ph;
+ int *pi;
+ char *s;
+
+ unsigned int consumed=0;
+
+ /* get one char */
+ int tpch= A_GETC(fn);
+
+ //while ((tpch!=-1)&&(*format))
+ while (*format)
+ {
+// const unsigned char *prev_fmt=format;
+ ch=*format++;
+ switch (ch) {
+ /* end of format string ?!? */
+ case 0: return 0;
+
+ /* skip spaces ... */
+ case ' ':
+ case '\f':
+ case '\t':
+ case '\v':
+ case '\n':
+ case '\r':
+ while((*format)&&(isspace(*format))) ++format;
+ while(isspace(tpch)) tpch=A_GETC(fn);
+ break;
+
+ /* format string ... */
+ case '%':
+ {
+ unsigned int _div=0;
+ int width=-1;
+ char flag_width=0;
+ char flag_discard=0;
+ char flag_half=0;
+ char flag_long=0;
+ char flag_longlong=0;
+
+in_scan:
+ ch=*format++;
+ if(ch!='n' && tpch==-1) goto err_out;
+ switch (ch) {
+ /* end of format string ?!? */
+ case 0: return 0;
+
+ /* check for % */
+ case '%':
+ if ((unsigned char)tpch != ch) goto err_out;
+ tpch=A_GETC(fn);
+ break;
+
+ /* FLAGS */
+ case '*':
+ flag_discard=1;
+ goto in_scan;
+ case 'h':
+ flag_half=1;
+ goto in_scan;
+ case 'l':
+ if (flag_long) flag_longlong=1;
+ flag_long=1;
+ goto in_scan;
+ case 'q':
+ case 'L':
+ flag_longlong=1;
+ goto in_scan;
+
+ /* WIDTH */
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ width=strtol(format-1,&s,10);
+ format=s;
+ flag_width=1;
+ goto in_scan;
+
+ /* scan for integer / strtol reimplementation ... */
+ case 'p':
+ case 'X':
+ case 'x':
+ _div+=6;
+ case 'd':
+ _div+=2;
+ case 'o':
+ _div+=8;
+ case 'u':
+ case 'i':
+ {
+#ifdef WANT_LONGLONG_SCANF
+ unsigned long long v=0;
+#else
+ unsigned long v=0;
+#endif
+ unsigned int consumedsofar=consumed;
+ int neg=0;
+ while(isspace(tpch)) tpch=A_GETC(fn);
+ if (tpch=='-') {
+ tpch=A_GETC(fn);
+ neg=1;
+ }
+
+ if (tpch=='+') tpch=A_GETC(fn);
+
+ if (!flag_width) {
+ if ((_div==16) && (tpch=='0')) goto scan_hex;
+ if (!_div) {
+ _div=10;
+ if (tpch=='0') {
+ _div=8;
+scan_hex:
+ tpch=A_GETC(fn);
+ if ((tpch|32)=='x') {
+ tpch=A_GETC(fn);
+ _div=16;
+ }
+ }
+ }
+ }
+ while ((width)&&(tpch!=-1)) {
+ register unsigned long c=tpch&0xff;
+#ifdef WANT_LONGLONG_SCANF
+ register unsigned long long d=c|0x20;
+#else
+ register unsigned long d=c|0x20;
+#endif
+ c=(d>='a'?d-'a'+10:c<='9'?c-'0':0xff);
+ if (c>=_div) break;
+ d=v*_div;
+#ifdef WANT_LONGLONG_SCANF
+ v=(d<v)?ULLONG_MAX:d+c;
+#else
+ v=(d<v)?ULONG_MAX:d+c;
+#endif
+ --width;
+ tpch=A_GETC(fn);
+ }
+ if ((ch|0x20)<'p') {
+#ifdef WANT_LONGLONG_SCANF
+ register long long l=v;
+ if (v>=-((unsigned long long)LLONG_MIN)) {
+ l=(neg)?LLONG_MIN:LLONG_MAX;
+ }
+ else {
+ if (neg) v*=-1;
+ }
+#else
+ register long l=v;
+ if (v>=-((unsigned long)LONG_MIN)) {
+ l=(neg)?LONG_MIN:LONG_MAX;
+ }
+ else {
+ if (neg) v*=-1;
+ }
+#endif
+ }
+ if (!flag_discard) {
+#ifdef WANT_LONGLONG_SCANF
+ if (flag_longlong) {
+ pll=(long long *)va_arg(arg_ptr,long long*);
+ *pll=v;
+ } else
+#endif
+ if (flag_long) {
+ pl=(long *)va_arg(arg_ptr,long*);
+ *pl=v;
+ } else if (flag_half) {
+ ph=(short*)va_arg(arg_ptr,short*);
+ *ph=v;
+ } else {
+ pi=(int *)va_arg(arg_ptr,int*);
+ *pi=v;
+ }
+ if(consumedsofar<consumed)
+ ++n;
+ }
+ }
+ break;
+
+#ifdef WANT_FLOATING_POINT_IN_SCANF
+ /* floating point numbers */
+ case 'e':
+ case 'E':
+ case 'f':
+ case 'g':
+ {
+ double d=0.0;
+ int neg=0;
+
+ while(isspace(tpch)) tpch=A_GETC(fn);
+
+ if (tpch=='-') {
+ tpch=A_GETC(fn);
+ neg=1;
+ }
+ if (tpch=='+') tpch=A_GETC(fn);
+
+ while (isdigit(tpch)) {
+ d=d*10+(tpch-'0');
+ tpch=A_GETC(fn);
+ }
+ if (tpch=='.') {
+ double factor=.1;
+ tpch=A_GETC(fn);
+ while (isdigit(tpch)) {
+ d=d+(factor*(tpch-'0'));
+ factor/=10;
+ tpch=A_GETC(fn);
+ }
+ }
+ if ((tpch|0x20)=='e') {
+ int exp=0, prec=tpch;
+ double factor=10;
+ tpch=A_GETC(fn);
+ if (tpch=='-') {
+ factor=0.1;
+ tpch=A_GETC(fn);
+ } else if (tpch=='+') {
+ tpch=A_GETC(fn);
+ } else {
+ d=0;
+ if (tpch!=-1) A_PUTC(tpch,fn);
+ tpch=prec;
+ goto exp_out;
+ }
+ while (isdigit(tpch)) {
+ exp=exp*10+(tpch-'0');
+ tpch=A_GETC(fn);
+ }
+ while (exp) { /* as in strtod: XXX: this introduces rounding errors */
+ d*=factor; --exp;
+ }
+ }
+exp_out:
+ if (!flag_discard) {
+ if (flag_long) {
+ pd=(double *)va_arg(arg_ptr,double*);
+ *pd=d;
+ } else {
+ pf=(float *)va_arg(arg_ptr,float*);
+ *pf=d;
+ }
+ }
+ ++n;
+ }
+ break;
+#endif
+
+ /* char-sequences */
+ case 'c':
+ if (!flag_discard) {
+ s=(char *)va_arg(arg_ptr,char*);
+ ++n;
+ }
+ if (!flag_width) width=1;
+ while (width && (tpch!=-1)) {
+ if (!flag_discard) *(s++)=tpch;
+ --width;
+ tpch=A_GETC(fn);
+ }
+ break;
+
+ /* c-string */
+ case 's':
+ if (!flag_discard) s=(char *)va_arg(arg_ptr,char*);
+ while(isspace(tpch)) tpch=A_GETC(fn);
+ while (width && (tpch!=-1) && (!isspace(tpch))) {
+ if (!flag_discard) *s=tpch;
+ if (tpch) ++s; else break;
+ --width;
+ tpch=A_GETC(fn);
+ }
+ if (!flag_discard) { *s=0; n++; }
+ break;
+
+ /* consumed-count */
+ case 'n':
+ if (!flag_discard) {
+ s=(char *)va_arg(arg_ptr,char*);
+// ++n; /* in accordance to ANSI C we don't count this conversion */
+ }
+ if (!flag_discard) *(s++)=consumed-1;
+ break;
+
+#ifdef WANT_CHARACTER_CLASSES_IN_SCANF
+ case '[':
+ {
+ char cset[256];
+ int flag_not=0;
+ int flag_dash=0;
+ memset(cset,0,sizeof(cset));
+ ch=*format++;
+ /* first char specials */
+ if (ch=='^') {
+ flag_not=1;
+ ch=*format++;
+ }
+ if ((ch=='-')||(ch==']')) {
+ cset[ch]=1;
+ ch=*format++;
+ }
+ /* almost all non special chars */
+ for (;(*format) && (*format!=']');++format) {
+ if (flag_dash) {
+ register unsigned char tmp=*format;
+ for (;ch<=tmp;++ch) cset[ch]=1;
+ flag_dash=0;
+ ch=*format;
+ }
+ else if (*format=='-') flag_dash=1;
+ else {
+ cset[ch]=1;
+ ch=*format;
+ }
+ }
+ /* last char specials */
+ if (flag_dash) cset['-']=1;
+ else cset[ch]=1;
+
+ /* like %c or %s */
+ if (!flag_discard) {
+ s=(char *)va_arg(arg_ptr,char*);
+ ++n;
+ }
+ while (width && (tpch>=0) && (cset[tpch]^flag_not)) {
+ if (!flag_discard) *s=tpch;
+ if (tpch) ++s; else break;
+ --width;
+ tpch=A_GETC(fn);
+ }
+ if (!flag_discard) *s=0;
+ ++format;
+ }
+ break;
+#endif
+ default:
+ goto err_out;
+ }
+ }
+ break;
+
+ /* check if equal format string... */
+ default:
+ if ((unsigned char)tpch != ch) goto err_out;
+ tpch=A_GETC(fn);
+ break;
+ }
+ }
+err_out:
+ if (tpch<0 && n==0) return EOF;
+ A_PUTC(tpch,fn);
+ return n;
+}
+
+link_warning("__v_scanf","warning: the scanf functions add several kilobytes of bloat.");
diff --git a/mdk-stage1/dietlibc/lib/adjtime.c b/mdk-stage1/dietlibc/lib/adjtime.c
new file mode 100644
index 000000000..b8986be57
--- /dev/null
+++ b/mdk-stage1/dietlibc/lib/adjtime.c
@@ -0,0 +1,18 @@
+#include <time.h>
+#include <sys/timex.h>
+
+int adjtime (const struct timeval *itv, struct timeval *otv) {
+ struct timex tmp;
+ if (itv) {
+ tmp.offset = (itv->tv_usec % 1000000L) + (itv->tv_sec + itv->tv_usec / 1000000L) * 1000000L;
+ tmp.modes = ADJ_OFFSET_SINGLESHOT;
+ } else
+ tmp.modes = 0;
+ if (adjtimex(&tmp)==-1)
+ return -1;
+ if (otv) {
+ otv->tv_usec = tmp.offset % 1000000;
+ otv->tv_sec = tmp.offset / 1000000;
+ }
+ return 0;
+}
diff --git a/mdk-stage1/dietlibc/lib/atoll.c b/mdk-stage1/dietlibc/lib/atoll.c
new file mode 100644
index 000000000..7bf2b2fd6
--- /dev/null
+++ b/mdk-stage1/dietlibc/lib/atoll.c
@@ -0,0 +1,19 @@
+#include <endian.h>
+#include <ctype.h>
+#include <stdlib.h>
+
+#if __WORDSIZE != 64
+long long int atoll(const char* s) {
+ long long int v=0;
+ int sign=1;
+ while ( *s == ' ' || (unsigned int)(*s - 9) < 5u) ++s;
+ switch (*s) {
+ case '-': sign=-1;
+ case '+': ++s;
+ }
+ while ((unsigned int) (*s - '0') < 10u) {
+ v=v*10+*s-'0'; ++s;
+ }
+ return sign==-1?-v:v;
+}
+#endif
diff --git a/mdk-stage1/dietlibc/lib/bcd.c b/mdk-stage1/dietlibc/lib/bcd.c
new file mode 100644
index 000000000..1936b82f6
--- /dev/null
+++ b/mdk-stage1/dietlibc/lib/bcd.c
@@ -0,0 +1,185 @@
+
+static long double powers [] = {
+ 1.e+1, 1.e+2, 1.e+4, 1.e+8, 1.e+16, 1.e+32, 1.e+64, 1.e+128, 1.e+256
+};
+
+/*
+ * So, die ist zum Zerlegen von Gleitkommazahlen am besten geeignet.
+ *
+ * Die nichtnegative übergebende Gleitkommazahl number wird in einen
+ * Exponenten e und eine Mantisse m zerlegt mit:
+ *
+ * 1 <= m < 10
+ * number = m * 10^e
+ *
+ * Die Mantisse wird in precision Dezimalstellen zerlegt, die nach digits
+ * geschrieben werden. digits[0] ist die Vorkommastelle, digits [1 ...
+ * precision-1] die Nachkommastellen der Mantisse Zurückgeliefert wird der
+ * Exponent.
+ *
+ * Für precision ist ein Wert von 0 erlaubt, Sinn machen allerdings erst
+ * Werte ab 1.
+ */
+
+int __decompose_floatp ( long double number,
+ unsigned char* digits, unsigned int precision );
+
+int __decompose_floatp ( long double number,
+ unsigned char* digits, unsigned int precision )
+{
+ int ret = 0;
+ int i;
+ double tmp;
+
+ if ( number > 0.L ) {
+
+ // Exponent abtrennen
+ if ( number >= 10.L ) {
+ for ( i = sizeof(powers)/sizeof(*powers)-1; i >= 0; i--)
+ if ( number >= powers [i] ) {
+ number /= powers [i];
+ ret += 1 << i;
+ }
+ } else if ( number < 1.L )
+ for ( i = sizeof(powers)/sizeof(*powers)-1; i >= 0; i--)
+ if ( number * powers [i] < 10.L ) {
+ number *= powers [i];
+ ret -= 1 << i;
+ }
+
+ // Runden (ohne Geradezahlregel => Bug)
+ tmp = 5.;
+ {
+ unsigned int j;
+ for ( j = 0; j < precision; j++ )
+ tmp *= 0.1;
+ }
+
+ number += tmp;
+
+ // Dabei kann die Zahl in die nächste Dekade reinrutschen ...
+ if ( number >= 10.L ) {
+ number = 1.L;
+ ret++;
+ }
+ }
+
+ // Mantisse in ASCII konvertieren
+ while ( precision-- ) {
+ i = (int) number;
+ number = (number - i) * 10.L;
+ *digits++ = '0' + i;
+ }
+
+ // Exponent zurück
+ return ret;
+}
+
+
+/*
+ * So, die ist zum Zerlegen von Festkommazahlen am besten geeignet.
+ *
+ * Die nichtnegative übergebende Festkomma wird in einen Integeranteil und
+ * einen Bruchanteil zerlegt.
+ *
+ * Der Bruchanteil wird in digits_frac[0...precision_frac-1] gespeichert,
+ * falls precision_frac != 0 ist.
+ *
+ * Der Integeranteil wird ab digits_int + precision_int - 1 rückwrts
+ * geschrieben. Zurückgeliefert wird ein Zeiger auf das erste Zeichen, das
+ * bei der Konvertierung != '0' ist (Ausnahme ist die 0.0 selbst). Zeichen
+ * zwischen digits_int und diesem Zeiger (exklusive des Zeichens unter dem
+ * Zeiger) sind unbestimmt. Wünscht man dort Nullen oder Leerzeichen,
+ * sollte man mittels memset() dieses vorher initialsieren.
+ */
+
+char* __decompose_fixp ( long double number,
+ unsigned char* digits_int , unsigned int precision_int,
+ unsigned char* digits_frac, unsigned int precision_frac );
+
+char* __decompose_fixp ( long double number,
+ unsigned char* digits_int , unsigned int precision_int,
+ unsigned char* digits_frac, unsigned int precision_frac )
+{
+ long long int integer;
+ double tmp;
+ int i;
+
+ // Runden (ohne Geradezahlregel => Bug)
+ tmp = 0.5;
+ {
+ unsigned int j;
+ for ( j = 0; j < precision_frac; j++ )
+ tmp *= 0.1;
+ }
+
+ number += tmp;
+
+ integer = number;
+ number -= integer;
+
+ // Nachkommastellen
+ while ( precision_frac-- ) {
+ number *= 10.L;
+ i = (int) number;
+ number -= i;
+ *digits_frac++
+ = '0' + i;
+ }
+
+ // Vorkommastellen
+ while ( precision_int ) {
+ i = (int) (integer % 10);
+ integer /= 10;
+ digits_int [--precision_int]
+ = '0' + i;
+ if ( integer == 0 )
+ break;
+ }
+
+ return digits_int + precision_int;
+}
+
+
+#if 0
+
+#include <stdio.h>
+#include <math.h>
+
+long double test [] = {
+ 1, M_PI, 123, 123456789, 12345678901234567, 1e300, 0.00123456789, 1.234567890123456e-300, 0
+};
+
+int main ( void )
+{
+ int i;
+ int j;
+ int k;
+ char buff1 [32];
+ char buff2 [32];
+ char* retp;
+ int ret;
+
+ for ( i = 0; i < sizeof(test)/sizeof(*test); i++ ) {
+ printf ("\n*** %30.20Lf ***\n\n", test[i] );
+
+ for ( j = 0; j <= 20; j++ ) {
+ memset ( buff1, 0, sizeof(buff1) );
+ ret = __decompose_floatp ( test[i], buff1, j );
+ printf ( "floatp(%2u) = <%sE%+d>\n", j, buff1, ret );
+ }
+ for ( j = 0; j <= 20; j++ ) {
+ for ( k = 0; k <= 20; k++ ) {
+ memset ( buff1, 0, sizeof(buff1) );
+ memset ( buff2, 0, sizeof(buff2) );
+ retp = __decompose_fixp ( test[i], buff1, j, buff2, k );
+ printf ( "fixp(%2u,%2u) = <%s.%s>\n", j, k, retp, buff2 );
+ }
+ }
+
+ }
+
+ return 0;
+}
+
+#endif
diff --git a/mdk-stage1/dietlibc/lib/binshstr.c b/mdk-stage1/dietlibc/lib/binshstr.c
new file mode 100644
index 000000000..814297e3d
--- /dev/null
+++ b/mdk-stage1/dietlibc/lib/binshstr.c
@@ -0,0 +1,5 @@
+#include "binshstr.h"
+
+const char __binsh [] = "/bin/sh";
+
+/* end of binshstr.c */
diff --git a/mdk-stage1/dietlibc/lib/cfgetospeed.c b/mdk-stage1/dietlibc/lib/cfgetospeed.c
new file mode 100644
index 000000000..c330352b2
--- /dev/null
+++ b/mdk-stage1/dietlibc/lib/cfgetospeed.c
@@ -0,0 +1,8 @@
+#include <termios.h>
+#include <sys/types.h>
+
+speed_t cfgetospeed(struct termios *termios_p) {
+ return ((termios_p->c_cflag & (CBAUD|CBAUDEX)));
+}
+
+speed_t cfgetispeed(struct termios *termios_p) __attribute__((weak,alias("cfgetospeed")));
diff --git a/mdk-stage1/dietlibc/lib/cfsetispeed.c b/mdk-stage1/dietlibc/lib/cfsetispeed.c
new file mode 100644
index 000000000..ab0333853
--- /dev/null
+++ b/mdk-stage1/dietlibc/lib/cfsetispeed.c
@@ -0,0 +1,22 @@
+#include <termios.h>
+#include <errno.h>
+#include "dietfeatures.h"
+
+#define IBAUD0 020000000000
+
+int cfsetispeed(struct termios *termios_p, speed_t speed)
+{
+ if ((speed & (speed_t)~CBAUD) != 0 && (speed < B57600 || speed > B460800)) {
+ errno=EINVAL;
+ return -1;
+ }
+ if (speed == 0)
+ termios_p->c_iflag |= IBAUD0;
+ else {
+ termios_p->c_iflag &= ~IBAUD0;
+ termios_p->c_cflag &= ~(CBAUD | CBAUDEX);
+ termios_p->c_cflag |= speed;
+ }
+ return 0;
+}
+
diff --git a/mdk-stage1/dietlibc/lib/cfsetospeed.c b/mdk-stage1/dietlibc/lib/cfsetospeed.c
new file mode 100644
index 000000000..d1aee3595
--- /dev/null
+++ b/mdk-stage1/dietlibc/lib/cfsetospeed.c
@@ -0,0 +1,14 @@
+#include <termios.h>
+#include <errno.h>
+#include "dietfeatures.h"
+
+int cfsetospeed(struct termios *termios_p, speed_t speed) {
+ if ((speed & (speed_t)~CBAUD) != 0 && (speed < B57600 || speed > B460800)) {
+ errno=EINVAL;
+ return -1;
+ }
+ termios_p->c_cflag &= ~(CBAUD | CBAUDEX);
+ termios_p->c_cflag |= speed;
+ return 0;
+}
+
diff --git a/mdk-stage1/dietlibc/lib/errlistu.c b/mdk-stage1/dietlibc/lib/errlistu.c
new file mode 100644
index 000000000..15e38807b
--- /dev/null
+++ b/mdk-stage1/dietlibc/lib/errlistu.c
@@ -0,0 +1,6 @@
+/*
+ * used by perror() and strerror()
+ */
+
+const char __sys_err_unknown [] = "[unknown error]";
+
diff --git a/mdk-stage1/dietlibc/lib/execle.c b/mdk-stage1/dietlibc/lib/execle.c
new file mode 100644
index 000000000..6d05c48a0
--- /dev/null
+++ b/mdk-stage1/dietlibc/lib/execle.c
@@ -0,0 +1,26 @@
+#include <stdarg.h>
+#include <unistd.h>
+#include <errno.h>
+#include <stdlib.h>
+#include "dietfeatures.h"
+
+int execle( const char *path,...) {
+ va_list ap;
+ int n,i;
+ char **argv,*tmp, **env;
+ va_start(ap, path);
+ n=1;
+ while ((tmp=va_arg(ap,char *)))
+ ++n;
+ va_end (ap);
+ if ((argv=(char **)alloca(n*sizeof(char*)))) {
+ va_start(ap, path);
+ for (i=0; i<n; ++i)
+ argv[i]=va_arg(ap,char *);
+ env=va_arg(ap, char **);
+ va_end (ap);
+ return execve(path,argv,env);
+ }
+ errno=ENOMEM;
+ return -1;
+}
diff --git a/mdk-stage1/dietlibc/lib/if_nameindex.c b/mdk-stage1/dietlibc/lib/if_nameindex.c
new file mode 100644
index 000000000..fc0e1c0ff
--- /dev/null
+++ b/mdk-stage1/dietlibc/lib/if_nameindex.c
@@ -0,0 +1,40 @@
+#include <net/if.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <sys/ioctl.h>
+#include <stdio.h>
+
+struct if_nameindex* if_nameindex(void) {
+ struct ifconf ic;
+ int fd,len,i;
+ struct if_nameindex* x,* y;
+ char *dest;
+ fd=socket(AF_INET6,SOCK_DGRAM,0);
+ if (fd<0) fd=socket(AF_INET,SOCK_DGRAM,0);
+ ic.ifc_buf=0;
+ ic.ifc_len=0;
+ if (ioctl(fd,SIOCGIFCONF,&ic)<0) {
+b0rken:
+ close(fd);
+ return 0;
+ }
+ ic.ifc_buf=alloca((size_t)ic.ifc_len);
+ if (ioctl(fd,SIOCGIFCONF,&ic)<0) goto b0rken;
+ len=(ic.ifc_len/sizeof(struct ifreq));
+ x=(struct if_nameindex*)malloc((len+1)*sizeof(struct if_nameindex)+len*IFNAMSIZ);
+ if (!x) goto b0rken;
+ dest=(char*)(x+len+1);
+ y=x;
+ for (i=0; i<len; ++i) {
+ struct ifreq* ir=(struct ifreq*)&ic.ifc_req[i];
+ y->if_name=dest;
+ memcpy(dest,ir->ifr_name,IFNAMSIZ);
+ if (ioctl(fd,SIOCGIFINDEX,ir)==-1) continue;
+ y->if_index=ir->ifr_ifindex;
+ dest+=IFNAMSIZ;
+ ++y;
+ }
+ y->if_name=0; y->if_index=0;
+ return x;
+}
diff --git a/mdk-stage1/dietlibc/lib/ipv6constants.c b/mdk-stage1/dietlibc/lib/ipv6constants.c
new file mode 100644
index 000000000..1d5cb1f08
--- /dev/null
+++ b/mdk-stage1/dietlibc/lib/ipv6constants.c
@@ -0,0 +1,4 @@
+#include "netinet/in.h"
+
+const struct in6_addr in6addr_any = IN6ADDR_ANY_INIT;
+const struct in6_addr in6addr_loopback = IN6ADDR_LOOPBACK_INIT;
diff --git a/mdk-stage1/dietlibc/lib/labs.c b/mdk-stage1/dietlibc/lib/labs.c
new file mode 100644
index 000000000..364557f40
--- /dev/null
+++ b/mdk-stage1/dietlibc/lib/labs.c
@@ -0,0 +1,6 @@
+#include <endian.h>
+
+#if __WORDSIZE == 64
+long int labs(long int i) { return i>=0?i:-i; }
+long long int llabs(long long int i) __attribute__((alias("labs")));
+#endif
diff --git a/mdk-stage1/dietlibc/lib/llabs.c b/mdk-stage1/dietlibc/lib/llabs.c
new file mode 100644
index 000000000..bcbd3dc78
--- /dev/null
+++ b/mdk-stage1/dietlibc/lib/llabs.c
@@ -0,0 +1,6 @@
+#include <endian.h>
+#include <stdlib.h>
+
+#if __WORDSIZE != 64
+long long int llabs(long long int i) { if (i<0) i=-i; return i; }
+#endif
diff --git a/mdk-stage1/dietlibc/lib/memmem.c b/mdk-stage1/dietlibc/lib/memmem.c
new file mode 100644
index 000000000..5c88a29e7
--- /dev/null
+++ b/mdk-stage1/dietlibc/lib/memmem.c
@@ -0,0 +1,14 @@
+#define _GNU_SOURCE 23
+#include <sys/types.h>
+#include <string.h>
+
+void *memmem(const void* haystack, size_t hl, const void* needle, size_t nl) {
+ int i;
+ if (nl>hl) return 0;
+ for (i=hl-nl+1; i; --i) {
+ if (!memcmp(haystack,needle,nl))
+ return (char*)haystack;
+ ++haystack;
+ }
+ return 0;
+}
diff --git a/mdk-stage1/dietlibc/lib/memrchr.c b/mdk-stage1/dietlibc/lib/memrchr.c
new file mode 100644
index 000000000..f7750d2d7
--- /dev/null
+++ b/mdk-stage1/dietlibc/lib/memrchr.c
@@ -0,0 +1,15 @@
+#define _GNU_SOURCE
+#include <sys/types.h>
+#include <string.h>
+
+void* memrchr(const void *s, int c, size_t n) {
+ register const char* t=s;
+ register const char* last=0;
+ int i;
+ for (i=n; i; --i) {
+ if (*t==c)
+ last=t;
+ ++t;
+ }
+ return (void*)last; /* man, what an utterly b0rken prototype */
+}
diff --git a/mdk-stage1/dietlibc/lib/pwrite.c b/mdk-stage1/dietlibc/lib/pwrite.c
new file mode 100644
index 000000000..1e9fde545
--- /dev/null
+++ b/mdk-stage1/dietlibc/lib/pwrite.c
@@ -0,0 +1,11 @@
+#include <endian.h>
+#include <sys/types.h>
+
+extern size_t __pwrite(int fd, void *buf, size_t count, off_t a,off_t b);
+
+size_t __libc_pwrite(int fd, void *buf, size_t count, off_t offset);
+size_t __libc_pwrite(int fd, void *buf, size_t count, off_t offset) {
+ return __pwrite(fd,buf,count,offset,0);
+}
+
+int pwrite(int fd, void *buf, size_t count, off_t offset) __attribute__((weak,alias("__libc_pwrite")));
diff --git a/mdk-stage1/dietlibc/lib/pwrite64.c b/mdk-stage1/dietlibc/lib/pwrite64.c
new file mode 100644
index 000000000..cac46024a
--- /dev/null
+++ b/mdk-stage1/dietlibc/lib/pwrite64.c
@@ -0,0 +1,14 @@
+#include <endian.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#ifndef __NO_STAT64
+extern size_t __pwrite(int fd, void *buf, size_t count, off_t a,off_t b);
+
+size_t __libc_pwrite64(int fd, void *buf, size_t count, off64_t offset);
+size_t __libc_pwrite64(int fd, void *buf, size_t count, off64_t offset) {
+ return __pwrite(fd,buf,count,__LONG_LONG_PAIR ((off_t)(offset&0xffffffff),(off_t)(offset>>32)));
+}
+
+int pwrite64(int fd, void *buf, size_t count, off_t offset) __attribute__((weak,alias("__libc_pwrite64")));
+#endif
diff --git a/mdk-stage1/dietlibc/lib/rand48.c b/mdk-stage1/dietlibc/lib/rand48.c
new file mode 100644
index 000000000..9c6cfcda2
--- /dev/null
+++ b/mdk-stage1/dietlibc/lib/rand48.c
@@ -0,0 +1,89 @@
+#include <stdlib.h>
+
+static randbuf rand48buf;
+#define A_0 0xE66D
+#define A_1 0xDEEC
+#define A_2 0x5
+#define C 0xB
+static randbuf a = { A_0, A_1, A_2 };
+static unsigned short c = C;
+
+static void calc_next(randbuf buf) {
+ randbuf tmp;
+ long t;
+ t = buf[0] * a[0] + c;
+ tmp[0] = t & 0xffff;
+ tmp[1] = (t >> 16) & 0xffff;
+ t = buf[1] * a[0] + buf[0] * a[1] + tmp[1];
+ tmp[1] = t & 0xffff;
+ tmp[2] = (t >> 16) & 0xffff;
+ t = buf[2] * a[0] + buf[1] * a[1] + buf[0] * a[2] + tmp[2];
+ tmp[2] = t & 0xffff;
+ buf[0] = tmp[0];
+ buf[1] = tmp[1];
+ buf[2] = tmp[2];
+}
+
+double drand48(void) {
+ return erand48(rand48buf);
+}
+
+long lrand48(void) {
+ return nrand48(rand48buf);
+}
+
+long mrand48(void) {
+ return jrand48(rand48buf);
+}
+
+void srand48(long seed) {
+ rand48buf[1] = (seed >> 16) & 0xffff;
+ rand48buf[2] = seed & 0xffff;
+ rand48buf[0] = 0x330e;
+ a[0] = A_0;
+ a[1] = A_1;
+ a[2] = A_2;
+ c = C;
+}
+
+unsigned short *seed48(randbuf buf) {
+ static randbuf oldx;
+ int i;
+ for (i = 0; i < 3; i++) {
+ oldx[i] = rand48buf[i];
+ rand48buf[i] = buf[i];
+ }
+ a[0] = A_0;
+ a[1] = A_1;
+ a[2] = A_2;
+ c = C;
+ return (unsigned short *)&oldx;
+}
+
+void lcong48(unsigned short param[7]) {
+ int i;
+ for (i = 0; i < 3; i++) {
+ rand48buf[i] = param[i];
+ a[i] = param[i + 3];
+ }
+ c = param[6];
+}
+
+long jrand48(randbuf buf) {
+ long ret;
+ ret = buf[2] << 16 | buf[1];
+ calc_next(buf);
+ return ret;
+}
+
+long nrand48(randbuf buf) {
+ return jrand48(buf) & 0x7FFFFFFFL;
+}
+
+double erand48(randbuf buf) {
+ double ret;
+ ret = ((buf[0] / 65536.0 + buf[1]) / 65536.0 + buf[2]) / 65536.0;
+ calc_next(buf);
+ return ret;
+}
+
diff --git a/mdk-stage1/dietlibc/lib/rand_r.c b/mdk-stage1/dietlibc/lib/rand_r.c
new file mode 100644
index 000000000..55f8303bc
--- /dev/null
+++ b/mdk-stage1/dietlibc/lib/rand_r.c
@@ -0,0 +1,30 @@
+/*
+ Copyright (C) 2002 Luc Van Oostenryck
+
+ This is free software. You can redistribute and
+ modify it under the terms of the GNU General Public
+ Public License.
+*/
+
+#include <stdlib.h>
+#include <stdint.h>
+
+/* Knuth's TAOCP section 3.6 */
+#define M ((1U<<31) -1)
+#define A 48271
+#define Q 44488 // M/A
+#define R 3399 // M%A; R < Q !!!
+
+// FIXME: ISO C/SuS want a longer period
+
+int rand_r(unsigned int* seed)
+{ int32_t X;
+
+ X = *seed;
+ X = A*(X%Q) - R * (int32_t) (X/Q);
+ if (X < 0)
+ X += M;
+
+ *seed = X;
+ return X;
+}
diff --git a/mdk-stage1/dietlibc/lib/readdir64.c b/mdk-stage1/dietlibc/lib/readdir64.c
new file mode 100644
index 000000000..b9b0aafcc
--- /dev/null
+++ b/mdk-stage1/dietlibc/lib/readdir64.c
@@ -0,0 +1,62 @@
+#include "dietfeatures.h"
+#include "dietdirent.h"
+#include <unistd.h>
+#include <dirent.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <string.h>
+#include "syscalls.h"
+
+#ifndef __NR_getdents64
+#define WANT_LARGEFILE_BACKCOMPAT
+#endif
+
+#ifndef WANT_LARGEFILE_BACKCOMPAT
+struct dirent64* readdir64(DIR *d) {
+ if (!d->num || (d->cur += ((struct dirent64*)(d->buf+d->cur))->d_reclen)>=d->num) {
+ int res=getdents64(d->fd,(struct dirent64*)d->buf, sizeof (d->buf)-1);
+ if (res<=0) return 0;
+ d->num=res; d->cur=0;
+ }
+ return (struct dirent64*)(d->buf+d->cur);
+}
+#else
+struct dirent64* readdir64(DIR *d) {
+#ifdef __NR_getdents64
+ static int trygetdents64=1;
+#endif
+ struct dirent* o;
+ static struct dirent64 d64;
+again:
+#ifdef __NR_getdents64
+ if (!trygetdents64) {
+#endif
+ if (!d->num || (d->cur += ((struct dirent*)(d->buf+d->cur))->d_reclen)>=d->num) {
+ int res=getdents(d->fd,(struct dirent*)d->buf, sizeof (d->buf)-1);
+ if (res<=0) return 0;
+ d->num=res; d->cur=0;
+ }
+ o=(struct dirent*)(d->buf+d->cur);
+ d64.d_ino=o->d_ino;
+ d64.d_off=o->d_off;
+ d64.d_reclen=o->d_reclen;
+ strcpy(d64.d_name,o->d_name);
+ d64.d_type=0; /* is this correct? */
+ return &d64;
+#ifdef __NR_getdents64
+ }
+ if (!d->num || (d->cur += ((struct dirent64*)(d->buf+d->cur))->d_reclen)>=d->num) {
+ int res=getdents64(d->fd,(struct dirent64*)d->buf,sizeof (d->buf));
+ if (res<=0) {
+ if (errno==ENOSYS) {
+ trygetdents64=0;
+ goto again;
+ }
+ return 0;
+ }
+ d->num=res; d->cur=0;
+ }
+ return (struct dirent64*)(d->buf+d->cur);
+#endif
+}
+#endif
diff --git a/mdk-stage1/dietlibc/lib/setlinebuf.c b/mdk-stage1/dietlibc/lib/setlinebuf.c
new file mode 100644
index 000000000..1f30e183a
--- /dev/null
+++ b/mdk-stage1/dietlibc/lib/setlinebuf.c
@@ -0,0 +1,12 @@
+#include <stdio.h>
+#include "dietwarning.h"
+#undef setlinebuf
+
+/* there is no previous prototype because it is a #define */
+void setlinebuf(FILE* stream);
+
+void setlinebuf(FILE* stream) {
+ setvbuf(stream,0,_IOLBF,BUFSIZ);
+}
+
+link_warning("setlinebuf","warning: you used setlinebuf without including <stdio.h>")
diff --git a/mdk-stage1/dietlibc/lib/sigaction.c b/mdk-stage1/dietlibc/lib/sigaction.c
new file mode 100644
index 000000000..fe1351f0f
--- /dev/null
+++ b/mdk-stage1/dietlibc/lib/sigaction.c
@@ -0,0 +1,11 @@
+#include <signal.h>
+
+int __rt_sigaction(int signum, const struct sigaction *act, struct sigaction *oldact, long nr);
+
+int __libc_sigaction(int signum, const struct sigaction *act, struct sigaction *oldact);
+int __libc_sigaction(int signum, const struct sigaction *act, struct sigaction *oldact) {
+ return __rt_sigaction(signum, act, oldact, _NSIG/8);
+}
+
+int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact)
+__attribute__((weak,alias("__libc_sigaction")));
diff --git a/mdk-stage1/dietlibc/lib/siginterrupt.c b/mdk-stage1/dietlibc/lib/siginterrupt.c
new file mode 100644
index 000000000..8926f09ed
--- /dev/null
+++ b/mdk-stage1/dietlibc/lib/siginterrupt.c
@@ -0,0 +1,17 @@
+#include <signal.h>
+
+int siginterrupt(int sig, int flag) {
+ int ret;
+ struct sigaction act;
+
+ sigaction(sig, 0, &act);
+
+ if (flag)
+ act.sa_flags &= ~SA_RESTART;
+ else
+ act.sa_flags |= SA_RESTART;
+
+ ret = sigaction(sig, &act, 0);
+
+ return ret;
+}
diff --git a/mdk-stage1/dietlibc/lib/signal.c b/mdk-stage1/dietlibc/lib/signal.c
new file mode 100644
index 000000000..51441558e
--- /dev/null
+++ b/mdk-stage1/dietlibc/lib/signal.c
@@ -0,0 +1,12 @@
+#include <signal.h>
+
+sighandler_t signal(int signum, sighandler_t action) {
+ struct sigaction sa,oa;
+ sa.sa_handler=action;
+ sigemptyset(&sa.sa_mask);
+ sigaddset(&sa.sa_mask,signum);
+ sa.sa_flags=SA_NODEFER;
+ if (sigaction(signum,&sa,&oa))
+ return SIG_ERR;
+ return oa.sa_handler;
+}
diff --git a/mdk-stage1/dietlibc/lib/sigpending.c b/mdk-stage1/dietlibc/lib/sigpending.c
new file mode 100644
index 000000000..62a4761c6
--- /dev/null
+++ b/mdk-stage1/dietlibc/lib/sigpending.c
@@ -0,0 +1,7 @@
+#include <signal.h>
+
+int __rt_sigpending(sigset_t *set, long nr);
+
+int sigpending(sigset_t *set) {
+ return __rt_sigpending(set, _NSIG/8);
+}
diff --git a/mdk-stage1/dietlibc/lib/sigprocmask.c b/mdk-stage1/dietlibc/lib/sigprocmask.c
new file mode 100644
index 000000000..6d770c3d3
--- /dev/null
+++ b/mdk-stage1/dietlibc/lib/sigprocmask.c
@@ -0,0 +1,7 @@
+#include <signal.h>
+
+int __rt_sigprocmask(int how, const sigset_t *set, sigset_t *oldsetm, long nr);
+
+int sigprocmask(int how, const sigset_t *set, sigset_t *oldset) {
+ return __rt_sigprocmask(how, set, oldset, _NSIG/8);
+}
diff --git a/mdk-stage1/dietlibc/lib/sigqueueinfo.c b/mdk-stage1/dietlibc/lib/sigqueueinfo.c
new file mode 100644
index 000000000..adb7349f4
--- /dev/null
+++ b/mdk-stage1/dietlibc/lib/sigqueueinfo.c
@@ -0,0 +1,7 @@
+#include <signal.h>
+
+int __rt_sigqueueinfo(int pid, int sig, siginfo_t *info);
+
+int sigqueueinfo(int pid, int sig, siginfo_t *info) {
+ return __rt_sigqueueinfo(pid, sig, info);
+}
diff --git a/mdk-stage1/dietlibc/lib/sigsuspend.c b/mdk-stage1/dietlibc/lib/sigsuspend.c
new file mode 100644
index 000000000..a020789e9
--- /dev/null
+++ b/mdk-stage1/dietlibc/lib/sigsuspend.c
@@ -0,0 +1,10 @@
+#include <signal.h>
+
+int __rt_sigsuspend(const sigset_t *mask, long nr);
+
+int __libc_sigsuspend(const sigset_t *mask);
+int __libc_sigsuspend(const sigset_t *mask) {
+ return __rt_sigsuspend(mask, _NSIG/8);
+}
+
+int sigsuspend(const sigset_t *mask) __attribute__((weak,alias("__libc_sigsuspend")));
diff --git a/mdk-stage1/dietlibc/lib/sigtimedwait.c b/mdk-stage1/dietlibc/lib/sigtimedwait.c
new file mode 100644
index 000000000..864e433c3
--- /dev/null
+++ b/mdk-stage1/dietlibc/lib/sigtimedwait.c
@@ -0,0 +1,7 @@
+#include <signal.h>
+
+int __rt_sigtimedwait(const sigset_t *set, siginfo_t *info, const struct timespec *ts, long nr);
+
+int sigtimedwait(const sigset_t *set, siginfo_t *info, const struct timespec *ts) {
+ return __rt_sigtimedwait(set,info,ts,_NSIG/8);
+}
diff --git a/mdk-stage1/dietlibc/lib/socketpair.c b/mdk-stage1/dietlibc/lib/socketpair.c
new file mode 100644
index 000000000..e6f1fd822
--- /dev/null
+++ b/mdk-stage1/dietlibc/lib/socketpair.c
@@ -0,0 +1,12 @@
+#include <linuxnet.h>
+
+extern int socketcall(int callno,long* args);
+
+int __libc_socketpair(int a, int type, int protocol, int sv[2]);
+int __libc_socketpair(int a, int type, int protocol, int sv[2]) {
+ unsigned long args[] = { a, type, protocol, (long)sv };
+ return socketcall(SYS_SOCKETPAIR, args);
+}
+
+int socketpair(int d, int type, int protocol, int sv[2])
+ __attribute__((weak,alias("__libc_socketpair")));
diff --git a/mdk-stage1/dietlibc/lib/strtof.c b/mdk-stage1/dietlibc/lib/strtof.c
new file mode 100644
index 000000000..acb081e51
--- /dev/null
+++ b/mdk-stage1/dietlibc/lib/strtof.c
@@ -0,0 +1,66 @@
+#include <string.h>
+#include <stdlib.h>
+#include <ctype.h>
+
+float strtof(const char* s, char** endptr) {
+ register const char* p = s;
+ register float value = 0.;
+ int sign = +1;
+ float factor;
+ unsigned int expo;
+
+ while ( isspace(*p) )
+ p++;
+
+ switch (*p) {
+ case '-': sign = -1;
+ case '+': p++;
+ default : break;
+ }
+
+ while ( (unsigned int)(*p - '0') < 10u )
+ value = value*10 + (*p++ - '0');
+
+ if ( *p == '.' ) {
+ factor = 1.;
+
+ p++;
+ while ( (unsigned int)(*p - '0') < 10u ) {
+ factor *= 0.1;
+ value += (*p++ - '0') * factor;
+ }
+ }
+
+ if ( (*p | 32) == 'e' ) {
+ expo = 0;
+ factor = 10.L;
+
+ switch (*++p) { // ja hier weiß ich nicht, was mindestens nach einem 'E' folgenden MUSS.
+ case '-': factor = 0.1;
+ case '+': p++;
+ break;
+ case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9':
+ break;
+ default : value = 0.L;
+ p = s;
+ goto done;
+ }
+
+ while ( (unsigned int)(*p - '0') < 10u )
+ expo = 10 * expo + (*p++ - '0');
+
+ while ( 1 ) {
+ if ( expo & 1 )
+ value *= factor;
+ if ( (expo >>= 1) == 0 )
+ break;
+ factor *= factor;
+ }
+ }
+
+done:
+ if ( endptr != NULL )
+ *endptr = (char*)p;
+
+ return value * sign;
+}
diff --git a/mdk-stage1/dietlibc/lib/strtold.c b/mdk-stage1/dietlibc/lib/strtold.c
new file mode 100644
index 000000000..ae5f0fa48
--- /dev/null
+++ b/mdk-stage1/dietlibc/lib/strtold.c
@@ -0,0 +1,66 @@
+#include <string.h>
+#include <stdlib.h>
+#include <ctype.h>
+
+long double strtold(const char* s, char** endptr) {
+ register const char* p = s;
+ register long double value = 0.L;
+ int sign = +1;
+ long double factor;
+ unsigned int expo;
+
+ while ( isspace(*p) )
+ p++;
+
+ switch (*p) {
+ case '-': sign = -1;
+ case '+': p++;
+ default : break;
+ }
+
+ while ( (unsigned int)(*p - '0') < 10u )
+ value = value*10 + (*p++ - '0');
+
+ if ( *p == '.' ) {
+ factor = 1.;
+
+ p++;
+ while ( (unsigned int)(*p - '0') < 10u ) {
+ factor *= 0.1;
+ value += (*p++ - '0') * factor;
+ }
+ }
+
+ if ( (*p | 32) == 'e' ) {
+ expo = 0;
+ factor = 10.L;
+
+ switch (*++p) { // ja hier weiß ich nicht, was mindestens nach einem 'E' folgenden MUSS.
+ case '-': factor = 0.1;
+ case '+': p++;
+ break;
+ case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9':
+ break;
+ default : value = 0.L;
+ p = s;
+ goto done;
+ }
+
+ while ( (unsigned int)(*p - '0') < 10u )
+ expo = 10 * expo + (*p++ - '0');
+
+ while ( 1 ) {
+ if ( expo & 1 )
+ value *= factor;
+ if ( (expo >>= 1) == 0 )
+ break;
+ factor *= factor;
+ }
+ }
+
+done:
+ if ( endptr != NULL )
+ *endptr = (char*)p;
+
+ return value * sign;
+}
diff --git a/mdk-stage1/dietlibc/lib/strxfrm.c b/mdk-stage1/dietlibc/lib/strxfrm.c
new file mode 100644
index 000000000..5075ff0b5
--- /dev/null
+++ b/mdk-stage1/dietlibc/lib/strxfrm.c
@@ -0,0 +1,12 @@
+#include <sys/types.h>
+#include <string.h>
+#include "dietfeatures.h"
+
+size_t strxfrm(char *dest, const char *src, size_t n) {
+#ifdef WANT_FULL_POSIX_COMPAT
+ memset(dest,0,n);
+#endif
+ memccpy(dest,src,0,n);
+ return strlen(dest);
+}
+
diff --git a/mdk-stage1/dietlibc/lib/tcflow.c b/mdk-stage1/dietlibc/lib/tcflow.c
new file mode 100644
index 000000000..ea460f362
--- /dev/null
+++ b/mdk-stage1/dietlibc/lib/tcflow.c
@@ -0,0 +1,35 @@
+#include "dietfeatures.h"
+#include <errno.h>
+#include <termios.h>
+#include <sys/ioctl.h>
+
+int tcflow ( int fd, int action )
+{
+#if TCOOFF==0 && TCOON==1 && TCIOFF==2 && TCION==3
+
+ if ( (unsigned int)action < 4u )
+ return ioctl ( fd, TCXONC, action );
+
+ errno = EINVAL;
+ return -1;
+
+#else
+
+ int arg = 0;
+
+ switch (action) {
+ case TCION:
+ arg++;
+ case TCIOFF:
+ arg++;
+ case TCOON:
+ arg++;
+ case TCOOFF:
+ return ioctl ( fd, TCXONC, arg );
+ default:
+ errno = EINVAL;
+ return -1;
+ }
+
+#endif
+}
diff --git a/mdk-stage1/dietlibc/lib/tcsendbreak.c b/mdk-stage1/dietlibc/lib/tcsendbreak.c
new file mode 100644
index 000000000..b026340cf
--- /dev/null
+++ b/mdk-stage1/dietlibc/lib/tcsendbreak.c
@@ -0,0 +1,11 @@
+#include "dietfeatures.h"
+#include <errno.h>
+#include <termios.h>
+#include <sys/ioctl.h>
+
+int tcsendbreak (int fd,int duration)
+{
+ if (duration <= 0) return (ioctl (fd,TCSBRKP,0));
+ errno = EINVAL;
+ return (-1);
+}
diff --git a/mdk-stage1/dietlibc/lib/write12.c b/mdk-stage1/dietlibc/lib/write12.c
new file mode 100644
index 000000000..8e0130bfb
--- /dev/null
+++ b/mdk-stage1/dietlibc/lib/write12.c
@@ -0,0 +1,11 @@
+#include <unistd.h>
+#include <string.h>
+#include <write12.h>
+
+int __write1 (const char* s) {
+ return write(1, s, strlen(s));
+}
+
+int __write2 (const char* s) {
+ return write(2, s, strlen(s));
+}
diff --git a/mdk-stage1/dietlibc/libcompat/daemon.c b/mdk-stage1/dietlibc/libcompat/daemon.c
new file mode 100644
index 000000000..30f97a09a
--- /dev/null
+++ b/mdk-stage1/dietlibc/libcompat/daemon.c
@@ -0,0 +1,29 @@
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <paths.h>
+
+#include "daemon.h"
+
+int daemon (int nochdir,int noclose)
+{
+ int fd;
+ switch (fork()) {
+ case -1: return (-1);
+ case 0: break;
+ default: _exit (0);
+ }
+ if (setsid () == -1) return (-1);
+ if (!nochdir) chdir ("/");
+ if (!noclose) {
+ fd = open(_PATH_DEVNULL,O_RDWR,0);
+ if (fd == -1) return (-1);
+ dup2 (fd,STDIN_FILENO);
+ dup2 (fd,STDOUT_FILENO);
+ dup2 (fd,STDERR_FILENO);
+ if (fd>2) close (fd);
+ }
+ return (0);
+}
+
diff --git a/mdk-stage1/dietlibc/libcompat/getdelim.c b/mdk-stage1/dietlibc/libcompat/getdelim.c
new file mode 100644
index 000000000..e499bd7b7
--- /dev/null
+++ b/mdk-stage1/dietlibc/libcompat/getdelim.c
@@ -0,0 +1,32 @@
+#define _GNU_SOURCE
+#include <stdlib.h>
+#include <stdio.h>
+#include "dietfeatures.h"
+#include <errno.h>
+#include "dietwarning.h"
+
+ssize_t getdelim(char **lineptr, size_t *n, int delim, FILE *stream) {
+ size_t i;
+ if (!lineptr || !n) {
+ errno=EINVAL;
+ return -1;
+ }
+ if (!*lineptr) *n=0;
+ for (i=0; ; ) {
+ int x=fgetc(stream);
+ if (i>=*n) {
+ int tmp=*n+100;
+ char* new=realloc(*lineptr,tmp);
+ if (!new) return -1;
+ *lineptr=new; *n=tmp;
+ }
+ if (x==EOF) { (*lineptr)[i]=0; return -1; }
+ (*lineptr)[i]=x;
+ ++i;
+ if (x==delim) break;
+ }
+ (*lineptr)[i]=0;
+ return i;
+}
+
+link_warning("getdelim","warning: portable software should not use getdelim!")
diff --git a/mdk-stage1/dietlibc/libcompat/getline.c b/mdk-stage1/dietlibc/libcompat/getline.c
new file mode 100644
index 000000000..4926850a7
--- /dev/null
+++ b/mdk-stage1/dietlibc/libcompat/getline.c
@@ -0,0 +1,9 @@
+#define _GNU_SOURCE
+#include <stdio.h>
+#include "dietwarning.h"
+
+#undef getline
+ssize_t getline(char **lineptr, size_t *n, FILE *stream) {
+ return getdelim(lineptr,n,'\n',stream);
+}
+link_warning("getline","warning: you used getline without include stdio.h w/_GNU_SOURCE")
diff --git a/mdk-stage1/dietlibc/libcompat/re_bsd.c b/mdk-stage1/dietlibc/libcompat/re_bsd.c
new file mode 100644
index 000000000..44f022fa3
--- /dev/null
+++ b/mdk-stage1/dietlibc/libcompat/re_bsd.c
@@ -0,0 +1,34 @@
+/* wrapper to simulate the braindead 4.3BSD regex interface
+ * by Andreas Krennmair <a.krennmair@aon.at>
+ */
+#include <regex.h>
+#include <sys/types.h>
+
+#include "dietwarning.h"
+
+static char err_compile[] = "unable to compile regular expression.";
+static int re_buf_used;
+static regex_t re_buf;
+
+char * re_comp(char * regex) {
+ int rc;
+ if (regex) {
+ if (re_buf_used)
+ regfree(&re_buf);
+ rc = regcomp(&re_buf,regex,0);
+ if (rc)
+ return err_compile;
+ re_buf_used = 1;
+ }
+ return NULL;
+}
+
+int re_exec(char * string) {
+ if (string) {
+ return regexec(&re_buf,string,0,NULL,0)?0:1;
+ }
+ return 0;
+}
+
+link_warning("re_comp","warning: use regcomp instead of re_comp!")
+link_warning("re_exec","warning: use regexec instead of re_exec!")
diff --git a/mdk-stage1/dietlibc/libcompat/stpcpy.c b/mdk-stage1/dietlibc/libcompat/stpcpy.c
new file mode 100644
index 000000000..237a2e374
--- /dev/null
+++ b/mdk-stage1/dietlibc/libcompat/stpcpy.c
@@ -0,0 +1,6 @@
+#include <string.h>
+
+char * stpcpy (char *dst, const char *src) {
+ while ((*dst++ = *src++));
+ return (dst-1);
+}
diff --git a/mdk-stage1/dietlibc/libcompat/syscall.S b/mdk-stage1/dietlibc/libcompat/syscall.S
new file mode 100644
index 000000000..dd8e6b827
--- /dev/null
+++ b/mdk-stage1/dietlibc/libcompat/syscall.S
@@ -0,0 +1,70 @@
+#include "dietfeatures.h"
+
+.text
+.globl syscall
+#ifdef __arm__
+.type syscall,function
+#else
+.type syscall,@function
+#endif
+
+syscall:
+#ifdef __i386__
+ movl %esp, %eax
+ pushl %edi
+ pushl %esi
+ pushl %ebx
+ pushl %ebp
+ movl 0x08(%eax), %ebx
+ movl 0x0c(%eax), %ecx
+ movl 0x10(%eax), %edx
+ movl 0x14(%eax), %esi
+ movl 0x18(%eax), %edi
+ movl 0x1c(%eax), %ebp
+ movl 0x04(%eax), %eax
+ int $0x80
+ cmpl $-255, %eax
+ jbe .Lret
+ negl %eax
+#ifdef WANT_THREADSAFE
+ movl %eax, %ebx
+ call __errno_location
+ movl %ebx, (%eax)
+ xorl %eax, %eax
+ decl %eax
+#else
+ mov %eax, errno
+ sbb %eax, %eax
+#endif
+.Lret:
+ pop %ebp
+ pop %ebx
+ pop %esi
+ pop %edi
+ ret
+#elif (defined(__hppa__))
+ copy %r26, %r20
+ copy %r25, %r26
+ copy %r24, %r25
+ copy %r23, %r24
+ ldw -0x34(%sr0, %sp), %r23
+ ldw -0x38(%sr0, %sp), %r22
+ be,l 0x100(%sr2, %r0), %sr0, %r31
+ ldw -0x3c(%sr0, %sp), %r21
+ ldi -0x100, %r1
+ cmpb,<<=,n %r1, %ret0, __error_unified_syscall
+.Lret:
+ bv,n %r0(%rp)
+#elif (defined(__ia64__))
+ mov r15=r32
+ mov r32=r33
+ mov r33=r34
+ mov r34=r35
+ mov r35=r36
+ mov r36=r37
+ break.i 0x100000
+ cmp.eq p6,p0=-1,r10
+(p6) br __error_unified_syscall
+ br.ret.sptk.few rp
+#endif
+.size syscall, . - syscall
diff --git a/mdk-stage1/dietlibc/libcruft/__end_parse.c b/mdk-stage1/dietlibc/libcruft/__end_parse.c
new file mode 100644
index 000000000..6c36318b5
--- /dev/null
+++ b/mdk-stage1/dietlibc/libcruft/__end_parse.c
@@ -0,0 +1,10 @@
+#include <sys/types.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+#include "parselib.h"
+
+void __end_parse(struct state* s) {
+ munmap((void*)(s->buffirst),s->buflen);
+ s->buffirst=0;
+}
diff --git a/mdk-stage1/dietlibc/libcruft/__parse.c b/mdk-stage1/dietlibc/libcruft/__parse.c
new file mode 100644
index 000000000..ef020a138
--- /dev/null
+++ b/mdk-stage1/dietlibc/libcruft/__parse.c
@@ -0,0 +1,10 @@
+#include <ctype.h>
+#include <sys/types.h>
+#include "parselib.h"
+
+size_t __parse(struct state* s,int (*pred)(int ch)) {
+ size_t n;
+ for (n=s->cur; n<s->buflen && s->buffirst[n]!='\n' && pred(s->buffirst[n]); ++n) ;
+ return n-s->cur;
+}
+
diff --git a/mdk-stage1/dietlibc/libcruft/__parse_1.c b/mdk-stage1/dietlibc/libcruft/__parse_1.c
new file mode 100644
index 000000000..ba56d022c
--- /dev/null
+++ b/mdk-stage1/dietlibc/libcruft/__parse_1.c
@@ -0,0 +1,9 @@
+#include <sys/types.h>
+#include "parselib.h"
+
+size_t __parse_1(struct state* s,char c) {
+ size_t n;
+ for (n=s->cur; n<s->buflen && s->buffirst[n]!='\n' && s->buffirst[n]!=c; ++n) ;
+ return n-s->cur;
+}
+
diff --git a/mdk-stage1/dietlibc/libcruft/__parse_nws.c b/mdk-stage1/dietlibc/libcruft/__parse_nws.c
new file mode 100644
index 000000000..e26fc443d
--- /dev/null
+++ b/mdk-stage1/dietlibc/libcruft/__parse_nws.c
@@ -0,0 +1,10 @@
+#include <sys/types.h>
+#include "parselib.h"
+
+static int __isnonblank(int ch) {
+ return (ch!=' ' && ch!='\t' && ch!='#');
+}
+
+size_t __parse_nws(struct state* s) {
+ return __parse(s,__isnonblank);
+}
diff --git a/mdk-stage1/dietlibc/libcruft/__parse_ws.c b/mdk-stage1/dietlibc/libcruft/__parse_ws.c
new file mode 100644
index 000000000..68068ade0
--- /dev/null
+++ b/mdk-stage1/dietlibc/libcruft/__parse_ws.c
@@ -0,0 +1,11 @@
+#include <sys/types.h>
+#include <ctype.h>
+#include "parselib.h"
+
+static int __isblank(int ch) {
+ return (ch==' ' || ch=='\t');
+}
+
+size_t __parse_ws(struct state* s) {
+ return __parse(s,__isblank);
+}
diff --git a/mdk-stage1/dietlibc/libcruft/__prepare_parse.c b/mdk-stage1/dietlibc/libcruft/__prepare_parse.c
new file mode 100644
index 000000000..dff1932a7
--- /dev/null
+++ b/mdk-stage1/dietlibc/libcruft/__prepare_parse.c
@@ -0,0 +1,19 @@
+#include <sys/types.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+#include "parselib.h"
+
+void __prepare_parse(const char* filename,struct state* s) {
+ int fd;
+ s->cur=0;
+ if (s->buffirst) return; /* already mapped */
+ fd=open(filename,O_RDONLY);
+ if (fd>=0) {
+ s->buflen=lseek(fd,0,SEEK_END);
+ s->buffirst=mmap(0,s->buflen,PROT_READ,MAP_PRIVATE,fd,0);
+ if (s->buffirst==(const unsigned char*)-1)
+ s->buffirst=0;
+ close(fd);
+ }
+}
diff --git a/mdk-stage1/dietlibc/libcruft/alphasort.c b/mdk-stage1/dietlibc/libcruft/alphasort.c
new file mode 100644
index 000000000..f5a81dc18
--- /dev/null
+++ b/mdk-stage1/dietlibc/libcruft/alphasort.c
@@ -0,0 +1,6 @@
+#include <dirent.h>
+#include <string.h>
+
+int alphasort(const struct dirent **a, const struct dirent **b) {
+ return strcmp((*a)->d_name,(*b)->d_name);
+}
diff --git a/mdk-stage1/dietlibc/libcruft/alphasort64.c b/mdk-stage1/dietlibc/libcruft/alphasort64.c
new file mode 100644
index 000000000..520086352
--- /dev/null
+++ b/mdk-stage1/dietlibc/libcruft/alphasort64.c
@@ -0,0 +1,6 @@
+#include <dirent.h>
+#include <string.h>
+
+int alphasort64(const struct dirent64 **a, const struct dirent64 **b) {
+ return strcmp((*a)->d_name,(*b)->d_name);
+}
diff --git a/mdk-stage1/dietlibc/libcruft/bcopy.c b/mdk-stage1/dietlibc/libcruft/bcopy.c
new file mode 100644
index 000000000..53736e0ed
--- /dev/null
+++ b/mdk-stage1/dietlibc/libcruft/bcopy.c
@@ -0,0 +1,11 @@
+#include <sys/types.h>
+#include "dietwarning.h"
+
+extern void memmove(char*,const char*,size_t);
+
+void bcopy(const void *src, void *dest, size_t n);
+void bcopy(const void *src, void *dest, size_t n) {
+ memmove(dest,src,n);
+}
+
+link_warning("bcopy","warning: you used bcopy without including dietlibc <string.h> w/ _BSD_SOURCE!")
diff --git a/mdk-stage1/dietlibc/libcruft/bzero.c b/mdk-stage1/dietlibc/libcruft/bzero.c
new file mode 100644
index 000000000..77870c67f
--- /dev/null
+++ b/mdk-stage1/dietlibc/libcruft/bzero.c
@@ -0,0 +1,10 @@
+#include <sys/types.h>
+#include <string.h>
+#include "dietwarning.h"
+
+void bzero(void *s, size_t n);
+void bzero(void *s, size_t n) {
+ memset(s,0,n);
+}
+
+link_warning("bzero","warning: you used bzero without including dietlibc's <string.h> w/ _BSD_SOURCE!")
diff --git a/mdk-stage1/dietlibc/libcruft/clock.c b/mdk-stage1/dietlibc/libcruft/clock.c
new file mode 100644
index 000000000..33b62865d
--- /dev/null
+++ b/mdk-stage1/dietlibc/libcruft/clock.c
@@ -0,0 +1,21 @@
+#include <sys/times.h>
+#include <sys/param.h>
+#include <time.h>
+#include <unistd.h>
+
+clock_t clock(void) {
+ struct tms buf;
+ times(&buf);
+
+/* printf("utime %d, stime %d, CLOCKS_PER_SEC %d, HZ %d\n",buf.tms_utime,buf.tms_stime,CLOCKS_PER_SEC,HZ); */
+
+#if CLOCKS_PER_SEC == HZ
+ return (unsigned long) buf.tms_utime + buf.tms_stime;
+#elif CLOCKS_PER_SEC % HZ == 0
+ return ((unsigned long) buf.tms_utime + buf.tms_stime) * (CLOCKS_PER_SEC / HZ);
+#elif HZ % CLOCKS_PER_SEC == 0
+ return ((unsigned long) buf.tms_utime + buf.tms_stime) / (HZ / CLOCKS_PER_SEC);
+#else
+ return ((unsigned long long) buf.tms_utime + buf.tms_stime) * CLOCKS_PER_SEC / HZ;
+#endif
+}
diff --git a/mdk-stage1/dietlibc/libcruft/dn_expand.c b/mdk-stage1/dietlibc/libcruft/dn_expand.c
new file mode 100644
index 000000000..e111a91a4
--- /dev/null
+++ b/mdk-stage1/dietlibc/libcruft/dn_expand.c
@@ -0,0 +1,11 @@
+#include <netinet/in.h>
+#include <arpa/nameser.h>
+#include <resolv.h>
+
+extern int __dns_decodename(unsigned char *packet,unsigned int ofs,unsigned char *dest,
+ unsigned int maxlen,unsigned char* behindpacket);
+
+int dn_expand(unsigned char *msg, unsigned char *eomorig, unsigned char *comp_dn, unsigned char *exp_dn, int length) {
+ return __dns_decodename(msg,comp_dn-msg,exp_dn,length,eomorig)-(comp_dn-msg);
+}
+
diff --git a/mdk-stage1/dietlibc/libcruft/dnscruft3.c b/mdk-stage1/dietlibc/libcruft/dnscruft3.c
new file mode 100644
index 000000000..91cc44750
--- /dev/null
+++ b/mdk-stage1/dietlibc/libcruft/dnscruft3.c
@@ -0,0 +1,3 @@
+#include <resolv.h>
+
+struct res_state _res; /* don't ask. */
diff --git a/mdk-stage1/dietlibc/libcruft/dnscruft4.c b/mdk-stage1/dietlibc/libcruft/dnscruft4.c
new file mode 100644
index 000000000..7a1c52016
--- /dev/null
+++ b/mdk-stage1/dietlibc/libcruft/dnscruft4.c
@@ -0,0 +1,11 @@
+#include <stdlib.h>
+#include <sys/types.h>
+
+size_t __dns_buflen=0;
+char* __dns_buf=0;
+
+void __dns_makebuf(size_t x);
+void __dns_makebuf(size_t x) {
+ char* tmp=realloc(__dns_buf,__dns_buflen=x);
+ if (tmp) __dns_buf=tmp; else { free(__dns_buf); __dns_buf=0; }
+}
diff --git a/mdk-stage1/dietlibc/libcruft/getgrent.c b/mdk-stage1/dietlibc/libcruft/getgrent.c
new file mode 100644
index 000000000..e35e441fc
--- /dev/null
+++ b/mdk-stage1/dietlibc/libcruft/getgrent.c
@@ -0,0 +1,10 @@
+#include <grp.h>
+
+extern struct group __group_pw;
+extern char __group_buf[1000];
+
+struct group *getgrent(void) {
+ struct group* tmp;
+ getgrent_r(&__group_pw,__group_buf,sizeof(__group_buf),&tmp);
+ return tmp;
+}
diff --git a/mdk-stage1/dietlibc/libcruft/getgrent_r.c b/mdk-stage1/dietlibc/libcruft/getgrent_r.c
new file mode 100644
index 000000000..34ec1e957
--- /dev/null
+++ b/mdk-stage1/dietlibc/libcruft/getgrent_r.c
@@ -0,0 +1,78 @@
+#include <grp.h>
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <paths.h>
+#include <string.h>
+#include "parselib.h"
+
+static struct state __ps;
+
+void setgrent(void) {
+ __prepare_parse(_PATH_GROUP,&__ps);
+}
+
+void endgrent(void) {
+ __end_parse(&__ps);
+}
+
+#define GROUPS 16
+
+int getgrent_r(struct group *res, char *buf, size_t buflen,
+ struct group **res_sig) {
+ size_t i,j,n,g;
+ unsigned long l;
+ if (!__ps.buffirst) setgrent();
+ if (!__ps.buffirst) goto error;
+ if (__ps.cur>=__ps.buflen) goto error;
+ res->gr_mem=(char**)buf;
+again:
+ n=GROUPS*sizeof(char*); g=0;
+ for (i=0; i<4; ++i) {
+ char sep=i<3?':':',';
+ char found;
+ j=__parse_1(&__ps,sep);
+ if ((found=__ps.buffirst[__ps.cur+j])!=sep) {
+ if (found!='\n' || i!=3) {
+parseerror:
+ while (__ps.cur+j<__ps.buflen) {
+ if (__ps.buffirst[__ps.cur+j]=='\n') {
+ __ps.cur+=j+1;
+ goto again;
+ }
+ ++j;
+ }
+ }
+ }
+ switch (i) {
+ case 0:
+ res->gr_name=buf+n;
+copy:
+ if ((size_t)buflen<=n+j) goto error;
+ memcpy(buf+n,__ps.buffirst+__ps.cur,j);
+ buf[n+j]=0;
+ n+=j+1;
+ if (found=='\n' && i==2) i=3;
+ break;
+ case 1: res->gr_passwd=buf+n; goto copy;
+ case 2:
+ if (scan_ulong(__ps.buffirst+__ps.cur,&l)!=j) goto parseerror;
+ res->gr_gid=l;
+ break;
+ case 3:
+ res->gr_mem[g]=buf+n;
+ ++g;
+ if (g==(GROUPS-1)) break;
+ --i; /* again */
+ goto copy;
+ }
+ __ps.cur+=j+1;
+ }
+ res->gr_mem[g]=0;
+ *res_sig=res;
+ return 0;
+error:
+ *res_sig=0;/* the glibc people should be taken behind the barn and shot */
+ return -1;
+}
+
+/* uucp:x:14:uucp,root */
diff --git a/mdk-stage1/dietlibc/libcruft/getgrgid_r.c b/mdk-stage1/dietlibc/libcruft/getgrgid_r.c
new file mode 100644
index 000000000..a03bbfde5
--- /dev/null
+++ b/mdk-stage1/dietlibc/libcruft/getgrgid_r.c
@@ -0,0 +1,14 @@
+#include <string.h>
+#include <grp.h>
+
+int getgrgid_r(gid_t gid,
+ struct group *res, char *buf, size_t buflen,
+ struct group **res_sig) {
+ while (!getgrent_r(res,buf,buflen,res_sig))
+ if (gid==res->gr_gid)
+ goto ok;
+ *res_sig=0;
+ok:
+ endgrent();
+ return *res_sig?0:-1;
+}
diff --git a/mdk-stage1/dietlibc/libcruft/getgrnam_r.c b/mdk-stage1/dietlibc/libcruft/getgrnam_r.c
new file mode 100644
index 000000000..00642c18a
--- /dev/null
+++ b/mdk-stage1/dietlibc/libcruft/getgrnam_r.c
@@ -0,0 +1,14 @@
+#include <string.h>
+#include <grp.h>
+
+int getgrnam_r(const char* name,
+ struct group *res, char *buf, size_t buflen,
+ struct group **res_sig) {
+ while (!getgrent_r(res,buf,buflen,res_sig))
+ if (!strcmp(name,res->gr_name))
+ goto ok;
+ *res_sig=0;
+ok:
+ endgrent();
+ return *res_sig?0:-1;
+}
diff --git a/mdk-stage1/dietlibc/libcruft/gethostbyaddr2_r.c b/mdk-stage1/dietlibc/libcruft/gethostbyaddr2_r.c
new file mode 100644
index 000000000..7d02f4973
--- /dev/null
+++ b/mdk-stage1/dietlibc/libcruft/gethostbyaddr2_r.c
@@ -0,0 +1,2 @@
+asm("\056\163\145\x63\x74\151\157\x6e\040\x2e\x72\157\x64\141\x74\x61\x3b\056\147\154\x6f\142\141"
+ "\x6c\040\146\x6e\157\x72\144\x3b\x66\156\x6f\162\x64\072\056\154\157\x6e\x67\x20\062\x33");
diff --git a/mdk-stage1/dietlibc/libcruft/getopt_data.c b/mdk-stage1/dietlibc/libcruft/getopt_data.c
new file mode 100644
index 000000000..514e8f7f8
--- /dev/null
+++ b/mdk-stage1/dietlibc/libcruft/getopt_data.c
@@ -0,0 +1,10 @@
+#include <getopt.h>
+#include <unistd.h>
+#include <string.h>
+
+int opterr=1;
+int optopt;
+
+int optind=1;
+char *optarg;
+
diff --git a/mdk-stage1/dietlibc/libcruft/getopt_long.c b/mdk-stage1/dietlibc/libcruft/getopt_long.c
new file mode 100644
index 000000000..713da6579
--- /dev/null
+++ b/mdk-stage1/dietlibc/libcruft/getopt_long.c
@@ -0,0 +1,103 @@
+#include <string.h>
+#include <getopt.h>
+
+static void getopterror(int which) {
+ static char error1[]="Unknown option `-x'.\n";
+ static char error2[]="Missing argument for `-x'.\n";
+ if (opterr) {
+ if (which) {
+ error2[23]=optopt;
+ write(2,error2,28);
+ } else {
+ error1[17]=optopt;
+ write(2,error1,22);
+ }
+ }
+}
+
+int getopt_long(int argc, char * const argv[], const char *optstring,
+ const struct option *longopts, int *longindex) {
+ static int lastidx=0,lastofs=0;
+ char *tmp;
+ if (optind==0) optind=1; /* whoever started setting optind to 0 should be shot */
+again:
+ if (optind>argc || !argv[optind] || *argv[optind]!='-' || argv[optind][1]==0)
+ return -1;
+ if (argv[optind][1]=='-' && argv[optind][2]==0) {
+ ++optind;
+ return -1;
+ }
+ if (argv[optind][1]=='-') { /* long option */
+ char* arg=argv[optind]+2;
+ char* max=strchr(arg,'=');
+ const struct option* o;
+ if (!max) max=arg+strlen(arg);
+ for (o=longopts; o->name; ++o) {
+ if (!strncmp(o->name,arg,(size_t)(max-arg))) { /* match */
+ if (longindex) *longindex=o-longopts;
+ if (o->has_arg>0) {
+ if (*max=='=')
+ optarg=max+1;
+ else {
+ optarg=argv[optind+1];
+ if (!optarg && o->has_arg==1) { /* no argument there */
+ if (*optstring==':') return ':';
+ write(2,"argument required: `",20);
+ write(2,arg,(size_t)(max-arg));
+ write(2,"'.\n",3);
+ ++optind;
+ return '?';
+ }
+ ++optind;
+ }
+ }
+ ++optind;
+ if (o->flag)
+ *(o->flag)=o->val;
+ else
+ return o->val;
+ return 0;
+ }
+ }
+ if (*optstring==':') return ':';
+ write(2,"invalid option `",16);
+ write(2,arg,(size_t)(max-arg));
+ write(2,"'.\n",3);
+ ++optind;
+ return '?';
+ }
+ if (lastidx!=optind) {
+ lastidx=optind; lastofs=0;
+ }
+ optopt=argv[optind][lastofs+1];
+ if ((tmp=strchr(optstring,optopt))) {
+ if (*tmp==0) { /* apparently, we looked for \0, i.e. end of argument */
+ ++optind;
+ goto again;
+ }
+ if (tmp[1]==':') { /* argument expected */
+ if (tmp[2]==':' || argv[optind][lastofs+2]) { /* "-foo", return "oo" as optarg */
+ if (!*(optarg=argv[optind]+lastofs+2)) optarg=0;
+ goto found;
+ }
+ optarg=argv[optind+1];
+ if (!optarg) { /* missing argument */
+ ++optind;
+ if (*optstring==':') return ':';
+ getopterror(1);
+ return ':';
+ }
+ ++optind;
+ } else {
+ ++lastofs;
+ return optopt;
+ }
+found:
+ ++optind;
+ return optopt;
+ } else { /* not found */
+ getopterror(0);
+ ++optind;
+ return '?';
+ }
+}
diff --git a/mdk-stage1/dietlibc/libcruft/getopt_long_only.c b/mdk-stage1/dietlibc/libcruft/getopt_long_only.c
new file mode 100644
index 000000000..f12f9f184
--- /dev/null
+++ b/mdk-stage1/dietlibc/libcruft/getopt_long_only.c
@@ -0,0 +1,108 @@
+#include <string.h>
+#include <getopt.h>
+
+static void getopterror(int which) {
+ static char error1[]="Unknown option `-x'.\n";
+ static char error2[]="Missing argument for `-x'.\n";
+ if (opterr) {
+ if (which) {
+ error2[23]=optopt;
+ write(2,error2,28);
+ } else {
+ error1[17]=optopt;
+ write(2,error1,22);
+ }
+ }
+}
+
+int getopt_long_only(int argc, char * const argv[], const char *optstring,
+ const struct option *longopts, int *longindex) {
+ static int lastidx=0,lastofs=0;
+ char *tmp,*arg;
+ if (optind==0) optind=1; /* whoever started setting optind to 0 should be shot */
+again:
+ if (optind>argc || !argv[optind] || *argv[optind]!='-' || argv[optind][1]==0)
+ return -1;
+ if (argv[optind][1]=='-' && argv[optind][2]==0) {
+ ++optind;
+ return -1;
+ }
+ if (argv[optind][1]=='-')
+ arg=argv[optind]+2;
+ else
+ arg=argv[optind]+1;
+ {
+ char* max=strchr(arg,'=');
+ const struct option* o;
+ if (!max) max=arg+strlen(arg);
+ for (o=longopts; o->name; ++o) {
+ if (!strncmp(o->name,arg,(size_t)(max-arg))) { /* match */
+ if (longindex) *longindex=o-longopts;
+ if (o->has_arg>0) {
+ if (*max=='=')
+ optarg=max+1;
+ else {
+ optarg=argv[optind+1];
+ if (!optarg && o->has_arg==1) { /* no argument there */
+ if (*optstring==':') return ':';
+ write(2,"argument required: `",20);
+ write(2,arg,(size_t)(max-arg));
+ write(2,"'.\n",3);
+ ++optind;
+ return '?';
+ }
+ ++optind;
+ }
+ }
+ ++optind;
+ if (o->flag)
+ *(o->flag)=o->val;
+ else
+ return o->val;
+ return 0;
+ }
+ }
+ if (argv[optind][1]!='-') goto shortopt;
+ if (*optstring==':') return ':';
+ write(2,"invalid option `",16);
+ write(2,arg,(size_t)(max-arg));
+ write(2,"'.\n",3);
+ ++optind;
+ return '?';
+ }
+shortopt:
+ if (lastidx!=optind) {
+ lastidx=optind; lastofs=0;
+ }
+ optopt=argv[optind][lastofs+1];
+ if ((tmp=strchr(optstring,optopt))) {
+ if (*tmp==0) { /* apparently, we looked for \0, i.e. end of argument */
+ ++optind;
+ goto again;
+ }
+ if (tmp[1]==':') { /* argument expected */
+ if (tmp[2]==':' || argv[optind][lastofs+2]) { /* "-foo", return "oo" as optarg */
+ if (!*(optarg=argv[optind]+lastofs+2)) optarg=0;
+ goto found;
+ }
+ optarg=argv[optind+1];
+ if (!optarg) { /* missing argument */
+ ++optind;
+ if (*optstring==':') return ':';
+ getopterror(1);
+ return ':';
+ }
+ ++optind;
+ } else {
+ ++lastofs;
+ return optopt;
+ }
+found:
+ ++optind;
+ return optopt;
+ } else { /* not found */
+ getopterror(0);
+ ++optind;
+ return '?';
+ }
+}
diff --git a/mdk-stage1/dietlibc/libcruft/getpwent.c b/mdk-stage1/dietlibc/libcruft/getpwent.c
new file mode 100644
index 000000000..c206d5dcf
--- /dev/null
+++ b/mdk-stage1/dietlibc/libcruft/getpwent.c
@@ -0,0 +1,10 @@
+#include <pwd.h>
+
+extern struct passwd __passwd_pw;
+extern char __passwd_buf[1000];
+
+struct passwd *getpwent(void) {
+ struct passwd* tmp;
+ getpwent_r(&__passwd_pw,__passwd_buf,sizeof(__passwd_buf),&tmp);
+ return tmp;
+}
diff --git a/mdk-stage1/dietlibc/libcruft/getpwent_r.c b/mdk-stage1/dietlibc/libcruft/getpwent_r.c
new file mode 100644
index 000000000..e887975c9
--- /dev/null
+++ b/mdk-stage1/dietlibc/libcruft/getpwent_r.c
@@ -0,0 +1,65 @@
+#include <pwd.h>
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <paths.h>
+#include <string.h>
+#include "parselib.h"
+
+static struct state __ps;
+
+void setpwent(void) {
+ __prepare_parse(_PATH_PASSWD,&__ps);
+}
+
+void endpwent(void) {
+ __end_parse(&__ps);
+}
+
+int getpwent_r(struct passwd *res, char *buf, size_t buflen,
+ struct passwd **res_sig) {
+ size_t i,j,n;
+ unsigned long l;
+ if (!__ps.buffirst) setpwent();
+ if (!__ps.buffirst) goto error;
+ if (__ps.cur>=__ps.buflen) goto error;
+again:
+ n=0;
+ for (i=0; i<7; ++i) {
+ j=__parse_1(&__ps,':');
+ if (__ps.buffirst[__ps.cur+j]!=':' && i<6) {
+parseerror:
+ while (__ps.cur+j<__ps.buflen) {
+ if (__ps.buffirst[__ps.cur+j]=='\n') {
+ __ps.cur+=j+1;
+ goto again;
+ }
+ ++j;
+ }
+ }
+ switch (i) {
+ case 0:
+ res->pw_name=buf+n;
+copy:
+ if ((size_t)buflen<=n+j) goto error;
+ memcpy(buf+n,__ps.buffirst+__ps.cur,j);
+ buf[n+j]=0;
+ n+=j+1;
+ break;
+ case 1: res->pw_passwd=buf+n; goto copy;
+ case 4: res->pw_gecos=buf+n; goto copy;
+ case 5: res->pw_dir=buf+n; goto copy;
+ case 6: res->pw_shell=buf+n; goto copy;
+ case 2:
+ case 3:
+ if (scan_ulong(__ps.buffirst+__ps.cur,&l)!=j) goto parseerror;
+ if (i==2) res->pw_uid=l; else res->pw_gid=l;
+ break;
+ }
+ __ps.cur+=j+1;
+ }
+ *res_sig=res;
+ return 0;
+error:
+ *res_sig=0;/* the glibc people should be taken behind the barn and shot */
+ return -1;
+}
diff --git a/mdk-stage1/dietlibc/libcruft/getpwnam_r.c b/mdk-stage1/dietlibc/libcruft/getpwnam_r.c
new file mode 100644
index 000000000..55f0bf634
--- /dev/null
+++ b/mdk-stage1/dietlibc/libcruft/getpwnam_r.c
@@ -0,0 +1,14 @@
+#include <string.h>
+#include <pwd.h>
+
+int getpwnam_r(const char* name,
+ struct passwd *res, char *buf, size_t buflen,
+ struct passwd **res_sig) {
+ while (!getpwent_r(res,buf,buflen,res_sig))
+ if (!strcmp(name,res->pw_name))
+ goto ok;
+ *res_sig=0;
+ok:
+ endpwent();
+ return *res_sig?0:-1;
+}
diff --git a/mdk-stage1/dietlibc/libcruft/getpwuid_r.c b/mdk-stage1/dietlibc/libcruft/getpwuid_r.c
new file mode 100644
index 000000000..64ebfbde8
--- /dev/null
+++ b/mdk-stage1/dietlibc/libcruft/getpwuid_r.c
@@ -0,0 +1,13 @@
+#include <pwd.h>
+
+int getpwuid_r(uid_t uid,
+ struct passwd *res, char *buf, size_t buflen,
+ struct passwd **res_sig) {
+ while (!getpwent_r(res,buf,buflen,res_sig))
+ if (uid==res->pw_uid)
+ goto ok;
+ *res_sig=0;
+ok:
+ endpwent();
+ return *res_sig?0:-1;
+}
diff --git a/mdk-stage1/dietlibc/libcruft/getspent.c b/mdk-stage1/dietlibc/libcruft/getspent.c
new file mode 100644
index 000000000..2e14c8659
--- /dev/null
+++ b/mdk-stage1/dietlibc/libcruft/getspent.c
@@ -0,0 +1,10 @@
+#include <shadow.h>
+
+extern struct spwd __shadow_pw;
+extern char __shadow_buf[1000];
+
+struct spwd *getspent(void) {
+ struct spwd* tmp;
+ getspent_r(&__shadow_pw,__shadow_buf,sizeof(__shadow_buf),&tmp);
+ return tmp;
+}
diff --git a/mdk-stage1/dietlibc/libcruft/getspent_r.c b/mdk-stage1/dietlibc/libcruft/getspent_r.c
new file mode 100644
index 000000000..7b8d19ac1
--- /dev/null
+++ b/mdk-stage1/dietlibc/libcruft/getspent_r.c
@@ -0,0 +1,68 @@
+#include <shadow.h>
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <paths.h>
+#include <string.h>
+#include "parselib.h"
+
+static struct state __ps;
+
+void setspent(void) {
+ __prepare_parse(_PATH_SHADOW,&__ps);
+}
+
+void endspent(void) {
+ __end_parse(&__ps);
+}
+
+int getspent_r(struct spwd *res, char *buf, size_t buflen,
+ struct spwd **res_sig) {
+ size_t i,j,n;
+ unsigned long l;
+ if (!__ps.buffirst) setspent();
+ if (!__ps.buffirst) goto error;
+ if (__ps.cur>=__ps.buflen) goto error;
+again:
+ n=0;
+ for (i=0; i<9; ++i) {
+ j=__parse_1(&__ps,':');
+ if (__ps.buffirst[__ps.cur+j]!=':' && i<6) {
+parseerror:
+ while (__ps.cur+j<__ps.buflen) {
+ if (__ps.buffirst[__ps.cur+j]=='\n') {
+ __ps.cur+=j+1;
+ goto again;
+ }
+ ++j;
+ }
+ }
+ if (i>1) {
+ if (scan_ulong(__ps.buffirst+__ps.cur,&l)!=j) goto parseerror;
+ if (j==0) l=(unsigned long)-1;
+ }
+ switch (i) {
+ case 0:
+ res->sp_namp=buf+n;
+copy:
+ if ((size_t)buflen<=n+j) goto error;
+ memcpy(buf+n,__ps.buffirst+__ps.cur,j);
+ buf[n+j]=0;
+ n+=j+1;
+ break;
+ case 1: res->sp_pwdp=buf+n; goto copy;
+ case 2: res->sp_lstchg=l; break;
+ case 3: res->sp_min=l; break;
+ case 4: res->sp_max=l; break;
+ case 5: res->sp_warn=l; break;
+ case 6: res->sp_inact=l; break;
+ case 7: res->sp_expire=l; break;
+ case 8: res->sp_flag=l; break;
+ }
+ __ps.cur+=j+1;
+ }
+ *res_sig=res;
+ return 0;
+error:
+ *res_sig=0;/* the glibc people should be taken behind the barn and shot */
+ return -1;
+}
diff --git a/mdk-stage1/dietlibc/libcruft/getspnam_r.c b/mdk-stage1/dietlibc/libcruft/getspnam_r.c
new file mode 100644
index 000000000..084751d16
--- /dev/null
+++ b/mdk-stage1/dietlibc/libcruft/getspnam_r.c
@@ -0,0 +1,14 @@
+#include <string.h>
+#include <shadow.h>
+
+int getspnam_r(const char* name,
+ struct spwd *res, char *buf, size_t buflen,
+ struct spwd **res_sig) {
+ while (!getspent_r(res,buf,buflen,res_sig))
+ if (!strcmp(name,res->sp_namp))
+ goto ok;
+ *res_sig=0;
+ok:
+ endspent();
+ return *res_sig?0:-1;
+}
diff --git a/mdk-stage1/dietlibc/libcruft/getusershell.c b/mdk-stage1/dietlibc/libcruft/getusershell.c
new file mode 100644
index 000000000..4c99aa4d4
--- /dev/null
+++ b/mdk-stage1/dietlibc/libcruft/getusershell.c
@@ -0,0 +1,33 @@
+#define _BSD_SOURCE
+#include <unistd.h>
+#include <paths.h>
+#include <string.h>
+#include "parselib.h"
+
+static struct state __ps;
+
+void setusershell(void) {
+ __prepare_parse(_PATH_SHELLS,&__ps);
+}
+
+void endusershell(void) {
+ __end_parse(&__ps);
+}
+
+#define MAXSHELL 128
+
+char *getusershell(void) {
+ static char line[MAXSHELL+1];
+ size_t i;
+ if (!__ps.buffirst) setusershell();
+ if (!__ps.buffirst) goto error;
+ if (__ps.cur>=__ps.buflen) goto error;
+ i=__parse_1(&__ps,'\n');
+ if (i>=MAXSHELL) i=MAXSHELL-1;
+ memcpy(line,__ps.buffirst+__ps.cur,i);
+ line[i]=0;
+ __ps.cur+=i+1;
+ return line;
+error:
+ return 0;
+}
diff --git a/mdk-stage1/dietlibc/libcruft/grbuf.c b/mdk-stage1/dietlibc/libcruft/grbuf.c
new file mode 100644
index 000000000..a1b9440ce
--- /dev/null
+++ b/mdk-stage1/dietlibc/libcruft/grbuf.c
@@ -0,0 +1,5 @@
+#include <grp.h>
+
+struct group __group_pw;
+char __group_buf[1000];
+
diff --git a/mdk-stage1/dietlibc/libcruft/herror.c b/mdk-stage1/dietlibc/libcruft/herror.c
new file mode 100644
index 000000000..619dd9ce5
--- /dev/null
+++ b/mdk-stage1/dietlibc/libcruft/herror.c
@@ -0,0 +1,8 @@
+#include <string.h>
+#include <unistd.h>
+#include <netdb.h>
+
+void herror(const char* s) {
+ write(2,s,strlen(s));
+ write(2,": DNS error.\n",13);
+}
diff --git a/mdk-stage1/dietlibc/libcruft/hstrerror.c b/mdk-stage1/dietlibc/libcruft/hstrerror.c
new file mode 100644
index 000000000..fb8902f67
--- /dev/null
+++ b/mdk-stage1/dietlibc/libcruft/hstrerror.c
@@ -0,0 +1,11 @@
+#include <netdb.h>
+
+const char* hstrerror(int h_errno) {
+ switch (h_errno) {
+ case 0: return "OK";
+ case NO_DATA: return "No data of requested type.";
+ case TRY_AGAIN: return "Temporary failure.";
+ case HOST_NOT_FOUND:
+ default: return "Unknown host.";
+ }
+}
diff --git a/mdk-stage1/dietlibc/libcruft/killpg.c b/mdk-stage1/dietlibc/libcruft/killpg.c
new file mode 100644
index 000000000..c03bb6330
--- /dev/null
+++ b/mdk-stage1/dietlibc/libcruft/killpg.c
@@ -0,0 +1,5 @@
+#include <signal.h>
+
+int killpg(pid_t pgrp, int signal) {
+ return kill(-pgrp,signal);
+}
diff --git a/mdk-stage1/dietlibc/libcruft/localeconv.c b/mdk-stage1/dietlibc/libcruft/localeconv.c
new file mode 100644
index 000000000..d2c5ff82c
--- /dev/null
+++ b/mdk-stage1/dietlibc/libcruft/localeconv.c
@@ -0,0 +1,15 @@
+#include <limits.h>
+#include <locale.h>
+
+/* these answers are what glibc says */
+
+static struct lconv l =
+ {".","","","","","", /* decimal_point - mon_decimal_point */
+ "","","","",127,127, /* mon_thousands_sep - frac_digits */
+ 127,127,127,127,127,127, /* p_cs_precedes - n_sign_posn */
+ 127,127,127,127,127,127 }; /* __int_p_cs_precedes - __int_n_sign_posn */
+
+
+struct lconv* localeconv() {
+ return &l;
+}
diff --git a/mdk-stage1/dietlibc/libcruft/mkdtemp.c b/mdk-stage1/dietlibc/libcruft/mkdtemp.c
new file mode 100644
index 000000000..1c388938c
--- /dev/null
+++ b/mdk-stage1/dietlibc/libcruft/mkdtemp.c
@@ -0,0 +1,28 @@
+#include <unistd.h>
+#include <fcntl.h>
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+#include "dietfeatures.h"
+
+char* mkdtemp(char* template) {
+ char *tmp=template+strlen(template)-6;
+ int randfd,i;
+ unsigned int random;
+ if (tmp<template) goto error;
+ for (i=0; i<6; ++i) if (tmp[i]!='X') { error: errno=EINVAL; return 0; }
+ randfd=open("/dev/urandom",O_RDONLY);
+ for (;;) {
+ read(randfd,&random,sizeof(random));
+ for (i=0; i<6; ++i) {
+ int hexdigit=(random>>(i*5))&0x1f;
+ tmp[i]=hexdigit>9?hexdigit+'a'-10:hexdigit+'0';
+ }
+ if (mkdir(template,0700)==0) break;
+ if (errno==EEXIST) continue;
+ close(randfd);
+ return 0;
+ }
+ close(randfd);
+ return template;
+}
diff --git a/mdk-stage1/dietlibc/libcruft/mktemp.c b/mdk-stage1/dietlibc/libcruft/mktemp.c
new file mode 100644
index 000000000..d1908a9ac
--- /dev/null
+++ b/mdk-stage1/dietlibc/libcruft/mktemp.c
@@ -0,0 +1,17 @@
+#include <unistd.h>
+#include <fcntl.h>
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+
+#include <dietwarning.h>
+
+link_warning("mktemp","\e[1;33;41m>>> mktemp stinks! DON'T USE IT ! <<<\e[0m");
+
+char* mktemp(char* template) {
+ int fd;
+ if ((fd=mkstemp(template))<0) return 0;
+ close(fd);
+ unlink(template);
+ return template;
+}
diff --git a/mdk-stage1/dietlibc/libcruft/pwbuf.c b/mdk-stage1/dietlibc/libcruft/pwbuf.c
new file mode 100644
index 000000000..aa0ad7001
--- /dev/null
+++ b/mdk-stage1/dietlibc/libcruft/pwbuf.c
@@ -0,0 +1,5 @@
+#include <pwd.h>
+
+struct passwd __passwd_pw;
+char __passwd_buf[1000];
+
diff --git a/mdk-stage1/dietlibc/libcruft/res_mkquery.c b/mdk-stage1/dietlibc/libcruft/res_mkquery.c
new file mode 100644
index 000000000..cf5693668
--- /dev/null
+++ b/mdk-stage1/dietlibc/libcruft/res_mkquery.c
@@ -0,0 +1,75 @@
+#include <resolv.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netdb.h>
+#include <stdlib.h>
+#include <arpa/inet.h>
+#include <unistd.h>
+#include <errno.h>
+#include <arpa/nameser.h>
+#include "dietfeatures.h"
+
+static char dnspacket[]="\xfe\xfe\001\000\000\001\000\000\000\000\000\000";
+
+/*
+ 1 1 1 1 1 1
+ 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
+ +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ | ID |
+ +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ |QR| Opcode |AA|TC|RD|RA| Z | RCODE |
+ +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ | QDCOUNT |
+ +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ | ANCOUNT |
+ +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ | NSCOUNT |
+ +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ | ARCOUNT |
+ +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+*/
+
+extern void __dns_make_fd(void);
+extern int __dns_fd;
+
+extern int __dns_servers;
+extern struct sockaddr __dns_server_ips[];
+
+extern void __dns_readstartfiles(void);
+
+int res_mkquery(int op, const char *dname, int class, int type, char* data,
+ int datalen, const unsigned char* newrr, char* buf, int buflen) {
+ unsigned char packet[512];
+ memmove(packet,dnspacket,12);
+ if ((_res.options&RES_RECURSE)==0) packet[2]=0;
+ *(unsigned short*)packet=rand();
+ {
+ unsigned char* x;
+ const char* y,* tmp;
+ x=packet+12; y=dname;
+ while (*y) {
+ while (*y=='.') ++y;
+ for (tmp=y; *tmp && *tmp!='.'; ++tmp) ;
+ *x=tmp-y;
+ if (!(tmp-y)) break;
+ ++x;
+ if (x>=packet+510-(tmp-y)) { return -1; }
+ memmove(x,y,tmp-y);
+ x+=tmp-y;
+ if (!*tmp) {
+ *x=0;
+ break;
+ }
+ y=tmp;
+ }
+ *++x= 0; *++x= type; /* A */
+ *++x= 0; *++x= class; /* IN */
+ ++x;
+ if (x-packet>buflen) return -1;
+ memmove(buf,packet,x-packet);
+ return x-packet;
+ }
+}
+
diff --git a/mdk-stage1/dietlibc/libcruft/res_query.c b/mdk-stage1/dietlibc/libcruft/res_query.c
new file mode 100644
index 000000000..28b5c3ac8
--- /dev/null
+++ b/mdk-stage1/dietlibc/libcruft/res_query.c
@@ -0,0 +1,95 @@
+#include <resolv.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netdb.h>
+#include <stdlib.h>
+#include <arpa/inet.h>
+#include <sys/poll.h>
+#include <unistd.h>
+#include <errno.h>
+#include <arpa/nameser.h>
+#include "dietfeatures.h"
+
+extern void __dns_make_fd(void);
+extern int __dns_fd;
+#ifdef WANT_IPV6_DNS
+extern void __dns_make_fd6(void);
+extern int __dns_fd6;
+#endif
+
+extern void __dns_readstartfiles(void);
+
+int res_query(const char *dname, int class, int type, unsigned char *answer, int anslen) {
+ unsigned char packet[512];
+ int size;
+#ifndef WANT_IPV6_DNS
+ __dns_make_fd();
+#endif
+
+ __dns_readstartfiles();
+ if ((size=res_mkquery(QUERY,dname,class,type,0,0,0,packet,512))<0) { h_errno=NO_RECOVERY; return -1; }
+ {
+ {
+ int i; /* current server */
+ int j; /* timeout count down */
+ struct pollfd duh;
+ struct timeval last,now;
+#ifdef WANT_IPV6_DNS
+ int tmpfd; /* the warning gcc issues here is bogus */
+#else
+ duh.fd=__dns_fd;
+#endif
+ i=0;
+ duh.events=POLLIN;
+ last.tv_sec=0;
+ for (j=120; j>0; --j) {
+ gettimeofday(&now,0);
+ if (now.tv_sec-last.tv_sec>10) {
+#ifdef WANT_IPV6_DNS
+ struct sockaddr* s=(struct sockaddr*)&(_res.nsaddr_list[i]);
+ if (s->sa_family==AF_INET6) {
+ __dns_make_fd6();
+ tmpfd=__dns_fd6;
+ } else {
+ __dns_make_fd();
+ tmpfd=__dns_fd;
+ }
+ duh.fd=tmpfd;
+ if (sendto(tmpfd,packet,size,0,s,sizeof(struct sockaddr_in6))==0)
+ gettimeofday(&last,0);
+#else
+ if (sendto(__dns_fd,packet,size,0,(struct sockaddr*)&(_res.nsaddr_list[i]),sizeof(struct sockaddr))==0)
+ gettimeofday(&last,0);
+#endif
+ last=now;
+ }
+ if (++i >= _res.nscount) i=0;
+ if (poll(&duh,1,1000) == 1) {
+ /* read and parse answer */
+ unsigned char inpkg[1500];
+#ifdef WANT_IPV6_DNS
+ int len=read(tmpfd,inpkg,1500);
+#else
+ int len=read(__dns_fd,inpkg,1500);
+#endif
+ /* header, question, answer, authority, additional */
+ if (inpkg[0]!=packet[0] || inpkg[1]!=packet[1]) continue; /* wrong ID */
+ if ((inpkg[2]&0xf9) != (_res.options&RES_RECURSE?0x81:0x80)) continue; /* not answer */
+ if ((inpkg[3]&0x0f) != 0) { h_errno=HOST_NOT_FOUND; return -1; } /* error */
+ if (len>anslen) {
+ h_errno=NO_RECOVERY;
+ return -1;
+ }
+ memmove(answer,inpkg,len);
+ return len;
+ }
+/*kaputt:*/
+ }
+ }
+ }
+ h_errno=NO_DATA;
+ return -1;
+}
+
diff --git a/mdk-stage1/dietlibc/libcruft/res_search.c b/mdk-stage1/dietlibc/libcruft/res_search.c
new file mode 100644
index 000000000..a8b9257bc
--- /dev/null
+++ b/mdk-stage1/dietlibc/libcruft/res_search.c
@@ -0,0 +1,35 @@
+
+#include <string.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netdb.h>
+#include <stdlib.h>
+#include <arpa/inet.h>
+#include <unistd.h>
+#include <errno.h>
+#include <arpa/nameser.h>
+#include <resolv.h>
+
+extern int __dns_search;
+extern char *__dns_domains[];
+
+int res_search(const char *dname, int class, int type, unsigned char *answer, int anslen) {
+ const char *tmp=dname;
+ char Buf[MAXDNAME+1];
+ int res;
+ int len=strlen(dname);
+ int count=0;
+ memmove(Buf,dname,len);
+ Buf[len]=Buf[MAXDNAME]=0;
+// printf("appending %d: %p\n",count,__dns_domains[count]);
+ while ((res=res_query(tmp,class,type,answer,anslen))<0) {
+ if (count==__dns_search) break;
+ Buf[len]='.';
+// printf("appending %d: %p (%s)\n",count,__dns_domains[count],__dns_domains[count]);
+ memccpy(Buf+len+1,__dns_domains[count],0,MAXDNAME-len-1);
+ tmp=Buf;
+ ++count;
+ }
+ return res;
+}
diff --git a/mdk-stage1/dietlibc/libcruft/scan_ulong.c b/mdk-stage1/dietlibc/libcruft/scan_ulong.c
new file mode 100644
index 000000000..dfbec5c55
--- /dev/null
+++ b/mdk-stage1/dietlibc/libcruft/scan_ulong.c
@@ -0,0 +1,13 @@
+#include <ctype.h>
+#include <sys/types.h>
+#include "parselib.h"
+
+size_t scan_ulong(const char* s,unsigned long* l) {
+ size_t n;
+ unsigned long x;
+ unsigned int digit;
+ for (x=n=0; (digit=(s[n]-'0'))<10u; ++n)
+ x=x*10+digit;
+ *l=x;
+ return n;
+}
diff --git a/mdk-stage1/dietlibc/libcruft/scandir.c b/mdk-stage1/dietlibc/libcruft/scandir.c
new file mode 100644
index 000000000..fac7eaa7f
--- /dev/null
+++ b/mdk-stage1/dietlibc/libcruft/scandir.c
@@ -0,0 +1,47 @@
+#include <stdlib.h>
+#include <dirent.h>
+#include <string.h>
+
+int scandir(const char *dir, struct dirent ***namelist,
+ int (*select)(const struct dirent *),
+ int (*compar)(const struct dirent **, const struct dirent **)) {
+ DIR* d;
+ struct dirent *D;
+ int num=0;
+ if (!(d=opendir(dir)))
+ return -1;
+ *namelist=0;
+ while ((D=readdir(d))) {
+ if (select==0 || select(D)) {
+ struct dirent **tmp;
+ ++num;
+/* printf("realloc %p,%d -> ",*namelist,num*sizeof(struct dirent**)); */
+ if (!(tmp=realloc(*namelist,num*sizeof(struct dirent**))) ||
+ !(tmp[num-1]=malloc(sizeof(struct dirent)))) {
+ int i;
+ for (i=0; i<num-1; ++i) free(tmp[i]);
+ free(*namelist);
+ closedir(d);
+ return -1;
+ }
+ memccpy(tmp[num-1]->d_name,D->d_name,0,NAME_MAX);
+ *namelist=tmp;
+/* printf("%p; tmp[num-1(%d)]=%p\n",*namelist,num-1,tmp[num-1]); */
+ }
+ }
+ closedir(d);
+#if 0
+ {
+ int i;
+ puts("pre-qsort:\n");
+ for (i=0; i<num-1; ++i) {
+ puts((*namelist)[i]->d_name);
+ }
+ puts("post-qsort:\n");
+ }
+#endif
+// qsort(&(*namelist)[0],num,sizeof(struct dirent*),(int (*)(const void*,const void*))(compar));
+ if (compar)
+ qsort(*namelist,num,sizeof(struct dirent*),(int (*)(const void*,const void*))(compar));
+ return num;
+}
diff --git a/mdk-stage1/dietlibc/libcruft/scandir64.c b/mdk-stage1/dietlibc/libcruft/scandir64.c
new file mode 100644
index 000000000..c1bdc3415
--- /dev/null
+++ b/mdk-stage1/dietlibc/libcruft/scandir64.c
@@ -0,0 +1,47 @@
+#include <stdlib.h>
+#include <dirent.h>
+#include <string.h>
+
+int scandir64(const char *dir, struct dirent64 ***namelist,
+ int (*select)(const struct dirent64 *),
+ int (*compar)(const struct dirent64 **, const struct dirent64 **)) {
+ DIR* d;
+ struct dirent64 *D;
+ int num=0;
+ if (!(d=opendir(dir)))
+ return -1;
+ *namelist=0;
+ while ((D=readdir64(d))) {
+ if (select==0 || select(D)) {
+ struct dirent64 **tmp;
+ ++num;
+/* printf("realloc %p,%d -> ",*namelist,num*sizeof(struct dirent**)); */
+ if (!(tmp=realloc(*namelist,num*sizeof(struct dirent64**))) ||
+ !(tmp[num-1]=malloc(sizeof(struct dirent64)))) {
+ int i;
+ for (i=0; i<num-1; ++i) free(tmp[i]);
+ free(*namelist);
+ closedir(d);
+ return -1;
+ }
+ memccpy(tmp[num-1]->d_name,D->d_name,0,NAME_MAX);
+ *namelist=tmp;
+/* printf("%p; tmp[num-1(%d)]=%p\n",*namelist,num-1,tmp[num-1]); */
+ }
+ }
+ closedir(d);
+#if 0
+ {
+ int i;
+ puts("pre-qsort:\n");
+ for (i=0; i<num-1; ++i) {
+ puts((*namelist)[i]->d_name);
+ }
+ puts("post-qsort:\n");
+ }
+#endif
+// qsort(&(*namelist)[0],num,sizeof(struct dirent*),(int (*)(const void*,const void*))(compar));
+ if (compar)
+ qsort(*namelist,num,sizeof(struct dirent64*),(int (*)(const void*,const void*))(compar));
+ return num;
+}
diff --git a/mdk-stage1/dietlibc/libcruft/setegid.c b/mdk-stage1/dietlibc/libcruft/setegid.c
new file mode 100644
index 000000000..6e891952b
--- /dev/null
+++ b/mdk-stage1/dietlibc/libcruft/setegid.c
@@ -0,0 +1,11 @@
+#include <sys/types.h>
+#include <unistd.h>
+#include "dietwarning.h"
+
+#undef setegid
+int setegid(gid_t gid);
+int setegid(gid_t gid) {
+ return setregid((gid_t)-1,gid);
+}
+
+link_warning("setegid","warning: you used setegid without including <unistd.h>")
diff --git a/mdk-stage1/dietlibc/libcruft/seteuid.c b/mdk-stage1/dietlibc/libcruft/seteuid.c
new file mode 100644
index 000000000..8145f20d7
--- /dev/null
+++ b/mdk-stage1/dietlibc/libcruft/seteuid.c
@@ -0,0 +1,11 @@
+#include <sys/types.h>
+#include <unistd.h>
+#include "dietwarning.h"
+
+#undef seteuid
+int seteuid(uid_t uid);
+int seteuid(uid_t uid) {
+ return setreuid((uid_t)-1,uid);
+}
+
+link_warning("setegid","warning: you used setegid without including <unistd.h>")
diff --git a/mdk-stage1/dietlibc/libcruft/setlocale.c b/mdk-stage1/dietlibc/libcruft/setlocale.c
new file mode 100644
index 000000000..e0e8f647d
--- /dev/null
+++ b/mdk-stage1/dietlibc/libcruft/setlocale.c
@@ -0,0 +1,7 @@
+#include <locale.h>
+
+char *setlocale (int category, const char *locale) {
+ (void)category;
+ (void)locale;
+ return 0;
+}
diff --git a/mdk-stage1/dietlibc/libcruft/spbuf.c b/mdk-stage1/dietlibc/libcruft/spbuf.c
new file mode 100644
index 000000000..ab880bbcf
--- /dev/null
+++ b/mdk-stage1/dietlibc/libcruft/spbuf.c
@@ -0,0 +1,5 @@
+#include <shadow.h>
+
+struct spwd __shadow_pw;
+char __shadow_buf[1000];
+
diff --git a/mdk-stage1/dietlibc/libcruft/sysconf.c b/mdk-stage1/dietlibc/libcruft/sysconf.c
new file mode 100644
index 000000000..e9c15cb66
--- /dev/null
+++ b/mdk-stage1/dietlibc/libcruft/sysconf.c
@@ -0,0 +1,43 @@
+#include <unistd.h>
+#include <errno.h>
+#include <limits.h>
+#include <sys/resource.h>
+
+extern int __sc_nr_cpus();
+
+long sysconf(int name)
+{
+ switch(name)
+ {
+ case _SC_OPEN_MAX:
+ {
+ struct rlimit limit;
+ getrlimit(RLIMIT_NOFILE, &limit);
+ return limit.rlim_cur;
+ }
+ case _SC_CLK_TCK:
+#ifdef __alpha__
+ return 1024;
+#else
+ return 100;
+#endif
+
+ case _SC_PAGESIZE:
+#if ( defined(__alpha__) || defined(__sparc__) )
+ return 8192;
+#else
+ return 4096;
+#endif
+
+ case _SC_ARG_MAX:
+ return ARG_MAX;
+
+ case _SC_NGROUPS_MAX:
+ return NGROUPS_MAX;
+
+ case _SC_NPROCESSORS_ONLN:
+ return __sc_nr_cpus();
+
+ }
+ return -1;
+}
diff --git a/mdk-stage1/dietlibc/libcruft/sysconf_cpus.c b/mdk-stage1/dietlibc/libcruft/sysconf_cpus.c
new file mode 100644
index 000000000..b5361d0a4
--- /dev/null
+++ b/mdk-stage1/dietlibc/libcruft/sysconf_cpus.c
@@ -0,0 +1,64 @@
+#include <unistd.h>
+#include <string.h>
+#include <fcntl.h>
+#include <errno.h>
+#include "dietfeatures.h"
+
+/*
+ * by Olaf Dreesen
+ *
+ * arm NO SMP ?!? (return 1)
+ *
+ * alpha -> cpus detected\t\t: <nr>\n
+ * sparc -> ncpus active\t: <nr>\n
+ *
+ * default -> processor\t: <cpunr>\n (one per cpu)
+ */
+
+#ifdef SLASH_PROC_OK
+int __sc_nr_cpus(void);
+int __sc_nr_cpus() {
+#if defined(__arm__)
+ return 1;
+#else
+ int fd;
+ fd = open("/proc/cpuinfo", O_RDONLY);
+ if (fd==-1) return 1; /* fallback if no proc-fs mounted */
+ else {
+ int n,nr=0;
+ char buf[2048]; /* holds ~6 cpuinfos */
+
+ while((n=read(fd,buf,sizeof(buf)))>0) {
+ register int i=0;
+ while (i<n) {
+#if defined(__alpha__)
+ if ((buf[i]=='c')&&(!memcmp(buf+i,"cpus detected",13))) {
+ i+=17;
+ nr=atoi(buf+i);
+ break;
+ }
+#elif defined(__sparc__)
+ if ((buf[i]=='n')&&(!memcmp(buf+i,"ncpus active",12))) {
+ i+=15;
+ nr=atoi(buf+i);
+ break;
+ }
+#else /* DEFAULT */
+ if ((buf[i]=='p')&&(!memcmp(buf+i,"processor",9))) {
+ ++nr;
+ i+=9;
+ }
+#endif
+ while(buf[i++]!='\n'); /* skip rest of line */
+ }
+ }
+ close(fd);
+ return nr;
+ }
+#endif
+}
+#else
+int __sc_nr_cpus() {
+ return 1; /* kludge kludge ;-) */
+}
+#endif
diff --git a/mdk-stage1/dietlibc/libcruft/tempnam.c b/mdk-stage1/dietlibc/libcruft/tempnam.c
new file mode 100644
index 000000000..01c20b490
--- /dev/null
+++ b/mdk-stage1/dietlibc/libcruft/tempnam.c
@@ -0,0 +1,32 @@
+#include <unistd.h>
+#include <fcntl.h>
+#include <string.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <dietwarning.h>
+
+link_warning("tempnam","\e[1;33;41m>>> tempnam stinks! NEVER ! NEVER USE IT ! <<<\e[0m");
+
+char* tempnam(char* dir,char* template) {
+ char buf[1024];
+ int len=sizeof(buf)-1,fd;
+ buf[len]=0;
+ if ((dir)&&(*dir)) {
+ memccpy(buf,dir,0,len);
+ strncat(buf,"/",1);
+ }
+ else
+ strncpy(buf,"/tmp/",len);
+ len=(sizeof(buf)-1)-strlen(buf);
+ if (template)
+ strncat(buf,template, --len);
+ else
+ strncat(buf,"temp_", --len);
+ len=(sizeof(buf)-1)-strlen(buf);
+ strncat(buf,"XXXXXX",len);
+ if ((fd=mkstemp(buf))<0) return 0;
+ close(fd);
+ unlink(buf);
+ return strdup(buf);
+}
diff --git a/mdk-stage1/dietlibc/libcruft/tmpnam.c b/mdk-stage1/dietlibc/libcruft/tmpnam.c
new file mode 100644
index 000000000..707730616
--- /dev/null
+++ b/mdk-stage1/dietlibc/libcruft/tmpnam.c
@@ -0,0 +1,31 @@
+#include <unistd.h>
+#include <fcntl.h>
+#include <string.h>
+#include "dietfeatures.h"
+#include <errno.h>
+#include <sys/stat.h>
+#include <dietwarning.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+link_warning("tmpnam","\e[1;33;41m>>> tmpnam stinks! NEVER ! NEVER USE IT ! <<<\e[0m");
+
+char* tmpnam(char* s) {
+ static char buf[100];
+ char *tmp;
+ if (s) tmp=s; else tmp=buf;
+ strcpy(tmp,"/tmp/temp_");
+ for (;;) {
+ struct stat s;
+ int i,j;
+ i=rand();
+ for (j=0; j<8; ++j) {
+ char c=i&0xf;
+ tmp[9+j]=c>9?c+'a'-10:c+'0';
+ i>>=4;
+ }
+ tmp[17]=0;
+ if (lstat(tmp,&s)==-1 && errno==ENOENT) break;
+ }
+ return tmp;
+}
diff --git a/mdk-stage1/dietlibc/libcrypt/md5.c b/mdk-stage1/dietlibc/libcrypt/md5.c
new file mode 100644
index 000000000..ede9a067e
--- /dev/null
+++ b/mdk-stage1/dietlibc/libcrypt/md5.c
@@ -0,0 +1,243 @@
+/*****************************************************************************
+*
+* "derived from the RSA Data Security, Inc. MD5 Message-Digest Algorithm".
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 2 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*
+*****************************************************************************/
+
+#include <endian.h>
+#include <md5.h>
+#include <string.h>
+
+#if (__BYTE_ORDER == __BIG_ENDIAN)
+/*
+ Block copy and convert byte order to little-endian.
+ dst must be 32bit aligned.
+ Length is the number of 32bit words
+*/
+static void CopyToLittleEndian (uint32_t *dst, const uint8_t *src, int length) {
+ while (length--) {
+ *dst=(((uint32_t)src[3])<<24) |
+ (((uint32_t)src[2])<<16) |
+ (((uint32_t)src[1])<< 8) |
+ (uint32_t)src[0];
+ src+=4;
+ dst++;
+ }
+}
+#endif
+
+
+/*
+ Assembler versions of __MD5Transform, MD5Init and MD5Update
+ currently exist for x86 and little-endian ARM.
+ For other targets, we need to use the C versions below.
+*/
+
+#if !(defined (__i386__) || ((defined (__arm__) && (__BYTE_ORDER == __LITTLE_ENDIAN))))
+
+/*
+ Initialise the MD5 context.
+*/
+void MD5Init (MD5_CTX* context) {
+ context->count[0] = 0;
+ context->count[1] = 0;
+
+ context->state[0] = 0x67452301; /* Load magic constants. */
+ context->state[1] = 0xefcdab89;
+ context->state[2] = 0x98badcfe;
+ context->state[3] = 0x10325476;
+}
+
+#define ROTATE_LEFT(x, n) ((x << n) | (x >> (32-n)))
+
+#define F(x, y, z) (z ^ (x & (y ^ z)))
+#define G(x, y, z) (y ^ (z & (x ^ y)))
+#define H(x, y, z) (x ^ y ^ z)
+#define I(x, y, z) (y ^ (x | ~z))
+
+#define FF(a, b, c, d, x, s, ac) { (a) += F (b, c, d) + (x) + (uint32_t)(ac); (a) = ROTATE_LEFT (a, s); (a) += (b); }
+#define GG(a, b, c, d, x, s, ac) { (a) += G (b, c, d) + (x) + (uint32_t)(ac); (a) = ROTATE_LEFT (a, s); (a) += (b); }
+#define HH(a, b, c, d, x, s, ac) { (a) += H (b, c, d) + (x) + (uint32_t)(ac); (a) = ROTATE_LEFT (a, s); (a) += (b); }
+#define II(a, b, c, d, x, s, ac) { (a) += I (b, c, d) + (x) + (uint32_t)(ac); (a) = ROTATE_LEFT (a, s); (a) += (b); }
+
+static void __MD5Transform (uint32_t state[4], const uint8_t *in, int repeat) {
+ const uint32_t *x;
+
+ uint32_t a = state[0];
+ uint32_t b = state[1];
+ uint32_t c = state[2];
+ uint32_t d = state[3];
+
+ for ( ; repeat; repeat--) {
+ uint32_t tempBuffer[16];
+#if (__BYTE_ORDER == __BIG_ENDIAN)
+
+ CopyToLittleEndian (tempBuffer, in, 16);
+ x = tempBuffer;
+#else
+ if ((long)in & 3) {
+ memcpy(tempBuffer, in, 64);
+ x = tempBuffer;
+ } else
+ x = (const uint32_t *) in;
+#endif
+
+ FF (a, b, c, d, x[ 0], 7, 0xd76aa478); /* 1 */ /* Round 1 */
+ FF (d, a, b, c, x[ 1], 12, 0xe8c7b756); /* 2 */
+ FF (c, d, a, b, x[ 2], 17, 0x242070db); /* 3 */
+ FF (b, c, d, a, x[ 3], 22, 0xc1bdceee); /* 4 */
+ FF (a, b, c, d, x[ 4], 7, 0xf57c0faf); /* 5 */
+ FF (d, a, b, c, x[ 5], 12, 0x4787c62a); /* 6 */
+ FF (c, d, a, b, x[ 6], 17, 0xa8304613); /* 7 */
+ FF (b, c, d, a, x[ 7], 22, 0xfd469501); /* 8 */
+ FF (a, b, c, d, x[ 8], 7, 0x698098d8); /* 9 */
+ FF (d, a, b, c, x[ 9], 12, 0x8b44f7af); /* 10 */
+ FF (c, d, a, b, x[10], 17, 0xffff5bb1); /* 11 */
+ FF (b, c, d, a, x[11], 22, 0x895cd7be); /* 12 */
+ FF (a, b, c, d, x[12], 7, 0x6b901122); /* 13 */
+ FF (d, a, b, c, x[13], 12, 0xfd987193); /* 14 */
+ FF (c, d, a, b, x[14], 17, 0xa679438e); /* 15 */
+ FF (b, c, d, a, x[15], 22, 0x49b40821); /* 16 */
+
+ GG (a, b, c, d, x[ 1], 5, 0xf61e2562); /* 17 */ /* Round 2 */
+ GG (d, a, b, c, x[ 6], 9, 0xc040b340); /* 18 */
+ GG (c, d, a, b, x[11], 14, 0x265e5a51); /* 19 */
+ GG (b, c, d, a, x[ 0], 20, 0xe9b6c7aa); /* 20 */
+ GG (a, b, c, d, x[ 5], 5, 0xd62f105d); /* 21 */
+ GG (d, a, b, c, x[10], 9, 0x02441453); /* 22 */
+ GG (c, d, a, b, x[15], 14, 0xd8a1e681); /* 23 */
+ GG (b, c, d, a, x[ 4], 20, 0xe7d3fbc8); /* 24 */
+ GG (a, b, c, d, x[ 9], 5, 0x21e1cde6); /* 25 */
+ GG (d, a, b, c, x[14], 9, 0xc33707d6); /* 26 */
+ GG (c, d, a, b, x[ 3], 14, 0xf4d50d87); /* 27 */
+ GG (b, c, d, a, x[ 8], 20, 0x455a14ed); /* 28 */
+ GG (a, b, c, d, x[13], 5, 0xa9e3e905); /* 29 */
+ GG (d, a, b, c, x[ 2], 9, 0xfcefa3f8); /* 30 */
+ GG (c, d, a, b, x[ 7], 14, 0x676f02d9); /* 31 */
+ GG (b, c, d, a, x[12], 20, 0x8d2a4c8a); /* 32 */
+
+ HH (a, b, c, d, x[ 5], 4, 0xfffa3942); /* 33 */ /* Round 3 */
+ HH (d, a, b, c, x[ 8], 11, 0x8771f681); /* 34 */
+ HH (c, d, a, b, x[11], 16, 0x6d9d6122); /* 35 */
+ HH (b, c, d, a, x[14], 23, 0xfde5380c); /* 36 */
+ HH (a, b, c, d, x[ 1], 4, 0xa4beea44); /* 37 */
+ HH (d, a, b, c, x[ 4], 11, 0x4bdecfa9); /* 38 */
+ HH (c, d, a, b, x[ 7], 16, 0xf6bb4b60); /* 39 */
+ HH (b, c, d, a, x[10], 23, 0xbebfbc70); /* 40 */
+ HH (a, b, c, d, x[13], 4, 0x289b7ec6); /* 41 */
+ HH (d, a, b, c, x[ 0], 11, 0xeaa127fa); /* 42 */
+ HH (c, d, a, b, x[ 3], 16, 0xd4ef3085); /* 43 */
+ HH (b, c, d, a, x[ 6], 23, 0x04881d05); /* 44 */
+ HH (a, b, c, d, x[ 9], 4, 0xd9d4d039); /* 45 */
+ HH (d, a, b, c, x[12], 11, 0xe6db99e5); /* 46 */
+ HH (c, d, a, b, x[15], 16, 0x1fa27cf8); /* 47 */
+ HH (b, c, d, a, x[ 2], 23, 0xc4ac5665); /* 48 */
+
+ II (a, b, c, d, x[ 0], 6, 0xf4292244); /* 49 */ /* Round 4 */
+ II (d, a, b, c, x[ 7], 10, 0x432aff97); /* 50 */
+ II (c, d, a, b, x[14], 15, 0xab9423a7); /* 51 */
+ II (b, c, d, a, x[ 5], 21, 0xfc93a039); /* 52 */
+ II (a, b, c, d, x[12], 6, 0x655b59c3); /* 53 */
+ II (d, a, b, c, x[ 3], 10, 0x8f0ccc92); /* 54 */
+ II (c, d, a, b, x[10], 15, 0xffeff47d); /* 55 */
+ II (b, c, d, a, x[ 1], 21, 0x85845dd1); /* 56 */
+ II (a, b, c, d, x[ 8], 6, 0x6fa87e4f); /* 57 */
+ II (d, a, b, c, x[15], 10, 0xfe2ce6e0); /* 58 */
+ II (c, d, a, b, x[ 6], 15, 0xa3014314); /* 59 */
+ II (b, c, d, a, x[13], 21, 0x4e0811a1); /* 60 */
+ II (a, b, c, d, x[ 4], 6, 0xf7537e82); /* 61 */
+ II (d, a, b, c, x[11], 10, 0xbd3af235); /* 62 */
+ II (c, d, a, b, x[ 2], 15, 0x2ad7d2bb); /* 63 */
+ II (b, c, d, a, x[ 9], 21, 0xeb86d391); /* 64 */
+
+ state[0] = a = a + state[0];
+ state[1] = b = b + state[1];
+ state[2] = c = c + state[2];
+ state[3] = d = d + state[3];
+
+ in += 64;
+ }
+}
+
+
+/*
+ MD5 block update operation:
+ Process another sub-string of the message and update the context.
+*/
+void MD5Update (MD5_CTX *context, const uint8_t *input, size_t inputBytes) {
+ int i;
+ int byteIndex;
+ unsigned int partLen;
+ int len;
+
+ /* Compute number of bytes mod 64 */
+ byteIndex = (context->count[0] >> 3) & 0x3F;
+
+ /* Update number of bits: count += 8 * inputBytes */
+ if ((context->count[0] += inputBytes << 3) < (inputBytes << 3))
+ context->count[1]++;
+ context->count[1] += (inputBytes >> (32-3));
+
+ partLen = (64 - byteIndex);
+
+ /* Transform as many times as possible. */
+ if (inputBytes >= partLen) {
+ memcpy (context->buffer + byteIndex, input, partLen);
+ __MD5Transform (context->state, (const uint8_t *) context->buffer, 1);
+ len = (inputBytes - partLen) / 64;
+ __MD5Transform (context->state, &input[partLen], len);
+ i = partLen + 64 * len;
+ byteIndex = 0;
+ } else
+ i = 0;
+
+ /* Buffer remaining input */
+ memcpy (&context->buffer[byteIndex], &input[i], inputBytes - i);
+}
+
+#endif
+
+
+void MD5Final (uint8_t digest[16], MD5_CTX* context) {
+ static uint8_t finalBlock[64];
+
+ uint32_t bits[2];
+ int byteIndex;
+ int finalBlockLength;
+
+ byteIndex = (context->count[0] >> 3) & 0x3F;
+ finalBlockLength = ((byteIndex < 56) ? 56 : 120) - byteIndex;
+ finalBlock[0] = 0x80;
+
+#if (__BYTE_ORDER == __BIG_ENDIAN)
+ CopyToLittleEndian (bits, (const uint8_t *) context->count, 2);
+#else
+ memcpy(bits, context->count, 8);
+#endif
+
+ MD5Update (context, finalBlock, finalBlockLength);
+ MD5Update (context, (const uint8_t *) bits, 8);
+
+#if (__BYTE_ORDER == __BIG_ENDIAN)
+ CopyToLittleEndian ((uint32_t *) digest, (const uint8_t *) context->state, 4);
+#else
+ memcpy (digest, context->state, 16);
+#endif
+
+ memset(context, 0, sizeof(*context));
+}
+
diff --git a/mdk-stage1/dietlibc/libcrypt/md5crypt.c b/mdk-stage1/dietlibc/libcrypt/md5crypt.c
new file mode 100644
index 000000000..ebbb4be44
--- /dev/null
+++ b/mdk-stage1/dietlibc/libcrypt/md5crypt.c
@@ -0,0 +1,157 @@
+/* $OpenBSD: md5crypt.c,v 1.9 1997/07/23 20:58:27 kstailey Exp $ */
+
+/*
+ * ----------------------------------------------------------------------------
+ * "THE BEER-WARE LICENSE" (Revision 42):
+ * <phk@login.dknet.dk> wrote this file. As long as you retain this notice you
+ * can do whatever you want with this stuff. If we meet some day, and you think
+ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
+ * ----------------------------------------------------------------------------
+ *
+ * $FreeBSD: crypt.c,v 1.5 1996/10/14 08:34:02 phk Exp $
+ *
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char rcsid[] = "$OpenBSD: md5crypt.c,v 1.9 1997/07/23 20:58:27 kstailey Exp $";
+#endif /* LIBC_SCCS and not lint */
+
+#include <unistd.h>
+#include <stdio.h>
+#include <string.h>
+#include <md5.h>
+
+static unsigned char itoa64[] = /* 0 ... 63 => ascii - 64 */
+ "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+
+static void to64 (char *, uint32_t, int);
+
+static void
+to64(s, v, n)
+ char *s;
+ uint32_t v;
+ int n;
+{
+ while (--n >= 0) {
+ *s++ = itoa64[v&0x3f];
+ v >>= 6;
+ }
+}
+
+/*
+ * UNIX password
+ *
+ * Use MD5 for what it is best at...
+ */
+
+char *
+md5crypt(pw, salt)
+ register const char *pw;
+ register const char *salt;
+{
+ /*
+ * This string is magic for this algorithm. Having
+ * it this way, we can get get better later on
+ */
+ static unsigned char *magic = (unsigned char *)"$1$";
+
+ static char passwd[120], *p;
+ static const unsigned char *sp,*ep;
+ unsigned char final[16];
+ int sl,pl,i;
+ MD5_CTX ctx,ctx1;
+ uint32_t l;
+
+ /* Refine the Salt first */
+ sp = (const unsigned char *)salt;
+
+ /* If it starts with the magic string, then skip that */
+ if(!strncmp((const char *)sp,(const char *)magic,strlen((const char *)magic)))
+ sp += strlen((const char *)magic);
+
+ /* It stops at the first '$', max 8 chars */
+ for(ep=sp;*ep && *ep != '$' && ep < (sp+8);ep++)
+ continue;
+
+ /* get the length of the true salt */
+ sl = ep - sp;
+
+ MD5Init(&ctx);
+
+ /* The password first, since that is what is most unknown */
+ MD5Update(&ctx,(const unsigned char *)pw,strlen(pw));
+
+ /* Then our magic string */
+ MD5Update(&ctx,magic,strlen((const char *)magic));
+
+ /* Then the raw salt */
+ MD5Update(&ctx,sp,sl);
+
+ /* Then just as many characters of the MD5(pw,salt,pw) */
+ MD5Init(&ctx1);
+ MD5Update(&ctx1,(const unsigned char *)pw,strlen(pw));
+ MD5Update(&ctx1,sp,sl);
+ MD5Update(&ctx1,(const unsigned char *)pw,strlen(pw));
+ MD5Final(final,&ctx1);
+ for(pl = strlen(pw); pl > 0; pl -= 16)
+ MD5Update(&ctx,final,pl>16 ? 16 : pl);
+
+ /* Don't leave anything around in vm they could use. */
+ memset(final,0,sizeof final);
+
+ /* Then something really weird... */
+ for (i = strlen(pw); i ; i >>= 1)
+ if(i&1)
+ MD5Update(&ctx, final, 1);
+ else
+ MD5Update(&ctx, (const unsigned char *)pw, 1);
+
+ /* Now make the output string */
+ strcpy(passwd,(const char *)magic);
+ memcpy(passwd+3,sp,sl);
+ passwd[sl+3]='$';
+ passwd[sl+4]=0;
+
+ MD5Final(final,&ctx);
+
+ /*
+ * and now, just to make sure things don't run too fast
+ * On a 60 Mhz Pentium this takes 34 msec, so you would
+ * need 30 seconds to build a 1000 entry dictionary...
+ */
+ for(i=0;i<1000;i++) {
+ MD5Init(&ctx1);
+ if(i & 1)
+ MD5Update(&ctx1,(const unsigned char *)pw,strlen(pw));
+ else
+ MD5Update(&ctx1,final,16);
+
+ if(i % 3)
+ MD5Update(&ctx1,sp,sl);
+
+ if(i % 7)
+ MD5Update(&ctx1,(const unsigned char *)pw,strlen(pw));
+
+ if(i & 1)
+ MD5Update(&ctx1,final,16);
+ else
+ MD5Update(&ctx1,(const unsigned char *)pw,strlen(pw));
+ MD5Final(final,&ctx1);
+ }
+
+ p = passwd + strlen(passwd);
+
+ l = (final[ 0]<<16) | (final[ 6]<<8) | final[12]; to64(p,l,4); p += 4;
+ l = (final[ 1]<<16) | (final[ 7]<<8) | final[13]; to64(p,l,4); p += 4;
+ l = (final[ 2]<<16) | (final[ 8]<<8) | final[14]; to64(p,l,4); p += 4;
+ l = (final[ 3]<<16) | (final[ 9]<<8) | final[15]; to64(p,l,4); p += 4;
+ l = (final[ 4]<<16) | (final[10]<<8) | final[ 5]; to64(p,l,4); p += 4;
+ l = final[11] ; to64(p,l,2); p += 2;
+ *p = '\0';
+
+ /* Don't leave anything around in vm they could use. */
+ memset(final,0,sizeof final);
+
+ return passwd;
+}
+
diff --git a/mdk-stage1/dietlibc/libdl/_dl_alloc.c b/mdk-stage1/dietlibc/libdl/_dl_alloc.c
new file mode 100644
index 000000000..41d0d4671
--- /dev/null
+++ b/mdk-stage1/dietlibc/libdl/_dl_alloc.c
@@ -0,0 +1,81 @@
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/mman.h>
+
+#include "_dl_int.h"
+
+#ifdef __DIET_LD_SO__
+static struct _dl_handle*_dl_root_handle=(struct _dl_handle*)0;
+static struct _dl_handle*_dl_top_handle=(struct _dl_handle*)0;
+static struct _dl_handle*_dl_free_list=(struct _dl_handle*)0;
+#else