summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGwenolé Beauchesne <gbeauchesne@mandriva.org>2003-02-18 16:48:15 +0000
committerGwenolé Beauchesne <gbeauchesne@mandriva.org>2003-02-18 16:48:15 +0000
commitcfc97c2e6d73efdf65b5ff0fc6ee66f1dc19f36c (patch)
treea377e1084729f1f289e32f7f180edb924d96718a
parent8182e7cfe7d9c60567e48b876282594395062530 (diff)
downloaddrakx-backup-do-not-use-cfc97c2e6d73efdf65b5ff0fc6ee66f1dc19f36c.tar
drakx-backup-do-not-use-cfc97c2e6d73efdf65b5ff0fc6ee66f1dc19f36c.tar.gz
drakx-backup-do-not-use-cfc97c2e6d73efdf65b5ff0fc6ee66f1dc19f36c.tar.bz2
drakx-backup-do-not-use-cfc97c2e6d73efdf65b5ff0fc6ee66f1dc19f36c.tar.xz
drakx-backup-do-not-use-cfc97c2e6d73efdf65b5ff0fc6ee66f1dc19f36c.zip
Merge in CVS dietlibc 0.21 for IA-64 and X86-64 support. However, drop the
following architectures we currently don't support: arm, mips, mipsel, parisc, s390, sparc64.
-rw-r--r--mdk-stage1/dietlibc/libugly/asprintf.c9
-rw-r--r--mdk-stage1/dietlibc/libugly/daemon.c35
-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/getmntent.c11
-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.c130
-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/gmtime_r.c6
-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/isleap.c2
-rw-r--r--mdk-stage1/dietlibc/libugly/localtime_r.c8
-rw-r--r--mdk-stage1/dietlibc/libugly/logging.c38
-rw-r--r--mdk-stage1/dietlibc/libugly/mktime.c68
-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/popen.c28
-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/setenv.c12
-rw-r--r--mdk-stage1/dietlibc/libugly/strftime.c275
-rw-r--r--mdk-stage1/dietlibc/libugly/strsignal.c92
-rw-r--r--mdk-stage1/dietlibc/libugly/system.c36
-rw-r--r--mdk-stage1/dietlibc/libugly/time_table_spd.c5
-rw-r--r--mdk-stage1/dietlibc/libugly/timezone.c3
-rw-r--r--mdk-stage1/dietlibc/libugly/tzfile.c37
-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/__testandset.S9
-rw-r--r--mdk-stage1/dietlibc/ppc/clone.S48
-rw-r--r--mdk-stage1/dietlibc/ppc/mmap.c11
-rw-r--r--mdk-stage1/dietlibc/ppc/start.S32
-rw-r--r--mdk-stage1/dietlibc/ppc/syscalls.h259
-rw-r--r--mdk-stage1/dietlibc/ppc/unified.S37
-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/__longjmp.S1
-rw-r--r--mdk-stage1/dietlibc/sparc/clone.S5
-rw-r--r--mdk-stage1/dietlibc/sparc/fork.S2
-rw-r--r--mdk-stage1/dietlibc/sparc/mmap.c4
-rw-r--r--mdk-stage1/dietlibc/sparc/pipe.S2
-rw-r--r--mdk-stage1/dietlibc/sparc/setjmp.S28
-rw-r--r--mdk-stage1/dietlibc/sparc/shmat.c2
-rw-r--r--mdk-stage1/dietlibc/sparc/sigaction.c7
-rw-r--r--mdk-stage1/dietlibc/sparc/start.S58
-rw-r--r--mdk-stage1/dietlibc/sparc/strlen.S11
-rw-r--r--mdk-stage1/dietlibc/sparc/syscalls.h276
-rw-r--r--mdk-stage1/dietlibc/sparc/unified.S10
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/_llseek.c5
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/_newselect.c6
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/access.c4
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/chdir.c3
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/chmod.c5
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/chown.c5
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/chroot.c4
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/clone.c1
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/close.c3
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/dup.c4
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/dup2.c4
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/execve.c4
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/exit.c3
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/fchdir.c3
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/fchmod.c5
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/fchown.c5
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/fcntl.c4
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/flock.c4
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/fork.c6
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/fsync.c4
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/ftruncate.c4
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/getcwd.c5
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/getdents.c4
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/getegid.c4
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/geteuid.c4
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/getgid.c4
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/getgroups.c4
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/getpgid.c4
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/getpriority.c4
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/getresgid.c8
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/getresuid.c8
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/getrlimit.c3
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/getrusage.c3
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/getsid.c4
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/gettimeofday.c5
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/getuid.c4
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/ioctl.c4
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/kill.c4
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/lchown.c5
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/link.c5
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/lseek.c4
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/mkdir.c4
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/mknod.c5
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/mount.c4
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/mprotect.c4
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/mremap.c5
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/munmap.c5
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/nanosleep.c5
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/open.c4
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/pipe.c4
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/poll.c4
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/read.c3
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/readlink.c5
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/reboot.c4
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/rename.c4
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/rmdir.c3
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/setdomainname.c4
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/setgid.c3
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/setgroups.c4
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/sethostname.c4
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/setitimer.c4
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/setpgid.c3
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/setpriority.c4
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/setregid.c4
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/setresgid.c8
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/setresuid.c8
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/setreuid.c4
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/setrlimit.c3
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/setsid.c4
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/setuid.c3
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/sigaction.c3
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/signal.c3
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/sigpending.c3
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/sigprocmask.c3
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/sigsuspend.c3
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/socketcall.c3
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/swapoff.c4
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/swapon.c4
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/symlink.c3
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/syslog.c3
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/time.c4
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/truncate.c4
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/umask.c5
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/umount.c3
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/uname.c5
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/unlink.c3
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/utime.c3
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/vhangup.c3
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/wait4.c4
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/waitpid.c4
-rw-r--r--mdk-stage1/dietlibc/syscalls.c/write.c3
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/__pread.S2
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/__pwrite.S (renamed from mdk-stage1/dietlibc/syscalls.s/pwrite.S)0
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/_llseek.S4
-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/exit.S3
-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/getdents64.S1
-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/getresuid.S4
-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/ioperm.S2
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/lchown32.S5
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/llseek.S6
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/madvise.S3
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/mlock.S (renamed from mdk-stage1/dietlibc/syscalls.c/sync.c)2
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/mmap2.S5
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/msync.S (renamed from mdk-stage1/dietlibc/syscalls.c/getpid.c)2
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/munlock.S3
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/n_sigaction.S3
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/n_sigpending.S3
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/n_sigprocmask.S3
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/n_sigsuspend.S3
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/nice.S2
-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/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/sendfile.S2
-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/setresgid.S4
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/setresgid32.S5
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/setresuid.S4
-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/sigaction.S3
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/signal.S3
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/sigpending.S3
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/sigprocmask.S3
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/sigsuspend.S3
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/stime.S2
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/syslog.S2
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/time.S2
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/truncate64.S10
-rw-r--r--mdk-stage1/dietlibc/syscalls.s/waitpid.S2
-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.S (renamed from mdk-stage1/dietlibc/syscalls.c/getppid.c)2
-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/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/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/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.S38
-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
268 files changed, 3580 insertions, 1014 deletions
diff --git a/mdk-stage1/dietlibc/libugly/asprintf.c b/mdk-stage1/dietlibc/libugly/asprintf.c
index d10c20b4a..9db1f67c7 100644
--- a/mdk-stage1/dietlibc/libugly/asprintf.c
+++ b/mdk-stage1/dietlibc/libugly/asprintf.c
@@ -1,21 +1,18 @@
#include <stdarg.h>
-#include <linux/types.h>
+#include <sys/types.h>
#include <stdlib.h>
+#include <stdio.h>
#include "dietwarning.h"
-extern int vsnprintf (char *str,size_t size,const char *format, va_list arg_ptr);
-
int asprintf(char **s, const char *format,...)
{
int n;
va_list arg_ptr;
va_start(arg_ptr, format);
n=vsnprintf(0,1000000,format,arg_ptr);
- va_end (arg_ptr);
va_start (arg_ptr, format);
- if ((*s=malloc(n+2))) {
+ if ((*s=malloc(n+1))) {
n=vsnprintf(*s,n+1,format,arg_ptr);
- va_end(arg_ptr);
return n;
}
return -1;
diff --git a/mdk-stage1/dietlibc/libugly/daemon.c b/mdk-stage1/dietlibc/libugly/daemon.c
deleted file mode 100644
index 6748cc3c9..000000000
--- a/mdk-stage1/dietlibc/libugly/daemon.c
+++ /dev/null
@@ -1,35 +0,0 @@
-#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);
- close (fd);
- }
- return (0);
-}
-
diff --git a/mdk-stage1/dietlibc/libugly/difftime.c b/mdk-stage1/dietlibc/libugly/difftime.c
new file mode 100644
index 000000000..fc71363c7
--- /dev/null
+++ b/mdk-stage1/dietlibc/libugly/difftime.c
@@ -0,0 +1,8 @@
+#include <time.h>
+#include "../dietwarning.h"
+
+double difftime(time_t time1, time_t time2) {
+ return (double)time1 - (double)time2;
+}
+
+link_warning("difftime","warning: difftime introduces an unnecessary floating point dependency. Don't use it!")
diff --git a/mdk-stage1/dietlibc/libugly/dirfd.c b/mdk-stage1/dietlibc/libugly/dirfd.c
new file mode 100644
index 000000000..8d5af8b9a
--- /dev/null
+++ b/mdk-stage1/dietlibc/libugly/dirfd.c
@@ -0,0 +1,8 @@
+#include <sys/types.h>
+#include "dietdirent.h"
+#define _BSD_SOURCE
+#include <dirent.h>
+
+int dirfd(DIR* dirp) {
+ return dirp->fd;
+}
diff --git a/mdk-stage1/dietlibc/libugly/freeaddrinfo.c b/mdk-stage1/dietlibc/libugly/freeaddrinfo.c
new file mode 100644
index 000000000..72a13f5e1
--- /dev/null
+++ b/mdk-stage1/dietlibc/libugly/freeaddrinfo.c
@@ -0,0 +1,11 @@
+#include <sys/socket.h>
+#include <stdlib.h>
+
+void freeaddrinfo(struct addrinfo *res) {
+ while (res) {
+ struct addrinfo *duh;
+ duh=res;
+ res=res->ai_next;
+ free(duh);
+ }
+}
diff --git a/mdk-stage1/dietlibc/libugly/ftime.c b/mdk-stage1/dietlibc/libugly/ftime.c
new file mode 100644
index 000000000..3aa2d15c3
--- /dev/null
+++ b/mdk-stage1/dietlibc/libugly/ftime.c
@@ -0,0 +1,15 @@
+#include <sys/time.h>
+#include <sys/timeb.h>
+#include <unistd.h>
+
+int ftime(struct timeb *tp) {
+ struct timeval tv;
+ struct timezone tz;
+ int ret=gettimeofday(&tv,&tz);
+ tp->time = tv.tv_sec;
+ tp->millitm = tv.tv_usec/1000;
+ tp->timezone = tz.tz_minuteswest;
+ tp->dstflag = tz.tz_dsttime;
+ return ret;
+}
+
diff --git a/mdk-stage1/dietlibc/libugly/gai_strerror.c b/mdk-stage1/dietlibc/libugly/gai_strerror.c
new file mode 100644
index 000000000..9dc4f5dde
--- /dev/null
+++ b/mdk-stage1/dietlibc/libugly/gai_strerror.c
@@ -0,0 +1,13 @@
+#include <sys/socket.h>
+
+const char* gai_strerror(int error) {
+ switch (error) {
+ case EAI_FAMILY: return "family not supported";
+ case EAI_SOCKTYPE: return "socket type not supported";
+ case EAI_NONAME: return "unknown host";
+ case EAI_SERVICE: return "unknown service";
+ case EAI_MEMORY: return "memory allocation failure";
+ case EAI_AGAIN: return "temporary failure";
+ }
+ return "DNS error. Sorry.";
+}
diff --git a/mdk-stage1/dietlibc/libugly/getaddrinfo.c b/mdk-stage1/dietlibc/libugly/getaddrinfo.c
new file mode 100644
index 000000000..a4675d92b
--- /dev/null
+++ b/mdk-stage1/dietlibc/libugly/getaddrinfo.c
@@ -0,0 +1,140 @@
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <stdlib.h>
+#include <string.h>
+#include <netdb.h>
+#include <arpa/inet.h>
+
+/* XXX TODO FIXME */
+
+int getaddrinfo(const char *node, const char *service, const struct addrinfo *hints, struct addrinfo **res) {
+ struct addrinfo **tmp;
+ int family;
+ tmp=res; *res=0;
+ if (hints) {
+ if (hints->ai_family && hints->ai_family != PF_INET6 && hints->ai_family != PF_INET) return EAI_FAMILY;
+ if (hints->ai_socktype && hints->ai_socktype != SOCK_STREAM && hints->ai_socktype != SOCK_DGRAM) return EAI_SOCKTYPE;
+ }
+ for (family=PF_INET6; ; family=PF_INET) {
+ if (!hints || hints->ai_family==family || hints->ai_family==AF_UNSPEC) { /* IPv6 addresses are OK */
+ struct hostent h;
+ struct hostent *H;
+ int herrno=0;
+ char buf[4096];
+ int lookupok=0;
+ h.h_addr_list=(char**)buf+16;
+ if (node) {
+ if (inet_pton(family,node,buf)>0) {
+ h.h_name=(char*)node;
+ h.h_addr_list[0]=buf;
+ lookupok=1;
+ } else if ((!hints || !(hints->ai_flags&AI_NUMERICHOST)) &&
+ !gethostbyname2_r(node,family,&h,buf,4096,&H,&herrno)) {
+ lookupok=1;
+ } else {
+ if (herrno==TRY_AGAIN) { freeaddrinfo(*res); return EAI_AGAIN; }
+ }
+ } else {
+ h.h_name=0;
+ h.h_addr_list[0]=buf;
+ memset(buf,0,16);
+ if (!hints || !(hints->ai_flags&AI_PASSIVE)) {
+ if (family==AF_INET) {
+ buf[0]=127; buf[3]=1;
+ } else
+ buf[15]=1;
+ }
+ lookupok=1;
+ }
+ if (lookupok) {
+ struct ai_v6 {
+ struct addrinfo ai;
+ union {
+ struct sockaddr_in6 ip6;
+ struct sockaddr_in ip4;
+ } ip;
+ char name[1];
+ } *foo;
+ unsigned short port;
+ int len=sizeof(struct ai_v6)+(h.h_name?strlen(h.h_name):0);
+ if (!(foo=malloc(len))) goto error;
+ foo->ai.ai_next=0;
+ foo->ai.ai_socktype=SOCK_STREAM;
+ foo->ai.ai_protocol=IPPROTO_TCP;
+ foo->ai.ai_addrlen=family==PF_INET6?sizeof(struct sockaddr_in6):sizeof(struct sockaddr_in);
+ foo->ai.ai_addr=(struct sockaddr*)&foo->ip;
+ if (family==PF_INET6) {
+ memset(&foo->ip,0,sizeof(foo->ip));
+ memmove(&foo->ip.ip6.sin6_addr,h.h_addr_list[0],16);
+ } else {
+ memmove(&foo->ip.ip4.sin_addr,h.h_addr_list[0],4);
+ }
+ foo->ip.ip6.sin6_family=foo->ai.ai_family=family;
+ if (h.h_name) {
+ foo->ai.ai_canonname=foo->name;
+ memmove(foo->name,h.h_name,strlen(h.h_name)+1);
+ } else
+ foo->ai.ai_canonname=0;
+ if (!hints || hints->ai_socktype!=SOCK_DGRAM) { /* TCP is OK */
+ char *x;
+ port=htons(strtol(service?service:"0",&x,0));
+ if (*x) { /* service is not numeric :-( */
+ struct servent* se;
+ if ((se=getservbyname(service,"tcp"))) { /* found a service. */
+ port=se->s_port;
+ blah1:
+ if (family==PF_INET6)
+ foo->ip.ip6.sin6_port=port;
+ else
+ foo->ip.ip4.sin_port=port;
+ if (!*tmp) *tmp=&(foo->ai); else (*tmp)->ai_next=&(foo->ai);
+ if (!(foo=malloc(len))) goto error;
+ memmove(foo,*tmp,len);
+ tmp=&(*tmp)->ai_next;
+ foo->ai.ai_addr=(struct sockaddr*)&foo->ip;
+ if (foo->ai.ai_canonname)
+ foo->ai.ai_canonname=foo->name;
+ } else {
+ freeaddrinfo(*res);
+ return EAI_SERVICE;
+ }
+ } else goto blah1;
+ }
+ foo->ai.ai_socktype=SOCK_DGRAM;
+ foo->ai.ai_protocol=IPPROTO_UDP;
+ if (!hints || hints->ai_socktype!=SOCK_STREAM) { /* UDP is OK */
+ char *x;
+ port=htons(strtol(service?service:"0",&x,0));
+ if (*x) { /* service is not numeric :-( */
+ struct servent* se;
+ if ((se=getservbyname(service,"udp"))) { /* found a service. */
+ port=se->s_port;
+ blah2:
+ if (family==PF_INET6)
+ foo->ip.ip6.sin6_port=port;
+ else
+ foo->ip.ip4.sin_port=port;
+ if (!*tmp) *tmp=&(foo->ai); else (*tmp)->ai_next=&(foo->ai);
+ if (!(foo=malloc(len))) goto error;
+ memmove(foo,*tmp,len);
+ tmp=&(*tmp)->ai_next;
+ foo->ai.ai_addr=(struct sockaddr*)&foo->ip;
+ foo->ai.ai_canonname=foo->name;
+ } else {
+ freeaddrinfo(*res);
+ return EAI_SERVICE;
+ }
+ } else goto blah2;
+ }
+ free(foo);
+ }
+ }
+ if (family==PF_INET) break;
+ }
+ if (*res==0) return EAI_NONAME; /* kludge kludge... */
+ return 0;
+error:
+ freeaddrinfo(*res);
+ return EAI_MEMORY;
+}
diff --git a/mdk-stage1/dietlibc/libugly/gethostent.c b/mdk-stage1/dietlibc/libugly/gethostent.c
new file mode 100644
index 000000000..fe92beacf
--- /dev/null
+++ b/mdk-stage1/dietlibc/libugly/gethostent.c
@@ -0,0 +1,116 @@
+#include <unistd.h>
+#include <fcntl.h>
+#include <netdb.h>
+#include <sys/mman.h>
+#include <errno.h>
+#include <netinet/in.h>
+#include <string.h>
+#include <ctype.h>
+#include <netdb.h>
+#include <sys/socket.h>
+#include <arpa/inet.h>
+#include "dietfeatures.h"
+
+static char* hostmap=0;
+static unsigned int hostlen;
+
+static char *cur;
+
+/* ::1 localhost6 alias1 alias2 # internet protocol, pseudo protocol number */
+struct hostent* gethostent_r(char* buf, int len) {
+ char *dest;
+ struct hostent* pe=(struct hostent*)buf;
+ char* last;
+ char* max=buf+len;
+ int aliasidx;
+ if (!hostmap) {
+ int hostfd=open(_PATH_HOSTS,O_RDONLY);
+ if (hostfd<0) return 0;
+ hostlen=lseek(hostfd,0,SEEK_END);
+ hostmap=mmap(0,hostlen,PROT_READ|PROT_WRITE,MAP_PRIVATE,hostfd,0);
+ if ((long)hostmap==(-1)) { close(hostfd); hostmap=0; goto error; }
+ close(hostfd); hostfd=-1;
+ cur=hostmap;
+ }
+ last=hostmap+hostlen;
+again:
+ if ((size_t)len<sizeof(struct hostent)+11*sizeof(char*)) goto nospace;
+ dest=buf+sizeof(struct hostent);
+ pe->h_name=0;
+ pe->h_aliases=(char**)dest; pe->h_aliases[0]=0; dest+=10*sizeof(char*);
+ pe->h_addr_list=(char**)dest; dest+=2*sizeof(char**);
+ if (cur>=last) return 0;
+ if (*cur=='#' || *cur=='\n') goto parseerror;
+ /* first, the ip number */
+ pe->h_name=cur;
+ while (cur<last && !isspace(*cur)) cur++;
+ if (cur>=last) return 0;
+ if (*cur=='\n') goto parseerror;
+ {
+ char save=*cur;
+ *cur=0;
+ pe->h_addr_list[0]=dest;
+ pe->h_addr_list[1]=0;
+ if (max-dest<16) goto nospace;
+ if (inet_pton(AF_INET6,pe->h_name,dest)>0) {
+ pe->h_addrtype=AF_INET6;
+ pe->h_length=16;
+ dest+=16;
+ } else if (inet_pton(AF_INET,pe->h_name,dest)>0) {
+ pe->h_addrtype=AF_INET;
+ pe->h_length=4;
+ dest+=4;
+ } else {
+ *cur=save;
+ goto parseerror;
+ }
+ *cur=save;
+ }
+ ++cur;
+ /* now the aliases */
+ for (aliasidx=0;aliasidx<9;++aliasidx) {
+ while (cur<last && isblank(*cur)) ++cur;
+ pe->h_aliases[aliasidx]=cur;
+ while (cur<last && !isspace(*cur)) ++cur;
+ {
+ char *from=pe->h_aliases[aliasidx];
+ int len=cur-from;
+ if (max-dest<len+2) goto nospace;
+ pe->h_aliases[aliasidx]=dest;
+ memmove(dest,from,(size_t)(cur-from));
+ dest+=len;
+ *dest=0; ++dest;
+ }
+ if (*cur=='\n') { ++cur; ++aliasidx; break; }
+ if (cur>=last || !isblank(*cur)) break;
+ cur++;
+ }
+ pe->h_aliases[aliasidx]=0;
+ pe->h_name=pe->h_aliases[0];
+ pe->h_aliases++;
+ return pe;
+parseerror:
+ while (cur<last && *cur!='\n') cur++;
+ cur++;
+ goto again;
+nospace:
+ errno=ERANGE;
+ goto __error;
+error:
+ errno=ENOMEM;
+__error:
+ if (hostmap!=(char*)-1) munmap(hostmap,hostlen);
+ hostmap=(char*)-1;
+ return 0;
+}
+
+void sethostent(int stayopen) {
+ (void)stayopen;
+ cur=hostmap;
+}
+
+void endhostent(void) {
+ if (hostmap!=(char*)-1) munmap(hostmap,hostlen);
+ hostmap=0;
+}
+
diff --git a/mdk-stage1/dietlibc/libugly/getmntent.c b/mdk-stage1/dietlibc/libugly/getmntent.c
index 250a77b7f..1a1bdca24 100644
--- a/mdk-stage1/dietlibc/libugly/getmntent.c
+++ b/mdk-stage1/dietlibc/libugly/getmntent.c
@@ -5,11 +5,11 @@
struct mntent *getmntent(FILE *filep) {
static struct mntent m;
- char buf[1024];
+ static char buf[1024];
do {
char *tmp=buf;
int num;
- fgets(buf,1024,filep);
+ if (!fgets(buf,1024,filep)) return 0;
/* "/dev/ide/host0/bus0/target0/lun0/part2 / reiserfs defaults 1 1" */
for (num=0; num<6; ++num) {
switch (num) {
@@ -17,12 +17,13 @@ struct mntent *getmntent(FILE *filep) {
case 1: m.mnt_dir=tmp; break;
case 2: m.mnt_type=tmp; break;
case 3: m.mnt_opts=tmp; break;
- case 4: m.mnt_freq=strtol(tmp,&tmp,0); if (*tmp!=' ') continue; break;
+ case 4: m.mnt_freq=strtol(tmp,&tmp,0); if (*tmp!=' ' && *tmp!='\t') continue; break;
case 5: m.mnt_passno=strtol(tmp,&tmp,0); if (*tmp=='\n') return &m; break;
}
- if ((tmp=strchr(tmp,' '))) {
+ while (*tmp && *tmp!=' ' && *tmp!='\n' && *tmp!='\t') ++tmp;
+ if (*tmp) {
if (num<4) *tmp++=0;
- while (*tmp==' ') ++tmp;
+ while (*tmp==' ' || *tmp=='\t') ++tmp;
} else
continue;
}
diff --git a/mdk-stage1/dietlibc/libugly/getnameinfo.c b/mdk-stage1/dietlibc/libugly/getnameinfo.c
new file mode 100644
index 000000000..40883ba09
--- /dev/null
+++ b/mdk-stage1/dietlibc/libugly/getnameinfo.c
@@ -0,0 +1,46 @@
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netdb.h>
+#include <arpa/inet.h>
+#include <string.h>
+
+extern int __ltostr(char *s, int size, unsigned long i, int base, char UpCase);
+
+int getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host,
+ size_t hostlen, char *serv, size_t servlen, int flags) {
+ sa_family_t f=((struct sockaddr_storage *)sa)->ss_family;
+ (void)salen; /* shut gcc up about unused salen */
+ if (host && hostlen>0) { /* user wants me to resolve the host name */
+ register const char*addr=(f==AF_INET6)?(char*)&((struct sockaddr_in6*)sa)->sin6_addr:
+ (char*)&((struct sockaddr_in*)sa)->sin_addr;
+ if (flags&NI_NUMERICHOST) {
+ if (!inet_ntop(f,addr,host,hostlen))
+ return EAI_NONAME;
+ } else {
+ char buf[4096];
+ struct hostent h;
+ struct hostent *H;
+ int herrno;
+ if (gethostbyaddr_r(addr,f==AF_INET6?16:4,f,&h,buf,4096,&H,&herrno)) {
+ switch (herrno) {
+ case TRY_AGAIN: return EAI_AGAIN;
+ case NO_DATA:
+ case HOST_NOT_FOUND: return EAI_NONAME;
+ }
+ }
+ strncpy(host,h.h_name,hostlen-1);
+ host[hostlen-1]=0;
+ }
+ }
+ if (serv && servlen>0) {
+ register short int port=(f==AF_INET6)?((struct sockaddr_in6*)sa)->sin6_port:((struct sockaddr_in*)sa)->sin_port;
+ if (flags&NI_NUMERICSERV) {
+ __ltostr(serv,servlen,ntohs(port),10,0);
+ } else {
+ struct servent *s;
+ if (!(s=getservbyport(port,flags&NI_DGRAM?"udp":"tcp")))
+ return EAI_SERVICE;
+ }
+ }
+ return 0;
+}
diff --git a/mdk-stage1/dietlibc/libugly/getprotobyname.c b/mdk-stage1/dietlibc/libugly/getprotobyname.c
new file mode 100644
index 000000000..1de348791
--- /dev/null
+++ b/mdk-stage1/dietlibc/libugly/getprotobyname.c
@@ -0,0 +1,12 @@
+#include <string.h>
+#include <netdb.h>
+
+extern struct protoent __protoent_pw;
+extern char __protoent_buf[1000];
+
+struct protoent *getprotobyname(const char *name) {
+ struct protoent* tmp;
+ if (getprotobyname_r(name,&__protoent_pw,__protoent_buf,sizeof(__protoent_buf),&tmp)==0)
+ return tmp;
+ return 0;
+}
diff --git a/mdk-stage1/dietlibc/libugly/getprotobyname_r.c b/mdk-stage1/dietlibc/libugly/getprotobyname_r.c
new file mode 100644
index 000000000..3b1219aa7
--- /dev/null
+++ b/mdk-stage1/dietlibc/libugly/getprotobyname_r.c
@@ -0,0 +1,17 @@
+#include <string.h>
+#include <netdb.h>
+
+extern int getprotobyname_r(const char* name,
+ struct protoent *res, char *buf, size_t buflen,
+ struct protoent **res_sig) {
+ while (!getprotoent_r(res,buf,buflen,res_sig)) {
+ int i;
+ if (!strcmp(res->p_name,name)) goto found;
+ for (i=0; res->p_aliases[i]; ++i)
+ if (!strcmp(res->p_aliases[i],name)) goto found;
+ }
+ *res_sig=0;
+found:
+ endprotoent();
+ return *res_sig?0:-1;
+}
diff --git a/mdk-stage1/dietlibc/libugly/getprotobynumber.c b/mdk-stage1/dietlibc/libugly/getprotobynumber.c
new file mode 100644
index 000000000..6170753e2
--- /dev/null
+++ b/mdk-stage1/dietlibc/libugly/getprotobynumber.c
@@ -0,0 +1,12 @@
+#include <string.h>
+#include <netdb.h>
+
+extern struct protoent __protoent_pw;
+extern char __protoent_buf[1000];
+
+struct protoent *getprotobynumber(int proto) {
+ struct protoent* tmp;
+ if (getprotobynumber_r(proto,&__protoent_pw,__protoent_buf,sizeof(__protoent_buf),&tmp)==0)
+ return tmp;
+ return 0;
+}
diff --git a/mdk-stage1/dietlibc/libugly/getprotobynumber_r.c b/mdk-stage1/dietlibc/libugly/getprotobynumber_r.c
new file mode 100644
index 000000000..2ca439fc6
--- /dev/null
+++ b/mdk-stage1/dietlibc/libugly/getprotobynumber_r.c
@@ -0,0 +1,13 @@
+#include <string.h>
+#include <netdb.h>
+
+extern int getprotobynumber_r(int proto,
+ struct protoent *res, char *buf, size_t buflen,
+ struct protoent **res_sig) {
+ while (!getprotoent_r(res,buf,buflen,res_sig))
+ if (proto==res->p_proto) goto found;
+ *res_sig=0;
+found:
+ endprotoent();
+ return *res_sig?0:-1;
+}
diff --git a/mdk-stage1/dietlibc/libugly/getprotoent.c b/mdk-stage1/dietlibc/libugly/getprotoent.c
index a648e2307..3f0fd4d41 100644
--- a/mdk-stage1/dietlibc/libugly/getprotoent.c
+++ b/mdk-stage1/dietlibc/libugly/getprotoent.c
@@ -1,130 +1,10 @@
-#include <unistd.h>
-#include <fcntl.h>
#include <netdb.h>
-#include <sys/mman.h>
-#include <errno.h>
-#include <netinet/in.h>
-#include <string.h>
-#include <ctype.h>
-static int protofd=-1;
-static char* protomap;
-static unsigned int protolen;
+extern struct protoent __protoent_pw;
+extern char __protoent_buf[1000];
-static char* aliases[10];
-
-static char *cur;
-
-/* ip 0 IP # internet protocol, pseudo protocol number */
struct protoent *getprotoent(void) {
- static struct protoent pe;
- char *last;
- int aliasidx;
- if (protofd<0) {
- protofd=open(_PATH_SERVICES,O_RDONLY);
- if (protofd<0) return 0;
- protolen=lseek(protofd,0,SEEK_END);
- protomap=mmap(0,protolen,PROT_READ|PROT_WRITE,MAP_PRIVATE,protofd,0);
- if ((long)protomap==(-1)) goto error;
- cur=protomap;
- }
- last=protomap+protolen;
-again:
- pe.p_name=0;
- pe.p_aliases=aliases; aliases[0]=0;
- pe.p_proto=0;
- if (cur>=last) return 0;
- if (*cur=='#' || *cur=='\n') goto parseerror;
- /* first, the primary name */
- if (!isalpha(*cur)) goto parseerror;
- pe.p_name=cur;
- pe.p_aliases=aliases;
- while (cur<last && isalnum(*cur)) cur++;
- if (cur>=last) return 0;
- if (*cur=='\n') goto parseerror;
- *cur=0; cur++;
- /* second, the protocol number */
- while (cur<last && isblank(*cur)) cur++;
- while (cur<last && isdigit(*cur)) {
- pe.p_proto=pe.p_proto*10+*cur-'0';
- cur++;
- }
-/* pe.p_proto=htons(pe.s_proto); */
- if (cur>=last) return 0;
- if (*cur=='\n') { *cur++=0; return &pe; }
- *cur=0; cur++;
- /* now the aliases */
- for (aliasidx=0;aliasidx<10;++aliasidx) {
- while (cur<last && isblank(*cur)) ++cur;
- aliases[aliasidx]=cur;
- while (cur<last && isalpha(*cur)) ++cur;
- if (*cur=='\n') { *cur++=0; ++aliasidx; break; }
- if (cur>=last || !isblank(*cur)) break;
- *cur++=0;
- }
- aliases[aliasidx]=0;
- return &pe;
-parseerror:
- while (cur<last && *cur!='\n') cur++;
- cur++;
- goto again;
-error:
- if (protomap!=(char*)-1) munmap(protomap,protolen);
- if (protofd!=-1) close(protofd);
- protomap=(char*)-1;
- protofd=-1;
- errno=ENOMEM;
- return 0;
-}
-
-void setprotoent(int stayopen) {
- cur=protomap;
-}
-
-struct protoent *getprotobyname(const char *name) {
- struct protoent *s;
- setprotoent(0);
- for (s=getprotoent(); s; s=getprotoent()) {
- char **tmp;
-#if 0
- write(1,"found ",6);
- write(1,s->p_name,strlen(s->p_name));
- write(1,"/",1);
- write(1,s->p_proto,strlen(s->p_proto));
- write(1,"\n",1);
- if (!strcmp(name,"auth")) {
- tmp=s->p_aliases;
- write(1," aka ",5);
- while (*tmp) {
- write(1,*tmp,strlen(*tmp));
- write(1,", ",2);
- ++tmp;
- }
- write(1,"\n",1);
- }
-#endif
- if (!strcmp(name,s->p_name))
- return s;
- tmp=s->p_aliases;
- while (*tmp)
- if (!strcmp(name,*tmp++)) return s;
- }
- return 0;
+ struct protoent* tmp;
+ getprotoent_r(&__protoent_pw,__protoent_buf,sizeof(__protoent_buf),&tmp);
+ return tmp;
}
-
-struct protoent *getprotobynumber(int proto) {
- struct protoent *s;
- for (s=getprotoent(); s; s=getprotoent()) {
- if (proto==s->p_proto)
- return s;
- }
- return 0;
-}
-
-void endprotoent(void) {
- if (protomap!=(char*)-1) munmap(protomap,protolen);
- if (protofd!=-1) close(protofd);
- protomap=(char*)-1;
- protofd=-1;
-}
-
diff --git a/mdk-stage1/dietlibc/libugly/getprotoent_r.c b/mdk-stage1/dietlibc/libugly/getprotoent_r.c
new file mode 100644
index 000000000..aa9af79c3
--- /dev/null
+++ b/mdk-stage1/dietlibc/libugly/getprotoent_r.c
@@ -0,0 +1,78 @@
+#include <string.h>
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <netdb.h>
+#include <ctype.h>
+#include "parselib.h"
+
+static struct state __ps;
+
+void setprotoent(int stayopen) {
+ (void)stayopen;
+ __prepare_parse(_PATH_PROTOCOLS,&__ps);
+}
+
+void endprotoent(void) {
+ __end_parse(&__ps);
+}
+
+#define ALIASES 16
+
+/* "igmp 2 IGMP # internet group management protocol" */
+int getprotoent_r(struct protoent *res, char *buf, size_t buflen,
+ struct protoent **res_sig) {
+ size_t i,j,n,g;
+ unsigned long l;
+ if (!__ps.buffirst) setprotoent(0);
+ if (!__ps.buffirst) goto error;
+ if (__ps.cur>=__ps.buflen) goto error;
+ res->p_aliases=(char**)buf;
+/* getprotoent */
+again:
+ n=ALIASES*sizeof(char*); g=0;
+ for (i=0; i<3; ++i) {
+ char found;
+ __ps.cur+=__parse_ws(&__ps);
+ if (__ps.cur>=__ps.buflen) { if (i==2) break; else goto error; }
+ j=__parse_nws(&__ps);
+ if (!isblank(found=__ps.buffirst[__ps.cur+j])) {
+ if (i==2) break; /* it's ok, no (more) aliases necessary */
+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->p_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' || found=='#') && i==1) i=3;
+ break;
+ case 1:
+ if (scan_ulong(__ps.buffirst+__ps.cur,&l)!=j) goto parseerror;
+ res->p_proto=l;
+ break;
+ case 2:
+ res->p_aliases[g]=buf+n;
+ ++g;
+ if (g==(ALIASES-1)) break;
+ --i; /* again */
+ goto copy;
+ }
+ __ps.cur+=j+1;
+ }
+ res->p_aliases[g]=0;
+ *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/libugly/getservbyname.c b/mdk-stage1/dietlibc/libugly/getservbyname.c
new file mode 100644
index 000000000..f1c74eaa9
--- /dev/null
+++ b/mdk-stage1/dietlibc/libugly/getservbyname.c
@@ -0,0 +1,12 @@
+#include <string.h>
+#include <netdb.h>
+
+extern struct servent __servent_pw;
+extern char __servent_buf[1000];
+
+struct servent *getservbyname(const char *name, const char *proto) {
+ struct servent* tmp;
+ if (getservbyname_r(name,proto,&__servent_pw,__servent_buf,sizeof(__servent_buf),&tmp)==0)
+ return tmp;
+ return 0;
+}
diff --git a/mdk-stage1/dietlibc/libugly/getservbyname_r.c b/mdk-stage1/dietlibc/libugly/getservbyname_r.c
new file mode 100644
index 000000000..f523a01ca
--- /dev/null
+++ b/mdk-stage1/dietlibc/libugly/getservbyname_r.c
@@ -0,0 +1,18 @@
+#include <string.h>
+#include <netdb.h>
+
+extern int getservbyname_r(const char* name,const char* proto,
+ struct servent *res, char *buf, size_t buflen,
+ struct servent **res_sig) {
+ while (!getservent_r(res,buf,buflen,res_sig)) {
+ int i;
+ if (proto && strcmp(res->s_proto,proto)) continue;
+ if (!strcmp(res->s_name,name)) goto found;
+ for (i=0; res->s_aliases[i]; ++i)
+ if (!strcmp(res->s_aliases[i],name)) goto found;
+ }
+ *res_sig=0;
+found:
+ endservent();
+ return *res_sig?0:-1;
+}
diff --git a/mdk-stage1/dietlibc/libugly/getservbyport.c b/mdk-stage1/dietlibc/libugly/getservbyport.c
new file mode 100644
index 000000000..2821deb63
--- /dev/null
+++ b/mdk-stage1/dietlibc/libugly/getservbyport.c
@@ -0,0 +1,12 @@
+#include <string.h>
+#include <netdb.h>
+
+extern struct servent __servent_pw;
+extern char __servent_buf[1000];
+
+struct servent *getservbyport(int port, const char *proto) {
+ struct servent* tmp;
+ if (getservbyport_r(port,proto,&__servent_pw,__servent_buf,sizeof(__servent_buf),&tmp)==0)
+ return tmp;
+ return 0;
+}
diff --git a/mdk-stage1/dietlibc/libugly/getservbyport_r.c b/mdk-stage1/dietlibc/libugly/getservbyport_r.c
new file mode 100644
index 000000000..9c0f21bdf
--- /dev/null
+++ b/mdk-stage1/dietlibc/libugly/getservbyport_r.c
@@ -0,0 +1,13 @@
+#include <string.h>
+#include <netdb.h>
+
+extern int getservbyport_r(int port,const char* proto,
+ struct servent *res, char *buf, size_t buflen,
+ struct servent **res_sig) {
+ while (!getservent_r(res,buf,buflen,res_sig))
+ if (port==res->s_port && !strcmp(res->s_proto,proto)) goto ok;
+ *res_sig=0;
+ok:
+ endservent();
+ return *res_sig?0:-1;
+}
diff --git a/mdk-stage1/dietlibc/libugly/getservent.c b/mdk-stage1/dietlibc/libugly/getservent.c
new file mode 100644
index 000000000..9eabc972a
--- /dev/null
+++ b/mdk-stage1/dietlibc/libugly/getservent.c
@@ -0,0 +1,10 @@
+#include <netdb.h>
+
+extern struct servent __servent_pw;
+extern char __servent_buf[1000];
+
+struct servent *getservent(void) {
+ struct servent* tmp;
+ getservent_r(&__servent_pw,__servent_buf,sizeof(__servent_buf),&tmp);
+ return tmp;
+}
diff --git a/mdk-stage1/dietlibc/libugly/getservent_r.c b/mdk-stage1/dietlibc/libugly/getservent_r.c
new file mode 100644
index 000000000..33db6f31d
--- /dev/null
+++ b/mdk-stage1/dietlibc/libugly/getservent_r.c
@@ -0,0 +1,91 @@
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <netinet/in.h>
+#include <string.h>
+#include <netdb.h>
+#include <ctype.h>
+#include "parselib.h"
+
+static struct state __ps;
+
+void setservent(int stayopen) {
+ (void)stayopen;
+ __prepare_parse(_PATH_SERVICES,&__ps);
+}
+
+void endservent(void) {
+ __end_parse(&__ps);
+}
+
+#define ALIASES 16
+
+/* "tcpmux 1/tcp # TCP port multiplexer (RFC1078)" */
+int getservent_r(struct servent *res, char *buf, size_t buflen,
+ struct servent **res_sig) {
+ size_t i,j,n,g;
+ unsigned long l;
+ if (!__ps.buffirst) setservent(0);
+ if (!__ps.buffirst) goto error;
+ if (__ps.cur>=__ps.buflen) goto error;
+ res->s_aliases=(char**)buf;
+/* getservent */
+again:
+ n=ALIASES*sizeof(char*); g=0;
+ for (i=0; i<3; ++i) {
+ char found;
+ __ps.cur+=__parse_ws(&__ps);
+ if (__ps.cur>=__ps.buflen) { if (i==2) break; else goto error; }
+ j=__parse_nws(&__ps);
+ if (!isblank(found=__ps.buffirst[__ps.cur+j])) {
+ if (i==2 && found=='#') break;
+ if (found=='#' || (i>1 && found!='\n')) {
+parseerror:
+ while (__ps.cur+j<__ps.buflen) {
+ if (__ps.buffirst[__ps.cur+j]=='\n') {
+ __ps.cur+=j+1;
+ goto again;
+ }
+ ++j;
+ }
+ goto error;
+ }
+ }
+ switch (i) {
+ case 0:
+ res->s_name=buf+n;
+copy:
+ if (!j) goto parseerror;
+ 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' || found=='#') && i==1) i=3;
+ break;
+ case 1:
+ {
+ int k;
+ k=scan_ulong(__ps.buffirst+__ps.cur,&l);
+ if (__ps.buffirst[__ps.cur+k]!='/') {
+ goto parseerror;
+ }
+ res->s_port=htons(l);
+ res->s_proto=buf+n;
+ j-=k+1; __ps.cur+=k+1;
+ goto copy;
+ }
+ case 2:
+ res->s_aliases[g]=buf+n;
+ ++g;
+ if (g==(ALIASES-1)) break;
+ --i; /* again */
+ goto copy;
+ }
+ __ps.cur+=j+1;
+ }
+ res->s_aliases[g]=0;
+ *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/libugly/gmtime_r.c b/mdk-stage1/dietlibc/libugly/gmtime_r.c
index c102d10fa..6bc0bb5b2 100644
--- a/mdk-stage1/dietlibc/libugly/gmtime_r.c
+++ b/mdk-stage1/dietlibc/libugly/gmtime_r.c
@@ -3,7 +3,7 @@
/* seconds per day */
#define SPD 24*60*60
-extern unsigned int __spm[];
+extern short __spm[];
struct tm *gmtime_r(const time_t *timep, struct tm *r) {
time_t i;
@@ -14,7 +14,7 @@ struct tm *gmtime_r(const time_t *timep, struct tm *r) {
r->tm_wday=(4+work)%7;
for (i=1970; ; ++i) {
register time_t k=__isleap(i)?366:365;
- if (work>k)
+ if (work>=k)
work-=k;
else
break;
@@ -28,7 +28,7 @@ struct tm *gmtime_r(const time_t *timep, struct tm *r) {
work-=1;
}
- for (i=11; i && __spm[i]>work; --i) ;
+ for (i=11; i && (__spm[i]>work); --i) ;
r->tm_mon=i;
r->tm_mday+=work-__spm[i];
return r;
diff --git a/mdk-stage1/dietlibc/libugly/grantpt.c b/mdk-stage1/dietlibc/libugly/grantpt.c
new file mode 100644
index 000000000..0aa903b29
--- /dev/null
+++ b/mdk-stage1/dietlibc/libugly/grantpt.c
@@ -0,0 +1,13 @@
+#define _XOPEN_SOURCE
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <stdlib.h>
+
+int grantpt (int fd) {
+ struct stat st;
+ if ((fstat(fd, &st))<0) return -1;
+ if ((chmod((char*)ptsname(fd), st.st_mode | S_IRUSR | S_IWUSR | S_IWGRP))<0)
+ return -1;
+ return 0;
+}
diff --git a/mdk-stage1/dietlibc/libugly/hasmntopt.c b/mdk-stage1/dietlibc/libugly/hasmntopt.c
new file mode 100644
index 000000000..2a547feee
--- /dev/null
+++ b/mdk-stage1/dietlibc/libugly/hasmntopt.c
@@ -0,0 +1,18 @@
+#include <string.h>
+#include <mntent.h>
+
+char *hasmntopt(const struct mntent *mnt, const char *opt) {
+ char *s=mnt->mnt_opts;
+ char *c;
+ int len=strlen(opt);
+ if (!s) return 0;
+ for (c=s;;) {
+ if (!(c=strstr(c,opt))) break;
+ if (c==s || c[-1]==',') {
+ if (c[len]==0 || c[len]==',' || c[len]=='=')
+ return c;
+ }
+ c+=len+1;
+ }
+ return 0;
+}
diff --git a/mdk-stage1/dietlibc/libugly/iconv.c b/mdk-stage1/dietlibc/libugly/iconv.c
new file mode 100644
index 000000000..45be5d91d
--- /dev/null
+++ b/mdk-stage1/dietlibc/libugly/iconv.c
@@ -0,0 +1,71 @@
+#include "dietfeatures.h"
+#include <errno.h>
+#include "dieticonv.h"
+#include <netinet/in.h>
+
+size_t iconv(iconv_t cd, const char* * inbuf, size_t *
+ inbytesleft, char* * outbuf, size_t * outbytesleft) {
+ size_t converted=0,i,j,k;
+ int bits;
+ if (!inbuf || !*inbuf) return 0;
+ while (*inbytesleft) {
+ unsigned int v=0;
+ v=*(unsigned char*)*inbuf;
+ i=j=1;
+ switch (ic_from(cd)) {
+ case UCS_2:
+ v=ntohs(*(unsigned short*)*inbuf);
+ i=2;
+ break;
+ case UCS_4:
+ v=ntohs(*(unsigned int*)*inbuf);
+ i=4;
+ case ISO_8859_1:
+ break;
+ case UTF_8:
+ if (!(v&0x80)) break;
+ for (i=0xC0; i!=0xFC; i=(i>>1)+0x80)
+ if ((v&((i>>1)|0x80))==i) {
+ v&=~i;
+ break;
+ }
+ for (i=1; ((*inbuf)[i]&0xc0)==0x80; ++i)
+ v=(v<<6)|((*inbuf)[i]&0x3f);
+/* printf("got %u in %u bytes, buflen %u\n",v,i,*inbytesleft); */
+ break;
+ }
+ switch (ic_to(cd)) {
+ case ISO_8859_1:
+ **outbuf=(unsigned char)v;
+ break;
+ case UCS_2:
+ *(unsigned short*)*outbuf=htons(v);
+ j=2;
+ break;
+ case UCS_4:
+ *(unsigned int*)*outbuf=htonl(v);
+ j=4;
+ break;
+ case UTF_8:
+ if (v>0x04000000) { bits=30; **outbuf=0xFC; j=6; } else
+ if (v>0x00200000) { bits=24; **outbuf=0xF8; j=5; } else
+ if (v>0x00010000) { bits=18; **outbuf=0xF0; j=4; } else
+ if (v>0x00000800) { bits=12; **outbuf=0xE0; j=3; } else
+ if (v>0x00000080) { bits=6; **outbuf=0xC0; j=2; } else
+ { bits=0; **outbuf=0; }
+ **outbuf |= (unsigned char)(v>>bits);
+ if (*outbytesleft<j) {
+ errno=E2BIG;
+ return (size_t)-1;
+ }
+ for (k=1; k<j; ++k) {
+ bits-=6;
+ (*outbuf)[k]=0x80+((v>>bits)&0x3F);
+ }
+ break;
+ }
+ *inbuf+=i; *inbytesleft-=i; ++converted;
+ *outbuf+=j; *outbytesleft-=j;
+ }
+ return converted;
+}
diff --git a/mdk-stage1/dietlibc/libugly/iconv_close.c b/mdk-stage1/dietlibc/libugly/iconv_close.c
new file mode 100644
index 000000000..7d5d4c4b9
--- /dev/null
+++ b/mdk-stage1/dietlibc/libugly/iconv_close.c
@@ -0,0 +1,7 @@
+#include <stdlib.h>
+#include "dieticonv.h"
+
+int iconv_close(iconv_t cd) {
+ (void)cd; /* shut gcc up about unused cd */
+ return 0;
+}
diff --git a/mdk-stage1/dietlibc/libugly/iconv_open.c b/mdk-stage1/dietlibc/libugly/iconv_open.c
new file mode 100644
index 000000000..eabab4273
--- /dev/null
+++ b/mdk-stage1/dietlibc/libugly/iconv_open.c
@@ -0,0 +1,28 @@
+#include <string.h>
+#include <strings.h>
+#include "dietfeatures.h"
+#include <errno.h>
+#include <stdlib.h>
+#include "dieticonv.h"
+
+static enum charset parsecharset(const char* s) {
+ if (!strcasecmp(s,"UTF-8")) return UTF_8; else
+ if (!strcasecmp(s,"UCS-2") || !strcasecmp(s,"UCS2")) return UCS_2; else
+ if (!strcasecmp(s,"UCS-4") || !strcasecmp(s,"UCS4")) return UCS_4; else
+ if (!strcasecmp(s,"ISO-8859-1")) return ISO_8859_1; else
+ if (!strcasecmp(s,"US-ASCII")) return ISO_8859_1; else
+ return INVALID;
+}
+
+iconv_t iconv_open(const char* tocode, const char* fromcode) {
+ int f,t;
+
+ f=parsecharset(fromcode);
+ t=parsecharset(tocode);
+
+ if (f==INVALID || t==INVALID) {
+ errno=EINVAL;
+ return (iconv_t)(-1);
+ }
+ return (f|t<<16);
+}
diff --git a/mdk-stage1/dietlibc/libugly/isleap.c b/mdk-stage1/dietlibc/libugly/isleap.c
index dcfa1ced6..d83712792 100644
--- a/mdk-stage1/dietlibc/libugly/isleap.c
+++ b/mdk-stage1/dietlibc/libugly/isleap.c
@@ -1,3 +1,5 @@
+#include <time.h>
+
int __isleap(int year) {
/* every fourth year is a leap year except for century years that are
* not divisible by 400. */
diff --git a/mdk-stage1/dietlibc/libugly/localtime_r.c b/mdk-stage1/dietlibc/libugly/localtime_r.c
index d4bc073ce..5d420303c 100644
--- a/mdk-stage1/dietlibc/libugly/localtime_r.c
+++ b/mdk-stage1/dietlibc/libugly/localtime_r.c
@@ -3,8 +3,11 @@
#include <sys/time.h>
#ifdef WANT_TZFILE_PARSER
-extern void __maplocaltime();
+extern void __maplocaltime(void);
extern time_t __tzfile_map(time_t t, int *isdst);
+#else
+extern long int timezone;
+extern int daylight;
#endif
struct tm* localtime_r(const time_t* t, struct tm* r) {
@@ -15,7 +18,8 @@ struct tm* localtime_r(const time_t* t, struct tm* r) {
#else
struct timezone tz;
gettimeofday(0, &tz);
- tmp=*t-tz.tz_minuteswest*60L;
+ timezone=tz.tz_minuteswest*60L;
+ tmp=*t+timezone;
#endif
return gmtime_r(&tmp,r);
}
diff --git a/mdk-stage1/dietlibc/libugly/logging.c b/mdk-stage1/dietlibc/libugly/logging.c
index 69c2c2337..680a1f850 100644
--- a/mdk-stage1/dietlibc/libugly/logging.c
+++ b/mdk-stage1/dietlibc/libugly/logging.c
@@ -1,3 +1,4 @@
+#include <errno.h>
#include "dietfeatures.h"
#include <stdio.h>
@@ -5,7 +6,6 @@
#include <stdarg.h>
#include <errno.h>
#include <unistd.h>
-#include <asm/socket.h>
#include <fcntl.h>
#include <syslog.h>
#include <string.h>
@@ -14,9 +14,9 @@
#include <signal.h>
#define _PATH_CONSOLE "/dev/console"
-#define BUF_SIZE 512 /* messagebuffer size (>= 200) */
+#define BUF_SIZE 2048 /* messagebuffer size (>= 200) */
-#define MAX_LOGTAG 80
+#define MAX_LOGTAG 1000
/* those have to be global *sigh* */
static volatile int connected = 0; /* have done connect */
@@ -37,13 +37,15 @@ static void closelog_intern(void)
connected = 0;
}
-void closelog(void)
+void __libc_closelog(void);
+void __libc_closelog(void)
{
closelog_intern();
LogTag[0]=0;
LogType = SOCK_DGRAM;
}
+void closelog(void) __attribute__((weak,alias("__libc_closelog")));
static void openlog_intern(int option, int facility)
{
@@ -63,27 +65,15 @@ static void openlog_intern(int option, int facility)
}
}
if ((LogFile != -1) && !connected) {
-#ifdef WANT_THREAD_SAFE
- int old_errno = (*(__errno_location()));
-#else
int old_errno=errno;
-#endif
if(connect(LogFile, &SyslogAddr, sizeof(SyslogAddr)) == -1) {
-#ifdef WANT_THREAD_SAFE
- int saved_errno = (*(__errno_location()));
-#else
int saved_errno=errno;
-#endif
close(LogFile);
LogFile = -1;
if((LogType == SOCK_DGRAM) && (saved_errno == EPROTOTYPE)) {
/* retry with SOCK_STREAM instead of SOCK_DGRAM */
LogType = SOCK_STREAM;
-#ifdef WANT_THREAD_SAFE
- (*(__errno_location()))=old_errno;
-#else
errno=old_errno;
-#endif
continue;
}
}
@@ -94,7 +84,8 @@ static void openlog_intern(int option, int facility)
}
/* has to be secured against multiple, simultanious call's in threaded environment */
-void openlog(const char *ident, int option, int facility)
+void __libc_openlog(const char *ident, int option, int facility);
+void __libc_openlog(const char *ident, int option, int facility)
{
if (ident) {
strncpy(LogTag,ident,MAX_LOGTAG);
@@ -102,6 +93,7 @@ void openlog(const char *ident, int option, int facility)
}
openlog_intern(option, facility);
}
+void openlog(const char *ident, int option, int facility) __attribute__((weak,alias("__libc_openlog")));
int setlogmask(int mask)
{
@@ -110,7 +102,8 @@ int setlogmask(int mask)
return old;
}
-void vsyslog(int priority, const char *format, va_list arg_ptr)
+void __libc_vsyslog(int priority, const char *format, va_list arg_ptr);
+void __libc_vsyslog(int priority, const char *format, va_list arg_ptr)
{
char buffer[BUF_SIZE];
char time_buf[20];
@@ -122,11 +115,7 @@ void vsyslog(int priority, const char *format, va_list arg_ptr)
int sigpipe;
struct sigaction action, oldaction;
struct sigaction *oldaction_ptr = NULL;
-#ifdef WANT_THREAD_SAFE
- int saved_errno = (*(__errno_location()));
-#else
int saved_errno = errno;
-#endif
/* check for invalid priority/facility bits */
if (priority & ~(LOG_PRIMASK|LOG_FACMASK)) {
@@ -156,11 +145,7 @@ void vsyslog(int priority, const char *format, va_list arg_ptr)
buflen = 41;
}
else {
-#ifdef WANT_THREAD_SAFE
- (*(__errno_location()))=saved_errno;
-#else
errno=saved_errno;
-#endif
buflen = vsnprintf(buffer+headerlen, BUF_SIZE - headerlen, format, arg_ptr);
}
if (LogStat & LOG_PERROR) {
@@ -201,6 +186,7 @@ void vsyslog(int priority, const char *format, va_list arg_ptr)
if (sigpipe == 0)
sigaction(SIGPIPE, &oldaction, (struct sigaction *) NULL);
}
+void vsyslog(int priority, const char *format, va_list arg_ptr) __attribute__((weak,alias("__libc_vsyslog")));
void syslog(int priority, const char *format, ...)
{
diff --git a/mdk-stage1/dietlibc/libugly/mktime.c b/mdk-stage1/dietlibc/libugly/mktime.c
index ee4dab6c1..348068e1d 100644
--- a/mdk-stage1/dietlibc/libugly/mktime.c
+++ b/mdk-stage1/dietlibc/libugly/mktime.c
@@ -1,21 +1,53 @@
#include <time.h>
-/* seconds per day */
-#define SPD 24*60*60
-
-extern unsigned int __spm[];
-
-time_t mktime(struct tm *t) {
- time_t x=0;
- unsigned int i;
- if (t->tm_year<70) return (time_t)(-1);
- for (i=70; i<t->tm_year; ++i) {
- x+=__isleap(i+1900)?366:365;
- }
- t->tm_yday=__spm[t->tm_mon] + t->tm_mday-1 + ((t->tm_mon>2) && __isleap(t->tm_year)?1:0);
- x+=t->tm_yday;
- /* x is now the number of days since Jan 1 1970 */
- t->tm_wday=(4+x)%7;
- x = x*SPD + t->tm_hour*60*60 + t->tm_min*60 + t->tm_sec;
- return x;
+extern const short __spm [];
+
+time_t mktime ( register struct tm* const t )
+{
+ register time_t day;
+ register time_t i;
+
+ if ( t->tm_year < 70 )
+ return (time_t) -1;
+
+ day = t->tm_yday = __spm [t->tm_mon] + t->tm_mday-1 + ( __isleap (t->tm_year+1900) & (t->tm_mon > 1) );
+
+ for ( i = 70; i < t->tm_year; i++ )
+ day += 365 + __isleap (i+1900);
+
+ /* day is now the number of days since 'Jan 1 1970' */
+ i = 7;
+ t->tm_wday = (day + 4) % i; /* Sunday=0, Monday=1, ..., Saturday=6 */
+
+ i = 24;
+ day *= i;
+ i = 60;
+ return ((day + t->tm_hour) * i + t->tm_min) * i + t->tm_sec;
+}
+
+#if 0
+
+#include <math.h>
+
+main()
+{
+ int i, j, k;
+ static char *s[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
+
+ for (i=70; i<200; i++)
+ for (j=0; j<12; j++)
+ for (k=1; k<=31; k++) {
+ struct tm t;
+ double x;
+ t.tm_year = i;
+ t.tm_mon = j;
+ t.tm_mday = k;
+ t.tm_hour = 0;
+ t.tm_min = 0;
+ t.tm_sec = 0;
+ x = mktime (&t);
+ printf ("%4d.%5.0f %2u.%02u.%04u %s\n", (int)floor(x/86400), x-86400.*(int)floor(x/86400), k, j+1, 1900+i, s[t.tm_wday] );
+ }
+
}
+#endif
diff --git a/mdk-stage1/dietlibc/libugly/netent.c b/mdk-stage1/dietlibc/libugly/netent.c
new file mode 100644
index 000000000..4710d0fe6
--- /dev/null
+++ b/mdk-stage1/dietlibc/libugly/netent.c
@@ -0,0 +1,130 @@
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+#include <errno.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <string.h>
+#include <ctype.h>
+#include "dietfeatures.h"
+#include <netdb.h>
+#include <arpa/inet.h>
+
+static int netfd=-1;
+static char* netmap;
+static unsigned int netlen;
+
+static char* aliases[10];
+
+static char *cur;
+
+/* loopback 127.0.0.0 lo # comment */
+struct netent *getnetent(void) {
+ static struct netent ne;
+ char *last;
+ int aliasidx;
+ if (netfd<0) {
+ netfd=open(_PATH_NETWORKS,O_RDONLY);
+ if (netfd<0) return 0;
+ fcntl (netfd, F_SETFD, FD_CLOEXEC);
+ netlen=lseek(netfd,0,SEEK_END);
+ netmap=mmap(0,netlen,PROT_READ|PROT_WRITE,MAP_PRIVATE,netfd,0);
+ if ((long)netmap==(-1)) goto error;
+ cur=netmap;
+ }
+ last=netmap+netlen;
+again:
+ ne.n_name=0;
+ ne.n_aliases=aliases; aliases[0]=0;
+ ne.n_addrtype=AF_INET;
+ ne.n_net=0;
+ if (cur>=last) return 0;
+ if (*cur=='#' || *cur=='\n') goto parseerror;
+ /* first, the primary name */
+ if (!isalpha(*cur)) goto parseerror;
+ ne.n_name=cur;
+ ne.n_aliases=aliases;
+ while (cur<last && isalnum(*cur)) cur++;
+ if (cur>=last) return 0;
+ if (*cur=='\n') goto parseerror;
+ *cur=0; cur++;
+ /* second, the ip */
+ while (cur<last && isblank(*cur)) cur++;
+ {
+ const char *tmp=cur;
+ char save;
+ while (cur<last && (isdigit(*cur) || *cur=='.')) ++cur;
+ save=*cur; *cur=0;
+ if (inet_aton(tmp,(struct in_addr*)&ne.n_net)==0) goto parseerror;
+ *cur=save;
+ }
+ if (cur>=last) return 0;
+ /* now the aliases */
+ for (aliasidx=0;aliasidx<10;++aliasidx) {
+ while (cur<last && isblank(*cur)) ++cur;
+ aliases[aliasidx]=cur;
+ while (cur<last && isalpha(*cur)) ++cur;
+ if (*cur=='\n') { *cur++=0; ++aliasidx; break; }
+ if (cur>=last || !isblank(*cur)) break;
+ *cur++=0;
+ }
+ aliases[aliasidx]=0;
+ return &ne;
+parseerror:
+ while (cur<last && *cur!='\n') cur++;
+ cur++;
+ goto again;
+error:
+ if (netmap!=(char*)-1) munmap(netmap,netlen);
+ if (netfd!=-1) close(netfd);
+ netmap=(char*)-1;
+ netfd=-1;
+ errno=ENOMEM;
+ return 0;
+}
+
+struct netent *getnetbyaddr(unsigned long net, int type) {
+ struct netent *s;
+ for (s=getnetent(); s; s=getnetent()) {
+ if (net==s->n_net && type==s->n_addrtype)
+ return s;
+ }
+ return 0;
+}
+
+void endnetent(void) {
+ if (netmap!=(char*)-1) munmap(netmap,netlen);
+ if (netfd!=-1) close(netfd);
+ netmap=(char*)-1;
+ netfd=-1;
+}
+
+void setnetent(int stayopen) {
+ (void)stayopen;
+ endnetent();
+}
+
+struct netent *getnetbyname(const char *name) {
+ struct netent *s;
+ setnetent(0);
+ for (s=getnetent(); s; s=getnetent()) {
+ char **tmp;
+#if 0
+ write(1,"found ",6);
+ write(1,s->s_name,strlen(s->s_name));
+ write(1,"/",1);
+ write(1,s->s_proto,strlen(s->s_proto));
+ write(1,"\n",1);
+ if (!strcmp(s->s_name,"ssh")) {
+ write(2,"ssh!\n",5);
+ }
+#endif
+ if (!strcmp(name,s->n_name))
+ return s;
+ tmp=s->n_aliases;
+ while (*tmp)
+ if (!strcmp(name,*tmp++)) return s;
+ }
+ return 0;
+}
+
diff --git a/mdk-stage1/dietlibc/libugly/openpty.c b/mdk-stage1/dietlibc/libugly/openpty.c
new file mode 100644
index 000000000..8d06f329c
--- /dev/null
+++ b/mdk-stage1/dietlibc/libugly/openpty.c
@@ -0,0 +1,54 @@
+#include <unistd.h>
+#include <pty.h>
+#include <fcntl.h>
+#include <termios.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+#include <string.h>
+
+extern int __ltostr(char *s, int size, unsigned long i, int base, char UpCase);
+
+int openpty(int *amaster, int *aslave, char *name, struct termios
+ *termp, struct winsize *winp) {
+ int fd;
+ char buf[20];
+#if 0
+ This is what glibc does:
+ open("/dev/ptmx", O_RDWR) = 4
+ statfs("/dev/pts", {f_type=0x1cd1, f_bsize=1024, f_blocks=0, f_bfree=0, f_files=0, f_ffree=0, f_namelen=255}) = 0
+ ioctl(4, TCGETS, {B38400 opost isig icanon echo ...}) = 0
+ ioctl(4, 0x80045430, [0]) = 0
+ stat("/dev/pts/0", {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0
+ statfs("/dev/pts/0", {f_type=0x1cd1, f_bsize=1024, f_blocks=0, f_bfree=0, f_files=0, f_ffree=0, f_namelen=255}) = 0
+ ioctl(4, 0x40045431, [0]) = 0
+ ioctl(4, TCGETS, {B38400 opost isig icanon echo ...}) = 0
+ ioctl(4, 0x80045430, [0]) = 0
+ stat("/dev/pts/0", {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0
+ open("/dev/pts/0", O_RDWR|O_NOCTTY) = 5
+#endif
+ if ((fd=open("/dev/ptmx",O_RDWR))<0) return -1;
+#if 0
+ if (ioctl(fd,TCGETS,&ts)<0) goto kaputt;
+#endif
+ {
+ int unlock=0;
+ while (ioctl(fd,TIOCSPTLCK, &unlock)<0) if (errno!=EINTR) goto kaputt;
+ }
+ {
+ int ptyno;
+ while (ioctl(fd,TIOCGPTN,&ptyno)<0) if (errno!=EINTR) goto kaputt;
+ strcpy(buf,"/dev/pts/");
+ __ltostr(buf+9,10,ptyno,10,0);
+ }
+ *aslave=open(buf,O_RDWR|O_NOCTTY);
+ if (*aslave<0) goto kaputt;
+ *amaster=fd;
+ if (name) strcpy(name,buf);
+ if (termp)
+ while (tcsetattr(*aslave,TCSAFLUSH,termp) && errno==EINTR);
+ if (winp) while (ioctl(*aslave, TIOCSWINSZ, winp) && errno==EINTR);
+ return 0;
+kaputt:
+ close(fd);
+ return -1;
+}
diff --git a/mdk-stage1/dietlibc/libugly/popen.c b/mdk-stage1/dietlibc/libugly/popen.c
index e0e441495..aa9a2cde0 100644
--- a/mdk-stage1/dietlibc/libugly/popen.c
+++ b/mdk-stage1/dietlibc/libugly/popen.c
@@ -1,32 +1,38 @@
#include "dietstdio.h"
#include <unistd.h>
+#include <fcntl.h>
+#include "binshstr.h"
extern char **environ;
FILE *popen(const char *command, const char *type) {
int pfd[2];
int fd0;
+ FILE* f;
pid_t pid;
+
if (pipe(pfd)<0) return 0;
fd0=(*type=='r');
- if ((pid=vfork())<0) {
+ if (!(f=fdopen(pfd[!fd0],type))) {
+ close(pfd[0]); /* malloc failed */
+ close(pfd[1]);
+ return 0;
+ }
+ if ((pid=fork())<0) {
close(pfd[0]);
close(pfd[1]);
return 0;
}
if (!pid) { /* child */
- char *argv[]={"sh","-c",0,0};
+ const char *argv[]={__sh,"-c",0,0};
close(pfd[!fd0]); close(fd0);
dup2(pfd[fd0],fd0); close(pfd[fd0]);
- argv[2]=(char*)command;
- execve("/bin/sh",argv,environ);
- _exit(255);
+ argv[2]=command;
+ execve(__binsh,(char*const*)argv,environ);
+ _exit(127);
}
close(pfd[fd0]);
- {
- register FILE* f;
- if ((f=fdopen(pfd[!fd0],type)))
- f->popen_kludge=pid;
- return f;
- }
+ fcntl (pfd[!fd0], F_SETFD, FD_CLOEXEC);
+ f->popen_kludge=pid;
+ return f;
}
diff --git a/mdk-stage1/dietlibc/libugly/protoent_buf.c b/mdk-stage1/dietlibc/libugly/protoent_buf.c
new file mode 100644
index 000000000..0e303a5d4
--- /dev/null
+++ b/mdk-stage1/dietlibc/libugly/protoent_buf.c
@@ -0,0 +1,5 @@
+#include <netdb.h>
+
+struct protoent __protoent_pw;
+char __protoent_buf[1000];
+
diff --git a/mdk-stage1/dietlibc/libugly/ptsname.c b/mdk-stage1/dietlibc/libugly/ptsname.c
new file mode 100644
index 000000000..a332faf6c
--- /dev/null
+++ b/mdk-stage1/dietlibc/libugly/ptsname.c
@@ -0,0 +1,17 @@
+#define _XOPEN_SOURCE
+#include <unistd.h>
+#include <sys/ioctl.h>
+#include <stdlib.h>
+#include <string.h>
+
+# define MAX_FDS 4
+
+char *ptsname(int fd) {
+ static char buffer[9+MAX_FDS]; /* Ahh..great */
+ int pty;
+
+ strcpy(buffer,"/dev/pts/");
+ if ((ioctl(fd, TIOCGPTN, &pty)) == -1) return 0;
+ __ltostr(buffer+9, MAX_FDS, pty, 10, 0);
+ return buffer;
+}
diff --git a/mdk-stage1/dietlibc/libugly/putpwent.c b/mdk-stage1/dietlibc/libugly/putpwent.c
new file mode 100644
index 000000000..f192c5934
--- /dev/null
+++ b/mdk-stage1/dietlibc/libugly/putpwent.c
@@ -0,0 +1,19 @@
+/* man, what a crook! */
+
+#include <pwd.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <errno.h>
+#include "dietwarning.h"
+
+int putpwent(const struct passwd *p, FILE *stream) {
+ if (p && stream) {
+ fprintf(stream,"%s:%s:%d:%d:%s:%s:%s\n", p->pw_name, p->pw_passwd,
+ p->pw_uid, p->pw_gid, p->pw_gecos, p->pw_dir, p->pw_shell);
+ return 0;
+ }
+ (*__errno_location())=EINVAL;
+ return -1;
+}
+
+link_warning("putpwent","putpwent is garbage, don't use!")
diff --git a/mdk-stage1/dietlibc/libugly/servent_buf.c b/mdk-stage1/dietlibc/libugly/servent_buf.c
new file mode 100644
index 000000000..b9e992adf
--- /dev/null
+++ b/mdk-stage1/dietlibc/libugly/servent_buf.c
@@ -0,0 +1,5 @@
+#include <netdb.h>
+
+struct servent __servent_pw;
+char __servent_buf[1000];
+
diff --git a/mdk-stage1/dietlibc/libugly/setenv.c b/mdk-stage1/dietlibc/libugly/setenv.c
index bf47cdb79..c65910471 100644
--- a/mdk-stage1/dietlibc/libugly/setenv.c
+++ b/mdk-stage1/dietlibc/libugly/setenv.c
@@ -5,13 +5,15 @@
link_warning("setenv","setenv calls malloc. Avoid it in small programs.");
int setenv(const char *name, const char *value, int overwrite) {
- char *c=malloc(strlen(name)+strlen(value)+3);
if (getenv(name)) {
if (!overwrite) return 0;
unsetenv(name);
}
- strcpy(c,name);
- strcat(c,"=");
- strcat(c,value);
- return putenv(c);
+ {
+ char *c=malloc(strlen(name)+strlen(value)+3);
+ strcpy(c,name);
+ strcat(c,"=");
+ strcat(c,value);
+ return putenv(c);
+ }
}
diff --git a/mdk-stage1/dietlibc/libugly/strftime.c b/mdk-stage1/dietlibc/libugly/strftime.c
index b7e750ab1..7fd608720 100644
--- a/mdk-stage1/dietlibc/libugly/strftime.c
+++ b/mdk-stage1/dietlibc/libugly/strftime.c
@@ -1,182 +1,111 @@
#include <sys/types.h>
#include <time.h>
-static char *sweekdays[]={"Sun","Mon","Tue","Wed","Thu","Fri","Sat"};
-static char *weekdays[]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
-static char *smonths[]={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};
-static char *months[]={"January","February","March","April","May","June","July","August","September","October","November","December"};
-static char *ampm[]={"am","pm","AM","PM"};
-
-static int i2a(char* dest,unsigned int x) {
- register unsigned int tmp=x;
- register int len=0;
- *dest++=tmp/10+'0'; tmp=tmp%10; ++len;
- *dest++=tmp+'0';
- return 2;
-}
-
-static int i2as(char* dest,unsigned int x) {
- int len=i2a(dest,x);
- if (*dest=='0') *dest=' ';
- return len;
+static const char sweekdays [7] [4] = {
+ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
+};
+static const char weekdays [7] [10] = {
+ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
+};
+static const char smonths [12] [4] = {
+ "Jan", "Feb", "Mar", "Apr", "May", "Jun",
+ "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
+};
+static const char* months [12] = {
+ "January", "February", "March", "April", smonths[5-1], "June",
+ "July", "August", "September", "October", "November", "December"
+};
+static const char ampm [4] [3] = {
+ "am", "pm",
+ "AM", "PM"
+};
+
+static int i2a ( char* dest,unsigned int x )
+{
+ int div = 10;
+ *dest++ = x/div + '0';
+ *dest++ = x%div + '0';
+ *dest++ = '\0';
+ return 2;
}
-size_t strftime(char *s, size_t max, const char *format, const struct tm *tm) {
- char *t=s;
- const char *src;
- char buf[5];
- while (*format) {
- switch (*format) {
- case 0: break;
- case '%':
- switch (*++format) {
- case '%': *t='%'; ++t; break;
- case 'a': src=sweekdays[tm->tm_wday]; goto append;
- case 'A': src=weekdays[tm->tm_wday]; goto append;
- case 'h':
- case 'b': src=smonths[tm->tm_mon]; goto append;
- case 'B': src=months[tm->tm_mon]; goto append;
- case 'c': t+=strftime(t,max-(t-s),"%b %a %d %k:%M:%S %Z %Y",tm); break;
- case 'C': buf[i2a(buf,(tm->tm_year+1900)/100)]=0; src=buf; goto append;
- case 'd': buf[i2a(buf,tm->tm_mday)]=0; src=buf; goto append;
- case 'e': buf[i2as(buf,tm->tm_mday)]=0; src=buf; goto append;
- case 'H': buf[i2a(buf,tm->tm_hour)]=0; src=buf; goto append;
- case 'I': buf[i2a(buf,tm->tm_hour%12)]=0; src=buf; goto append;
- case 'j': buf[i2a(buf,tm->tm_yday)]=0; src=buf; goto append;
- case 'k': buf[i2as(buf,tm->tm_hour)]=0; src=buf; goto append;
- case 'l': buf[i2as(buf,tm->tm_hour%12)]=0; src=buf; goto append;
- case 'm': buf[i2a(buf,tm->tm_mon+1)]=0; src=buf; goto append;
- case 'M': buf[i2a(buf,tm->tm_min)]=0; src=buf; goto append;
- case 'n': *t='\n'; break;
- case 'p': src=ampm[tm->tm_hour>11?3:2]; goto append;
- case 'P': src=ampm[tm->tm_hour>11?1:0]; goto append;
- case 'r': t+=strftime(t,max-(t-s),"%I:%M:%S %p",tm); break;
- case 'R': t+=strftime(t,max-(t-s),"%H:%M",tm); break;
- case 'S': buf[i2a(buf,tm->tm_sec)]=0; src=buf; goto append;
- case 't': *t='\t'; break;
- case 'T': t+=strftime(t,max-(t-s),"%H:%M:%S",tm); break;
- case 'u': buf[i2a(buf,tm->tm_wday?tm->tm_wday:7)]=0; src=buf; goto append;
- case 'w': buf[i2a(buf,tm->tm_wday)]=0; src=buf; goto append;
- case 'x': t+=strftime(t,max-(t-s),"%b %a %d",tm); break;
- case 'X': t+=strftime(t,max-(t-s),"%k:%M:%S",tm); break;
- case 'y': buf[i2a(buf,tm->tm_year%100)]=0; src=buf; goto append;
- case 'Y': i2a(buf,(tm->tm_year+1900)/100); buf[i2a(buf+2,(tm->tm_year%100))+2]=0; src=buf; goto append;
- case 'Z': src="GMT"; goto append; /* hehe */
-append:
- while (*src && t<s+max) { *t=*src; ++t; ++src; }
- };
- break;
- default:
- *t=*format; ++t;
+size_t strftime ( char* dst, size_t max, const char* format, const struct tm* tm )
+{
+ char* p = dst;
+ const char* src;
+ unsigned int no;
+ char buf [5];
+
+
+ for ( ; *format != '\0'; format++ ) {
+ if (*format == '%') {
+ if (*++format == '%') {
+ *p++ = '%';
+ }
+ else
+again:
+ switch (*format) {
+// case '%': *p++ = '%'; break; // reduce size of jump table
+ case 'n': *p++ = '\n'; break;
+ case 't': *p++ = '\t'; break;
+ case 'O': case 'E': ++format; goto again;
+ case 'c': src = "%b %a %d %k:%M:%S %Z %Y"; goto _strf;
+ case 'r': src = "%I:%M:%S %p"; goto _strf;
+ case 'R': src = "%H:%M"; goto _strf;
+ case 'x': src = "%b %a %d"; goto _strf;
+ case 'X': src = "%k:%M:%S"; goto _strf;
+ case 'D': src = "%m/%d/%y"; goto _strf;
+ case 'T': src = "%H:%M:%S";
+ _strf: p += strftime (p, (size_t)(dst+max-p), src, tm); break;
+ case 'a': src = sweekdays [tm->tm_wday]; goto _str;
+ case 'A': src = weekdays [tm->tm_wday]; goto _str;
+ case 'h':
+ case 'b': src = smonths [tm->tm_mon]; goto _str;
+ case 'B': src = months [tm->tm_mon]; goto _str;
+ case 'p': src = ampm [tm->tm_hour > 12 ? 3 : 2]; goto _str;
+ case 'P': src = ampm [tm->tm_hour > 12 ? 1 : 0]; goto _str;
+ case 'C': no = tm->tm_year/100 + 19; goto _no;
+ case 'd': no = tm->tm_mday; goto _no;
+ case 'e': no = tm->tm_mday; goto _nos;
+ case 'H': no = tm->tm_hour; goto _no;
+ case 'I': no = tm->tm_hour % 12; goto _no;
+ case 'j': no = tm->tm_yday; goto _no;
+ case 'k': no = tm->tm_hour; goto _nos;
+ case 'l': no = tm->tm_hour % 12; goto _nos;
+ case 'm': no = tm->tm_mon + 1; goto _no;
+ case 'M': no = tm->tm_min; goto _no;
+ case 'S': no = tm->tm_sec; goto _no;
+ case 'u': no = tm->tm_wday ? tm->tm_wday : 7; goto _no;
+ case 'w': no = tm->tm_wday; goto _no;
+ case 'U': no = (tm->tm_yday - tm->tm_wday + 7) / 7; goto _no;
+ case 'W': no = (tm->tm_yday - (tm->tm_wday - 1 + 7) % 7 + 7) / 7; goto _no;
+ case 'Z': tzset(); src = tzname[0]; goto _str;
+ case 'Y': i2a ( buf+0, (unsigned int)(tm->tm_year / 100 + 19) );
+ i2a ( buf+2, (unsigned int)(tm->tm_year % 100) );
+ src = buf;
+ goto _str;
+ case 'y': no = tm->tm_year % 100; goto _no;
+ _no: i2a ( buf, no ); /* append number 'no' */
+ src = buf;
+ goto _str;
+ _nos: i2a ( buf, no ); /* the same, but '0'->' ' */
+ if (buf[0] == '0')
+ buf[0] = ' ';
+ src = buf;
+ _str: while (*src && p < dst+max) /* append string */
+ *p++ = *src++;
+ break;
+ };
+ } else {
+ *p++ = *format;
+ }
+
+ if (p >= dst+max)
+ break;
}
- ++format;
- if (t>=s+max) break;
- continue;
- }
- *t=0; return t-s;
+
+ *p = '\0';
+ return p - dst;
}
-
-/*
- %u The day of the week as a decimal, range 1 to 7,
- Monday being 1. See also %w. (SU)
-
- %U The week number of the current year as a decimal
- number, range 00 to 53, starting with the first
- Sunday as the first day of week 01. See also %V and
- %W.
-
- %V The ISO 8601:1988 week number of the current year
- as a decimal number, range 01 to 53, where week 1
- is the first week that has at least 4 days in the
- current year, and with Monday as the first day of
- the week. See also %U and %W. (SU)
-
- %w The day of the week as a decimal, range 0 to 6,
- Sunday being 0. See also %u.
-
- %W The week number of the current year as a decimal
- number, range 00 to 53, starting with the first
- Monday as the first day of week 01.
-
- %x The preferred date representation for the current
- locale without the time.
-
- %X The preferred time representation for the current
- locale without the date.
-
- %y The year as a decimal number without a century
- (range 00 to 99).
-
- %Y The year as a decimal number including the century.
-
- %z The time-zone as hour offset from GMT. Required to
- emit RFC822-conformant dates (using "%a, %d %b %Y
- %H:%M:%S %z"). (GNU)
-
- %Z The time zone or name or abbreviation.
-
- %+ The date and time in date(1) format. (TZ)
-
- %% A literal `%' character.
-
- Some conversion specifiers can be modified by preceding
- them by the E or O modifier to indicate that an alterna­
- tive format should be used. If the alternative format or
- specification does not exist for the current locale, the
- behaviour will be as if the unmodified conversion specifi­
- cation were used. (SU) The Single Unix Specification men­
- tions %Ec, %EC, %Ex, %EX, %Ry, %EY, %Od, %Oe, %OH, %OI,
- %Om, %OM, %OS, %Ou, %OU, %OV, %Ow, %OW, %Oy, where the
- effect of the O modifier is to use alternative numeric
- symbols (say, roman numerals), and that of the E modifier
-
-
-
-GNU 29 March 1999 3
-
-
-
-
-
-STRFTIME(3) Linux Programmer's Manual STRFTIME(3)
-
-
- is to use a locale-dependent alternative representation.
-
- The broken-down time structure tm is defined in <time.h>.
- See also ctime(3).
-
-
-RETURN VALUE
- The strftime() function returns the number of characters
- placed in the array s, not including the terminating NUL
- character, provided the string, including the terminating
- NUL, fits. Otherwise, it returns 0, and the contents of
- the array is undefined. (Thus at least since libc 4.4.4;
- very old versions of libc, such as libc 4.4.1, would
- return max if the array was too small.)
-
- Note that the return value 0 does not necessarily indicate
- an error; for example, in many locales %p yields an empty
- string.
-
-ENVIRONMENT
- The environment variables TZ and LC_TIME are used.
-
-CONFORMING TO
- ANSI C, SVID 3, ISO 9899. There are strict inclusions
- between the set of conversions given in ANSI C (unmarked),
- those given in the Single Unix Specification (marked SU),
- those given in Olson's timezone package (marked TZ), and
- those given in glibc (marked GNU), except that %+ is not
- supported in glibc2. On the other hand glibc2 has several
- more extensions. POSIX.1 only refers to ANSI C; POSIX.2
- describes under date(1) several extensions that could
- apply to strftime as well.
-
-SEE ALSO
- date(1), time(2), ctime(3), setlocale(3), sprintf(3)
-
-*/
diff --git a/mdk-stage1/dietlibc/libugly/strsignal.c b/mdk-stage1/dietlibc/libugly/strsignal.c
index 54314d2c7..d72777571 100644
--- a/mdk-stage1/dietlibc/libugly/strsignal.c
+++ b/mdk-stage1/dietlibc/libugly/strsignal.c
@@ -1,92 +1,10 @@
+#define _GNU_SOURCE
+#include <string.h>
#include <signal.h>
-/* F....ng Kernel haeder is damn broken... */
-#ifndef _NSIG
-#define _NSIG 64
-#endif
-#include <asm/signal.h>
-char * strsignal(int sig) {
- if (sig==SIGHUP)
- return "Hangup";
- else if (sig==SIGINT)
- return "Interrupt";
- else if (sig==SIGQUIT)
- return "Quit";
- else if (sig==SIGILL)
- return "Illegal instruction";
- else if (sig==SIGTRAP)
- return "Trace/breakpoint trap";
- else if (sig==SIGABRT)
- return "Aborted";
- else if (sig==SIGFPE)
- return "Floating point exception";
- else if (sig==SIGKILL)
- return "Killed";
- else if (sig==SIGBUS)
- return "Bus error";
- else if (sig==SIGSEGV)
- return "Segmentation fault";
- else if (sig==SIGPIPE)
- return "Broken pipe";
- else if (sig==SIGALRM)
- return "Alarm clock";
- else if (sig==SIGTERM)
- return "Terminated";
- else if (sig==SIGURG)
- return "Urgent I/O condition";
- else if (sig==SIGSTOP)
- return "Stopped (signal)";
- else if (sig==SIGTSTP)
- return "Stopped";
- else if (sig==SIGCONT)
- return "Continue";
- else if (sig==SIGCHLD)
- return "Child exited";
- else if (sig==SIGTTIN)
- return "Stopped (tty input)";
- else if (sig==SIGTTOU)
- return "Stopped (tty output)";
- else if (sig==SIGIO)
- return "I/O possible";
- else if (sig==SIGXCPU)
- return "CPU time limit exceeded";
- else if (sig==SIGXFSZ)
- return "File size limit exceeded";
- else if (sig==SIGVTALRM)
- return "Virtual timer expired";
- else if (sig==SIGPROF)
- return "Profiling timer expired";
- else if (sig==SIGWINCH)
- return "Window changed";
- else if (sig==SIGUSR1)
- return "User defined signal 1";
- else if (sig==SIGUSR2)
- return "User defined signal 1";
-#ifdef SIGEMT
- else if (sig==SIGEMT)
- return "EMT trap";
-#endif
-#ifdef SIGSYS
- else if (sig==SIGSYS)
- return "Bad system call";
-#endif
-#ifdef SIGSTKFLT
- else if (sig==SIGSTKFLT)
- return "Stack fault";
-#endif
-#ifdef SIGINFO
- else if (sig==SIGINFO)
- return "Information request";
-#elif defined(SIGPWR) && (!defined(SIGLOST) || (SIGPWR!=SIGLOST))
- else if (sig==SIGPWR)
- return "Power falure";
-#endif
-#ifdef SIGLOST
- else if (sig==SIGLOST)
- return "Resource lost";
-#endif
- else if ((sig>=SIGRTMIN)&&(sig<=SIGRTMAX))
- return "Real time signal";
+const char* strsignal(int sig) {
+ if (sig<=SIGRTMAX)
+ return sys_siglist[sig];
else
return "(unknown signal)";
}
diff --git a/mdk-stage1/dietlibc/libugly/system.c b/mdk-stage1/dietlibc/libugly/system.c
index b9eea20eb..714aad056 100644
--- a/mdk-stage1/dietlibc/libugly/system.c
+++ b/mdk-stage1/dietlibc/libugly/system.c
@@ -1,23 +1,19 @@
#include <signal.h>
-#include <asm/errno.h>
#include <errno.h>
#include <unistd.h>
+#include <sys/wait.h>
#include "dietwarning.h"
-
-#define SHELL_PATH "/bin/sh" /* Path of the shell. */
-#define SHELL_NAME "sh" /* Name to give it. */
+#include "dietfeatures.h"
+#include "binshstr.h"
extern char **environ;
-int __libc_fork();
-int __libc_waitpid(int pid, int *status, int options);
-int execve(const char*filename, char *const argv[], char *const envp[]);
-void __set_errno(int errno);
-int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact);
+int __libc_system (const char *line);
int __libc_system (const char *line)
{
struct sigaction sa, intr, quit;
+ sigset_t block,omask;
int save,pid,ret=-1;
if (line == 0) return __libc_system("exit 0") == 0;
@@ -29,38 +25,48 @@ int __libc_system (const char *line)
if (sigaction(SIGINT, &sa, &intr)<0) return -1;
if (sigaction(SIGQUIT, &sa, &quit)<0) {
save = errno;
+undo:
sigaction (SIGINT, &intr, (struct sigaction*)0);
- __set_errno (save);
+ errno=save;
return -1;
}
+ sigemptyset(&block);
+ sigaddset(&block,SIGCHLD);
+ if (sigprocmask(SIG_BLOCK,&block,&omask)<0) {
+ save=errno;
+ sigaction (SIGQUIT, &quit, (struct sigaction*)0);
+ goto undo;
+ }
- pid=__libc_fork();
+ pid=fork();
if (pid>0)
{ /* parent */
int n;
do
- n=__libc_waitpid(pid, &ret, 0);
+ n=waitpid(pid, &ret, 0);
while ((n==-1) && (errno==EINTR));
if (n!=pid) ret=-1;
}
else if (!pid)
{ /* child */
const char *nargs[4];
- nargs[0] = SHELL_NAME;
+ nargs[0] = __sh;
nargs[1] = "-c";
nargs[2] = line;
nargs[3] = 0;
sigaction(SIGINT, &intr, (struct sigaction*)0);
sigaction(SIGQUIT, &quit, (struct sigaction*)0);
+ sigprocmask(SIG_SETMASK,&omask,0);
- execve(SHELL_PATH,(char *const *)nargs, environ);
+ execve(__binsh,(char *const *)nargs, environ);
_exit(127);
}
save = errno;
sigaction (SIGINT, &intr, (struct sigaction *)0);
sigaction (SIGQUIT, &quit, (struct sigaction *)0);
- __set_errno(save);
+ sigprocmask(SIG_SETMASK,&omask,0);
+ errno=save;
return ret;
}
diff --git a/mdk-stage1/dietlibc/libugly/time_table_spd.c b/mdk-stage1/dietlibc/libugly/time_table_spd.c
index bfe1cf86d..6850d76c4 100644
--- a/mdk-stage1/dietlibc/libugly/time_table_spd.c
+++ b/mdk-stage1/dietlibc/libugly/time_table_spd.c
@@ -1,6 +1,7 @@
+#include <time.h>
-/* seconds per month -- nonleap! */
-const unsigned int __spm[12] =
+/* days per month -- nonleap! */
+const short __spm[12] =
{ 0,
(31),
(31+28),
diff --git a/mdk-stage1/dietlibc/libugly/timezone.c b/mdk-stage1/dietlibc/libugly/timezone.c
new file mode 100644
index 000000000..e8a94a906
--- /dev/null
+++ b/mdk-stage1/dietlibc/libugly/timezone.c
@@ -0,0 +1,3 @@
+
+long int timezone;
+int daylight;
diff --git a/mdk-stage1/dietlibc/libugly/tzfile.c b/mdk-stage1/dietlibc/libugly/tzfile.c
index 5702d4bea..aca613e56 100644
--- a/mdk-stage1/dietlibc/libugly/tzfile.c
+++ b/mdk-stage1/dietlibc/libugly/tzfile.c
@@ -3,28 +3,30 @@
#include <fcntl.h>
#include <sys/mman.h>
#include <netinet/in.h>
+#include <time.h>
-#include <stdio.h>
+/* #include <stdio.h> */
+
+char* tzname[2];
#ifdef WANT_TZFILE_PARSER
static char *tzfile=0;
static int tzlen=-1;
-void __maplocaltime() {
+void __maplocaltime(void);
+void __maplocaltime(void) {
int fd;
unsigned int len;
if (tzlen>=0) return;
tzlen=0;
if ((fd=open("/etc/localtime",O_RDONLY))<0) return;
len=lseek(fd,0,SEEK_END);
- if ((tzfile=mmap(0,len,PROT_READ,MAP_SHARED,fd,0))==MAP_FAILED) return;
+ if ((tzfile=mmap(0,len,PROT_READ,MAP_PRIVATE,fd,0))==MAP_FAILED) return;
close(fd);
if (ntohl(*(int*)tzfile) != 0x545a6966) return;
tzlen=len;
}
-char *tzset(void) __attribute__((weak,alias("__maplocaltime")));
-
static unsigned long __myntohl(const unsigned char* c) {
return (((unsigned long)c[0])<<24) +
(((unsigned long)c[1])<<16) +
@@ -32,6 +34,7 @@ static unsigned long __myntohl(const unsigned char* c) {
((unsigned long)c[3]);
}
+time_t __tzfile_map(time_t t, int *isdst);
time_t __tzfile_map(time_t t, int *isdst) {
/* "TZif" plus 16 reserved bytes. */
char *tmp;
@@ -64,23 +67,41 @@ time_t __tzfile_map(time_t t, int *isdst) {
printf("%s(%lu,%d,%d)",i?", ":"",ntohl(*(int*)tmp),tmp[4],tmp[5]); tmp+=6;
}
printf("\n");
+ for (i=0; i<tzh_charcnt; ++i) {
+ printf("%s\"%s\"",i?", ":"",tmp);
+ tmp+=strlen(tmp);
+ }
+ printf("\n");
#endif
tmp=tzfile+20+6*4;
- for (i=0; i<tzh_timecnt; ++i)
+ daylight=(tzh_timecnt>0);
+ for (i=0; i<tzh_timecnt; ++i) {
if ((time_t)__myntohl(tmp+i*4) >= t) {
+ char* tz=tmp;
/* printf("match at %d\n",i); */
tmp+=tzh_timecnt*4;
i=tmp[i-1];
/* printf("using index %d\n",i); */
tmp+=tzh_timecnt;
+ tz+=tzh_timecnt*5+tzh_leapcnt*4+tzh_typecnt*6;
tmp+=i*6;
/* printf("(%lu,%d,%d)\n",ntohl(*(int*)tmp),tmp[4],tmp[5]); */
*isdst=tmp[4];
- return t+__myntohl(tmp);
+ tzname[0]=tz+tmp[5];
+ timezone=-(__myntohl(tmp));
+ return t-timezone;
}
+ }
return t;
}
+
+void tzset(void) {
+ int isdst;
+ __maplocaltime();
+ __tzfile_map(time(0),&isdst);
+}
+
#else
-void tzset(void) __attribute__((weak,alias("return0")));
+void tzset(void) __attribute__((weak,alias("__nop")));
#endif
diff --git a/mdk-stage1/dietlibc/libugly/unlockpt.c b/mdk-stage1/dietlibc/libugly/unlockpt.c
new file mode 100644
index 000000000..e0246ed8e
--- /dev/null
+++ b/mdk-stage1/dietlibc/libugly/unlockpt.c
@@ -0,0 +1,10 @@
+#define _XOPEN_SOURCE
+#include <sys/ioctl.h>
+#include <unistd.h>
+#include <stdlib.h>
+
+int unlockpt (int fd) {
+ int foo;
+ /* hehe, that one is easy */
+ return (ioctl (fd, TIOCSPTLCK, &foo));
+}
diff --git a/mdk-stage1/dietlibc/libugly/utent.c b/mdk-stage1/dietlibc/libugly/utent.c
new file mode 100644
index 000000000..d8d5d1ba7
--- /dev/null
+++ b/mdk-stage1/dietlibc/libugly/utent.c
@@ -0,0 +1,103 @@
+#include <unistd.h>
+#include <fcntl.h>
+#include <string.h>
+#include <utmp.h>
+
+static const char *utmp_file_name = _PATH_UTMP;
+static int fd = -1;
+
+static int lock_record(int type) {
+ struct flock fl;
+ fl.l_whence = SEEK_CUR;
+ fl.l_start = 0;
+ fl.l_len = sizeof(struct utmp);
+ fl.l_pid = 0;
+ fl.l_type = type;
+ return fcntl(fd, F_SETLKW, &fl);
+}
+
+static int unlock_record() {
+ struct flock fl;
+ fl.l_whence = SEEK_CUR;
+ fl.l_start = -sizeof(struct utmp);
+ fl.l_len = sizeof(struct utmp);
+ fl.l_pid = 0;
+ fl.l_type = F_UNLCK;
+ return fcntl(fd, F_SETLK, &fl);
+}
+
+void utmpname(const char *file) {
+ if (file)
+ utmp_file_name = file;
+ else
+ utmp_file_name = _PATH_UTMP;
+}
+
+void setutent() {
+ if (fd<0) fd = open(utmp_file_name,O_RDWR);
+ if (fd<0) fd = open(utmp_file_name,O_RDONLY);
+ fcntl (fd, F_SETFD, FD_CLOEXEC);
+ lseek(fd,0,SEEK_SET);
+}
+
+void endutent() {
+ if (fd<0) return;
+ close(fd); fd=-1;
+}
+
+struct utmp *getutent(void) {
+ static struct utmp getutent_tmp;
+ int ret;
+
+ if (fd<0) {
+ setutent();
+ if (fd<0) return 0;
+ }
+ if (lock_record(F_RDLCK)) return 0;
+ ret=read(fd, &getutent_tmp, sizeof(struct utmp));
+ unlock_record();
+ if (ret<1) return 0;
+ return &getutent_tmp;
+}
+
+struct utmp *getutid(struct utmp *ut) {
+ struct utmp *tmp;
+
+ while ((tmp = getutent())) {
+ if (ut->ut_type && (ut->ut_type <= OLD_TIME)) {
+ if (ut->ut_type == tmp->ut_type) break;
+ }
+ if ((ut->ut_type >= INIT_PROCESS) && (ut->ut_type <= DEAD_PROCESS)) {
+ if (!strncmp(ut->ut_id,tmp->ut_id,4)) break;
+ }
+ }
+ return tmp;
+}
+
+struct utmp *getutline(struct utmp *ut) {
+ struct utmp *tmp;
+
+ while ((tmp = getutent())) {
+ if ((tmp->ut_type == USER_PROCESS) || (tmp->ut_type == LOGIN_PROCESS)) {
+ if (!strncmp(ut->ut_line,tmp->ut_line,UT_LINESIZE)) break;
+ }
+ }
+ return tmp;
+}
+
+void pututline(struct utmp *ut) {
+ struct utmp *tmp;
+
+ if ((tmp = getutid(ut))) {
+ lseek(fd, - (off_t)sizeof(struct utmp), SEEK_CUR);
+ if (lock_record(F_WRLCK)) return;
+ write(fd, ut, sizeof(struct utmp));
+ }
+ else {
+ lseek(fd, 0, SEEK_END);
+ if (lock_record(F_WRLCK)) return;
+ write(fd, ut, (off_t)sizeof(struct utmp));
+ }
+ unlock_record();
+}
+
diff --git a/mdk-stage1/dietlibc/libugly/wtent.c b/mdk-stage1/dietlibc/libugly/wtent.c
new file mode 100644
index 000000000..1ca7c3202
--- /dev/null
+++ b/mdk-stage1/dietlibc/libugly/wtent.c
@@ -0,0 +1,30 @@
+#include <unistd.h>
+#include <fcntl.h>
+#include <string.h>
+#include <utmp.h>
+
+void updwtmp(const char *wtmp_file, const struct utmp *ut) {
+ int fd = open(wtmp_file, O_WRONLY|O_APPEND);
+ if (fd<0) return;
+ fcntl (fd, F_SETFD, FD_CLOEXEC);
+ write(fd, ut, sizeof(struct utmp));
+ close(fd);
+}
+
+void logwtmp(const char *line, const char *name, const char *host) {
+ struct utmp ut;
+
+ memset(&ut, 0, sizeof(struct utmp));
+
+ ut.ut_pid = getpid ();
+ ut.ut_type = name[0] ? USER_PROCESS : DEAD_PROCESS;
+
+ memccpy (ut.ut_line, line, 0, sizeof ut.ut_line);
+ memccpy (ut.ut_name, name, 0, sizeof ut.ut_name);
+ memccpy (ut.ut_host, host, 0, sizeof ut.ut_host);
+
+ gettimeofday (&ut.ut_tv, NULL);
+
+ updwtmp (_PATH_WTMP, &ut);
+}
+
diff --git a/mdk-stage1/dietlibc/ppc/__testandset.S b/mdk-stage1/dietlibc/ppc/__testandset.S
index a6063fbb2..146982337 100644
--- a/mdk-stage1/dietlibc/ppc/__testandset.S
+++ b/mdk-stage1/dietlibc/ppc/__testandset.S
@@ -2,10 +2,11 @@
.type __testandset,@function
.align 2
__testandset:
- lwarx 5,0,3
- add 0,4,5
- stwcx 0,0,3
- bne __testandset
+1: lwarx 5,0,3
+ li 0,1
+ stwcx. 0,0,3
+ bne- 1b
+ mr 3,5
blr
.size __testandset,.-__testandset
diff --git a/mdk-stage1/dietlibc/ppc/clone.S b/mdk-stage1/dietlibc/ppc/clone.S
new file mode 100644
index 000000000..98f6bd4e8
--- /dev/null
+++ b/mdk-stage1/dietlibc/ppc/clone.S
@@ -0,0 +1,48 @@
+#include <dietfeatures.h>
+#include "syscalls.h"
+#include <errno.h>
+
+.text
+.weak clone
+clone:
+.global __clone
+__clone:
+ cmpwi 4,0 /* check have non null child_stack pointer */
+ cmpwi cr1, 3,0 /* check have non null thread_funcion */
+ cror eq,4*cr1+eq,eq /* now if eq is set one is or both are zero */
+ beq .Lclone_error
+
+ stwu 1,-32(1) /* alloc some space on the stack */
+ stmw 29, 16(1) /* save r29,r30,r31 on stack */
+
+ rlwinm 4,4,0,0,27 /* mask out lower 4 bits */
+
+ /* move parameter to positions clone wants them */
+ mr 29,3 /* r29 = r3 fn */
+ mr 30,4 /* r30 = r4 stack */
+ mr 31,6 /* r31 = r6 arg */
+ mr 3, 5 /* r3 = r5 flags */
+
+ li 0, __NR_clone /* load syscall nr. */
+ sc
+
+ cmpwi cr1,3,0 /* compare return of syscall with 0 */
+ crandc 4*cr1+eq,4*cr1+eq,so
+ bne .Lclone_parent /* return was non zero -> .Lclone_parent */
+
+ /* we are the cloned process */
+ mr 1, 30 /* set stack pointer */
+ mtctr 29 /* set count register to fn ? */
+ mr 3, 31 /* set argument */
+ bctrl /* branch trough count register and link */
+ b _exit /* exit thread */
+
+.Lclone_parent:
+ lmw 29,16(1) /* restore saved registers */
+ addi 1, 1,32 /* free stack */
+ bnslr+ /* had cloned a thread so return to parent */
+ b error_unified_syscall
+
+.Lclone_error:
+ li 3, EINVAL
+ b error_unified_syscall
diff --git a/mdk-stage1/dietlibc/ppc/mmap.c b/mdk-stage1/dietlibc/ppc/mmap.c
index 25d2926b2..d03e87089 100644
--- a/mdk-stage1/dietlibc/ppc/mmap.c
+++ b/mdk-stage1/dietlibc/ppc/mmap.c
@@ -1,5 +1,7 @@
-#include <linux/types.h>
-#include <linux/unistd.h>
+#include "dietfeatures.h"
+#include <sys/types.h>
+#include <errno.h>
+#include "syscalls.h"
int mmap(void*start,size_t length,int prot,int flags,int fd,off_t offset) {
unsigned long __sc_ret, __sc_err;
@@ -29,9 +31,10 @@ int mmap(void*start,size_t length,int prot,int flags,int fd,off_t offset) {
"r" (__sc_6),
"r" (__sc_7),
"r" (__sc_8)
- : __syscall_clobbers);
+ : "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12");
__sc_ret = __sc_3;
__sc_err = __sc_0;
}
- __syscall_return (int);
+ return (__sc_err & 0x10000000 ? errno = __sc_ret, __sc_ret = -1 : 0),
+ (int) __sc_ret;
}
diff --git a/mdk-stage1/dietlibc/ppc/start.S b/mdk-stage1/dietlibc/ppc/start.S
index c7afeecd2..7b2aed7fb 100644
--- a/mdk-stage1/dietlibc/ppc/start.S
+++ b/mdk-stage1/dietlibc/ppc/start.S
@@ -1,21 +1,17 @@
-#include "start.h"
-
-#ifdef __powerpc__
-
.text
.global _start
.type _start,@function
_start:
/* Save the stack pointer, in case we're statically linked under Linux. */
- mr 9,1
+ mr 9,1
/* Set up an initial stack frame, and clear the LR. */
- clrrwi 1,1,4
- li 0,0
- stwu 1,-16(1)
- mtlr 0
- stw 0,0(1)
+ clrrwi 1,1,4
+ li 0,0
+ stwu 1,-16(1)
+ mtlr 0
+ stw 0,0(1)
- /* r9 enthält den initialen Stackpointer.
+ /* r9 contains the initial stack pointer
argc = (r9)
argv = (r9+4)
envp = argv+(argc+1)*4 */
@@ -27,18 +23,20 @@ _start:
slwi 5,5,2 /* (argc+1)*4 */
add 5,5,4 /* argv+(argc+1)*4 */
- lis 6,environ@ha
- stw 5,environ@l(6)
+ lis 14,environ@ha
+ stw 5,environ@l(14)
+#ifdef WANT_DYNAMIC
+ mr 6,7
+ bl _dyn_start
+#else
bl main
+#endif
b exit
.size _start,.-_start
/* Define a symbol for the first piece of initialized data. */
- .section ".data"
+ .section ".data"
__data_start:
-
-#endif
-
diff --git a/mdk-stage1/dietlibc/ppc/syscalls.h b/mdk-stage1/dietlibc/ppc/syscalls.h
new file mode 100644
index 000000000..5e8707357
--- /dev/null
+++ b/mdk-stage1/dietlibc/ppc/syscalls.h
@@ -0,0 +1,259 @@
+
+#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
+#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_vm86 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_query_module 166
+#define __NR_poll 167
+#define __NR_nfsservctl 168
+#define __NR_setresgid 169
+#define __NR_getresgid 170
+#define __NR_prctl 171
+#define __NR_rt_sigreturn 172
+#define __NR_rt_sigaction 173
+#define __NR_rt_sigprocmask 174
+#define __NR_rt_sigpending 175
+#define __NR_rt_sigtimedwait 176
+#define __NR_rt_sigqueueinfo 177
+#define __NR_rt_sigsuspend 178
+#define __NR_pread 179
+#define __NR_pwrite 180
+#define __NR_chown 181
+#define __NR_getcwd 182
+#define __NR_capget 183
+#define __NR_capset 184
+#define __NR_sigaltstack 185
+#define __NR_sendfile 186
+#define __NR_getpmsg 187 /* some people actually want streams */
+#define __NR_putpmsg 188 /* some people actually want streams */
+#define __NR_vfork 189
+#define __NR_ugetrlimit 190 /* 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_pciconfig_read 198
+#define __NR_pciconfig_write 199
+#define __NR_pciconfig_iobase 200
+#define __NR_multiplexer 201
+#define __NR_getdents64 202
+#define __NR_pivot_root 203
+#define __NR_fcntl64 204
+#define __NR_madvise 205
+#define __NR_mincore 206
+#define __NR_gettid 207
+#define __NR_tkill 208
+#define __NR_setxattr 209
+#define __NR_lsetxattr 210
+#define __NR_fsetxattr 211
+#define __NR_getxattr 212
+#define __NR_lgetxattr 213
+#define __NR_fgetxattr 214
+#define __NR_listxattr 215
+#define __NR_llistxattr 216
+#define __NR_flistxattr 217
+#define __NR_removexattr 218
+#define __NR_lremovexattr 219
+#define __NR_fremovexattr 220
+#define __NR_futex 221
+#define __NR_sched_setaffinity 222
+#define __NR_sched_getaffinity 223
+#define __NR_security 224
+#define __NR_tuxcall 225
+#define __NR_sendfile64 226
+#define __NR_io_setup 227
+#define __NR_io_destroy 228
+#define __NR_io_getevents 229
+#define __NR_io_submit 230
+#define __NR_io_cancel 231
+#define __NR_alloc_hugepages 232
+#define __NR_free_hugepages 233
+#define __NR_exit_group 234
+#define __NR_lookup_dcookie 235
+#define __NR_sys_epoll_create 236
+#define __NR_sys_epoll_ctl 237
+#define __NR_sys_epoll_wait 238
+#define __NR_remap_file_pages 239
+
+#define syscall_weak(name,wsym,sym) \
+.text; \
+.type wsym,@function; \
+.weak wsym; \
+wsym: ; \
+.type sym,@function; \
+.global sym; \
+sym: \
+ li 0,__NR_##name; \
+ b __unified_syscall
+
+#define syscall(name,sym) \
+.text; \
+.type sym,@function; \
+.global sym; \
+sym: \
+ li 0,__NR_##name; \
+ b __unified_syscall
+
diff --git a/mdk-stage1/dietlibc/ppc/unified.S b/mdk-stage1/dietlibc/ppc/unified.S
index d2b419f0b..eb136a96b 100644
--- a/mdk-stage1/dietlibc/ppc/unified.S
+++ b/mdk-stage1/dietlibc/ppc/unified.S
@@ -1,21 +1,40 @@
#include <dietfeatures.h>
+#include "syscalls.h"
.text
+.type exit,@function
+.weak exit
+exit:
+.type _exit,@function
+.global _exit
+_exit:
+ li 0,__NR_exit
.global __unified_syscall
__unified_syscall:
sc
- mfcr 0
- andis. 9,0,4096
- mr 0,3
- beq .L1
-#ifdef WANT_THREAD_SAVE
- bl __set_errno
+ bnslr+
+
+.global error_unified_syscall
+error_unified_syscall:
+#ifdef WANT_THREAD_SAFE
+ stwu 1,-16(1)
+ mflr 0
+ stw 0,20(1)
+ stw 3,12(1)
+ bl __errno_location
+ lwz 0,12(1)
+ stw 0,0(3)
+ lwz 0,20(1)
+ mtlr 0
+ addi 1,1,16
#else
lis 9,errno@ha
stw 3,errno@l(9)
#endif
- li 0,-1
-.L1:
- mr 3,0
+ li 3,-1
+
+/* here we go and "reuse" the return for weak-void functions */
+#include "dietuglyweaks.h"
+
blr
diff --git a/mdk-stage1/dietlibc/profiling/PORTING b/mdk-stage1/dietlibc/profiling/PORTING
new file mode 100644
index 000000000..c3fc5eba7
--- /dev/null
+++ b/mdk-stage1/dietlibc/profiling/PORTING
@@ -0,0 +1,25 @@
+ Porting to other platforms
+
+ ... is easy. Just create an mcount.S in the $ARCH
+ directory (eg. dietlibc/i386) which includes a
+ function (called "mcount") that:
+
+ 1.) saves ALL registers that are freely usable
+ and which might be used by __mcount().
+ 2.) loads the instruction pointer (PC) from the
+ function that called mcount, and the function
+ which called the function, that called mcount
+ into the first two argument registers (or push
+ them on the stack - depending on the processor-
+ architecture).
+ 3.) call __mcount.
+ 4.) restore the registers saved in 1)
+
+ Then You need a macro called PC in <asm/sigcontext.h>
+ which extracts the (instruction pointer / program
+ counter) from a sigcontext structure (eg. on i386 this
+ would be ctx.eip).
+
+ $ARCH/start.S must also be modified to call monitor
+ with the offset of .text and _etext as parameters.
+
diff --git a/mdk-stage1/dietlibc/profiling/README b/mdk-stage1/dietlibc/profiling/README
new file mode 100644
index 000000000..0a0293073
--- /dev/null
+++ b/mdk-stage1/dietlibc/profiling/README
@@ -0,0 +1,37 @@
+
+ Notes on profiling support for dietlibc
+
+ 1.) A big problem when doing profiling on statically linked
+ programs, is that the internal profiling functions (mcount
+ and friends) will be included in the call graph although
+ they would not if the program would have been dynamically
+ linked. This is because every symbol between .text and
+ _etext is included in the call-graph. If a program is
+ dynamically linked, then mcount and friends are not between
+ .text and _etext, so they are not included. A workaround
+ for this, would be to put mcount, __mcount, monitor and
+ profiler into another section (eg. ".profile"), but this
+ creates some strange problems, I'm currently not aware of.
+ If you want to debug this: Putting a function into a specific
+ section works like this (with gcc):
+
+ void foo (int bar) __attribute__ ((section(".foobar")))
+
+ 2.) _start may randomly be found in the callgraph. I don't
+ know why. May be a bug in gprof.
+
+ 3.) The profiling is a complete rewrite, though I looked at
+ the glibc Version for inspiration. Please note that this
+ version might not be as portable as the glibc version but
+ its much smaller (although this is not a really important
+ argument, as profiled binaries seldom get shipped) and
+ hopefully easier to understand.
+
+ 4.) all objects that should be profiled mustn't be compiled
+ with -fomit-frame-pointer (as with glibc). Add
+ -fno-fomit-frame-pointer to $CFLAGS if you're encountering
+ weird problems.
+
+ 5.) There is currently no basic-block statistic support.
+
+Please send comments and bug reports to: tom@rhadamanthys.org
diff --git a/mdk-stage1/dietlibc/profiling/__mcount.c b/mdk-stage1/dietlibc/profiling/__mcount.c
new file mode 100644
index 000000000..b1955f370
--- /dev/null
+++ b/mdk-stage1/dietlibc/profiling/__mcount.c
@@ -0,0 +1,24 @@
+#include <unistd.h>
+#include <sys/gmon.h>
+
+extern struct monparam mparam;
+
+void __mcount (unsigned long, unsigned long) PROF_SECTION;
+
+void
+__mcount (unsigned long frompc, unsigned long selfpc)
+{
+ struct rawarc *arc = mparam.arcs, thisarc;
+ unsigned long num;
+ /* If arc already exists, increment count */
+ for (num = 0; num < mparam.arcnum; num++)
+ if (arc[num].raw_frompc == frompc && arc[num].raw_selfpc == selfpc) {
+ arc[num].raw_count++;
+ return;
+ }
+ if (selfpc < mparam.lowpc || selfpc > mparam.highpc) return;
+ thisarc.raw_frompc = frompc;
+ thisarc.raw_selfpc = selfpc;
+ thisarc.raw_count = 1;
+ arc[mparam.arcnum++] = thisarc;
+}
diff --git a/mdk-stage1/dietlibc/profiling/monitor.c b/mdk-stage1/dietlibc/profiling/monitor.c
new file mode 100644
index 000000000..cc06e3465
--- /dev/null
+++ b/mdk-stage1/dietlibc/profiling/monitor.c
@@ -0,0 +1,93 @@
+/**************************************************************
+ 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 License.
+
+ This file is part of the profiling support for dietlibc
+
+ monitor(3) interface
+
+ *************************************************************/
+#include <sys/uio.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <sys/gmon.h>
+
+typedef unsigned short u_short;
+
+struct monparam mparam;
+
+void monitor (unsigned long, unsigned long) PROF_SECTION;
+void _stop_monitor (void) PROF_SECTION;
+
+/*
+ monitor is called by _start, to start profiling
+ lowpc -> lowest valid program counter (normally .text)
+ highpc -> highest valid program counter (normally _etext)
+*/
+void
+monitor (unsigned long lowpc, unsigned long highpc)
+{
+ mparam.highpc = highpc;
+ mparam.lowpc = lowpc;
+ mparam.kcountsize = (mparam.textsize = highpc-lowpc) << 1;
+ mparam.kcount = (u_short *) malloc (mparam.kcountsize);
+ mparam.arcs = (struct rawarc *) malloc (MAXARCS*sizeof (struct rawarc));
+ if (!mparam.kcount || !mparam.arcs)
+ exit (42);
+ mparam.arcnum = 0;
+ /* start profiling */
+ profil (mparam.kcount, highpc-lowpc, lowpc, 10000);
+}
+
+/*
+ write_gmon - write all data collected by the helper routines
+ to gmon.out
+*/
+static void
+write_gmon (void)
+{
+ struct gmon_hdr ghdr = { "gmon", 1, "" };
+ int fd = open ("gmon.out", O_CREAT | O_RDWR | O_TRUNC, 0666);
+
+ if (fd < 0) return;
+ write (fd, &ghdr, sizeof (ghdr));
+ if (mparam.kcountsize)
+ {
+ char tag = GMON_TAG_TIME_HIST;
+ struct gmon_hist_hdr ghdr = {
+ mparam.lowpc, mparam.highpc,
+ (mparam.kcountsize >> 1), 100, "seconds", 's'
+ };
+ struct iovec iov[3] = {
+ { &tag, sizeof (tag) },
+ { &ghdr, sizeof (ghdr) },
+ { mparam.kcount, mparam.kcountsize >> 1 << 1 }
+ };
+ writev (fd, iov, 3);
+ }
+ if (mparam.arcnum)
+ {
+ char tag = GMON_TAG_CG_ARC;
+ struct iovec iov[mparam.arcnum*2];
+ unsigned long l;
+ for (l=0;l<mparam.arcnum;l++) {
+ iov[l*2].iov_base = &tag;
+ iov[l*2].iov_len = sizeof (tag);
+ iov[l*2+1].iov_base = &mparam.arcs[l];
+ iov[l*2+1].iov_len = sizeof (mparam.arcs[l]);
+ }
+ writev (fd, iov, mparam.arcnum*2);
+ }
+ close (fd);
+}
+
+/* called by _start before exit */
+void
+_stop_monitor (void)
+{
+ profil (NULL, 0, 0, 0);
+ write_gmon ();
+}
diff --git a/mdk-stage1/dietlibc/profiling/profil.c b/mdk-stage1/dietlibc/profiling/profil.c
new file mode 100644
index 000000000..fa9a0ef2b
--- /dev/null
+++ b/mdk-stage1/dietlibc/profiling/profil.c
@@ -0,0 +1,75 @@
+/******************************************************
+ 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 License.
+
+ This file is part of the profiling support for dietlibc
+
+ profil (3) generic implementation
+
+ *************************************************************/
+
+#include <asm/sigcontext.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <unistd.h>
+#include <signal.h>
+
+#define SHORT_SIZE sizeof (short)
+#define MAX_SHORT 65536
+
+#ifdef DEBUG
+# include <stdio.h>
+# define debug printf
+#else
+# define debug
+#endif
+
+#ifndef u_short
+# define u_short unsigned short
+#endif
+
+#ifndef u_int
+# define u_int unsigned int
+#endif
+
+static unsigned short *buffer = NULL;
+static size_t maxhits = 0;
+static unsigned long low_pc = 0;
+static unsigned long pscale = 0;
+
+/* profiler - helper function for profil(3) */
+static void
+profiler (int signal, struct sigcontext ctx)
+{
+ size_t s = PC(ctx)-low_pc;
+ (void)signal;
+ if ((PC(ctx)) < low_pc) return;
+ s >>= 1;
+ if (s < maxhits)
+ ++buffer[s];
+}
+
+/* profil(3) - start or stop the profiling timer */
+int
+profil (u_short *buf, size_t bufsiz, size_t offset, u_int scale)
+{
+ struct itimerval itv = { { 0, 1 }, { 0, 1 } };
+ struct sigaction sa;
+ if (!buf) {
+ sigaction (SIGPROF, NULL, NULL);
+ setitimer (ITIMER_PROF, NULL, NULL);
+ return (0);
+ }
+ sa.sa_handler = (sighandler_t)&profiler;
+ sa.sa_flags = SA_RESTART;
+ sigfillset (&sa.sa_mask);
+ sigaction (SIGPROF, &sa, NULL);
+ pscale = scale;
+ buffer = buf;
+ low_pc = offset;
+ maxhits = bufsiz/SHORT_SIZE;
+
+ return (setitimer (ITIMER_PROF, &itv, &itv));
+}
diff --git a/mdk-stage1/dietlibc/sparc/__longjmp.S b/mdk-stage1/dietlibc/sparc/__longjmp.S
index 72e001a2f..6550d2b5c 100644
--- a/mdk-stage1/dietlibc/sparc/__longjmp.S
+++ b/mdk-stage1/dietlibc/sparc/__longjmp.S
@@ -10,6 +10,7 @@
.text
.global __longjmp
+.type __longjmp,function
__longjmp:
/* Store our arguments in global registers so we can still
use them while unwinding frames and their register windows. */
diff --git a/mdk-stage1/dietlibc/sparc/clone.S b/mdk-stage1/dietlibc/sparc/clone.S
index 58b438249..fd8d1d126 100644
--- a/mdk-stage1/dietlibc/sparc/clone.S
+++ b/mdk-stage1/dietlibc/sparc/clone.S
@@ -1,10 +1,11 @@
-#include <asm/errno.h>
-#include <asm/unistd.h>
+#include <errno.h>
+#include "syscalls.h"
.text
.align 4
.weak clone
clone:
+.type __clone,#function
.global __clone
__clone:
save %sp, -96, %sp
diff --git a/mdk-stage1/dietlibc/sparc/fork.S b/mdk-stage1/dietlibc/sparc/fork.S
index 869c9b30c..a54cab2a9 100644
--- a/mdk-stage1/dietlibc/sparc/fork.S
+++ b/mdk-stage1/dietlibc/sparc/fork.S
@@ -10,7 +10,7 @@ __libc_fork:
bcc,a 1f
nop
save %sp, -96, %sp
-#ifdef WANT_THREAD_SAVE
+#ifdef WANT_THREAD_SAFE
call __errno_location
nop
#else
diff --git a/mdk-stage1/dietlibc/sparc/mmap.c b/mdk-stage1/dietlibc/sparc/mmap.c
index 25ebdc24e..5342bac4e 100644
--- a/mdk-stage1/dietlibc/sparc/mmap.c
+++ b/mdk-stage1/dietlibc/sparc/mmap.c
@@ -1,5 +1,5 @@
-#include <linux/types.h>
-#include <linux/unistd.h>
+#include <sys/types.h>
+#include "syscalls.h"
#define __SYSCALL_STRING \
"ta 0x10;" \
diff --git a/mdk-stage1/dietlibc/sparc/pipe.S b/mdk-stage1/dietlibc/sparc/pipe.S
index 820da2570..076822765 100644
--- a/mdk-stage1/dietlibc/sparc/pipe.S
+++ b/mdk-stage1/dietlibc/sparc/pipe.S
@@ -9,7 +9,7 @@ pipe:
bcc,a 1f
nop
save %sp, -96, %sp
-#ifdef WANT_THREAD_SAVE
+#ifdef WANT_THREAD_SAFE
call __errno_location
nop
#else
diff --git a/mdk-stage1/dietlibc/sparc/setjmp.S b/mdk-stage1/dietlibc/sparc/setjmp.S
index efc5a7013..579df757c 100644
--- a/mdk-stage1/dietlibc/sparc/setjmp.S
+++ b/mdk-stage1/dietlibc/sparc/setjmp.S
@@ -6,32 +6,34 @@
#define ST_FLUSH_WINDOWS 0x03
-.section .rodata
.text
.globl __setjmp
+.type __setjmp,function
__setjmp:
- b 1f
- set 0, %o1
+ b 1f
+ set 0, %o1
.size __setjmp,.-__setjmp
.globl setjmp
+.type setjmp,function
setjmp:
- set 1, %o1
+ set 1, %o1
.size setjmp,.-setjmp
.globl __sigsetjmp
+.type __sigsetjmp,function
__sigsetjmp:
1:
- /* Save our PC, SP and FP. Save the signal mask if requested with
- a tail-call for simplicity; it always returns zero. */
- ta ST_FLUSH_WINDOWS
+ /* Save our PC, SP and FP. Save the signal mask if requested with
+ a tail-call for simplicity; it always returns zero. */
+ ta ST_FLUSH_WINDOWS
- st %o7, [%o0 + (JB_PC * 4)]
- st %sp, [%o0 + (JB_SP * 4)]
- st %fp, [%o0 + (JB_FP * 4)]
+ st %o7, [%o0 + (JB_PC * 4)]
+ st %sp, [%o0 + (JB_SP * 4)]
+ st %fp, [%o0 + (JB_FP * 4)]
- mov %o7, %g1
- call __sigjmp_save
- mov %g1, %o7
+ mov %o7, %g1
+ call __sigjmp_save
+ mov %g1, %o7
.size __sigsetjmp,.-__sigsetjmp
diff --git a/mdk-stage1/dietlibc/sparc/shmat.c b/mdk-stage1/dietlibc/sparc/shmat.c
index 73b2d89a9..b7dce2e83 100644
--- a/mdk-stage1/dietlibc/sparc/shmat.c
+++ b/mdk-stage1/dietlibc/sparc/shmat.c
@@ -1,7 +1,7 @@
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
-#include <asm/ipc.h>
+#include <unistd.h>
extern void* __ipc();
diff --git a/mdk-stage1/dietlibc/sparc/sigaction.c b/mdk-stage1/dietlibc/sparc/sigaction.c
new file mode 100644
index 000000000..028723699
--- /dev/null
+++ b/mdk-stage1/dietlibc/sparc/sigaction.c
@@ -0,0 +1,7 @@
+#include <signal.h>
+
+int __rt_sigaction(int signum, const struct sigaction *act, struct sigaction *oldact, void* restorer, long nr);
+
+int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact) {
+ return __rt_sigaction(signum, act, oldact, 0, _NSIG/8);
+}
diff --git a/mdk-stage1/dietlibc/sparc/start.S b/mdk-stage1/dietlibc/sparc/start.S
index e948aaddc..c6408ee8f 100644
--- a/mdk-stage1/dietlibc/sparc/start.S
+++ b/mdk-stage1/dietlibc/sparc/start.S
@@ -1,46 +1,50 @@
-#include "start.h"
-
-#ifdef __sparc__
- .section ".text"
- .align 4
- .global _start
- .type _start,@function
+ .section ".text"
+ .align 4
+ .global _start
+ .type _start,@function
_start:
- /* Terminate the stack frame, and reserve space for functions to
- drop their arguments. */
- mov %g0, %fp
- sub %sp, 6*4, %sp
+/* Terminate the stack frame, and reserve space for functions to
+ drop their arguments. */
+ mov %g0, %fp
+ sub %sp, 6*4, %sp
- /* Extract the arguments and environment as encoded on the stack. The
- argument info starts after one register window (16 words) past the SP. */
- ld [%sp+22*4], %o0
- add %sp, 23*4, %o1
+/* Extract the arguments and environment as encoded on the stack. The
+ argument info starts after one register window (16 words) past the SP. */
+ ld [%sp+22*4], %o0
+ add %sp, 23*4, %o1
add %o1, %o0, %o2
add %o2, %o0, %o2
add %o2, %o0, %o2
add %o2, %o0, %o2
add %o2, 4, %o2
- sethi %hi(environ), %o3
- or %o3, %lo(environ), %o3
+ sethi %hi(environ), %o3
+ or %o3, %lo(environ), %o3
st %o2, [%o3]
- /* When starting a binary via the dynamic linker, %g1 contains the
- address of the shared library termination function, which will be
- registered with atexit(). If we are statically linked, this will
- be NULL. */
+/* When starting a binary via the dynamic linker, %g1 contains the
+ address of the shared library termination function, which will be
+ registered with atexit(). If we are statically linked, this will
+ be NULL. */
- /* Let libc do the rest of the initialization, and call main. */
+/* Let libc do the rest of the initialization, and call main. */
+#ifdef WANT_DYNAMIC
+ call dyn_start
+#else
call main
- mov %g1, %o5
+#endif
+ mov %g1, %o3
b exit
mov %o0, %i0
- /* Die very horribly if exit returns. */
- unimp
+/* Die very horribly if exit returns. */
- .size _start, .-_start
-#endif
+/* here we go and "reuse" the return for weak-void functions */
+#include "dietuglyweaks.h"
+ ret
+ nop
+
+ .size _start, .-_start
diff --git a/mdk-stage1/dietlibc/sparc/strlen.S b/mdk-stage1/dietlibc/sparc/strlen.S
new file mode 100644
index 000000000..59ffb7981
--- /dev/null
+++ b/mdk-stage1/dietlibc/sparc/strlen.S
@@ -0,0 +1,11 @@
+.text
+.globl strlen
+strlen:
+ add %o0, 1, %o1
+.Lloop:
+ ldsb [%o0], %o2
+ orcc %o2, %o2, %g0
+ bne .Lloop
+ add %o0, 1, %o0
+ retl
+ sub %o0, %o1, %o0
diff --git a/mdk-stage1/dietlibc/sparc/syscalls.h b/mdk-stage1/dietlibc/sparc/syscalls.h
new file mode 100644
index 000000000..ea5227c71
--- /dev/null
+++ b/mdk-stage1/dietlibc/sparc/syscalls.h
@@ -0,0 +1,276 @@
+
+#define __NR_exit 1 /* Common */
+#define __NR_fork 2 /* Common */
+#define __NR_read 3 /* Common */
+#define __NR_write 4 /* Common */
+#define __NR_open 5 /* Common */
+#define __NR_close 6 /* Common */
+#define __NR_wait4 7 /* Common */
+#define __NR_creat 8 /* Common */
+#define __NR_link 9 /* Common */
+#define __NR_unlink 10 /* Common */
+#define __NR_execv 11 /* SunOS Specific */
+#define __NR_chdir 12 /* Common */
+#define __NR_chown 13 /* Common */
+#define __NR_mknod 14 /* Common */
+#define __NR_chmod 15 /* Common */
+#define __NR_lchown 16 /* Common */
+#define __NR_brk 17 /* Common */
+#define __NR_perfctr 18 /* Performance counter operations */
+#define __NR_lseek 19 /* Common */
+#define __NR_getpid 20 /* Common */
+#define __NR_capget 21 /* Linux Specific */
+#define __NR_capset 22 /* Linux Specific */
+#define __NR_setuid 23 /* Implemented via setreuid in SunOS */
+#define __NR_getuid 24 /* Common */
+/* #define __NR_time alias 25 ENOSYS under SunOS */
+#define __NR_ptrace 26 /* Common */
+#define __NR_alarm 27 /* Implemented via setitimer in SunOS */
+#define __NR_sigaltstack 28 /* Common */
+#define __NR_pause 29 /* Is sigblock(0)->sigpause() in SunOS */
+#define __NR_utime 30 /* Implemented via utimes() under SunOS */
+#define __NR_lchown32 31 /* Linux sparc32 specific */
+#define __NR_fchown32 32 /* Linux sparc32 specific */
+#define __NR_access 33 /* Common */
+#define __NR_nice 34 /* Implemented via get/setpriority() in SunOS */
+#define __NR_chown32 35 /* Linux sparc32 specific */
+#define __NR_sync 36 /* Common */
+#define __NR_kill 37 /* Common */
+#define __NR_stat 38 /* Common */
+#define __NR_sendfile 39 /* Linux Specific */
+#define __NR_lstat 40 /* Common */
+#define __NR_dup 41 /* Common */
+#define __NR_pipe 42 /* Common */
+#define __NR_times 43 /* Implemented via getrusage() in SunOS */
+#define __NR_getuid32 44 /* Linux sparc32 specific */
+#define __NR_umount2 45 /* Linux Specific */
+#define __NR_setgid 46 /* Implemented via setregid() in SunOS */
+#define __NR_getgid 47 /* Common */
+#define __NR_signal 48 /* Implemented via sigvec() in SunOS */
+#define __NR_geteuid 49 /* SunOS calls getuid() */
+#define __NR_getegid 50 /* SunOS calls getgid() */
+#define __NR_acct 51 /* Common */
+/* #define __NR_memory_ordering 52 Linux sparc64 specific */
+#define __NR_getgid32 53 /* Linux sparc32 specific */
+#define __NR_ioctl 54 /* Common */
+#define __NR_reboot 55 /* Common */
+#define __NR_mmap2 56 /* Linux sparc32 Specific */
+#define __NR_symlink 57 /* Common */
+#define __NR_readlink 58 /* Common */
+#define __NR_execve 59 /* Common */
+#define __NR_umask 60 /* Common */
+#define __NR_chroot 61 /* Common */
+#define __NR_fstat 62 /* Common */
+#define __NR_fstat64 63 /* Linux sparc32 Specific */
+#define __NR_getpagesize 64 /* Common */
+#define __NR_msync 65 /* Common in newer 1.3.x revs... */
+#define __NR_vfork 66 /* Common */
+#define __NR_pread 67 /* Linux Specific */
+#define __NR_pwrite 68 /* Linux Specific */
+#define __NR_geteuid32 69 /* Linux sparc32, sbrk under SunOS */
+#define __NR_getegid32 70 /* Linux sparc32, sstk under SunOS */
+#define __NR_mmap 71 /* Common */
+#define __NR_setreuid32 72 /* Linux sparc32, vadvise under SunOS */
+#define __NR_munmap 73 /* Common */
+#define __NR_mprotect 74 /* Common */
+#define __NR_madvise 75 /* Common */
+#define __NR_vhangup 76 /* Common */
+#define __NR_truncate64 77 /* Linux sparc32 Specific */
+#define __NR_mincore 78 /* Common */
+#define __NR_getgroups 79 /* Common */
+#define __NR_setgroups 80 /* Common */
+#define __NR_getpgrp 81 /* Common */
+#define __NR_setgroups32 82 /* Linux sparc32, setpgrp under SunOS */
+#define __NR_setitimer 83 /* Common */
+#define __NR_ftruncate64 84 /* Linux sparc32 Specific */
+#define __NR_swapon 85 /* Common */
+#define __NR_getitimer 86 /* Common */
+#define __NR_setuid32 87 /* Linux sparc32, gethostname under SunOS */
+#define __NR_sethostname 88 /* Common */
+#define __NR_setgid32 89 /* Linux sparc32, getdtablesize under SunOS */
+#define __NR_dup2 90 /* Common */
+#define __NR_setfsuid32 91 /* Linux sparc32, getdopt under SunOS */
+#define __NR_fcntl 92 /* Common */
+#define __NR_select 93 /* Common */
+#define __NR_setfsgid32 94 /* Linux sparc32, setdopt under SunOS */
+#define __NR_fsync 95 /* Common */
+#define __NR_setpriority 96 /* Common */
+#define __NR_socket 97 /* Common */
+#define __NR_connect 98 /* Common */
+#define __NR_accept 99 /* Common */
+#define __NR_getpriority 100 /* Common */
+#define __NR_rt_sigreturn 101 /* Linux Specific */
+#define __NR_rt_sigaction 102 /* Linux Specific */
+#define __NR_rt_sigprocmask 103 /* Linux Specific */
+#define __NR_rt_sigpending 104 /* Linux Specific */
+#define __NR_rt_sigtimedwait 105 /* Linux Specific */
+#define __NR_rt_sigqueueinfo 106 /* Linux Specific */
+#define __NR_rt_sigsuspend 107 /* Linux Specific */
+#define __NR_setresuid32 108 /* Linux Specific, sigvec under SunOS */
+#define __NR_getresuid32 109 /* Linux Specific, sigblock under SunOS */
+#define __NR_setresgid32 110 /* Linux Specific, sigsetmask under SunOS */
+#define __NR_getresgid32 111 /* Linux Specific, sigpause under SunOS */
+#define __NR_setregid32 112 /* Linux sparc32, sigstack under SunOS */
+#define __NR_recvmsg 113 /* Common */
+#define __NR_sendmsg 114 /* Common */
+#define __NR_getgroups32 115 /* Linux sparc32, vtrace under SunOS */
+#define __NR_gettimeofday 116 /* Common */
+#define __NR_getrusage 117 /* Common */
+#define __NR_getsockopt 118 /* Common */
+#define __NR_getcwd 119 /* Linux Specific */
+#define __NR_readv 120 /* Common */
+#define __NR_writev 121 /* Common */
+#define __NR_settimeofday 122 /* Common */
+#define __NR_fchown 123 /* Common */
+#define __NR_fchmod 124 /* Common */
+#define __NR_recvfrom 125 /* Common */
+#define __NR_setreuid 126 /* Common */
+#define __NR_setregid 127 /* Common */
+#define __NR_rename 128 /* Common */
+#define __NR_truncate 129 /* Common */
+#define __NR_ftruncate 130 /* Common */
+#define __NR_flock 131 /* Common */
+#define __NR_lstat64 132 /* Linux sparc32 Specific */
+#define __NR_sendto 133 /* Common */
+#define __NR_shutdown 134 /* Common */
+#define __NR_socketpair 135 /* Common */
+#define __NR_mkdir 136 /* Common */
+#define __NR_rmdir 137 /* Common */
+#define __NR_utimes 138 /* SunOS Specific */
+#define __NR_stat64 139 /* Linux sparc32 Specific */
+/* #define __NR_adjtime 140 SunOS Specific */
+#define __NR_getpeername 141 /* Common */
+/* #define __NR_gethostid 142 SunOS Specific */
+/* #define __NR_ni_syscall 143 ENOSYS under SunOS */
+#define __NR_getrlimit 144 /* Common */
+#define __NR_setrlimit 145 /* Common */
+#define __NR_pivot_root 146 /* Linux Specific, killpg under SunOS */
+#define __NR_prctl 147 /* ENOSYS under SunOS */
+#define __NR_pciconfig_read 148 /* ENOSYS under SunOS */
+#define __NR_pciconfig_write 149 /* ENOSYS under SunOS */
+#define __NR_getsockname 150 /* Common */
+/* #define __NR_getmsg 151 SunOS Specific */
+/* #define __NR_putmsg 152 SunOS Specific */
+#define __NR_poll 153 /* Common */
+#define __NR_getdents64 154 /* Linux specific */
+#define __NR_fcntl64 155 /* Linux sparc32 Specific */
+/* #define __NR_getdirentries 156 SunOS Specific */
+#define __NR_statfs 157 /* Common */
+#define __NR_fstatfs 158 /* Common */
+#define __NR_umount 159 /* Common */
+/* #define __NR_async_daemon 160 SunOS Specific */
+/* #define __NR_getfh 161 SunOS Specific */
+#define __NR_getdomainname 162 /* SunOS Specific */
+#define __NR_setdomainname 163 /* Common */
+/* #define __NR_ni_syscall 164 ENOSYS under SunOS */
+#define __NR_quotactl 165 /* Common */
+/* #define __NR_exportfs 166 SunOS Specific */
+#define __NR_mount 167 /* Common */
+#define __NR_ustat 168 /* Common */
+/* #define __NR_semsys 169 SunOS Specific */
+/* #define __NR_msgsys 170 SunOS Specific */
+/* #define __NR_shmsys 171 SunOS Specific */
+/* #define __NR_auditsys 172 SunOS Specific */
+/* #define __NR_rfssys 173 SunOS Specific */
+#define __NR_getdents 174 /* Common */
+#define __NR_setsid 175 /* Common */
+#define __NR_fchdir 176 /* Common */
+/* #define __NR_fchroot 177 SunOS Specific */
+/* #define __NR_vpixsys 178 SunOS Specific */
+/* #define __NR_aioread 179 SunOS Specific */
+/* #define __NR_aiowrite 180 SunOS Specific */
+/* #define __NR_aiowait 181 SunOS Specific */
+/* #define __NR_aiocancel 182 SunOS Specific */
+#define __NR_sigpending 183 /* Common */
+#define __NR_query_module 184 /* Linux Specific */
+#define __NR_setpgid 185 /* Common */
+/* #define __NR_pathconf 186 SunOS Specific */
+/* #define __NR_fpathconf 187 SunOS Specific */
+/* #define __NR_sysconf 188 SunOS Specific */
+#define __NR_uname 189 /* Linux Specific */
+#define __NR_init_module 190 /* Linux Specific */
+#define __NR_personality 191 /* Linux Specific */
+/* #define __NR_prof 192 Linux Specific */
+/* #define __NR_break 193 Linux Specific */
+/* #define __NR_lock 194 Linux Specific */
+/* #define __NR_mpx 195 Linux Specific */
+/* #define __NR_ulimit 196 Linux Specific */
+#define __NR_getppid 197 /* Linux Specific */
+#define __NR_sigaction 198 /* Linux Specific */
+#define __NR_sgetmask 199 /* Linux Specific */
+#define __NR_ssetmask 200 /* Linux Specific */
+#define __NR_sigsuspend 201 /* Linux Specific */
+#define __NR_oldlstat 202 /* Linux Specific */
+#define __NR_uselib 203 /* Linux Specific */
+#define __NR_readdir 204 /* Linux Specific */
+/* #define __NR_ioperm 205 Linux Specific - i386 specific, unused */
+#define __NR_socketcall 206 /* Linux Specific */
+#define __NR_syslog 207 /* Linux Specific */
+/* #define __NR_olduname 208 Linux Specific */
+/* #define __NR_iopl 209 Linux Specific - i386 specific, unused */
+/* #define __NR_idle 210 Linux Specific - was sys_idle, now unused */
+/* #define __NR_vm86 211 Linux Specific - i386 specific, unused */
+#define __NR_waitpid 212 /* Linux Specific */
+#define __NR_swapoff 213 /* Linux Specific */
+#define __NR_sysinfo 214 /* Linux Specific */
+#define __NR_ipc 215 /* Linux Specific */
+#define __NR_sigreturn 216 /* Linux Specific */
+#define __NR_clone 217 /* Linux Specific */
+/* #define __NR_modify_ldt 218 Linux Specific - i386 specific, unused */
+#define __NR_adjtimex 219 /* Linux Specific */
+#define __NR_sigprocmask 220 /* Linux Specific */
+#define __NR_create_module 221 /* Linux Specific */
+#define __NR_delete_module 222 /* Linux Specific */
+#define __NR_get_kernel_syms 223 /* Linux Specific */
+#define __NR_getpgid 224 /* Linux Specific */
+#define __NR_bdflush 225 /* Linux Specific */
+#define __NR_sysfs 226 /* Linux Specific */
+#define __NR_afs_syscall 227 /* Linux Specific */
+#define __NR_setfsuid 228 /* Linux Specific */
+#define __NR_setfsgid 229 /* Linux Specific */
+#define __NR__newselect 230 /* Linux Specific */
+#define __NR_time 231 /* Linux Specific */
+/* #define __NR_oldstat 232 Linux Specific */
+#define __NR_stime 233 /* Linux Specific */
+/* #define __NR_oldfstat 234 Linux Specific */
+/* #define __NR_phys 235 Linux Specific */
+#define __NR__llseek 236 /* Linux Specific */
+#define __NR_mlock 237
+#define __NR_munlock 238
+#define __NR_mlockall 239
+#define __NR_munlockall 240
+#define __NR_sched_setparam 241
+#define __NR_sched_getparam 242
+#define __NR_sched_setscheduler 243
+#define __NR_sched_getscheduler 244
+#define __NR_sched_yield 245
+#define __NR_sched_get_priority_max 246
+#define __NR_sched_get_priority_min 247
+#define __NR_sched_rr_get_interval 248
+#define __NR_nanosleep 249
+#define __NR_mremap 250
+#define __NR__sysctl 251
+#define __NR_getsid 252
+#define __NR_fdatasync 253
+#define __NR_nfsservctl 254
+#define __NR_aplib 255
+
+#define syscall_weak(name,wsym,sym) \
+.text; \
+.type wsym,function; \
+.weak wsym; \
+wsym: ; \
+.type sym,function; \
+.global sym; \
+sym: \
+ b __unified_syscall; \
+ mov __NR_##name, %g1
+
+#define syscall(name,sym) \
+.text; \
+.type sym,function; \
+.global sym; \
+sym: \
+ b __unified_syscall; \
+ mov __NR_##name, %g1
+
diff --git a/mdk-stage1/dietlibc/sparc/unified.S b/mdk-stage1/dietlibc/sparc/unified.S
index 3cd609da5..873a522df 100644
--- a/mdk-stage1/dietlibc/sparc/unified.S
+++ b/mdk-stage1/dietlibc/sparc/unified.S
@@ -1,6 +1,14 @@
#include <dietfeatures.h>
+#include "syscalls.h"
.text
+.weak exit
+.type exit,function
+exit:
+.global _exit
+.type _exit,function
+_exit:
+ mov __NR_exit, %g1
.global __unified_syscall
__unified_syscall:
ta 0x10
@@ -14,7 +22,7 @@ __unified_syscall:
cmp %l2, 0xfe
bgu 2f
neg %i0, %l3
-#ifdef WANT_THREAD_SAVE
+#ifdef WANT_THREAD_SAFE
call __errno_location
nop
#else
diff --git a/mdk-stage1/dietlibc/syscalls.c/_llseek.c b/mdk-stage1/dietlibc/syscalls.c/_llseek.c
deleted file mode 100644
index fdf49eba5..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/_llseek.c
+++ /dev/null
@@ -1,5 +0,0 @@
-#include <unistd.h>
-#include <sys/types.h>
-#include "syscalls.h"
-
-_syscall5(int,_llseek,uint,fd,ulong,hi,ulong,lo,loff_t*,res,uint,wh);
diff --git a/mdk-stage1/dietlibc/syscalls.c/_newselect.c b/mdk-stage1/dietlibc/syscalls.c/_newselect.c
deleted file mode 100644
index cb42193bd..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/_newselect.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <linux/types.h>
-#include <linux/time.h>
-#include "syscalls.h"
-
-_syscall5(int,_newselect,int,n,fd_set *,rd,fd_set *,wr,fd_set *,ex,struct timeval *,timeval);
-
diff --git a/mdk-stage1/dietlibc/syscalls.c/access.c b/mdk-stage1/dietlibc/syscalls.c/access.c
deleted file mode 100644
index 80944733a..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/access.c
+++ /dev/null
@@ -1,4 +0,0 @@
-#include <linux/types.h>
-#include "syscalls.h"
-
-_syscall2(int,access,const char*,pathname,int,mode)
diff --git a/mdk-stage1/dietlibc/syscalls.c/chdir.c b/mdk-stage1/dietlibc/syscalls.c/chdir.c
deleted file mode 100644
index a679f528d..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/chdir.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#include "syscalls.h"
-
-_syscall1(int,chdir,void*,path)
diff --git a/mdk-stage1/dietlibc/syscalls.c/chmod.c b/mdk-stage1/dietlibc/syscalls.c/chmod.c
deleted file mode 100644
index 80ad33b40..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/chmod.c
+++ /dev/null
@@ -1,5 +0,0 @@
-#include <linux/types.h>
-#include "syscalls.h"
-
-_syscall2(int,chmod,const char * ,path,mode_t,mode)
-
diff --git a/mdk-stage1/dietlibc/syscalls.c/chown.c b/mdk-stage1/dietlibc/syscalls.c/chown.c
deleted file mode 100644
index 5a9352684..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/chown.c
+++ /dev/null
@@ -1,5 +0,0 @@
-#include <linux/types.h>
-#include "syscalls.h"
-
-_syscall3(int,chown,char*,path,uid_t,owner,gid_t,group)
-
diff --git a/mdk-stage1/dietlibc/syscalls.c/chroot.c b/mdk-stage1/dietlibc/syscalls.c/chroot.c
deleted file mode 100644
index ab39f7ebe..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/chroot.c
+++ /dev/null
@@ -1,4 +0,0 @@
-#include "syscalls.h"
-
-_syscall1(int,chroot,void*,path)
-
diff --git a/mdk-stage1/dietlibc/syscalls.c/clone.c b/mdk-stage1/dietlibc/syscalls.c/clone.c
deleted file mode 100644
index 985eee4c8..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/clone.c
+++ /dev/null
@@ -1 +0,0 @@
-#warning "No CLONE support yet"
diff --git a/mdk-stage1/dietlibc/syscalls.c/close.c b/mdk-stage1/dietlibc/syscalls.c/close.c
deleted file mode 100644
index a7d7f0076..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/close.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#include "syscalls.h"
-
-_syscall1(int,close,int,fd)
diff --git a/mdk-stage1/dietlibc/syscalls.c/dup.c b/mdk-stage1/dietlibc/syscalls.c/dup.c
deleted file mode 100644
index 9c28f0bd6..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/dup.c
+++ /dev/null
@@ -1,4 +0,0 @@
-#include "syscalls.h"
-
-_syscall1(int,dup,int,fd)
-
diff --git a/mdk-stage1/dietlibc/syscalls.c/dup2.c b/mdk-stage1/dietlibc/syscalls.c/dup2.c
deleted file mode 100644
index 399314aa8..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/dup2.c
+++ /dev/null
@@ -1,4 +0,0 @@
-#include "syscalls.h"
-
-_syscall2(int,dup2,int,one,int,two)
-
diff --git a/mdk-stage1/dietlibc/syscalls.c/execve.c b/mdk-stage1/dietlibc/syscalls.c/execve.c
deleted file mode 100644
index c2bac0117..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/execve.c
+++ /dev/null
@@ -1,4 +0,0 @@
-#include "syscalls.h"
-
-_syscall3(int,execve,const char *,fn,void *,argv,void *,envp)
-
diff --git a/mdk-stage1/dietlibc/syscalls.c/exit.c b/mdk-stage1/dietlibc/syscalls.c/exit.c
deleted file mode 100644
index 87087c939..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/exit.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#include "syscalls.h"
-
-_syscall1(int,exit,int,exitcode)
diff --git a/mdk-stage1/dietlibc/syscalls.c/fchdir.c b/mdk-stage1/dietlibc/syscalls.c/fchdir.c
deleted file mode 100644
index b3a41dc7a..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/fchdir.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#include "syscalls.h"
-
-_syscall1(int,fchdir,int,fd)
diff --git a/mdk-stage1/dietlibc/syscalls.c/fchmod.c b/mdk-stage1/dietlibc/syscalls.c/fchmod.c
deleted file mode 100644
index 09e52b6c7..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/fchmod.c
+++ /dev/null
@@ -1,5 +0,0 @@
-#include <linux/types.h>
-#include "syscalls.h"
-
-_syscall2(int,fchmod,int,filedes,mode_t,mode)
-
diff --git a/mdk-stage1/dietlibc/syscalls.c/fchown.c b/mdk-stage1/dietlibc/syscalls.c/fchown.c
deleted file mode 100644
index 58923a137..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/fchown.c
+++ /dev/null
@@ -1,5 +0,0 @@
-#include <linux/types.h>
-#include "syscalls.h"
-
-_syscall3(int,fchown,int,fd,uid_t,owner,gid_t,group)
-
diff --git a/mdk-stage1/dietlibc/syscalls.c/fcntl.c b/mdk-stage1/dietlibc/syscalls.c/fcntl.c
deleted file mode 100644
index b21be9531..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/fcntl.c
+++ /dev/null
@@ -1,4 +0,0 @@
-#include "syscalls.h"
-
-_syscall3(int,fcntl,int,fd,int,cmd,long,arg)
-
diff --git a/mdk-stage1/dietlibc/syscalls.c/flock.c b/mdk-stage1/dietlibc/syscalls.c/flock.c
deleted file mode 100644
index 6fcb336ef..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/flock.c
+++ /dev/null
@@ -1,4 +0,0 @@
-#include "syscalls.h"
-
-_syscall2(int,flock,int,fd,int,op)
-
diff --git a/mdk-stage1/dietlibc/syscalls.c/fork.c b/mdk-stage1/dietlibc/syscalls.c/fork.c
deleted file mode 100644
index 1d4b892b6..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/fork.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include "syscalls.h"
-
-#ifndef __sparc__
-
-_syscall0(int,fork)
-#endif
diff --git a/mdk-stage1/dietlibc/syscalls.c/fsync.c b/mdk-stage1/dietlibc/syscalls.c/fsync.c
deleted file mode 100644
index db6198b8a..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/fsync.c
+++ /dev/null
@@ -1,4 +0,0 @@
-#include "syscalls.h"
-
-_syscall1(int,fsync,int,fd)
-
diff --git a/mdk-stage1/dietlibc/syscalls.c/ftruncate.c b/mdk-stage1/dietlibc/syscalls.c/ftruncate.c
deleted file mode 100644
index 5f002a899..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/ftruncate.c
+++ /dev/null
@@ -1,4 +0,0 @@
-#include <sys/types.h>
-#include "syscalls.h"
-
-_syscall2(int,ftruncate,int,fd,off_t,length)
diff --git a/mdk-stage1/dietlibc/syscalls.c/getcwd.c b/mdk-stage1/dietlibc/syscalls.c/getcwd.c
deleted file mode 100644
index 9e5e4a3e2..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/getcwd.c
+++ /dev/null
@@ -1,5 +0,0 @@
-#include "syscalls.h"
-
-/* this syscall exists since Linux 2.1.92 */
-
-_syscall2(int,getcwd,char*,buf,unsigned long,size)
diff --git a/mdk-stage1/dietlibc/syscalls.c/getdents.c b/mdk-stage1/dietlibc/syscalls.c/getdents.c
deleted file mode 100644
index be941b21e..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/getdents.c
+++ /dev/null
@@ -1,4 +0,0 @@
-#include "syscalls.h"
-
-_syscall3(int, getdents, unsigned int, fd, void *, dirp, unsigned int, count);
-
diff --git a/mdk-stage1/dietlibc/syscalls.c/getegid.c b/mdk-stage1/dietlibc/syscalls.c/getegid.c
deleted file mode 100644
index 3213d640c..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/getegid.c
+++ /dev/null
@@ -1,4 +0,0 @@
-#include <linux/types.h>
-#include "syscalls.h"
-
-_syscall0(gid_t,getegid)
diff --git a/mdk-stage1/dietlibc/syscalls.c/geteuid.c b/mdk-stage1/dietlibc/syscalls.c/geteuid.c
deleted file mode 100644
index 5b31a3cca..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/geteuid.c
+++ /dev/null
@@ -1,4 +0,0 @@
-#include <linux/types.h>
-#include "syscalls.h"
-
-_syscall0(uid_t,geteuid)
diff --git a/mdk-stage1/dietlibc/syscalls.c/getgid.c b/mdk-stage1/dietlibc/syscalls.c/getgid.c
deleted file mode 100644
index 2f7d96286..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/getgid.c
+++ /dev/null
@@ -1,4 +0,0 @@
-#include <linux/types.h>
-#include "syscalls.h"
-
-_syscall0(gid_t,getgid)
diff --git a/mdk-stage1/dietlibc/syscalls.c/getgroups.c b/mdk-stage1/dietlibc/syscalls.c/getgroups.c
deleted file mode 100644
index 3e4d6797a..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/getgroups.c
+++ /dev/null
@@ -1,4 +0,0 @@
-#include <linux/types.h>
-#include "syscalls.h"
-
-_syscall2(int,getgroups,int,size,int*,list)
diff --git a/mdk-stage1/dietlibc/syscalls.c/getpgid.c b/mdk-stage1/dietlibc/syscalls.c/getpgid.c
deleted file mode 100644
index 0b4ff528b..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/getpgid.c
+++ /dev/null
@@ -1,4 +0,0 @@
-#include <linux/types.h>
-#include "syscalls.h"
-
-_syscall1(pid_t,getpgid,pid_t,pid)
diff --git a/mdk-stage1/dietlibc/syscalls.c/getpriority.c b/mdk-stage1/dietlibc/syscalls.c/getpriority.c
deleted file mode 100644
index 6f94bcf42..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/getpriority.c
+++ /dev/null
@@ -1,4 +0,0 @@
-#include "syscalls.h"
-
-_syscall3(int,getpriority,int,which,int,who)
-
diff --git a/mdk-stage1/dietlibc/syscalls.c/getresgid.c b/mdk-stage1/dietlibc/syscalls.c/getresgid.c
deleted file mode 100644
index 264ec7dce..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/getresgid.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <linux/types.h>
-#include "syscalls.h"
-
-#ifdef __NR_getresgid
-
-_syscall3(int,getresgid,gid_t*,rgid,gid_t*,egid,gid_t*,sgid)
-
-#endif
diff --git a/mdk-stage1/dietlibc/syscalls.c/getresuid.c b/mdk-stage1/dietlibc/syscalls.c/getresuid.c
deleted file mode 100644
index 74e2daec2..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/getresuid.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <linux/types.h>
-#include "syscalls.h"
-
-#ifdef __getresuid
-
-_syscall3(int,getresuid,uid_t*,ruid,uid_t*,euid,uid_t*,suid)
-
-#endif
diff --git a/mdk-stage1/dietlibc/syscalls.c/getrlimit.c b/mdk-stage1/dietlibc/syscalls.c/getrlimit.c
deleted file mode 100644
index 635b2baf4..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/getrlimit.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#include "syscalls.h"
-
-_syscall2(int,getrlimit,int,resource,void*,rlim)
diff --git a/mdk-stage1/dietlibc/syscalls.c/getrusage.c b/mdk-stage1/dietlibc/syscalls.c/getrusage.c
deleted file mode 100644
index 815d3e617..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/getrusage.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#include "syscalls.h"
-
-_syscall2(int,getrusage,int,who,void*,rusage)
diff --git a/mdk-stage1/dietlibc/syscalls.c/getsid.c b/mdk-stage1/dietlibc/syscalls.c/getsid.c
deleted file mode 100644
index 69974c36c..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/getsid.c
+++ /dev/null
@@ -1,4 +0,0 @@
-#include <linux/types.h>
-#include "syscalls.h"
-
-_syscall1(pid_t,getsid,pid_t,pid)
diff --git a/mdk-stage1/dietlibc/syscalls.c/gettimeofday.c b/mdk-stage1/dietlibc/syscalls.c/gettimeofday.c
deleted file mode 100644
index 5f4931a0c..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/gettimeofday.c
+++ /dev/null
@@ -1,5 +0,0 @@
-#include <linux/types.h>
-#include <linux/time.h>
-#include "syscalls.h"
-
-_syscall2(int,gettimeofday,struct timeval *,tv,void *,tz)
diff --git a/mdk-stage1/dietlibc/syscalls.c/getuid.c b/mdk-stage1/dietlibc/syscalls.c/getuid.c
deleted file mode 100644
index bf38447a6..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/getuid.c
+++ /dev/null
@@ -1,4 +0,0 @@
-#include <linux/types.h>
-#include "syscalls.h"
-
-_syscall0(uid_t,getuid)
diff --git a/mdk-stage1/dietlibc/syscalls.c/ioctl.c b/mdk-stage1/dietlibc/syscalls.c/ioctl.c
deleted file mode 100644
index 1612109d3..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/ioctl.c
+++ /dev/null
@@ -1,4 +0,0 @@
-#include "syscalls.h"
-
-_syscall3(int,ioctl,int,fd,int,request,void *,argp)
-
diff --git a/mdk-stage1/dietlibc/syscalls.c/kill.c b/mdk-stage1/dietlibc/syscalls.c/kill.c
deleted file mode 100644
index e56b0ac1b..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/kill.c
+++ /dev/null
@@ -1,4 +0,0 @@
-#include <linux/types.h>
-#include "syscalls.h"
-
-_syscall2(int,kill,pid_t,pid,int,sig)
diff --git a/mdk-stage1/dietlibc/syscalls.c/lchown.c b/mdk-stage1/dietlibc/syscalls.c/lchown.c
deleted file mode 100644
index 976d2ee1f..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/lchown.c
+++ /dev/null
@@ -1,5 +0,0 @@
-#include <linux/types.h>
-#include "syscalls.h"
-
-_syscall3(int,lchown,char*,path,uid_t,owner,gid_t,group)
-
diff --git a/mdk-stage1/dietlibc/syscalls.c/link.c b/mdk-stage1/dietlibc/syscalls.c/link.c
deleted file mode 100644
index ab9b427d9..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/link.c
+++ /dev/null
@@ -1,5 +0,0 @@
-#include <linux/types.h>
-#include "syscalls.h"
-
-_syscall2(int,link,const char *,a,const char *,b)
-
diff --git a/mdk-stage1/dietlibc/syscalls.c/lseek.c b/mdk-stage1/dietlibc/syscalls.c/lseek.c
deleted file mode 100644
index 9925a2185..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/lseek.c
+++ /dev/null
@@ -1,4 +0,0 @@
-#include "syscalls.h"
-
-_syscall3(unsigned long,lseek,int,fd,unsigned long,offset,int,whence)
-
diff --git a/mdk-stage1/dietlibc/syscalls.c/mkdir.c b/mdk-stage1/dietlibc/syscalls.c/mkdir.c
deleted file mode 100644
index aac682c99..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/mkdir.c
+++ /dev/null
@@ -1,4 +0,0 @@
-#include <linux/types.h>
-#include "syscalls.h"
-
-_syscall2(int,mkdir,void*,path,mode_t,mode)
diff --git a/mdk-stage1/dietlibc/syscalls.c/mknod.c b/mdk-stage1/dietlibc/syscalls.c/mknod.c
deleted file mode 100644
index 00e836b73..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/mknod.c
+++ /dev/null
@@ -1,5 +0,0 @@
-#include <linux/types.h>
-#include "syscalls.h"
-
-_syscall3(int,mknod,const char*,pathname,mode_t,mode,dev_t,dev)
-
diff --git a/mdk-stage1/dietlibc/syscalls.c/mount.c b/mdk-stage1/dietlibc/syscalls.c/mount.c
deleted file mode 100644
index 2d71ee812..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/mount.c
+++ /dev/null
@@ -1,4 +0,0 @@
-#include "syscalls.h"
-
-_syscall5(int,mount,const char *,spec,const char *,dir,const char *,type,unsigned long,rwflag,const void *,data);
-
diff --git a/mdk-stage1/dietlibc/syscalls.c/mprotect.c b/mdk-stage1/dietlibc/syscalls.c/mprotect.c
deleted file mode 100644
index 634a12089..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/mprotect.c
+++ /dev/null
@@ -1,4 +0,0 @@
-#include <linux/types.h>
-#include "syscalls.h"
-
-_syscall3(int,mprotect,const void *,addr, size_t, len, int, prot)
diff --git a/mdk-stage1/dietlibc/syscalls.c/mremap.c b/mdk-stage1/dietlibc/syscalls.c/mremap.c
deleted file mode 100644
index 37d066bac..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/mremap.c
+++ /dev/null
@@ -1,5 +0,0 @@
-#include <linux/types.h>
-#include "syscalls.h"
-
-_syscall4(int,mremap,void*,old_address,size_t,old_size,size_t,new_size,unsigned long,flags)
-
diff --git a/mdk-stage1/dietlibc/syscalls.c/munmap.c b/mdk-stage1/dietlibc/syscalls.c/munmap.c
deleted file mode 100644
index 40bc98270..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/munmap.c
+++ /dev/null
@@ -1,5 +0,0 @@
-#include <linux/types.h>
-#include "syscalls.h"
-
-_syscall2(int,munmap,void*,start,size_t,len)
-
diff --git a/mdk-stage1/dietlibc/syscalls.c/nanosleep.c b/mdk-stage1/dietlibc/syscalls.c/nanosleep.c
deleted file mode 100644
index 71aca1f09..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/nanosleep.c
+++ /dev/null
@@ -1,5 +0,0 @@
-#include <linux/types.h>
-#include <linux/time.h>
-#include "syscalls.h"
-
-_syscall2(int,nanosleep,struct timeval *,in,struct timeval *,out)
diff --git a/mdk-stage1/dietlibc/syscalls.c/open.c b/mdk-stage1/dietlibc/syscalls.c/open.c
deleted file mode 100644
index 8b3ccfcc3..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/open.c
+++ /dev/null
@@ -1,4 +0,0 @@
-#include <linux/types.h>
-#include "syscalls.h"
-
-_syscall3(int,open,const char *,fn,int,flags,mode_t,mode)
diff --git a/mdk-stage1/dietlibc/syscalls.c/pipe.c b/mdk-stage1/dietlibc/syscalls.c/pipe.c
deleted file mode 100644
index 42197c881..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/pipe.c
+++ /dev/null
@@ -1,4 +0,0 @@
-#include <linux/types.h>
-#include "syscalls.h"
-
-_syscall1(int,pipe,int *,filedes)
diff --git a/mdk-stage1/dietlibc/syscalls.c/poll.c b/mdk-stage1/dietlibc/syscalls.c/poll.c
deleted file mode 100644
index 10d0d1f78..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/poll.c
+++ /dev/null
@@ -1,4 +0,0 @@
-#include <linux/types.h>
-#include "syscalls.h"
-
-_syscall3(int,poll,void *,ufds,int,nfds,int,timeout)
diff --git a/mdk-stage1/dietlibc/syscalls.c/read.c b/mdk-stage1/dietlibc/syscalls.c/read.c
deleted file mode 100644
index f5532054e..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/read.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#include "syscalls.h"
-
-_syscall3(int,read,int,fd,const char *,buf,unsigned long,count)
diff --git a/mdk-stage1/dietlibc/syscalls.c/readlink.c b/mdk-stage1/dietlibc/syscalls.c/readlink.c
deleted file mode 100644
index 482f8fe27..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/readlink.c
+++ /dev/null
@@ -1,5 +0,0 @@
-#include "syscalls.h"
-#include <linux/types.h>
-
-_syscall3(int,readlink,char*,path,char*,buf,size_t,bufsiz)
-
diff --git a/mdk-stage1/dietlibc/syscalls.c/reboot.c b/mdk-stage1/dietlibc/syscalls.c/reboot.c
deleted file mode 100644
index 0ad474894..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/reboot.c
+++ /dev/null
@@ -1,4 +0,0 @@
-#include "syscalls.h"
-
-_syscall3(int,reboot,int,magic,int,magic_too,int,flag)
-
diff --git a/mdk-stage1/dietlibc/syscalls.c/rename.c b/mdk-stage1/dietlibc/syscalls.c/rename.c
deleted file mode 100644
index f86d50728..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/rename.c
+++ /dev/null
@@ -1,4 +0,0 @@
-#include "syscalls.h"
-
-_syscall2(int,rename,char*,oldpath,char*,newpath)
-
diff --git a/mdk-stage1/dietlibc/syscalls.c/rmdir.c b/mdk-stage1/dietlibc/syscalls.c/rmdir.c
deleted file mode 100644
index 303885264..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/rmdir.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#include "syscalls.h"
-
-_syscall1(int,rmdir,void*,path)
diff --git a/mdk-stage1/dietlibc/syscalls.c/setdomainname.c b/mdk-stage1/dietlibc/syscalls.c/setdomainname.c
deleted file mode 100644
index 83d3aa8b8..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/setdomainname.c
+++ /dev/null
@@ -1,4 +0,0 @@
-#include "syscalls.h"
-
-_syscall2(int,setdomainname,const char *,name,int,len)
-
diff --git a/mdk-stage1/dietlibc/syscalls.c/setgid.c b/mdk-stage1/dietlibc/syscalls.c/setgid.c
deleted file mode 100644
index 1f7263aeb..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/setgid.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#include "syscalls.h"
-
-_syscall1(int,setgid,int,gid)
diff --git a/mdk-stage1/dietlibc/syscalls.c/setgroups.c b/mdk-stage1/dietlibc/syscalls.c/setgroups.c
deleted file mode 100644
index fed3b85c1..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/setgroups.c
+++ /dev/null
@@ -1,4 +0,0 @@
-#include "syscalls.h"
-
-_syscall2(int,setgroups,int,size,const int*,list)
-
diff --git a/mdk-stage1/dietlibc/syscalls.c/sethostname.c b/mdk-stage1/dietlibc/syscalls.c/sethostname.c
deleted file mode 100644
index e4b736f87..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/sethostname.c
+++ /dev/null
@@ -1,4 +0,0 @@
-#include "syscalls.h"
-
-_syscall2(int,sethostname,const char *,name,int,len)
-
diff --git a/mdk-stage1/dietlibc/syscalls.c/setitimer.c b/mdk-stage1/dietlibc/syscalls.c/setitimer.c
deleted file mode 100644
index 28935cab7..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/setitimer.c
+++ /dev/null
@@ -1,4 +0,0 @@
-#include "syscalls.h"
-
-_syscall3(int,setitimer,int,which,void *,value,void *,ovalue)
-
diff --git a/mdk-stage1/dietlibc/syscalls.c/setpgid.c b/mdk-stage1/dietlibc/syscalls.c/setpgid.c
deleted file mode 100644
index 66fbf82dd..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/setpgid.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#include "syscalls.h"
-
-_syscall2(int,setpgid,int,name,int,len)
diff --git a/mdk-stage1/dietlibc/syscalls.c/setpriority.c b/mdk-stage1/dietlibc/syscalls.c/setpriority.c
deleted file mode 100644
index bc04227d2..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/setpriority.c
+++ /dev/null
@@ -1,4 +0,0 @@
-#include "syscalls.h"
-
-_syscall3(int,setpriority,int,which,int,who,int,prio)
-
diff --git a/mdk-stage1/dietlibc/syscalls.c/setregid.c b/mdk-stage1/dietlibc/syscalls.c/setregid.c
deleted file mode 100644
index c6911aca8..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/setregid.c
+++ /dev/null
@@ -1,4 +0,0 @@
-#include <linux/types.h>
-#include "syscalls.h"
-
-_syscall2(int,setregid,gid_t,rgid,gid_t,egid)
diff --git a/mdk-stage1/dietlibc/syscalls.c/setresgid.c b/mdk-stage1/dietlibc/syscalls.c/setresgid.c
deleted file mode 100644
index 817fd2942..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/setresgid.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <linux/types.h>
-#include "syscalls.h"
-
-#ifdef __NR_setresgid
-
-_syscall3(int,setresgid,gid_t*,rgid,gid_t*,egid,gid_t*,sgid)
-
-#endif
diff --git a/mdk-stage1/dietlibc/syscalls.c/setresuid.c b/mdk-stage1/dietlibc/syscalls.c/setresuid.c
deleted file mode 100644
index 7073d8ac2..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/setresuid.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <linux/types.h>
-#include "syscalls.h"
-
-#ifdef __NR_setresuid
-
-_syscall3(int,setresuid,uid_t*,ruid,uid_t*,euid,uid_t*,suid)
-
-#endif
diff --git a/mdk-stage1/dietlibc/syscalls.c/setreuid.c b/mdk-stage1/dietlibc/syscalls.c/setreuid.c
deleted file mode 100644
index c0c23a12d..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/setreuid.c
+++ /dev/null
@@ -1,4 +0,0 @@
-#include <linux/types.h>
-#include "syscalls.h"
-
-_syscall2(int,setreuid,uid_t,ruid,uid_t,euid)
diff --git a/mdk-stage1/dietlibc/syscalls.c/setrlimit.c b/mdk-stage1/dietlibc/syscalls.c/setrlimit.c
deleted file mode 100644
index 213234282..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/setrlimit.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#include "syscalls.h"
-
-_syscall2(int,setrlimit,int,resource,void*,rlim)
diff --git a/mdk-stage1/dietlibc/syscalls.c/setsid.c b/mdk-stage1/dietlibc/syscalls.c/setsid.c
deleted file mode 100644
index 4b35a1316..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/setsid.c
+++ /dev/null
@@ -1,4 +0,0 @@
-#include <linux/types.h>
-#include "syscalls.h"
-
-_syscall0(pid_t,setsid)
diff --git a/mdk-stage1/dietlibc/syscalls.c/setuid.c b/mdk-stage1/dietlibc/syscalls.c/setuid.c
deleted file mode 100644
index 620876c9f..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/setuid.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#include "syscalls.h"
-
-_syscall1(int,setuid,int,uid)
diff --git a/mdk-stage1/dietlibc/syscalls.c/sigaction.c b/mdk-stage1/dietlibc/syscalls.c/sigaction.c
deleted file mode 100644
index cfa5c683f..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/sigaction.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#include "syscalls.h"
-
-_syscall3(int,sigaction,int,signum,void*,act,void*,oldact)
diff --git a/mdk-stage1/dietlibc/syscalls.c/signal.c b/mdk-stage1/dietlibc/syscalls.c/signal.c
deleted file mode 100644
index 1a913be45..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/signal.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#include "syscalls.h"
-
-_syscall2(int,signal,int,num,void *,len)
diff --git a/mdk-stage1/dietlibc/syscalls.c/sigpending.c b/mdk-stage1/dietlibc/syscalls.c/sigpending.c
deleted file mode 100644
index 08fb23991..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/sigpending.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#include "syscalls.h"
-
-_syscall1(int,sigpending,void*,set)
diff --git a/mdk-stage1/dietlibc/syscalls.c/sigprocmask.c b/mdk-stage1/dietlibc/syscalls.c/sigprocmask.c
deleted file mode 100644
index e9dcc2d67..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/sigprocmask.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#include "syscalls.h"
-
-_syscall3(int,sigprocmask,int,how,void*,set,void*,oldset)
diff --git a/mdk-stage1/dietlibc/syscalls.c/sigsuspend.c b/mdk-stage1/dietlibc/syscalls.c/sigsuspend.c
deleted file mode 100644
index 0fe90e623..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/sigsuspend.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#include "syscalls.h"
-
-_syscall1(int,sigsuspend,void*,mask)
diff --git a/mdk-stage1/dietlibc/syscalls.c/socketcall.c b/mdk-stage1/dietlibc/syscalls.c/socketcall.c
deleted file mode 100644
index eee1ae86d..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/socketcall.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#include "syscalls.h"
-
-_syscall2(int,socketcall,int,code,unsigned long *, args)
diff --git a/mdk-stage1/dietlibc/syscalls.c/swapoff.c b/mdk-stage1/dietlibc/syscalls.c/swapoff.c
deleted file mode 100644
index e1daa89a9..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/swapoff.c
+++ /dev/null
@@ -1,4 +0,0 @@
-#include "syscalls.h"
-
-_syscall1(int,swapoff,const char *,fn)
-
diff --git a/mdk-stage1/dietlibc/syscalls.c/swapon.c b/mdk-stage1/dietlibc/syscalls.c/swapon.c
deleted file mode 100644
index 543e41e79..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/swapon.c
+++ /dev/null
@@ -1,4 +0,0 @@
-#include <linux/types.h>
-#include "syscalls.h"
-
-_syscall2(int,swapon,const char*,path,int,swapflags)
diff --git a/mdk-stage1/dietlibc/syscalls.c/symlink.c b/mdk-stage1/dietlibc/syscalls.c/symlink.c
deleted file mode 100644
index b3f4d0b1c..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/symlink.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#include "syscalls.h"
-
-_syscall2(int,symlink,const char *,a,const char *,b)
diff --git a/mdk-stage1/dietlibc/syscalls.c/syslog.c b/mdk-stage1/dietlibc/syscalls.c/syslog.c
deleted file mode 100644
index aace870ea..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/syslog.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#include "syscalls.h"
-
-_syscall3(int,syslog,int, type, char *, buf, int, len);
diff --git a/mdk-stage1/dietlibc/syscalls.c/time.c b/mdk-stage1/dietlibc/syscalls.c/time.c
deleted file mode 100644
index dc15b28f9..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/time.c
+++ /dev/null
@@ -1,4 +0,0 @@
-#include <linux/types.h>
-#include "syscalls.h"
-
-_syscall1(time_t,time,time_t*,path)
diff --git a/mdk-stage1/dietlibc/syscalls.c/truncate.c b/mdk-stage1/dietlibc/syscalls.c/truncate.c
deleted file mode 100644
index 721bd7134..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/truncate.c
+++ /dev/null
@@ -1,4 +0,0 @@
-#include <linux/types.h>
-#include "syscalls.h"
-
-_syscall2(int,truncate,const char*,path,off_t,length)
diff --git a/mdk-stage1/dietlibc/syscalls.c/umask.c b/mdk-stage1/dietlibc/syscalls.c/umask.c
deleted file mode 100644
index 506038243..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/umask.c
+++ /dev/null
@@ -1,5 +0,0 @@
-#include <linux/types.h>
-#include "syscalls.h"
-
-_syscall1(int,umask,mode_t,mask)
-
diff --git a/mdk-stage1/dietlibc/syscalls.c/umount.c b/mdk-stage1/dietlibc/syscalls.c/umount.c
deleted file mode 100644
index 4d3ef7637..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/umount.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#include "syscalls.h"
-
-_syscall1(int,umount,const char *,dir)
diff --git a/mdk-stage1/dietlibc/syscalls.c/uname.c b/mdk-stage1/dietlibc/syscalls.c/uname.c
deleted file mode 100644
index 68f135007..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/uname.c
+++ /dev/null
@@ -1,5 +0,0 @@
-#include <linux/types.h>
-#include "syscalls.h"
-
-_syscall1(int,uname,void *,utsname)
-
diff --git a/mdk-stage1/dietlibc/syscalls.c/unlink.c b/mdk-stage1/dietlibc/syscalls.c/unlink.c
deleted file mode 100644
index 860ccebbf..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/unlink.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#include "syscalls.h"
-
-_syscall1(int,unlink,const char *,fn)
diff --git a/mdk-stage1/dietlibc/syscalls.c/utime.c b/mdk-stage1/dietlibc/syscalls.c/utime.c
deleted file mode 100644
index 185bdf9e8..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/utime.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#include "syscalls.h"
-
-_syscall2(int,utime,void*,filename,void*,buf)
diff --git a/mdk-stage1/dietlibc/syscalls.c/vhangup.c b/mdk-stage1/dietlibc/syscalls.c/vhangup.c
deleted file mode 100644
index bb0669765..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/vhangup.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#include "syscalls.h"
-
-_syscall0(int,vhangup)
diff --git a/mdk-stage1/dietlibc/syscalls.c/wait4.c b/mdk-stage1/dietlibc/syscalls.c/wait4.c
deleted file mode 100644
index 4ae7eabcd..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/wait4.c
+++ /dev/null
@@ -1,4 +0,0 @@
-#include <linux/types.h>
-#include "syscalls.h"
-
-_syscall4(int,wait4,pid_t,pid,int *,status,int,opts,void *,rusage)
diff --git a/mdk-stage1/dietlibc/syscalls.c/waitpid.c b/mdk-stage1/dietlibc/syscalls.c/waitpid.c
deleted file mode 100644
index b7167f9ce..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/waitpid.c
+++ /dev/null
@@ -1,4 +0,0 @@
-#include <linux/types.h>
-#include "syscalls.h"
-
-_syscall3(int,waitpid,int,pid,int *,status,int,options)
diff --git a/mdk-stage1/dietlibc/syscalls.c/write.c b/mdk-stage1/dietlibc/syscalls.c/write.c
deleted file mode 100644
index d1f7347d5..000000000
--- a/mdk-stage1/dietlibc/syscalls.c/write.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#include "syscalls.h"
-
-_syscall3(int,write,int,fd,const char *,buf,unsigned long,count)
diff --git a/mdk-stage1/dietlibc/syscalls.s/__pread.S b/mdk-stage1/dietlibc/syscalls.s/__pread.S
index ad47c7873..ae2068352 100644
--- a/mdk-stage1/dietlibc/syscalls.s/__pread.S
+++ b/mdk-stage1/dietlibc/syscalls.s/__pread.S
@@ -1,3 +1,3 @@
#include "syscalls.h"
-syscall_weak(pread,__pread,__libc__pread)
+syscall(pread,__pread)
diff --git a/mdk-stage1/dietlibc/syscalls.s/pwrite.S b/mdk-stage1/dietlibc/syscalls.s/__pwrite.S
index f52ead7b2..f52ead7b2 100644
--- a/mdk-stage1/dietlibc/syscalls.s/pwrite.S
+++ b/mdk-stage1/dietlibc/syscalls.s/__pwrite.S
diff --git a/mdk-stage1/dietlibc/syscalls.s/_llseek.S b/mdk-stage1/dietlibc/syscalls.s/_llseek.S
index 3e240d822..68d021168 100644
--- a/mdk-stage1/dietlibc/syscalls.s/_llseek.S
+++ b/mdk-stage1/dietlibc/syscalls.s/_llseek.S
@@ -1,3 +1,7 @@
#include "syscalls.h"
+#ifdef __NR__llseek
+.global llseek
+llseek:
syscall(_llseek,_llseek)
+#endif
diff --git a/mdk-stage1/dietlibc/syscalls.s/adjtimex.S b/mdk-stage1/dietlibc/syscalls.s/adjtimex.S
new file mode 100644
index 000000000..190ebcd7e
--- /dev/null
+++ b/mdk-stage1/dietlibc/syscalls.s/adjtimex.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall(adjtimex,adjtimex)
diff --git a/mdk-stage1/dietlibc/syscalls.s/alarm.S b/mdk-stage1/dietlibc/syscalls.s/alarm.S
new file mode 100644
index 000000000..b1b0d3e49
--- /dev/null
+++ b/mdk-stage1/dietlibc/syscalls.s/alarm.S
@@ -0,0 +1,4 @@
+#include "syscalls.h"
+#ifdef __NR_alarm
+syscall(alarm,alarm)
+#endif
diff --git a/mdk-stage1/dietlibc/syscalls.s/bdflush.S b/mdk-stage1/dietlibc/syscalls.s/bdflush.S
new file mode 100644
index 000000000..b7788baef
--- /dev/null
+++ b/mdk-stage1/dietlibc/syscalls.s/bdflush.S
@@ -0,0 +1,5 @@
+#include "syscalls.h"
+
+#ifdef __NR_bdflush
+syscall(bdflush,bdflush)
+#endif
diff --git a/mdk-stage1/dietlibc/syscalls.s/chown32.S b/mdk-stage1/dietlibc/syscalls.s/chown32.S
new file mode 100644
index 000000000..98d68f980
--- /dev/null
+++ b/mdk-stage1/dietlibc/syscalls.s/chown32.S
@@ -0,0 +1,5 @@
+#include "syscalls.h"
+
+#ifdef __NR_chown32
+syscall_weak(chown32,chown32,__libc_chown32)
+#endif
diff --git a/mdk-stage1/dietlibc/syscalls.s/create_module.S b/mdk-stage1/dietlibc/syscalls.s/create_module.S
new file mode 100644
index 000000000..f2da644ad
--- /dev/null
+++ b/mdk-stage1/dietlibc/syscalls.s/create_module.S
@@ -0,0 +1,5 @@
+#include "syscalls.h"
+
+#ifdef __NR_create_module
+syscall(create_module,create_module)
+#endif
diff --git a/mdk-stage1/dietlibc/syscalls.s/delete_module.S b/mdk-stage1/dietlibc/syscalls.s/delete_module.S
new file mode 100644
index 000000000..d0919b6be
--- /dev/null
+++ b/mdk-stage1/dietlibc/syscalls.s/delete_module.S
@@ -0,0 +1,5 @@
+#include "syscalls.h"
+
+#ifdef __NR_delete_module
+syscall(delete_module,delete_module)
+#endif
diff --git a/mdk-stage1/dietlibc/syscalls.s/environ.S b/mdk-stage1/dietlibc/syscalls.s/environ.S
new file mode 100644
index 000000000..eb3ff0b94
--- /dev/null
+++ b/mdk-stage1/dietlibc/syscalls.s/environ.S
@@ -0,0 +1,16 @@
+.section ".bss"
+.align 8
+
+.type environ,object
+.weak environ
+.type __environ,object
+.weak __environ
+__environ:
+environ:
+#if __WORDSIZE == 64
+ .quad 0
+#else
+ .long 0
+#endif
+.size environ,.-environ
+.size __environ,.-__environ
diff --git a/mdk-stage1/dietlibc/syscalls.s/epoll_create.S b/mdk-stage1/dietlibc/syscalls.s/epoll_create.S
new file mode 100644
index 000000000..09bb50209
--- /dev/null
+++ b/mdk-stage1/dietlibc/syscalls.s/epoll_create.S
@@ -0,0 +1,5 @@
+#include "syscalls.h"
+
+#ifdef __NR_sys_epoll_create
+syscall(sys_epoll_create,epoll_create)
+#endif
diff --git a/mdk-stage1/dietlibc/syscalls.s/epoll_ctl.S b/mdk-stage1/dietlibc/syscalls.s/epoll_ctl.S
new file mode 100644
index 000000000..4587f59de
--- /dev/null
+++ b/mdk-stage1/dietlibc/syscalls.s/epoll_ctl.S
@@ -0,0 +1,5 @@
+#include "syscalls.h"
+
+#ifdef __NR_sys_epoll_ctl
+syscall(sys_epoll_ctl,epoll_ctl)
+#endif
diff --git a/mdk-stage1/dietlibc/syscalls.s/epoll_wait.S b/mdk-stage1/dietlibc/syscalls.s/epoll_wait.S
new file mode 100644
index 000000000..dab5a58b7
--- /dev/null
+++ b/mdk-stage1/dietlibc/syscalls.s/epoll_wait.S
@@ -0,0 +1,5 @@
+#include "syscalls.h"
+
+#ifdef __NR_sys_epoll_wait
+syscall(sys_epoll_wait,epoll_wait)
+#endif
diff --git a/mdk-stage1/dietlibc/syscalls.s/errlist.S b/mdk-stage1/dietlibc/syscalls.s/errlist.S
new file mode 100644
index 000000000..503bd22e4
--- /dev/null
+++ b/mdk-stage1/dietlibc/syscalls.s/errlist.S
@@ -0,0 +1,293 @@
+#include <endian.h>
+
+#
+# My gcc tries to align some of the strings if written the code in C. This costs a lot of bytes.
+#
+
+#ifdef __DYN_LIB
+.section .data
+#else
+.section .rodata
+#endif
+
+.globl sys_errlist
+ .align 4
+#ifdef __arm__
+ .type sys_errlist,object
+ .type sys_nerr,object
+#else
+ .type sys_errlist,@object
+ .type sys_nerr,@object
+#endif
+
+#if (__WORDSIZE == 64)
+#define deflong .quad
+#else
+#define deflong .long
+#endif
+
+sys_errlist:
+ deflong .LC000
+ deflong .LC001
+ deflong .LC002
+ deflong .LC003
+ deflong .LC004
+ deflong .LC005
+ deflong .LC006
+ deflong .LC007
+ deflong .LC008
+ deflong .LC009
+ deflong .LC010
+ deflong .LC011
+ deflong .LC012
+ deflong .LC013
+ deflong .LC014
+ deflong .LC015
+ deflong .LC016
+ deflong .LC017
+ deflong .LC018
+ deflong .LC019
+ deflong .LC020
+ deflong .LC021
+ deflong .LC022
+ deflong .LC023
+ deflong .LC024
+ deflong .LC025
+ deflong .LC026
+ deflong .LC027
+ deflong .LC028
+ deflong .LC029
+ deflong .LC030
+ deflong .LC031
+ deflong .LC032
+ deflong .LC033
+ deflong .LC034
+ deflong .LC035
+ deflong .LC036
+ deflong .LC037
+ deflong .LC038
+ deflong .LC039
+ deflong .LC040
+ deflong .LC041
+ deflong .LC042
+ deflong .LC043
+ deflong .LC044
+ deflong .LC045
+ deflong .LC046
+ deflong .LC047
+ deflong .LC048
+ deflong .LC049
+ deflong .LC050
+ deflong .LC051
+ deflong .LC052
+ deflong .LC053
+ deflong .LC054
+ deflong .LC055
+ deflong .LC056
+ deflong .LC057
+ deflong .LC058
+ deflong .LC059
+ deflong .LC060
+ deflong .LC061
+ deflong .LC062
+ deflong .LC063
+ deflong .LC064
+ deflong .LC065
+ deflong .LC066
+ deflong .LC067
+ deflong .LC068
+ deflong .LC069
+ deflong .LC070
+ deflong .LC071
+ deflong .LC072
+ deflong .LC073
+ deflong .LC074
+ deflong .LC075
+ deflong .LC076
+ deflong .LC077
+ deflong .LC078
+ deflong .LC079
+ deflong .LC080
+ deflong .LC081
+ deflong .LC082
+ deflong .LC083
+ deflong .LC084
+ deflong .LC085
+ deflong .LC086
+ deflong .LC087
+ deflong .LC088
+ deflong .LC089
+ deflong .LC090
+ deflong .LC091
+ deflong .LC092
+ deflong .LC093
+ deflong .LC094
+ deflong .LC095
+ deflong .LC096
+ deflong .LC097
+ deflong .LC098
+ deflong .LC099
+ deflong .LC100
+ deflong .LC101
+ deflong .LC102
+ deflong .LC103
+ deflong .LC104
+ deflong .LC105
+ deflong .LC106
+ deflong .LC107
+ deflong .LC108
+ deflong .LC109
+ deflong .LC110
+ deflong .LC111
+ deflong .LC112
+ deflong .LC113
+ deflong .LC114
+ deflong .LC115
+ deflong .LC116
+ deflong .LC117
+ deflong .LC118
+ deflong .LC119
+ deflong .LC120
+ deflong .LC121
+ deflong .LC122
+ deflong .LC123
+ deflong .LC124
+ deflong 0
+
+.globl sys_nerr
+ .align 4
+ .size sys_nerr,4
+
+sys_nerr:
+ .long 125
+
+
+#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 "Try again"
+.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 "Resource deadlock would occur"
+.LC036: .string "File name too long"
+.LC037: .string "No record locks available"
+.LC038: .string "Function not implemented"
+.LC039: .string "Directory not empty"
+.LC040: .string "Too many symbolic links encountered"
+.LC041: .string "Operation would block"
+.LC042: .string "No message of desired type"
+.LC043: .string "Identifier removed"
+.LC044: .string "Channel number out of range"
+.LC045: .string "Level 2 not synchronized"
+.LC046: .string "Level 3 halted"
+.LC047: .string "Level 3 reset"
+.LC048: .string "Link number out of range"
+.LC049: .string "Protocol driver not attached"
+.LC050: .string "No CSI structure available"
+.LC051: .string "Level 2 halted"
+.LC052: .string "Invalid exchange"
+.LC053: .string "Invalid request descriptor"
+.LC054: .string "Exchange full"
+.LC055: .string "No anode"
+.LC056: .string "Invalid request code"
+.LC057: .string "Invalid slot"
+.LC058: .string "File locking deadlock error"
+.LC059: .string "Bad font file format"
+.LC060: .string "Device not a stream"
+.LC061: .string "No data available"
+.LC062: .string "Timer expired"
+.LC063: .string "Out of streams resources"
+.LC064: .string "Machine is not on the network"
+.LC065: .string "Package not installed"
+.LC066: .string "Object is remote"
+.LC067: .string "Link has been severed"
+.LC068: .string "Advertise error"
+.LC069: .string "Srmount error"
+.LC070: .string "Communication error on send"
+.LC071: .string "Protocol error"
+.LC072: .string "Multihop attempted"
+.LC073: .string "RFS specific error"
+.LC074: .string "Not a data message"
+.LC075: .string "Value too large for defined data type"
+.LC076: .string "Name not unique on network"
+.LC077: .string "File descriptor in bad state"
+.LC078: .string "Remote address changed"
+.LC079: .string "Can not access a needed shared library"
+.LC080: .string "Accessing a corrupted shared library"
+.LC081: .string ".lib section in a.out corrupted"
+.LC082: .string "Attempting to link in too many shared libraries"
+.LC083: .string "Cannot exec a shared library directly"
+.LC084: .string "Illegal byte sequence"
+.LC085: .string "Interrupted system call should be restarted"
+.LC086: .string "Streams pipe error"
+.LC087: .string "Too many users"
+.LC088: .string "Socket operation on non-socket"
+.LC089: .string "Destination address required"
+.LC090: .string "Message too long"
+.LC091: .string "Protocol wrong type for socket"
+.LC092: .string "Protocol not available"
+.LC093: .string "Protocol not supported"
+.LC094: .string "Socket type not supported"
+.LC095: .string "Operation not supported on transport endpoint"
+.LC096: .string "Protocol family not supported"
+.LC097: .string "Address family not supported by protocol"
+.LC098: .string "Address already in use"
+.LC099: .string "Cannot assign requested address"
+.LC100: .string "Network is down"
+.LC101: .string "Network is unreachable"
+.LC102: .string "Network dropped connection because of reset"
+.LC103: .string "Software caused connection abort"
+.LC104: .string "Connection reset by peer"
+.LC105: .string "No buffer space available"
+.LC106: .string "Transport endpoint is already connected"
+.LC107: .string "Transport endpoint is not connected"
+.LC108: .string "Cannot send after transport endpoint shutdown"
+.LC109: .string "Too many references: cannot splice"
+.LC110: .string "Connection timed out"
+.LC111: .string "Connection refused"
+.LC112: .string "Host is down"
+.LC113: .string "No route to host"
+.LC114: .string "Operation already in progress"
+.LC115: .string "Operation now in progress"
+.LC116: .string "Stale NFS file handle"
+.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 "Quota exceeded"
+.LC123: .string "No medium found"
+.LC124: .string "Wrong medium type"
diff --git a/mdk-stage1/dietlibc/syscalls.s/errno.S b/mdk-stage1/dietlibc/syscalls.s/errno.S
new file mode 100644
index 000000000..2f0a2eca8
--- /dev/null
+++ b/mdk-stage1/dietlibc/syscalls.s/errno.S
@@ -0,0 +1,8 @@
+.section ".bss"
+.align 8
+
+.type errno,object
+.weak errno
+errno:
+ .long 0
+.size errno,.-errno
diff --git a/mdk-stage1/dietlibc/syscalls.s/exit.S b/mdk-stage1/dietlibc/syscalls.s/exit.S
deleted file mode 100644
index 11c989529..000000000
--- a/mdk-stage1/dietlibc/syscalls.s/exit.S
+++ /dev/null
@@ -1,3 +0,0 @@
-#include "syscalls.h"
-
-syscall_weak(exit,exit,_exit)
diff --git a/mdk-stage1/dietlibc/syscalls.s/fchown32.S b/mdk-stage1/dietlibc/syscalls.s/fchown32.S
new file mode 100644
index 000000000..25b18bc8e
--- /dev/null
+++ b/mdk-stage1/dietlibc/syscalls.s/fchown32.S
@@ -0,0 +1,5 @@
+#include "syscalls.h"
+
+#ifdef __NR_fchown32
+syscall_weak(fchown32,fchown32,__libc_fchown32)
+#endif
diff --git a/mdk-stage1/dietlibc/syscalls.s/fdatasync.S b/mdk-stage1/dietlibc/syscalls.s/fdatasync.S
new file mode 100644
index 000000000..46afd94d2
--- /dev/null
+++ b/mdk-stage1/dietlibc/syscalls.s/fdatasync.S
@@ -0,0 +1,6 @@
+#include "syscalls.h"
+
+#ifndef __NR_fdatasync
+#define __NR_fdatasync __NR_fsync
+#endif
+syscall_weak(fdatasync,fdatasync,__libc_fdatasync)
diff --git a/mdk-stage1/dietlibc/syscalls.s/ftruncate64.S b/mdk-stage1/dietlibc/syscalls.s/ftruncate64.S
new file mode 100644
index 000000000..639dcf5b7
--- /dev/null
+++ b/mdk-stage1/dietlibc/syscalls.s/ftruncate64.S
@@ -0,0 +1,10 @@
+#include "dietfeatures.h"
+#include "syscalls.h"
+
+#ifdef __NR_ftruncate64
+#ifdef WANT_LARGEFILE_BACKCOMPAT
+syscall(ftruncate64,__dietlibc_ftruncate64)
+#else
+syscall(ftruncate64,ftruncate64)
+#endif
+#endif
diff --git a/mdk-stage1/dietlibc/syscalls.s/getdents64.S b/mdk-stage1/dietlibc/syscalls.s/getdents64.S
index 16859addf..691d8f650 100644
--- a/mdk-stage1/dietlibc/syscalls.s/getdents64.S
+++ b/mdk-stage1/dietlibc/syscalls.s/getdents64.S
@@ -1,3 +1,4 @@
+#include "dietfeatures.h"
#include "syscalls.h"
#ifdef __NR_getdents64
diff --git a/mdk-stage1/dietlibc/syscalls.s/getegid32.S b/mdk-stage1/dietlibc/syscalls.s/getegid32.S
new file mode 100644
index 000000000..fd527d3f2
--- /dev/null
+++ b/mdk-stage1/dietlibc/syscalls.s/getegid32.S
@@ -0,0 +1,5 @@
+#include "syscalls.h"
+
+#ifdef __NR_getegid32
+syscall_weak(getegid32,getegid32,__libc_getegid32)
+#endif
diff --git a/mdk-stage1/dietlibc/syscalls.s/geteuid32.S b/mdk-stage1/dietlibc/syscalls.s/geteuid32.S
new file mode 100644
index 000000000..8881fa580
--- /dev/null
+++ b/mdk-stage1/dietlibc/syscalls.s/geteuid32.S
@@ -0,0 +1,5 @@
+#include "syscalls.h"
+
+#ifdef __NR_geteuid32
+syscall_weak(geteuid32,geteuid32,__libc_geteuid32)
+#endif
diff --git a/mdk-stage1/dietlibc/syscalls.s/getgid32.S b/mdk-stage1/dietlibc/syscalls.s/getgid32.S
new file mode 100644
index 000000000..09fca3504
--- /dev/null
+++ b/mdk-stage1/dietlibc/syscalls.s/getgid32.S
@@ -0,0 +1,5 @@
+#include "syscalls.h"
+
+#ifdef __NR_getgid32
+syscall_weak(getgid32,getgid32,__libc_getgid32)
+#endif
diff --git a/mdk-stage1/dietlibc/syscalls.s/getgroups32.S b/mdk-stage1/dietlibc/syscalls.s/getgroups32.S
new file mode 100644
index 000000000..29e6005d6
--- /dev/null
+++ b/mdk-stage1/dietlibc/syscalls.s/getgroups32.S
@@ -0,0 +1,5 @@
+#include "syscalls.h"
+
+#ifdef __NR_getgroups32
+syscall_weak(getgroups32,getgroups32,__libc_getgroups32)
+#endif
diff --git a/mdk-stage1/dietlibc/syscalls.s/getresgid32.S b/mdk-stage1/dietlibc/syscalls.s/getresgid32.S
new file mode 100644
index 000000000..35ee7436b
--- /dev/null
+++ b/mdk-stage1/dietlibc/syscalls.s/getresgid32.S
@@ -0,0 +1,5 @@
+#include "syscalls.h"
+
+#ifdef __NR_getresgid32
+syscall_weak(getresgid32,getresgid32,__libc_getresgid32)
+#endif
diff --git a/mdk-stage1/dietlibc/syscalls.s/getresuid.S b/mdk-stage1/dietlibc/syscalls.s/getresuid.S
index 62f6d764f..95c5505a8 100644
--- a/mdk-stage1/dietlibc/syscalls.s/getresuid.S
+++ b/mdk-stage1/dietlibc/syscalls.s/getresuid.S
@@ -1,7 +1,7 @@
#include "syscalls.h"
-#ifdef __getresuid
+#ifdef __NR_getresuid
-syscall(getresuid)
+syscall(getresuid,getresuid)
#endif
diff --git a/mdk-stage1/dietlibc/syscalls.s/getuid32.S b/mdk-stage1/dietlibc/syscalls.s/getuid32.S
new file mode 100644
index 000000000..f90ce06a5
--- /dev/null
+++ b/mdk-stage1/dietlibc/syscalls.s/getuid32.S
@@ -0,0 +1,5 @@
+#include "syscalls.h"
+
+#ifdef __NR_getuid32
+syscall_weak(getuid32,getuid32,__libc_getuid32)
+#endif
diff --git a/mdk-stage1/dietlibc/syscalls.s/init_module.S b/mdk-stage1/dietlibc/syscalls.s/init_module.S
new file mode 100644
index 000000000..4e8709d75
--- /dev/null
+++ b/mdk-stage1/dietlibc/syscalls.s/init_module.S
@@ -0,0 +1,5 @@
+#include "syscalls.h"
+
+#ifdef __NR_init_module
+syscall(init_module,init_module)
+#endif
diff --git a/mdk-stage1/dietlibc/syscalls.s/ioperm.S b/mdk-stage1/dietlibc/syscalls.s/ioperm.S
index 0acfde07a..74a51fc4b 100644
--- a/mdk-stage1/dietlibc/syscalls.s/ioperm.S
+++ b/mdk-stage1/dietlibc/syscalls.s/ioperm.S
@@ -1,3 +1,5 @@
#include "syscalls.h"
+#ifdef __NR_ioperm
syscall(ioperm,ioperm)
+#endif
diff --git a/mdk-stage1/dietlibc/syscalls.s/lchown32.S b/mdk-stage1/dietlibc/syscalls.s/lchown32.S
new file mode 100644
index 000000000..6863dcb24
--- /dev/null
+++ b/mdk-stage1/dietlibc/syscalls.s/lchown32.S
@@ -0,0 +1,5 @@
+#include "syscalls.h"
+
+#ifdef __NR_lchown32
+syscall_weak(lchown32,lchown32,__libc_lchown32)
+#endif
diff --git a/mdk-stage1/dietlibc/syscalls.s/llseek.S b/mdk-stage1/dietlibc/syscalls.s/llseek.S
deleted file mode 100644
index 0318b492e..000000000
--- a/mdk-stage1/dietlibc/syscalls.s/llseek.S
+++ /dev/null
@@ -1,6 +0,0 @@
-#include "dietfeatures.h"
-#include "syscalls.h"
-
-#ifdef __NR__llseek
-syscall(_llseek,llseek)
-#endif
diff --git a/mdk-stage1/dietlibc/syscalls.s/madvise.S b/mdk-stage1/dietlibc/syscalls.s/madvise.S
new file mode 100644
index 000000000..dde7daaea
--- /dev/null
+++ b/mdk-stage1/dietlibc/syscalls.s/madvise.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall(madvise,madvise)
diff --git a/mdk-stage1/dietlibc/syscalls.c/sync.c b/mdk-stage1/dietlibc/syscalls.s/mlock.S
index cca17461f..e2fa3d1bd 100644
--- a/mdk-stage1/dietlibc/syscalls.c/sync.c
+++ b/mdk-stage1/dietlibc/syscalls.s/mlock.S
@@ -1,3 +1,3 @@
#include "syscalls.h"
-_syscall0(int,sync)
+syscall(mlock,mlock)
diff --git a/mdk-stage1/dietlibc/syscalls.s/mmap2.S b/mdk-stage1/dietlibc/syscalls.s/mmap2.S
new file mode 100644
index 000000000..faf7eaaff
--- /dev/null
+++ b/mdk-stage1/dietlibc/syscalls.s/mmap2.S
@@ -0,0 +1,5 @@
+#include "syscalls.h"
+
+#ifdef __NR_mmap2
+syscall(mmap2,__mmap2)
+#endif
diff --git a/mdk-stage1/dietlibc/syscalls.c/getpid.c b/mdk-stage1/dietlibc/syscalls.s/msync.S
index d60a8db9a..6359d4cb0 100644
--- a/mdk-stage1/dietlibc/syscalls.c/getpid.c
+++ b/mdk-stage1/dietlibc/syscalls.s/msync.S
@@ -1,3 +1,3 @@
#include "syscalls.h"
-_syscall0(int,getpid)
+syscall(msync,msync)
diff --git a/mdk-stage1/dietlibc/syscalls.s/munlock.S b/mdk-stage1/dietlibc/syscalls.s/munlock.S
new file mode 100644
index 000000000..2001c89b7
--- /dev/null
+++ b/mdk-stage1/dietlibc/syscalls.s/munlock.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall(munlock,munlock)
diff --git a/mdk-stage1/dietlibc/syscalls.s/n_sigaction.S b/mdk-stage1/dietlibc/syscalls.s/n_sigaction.S
new file mode 100644
index 000000000..821f93d33
--- /dev/null
+++ b/mdk-stage1/dietlibc/syscalls.s/n_sigaction.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall_weak(sigaction,__old_sigaction,__n_sigaction)
diff --git a/mdk-stage1/dietlibc/syscalls.s/n_sigpending.S b/mdk-stage1/dietlibc/syscalls.s/n_sigpending.S
new file mode 100644
index 000000000..2ccb1da82
--- /dev/null
+++ b/mdk-stage1/dietlibc/syscalls.s/n_sigpending.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall_weak(sigpending,__old_sigpending,__n_sigpending)
diff --git a/mdk-stage1/dietlibc/syscalls.s/n_sigprocmask.S b/mdk-stage1/dietlibc/syscalls.s/n_sigprocmask.S
new file mode 100644
index 000000000..2a64bf166
--- /dev/null
+++ b/mdk-stage1/dietlibc/syscalls.s/n_sigprocmask.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall_weak(sigprocmask,__old_sigprocmask,__n_sigprocmask)
diff --git a/mdk-stage1/dietlibc/syscalls.s/n_sigsuspend.S b/mdk-stage1/dietlibc/syscalls.s/n_sigsuspend.S
new file mode 100644
index 000000000..be461b37d
--- /dev/null
+++ b/mdk-stage1/dietlibc/syscalls.s/n_sigsuspend.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall_weak(sigsuspend,__old_sigsuspend,__n_sigsuspend)
diff --git a/mdk-stage1/dietlibc/syscalls.s/nice.S b/mdk-stage1/dietlibc/syscalls.s/nice.S
index 7d3f740b2..4dad30edb 100644
--- a/mdk-stage1/dietlibc/syscalls.s/nice.S
+++ b/mdk-stage1/dietlibc/syscalls.s/nice.S
@@ -1,3 +1,5 @@
#include "syscalls.h"
+#ifdef __NR_nice
syscall(nice,nice)
+#endif
diff --git a/mdk-stage1/dietlibc/syscalls.s/pivot_root.S b/mdk-stage1/dietlibc/syscalls.s/pivot_root.S
new file mode 100644
index 000000000..89bc40298
--- /dev/null
+++ b/mdk-stage1/dietlibc/syscalls.s/pivot_root.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall(pivot_root,pivot_root)
diff --git a/mdk-stage1/dietlibc/syscalls.s/prctl.S b/mdk-stage1/dietlibc/syscalls.s/prctl.S
new file mode 100644
index 000000000..654d5ded5
--- /dev/null
+++ b/mdk-stage1/dietlibc/syscalls.s/prctl.S
@@ -0,0 +1,5 @@
+#include "syscalls.h"
+
+#ifdef __NR_prctl
+syscall(prctl,prctl)
+#endif
diff --git a/mdk-stage1/dietlibc/syscalls.s/ptrace.S b/mdk-stage1/dietlibc/syscalls.s/ptrace.S
new file mode 100644
index 000000000..8f198f41e
--- /dev/null
+++ b/mdk-stage1/dietlibc/syscalls.s/ptrace.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall(ptrace,__diet_ptrace)
diff --git a/mdk-stage1/dietlibc/syscalls.s/ptrace.s b/mdk-stage1/dietlibc/syscalls.s/ptrace.s
deleted file mode 100644
index 392e6a4ed..000000000
--- a/mdk-stage1/dietlibc/syscalls.s/ptrace.s
+++ /dev/null
@@ -1,3 +0,0 @@
-#include "syscalls.h"
-
-syscall(ptrace,ptrace)
diff --git a/mdk-stage1/dietlibc/syscalls.s/rt_sigaction.S b/mdk-stage1/dietlibc/syscalls.s/rt_sigaction.S
new file mode 100644
index 000000000..2382b23af
--- /dev/null
+++ b/mdk-stage1/dietlibc/syscalls.s/rt_sigaction.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall(rt_sigaction,__rt_sigaction)
diff --git a/mdk-stage1/dietlibc/syscalls.s/rt_sigpending.S b/mdk-stage1/dietlibc/syscalls.s/rt_sigpending.S
new file mode 100644
index 000000000..3ad8f6ff3
--- /dev/null
+++ b/mdk-stage1/dietlibc/syscalls.s/rt_sigpending.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall(rt_sigpending,__rt_sigpending)
diff --git a/mdk-stage1/dietlibc/syscalls.s/rt_sigprocmask.S b/mdk-stage1/dietlibc/syscalls.s/rt_sigprocmask.S
new file mode 100644
index 000000000..b4c2aba5a
--- /dev/null
+++ b/mdk-stage1/dietlibc/syscalls.s/rt_sigprocmask.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall(rt_sigprocmask,__rt_sigprocmask)
diff --git a/mdk-stage1/dietlibc/syscalls.s/rt_sigqueueinfo.S b/mdk-stage1/dietlibc/syscalls.s/rt_sigqueueinfo.S
new file mode 100644
index 000000000..fbc0b511f
--- /dev/null
+++ b/mdk-stage1/dietlibc/syscalls.s/rt_sigqueueinfo.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall(rt_sigqueueinfo,__rt_sigqueueinfo)
diff --git a/mdk-stage1/dietlibc/syscalls.s/rt_sigsuspend.S b/mdk-stage1/dietlibc/syscalls.s/rt_sigsuspend.S
new file mode 100644
index 000000000..58297409e
--- /dev/null
+++ b/mdk-stage1/dietlibc/syscalls.s/rt_sigsuspend.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall(rt_sigsuspend,__rt_sigsuspend)
diff --git a/mdk-stage1/dietlibc/syscalls.s/rt_sigtimedwait.S b/mdk-stage1/dietlibc/syscalls.s/rt_sigtimedwait.S
new file mode 100644
index 000000000..27cdef474
--- /dev/null
+++ b/mdk-stage1/dietlibc/syscalls.s/rt_sigtimedwait.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall(rt_sigtimedwait,__rt_sigtimedwait)
diff --git a/mdk-stage1/dietlibc/syscalls.s/sendfile.S b/mdk-stage1/dietlibc/syscalls.s/sendfile.S
index 12d6195dd..4dcb0ef69 100644
--- a/mdk-stage1/dietlibc/syscalls.s/sendfile.S
+++ b/mdk-stage1/dietlibc/syscalls.s/sendfile.S
@@ -3,4 +3,4 @@
syscall_weak(sendfile,sendfile,__libc_sendfile)
-link_warning(sendfile,"sendfile is not portable and does not support large files")
+link_warning(sendfile,"sendfile is not portable")
diff --git a/mdk-stage1/dietlibc/syscalls.s/sendfile64.S b/mdk-stage1/dietlibc/syscalls.s/sendfile64.S
new file mode 100644
index 000000000..054ed7177
--- /dev/null
+++ b/mdk-stage1/dietlibc/syscalls.s/sendfile64.S
@@ -0,0 +1,8 @@
+#include "syscalls.h"
+#include "dietwarning.h"
+
+#ifdef __NR_sendfile64
+syscall_weak(sendfile64,sendfile64,__libc_sendfile64)
+
+link_warning(sendfile64,"sendfile64 is not portable")
+#endif
diff --git a/mdk-stage1/dietlibc/syscalls.s/setfsgid.S b/mdk-stage1/dietlibc/syscalls.s/setfsgid.S
new file mode 100644
index 000000000..095f1b2b8
--- /dev/null
+++ b/mdk-stage1/dietlibc/syscalls.s/setfsgid.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall(setfsgid,setfsgid)
diff --git a/mdk-stage1/dietlibc/syscalls.s/setfsgid32.S b/mdk-stage1/dietlibc/syscalls.s/setfsgid32.S
new file mode 100644
index 000000000..b671bf90d
--- /dev/null
+++ b/mdk-stage1/dietlibc/syscalls.s/setfsgid32.S
@@ -0,0 +1,5 @@
+#include "syscalls.h"
+
+#ifdef __NR_setfsgid32
+syscall_weak(setfsgid32,setfsgid32,__libc_setfsgid32)
+#endif
diff --git a/mdk-stage1/dietlibc/syscalls.s/setfsuid.S b/mdk-stage1/dietlibc/syscalls.s/setfsuid.S
new file mode 100644
index 000000000..7dcd7b432
--- /dev/null
+++ b/mdk-stage1/dietlibc/syscalls.s/setfsuid.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall(setfsuid,setfsuid)
diff --git a/mdk-stage1/dietlibc/syscalls.s/setfsuid32.S b/mdk-stage1/dietlibc/syscalls.s/setfsuid32.S
new file mode 100644
index 000000000..df5a0a877
--- /dev/null
+++ b/mdk-stage1/dietlibc/syscalls.s/setfsuid32.S
@@ -0,0 +1,5 @@
+#include "syscalls.h"
+
+#ifdef __NR_setfsuid32
+syscall_weak(setfsuid32,setfsuid32,__libc_setfsuid32)
+#endif
diff --git a/mdk-stage1/dietlibc/syscalls.s/setgid32.S b/mdk-stage1/dietlibc/syscalls.s/setgid32.S
new file mode 100644
index 000000000..11be4922a
--- /dev/null
+++ b/mdk-stage1/dietlibc/syscalls.s/setgid32.S
@@ -0,0 +1,5 @@
+#include "syscalls.h"
+
+#ifdef __NR_setgid32
+syscall_weak(setgid32,setgid32,__libc_setgid32)
+#endif
diff --git a/mdk-stage1/dietlibc/syscalls.s/setregid32.S b/mdk-stage1/dietlibc/syscalls.s/setregid32.S
new file mode 100644
index 000000000..4565bba17
--- /dev/null
+++ b/mdk-stage1/dietlibc/syscalls.s/setregid32.S
@@ -0,0 +1,5 @@
+#include "syscalls.h"
+
+#ifdef __NR_setregid32
+syscall_weak(setregid32,setregid32,__libc_setregid32)
+#endif
diff --git a/mdk-stage1/dietlibc/syscalls.s/setresgid.S b/mdk-stage1/dietlibc/syscalls.s/setresgid.S
index 64cbac94e..2277cbaf4 100644
--- a/mdk-stage1/dietlibc/syscalls.s/setresgid.S
+++ b/mdk-stage1/dietlibc/syscalls.s/setresgid.S
@@ -1,7 +1,7 @@
#include "syscalls.h"
-#ifdef __setresgid
+#ifdef __NR_setresgid
-syscall(setresgid)
+syscall(setresgid,setresgid)
#endif
diff --git a/mdk-stage1/dietlibc/syscalls.s/setresgid32.S b/mdk-stage1/dietlibc/syscalls.s/setresgid32.S
new file mode 100644
index 000000000..209b27f97
--- /dev/null
+++ b/mdk-stage1/dietlibc/syscalls.s/setresgid32.S
@@ -0,0 +1,5 @@
+#include "syscalls.h"
+
+#ifdef __NR_setresgid32
+syscall_weak(setresgid32,setresgid32,__libc_setresgid32)
+#endif
diff --git a/mdk-stage1/dietlibc/syscalls.s/setresuid.S b/mdk-stage1/dietlibc/syscalls.s/setresuid.S
index 20b6abee9..cd322b77e 100644
--- a/mdk-stage1/dietlibc/syscalls.s/setresuid.S
+++ b/mdk-stage1/dietlibc/syscalls.s/setresuid.S
@@ -1,7 +1,7 @@
#include "syscalls.h"
-#ifdef __setresuid
+#ifdef __NR_setresuid
-syscall(setresuid)
+syscall(setresuid,setresuid)
#endif
diff --git a/mdk-stage1/dietlibc/syscalls.s/setreuid32.S b/mdk-stage1/dietlibc/syscalls.s/setreuid32.S
new file mode 100644
index 000000000..7bb06fa25
--- /dev/null
+++ b/mdk-stage1/dietlibc/syscalls.s/setreuid32.S
@@ -0,0 +1,5 @@
+#include "syscalls.h"
+
+#ifdef __NR_setreuid32
+syscall_weak(setreuid32,setreuid32,__libc_setreuid32)
+#endif
diff --git a/mdk-stage1/dietlibc/syscalls.s/settimeofday.S b/mdk-stage1/dietlibc/syscalls.s/settimeofday.S
new file mode 100644
index 000000000..4ca626aa4
--- /dev/null
+++ b/mdk-stage1/dietlibc/syscalls.s/settimeofday.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall(settimeofday,settimeofday)
diff --git a/mdk-stage1/dietlibc/syscalls.s/setuid32.S b/mdk-stage1/dietlibc/syscalls.s/setuid32.S
new file mode 100644
index 000000000..869603471
--- /dev/null
+++ b/mdk-stage1/dietlibc/syscalls.s/setuid32.S
@@ -0,0 +1,5 @@
+#include "syscalls.h"
+
+#ifdef __NR_setuid32
+syscall_weak(setuid32,setuid32,__libc_setuid32)
+#endif
diff --git a/mdk-stage1/dietlibc/syscalls.s/sigaction.S b/mdk-stage1/dietlibc/syscalls.s/sigaction.S
deleted file mode 100644
index 32382870c..000000000
--- a/mdk-stage1/dietlibc/syscalls.s/sigaction.S
+++ /dev/null
@@ -1,3 +0,0 @@
-#include "syscalls.h"
-
-syscall(sigaction,sigaction)
diff --git a/mdk-stage1/dietlibc/syscalls.s/signal.S b/mdk-stage1/dietlibc/syscalls.s/signal.S
deleted file mode 100644
index 86c4d5db0..000000000
--- a/mdk-stage1/dietlibc/syscalls.s/signal.S
+++ /dev/null
@@ -1,3 +0,0 @@
-#include "syscalls.h"
-
-syscall(signal,signal)
diff --git a/mdk-stage1/dietlibc/syscalls.s/sigpending.S b/mdk-stage1/dietlibc/syscalls.s/sigpending.S
deleted file mode 100644
index 08715bef5..000000000
--- a/mdk-stage1/dietlibc/syscalls.s/sigpending.S
+++ /dev/null
@@ -1,3 +0,0 @@
-#include "syscalls.h"
-
-syscall(sigpending,sigpending)
diff --git a/mdk-stage1/dietlibc/syscalls.s/sigprocmask.S b/mdk-stage1/dietlibc/syscalls.s/sigprocmask.S
deleted file mode 100644
index 07f5b9d26..000000000
--- a/mdk-stage1/dietlibc/syscalls.s/sigprocmask.S
+++ /dev/null
@@ -1,3 +0,0 @@
-#include "syscalls.h"
-
-syscall_weak(sigprocmask,sigprocmask,__sigprocmask)
diff --git a/mdk-stage1/dietlibc/syscalls.s/sigsuspend.S b/mdk-stage1/dietlibc/syscalls.s/sigsuspend.S
deleted file mode 100644
index 062264ab6..000000000
--- a/mdk-stage1/dietlibc/syscalls.s/sigsuspend.S
+++ /dev/null
@@ -1,3 +0,0 @@
-#include "syscalls.h"
-
-syscall_weak(sigsuspend,sigsuspend,__libc_sigsuspend)
diff --git a/mdk-stage1/dietlibc/syscalls.s/stime.S b/mdk-stage1/dietlibc/syscalls.s/stime.S
index 9d9f5bf0a..281809c27 100644
--- a/mdk-stage1/dietlibc/syscalls.s/stime.S
+++ b/mdk-stage1/dietlibc/syscalls.s/stime.S
@@ -1,3 +1,5 @@
#include "syscalls.h"
+#ifdef __NR_stime
syscall(stime,stime)
+#endif
diff --git a/mdk-stage1/dietlibc/syscalls.s/syslog.S b/mdk-stage1/dietlibc/syscalls.s/syslog.S
index 6af3c4eac..4ebd81a39 100644
--- a/mdk-stage1/dietlibc/syscalls.s/syslog.S
+++ b/mdk-stage1/dietlibc/syscalls.s/syslog.S
@@ -1,3 +1,3 @@
#include "syscalls.h"
-syscall(syslog,__syscall_syslog)
+syscall_weak(syslog,__syscall_syslog,klogctl)
diff --git a/mdk-stage1/dietlibc/syscalls.s/time.S b/mdk-stage1/dietlibc/syscalls.s/time.S
index 26c79091c..aa646cfdf 100644
--- a/mdk-stage1/dietlibc/syscalls.s/time.S
+++ b/mdk-stage1/dietlibc/syscalls.s/time.S
@@ -1,3 +1,5 @@
#include "syscalls.h"
+#ifdef __NR_time
syscall(time,time)
+#endif
diff --git a/mdk-stage1/dietlibc/syscalls.s/truncate64.S b/mdk-stage1/dietlibc/syscalls.s/truncate64.S
new file mode 100644
index 000000000..0e375728e
--- /dev/null
+++ b/mdk-stage1/dietlibc/syscalls.s/truncate64.S
@@ -0,0 +1,10 @@
+#include "dietfeatures.h"
+#include "syscalls.h"
+
+#ifdef __NR_truncate64
+#ifdef WANT_LARGEFILE_BACKCOMPAT
+syscall(truncate64,__dietlibc_truncate64)
+#else
+syscall(truncate64,truncate64)
+#endif
+#endif
diff --git a/mdk-stage1/dietlibc/syscalls.s/waitpid.S b/mdk-stage1/dietlibc/syscalls.s/waitpid.S
index 5cdc18afb..bedc73eb6 100644
--- a/mdk-stage1/dietlibc/syscalls.s/waitpid.S
+++ b/mdk-stage1/dietlibc/syscalls.s/waitpid.S
@@ -1,3 +1,5 @@
#include "syscalls.h"
+#ifdef __NR_waitpid
syscall_weak(waitpid,waitpid,__libc_waitpid)
+#endif
diff --git a/mdk-stage1/dietlibc/x86_64/Makefile.add b/mdk-stage1/dietlibc/x86_64/Makefile.add
new file mode 100644
index 000000000..7d60185a7
--- /dev/null
+++ b/mdk-stage1/dietlibc/x86_64/Makefile.add
@@ -0,0 +1,2 @@
+CFLAGS := -Os -fstrict-aliasing -momit-leaf-frame-pointer -mfancy-math-387
+VPATH := x86_64:syscalls.s:$(VPATH)
diff --git a/mdk-stage1/dietlibc/x86_64/__longjmp.S b/mdk-stage1/dietlibc/x86_64/__longjmp.S
new file mode 100644
index 000000000..43ec0539f
--- /dev/null
+++ b/mdk-stage1/dietlibc/x86_64/__longjmp.S
@@ -0,0 +1,26 @@
+#include <setjmp.h>
+#include "dietwarning.h"
+
+.text
+.global __longjmp
+.type __longjmp,@function
+__longjmp:
+ mov $1,%eax
+ /* Restore the return address now. */
+ movq (JB_PC*8)(%rdi),%rdx
+ /* Restore registers. */
+ movq (JB_RBX*8)(%rdi),%rbx
+ movq (JB_RBP*8)(%rdi),%rbp
+ movq (JB_R12*8)(%rdi),%r12
+ movq (JB_R13*8)(%rdi),%r13
+ movq (JB_R14*8)(%rdi),%r14
+ movq (JB_R15*8)(%rdi),%r15
+ movq (JB_RSP*8)(%rdi),%rsp
+ /* never return 0 */
+ test %esi,%esi
+ cmovne %esi,%eax
+ /* Jump to saved PC. */
+ jmp *%rdx
+.size __longjmp,.-__longjmp;
+
+link_warning("__longjmp","longjmp() not yet tested")
diff --git a/mdk-stage1/dietlibc/x86_64/__testandset.S b/mdk-stage1/dietlibc/x86_64/__testandset.S
new file mode 100644
index 000000000..7355477e6
--- /dev/null
+++ b/mdk-stage1/dietlibc/x86_64/__testandset.S
@@ -0,0 +1,12 @@
+#include "dietwarning.h"
+
+.text
+.global __testandset
+.type __testandset,@function
+__testandset:
+ xorl %eax,%eax
+ incl %eax
+ xchg %rax,(%rdi)
+ ret
+
+link_warning("__testandset", "warning: __testandset() was never tested!")
diff --git a/mdk-stage1/dietlibc/x86_64/accept.S b/mdk-stage1/dietlibc/x86_64/accept.S
new file mode 100644
index 000000000..7bdc38c7e
--- /dev/null
+++ b/mdk-stage1/dietlibc/x86_64/accept.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall(accept, accept);
diff --git a/mdk-stage1/dietlibc/syscalls.c/getppid.c b/mdk-stage1/dietlibc/x86_64/bind.S
index ee87a8eae..05849d470 100644
--- a/mdk-stage1/dietlibc/syscalls.c/getppid.c
+++ b/mdk-stage1/dietlibc/x86_64/bind.S
@@ -1,3 +1,3 @@
#include "syscalls.h"
-_syscall0(int,getppid)
+syscall(bind, bind);
diff --git a/mdk-stage1/dietlibc/x86_64/clone.S b/mdk-stage1/dietlibc/x86_64/clone.S
new file mode 100644
index 000000000..82c8c5bae
--- /dev/null
+++ b/mdk-stage1/dietlibc/x86_64/clone.S
@@ -0,0 +1,64 @@
+#include "syscalls.h"
+#include <errno.h>
+#include "dietwarning.h"
+
+.text
+.type clone,@function
+.weak clone
+clone:
+.type __clone,@function
+.global __clone
+__clone:
+ movl $-EINVAL,%eax
+ testq %rdi,%rdi /* have non null thread_funcion */
+ jz .Lclone_error
+ testq %rsi,%rsi /* have non null child_stack pointer */
+ jz .Lclone_error
+
+ /* put the parameters on thread stack */
+ subq $16,%rsi
+ movq %rcx,8(%rsi) /* thread parameter */
+ movq %rdi,0(%rsi) /* thread function */
+
+ /* syscall */
+ movq %rdx,%rdi
+ movl $__NR_clone,%eax
+ syscall
+ cmpl $0,%eax
+ jl .Lclone_error
+ jne .Lreturn
+
+.thread_start:
+ /* call thread function */
+ popq %rax
+ popq %rdi
+ call *%rax
+ /* exit a thread */
+ movq %rax,%rdi
+#ifdef PIC
+ jmp _exit@PLT
+#else
+ jmp _exit
+#endif
+
+.Lclone_error:
+ /* set errno */
+ negl %eax
+ pushq %rax
+#ifdef PIC
+ call __errno_location@PLT
+#else
+ call __errno_location
+#endif
+ popq %rcx
+ movl %ecx,(%rax)
+ orq $-1, %rax
+
+.Lreturn:
+ /* just return */
+ ret
+
+link_warning("clone", "warning: clone() not yet tested")
+link_warning("__clone", "warning: clone() not yet tested")
+//link_warning("clone", "warning: clone() not yet implemented")
+//link_warning("__clone", "warning: clone() not yet implemented")
diff --git a/mdk-stage1/dietlibc/x86_64/connect.S b/mdk-stage1/dietlibc/x86_64/connect.S
new file mode 100644
index 000000000..5fbd151ae
--- /dev/null
+++ b/mdk-stage1/dietlibc/x86_64/connect.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall(connect, connect);
diff --git a/mdk-stage1/dietlibc/x86_64/getpeername.S b/mdk-stage1/dietlibc/x86_64/getpeername.S
new file mode 100644
index 000000000..fdaa1038a
--- /dev/null
+++ b/mdk-stage1/dietlibc/x86_64/getpeername.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall(getpeername, getpeername);
diff --git a/mdk-stage1/dietlibc/x86_64/getsockname.S b/mdk-stage1/dietlibc/x86_64/getsockname.S
new file mode 100644
index 000000000..1ea0bc000
--- /dev/null
+++ b/mdk-stage1/dietlibc/x86_64/getsockname.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall(getsockname, getsockname);
diff --git a/mdk-stage1/dietlibc/x86_64/getsockopt.S b/mdk-stage1/dietlibc/x86_64/getsockopt.S
new file mode 100644
index 000000000..465c4e08e
--- /dev/null
+++ b/mdk-stage1/dietlibc/x86_64/getsockopt.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall(getsockopt, getsockopt);
diff --git a/mdk-stage1/dietlibc/x86_64/listen.S b/mdk-stage1/dietlibc/x86_64/listen.S
new file mode 100644
index 000000000..66a3fe376
--- /dev/null
+++ b/mdk-stage1/dietlibc/x86_64/listen.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall(listen, listen);
diff --git a/mdk-stage1/dietlibc/x86_64/mmap.S b/mdk-stage1/dietlibc/x86_64/mmap.S
new file mode 100644
index 000000000..764d5fd96
--- /dev/null
+++ b/mdk-stage1/dietlibc/x86_64/mmap.S
@@ -0,0 +1,8 @@
+#include "syscalls.h"
+
+.text
+.global mmap
+.type mmap,@function
+mmap:
+ mov $__NR_mmap,%al
+ jmp __unified_syscall
diff --git a/mdk-stage1/dietlibc/x86_64/recv.c b/mdk-stage1/dietlibc/x86_64/recv.c
new file mode 100644
index 000000000..3b76c0716
--- /dev/null
+++ b/mdk-stage1/dietlibc/x86_64/recv.c
@@ -0,0 +1,13 @@
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <linuxnet.h>
+
+int __libc_recv(int fd, void * buf, size_t n, int flags);
+ /* shut up gcc warning about missing prototype */
+
+int __libc_recv(int fd, void * buf, size_t n, int flags) {
+ return recvfrom(fd, buf, n, flags, 0, 0);
+}
+
+int recv(int a, void * b, size_t c, int flags)
+ __attribute__ ((weak, alias("__libc_recv")));
diff --git a/mdk-stage1/dietlibc/x86_64/recvfrom.S b/mdk-stage1/dietlibc/x86_64/recvfrom.S
new file mode 100644
index 000000000..d3c2e602f
--- /dev/null
+++ b/mdk-stage1/dietlibc/x86_64/recvfrom.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall(recvfrom, recvfrom);
diff --git a/mdk-stage1/dietlibc/x86_64/recvmsg.S b/mdk-stage1/dietlibc/x86_64/recvmsg.S
new file mode 100644
index 000000000..cfbbafdc1
--- /dev/null
+++ b/mdk-stage1/dietlibc/x86_64/recvmsg.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall(recvmsg, recvmsg);
diff --git a/mdk-stage1/dietlibc/x86_64/send.c b/mdk-stage1/dietlibc/x86_64/send.c
new file mode 100644
index 000000000..bdeb1d31f
--- /dev/null
+++ b/mdk-stage1/dietlibc/x86_64/send.c
@@ -0,0 +1,13 @@
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <linuxnet.h>
+
+int __libc_send(int fd, const void * buf, size_t n, int flags);
+ /* shut up gcc warning about missing prototype */
+
+int __libc_send(int fd, const void * buf, size_t n, int flags) {
+ return sendto(fd, buf, n, flags, NULL, 0);
+}
+
+int send(int a, const void * b, size_t c, int flags)
+ __attribute__ ((weak, alias("__libc_send")));
diff --git a/mdk-stage1/dietlibc/x86_64/sendmsg.S b/mdk-stage1/dietlibc/x86_64/sendmsg.S
new file mode 100644
index 000000000..c2bc80f72
--- /dev/null
+++ b/mdk-stage1/dietlibc/x86_64/sendmsg.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall(sendmsg, sendmsg);
diff --git a/mdk-stage1/dietlibc/x86_64/sendto.S b/mdk-stage1/dietlibc/x86_64/sendto.S
new file mode 100644
index 000000000..1579a3b45
--- /dev/null
+++ b/mdk-stage1/dietlibc/x86_64/sendto.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall(sendto, sendto);
diff --git a/mdk-stage1/dietlibc/x86_64/setjmp.S b/mdk-stage1/dietlibc/x86_64/setjmp.S
new file mode 100644
index 000000000..3d1ec11f0
--- /dev/null
+++ b/mdk-stage1/dietlibc/x86_64/setjmp.S
@@ -0,0 +1,37 @@
+#include <setjmp.h>
+#include "dietwarning.h"
+
+.text
+.weak setjmp
+.type setjmp,@function
+setjmp:
+.globl __setjmp
+.type __setjmp,@function
+__setjmp:
+ xorq %rsi,%rsi
+
+.globl __sigsetjmp
+.type __sigsetjmp,@function
+__sigsetjmp:
+ movq %rbx,(JB_RBX*8)(%rdi)
+ movq %rbp,(JB_RBP*8)(%rdi)
+ movq %r12,(JB_R12*8)(%rdi)
+ movq %r13,(JB_R13*8)(%rdi)
+ movq %r14,(JB_R14*8)(%rdi)
+ movq %r15,(JB_R15*8)(%rdi)
+ leaq 8(%rsp),%rdx
+ movq %rdx,(JB_RSP*8)(%rdi)
+ movq (%rsp),%rdx
+ movq %rdx,(JB_PC*8)(%rdi)
+#ifdef PIC
+ jmp __sigjmp_save@PLT
+#else
+ jmp __sigjmp_save
+#endif
+.size __sigsetjmp,.-__sigsetjmp;
+
+link_warning("setjmp","setjmp() not yet tested")
+link_warning("__sigsetjmp","setjmp() not yet tested")
+//link_warning("setjmp","error: setjmp() not yet implemented")
+//link_warning("__sigsetjmp","error: setjmp() not yet implemented")
+
diff --git a/mdk-stage1/dietlibc/x86_64/setsockopt.S b/mdk-stage1/dietlibc/x86_64/setsockopt.S
new file mode 100644
index 000000000..45fcfbb6c
--- /dev/null
+++ b/mdk-stage1/dietlibc/x86_64/setsockopt.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall(setsockopt, setsockopt);
diff --git a/mdk-stage1/dietlibc/x86_64/shutdown.S b/mdk-stage1/dietlibc/x86_64/shutdown.S
new file mode 100644
index 000000000..024e99e18
--- /dev/null
+++ b/mdk-stage1/dietlibc/x86_64/shutdown.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall(shutdown, shutdown);
diff --git a/mdk-stage1/dietlibc/x86_64/sigaction.c b/mdk-stage1/dietlibc/x86_64/sigaction.c
new file mode 100644
index 000000000..18f32efde
--- /dev/null
+++ b/mdk-stage1/dietlibc/x86_64/sigaction.c
@@ -0,0 +1,26 @@
+#include <signal.h>
+#include <stdlib.h>
+#include <string.h>
+#include <syscalls.h>
+
+int __rt_sigaction(int signum, const struct sigaction *act, struct sigaction *oldact, long nr);
+
+static void restore_rt(void) {
+ asm volatile ("syscall" : : "a" (__NR_rt_sigreturn));
+}
+
+int __libc_sigaction(int signum, const struct sigaction *act, struct sigaction *oldact);
+int __libc_sigaction(int signum, const struct sigaction *act, struct sigaction *oldact) {
+ struct sigaction *newact = (struct sigaction *)act;
+ if (act) {
+ newact = alloca(sizeof(*newact));
+ newact->sa_handler = act->sa_handler;
+ newact->sa_flags = act->sa_flags | SA_RESTORER;
+ newact->sa_restorer = &restore_rt;
+ newact->sa_mask = act->sa_mask;
+ }
+ return __rt_sigaction(signum, newact, 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/x86_64/socket.S b/mdk-stage1/dietlibc/x86_64/socket.S
new file mode 100644
index 000000000..cc453881f
--- /dev/null
+++ b/mdk-stage1/dietlibc/x86_64/socket.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall(socket, socket);
diff --git a/mdk-stage1/dietlibc/x86_64/socketpair.S b/mdk-stage1/dietlibc/x86_64/socketpair.S
new file mode 100644
index 000000000..d92eaa4d8
--- /dev/null
+++ b/mdk-stage1/dietlibc/x86_64/socketpair.S
@@ -0,0 +1,3 @@
+#include "syscalls.h"
+
+syscall(socketpair, socketpair);
diff --git a/mdk-stage1/dietlibc/x86_64/start.S b/mdk-stage1/dietlibc/x86_64/start.S
new file mode 100644
index 000000000..328bbcfe3
--- /dev/null
+++ b/mdk-stage1/dietlibc/x86_64/start.S
@@ -0,0 +1,38 @@
+#include "dietfeatures.h"
+
+.text
+.global _start
+_start:
+ popq %rdi /* %rdi = argc */
+ movq %rsp,%rsi /* %rsi = argv */
+ pushq %rdi
+
+ leaq 8(%rsi,%rdi,8),%rdx /* %rdx = envp = (8*rdi)+%rsi+8 */
+
+ movq %rdx, environ
+
+#ifdef PROFILING
+ pushq $_etext
+ pushq $.text
+ call monitor
+ addq $0x16, %rsp
+#endif
+
+#ifdef WANT_DYNAMIC
+ call _dyn_start
+#else
+ call main
+#endif
+
+#ifdef PROFILING
+ pushq %rax
+ call _stop_monitor
+ popq %rdi
+#else
+ movq %rax, %rdi /* return value */
+#endif
+ call exit
+ hlt
+.Lstart:
+ .size _start,.Lstart-_start
+
diff --git a/mdk-stage1/dietlibc/x86_64/syscalls.h b/mdk-stage1/dietlibc/x86_64/syscalls.h
new file mode 100644
index 000000000..6fcfbfc60
--- /dev/null
+++ b/mdk-stage1/dietlibc/x86_64/syscalls.h
@@ -0,0 +1,282 @@
+#define __NR_read 0
+#define __NR_write 1
+#define __NR_open 2
+#define __NR_close 3
+#define __NR_stat 4
+#define __NR_fstat 5
+#define __NR_lstat 6
+#define __NR_poll 7
+
+#define __NR_lseek 8
+#define __NR_mmap 9
+#define __NR_mprotect 10
+#define __NR_munmap 11
+#define __NR_brk 12
+#define __NR_rt_sigaction 13
+#define __NR_rt_sigprocmask 14
+#define __NR_rt_sigreturn 15
+
+#define __NR_ioctl 16
+#define __NR_pread 17
+#define __NR_pwrite 18
+#define __NR_readv 19
+#define __NR_writev 20
+#define __NR_access 21
+#define __NR_pipe 22
+#define __NR_select 23
+
+#define __NR_sched_yield 24
+#define __NR_mremap 25
+#define __NR_msync 26
+#define __NR_mincore 27
+#define __NR_madvise 28
+#define __NR_shmget 29
+#define __NR_shmat 30
+#define __NR_shmctl 31
+
+#define __NR_dup 32
+#define __NR_dup2 33
+#define __NR_pause 34
+#define __NR_nanosleep 35
+#define __NR_getitimer 36
+#define __NR_alarm 37
+#define __NR_setitimer 38
+#define __NR_getpid 39
+
+#define __NR_sendfile 40
+#define __NR_socket 41
+#define __NR_connect 42
+#define __NR_accept 43
+#define __NR_sendto 44
+#define __NR_recvfrom 45
+#define __NR_sendmsg 46
+#define __NR_recvmsg 47
+
+#define __NR_shutdown 48
+#define __NR_bind 49
+#define __NR_listen 50
+#define __NR_getsockname 51
+#define __NR_getpeername 52
+#define __NR_socketpair 53
+#define __NR_setsockopt 54
+#define __NR_getsockopt 55
+
+#define __NR_clone 56
+#define __NR_fork 57
+#define __NR_vfork 58
+#define __NR_execve 59
+#define __NR_exit 60
+#define __NR_wait4 61
+#define __NR_kill 62
+#define __NR_uname 63
+
+#define __NR_semget 64
+#define __NR_semop 65
+#define __NR_semctl 66
+#define __NR_shmdt 67
+#define __NR_msgget 68
+#define __NR_msgsnd 69
+#define __NR_msgrcv 70
+#define __NR_msgctl 71
+
+#define __NR_fcntl 72
+#define __NR_flock 73
+#define __NR_fsync 74
+#define __NR_fdatasync 75
+#define __NR_truncate 76
+#define __NR_ftruncate 77
+#define __NR_getdents 78
+#define __NR_getcwd 79
+
+#define __NR_chdir 80
+#define __NR_fchdir 81
+#define __NR_rename 82
+#define __NR_mkdir 83
+#define __NR_rmdir 84
+#define __NR_creat 85
+#define __NR_link 86
+#define __NR_unlink 87
+
+#define __NR_symlink 88
+#define __NR_readlink 89
+#define __NR_chmod 90
+#define __NR_fchmod 91
+#define __NR_chown 92
+#define __NR_fchown 93
+#define __NR_lchown 94
+#define __NR_umask 95
+
+#define __NR_gettimeofday 96
+#define __NR_getrlimit 97
+#define __NR_getrusage 98
+#define __NR_sysinfo 99
+#define __NR_times 100
+#define __NR_ptrace 101
+#define __NR_getuid 102
+#define __NR_syslog 103
+
+/* at the very end the stuff that never runs during the benchmarks */
+#define __NR_getgid 104
+#define __NR_setuid 105
+#define __NR_setgid 106
+#define __NR_geteuid 107
+#define __NR_getegid 108
+#define __NR_setpgid 109
+#define __NR_getppid 110
+#define __NR_getpgrp 111
+
+#define __NR_setsid 112
+#define __NR_setreuid 113
+#define __NR_setregid 114
+#define __NR_getgroups 115
+#define __NR_setgroups 116
+#define __NR_setresuid 117
+#define __NR_getresuid 118
+#define __NR_setresgid 119
+
+#define __NR_getresgid 120
+#define __NR_getpgid 121
+#define __NR_setfsuid 122
+#define __NR_setfsgid 123
+#define __NR_getsid 124
+#define __NR_capget 125
+#define __NR_capset 126
+
+#define __NR_rt_sigpending 127
+#define __NR_rt_sigtimedwait 128
+#define __NR_rt_sigqueueinfo 129
+#define __NR_rt_sigsuspend 130
+#define __NR_sigaltstack 131
+#define __NR_utime 132
+#define __NR_mknod 133
+
+#define __NR_uselib 134
+#define __NR_personality 135
+
+#define __NR_ustat 136
+#define __NR_statfs 137
+#define __NR_fstatfs 138
+#define __NR_sysfs 139
+
+#define __NR_getpriority 140
+#define __NR_setpriority 141
+#define __NR_sched_setparam 142
+#define __NR_sched_getparam 143
+#define __NR_sched_setscheduler 144
+#define __NR_sched_getscheduler 145
+#define __NR_sched_get_priority_max 146
+#define __NR_sched_get_priority_min 147
+#define __NR_sched_rr_get_interval 148
+
+#define __NR_mlock 149
+#define __NR_munlock 150
+#define __NR_mlockall 151
+#define __NR_munlockall 152
+
+#define __NR_vhangup 153
+
+#define __NR_modify_ldt 154
+
+#define __NR_pivot_root 155
+
+#define __NR__sysctl 156
+
+#define __NR_prctl 157
+#define __NR_arch_prctl 158
+
+#define __NR_adjtimex 159
+
+#define __NR_setrlimit 160
+
+#define __NR_chroot 161
+
+#define __NR_sync 162
+
+#define __NR_acct 163
+
+#define __NR_settimeofday 164
+
+#define __NR_mount 165
+#define __NR_umount2 166
+
+#define __NR_swapon 167
+#define __NR_swapoff 168
+
+#define __NR_reboot 169
+
+#define __NR_sethostname 170
+#define __NR_setdomainname 171
+
+#define __NR_iopl 172
+#define __NR_ioperm 173
+
+#define __NR_create_module 174
+#define __NR_init_module 175
+#define __NR_delete_module 176
+#define __NR_get_kernel_syms 177
+#define __NR_query_module 178
+
+#define __NR_quotactl 179
+
+#define __NR_nfsservctl 180
+
+#define __NR_getpmsg 181
+#define __NR_putpmsg 182
+
+#define __NR_afs_syscall 183
+
+#define __NR_tuxcall 184 /* reserved for tux */
+
+#define __NR_security 185 /* reserved for security */
+
+#define __NR_gettid 186
+
+#define __NR_readahead 187
+
+#define __NR_setxattr 188
+#define __NR_lsetxattr 189
+#define __NR_fsetxattr 190
+#define __NR_getxattr 191
+#define __NR_lgetxattr 192
+#define __NR_fgetxattr 193
+#define __NR_listxattr 194
+#define __NR_llistxattr 195
+#define __NR_flistxattr 196
+#define __NR_removexattr 197
+#define __NR_lremovexattr 198
+#define __NR_fremovexattr 199
+#define __NR_tkill 200 /* 2.5 only */
+#define __NR_time 201
+#define __NR_futex 202 /* 2.5 only */
+#define __NR_sched_setaffinity 203
+#define __NR_sched_getaffinity 204
+#define __NR_set_thread_area 205
+#define __NR_io_setup 206
+#define __NR_io_destroy 207
+#define __NR_io_getevents 208
+#define __NR_io_submit 209
+#define __NR_io_cancel 210
+#define __NR_get_thread_area 211
+#define __NR_lookup_dcookie 212
+
+#define __NR_syscall_max __NR_futex
+
+#define syscall_weak(name,wsym,sym) \
+.text; \
+.type wsym,@function; \
+.weak wsym; \
+wsym: ; \
+.type sym,@function; \
+.global sym; \
+sym: \
+ mov $__NR_##name,%al; \
+ jmp __unified_syscall
+
+#define syscall(name,sym) \
+.text; \
+.type sym,@function; \
+.global sym; \
+sym: \
+ mov $__NR_##name,%al; \
+ jmp __unified_syscall
+
diff --git a/mdk-stage1/dietlibc/x86_64/umount.S b/mdk-stage1/dietlibc/x86_64/umount.S
new file mode 100644
index 000000000..2b51b8edf
--- /dev/null
+++ b/mdk-stage1/dietlibc/x86_64/umount.S
@@ -0,0 +1,9 @@
+#include "syscalls.h"
+
+.text
+.global umount
+.type umount,@function
+umount:
+ mov $__NR_umount2,%al
+ xorq %rsi,%rsi
+ jmp __unified_syscall
diff --git a/mdk-stage1/dietlibc/x86_64/unified.S b/mdk-stage1/dietlibc/x86_64/unified.S
new file mode 100644
index 000000000..29ac1bcb0
--- /dev/null
+++ b/mdk-stage1/dietlibc/x86_64/unified.S
@@ -0,0 +1,32 @@
+#include <dietfeatures.h>
+
+#define SYS_exit 0x3c
+
+.text
+.weak exit
+exit:
+.global _exit
+_exit:
+ mov $SYS_exit,%al
+
+#ifndef __DYN_LIB
+.global __unified_syscall
+#endif
+__unified_syscall:
+ movzbl %al, %eax
+ mov %rcx, %r10
+ syscall
+ cmpq $0, %rax
+ jge .Lnoerror
+ negl %eax
+ pushq %rax
+ call __errno_location
+ popq %rcx
+ movl %ecx,(%rax)
+ orq $-1, %rax
+.Lnoerror:
+
+/* here we go and "reuse" the return for weak-void functions */
+#include "dietuglyweaks.h"
+
+ ret
diff --git a/mdk-stage1/dietlibc/x86_64/waitpid.S b/mdk-stage1/dietlibc/x86_64/waitpid.S
new file mode 100644
index 000000000..944df48bf
--- /dev/null
+++ b/mdk-stage1/dietlibc/x86_64/waitpid.S
@@ -0,0 +1,12 @@
+#include "syscalls.h"
+
+.text
+.type waitpid,@function
+.weak waitpid
+waitpid:
+.type __libc_waitpid,@function
+.global __libc_waitpid
+__libc_waitpid:
+ mov $0,%rcx
+ mov $__NR_wait4,%al
+ jmp __unified_syscall