From 4cd6a4a5d7e49d54d53dcf4a6f3393d50bd88e8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwenol=C3=A9=20Beauchesne?= Date: Wed, 4 Jun 2003 18:44:09 +0000 Subject: Import dietlibc 0.22 + other fixes for AMD64 --- mdk-stage1/dietlibc/alpha/__alarm.c | 13 + mdk-stage1/dietlibc/alpha/__testandset.S | 11 + mdk-stage1/dietlibc/alpha/errlist.S | 288 +++++ mdk-stage1/dietlibc/alpha/lseek64.S | 5 + mdk-stage1/dietlibc/alpha/n_sigprocmask.S | 3 + mdk-stage1/dietlibc/alpha/sigaction.c | 7 + mdk-stage1/dietlibc/alpha/socketpair.S | 3 + mdk-stage1/dietlibc/alpha/syscalls.h | 371 ++++++ mdk-stage1/dietlibc/i386/PIC.h | 82 ++ mdk-stage1/dietlibc/i386/__half.S | 10 + mdk-stage1/dietlibc/i386/__ten.S | 9 + mdk-stage1/dietlibc/i386/accept.S | 4 + mdk-stage1/dietlibc/i386/acos.S | 30 + mdk-stage1/dietlibc/i386/acosh.S | 18 + mdk-stage1/dietlibc/i386/asin.S | 29 + mdk-stage1/dietlibc/i386/asinh.S | 18 + mdk-stage1/dietlibc/i386/atan.S | 27 + mdk-stage1/dietlibc/i386/atan2.S | 12 + mdk-stage1/dietlibc/i386/atanh.S | 19 + mdk-stage1/dietlibc/i386/atol.S | 55 + mdk-stage1/dietlibc/i386/atoll.S | 64 + mdk-stage1/dietlibc/i386/bind.S | 4 + mdk-stage1/dietlibc/i386/cbrt.S | 46 + mdk-stage1/dietlibc/i386/ceil.S | 44 + mdk-stage1/dietlibc/i386/connect.S | 4 + mdk-stage1/dietlibc/i386/copysign.S | 18 + mdk-stage1/dietlibc/i386/cos.S | 35 + mdk-stage1/dietlibc/i386/cosh.S | 29 + mdk-stage1/dietlibc/i386/dyn_syscalls.S | 282 +++++ mdk-stage1/dietlibc/i386/exp.S | 35 + mdk-stage1/dietlibc/i386/exp10.S | 27 + mdk-stage1/dietlibc/i386/exp2.S | 18 + mdk-stage1/dietlibc/i386/expm1.S | 23 + mdk-stage1/dietlibc/i386/fabs.S | 11 + mdk-stage1/dietlibc/i386/floor.S | 26 + mdk-stage1/dietlibc/i386/fmod.S | 37 + mdk-stage1/dietlibc/i386/getenv.S | 48 + mdk-stage1/dietlibc/i386/getpeername.S | 4 + mdk-stage1/dietlibc/i386/getsockname.S | 4 + mdk-stage1/dietlibc/i386/getsockopt.S | 4 + mdk-stage1/dietlibc/i386/htonl.S | 13 + mdk-stage1/dietlibc/i386/htons.S | 11 + mdk-stage1/dietlibc/i386/hypot.S | 15 + mdk-stage1/dietlibc/i386/ilogb.S | 23 + mdk-stage1/dietlibc/i386/ipow.S | 27 + mdk-stage1/dietlibc/i386/isleap.S | 28 + mdk-stage1/dietlibc/i386/ldexp.S | 28 + mdk-stage1/dietlibc/i386/libm2.S | 643 ++++++++++ mdk-stage1/dietlibc/i386/listen.S | 4 + mdk-stage1/dietlibc/i386/log.S | 26 + mdk-stage1/dietlibc/i386/log10.S | 11 + mdk-stage1/dietlibc/i386/log1p.S | 12 + mdk-stage1/dietlibc/i386/log2.S | 11 + mdk-stage1/dietlibc/i386/ltostr.S | 62 + mdk-stage1/dietlibc/i386/mcount.S | 44 + mdk-stage1/dietlibc/i386/md5asm.S | 300 +++++ mdk-stage1/dietlibc/i386/memccpy.S | 39 + mdk-stage1/dietlibc/i386/memchr.S | 24 + mdk-stage1/dietlibc/i386/memcmp.S | 26 + mdk-stage1/dietlibc/i386/memcpy.S | 16 + mdk-stage1/dietlibc/i386/memset.S | 15 + mdk-stage1/dietlibc/i386/mmap.S | 14 + mdk-stage1/dietlibc/i386/mmap64.S | 63 + mdk-stage1/dietlibc/i386/poly.S | 24 + mdk-stage1/dietlibc/i386/pow.S | 67 + mdk-stage1/dietlibc/i386/recv.S | 4 + mdk-stage1/dietlibc/i386/recvfrom.S | 4 + mdk-stage1/dietlibc/i386/recvmsg.S | 4 + mdk-stage1/dietlibc/i386/rint.S | 23 + mdk-stage1/dietlibc/i386/send.S | 4 + mdk-stage1/dietlibc/i386/sendmsg.S | 4 + mdk-stage1/dietlibc/i386/sendto.S | 4 + mdk-stage1/dietlibc/i386/setsockopt.S | 4 + mdk-stage1/dietlibc/i386/shutdown.S | 4 + mdk-stage1/dietlibc/i386/sin.S | 34 + mdk-stage1/dietlibc/i386/sincos.S | 18 + mdk-stage1/dietlibc/i386/sinh.S | 29 + mdk-stage1/dietlibc/i386/sleep.S | 25 + mdk-stage1/dietlibc/i386/socket.S | 4 + mdk-stage1/dietlibc/i386/socketcall.S | 17 + mdk-stage1/dietlibc/i386/socketpair.S | 4 + mdk-stage1/dietlibc/i386/sqrt.S | 23 + mdk-stage1/dietlibc/i386/sqrtl.S | 11 + mdk-stage1/dietlibc/i386/stpcpy.S | 22 + mdk-stage1/dietlibc/i386/strcasecmp.S | 31 + mdk-stage1/dietlibc/i386/strcat.S | 29 + mdk-stage1/dietlibc/i386/strchr.S | 22 + mdk-stage1/dietlibc/i386/strcmp.S | 31 + mdk-stage1/dietlibc/i386/strcpy.S | 24 + mdk-stage1/dietlibc/i386/strlen.S | 18 + mdk-stage1/dietlibc/i386/strncmp.S | 28 + mdk-stage1/dietlibc/i386/strncpy.S | 42 + mdk-stage1/dietlibc/i386/strrchr.S | 19 + mdk-stage1/dietlibc/i386/syscalls.h | 303 +++++ mdk-stage1/dietlibc/i386/tan.S | 12 + mdk-stage1/dietlibc/i386/tanh.S | 32 + mdk-stage1/dietlibc/i386/usleep.S | 31 + mdk-stage1/dietlibc/i386/vfork.S | 9 + mdk-stage1/dietlibc/i386/write12.S | 37 + mdk-stage1/dietlibc/ia64/Makefile.add | 2 + mdk-stage1/dietlibc/ia64/README | 4 + mdk-stage1/dietlibc/ia64/__alarm.c | 1 + mdk-stage1/dietlibc/ia64/__longjmp.S | 1 + mdk-stage1/dietlibc/ia64/__nice.c | 6 + mdk-stage1/dietlibc/ia64/__testandset.S | 11 + mdk-stage1/dietlibc/ia64/__time.c | 14 + mdk-stage1/dietlibc/ia64/__waitpid.c | 5 + mdk-stage1/dietlibc/ia64/accept.S | 3 + mdk-stage1/dietlibc/ia64/bind.S | 3 + mdk-stage1/dietlibc/ia64/clone.S | 41 + mdk-stage1/dietlibc/ia64/connect.S | 3 + mdk-stage1/dietlibc/ia64/fork.S | 8 + mdk-stage1/dietlibc/ia64/getpeername.S | 3 + mdk-stage1/dietlibc/ia64/getsockname.S | 3 + mdk-stage1/dietlibc/ia64/getsockopt.S | 3 + mdk-stage1/dietlibc/ia64/listen.S | 3 + mdk-stage1/dietlibc/ia64/mmap.S | 3 + mdk-stage1/dietlibc/ia64/msgctl.S | 3 + mdk-stage1/dietlibc/ia64/msgget.S | 3 + mdk-stage1/dietlibc/ia64/msgrcv.S | 3 + mdk-stage1/dietlibc/ia64/msgsnd.S | 3 + mdk-stage1/dietlibc/ia64/pipe.S | 20 + mdk-stage1/dietlibc/ia64/recv.S | 3 + mdk-stage1/dietlibc/ia64/recvfrom.S | 3 + mdk-stage1/dietlibc/ia64/recvmsg.S | 3 + mdk-stage1/dietlibc/ia64/semctl.S | 3 + mdk-stage1/dietlibc/ia64/semget.S | 3 + mdk-stage1/dietlibc/ia64/semop.S | 3 + mdk-stage1/dietlibc/ia64/send.S | 3 + mdk-stage1/dietlibc/ia64/sendmsg.S | 3 + mdk-stage1/dietlibc/ia64/sendto.S | 3 + mdk-stage1/dietlibc/ia64/setjmp.S | 1 + mdk-stage1/dietlibc/ia64/setsockopt.S | 3 + mdk-stage1/dietlibc/ia64/shmat.S | 3 + mdk-stage1/dietlibc/ia64/shmctl.S | 3 + mdk-stage1/dietlibc/ia64/shmdt.S | 3 + mdk-stage1/dietlibc/ia64/shmget.S | 3 + mdk-stage1/dietlibc/ia64/shutdown.S | 3 + mdk-stage1/dietlibc/ia64/socket.S | 3 + mdk-stage1/dietlibc/ia64/socketpair.S | 3 + mdk-stage1/dietlibc/ia64/start.S | 45 + mdk-stage1/dietlibc/ia64/syscalls.h | 242 ++++ mdk-stage1/dietlibc/ia64/unified.S | 46 + mdk-stage1/dietlibc/ia64/utime.S | 3 + mdk-stage1/dietlibc/ia64/vfork.S | 8 + mdk-stage1/dietlibc/include/asm/alpha-sigcontext.h | 29 + mdk-stage1/dietlibc/include/asm/arm-sigcontext.h | 32 + mdk-stage1/dietlibc/include/asm/i386-sigcontext.h | 66 + mdk-stage1/dietlibc/include/asm/ia64-sigcontext.h | 25 + mdk-stage1/dietlibc/include/asm/mips-sigcontext.h | 23 + .../dietlibc/include/asm/parisc-sigcontext.h | 16 + mdk-stage1/dietlibc/include/asm/ppc-sigcontext.h | 76 ++ mdk-stage1/dietlibc/include/asm/sigcontext.h | 36 + mdk-stage1/dietlibc/include/asm/sparc-sigcontext.h | 50 + mdk-stage1/dietlibc/include/asm/statfs.h | 1 + mdk-stage1/dietlibc/include/asm/types.h | 32 + mdk-stage1/dietlibc/include/cpio.h | 27 + mdk-stage1/dietlibc/include/dietref.h | 22 + mdk-stage1/dietlibc/include/float.h | 96 ++ mdk-stage1/dietlibc/include/iconv.h | 25 + mdk-stage1/dietlibc/include/libgen.h | 9 + mdk-stage1/dietlibc/include/libintl.h | 23 + mdk-stage1/dietlibc/include/linux/eventpoll.h | 17 + mdk-stage1/dietlibc/include/linux/if_ether.h | 101 ++ mdk-stage1/dietlibc/include/linux/loop.h | 47 + mdk-stage1/dietlibc/include/linux/nfs.h | 88 ++ mdk-stage1/dietlibc/include/linux/posix_types.h | 115 ++ mdk-stage1/dietlibc/include/linux/types.h | 6 + mdk-stage1/dietlibc/include/md5.h | 48 + mdk-stage1/dietlibc/include/net/ethernet.h | 76 ++ mdk-stage1/dietlibc/include/net/if_ether.h | 74 ++ mdk-stage1/dietlibc/include/netinet/ip_icmp.h | 145 +++ mdk-stage1/dietlibc/include/netinet/tcp.h | 164 +++ mdk-stage1/dietlibc/include/netinet/udp.h | 16 + mdk-stage1/dietlibc/include/netpacket/packet.h | 41 + mdk-stage1/dietlibc/include/pty.h | 13 + mdk-stage1/dietlibc/include/stdarg-cruft.h | 299 +++++ mdk-stage1/dietlibc/include/stdarg.h | 24 + mdk-stage1/dietlibc/include/stddef.h | 23 + mdk-stage1/dietlibc/include/sys/alpha-ioctl.h | 168 +++ mdk-stage1/dietlibc/include/sys/arm-ioctl.h | 149 +++ mdk-stage1/dietlibc/include/sys/epoll.h | 60 + mdk-stage1/dietlibc/include/sys/fsuid.h | 12 + mdk-stage1/dietlibc/include/sys/gmon.h | 99 ++ mdk-stage1/dietlibc/include/sys/gmon_out.h | 1 + mdk-stage1/dietlibc/include/sys/hppa-ioctl.h | 133 ++ mdk-stage1/dietlibc/include/sys/i386-ioctl.h | 141 +++ mdk-stage1/dietlibc/include/sys/klog.h | 8 + mdk-stage1/dietlibc/include/sys/mips-ioctl.h | 177 +++ mdk-stage1/dietlibc/include/sys/ppc-ioctl.h | 164 +++ mdk-stage1/dietlibc/include/sys/prctl.h | 8 + mdk-stage1/dietlibc/include/sys/s390-ioctl.h | 141 +++ mdk-stage1/dietlibc/include/sys/soundcard.h | 1300 ++++++++++++++++++++ mdk-stage1/dietlibc/include/sys/sparc-ioctl.h | 172 +++ mdk-stage1/dietlibc/include/sys/sysmacros.h | 6 + mdk-stage1/dietlibc/include/sys/timeb.h | 13 + mdk-stage1/dietlibc/include/sys/timex.h | 50 + mdk-stage1/dietlibc/include/sys/ucontext.h | 110 ++ mdk-stage1/dietlibc/include/sysexits.h | 26 + mdk-stage1/dietlibc/include/tar.h | 36 + mdk-stage1/dietlibc/include/termio.h | 4 + mdk-stage1/dietlibc/include/write12.h | 4 + mdk-stage1/dietlibc/lib/__ftruncate64.c | 23 + mdk-stage1/dietlibc/lib/__isinf.c | 15 + mdk-stage1/dietlibc/lib/__ptrace.c | 27 + mdk-stage1/dietlibc/lib/__stime.c | 14 + mdk-stage1/dietlibc/lib/__truncate64.c | 23 + mdk-stage1/dietlibc/lib/__v_printf.c | 300 +++++ mdk-stage1/dietlibc/lib/__v_scanf.c | 391 ++++++ mdk-stage1/dietlibc/lib/adjtime.c | 18 + mdk-stage1/dietlibc/lib/atoll.c | 19 + mdk-stage1/dietlibc/lib/bcd.c | 185 +++ mdk-stage1/dietlibc/lib/binshstr.c | 5 + mdk-stage1/dietlibc/lib/cfgetospeed.c | 8 + mdk-stage1/dietlibc/lib/cfsetispeed.c | 22 + mdk-stage1/dietlibc/lib/cfsetospeed.c | 14 + mdk-stage1/dietlibc/lib/errlistu.c | 6 + mdk-stage1/dietlibc/lib/execle.c | 26 + mdk-stage1/dietlibc/lib/if_nameindex.c | 40 + mdk-stage1/dietlibc/lib/ipv6constants.c | 4 + mdk-stage1/dietlibc/lib/labs.c | 6 + mdk-stage1/dietlibc/lib/llabs.c | 6 + mdk-stage1/dietlibc/lib/memmem.c | 14 + mdk-stage1/dietlibc/lib/memrchr.c | 15 + mdk-stage1/dietlibc/lib/pwrite.c | 11 + mdk-stage1/dietlibc/lib/pwrite64.c | 14 + mdk-stage1/dietlibc/lib/rand48.c | 89 ++ mdk-stage1/dietlibc/lib/rand_r.c | 30 + mdk-stage1/dietlibc/lib/readdir64.c | 62 + mdk-stage1/dietlibc/lib/setlinebuf.c | 12 + mdk-stage1/dietlibc/lib/sigaction.c | 11 + mdk-stage1/dietlibc/lib/siginterrupt.c | 17 + mdk-stage1/dietlibc/lib/signal.c | 12 + mdk-stage1/dietlibc/lib/sigpending.c | 7 + mdk-stage1/dietlibc/lib/sigprocmask.c | 7 + mdk-stage1/dietlibc/lib/sigqueueinfo.c | 7 + mdk-stage1/dietlibc/lib/sigsuspend.c | 10 + mdk-stage1/dietlibc/lib/sigtimedwait.c | 7 + mdk-stage1/dietlibc/lib/socketpair.c | 12 + mdk-stage1/dietlibc/lib/strtof.c | 66 + mdk-stage1/dietlibc/lib/strtold.c | 66 + mdk-stage1/dietlibc/lib/strxfrm.c | 12 + mdk-stage1/dietlibc/lib/tcflow.c | 35 + mdk-stage1/dietlibc/lib/tcsendbreak.c | 11 + mdk-stage1/dietlibc/lib/write12.c | 11 + mdk-stage1/dietlibc/libcompat/daemon.c | 29 + mdk-stage1/dietlibc/libcompat/getdelim.c | 32 + mdk-stage1/dietlibc/libcompat/getline.c | 9 + mdk-stage1/dietlibc/libcompat/re_bsd.c | 34 + mdk-stage1/dietlibc/libcompat/stpcpy.c | 6 + mdk-stage1/dietlibc/libcompat/syscall.S | 70 ++ mdk-stage1/dietlibc/libcruft/__end_parse.c | 10 + mdk-stage1/dietlibc/libcruft/__parse.c | 10 + mdk-stage1/dietlibc/libcruft/__parse_1.c | 9 + mdk-stage1/dietlibc/libcruft/__parse_nws.c | 10 + mdk-stage1/dietlibc/libcruft/__parse_ws.c | 11 + mdk-stage1/dietlibc/libcruft/__prepare_parse.c | 19 + mdk-stage1/dietlibc/libcruft/alphasort.c | 6 + mdk-stage1/dietlibc/libcruft/alphasort64.c | 6 + mdk-stage1/dietlibc/libcruft/bcopy.c | 11 + mdk-stage1/dietlibc/libcruft/bzero.c | 10 + mdk-stage1/dietlibc/libcruft/clock.c | 21 + mdk-stage1/dietlibc/libcruft/dn_expand.c | 11 + mdk-stage1/dietlibc/libcruft/dnscruft3.c | 3 + mdk-stage1/dietlibc/libcruft/dnscruft4.c | 11 + mdk-stage1/dietlibc/libcruft/getgrent.c | 10 + mdk-stage1/dietlibc/libcruft/getgrent_r.c | 78 ++ mdk-stage1/dietlibc/libcruft/getgrgid_r.c | 14 + mdk-stage1/dietlibc/libcruft/getgrnam_r.c | 14 + mdk-stage1/dietlibc/libcruft/gethostbyaddr2_r.c | 2 + mdk-stage1/dietlibc/libcruft/getopt_data.c | 10 + mdk-stage1/dietlibc/libcruft/getopt_long.c | 103 ++ mdk-stage1/dietlibc/libcruft/getopt_long_only.c | 108 ++ mdk-stage1/dietlibc/libcruft/getpwent.c | 10 + mdk-stage1/dietlibc/libcruft/getpwent_r.c | 65 + mdk-stage1/dietlibc/libcruft/getpwnam_r.c | 14 + mdk-stage1/dietlibc/libcruft/getpwuid_r.c | 13 + mdk-stage1/dietlibc/libcruft/getspent.c | 10 + mdk-stage1/dietlibc/libcruft/getspent_r.c | 68 + mdk-stage1/dietlibc/libcruft/getspnam_r.c | 14 + mdk-stage1/dietlibc/libcruft/getusershell.c | 33 + mdk-stage1/dietlibc/libcruft/grbuf.c | 5 + mdk-stage1/dietlibc/libcruft/herror.c | 8 + mdk-stage1/dietlibc/libcruft/hstrerror.c | 11 + mdk-stage1/dietlibc/libcruft/killpg.c | 5 + mdk-stage1/dietlibc/libcruft/localeconv.c | 15 + mdk-stage1/dietlibc/libcruft/mkdtemp.c | 28 + mdk-stage1/dietlibc/libcruft/mktemp.c | 17 + mdk-stage1/dietlibc/libcruft/pwbuf.c | 5 + mdk-stage1/dietlibc/libcruft/res_mkquery.c | 75 ++ mdk-stage1/dietlibc/libcruft/res_query.c | 95 ++ mdk-stage1/dietlibc/libcruft/res_search.c | 35 + mdk-stage1/dietlibc/libcruft/scan_ulong.c | 13 + mdk-stage1/dietlibc/libcruft/scandir.c | 47 + mdk-stage1/dietlibc/libcruft/scandir64.c | 47 + mdk-stage1/dietlibc/libcruft/setegid.c | 11 + mdk-stage1/dietlibc/libcruft/seteuid.c | 11 + mdk-stage1/dietlibc/libcruft/setlocale.c | 7 + mdk-stage1/dietlibc/libcruft/spbuf.c | 5 + mdk-stage1/dietlibc/libcruft/sysconf.c | 43 + mdk-stage1/dietlibc/libcruft/sysconf_cpus.c | 64 + mdk-stage1/dietlibc/libcruft/tempnam.c | 32 + mdk-stage1/dietlibc/libcruft/tmpnam.c | 31 + mdk-stage1/dietlibc/libcrypt/md5.c | 243 ++++ mdk-stage1/dietlibc/libcrypt/md5crypt.c | 157 +++ mdk-stage1/dietlibc/libdl/_dl_alloc.c | 81 ++ mdk-stage1/dietlibc/libdl/_dl_load.c | 401 ++++++ mdk-stage1/dietlibc/libdl/_dl_main.c | 1059 ++++++++++++++++ mdk-stage1/dietlibc/libdl/_dl_queue.c | 39 + mdk-stage1/dietlibc/libdl/_dl_rel.c | 42 + mdk-stage1/dietlibc/libdl/_dl_rel.h | 25 + mdk-stage1/dietlibc/libdl/_dl_relocate.c | 96 ++ mdk-stage1/dietlibc/libdl/elf_hash.h | 10 + mdk-stage1/dietlibc/libdl/test/test.c | 20 + mdk-stage1/dietlibc/libdl/test/test_so.c | 11 + mdk-stage1/dietlibc/libm/acosh.c | 6 + mdk-stage1/dietlibc/libm/asinh.c | 6 + mdk-stage1/dietlibc/libm/atanh.c | 8 + mdk-stage1/dietlibc/libm/bessel.c | 171 +++ mdk-stage1/dietlibc/libm/cosh.c | 9 + mdk-stage1/dietlibc/libm/erf.c | 95 ++ mdk-stage1/dietlibc/libm/gamma.c | 98 ++ mdk-stage1/dietlibc/libm/ipow.c | 29 + mdk-stage1/dietlibc/libm/poly.c | 41 + mdk-stage1/dietlibc/libm/pow.c | 42 + mdk-stage1/dietlibc/libm/rint.c | 5 + mdk-stage1/dietlibc/libm/sinh.c | 9 + mdk-stage1/dietlibc/libm/tanh.c | 7 + mdk-stage1/dietlibc/libpthread/pthread_equal.c | 3 + mdk-stage1/dietlibc/libpthread/pthread_errno.c | 5 + mdk-stage1/dietlibc/libpthread/pthread_fdglue2.c | 16 + mdk-stage1/dietlibc/libpthread/pthread_fgetc.c | 10 + mdk-stage1/dietlibc/libpthread/pthread_flockfile.c | 5 + mdk-stage1/dietlibc/libpthread/pthread_fputc.c | 9 + .../dietlibc/libpthread/pthread_funlockfile.c | 5 + .../dietlibc/libpthread/pthread_getschedparam.c | 22 + mdk-stage1/dietlibc/libpthread/pthread_internal.c | 359 ++++++ mdk-stage1/dietlibc/libpthread/pthread_key.c | 48 + .../dietlibc/libpthread/pthread_setschedparam.c | 21 + mdk-stage1/dietlibc/libpthread/pthread_sigmask.c | 8 + .../dietlibc/libpthread/pthread_sys_fdatasync.c | 10 + mdk-stage1/dietlibc/libshell/basename.c | 27 + mdk-stage1/dietlibc/libshell/dirname.c | 25 + mdk-stage1/dietlibc/libstdio/fdglue2.c | 43 + mdk-stage1/dietlibc/libstdio/fdprintf.c | 13 + mdk-stage1/dietlibc/libstdio/fgetc_unlocked.c | 30 + mdk-stage1/dietlibc/libstdio/fgetpos.c | 8 + mdk-stage1/dietlibc/libstdio/fputc_unlocked.c | 20 + mdk-stage1/dietlibc/libstdio/fscanf.c | 14 + mdk-stage1/dietlibc/libstdio/fseeko.c | 10 + mdk-stage1/dietlibc/libstdio/fseeko64.c | 12 + mdk-stage1/dietlibc/libstdio/fsetpos.c | 7 + mdk-stage1/dietlibc/libstdio/ftello.c | 7 + mdk-stage1/dietlibc/libstdio/ftello64.c | 9 + mdk-stage1/dietlibc/libstdio/puts.c | 16 + mdk-stage1/dietlibc/libstdio/scanf.c | 14 + mdk-stage1/dietlibc/libstdio/tmpfile.c | 12 + mdk-stage1/dietlibc/libstdio/vfdprintf.c | 15 + mdk-stage1/dietlibc/libstdio/vfprintf.c | 15 + mdk-stage1/dietlibc/libstdio/vfscanf.c | 11 + mdk-stage1/dietlibc/libstdio/vprintf.c | 15 + mdk-stage1/dietlibc/libstdio/vscanf.c | 10 + mdk-stage1/dietlibc/libugly/difftime.c | 8 + mdk-stage1/dietlibc/libugly/dirfd.c | 8 + mdk-stage1/dietlibc/libugly/freeaddrinfo.c | 11 + mdk-stage1/dietlibc/libugly/ftime.c | 15 + mdk-stage1/dietlibc/libugly/gai_strerror.c | 13 + mdk-stage1/dietlibc/libugly/getaddrinfo.c | 140 +++ mdk-stage1/dietlibc/libugly/gethostent.c | 116 ++ mdk-stage1/dietlibc/libugly/getnameinfo.c | 46 + mdk-stage1/dietlibc/libugly/getprotobyname.c | 12 + mdk-stage1/dietlibc/libugly/getprotobyname_r.c | 17 + mdk-stage1/dietlibc/libugly/getprotobynumber.c | 12 + mdk-stage1/dietlibc/libugly/getprotobynumber_r.c | 13 + mdk-stage1/dietlibc/libugly/getprotoent_r.c | 78 ++ mdk-stage1/dietlibc/libugly/getservbyname.c | 12 + mdk-stage1/dietlibc/libugly/getservbyname_r.c | 18 + mdk-stage1/dietlibc/libugly/getservbyport.c | 12 + mdk-stage1/dietlibc/libugly/getservbyport_r.c | 13 + mdk-stage1/dietlibc/libugly/getservent.c | 10 + mdk-stage1/dietlibc/libugly/getservent_r.c | 91 ++ mdk-stage1/dietlibc/libugly/grantpt.c | 13 + mdk-stage1/dietlibc/libugly/hasmntopt.c | 18 + mdk-stage1/dietlibc/libugly/iconv.c | 71 ++ mdk-stage1/dietlibc/libugly/iconv_close.c | 7 + mdk-stage1/dietlibc/libugly/iconv_open.c | 28 + mdk-stage1/dietlibc/libugly/netent.c | 130 ++ mdk-stage1/dietlibc/libugly/openpty.c | 54 + mdk-stage1/dietlibc/libugly/protoent_buf.c | 5 + mdk-stage1/dietlibc/libugly/ptsname.c | 17 + mdk-stage1/dietlibc/libugly/putpwent.c | 19 + mdk-stage1/dietlibc/libugly/servent_buf.c | 5 + mdk-stage1/dietlibc/libugly/strndup.c | 10 + mdk-stage1/dietlibc/libugly/timezone.c | 3 + mdk-stage1/dietlibc/libugly/unlockpt.c | 10 + mdk-stage1/dietlibc/libugly/utent.c | 103 ++ mdk-stage1/dietlibc/libugly/wtent.c | 30 + mdk-stage1/dietlibc/ppc/clone.S | 48 + mdk-stage1/dietlibc/ppc/syscalls.h | 259 ++++ mdk-stage1/dietlibc/profiling/PORTING | 25 + mdk-stage1/dietlibc/profiling/README | 37 + mdk-stage1/dietlibc/profiling/__mcount.c | 24 + mdk-stage1/dietlibc/profiling/monitor.c | 93 ++ mdk-stage1/dietlibc/profiling/profil.c | 75 ++ mdk-stage1/dietlibc/sparc/errlist.S | 280 +++++ mdk-stage1/dietlibc/sparc/sigaction.c | 7 + mdk-stage1/dietlibc/sparc/strlen.S | 11 + mdk-stage1/dietlibc/sparc/syscalls.h | 276 +++++ mdk-stage1/dietlibc/syscalls.s/__pwrite.S | 3 + mdk-stage1/dietlibc/syscalls.s/adjtimex.S | 3 + mdk-stage1/dietlibc/syscalls.s/alarm.S | 4 + mdk-stage1/dietlibc/syscalls.s/bdflush.S | 5 + mdk-stage1/dietlibc/syscalls.s/chown32.S | 5 + mdk-stage1/dietlibc/syscalls.s/create_module.S | 5 + mdk-stage1/dietlibc/syscalls.s/delete_module.S | 5 + mdk-stage1/dietlibc/syscalls.s/environ.S | 16 + mdk-stage1/dietlibc/syscalls.s/epoll_create.S | 5 + mdk-stage1/dietlibc/syscalls.s/epoll_ctl.S | 5 + mdk-stage1/dietlibc/syscalls.s/epoll_wait.S | 5 + mdk-stage1/dietlibc/syscalls.s/errlist.S | 293 +++++ mdk-stage1/dietlibc/syscalls.s/errno.S | 8 + mdk-stage1/dietlibc/syscalls.s/fchown32.S | 5 + mdk-stage1/dietlibc/syscalls.s/fdatasync.S | 6 + mdk-stage1/dietlibc/syscalls.s/ftruncate64.S | 10 + mdk-stage1/dietlibc/syscalls.s/getegid32.S | 5 + mdk-stage1/dietlibc/syscalls.s/geteuid32.S | 5 + mdk-stage1/dietlibc/syscalls.s/getgid32.S | 5 + mdk-stage1/dietlibc/syscalls.s/getgroups32.S | 5 + mdk-stage1/dietlibc/syscalls.s/getresgid32.S | 5 + mdk-stage1/dietlibc/syscalls.s/getuid32.S | 5 + mdk-stage1/dietlibc/syscalls.s/init_module.S | 5 + mdk-stage1/dietlibc/syscalls.s/lchown32.S | 5 + mdk-stage1/dietlibc/syscalls.s/madvise.S | 3 + mdk-stage1/dietlibc/syscalls.s/mlock.S | 3 + mdk-stage1/dietlibc/syscalls.s/mmap2.S | 5 + mdk-stage1/dietlibc/syscalls.s/msync.S | 3 + mdk-stage1/dietlibc/syscalls.s/munlock.S | 3 + mdk-stage1/dietlibc/syscalls.s/n_sigaction.S | 5 + mdk-stage1/dietlibc/syscalls.s/n_sigpending.S | 5 + mdk-stage1/dietlibc/syscalls.s/n_sigprocmask.S | 5 + mdk-stage1/dietlibc/syscalls.s/n_sigsuspend.S | 5 + mdk-stage1/dietlibc/syscalls.s/pivot_root.S | 3 + mdk-stage1/dietlibc/syscalls.s/prctl.S | 5 + mdk-stage1/dietlibc/syscalls.s/ptrace.S | 3 + mdk-stage1/dietlibc/syscalls.s/rt_sigaction.S | 3 + mdk-stage1/dietlibc/syscalls.s/rt_sigpending.S | 3 + mdk-stage1/dietlibc/syscalls.s/rt_sigprocmask.S | 3 + mdk-stage1/dietlibc/syscalls.s/rt_sigqueueinfo.S | 3 + mdk-stage1/dietlibc/syscalls.s/rt_sigsuspend.S | 3 + mdk-stage1/dietlibc/syscalls.s/rt_sigtimedwait.S | 3 + mdk-stage1/dietlibc/syscalls.s/sendfile64.S | 8 + mdk-stage1/dietlibc/syscalls.s/setfsgid.S | 3 + mdk-stage1/dietlibc/syscalls.s/setfsgid32.S | 5 + mdk-stage1/dietlibc/syscalls.s/setfsuid.S | 3 + mdk-stage1/dietlibc/syscalls.s/setfsuid32.S | 5 + mdk-stage1/dietlibc/syscalls.s/setgid32.S | 5 + mdk-stage1/dietlibc/syscalls.s/setregid32.S | 5 + mdk-stage1/dietlibc/syscalls.s/setresgid32.S | 5 + mdk-stage1/dietlibc/syscalls.s/setreuid32.S | 5 + mdk-stage1/dietlibc/syscalls.s/settimeofday.S | 3 + mdk-stage1/dietlibc/syscalls.s/setuid32.S | 5 + mdk-stage1/dietlibc/syscalls.s/truncate64.S | 10 + mdk-stage1/dietlibc/x86_64/Makefile.add | 2 + mdk-stage1/dietlibc/x86_64/__longjmp.S | 26 + mdk-stage1/dietlibc/x86_64/__testandset.S | 12 + mdk-stage1/dietlibc/x86_64/accept.S | 3 + mdk-stage1/dietlibc/x86_64/bind.S | 3 + mdk-stage1/dietlibc/x86_64/clone.S | 64 + mdk-stage1/dietlibc/x86_64/connect.S | 3 + mdk-stage1/dietlibc/x86_64/getpeername.S | 3 + mdk-stage1/dietlibc/x86_64/getsockname.S | 3 + mdk-stage1/dietlibc/x86_64/getsockopt.S | 3 + mdk-stage1/dietlibc/x86_64/listen.S | 3 + mdk-stage1/dietlibc/x86_64/mmap.S | 8 + mdk-stage1/dietlibc/x86_64/msgctl.S | 3 + mdk-stage1/dietlibc/x86_64/msgget.S | 3 + mdk-stage1/dietlibc/x86_64/msgrcv.S | 3 + mdk-stage1/dietlibc/x86_64/msgsnd.S | 3 + mdk-stage1/dietlibc/x86_64/recv.c | 13 + mdk-stage1/dietlibc/x86_64/recvfrom.S | 3 + mdk-stage1/dietlibc/x86_64/recvmsg.S | 3 + mdk-stage1/dietlibc/x86_64/semctl.S | 3 + mdk-stage1/dietlibc/x86_64/semget.S | 3 + mdk-stage1/dietlibc/x86_64/semop.S | 3 + mdk-stage1/dietlibc/x86_64/send.c | 13 + mdk-stage1/dietlibc/x86_64/sendmsg.S | 3 + mdk-stage1/dietlibc/x86_64/sendto.S | 3 + mdk-stage1/dietlibc/x86_64/setjmp.S | 37 + mdk-stage1/dietlibc/x86_64/setsockopt.S | 3 + mdk-stage1/dietlibc/x86_64/shmat.S | 3 + mdk-stage1/dietlibc/x86_64/shmctl.S | 3 + mdk-stage1/dietlibc/x86_64/shmdt.S | 3 + mdk-stage1/dietlibc/x86_64/shmget.S | 3 + mdk-stage1/dietlibc/x86_64/shutdown.S | 3 + mdk-stage1/dietlibc/x86_64/sigaction.c | 26 + mdk-stage1/dietlibc/x86_64/socket.S | 3 + mdk-stage1/dietlibc/x86_64/socketpair.S | 3 + mdk-stage1/dietlibc/x86_64/start.S | 55 + mdk-stage1/dietlibc/x86_64/syscalls.h | 282 +++++ mdk-stage1/dietlibc/x86_64/umount.S | 9 + mdk-stage1/dietlibc/x86_64/unified.S | 32 + mdk-stage1/dietlibc/x86_64/waitpid.S | 12 + 502 files changed, 19926 insertions(+) create mode 100644 mdk-stage1/dietlibc/alpha/__alarm.c create mode 100644 mdk-stage1/dietlibc/alpha/__testandset.S create mode 100644 mdk-stage1/dietlibc/alpha/errlist.S create mode 100644 mdk-stage1/dietlibc/alpha/lseek64.S create mode 100644 mdk-stage1/dietlibc/alpha/n_sigprocmask.S create mode 100644 mdk-stage1/dietlibc/alpha/sigaction.c create mode 100644 mdk-stage1/dietlibc/alpha/socketpair.S create mode 100644 mdk-stage1/dietlibc/alpha/syscalls.h create mode 100644 mdk-stage1/dietlibc/i386/PIC.h create mode 100644 mdk-stage1/dietlibc/i386/__half.S create mode 100644 mdk-stage1/dietlibc/i386/__ten.S create mode 100644 mdk-stage1/dietlibc/i386/accept.S create mode 100644 mdk-stage1/dietlibc/i386/acos.S create mode 100644 mdk-stage1/dietlibc/i386/acosh.S create mode 100644 mdk-stage1/dietlibc/i386/asin.S create mode 100644 mdk-stage1/dietlibc/i386/asinh.S create mode 100644 mdk-stage1/dietlibc/i386/atan.S create mode 100644 mdk-stage1/dietlibc/i386/atan2.S create mode 100644 mdk-stage1/dietlibc/i386/atanh.S create mode 100644 mdk-stage1/dietlibc/i386/atol.S create mode 100644 mdk-stage1/dietlibc/i386/atoll.S create mode 100644 mdk-stage1/dietlibc/i386/bind.S create mode 100644 mdk-stage1/dietlibc/i386/cbrt.S create mode 100644 mdk-stage1/dietlibc/i386/ceil.S create mode 100644 mdk-stage1/dietlibc/i386/connect.S create mode 100644 mdk-stage1/dietlibc/i386/copysign.S create mode 100644 mdk-stage1/dietlibc/i386/cos.S create mode 100644 mdk-stage1/dietlibc/i386/cosh.S create mode 100644 mdk-stage1/dietlibc/i386/dyn_syscalls.S create mode 100644 mdk-stage1/dietlibc/i386/exp.S create mode 100644 mdk-stage1/dietlibc/i386/exp10.S create mode 100644 mdk-stage1/dietlibc/i386/exp2.S create mode 100644 mdk-stage1/dietlibc/i386/expm1.S create mode 100644 mdk-stage1/dietlibc/i386/fabs.S create mode 100644 mdk-stage1/dietlibc/i386/floor.S create mode 100644 mdk-stage1/dietlibc/i386/fmod.S create mode 100644 mdk-stage1/dietlibc/i386/getenv.S create mode 100644 mdk-stage1/dietlibc/i386/getpeername.S create mode 100644 mdk-stage1/dietlibc/i386/getsockname.S create mode 100644 mdk-stage1/dietlibc/i386/getsockopt.S create mode 100644 mdk-stage1/dietlibc/i386/htonl.S create mode 100644 mdk-stage1/dietlibc/i386/htons.S create mode 100644 mdk-stage1/dietlibc/i386/hypot.S create mode 100644 mdk-stage1/dietlibc/i386/ilogb.S create mode 100644 mdk-stage1/dietlibc/i386/ipow.S create mode 100644 mdk-stage1/dietlibc/i386/isleap.S create mode 100644 mdk-stage1/dietlibc/i386/ldexp.S create mode 100644 mdk-stage1/dietlibc/i386/libm2.S create mode 100644 mdk-stage1/dietlibc/i386/listen.S create mode 100644 mdk-stage1/dietlibc/i386/log.S create mode 100644 mdk-stage1/dietlibc/i386/log10.S create mode 100644 mdk-stage1/dietlibc/i386/log1p.S create mode 100644 mdk-stage1/dietlibc/i386/log2.S create mode 100644 mdk-stage1/dietlibc/i386/ltostr.S create mode 100644 mdk-stage1/dietlibc/i386/mcount.S create mode 100644 mdk-stage1/dietlibc/i386/md5asm.S create mode 100644 mdk-stage1/dietlibc/i386/memccpy.S create mode 100644 mdk-stage1/dietlibc/i386/memchr.S create mode 100644 mdk-stage1/dietlibc/i386/memcmp.S create mode 100644 mdk-stage1/dietlibc/i386/memcpy.S create mode 100644 mdk-stage1/dietlibc/i386/memset.S create mode 100644 mdk-stage1/dietlibc/i386/mmap.S create mode 100644 mdk-stage1/dietlibc/i386/mmap64.S create mode 100644 mdk-stage1/dietlibc/i386/poly.S create mode 100644 mdk-stage1/dietlibc/i386/pow.S create mode 100644 mdk-stage1/dietlibc/i386/recv.S create mode 100644 mdk-stage1/dietlibc/i386/recvfrom.S create mode 100644 mdk-stage1/dietlibc/i386/recvmsg.S create mode 100644 mdk-stage1/dietlibc/i386/rint.S create mode 100644 mdk-stage1/dietlibc/i386/send.S create mode 100644 mdk-stage1/dietlibc/i386/sendmsg.S create mode 100644 mdk-stage1/dietlibc/i386/sendto.S create mode 100644 mdk-stage1/dietlibc/i386/setsockopt.S create mode 100644 mdk-stage1/dietlibc/i386/shutdown.S create mode 100644 mdk-stage1/dietlibc/i386/sin.S create mode 100644 mdk-stage1/dietlibc/i386/sincos.S create mode 100644 mdk-stage1/dietlibc/i386/sinh.S create mode 100644 mdk-stage1/dietlibc/i386/sleep.S create mode 100644 mdk-stage1/dietlibc/i386/socket.S create mode 100644 mdk-stage1/dietlibc/i386/socketcall.S create mode 100644 mdk-stage1/dietlibc/i386/socketpair.S create mode 100644 mdk-stage1/dietlibc/i386/sqrt.S create mode 100644 mdk-stage1/dietlibc/i386/sqrtl.S create mode 100644 mdk-stage1/dietlibc/i386/stpcpy.S create mode 100644 mdk-stage1/dietlibc/i386/strcasecmp.S create mode 100644 mdk-stage1/dietlibc/i386/strcat.S create mode 100644 mdk-stage1/dietlibc/i386/strchr.S create mode 100644 mdk-stage1/dietlibc/i386/strcmp.S create mode 100644 mdk-stage1/dietlibc/i386/strcpy.S create mode 100644 mdk-stage1/dietlibc/i386/strlen.S create mode 100644 mdk-stage1/dietlibc/i386/strncmp.S create mode 100644 mdk-stage1/dietlibc/i386/strncpy.S create mode 100644 mdk-stage1/dietlibc/i386/strrchr.S create mode 100644 mdk-stage1/dietlibc/i386/syscalls.h create mode 100644 mdk-stage1/dietlibc/i386/tan.S create mode 100644 mdk-stage1/dietlibc/i386/tanh.S create mode 100644 mdk-stage1/dietlibc/i386/usleep.S create mode 100644 mdk-stage1/dietlibc/i386/vfork.S create mode 100644 mdk-stage1/dietlibc/i386/write12.S create mode 100644 mdk-stage1/dietlibc/ia64/Makefile.add create mode 100644 mdk-stage1/dietlibc/ia64/README create mode 100644 mdk-stage1/dietlibc/ia64/__alarm.c create mode 100644 mdk-stage1/dietlibc/ia64/__longjmp.S create mode 100644 mdk-stage1/dietlibc/ia64/__nice.c create mode 100644 mdk-stage1/dietlibc/ia64/__testandset.S create mode 100644 mdk-stage1/dietlibc/ia64/__time.c create mode 100644 mdk-stage1/dietlibc/ia64/__waitpid.c create mode 100644 mdk-stage1/dietlibc/ia64/accept.S create mode 100644 mdk-stage1/dietlibc/ia64/bind.S create mode 100644 mdk-stage1/dietlibc/ia64/clone.S create mode 100644 mdk-stage1/dietlibc/ia64/connect.S create mode 100644 mdk-stage1/dietlibc/ia64/fork.S create mode 100644 mdk-stage1/dietlibc/ia64/getpeername.S create mode 100644 mdk-stage1/dietlibc/ia64/getsockname.S create mode 100644 mdk-stage1/dietlibc/ia64/getsockopt.S create mode 100644 mdk-stage1/dietlibc/ia64/listen.S create mode 100644 mdk-stage1/dietlibc/ia64/mmap.S create mode 100644 mdk-stage1/dietlibc/ia64/msgctl.S create mode 100644 mdk-stage1/dietlibc/ia64/msgget.S create mode 100644 mdk-stage1/dietlibc/ia64/msgrcv.S create mode 100644 mdk-stage1/dietlibc/ia64/msgsnd.S create mode 100644 mdk-stage1/dietlibc/ia64/pipe.S create mode 100644 mdk-stage1/dietlibc/ia64/recv.S create mode 100644 mdk-stage1/dietlibc/ia64/recvfrom.S create mode 100644 mdk-stage1/dietlibc/ia64/recvmsg.S create mode 100644 mdk-stage1/dietlibc/ia64/semctl.S create mode 100644 mdk-stage1/dietlibc/ia64/semget.S create mode 100644 mdk-stage1/dietlibc/ia64/semop.S create mode 100644 mdk-stage1/dietlibc/ia64/send.S create mode 100644 mdk-stage1/dietlibc/ia64/sendmsg.S create mode 100644 mdk-stage1/dietlibc/ia64/sendto.S create mode 100644 mdk-stage1/dietlibc/ia64/setjmp.S create mode 100644 mdk-stage1/dietlibc/ia64/setsockopt.S create mode 100644 mdk-stage1/dietlibc/ia64/shmat.S create mode 100644 mdk-stage1/dietlibc/ia64/shmctl.S create mode 100644 mdk-stage1/dietlibc/ia64/shmdt.S create mode 100644 mdk-stage1/dietlibc/ia64/shmget.S create mode 100644 mdk-stage1/dietlibc/ia64/shutdown.S create mode 100644 mdk-stage1/dietlibc/ia64/socket.S create mode 100644 mdk-stage1/dietlibc/ia64/socketpair.S create mode 100644 mdk-stage1/dietlibc/ia64/start.S create mode 100644 mdk-stage1/dietlibc/ia64/syscalls.h create mode 100644 mdk-stage1/dietlibc/ia64/unified.S create mode 100644 mdk-stage1/dietlibc/ia64/utime.S create mode 100644 mdk-stage1/dietlibc/ia64/vfork.S create mode 100644 mdk-stage1/dietlibc/include/asm/alpha-sigcontext.h create mode 100644 mdk-stage1/dietlibc/include/asm/arm-sigcontext.h create mode 100644 mdk-stage1/dietlibc/include/asm/i386-sigcontext.h create mode 100644 mdk-stage1/dietlibc/include/asm/ia64-sigcontext.h create mode 100644 mdk-stage1/dietlibc/include/asm/mips-sigcontext.h create mode 100644 mdk-stage1/dietlibc/include/asm/parisc-sigcontext.h create mode 100644 mdk-stage1/dietlibc/include/asm/ppc-sigcontext.h create mode 100644 mdk-stage1/dietlibc/include/asm/sigcontext.h create mode 100644 mdk-stage1/dietlibc/include/asm/sparc-sigcontext.h create mode 100644 mdk-stage1/dietlibc/include/asm/statfs.h create mode 100644 mdk-stage1/dietlibc/include/asm/types.h create mode 100644 mdk-stage1/dietlibc/include/cpio.h create mode 100644 mdk-stage1/dietlibc/include/dietref.h create mode 100644 mdk-stage1/dietlibc/include/float.h create mode 100644 mdk-stage1/dietlibc/include/iconv.h create mode 100644 mdk-stage1/dietlibc/include/libgen.h create mode 100644 mdk-stage1/dietlibc/include/libintl.h create mode 100644 mdk-stage1/dietlibc/include/linux/eventpoll.h create mode 100644 mdk-stage1/dietlibc/include/linux/if_ether.h create mode 100644 mdk-stage1/dietlibc/include/linux/loop.h create mode 100644 mdk-stage1/dietlibc/include/linux/nfs.h create mode 100644 mdk-stage1/dietlibc/include/linux/posix_types.h create mode 100644 mdk-stage1/dietlibc/include/linux/types.h create mode 100644 mdk-stage1/dietlibc/include/md5.h create mode 100644 mdk-stage1/dietlibc/include/net/ethernet.h create mode 100644 mdk-stage1/dietlibc/include/net/if_ether.h create mode 100644 mdk-stage1/dietlibc/include/netinet/ip_icmp.h create mode 100644 mdk-stage1/dietlibc/include/netinet/tcp.h create mode 100644 mdk-stage1/dietlibc/include/netinet/udp.h create mode 100644 mdk-stage1/dietlibc/include/netpacket/packet.h create mode 100644 mdk-stage1/dietlibc/include/pty.h create mode 100644 mdk-stage1/dietlibc/include/stdarg-cruft.h create mode 100644 mdk-stage1/dietlibc/include/stdarg.h create mode 100644 mdk-stage1/dietlibc/include/stddef.h create mode 100644 mdk-stage1/dietlibc/include/sys/alpha-ioctl.h create mode 100644 mdk-stage1/dietlibc/include/sys/arm-ioctl.h create mode 100644 mdk-stage1/dietlibc/include/sys/epoll.h create mode 100644 mdk-stage1/dietlibc/include/sys/fsuid.h create mode 100644 mdk-stage1/dietlibc/include/sys/gmon.h create mode 100644 mdk-stage1/dietlibc/include/sys/gmon_out.h create mode 100644 mdk-stage1/dietlibc/include/sys/hppa-ioctl.h create mode 100644 mdk-stage1/dietlibc/include/sys/i386-ioctl.h create mode 100644 mdk-stage1/dietlibc/include/sys/klog.h create mode 100644 mdk-stage1/dietlibc/include/sys/mips-ioctl.h create mode 100644 mdk-stage1/dietlibc/include/sys/ppc-ioctl.h create mode 100644 mdk-stage1/dietlibc/include/sys/prctl.h create mode 100644 mdk-stage1/dietlibc/include/sys/s390-ioctl.h create mode 100644 mdk-stage1/dietlibc/include/sys/soundcard.h create mode 100644 mdk-stage1/dietlibc/include/sys/sparc-ioctl.h create mode 100644 mdk-stage1/dietlibc/include/sys/sysmacros.h create mode 100644 mdk-stage1/dietlibc/include/sys/timeb.h create mode 100644 mdk-stage1/dietlibc/include/sys/timex.h create mode 100644 mdk-stage1/dietlibc/include/sys/ucontext.h create mode 100644 mdk-stage1/dietlibc/include/sysexits.h create mode 100644 mdk-stage1/dietlibc/include/tar.h create mode 100644 mdk-stage1/dietlibc/include/termio.h create mode 100644 mdk-stage1/dietlibc/include/write12.h create mode 100644 mdk-stage1/dietlibc/lib/__ftruncate64.c create mode 100644 mdk-stage1/dietlibc/lib/__isinf.c create mode 100644 mdk-stage1/dietlibc/lib/__ptrace.c create mode 100644 mdk-stage1/dietlibc/lib/__stime.c create mode 100644 mdk-stage1/dietlibc/lib/__truncate64.c create mode 100644 mdk-stage1/dietlibc/lib/__v_printf.c create mode 100644 mdk-stage1/dietlibc/lib/__v_scanf.c create mode 100644 mdk-stage1/dietlibc/lib/adjtime.c create mode 100644 mdk-stage1/dietlibc/lib/atoll.c create mode 100644 mdk-stage1/dietlibc/lib/bcd.c create mode 100644 mdk-stage1/dietlibc/lib/binshstr.c create mode 100644 mdk-stage1/dietlibc/lib/cfgetospeed.c create mode 100644 mdk-stage1/dietlibc/lib/cfsetispeed.c create mode 100644 mdk-stage1/dietlibc/lib/cfsetospeed.c create mode 100644 mdk-stage1/dietlibc/lib/errlistu.c create mode 100644 mdk-stage1/dietlibc/lib/execle.c create mode 100644 mdk-stage1/dietlibc/lib/if_nameindex.c create mode 100644 mdk-stage1/dietlibc/lib/ipv6constants.c create mode 100644 mdk-stage1/dietlibc/lib/labs.c create mode 100644 mdk-stage1/dietlibc/lib/llabs.c create mode 100644 mdk-stage1/dietlibc/lib/memmem.c create mode 100644 mdk-stage1/dietlibc/lib/memrchr.c create mode 100644 mdk-stage1/dietlibc/lib/pwrite.c create mode 100644 mdk-stage1/dietlibc/lib/pwrite64.c create mode 100644 mdk-stage1/dietlibc/lib/rand48.c create mode 100644 mdk-stage1/dietlibc/lib/rand_r.c create mode 100644 mdk-stage1/dietlibc/lib/readdir64.c create mode 100644 mdk-stage1/dietlibc/lib/setlinebuf.c create mode 100644 mdk-stage1/dietlibc/lib/sigaction.c create mode 100644 mdk-stage1/dietlibc/lib/siginterrupt.c create mode 100644 mdk-stage1/dietlibc/lib/signal.c create mode 100644 mdk-stage1/dietlibc/lib/sigpending.c create mode 100644 mdk-stage1/dietlibc/lib/sigprocmask.c create mode 100644 mdk-stage1/dietlibc/lib/sigqueueinfo.c create mode 100644 mdk-stage1/dietlibc/lib/sigsuspend.c create mode 100644 mdk-stage1/dietlibc/lib/sigtimedwait.c create mode 100644 mdk-stage1/dietlibc/lib/socketpair.c create mode 100644 mdk-stage1/dietlibc/lib/strtof.c create mode 100644 mdk-stage1/dietlibc/lib/strtold.c create mode 100644 mdk-stage1/dietlibc/lib/strxfrm.c create mode 100644 mdk-stage1/dietlibc/lib/tcflow.c create mode 100644 mdk-stage1/dietlibc/lib/tcsendbreak.c create mode 100644 mdk-stage1/dietlibc/lib/write12.c create mode 100644 mdk-stage1/dietlibc/libcompat/daemon.c create mode 100644 mdk-stage1/dietlibc/libcompat/getdelim.c create mode 100644 mdk-stage1/dietlibc/libcompat/getline.c create mode 100644 mdk-stage1/dietlibc/libcompat/re_bsd.c create mode 100644 mdk-stage1/dietlibc/libcompat/stpcpy.c create mode 100644 mdk-stage1/dietlibc/libcompat/syscall.S create mode 100644 mdk-stage1/dietlibc/libcruft/__end_parse.c create mode 100644 mdk-stage1/dietlibc/libcruft/__parse.c create mode 100644 mdk-stage1/dietlibc/libcruft/__parse_1.c create mode 100644 mdk-stage1/dietlibc/libcruft/__parse_nws.c create mode 100644 mdk-stage1/dietlibc/libcruft/__parse_ws.c create mode 100644 mdk-stage1/dietlibc/libcruft/__prepare_parse.c create mode 100644 mdk-stage1/dietlibc/libcruft/alphasort.c create mode 100644 mdk-stage1/dietlibc/libcruft/alphasort64.c create mode 100644 mdk-stage1/dietlibc/libcruft/bcopy.c create mode 100644 mdk-stage1/dietlibc/libcruft/bzero.c create mode 100644 mdk-stage1/dietlibc/libcruft/clock.c create mode 100644 mdk-stage1/dietlibc/libcruft/dn_expand.c create mode 100644 mdk-stage1/dietlibc/libcruft/dnscruft3.c create mode 100644 mdk-stage1/dietlibc/libcruft/dnscruft4.c create mode 100644 mdk-stage1/dietlibc/libcruft/getgrent.c create mode 100644 mdk-stage1/dietlibc/libcruft/getgrent_r.c create mode 100644 mdk-stage1/dietlibc/libcruft/getgrgid_r.c create mode 100644 mdk-stage1/dietlibc/libcruft/getgrnam_r.c create mode 100644 mdk-stage1/dietlibc/libcruft/gethostbyaddr2_r.c create mode 100644 mdk-stage1/dietlibc/libcruft/getopt_data.c create mode 100644 mdk-stage1/dietlibc/libcruft/getopt_long.c create mode 100644 mdk-stage1/dietlibc/libcruft/getopt_long_only.c create mode 100644 mdk-stage1/dietlibc/libcruft/getpwent.c create mode 100644 mdk-stage1/dietlibc/libcruft/getpwent_r.c create mode 100644 mdk-stage1/dietlibc/libcruft/getpwnam_r.c create mode 100644 mdk-stage1/dietlibc/libcruft/getpwuid_r.c create mode 100644 mdk-stage1/dietlibc/libcruft/getspent.c create mode 100644 mdk-stage1/dietlibc/libcruft/getspent_r.c create mode 100644 mdk-stage1/dietlibc/libcruft/getspnam_r.c create mode 100644 mdk-stage1/dietlibc/libcruft/getusershell.c create mode 100644 mdk-stage1/dietlibc/libcruft/grbuf.c create mode 100644 mdk-stage1/dietlibc/libcruft/herror.c create mode 100644 mdk-stage1/dietlibc/libcruft/hstrerror.c create mode 100644 mdk-stage1/dietlibc/libcruft/killpg.c create mode 100644 mdk-stage1/dietlibc/libcruft/localeconv.c create mode 100644 mdk-stage1/dietlibc/libcruft/mkdtemp.c create mode 100644 mdk-stage1/dietlibc/libcruft/mktemp.c create mode 100644 mdk-stage1/dietlibc/libcruft/pwbuf.c create mode 100644 mdk-stage1/dietlibc/libcruft/res_mkquery.c create mode 100644 mdk-stage1/dietlibc/libcruft/res_query.c create mode 100644 mdk-stage1/dietlibc/libcruft/res_search.c create mode 100644 mdk-stage1/dietlibc/libcruft/scan_ulong.c create mode 100644 mdk-stage1/dietlibc/libcruft/scandir.c create mode 100644 mdk-stage1/dietlibc/libcruft/scandir64.c create mode 100644 mdk-stage1/dietlibc/libcruft/setegid.c create mode 100644 mdk-stage1/dietlibc/libcruft/seteuid.c create mode 100644 mdk-stage1/dietlibc/libcruft/setlocale.c create mode 100644 mdk-stage1/dietlibc/libcruft/spbuf.c create mode 100644 mdk-stage1/dietlibc/libcruft/sysconf.c create mode 100644 mdk-stage1/dietlibc/libcruft/sysconf_cpus.c create mode 100644 mdk-stage1/dietlibc/libcruft/tempnam.c create mode 100644 mdk-stage1/dietlibc/libcruft/tmpnam.c create mode 100644 mdk-stage1/dietlibc/libcrypt/md5.c create mode 100644 mdk-stage1/dietlibc/libcrypt/md5crypt.c create mode 100644 mdk-stage1/dietlibc/libdl/_dl_alloc.c create mode 100644 mdk-stage1/dietlibc/libdl/_dl_load.c create mode 100644 mdk-stage1/dietlibc/libdl/_dl_main.c create mode 100644 mdk-stage1/dietlibc/libdl/_dl_queue.c create mode 100644 mdk-stage1/dietlibc/libdl/_dl_rel.c create mode 100644 mdk-stage1/dietlibc/libdl/_dl_rel.h create mode 100644 mdk-stage1/dietlibc/libdl/_dl_relocate.c create mode 100644 mdk-stage1/dietlibc/libdl/elf_hash.h create mode 100644 mdk-stage1/dietlibc/libdl/test/test.c create mode 100644 mdk-stage1/dietlibc/libdl/test/test_so.c create mode 100644 mdk-stage1/dietlibc/libm/acosh.c create mode 100644 mdk-stage1/dietlibc/libm/asinh.c create mode 100644 mdk-stage1/dietlibc/libm/atanh.c create mode 100644 mdk-stage1/dietlibc/libm/bessel.c create mode 100644 mdk-stage1/dietlibc/libm/cosh.c create mode 100644 mdk-stage1/dietlibc/libm/erf.c create mode 100644 mdk-stage1/dietlibc/libm/gamma.c create mode 100644 mdk-stage1/dietlibc/libm/ipow.c create mode 100644 mdk-stage1/dietlibc/libm/poly.c create mode 100644 mdk-stage1/dietlibc/libm/pow.c create mode 100644 mdk-stage1/dietlibc/libm/rint.c create mode 100644 mdk-stage1/dietlibc/libm/sinh.c create mode 100644 mdk-stage1/dietlibc/libm/tanh.c create mode 100644 mdk-stage1/dietlibc/libpthread/pthread_equal.c create mode 100644 mdk-stage1/dietlibc/libpthread/pthread_errno.c create mode 100644 mdk-stage1/dietlibc/libpthread/pthread_fdglue2.c create mode 100644 mdk-stage1/dietlibc/libpthread/pthread_fgetc.c create mode 100644 mdk-stage1/dietlibc/libpthread/pthread_flockfile.c create mode 100644 mdk-stage1/dietlibc/libpthread/pthread_fputc.c create mode 100644 mdk-stage1/dietlibc/libpthread/pthread_funlockfile.c create mode 100644 mdk-stage1/dietlibc/libpthread/pthread_getschedparam.c create mode 100644 mdk-stage1/dietlibc/libpthread/pthread_internal.c create mode 100644 mdk-stage1/dietlibc/libpthread/pthread_key.c create mode 100644 mdk-stage1/dietlibc/libpthread/pthread_setschedparam.c create mode 100644 mdk-stage1/dietlibc/libpthread/pthread_sigmask.c create mode 100644 mdk-stage1/dietlibc/libpthread/pthread_sys_fdatasync.c create mode 100644 mdk-stage1/dietlibc/libshell/basename.c create mode 100644 mdk-stage1/dietlibc/libshell/dirname.c create mode 100644 mdk-stage1/dietlibc/libstdio/fdglue2.c create mode 100644 mdk-stage1/dietlibc/libstdio/fdprintf.c create mode 100644 mdk-stage1/dietlibc/libstdio/fgetc_unlocked.c create mode 100644 mdk-stage1/dietlibc/libstdio/fgetpos.c create mode 100644 mdk-stage1/dietlibc/libstdio/fputc_unlocked.c create mode 100644 mdk-stage1/dietlibc/libstdio/fscanf.c create mode 100644 mdk-stage1/dietlibc/libstdio/fseeko.c create mode 100644 mdk-stage1/dietlibc/libstdio/fseeko64.c create mode 100644 mdk-stage1/dietlibc/libstdio/fsetpos.c create mode 100644 mdk-stage1/dietlibc/libstdio/ftello.c create mode 100644 mdk-stage1/dietlibc/libstdio/ftello64.c create mode 100644 mdk-stage1/dietlibc/libstdio/puts.c create mode 100644 mdk-stage1/dietlibc/libstdio/scanf.c create mode 100644 mdk-stage1/dietlibc/libstdio/tmpfile.c create mode 100644 mdk-stage1/dietlibc/libstdio/vfdprintf.c create mode 100644 mdk-stage1/dietlibc/libstdio/vfprintf.c create mode 100644 mdk-stage1/dietlibc/libstdio/vfscanf.c create mode 100644 mdk-stage1/dietlibc/libstdio/vprintf.c create mode 100644 mdk-stage1/dietlibc/libstdio/vscanf.c create mode 100644 mdk-stage1/dietlibc/libugly/difftime.c create mode 100644 mdk-stage1/dietlibc/libugly/dirfd.c create mode 100644 mdk-stage1/dietlibc/libugly/freeaddrinfo.c create mode 100644 mdk-stage1/dietlibc/libugly/ftime.c create mode 100644 mdk-stage1/dietlibc/libugly/gai_strerror.c create mode 100644 mdk-stage1/dietlibc/libugly/getaddrinfo.c create mode 100644 mdk-stage1/dietlibc/libugly/gethostent.c create mode 100644 mdk-stage1/dietlibc/libugly/getnameinfo.c create mode 100644 mdk-stage1/dietlibc/libugly/getprotobyname.c create mode 100644 mdk-stage1/dietlibc/libugly/getprotobyname_r.c create mode 100644 mdk-stage1/dietlibc/libugly/getprotobynumber.c create mode 100644 mdk-stage1/dietlibc/libugly/getprotobynumber_r.c create mode 100644 mdk-stage1/dietlibc/libugly/getprotoent_r.c create mode 100644 mdk-stage1/dietlibc/libugly/getservbyname.c create mode 100644 mdk-stage1/dietlibc/libugly/getservbyname_r.c create mode 100644 mdk-stage1/dietlibc/libugly/getservbyport.c create mode 100644 mdk-stage1/dietlibc/libugly/getservbyport_r.c create mode 100644 mdk-stage1/dietlibc/libugly/getservent.c create mode 100644 mdk-stage1/dietlibc/libugly/getservent_r.c create mode 100644 mdk-stage1/dietlibc/libugly/grantpt.c create mode 100644 mdk-stage1/dietlibc/libugly/hasmntopt.c create mode 100644 mdk-stage1/dietlibc/libugly/iconv.c create mode 100644 mdk-stage1/dietlibc/libugly/iconv_close.c create mode 100644 mdk-stage1/dietlibc/libugly/iconv_open.c create mode 100644 mdk-stage1/dietlibc/libugly/netent.c create mode 100644 mdk-stage1/dietlibc/libugly/openpty.c create mode 100644 mdk-stage1/dietlibc/libugly/protoent_buf.c create mode 100644 mdk-stage1/dietlibc/libugly/ptsname.c create mode 100644 mdk-stage1/dietlibc/libugly/putpwent.c create mode 100644 mdk-stage1/dietlibc/libugly/servent_buf.c create mode 100644 mdk-stage1/dietlibc/libugly/strndup.c create mode 100644 mdk-stage1/dietlibc/libugly/timezone.c create mode 100644 mdk-stage1/dietlibc/libugly/unlockpt.c create mode 100644 mdk-stage1/dietlibc/libugly/utent.c create mode 100644 mdk-stage1/dietlibc/libugly/wtent.c create mode 100644 mdk-stage1/dietlibc/ppc/clone.S create mode 100644 mdk-stage1/dietlibc/ppc/syscalls.h create mode 100644 mdk-stage1/dietlibc/profiling/PORTING create mode 100644 mdk-stage1/dietlibc/profiling/README create mode 100644 mdk-stage1/dietlibc/profiling/__mcount.c create mode 100644 mdk-stage1/dietlibc/profiling/monitor.c create mode 100644 mdk-stage1/dietlibc/profiling/profil.c create mode 100644 mdk-stage1/dietlibc/sparc/errlist.S create mode 100644 mdk-stage1/dietlibc/sparc/sigaction.c create mode 100644 mdk-stage1/dietlibc/sparc/strlen.S create mode 100644 mdk-stage1/dietlibc/sparc/syscalls.h create mode 100644 mdk-stage1/dietlibc/syscalls.s/__pwrite.S create mode 100644 mdk-stage1/dietlibc/syscalls.s/adjtimex.S create mode 100644 mdk-stage1/dietlibc/syscalls.s/alarm.S create mode 100644 mdk-stage1/dietlibc/syscalls.s/bdflush.S create mode 100644 mdk-stage1/dietlibc/syscalls.s/chown32.S create mode 100644 mdk-stage1/dietlibc/syscalls.s/create_module.S create mode 100644 mdk-stage1/dietlibc/syscalls.s/delete_module.S create mode 100644 mdk-stage1/dietlibc/syscalls.s/environ.S create mode 100644 mdk-stage1/dietlibc/syscalls.s/epoll_create.S create mode 100644 mdk-stage1/dietlibc/syscalls.s/epoll_ctl.S create mode 100644 mdk-stage1/dietlibc/syscalls.s/epoll_wait.S create mode 100644 mdk-stage1/dietlibc/syscalls.s/errlist.S create mode 100644 mdk-stage1/dietlibc/syscalls.s/errno.S create mode 100644 mdk-stage1/dietlibc/syscalls.s/fchown32.S create mode 100644 mdk-stage1/dietlibc/syscalls.s/fdatasync.S create mode 100644 mdk-stage1/dietlibc/syscalls.s/ftruncate64.S create mode 100644 mdk-stage1/dietlibc/syscalls.s/getegid32.S create mode 100644 mdk-stage1/dietlibc/syscalls.s/geteuid32.S create mode 100644 mdk-stage1/dietlibc/syscalls.s/getgid32.S create mode 100644 mdk-stage1/dietlibc/syscalls.s/getgroups32.S create mode 100644 mdk-stage1/dietlibc/syscalls.s/getresgid32.S create mode 100644 mdk-stage1/dietlibc/syscalls.s/getuid32.S create mode 100644 mdk-stage1/dietlibc/syscalls.s/init_module.S create mode 100644 mdk-stage1/dietlibc/syscalls.s/lchown32.S create mode 100644 mdk-stage1/dietlibc/syscalls.s/madvise.S create mode 100644 mdk-stage1/dietlibc/syscalls.s/mlock.S create mode 100644 mdk-stage1/dietlibc/syscalls.s/mmap2.S create mode 100644 mdk-stage1/dietlibc/syscalls.s/msync.S create mode 100644 mdk-stage1/dietlibc/syscalls.s/munlock.S create mode 100644 mdk-stage1/dietlibc/syscalls.s/n_sigaction.S create mode 100644 mdk-stage1/dietlibc/syscalls.s/n_sigpending.S create mode 100644 mdk-stage1/dietlibc/syscalls.s/n_sigprocmask.S create mode 100644 mdk-stage1/dietlibc/syscalls.s/n_sigsuspend.S create mode 100644 mdk-stage1/dietlibc/syscalls.s/pivot_root.S create mode 100644 mdk-stage1/dietlibc/syscalls.s/prctl.S create mode 100644 mdk-stage1/dietlibc/syscalls.s/ptrace.S create mode 100644 mdk-stage1/dietlibc/syscalls.s/rt_sigaction.S create mode 100644 mdk-stage1/dietlibc/syscalls.s/rt_sigpending.S create mode 100644 mdk-stage1/dietlibc/syscalls.s/rt_sigprocmask.S create mode 100644 mdk-stage1/dietlibc/syscalls.s/rt_sigqueueinfo.S create mode 100644 mdk-stage1/dietlibc/syscalls.s/rt_sigsuspend.S create mode 100644 mdk-stage1/dietlibc/syscalls.s/rt_sigtimedwait.S create mode 100644 mdk-stage1/dietlibc/syscalls.s/sendfile64.S create mode 100644 mdk-stage1/dietlibc/syscalls.s/setfsgid.S create mode 100644 mdk-stage1/dietlibc/syscalls.s/setfsgid32.S create mode 100644 mdk-stage1/dietlibc/syscalls.s/setfsuid.S create mode 100644 mdk-stage1/dietlibc/syscalls.s/setfsuid32.S create mode 100644 mdk-stage1/dietlibc/syscalls.s/setgid32.S create mode 100644 mdk-stage1/dietlibc/syscalls.s/setregid32.S create mode 100644 mdk-stage1/dietlibc/syscalls.s/setresgid32.S create mode 100644 mdk-stage1/dietlibc/syscalls.s/setreuid32.S create mode 100644 mdk-stage1/dietlibc/syscalls.s/settimeofday.S create mode 100644 mdk-stage1/dietlibc/syscalls.s/setuid32.S create mode 100644 mdk-stage1/dietlibc/syscalls.s/truncate64.S create mode 100644 mdk-stage1/dietlibc/x86_64/Makefile.add create mode 100644 mdk-stage1/dietlibc/x86_64/__longjmp.S create mode 100644 mdk-stage1/dietlibc/x86_64/__testandset.S create mode 100644 mdk-stage1/dietlibc/x86_64/accept.S create mode 100644 mdk-stage1/dietlibc/x86_64/bind.S create mode 100644 mdk-stage1/dietlibc/x86_64/clone.S create mode 100644 mdk-stage1/dietlibc/x86_64/connect.S create mode 100644 mdk-stage1/dietlibc/x86_64/getpeername.S create mode 100644 mdk-stage1/dietlibc/x86_64/getsockname.S create mode 100644 mdk-stage1/dietlibc/x86_64/getsockopt.S create mode 100644 mdk-stage1/dietlibc/x86_64/listen.S create mode 100644 mdk-stage1/dietlibc/x86_64/mmap.S create mode 100644 mdk-stage1/dietlibc/x86_64/msgctl.S create mode 100644 mdk-stage1/dietlibc/x86_64/msgget.S create mode 100644 mdk-stage1/dietlibc/x86_64/msgrcv.S create mode 100644 mdk-stage1/dietlibc/x86_64/msgsnd.S create mode 100644 mdk-stage1/dietlibc/x86_64/recv.c create mode 100644 mdk-stage1/dietlibc/x86_64/recvfrom.S create mode 100644 mdk-stage1/dietlibc/x86_64/recvmsg.S create mode 100644 mdk-stage1/dietlibc/x86_64/semctl.S create mode 100644 mdk-stage1/dietlibc/x86_64/semget.S create mode 100644 mdk-stage1/dietlibc/x86_64/semop.S create mode 100644 mdk-stage1/dietlibc/x86_64/send.c create mode 100644 mdk-stage1/dietlibc/x86_64/sendmsg.S create mode 100644 mdk-stage1/dietlibc/x86_64/sendto.S create mode 100644 mdk-stage1/dietlibc/x86_64/setjmp.S create mode 100644 mdk-stage1/dietlibc/x86_64/setsockopt.S create mode 100644 mdk-stage1/dietlibc/x86_64/shmat.S create mode 100644 mdk-stage1/dietlibc/x86_64/shmctl.S create mode 100644 mdk-stage1/dietlibc/x86_64/shmdt.S create mode 100644 mdk-stage1/dietlibc/x86_64/shmget.S create mode 100644 mdk-stage1/dietlibc/x86_64/shutdown.S create mode 100644 mdk-stage1/dietlibc/x86_64/sigaction.c create mode 100644 mdk-stage1/dietlibc/x86_64/socket.S create mode 100644 mdk-stage1/dietlibc/x86_64/socketpair.S create mode 100644 mdk-stage1/dietlibc/x86_64/start.S create mode 100644 mdk-stage1/dietlibc/x86_64/syscalls.h create mode 100644 mdk-stage1/dietlibc/x86_64/umount.S create mode 100644 mdk-stage1/dietlibc/x86_64/unified.S create mode 100644 mdk-stage1/dietlibc/x86_64/waitpid.S diff --git a/mdk-stage1/dietlibc/alpha/__alarm.c b/mdk-stage1/dietlibc/alpha/__alarm.c new file mode 100644 index 000000000..7ca35cb78 --- /dev/null +++ b/mdk-stage1/dietlibc/alpha/__alarm.c @@ -0,0 +1,13 @@ +#include +#include + +unsigned int alarm(unsigned int seconds) { + struct itimerval old, new; + unsigned int ret; + new.it_interval.tv_usec=0; + new.it_interval.tv_sec=0; + new.it_value.tv_usec =0; + new.it_value.tv_sec =(long)seconds; + if (setitimer(ITIMER_REAL,&new,&old)==-1) return 0; + return old.it_value.tv_sec+(old.it_value.tv_usec?1:0); +} diff --git a/mdk-stage1/dietlibc/alpha/__testandset.S b/mdk-stage1/dietlibc/alpha/__testandset.S new file mode 100644 index 000000000..c5ef81241 --- /dev/null +++ b/mdk-stage1/dietlibc/alpha/__testandset.S @@ -0,0 +1,11 @@ +.text +.align 2 +.global __testandsets +.type __testandsets,@function +__testandset: + ldq_l $0, 0($16) /* load lock */ + bne $0,1f /* ok there is a lock... */ + lda $0, 1($31) /* load a 1 to register 0 */ + stq_c $0, 0($16) /* write lock is locked :) */ + beq $0,__testandset /* oops someone changed MY lock */ +1: ret $31, ($26), 0x01 /* return */ diff --git a/mdk-stage1/dietlibc/alpha/errlist.S b/mdk-stage1/dietlibc/alpha/errlist.S new file mode 100644 index 000000000..a5956ce05 --- /dev/null +++ b/mdk-stage1/dietlibc/alpha/errlist.S @@ -0,0 +1,288 @@ +#ifdef __DYN_LIB +.section .data +#else +.section .rodata +#endif + +.align 8 +.global sys_errlist +.type sys_errlist,@object + +sys_errlist: + .quad .LC000 + .quad .LC001 + .quad .LC002 + .quad .LC003 + .quad .LC004 + .quad .LC005 + .quad .LC006 + .quad .LC007 + .quad .LC008 + .quad .LC009 + .quad .LC010 + .quad .LC011 + .quad .LC012 + .quad .LC013 + .quad .LC014 + .quad .LC015 + .quad .LC016 + .quad .LC017 + .quad .LC018 + .quad .LC019 + .quad .LC020 + .quad .LC021 + .quad .LC022 + .quad .LC023 + .quad .LC024 + .quad .LC025 + .quad .LC026 + .quad .LC027 + .quad .LC028 + .quad .LC029 + .quad .LC030 + .quad .LC031 + .quad .LC032 + .quad .LC033 + .quad .LC034 + .quad .LC035 + .quad .LC036 + .quad .LC037 + .quad .LC038 + .quad .LC039 + .quad .LC040 + .quad .LC041 + .quad .LC042 + .quad .LC043 + .quad .LC044 + .quad .LC045 + .quad .LC046 + .quad .LC047 + .quad .LC048 + .quad .LC049 + .quad .LC050 + .quad .LC051 + .quad .LC052 + .quad .LC053 + .quad .LC054 + .quad .LC055 + .quad .LC056 + .quad .LC057 + .quad .LC058 + .quad .LC059 + .quad .LC060 + .quad .LC061 + .quad .LC062 + .quad .LC063 + .quad .LC064 + .quad .LC065 + .quad .LC066 + .quad .LC067 + .quad .LC068 + .quad .LC069 + .quad .LC070 + .quad .LC071 + .quad .LC072 + .quad .LC073 + .quad .LC074 + .quad .LC075 + .quad .LC076 + .quad .LC077 + .quad .LC078 + .quad .LC079 + .quad .LC080 + .quad .LC081 + .quad .LC082 + .quad .LC083 + .quad .LC084 + .quad .LC085 + .quad .LC086 + .quad .LC087 + .quad .LC088 + .quad .LC089 + .quad .LC090 + .quad .LC091 + .quad .LC092 + .quad .LC093 + .quad .LC094 + .quad .LC095 + .quad .LC096 + .quad .LC097 + .quad .LC098 + .quad .LC099 + .quad .LC100 + .quad .LC101 + .quad .LC102 + .quad .LC103 + .quad .LC104 + .quad .LC105 + .quad .LC106 + .quad .LC107 + .quad .LC108 + .quad .LC109 + .quad .LC110 + .quad .LC111 + .quad .LC112 + .quad .LC113 + .quad .LC114 + .quad .LC115 + .quad .LC116 + .quad .LC117 + .quad .LC118 + .quad .LC119 + .quad .LC120 + .quad .LC121 + .quad .LC122 + .quad .LC123 + .quad .LC124 + .quad .LC125 + .quad .LC126 + .quad .LC127 + .quad .LC128 + .quad .LC129 + .quad .LC130 + .quad 0 +.size sys_errlist,.-sys_errlist + +.align 4 +.global sys_nerr +.type sys_nerr,@object +sys_nerr: + .long 130 +.size sys_nerr,4 + +#ifdef __DYN_LIB +.section .rodata +#endif + +.LC000: .string "Success" +.LC001: .string "Operation not permitted" +.LC002: .string "No such file or directory" +.LC003: .string "No such process" +.LC004: .string "Interrupted system call" +.LC005: .string "I/O error" +.LC006: .string "No such device or address" +.LC007: .string "Arg list too long" +.LC008: .string "Exec format error" +.LC009: .string "Bad file number" +.LC010: .string "No child processes" +.LC011: .string "Resource deadlock would occur" +.LC012: .string "Out of memory" +.LC013: .string "Permission denied" +.LC014: .string "Bad address" +.LC015: .string "Block device required" +.LC016: .string "Device or resource busy" +.LC017: .string "File exists" +.LC018: .string "Cross-device link" +.LC019: .string "No such device" +.LC020: .string "Not a directory" +.LC021: .string "Is a directory" +.LC022: .string "Invalid argument" +.LC023: .string "File table overflow" +.LC024: .string "Too many open files" +.LC025: .string "Not a typewriter" +.LC026: .string "Text file busy" +.LC027: .string "File too large" +.LC028: .string "No space left on device" +.LC029: .string "Illegal seek" +.LC030: .string "Read-only file system" +.LC031: .string "Too many links" +.LC032: .string "Broken pipe" +.LC033: .string "Math argument out of domain of func" +.LC034: .string "Math result not representable" +.LC035: .string "Try again" +.LC036: .string "Operation now in progress" +.LC037: .string "Operation already in progress" +.LC038: .string "Socket operation on non-socket" +.LC039: .string "Destination address required" +.LC040: .string "Message too long" +.LC041: .string "Protocol wrong type for socket" +.LC042: .string "Protocol not available" +.LC043: .string "Protocol not supported" +.LC044: .string "Socket type not supported" +.LC045: .string "Operation not supported on transport endpoint" +.LC046: .string "Protocol family not supported" +.LC047: .string "Address family not supported by protocol" +.LC048: .string "Address already in use" +.LC049: .string "Cannot assign requested address" +.LC050: .string "Network is down" +.LC051: .string "Network is unreachable" +.LC052: .string "Network dropped connection because of reset" +.LC053: .string "Software caused connection abort" +.LC054: .string "Connection reset by peer" +.LC055: .string "No buffer space available" +.LC056: .string "Transport endpoint is already connected" +.LC057: .string "Transport endpoint is not connected" +.LC058: .string "Cannot send after transport endpoint shutdown" +.LC059: .string "Too many references: cannot splice" +.LC060: .string "Connection timed out" +.LC061: .string "Connection refused" +.LC062: .string "Too many symbolic links encountered" +.LC063: .string "File name too long" +.LC064: .string "Host is down" +.LC065: .string "No route to host" +.LC066: .string "Directory not empty" +.LC067: .string "Error 67" +.LC068: .string "Too many users" +.LC069: .string "Quota exceeded" +.LC070: .string "Stale NFS file handle" +.LC071: .string "Object is remote" +.LC072: .string "Error 72" +.LC073: .string "Error 73" +.LC074: .string "Error 74" +.LC075: .string "Error 75" +.LC076: .string "Error 76" +.LC077: .string "No record locks available" +.LC078: .string "Function not implemented" +.LC079: .string "Error 79" +.LC080: .string "No message of desired type" +.LC081: .string "Identifier removed" +.LC082: .string "Out of streams resources" +.LC083: .string "Timer expired" +.LC084: .string "Not a data message" +.LC085: .string "Protocol error" +.LC086: .string "No data available" +.LC087: .string "Device not a stream" +.LC088: .string "Channel number out of range" +.LC089: .string "Level 2 not synchronized" +.LC090: .string "Level 3 halted" +.LC091: .string "Level 3 reset" +.LC092: .string "Package not installed" +.LC093: .string "Link number out of range" +.LC094: .string "Protocol driver not attached" +.LC095: .string "No CSI structure available" +.LC096: .string "Level 2 halted" +.LC097: .string "Invalid exchange" +.LC098: .string "Invalid request descriptor" +.LC099: .string "Exchange full" +.LC100: .string "No anode" +.LC101: .string "Invalid request code" +.LC102: .string "Invalid slot" +.LC103: .string "Error 103" +.LC104: .string "Bad font file format" +.LC105: .string "Machine is not on the network" +.LC106: .string "Link has been severed" +.LC107: .string "Advertise error" +.LC108: .string "Srmount error" +.LC109: .string "Communication error on send" +.LC110: .string "Multihop attempted" +.LC111: .string "RFS specific error" +.LC112: .string "Value too large for defined data type" +.LC113: .string "Name not unique on network" +.LC114: .string "File descriptor in bad state" +.LC115: .string "Remote address changed" +.LC116: .string "Illegal byte sequence" +.LC117: .string "Structure needs cleaning" +.LC118: .string "Not a XENIX named type file" +.LC119: .string "No XENIX semaphores available" +.LC120: .string "Is a named type file" +.LC121: .string "Remote I/O error" +.LC122: .string "Can not access a needed shared library" +.LC123: .string "Accessing a corrupted shared library" +.LC124: .string ".lib section in a.out corrupted" +.LC125: .string "Attempting to link in too many shared libraries" +.LC126: .string "Cannot exec a shared library directly" +.LC127: .string "Interrupted system call should be restarted" +.LC128: .string "Streams pipe error" +.LC129: .string "No medium found" +.LC130: .string "Wrong medium type" + diff --git a/mdk-stage1/dietlibc/alpha/lseek64.S b/mdk-stage1/dietlibc/alpha/lseek64.S new file mode 100644 index 000000000..f051e734d --- /dev/null +++ b/mdk-stage1/dietlibc/alpha/lseek64.S @@ -0,0 +1,5 @@ +#include "syscalls.h" + +.global lseek64 +lseek64: + br lseek diff --git a/mdk-stage1/dietlibc/alpha/n_sigprocmask.S b/mdk-stage1/dietlibc/alpha/n_sigprocmask.S new file mode 100644 index 000000000..55f9fde28 --- /dev/null +++ b/mdk-stage1/dietlibc/alpha/n_sigprocmask.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall_weak(osf_sigprocmask,__old_sigprocmask,__n_sigprocmask) diff --git a/mdk-stage1/dietlibc/alpha/sigaction.c b/mdk-stage1/dietlibc/alpha/sigaction.c new file mode 100644 index 000000000..f6c3ada7d --- /dev/null +++ b/mdk-stage1/dietlibc/alpha/sigaction.c @@ -0,0 +1,7 @@ +#include + +int __rt_sigaction(int signum, const struct sigaction *act, struct sigaction *oldact, long nr, void* restorer); + +int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact) { + return __rt_sigaction(signum, act, oldact, _NSIG/8, 0); +} diff --git a/mdk-stage1/dietlibc/alpha/socketpair.S b/mdk-stage1/dietlibc/alpha/socketpair.S new file mode 100644 index 000000000..06956a7ce --- /dev/null +++ b/mdk-stage1/dietlibc/alpha/socketpair.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(socketpair,socketpair) diff --git a/mdk-stage1/dietlibc/alpha/syscalls.h b/mdk-stage1/dietlibc/alpha/syscalls.h new file mode 100644 index 000000000..5c654b4bf --- /dev/null +++ b/mdk-stage1/dietlibc/alpha/syscalls.h @@ -0,0 +1,371 @@ + +#define __NR_osf_syscall 0 /* not implemented */ +#define __NR_exit 1 +#define __NR_fork 2 +#define __NR_read 3 +#define __NR_write 4 +#define __NR_osf_old_open 5 /* not implemented */ +#define __NR_close 6 +#define __NR_osf_wait4 7 +#define __NR_osf_old_creat 8 /* not implemented */ +#define __NR_link 9 +#define __NR_unlink 10 +#define __NR_osf_execve 11 /* not implemented */ +#define __NR_chdir 12 +#define __NR_fchdir 13 +#define __NR_mknod 14 +#define __NR_chmod 15 +#define __NR_chown 16 +#define __NR_brk 17 +#define __NR_osf_getfsstat 18 /* not implemented */ +#define __NR_lseek 19 +#define __NR_getxpid 20 +#define __NR_osf_mount 21 +#define __NR_umount 22 +#define __NR_setuid 23 +#define __NR_getxuid 24 +#define __NR_exec_with_loader 25 /* not implemented */ +#define __NR_ptrace 26 +#define __NR_osf_nrecvmsg 27 /* not implemented */ +#define __NR_osf_nsendmsg 28 /* not implemented */ +#define __NR_osf_nrecvfrom 29 /* not implemented */ +#define __NR_osf_naccept 30 /* not implemented */ +#define __NR_osf_ngetpeername 31 /* not implemented */ +#define __NR_osf_ngetsockname 32 /* not implemented */ +#define __NR_access 33 +#define __NR_osf_chflags 34 /* not implemented */ +#define __NR_osf_fchflags 35 /* not implemented */ +#define __NR_sync 36 +#define __NR_kill 37 +#define __NR_osf_old_stat 38 /* not implemented */ +#define __NR_setpgid 39 +#define __NR_osf_old_lstat 40 /* not implemented */ +#define __NR_dup 41 +#define __NR_pipe 42 +#define __NR_osf_set_program_attributes 43 +#define __NR_osf_profil 44 /* not implemented */ +#define __NR_open 45 +#define __NR_osf_old_sigaction 46 /* not implemented */ +#define __NR_getxgid 47 +#define __NR_osf_sigprocmask 48 +#define __NR_osf_getlogin 49 /* not implemented */ +#define __NR_osf_setlogin 50 /* not implemented */ +#define __NR_acct 51 +#define __NR_sigpending 52 + +#define __NR_ioctl 54 +#define __NR_osf_reboot 55 /* not implemented */ +#define __NR_osf_revoke 56 /* not implemented */ +#define __NR_symlink 57 +#define __NR_readlink 58 +#define __NR_execve 59 +#define __NR_umask 60 +#define __NR_chroot 61 +#define __NR_osf_old_fstat 62 /* not implemented */ +#define __NR_getpgrp 63 +#define __NR_getpagesize 64 +#define __NR_osf_mremap 65 /* not implemented */ +#define __NR_vfork 66 +#define __NR_stat 67 +#define __NR_lstat 68 +#define __NR_osf_sbrk 69 /* not implemented */ +#define __NR_osf_sstk 70 /* not implemented */ +#define __NR_mmap 71 /* OSF/1 mmap is superset of Linux */ +#define __NR_osf_old_vadvise 72 /* not implemented */ +#define __NR_munmap 73 +#define __NR_mprotect 74 +#define __NR_madvise 75 +#define __NR_vhangup 76 +#define __NR_osf_kmodcall 77 /* not implemented */ +#define __NR_osf_mincore 78 /* not implemented */ +#define __NR_getgroups 79 +#define __NR_setgroups 80 +#define __NR_osf_old_getpgrp 81 /* not implemented */ +#define __NR_setpgrp 82 /* BSD alias for setpgid */ +#define __NR_osf_setitimer 83 +#define __NR_osf_old_wait 84 /* not implemented */ +#define __NR_osf_table 85 /* not implemented */ +#define __NR_osf_getitimer 86 +#define __NR_gethostname 87 +#define __NR_sethostname 88 +#define __NR_getdtablesize 89 +#define __NR_dup2 90 +#define __NR_fstat 91 +#define __NR_fcntl 92 +#define __NR_osf_select 93 +#define __NR_poll 94 +#define __NR_fsync 95 +#define __NR_setpriority 96 +#define __NR_socket 97 +#define __NR_connect 98 +#define __NR_accept 99 +#define __NR_getpriority 100 +#define __NR_send 101 +#define __NR_recv 102 +#define __NR_sigreturn 103 +#define __NR_bind 104 +#define __NR_setsockopt 105 +#define __NR_listen 106 +#define __NR_osf_plock 107 /* not implemented */ +#define __NR_osf_old_sigvec 108 /* not implemented */ +#define __NR_osf_old_sigblock 109 /* not implemented */ +#define __NR_osf_old_sigsetmask 110 /* not implemented */ +#define __NR_sigsuspend 111 +#define __NR_osf_sigstack 112 +#define __NR_recvmsg 113 +#define __NR_sendmsg 114 +#define __NR_osf_old_vtrace 115 /* not implemented */ +#define __NR_osf_gettimeofday 116 +#define __NR_osf_getrusage 117 +#define __NR_getsockopt 118 + +#define __NR_readv 120 +#define __NR_writev 121 +#define __NR_osf_settimeofday 122 +#define __NR_fchown 123 +#define __NR_fchmod 124 +#define __NR_recvfrom 125 +#define __NR_setreuid 126 +#define __NR_setregid 127 +#define __NR_rename 128 +#define __NR_truncate 129 +#define __NR_ftruncate 130 +#define __NR_flock 131 +#define __NR_setgid 132 +#define __NR_sendto 133 +#define __NR_shutdown 134 +#define __NR_socketpair 135 +#define __NR_mkdir 136 +#define __NR_rmdir 137 +#define __NR_osf_utimes 138 +#define __NR_osf_old_sigreturn 139 /* not implemented */ +#define __NR_osf_adjtime 140 /* not implemented */ +#define __NR_getpeername 141 +#define __NR_osf_gethostid 142 /* not implemented */ +#define __NR_osf_sethostid 143 /* not implemented */ +#define __NR_getrlimit 144 +#define __NR_setrlimit 145 +#define __NR_osf_old_killpg 146 /* not implemented */ +#define __NR_setsid 147 +#define __NR_quotactl 148 +#define __NR_osf_oldquota 149 /* not implemented */ +#define __NR_getsockname 150 + +#define __NR_osf_pid_block 153 /* not implemented */ +#define __NR_osf_pid_unblock 154 /* not implemented */ + +#define __NR_sigaction 156 +#define __NR_osf_sigwaitprim 157 /* not implemented */ +#define __NR_osf_nfssvc 158 /* not implemented */ +#define __NR_osf_getdirentries 159 +#define __NR_osf_statfs 160 +#define __NR_osf_fstatfs 161 + +#define __NR_osf_asynch_daemon 163 /* not implemented */ +#define __NR_osf_getfh 164 /* not implemented */ +#define __NR_osf_getdomainname 165 +#define __NR_setdomainname 166 + +#define __NR_osf_exportfs 169 /* not implemented */ + +#define __NR_osf_alt_plock 181 /* not implemented */ + +#define __NR_osf_getmnt 184 /* not implemented */ + +#define __NR_osf_alt_sigpending 187 /* not implemented */ +#define __NR_osf_alt_setsid 188 /* not implemented */ + +#define __NR_osf_swapon 199 +#define __NR_msgctl 200 +#define __NR_msgget 201 +#define __NR_msgrcv 202 +#define __NR_msgsnd 203 +#define __NR_semctl 204 +#define __NR_semget 205 +#define __NR_semop 206 +#define __NR_osf_utsname 207 +#define __NR_lchown 208 +#define __NR_osf_shmat 209 +#define __NR_shmctl 210 +#define __NR_shmdt 211 +#define __NR_shmget 212 +#define __NR_osf_mvalid 213 /* not implemented */ +#define __NR_osf_getaddressconf 214 /* not implemented */ +#define __NR_osf_msleep 215 /* not implemented */ +#define __NR_osf_mwakeup 216 /* not implemented */ +#define __NR_msync 217 +#define __NR_osf_signal 218 /* not implemented */ +#define __NR_osf_utc_gettime 219 /* not implemented */ +#define __NR_osf_utc_adjtime 220 /* not implemented */ + +#define __NR_osf_security 222 /* not implemented */ +#define __NR_osf_kloadcall 223 /* not implemented */ + +#define __NR_getpgid 233 +#define __NR_getsid 234 +#define __NR_sigaltstack 235 +#define __NR_osf_waitid 236 /* not implemented */ +#define __NR_osf_priocntlset 237 /* not implemented */ +#define __NR_osf_sigsendset 238 /* not implemented */ +#define __NR_osf_set_speculative 239 /* not implemented */ +#define __NR_osf_msfs_syscall 240 /* not implemented */ +#define __NR_osf_sysinfo 241 +#define __NR_osf_uadmin 242 /* not implemented */ +#define __NR_osf_fuser 243 /* not implemented */ +#define __NR_osf_proplist_syscall 244 +#define __NR_osf_ntp_adjtime 245 /* not implemented */ +#define __NR_osf_ntp_gettime 246 /* not implemented */ +#define __NR_osf_pathconf 247 /* not implemented */ +#define __NR_osf_fpathconf 248 /* not implemented */ + +#define __NR_osf_uswitch 250 /* not implemented */ +#define __NR_osf_usleep_thread 251 +#define __NR_osf_audcntl 252 /* not implemented */ +#define __NR_osf_audgen 253 /* not implemented */ +#define __NR_sysfs 254 +#define __NR_osf_subsys_info 255 /* not implemented */ +#define __NR_osf_getsysinfo 256 +#define __NR_osf_setsysinfo 257 +#define __NR_osf_afs_syscall 258 /* not implemented */ +#define __NR_osf_swapctl 259 /* not implemented */ +#define __NR_osf_memcntl 260 /* not implemented */ +#define __NR_osf_fdatasync 261 /* not implemented */ + + +/* + * Linux-specific system calls begin at 300 + */ +#define __NR_bdflush 300 +#define __NR_sethae 301 +#define __NR_mount 302 +#define __NR_old_adjtimex 303 +#define __NR_swapoff 304 +#define __NR_getdents 305 +#define __NR_create_module 306 +#define __NR_init_module 307 +#define __NR_delete_module 308 +#define __NR_get_kernel_syms 309 +#define __NR_syslog 310 +#define __NR_reboot 311 +#define __NR_clone 312 +#define __NR_uselib 313 +#define __NR_mlock 314 +#define __NR_munlock 315 +#define __NR_mlockall 316 +#define __NR_munlockall 317 +#define __NR_sysinfo 318 +#define __NR__sysctl 319 +/* 320 was sys_idle. */ +#define __NR_oldumount 321 +#define __NR_swapon 322 +#define __NR_times 323 +#define __NR_personality 324 +#define __NR_setfsuid 325 +#define __NR_setfsgid 326 +#define __NR_ustat 327 +#define __NR_statfs 328 +#define __NR_fstatfs 329 +#define __NR_sched_setparam 330 +#define __NR_sched_getparam 331 +#define __NR_sched_setscheduler 332 +#define __NR_sched_getscheduler 333 +#define __NR_sched_yield 334 +#define __NR_sched_get_priority_max 335 +#define __NR_sched_get_priority_min 336 +#define __NR_sched_rr_get_interval 337 +#define __NR_afs_syscall 338 +#define __NR_uname 339 +#define __NR_nanosleep 340 +#define __NR_mremap 341 +#define __NR_nfsservctl 342 +#define __NR_setresuid 343 +#define __NR_getresuid 344 +#define __NR_pciconfig_read 345 +#define __NR_pciconfig_write 346 +#define __NR_query_module 347 +#define __NR_prctl 348 +#define __NR_pread 349 +#define __NR_pwrite 350 +#define __NR_rt_sigreturn 351 +#define __NR_rt_sigaction 352 +#define __NR_rt_sigprocmask 353 +#define __NR_rt_sigpending 354 +#define __NR_rt_sigtimedwait 355 +#define __NR_rt_sigqueueinfo 356 +#define __NR_rt_sigsuspend 357 +#define __NR_select 358 +#define __NR_gettimeofday 359 +#define __NR_settimeofday 360 +#define __NR_getitimer 361 +#define __NR_setitimer 362 +#define __NR_utimes 363 +#define __NR_getrusage 364 +#define __NR_wait4 365 +#define __NR_adjtimex 366 +#define __NR_getcwd 367 +#define __NR_capget 368 +#define __NR_capset 369 +#define __NR_sendfile 370 +#define __NR_setresgid 371 +#define __NR_getresgid 372 +#define __NR_dipc 373 +#define __NR_pivot_root 374 +#define __NR_mincore 375 +#define __NR_pciconfig_iobase 376 +#define __NR_getdents64 377 +#define __NR_gettid 378 +#define __NR_readahead 379 +#define __NR_security 380 /* syscall for security modules */ +#define __NR_tkill 381 +#define __NR_setxattr 382 +#define __NR_lsetxattr 383 +#define __NR_fsetxattr 384 +#define __NR_getxattr 385 +#define __NR_lgetxattr 386 +#define __NR_fgetxattr 387 +#define __NR_listxattr 388 +#define __NR_llistxattr 389 +#define __NR_flistxattr 390 +#define __NR_removexattr 391 +#define __NR_lremovexattr 392 +#define __NR_fremovexattr 393 +#define __NR_futex 394 +#define __NR_sched_setaffinity 395 +#define __NR_sched_getaffinity 396 +#define __NR_tuxcall 397 +#define __NR_io_setup 398 +#define __NR_io_destroy 399 +#define __NR_io_getevents 400 +#define __NR_io_submit 401 +#define __NR_io_cancel 402 +#define __NR_alloc_hugepages 403 +#define __NR_free_hugepages 404 +#define __NR_exit_group 405 +#define __NR_lookup_dcookie 406 +#define __NR_sys_epoll_create 407 +#define __NR_sys_epoll_ctl 408 +#define __NR_sys_epoll_wait 409 +#define __NR_remap_file_pages 410 +#define __NR_set_tid_address 411 + +#define syscall_weak(name,wsym,sym) \ +.text ; \ +.align 2 ; \ +.weak wsym; \ +.type wsym,@function ; \ +wsym: ; \ +.global sym ; \ +.type sym,@function ; \ +sym: ; \ + lda $0, __NR_##name($31) ; \ + br __unified_syscall + +#define syscall(name,sym) \ +.text ; \ +.align 2 ; \ +.global sym ; \ +.type sym,@function ; \ +sym: ; \ + lda $0, __NR_##name($31) ; \ + br __unified_syscall + diff --git a/mdk-stage1/dietlibc/i386/PIC.h b/mdk-stage1/dietlibc/i386/PIC.h new file mode 100644 index 000000000..45ddeb446 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/PIC.h @@ -0,0 +1,82 @@ +#ifndef __I386_PIC_H__ +#define __I386_PIC_H__ +#ifdef __DYN_LIB + +#if 1 +/* don't trash the athlon return stack */ +.text +.Lgetpic: + mov (%esp),%ebx + ret + +.macro PIC_INIT + call .Lgetpic + addl $_GLOBAL_OFFSET_TABLE_, %ebx +.endm +#else +/* standard code for PIC init */ +.macro PIC_INIT + call 0f +0: popl %ebx + addl $_GLOBAL_OFFSET_TABLE_+[.-0b], %ebx +.endm +#endif + +#define PIC_SAVE pushl %ebx +#define PIC_RESTORE popl %ebx + + +/* get memory variable (var) in register (reg) */ +.macro GET_VAR var reg + movl \var@GOT(%ebx), \reg + movl (\reg), \reg +.endm + +/* put register (reg) into memory variable (var) TRASH register (tmp) */ +.macro PUT_VAR reg var tmp + movl \var@GOT(%ebx), \tmp + movl \reg, (\tmp) +.endm + +/* get memory variable (var) in register (reg) + * IF no more PIC-code is needed */ +.macro GET_1VAR var reg + PIC_SAVE + PIC_INIT + GET_VAR \var, \reg + PIC_RESTORE +.endm + +/* put register (reg) into memory variable (var) + * IF no more PIC-code is needed */ +.macro PUT_1VAR reg var + PIC_SAVE + PIC_INIT + PUT_VAR \reg, \var, %ebx + PIC_RESTORE +.endm + +#else + +#define PIC_SAVE +#define PIC_RESTORE +#define PIC_INIT + +.macro GET_VAR var reg + movl \var, \reg +.endm + +.macro PUT_VAR reg var tmp + movl \reg, \var +.endm + +.macro GET_1VAR var reg + GET_VAR \var, \reg +.endm + +.macro PUT_1VAR reg var + PUT_VAR \reg, \var, none +.endm + +#endif +#endif diff --git a/mdk-stage1/dietlibc/i386/__half.S b/mdk-stage1/dietlibc/i386/__half.S new file mode 100644 index 000000000..6355c93e4 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/__half.S @@ -0,0 +1,10 @@ +# +# Definiert Konstante (float)0.5 unter dem Namen __half +# Wird von etlichen Funktionen benutzt (sinh, cosh, atanh) +# + +.global __half +.data +.type __half,@object +.size __half,4 +__half: .long 0x3f000000 diff --git a/mdk-stage1/dietlibc/i386/__ten.S b/mdk-stage1/dietlibc/i386/__ten.S new file mode 100644 index 000000000..47b9431f4 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/__ten.S @@ -0,0 +1,9 @@ +# +# Definiert Konstante (float)10. unter dem Namen __ten +# + +.global __ten +.data +.type __ten,@object +.size __ten,4 +__ten: .long 0x41200000 diff --git a/mdk-stage1/dietlibc/i386/accept.S b/mdk-stage1/dietlibc/i386/accept.S new file mode 100644 index 000000000..d8be36a54 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/accept.S @@ -0,0 +1,4 @@ +#include +#include + +__socketcall(accept,ACCEPT) diff --git a/mdk-stage1/dietlibc/i386/acos.S b/mdk-stage1/dietlibc/i386/acos.S new file mode 100644 index 000000000..baabf9f04 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/acos.S @@ -0,0 +1,30 @@ + +.text + +.global acosf,acos,acosl # ,__acos + .type acosf,@function + .type acos,@function + .type acosl,@function +# .type __acos,@function +acosf: + flds 4(%esp) + jmp __acos +acosl: + fldt 4(%esp) + jmp __acos +acos: + fldl 4(%esp) +__acos: + fld %st + fmul %st + fld1 + fsubp + fsqrt + fxch %st(1) + fpatan + ret + +.ende: +.size acos,.ende-acos +.size acosf,.ende-acosf +.size acosl,.ende-acosl diff --git a/mdk-stage1/dietlibc/i386/acosh.S b/mdk-stage1/dietlibc/i386/acosh.S new file mode 100644 index 000000000..0611c9d31 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/acosh.S @@ -0,0 +1,18 @@ +.text +.global acosh +.type acosh,@function + +acosh: + fldln2 + fldl 4(%esp) + fld %st(0) + fmul %st(0),%st(0) + fld1 + fsubrp %st(0),%st(1) + fsqrt + faddp %st(0),%st(1) + fyl2x + ret + +.Lende: + .size acosh,.Lende-acosh diff --git a/mdk-stage1/dietlibc/i386/asin.S b/mdk-stage1/dietlibc/i386/asin.S new file mode 100644 index 000000000..7b0c31407 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/asin.S @@ -0,0 +1,29 @@ + +.text + +.global asinf,asin,asinl # ,__asin + .type asinf,@function + .type asin,@function + .type asinl,@function +# .type __asin,@function +asinf: + flds 4(%esp) + jmp __asin +asinl: + fldt 4(%esp) + jmp __asin +asin: + fldl 4(%esp) +__asin: + fld %st + fmul %st + fld1 + fsubp + fsqrt + fpatan + ret + +.ende: +.size asin,.ende-asin +.size asinf,.ende-asinf +.size asinl,.ende-asinl diff --git a/mdk-stage1/dietlibc/i386/asinh.S b/mdk-stage1/dietlibc/i386/asinh.S new file mode 100644 index 000000000..8c3964392 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/asinh.S @@ -0,0 +1,18 @@ +.text +.global asinh +.type asinh,@function + +asinh: + fldln2 + fldl 4(%esp) + fld %st(0) + fmul %st(0),%st(0) + fld1 + faddp %st(0),%st(1) + fsqrt + faddp %st(0),%st(1) + fyl2x + ret + +.Lende: + .size asinh,.Lende-asinh diff --git a/mdk-stage1/dietlibc/i386/atan.S b/mdk-stage1/dietlibc/i386/atan.S new file mode 100644 index 000000000..76513f928 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/atan.S @@ -0,0 +1,27 @@ + +.text + +.global atanf,atan,atanl + .type atanf,@function + .type atan,@function + .type atanl,@function +atanf: + flds 4(%esp) + fld1 + fpatan + ret +atan: + fldl 4(%esp) + fld1 + fpatan + ret +atanl: + fldt 4(%esp) + fld1 + fpatan + ret + +.ende: +.size atan,.ende-atan +.size atanf,.ende-atanf +.size atanl,.ende-atanl diff --git a/mdk-stage1/dietlibc/i386/atan2.S b/mdk-stage1/dietlibc/i386/atan2.S new file mode 100644 index 000000000..acf6e03ae --- /dev/null +++ b/mdk-stage1/dietlibc/i386/atan2.S @@ -0,0 +1,12 @@ + +.text +.type atan2,@function +.global atan2 +atan2: + fldl 4(%esp) + fldl 12(%esp) + fpatan + ret + +.ende: +.size atan2,.ende-atan2 diff --git a/mdk-stage1/dietlibc/i386/atanh.S b/mdk-stage1/dietlibc/i386/atanh.S new file mode 100644 index 000000000..b75f0fa8e --- /dev/null +++ b/mdk-stage1/dietlibc/i386/atanh.S @@ -0,0 +1,19 @@ +.text +.global atanh +.type atanh,@function + +atanh: + fldln2 + fldl 4(%esp) + fld1 + fld %st(1) + fadd %st(1),%st(0) + fxch %st(1) + fsubp %st(0),%st(2) + fdivp %st(0),%st(1) + fyl2x + fmuls __half + ret + +.Lende: + .size atanh,.Lende-atanh diff --git a/mdk-stage1/dietlibc/i386/atol.S b/mdk-stage1/dietlibc/i386/atol.S new file mode 100644 index 000000000..5bd7f2c24 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/atol.S @@ -0,0 +1,55 @@ +/* + Copyright (C) 2001, 2002 Thomas M. Ogrisegg + + This is free software. You can redistribute and + modify it under the terms of the GNU General Public + Public License. + + atol.S + i386 assembler implementation of atoi(3) & atol(3) +*/ + +.text +.globl atoi +.globl atol +.type atoi,@function +.type atol,@function + +atoi: +atol: + pushl %esi + movl 0x8(%esp), %esi + xorl %eax, %eax + xorl %edx, %edx + xorb %cl, %cl +.LSpace: + lodsb + cmpb $0x21, %al + jng .LSpace + cmpb $'+', %al + jz .Lfe5 + cmpb $'-', %al + jnz .Lfe3 + inc %cl + jmp .Lfe5 +.Lfe2: + imul $0xa, %edx + addl %eax, %edx +.Lfe5: + lodsb +.Lfe3: + cmpb $47, %al + jng .Lout + subb $('0'), %al + cmpb $9, %al + jng .Lfe2 +.Lout: + movl %edx, %eax + or %cl, %cl + jz .Lreturn + negl %eax +.Lreturn: + popl %esi + ret +.size atoi, . - atoi +.size atol, . - atol diff --git a/mdk-stage1/dietlibc/i386/atoll.S b/mdk-stage1/dietlibc/i386/atoll.S new file mode 100644 index 000000000..093bf762a --- /dev/null +++ b/mdk-stage1/dietlibc/i386/atoll.S @@ -0,0 +1,64 @@ + +.text +.type atoll,@function +.global atoll + +atoll: + movl 4(%esp),%ecx + push %edi + + xorl %edi,%edi # sign = 0 + + decl %ecx +.Lspaces: + incl %ecx # while ( isspace(*p) ) p++; + movb (%ecx),%al + cmpb $' ',%al + je .Lspaces + subb $9,%al + cmpb $5,%al + jc .Lspaces # c = *p - 9; + + cmpb $'+'-9,%al # if ( c == '+' - 9 ) p++; + je .Lpos + cmpb $'-'-9,%al # else if ( c == '-' - 9 ) sign = -sign, p++; + jne .Lnosign + decl %edi +.Lpos: incl %ecx +.Lnosign: + + push %ebx + push %esi + push %ebp + movl $10,%ebp + + xorl %esi,%esi # Hi(value) = 0; + xorl %eax,%eax # Lo(value) = 0; +.Lcont: movzbl (%ecx),%ebx # while ( (unsigned) (*p - '0') < 10 ) + inc %ecx + subl $'0',%ebx + cmpl %ebp,%ebx + jnc .Lfini + imull %ebp,%esi # value *= 10, + mull %ebp + addl %edx,%esi + addl %ebx,%eax # value += (*p - '0'); + adcl $0,%esi + jmp .Lcont + +.Lfini: xchg %edx,%esi # return sign== 0 ? +value + xorl %edi,%eax # sign==-1 ? -value + xorl %edi,%edx + subl %edi,%eax + sbbl %edi,%edx + + pop %ebp + pop %esi + pop %ebx + pop %edi + ret + +.Lende: + +.size atoll,.Lende-atoll + diff --git a/mdk-stage1/dietlibc/i386/bind.S b/mdk-stage1/dietlibc/i386/bind.S new file mode 100644 index 000000000..caff9bb8b --- /dev/null +++ b/mdk-stage1/dietlibc/i386/bind.S @@ -0,0 +1,4 @@ +#include +#include + +__socketcall(bind,BIND) diff --git a/mdk-stage1/dietlibc/i386/cbrt.S b/mdk-stage1/dietlibc/i386/cbrt.S new file mode 100644 index 000000000..9d8aebd1e --- /dev/null +++ b/mdk-stage1/dietlibc/i386/cbrt.S @@ -0,0 +1,46 @@ +.text + +tab: .byte 0, 0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4 + .byte 4, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9 + .byte 10,10,11,11,12,12,12,13,13,14,14,14,15,15,15,16 + +_3: .long 0x40400000 + + +.global cbrt +cbrt: + fldl 4(%esp) + movw 10(%esp),%ax + movb %ah,%ch + andw $0x7FFF,%ax + jz zero /* cbrt(0) = 0 */ + pushl %ebx + cwd + movl $16*3,%ebx /* AX 3FE0 3FF0 4000 4010 */ + divw %bx /* AX 154 155 155 155 */ + /* DX 20 0 10 20 */ + shlw $5,%ax + addb %ch,%ch + rcrw %ax /* AX 1540 1550 1550 1550 */ + addw $0x3FF0-0x1550,%ax /* AX 3FE0 3FF0 3FF0 3FF0 */ + movw %dx,%bx + addb tab(%ebx),%al + adcb $0,%ah + popl %ebx + movw %ax,10(%esp) + fldl 4(%esp) /* y x */ + + movl $4,%ecx +lop: + fld %st(0) /* y y x */ + fmul %st(0),%st(0) /* y^2 y x */ + fdivr %st(2),%st(0) /* x/y^2 y x */ + fadd %st(1),%st(0) /* x/y^2+y y x */ + faddp /* x/y^2+2y x */ + fdivs _3 /* y' x */ + loop lop + + fstp %st(1) /* y' */ +zero: + ret + diff --git a/mdk-stage1/dietlibc/i386/ceil.S b/mdk-stage1/dietlibc/i386/ceil.S new file mode 100644 index 000000000..e6a4e989c --- /dev/null +++ b/mdk-stage1/dietlibc/i386/ceil.S @@ -0,0 +1,44 @@ +.text + +.global ceilf,ceil,ceill,__flcetr + .type ceilf,@function + .type ceil,@function + .type ceill,@function + .type __flcetr,@function + +ceilf: + flds 4(%esp) + movb $0x08,%ah + jmp __flcetr + +ceill: + fldt 4(%esp) + movb $0x08,%ah + jmp __flcetr + +ceil: + fldl 4(%esp) + movb $0x08,%ah + +# Wspolny kod dla funkcji floor, ceil i trunc +# W ah maska bitow 11 i 10 rejestru sterowania koprocesora +__flcetr: + xorl %ecx,%ecx # wyzerowanie rejestru + movb %ah,%ch # i utworzenie maski w cx + pushl %eax # krotsze niz subl $4,%esp + fstcw (%esp) + movw (%esp),%ax + andb $0x03,%ah # wyzerowanie bitow 11 i 10 + orl %ecx,%eax # ustawienie bitow z maski + movw %ax,2(%esp) + fldcw 2(%esp) + frndint + fldcw (%esp) # odtworzenie rejestru sterowania + popl %eax # i polozenia stosu + ret + +.Lende: +.size ceil,.Lende-ceil +.size ceill,.Lende-ceill +.size ceilf,.Lende-ceilf +.size flcetr,.Lende-__flcetr diff --git a/mdk-stage1/dietlibc/i386/connect.S b/mdk-stage1/dietlibc/i386/connect.S new file mode 100644 index 000000000..a295a8814 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/connect.S @@ -0,0 +1,4 @@ +#include +#include + +__socketcall(connect,CONNECT) diff --git a/mdk-stage1/dietlibc/i386/copysign.S b/mdk-stage1/dietlibc/i386/copysign.S new file mode 100644 index 000000000..3a495efee --- /dev/null +++ b/mdk-stage1/dietlibc/i386/copysign.S @@ -0,0 +1,18 @@ + +.text +.type copysign,@function +.global copysign + +# double copysign ( double value, double sign ); + +copysign: + movb 12+7(%esp),%al + movb 4+7(%esp),%ah + andw $0x7F80,%ax + orb %ah,%al + movb 4+7(%esp),%al + fldl 4(%esp) + ret + +.ende: +.size copysign,.ende-copysign diff --git a/mdk-stage1/dietlibc/i386/cos.S b/mdk-stage1/dietlibc/i386/cos.S new file mode 100644 index 000000000..f95c81ca7 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/cos.S @@ -0,0 +1,35 @@ +.text + +.global cosf,cos,cosl +.type cosf,@function +.type cos,@function +.type cosl,@function + +cosf: + flds 4(%esp) + jmp 1f +cos: + fldl 4(%esp) +1: + fcos + fnstsw %ax + testb $0x04, %ah + je 3f + fldpi + fadd %st + fxch %st(1) +2: fprem1 + fnstsw %ax + testb $0x04, %ah + jne 2b + fstp %st(1) + fcos +3: ret +cosl: + fldt 4(%esp) + jmp 1b + +.Lende: +.size cos,.Lende-cos +.size cosl,.Lende-cosl +.size cosf,.Lende-cosf diff --git a/mdk-stage1/dietlibc/i386/cosh.S b/mdk-stage1/dietlibc/i386/cosh.S new file mode 100644 index 000000000..f6a33704d --- /dev/null +++ b/mdk-stage1/dietlibc/i386/cosh.S @@ -0,0 +1,29 @@ + +.text +.type cosh,@function +.global cosh + +cosh: # note: exp(x) = 2^(x*log2(e)) + fldl2e + fmull 4(%esp) # x*log2(e) + fld %st(0) # x*log2(e) x*log2(e) + frndint # int(x*log2(e)) x*log2(e) + fxch # x*log2(e) int(x*log2(e)) + fsub %st(1),%st(0) # frac(x*log2(e)) int(x*log2(e)) + f2xm1 # 2^(fract(x*log2(e)))-1 int(x*log2(e)) + fld1 # 1 2^(fract(x*log2(e)))-1 int(x*log2(e)) + faddp %st(0),%st(1) # 2^(fract(x*log2(e))) int(x*log2(e)) + fscale # 2^(x*log2(e)) int(x*log2(e)) + fstp %st(1) # 2^(x*log2(e)) + +# now we have y = exp(x), but cosh(x) = (y + 1/y) * 0.5 + + fld1 + fdiv %st(1),%st(0) + faddp + fmuls __half + ret + +.Lende: + +.size cosh,.ende-cosh diff --git a/mdk-stage1/dietlibc/i386/dyn_syscalls.S b/mdk-stage1/dietlibc/i386/dyn_syscalls.S new file mode 100644 index 000000000..c4fd2fff5 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/dyn_syscalls.S @@ -0,0 +1,282 @@ +/* + * dynamic unified-syscalls + * Olaf Dreesen + */ + +#include "../syscalls.s/environ.S" +#include "../syscalls.s/errno.S" + +#include +#include "syscalls.h" +#include "PIC.h" + +/* ok now include all syscalls.s (*.S) and sysdep *.S */ + +#include "mmap.S" + +/* here on i386 I had split them some pre- some post-unified-syscall, + * because the jumps pre-u.s.c. have only a 1 byte displacement. the first + * post-u.s.c. have also 1 byte dsplacement the rest a 4 byte. + * this pre/post split saves about 250 byte of code .... + * + * Please put additional syscalls AFTER the post-u.s.c. + * or try to not break the savings :) */ + +#include "select.S" + +#include "../syscalls.s/fork.S" +#include "../syscalls.s/read.S" +#include "../syscalls.s/write.S" +#include "../syscalls.s/open.S" +#include "../syscalls.s/close.S" +#include "../syscalls.s/waitpid.S" + +#include "../syscalls.s/getgid.S" +#include "../syscalls.s/getpgid.S" +#include "../syscalls.s/getpid.S" +#include "../syscalls.s/getppid.S" +#include "../syscalls.s/getuid.S" +#include "../syscalls.s/kill.S" +#include "../syscalls.s/ioctl.S" +#include "../syscalls.s/_llseek.S" +#include "../syscalls.s/lseek.S" +#include "../syscalls.s/lstat.S" +#include "../syscalls.s/lstat64.S" +#include "../syscalls.s/mkdir.S" +#include "../syscalls.s/mprotect.S" +#include "../syscalls.s/nanosleep.S" +#include "../syscalls.s/pipe.S" +#include "../syscalls.s/poll.S" +#include "../syscalls.s/readv.S" +#include "../syscalls.s/stat.S" +#include "../syscalls.s/stat64.S" +#include "../syscalls.s/truncate.S" +#include "../syscalls.s/umask.S" +#include "../syscalls.s/wait4.S" +#include "../syscalls.s/writev.S" +#include "../syscalls.s/__getpagesize.S" + +/* OK this is basicaly unified.S */ +.text +.type __unified_syscall_256,@function +__unified_syscall_256: + movzwl %ax, %eax + jmp .L23 +.L22: +.size __unified_syscall_256,.L22-__unified_syscall_256 +.type exit,@function +.weak exit +exit: +.type _exit,@function +.global _exit +_exit: +__exit: + mov $__NR_exit, %al +__unified_syscall: + movzbl %al, %eax +.L23: + push %edi + push %esi + push %ebx + movl %esp,%edi + movl 0x10(%edi),%ebx + movl 0x14(%edi),%ecx + movl 0x18(%edi),%edx + movl 0x1c(%edi),%esi + movl 0x20(%edi),%edi + int $0x80 + cmp $-124,%eax + jbe .Lnoerror + neg %eax + + /* PIC-code Ohhhhh My. */ + push %eax + PIC_INIT + call __errno_location@PLT + popl %ebx + movl %ebx,(%eax) + orl $-1,%eax +.Lnoerror: + pop %ebx + pop %esi + pop %edi +#include "dietuglyweaks.h" + ret + +#include "../syscalls.s/__pread.S" +#include "../syscalls.s/__pwrite.S" +#include "../syscalls.s/__reboot.S" +#include "../syscalls.s/access.S" +#include "../syscalls.s/adjtimex.S" +#include "../syscalls.s/brk.S" +#include "../syscalls.s/chdir.S" +#include "../syscalls.s/chmod.S" +#include "../syscalls.s/chown.S" +#include "../syscalls.s/chroot.S" +#include "../syscalls.s/dup.S" +#include "../syscalls.s/dup2.S" +#include "../syscalls.s/execve.S" +#include "../syscalls.s/fchdir.S" +#include "../syscalls.s/fchmod.S" +#include "../syscalls.s/fchown.S" +#include "../syscalls.s/fcntl.S" +#include "../syscalls.s/flock.S" +#include "../syscalls.s/fstat.S" +#include "../syscalls.s/fstat64.S" +#include "../syscalls.s/fstatfs.S" +#include "../syscalls.s/fsync.S" +#include "../syscalls.s/fdatasync.S" +#include "../syscalls.s/ftruncate.S" +#include "../syscalls.s/getcwd.S" +#include "../syscalls.s/getdents.S" +#include "../syscalls.s/getdents64.S" +#include "../syscalls.s/getegid.S" +#include "../syscalls.s/geteuid.S" +#include "../syscalls.s/getgroups.S" +#include "../syscalls.s/getitimer.S" +#include "../syscalls.s/getpriority.S" +#include "../syscalls.s/getresgid.S" +#include "../syscalls.s/getresuid.S" +#include "../syscalls.s/getrlimit.S" +#include "../syscalls.s/getrusage.S" +#include "../syscalls.s/getsid.S" +#include "../syscalls.s/gettimeofday.S" +#include "../syscalls.s/ioperm.S" +#include "../syscalls.s/iopl.S" +#include "../syscalls.s/ipc.S" +#include "../syscalls.s/lchown.S" +#include "../syscalls.s/link.S" +#include "../syscalls.s/mknod.S" +#include "../syscalls.s/mlock.S" +#include "../syscalls.s/mlockall.S" +#include "../syscalls.s/mount.S" +#include "../syscalls.s/mremap.S" +#include "../syscalls.s/munlockall.S" +#include "../syscalls.s/munmap.S" +#include "../syscalls.s/n_sigaction.S" +#include "../syscalls.s/n_sigpending.S" +#include "../syscalls.s/n_sigprocmask.S" +#include "../syscalls.s/n_sigsuspend.S" +#include "../syscalls.s/nice.S" +#include "../syscalls.s/pause.S" +#include "../syscalls.s/personality.S" +#include "../syscalls.s/query_module.S" +#include "../syscalls.s/init_module.S" +#include "../syscalls.s/delete_module.S" +#include "../syscalls.s/create_module.S" +#include "../syscalls.s/readlink.S" +#include "../syscalls.s/rename.S" +#include "../syscalls.s/rmdir.S" +#include "../syscalls.s/rt_sigaction.S" +#include "../syscalls.s/rt_sigpending.S" +#include "../syscalls.s/rt_sigprocmask.S" +#include "../syscalls.s/rt_sigqueueinfo.S" +#include "../syscalls.s/rt_sigsuspend.S" +#include "../syscalls.s/rt_sigtimedwait.S" +#include "../syscalls.s/sched_get_priority_max.S" +#include "../syscalls.s/sched_get_priority_min.S" +#include "../syscalls.s/sched_getparam.S" +#include "../syscalls.s/sched_getscheduler.S" +#include "../syscalls.s/sched_rr_get_interval.S" +#include "../syscalls.s/sched_setparam.S" +#include "../syscalls.s/sched_setscheduler.S" +#include "../syscalls.s/sched_yield.S" +#include "../syscalls.s/sendfile.S" +#include "../syscalls.s/setdomainname.S" +#include "../syscalls.s/setfsgid.S" +#include "../syscalls.s/setfsuid.S" +#include "../syscalls.s/setgid.S" +#include "../syscalls.s/setgroups.S" +#include "../syscalls.s/sethostname.S" +#include "../syscalls.s/setitimer.S" +#include "../syscalls.s/setpgid.S" +#include "../syscalls.s/setpriority.S" +#include "../syscalls.s/setregid.S" +#include "../syscalls.s/setresgid.S" +#include "../syscalls.s/setresuid.S" +#include "../syscalls.s/setreuid.S" +#include "../syscalls.s/setrlimit.S" +#include "../syscalls.s/setsid.S" +#include "../syscalls.s/setuid.S" +#include "../syscalls.s/sigaltstack.S" +#include "../syscalls.s/statfs.S" +#include "../syscalls.s/stime.S" +#include "../syscalls.s/swapoff.S" +#include "../syscalls.s/swapon.S" +#include "../syscalls.s/symlink.S" +#include "../syscalls.s/sync.S" +#include "../syscalls.s/sysctl.S" +#include "../syscalls.s/sysinfo.S" +#include "../syscalls.s/syslog.S" +#include "../syscalls.s/time.S" +#include "../syscalls.s/times.S" +#include "../syscalls.s/umount.S" +#include "../syscalls.s/umount2.S" +#include "../syscalls.s/uname.S" +#include "../syscalls.s/unlink.S" +#include "../syscalls.s/utime.S" +#include "../syscalls.s/vhangup.S" + +#include "../syscalls.s/chown32.S" +#include "../syscalls.s/fchown32.S" +#include "../syscalls.s/getegid32.S" +#include "../syscalls.s/geteuid32.S" +#include "../syscalls.s/getgid32.S" +#include "../syscalls.s/getgroups32.S" +#include "../syscalls.s/getresgid32.S" +#include "../syscalls.s/getuid32.S" +#include "../syscalls.s/lchown32.S" +#include "../syscalls.s/setfsgid32.S" +#include "../syscalls.s/setfsuid32.S" +#include "../syscalls.s/setgid32.S" +#include "../syscalls.s/setregid32.S" +#include "../syscalls.s/setresgid32.S" +#include "../syscalls.s/setreuid32.S" +#include "../syscalls.s/setuid32.S" +#include "../syscalls.s/alarm.S" +#include "../syscalls.s/ptrace.S" +#include "../syscalls.s/truncate64.S" +#include "../syscalls.s/ftruncate64.S" +#include "../syscalls.s/epoll_create.S" +#include "../syscalls.s/epoll_ctl.S" +#include "../syscalls.s/epoll_wait.S" + +#undef __PIC__ +#undef __socketcall +/* oh what a kludge! */ +#define socketcall .Lsocketcall +#include "../i386/send.S" +#include "../i386/recv.S" +#include "../i386/socket.S" +#include "../i386/accept.S" +#include "../i386/shutdown.S" +#include "../i386/socketpair.S" +#include "../i386/setsockopt.S" +#include "../i386/sendto.S" +#include "../i386/sendmsg.S" +#include "../i386/recvmsg.S" +#include "../i386/recvfrom.S" +#include "../i386/listen.S" +#include "../i386/getsockopt.S" +#include "../i386/getsockname.S" +#include "../i386/getpeername.S" +#include "../i386/connect.S" +#include "../i386/bind.S" +#undef socketcall +.Lsocketcall: +#include "../i386/socketcall.S" +#define __PIC__ +#undef __socketcall + + +/* so now this was the last u.s.c. */ + +/* other asm-files ... */ +#define PIC + +#define _exit __exit +#include "clone.S" +#undef _exit + +#include "__longjmp.S" +#include "setjmp.S" diff --git a/mdk-stage1/dietlibc/i386/exp.S b/mdk-stage1/dietlibc/i386/exp.S new file mode 100644 index 000000000..6c82128e4 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/exp.S @@ -0,0 +1,35 @@ +.text + +.global expf,exp,expl,__finexp + .type expf,@function + .type exp,@function + .type expl,@function + .type __finexp,@function +expf: + fldl2e + fmuls 4(%esp) + jmp __finexp +expl: + fldl2e + fldt 4(%esp) + fmulp + jmp __finexp +exp: + fldl2e + fmull 4(%esp) +__finexp: + fst %st(1) + frndint + fst %st(2) + fsubrp + f2xm1 + fld1 + faddp + fscale + ret + +.Lende: +.size exp,.Lende-exp +.size expl,.Lende-expl +.size expf,.Lende-expf +.size __finexp,.Lende-__finexp diff --git a/mdk-stage1/dietlibc/i386/exp10.S b/mdk-stage1/dietlibc/i386/exp10.S new file mode 100644 index 000000000..6223e5f85 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/exp10.S @@ -0,0 +1,27 @@ + +.text +.type exp10,@function +.global exp10 +.type pow10,@function +.global pow10 + + +pow10: +exp10: # note: 10^(x) = 2^(x*log2(10)) + fldl2t + fmull 4(%esp) # x*log2(10) + fld %st(0) # x*log2(10) x*log2(10) + frndint # int(x*log2(10)) x*log2(10) + fxch # x*log2(10) int(x*log2(10)) + fsub %st(1),%st(0) # frac(x*log2(10)) int(x*log2(10)) + f2xm1 # 2^(fract(x*log2(10)))-1 int(x*log2(10)) + fld1 # 1 2^(fract(x*log2(10)))-1 int(x*log2(10)) + faddp %st(0),%st(1) # 2^(fract(x*log2(10))) int(x*log2(10)) + fscale # 2^(x*log2(10)) int(x*log2(10)) + fstp %st(1) # 2^(x*log2(10)) + ret + +.ende: + +.size exp10,.ende-exp10 +.size pow10,.ende-pow10 diff --git a/mdk-stage1/dietlibc/i386/exp2.S b/mdk-stage1/dietlibc/i386/exp2.S new file mode 100644 index 000000000..d5389a22e --- /dev/null +++ b/mdk-stage1/dietlibc/i386/exp2.S @@ -0,0 +1,18 @@ +.text +.type exp2,@function +.global exp2 +exp2: # note: exp2(x) = 2^x + fldl 4(%esp) # x + fld %st(0) # x x + frndint # int(x) x + fxch # x int(x) + fsub %st(1),%st(0) # frac(x) int(x) + f2xm1 # 2^(fract(x))-1 int(x) + fld1 # 1 2^(fract(x))-1 int(x) + faddp %st(0),%st(1) # 2^(fract(x)) int(x) + fscale # 2^x int(x) + fstp %st(1) # 2^x + ret + +.ende: +.size exp2,.ende-exp2 diff --git a/mdk-stage1/dietlibc/i386/expm1.S b/mdk-stage1/dietlibc/i386/expm1.S new file mode 100644 index 000000000..677f4723f --- /dev/null +++ b/mdk-stage1/dietlibc/i386/expm1.S @@ -0,0 +1,23 @@ +.text +.type expm1,@function +.global expm1 +expm1: # note: exp(x) = 2^(x*log2(e)) + fldl2e + fmull 4(%esp) # x*log2(e) + fld %st(0) # x*log2(e) x*log2(e) + frndint # int(x*log2(e)) x*log2(e) + fxch # x*log2(e) int(x*log2(e)) + fsub %st(1),%st(0) # frac(x*log2(e)) int(x*log2(e)) + f2xm1 # 2^(fract(x*log2(e)))-1 int(x*log2(e)) + fscale # 2^(x*log2(e))-2^int(x*log2(e)) int(x*log2(e)) + fxch # int(x*log2(e)) 2^(x*log2(e))-2^int(x*log2(e)) + fld1 # 1 int(x*log2(e)) 2^(x*log2(e))-2^int(x*log2(e)) + fscale # 2^int(x*log2(e)) int(x*log2(e)) 2^(x*log2(e))-2^int(x*log2(e)) + fstp %st(1) # 2^int(x*log2(e)) 2^(x*log2(e))-2^int(x*log2(e)) + fld1 # 1 2^int(x*log2(e)) 2^(x*log2(e))-2^int(x*log2(e)) + fsubrp %st(1) # 2^int(x*log2(e))-1 2^(x*log2(e))-2^int(x*log2(e)) + faddp %st(1) + ret + +.ende: +.size expm1,.ende-expm1 diff --git a/mdk-stage1/dietlibc/i386/fabs.S b/mdk-stage1/dietlibc/i386/fabs.S new file mode 100644 index 000000000..d9c1c2212 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/fabs.S @@ -0,0 +1,11 @@ + +.text +.type fabs,@function +.global fabs +fabs: + fldl 4(%esp) + fabs + ret + +.ende: +.size fabs,.ende-fabs diff --git a/mdk-stage1/dietlibc/i386/floor.S b/mdk-stage1/dietlibc/i386/floor.S new file mode 100644 index 000000000..af26d0c94 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/floor.S @@ -0,0 +1,26 @@ +.text + +.global floorf,floor,floorl + .type floorf,@function + .type floor,@function + .type floorf,@function + +floorf: + flds 4(%esp) + movb $0x04,%ah + jmp __flcetr + +floor: + fldl 4(%esp) + movb $0x04,%ah + jmp __flcetr + +floorl: + fldt 4(%esp) + movb $0x04,%ah + jmp __flcetr + +.Lende: +.size floor,.Lende-floor +.size floorl,.Lende-floorl +.size floorf,.Lende-floorf diff --git a/mdk-stage1/dietlibc/i386/fmod.S b/mdk-stage1/dietlibc/i386/fmod.S new file mode 100644 index 000000000..5bf4c06ab --- /dev/null +++ b/mdk-stage1/dietlibc/i386/fmod.S @@ -0,0 +1,37 @@ +.text +.type fmod,@function +.type fmodf,@function +.type fmodl,@function +.type __fmod2pi,@function +.global fmod, fmodl, fmodf, __fmod2pi + +__fmod2pi: + fldpi + fadd %st(0) + fxch + jmp .Lfmod + +fmodf: + flds 8(%esp) # y + flds 4(%esp) # x + jmp .Lfmod +fmod: + fldl 12(%esp) + fldl 4(%esp) +.Lfmod: + fprem + fstsw %ax + sahf + jp .Lfmod + ret + +fmodl: + fldt 16(%esp) + fldt 4(%esp) + jmp .Lfmod + + +.ende: +.size fmod,.ende-fmod +.size fmodl,.ende-fmodl +.size fmodf,.ende-fmodf diff --git a/mdk-stage1/dietlibc/i386/getenv.S b/mdk-stage1/dietlibc/i386/getenv.S new file mode 100644 index 000000000..dafbf37ee --- /dev/null +++ b/mdk-stage1/dietlibc/i386/getenv.S @@ -0,0 +1,48 @@ +#include "PIC.h" + +.text +.global getenv +.type getenv,@function +getenv: + pushl %esi + pushl %edi + movl 0xc(%esp), %edi + cld + movl %edi, %edx + xorl %eax, %eax + leal -1(%eax), %ecx + repnz scasb + not %ecx + dec %ecx + pushl %ecx + movl (%edx), %ecx + + GET_1VAR environ, %esi # non-PIC: movl environ, %esi + jmp .Lloop + +.Lprepare: + movl (%edx), %ecx + movl %eax, %esi +.Lloop: + lodsl + or %eax, %eax + jz .Lout + cmpb %cl, (%eax) + jnz .Lloop + + movl %edx, %edi + xchg %esi, %eax + movl (%esp), %ecx + repz cmpsb + jne .Lprepare + or %ecx, %ecx + jnz .Lprepare + cmpb $'=', (%esi) + jne .Lprepare + leal 0x1(%esi), %eax +.Lout: + popl %ecx + popl %edi + popl %esi + ret +.size getenv, . - getenv diff --git a/mdk-stage1/dietlibc/i386/getpeername.S b/mdk-stage1/dietlibc/i386/getpeername.S new file mode 100644 index 000000000..833322941 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/getpeername.S @@ -0,0 +1,4 @@ +#include +#include + +__socketcall(getpeername,GETPEERNAME) diff --git a/mdk-stage1/dietlibc/i386/getsockname.S b/mdk-stage1/dietlibc/i386/getsockname.S new file mode 100644 index 000000000..f0618481c --- /dev/null +++ b/mdk-stage1/dietlibc/i386/getsockname.S @@ -0,0 +1,4 @@ +#include +#include + +__socketcall(getsockname,GETSOCKNAME) diff --git a/mdk-stage1/dietlibc/i386/getsockopt.S b/mdk-stage1/dietlibc/i386/getsockopt.S new file mode 100644 index 000000000..23d7c2470 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/getsockopt.S @@ -0,0 +1,4 @@ +#include +#include + +__socketcall(getsockopt,GETSOCKOPT) diff --git a/mdk-stage1/dietlibc/i386/htonl.S b/mdk-stage1/dietlibc/i386/htonl.S new file mode 100644 index 000000000..f3732d16a --- /dev/null +++ b/mdk-stage1/dietlibc/i386/htonl.S @@ -0,0 +1,13 @@ +.text +.global htonl +.type htonl,@function +.global ntohl +.type ntohl,@function + +htonl: +ntohl: + movl 4(%esp),%eax + xchgb %al,%ah + rorl $16,%eax + xchgb %al,%ah + ret diff --git a/mdk-stage1/dietlibc/i386/htons.S b/mdk-stage1/dietlibc/i386/htons.S new file mode 100644 index 000000000..367d6d03c --- /dev/null +++ b/mdk-stage1/dietlibc/i386/htons.S @@ -0,0 +1,11 @@ +.text +.global htons +.type htons,@function +.global ntohs +.type ntohs,@function + +htons: +ntohs: + movzwl 4(%esp),%eax + xchgb %al,%ah + ret diff --git a/mdk-stage1/dietlibc/i386/hypot.S b/mdk-stage1/dietlibc/i386/hypot.S new file mode 100644 index 000000000..730b2c5c9 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/hypot.S @@ -0,0 +1,15 @@ + +.text +.type hypot,@function +.global hypot +hypot: + fldl 4(%esp) + fmul %st(0),%st(0) + fldl 12(%esp) + fmul %st(0),%st(0) + faddp + fsqrt + ret + +.ende: +.size hypot,.ende-hypot diff --git a/mdk-stage1/dietlibc/i386/ilogb.S b/mdk-stage1/dietlibc/i386/ilogb.S new file mode 100644 index 000000000..3bebd88ba --- /dev/null +++ b/mdk-stage1/dietlibc/i386/ilogb.S @@ -0,0 +1,23 @@ +# +# int ilogb ( double x ); +# +# returns (int) log2 (fabs(x)) for x!=0 +# returns MIN_INT for x==0 +# + +.text +.global ilogb +.type ilogb,@function + +ilogb: + movl 8(%esp),%eax + addl %eax,%eax + jz .Lzero + shrl $21,%eax + subl $1023,%eax + ret + +.Lzero: + stc + rcrl %eax + ret diff --git a/mdk-stage1/dietlibc/i386/ipow.S b/mdk-stage1/dietlibc/i386/ipow.S new file mode 100644 index 000000000..cca6a0ce1 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/ipow.S @@ -0,0 +1,27 @@ +# +# This is not standard, but often you only need such this function +# which is much shorter than the generic pow() function. +# +# double ipow ( double mant, int expo ); +# + +.text +.global ipow +.type ipow,@function + +ipow: fld1 + movl 12(%esp),%ecx + fldl 4(%esp) + and %ecx,%ecx + jns .Lstart + negl %ecx + fdivr %st(1),%st(0) + jmp .Lstart + +.Lnext: fmul %st(0),%st(0) +.Lstart:shrl %ecx + jnc .Lnomul + fmul %st(0),%st(1) +.Lnomul:jnz .Lnext + fcomp + ret diff --git a/mdk-stage1/dietlibc/i386/isleap.S b/mdk-stage1/dietlibc/i386/isleap.S new file mode 100644 index 000000000..28d1ee0ce --- /dev/null +++ b/mdk-stage1/dietlibc/i386/isleap.S @@ -0,0 +1,28 @@ +.text +.globl __isleap +.type __isleap,@function + +__isleap: + movl 4(%esp),%eax + testb $3,%al + jne .Lretzero +#if 1 + movb $100,%cl /* this works only for 0 a.D. ... 25599 a.C. */ + divb %cl + andb %ah,%ah +#else + cltd /* This works for 2147483648 b.C. ... 2147483647 a.C. */ + movl $100,%ecx + divl %ecx + andl %edx,%edx +#endif + jne .Lretone + testb $3,%al + jne .Lretzero +.Lretone: xorl %eax,%eax + incl %eax + ret + +.Lretzero:xorl %eax,%eax + ret + diff --git a/mdk-stage1/dietlibc/i386/ldexp.S b/mdk-stage1/dietlibc/i386/ldexp.S new file mode 100644 index 000000000..51d9bae89 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/ldexp.S @@ -0,0 +1,28 @@ +.text +.global ldexpf,ldexp,ldexpl + .type ldexpf,@function + .type ldexp,@function + .type ldexpl,@function + +ldexpf: + fildl 8(%esp) + flds 4(%esp) + fscale + ret + +ldexp: + fildl 12(%esp) + fldl 4(%esp) + fscale + ret + +ldexpl: + fildl 16(%esp) + fldt 4(%esp) + fscale + ret + +.ende: +.size ldexpl,.ende-ldexpl +.size ldexp,ldexpl-ldexp +.size ldexpf,ldexp-ldexpf diff --git a/mdk-stage1/dietlibc/i386/libm2.S b/mdk-stage1/dietlibc/i386/libm2.S new file mode 100644 index 000000000..91c4437cd --- /dev/null +++ b/mdk-stage1/dietlibc/i386/libm2.S @@ -0,0 +1,643 @@ +.text +#d.half: +# .long 0x3f000000 # 1/2 +#d.log1p: +# .long 0x3ed413cc # < sqrt(2)-1-2^(-25) + +.global fabsf,fabs,fabsl + .type fabsf,@function + .type fabs,@function + .type fabsl,@function +fabsf: + flds 4(%esp) + fabs + ret +fabs: + fldl 4(%esp) + fabs + ret +fabsl: + fldt 4(%esp) + fabs + ret + +.global sincosf,sincos,sincosl +.type sincosf,@function +.type sincos,@function +.type sincosl,@function +# void sincos ( double x, double* sinx, double* cosx ); + +sincosf: + flds 4(%esp) + call __fmod2pi + movl 12(%esp),%eax + movl 8(%esp),%ecx + fsincos + fstps (%eax) + fstps (%ecx) + ret +sincos: + fldl 4(%esp) + call __fmod2pi + movl 16(%esp),%eax + movl 12(%esp),%ecx + fsincos + fstpl (%eax) + fstpl (%ecx) + ret +sincosl: + fldt 4(%esp) + call __fmod2pi + movl 20(%esp),%eax + movl 16(%esp),%ecx + fsincos + fstpt (%eax) + fstpt (%ecx) + ret + +.global tanf,tan,tanl +.type tanf,@function +.type tan,@function +.type tanl,@function +tanf: + flds 4(%esp) + jmp __tan +tan: + fldl 4(%esp) +__tan: + call __fmod2pi + fsincos + fdivrp + ret +tanl: + fldt 4(%esp) + jmp __tan + +.global atan2f,atan2,atan2l + .type atan2f,@function + .type atan2,@function + .type atan2l,@function +atan2f: + flds 4(%esp) + flds 8(%esp) + fpatan + ret +atan2l: + fldt 4(%esp) + fldt 16(%esp) + fpatan + ret +atan2: + fldl 4(%esp) + fldl 12(%esp) + fpatan + ret + +.global cbrtf,cbrt,cbrtl + .type cbrtf,@function + .type cbrt,@function + .type cbrtl,@function +cbrtf: + flds 4(%esp) + jmp __cbrt +cbrtl: + fldt 4(%esp) + jmp __cbrt +cbrt: + fldl 4(%esp) +# fldt 1/3 +__cbrt: + pushl $0x00003ffd # yes, this method of loading 1/3 + pushl $0xaaaaaaaa # is shorter than keeping the data + pushl $0xaaaaaaab # separate + fldt (%esp) + addl $12,%esp + fxch # st(0)=x, st(1)=1/3 + ftst + fstsw %ax + sahf + jz 1f + jnc finpow + fchs + call finpow + fchs +1: ret + +# x^y; st(0)=x, st(1)=y (x > 0) +finpow: + fyl2x + jmp __finexp + +.global exp2f,exp2,exp2l + .type exp2f,@function + .type exp2,@function + .type exp2l,@function +exp2f: + flds 4(%esp) + jmp __finexp +exp2: + fldl 4(%esp) + jmp __finexp +exp2l: + fldt 4(%esp) + jmp __finexp + +.global exp10f,exp10,exp10l #,pow10f,pow10,pow10l + .type exp10f,@function + .type exp10,@function + .type exp10l,@function +# .type pow10f,@function +# .type pow10,@function +# .type pow10l,@function +exp10f: +#pow10f: + fldl2t + fmuls 4(%esp) + jmp __finexp +exp10: +#pow10: + fldl2t + fmull 4(%esp) + jmp __finexp +exp10l: +#pow10l: + fldl2t + fldt 4(%esp) + fmulp + jmp __finexp + +# exp(x)-1 +.global expm1f,expm1,expm1l + .type expm1f,@function + .type expm1,@function + .type expm1l,@function +expm1f: + fldl2e + fmuls 4(%esp) + jmp finem1 +expm1l: + fldl2e + fldt 4(%esp) + fmulp + jmp finem1 +expm1: + fldl2e + fmull 4(%esp) +# -1 <= st <= 1 ? +finem1: + fst %st(1) # st(1)=st(0) + fabs + fld1 + fcompp + fstsw %ax + sahf +# |x| >= 1 + jc 1f + f2xm1 + ret +1: call __finexp + fld1 + fsubrp + ret + +# sinh(x)=(exp(x)-exp(-x))/2 +# cosh(x)=(exp(x)+exp(-x))/2 +# tanh(x)=sinh(x)/cosh(x) +.global sinhf,sinh,sinhl + .type sinhf,@function + .type sinh,@function + .type sinhl,@function +sinhf: + fldl2e + fmuls 4(%esp) + jmp finsinh +sinh: + fldl2e + fmull 4(%esp) +finsinh: + call __finexp + fld1 + fdiv %st(1),%st(0) # st(0)=1/exp(x), st(1)=exp(x) + fsubrp %st(0),%st(1) + pushl $0x3f000000 # 1/2 + flds (%esp) + popl %eax + fmulp + ret + +sinhl: + fldl2e + fldt 4(%esp) + fmulp + jmp finsinh + +.global coshf,cosh,coshl + .type coshf,@function + .type cosh,@function + .type coshl,@function +coshf: + fldl2e + fmuls 4(%esp) + jmp fincosh +cosh: + fldl2e + fmull 4(%esp) +fincosh: + call __finexp + fld1 + fdiv %st(1),%st(0) # st(0)=1/exp(x), st(1)=exp(x) + faddp %st,%st(1) + pushl $0x3f000000 # 1/2 + flds (%esp) + popl %eax + fmulp + ret + +coshl: + fldl2e + fldt 4(%esp) + fmulp + jmp fincosh + +.global tanhf,tanh,tanhl + .type tanhf,@function + .type tanh,@function + .type tanhl,@function +tanhf: + fldl2e + fmuls 4(%esp) + call __finexp + jmp fintanh +tanh: + fldl2e + fmull 4(%esp) + call __finexp +fintanh: + fld1 + fdiv %st(1),%st # st(0)=1/exp(x), st(1)=exp(x) + fst %st(2) # st(2)=1/exp(x) + fadd %st(1),%st(0) + fstp %st(3) # st(2)=exp(x)+exp(-x), st(1)=exp(-x), st(0)=exp(x) + fsubp # st(1)=exp(x)+exp(-x), st(0)=exp(x)-exp(-x) + fdivp + ret + +tanhl: + fldl2e + fldt 4(%esp) + fmulp + call __finexp + jmp fintanh + +.global hypotf,hypot,hypotl # ,__hypot + .type hypotf,@function + .type hypot,@function + .type hypotl,@function +# .type __hypot,@function +hypotf: + flds 8(%esp) + flds 4(%esp) + jmp __hypot +hypotl: + fldt 16(%esp) + fldt 4(%esp) + jmp __hypot +hypot: + fldl 12(%esp) + fldl 4(%esp) +__hypot: + fmul %st(0),%st(0) + fxch + fmul %st(0),%st(0) + faddp + fsqrt + ret + +.global log1pf,log1p,log1pl + .type log1pf,@function + .type log1p,@function + .type log1pl,@function +log1pf: + flds 4(%esp) + jmp __log1p +log1pl: + fldt 4(%esp) + jmp __log1p +log1p: + fldl 4(%esp) +__log1p: +# Sprawdzenie zakresu parametru + fst %st(1) + pushl $0x3ed413cc # sqrt(2)-1-2^(-25) + fabs + flds (%esp) + popl %eax + fcompp # porownanie + fstsw %ax + fldln2 + fxch + sahf +# |x| >= sqrt(2)-1 + jc 1f + fyl2xp1 + ret +1: fld1 # x = x + 1 + faddp + fyl2x + ret + +.global log10f,log10,log10l + .type log10f,@function + .type log10,@function + .type log10l,@function +log10f: + fldlg2 + flds 4(%esp) + fyl2x + ret +log10l: + fldlg2 + fldt 4(%esp) + fyl2x + ret +log10: + fldlg2 + fldl 4(%esp) + fyl2x + ret + +.global log2f,log2,log2l + .type log2f,@function + .type log2,@function + .type log2l,@function +log2f: + fld1 + flds 4(%esp) + fyl2x + ret +log2l: + fld1 + fldt 4(%esp) + fyl2x + ret +log2: + fld1 + fldl 4(%esp) + fyl2x + ret + +.global fmaf,fma,fmal + .type fmaf,@function + .type fma,@function + .type fmal,@function +fmaf: + flds 4(%esp) + fmuls 8(%esp) + fadds 12(%esp) + ret +fma: + fldl 4(%esp) + fmull 12(%esp) + faddl 20(%esp) + ret +fmal: + fldt 4(%esp) + fldt 16(%esp) + fmulp %st,%st(1) + fldt 28(%esp) + faddp %st,%st(1) + ret + +.global asinhf,asinh,asinhl + .type asinhf,@function + .type asinh,@function + .type asinhl,@function +asinhf: + flds 4(%esp) + jmp __asinh +asinh: + fldl 4(%esp) +__asinh: + fld %st(0) + fmul %st(0),%st(0) + fld1 + faddp %st(0),%st(1) +finasch: + fsqrt + faddp %st(0),%st(1) + fldln2 + fxch + fyl2x + ret +asinhl: + fldt 4(%esp) + jmp __asinh + +.global acoshf,acosh,acoshl + .type acoshf,@function + .type acosh,@function + .type acoshl,@function +acoshf: + flds 4(%esp) + jmp __acosh +acosh: + fldl 4(%esp) +__acosh: + fld %st(0) + fmul %st(0),%st(0) + fld1 + fsubrp %st(0),%st(1) # st1=st1-st0; pop + jmp finasch +acoshl: + fldt 4(%esp) + jmp __acosh + +.global atanhf,atanh,atanhl + .type atanhf,@function + .type atanh,@function + .type atanhl,@function +atanhf: + flds 4(%esp) + jmp __atanh +atanh: + fldl 4(%esp) +__atanh: + fst %st(1) + fld1 # st0=1, st1=x, st2=x + fadd %st(0),%st(2) # st0=1, st1=x, st2=x+1 + fsubp %st(0),%st(1) # st0=1-x, st1=x+1 + fdivrp %st(0),%st(1) + fsqrt + fldln2 + fxch + fyl2x + ret +atanhl: + fldt 4(%esp) + jmp __atanh + +.global dremf,drem,dreml + .type dremf,@function + .type drem,@function + .type dreml,@function +dremf: + flds 8(%esp) # y + flds 4(%esp) # x + jmp __drem +drem: + fldl 12(%esp) + fldl 4(%esp) +__drem: + fprem1 + fstsw %ax + sahf + jp __drem + ret + +dreml: + fldt 16(%esp) + fldt 4(%esp) + jmp __drem + +# |ret| = |x|, sign(ret) = sign(y) +.global copysignf,copysign,copysignl + .type copysignf,@function + .type copysign,@function + .type copysignl,@function +copysignf: + flds 4(%esp) # x + flds 8(%esp) # y + jmp __copysign +copysign: + fldl 4(%esp) + fldl 12(%esp) +__copysign: + fmul %st(1),%st # st = x*y + ftst + fstsw %ax + fincstp + sahf + jnc 1f + fchs +1: ret + +copysignl: + fldt 4(%esp) + fldt 16(%esp) + jmp __copysign + +.global fdimf,fdim,fdiml + .type fdimf,@function + .type fdim,@function + .type fdiml,@function +fdimf: + flds 4(%esp) + fsubl 12(%esp) + jmp __fdim +fdim: + fldl 4(%esp) + fsubl 12(%esp) +__fdim: + fstsw %ax + sahf + jnc 1f + fldz +1: ret +fdiml: + fldt 4(%esp) + fldt 16(%esp) + fsubp + jmp __fdim + + +.global truncf,trunc,truncl + .type truncf,@function + .type trunc,@function + .type truncl,@function + +truncf: + flds 4(%esp) + movb $0x0c,%ah + jmp __flcetr + +trunc: + fldl 4(%esp) + movb $0x0c,%ah + jmp __flcetr + +truncl: + fldt 4(%esp) + movb $0x0c,%ah + jmp __flcetr + +.global frexpf,frexp,frexpl + .type frexpf,@function + .type frexp,@function + .type frexpl,@function + +frexpf: + flds 4(%esp) + movl 8(%esp),%eax + jmp __frexp + +frexp: + fldl 4(%esp) + movl 12(%esp),%eax +__frexp: + fxtract + fxch + fistpl (%eax) + pushl $0x3f000000 # 1/2 + fmuls (%esp) + incl (%eax) + popl %eax + ret + +frexpl: + fldt 4(%esp) + movl 16(%esp),%eax + jmp __frexp + +.global logbf,logb,logbl + .type logbf,@function + .type logb,@function + .type logbl,@function + +#logbf: flds 4(%esp) +# fxtract +# fxch +# ret + +#logb: fldl 4(%esp) +# fxtract +# fxch +# ret + +#logbl: fldt 4(%esp) +# fxtract +# fxch +# ret + +.global ilogbf,ilogb,ilogbl + .type ilogbf,@function + .type ilogb,@function + .type ilogbl,@function + +logbf: +ilogbf: flds 4(%esp) + jmp __ilogb + +logb: +ilogb: fldl 4(%esp) +__ilogb: + fxtract + pushl %eax + fxch + fistl (%esp) + popl %eax + ret + +logbl: +ilogbl: fldt 4(%esp) + jmp __ilogb + diff --git a/mdk-stage1/dietlibc/i386/listen.S b/mdk-stage1/dietlibc/i386/listen.S new file mode 100644 index 000000000..a0879be37 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/listen.S @@ -0,0 +1,4 @@ +#include +#include + +__socketcall(listen,LISTEN) diff --git a/mdk-stage1/dietlibc/i386/log.S b/mdk-stage1/dietlibc/i386/log.S new file mode 100644 index 000000000..0d42c9297 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/log.S @@ -0,0 +1,26 @@ +.text + +.global logf,log,logl + .type logf,@function + .type log,@function + .type logl,@function +logf: + fldln2 + flds 4(%esp) + fyl2x + ret +logl: + fldln2 + fldt 4(%esp) + fyl2x + ret +log: + fldln2 + fldl 4(%esp) + fyl2x + ret + +.Lende: +.size log,.Lende-log +.size logl,.Lende-logl +.size logf,.Lende-logf diff --git a/mdk-stage1/dietlibc/i386/log10.S b/mdk-stage1/dietlibc/i386/log10.S new file mode 100644 index 000000000..dcd08cc3f --- /dev/null +++ b/mdk-stage1/dietlibc/i386/log10.S @@ -0,0 +1,11 @@ +.text +.type log10,@function +.global log10 +log10: + fldlg2 + fldl 4(%esp) + fyl2x + ret + +.ende: +.size log10,.ende-log10 diff --git a/mdk-stage1/dietlibc/i386/log1p.S b/mdk-stage1/dietlibc/i386/log1p.S new file mode 100644 index 000000000..4dd2d58b4 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/log1p.S @@ -0,0 +1,12 @@ +.text +.type log1p,@function +.global log1p +log1p: + fldln2 + fldl 4(%esp) + fyl2xp1 + ret + +.ende: +.size log1p,.ende-log1p + diff --git a/mdk-stage1/dietlibc/i386/log2.S b/mdk-stage1/dietlibc/i386/log2.S new file mode 100644 index 000000000..80e99a8c9 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/log2.S @@ -0,0 +1,11 @@ +.text +.type log2,@function +.global log2 +log2: + fld1 + fldl 4(%esp) + fyl2x + ret + +.ende: +.size log2,.ende-log2 diff --git a/mdk-stage1/dietlibc/i386/ltostr.S b/mdk-stage1/dietlibc/i386/ltostr.S new file mode 100644 index 000000000..ddf85a4f6 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/ltostr.S @@ -0,0 +1,62 @@ +/* + Copyright (C) 2002 Thomas M. Ogrisegg + + __ltostr.S -- convert an integer into a string + + %eax = dividend + %ebx = divisor + %ecx = size of output-buffer + %edi = output-buffer + %ebp = if uppercase is set, then %ebp is 'A'-10 else %ebp is 'a'-10 + +*/ + +.text +.globl __ltostr +__ltostr: + pushl %esi + pushl %edi # destination + pushl %ebp + pushl %ebx + movl %esp, %eax + movl 0x14(%eax), %edi + movl 0x18(%eax), %ecx # size + movl 0x20(%eax), %ebx # divisor + movl 0x1c(%eax), %eax # dividend + decl %ecx + movl %ecx, %esi + movl $('A'-0xa), %ebp + xorl %edx, %edx # must be 0 -- used by idiv + cmpl $0x0, 36(%esp) # check for uppercase + jnz .Lnext + addl $0x20, %ebp # set lowercase +.Lnext: + idiv %ebx, %eax + cmpb $0x9, %dl + jg .Lnext2 + addb $'0', %dl + jmp .Lstos +.Lnext2: + addl %ebp, %edx +.Lstos: + movb %dl, (%edi, %ecx) + xorl %edx, %edx + decl %ecx + jz .Lout + orl %eax, %eax + jnz .Lnext +.Lout: + cld + movl %esi, %ebx + leal 1(%edi, %ecx), %esi + subl %ebx, %ecx + negl %ecx + movl %ecx, %eax + repnz movsb + movb $0x0, (%edi) + popl %ebx + popl %ebp + popl %edi + popl %esi + ret +.size __ltostr, . - __ltostr diff --git a/mdk-stage1/dietlibc/i386/mcount.S b/mdk-stage1/dietlibc/i386/mcount.S new file mode 100644 index 000000000..11feed5e0 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/mcount.S @@ -0,0 +1,44 @@ +/* + Copyright (C) 2001, 2002 Thomas M. Ogrisegg + + This is free software. You can redistribute and + modify it under the terms of the GNU General Public + Public License. + + mcount.S + i386 assembler implementation of mcount +*/ + +/* .section ".profile" */ +.text +.globl mcount +.type mcount,@function +mcount: +/* + save all generic registers which + might be used by __mcount, but aren't + automatically saved + */ + pushl %eax + pushl %ecx + pushl %edx + +/* push the instruction pointer of the calling function */ + pushl 0xc(%esp) + +/* push the instruction pointer of the + function that called the calling function */ + pushl 0x4(%ebp) + + call __mcount + +/* clean up stack */ + addl $0x8, %esp + +/* restore the previously saved registers */ + popl %edx + popl %ecx + popl %eax + ret + +.size mcount,.-mcount diff --git a/mdk-stage1/dietlibc/i386/md5asm.S b/mdk-stage1/dietlibc/i386/md5asm.S new file mode 100644 index 000000000..a99a92934 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/md5asm.S @@ -0,0 +1,300 @@ +#define S11 7 +#define S12 12 +#define S13 17 +#define S14 22 +#define S21 5 +#define S22 9 +#define S23 14 +#define S24 20 +#define S31 4 +#define S32 11 +#define S33 16 +#define S34 23 +#define S41 6 +#define S42 10 +#define S43 15 +#define S44 21 + + +// #define F(x, y, z) (x & y) + (~x & z) = x&y + (z - z&x) = z + y&x - z&x +//#define F(x, y, z) movl x,%ebx; movl x,%eax; notl %ebx; andl y,%eax; andl z,%ebx; addl %ebx,%eax +#define F(x, y, z) movl y,%eax; movl z,%ebx; andl x,%eax; andl x,%ebx; addl z,%eax; subl %ebx,%eax + +// #define G(x, y, z) (x & z) + (y & ~z) = x&z + (y - y&z) = y + x&z - y&z +#define G(x, y, z) movl z,%ebx; movl z,%eax; notl %ebx; andl x,%eax; andl y,%ebx; addl %ebx,%eax +//#define G(x, y, z) movl x,%eax; movl y,%ebx; andl z,%eax; andl z,%ebx; addl y,%eax; subl %ebx,%eax +//#define G(x, y, z) movl z,%eax; movl z,%ebx; andl x,%eax; andl y,%ebx; addl y,%eax; subl %ebx,%eax + +// #define H(x, y, z) x ^ y ^ z +#define H(x, y, z) movl z,%eax; xorl y,%eax; xorl x,%eax + +// #define I(x, y, z) y ^ (x | ~z) +#define I(x, y, z) movl z,%eax; notl %eax; orl x,%eax; xorl y,%eax + + +// #define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n)))) +#define ROTATE_LEFT(x, n) roll $n,x + +// #define FF(a, b, c, d, x, s, ac) { (a) += F (b, c, d) + (x) + (word)(ac); (a) = ROTATE_LEFT (a, s); (a) += (b); } +// #define GG(a, b, c, d, x, s, ac) { (a) += G (b, c, d) + (x) + (word)(ac); (a) = ROTATE_LEFT (a, s); (a) += (b); } +// #define HH(a, b, c, d, x, s, ac) { (a) += H (b, c, d) + (x) + (word)(ac); (a) = ROTATE_LEFT (a, s); (a) += (b); } +// #define II(a, b, c, d, x, s, ac) { (a) += I (b, c, d) + (x) + (word)(ac); (a) = ROTATE_LEFT (a, s); (a) += (b); } + +#define FF(a, b, c, d, x, s, ac) addl x, a; addl $ac,a; F (b, c, d); addl %eax,a; roll $s,a; addl b,a +#define GG(a, b, c, d, x, s, ac) addl x, a; addl $ac,a; G (b, c, d); addl %eax,a; roll $s,a; addl b,a +#define HH(a, b, c, d, x, s, ac) addl x, a; addl $ac,a; H (b, c, d); addl %eax,a; roll $s,a; addl b,a +#define II(a, b, c, d, x, s, ac) addl x, a; addl $ac,a; I (b, c, d); addl %eax,a; roll $s,a; addl b,a + + +// // x is ecx +// word a = state [0]; // a is edx +// word b = state [1]; // b is esi +// word c = state [2]; // c is edi +// word d = state [3]; // d is ebp + +#define X(n) 4*(n)(%ecx) +#define X0 (%ecx) +#define a %edx +#define b %esi +#define c %edi +#define d %ebp + + + +/* MD5 basic transformation: Transforms state based on data block */ + +// void __MD5Transform ( word state[4], const word* x, size_t repeat ) + +.text +.type __MD5Transform, @function +.align 32 +.global __MD5Transform + + .align 32 +.Lrepeat: + + /* Round 1 */ + FF (a, b, c, d, X0 , S11, 0xd76aa478); /* 1 */ + FF (d, a, b, c, X( 1), S12, 0xe8c7b756); /* 2 */ + FF (c, d, a, b, X( 2), S13, 0x242070db); /* 3 */ + FF (b, c, d, a, X( 3), S14, 0xc1bdceee); /* 4 */ + FF (a, b, c, d, X( 4), S11, 0xf57c0faf); /* 5 */ + FF (d, a, b, c, X( 5), S12, 0x4787c62a); /* 6 */ + FF (c, d, a, b, X( 6), S13, 0xa8304613); /* 7 */ + FF (b, c, d, a, X( 7), S14, 0xfd469501); /* 8 */ + FF (a, b, c, d, X( 8), S11, 0x698098d8); /* 9 */ + FF (d, a, b, c, X( 9), S12, 0x8b44f7af); /* 10 */ + FF (c, d, a, b, X(10), S13, 0xffff5bb1); /* 11 */ + FF (b, c, d, a, X(11), S14, 0x895cd7be); /* 12 */ + FF (a, b, c, d, X(12), S11, 0x6b901122); /* 13 */ + FF (d, a, b, c, X(13), S12, 0xfd987193); /* 14 */ + FF (c, d, a, b, X(14), S13, 0xa679438e); /* 15 */ + FF (b, c, d, a, X(15), S14, 0x49b40821); /* 16 */ + + /* Round 2 */ + GG (a, b, c, d, X( 1), S21, 0xf61e2562); /* 17 */ + GG (d, a, b, c, X( 6), S22, 0xc040b340); /* 18 */ + GG (c, d, a, b, X(11), S23, 0x265e5a51); /* 19 */ + GG (b, c, d, a, X0 , S24, 0xe9b6c7aa); /* 20 */ + GG (a, b, c, d, X( 5), S21, 0xd62f105d); /* 21 */ + GG (d, a, b, c, X(10), S22, 0x02441453); /* 22 */ + GG (c, d, a, b, X(15), S23, 0xd8a1e681); /* 23 */ + GG (b, c, d, a, X( 4), S24, 0xe7d3fbc8); /* 24 */ + GG (a, b, c, d, X( 9), S21, 0x21e1cde6); /* 25 */ + GG (d, a, b, c, X(14), S22, 0xc33707d6); /* 26 */ + GG (c, d, a, b, X( 3), S23, 0xf4d50d87); /* 27 */ + GG (b, c, d, a, X( 8), S24, 0x455a14ed); /* 28 */ + GG (a, b, c, d, X(13), S21, 0xa9e3e905); /* 29 */ + GG (d, a, b, c, X( 2), S22, 0xfcefa3f8); /* 30 */ + GG (c, d, a, b, X( 7), S23, 0x676f02d9); /* 31 */ + GG (b, c, d, a, X(12), S24, 0x8d2a4c8a); /* 32 */ + + /* Round 3 */ + HH (a, b, c, d, X( 5), S31, 0xfffa3942); /* 33 */ + HH (d, a, b, c, X( 8), S32, 0x8771f681); /* 34 */ + HH (c, d, a, b, X(11), S33, 0x6d9d6122); /* 35 */ + HH (b, c, d, a, X(14), S34, 0xfde5380c); /* 36 */ + HH (a, b, c, d, X( 1), S31, 0xa4beea44); /* 37 */ + HH (d, a, b, c, X( 4), S32, 0x4bdecfa9); /* 38 */ + HH (c, d, a, b, X( 7), S33, 0xf6bb4b60); /* 39 */ + HH (b, c, d, a, X(10), S34, 0xbebfbc70); /* 40 */ + HH (a, b, c, d, X(13), S31, 0x289b7ec6); /* 41 */ + HH (d, a, b, c, X0 , S32, 0xeaa127fa); /* 42 */ + HH (c, d, a, b, X( 3), S33, 0xd4ef3085); /* 43 */ + HH (b, c, d, a, X( 6), S34, 0x04881d05); /* 44 */ + HH (a, b, c, d, X( 9), S31, 0xd9d4d039); /* 45 */ + HH (d, a, b, c, X(12), S32, 0xe6db99e5); /* 46 */ + HH (c, d, a, b, X(15), S33, 0x1fa27cf8); /* 47 */ + HH (b, c, d, a, X( 2), S34, 0xc4ac5665); /* 48 */ + + /* Round 4 */ + II (a, b, c, d, X0 , S41, 0xf4292244); /* 49 */ + II (d, a, b, c, X( 7), S42, 0x432aff97); /* 50 */ + II (c, d, a, b, X(14), S43, 0xab9423a7); /* 51 */ + II (b, c, d, a, X( 5), S44, 0xfc93a039); /* 52 */ + II (a, b, c, d, X(12), S41, 0x655b59c3); /* 53 */ + II (d, a, b, c, X( 3), S42, 0x8f0ccc92); /* 54 */ + II (c, d, a, b, X(10), S43, 0xffeff47d); /* 55 */ + II (b, c, d, a, X( 1), S44, 0x85845dd1); /* 56 */ + II (a, b, c, d, X( 8), S41, 0x6fa87e4f); /* 57 */ + II (d, a, b, c, X(15), S42, 0xfe2ce6e0); /* 58 */ + II (c, d, a, b, X( 6), S43, 0xa3014314); /* 59 */ + II (b, c, d, a, X(13), S44, 0x4e0811a1); /* 60 */ + II (a, b, c, d, X( 4), S41, 0xf7537e82); /* 61 */ + II (d, a, b, c, X(11), S42, 0xbd3af235); /* 62 */ + II (c, d, a, b, X( 2), S43, 0x2ad7d2bb); /* 63 */ + II (b, c, d, a, X( 9), S44, 0xeb86d391); /* 64 */ + +// state [0] += a; +// state [1] += b; +// state [2] += c; +// state [3] += d; + + addl $64,%ecx + + movl 4+32(%esp),%eax // state + addl (%eax),a + addl 4(%eax),b + addl 8(%eax),c + addl 12(%eax),d + movl a, (%eax) + movl b, 4(%eax) + movl c, 8(%eax) + movl d,12(%eax) + +.Lstart: + decl 12+32(%esp) + jns .Lrepeat + + popal + ret + +__MD5Transform: +__MD5TransformLocal: + pushal + movl 8+32(%esp),%ecx // x + movl 4+32(%esp),%eax // state + movl (%eax),a + movl 4(%eax),b + movl 8(%eax),c + movl 12(%eax),d + jmp .Lstart + +.Lende: +.size __MD5Transform, .Lende-__MD5Transform + +.type MD5Init,@function +.global MD5Init + +MD5Init: + movl 4(%esp), %ecx + xorl %eax,%eax + movl $0x67452301, (%ecx) + movl $0xefcdab89, 4(%ecx) + movl $0x98badcfe, 8(%ecx) + movl $0x10325476, 12(%ecx) + movl %eax, 16(%ecx) + movl %eax, 20(%ecx) + ret + + +.global MD5Update +.type MD5Update,@function + + +// void MD5Update ( MD5_CTX* context, const byte* input, size_t inputBytes ) + +#define CONTEXT 4+32(%esp) +#define INPUT 8+32(%esp) +#define INPUTBYTES 12+32(%esp) + +#define COUNT 16(%ebx) +#define BUFFER 24(%ebx) + + +MD5Update: + pushal + cld + movl CONTEXT, %ebx + +// ByteIndex = (context->count[0] >> 3) & 0x3F; + + movl COUNT, %ebp + shrl $3, %ebp + andl $63,%ebp // ebp = ByteIndex + +// if ( (context->count[0] += inputBytes << 3 ) < (inputBytes << 3) ) +// context->count[1]++; +// context->count[1] += inputBytes >> (32-3); + + movl $8, %eax + mull INPUTBYTES + addl %eax, 0+COUNT + adcl %edx, 4+COUNT + +// partLen = 64 - ByteIndex; + + movl $64, %eax + subl %ebp, %eax // eax = partLen + +// i = 0; +// if ( partLen <= inputBytes ) { + + xorl %ecx,%ecx // ecx = i + cmpl INPUTBYTES, %eax + ja .Lende2 + +// memcpy ( context->buffer + ByteIndex, input, partLen ); + + leal 24(%ebx,%ebp,1), %edi + movl INPUT, %esi + movl %eax, %ecx + rep movsb + +// MD5Transform ( context->state, context->buffer, 1 ); + + pushl $1 + leal BUFFER, %ecx + pushl %ecx + push %ebx + call __MD5TransformLocal + +// len = (inputBytes - partLen) / 64; + + movl 12+INPUTBYTES, %ecx + subl %eax, %ecx + shrl $6, %ecx + +// MD5Transform ( context->state, input+partLen, len ); + + pushl %ecx + pushl %esi + pushl %ebx + call __MD5TransformLocal + addl $24,%esp + +// i = partLen + 64 * len; +// ByteIndex = 0; + + shll $6, %ecx + addl %eax, %ecx + xorl %ebp, %ebp + +.Lende2: + +// } +// memcpy ( context->buffer + ByteIndex, input + i, inputBytes - i ); + + movl INPUT, %esi + addl %ecx, %esi + + negl %ecx + addl INPUTBYTES, %ecx + + leal 24(%ebx,%ebp,1), %edi + rep movsb + + popal + ret + + diff --git a/mdk-stage1/dietlibc/i386/memccpy.S b/mdk-stage1/dietlibc/i386/memccpy.S new file mode 100644 index 000000000..0b7dce49e --- /dev/null +++ b/mdk-stage1/dietlibc/i386/memccpy.S @@ -0,0 +1,39 @@ +/* + Copyright (C) 2002 Thomas M. Ogrisegg + + This is free software. You can redistribute and + modify it under the terms of the GNU General Public + Public License. + + memccpy.S + i386 assembler implementation of memccpy(3) +*/ + +.text +.global memccpy +.type memccpy,@function +memccpy: + pushl %esi + pushl %edi + + movl %esp, %ecx + movl 0x0c(%ecx), %edi + movl 0x10(%ecx), %esi + movb 0x14(%ecx), %dl + movl 0x18(%ecx), %ecx + cld +.Lloop: + lodsb + stosb + cmp %al, %dl + jz .Lout + decl %ecx + jnz .Lloop + xorl %edi, %edi +.Lout: + movl %edi, %eax + popl %edi + popl %esi + ret +.Lende: +.size memccpy,.Lende-memccpy diff --git a/mdk-stage1/dietlibc/i386/memchr.S b/mdk-stage1/dietlibc/i386/memchr.S new file mode 100644 index 000000000..7d04f990b --- /dev/null +++ b/mdk-stage1/dietlibc/i386/memchr.S @@ -0,0 +1,24 @@ +.text +.align 0 +.global memchr +.type memchr,@function +memchr: + pushl %edi + movl 8(%esp),%edi + movl 12(%esp),%eax + movl 16(%esp),%ecx + cld + jecxz .Lnotfound + + repne scasb + + je .Lfound +.Lnotfound: + xorl %edi, %edi + incl %edi +.Lfound: + movl %edi, %eax + decl %eax + + popl %edi + ret diff --git a/mdk-stage1/dietlibc/i386/memcmp.S b/mdk-stage1/dietlibc/i386/memcmp.S new file mode 100644 index 000000000..aa6d55f23 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/memcmp.S @@ -0,0 +1,26 @@ +.text +.align 0 +.global memcmp +.type memcmp,@function +memcmp: + xorl %eax,%eax + orl 12(%esp),%eax + jz .Lempty + pushl %esi + pushl %edi + movl 12(%esp),%esi + movl 16(%esp),%edi + movl %eax,%ecx + + rep cmpsb + + decl %esi + decl %edi + lodsb + subb (%edi), %al + movsx %al, %eax + + popl %edi + popl %esi +.Lempty: + ret diff --git a/mdk-stage1/dietlibc/i386/memcpy.S b/mdk-stage1/dietlibc/i386/memcpy.S new file mode 100644 index 000000000..cbe74459f --- /dev/null +++ b/mdk-stage1/dietlibc/i386/memcpy.S @@ -0,0 +1,16 @@ +.text +.align 0 +.global memcpy +.type memcpy,@function +memcpy: + pushl %esi + pushl %edi + movl 12(%esp),%edi + movl 16(%esp),%esi + movl 20(%esp),%ecx + movl %edi, %eax + cld + rep movsb + popl %edi + popl %esi + ret diff --git a/mdk-stage1/dietlibc/i386/memset.S b/mdk-stage1/dietlibc/i386/memset.S new file mode 100644 index 000000000..472390b84 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/memset.S @@ -0,0 +1,15 @@ +.text +.align 0 +.global memset +.type memset,@function +memset: + pushl %edi + movl 8(%esp),%edi + movl 12(%esp),%eax + movl 16(%esp),%ecx + cld + pushl %edi + rep stosb + popl %eax + popl %edi + ret diff --git a/mdk-stage1/dietlibc/i386/mmap.S b/mdk-stage1/dietlibc/i386/mmap.S new file mode 100644 index 000000000..c824aa037 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/mmap.S @@ -0,0 +1,14 @@ +#include "syscalls.h" + +.text +.global mmap +.type mmap,@function +mmap: + mov $__NR_mmap,%al + lea 0x4(%esp,1),%edx + push %edx + call __unified_syscall + pop %ecx + ret +.Lende3: +.size mmap,.Lende3-mmap diff --git a/mdk-stage1/dietlibc/i386/mmap64.S b/mdk-stage1/dietlibc/i386/mmap64.S new file mode 100644 index 000000000..421325260 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/mmap64.S @@ -0,0 +1,63 @@ +#include +#include +#include + +#ifdef __DYN_LIB +#ifndef WANT_THREAD_SAFE +#define WANT_THREAD_SAFE +#endif +#endif + +.text +.global mmap64 +.type mmap64,@function +mmap64: +/* man is this ugly! */ + push %ebp + push %edi + push %esi + push %ebx + movl %esp, %edi + movl 0x28(%edi), %eax + movl 0x2c(%edi), %edx + testl $0xfff, %eax /* offset in pages */ + jnz .Leinval + shrdl $12, %edx, %eax + shrl $12, %edx + jnz .Leinval + movl %eax, %ebp + movl 0x14(%edi),%ebx + movl 0x18(%edi),%ecx + movl 0x1c(%edi),%edx + movl 0x20(%edi),%esi + movl 0x24(%edi),%edi + movl $__NR_mmap2,%eax + int $0x80 + cmp $-124,%eax + jbe .Lnoerror + neg %eax +.Lerror: +#ifdef WANT_THREAD_SAFE + movl %eax,%ebx +#ifdef __DYN_LIB + call __errno_location@PLT +#else + call __errno_location +#endif + movl %ebx,(%eax) + orl $-1,%eax +#else + mov %eax,errno + sbb %eax,%eax # eax = eax - eax - CY = -1 +#endif +.Lnoerror: + pop %ebx + pop %esi + pop %edi + pop %ebp + ret +.Leinval: + movl $EINVAL,%eax + jmp .Lerror +.Lende2: +.size mmap64,.Lende2-mmap64 diff --git a/mdk-stage1/dietlibc/i386/poly.S b/mdk-stage1/dietlibc/i386/poly.S new file mode 100644 index 000000000..d8be7d7f5 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/poly.S @@ -0,0 +1,24 @@ + +.text +.global __poly +.type __poly,@function + + +# +# double __poly ( double x, int n, const double* c ); +# + +__poly: + movl 16(%esp),%eax + movl 12(%esp),%ecx + leal (%eax,%ecx,8),%eax + fldl 4(%esp) + fldz +.Lloop: + fmul %st(1),%st(0) + faddl (%eax) + addl $-8,%eax + decl %ecx + jns .Lloop + fstp %st(1) + ret diff --git a/mdk-stage1/dietlibc/i386/pow.S b/mdk-stage1/dietlibc/i386/pow.S new file mode 100644 index 000000000..46562a299 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/pow.S @@ -0,0 +1,67 @@ +.text +.global pow +.type pow,@function + +# pow(x,y) +.global powf,pow,powl + .type powf,@function + .type pow,@function + .type powl,@function +powf: + flds 4(%esp) # x + flds 8(%esp) # y + jmp .L__pow +powl: + fldt 4(%esp) + fldt 16(%esp) + jmp .L__pow +pow: + fldl 4(%esp) + fldl 12(%esp) +# x^y; st(0)=y, st(1)=x +.L__pow: + ftst # y = 0 ? + fstsw %ax + fld1 # st(0)=1, st(1)=y, st(2)=x + sahf + jz 1f # return 1 + fcomp %st(1) # y = 1 ? + fstsw %ax + fxch # st(0)=x, st(1)=y + sahf + jz 1f # return x + ftst # x = 0 ? + fstsw %ax + sahf + jz 1f + jnc .Lfinpow # x > 0 + fxch # st(0)=y, st(1)=x + fld %st(0) # st(0)=y, st(1)=y, st(2)=x + frndint # st(0)=int(y) + fcomp %st(1) # y = int(y)? + fstsw %ax + fxch + sahf + jnz .Lfinpow # fyl2x -> st(0) = NaN +# y even or odd ? + fld1 + fadd %st(0) # st(0) = 2 + fdivr %st(2),%st(0) # st(0)=st(2)/2 + frndint + fadd %st(0),%st(0) + fcomp %st(2) # st(0) = x, st(1) = y + fstsw %ax + fchs # st(0) = -x + sahf + jz .Lfinpow # y even + call .Lfinpow # y odd + fchs +1: ret +.Lfinpow: + fyl2x + jmp __finexp + +.Lende: +.size pow,.Lende-pow +.size powf,.Lende-powf +.size powl,.Lende-powl diff --git a/mdk-stage1/dietlibc/i386/recv.S b/mdk-stage1/dietlibc/i386/recv.S new file mode 100644 index 000000000..215343ccc --- /dev/null +++ b/mdk-stage1/dietlibc/i386/recv.S @@ -0,0 +1,4 @@ +#include +#include + +__socketcall(recv,RECV) diff --git a/mdk-stage1/dietlibc/i386/recvfrom.S b/mdk-stage1/dietlibc/i386/recvfrom.S new file mode 100644 index 000000000..a9dde840d --- /dev/null +++ b/mdk-stage1/dietlibc/i386/recvfrom.S @@ -0,0 +1,4 @@ +#include +#include + +__socketcall(recvfrom,RECVFROM) diff --git a/mdk-stage1/dietlibc/i386/recvmsg.S b/mdk-stage1/dietlibc/i386/recvmsg.S new file mode 100644 index 000000000..cb26e2f08 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/recvmsg.S @@ -0,0 +1,4 @@ +#include +#include + +__socketcall(recvmsg,RECVMSG) diff --git a/mdk-stage1/dietlibc/i386/rint.S b/mdk-stage1/dietlibc/i386/rint.S new file mode 100644 index 000000000..f56ab1f93 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/rint.S @@ -0,0 +1,23 @@ +.text + +.global rintf,rint,rintl + .type rintf,@function + .type rint,@function + .type rintl,@function +rintf: + flds 4(%esp) + frndint + ret +rint: + fldl 4(%esp) + frndint + ret +rintl: + fldt 4(%esp) + frndint + ret + +.Lende: +.size rint,.Lende-rint +.size rintl,.Lende-rintl +.size rintf,.Lende-rintf diff --git a/mdk-stage1/dietlibc/i386/send.S b/mdk-stage1/dietlibc/i386/send.S new file mode 100644 index 000000000..f2dd7e3d5 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/send.S @@ -0,0 +1,4 @@ +#include +#include + +__socketcall(send,SEND) diff --git a/mdk-stage1/dietlibc/i386/sendmsg.S b/mdk-stage1/dietlibc/i386/sendmsg.S new file mode 100644 index 000000000..484d62e50 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/sendmsg.S @@ -0,0 +1,4 @@ +#include +#include + +__socketcall(sendmsg,SENDMSG) diff --git a/mdk-stage1/dietlibc/i386/sendto.S b/mdk-stage1/dietlibc/i386/sendto.S new file mode 100644 index 000000000..04270f0f0 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/sendto.S @@ -0,0 +1,4 @@ +#include +#include + +__socketcall(sendto,SENDTO) diff --git a/mdk-stage1/dietlibc/i386/setsockopt.S b/mdk-stage1/dietlibc/i386/setsockopt.S new file mode 100644 index 000000000..6a81aec82 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/setsockopt.S @@ -0,0 +1,4 @@ +#include +#include + +__socketcall(setsockopt,SETSOCKOPT) diff --git a/mdk-stage1/dietlibc/i386/shutdown.S b/mdk-stage1/dietlibc/i386/shutdown.S new file mode 100644 index 000000000..f9dc707e8 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/shutdown.S @@ -0,0 +1,4 @@ +#include +#include + +__socketcall(shutdown,SHUTDOWN) diff --git a/mdk-stage1/dietlibc/i386/sin.S b/mdk-stage1/dietlibc/i386/sin.S new file mode 100644 index 000000000..404bf5eed --- /dev/null +++ b/mdk-stage1/dietlibc/i386/sin.S @@ -0,0 +1,34 @@ + +.text + +.global sinf,sin,sinl +.type sinf,@function +.type sin,@function +.type sinl,@function +sinf: + flds 4(%esp) + jmp 1f +sin: + fldl 4(%esp) +1: fsin + fnstsw %ax + testb $0x04, %ah + je 3f + fldpi + fadd %st + fxch %st(1) +2: fprem1 + fnstsw %ax + testb $0x04, %ah + jne 2b + fstp %st(1) + fsin +3: ret +sinl: + fldt 4(%esp) + jmp 1b + +.ende: +.size sin,.ende-sin +.size sinf,.ende-sinf +.size sinl,.ende-sinl diff --git a/mdk-stage1/dietlibc/i386/sincos.S b/mdk-stage1/dietlibc/i386/sincos.S new file mode 100644 index 000000000..7395075f3 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/sincos.S @@ -0,0 +1,18 @@ + +.text +.type sincos,@function +.global sincos + +# void sincos ( double x, double* sinx, double* cosx ); + +sincos: + fldl 4(%esp) + fsincos + movl 16(%esp),%eax + movl 12(%esp),%ecx + fstpl (%eax) + fstpl (%ecx) + ret + +.ende: +.size sincos,.ende-sincos diff --git a/mdk-stage1/dietlibc/i386/sinh.S b/mdk-stage1/dietlibc/i386/sinh.S new file mode 100644 index 000000000..98f7ee752 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/sinh.S @@ -0,0 +1,29 @@ + +.text +.type sinh,@function +.global sinh + +sinh: # note: exp(x) = 2^(x*log2(e)) + fldl2e + fmull 4(%esp) # x*log2(e) + fld %st(0) # x*log2(e) x*log2(e) + frndint # int(x*log2(e)) x*log2(e) + fxch # x*log2(e) int(x*log2(e)) + fsub %st(1),%st(0) # frac(x*log2(e)) int(x*log2(e)) + f2xm1 # 2^(fract(x*log2(e)))-1 int(x*log2(e)) + fld1 # 1 2^(fract(x*log2(e)))-1 int(x*log2(e)) + faddp %st(0),%st(1) # 2^(fract(x*log2(e))) int(x*log2(e)) + fscale # 2^(x*log2(e)) int(x*log2(e)) + fstp %st(1) # 2^(x*log2(e)) + +# now we have y = exp(x), but sinh(x) = (y - 1/y) * 0.5 + + fld1 + fdiv %st(1),%st(0) + fsubrp + fmuls __half + ret + +.Lende: + +.size sinh,.ende-sinh diff --git a/mdk-stage1/dietlibc/i386/sleep.S b/mdk-stage1/dietlibc/i386/sleep.S new file mode 100644 index 000000000..356552dc2 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/sleep.S @@ -0,0 +1,25 @@ +#include "PIC.h" + +.text +.global sleep +.type sleep,@function + +sleep: + movl 4(%esp),%eax # Argument holen + PIC_SAVE # non-PIC: empty line + PIC_INIT # non-PIC: empty line + pushl $0 # 0 ns + pushl %eax # 'x' µs warten + movl %esp,%eax + pushl %eax # zweimal ein Zeiger auf das Stackobjekt + pushl %eax # ptr ptr sec nsec return arg +#ifdef __DYN_LIB + call nanosleep@PLT +#else + call nanosleep +#endif + movl 20(%esp),%eax # 'x' holen + subl 8(%esp),%eax # schon abgelaufende Zeit subtrahieren + addl $16,%esp + PIC_RESTORE # non-PIC: empty line + ret diff --git a/mdk-stage1/dietlibc/i386/socket.S b/mdk-stage1/dietlibc/i386/socket.S new file mode 100644 index 000000000..bc8cbe536 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/socket.S @@ -0,0 +1,4 @@ +#include +#include + +__socketcall(socket,SOCKET) diff --git a/mdk-stage1/dietlibc/i386/socketcall.S b/mdk-stage1/dietlibc/i386/socketcall.S new file mode 100644 index 000000000..4e8019ec2 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/socketcall.S @@ -0,0 +1,17 @@ +#include + +.text +.global socketcall +.type socketcall,@function +socketcall: + leal 4(%esp), %ecx + pushl %ecx + movzbl %al,%eax + pushl %eax + movb $__NR_socketcall,%al + call __unified_syscall + popl %ecx + popl %ecx + retl +.Lende: +.size socketcall,.Lende-socketcall diff --git a/mdk-stage1/dietlibc/i386/socketpair.S b/mdk-stage1/dietlibc/i386/socketpair.S new file mode 100644 index 000000000..a5de65f25 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/socketpair.S @@ -0,0 +1,4 @@ +#include +#include + +__socketcall(socketpair,SOCKETPAIR) diff --git a/mdk-stage1/dietlibc/i386/sqrt.S b/mdk-stage1/dietlibc/i386/sqrt.S new file mode 100644 index 000000000..5e4527612 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/sqrt.S @@ -0,0 +1,23 @@ +.text + +.global sqrtf,sqrt,sqrtl + .type sqrtf,@function + .type sqrt,@function + .type sqrtl,@function +sqrtf: + flds 4(%esp) + fsqrt + ret +sqrt: + fldl 4(%esp) + fsqrt + ret +sqrtl: + fldt 4(%esp) + fsqrt + ret + +.ende: +.size sqrt,.ende-sqrt +.size sqrtf,.ende-sqrtf +.size sqrtl,.ende-sqrtl diff --git a/mdk-stage1/dietlibc/i386/sqrtl.S b/mdk-stage1/dietlibc/i386/sqrtl.S new file mode 100644 index 000000000..c1a931fd8 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/sqrtl.S @@ -0,0 +1,11 @@ +.text +.type sqrtl,@function +.global sqrtl +sqrtl: + fldt 4(%esp) + fsqrt + ret + +.ende: +.size sqrtl,.ende-sqrtl + diff --git a/mdk-stage1/dietlibc/i386/stpcpy.S b/mdk-stage1/dietlibc/i386/stpcpy.S new file mode 100644 index 000000000..1cb74b2ea --- /dev/null +++ b/mdk-stage1/dietlibc/i386/stpcpy.S @@ -0,0 +1,22 @@ +.text +.global stpcpy +.type stpcpy,@function +stpcpy: + pushl %edi + pushl %esi + movl 0xc(%esp), %edi + movl 0x10(%esp), %esi + +.Lcopy: + lodsb + stosb + testb %al, %al + jnz .Lcopy + + movl %edi, %eax + decl %eax + popl %esi + popl %edi + ret +.Lende: +.size stpcpy,.Lende-stpcpy diff --git a/mdk-stage1/dietlibc/i386/strcasecmp.S b/mdk-stage1/dietlibc/i386/strcasecmp.S new file mode 100644 index 000000000..a836680db --- /dev/null +++ b/mdk-stage1/dietlibc/i386/strcasecmp.S @@ -0,0 +1,31 @@ +.text +.globl strcasecmp + +strcasecmp: + pushl %esi + movl 0x8(%esp), %esi + movl 0xc(%esp), %edx + xorl %eax, %eax + xorl %ecx, %ecx + cld +.Lloop: + lodsb + movb (%edx), %cl + incl %edx + or %al, %al + jz .Lfinifirst + cmp $'A', %al + jnge .Lcmp + cmp $'z', %al + jg .Lcmp + or $0x20, %al + or $0x20, %cl +.Lcmp: + subl %ecx, %eax + jz .Lloop +.Lret: + popl %esi + ret +.Lfinifirst: + subl %ecx, %eax + jmp .Lret diff --git a/mdk-stage1/dietlibc/i386/strcat.S b/mdk-stage1/dietlibc/i386/strcat.S new file mode 100644 index 000000000..e7d74ef13 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/strcat.S @@ -0,0 +1,29 @@ +.text +.align 0 +.global strcat +.type strcat,@function +strcat: + pushl %edi + pushl %esi + + movl 12(%esp), %edi + movl 16(%esp), %esi + + pushl %edi + + xorl %eax, %eax + xorl %ecx, %ecx + decl %ecx + repne scasb + decl %edi + +.Lloop: + lodsb + stosb + testb %al, %al + jnz .Lloop + + popl %eax + popl %esi + popl %edi + ret diff --git a/mdk-stage1/dietlibc/i386/strchr.S b/mdk-stage1/dietlibc/i386/strchr.S new file mode 100644 index 000000000..4515d9835 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/strchr.S @@ -0,0 +1,22 @@ + +.text +.type strchr,@function +.global strchr +.weak index +.type index,@function + +index: +strchr: + movl 4(%esp),%ecx + movb 8(%esp),%dl +.Lloop: + movb (%ecx),%al + cmpb %al,%dl + jz .Lfound + incl %ecx + testb %al,%al + jnz .Lloop + xorl %ecx,%ecx +.Lfound: + movl %ecx,%eax + ret diff --git a/mdk-stage1/dietlibc/i386/strcmp.S b/mdk-stage1/dietlibc/i386/strcmp.S new file mode 100644 index 000000000..e01064ffb --- /dev/null +++ b/mdk-stage1/dietlibc/i386/strcmp.S @@ -0,0 +1,31 @@ +.text +.global strcmp +.type strcmp,@function +.weak strcoll +.type strcoll,@function + +#ifdef HIGH_PERFORMANCE +.align 16 +#endif + +.Ldiff: + movzbl (%edx), %ecx + subl %ecx, %eax # (unsigned char)*p - (unsigned char)*q, so wie die Original libc + ret # und ohne Überlaufprobleme: + # (int) ((signed char)c - (signed char)d) != (int)(signed char) ((unsigned char)c - (unsigned char)d) + # c = 'ä', d = 'e': left expression: -129, right expression: 127 + +strcoll: +strcmp: + movl 4(%esp), %ecx + movl 8(%esp), %edx + xorl %eax, %eax +.Lloop: # Schleifenanfang liegt genau auf Modulanfang + 0x10, damit alignbar + movb (%ecx), %al + cmpb (%edx), %al + jnz .Ldiff + incl %edx + incl %ecx + testb %al, %al + jnz .Lloop + ret diff --git a/mdk-stage1/dietlibc/i386/strcpy.S b/mdk-stage1/dietlibc/i386/strcpy.S new file mode 100644 index 000000000..a597436bc --- /dev/null +++ b/mdk-stage1/dietlibc/i386/strcpy.S @@ -0,0 +1,24 @@ + +.text +.align 0 +.global strcpy +.type strcpy,@function +strcpy: + pushl %esi + pushl %edi + + movl 12(%esp), %edx + movl 16(%esp), %esi + movl %edx, %edi + cld + +.Lloop: + lodsb + stosb + orb %al, %al + jnz .Lloop + + popl %edi + popl %esi + movl %edx,%eax + ret diff --git a/mdk-stage1/dietlibc/i386/strlen.S b/mdk-stage1/dietlibc/i386/strlen.S new file mode 100644 index 000000000..66f8ee553 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/strlen.S @@ -0,0 +1,18 @@ + +.text +.type strlen,@function +.global strlen + +strlen: + movl 4(%esp),%ecx + xorl %eax,%eax + jecxz .Lnull + decl %eax +.Llbl: incl %eax + cmpb $0,(%ecx, %eax) + jne .Llbl +.Lnull: ret + +.Lende: + +.size strlen,.Lende-strlen diff --git a/mdk-stage1/dietlibc/i386/strncmp.S b/mdk-stage1/dietlibc/i386/strncmp.S new file mode 100644 index 000000000..bf07b07d0 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/strncmp.S @@ -0,0 +1,28 @@ +.text +.align 0 +.global strncmp +.type strncmp,@function +strncmp: + push %ebx + movl %esp,%ebx + movl 12(%ebx),%edx + movl 16(%ebx),%ecx + movl 8(%ebx),%ebx +.Lloop: + jecxz .Ldone + decl %ecx + movb (%ebx),%al + incl %edx + incl %ebx + movb %al,%ah + subb -1(%edx),%al + jnz .Lnotequal + testb %ah,%ah + jnz .Lloop + +.Ldone: + xorl %eax,%eax +.Lnotequal: + movsx %al, %eax + popl %ebx + ret diff --git a/mdk-stage1/dietlibc/i386/strncpy.S b/mdk-stage1/dietlibc/i386/strncpy.S new file mode 100644 index 000000000..837b43c41 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/strncpy.S @@ -0,0 +1,42 @@ +/* + Copyright (C) 2002 Thomas M. Ogrisegg + + This is free software. You can redistribute and + modify it under the terms of the GNU General Public + Public License. + + strncpy.S + i386 assembler implementation of strncpy(3) +*/ + +#include "dietfeatures.h" + +.text +.globl strncpy +.type strncpy,@function + +strncpy: + pushl %esi + pushl %edi + movl %esp, %ecx + movl 0x0c(%ecx), %edi + movl 0x10(%ecx), %esi + movl 0x14(%ecx), %ecx + + movl %edi, %edx + +.Lloop: + dec %ecx + js .Lout + lodsb + stosb + or %al, %al + jnz .Lloop +#ifdef WANT_FULL_POSIX_COMPAT + repnz stosb +#endif +.Lout: + movl %edx, %eax + popl %edi + popl %esi + ret diff --git a/mdk-stage1/dietlibc/i386/strrchr.S b/mdk-stage1/dietlibc/i386/strrchr.S new file mode 100644 index 000000000..9fd6e8b32 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/strrchr.S @@ -0,0 +1,19 @@ +.text +.globl strrchr +.type strrchr,@function + +strrchr: + movl 0x4(%esp), %edx + movb 0x8(%esp), %cl + xorl %eax, %eax + decl %edx +.Lloop: + incl %edx + cmpb $0x0,(%edx) + jz .Lret + cmpb %cl, (%edx) + jnz .Lloop + movl %edx, %eax + jmp .Lloop +.Lret: + ret diff --git a/mdk-stage1/dietlibc/i386/syscalls.h b/mdk-stage1/dietlibc/i386/syscalls.h new file mode 100644 index 000000000..3cbf7b605 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/syscalls.h @@ -0,0 +1,303 @@ + +#define __NR_exit 1 +#define __NR_fork 2 +#define __NR_read 3 +#define __NR_write 4 +#define __NR_open 5 +#define __NR_close 6 +#define __NR_waitpid 7 +#define __NR_creat 8 +#define __NR_link 9 +#define __NR_unlink 10 +#define __NR_execve 11 +#define __NR_chdir 12 +#define __NR_time 13 +#define __NR_mknod 14 +#define __NR_chmod 15 +#define __NR_lchown 16 +#define __NR_break 17 +#define __NR_oldstat 18 +#define __NR_lseek 19 +#define __NR_getpid 20 +#define __NR_mount 21 +#define __NR_umount 22 +#define __NR_setuid 23 +#define __NR_getuid 24 +#define __NR_stime 25 +#define __NR_ptrace 26 +#define __NR_alarm 27 +#define __NR_oldfstat 28 +#define __NR_pause 29 +#define __NR_utime 30 +#define __NR_stty 31 +#define __NR_gtty 32 +#define __NR_access 33 +#define __NR_nice 34 +#define __NR_ftime 35 +#define __NR_sync 36 +#define __NR_kill 37 +#define __NR_rename 38 +#define __NR_mkdir 39 +#define __NR_rmdir 40 +#define __NR_dup 41 +#define __NR_pipe 42 +#define __NR_times 43 +#define __NR_prof 44 +#define __NR_brk 45 +#define __NR_setgid 46 +#define __NR_getgid 47 +#define __NR_signal 48 +#define __NR_geteuid 49 +#define __NR_getegid 50 +#define __NR_acct 51 +#define __NR_umount2 52 +#define __NR_lock 53 +#define __NR_ioctl 54 +#define __NR_fcntl 55 +#define __NR_mpx 56 +#define __NR_setpgid 57 +#define __NR_ulimit 58 +#define __NR_oldolduname 59 +#define __NR_umask 60 +#define __NR_chroot 61 +#define __NR_ustat 62 +#define __NR_dup2 63 +#define __NR_getppid 64 +#define __NR_getpgrp 65 +#define __NR_setsid 66 +#define __NR_sigaction 67 +#define __NR_sgetmask 68 +#define __NR_ssetmask 69 +#define __NR_setreuid 70 +#define __NR_setregid 71 +#define __NR_sigsuspend 72 +#define __NR_sigpending 73 +#define __NR_sethostname 74 +#define __NR_setrlimit 75 +#define __NR_getrlimit 76 /* Back compatible 2Gig limited rlimit */ +#define __NR_getrusage 77 +#define __NR_gettimeofday 78 +#define __NR_settimeofday 79 +#define __NR_getgroups 80 +#define __NR_setgroups 81 +#define __NR_select 82 +#define __NR_symlink 83 +#define __NR_oldlstat 84 +#define __NR_readlink 85 +#define __NR_uselib 86 +#define __NR_swapon 87 +#define __NR_reboot 88 +#define __NR_readdir 89 +#define __NR_mmap 90 +#define __NR_munmap 91 +#define __NR_truncate 92 +#define __NR_ftruncate 93 +#define __NR_fchmod 94 +#define __NR_fchown 95 +#define __NR_getpriority 96 +#define __NR_setpriority 97 +#define __NR_profil 98 +#define __NR_statfs 99 +#define __NR_fstatfs 100 +#define __NR_ioperm 101 +#define __NR_socketcall 102 +#define __NR_syslog 103 +#define __NR_setitimer 104 +#define __NR_getitimer 105 +#define __NR_stat 106 +#define __NR_lstat 107 +#define __NR_fstat 108 +#define __NR_olduname 109 +#define __NR_iopl 110 +#define __NR_vhangup 111 +#define __NR_idle 112 +#define __NR_vm86old 113 +#define __NR_wait4 114 +#define __NR_swapoff 115 +#define __NR_sysinfo 116 +#define __NR_ipc 117 +#define __NR_fsync 118 +#define __NR_sigreturn 119 +#define __NR_clone 120 +#define __NR_setdomainname 121 +#define __NR_uname 122 +#define __NR_modify_ldt 123 +#define __NR_adjtimex 124 +#define __NR_mprotect 125 +#define __NR_sigprocmask 126 +#define __NR_create_module 127 +#define __NR_init_module 128 +#define __NR_delete_module 129 +#define __NR_get_kernel_syms 130 +#define __NR_quotactl 131 +#define __NR_getpgid 132 +#define __NR_fchdir 133 +#define __NR_bdflush 134 +#define __NR_sysfs 135 +#define __NR_personality 136 +#define __NR_afs_syscall 137 /* Syscall for Andrew File System */ +#define __NR_setfsuid 138 +#define __NR_setfsgid 139 +#define __NR__llseek 140 +#define __NR_getdents 141 +#define __NR__newselect 142 +#define __NR_flock 143 +#define __NR_msync 144 +#define __NR_readv 145 +#define __NR_writev 146 +#define __NR_getsid 147 +#define __NR_fdatasync 148 +#define __NR__sysctl 149 +#define __NR_mlock 150 +#define __NR_munlock 151 +#define __NR_mlockall 152 +#define __NR_munlockall 153 +#define __NR_sched_setparam 154 +#define __NR_sched_getparam 155 +#define __NR_sched_setscheduler 156 +#define __NR_sched_getscheduler 157 +#define __NR_sched_yield 158 +#define __NR_sched_get_priority_max 159 +#define __NR_sched_get_priority_min 160 +#define __NR_sched_rr_get_interval 161 +#define __NR_nanosleep 162 +#define __NR_mremap 163 +#define __NR_setresuid 164 +#define __NR_getresuid 165 +#define __NR_vm86 166 +#define __NR_query_module 167 +#define __NR_poll 168 +#define __NR_nfsservctl 169 +#define __NR_setresgid 170 +#define __NR_getresgid 171 +#define __NR_prctl 172 +#define __NR_rt_sigreturn 173 +#define __NR_rt_sigaction 174 +#define __NR_rt_sigprocmask 175 +#define __NR_rt_sigpending 176 +#define __NR_rt_sigtimedwait 177 +#define __NR_rt_sigqueueinfo 178 +#define __NR_rt_sigsuspend 179 +#define __NR_pread 180 +#define __NR_pwrite 181 +#define __NR_chown 182 +#define __NR_getcwd 183 +#define __NR_capget 184 +#define __NR_capset 185 +#define __NR_sigaltstack 186 +#define __NR_sendfile 187 +#define __NR_getpmsg 188 /* some people actually want streams */ +#define __NR_putpmsg 189 /* some people actually want streams */ +#define __NR_vfork 190 +#define __NR_ugetrlimit 191 /* SuS compliant getrlimit */ +#define __NR_mmap2 192 +#define __NR_truncate64 193 +#define __NR_ftruncate64 194 +#define __NR_stat64 195 +#define __NR_lstat64 196 +#define __NR_fstat64 197 +#define __NR_lchown32 198 +#define __NR_getuid32 199 +#define __NR_getgid32 200 +#define __NR_geteuid32 201 +#define __NR_getegid32 202 +#define __NR_setreuid32 203 +#define __NR_setregid32 204 +#define __NR_getgroups32 205 +#define __NR_setgroups32 206 +#define __NR_fchown32 207 +#define __NR_setresuid32 208 +#define __NR_getresuid32 209 +#define __NR_setresgid32 210 +#define __NR_getresgid32 211 +#define __NR_chown32 212 +#define __NR_setuid32 213 +#define __NR_setgid32 214 +#define __NR_setfsuid32 215 +#define __NR_setfsgid32 216 +#define __NR_pivot_root 217 +#define __NR_mincore 218 +#define __NR_madvise 219 +#define __NR_madvise1 219 /* delete when C lib stub is removed */ +#define __NR_getdents64 220 +#define __NR_fcntl64 221 +#define __NR_security 223 /* syscall for security modules */ +#define __NR_gettid 224 +#define __NR_readahead 225 +#define __NR_setxattr 226 +#define __NR_lsetxattr 227 +#define __NR_fsetxattr 228 +#define __NR_getxattr 229 +#define __NR_lgetxattr 230 +#define __NR_fgetxattr 231 +#define __NR_listxattr 232 +#define __NR_llistxattr 233 +#define __NR_flistxattr 234 +#define __NR_removexattr 235 +#define __NR_lremovexattr 236 +#define __NR_fremovexattr 237 +#define __NR_tkill 238 +#define __NR_sendfile64 239 +#define __NR_futex 240 +#define __NR_sched_setaffinity 241 +#define __NR_sched_getaffinity 242 +#define __NR_set_thread_area 243 +#define __NR_get_thread_area 244 +#define __NR_io_setup 245 +#define __NR_io_destroy 246 +#define __NR_io_getevents 247 +#define __NR_io_submit 248 +#define __NR_io_cancel 249 +#define __NR_alloc_hugepages 250 +#define __NR_free_hugepages 251 +#define __NR_exit_group 252 +#define __NR_lookup_dcookie 253 +#define __NR_sys_epoll_create 254 +#define __NR_sys_epoll_ctl 255 +#define __NR_sys_epoll_wait 256 +#define __NR_remap_file_pages 257 +#define __NR_set_tid_address 258 + +#define syscall_weak(name,wsym,sym) \ +.text; \ +.type wsym,@function; \ +.weak wsym; \ +wsym: ; \ +.type sym,@function; \ +.global sym; \ +sym: \ + movb $__NR_##name,%al; \ + jmp __unified_syscall; \ +.Lend##sym: ; \ +.size sym,.Lend##sym-sym + +#define syscall(name,sym) \ +.text; \ +.type sym,@function; \ +.global sym; \ +sym: \ +.ifle __NR_##name-255; \ + movb $__NR_##name,%al; \ + jmp __unified_syscall; \ +.else; \ + movw $__NR_##name,%ax; \ + jmp __unified_syscall_256; \ +.endif; \ +.Lend##sym: ; \ +.size sym,.Lend##sym-sym + +#ifndef __PIC__ +#define __socketcall(name,NAME) \ +.text; \ +.type name,@function; \ +.weak name; \ +name: ; \ +.global __libc_##name; \ +__libc_##name: ; \ + movb $SYS_##NAME,%al; \ + jmp socketcall; \ +.Lend##name:; \ +.size name,.Lend##name-name +#else +#define __socketcall(name,NAME) +#endif diff --git a/mdk-stage1/dietlibc/i386/tan.S b/mdk-stage1/dietlibc/i386/tan.S new file mode 100644 index 000000000..4904c2d59 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/tan.S @@ -0,0 +1,12 @@ + +.text +.type tan,@function +.global tan +tan: + fldl 4(%esp) + fsincos + fdivrp + ret + +.Lende: +.size tan,.Lende-tan diff --git a/mdk-stage1/dietlibc/i386/tanh.S b/mdk-stage1/dietlibc/i386/tanh.S new file mode 100644 index 000000000..61d3f3376 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/tanh.S @@ -0,0 +1,32 @@ + +.text +.type tanh,@function +.global tanh + +tanh: # note: exp(x) = 2^(x*log2(e)) + fldl2e + fmull 4(%esp) # x*log2(e) + fld %st(0) # x*log2(e) x*log2(e) + frndint # int(x*log2(e)) x*log2(e) + fxch # x*log2(e) int(x*log2(e)) + fsub %st(1),%st(0) # frac(x*log2(e)) int(x*log2(e)) + f2xm1 # 2^(fract(x*log2(e)))-1 int(x*log2(e)) + fld1 # 1 2^(fract(x*log2(e)))-1 int(x*log2(e)) + faddp %st(0),%st(1) # 2^(fract(x*log2(e))) int(x*log2(e)) + fscale # 2^(x*log2(e)) int(x*log2(e)) + fstp %st(1) # 2^(x*log2(e)) + +# now we have y = exp(x), but tanh(x) = (y - 1/y) / (y + 1/y) + + fld1 + fdiv %st(1),%st(0) # 1/y y + fld %st(0) # 1/y 1/y y + fadd %st(2) # y+1/y 1/y y + fxch %st(2) # y 1/y y+1/y + fsubp # y-1/y y+1/y + fdivp # (y-1/y)/(y+1/y) + ret + +.Lende: + +.size tanh,.ende-tanh diff --git a/mdk-stage1/dietlibc/i386/usleep.S b/mdk-stage1/dietlibc/i386/usleep.S new file mode 100644 index 000000000..7c0cc6ce7 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/usleep.S @@ -0,0 +1,31 @@ +#include "PIC.h" + +.text +.global usleep +.type usleep,@function + +usleep: + movl 4(%esp),%eax + PIC_SAVE # non-PIC: empty line + PIC_INIT # non-PIC: empty line + xorl %edx,%edx + movl $1000000,%ecx + divl %ecx + imull $1000,%edx + pushl %edx + pushl %eax + movl %esp,%eax + pushl %eax + pushl %eax +#ifdef __DYN_LIB + call nanosleep@PLT +#else + call nanosleep +#endif + addl $16,%esp + PIC_RESTORE # non-PIC: empty line + ret + +.Lende: +.size usleep,.Lende-usleep + diff --git a/mdk-stage1/dietlibc/i386/vfork.S b/mdk-stage1/dietlibc/i386/vfork.S new file mode 100644 index 000000000..c07c5f6af --- /dev/null +++ b/mdk-stage1/dietlibc/i386/vfork.S @@ -0,0 +1,9 @@ +.text +.globl vfork +vfork: + popl %edx + xorl %eax,%eax + movb $190, %al + int $0x80 + jmpl *%edx +.size vfork, . - vfork diff --git a/mdk-stage1/dietlibc/i386/write12.S b/mdk-stage1/dietlibc/i386/write12.S new file mode 100644 index 000000000..a40f63a86 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/write12.S @@ -0,0 +1,37 @@ +#include "PIC.h" + +.text + +.global __write1 +.type __write1,@function + +.global __write2 +.type __write2,@function + + # regparm=1, daher Stringadresse in %eax +__write2: + clc # CY = 0 + .byte 0xB2 # zusammen mit nächstem Byte: mov dl,0xF9 +__write1: + stc # CY = 1 + sbbl %ecx,%ecx # __write2: ecx=0, __write1: ecx=-1 + incl %ecx + incl %ecx # __write2: ecx=2, __write1: ecx=1 + xorl %edx,%edx + decl %edx +.Lnext: incl %edx + cmpb %ch,(%edx,%eax) # ch=0, da bei beiden Filedescriptoren Bits 15:8 0 sind + jnz .Lnext # Stringlänge in edx, ohne eax zerstört zu haben + PIC_SAVE # non-PIC: empty line + PIC_INIT # non-PIC: empty line + pushl %edx + pushl %eax + pushl %ecx +#ifdef __DYN_LIB + call write@PLT +#else + call write # alles ruf uf dn Stack und ab damit +#endif + addl $12,%esp # und das leidvolle Putzen + PIC_RESTORE # non-PIC: empty line + ret diff --git a/mdk-stage1/dietlibc/ia64/Makefile.add b/mdk-stage1/dietlibc/ia64/Makefile.add new file mode 100644 index 000000000..f660930af --- /dev/null +++ b/mdk-stage1/dietlibc/ia64/Makefile.add @@ -0,0 +1,2 @@ +VPATH:=ia64:syscalls.s:$(VPATH) +LIBOBJ+=$(OBJDIR)/__time.o $(OBJDIR)/__waitpid.o $(OBJDIR)/__nice.o $(OBJDIR)/__alarm.o diff --git a/mdk-stage1/dietlibc/ia64/README b/mdk-stage1/dietlibc/ia64/README new file mode 100644 index 000000000..684364d93 --- /dev/null +++ b/mdk-stage1/dietlibc/ia64/README @@ -0,0 +1,4 @@ +A Port for IA64. + +Does not yet support: clone, FPU and profiling. And includes +some subtle bugs which will hopefully be fixed later. diff --git a/mdk-stage1/dietlibc/ia64/__alarm.c b/mdk-stage1/dietlibc/ia64/__alarm.c new file mode 100644 index 000000000..e2c499f2c --- /dev/null +++ b/mdk-stage1/dietlibc/ia64/__alarm.c @@ -0,0 +1 @@ +#include "alpha/__alarm.c" diff --git a/mdk-stage1/dietlibc/ia64/__longjmp.S b/mdk-stage1/dietlibc/ia64/__longjmp.S new file mode 100644 index 000000000..698bda528 --- /dev/null +++ b/mdk-stage1/dietlibc/ia64/__longjmp.S @@ -0,0 +1 @@ +/* No longjmp yet */ diff --git a/mdk-stage1/dietlibc/ia64/__nice.c b/mdk-stage1/dietlibc/ia64/__nice.c new file mode 100644 index 000000000..012ea2628 --- /dev/null +++ b/mdk-stage1/dietlibc/ia64/__nice.c @@ -0,0 +1,6 @@ +#include + +int nice(int x) { + if (setpriority(PRIO_PROCESS,0,x)) return -1; + return getpriority(PRIO_PROCESS,0); +} diff --git a/mdk-stage1/dietlibc/ia64/__testandset.S b/mdk-stage1/dietlibc/ia64/__testandset.S new file mode 100644 index 000000000..d462e3c58 --- /dev/null +++ b/mdk-stage1/dietlibc/ia64/__testandset.S @@ -0,0 +1,11 @@ +.text +.globl __testandset +.proc __testandset +__testandset: + mov ar.ccv = r0 + mov r29 = 1 + ld8 r3 = [r32] + cmpxchg8.acq r8 = [r32], r29, ar.ccv /* cmpxchg is atomic */ + br.ret.sptk.clr b0 +.endp __testandset +.size __testandset, . - __testandset diff --git a/mdk-stage1/dietlibc/ia64/__time.c b/mdk-stage1/dietlibc/ia64/__time.c new file mode 100644 index 000000000..7547acb1d --- /dev/null +++ b/mdk-stage1/dietlibc/ia64/__time.c @@ -0,0 +1,14 @@ +#include +#include + +time_t time(time_t*t) { + struct timeval tv; + time_t ret; + if (gettimeofday(&tv,0)) { + ret=(time_t)-1; + } else { + ret=(time_t)tv.tv_sec; + } + if (t) *t=ret; + return ret; +} diff --git a/mdk-stage1/dietlibc/ia64/__waitpid.c b/mdk-stage1/dietlibc/ia64/__waitpid.c new file mode 100644 index 000000000..8c228f375 --- /dev/null +++ b/mdk-stage1/dietlibc/ia64/__waitpid.c @@ -0,0 +1,5 @@ +#include + +pid_t waitpid(int pid, int * wait_stat, int flags) { + return wait4(pid, wait_stat, flags, 0); +} diff --git a/mdk-stage1/dietlibc/ia64/accept.S b/mdk-stage1/dietlibc/ia64/accept.S new file mode 100644 index 000000000..7bdc38c7e --- /dev/null +++ b/mdk-stage1/dietlibc/ia64/accept.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(accept, accept); diff --git a/mdk-stage1/dietlibc/ia64/bind.S b/mdk-stage1/dietlibc/ia64/bind.S new file mode 100644 index 000000000..05849d470 --- /dev/null +++ b/mdk-stage1/dietlibc/ia64/bind.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(bind, bind); diff --git a/mdk-stage1/dietlibc/ia64/clone.S b/mdk-stage1/dietlibc/ia64/clone.S new file mode 100644 index 000000000..ba768141c --- /dev/null +++ b/mdk-stage1/dietlibc/ia64/clone.S @@ -0,0 +1,41 @@ +/* This is untested code which probably won´t work out of the box! */ + +#include "syscalls.h" +#include + +.text +.globl __clone +.proc __clone +.weak __clone2 +__clone2: +__clone: + mov r8 = EINVAL + cmp.eq p6,p0=0,r32 +(p6) br.cond.spnt.few __error_unified_syscall + cmp.eq p6,p0=0,r33 +(p6) br.cond.spnt.few __error_unified_syscall + flushrs + + mov.m r17 = ar.rsc + mov r14 = r32 + mov r18 = r33 + mov r16 = r36;; + mov r15 = __NR_clone2 + break 0x100000 + cmp.eq p6,p0=-1,r10 +(p6) br.cond.spnt.few __error_unified_syscall + cmp.eq p6,p7=0,r8 +(p6) ld8 r34=[r14],8 +(p6) mov.m ar.bspstore=r18 +(p6) mov r32 = r16 + mov.m ar.rsc = r17 +(p7) br.ret.sptk b0 + ld8 r1 = [r14] + mov b6 = r34 + br.call.dptk.few b0=b6 + mov r32 = r8 + br.call.dptk.few b0=__error_unified_syscall + br.ret.sptk.few b0 +.endp __clone +.endp __clone2 +.size __clone, . - __clone diff --git a/mdk-stage1/dietlibc/ia64/connect.S b/mdk-stage1/dietlibc/ia64/connect.S new file mode 100644 index 000000000..5fbd151ae --- /dev/null +++ b/mdk-stage1/dietlibc/ia64/connect.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(connect, connect); diff --git a/mdk-stage1/dietlibc/ia64/fork.S b/mdk-stage1/dietlibc/ia64/fork.S new file mode 100644 index 000000000..3b253a80b --- /dev/null +++ b/mdk-stage1/dietlibc/ia64/fork.S @@ -0,0 +1,8 @@ +#include "syscalls.h" + +.text +.globl fork +fork: + mov r15 = __NR_clone + mov r32 = 17 + br __unified_syscall diff --git a/mdk-stage1/dietlibc/ia64/getpeername.S b/mdk-stage1/dietlibc/ia64/getpeername.S new file mode 100644 index 000000000..fdaa1038a --- /dev/null +++ b/mdk-stage1/dietlibc/ia64/getpeername.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(getpeername, getpeername); diff --git a/mdk-stage1/dietlibc/ia64/getsockname.S b/mdk-stage1/dietlibc/ia64/getsockname.S new file mode 100644 index 000000000..1ea0bc000 --- /dev/null +++ b/mdk-stage1/dietlibc/ia64/getsockname.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(getsockname, getsockname); diff --git a/mdk-stage1/dietlibc/ia64/getsockopt.S b/mdk-stage1/dietlibc/ia64/getsockopt.S new file mode 100644 index 000000000..465c4e08e --- /dev/null +++ b/mdk-stage1/dietlibc/ia64/getsockopt.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(getsockopt, getsockopt); diff --git a/mdk-stage1/dietlibc/ia64/listen.S b/mdk-stage1/dietlibc/ia64/listen.S new file mode 100644 index 000000000..66a3fe376 --- /dev/null +++ b/mdk-stage1/dietlibc/ia64/listen.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(listen, listen); diff --git a/mdk-stage1/dietlibc/ia64/mmap.S b/mdk-stage1/dietlibc/ia64/mmap.S new file mode 100644 index 000000000..cca4bbdbb --- /dev/null +++ b/mdk-stage1/dietlibc/ia64/mmap.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall (mmap, mmap) diff --git a/mdk-stage1/dietlibc/ia64/msgctl.S b/mdk-stage1/dietlibc/ia64/msgctl.S new file mode 100644 index 000000000..d7caed2cc --- /dev/null +++ b/mdk-stage1/dietlibc/ia64/msgctl.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(msgctl,msgctl) diff --git a/mdk-stage1/dietlibc/ia64/msgget.S b/mdk-stage1/dietlibc/ia64/msgget.S new file mode 100644 index 000000000..518d67ac4 --- /dev/null +++ b/mdk-stage1/dietlibc/ia64/msgget.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(msgget,msgget) diff --git a/mdk-stage1/dietlibc/ia64/msgrcv.S b/mdk-stage1/dietlibc/ia64/msgrcv.S new file mode 100644 index 000000000..ab62e6c30 --- /dev/null +++ b/mdk-stage1/dietlibc/ia64/msgrcv.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(msgrcv,msgrcv) diff --git a/mdk-stage1/dietlibc/ia64/msgsnd.S b/mdk-stage1/dietlibc/ia64/msgsnd.S new file mode 100644 index 000000000..890a996a2 --- /dev/null +++ b/mdk-stage1/dietlibc/ia64/msgsnd.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(msgsnd,msgsnd) diff --git a/mdk-stage1/dietlibc/ia64/pipe.S b/mdk-stage1/dietlibc/ia64/pipe.S new file mode 100644 index 000000000..c3bf4570b --- /dev/null +++ b/mdk-stage1/dietlibc/ia64/pipe.S @@ -0,0 +1,20 @@ +#include "syscalls.h" + +.text +.globl pipe +.proc pipe + +pipe: + st8 [r12] = r32 + mov r15 = __NR_pipe + break.i 0x100000 + ld8 r2 = [r12] + cmp.eq p7,p6=-1,r10 +(p6) st4 [r2] = r8,4 + mov r8 = r0 +(p7) br.cond.spnt.few __error_unified_syscall +(p6) st4 [r2] = r9 +(p6) br.ret.sptk.few b0 + +.endp pipe +.size pipe, . - pipe diff --git a/mdk-stage1/dietlibc/ia64/recv.S b/mdk-stage1/dietlibc/ia64/recv.S new file mode 100644 index 000000000..1f1640390 --- /dev/null +++ b/mdk-stage1/dietlibc/ia64/recv.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(recv, recv); diff --git a/mdk-stage1/dietlibc/ia64/recvfrom.S b/mdk-stage1/dietlibc/ia64/recvfrom.S new file mode 100644 index 000000000..d3c2e602f --- /dev/null +++ b/mdk-stage1/dietlibc/ia64/recvfrom.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(recvfrom, recvfrom); diff --git a/mdk-stage1/dietlibc/ia64/recvmsg.S b/mdk-stage1/dietlibc/ia64/recvmsg.S new file mode 100644 index 000000000..cfbbafdc1 --- /dev/null +++ b/mdk-stage1/dietlibc/ia64/recvmsg.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(recvmsg, recvmsg); diff --git a/mdk-stage1/dietlibc/ia64/semctl.S b/mdk-stage1/dietlibc/ia64/semctl.S new file mode 100644 index 000000000..e215ed955 --- /dev/null +++ b/mdk-stage1/dietlibc/ia64/semctl.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(semctl,semctl) diff --git a/mdk-stage1/dietlibc/ia64/semget.S b/mdk-stage1/dietlibc/ia64/semget.S new file mode 100644 index 000000000..67f488546 --- /dev/null +++ b/mdk-stage1/dietlibc/ia64/semget.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(semget,semget) diff --git a/mdk-stage1/dietlibc/ia64/semop.S b/mdk-stage1/dietlibc/ia64/semop.S new file mode 100644 index 000000000..81b6fc606 --- /dev/null +++ b/mdk-stage1/dietlibc/ia64/semop.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(semop,semop) diff --git a/mdk-stage1/dietlibc/ia64/send.S b/mdk-stage1/dietlibc/ia64/send.S new file mode 100644 index 000000000..38f47f398 --- /dev/null +++ b/mdk-stage1/dietlibc/ia64/send.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(send, send); diff --git a/mdk-stage1/dietlibc/ia64/sendmsg.S b/mdk-stage1/dietlibc/ia64/sendmsg.S new file mode 100644 index 000000000..c2bc80f72 --- /dev/null +++ b/mdk-stage1/dietlibc/ia64/sendmsg.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(sendmsg, sendmsg); diff --git a/mdk-stage1/dietlibc/ia64/sendto.S b/mdk-stage1/dietlibc/ia64/sendto.S new file mode 100644 index 000000000..1579a3b45 --- /dev/null +++ b/mdk-stage1/dietlibc/ia64/sendto.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(sendto, sendto); diff --git a/mdk-stage1/dietlibc/ia64/setjmp.S b/mdk-stage1/dietlibc/ia64/setjmp.S new file mode 100644 index 000000000..f0f5bc431 --- /dev/null +++ b/mdk-stage1/dietlibc/ia64/setjmp.S @@ -0,0 +1 @@ +/* No, I am not going to save 128 registers */ diff --git a/mdk-stage1/dietlibc/ia64/setsockopt.S b/mdk-stage1/dietlibc/ia64/setsockopt.S new file mode 100644 index 000000000..45fcfbb6c --- /dev/null +++ b/mdk-stage1/dietlibc/ia64/setsockopt.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(setsockopt, setsockopt); diff --git a/mdk-stage1/dietlibc/ia64/shmat.S b/mdk-stage1/dietlibc/ia64/shmat.S new file mode 100644 index 000000000..51248173d --- /dev/null +++ b/mdk-stage1/dietlibc/ia64/shmat.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(shmat,shmat) diff --git a/mdk-stage1/dietlibc/ia64/shmctl.S b/mdk-stage1/dietlibc/ia64/shmctl.S new file mode 100644 index 000000000..d56caace4 --- /dev/null +++ b/mdk-stage1/dietlibc/ia64/shmctl.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(shmctl,shmctl) diff --git a/mdk-stage1/dietlibc/ia64/shmdt.S b/mdk-stage1/dietlibc/ia64/shmdt.S new file mode 100644 index 000000000..d9812a799 --- /dev/null +++ b/mdk-stage1/dietlibc/ia64/shmdt.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(shmdt,shmdt) diff --git a/mdk-stage1/dietlibc/ia64/shmget.S b/mdk-stage1/dietlibc/ia64/shmget.S new file mode 100644 index 000000000..82914223f --- /dev/null +++ b/mdk-stage1/dietlibc/ia64/shmget.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(shmget,shmget) diff --git a/mdk-stage1/dietlibc/ia64/shutdown.S b/mdk-stage1/dietlibc/ia64/shutdown.S new file mode 100644 index 000000000..024e99e18 --- /dev/null +++ b/mdk-stage1/dietlibc/ia64/shutdown.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(shutdown, shutdown); diff --git a/mdk-stage1/dietlibc/ia64/socket.S b/mdk-stage1/dietlibc/ia64/socket.S new file mode 100644 index 000000000..cc453881f --- /dev/null +++ b/mdk-stage1/dietlibc/ia64/socket.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(socket, socket); diff --git a/mdk-stage1/dietlibc/ia64/socketpair.S b/mdk-stage1/dietlibc/ia64/socketpair.S new file mode 100644 index 000000000..d92eaa4d8 --- /dev/null +++ b/mdk-stage1/dietlibc/ia64/socketpair.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(socketpair, socketpair); diff --git a/mdk-stage1/dietlibc/ia64/start.S b/mdk-stage1/dietlibc/ia64/start.S new file mode 100644 index 000000000..dbacb25f6 --- /dev/null +++ b/mdk-stage1/dietlibc/ia64/start.S @@ -0,0 +1,45 @@ +/* + Copyright (C) 2002 Thomas M. Ogrisegg + + This is free software. You can redistribute and + modify it under the terms of the GNU General Public + Public License. + + This file is part of the IA64-Port of the dietlibc + + start.S + Implemenation of the _start startup function +*/ + +.psr abi64 +.psr lsb +.lsb + +.text +.globl _start +.proc _start + +_start: + alloc r2 = ar.pfs,0,0,7,0 + adds out1 = 16, sp /* base arguments */ + movl gp = @gprel(0f) /* base offset */ + ;; +0: + ld8 out0 = [out1], 8 /* load argc and set argv */ + mov r9 = ip + ;; + shladd out2=out0,3,out1 /* envp = argv+8*argc */ + sub gp = r9, gp /* subtract program counter */ + ;; + addl r15 = @ltoff(environ#), gp /* offset to environ */ + adds out2 = 8, out2 /* envp += 8 */ + ;; + ld8 r14 = [r15] + ;; + st8 [r14] = out2 /* store envp in environ */ + br.call.sptk.few rp = main /* call main */ + ;; + mov r32 = r8 /* store return code */ + br _exit /* branch to _exit */ +.endp _start +.size _start, . - _start diff --git a/mdk-stage1/dietlibc/ia64/syscalls.h b/mdk-stage1/dietlibc/ia64/syscalls.h new file mode 100644 index 000000000..65eda0ed2 --- /dev/null +++ b/mdk-stage1/dietlibc/ia64/syscalls.h @@ -0,0 +1,242 @@ +#ifndef __DLIBC_SYSCALL_H_ +#define __DLIBC_SYSCALL_H_ + +#define __NR_ni_syscall 1024 +#define __NR_exit 1025 +#define __NR_read 1026 +#define __NR_write 1027 +#define __NR_open 1028 +#define __NR_close 1029 +#define __NR_creat 1030 +#define __NR_link 1031 +#define __NR_unlink 1032 +#define __NR_execve 1033 +#define __NR_chdir 1034 +#define __NR_fchdir 1035 +#define __NR_utimes 1036 +#define __NR_mknod 1037 +#define __NR_chmod 1038 +#define __NR_chown 1039 +#define __NR_lseek 1040 +#define __NR_getpid 1041 +#define __NR_getppid 1042 +#define __NR_mount 1043 +#define __NR_umount 1044 +#define __NR_setuid 1045 +#define __NR_getuid 1046 +#define __NR_geteuid 1047 +#define __NR_ptrace 1048 +#define __NR_access 1049 +#define __NR_sync 1050 +#define __NR_fsync 1051 +#define __NR_fdatasync 1052 +#define __NR_kill 1053 +#define __NR_rename 1054 +#define __NR_mkdir 1055 +#define __NR_rmdir 1056 +#define __NR_dup 1057 +#define __NR_pipe 1058 +#define __NR_times 1059 +#define __NR_brk 1060 +#define __NR_setgid 1061 +#define __NR_getgid 1062 +#define __NR_getegid 1063 +#define __NR_acct 1064 +#define __NR_ioctl 1065 +#define __NR_fcntl 1066 +#define __NR_umask 1067 +#define __NR_chroot 1068 +#define __NR_ustat 1069 +#define __NR_dup2 1070 +#define __NR_setreuid 1071 +#define __NR_setregid 1072 +#define __NR_getresuid 1073 +#define __NR_setresuid 1074 +#define __NR_getresgid 1075 +#define __NR_setresgid 1076 +#define __NR_getgroups 1077 +#define __NR_setgroups 1078 +#define __NR_getpgid 1079 +#define __NR_setpgid 1080 +#define __NR_setsid 1081 +#define __NR_getsid 1082 +#define __NR_sethostname 1083 +#define __NR_setrlimit 1084 +#define __NR_getrlimit 1085 +#define __NR_getrusage 1086 +#define __NR_gettimeofday 1087 +#define __NR_settimeofday 1088 +#define __NR_select 1089 +#define __NR_poll 1090 +#define __NR_symlink 1091 +#define __NR_readlink 1092 +#define __NR_uselib 1093 +#define __NR_swapon 1094 +#define __NR_swapoff 1095 +#define __NR_reboot 1096 +#define __NR_truncate 1097 +#define __NR_ftruncate 1098 +#define __NR_fchmod 1099 +#define __NR_fchown 1100 +#define __NR_getpriority 1101 +#define __NR_setpriority 1102 +#define __NR_statfs 1103 +#define __NR_fstatfs 1104 +#define __NR_gettid 1105 +#define __NR_semget 1106 +#define __NR_semop 1107 +#define __NR_semctl 1108 +#define __NR_msgget 1109 +#define __NR_msgsnd 1110 +#define __NR_msgrcv 1111 +#define __NR_msgctl 1112 +#define __NR_shmget 1113 +#define __NR_shmat 1114 +#define __NR_shmdt 1115 +#define __NR_shmctl 1116 +#define __NR_syslog 1117 +#define __NR_setitimer 1118 +#define __NR_getitimer 1119 +#define __NR_old_stat 1120 +#define __NR_old_lstat 1121 +#define __NR_old_fstat 1122 +#define __NR_vhangup 1123 +#define __NR_lchown 1124 +#define __NR_vm86 1125 +#define __NR_wait4 1126 +#define __NR_sysinfo 1127 +#define __NR_clone 1128 +#define __NR_setdomainname 1129 +#define __NR_uname 1130 +#define __NR_adjtimex 1131 +#define __NR_create_module 1132 +#define __NR_init_module 1133 +#define __NR_delete_module 1134 +#define __NR_get_kernel_syms 1135 +#define __NR_query_module 1136 +#define __NR_quotactl 1137 +#define __NR_bdflush 1138 +#define __NR_sysfs 1139 +#define __NR_personality 1140 +#define __NR_afs_syscall 1141 +#define __NR_setfsuid 1142 +#define __NR_setfsgid 1143 +#define __NR_getdents 1144 +#define __NR_flock 1145 +#define __NR_readv 1146 +#define __NR_writev 1147 +#define __NR_pread 1148 +#define __NR_pwrite 1149 +#define __NR__sysctl 1150 +#define __NR_mmap 1151 +#define __NR_munmap 1152 +#define __NR_mlock 1153 +#define __NR_mlockall 1154 +#define __NR_mprotect 1155 +#define __NR_mremap 1156 +#define __NR_msync 1157 +#define __NR_munlock 1158 +#define __NR_munlockall 1159 +#define __NR_sched_getparam 1160 +#define __NR_sched_setparam 1161 +#define __NR_sched_getscheduler 1162 +#define __NR_sched_setscheduler 1163 +#define __NR_sched_yield 1164 +#define __NR_sched_get_priority_max 1165 +#define __NR_sched_get_priority_min 1166 +#define __NR_sched_rr_get_interval 1167 +#define __NR_nanosleep 1168 +#define __NR_nfsservctl 1169 +#define __NR_prctl 1170 +#define __NR_mmap2 1172 +#define __NR_pciconfig_read 1173 +#define __NR_pciconfig_write 1174 +#define __NR_perfmonctl 1175 +#define __NR_sigaltstack 1176 +#define __NR_rt_sigaction 1177 +#define __NR_rt_sigpending 1178 +#define __NR_rt_sigprocmask 1179 +#define __NR_rt_sigqueueinfo 1180 +#define __NR_rt_sigreturn 1181 +#define __NR_rt_sigsuspend 1182 +#define __NR_rt_sigtimedwait 1183 +#define __NR_getcwd 1184 +#define __NR_capget 1185 +#define __NR_capset 1186 +#define __NR_sendfile 1187 +#define __NR_getpmsg 1188 +#define __NR_putpmsg 1189 +#define __NR_socket 1190 +#define __NR_bind 1191 +#define __NR_connect 1192 +#define __NR_listen 1193 +#define __NR_accept 1194 +#define __NR_getsockname 1195 +#define __NR_getpeername 1196 +#define __NR_socketpair 1197 +#define __NR_send 1198 +#define __NR_sendto 1199 +#define __NR_recv 1200 +#define __NR_recvfrom 1201 +#define __NR_shutdown 1202 +#define __NR_setsockopt 1203 +#define __NR_getsockopt 1204 +#define __NR_sendmsg 1205 +#define __NR_recvmsg 1206 +#define __NR_pivot_root 1207 +#define __NR_mincore 1208 +#define __NR_madvise 1209 +#define __NR_stat 1210 +#define __NR_lstat 1211 +#define __NR_fstat 1212 +#define __NR_clone2 1213 +#define __NR_getdents64 1214 +#define __NR_getunwind 1215 +#define __NR_readahead 1216 +#define __NR_setxattr 1217 +#define __NR_lsetxattr 1218 +#define __NR_fsetxattr 1219 +#define __NR_getxattr 1220 +#define __NR_lgetxattr 1221 +#define __NR_fgetxattr 1222 +#define __NR_listxattr 1223 +#define __NR_llistxattr 1224 +#define __NR_flistxattr 1225 +#define __NR_removexattr 1226 +#define __NR_lremovexattr 1227 +#define __NR_fremovexattr 1228 +#define __NR_tkill 1229 +#define __NR_futex 1230 +#define __NR_sched_setaffinity 1231 +#define __NR_sched_getaffinity 1232 +#define __NR_security 1233 +#define __NR_alloc_hugepages 1234 +#define __NR_free_hugepages 1235 +#define __NR_exit_group 1236 +#define __NR_lookup_dcookie 1237 +#define __NR_io_setup 1238 +#define __NR_io_destroy 1239 +#define __NR_io_getevents 1240 +#define __NR_io_submit 1241 +#define __NR_io_cancel 1242 +#define __NR_epoll_create 1243 +#define __NR_epoll_ctl 1244 +#define __NR_epoll_wait 1245 + +#define syscall(name, sym) \ +.text; \ +.globl sym; \ +sym: \ + mov r15 = __NR_##name; \ + br __unified_syscall; + +#define syscall_weak(name, sym, wsym) \ +.text; \ +.weak wsym; \ +wsym: \ +.globl sym; \ +sym: \ + mov r15 = __NR_##name; \ + br __unified_syscall; + +#endif diff --git a/mdk-stage1/dietlibc/ia64/unified.S b/mdk-stage1/dietlibc/ia64/unified.S new file mode 100644 index 000000000..998fba75e --- /dev/null +++ b/mdk-stage1/dietlibc/ia64/unified.S @@ -0,0 +1,46 @@ +/* + Copyright (C) 2002 Thomas M. Ogrisegg + + This is free software. You can redistribute and + modify it under the terms of the GNU General Public + Public License. + + This file is part of the ia64-Port of dietlibc + + unified.S + General system-call interface +*/ + +.lsb + +.text + +.globl __unified_syscall +.proc __unified_syscall +.globl __error_unified_syscall +.proc __error_unified_syscall +.globl _exit +.proc _exit + +_exit: + mov r15 = 1025 +.endp _exit +.size _exit, . - _exit + +__unified_syscall: + break.i 0x100000 + movl r2=errno + cmp.eq p6,p0=-1,r10 + ;; +__error_unified_syscall: +(p6) st4 [r2]=r8 +(p6) mov r8=-1 + +#include "dietuglyweaks.h" + + br.ret.sptk.few rp + +.endp __unified_syscall +.endp __error_unified_syscall +.size __unified_syscall, __error_unified_syscall - __unified_syscall +.size __error_unified_syscall, . - __error_unified_syscall diff --git a/mdk-stage1/dietlibc/ia64/utime.S b/mdk-stage1/dietlibc/ia64/utime.S new file mode 100644 index 000000000..a9a8aada6 --- /dev/null +++ b/mdk-stage1/dietlibc/ia64/utime.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(utimes,utime) diff --git a/mdk-stage1/dietlibc/ia64/vfork.S b/mdk-stage1/dietlibc/ia64/vfork.S new file mode 100644 index 000000000..e59f04364 --- /dev/null +++ b/mdk-stage1/dietlibc/ia64/vfork.S @@ -0,0 +1,8 @@ +#include "syscalls.h" + +.text +.globl vfork +vfork: + mov r15 = __NR_clone + mov r32 = 16657 + br __unified_syscall diff --git a/mdk-stage1/dietlibc/include/asm/alpha-sigcontext.h b/mdk-stage1/dietlibc/include/asm/alpha-sigcontext.h new file mode 100644 index 000000000..13faab0b5 --- /dev/null +++ b/mdk-stage1/dietlibc/include/asm/alpha-sigcontext.h @@ -0,0 +1,29 @@ +struct sigcontext { + /* + * What should we have here? I'd probably better use the same + * stack layout as OSF/1, just in case we ever want to try + * running their binaries.. + * + * This is the basic layout, but I don't know if we'll ever + * actually fill in all the values.. + */ + long sc_onstack; + long sc_mask; + long sc_pc; + long sc_ps; + long sc_regs[32]; + long sc_ownedfp; + long sc_fpregs[32]; + unsigned long sc_fpcr; + unsigned long sc_fp_control; + unsigned long sc_reserved1, sc_reserved2; + unsigned long sc_ssize; + char * sc_sbase; + unsigned long sc_traparg_a0; + unsigned long sc_traparg_a1; + unsigned long sc_traparg_a2; + unsigned long sc_fp_trap_pc; + unsigned long sc_fp_trigger_sum; + unsigned long sc_fp_trigger_inst; +}; + diff --git a/mdk-stage1/dietlibc/include/asm/arm-sigcontext.h b/mdk-stage1/dietlibc/include/asm/arm-sigcontext.h new file mode 100644 index 000000000..26fa04e64 --- /dev/null +++ b/mdk-stage1/dietlibc/include/asm/arm-sigcontext.h @@ -0,0 +1,32 @@ + +#define PC(ctx) (ctx.arm_pc) + +/* + * Signal context structure - contains all info to do with the state + * before the signal handler was invoked. Note: only add new entries + * to the end of the structure. + */ +struct sigcontext { + unsigned long trap_no; + unsigned long error_code; + unsigned long oldmask; + unsigned long arm_r0; + unsigned long arm_r1; + unsigned long arm_r2; + unsigned long arm_r3; + unsigned long arm_r4; + unsigned long arm_r5; + unsigned long arm_r6; + unsigned long arm_r7; + unsigned long arm_r8; + unsigned long arm_r9; + unsigned long arm_r10; + unsigned long arm_fp; + unsigned long arm_ip; + unsigned long arm_sp; + unsigned long arm_lr; + unsigned long arm_pc; + unsigned long arm_cpsr; + unsigned long fault_address; +}; + diff --git a/mdk-stage1/dietlibc/include/asm/i386-sigcontext.h b/mdk-stage1/dietlibc/include/asm/i386-sigcontext.h new file mode 100644 index 000000000..e830b9b97 --- /dev/null +++ b/mdk-stage1/dietlibc/include/asm/i386-sigcontext.h @@ -0,0 +1,66 @@ + +struct _fpreg { + unsigned short significand[4]; + unsigned short exponent; +}; + +struct _fpxreg { + unsigned short significand[4]; + unsigned short exponent; + unsigned short padding[3]; +}; + +struct _xmmreg { + unsigned long element[4]; +}; + +struct _fpstate { + /* Regular FPU environment */ + unsigned long cw; + unsigned long sw; + unsigned long tag; + unsigned long ipoff; + unsigned long cssel; + unsigned long dataoff; + unsigned long datasel; + struct _fpreg _st[8]; + unsigned short status; + unsigned short magic; /* 0xffff = regular FPU data only */ + + /* FXSR FPU environment */ + unsigned long _fxsr_env[6]; /* FXSR FPU env is ignored */ + unsigned long mxcsr; + unsigned long reserved; + struct _fpxreg _fxsr_st[8]; /* FXSR FPU reg data is ignored */ + struct _xmmreg _xmm[8]; + unsigned long padding[56]; +}; + +#define X86_FXSR_MAGIC 0x0000 +#define PC(ctx) (ctx.eip) + +struct sigcontext { + unsigned short gs, __gsh; + unsigned short fs, __fsh; + unsigned short es, __esh; + unsigned short ds, __dsh; + unsigned long edi; + unsigned long esi; + unsigned long ebp; + unsigned long esp; + unsigned long ebx; + unsigned long edx; + unsigned long ecx; + unsigned long eax; + unsigned long trapno; + unsigned long err; + unsigned long eip; + unsigned short cs, __csh; + unsigned long eflags; + unsigned long esp_at_signal; + unsigned short ss, __ssh; + struct _fpstate * fpstate; + unsigned long oldmask; + unsigned long cr2; +}; + diff --git a/mdk-stage1/dietlibc/include/asm/ia64-sigcontext.h b/mdk-stage1/dietlibc/include/asm/ia64-sigcontext.h new file mode 100644 index 000000000..ebab3c8f4 --- /dev/null +++ b/mdk-stage1/dietlibc/include/asm/ia64-sigcontext.h @@ -0,0 +1,25 @@ +#include + +#define PC(ctx) (ctx.sc_ip) + +struct sigcontext { + unsigned long sc_flags; + unsigned long sc_nat; + stack_t sc_stack; + unsigned long sc_ip; + unsigned long sc_cfm; + unsigned long sc_um; + unsigned long sc_ar_rsc; + unsigned long sc_ar_bsp; + unsigned long sc_ar_rnat; + unsigned long sc_ar_ccv; + unsigned long sc_ar_unat; + unsigned long sc_ar_fpsr; + unsigned long sc_ar_pfs; + unsigned long sc_ar_lc; + unsigned long sc_pr; + unsigned long sc_br[8]; + unsigned long sc_gr[32]; + struct ia64_fpreg sc_fr[128]; + sigset_t sc_mask; +}; diff --git a/mdk-stage1/dietlibc/include/asm/mips-sigcontext.h b/mdk-stage1/dietlibc/include/asm/mips-sigcontext.h new file mode 100644 index 000000000..1210abf31 --- /dev/null +++ b/mdk-stage1/dietlibc/include/asm/mips-sigcontext.h @@ -0,0 +1,23 @@ + +/* + * Keep this struct definition in sync with the sigcontext fragment + * in arch/mips/tools/offset.c + */ +struct sigcontext { + unsigned int sc_regmask; /* Unused */ + unsigned int sc_status; + unsigned long long sc_pc; + unsigned long long sc_regs[32]; + unsigned long long sc_fpregs[32]; /* Unused */ + unsigned int sc_ownedfp; + unsigned int sc_fpc_csr; /* Unused */ + unsigned int sc_fpc_eir; /* Unused */ + unsigned int sc_ssflags; /* Unused */ + unsigned long long sc_mdhi; + unsigned long long sc_mdlo; + + unsigned int sc_cause; /* Unused */ + unsigned int sc_badvaddr; /* Unused */ + + unsigned long sc_sigset[4]; /* kernel's sigset_t */ +}; diff --git a/mdk-stage1/dietlibc/include/asm/parisc-sigcontext.h b/mdk-stage1/dietlibc/include/asm/parisc-sigcontext.h new file mode 100644 index 000000000..9428dd3e5 --- /dev/null +++ b/mdk-stage1/dietlibc/include/asm/parisc-sigcontext.h @@ -0,0 +1,16 @@ + +#define PARISC_SC_FLAG_ONSTACK 1<<0 +#define PARISC_SC_FLAG_IN_SYSCALL 1<<1 + +/* We will add more stuff here as it becomes necessary, until we know + it works. */ +struct sigcontext { + unsigned long sc_flags; + + unsigned long sc_gr[32]; /* PSW in sc_gr[0] */ + unsigned long long sc_fr[32]; /* FIXME, do we need other state info? */ + unsigned long sc_iasq[2]; + unsigned long sc_iaoq[2]; + unsigned long sc_sar; /* cr11 */ +}; + diff --git a/mdk-stage1/dietlibc/include/asm/ppc-sigcontext.h b/mdk-stage1/dietlibc/include/asm/ppc-sigcontext.h new file mode 100644 index 000000000..1d9704f3a --- /dev/null +++ b/mdk-stage1/dietlibc/include/asm/ppc-sigcontext.h @@ -0,0 +1,76 @@ + +struct pt_regs { + unsigned long gpr[32]; + unsigned long nip; + unsigned long msr; + unsigned long orig_gpr3; /* Used for restarting system calls */ + unsigned long ctr; + unsigned long link; + unsigned long xer; + unsigned long ccr; + unsigned long mq; /* 601 only (not used at present) */ + /* Used on APUS to hold IPL value. */ + unsigned long trap; /* Reason for being here */ + unsigned long dar; /* Fault registers */ + unsigned long dsisr; + unsigned long result; /* Result of a system call */ +}; + +/* + * Offsets used by 'ptrace' system call interface. + * These can't be changed without breaking binary compatibility + * with MkLinux, etc. + */ +#define PT_R0 0 +#define PT_R1 1 +#define PT_R2 2 +#define PT_R3 3 +#define PT_R4 4 +#define PT_R5 5 +#define PT_R6 6 +#define PT_R7 7 +#define PT_R8 8 +#define PT_R9 9 +#define PT_R10 10 +#define PT_R11 11 +#define PT_R12 12 +#define PT_R13 13 +#define PT_R14 14 +#define PT_R15 15 +#define PT_R16 16 +#define PT_R17 17 +#define PT_R18 18 +#define PT_R19 19 +#define PT_R20 20 +#define PT_R21 21 +#define PT_R22 22 +#define PT_R23 23 +#define PT_R24 24 +#define PT_R25 25 +#define PT_R26 26 +#define PT_R27 27 +#define PT_R28 28 +#define PT_R29 29 +#define PT_R30 30 +#define PT_R31 31 + +#define PT_NIP 32 +#define PT_MSR 33 +#define PT_CTR 35 +#define PT_LNK 36 +#define PT_XER 37 +#define PT_CCR 38 +#define PT_MQ 39 + +#define PT_FPR0 48 /* each FP reg occupies 2 slots in this space */ +#define PT_FPR31 (PT_FPR0 + 2*31) +#define PT_FPSCR (PT_FPR0 + 2*32 + 1) + +#define sigcontext_struct sigcontext +struct sigcontext { + unsigned long _unused[4]; + int signal; + unsigned long handler; + unsigned long oldmask; + struct pt_regs *regs; +}; diff --git a/mdk-stage1/dietlibc/include/asm/sigcontext.h b/mdk-stage1/dietlibc/include/asm/sigcontext.h new file mode 100644 index 000000000..c4a720cc0 --- /dev/null +++ b/mdk-stage1/dietlibc/include/asm/sigcontext.h @@ -0,0 +1,36 @@ +#ifndef _ASM_SIGCONTEXT_H +#define _ASM_SIGCONTEXT_H + +#if defined(__i386__) || defined(__x86_64__) +#include +#endif + +#ifdef __sparc__ +#include +#endif + +#ifdef __mips__ +#include +#endif + +#ifdef __powerpc__ +#include +#endif + +#ifdef __alpha__ +#include +#endif + +#ifdef __arm__ +#include +#endif + +#ifdef __hppa__ +#include +#endif + +#ifdef __ia64__ +#include +#endif + +#endif diff --git a/mdk-stage1/dietlibc/include/asm/sparc-sigcontext.h b/mdk-stage1/dietlibc/include/asm/sparc-sigcontext.h new file mode 100644 index 000000000..98e4e09ce --- /dev/null +++ b/mdk-stage1/dietlibc/include/asm/sparc-sigcontext.h @@ -0,0 +1,50 @@ + +#define __SUNOS_MAXWIN 31 + +/* This is what SunOS does, so shall I. */ +struct sigcontext { + int sigc_onstack; /* state to restore */ + int sigc_mask; /* sigmask to restore */ + int sigc_sp; /* stack pointer */ + int sigc_pc; /* program counter */ + int sigc_npc; /* next program counter */ + int sigc_psr; /* for condition codes etc */ + int sigc_g1; /* User uses these two registers */ + int sigc_o0; /* within the trampoline code. */ + + /* Now comes information regarding the users window set + * at the time of the signal. + */ + int sigc_oswins; /* outstanding windows */ + + /* stack ptrs for each regwin buf */ + char *sigc_spbuf[__SUNOS_MAXWIN]; + + /* Windows to restore after signal */ + struct { + unsigned long locals[8]; + unsigned long ins[8]; + } sigc_wbuf[__SUNOS_MAXWIN]; +}; + +typedef struct { + struct { + unsigned long psr; + unsigned long pc; + unsigned long npc; + unsigned long y; + unsigned long u_regs[16]; /* globals and ins */ + } si_regs; + int si_mask; +} __siginfo_t; + +typedef struct { + unsigned long si_float_regs [32]; + unsigned long si_fsr; + unsigned long si_fpqdepth; + struct { + unsigned long *insn_addr; + unsigned long insn; + } si_fpqueue [16]; +} __siginfo_fpu_t; + diff --git a/mdk-stage1/dietlibc/include/asm/statfs.h b/mdk-stage1/dietlibc/include/asm/statfs.h new file mode 100644 index 000000000..53b3b5e4d --- /dev/null +++ b/mdk-stage1/dietlibc/include/asm/statfs.h @@ -0,0 +1 @@ +#include diff --git a/mdk-stage1/dietlibc/include/asm/types.h b/mdk-stage1/dietlibc/include/asm/types.h new file mode 100644 index 000000000..aafa80f16 --- /dev/null +++ b/mdk-stage1/dietlibc/include/asm/types.h @@ -0,0 +1,32 @@ +#ifndef _ASM_TYPES_H +#define _ASM_TYPES_H + +#include + +#ifdef __alpha__ +typedef unsigned int umode_t; +#else +typedef unsigned short umode_t; +#endif + +typedef uint8_t __u8; +typedef uint16_t __u16; +typedef uint32_t __u32; +#ifndef __STRICT_ANSI__ +typedef uint64_t __u64; +#endif + +typedef int8_t __s8; +typedef int16_t __s16; +typedef int32_t __s32; +#ifndef __STRICT_ANSI__ +typedef int64_t __s64; +#endif + +#if defined(__alpha__) +typedef unsigned long __kernel_size_t; +#else +typedef unsigned int __kernel_size_t; +#endif + +#endif diff --git a/mdk-stage1/dietlibc/include/cpio.h b/mdk-stage1/dietlibc/include/cpio.h new file mode 100644 index 000000000..a18c2fbb6 --- /dev/null +++ b/mdk-stage1/dietlibc/include/cpio.h @@ -0,0 +1,27 @@ +#ifndef _CPIO_H_ +#define _CPIO_H_ + +#define C_IRUSR 0000400 +#define C_IWUSR 0000200 +#define C_IXUSR 0000100 +#define C_IRGRP 0000040 +#define C_IWGRP 0000020 +#define C_IXGRP 0000010 +#define C_IROTH 0000004 +#define C_IWOTH 0000002 +#define C_IXOTH 0000001 +#define C_ISUID 0004000 +#define C_ISGID 0002000 +#define C_ISVTX 0001000 +#define C_ISDIR 0040000 +#define C_ISFIFO 0010000 +#define C_ISREG 0100000 +#define C_ISBLK 0060000 +#define C_ISCHR 0020000 +#define C_ISCTG 0110000 +#define C_ISLNK 0120000 +#define C_ISSOCK 0140000 + +#define MAGIC "070707" + +#endif /* _CPIO_H_ */ diff --git a/mdk-stage1/dietlibc/include/dietref.h b/mdk-stage1/dietlibc/include/dietref.h new file mode 100644 index 000000000..99d446300 --- /dev/null +++ b/mdk-stage1/dietlibc/include/dietref.h @@ -0,0 +1,22 @@ +/* diet includes this file to create linker dependencies on the diet + * libc, so trying to link an object file compiled with diet against + * glibc will fail. */ + +#ifndef NODIETREF +#include +#ifdef __ASSEMBLER__ +.section .note +#if (__WORDSIZE == 64) +.quad __you_tried_to_link_a_dietlibc_object_against_glibc +#else +.long __you_tried_to_link_a_dietlibc_object_against_glibc +#endif +.previous +#else +#if (__WORDSIZE == 64) +__asm__ (".section .note\n\t.quad __you_tried_to_link_a_dietlibc_object_against_glibc\n\t.previous"); +#else +__asm__ (".section .note\n\t.long __you_tried_to_link_a_dietlibc_object_against_glibc\n\t.previous"); +#endif +#endif +#endif diff --git a/mdk-stage1/dietlibc/include/float.h b/mdk-stage1/dietlibc/include/float.h new file mode 100644 index 000000000..9c9c85a3a --- /dev/null +++ b/mdk-stage1/dietlibc/include/float.h @@ -0,0 +1,96 @@ +#ifndef _FLOAT_H +#define _FLOAT_H + +/* blatantly copied from gcc headers for sparc */ + + /* Radix of exponent representation */ +#undef FLT_RADIX +#define FLT_RADIX 2 + /* Number of base-FLT_RADIX digits in the significand of a float */ +#undef FLT_MANT_DIG +#define FLT_MANT_DIG 24 + /* Number of decimal digits of precision in a float */ +#undef FLT_DIG +#define FLT_DIG 6 + /* Addition rounds to 0: zero, 1: nearest, 2: +inf, 3: -inf, -1: unknown */ +#undef FLT_ROUNDS +#define FLT_ROUNDS 1 + /* Difference between 1.0 and the minimum float greater than 1.0 */ +#undef FLT_EPSILON +#define FLT_EPSILON 1.19209290e-07F + /* Minimum int x such that FLT_RADIX**(x-1) is a normalised float */ +#undef FLT_MIN_EXP +#define FLT_MIN_EXP (-125) + /* Minimum normalised float */ +#undef FLT_MIN +#define FLT_MIN 1.17549435e-38F + /* Minimum int x such that 10**x is a normalised float */ +#undef FLT_MIN_10_EXP +#define FLT_MIN_10_EXP (-37) + /* Maximum int x such that FLT_RADIX**(x-1) is a representable float */ +#undef FLT_MAX_EXP +#define FLT_MAX_EXP 128 + /* Maximum float */ +#undef FLT_MAX +#define FLT_MAX 3.40282347e+38F + /* Maximum int x such that 10**x is a representable float */ +#undef FLT_MAX_10_EXP +#define FLT_MAX_10_EXP 38 + + /* Number of base-FLT_RADIX digits in the significand of a double */ +#undef DBL_MANT_DIG +#define DBL_MANT_DIG 53 + /* Number of decimal digits of precision in a double */ +#undef DBL_DIG +#define DBL_DIG 15 + /* Difference between 1.0 and the minimum double greater than 1.0 */ +#undef DBL_EPSILON +#define DBL_EPSILON 2.2204460492503131e-16 + /* Minimum int x such that FLT_RADIX**(x-1) is a normalised double */ +#undef DBL_MIN_EXP +#define DBL_MIN_EXP (-1021) + /* Minimum normalised double */ +#undef DBL_MIN +#define DBL_MIN 2.2250738585072014e-308 + /* Minimum int x such that 10**x is a normalised double */ +#undef DBL_MIN_10_EXP +#define DBL_MIN_10_EXP (-307) + /* Maximum int x such that FLT_RADIX**(x-1) is a representable double */ +#undef DBL_MAX_EXP +#define DBL_MAX_EXP 1024 + /* Maximum double */ +#undef DBL_MAX +#define DBL_MAX 1.7976931348623157e+308 + /* Maximum int x such that 10**x is a representable double */ +#undef DBL_MAX_10_EXP +#define DBL_MAX_10_EXP 308 + + /* Number of base-FLT_RADIX digits in the significand of a long double */ +#undef LDBL_MANT_DIG +#define LDBL_MANT_DIG 53 + /* Number of decimal digits of precision in a long double */ +#undef LDBL_DIG +#define LDBL_DIG 15 + /* Difference between 1.0 and the minimum long double greater than 1.0 */ +#undef LDBL_EPSILON +#define LDBL_EPSILON 2.2204460492503131e-16L + /* Minimum int x such that FLT_RADIX**(x-1) is a normalised long double */ +#undef LDBL_MIN_EXP +#define LDBL_MIN_EXP (-1021) + /* Minimum normalised long double */ +#undef LDBL_MIN +#define LDBL_MIN 2.2250738585072014e-308L + /* Minimum int x such that 10**x is a normalised long double */ +#undef LDBL_MIN_10_EXP +#define LDBL_MIN_10_EXP (-307) + /* Maximum int x such that FLT_RADIX**(x-1) is a representable long double */ +#undef LDBL_MAX_EXP +#define LDBL_MAX_EXP 1024 + /* Maximum long double */ +#undef LDBL_MAX +#define LDBL_MAX 1.7976931348623157e+308L + /* Maximum int x such that 10**x is a representable long double */ +#undef LDBL_MAX_10_EXP +#define LDBL_MAX_10_EXP 308 + +#endif diff --git a/mdk-stage1/dietlibc/include/iconv.h b/mdk-stage1/dietlibc/include/iconv.h new file mode 100644 index 000000000..1205994ca --- /dev/null +++ b/mdk-stage1/dietlibc/include/iconv.h @@ -0,0 +1,25 @@ +#ifndef _ICONV_H +#define _ICONV_H + +#include +#include + +/* Identifier for conversion method from one codeset to another. */ +typedef unsigned int iconv_t; + +/* Allocate descriptor for code conversion from codeset FROMCODE to + codeset TOCODE. */ +extern iconv_t iconv_open (const char *tocode, const char *fromcode) __THROW; + +/* Convert at most *INBYTESLEFT bytes from *INBUF according to the + code conversion algorithm specified by CD and place up to + *OUTBYTESLEFT bytes in buffer at *OUTBUF. */ +extern size_t iconv (iconv_t cd, const char** inbuf, + size_t* inbytesleft, + char** outbuf, + size_t* outbytesleft) __THROW; + +/* Free resources allocated for descriptor CD for code conversion. */ +extern int iconv_close (iconv_t cd) __THROW; + +#endif /* iconv.h */ diff --git a/mdk-stage1/dietlibc/include/libgen.h b/mdk-stage1/dietlibc/include/libgen.h new file mode 100644 index 000000000..ab13b0a30 --- /dev/null +++ b/mdk-stage1/dietlibc/include/libgen.h @@ -0,0 +1,9 @@ +#ifndef _LIBGEN_H +#define _LIBGEN_H + +#include + +char *dirname(char *path) __THROW; +char *basename(char *path) __THROW; + +#endif diff --git a/mdk-stage1/dietlibc/include/libintl.h b/mdk-stage1/dietlibc/include/libintl.h new file mode 100644 index 000000000..20873f55f --- /dev/null +++ b/mdk-stage1/dietlibc/include/libintl.h @@ -0,0 +1,23 @@ +#ifndef _LIBINTL_H +#define _LIBINTL_H + +#include +#include +#include + +#define gettext(msgid) dgettext(0,msgid) +#define dgettext(domainname,msgid) dcgettext(domainname,msgid,LC_MESSAGES) + +#define ngettext(msgid1,msgid2,n) dngettext(0,msgid1,msgid2,n) +#define dngettext(dn,msgid1,msgid2,n) dngettext(dn,msgid1,msgid2,n,LC_MESSAGES) + +char* dcgettext(const char *domainname, const char *msgid, int category) __THROW; +char* dcngettext(const char *domainname, + const char *msgid1, const char *msgid2, + unsigned long int n, int __category) __THROW; + +char* textdomain(const char *domainname) __THROW; +char* bindtextdomain(const char *domainname, const char *dirname) __THROW; +char* bind_textdomain_codeset(const char *domainname, const char *codeset) __THROW; + +#endif diff --git a/mdk-stage1/dietlibc/include/linux/eventpoll.h b/mdk-stage1/dietlibc/include/linux/eventpoll.h new file mode 100644 index 000000000..19990ac2a --- /dev/null +++ b/mdk-stage1/dietlibc/include/linux/eventpoll.h @@ -0,0 +1,17 @@ +#ifndef _LINUX_EVENTPOLL_H +#define _LINUX_EVENTPOLL_H + +#include +#include +#include + +#define POLLFD_X_PAGE (PAGE_SIZE / sizeof(struct pollfd)) +#define EP_FDS_PAGES(n) (((n) + POLLFD_X_PAGE - 1) / POLLFD_X_PAGE) +#define EP_MAP_SIZE(n) (EP_FDS_PAGES(n) * PAGE_SIZE * 2) + +struct evpoll { + int ep_timeout; + unsigned long ep_resoff; +}; + +#endif diff --git a/mdk-stage1/dietlibc/include/linux/if_ether.h b/mdk-stage1/dietlibc/include/linux/if_ether.h new file mode 100644 index 000000000..dbeb3728e --- /dev/null +++ b/mdk-stage1/dietlibc/include/linux/if_ether.h @@ -0,0 +1,101 @@ +/* + * INET An implementation of the TCP/IP protocol suite for the LINUX + * operating system. INET is implemented using the BSD Socket + * interface as the means of communication with the user level. + * + * Global definitions for the Ethernet IEEE 802.3 interface. + * + * Version: @(#)if_ether.h 1.0.1a 02/08/94 + * + * Author: Fred N. van Kempen, + * Donald Becker, + * Alan Cox, + * Steve Whitehouse, + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + */ + +#ifndef _LINUX_IF_ETHER_H +#define _LINUX_IF_ETHER_H + +/* + * IEEE 802.3 Ethernet magic constants. The frame sizes omit the preamble + * and FCS/CRC (frame check sequence). + */ + +#define ETH_ALEN 6 /* Octets in one ethernet addr */ +#define ETH_HLEN 14 /* Total octets in header. */ +#define ETH_ZLEN 60 /* Min. octets in frame sans FCS */ +#define ETH_DATA_LEN 1500 /* Max. octets in payload */ +#define ETH_FRAME_LEN 1514 /* Max. octets in frame sans FCS */ + +/* + * These are the defined Ethernet Protocol ID's. + */ + +#define ETH_P_LOOP 0x0060 /* Ethernet Loopback packet */ +#define ETH_P_PUP 0x0200 /* Xerox PUP packet */ +#define ETH_P_PUPAT 0x0201 /* Xerox PUP Addr Trans packet */ +#define ETH_P_IP 0x0800 /* Internet Protocol packet */ +#define ETH_P_X25 0x0805 /* CCITT X.25 */ +#define ETH_P_ARP 0x0806 /* Address Resolution packet */ +#define ETH_P_BPQ 0x08FF /* G8BPQ AX.25 Ethernet Packet [ NOT AN OFFICIALLY REGISTERED ID ] */ +#define ETH_P_IEEEPUP 0x0a00 /* Xerox IEEE802.3 PUP packet */ +#define ETH_P_IEEEPUPAT 0x0a01 /* Xerox IEEE802.3 PUP Addr Trans packet */ +#define ETH_P_DEC 0x6000 /* DEC Assigned proto */ +#define ETH_P_DNA_DL 0x6001 /* DEC DNA Dump/Load */ +#define ETH_P_DNA_RC 0x6002 /* DEC DNA Remote Console */ +#define ETH_P_DNA_RT 0x6003 /* DEC DNA Routing */ +#define ETH_P_LAT 0x6004 /* DEC LAT */ +#define ETH_P_DIAG 0x6005 /* DEC Diagnostics */ +#define ETH_P_CUST 0x6006 /* DEC Customer use */ +#define ETH_P_SCA 0x6007 /* DEC Systems Comms Arch */ +#define ETH_P_RARP 0x8035 /* Reverse Addr Res packet */ +#define ETH_P_ATALK 0x809B /* Appletalk DDP */ +#define ETH_P_AARP 0x80F3 /* Appletalk AARP */ +#define ETH_P_8021Q 0x8100 /* 802.1Q VLAN Extended Header */ +#define ETH_P_IPX 0x8137 /* IPX over DIX */ +#define ETH_P_IPV6 0x86DD /* IPv6 over bluebook */ +#define ETH_P_PPP_DISC 0x8863 /* PPPoE discovery messages */ +#define ETH_P_PPP_SES 0x8864 /* PPPoE session messages */ +#define ETH_P_ATMMPOA 0x884c /* MultiProtocol Over ATM */ +#define ETH_P_ATMFATE 0x8884 /* Frame-based ATM Transport + * over Ethernet + */ + +/* + * Non DIX types. Won't clash for 1500 types. + */ + +#define ETH_P_802_3 0x0001 /* Dummy type for 802.3 frames */ +#define ETH_P_AX25 0x0002 /* Dummy protocol id for AX.25 */ +#define ETH_P_ALL 0x0003 /* Every packet (be careful!!!) */ +#define ETH_P_802_2 0x0004 /* 802.2 frames */ +#define ETH_P_SNAP 0x0005 /* Internal only */ +#define ETH_P_DDCMP 0x0006 /* DEC DDCMP: Internal only */ +#define ETH_P_WAN_PPP 0x0007 /* Dummy type for WAN PPP frames*/ +#define ETH_P_PPP_MP 0x0008 /* Dummy type for PPP MP frames */ +#define ETH_P_LOCALTALK 0x0009 /* Localtalk pseudo type */ +#define ETH_P_PPPTALK 0x0010 /* Dummy type for Atalk over PPP*/ +#define ETH_P_TR_802_2 0x0011 /* 802.2 frames */ +#define ETH_P_MOBITEX 0x0015 /* Mobitex (kaz@cafe.net) */ +#define ETH_P_CONTROL 0x0016 /* Card specific control frames */ +#define ETH_P_IRDA 0x0017 /* Linux-IrDA */ +#define ETH_P_ECONET 0x0018 /* Acorn Econet */ +#define ETH_P_HDLC 0x0019 /* HDLC frames */ + +/* + * This is an Ethernet frame header. + */ + +struct ethhdr +{ + unsigned char h_dest[ETH_ALEN]; /* destination eth addr */ + unsigned char h_source[ETH_ALEN]; /* source ether addr */ + unsigned short h_proto; /* packet type ID field */ +}; + +#endif /* _LINUX_IF_ETHER_H */ diff --git a/mdk-stage1/dietlibc/include/linux/loop.h b/mdk-stage1/dietlibc/include/linux/loop.h new file mode 100644 index 000000000..1366f1877 --- /dev/null +++ b/mdk-stage1/dietlibc/include/linux/loop.h @@ -0,0 +1,47 @@ +#ifndef _LINUX_LOOP_H +#define _LINUX_LOOP_H + +/* stolen form kernel */ + +#define LO_NAME_SIZE 64 +#define LO_KEY_SIZE 32 + +/* Loop flags */ +#define LO_FLAGS_DO_BMAP 1 +#define LO_FLAGS_READ_ONLY 2 +#define LO_FLAGS_BH_REMAP 4 + +struct loop_info { + int lo_number; /* ioctl r/o */ + dev_t lo_device; /* ioctl r/o */ + unsigned long lo_inode; /* ioctl r/o */ + dev_t lo_rdevice; /* ioctl r/o */ + int lo_offset; + int lo_encrypt_type; + int lo_encrypt_key_size; /* ioctl w/o */ + int lo_flags; /* ioctl r/o */ + char lo_name[LO_NAME_SIZE]; + unsigned char lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */ + unsigned long lo_init[2]; + char reserved[4]; +}; + +/* Loop filter types */ +#define LO_CRYPT_NONE 0 +#define LO_CRYPT_XOR 1 +#define LO_CRYPT_DES 2 +#define LO_CRYPT_FISH2 3 /* Brand new Twofish encryption */ +#define LO_CRYPT_BLOW 4 +#define LO_CRYPT_CAST128 5 +#define LO_CRYPT_IDEA 6 +#define LO_CRYPT_DUMMY 9 +#define LO_CRYPT_SKIPJACK 10 +#define MAX_LO_CRYPT 20 + +/* IOCTL commands --- we will commandeer 0x4C ('L') */ +#define LOOP_SET_FD 0x4C00 +#define LOOP_CLR_FD 0x4C01 +#define LOOP_SET_STATUS 0x4C02 +#define LOOP_GET_STATUS 0x4C03 + +#endif diff --git a/mdk-stage1/dietlibc/include/linux/nfs.h b/mdk-stage1/dietlibc/include/linux/nfs.h new file mode 100644 index 000000000..9be6db37e --- /dev/null +++ b/mdk-stage1/dietlibc/include/linux/nfs.h @@ -0,0 +1,88 @@ +/* + * NFS protocol definitions + * + * This file contains constants mostly for Version 2 of the protocol, + * but also has a couple of NFSv3 bits in (notably the error codes). + */ +#ifndef _LINUX_NFS_H +#define _LINUX_NFS_H + +#define NFS_PROGRAM 100003 +#define NFS_PORT 2049 +#define NFS_MAXDATA 8192 +#define NFS_MAXPATHLEN 1024 +#define NFS_MAXNAMLEN 255 +#define NFS_MAXGROUPS 16 +#define NFS_FHSIZE 32 +#define NFS_COOKIESIZE 4 +#define NFS_FIFO_DEV (-1) +#define NFSMODE_FMT 0170000 +#define NFSMODE_DIR 0040000 +#define NFSMODE_CHR 0020000 +#define NFSMODE_BLK 0060000 +#define NFSMODE_REG 0100000 +#define NFSMODE_LNK 0120000 +#define NFSMODE_SOCK 0140000 +#define NFSMODE_FIFO 0010000 + +#define NFS_MNT_PROGRAM 100005 +#define NFS_MNT_PORT 627 + +/* + * NFS stats. The good thing with these values is that NFSv3 errors are + * a superset of NFSv2 errors (with the exception of NFSERR_WFLUSH which + * no-one uses anyway), so we can happily mix code as long as we make sure + * no NFSv3 errors are returned to NFSv2 clients. + * Error codes that have a `--' in the v2 column are not part of the + * standard, but seem to be widely used nevertheless. + */ + enum nfs_stat { + NFS_OK = 0, /* v2 v3 */ + NFSERR_PERM = 1, /* v2 v3 */ + NFSERR_NOENT = 2, /* v2 v3 */ + NFSERR_IO = 5, /* v2 v3 */ + NFSERR_NXIO = 6, /* v2 v3 */ + NFSERR_EAGAIN = 11, /* v2 v3 */ + NFSERR_ACCES = 13, /* v2 v3 */ + NFSERR_EXIST = 17, /* v2 v3 */ + NFSERR_XDEV = 18, /* v3 */ + NFSERR_NODEV = 19, /* v2 v3 */ + NFSERR_NOTDIR = 20, /* v2 v3 */ + NFSERR_ISDIR = 21, /* v2 v3 */ + NFSERR_INVAL = 22, /* v2 v3 that Sun forgot */ + NFSERR_FBIG = 27, /* v2 v3 */ + NFSERR_NOSPC = 28, /* v2 v3 */ + NFSERR_ROFS = 30, /* v2 v3 */ + NFSERR_MLINK = 31, /* v3 */ + NFSERR_OPNOTSUPP = 45, /* v2 v3 */ + NFSERR_NAMETOOLONG = 63, /* v2 v3 */ + NFSERR_NOTEMPTY = 66, /* v2 v3 */ + NFSERR_DQUOT = 69, /* v2 v3 */ + NFSERR_STALE = 70, /* v2 v3 */ + NFSERR_REMOTE = 71, /* v2 v3 */ + NFSERR_WFLUSH = 99, /* v2 */ + NFSERR_BADHANDLE = 10001, /* v3 */ + NFSERR_NOT_SYNC = 10002, /* v3 */ + NFSERR_BAD_COOKIE = 10003, /* v3 */ + NFSERR_NOTSUPP = 10004, /* v3 */ + NFSERR_TOOSMALL = 10005, /* v3 */ + NFSERR_SERVERFAULT = 10006, /* v3 */ + NFSERR_BADTYPE = 10007, /* v3 */ + NFSERR_JUKEBOX = 10008 /* v3 */ + }; + +/* NFSv2 file types - beware, these are not the same in NFSv3 */ + +enum nfs_ftype { + NFNON = 0, + NFREG = 1, + NFDIR = 2, + NFBLK = 3, + NFCHR = 4, + NFLNK = 5, + NFSOCK = 6, + NFBAD = 7, + NFFIFO = 8 +}; + +#endif /* _LINUX_NFS_H */ diff --git a/mdk-stage1/dietlibc/include/linux/posix_types.h b/mdk-stage1/dietlibc/include/linux/posix_types.h new file mode 100644 index 000000000..0d494a1f6 --- /dev/null +++ b/mdk-stage1/dietlibc/include/linux/posix_types.h @@ -0,0 +1,115 @@ +#ifndef _LINUX_POSIX_TYPES_H +#define _LINUX_POSIX_TYPES_H + +/* + * This allows for 1024 file descriptors: if NR_OPEN is ever grown + * beyond that you'll have to change this too. But 1024 fd's seem to be + * enough even for such "real" unices like OSF/1, so hopefully this is + * one limit that doesn't have to be changed [again]. + * + * Note that POSIX wants the FD_CLEAR(fd,fdsetp) defines to be in + * (and thus ) - but this is a more logical + * place for them. Solved by having dummy defines in . + */ + +/* + * Those macros may have been defined in . But we always + * use the ones here. + */ +#undef __NFDBITS +#define __NFDBITS (8 * sizeof(unsigned long)) + +#undef __FD_SETSIZE +#define __FD_SETSIZE 1024 + +#undef __FDSET_LONGS +#define __FDSET_LONGS (__FD_SETSIZE/__NFDBITS) + +#undef __FDELT +#define __FDELT(d) ((d) / __NFDBITS) + +#undef __FDMASK +#define __FDMASK(d) (1UL << ((d) % __NFDBITS)) + +typedef struct { + unsigned long fds_bits [__FDSET_LONGS]; +} __kernel_fd_set; + +#ifndef __KERNEL_STRICT_NAMES +typedef __kernel_fd_set fd_set; +#endif + +#if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) + +#undef __FD_SET +static __inline__ void __FD_SET(unsigned long fd, __kernel_fd_set *fdsetp) +{ + unsigned long _tmp = fd / __NFDBITS; + unsigned long _rem = fd % __NFDBITS; + fdsetp->fds_bits[_tmp] |= (1UL<<_rem); +} + +#undef __FD_CLR +static __inline__ void __FD_CLR(unsigned long fd, __kernel_fd_set *fdsetp) +{ + unsigned long _tmp = fd / __NFDBITS; + unsigned long _rem = fd % __NFDBITS; + fdsetp->fds_bits[_tmp] &= ~(1UL<<_rem); +} + +#undef __FD_ISSET +static __inline__ int __FD_ISSET(unsigned long fd, __const__ __kernel_fd_set *p) +{ + unsigned long _tmp = fd / __NFDBITS; + unsigned long _rem = fd % __NFDBITS; + return (p->fds_bits[_tmp] & (1UL<<_rem)) != 0; +} + +/* + * This will unroll the loop for the normal constant cases (8 or 32 longs, + * for 256 and 1024-bit fd_sets respectively) + */ +#undef __FD_ZERO +static __inline__ void __FD_ZERO(__kernel_fd_set *p) +{ + unsigned long *tmp = p->fds_bits; + int i; + + if (__builtin_constant_p(__FDSET_LONGS)) { + switch (__FDSET_LONGS) { + case 32: + tmp[ 0] = 0; tmp[ 1] = 0; tmp[ 2] = 0; tmp[ 3] = 0; + tmp[ 4] = 0; tmp[ 5] = 0; tmp[ 6] = 0; tmp[ 7] = 0; + tmp[ 8] = 0; tmp[ 9] = 0; tmp[10] = 0; tmp[11] = 0; + tmp[12] = 0; tmp[13] = 0; tmp[14] = 0; tmp[15] = 0; + tmp[16] = 0; tmp[17] = 0; tmp[18] = 0; tmp[19] = 0; + tmp[20] = 0; tmp[21] = 0; tmp[22] = 0; tmp[23] = 0; + tmp[24] = 0; tmp[25] = 0; tmp[26] = 0; tmp[27] = 0; + tmp[28] = 0; tmp[29] = 0; tmp[30] = 0; tmp[31] = 0; + return; + case 16: + tmp[ 0] = 0; tmp[ 1] = 0; tmp[ 2] = 0; tmp[ 3] = 0; + tmp[ 4] = 0; tmp[ 5] = 0; tmp[ 6] = 0; tmp[ 7] = 0; + tmp[ 8] = 0; tmp[ 9] = 0; tmp[10] = 0; tmp[11] = 0; + tmp[12] = 0; tmp[13] = 0; tmp[14] = 0; tmp[15] = 0; + return; + case 8: + tmp[ 0] = 0; tmp[ 1] = 0; tmp[ 2] = 0; tmp[ 3] = 0; + tmp[ 4] = 0; tmp[ 5] = 0; tmp[ 6] = 0; tmp[ 7] = 0; + return; + case 4: + tmp[ 0] = 0; tmp[ 1] = 0; tmp[ 2] = 0; tmp[ 3] = 0; + return; + } + } + i = __FDSET_LONGS; + while (i) { + i--; + *tmp = 0; + tmp++; + } +} + +#endif /* defined(__KERNEL__) */ + +#endif /* _LINUX_POSIX_TYPES_H */ diff --git a/mdk-stage1/dietlibc/include/linux/types.h b/mdk-stage1/dietlibc/include/linux/types.h new file mode 100644 index 000000000..1cd33bd41 --- /dev/null +++ b/mdk-stage1/dietlibc/include/linux/types.h @@ -0,0 +1,6 @@ +#ifndef _LINUX_TYPES_H +#define _LINUX_TYPES_H + +#include + +#endif diff --git a/mdk-stage1/dietlibc/include/md5.h b/mdk-stage1/dietlibc/include/md5.h new file mode 100644 index 000000000..7cbc0e8f3 --- /dev/null +++ b/mdk-stage1/dietlibc/include/md5.h @@ -0,0 +1,48 @@ +/* + Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All + rights reserved. + + License to copy and use this software is granted provided that it + is identified as the "RSA Data Security, Inc. MD5 Message-Digest + Algorithm" in all material mentioning or referencing this software + or this function. + + License is also granted to make and use derivative works provided + that such works are identified as "derived from the RSA Data + Security, Inc. MD5 Message-Digest Algorithm" in all material + mentioning or referencing the derived work. + + RSA Data Security, Inc. makes no representations concerning either + the merchantability of this software or the suitability of this + software for any particular purpose. It is provided "as is" + without express or implied warranty of any kind. + These notices must be retained in any copies of any part of this + documentation and/or software. +*/ + +#ifndef _MD5_H +#define _MD5_H + +#include + +/* + Define the MD5 context structure. + Please DO NOT change the order or contents of the structure as + various assembler files depend on it !! +*/ +typedef struct +{ + uint32_t state[4]; /* state (ABCD) */ + uint32_t count[2]; /* number of bits, modulo 2^64 (least sig word first) */ + uint8_t buffer[64]; /* input buffer for incomplete buffer data */ +} +MD5_CTX; + +void MD5Init (MD5_CTX* ctx); +void MD5Update (MD5_CTX* ctx, const uint8_t* buf, size_t len); +void MD5Final (uint8_t digest[16], MD5_CTX* ctx); + +char* md5crypt (const char* pw, const char* salt); + +#endif + diff --git a/mdk-stage1/dietlibc/include/net/ethernet.h b/mdk-stage1/dietlibc/include/net/ethernet.h new file mode 100644 index 000000000..900ffd536 --- /dev/null +++ b/mdk-stage1/dietlibc/include/net/ethernet.h @@ -0,0 +1,76 @@ +/* Copyright (C) 1997, 1999, 2001 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* Based on the FreeBSD version of this file. Curiously, that file + lacks a copyright in the header. */ + +#ifndef __NET_ETHERNET_H +#define __NET_ETHERNET_H 1 + +#include +#include +#include /* IEEE 802.3 Ethernet constants */ + +__BEGIN_DECLS + +/* This is a name for the 48 bit ethernet address available on many + systems. */ +struct ether_addr +{ + uint8_t ether_addr_octet[ETH_ALEN]; +} __attribute__ ((__packed__)); + +/* 10Mb/s ethernet header */ +struct ether_header +{ + uint8_t ether_dhost[ETH_ALEN]; /* destination eth addr */ + uint8_t ether_shost[ETH_ALEN]; /* source ether addr */ + uint16_t ether_type; /* packet type ID field */ +} __attribute__ ((__packed__)); + +/* Ethernet protocol ID's */ +#define ETHERTYPE_PUP 0x0200 /* Xerox PUP */ +#define ETHERTYPE_IP 0x0800 /* IP */ +#define ETHERTYPE_ARP 0x0806 /* Address resolution */ +#define ETHERTYPE_REVARP 0x8035 /* Reverse ARP */ + +#define ETHER_ADDR_LEN ETH_ALEN /* size of ethernet addr */ +#define ETHER_TYPE_LEN 2 /* bytes in type field */ +#define ETHER_CRC_LEN 4 /* bytes in CRC field */ +#define ETHER_HDR_LEN ETH_HLEN /* total octets in header */ +#define ETHER_MIN_LEN (ETH_ZLEN + ETHER_CRC_LEN) /* min packet length */ +#define ETHER_MAX_LEN (ETH_FRAME_LEN + ETHER_CRC_LEN) /* max packet length */ + +/* make sure ethenet length is valid */ +#define ETHER_IS_VALID_LEN(foo) \ + ((foo) >= ETHER_MIN_LEN && (foo) <= ETHER_MAX_LEN) + +/* + * The ETHERTYPE_NTRAILER packet types starting at ETHERTYPE_TRAIL have + * (type-ETHERTYPE_TRAIL)*512 bytes of data followed + * by an ETHER type (as given above) and then the (variable-length) header. + */ +#define ETHERTYPE_TRAIL 0x1000 /* Trailer packet */ +#define ETHERTYPE_NTRAILER 16 + +#define ETHERMTU ETH_DATA_LEN +#define ETHERMIN (ETHER_MIN_LEN - ETHER_HDR_LEN - ETHER_CRC_LEN) + +__END_DECLS + +#endif /* net/ethernet.h */ diff --git a/mdk-stage1/dietlibc/include/net/if_ether.h b/mdk-stage1/dietlibc/include/net/if_ether.h new file mode 100644 index 000000000..7451a6dc6 --- /dev/null +++ b/mdk-stage1/dietlibc/include/net/if_ether.h @@ -0,0 +1,74 @@ +#ifndef _NET_IF_ETHER_H +#define _NET_IF_ETHER_H + +/* taken from */ + +#define ETH_ALEN 6 /* Octets in one ethernet addr */ +#define ETH_HLEN 14 /* Total octets in header. */ +#define ETH_ZLEN 60 /* Min. octets in frame sans FCS */ +#define ETH_DATA_LEN 1500 /* Max. octets in payload */ +#define ETH_FRAME_LEN 1514 /* Max. octets in frame sans FCS */ + +/* + * These are the defined Ethernet Protocol ID's. + */ + +#define ETH_P_LOOP 0x0060 /* Ethernet Loopback packet */ +#define ETH_P_PUP 0x0200 /* Xerox PUP packet */ +#define ETH_P_PUPAT 0x0201 /* Xerox PUP Addr Trans packet */ +#define ETH_P_IP 0x0800 /* Internet Protocol packet */ +#define ETH_P_X25 0x0805 /* CCITT X.25 */ +#define ETH_P_ARP 0x0806 /* Address Resolution packet */ +#define ETH_P_BPQ 0x08FF /* G8BPQ AX.25 Ethernet Packet [ NOT AN OFFICIALLY REGISTERED ID ] */ +#define ETH_P_IEEEPUP 0x0a00 /* Xerox IEEE802.3 PUP packet */ +#define ETH_P_IEEEPUPAT 0x0a01 /* Xerox IEEE802.3 PUP Addr Trans packet */ +#define ETH_P_DEC 0x6000 /* DEC Assigned proto */ +#define ETH_P_DNA_DL 0x6001 /* DEC DNA Dump/Load */ +#define ETH_P_DNA_RC 0x6002 /* DEC DNA Remote Console */ +#define ETH_P_DNA_RT 0x6003 /* DEC DNA Routing */ +#define ETH_P_LAT 0x6004 /* DEC LAT */ +#define ETH_P_DIAG 0x6005 /* DEC Diagnostics */ +#define ETH_P_CUST 0x6006 /* DEC Customer use */ +#define ETH_P_SCA 0x6007 /* DEC Systems Comms Arch */ +#define ETH_P_RARP 0x8035 /* Reverse Addr Res packet */ +#define ETH_P_ATALK 0x809B /* Appletalk DDP */ +#define ETH_P_AARP 0x80F3 /* Appletalk AARP */ +#define ETH_P_8021Q 0x8100 /* 802.1Q VLAN Extended Header */ +#define ETH_P_IPX 0x8137 /* IPX over DIX */ +#define ETH_P_IPV6 0x86DD /* IPv6 over bluebook */ +#define ETH_P_PPP_DISC 0x8863 /* PPPoE discovery messages */ +#define ETH_P_PPP_SES 0x8864 /* PPPoE session messages */ +#define ETH_P_ATMMPOA 0x884c /* MultiProtocol Over ATM */ +#define ETH_P_ATMFATE 0x8884 /* Frame-based ATM Transport over Ethernet */ + +/* + * Non DIX types. Won't clash for 1500 types. + */ + +#define ETH_P_802_3 0x0001 /* Dummy type for 802.3 frames */ +#define ETH_P_AX25 0x0002 /* Dummy protocol id for AX.25 */ +#define ETH_P_ALL 0x0003 /* Every packet (be careful!!!) */ +#define ETH_P_802_2 0x0004 /* 802.2 frames */ +#define ETH_P_SNAP 0x0005 /* Internal only */ +#define ETH_P_DDCMP 0x0006 /* DEC DDCMP: Internal only */ +#define ETH_P_WAN_PPP 0x0007 /* Dummy type for WAN PPP frames*/ +#define ETH_P_PPP_MP 0x0008 /* Dummy type for PPP MP frames */ +#define ETH_P_LOCALTALK 0x0009 /* Localtalk pseudo type */ +#define ETH_P_PPPTALK 0x0010 /* Dummy type for Atalk over PPP*/ +#define ETH_P_TR_802_2 0x0011 /* 802.2 frames */ +#define ETH_P_MOBITEX 0x0015 /* Mobitex (kaz@cafe.net) */ +#define ETH_P_CONTROL 0x0016 /* Card specific control frames */ +#define ETH_P_IRDA 0x0017 /* Linux-IrDA */ +#define ETH_P_ECONET 0x0018 /* Acorn Econet */ + +/* + * This is an Ethernet frame header. + */ + +struct ethhdr { + unsigned char h_dest[ETH_ALEN]; /* destination eth addr */ + unsigned char h_source[ETH_ALEN]; /* source ether addr */ + unsigned short h_proto; /* packet type ID field */ +}; + +#endif diff --git a/mdk-stage1/dietlibc/include/netinet/ip_icmp.h b/mdk-stage1/dietlibc/include/netinet/ip_icmp.h new file mode 100644 index 000000000..cf8e016f7 --- /dev/null +++ b/mdk-stage1/dietlibc/include/netinet/ip_icmp.h @@ -0,0 +1,145 @@ +#ifndef NETINET_IP_ICMP_H +#define NETINET_IP_ICMP_H + +#include +#include +#include + +struct icmphdr { + uint8_t type; /* message type */ + uint8_t code; /* type sub-code */ + uint16_t checksum; + union { + struct { + uint16_t id; + uint16_t sequence; + } echo; /* echo datagram */ + uint32_t gateway; /* gateway address */ + struct { + uint16_t __unused; + uint16_t mtu; + } frag; /* path mtu discovery */ + } un; +}; + +#define ICMP_ECHOREPLY 0 /* Echo Reply */ +#define ICMP_DEST_UNREACH 3 /* Destination Unreachable */ +#define ICMP_SOURCE_QUENCH 4 /* Source Quench */ +#define ICMP_REDIRECT 5 /* Redirect (change route) */ +#define ICMP_ECHO 8 /* Echo Request */ +#define ICMP_TIME_EXCEEDED 11 /* Time Exceeded */ +#define ICMP_PARAMETERPROB 12 /* Parameter Problem */ +#define ICMP_TIMESTAMP 13 /* Timestamp Request */ +#define ICMP_TIMESTAMPREPLY 14 /* Timestamp Reply */ +#define ICMP_INFO_REQUEST 15 /* Information Request */ +#define ICMP_INFO_REPLY 16 /* Information Reply */ +#define ICMP_ADDRESS 17 /* Address Mask Request */ +#define ICMP_ADDRESSREPLY 18 /* Address Mask Reply */ +#define NR_ICMP_TYPES 18 + + +/* Codes for UNREACH. */ +#define ICMP_NET_UNREACH 0 /* Network Unreachable */ +#define ICMP_HOST_UNREACH 1 /* Host Unreachable */ +#define ICMP_PROT_UNREACH 2 /* Protocol Unreachable */ +#define ICMP_PORT_UNREACH 3 /* Port Unreachable */ +#define ICMP_FRAG_NEEDED 4 /* Fragmentation Needed/DF set */ +#define ICMP_SR_FAILED 5 /* Source Route failed */ +#define ICMP_NET_UNKNOWN 6 +#define ICMP_HOST_UNKNOWN 7 +#define ICMP_HOST_ISOLATED 8 +#define ICMP_NET_ANO 9 +#define ICMP_HOST_ANO 10 +#define ICMP_NET_UNR_TOS 11 +#define ICMP_HOST_UNR_TOS 12 +#define ICMP_PKT_FILTERED 13 /* Packet filtered */ +#define ICMP_PREC_VIOLATION 14 /* Precedence violation */ +#define ICMP_PREC_CUTOFF 15 /* Precedence cut off */ +#define NR_ICMP_UNREACH 15 /* instead of hardcoding immediate value */ + +/* Codes for REDIRECT. */ +#define ICMP_REDIR_NET 0 /* Redirect Net */ +#define ICMP_REDIR_HOST 1 /* Redirect Host */ +#define ICMP_REDIR_NETTOS 2 /* Redirect Net for TOS */ +#define ICMP_REDIR_HOSTTOS 3 /* Redirect Host for TOS */ + +/* Codes for TIME_EXCEEDED. */ +#define ICMP_EXC_TTL 0 /* TTL count exceeded */ +#define ICMP_EXC_FRAGTIME 1 /* Fragment Reass time exceeded */ + +/* + * Lower bounds on packet lengths for various types. + * For the error advice packets must first insure that the + * packet is large enough to contain the returned ip header. + * Only then can we do the check to see if 64 bits of packet + * data have been returned, since we need to check the returned + * ip header length. + */ +#define ICMP_MINLEN 8 /* abs minimum */ +#define ICMP_TSLEN (8 + 3 * sizeof (n_time)) /* timestamp */ +#define ICMP_MASKLEN 12 /* address mask */ +#define ICMP_ADVLENMIN (8 + sizeof (struct ip) + 8) /* min */ +#ifndef _IP_VHL +#define ICMP_ADVLEN(p) (8 + ((p)->icmp_ip.ip_hl << 2) + 8) + /* N.B.: must separately check that ip_hl >= 5 */ +#else +#define ICMP_ADVLEN(p) (8 + (IP_VHL_HL((p)->icmp_ip.ip_vhl) << 2) + 8) + /* N.B.: must separately check that header length >= 5 */ +#endif + +/* Definition of type and code fields. */ +/* defined above: ICMP_ECHOREPLY, ICMP_REDIRECT, ICMP_ECHO */ +#define ICMP_UNREACH 3 /* dest unreachable, codes: */ +#define ICMP_SOURCEQUENCH 4 /* packet lost, slow down */ +#define ICMP_ROUTERADVERT 9 /* router advertisement */ +#define ICMP_ROUTERSOLICIT 10 /* router solicitation */ +#define ICMP_TIMXCEED 11 /* time exceeded, code: */ +#define ICMP_PARAMPROB 12 /* ip header bad */ +#define ICMP_TSTAMP 13 /* timestamp request */ +#define ICMP_TSTAMPREPLY 14 /* timestamp reply */ +#define ICMP_IREQ 15 /* information request */ +#define ICMP_IREQREPLY 16 /* information reply */ +#define ICMP_MASKREQ 17 /* address mask request */ +#define ICMP_MASKREPLY 18 /* address mask reply */ + +#define ICMP_MAXTYPE 18 + +/* UNREACH codes */ +#define ICMP_UNREACH_NET 0 /* bad net */ +#define ICMP_UNREACH_HOST 1 /* bad host */ +#define ICMP_UNREACH_PROTOCOL 2 /* bad protocol */ +#define ICMP_UNREACH_PORT 3 /* bad port */ +#define ICMP_UNREACH_NEEDFRAG 4 /* IP_DF caused drop */ +#define ICMP_UNREACH_SRCFAIL 5 /* src route failed */ +#define ICMP_UNREACH_NET_UNKNOWN 6 /* unknown net */ +#define ICMP_UNREACH_HOST_UNKNOWN 7 /* unknown host */ +#define ICMP_UNREACH_ISOLATED 8 /* src host isolated */ +#define ICMP_UNREACH_NET_PROHIB 9 /* net denied */ +#define ICMP_UNREACH_HOST_PROHIB 10 /* host denied */ +#define ICMP_UNREACH_TOSNET 11 /* bad tos for net */ +#define ICMP_UNREACH_TOSHOST 12 /* bad tos for host */ +#define ICMP_UNREACH_FILTER_PROHIB 13 /* admin prohib */ +#define ICMP_UNREACH_HOST_PRECEDENCE 14 /* host prec vio. */ +#define ICMP_UNREACH_PRECEDENCE_CUTOFF 15 /* prec cutoff */ + +/* REDIRECT codes */ +#define ICMP_REDIRECT_NET 0 /* for network */ +#define ICMP_REDIRECT_HOST 1 /* for host */ +#define ICMP_REDIRECT_TOSNET 2 /* for tos and net */ +#define ICMP_REDIRECT_TOSHOST 3 /* for tos and host */ + +/* TIMEXCEED codes */ +#define ICMP_TIMXCEED_INTRANS 0 /* ttl==0 in transit */ +#define ICMP_TIMXCEED_REASS 1 /* ttl==0 in reass */ + +/* PARAMPROB code */ +#define ICMP_PARAMPROB_OPTABSENT 1 /* req. opt. absent */ + +#define ICMP_INFOTYPE(type) \ + ((type) == ICMP_ECHOREPLY || (type) == ICMP_ECHO || \ + (type) == ICMP_ROUTERADVERT || (type) == ICMP_ROUTERSOLICIT || \ + (type) == ICMP_TSTAMP || (type) == ICMP_TSTAMPREPLY || \ + (type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || \ + (type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY) + +#endif diff --git a/mdk-stage1/dietlibc/include/netinet/tcp.h b/mdk-stage1/dietlibc/include/netinet/tcp.h new file mode 100644 index 000000000..e47f24dff --- /dev/null +++ b/mdk-stage1/dietlibc/include/netinet/tcp.h @@ -0,0 +1,164 @@ +#ifndef _NETINET_TCP_H +#define _NETINET_TCP_H + +#include +#include + +struct tcphdr { /* size 20/0x14 40/0x28 with IP header */ + uint16_t source; /* offset 0 20/0x14 */ + uint16_t dest; /* offset 2 22/0x16 */ + uint32_t seq; /* offset 4 24/0x18 */ + uint32_t ack_seq; /* offset 8 28/0x1c */ +#if __BYTE_ORDER == __LITTLE_ENDIAN + uint16_t res1:4, doff:4, fin:1, syn:1, rst:1, psh:1, ack:1, urg:1, ece:1, cwr:1; +#else + uint16_t doff:4, res1:4, cwr:1, ece:1, urg:1, ack:1, psh:1, rst:1, syn:1, fin:1; +#endif + /* offset 12/0xc 32/0x20 */ + uint16_t window; /* offset 14/0xe 34/0x22 */ + uint16_t check; /* offset 16/0x10 36/0x24 */ + uint16_t urg_ptr; /* offset 18/0x12 38/0x26 */ +}; + + +enum { + TCP_ESTABLISHED = 1, + TCP_SYN_SENT, + TCP_SYN_RECV, + TCP_FIN_WAIT1, + TCP_FIN_WAIT2, + TCP_TIME_WAIT, + TCP_CLOSE, + TCP_CLOSE_WAIT, + TCP_LAST_ACK, + TCP_LISTEN, + TCP_CLOSING, /* now a valid state */ + + TCP_MAX_STATES /* Leave at the end! */ +}; + +#define TCP_STATE_MASK 0xF +#define TCP_ACTION_FIN (1 << 7) + +enum { + TCPF_ESTABLISHED = (1 << 1), + TCPF_SYN_SENT = (1 << 2), + TCPF_SYN_RECV = (1 << 3), + TCPF_FIN_WAIT1 = (1 << 4), + TCPF_FIN_WAIT2 = (1 << 5), + TCPF_TIME_WAIT = (1 << 6), + TCPF_CLOSE = (1 << 7), + TCPF_CLOSE_WAIT = (1 << 8), + TCPF_LAST_ACK = (1 << 9), + TCPF_LISTEN = (1 << 10), + TCPF_CLOSING = (1 << 11) +}; + +/* + * The union cast uses a gcc extension to avoid aliasing problems + * (union is compatible to any of its members) + * This means this part of the code is -fstrict-aliasing safe now. + */ +union tcp_word_hdr { + struct tcphdr hdr; + uint32_t words[5]; +}; + +#define tcp_flag_word(tp) ( ((union tcp_word_hdr *)(tp))->words [3]) + +enum { +#if __BYTE_ORDER == __LITTLE_ENDIAN + TCP_FLAG_CWR = 0x00008000, + TCP_FLAG_ECE = 0x00004000, + TCP_FLAG_URG = 0x00002000, + TCP_FLAG_ACK = 0x00001000, + TCP_FLAG_PSH = 0x00000800, + TCP_FLAG_RST = 0x00000400, + TCP_FLAG_SYN = 0x00000200, + TCP_FLAG_FIN = 0x00000100, + TCP_RESERVED_BITS = 0x0000C00F, + TCP_DATA_OFFSET = 0x000000F0 +#else + TCP_FLAG_CWR = 0x00800000, + TCP_FLAG_ECE = 0x00400000, + TCP_FLAG_URG = 0x00200000, + TCP_FLAG_ACK = 0x00100000, + TCP_FLAG_PSH = 0x00080000, + TCP_FLAG_RST = 0x00040000, + TCP_FLAG_SYN = 0x00020000, + TCP_FLAG_FIN = 0x00010000, + TCP_RESERVED_BITS = 0x0FC00000, + TCP_DATA_OFFSET = 0xF0000000 +#endif +}; + +/* TCP socket options */ +#define TCP_NODELAY 1 /* Turn off Nagle's algorithm. */ +#define TCP_MAXSEG 2 /* Limit MSS */ +#define TCP_CORK 3 /* Never send partially complete segments */ +#define TCP_KEEPIDLE 4 /* Start keeplives after this period */ +#define TCP_KEEPINTVL 5 /* Interval between keepalives */ +#define TCP_KEEPCNT 6 /* Number of keepalives before death */ +#define TCP_SYNCNT 7 /* Number of SYN retransmits */ +#define TCP_LINGER2 8 /* Life time of orphaned FIN-WAIT-2 state */ +#define TCP_DEFER_ACCEPT 9 /* Wake up listener only when data arrive */ +#define TCP_WINDOW_CLAMP 10 /* Bound advertised window */ +#define TCP_INFO 11 /* Information about this connection. */ +#define TCP_QUICKACK 12 /* Block/reenable quick acks */ + +#define TCPI_OPT_TIMESTAMPS 1 +#define TCPI_OPT_SACK 2 +#define TCPI_OPT_WSCALE 4 +#define TCPI_OPT_ECN 8 + +enum tcp_ca_state { + TCP_CA_Open = 0, +#define TCPF_CA_Open (1< +#include + +struct udphdr { /* size 8 28/0x1c with IP header */ + uint16_t source; /* offset 0 20/0x14 */ + uint16_t dest; /* offset 2 22/0x16 */ + uint16_t len; /* offset 4 24/0x18 */ + uint16_t check; /* offset 6 26/0x1a */ +}; + +#define SOL_UDP 17 /* sockopt level for UDP */ + +#endif diff --git a/mdk-stage1/dietlibc/include/netpacket/packet.h b/mdk-stage1/dietlibc/include/netpacket/packet.h new file mode 100644 index 000000000..b265094c6 --- /dev/null +++ b/mdk-stage1/dietlibc/include/netpacket/packet.h @@ -0,0 +1,41 @@ +#ifndef __NETPACKET_PACKET_H +#define __NETPACKET_PACKET_H + +struct sockaddr_ll { + unsigned short int sll_family; + unsigned short int sll_protocol; + int sll_ifindex; + unsigned short int sll_hatype; + unsigned char sll_pkttype; + unsigned char sll_halen; + unsigned char sll_addr[8]; +}; + +#define PACKET_HOST 0 /* To us. */ +#define PACKET_BROADCAST 1 /* To all. */ +#define PACKET_MULTICAST 2 /* To group. */ +#define PACKET_OTHERHOST 3 /* To someone else. */ +#define PACKET_OUTGOING 4 /* Originated by us. */ +#define PACKET_LOOPBACK 5 +#define PACKET_FASTROUTE 6 + +/* Packet socket options. */ + +#define PACKET_ADD_MEMBERSHIP 1 +#define PACKET_DROP_MEMBERSHIP 2 +#define PACKET_RECV_OUTPUT 3 +#define PACKET_RX_RING 5 +#define PACKET_STATISTICS 6 + +struct packet_mreq { + int mr_ifindex; + unsigned short int mr_type; + unsigned short int mr_alen; + unsigned char mr_address[8]; +}; + +#define PACKET_MR_MULTICAST 0 +#define PACKET_MR_PROMISC 1 +#define PACKET_MR_ALLMULTI 2 + +#endif diff --git a/mdk-stage1/dietlibc/include/pty.h b/mdk-stage1/dietlibc/include/pty.h new file mode 100644 index 000000000..fa53d9934 --- /dev/null +++ b/mdk-stage1/dietlibc/include/pty.h @@ -0,0 +1,13 @@ +#ifndef _PTY_H +#define _PTY_H + +#include +#include + +/* Create pseudo tty master slave pair with NAME and set terminal + * attributes according to TERMP and WINP and return handles for both + * ends in AMASTER and ASLAVE. */ +extern int openpty (int *__amaster, int *__aslave, char *__name, struct + termios *__termp, struct winsize *__winp) __THROW; + +#endif diff --git a/mdk-stage1/dietlibc/include/stdarg-cruft.h b/mdk-stage1/dietlibc/include/stdarg-cruft.h new file mode 100644 index 000000000..fbd9e0ca4 --- /dev/null +++ b/mdk-stage1/dietlibc/include/stdarg-cruft.h @@ -0,0 +1,299 @@ +#if defined(__sparc__) || defined(__alpha__) || defined(__mips__) +enum { + __no_type_class = -1, + __void_type_class, + __integer_type_class, + __char_type_class, + __enumeral_type_class, + __boolean_type_class, + __pointer_type_class, + __reference_type_class, + __offset_type_class, + __real_type_class, + __complex_type_class, + __function_type_class, + __method_type_class, + __record_type_class, + __union_type_class, + __array_type_class, + __string_type_class, + __set_type_class, + __file_type_class, + __lang_type_class +}; +#endif + +#if defined(__sparc__) + +typedef char* va_list; +#define va_end(ap) ap=0 + +#define va_start(AP, LASTARG) \ + (__builtin_next_arg (LASTARG), AP = (char *) __builtin_saveregs ()) + +#define __va_rounded_size(TYPE) \ + (((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int)) + +/* We don't declare the union member `d' to have type TYPE + because that would lose in C++ if TYPE has a constructor. */ +/* We cast to void * and then to TYPE * because this avoids + a warning about increasing the alignment requirement. + The casts to char * avoid warnings about invalid pointer arithmetic. */ +#define va_arg(pvar,TYPE) \ +__extension__ \ +(*({((__builtin_classify_type (*(TYPE*) 0) >= __record_type_class \ + || (__builtin_classify_type (*(TYPE*) 0) == __real_type_class \ + && sizeof (TYPE) == 16)) \ + ? ((pvar) = (char *)(pvar) + __va_rounded_size (TYPE *), \ + *(TYPE **) (void *) ((char *)(pvar) - __va_rounded_size (TYPE *))) \ + : __va_rounded_size (TYPE) == 8 \ + ? ({ union {char __d[sizeof (TYPE)]; int __i[2];} __u; \ + __u.__i[0] = ((int *) (void *) (pvar))[0]; \ + __u.__i[1] = ((int *) (void *) (pvar))[1]; \ + (pvar) = (char *)(pvar) + 8; \ + (TYPE *) (void *) __u.__d; }) \ + : ((pvar) = (char *)(pvar) + __va_rounded_size (TYPE), \ + ((TYPE *) (void *) ((char *)(pvar) - __va_rounded_size (TYPE)))));})) + + +#elif defined(__mips__) + +typedef char * va_list; + +#ifdef __mips64 +#define __va_rounded_size(__TYPE) \ + (((sizeof (__TYPE) + 8 - 1) / 8) * 8) +#else +#define __va_rounded_size(__TYPE) \ + (((sizeof (__TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int)) +#endif +#ifdef __mips64 +#define __va_reg_size 8 +#else +#define __va_reg_size 4 +#endif + +#define va_start(__AP, __LASTARG) \ + (__AP = (va_list) __builtin_next_arg (__LASTARG)) + +#ifdef __mips64 +#ifdef __MIPSEB__ +#define va_arg(__AP, __type) \ + ((__type *) (void *) (__AP = (char *) \ + ((((__PTRDIFF_TYPE__)__AP + 8 - 1) & -8) \ + + __va_rounded_size (__type))))[-1] +#else +#define va_arg(__AP, __type) \ + ((__AP = (char *) ((((__PTRDIFF_TYPE__)__AP + 8 - 1) & -8) \ + + __va_rounded_size (__type))), \ + *(__type *) (void *) (__AP - __va_rounded_size (__type))) +#endif + +#else /* not __mips64 */ + +#ifdef __MIPSEB__ +/* For big-endian machines. */ +#define va_arg(__AP, __type) \ + ((__AP = (char *) ((__alignof__ (__type) > 4 \ + ? ((__PTRDIFF_TYPE__)__AP + 8 - 1) & -8 \ + : ((__PTRDIFF_TYPE__)__AP + 4 - 1) & -4) \ + + __va_rounded_size (__type))), \ + *(__type *) (void *) (__AP - __va_rounded_size (__type))) +#else +/* For little-endian machines. */ +#define va_arg(__AP, __type) \ + ((__type *) (void *) (__AP = (char *) ((__alignof__(__type) > 4 \ + ? ((__PTRDIFF_TYPE__)__AP + 8 - 1) & -8 \ + : ((__PTRDIFF_TYPE__)__AP + 4 - 1) & -4) \ + + __va_rounded_size(__type))))[-1] +#endif +#endif + +#elif defined(__powerpc__) + +typedef struct __va_list_tag { + unsigned char gpr; /* index into the array of 8 GPRs stored in the + register save area gpr=0 corresponds to r3, + gpr=1 to r4, etc. */ + unsigned char fpr; /* index into the array of 8 FPRs stored in the + register save area fpr=0 corresponds to f1, + fpr=1 to f2, etc. */ + char *overflow_arg_area; /* location on stack that holds the next + overflow argument */ + char *reg_save_area; /* where r3:r10 and f1:f8, if saved are stored */ +} va_list[1]; + +#define __va_overflow(AP) (AP)->overflow_arg_area +#ifdef __OPTIMIZE__ +extern void __va_arg_type_violation(void) __attribute__((__noreturn__)); +#else +#define __va_arg_type_violation() +#endif + +typedef struct { + long __gp_save[8]; /* save area for GP registers */ + double __fp_save[8]; /* save area for FP registers */ +} __va_regsave_t; + +/* Macros to access the register save area */ +/* We cast to void * and then to TYPE * because this avoids + a warning about increasing the alignment requirement. */ +#define __VA_FP_REGSAVE(AP,OFS,TYPE) \ + ((TYPE *) (void *) (&(((__va_regsave_t *) \ + (AP)->reg_save_area)->__fp_save[OFS]))) + +#define __VA_GP_REGSAVE(AP,OFS,TYPE) \ + ((TYPE *) (void *) (&(((__va_regsave_t *) \ + (AP)->reg_save_area)->__gp_save[OFS]))) + +#define __va_start_common(AP, FAKE) \ + __builtin_memcpy ((AP), __builtin_saveregs (), sizeof(va_list)) + +#define va_start(AP,LASTARG) \ + (__builtin_next_arg (LASTARG), __va_start_common (AP, 0)) + +#ifdef _SOFT_FLOAT +#define __va_float_p(TYPE) 0 +#else +#define __va_float_p(TYPE) (__builtin_classify_type(*(TYPE *)0) == 8) +#endif + +#define __va_aggregate_p(TYPE) (__builtin_classify_type(*(TYPE *)0) >= 12) +#define __va_size(TYPE) ((sizeof(TYPE) + sizeof (long) - 1) / sizeof (long)) + +#define va_arg(AP,TYPE) \ +__extension__ (*({ \ + register TYPE *__ptr; \ + \ + if (__va_float_p (TYPE) && sizeof (TYPE) < 16) \ + { \ + unsigned char __fpr = (AP)->fpr; \ + if (__fpr < 8) \ + { \ + __ptr = __VA_FP_REGSAVE (AP, __fpr, TYPE); \ + (AP)->fpr = __fpr + 1; \ + } \ + else if (sizeof (TYPE) == 8) \ + { \ + unsigned long __addr = (unsigned long) (__va_overflow (AP)); \ + __ptr = (TYPE *)((__addr + 7) & -8); \ + __va_overflow (AP) = (char *)(__ptr + 1); \ + } \ + else \ + { \ + /* float is promoted to double. */ \ + __va_arg_type_violation (); \ + } \ + } \ + \ + /* Aggregates and long doubles are passed by reference. */ \ + else if (__va_aggregate_p (TYPE) || __va_float_p (TYPE)) \ + { \ + unsigned char __gpr = (AP)->gpr; \ + if (__gpr < 8) \ + { \ + __ptr = * __VA_GP_REGSAVE (AP, __gpr, TYPE *); \ + (AP)->gpr = __gpr + 1; \ + } \ + else \ + { \ + TYPE **__pptr = (TYPE **) (__va_overflow (AP)); \ + __ptr = * __pptr; \ + __va_overflow (AP) = (char *) (__pptr + 1); \ + } \ + } \ + \ + /* Only integrals remaining. */ \ + else \ + { \ + /* longlong is aligned. */ \ + if (sizeof (TYPE) == 8) \ + { \ + unsigned char __gpr = (AP)->gpr; \ + if (__gpr < 7) \ + { \ + __gpr += __gpr & 1; \ + __ptr = __VA_GP_REGSAVE (AP, __gpr, TYPE); \ + (AP)->gpr = __gpr + 2; \ + } \ + else \ + { \ + unsigned long __addr = (unsigned long) (__va_overflow (AP)); \ + __ptr = (TYPE *)((__addr + 7) & -8); \ + (AP)->gpr = 8; \ + __va_overflow (AP) = (char *)(__ptr + 1); \ + } \ + } \ + else if (sizeof (TYPE) == 4) \ + { \ + unsigned char __gpr = (AP)->gpr; \ + if (__gpr < 8) \ + { \ + __ptr = __VA_GP_REGSAVE (AP, __gpr, TYPE); \ + (AP)->gpr = __gpr + 1; \ + } \ + else \ + { \ + __ptr = (TYPE *) __va_overflow (AP); \ + __va_overflow (AP) = (char *)(__ptr + 1); \ + } \ + } \ + else \ + { \ + /* Everything else was promoted to int. */ \ + __va_arg_type_violation (); \ + } \ + } \ + __ptr; \ +})) + +#define va_end(AP) ((void)0) + +/* Copy va_list into another variable of this type. */ +#define __va_copy(dest, src) *(dest) = *(src) + +#elif defined(__alpha__) + +typedef struct { + char *__base; /* Pointer to first integer register. */ + int __offset; /* Byte offset of args so far. */ +} va_list; + +#define va_start(pvar, firstarg) \ + (__builtin_next_arg (firstarg), \ + (pvar) = *(va_list *) __builtin_saveregs ()) +#define va_end(__va) ((void) 0) + +#define __va_tsize(__type) \ + (((sizeof (__type) + __extension__ sizeof (long long) - 1) \ + / __extension__ sizeof (long long)) * __extension__ sizeof (long long)) + +#define va_arg(__va, __type) \ +(*(((__va).__offset += __va_tsize (__type)), \ + (__type *)(void *)((__va).__base + (__va).__offset \ + - (((__builtin_classify_type (* (__type *) 0) \ + == __real_type_class) && (__va).__offset <= (6 * 8)) \ + ? (6 * 8) + 8 : __va_tsize (__type))))) + +#else /* !__sparc__ && !__powerpc__ && !__mips__ && !__alpha__*/ + +typedef char* va_list; + +/* this only works when everything is passed on the stack (i.e. x86) */ +#if __WORDSIZE == 64 +#define va_start(ap,argn) ap=((char*)&argn)+8 +#else +#define va_start(ap,argn) ap=((char*)&argn)+4 +#endif +#define va_arg(ap,type) (ap+=sizeof(type), *(type*)((void*)ap-sizeof(type))) + +#endif + +#ifndef __va_copy +#define __va_copy(x,y) x=y +#endif + +#ifndef va_end +#define va_end(ap) ((void)0) +#endif + diff --git a/mdk-stage1/dietlibc/include/stdarg.h b/mdk-stage1/dietlibc/include/stdarg.h new file mode 100644 index 000000000..3a21bdb56 --- /dev/null +++ b/mdk-stage1/dietlibc/include/stdarg.h @@ -0,0 +1,24 @@ +#ifndef _STDARG_H +#define _STDARG_H + +#include + +#if (__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 96)) + +typedef __builtin_va_list va_list; +#define va_start(v,l) __builtin_stdarg_start((v),l) +#define va_end __builtin_va_end +#define va_arg __builtin_va_arg +#define __va_copy(d,s) __builtin_va_copy((d),(s)) + +#endif + +#ifndef va_end +#include +#endif + +#if !defined(__STRICT_ANSI__) || __STDC_VERSION__ + 0 >= 199900L +#define va_copy(d,s) __va_copy(d,s) +#endif + +#endif diff --git a/mdk-stage1/dietlibc/include/stddef.h b/mdk-stage1/dietlibc/include/stddef.h new file mode 100644 index 000000000..cdf54ec1e --- /dev/null +++ b/mdk-stage1/dietlibc/include/stddef.h @@ -0,0 +1,23 @@ +#ifndef _STDDEF_H +#define _STDDEF_H + +/* ugh. This is normally provided by gcc. */ + +#ifdef __GNUC__ +typedef __PTRDIFF_TYPE__ ptrdiff_t; +typedef __SIZE_TYPE__ size_t; +typedef __WCHAR_TYPE__ wchar_t; +#else +typedef signed long ptrdiff_t; +typedef unsigned long size_t; +typedef int wchar_t; +#endif + +#ifndef NULL +#define NULL (void*)0 +#endif + +#undef offsetof +#define offsetof(type,member) ((size_t) &((type*)0)->member) + +#endif diff --git a/mdk-stage1/dietlibc/include/sys/alpha-ioctl.h b/mdk-stage1/dietlibc/include/sys/alpha-ioctl.h new file mode 100644 index 000000000..f1bde3bbb --- /dev/null +++ b/mdk-stage1/dietlibc/include/sys/alpha-ioctl.h @@ -0,0 +1,168 @@ +#define _IOC_NRBITS 8 +#define _IOC_TYPEBITS 8 +#define _IOC_SIZEBITS 13 +#define _IOC_DIRBITS 3 + +#define _IOC_NRMASK ((1 << _IOC_NRBITS)-1) +#define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1) +#define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1) +#define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1) + +#define _IOC_NRSHIFT 0 +#define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS) +#define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS) +#define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS) + +/* + * Direction bits _IOC_NONE could be 0, but OSF/1 gives it a bit. + * And this turns out useful to catch old ioctl numbers in header + * files for us. + */ +#define _IOC_NONE 1U +#define _IOC_READ 2U +#define _IOC_WRITE 4U + +#define _IOC(dir,type,nr,size) \ + ((unsigned int) \ + (((dir) << _IOC_DIRSHIFT) | \ + ((type) << _IOC_TYPESHIFT) | \ + ((nr) << _IOC_NRSHIFT) | \ + ((size) << _IOC_SIZESHIFT))) + +/* used to create numbers */ +#define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0) +#define _IOR(type,nr,size) _IOC(_IOC_READ,(type),(nr),sizeof(size)) +#define _IOW(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),sizeof(size)) +#define _IOWR(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size)) + +/* used to decode them.. */ +#define _IOC_DIR(nr) (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK) +#define _IOC_TYPE(nr) (((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK) +#define _IOC_NR(nr) (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK) +#define _IOC_SIZE(nr) (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK) + +/* ...and for the drivers/sound files... */ + +#define IOC_IN (_IOC_WRITE << _IOC_DIRSHIFT) +#define IOC_OUT (_IOC_READ << _IOC_DIRSHIFT) +#define IOC_INOUT ((_IOC_WRITE|_IOC_READ) << _IOC_DIRSHIFT) +#define IOCSIZE_MASK (_IOC_SIZEMASK << _IOC_SIZESHIFT) +#define IOCSIZE_SHIFT (_IOC_SIZESHIFT) + +#define FIOCLEX _IO('f', 1) +#define FIONCLEX _IO('f', 2) +#define FIOASYNC _IOW('f', 125, int) +#define FIONBIO _IOW('f', 126, int) +#define FIONREAD _IOR('f', 127, int) +#define TIOCINQ FIONREAD +#define FIOQSIZE _IOR('f', 128, loff_t) + +#define TIOCGETP _IOR('t', 8, struct sgttyb) +#define TIOCSETP _IOW('t', 9, struct sgttyb) +#define TIOCSETN _IOW('t', 10, struct sgttyb) /* TIOCSETP wo flush */ + +#define TIOCSETC _IOW('t', 17, struct tchars) +#define TIOCGETC _IOR('t', 18, struct tchars) +#define TCGETS _IOR('t', 19, struct termios) +#define TCSETS _IOW('t', 20, struct termios) +#define TCSETSW _IOW('t', 21, struct termios) +#define TCSETSF _IOW('t', 22, struct termios) + +#define TCGETA _IOR('t', 23, struct termio) +#define TCSETA _IOW('t', 24, struct termio) +#define TCSETAW _IOW('t', 25, struct termio) +#define TCSETAF _IOW('t', 28, struct termio) + +#define TCSBRK _IO('t', 29) +#define TCXONC _IO('t', 30) +#define TCFLSH _IO('t', 31) + +#define TIOCSWINSZ _IOW('t', 103, struct winsize) +#define TIOCGWINSZ _IOR('t', 104, struct winsize) +#define TIOCSTART _IO('t', 110) /* start output, like ^Q */ +#define TIOCSTOP _IO('t', 111) /* stop output, like ^S */ +#define TIOCOUTQ _IOR('t', 115, int) /* output queue size */ + +#define TIOCGLTC _IOR('t', 116, struct ltchars) +#define TIOCSLTC _IOW('t', 117, struct ltchars) +#define TIOCSPGRP _IOW('t', 118, int) +#define TIOCGPGRP _IOR('t', 119, int) + +#define TIOCEXCL 0x540C +#define TIOCNXCL 0x540D +#define TIOCSCTTY 0x540E + +#define TIOCSTI 0x5412 +#define TIOCMGET 0x5415 +#define TIOCMBIS 0x5416 +#define TIOCMBIC 0x5417 +#define TIOCMSET 0x5418 +# define TIOCM_LE 0x001 +# define TIOCM_DTR 0x002 +# define TIOCM_RTS 0x004 +# define TIOCM_ST 0x008 +# define TIOCM_SR 0x010 +# define TIOCM_CTS 0x020 +# define TIOCM_CAR 0x040 +# define TIOCM_RNG 0x080 +# define TIOCM_DSR 0x100 +# define TIOCM_CD TIOCM_CAR +# define TIOCM_RI TIOCM_RNG +# define TIOCM_OUT1 0x2000 +# define TIOCM_OUT2 0x4000 +# define TIOCM_LOOP 0x8000 + +#define TIOCGSOFTCAR 0x5419 +#define TIOCSSOFTCAR 0x541A +#define TIOCLINUX 0x541C +#define TIOCCONS 0x541D +#define TIOCGSERIAL 0x541E +#define TIOCSSERIAL 0x541F +#define TIOCPKT 0x5420 +# define TIOCPKT_DATA 0 +# define TIOCPKT_FLUSHREAD 1 +# define TIOCPKT_FLUSHWRITE 2 +# define TIOCPKT_STOP 4 +# define TIOCPKT_START 8 +# define TIOCPKT_NOSTOP 16 +# define TIOCPKT_DOSTOP 32 + + +#define TIOCNOTTY 0x5422 +#define TIOCSETD 0x5423 +#define TIOCGETD 0x5424 +#define TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */ +#define TIOCTTYGSTRUCT 0x5426 /* For debugging only */ +#define TIOCSBRK 0x5427 /* BSD compatibility */ +#define TIOCCBRK 0x5428 /* BSD compatibility */ +#define TIOCGSID 0x5429 /* Return the session ID of FD */ +#define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */ +#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */ + +#define TIOCSERCONFIG 0x5453 +#define TIOCSERGWILD 0x5454 +#define TIOCSERSWILD 0x5455 +#define TIOCGLCKTRMIOS 0x5456 +#define TIOCSLCKTRMIOS 0x5457 +#define TIOCSERGSTRUCT 0x5458 /* For debugging only */ +#define TIOCSERGETLSR 0x5459 /* Get line status register */ + /* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */ +# define TIOCSER_TEMT 0x01 /* Transmitter physically empty */ +#define TIOCSERGETMULTI 0x545A /* Get multiport config */ +#define TIOCSERSETMULTI 0x545B /* Set multiport config */ + +#define TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */ +#define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */ +#define TIOCGHAYESESP 0x545E /* Get Hayes ESP configuration */ +#define TIOCSHAYESESP 0x545F /* Set Hayes ESP configuration */ + +/* Socket-level I/O control calls. */ + +#define FIOGETOWN _IOR('f', 123, int) +#define FIOSETOWN _IOW('f', 124, int) + +#define SIOCATMARK _IOR('s', 7, int) +#define SIOCSPGRP _IOW('s', 8, pid_t) +#define SIOCGPGRP _IOR('s', 9, pid_t) + +#define SIOCGSTAMP 0x8906 /* Get stamp - linux-specific */ diff --git a/mdk-stage1/dietlibc/include/sys/arm-ioctl.h b/mdk-stage1/dietlibc/include/sys/arm-ioctl.h new file mode 100644 index 000000000..ab8b844a5 --- /dev/null +++ b/mdk-stage1/dietlibc/include/sys/arm-ioctl.h @@ -0,0 +1,149 @@ + +/* ioctl command encoding: 32 bits total, command in lower 16 bits, + * size of the parameter structure in the lower 14 bits of the + * upper 16 bits. + * Encoding the size of the parameter structure in the ioctl request + * is useful for catching programs compiled with old versions + * and to avoid overwriting user space outside the user buffer area. + * The highest 2 bits are reserved for indicating the ``access mode''. + * NOTE: This limits the max parameter size to 16kB -1 ! + */ + +/* + * The following is for compatibility across the various Linux + * platforms. The i386 ioctl numbering scheme doesn't really enforce + * a type field. De facto, however, the top 8 bits of the lower 16 + * bits are indeed used as a type field, so we might just as well make + * this explicit here. Please be sure to use the decoding macros + * below from now on. + */ +#define _IOC_NRBITS 8 +#define _IOC_TYPEBITS 8 +#define _IOC_SIZEBITS 14 +#define _IOC_DIRBITS 2 + +#define _IOC_NRMASK ((1 << _IOC_NRBITS)-1) +#define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1) +#define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1) +#define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1) + +#define _IOC_NRSHIFT 0 +#define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS) +#define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS) +#define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS) + +/* + * Direction bits. + */ +#define _IOC_NONE 0U +#define _IOC_WRITE 1U +#define _IOC_READ 2U + +#define _IOC(dir,type,nr,size) \ + (((dir) << _IOC_DIRSHIFT) | \ + ((type) << _IOC_TYPESHIFT) | \ + ((nr) << _IOC_NRSHIFT) | \ + ((size) << _IOC_SIZESHIFT)) + +/* used to create numbers */ +#define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0) +#define _IOR(type,nr,size) _IOC(_IOC_READ,(type),(nr),sizeof(size)) +#define _IOW(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),sizeof(size)) +#define _IOWR(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size)) + +/* used to decode ioctl numbers.. */ +#define _IOC_DIR(nr) (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK) +#define _IOC_TYPE(nr) (((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK) +#define _IOC_NR(nr) (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK) +#define _IOC_SIZE(nr) (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK) + +/* ...and for the drivers/sound files... */ + +#define IOC_IN (_IOC_WRITE << _IOC_DIRSHIFT) +#define IOC_OUT (_IOC_READ << _IOC_DIRSHIFT) +#define IOC_INOUT ((_IOC_WRITE|_IOC_READ) << _IOC_DIRSHIFT) +#define IOCSIZE_MASK (_IOC_SIZEMASK << _IOC_SIZESHIFT) +#define IOCSIZE_SHIFT (_IOC_SIZESHIFT) + +/* 0x54 is just a magic number to make these relatively unique ('T') */ + +#define TCGETS 0x5401 +#define TCSETS 0x5402 +#define TCSETSW 0x5403 +#define TCSETSF 0x5404 +#define TCGETA 0x5405 +#define TCSETA 0x5406 +#define TCSETAW 0x5407 +#define TCSETAF 0x5408 +#define TCSBRK 0x5409 +#define TCXONC 0x540A +#define TCFLSH 0x540B +#define TIOCEXCL 0x540C +#define TIOCNXCL 0x540D +#define TIOCSCTTY 0x540E +#define TIOCGPGRP 0x540F +#define TIOCSPGRP 0x5410 +#define TIOCOUTQ 0x5411 +#define TIOCSTI 0x5412 +#define TIOCGWINSZ 0x5413 +#define TIOCSWINSZ 0x5414 +#define TIOCMGET 0x5415 +#define TIOCMBIS 0x5416 +#define TIOCMBIC 0x5417 +#define TIOCMSET 0x5418 +#define TIOCGSOFTCAR 0x5419 +#define TIOCSSOFTCAR 0x541A +#define FIONREAD 0x541B +#define TIOCINQ FIONREAD +#define TIOCLINUX 0x541C +#define TIOCCONS 0x541D +#define TIOCGSERIAL 0x541E +#define TIOCSSERIAL 0x541F +#define TIOCPKT 0x5420 +#define FIONBIO 0x5421 +#define TIOCNOTTY 0x5422 +#define TIOCSETD 0x5423 +#define TIOCGETD 0x5424 +#define TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */ +#define TIOCTTYGSTRUCT 0x5426 /* For debugging only */ +#define TIOCSBRK 0x5427 /* BSD compatibility */ +#define TIOCCBRK 0x5428 /* BSD compatibility */ +#define TIOCGSID 0x5429 /* Return the session ID of FD */ +#define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */ +#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */ + +#define FIONCLEX 0x5450 /* these numbers need to be adjusted. */ +#define FIOCLEX 0x5451 +#define FIOASYNC 0x5452 +#define TIOCSERCONFIG 0x5453 +#define TIOCSERGWILD 0x5454 +#define TIOCSERSWILD 0x5455 +#define TIOCGLCKTRMIOS 0x5456 +#define TIOCSLCKTRMIOS 0x5457 +#define TIOCSERGSTRUCT 0x5458 /* For debugging only */ +#define TIOCSERGETLSR 0x5459 /* Get line status register */ +#define TIOCSERGETMULTI 0x545A /* Get multiport config */ +#define TIOCSERSETMULTI 0x545B /* Set multiport config */ + +#define TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */ +#define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */ +#define FIOQSIZE 0x545E + +/* Used for packet mode */ +#define TIOCPKT_DATA 0 +#define TIOCPKT_FLUSHREAD 1 +#define TIOCPKT_FLUSHWRITE 2 +#define TIOCPKT_STOP 4 +#define TIOCPKT_START 8 +#define TIOCPKT_NOSTOP 16 +#define TIOCPKT_DOSTOP 32 + +#define TIOCSER_TEMT 0x01 /* Transmitter physically empty */ + +/* Socket-level I/O control calls. */ +#define FIOSETOWN 0x8901 +#define SIOCSPGRP 0x8902 +#define FIOGETOWN 0x8903 +#define SIOCGPGRP 0x8904 +#define SIOCATMARK 0x8905 +#define SIOCGSTAMP 0x8906 /* Get stamp */ diff --git a/mdk-stage1/dietlibc/include/sys/epoll.h b/mdk-stage1/dietlibc/include/sys/epoll.h new file mode 100644 index 000000000..d65d5465f --- /dev/null +++ b/mdk-stage1/dietlibc/include/sys/epoll.h @@ -0,0 +1,60 @@ +#ifndef _SYS_EPOLL_H +#define _SYS_EPOLL_H + +#include +#include +#include + +/* Valid opcodes ( "op" parameter ) to issue to epoll_ctl() */ +#define EPOLL_CTL_ADD 1 /* Add a file decriptor to the interface */ +#define EPOLL_CTL_DEL 2 /* Remove a file decriptor from the interface */ +#define EPOLL_CTL_MOD 3 /* Change file decriptor epoll_event structure */ + +enum EPOLL_EVENTS { + EPOLLIN = 0x001, +#define EPOLLIN EPOLLIN + EPOLLPRI = 0x002, +#define EPOLLPRI EPOLLPRI + EPOLLOUT = 0x004, +#define EPOLLOUT EPOLLOUT + +#ifdef __USE_XOPEN + EPOLLRDNORM = 0x040, +#define EPOLLRDNORM EPOLLRDNORM + EPOLLRDBAND = 0x080, +#define EPOLLRDBAND EPOLLRDBAND + EPOLLWRNORM = 0x100, +#define EPOLLWRNORM EPOLLWRNORM + EPOLLWRBAND = 0x200, +#define EPOLLWRBAND EPOLLWRBAND +#endif /* #ifdef __USE_XOPEN */ + +#ifdef __USE_GNU + EPOLLMSG = 0x400, +#define EPOLLMSG EPOLLMSG +#endif /* #ifdef __USE_GNU */ + + EPOLLERR = 0x008, +#define EPOLLERR EPOLLERR + EPOLLHUP = 0x010 +#define EPOLLHUP EPOLLHUP +}; + +typedef union epoll_data { + void *ptr; + int fd; + uint32_t u32; + uint64_t u64; +} epoll_data_t; + +struct epoll_event { + uint32_t events; + epoll_data_t data; +}; + +int epoll_create(int size) __THROW; +int epoll_ctl(int epfd, int op, int fd, struct epoll_event* event) __THROW; +int epoll_wait(int epfd, struct epoll_event *events, int maxevents, + int timeout) __THROW; + +#endif diff --git a/mdk-stage1/dietlibc/include/sys/fsuid.h b/mdk-stage1/dietlibc/include/sys/fsuid.h new file mode 100644 index 000000000..538070451 --- /dev/null +++ b/mdk-stage1/dietlibc/include/sys/fsuid.h @@ -0,0 +1,12 @@ +#ifndef __FSUID_H +#define __FSUID_H 1 + +#include + +/* Linux only: */ +int setfsuid(uid_t uid); +int setfsgid(gid_t gid); +int setfsuid32(uid32_t fsuid) __THROW; +int setfsgid32(gid32_t fsgid) __THROW; + +#endif diff --git a/mdk-stage1/dietlibc/include/sys/gmon.h b/mdk-stage1/dietlibc/include/sys/gmon.h new file mode 100644 index 000000000..50aae3028 --- /dev/null +++ b/mdk-stage1/dietlibc/include/sys/gmon.h @@ -0,0 +1,99 @@ +#ifndef __DLC_GMON_H_ +#define __DLC_GMON_H_ + +# define HISTCOUNTER unsigned short +# define HISTFRACTION 2 +# define HASHFRACTION 2 +# define ARCDENSITY 2 +# define MINARCS 50 +# define MAXARCS (( 1 << (8 * sizeof(HISTCOUNTER))) - 2) + +# define ROUNDDOWN(x,y) (((x)/(y))*y) +# define ROUNDUP(x,y) ((((x)+(y)-1)/(y))*y) + +# define PROF_SECTION __attribute__ ((section (".profile"))) + +struct tostruct { + unsigned long selfpc; + signed long count; + unsigned short link; + unsigned short pad; +}; + +struct rawarc { + unsigned long raw_frompc; + unsigned long raw_selfpc; + signed long raw_count; +}; + +struct monparam { + unsigned short *kcount; + unsigned long kcountsize; + struct rawarc *arcs; + unsigned long arcnum; + unsigned long lowpc; + unsigned long highpc; + unsigned long textsize; +}; + +struct gmonparam { + long state; + unsigned short *kcount; + unsigned long kcountsize; + unsigned short *froms; + unsigned long fromsize; + struct tostruct *tos; + unsigned long tossize; + long tolimit; + unsigned long lowpc; + unsigned long highpc; + unsigned long textsize; + unsigned long hashfraction; + unsigned long log_hashfraction; +}; + +struct gmon_hdr { + char cookie[4]; + long version; + char spare[12]; +}; + +struct gmon_hist_hdr { + long low_pc; + long high_pc; + long hist_size; + long prof_rate; + char dimen[15]; + char dimen_abbrev; +}; + +struct gmon_cg_arc_record { + long from_pc; + long self_pc; + long count; +}; + +struct __bb { + long zero_word; + char *filename; + long *counts; + long ncounts; + struct __bb *next; + unsigned long *addresses; +}; + +typedef enum { + GMON_TAG_TIME_HIST, GMON_TAG_CG_ARC, GMON_TAG_BB_COUNT +} GMON_Record_Tag; + +enum { GMON_PROF_ON, GMON_PROF_BUSY, GMON_PROF_ERROR, GMON_PROF_OFF }; +enum { GPROF_STATE, GPROF_COUNT, GPROF_FROMS, GPROF_TOS, GPROF_GMONPARAM }; + +extern struct gmonparam gmparam; +extern struct __bb * __bb_head; + +extern void __monstartup(unsigned long, unsigned long); +extern void monstartup(unsigned long, unsigned long); +extern void _mcleanup(void); + +#endif diff --git a/mdk-stage1/dietlibc/include/sys/gmon_out.h b/mdk-stage1/dietlibc/include/sys/gmon_out.h new file mode 100644 index 000000000..31566b999 --- /dev/null +++ b/mdk-stage1/dietlibc/include/sys/gmon_out.h @@ -0,0 +1 @@ +#include diff --git a/mdk-stage1/dietlibc/include/sys/hppa-ioctl.h b/mdk-stage1/dietlibc/include/sys/hppa-ioctl.h new file mode 100644 index 000000000..62b6f1cf9 --- /dev/null +++ b/mdk-stage1/dietlibc/include/sys/hppa-ioctl.h @@ -0,0 +1,133 @@ +#ifndef __ARCH_PARISC_IOCTLS_H__ +#define __ARCH_PARISC_IOCTLS_H__ + +#ifndef _ASM_PARISC_IOCTL_H +#define _ASM_PARISC_IOCTL_H + +#define _IOC_NRBITS 8 +#define _IOC_TYPEBITS 8 +#define _IOC_SIZEBITS 14 +#define _IOC_DIRBITS 2 + +#define _IOC_NRMASK ((1 << _IOC_NRBITS)-1) +#define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1) +#define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1) +#define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1) + +#define _IOC_NRSHIFT 0 +#define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS) +#define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS) +#define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS) + +/* + * Direction bits. + */ +#define _IOC_NONE 0U +#define _IOC_WRITE 2U +#define _IOC_READ 1U + +#define _IOC(dir,type,nr,size) \ + (((dir) << _IOC_DIRSHIFT) | \ + ((type) << _IOC_TYPESHIFT) | \ + ((nr) << _IOC_NRSHIFT) | \ + ((size) << _IOC_SIZESHIFT)) + +/* used to create numbers */ +#define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0) +#define _IOR(type,nr,size) _IOC(_IOC_READ,(type),(nr),sizeof(size)) +#define _IOW(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),sizeof(size)) +#define _IOWR(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size)) + +/* used to decode ioctl numbers.. */ +#define _IOC_DIR(nr) (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK) +#define _IOC_TYPE(nr) (((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK) +#define _IOC_NR(nr) (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK) +#define _IOC_SIZE(nr) (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK) + +/* ...and for the drivers/sound files... */ + +#define IOC_IN (_IOC_WRITE << _IOC_DIRSHIFT) +#define IOC_OUT (_IOC_READ << _IOC_DIRSHIFT) +#define IOC_INOUT ((_IOC_WRITE|_IOC_READ) << _IOC_DIRSHIFT) +#define IOCSIZE_MASK (_IOC_SIZEMASK << _IOC_SIZESHIFT) +#define IOCSIZE_SHIFT (_IOC_SIZESHIFT) + +#endif /* _ASM_PARISC_IOCTL_H */ +/* 0x54 is just a magic number to make these relatively unique ('T') */ + +#define TCGETS _IOR('T', 16, struct termios) /* TCGETATTR */ +#define TCSETS _IOW('T', 17, struct termios) /* TCSETATTR */ +#define TCSETSW _IOW('T', 18, struct termios) /* TCSETATTRD */ +#define TCSETSF _IOW('T', 19, struct termios) /* TCSETATTRF */ +#define TCGETA _IOR('T', 1, struct termio) +#define TCSETA _IOW('T', 2, struct termio) +#define TCSETAW _IOW('T', 3, struct termio) +#define TCSETAF _IOW('T', 4, struct termio) +#define TCSBRK _IO('T', 5) +#define TCXONC _IO('T', 6) +#define TCFLSH _IO('T', 7) +#define TIOCEXCL 0x540C +#define TIOCNXCL 0x540D +#define TIOCSCTTY 0x540E +#define TIOCGPGRP _IOR('T', 30, int) +#define TIOCSPGRP _IOW('T', 29, int) +#define TIOCOUTQ 0x5411 +#define TIOCSTI 0x5412 +#define TIOCGWINSZ 0x5413 +#define TIOCSWINSZ 0x5414 +#define TIOCMGET 0x5415 +#define TIOCMBIS 0x5416 +#define TIOCMBIC 0x5417 +#define TIOCMSET 0x5418 +#define TIOCGSOFTCAR 0x5419 +#define TIOCSSOFTCAR 0x541A +#define FIONREAD 0x541B +#define TIOCINQ FIONREAD +#define TIOCLINUX 0x541C +#define TIOCCONS 0x541D +#define TIOCGSERIAL 0x541E +#define TIOCSSERIAL 0x541F +#define TIOCPKT 0x5420 +#define FIONBIO 0x5421 +#define TIOCNOTTY 0x5422 +#define TIOCSETD 0x5423 +#define TIOCGETD 0x5424 +#define TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */ +#define TIOCTTYGSTRUCT 0x5426 /* For debugging only */ +#define TIOCSBRK 0x5427 /* BSD compatibility */ +#define TIOCCBRK 0x5428 /* BSD compatibility */ +#define TIOCGSID _IOR('T', 20, int) /* Return the session ID of FD */ +#define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */ +#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */ + +#define FIONCLEX 0x5450 /* these numbers need to be adjusted. */ +#define FIOCLEX 0x5451 +#define FIOASYNC 0x5452 +#define TIOCSERCONFIG 0x5453 +#define TIOCSERGWILD 0x5454 +#define TIOCSERSWILD 0x5455 +#define TIOCGLCKTRMIOS 0x5456 +#define TIOCSLCKTRMIOS 0x5457 +#define TIOCSERGSTRUCT 0x5458 /* For debugging only */ +#define TIOCSERGETLSR 0x5459 /* Get line status register */ +#define TIOCSERGETMULTI 0x545A /* Get multiport config */ +#define TIOCSERSETMULTI 0x545B /* Set multiport config */ + +#define TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */ +#define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */ +#define TIOCGHAYESESP 0x545E /* Get Hayes ESP configuration */ +#define TIOCSHAYESESP 0x545F /* Set Hayes ESP configuration */ +#define FIOQSIZE 0x5460 /* Get exact space used by quota */ + +/* Used for packet mode */ +#define TIOCPKT_DATA 0 +#define TIOCPKT_FLUSHREAD 1 +#define TIOCPKT_FLUSHWRITE 2 +#define TIOCPKT_STOP 4 +#define TIOCPKT_START 8 +#define TIOCPKT_NOSTOP 16 +#define TIOCPKT_DOSTOP 32 + +#define TIOCSER_TEMT 0x01 /* Transmitter physically empty */ + +#endif /* _ASM_PARISC_IOCTLS_H */ diff --git a/mdk-stage1/dietlibc/include/sys/i386-ioctl.h b/mdk-stage1/dietlibc/include/sys/i386-ioctl.h new file mode 100644 index 000000000..c9aa270d6 --- /dev/null +++ b/mdk-stage1/dietlibc/include/sys/i386-ioctl.h @@ -0,0 +1,141 @@ + +/* + * The following is for compatibility across the various Linux + * platforms. The i386 ioctl numbering scheme doesn't really enforce + * a type field. De facto, however, the top 8 bits of the lower 16 + * bits are indeed used as a type field, so we might just as well make + * this explicit here. Please be sure to use the decoding macros + * below from now on. + */ +#define _IOC_NRBITS 8 +#define _IOC_TYPEBITS 8 +#define _IOC_SIZEBITS 14 +#define _IOC_DIRBITS 2 + +#define _IOC_NRMASK ((1 << _IOC_NRBITS)-1) +#define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1) +#define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1) +#define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1) + +#define _IOC_NRSHIFT 0 +#define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS) +#define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS) +#define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS) + +/* + * Direction bits. + */ +#define _IOC_NONE 0U +#define _IOC_WRITE 1U +#define _IOC_READ 2U + +#define _IOC(dir,type,nr,size) \ + (((dir) << _IOC_DIRSHIFT) | \ + ((type) << _IOC_TYPESHIFT) | \ + ((nr) << _IOC_NRSHIFT) | \ + ((size) << _IOC_SIZESHIFT)) + +/* used to create numbers */ +#define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0) +#define _IOR(type,nr,size) _IOC(_IOC_READ,(type),(nr),sizeof(size)) +#define _IOW(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),sizeof(size)) +#define _IOWR(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size)) + +/* used to decode ioctl numbers.. */ +#define _IOC_DIR(nr) (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK) +#define _IOC_TYPE(nr) (((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK) +#define _IOC_NR(nr) (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK) +#define _IOC_SIZE(nr) (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK) + +/* ...and for the drivers/sound files... */ + +#define IOC_IN (_IOC_WRITE << _IOC_DIRSHIFT) +#define IOC_OUT (_IOC_READ << _IOC_DIRSHIFT) +#define IOC_INOUT ((_IOC_WRITE|_IOC_READ) << _IOC_DIRSHIFT) +#define IOCSIZE_MASK (_IOC_SIZEMASK << _IOC_SIZESHIFT) +#define IOCSIZE_SHIFT (_IOC_SIZESHIFT) + +/* 0x54 is just a magic number to make these relatively unique ('T') */ + +#define TCGETS 0x5401 +#define TCSETS 0x5402 +#define TCSETSW 0x5403 +#define TCSETSF 0x5404 +#define TCGETA 0x5405 +#define TCSETA 0x5406 +#define TCSETAW 0x5407 +#define TCSETAF 0x5408 +#define TCSBRK 0x5409 +#define TCXONC 0x540A +#define TCFLSH 0x540B +#define TIOCEXCL 0x540C +#define TIOCNXCL 0x540D +#define TIOCSCTTY 0x540E +#define TIOCGPGRP 0x540F +#define TIOCSPGRP 0x5410 +#define TIOCOUTQ 0x5411 +#define TIOCSTI 0x5412 +#define TIOCGWINSZ 0x5413 +#define TIOCSWINSZ 0x5414 +#define TIOCMGET 0x5415 +#define TIOCMBIS 0x5416 +#define TIOCMBIC 0x5417 +#define TIOCMSET 0x5418 +#define TIOCGSOFTCAR 0x5419 +#define TIOCSSOFTCAR 0x541A +#define FIONREAD 0x541B +#define TIOCINQ FIONREAD +#define TIOCLINUX 0x541C +#define TIOCCONS 0x541D +#define TIOCGSERIAL 0x541E +#define TIOCSSERIAL 0x541F +#define TIOCPKT 0x5420 +#define FIONBIO 0x5421 +#define TIOCNOTTY 0x5422 +#define TIOCSETD 0x5423 +#define TIOCGETD 0x5424 +#define TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */ +#define TIOCTTYGSTRUCT 0x5426 /* For debugging only */ +#define TIOCSBRK 0x5427 /* BSD compatibility */ +#define TIOCCBRK 0x5428 /* BSD compatibility */ +#define TIOCGSID 0x5429 /* Return the session ID of FD */ +#define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */ +#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */ + +#define FIONCLEX 0x5450 /* these numbers need to be adjusted. */ +#define FIOCLEX 0x5451 +#define FIOASYNC 0x5452 +#define TIOCSERCONFIG 0x5453 +#define TIOCSERGWILD 0x5454 +#define TIOCSERSWILD 0x5455 +#define TIOCGLCKTRMIOS 0x5456 +#define TIOCSLCKTRMIOS 0x5457 +#define TIOCSERGSTRUCT 0x5458 /* For debugging only */ +#define TIOCSERGETLSR 0x5459 /* Get line status register */ +#define TIOCSERGETMULTI 0x545A /* Get multiport config */ +#define TIOCSERSETMULTI 0x545B /* Set multiport config */ + +#define TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */ +#define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */ +#define TIOCGHAYESESP 0x545E /* Get Hayes ESP configuration */ +#define TIOCSHAYESESP 0x545F /* Set Hayes ESP configuration */ +#define FIOQSIZE 0x5460 + +/* Used for packet mode */ +#define TIOCPKT_DATA 0 +#define TIOCPKT_FLUSHREAD 1 +#define TIOCPKT_FLUSHWRITE 2 +#define TIOCPKT_STOP 4 +#define TIOCPKT_START 8 +#define TIOCPKT_NOSTOP 16 +#define TIOCPKT_DOSTOP 32 + +#define TIOCSER_TEMT 0x01 /* Transmitter physically empty */ + +/* Socket-level I/O control calls. */ +#define FIOSETOWN 0x8901 +#define SIOCSPGRP 0x8902 +#define FIOGETOWN 0x8903 +#define SIOCGPGRP 0x8904 +#define SIOCATMARK 0x8905 +#define SIOCGSTAMP 0x8906 /* Get stamp */ diff --git a/mdk-stage1/dietlibc/include/sys/klog.h b/mdk-stage1/dietlibc/include/sys/klog.h new file mode 100644 index 000000000..abacfef9c --- /dev/null +++ b/mdk-stage1/dietlibc/include/sys/klog.h @@ -0,0 +1,8 @@ +#ifndef _SYS_KLOG_H +#define _SYS_KLOG_H + +#include + +extern int klogctl (int __type, char *__bufp, int __len) __THROW; + +#endif diff --git a/mdk-stage1/dietlibc/include/sys/mips-ioctl.h b/mdk-stage1/dietlibc/include/sys/mips-ioctl.h new file mode 100644 index 000000000..889ac83ae --- /dev/null +++ b/mdk-stage1/dietlibc/include/sys/mips-ioctl.h @@ -0,0 +1,177 @@ +#define _IOC_NRBITS 8 +#define _IOC_TYPEBITS 8 +#define _IOC_SIZEBITS 13 +#define _IOC_DIRBITS 3 + +#define _IOC_NRMASK ((1 << _IOC_NRBITS)-1) +#define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1) +#define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1) +#define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1) + +#define _IOC_NRSHIFT 0 +#define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS) +#define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS) +#define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS) + +/* + * We to additionally limit parameters to a maximum 255 bytes. + */ +#define _IOC_SLMASK 0xff + +/* + * Direction bits _IOC_NONE could be 0, but OSF/1 gives it a bit. + * And this turns out useful to catch old ioctl numbers in header + * files for us. + */ +#define _IOC_NONE 1U +#define _IOC_READ 2U +#define _IOC_WRITE 4U + +/* + * The following are included for compatibility + */ +#define _IOC_VOID 0x20000000 +#define _IOC_OUT 0x40000000 +#define _IOC_IN 0x80000000 +#define _IOC_INOUT (IOC_IN|IOC_OUT) + +#define _IOC(dir,type,nr,size) \ + (((dir) << _IOC_DIRSHIFT) | \ + ((type) << _IOC_TYPESHIFT) | \ + ((nr) << _IOC_NRSHIFT) | \ + (((size) & _IOC_SLMASK) << _IOC_SIZESHIFT)) + +/* used to create numbers */ +#define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0) +#define _IOR(type,nr,size) _IOC(_IOC_READ,(type),(nr),sizeof(size)) +#define _IOW(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),sizeof(size)) +#define _IOWR(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size)) + +/* used to decode them.. */ +#define _IOC_DIR(nr) (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK) +#define _IOC_TYPE(nr) (((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK) +#define _IOC_NR(nr) (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK) +#define _IOC_SIZE(nr) (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK) + +/* ...and for the drivers/sound files... */ + +#define IOC_IN (_IOC_WRITE << _IOC_DIRSHIFT) +#define IOC_OUT (_IOC_READ << _IOC_DIRSHIFT) +#define IOC_INOUT ((_IOC_WRITE|_IOC_READ) << _IOC_DIRSHIFT) +#define IOCSIZE_MASK (_IOC_SIZEMASK << _IOC_SIZESHIFT) +#define IOCSIZE_SHIFT (_IOC_SIZESHIFT) + +#if defined(__USE_MISC) || defined (__KERNEL__) +#define tIOC ('t' << 8) +#endif + +#define TCGETA 0x5401 +#define TCSETA 0x5402 +#define TCSETAW 0x5403 +#define TCSETAF 0x5404 + +#define TCSBRK 0x5405 +#define TCXONC 0x5406 +#define TCFLSH 0x5407 + +#define TCGETS 0x540d +#define TCSETS 0x540e +#define TCSETSW 0x540f +#define TCSETSF 0x5410 + +#define TIOCEXCL 0x740d /* set exclusive use of tty */ +#define TIOCNXCL 0x740e /* reset exclusive use of tty */ +#define TIOCOUTQ 0x7472 /* output queue size */ +#define TIOCSTI 0x5472 /* simulate terminal input */ +#define TIOCMGET 0x741d /* get all modem bits */ +#define TIOCMBIS 0x741b /* bis modem bits */ +#define TIOCMBIC 0x741c /* bic modem bits */ +#define TIOCMSET 0x741a /* set all modem bits */ +#define TIOCPKT 0x5470 /* pty: set/clear packet mode */ +#define TIOCPKT_DATA 0x00 /* data packet */ +#define TIOCPKT_FLUSHREAD 0x01 /* flush packet */ +#define TIOCPKT_FLUSHWRITE 0x02 /* flush packet */ +#define TIOCPKT_STOP 0x04 /* stop output */ +#define TIOCPKT_START 0x08 /* start output */ +#define TIOCPKT_NOSTOP 0x10 /* no more ^S, ^Q */ +#define TIOCPKT_DOSTOP 0x20 /* now do ^S ^Q */ +#if 0 +#define TIOCPKT_IOCTL 0x40 /* state change of pty driver */ +#endif +#define TIOCSWINSZ _IOW('t', 103, struct winsize) /* set window size */ +#define TIOCGWINSZ _IOR('t', 104, struct winsize) /* get window size */ +#define TIOCNOTTY 0x5471 /* void tty association */ +#define TIOCSETD (tIOC | 1) +#define TIOCGETD (tIOC | 0) + +#define FIOCLEX 0x6601 +#define FIONCLEX 0x6602 /* these numbers need to be adjusted. */ +#define FIOASYNC 0x667d +#define FIONBIO 0x667e +#define FIOQSIZE 0x667f + +#if defined(__USE_MISC) || defined (__KERNEL__) +#define TIOCGLTC (tIOC | 116) /* get special local chars */ +#define TIOCSLTC (tIOC | 117) /* set special local chars */ +#endif +#define TIOCSPGRP _IOW('t', 118, int) /* set pgrp of tty */ +#define TIOCGPGRP _IOR('t', 119, int) /* get pgrp of tty */ +#define TIOCCONS _IOW('t', 120, int) /* become virtual console */ + +#define FIONREAD 0x467f +#define TIOCINQ FIONREAD + +#if defined(__USE_MISC) || defined (__KERNEL__) +#define TIOCGETP (tIOC | 8) +#define TIOCSETP (tIOC | 9) +#define TIOCSETN (tIOC | 10) /* TIOCSETP wo flush */ +#endif + +#if 0 +#define TIOCSETA _IOW('t', 20, struct termios) /* set termios struct */ +#define TIOCSETAW _IOW('t', 21, struct termios) /* drain output, set */ +#define TIOCSETAF _IOW('t', 22, struct termios) /* drn out, fls in, set */ +#define TIOCGETD _IOR('t', 26, int) /* get line discipline */ +#define TIOCSETD _IOW('t', 27, int) /* set line discipline */ + /* 127-124 compat */ +#endif + +/* I hope the range from 0x5480 on is free ... */ +#define TIOCSCTTY 0x5480 /* become controlling tty */ +#define TIOCGSOFTCAR 0x5481 +#define TIOCSSOFTCAR 0x5482 +#define TIOCLINUX 0x5483 +#define TIOCGSERIAL 0x5484 +#define TIOCSSERIAL 0x5485 + +#define TCSBRKP 0x5486 /* Needed for POSIX tcsendbreak() */ +#define TIOCTTYGSTRUCT 0x5487 /* For debugging only */ +#define TIOCSBRK 0x5427 /* BSD compatibility */ +#define TIOCCBRK 0x5428 /* BSD compatibility */ +#define TIOCGSID 0x7416 /* Return the session ID of FD */ +#define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */ +#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */ + +#define TIOCSERCONFIG 0x5488 +#define TIOCSERGWILD 0x5489 +#define TIOCSERSWILD 0x548a +#define TIOCGLCKTRMIOS 0x548b +#define TIOCSLCKTRMIOS 0x548c +#define TIOCSERGSTRUCT 0x548d /* For debugging only */ +#define TIOCSERGETLSR 0x548e /* Get line status register */ +#define TIOCSERGETMULTI 0x548f /* Get multiport config */ +#define TIOCSERSETMULTI 0x5490 /* Set multiport config */ +#define TIOCMIWAIT 0x5491 /* wait for a change on serial input line(s) */ +#define TIOCGICOUNT 0x5492 /* read serial port inline interrupt counts */ +#define TIOCGHAYESESP 0x5493 /* Get Hayes ESP configuration */ +#define TIOCSHAYESESP 0x5494 /* Set Hayes ESP configuration */ + +/* Socket-level I/O control calls. */ +#define FIOGETOWN _IOR('f', 123, int) +#define FIOSETOWN _IOW('f', 124, int) + +#define SIOCATMARK _IOR('s', 7, int) +#define SIOCSPGRP _IOW('s', 8, pid_t) +#define SIOCGPGRP _IOR('s', 9, pid_t) + +#define SIOCGSTAMP 0x8906 /* Get stamp - linux-specific */ diff --git a/mdk-stage1/dietlibc/include/sys/ppc-ioctl.h b/mdk-stage1/dietlibc/include/sys/ppc-ioctl.h new file mode 100644 index 000000000..c3de6d254 --- /dev/null +++ b/mdk-stage1/dietlibc/include/sys/ppc-ioctl.h @@ -0,0 +1,164 @@ + +#define _IOC_NRBITS 8 +#define _IOC_TYPEBITS 8 +#define _IOC_SIZEBITS 13 +#define _IOC_DIRBITS 3 + +#define _IOC_NRMASK ((1 << _IOC_NRBITS)-1) +#define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1) +#define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1) +#define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1) + +#define _IOC_NRSHIFT 0 +#define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS) +#define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS) +#define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS) + +/* + * Direction bits _IOC_NONE could be 0, but OSF/1 gives it a bit. + * And this turns out useful to catch old ioctl numbers in header + * files for us. + */ +#define _IOC_NONE 1U +#define _IOC_READ 2U +#define _IOC_WRITE 4U + +#define _IOC(dir,type,nr,size) \ + (((dir) << _IOC_DIRSHIFT) | \ + ((type) << _IOC_TYPESHIFT) | \ + ((nr) << _IOC_NRSHIFT) | \ + ((size) << _IOC_SIZESHIFT)) + +/* used to create numbers */ +#define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0) +#define _IOR(type,nr,size) _IOC(_IOC_READ,(type),(nr),sizeof(size)) +#define _IOW(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),sizeof(size)) +#define _IOWR(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size)) + +/* used to decode them.. */ +#define _IOC_DIR(nr) (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK) +#define _IOC_TYPE(nr) (((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK) +#define _IOC_NR(nr) (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK) +#define _IOC_SIZE(nr) (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK) + +/* various drivers, such as the pcmcia stuff, need these... */ +#define IOC_IN (_IOC_WRITE << _IOC_DIRSHIFT) +#define IOC_OUT (_IOC_READ << _IOC_DIRSHIFT) +#define IOC_INOUT ((_IOC_WRITE|_IOC_READ) << _IOC_DIRSHIFT) +#define IOCSIZE_MASK (_IOC_SIZEMASK << _IOC_SIZESHIFT) +#define IOCSIZE_SHIFT (_IOC_SIZESHIFT) + +#define FIOCLEX _IO('f', 1) +#define FIONCLEX _IO('f', 2) +#define FIOASYNC _IOW('f', 125, int) +#define FIONBIO _IOW('f', 126, int) +#define FIONREAD _IOR('f', 127, int) +#define TIOCINQ FIONREAD +#define FIOQSIZE _IOR('f', 128, loff_t) + +#define TIOCGETP _IOR('t', 8, struct sgttyb) +#define TIOCSETP _IOW('t', 9, struct sgttyb) +#define TIOCSETN _IOW('t', 10, struct sgttyb) /* TIOCSETP wo flush */ + +#define TIOCSETC _IOW('t', 17, struct tchars) +#define TIOCGETC _IOR('t', 18, struct tchars) +#define TCGETS _IOR('t', 19, struct termios) +#define TCSETS _IOW('t', 20, struct termios) +#define TCSETSW _IOW('t', 21, struct termios) +#define TCSETSF _IOW('t', 22, struct termios) + +#define TCGETA _IOR('t', 23, struct termio) +#define TCSETA _IOW('t', 24, struct termio) +#define TCSETAW _IOW('t', 25, struct termio) +#define TCSETAF _IOW('t', 28, struct termio) + +#define TCSBRK _IO('t', 29) +#define TCXONC _IO('t', 30) +#define TCFLSH _IO('t', 31) + +#define TIOCSWINSZ _IOW('t', 103, struct winsize) +#define TIOCGWINSZ _IOR('t', 104, struct winsize) +#define TIOCSTART _IO('t', 110) /* start output, like ^Q */ +#define TIOCSTOP _IO('t', 111) /* stop output, like ^S */ +#define TIOCOUTQ _IOR('t', 115, int) /* output queue size */ + +#define TIOCGLTC _IOR('t', 116, struct ltchars) +#define TIOCSLTC _IOW('t', 117, struct ltchars) +#define TIOCSPGRP _IOW('t', 118, int) +#define TIOCGPGRP _IOR('t', 119, int) + +#define TIOCEXCL 0x540C +#define TIOCNXCL 0x540D +#define TIOCSCTTY 0x540E + +#define TIOCSTI 0x5412 +#define TIOCMGET 0x5415 +#define TIOCMBIS 0x5416 +#define TIOCMBIC 0x5417 +#define TIOCMSET 0x5418 +# define TIOCM_LE 0x001 +# define TIOCM_DTR 0x002 +# define TIOCM_RTS 0x004 +# define TIOCM_ST 0x008 +# define TIOCM_SR 0x010 +# define TIOCM_CTS 0x020 +# define TIOCM_CAR 0x040 +# define TIOCM_RNG 0x080 +# define TIOCM_DSR 0x100 +# define TIOCM_CD TIOCM_CAR +# define TIOCM_RI TIOCM_RNG + +#define TIOCGSOFTCAR 0x5419 +#define TIOCSSOFTCAR 0x541A +#define TIOCLINUX 0x541C +#define TIOCCONS 0x541D +#define TIOCGSERIAL 0x541E +#define TIOCSSERIAL 0x541F +#define TIOCPKT 0x5420 +# define TIOCPKT_DATA 0 +# define TIOCPKT_FLUSHREAD 1 +# define TIOCPKT_FLUSHWRITE 2 +# define TIOCPKT_STOP 4 +# define TIOCPKT_START 8 +# define TIOCPKT_NOSTOP 16 +# define TIOCPKT_DOSTOP 32 + + +#define TIOCNOTTY 0x5422 +#define TIOCSETD 0x5423 +#define TIOCGETD 0x5424 +#define TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */ +#define TIOCTTYGSTRUCT 0x5426 /* For debugging only */ +#define TIOCSBRK 0x5427 /* BSD compatibility */ +#define TIOCCBRK 0x5428 /* BSD compatibility */ +#define TIOCGSID 0x5429 /* Return the session ID of FD */ +#define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */ +#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */ + +#define TIOCSERCONFIG 0x5453 +#define TIOCSERGWILD 0x5454 +#define TIOCSERSWILD 0x5455 +#define TIOCGLCKTRMIOS 0x5456 +#define TIOCSLCKTRMIOS 0x5457 +#define TIOCSERGSTRUCT 0x5458 /* For debugging only */ +#define TIOCSERGETLSR 0x5459 /* Get line status register */ + /* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */ +# define TIOCSER_TEMT 0x01 /* Transmitter physically empty */ +#define TIOCSERGETMULTI 0x545A /* Get multiport config */ +#define TIOCSERSETMULTI 0x545B /* Set multiport config */ + +#define TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */ +#define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */ + +#if 0 /* These are defined this way on Alpha - maybe later. */ +/* Socket-level I/O control calls. */ + +#define FIOGETOWN _IOR('f', 123, int) +#define FIOSETOWN _IOW('f', 124, int) + +#define SIOCATMARK _IOR('s', 7, int) +#define SIOCSPGRP _IOW('s', 8, pid_t) +#define SIOCGPGRP _IOR('s', 9, pid_t) + +#define SIOCGSTAMP 0x8906 /* Get stamp - linux-specific */ +#endif diff --git a/mdk-stage1/dietlibc/include/sys/prctl.h b/mdk-stage1/dietlibc/include/sys/prctl.h new file mode 100644 index 000000000..26749cbd4 --- /dev/null +++ b/mdk-stage1/dietlibc/include/sys/prctl.h @@ -0,0 +1,8 @@ +#ifndef _SYS_PRCTL_H +#define _SYS_PRCTL_H + +#include + +int prctl(int option, unsigned long arg2, unsigned long arg3 , unsigned long arg4, unsigned long arg5) __THROW; + +#endif diff --git a/mdk-stage1/dietlibc/include/sys/s390-ioctl.h b/mdk-stage1/dietlibc/include/sys/s390-ioctl.h new file mode 100644 index 000000000..4682a0fda --- /dev/null +++ b/mdk-stage1/dietlibc/include/sys/s390-ioctl.h @@ -0,0 +1,141 @@ + +/* ioctl command encoding: 32 bits total, command in lower 16 bits, + * size of the parameter structure in the lower 14 bits of the + * upper 16 bits. + * Encoding the size of the parameter structure in the ioctl request + * is useful for catching programs compiled with old versions + * and to avoid overwriting user space outside the user buffer area. + * The highest 2 bits are reserved for indicating the ``access mode''. + * NOTE: This limits the max parameter size to 16kB -1 ! + */ + +/* + * The following is for compatibility across the various Linux + * platforms. The i386 ioctl numbering scheme doesn't really enforce + * a type field. De facto, however, the top 8 bits of the lower 16 + * bits are indeed used as a type field, so we might just as well make + * this explicit here. Please be sure to use the decoding macros + * below from now on. + */ +#define _IOC_NRBITS 8 +#define _IOC_TYPEBITS 8 +#define _IOC_SIZEBITS 14 +#define _IOC_DIRBITS 2 + +#define _IOC_NRMASK ((1 << _IOC_NRBITS)-1) +#define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1) +#define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1) +#define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1) + +#define _IOC_NRSHIFT 0 +#define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS) +#define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS) +#define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS) + +/* + * Direction bits. + */ +#define _IOC_NONE 0U +#define _IOC_WRITE 1U +#define _IOC_READ 2U + +#define _IOC(dir,type,nr,size) \ + (((dir) << _IOC_DIRSHIFT) | \ + ((type) << _IOC_TYPESHIFT) | \ + ((nr) << _IOC_NRSHIFT) | \ + ((size) << _IOC_SIZESHIFT)) + +/* used to create numbers */ +#define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0) +#define _IOR(type,nr,size) _IOC(_IOC_READ,(type),(nr),sizeof(size)) +#define _IOW(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),sizeof(size)) +#define _IOWR(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size)) + +/* used to decode ioctl numbers.. */ +#define _IOC_DIR(nr) (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK) +#define _IOC_TYPE(nr) (((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK) +#define _IOC_NR(nr) (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK) +#define _IOC_SIZE(nr) (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK) + +/* ...and for the drivers/sound files... */ + +#define IOC_IN (_IOC_WRITE << _IOC_DIRSHIFT) +#define IOC_OUT (_IOC_READ << _IOC_DIRSHIFT) +#define IOC_INOUT ((_IOC_WRITE|_IOC_READ) << _IOC_DIRSHIFT) +#define IOCSIZE_MASK (_IOC_SIZEMASK << _IOC_SIZESHIFT) +#define IOCSIZE_SHIFT (_IOC_SIZESHIFT) + +/* 0x54 is just a magic number to make these relatively unique ('T') */ + +#define TCGETS 0x5401 +#define TCSETS 0x5402 +#define TCSETSW 0x5403 +#define TCSETSF 0x5404 +#define TCGETA 0x5405 +#define TCSETA 0x5406 +#define TCSETAW 0x5407 +#define TCSETAF 0x5408 +#define TCSBRK 0x5409 +#define TCXONC 0x540A +#define TCFLSH 0x540B +#define TIOCEXCL 0x540C +#define TIOCNXCL 0x540D +#define TIOCSCTTY 0x540E +#define TIOCGPGRP 0x540F +#define TIOCSPGRP 0x5410 +#define TIOCOUTQ 0x5411 +#define TIOCSTI 0x5412 +#define TIOCGWINSZ 0x5413 +#define TIOCSWINSZ 0x5414 +#define TIOCMGET 0x5415 +#define TIOCMBIS 0x5416 +#define TIOCMBIC 0x5417 +#define TIOCMSET 0x5418 +#define TIOCGSOFTCAR 0x5419 +#define TIOCSSOFTCAR 0x541A +#define FIONREAD 0x541B +#define TIOCINQ FIONREAD +#define TIOCLINUX 0x541C +#define TIOCCONS 0x541D +#define TIOCGSERIAL 0x541E +#define TIOCSSERIAL 0x541F +#define TIOCPKT 0x5420 +#define FIONBIO 0x5421 +#define TIOCNOTTY 0x5422 +#define TIOCSETD 0x5423 +#define TIOCGETD 0x5424 +#define TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */ +#define TIOCTTYGSTRUCT 0x5426 /* For debugging only */ +#define TIOCSBRK 0x5427 /* BSD compatibility */ +#define TIOCCBRK 0x5428 /* BSD compatibility */ +#define TIOCGSID 0x5429 /* Return the session ID of FD */ +#define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */ +#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */ + +#define FIONCLEX 0x5450 /* these numbers need to be adjusted. */ +#define FIOCLEX 0x5451 +#define FIOASYNC 0x5452 +#define TIOCSERCONFIG 0x5453 +#define TIOCSERGWILD 0x5454 +#define TIOCSERSWILD 0x5455 +#define TIOCGLCKTRMIOS 0x5456 +#define TIOCSLCKTRMIOS 0x5457 +#define TIOCSERGSTRUCT 0x5458 /* For debugging only */ +#define TIOCSERGETLSR 0x5459 /* Get line status register */ +#define TIOCSERGETMULTI 0x545A /* Get multiport config */ +#define TIOCSERSETMULTI 0x545B /* Set multiport config */ + +#define TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */ +#define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */ +#define FIOQSIZE 0x545E + +/* Used for packet mode */ +#define TIOCPKT_DATA 0 +#define TIOCPKT_FLUSHREAD 1 +#define TIOCPKT_FLUSHWRITE 2 +#define TIOCPKT_STOP 4 +#define TIOCPKT_START 8 +#define TIOCPKT_NOSTOP 16 +#define TIOCPKT_DOSTOP 32 + +#define TIOCSER_TEMT 0x01 /* Transmitter physically empty */ diff --git a/mdk-stage1/dietlibc/include/sys/soundcard.h b/mdk-stage1/dietlibc/include/sys/soundcard.h new file mode 100644 index 000000000..e8766499a --- /dev/null +++ b/mdk-stage1/dietlibc/include/sys/soundcard.h @@ -0,0 +1,1300 @@ +#ifndef _SYS_SOUNDCARD_H +#define _SYS_SOUNDCARD_H + +/* + * Copyright by Hannu Savolainen 1993-1997 + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. 2. + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + + +/* + * OSS interface version. With versions earlier than 3.6 this value is + * an integer with value less than 361. In versions 3.6 and later + * it's a six digit hexadecimal value. For example value + * of 0x030600 represents OSS version 3.6.0. + * Use ioctl(fd, OSS_GETVERSION, &int) to get the version number of + * the currently active driver. + */ +#define SOUND_VERSION 0x030802 +#define OPEN_SOUND_SYSTEM + +/* In Linux we need to be prepared for cross compiling */ +#include + +/* + * Supported card ID numbers (Should be somewhere else?) + */ + +#define SNDCARD_ADLIB 1 +#define SNDCARD_SB 2 +#define SNDCARD_PAS 3 +#define SNDCARD_GUS 4 +#define SNDCARD_MPU401 5 +#define SNDCARD_SB16 6 +#define SNDCARD_SB16MIDI 7 +#define SNDCARD_UART6850 8 +#define SNDCARD_GUS16 9 +#define SNDCARD_MSS 10 +#define SNDCARD_PSS 11 +#define SNDCARD_SSCAPE 12 +#define SNDCARD_PSS_MPU 13 +#define SNDCARD_PSS_MSS 14 +#define SNDCARD_SSCAPE_MSS 15 +#define SNDCARD_TRXPRO 16 +#define SNDCARD_TRXPRO_SB 17 +#define SNDCARD_TRXPRO_MPU 18 +#define SNDCARD_MAD16 19 +#define SNDCARD_MAD16_MPU 20 +#define SNDCARD_CS4232 21 +#define SNDCARD_CS4232_MPU 22 +#define SNDCARD_MAUI 23 +#define SNDCARD_PSEUDO_MSS 24 +#define SNDCARD_GUSPNP 25 +#define SNDCARD_UART401 26 +/* Sound card numbers 27 to N are reserved. Don't add more numbers here. */ + +/*********************************** + * IOCTL Commands for /dev/sequencer + */ + +#ifndef _SIOWR +#if defined(_IOWR) && (defined(_AIX) || (!defined(sun) && !defined(sparc) && !defined(__sparc__) && !defined(__INCioctlh) && !defined(__Lynx__))) +/* Use already defined ioctl defines if they exist (except with Sun or Sparc) */ +#define SIOCPARM_MASK IOCPARM_MASK +#define SIOC_VOID IOC_VOID +#define SIOC_OUT IOC_OUT +#define SIOC_IN IOC_IN +#define SIOC_INOUT IOC_INOUT +#define _SIOC_SIZE _IOC_SIZE +#define _SIOC_DIR _IOC_DIR +#define _SIOC_NONE _IOC_NONE +#define _SIOC_READ _IOC_READ +#define _SIOC_WRITE _IOC_WRITE +#define _SIO _IO +#define _SIOR _IOR +#define _SIOW _IOW +#define _SIOWR _IOWR +#else + +/* Ioctl's have the command encoded in the lower word, + * and the size of any in or out parameters in the upper + * word. The high 2 bits of the upper word are used + * to encode the in/out status of the parameter; for now + * we restrict parameters to at most 8191 bytes. + */ +/* #define SIOCTYPE (0xff<<8) */ +#define SIOCPARM_MASK 0x1fff /* parameters must be < 8192 bytes */ +#define SIOC_VOID 0x00000000 /* no parameters */ +#define SIOC_OUT 0x20000000 /* copy out parameters */ +#define SIOC_IN 0x40000000 /* copy in parameters */ +#define SIOC_INOUT (SIOC_IN|SIOC_OUT) +/* the 0x20000000 is so we can distinguish new ioctl's from old */ +#define _SIO(x,y) ((int)(SIOC_VOID|(x<<8)|y)) +#define _SIOR(x,y,t) ((int)(SIOC_OUT|((sizeof(t)&SIOCPARM_MASK)<<16)|(x<<8)|y)) +#define _SIOW(x,y,t) ((int)(SIOC_IN|((sizeof(t)&SIOCPARM_MASK)<<16)|(x<<8)|y)) +/* this should be _SIORW, but stdio got there first */ +#define _SIOWR(x,y,t) ((int)(SIOC_INOUT|((sizeof(t)&SIOCPARM_MASK)<<16)|(x<<8)|y)) +#define _SIOC_SIZE(x) ((x>>16)&SIOCPARM_MASK) +#define _SIOC_DIR(x) (x & 0xf0000000) +#define _SIOC_NONE SIOC_VOID +#define _SIOC_READ SIOC_OUT +#define _SIOC_WRITE SIOC_IN +# endif /* _IOWR */ +#endif /* !_SIOWR */ + +#define SNDCTL_SEQ_RESET _SIO ('Q', 0) +#define SNDCTL_SEQ_SYNC _SIO ('Q', 1) +#define SNDCTL_SYNTH_INFO _SIOWR('Q', 2, struct synth_info) +#define SNDCTL_SEQ_CTRLRATE _SIOWR('Q', 3, int) /* Set/get timer resolution (HZ) */ +#define SNDCTL_SEQ_GETOUTCOUNT _SIOR ('Q', 4, int) +#define SNDCTL_SEQ_GETINCOUNT _SIOR ('Q', 5, int) +#define SNDCTL_SEQ_PERCMODE _SIOW ('Q', 6, int) +#define SNDCTL_FM_LOAD_INSTR _SIOW ('Q', 7, struct sbi_instrument) /* Obsolete. Don't use!!!!!! */ +#define SNDCTL_SEQ_TESTMIDI _SIOW ('Q', 8, int) +#define SNDCTL_SEQ_RESETSAMPLES _SIOW ('Q', 9, int) +#define SNDCTL_SEQ_NRSYNTHS _SIOR ('Q',10, int) +#define SNDCTL_SEQ_NRMIDIS _SIOR ('Q',11, int) +#define SNDCTL_MIDI_INFO _SIOWR('Q',12, struct midi_info) +#define SNDCTL_SEQ_THRESHOLD _SIOW ('Q',13, int) +#define SNDCTL_SYNTH_MEMAVL _SIOWR('Q',14, int) /* in=dev#, out=memsize */ +#define SNDCTL_FM_4OP_ENABLE _SIOW ('Q',15, int) /* in=dev# */ +#define SNDCTL_SEQ_PANIC _SIO ('Q',17) +#define SNDCTL_SEQ_OUTOFBAND _SIOW ('Q',18, struct seq_event_rec) +#define SNDCTL_SEQ_GETTIME _SIOR ('Q',19, int) +#define SNDCTL_SYNTH_ID _SIOWR('Q',20, struct synth_info) +#define SNDCTL_SYNTH_CONTROL _SIOWR('Q',21, struct synth_control) +#define SNDCTL_SYNTH_REMOVESAMPLE _SIOWR('Q',22, struct remove_sample) + +typedef struct synth_control +{ + int devno; /* Synthesizer # */ + char data[4000]; /* Device spesific command/data record */ +}synth_control; + +typedef struct remove_sample +{ + int devno; /* Synthesizer # */ + int bankno; /* MIDI bank # (0=General MIDI) */ + int instrno; /* MIDI instrument number */ +} remove_sample; + +typedef struct seq_event_rec { + unsigned char arr[8]; +} seq_event_rec; + +#define SNDCTL_TMR_TIMEBASE _SIOWR('T', 1, int) +#define SNDCTL_TMR_START _SIO ('T', 2) +#define SNDCTL_TMR_STOP _SIO ('T', 3) +#define SNDCTL_TMR_CONTINUE _SIO ('T', 4) +#define SNDCTL_TMR_TEMPO _SIOWR('T', 5, int) +#define SNDCTL_TMR_SOURCE _SIOWR('T', 6, int) +# define TMR_INTERNAL 0x00000001 +# define TMR_EXTERNAL 0x00000002 +# define TMR_MODE_MIDI 0x00000010 +# define TMR_MODE_FSK 0x00000020 +# define TMR_MODE_CLS 0x00000040 +# define TMR_MODE_SMPTE 0x00000080 +#define SNDCTL_TMR_METRONOME _SIOW ('T', 7, int) +#define SNDCTL_TMR_SELECT _SIOW ('T', 8, int) + +/* + * Some big endian/little endian handling macros + */ + +#if defined(_AIX) || defined(AIX) || defined(sparc) || defined(__sparc__) || defined(HPPA) || defined(PPC) +/* Big endian machines */ +# define _PATCHKEY(id) (0xfd00|id) +# define AFMT_S16_NE AFMT_S16_BE +#else +# define _PATCHKEY(id) ((id<<8)|0xfd) +# define AFMT_S16_NE AFMT_S16_LE +#endif + +/* + * Sample loading mechanism for internal synthesizers (/dev/sequencer) + * The following patch_info structure has been designed to support + * Gravis UltraSound. It tries to be universal format for uploading + * sample based patches but is probably too limited. + * + * (PBD) As Hannu guessed, the GUS structure is too limited for + * the WaveFront, but this is the right place for a constant definition. + */ + +struct patch_info { + unsigned short key; /* Use WAVE_PATCH here */ +#define WAVE_PATCH _PATCHKEY(0x04) +#define GUS_PATCH WAVE_PATCH +#define WAVEFRONT_PATCH _PATCHKEY(0x06) + + short device_no; /* Synthesizer number */ + short instr_no; /* Midi pgm# */ + + unsigned int mode; +/* + * The least significant byte has the same format than the GUS .PAT + * files + */ +#define WAVE_16_BITS 0x01 /* bit 0 = 8 or 16 bit wave data. */ +#define WAVE_UNSIGNED 0x02 /* bit 1 = Signed - Unsigned data. */ +#define WAVE_LOOPING 0x04 /* bit 2 = looping enabled-1. */ +#define WAVE_BIDIR_LOOP 0x08 /* bit 3 = Set is bidirectional looping. */ +#define WAVE_LOOP_BACK 0x10 /* bit 4 = Set is looping backward. */ +#define WAVE_SUSTAIN_ON 0x20 /* bit 5 = Turn sustaining on. (Env. pts. 3)*/ +#define WAVE_ENVELOPES 0x40 /* bit 6 = Enable envelopes - 1 */ +#define WAVE_FAST_RELEASE 0x80 /* bit 7 = Shut off immediately after note off */ + /* (use the env_rate/env_offs fields). */ +/* Linux specific bits */ +#define WAVE_VIBRATO 0x00010000 /* The vibrato info is valid */ +#define WAVE_TREMOLO 0x00020000 /* The tremolo info is valid */ +#define WAVE_SCALE 0x00040000 /* The scaling info is valid */ +#define WAVE_FRACTIONS 0x00080000 /* Fraction information is valid */ +/* Reserved bits */ +#define WAVE_ROM 0x40000000 /* For future use */ +#define WAVE_MULAW 0x20000000 /* For future use */ +/* Other bits must be zeroed */ + + int len; /* Size of the wave data in bytes */ + int loop_start, loop_end; /* Byte offsets from the beginning */ + +/* + * The base_freq and base_note fields are used when computing the + * playback speed for a note. The base_note defines the tone frequency + * which is heard if the sample is played using the base_freq as the + * playback speed. + * + * The low_note and high_note fields define the minimum and maximum note + * frequencies for which this sample is valid. It is possible to define + * more than one samples for an instrument number at the same time. The + * low_note and high_note fields are used to select the most suitable one. + * + * The fields base_note, high_note and low_note should contain + * the note frequency multiplied by 1000. For example value for the + * middle A is 440*1000. + */ + + unsigned int base_freq; + unsigned int base_note; + unsigned int high_note; + unsigned int low_note; + int panning; /* -128=left, 127=right */ + int detuning; + +/* New fields introduced in version 1.99.5 */ + + /* Envelope. Enabled by mode bit WAVE_ENVELOPES */ + unsigned char env_rate[ 6 ]; /* GUS HW ramping rate */ + unsigned char env_offset[ 6 ]; /* 255 == 100% */ + + /* + * The tremolo, vibrato and scale info are not supported yet. + * Enable by setting the mode bits WAVE_TREMOLO, WAVE_VIBRATO or + * WAVE_SCALE + */ + + unsigned char tremolo_sweep; + unsigned char tremolo_rate; + unsigned char tremolo_depth; + + unsigned char vibrato_sweep; + unsigned char vibrato_rate; + unsigned char vibrato_depth; + + int scale_frequency; + unsigned int scale_factor; /* from 0 to 2048 or 0 to 2 */ + + int volume; + int fractions; + int reserved1; + int spare[2]; + char data[1]; /* The waveform data starts here */ + }; + +struct sysex_info { + short key; /* Use SYSEX_PATCH or MAUI_PATCH here */ +#define SYSEX_PATCH _PATCHKEY(0x05) +#define MAUI_PATCH _PATCHKEY(0x06) + short device_no; /* Synthesizer number */ + int len; /* Size of the sysex data in bytes */ + unsigned char data[1]; /* Sysex data starts here */ + }; + +/* + * /dev/sequencer input events. + * + * The data written to the /dev/sequencer is a stream of events. Events + * are records of 4 or 8 bytes. The first byte defines the size. + * Any number of events can be written with a write call. There + * is a set of macros for sending these events. Use these macros if you + * want to maximize portability of your program. + * + * Events SEQ_WAIT, SEQ_MIDIPUTC and SEQ_ECHO. Are also input events. + * (All input events are currently 4 bytes long. Be prepared to support + * 8 byte events also. If you receive any event having first byte >= 128, + * it's a 8 byte event. + * + * The events are documented at the end of this file. + * + * Normal events (4 bytes) + * There is also a 8 byte version of most of the 4 byte events. The + * 8 byte one is recommended. + */ +#define SEQ_NOTEOFF 0 +#define SEQ_FMNOTEOFF SEQ_NOTEOFF /* Just old name */ +#define SEQ_NOTEON 1 +#define SEQ_FMNOTEON SEQ_NOTEON +#define SEQ_WAIT TMR_WAIT_ABS +#define SEQ_PGMCHANGE 3 +#define SEQ_FMPGMCHANGE SEQ_PGMCHANGE +#define SEQ_SYNCTIMER TMR_START +#define SEQ_MIDIPUTC 5 +#define SEQ_DRUMON 6 /*** OBSOLETE ***/ +#define SEQ_DRUMOFF 7 /*** OBSOLETE ***/ +#define SEQ_ECHO TMR_ECHO /* For synching programs with output */ +#define SEQ_AFTERTOUCH 9 +#define SEQ_CONTROLLER 10 + +/******************************************* + * Midi controller numbers + ******************************************* + * Controllers 0 to 31 (0x00 to 0x1f) and + * 32 to 63 (0x20 to 0x3f) are continuous + * controllers. + * In the MIDI 1.0 these controllers are sent using + * two messages. Controller numbers 0 to 31 are used + * to send the MSB and the controller numbers 32 to 63 + * are for the LSB. Note that just 7 bits are used in MIDI bytes. + */ + +#define CTL_BANK_SELECT 0x00 +#define CTL_MODWHEEL 0x01 +#define CTL_BREATH 0x02 +/* undefined 0x03 */ +#define CTL_FOOT 0x04 +#define CTL_PORTAMENTO_TIME 0x05 +#define CTL_DATA_ENTRY 0x06 +#define CTL_MAIN_VOLUME 0x07 +#define CTL_BALANCE 0x08 +/* undefined 0x09 */ +#define CTL_PAN 0x0a +#define CTL_EXPRESSION 0x0b +/* undefined 0x0c */ +/* undefined 0x0d */ +/* undefined 0x0e */ +/* undefined 0x0f */ +#define CTL_GENERAL_PURPOSE1 0x10 +#define CTL_GENERAL_PURPOSE2 0x11 +#define CTL_GENERAL_PURPOSE3 0x12 +#define CTL_GENERAL_PURPOSE4 0x13 +/* undefined 0x14 - 0x1f */ + +/* undefined 0x20 */ +/* The controller numbers 0x21 to 0x3f are reserved for the */ +/* least significant bytes of the controllers 0x00 to 0x1f. */ +/* These controllers are not recognised by the driver. */ + +/* Controllers 64 to 69 (0x40 to 0x45) are on/off switches. */ +/* 0=OFF and 127=ON (intermediate values are possible) */ +#define CTL_DAMPER_PEDAL 0x40 +#define CTL_SUSTAIN 0x40 /* Alias */ +#define CTL_HOLD 0x40 /* Alias */ +#define CTL_PORTAMENTO 0x41 +#define CTL_SOSTENUTO 0x42 +#define CTL_SOFT_PEDAL 0x43 +/* undefined 0x44 */ +#define CTL_HOLD2 0x45 +/* undefined 0x46 - 0x4f */ + +#define CTL_GENERAL_PURPOSE5 0x50 +#define CTL_GENERAL_PURPOSE6 0x51 +#define CTL_GENERAL_PURPOSE7 0x52 +#define CTL_GENERAL_PURPOSE8 0x53 +/* undefined 0x54 - 0x5a */ +#define CTL_EXT_EFF_DEPTH 0x5b +#define CTL_TREMOLO_DEPTH 0x5c +#define CTL_CHORUS_DEPTH 0x5d +#define CTL_DETUNE_DEPTH 0x5e +#define CTL_CELESTE_DEPTH 0x5e /* Alias for the above one */ +#define CTL_PHASER_DEPTH 0x5f +#define CTL_DATA_INCREMENT 0x60 +#define CTL_DATA_DECREMENT 0x61 +#define CTL_NONREG_PARM_NUM_LSB 0x62 +#define CTL_NONREG_PARM_NUM_MSB 0x63 +#define CTL_REGIST_PARM_NUM_LSB 0x64 +#define CTL_REGIST_PARM_NUM_MSB 0x65 +/* undefined 0x66 - 0x78 */ +/* reserved 0x79 - 0x7f */ + +/* Pseudo controllers (not midi compatible) */ +#define CTRL_PITCH_BENDER 255 +#define CTRL_PITCH_BENDER_RANGE 254 +#define CTRL_EXPRESSION 253 /* Obsolete */ +#define CTRL_MAIN_VOLUME 252 /* Obsolete */ +#define SEQ_BALANCE 11 +#define SEQ_VOLMODE 12 + +/* + * Volume mode decides how volumes are used + */ + +#define VOL_METHOD_ADAGIO 1 +#define VOL_METHOD_LINEAR 2 + +/* + * Note! SEQ_WAIT, SEQ_MIDIPUTC and SEQ_ECHO are used also as + * input events. + */ + +/* + * Event codes 0xf0 to 0xfc are reserved for future extensions. + */ + +#define SEQ_FULLSIZE 0xfd /* Long events */ +/* + * SEQ_FULLSIZE events are used for loading patches/samples to the + * synthesizer devices. These events are passed directly to the driver + * of the associated synthesizer device. There is no limit to the size + * of the extended events. These events are not queued but executed + * immediately when the write() is called (execution can take several + * seconds of time). + * + * When a SEQ_FULLSIZE message is written to the device, it must + * be written using exactly one write() call. Other events cannot + * be mixed to the same write. + * + * For FM synths (YM3812/OPL3) use struct sbi_instrument and write it to the + * /dev/sequencer. Don't write other data together with the instrument structure + * Set the key field of the structure to FM_PATCH. The device field is used to + * route the patch to the corresponding device. + * + * For wave table use struct patch_info. Initialize the key field + * to WAVE_PATCH. + */ +#define SEQ_PRIVATE 0xfe /* Low level HW dependent events (8 bytes) */ +#define SEQ_EXTENDED 0xff /* Extended events (8 bytes) OBSOLETE */ + +/* + * Record for FM patches + */ + +typedef unsigned char sbi_instr_data[32]; + +struct sbi_instrument { + unsigned short key; /* FM_PATCH or OPL3_PATCH */ +#define FM_PATCH _PATCHKEY(0x01) +#define OPL3_PATCH _PATCHKEY(0x03) + short device; /* Synth# (0-4) */ + int channel; /* Program# to be initialized */ + sbi_instr_data operators; /* Register settings for operator cells (.SBI format) */ + }; + +struct synth_info { /* Read only */ + char name[30]; + int device; /* 0-N. INITIALIZE BEFORE CALLING */ + int synth_type; +#define SYNTH_TYPE_FM 0 +#define SYNTH_TYPE_SAMPLE 1 +#define SYNTH_TYPE_MIDI 2 /* Midi interface */ + + int synth_subtype; +#define FM_TYPE_ADLIB 0x00 +#define FM_TYPE_OPL3 0x01 +#define MIDI_TYPE_MPU401 0x401 + +#define SAMPLE_TYPE_BASIC 0x10 +#define SAMPLE_TYPE_GUS SAMPLE_TYPE_BASIC +#define SAMPLE_TYPE_WAVEFRONT 0x11 + + int perc_mode; /* No longer supported */ + int nr_voices; + int nr_drums; /* Obsolete field */ + int instr_bank_size; + unsigned int capabilities; +#define SYNTH_CAP_PERCMODE 0x00000001 /* No longer used */ +#define SYNTH_CAP_OPL3 0x00000002 /* Set if OPL3 supported */ +#define SYNTH_CAP_INPUT 0x00000004 /* Input (MIDI) device */ + int dummies[19]; /* Reserve space */ + }; + +struct sound_timer_info { + char name[32]; + int caps; + }; + +#define MIDI_CAP_MPU401 1 /* MPU-401 intelligent mode */ + +struct midi_info { + char name[30]; + int device; /* 0-N. INITIALIZE BEFORE CALLING */ + unsigned int capabilities; /* To be defined later */ + int dev_type; + int dummies[18]; /* Reserve space */ + }; + +/******************************************** + * ioctl commands for the /dev/midi## + */ +typedef struct { + unsigned char cmd; + char nr_args, nr_returns; + unsigned char data[30]; + } mpu_command_rec; + +#define SNDCTL_MIDI_PRETIME _SIOWR('m', 0, int) +#define SNDCTL_MIDI_MPUMODE _SIOWR('m', 1, int) +#define SNDCTL_MIDI_MPUCMD _SIOWR('m', 2, mpu_command_rec) + +/******************************************** + * IOCTL commands for /dev/dsp and /dev/audio + */ + +#define SNDCTL_DSP_RESET _SIO ('P', 0) +#define SNDCTL_DSP_SYNC _SIO ('P', 1) +#define SNDCTL_DSP_SPEED _SIOWR('P', 2, int) +#define SNDCTL_DSP_STEREO _SIOWR('P', 3, int) +#define SNDCTL_DSP_GETBLKSIZE _SIOWR('P', 4, int) +#define SNDCTL_DSP_SAMPLESIZE SNDCTL_DSP_SETFMT +#define SNDCTL_DSP_CHANNELS _SIOWR('P', 6, int) +#define SOUND_PCM_WRITE_CHANNELS SNDCTL_DSP_CHANNELS +#define SOUND_PCM_WRITE_FILTER _SIOWR('P', 7, int) +#define SNDCTL_DSP_POST _SIO ('P', 8) +#define SNDCTL_DSP_SUBDIVIDE _SIOWR('P', 9, int) +#define SNDCTL_DSP_SETFRAGMENT _SIOWR('P',10, int) + +/* Audio data formats (Note! U8=8 and S16_LE=16 for compatibility) */ +#define SNDCTL_DSP_GETFMTS _SIOR ('P',11, int) /* Returns a mask */ +#define SNDCTL_DSP_SETFMT _SIOWR('P',5, int) /* Selects ONE fmt*/ +# define AFMT_QUERY 0x00000000 /* Return current fmt */ +# define AFMT_MU_LAW 0x00000001 +# define AFMT_A_LAW 0x00000002 +# define AFMT_IMA_ADPCM 0x00000004 +# define AFMT_U8 0x00000008 +# define AFMT_S16_LE 0x00000010 /* Little endian signed 16*/ +# define AFMT_S16_BE 0x00000020 /* Big endian signed 16 */ +# define AFMT_S8 0x00000040 +# define AFMT_U16_LE 0x00000080 /* Little endian U16 */ +# define AFMT_U16_BE 0x00000100 /* Big endian U16 */ +# define AFMT_MPEG 0x00000200 /* MPEG (2) audio */ +# define AFMT_AC3 0x00000400 /* Dolby Digital AC3 */ + +/* + * Buffer status queries. + */ +typedef struct audio_buf_info { + int fragments; /* # of available fragments (partially usend ones not counted) */ + int fragstotal; /* Total # of fragments allocated */ + int fragsize; /* Size of a fragment in bytes */ + + int bytes; /* Available space in bytes (includes partially used fragments) */ + /* Note! 'bytes' could be more than fragments*fragsize */ + } audio_buf_info; + +#define SNDCTL_DSP_GETOSPACE _SIOR ('P',12, audio_buf_info) +#define SNDCTL_DSP_GETISPACE _SIOR ('P',13, audio_buf_info) +#define SNDCTL_DSP_NONBLOCK _SIO ('P',14) +#define SNDCTL_DSP_GETCAPS _SIOR ('P',15, int) +# define DSP_CAP_REVISION 0x000000ff /* Bits for revision level (0 to 255) */ +# define DSP_CAP_DUPLEX 0x00000100 /* Full duplex record/playback */ +# define DSP_CAP_REALTIME 0x00000200 /* Real time capability */ +# define DSP_CAP_BATCH 0x00000400 /* Device has some kind of */ + /* internal buffers which may */ + /* cause some delays and */ + /* decrease precision of timing */ +# define DSP_CAP_COPROC 0x00000800 /* Has a coprocessor */ + /* Sometimes it's a DSP */ + /* but usually not */ +# define DSP_CAP_TRIGGER 0x00001000 /* Supports SETTRIGGER */ +# define DSP_CAP_MMAP 0x00002000 /* Supports mmap() */ +# define DSP_CAP_MULTI 0x00004000 /* support multiple open */ +# define DSP_CAP_BIND 0x00008000 /* channel binding to front/rear/cneter/lfe */ + + +#define SNDCTL_DSP_GETTRIGGER _SIOR ('P',16, int) +#define SNDCTL_DSP_SETTRIGGER _SIOW ('P',16, int) +# define PCM_ENABLE_INPUT 0x00000001 +# define PCM_ENABLE_OUTPUT 0x00000002 + +typedef struct count_info { + int bytes; /* Total # of bytes processed */ + int blocks; /* # of fragment transitions since last time */ + int ptr; /* Current DMA pointer value */ + } count_info; + +#define SNDCTL_DSP_GETIPTR _SIOR ('P',17, count_info) +#define SNDCTL_DSP_GETOPTR _SIOR ('P',18, count_info) + +typedef struct buffmem_desc { + unsigned *buffer; + int size; + } buffmem_desc; +#define SNDCTL_DSP_MAPINBUF _SIOR ('P', 19, buffmem_desc) +#define SNDCTL_DSP_MAPOUTBUF _SIOR ('P', 20, buffmem_desc) +#define SNDCTL_DSP_SETSYNCRO _SIO ('P', 21) +#define SNDCTL_DSP_SETDUPLEX _SIO ('P', 22) +#define SNDCTL_DSP_GETODELAY _SIOR ('P', 23, int) + +#define SNDCTL_DSP_GETCHANNELMASK _SIOWR('P', 64, int) +#define SNDCTL_DSP_BIND_CHANNEL _SIOWR('P', 65, int) +# define DSP_BIND_QUERY 0x00000000 +# define DSP_BIND_FRONT 0x00000001 +# define DSP_BIND_SURR 0x00000002 +# define DSP_BIND_CENTER_LFE 0x00000004 +# define DSP_BIND_HANDSET 0x00000008 +# define DSP_BIND_MIC 0x00000010 +# define DSP_BIND_MODEM1 0x00000020 +# define DSP_BIND_MODEM2 0x00000040 +# define DSP_BIND_I2S 0x00000080 +# define DSP_BIND_SPDIF 0x00000100 + +#define SNDCTL_DSP_SETSPDIF _SIOW ('P', 66, int) +#define SNDCTL_DSP_GETSPDIF _SIOR ('P', 67, int) +# define SPDIF_PRO 0x0001 +# define SPDIF_N_AUD 0x0002 +# define SPDIF_COPY 0x0004 +# define SPDIF_PRE 0x0008 +# define SPDIF_CC 0x07f0 +# define SPDIF_L 0x0800 +# define SPDIF_DRS 0x4000 +# define SPDIF_V 0x8000 + +/* + * Application's profile defines the way how playback underrun situations should be handled. + * + * APF_NORMAL (the default) and APF_NETWORK make the driver to cleanup the + * playback buffer whenever an underrun occurs. This consumes some time + * prevents looping the existing buffer. + * APF_CPUINTENS is intended to be set by CPU intensive applications which + * are likely to run out of time occasionally. In this mode the buffer cleanup is + * disabled which saves CPU time but also let's the previous buffer content to + * be played during the "pause" after the underrun. + */ +#define SNDCTL_DSP_PROFILE _SIOW ('P', 23, int) +#define APF_NORMAL 0 /* Normal applications */ +#define APF_NETWORK 1 /* Underruns probably caused by an "external" delay */ +#define APF_CPUINTENS 2 /* Underruns probably caused by "overheating" the CPU */ + +#define SOUND_PCM_READ_RATE _SIOR ('P', 2, int) +#define SOUND_PCM_READ_CHANNELS _SIOR ('P', 6, int) +#define SOUND_PCM_READ_BITS _SIOR ('P', 5, int) +#define SOUND_PCM_READ_FILTER _SIOR ('P', 7, int) + +/* Some alias names */ +#define SOUND_PCM_WRITE_BITS SNDCTL_DSP_SETFMT +#define SOUND_PCM_WRITE_RATE SNDCTL_DSP_SPEED +#define SOUND_PCM_POST SNDCTL_DSP_POST +#define SOUND_PCM_RESET SNDCTL_DSP_RESET +#define SOUND_PCM_SYNC SNDCTL_DSP_SYNC +#define SOUND_PCM_SUBDIVIDE SNDCTL_DSP_SUBDIVIDE +#define SOUND_PCM_SETFRAGMENT SNDCTL_DSP_SETFRAGMENT +#define SOUND_PCM_GETFMTS SNDCTL_DSP_GETFMTS +#define SOUND_PCM_SETFMT SNDCTL_DSP_SETFMT +#define SOUND_PCM_GETOSPACE SNDCTL_DSP_GETOSPACE +#define SOUND_PCM_GETISPACE SNDCTL_DSP_GETISPACE +#define SOUND_PCM_NONBLOCK SNDCTL_DSP_NONBLOCK +#define SOUND_PCM_GETCAPS SNDCTL_DSP_GETCAPS +#define SOUND_PCM_GETTRIGGER SNDCTL_DSP_GETTRIGGER +#define SOUND_PCM_SETTRIGGER SNDCTL_DSP_SETTRIGGER +#define SOUND_PCM_SETSYNCRO SNDCTL_DSP_SETSYNCRO +#define SOUND_PCM_GETIPTR SNDCTL_DSP_GETIPTR +#define SOUND_PCM_GETOPTR SNDCTL_DSP_GETOPTR +#define SOUND_PCM_MAPINBUF SNDCTL_DSP_MAPINBUF +#define SOUND_PCM_MAPOUTBUF SNDCTL_DSP_MAPOUTBUF + +/* + * ioctl calls to be used in communication with coprocessors and + * DSP chips. + */ + +typedef struct copr_buffer { + int command; /* Set to 0 if not used */ + int flags; +#define CPF_NONE 0x0000 +#define CPF_FIRST 0x0001 /* First block */ +#define CPF_LAST 0x0002 /* Last block */ + int len; + int offs; /* If required by the device (0 if not used) */ + + unsigned char data[4000]; /* NOTE! 4000 is not 4k */ + } copr_buffer; + +typedef struct copr_debug_buf { + int command; /* Used internally. Set to 0 */ + int parm1; + int parm2; + int flags; + int len; /* Length of data in bytes */ + } copr_debug_buf; + +typedef struct copr_msg { + int len; + unsigned char data[4000]; + } copr_msg; + +#define SNDCTL_COPR_RESET _SIO ('C', 0) +#define SNDCTL_COPR_LOAD _SIOWR('C', 1, copr_buffer) +#define SNDCTL_COPR_RDATA _SIOWR('C', 2, copr_debug_buf) +#define SNDCTL_COPR_RCODE _SIOWR('C', 3, copr_debug_buf) +#define SNDCTL_COPR_WDATA _SIOW ('C', 4, copr_debug_buf) +#define SNDCTL_COPR_WCODE _SIOW ('C', 5, copr_debug_buf) +#define SNDCTL_COPR_RUN _SIOWR('C', 6, copr_debug_buf) +#define SNDCTL_COPR_HALT _SIOWR('C', 7, copr_debug_buf) +#define SNDCTL_COPR_SENDMSG _SIOWR('C', 8, copr_msg) +#define SNDCTL_COPR_RCVMSG _SIOR ('C', 9, copr_msg) + +/********************************************* + * IOCTL commands for /dev/mixer + */ + +/* + * Mixer devices + * + * There can be up to 20 different analog mixer channels. The + * SOUND_MIXER_NRDEVICES gives the currently supported maximum. + * The SOUND_MIXER_READ_DEVMASK returns a bitmask which tells + * the devices supported by the particular mixer. + */ + +#define SOUND_MIXER_NRDEVICES 25 +#define SOUND_MIXER_VOLUME 0 +#define SOUND_MIXER_BASS 1 +#define SOUND_MIXER_TREBLE 2 +#define SOUND_MIXER_SYNTH 3 +#define SOUND_MIXER_PCM 4 +#define SOUND_MIXER_SPEAKER 5 +#define SOUND_MIXER_LINE 6 +#define SOUND_MIXER_MIC 7 +#define SOUND_MIXER_CD 8 +#define SOUND_MIXER_IMIX 9 /* Recording monitor */ +#define SOUND_MIXER_ALTPCM 10 +#define SOUND_MIXER_RECLEV 11 /* Recording level */ +#define SOUND_MIXER_IGAIN 12 /* Input gain */ +#define SOUND_MIXER_OGAIN 13 /* Output gain */ +/* + * The AD1848 codec and compatibles have three line level inputs + * (line, aux1 and aux2). Since each card manufacturer have assigned + * different meanings to these inputs, it's inpractical to assign + * specific meanings (line, cd, synth etc.) to them. + */ +#define SOUND_MIXER_LINE1 14 /* Input source 1 (aux1) */ +#define SOUND_MIXER_LINE2 15 /* Input source 2 (aux2) */ +#define SOUND_MIXER_LINE3 16 /* Input source 3 (line) */ +#define SOUND_MIXER_DIGITAL1 17 /* Digital (input) 1 */ +#define SOUND_MIXER_DIGITAL2 18 /* Digital (input) 2 */ +#define SOUND_MIXER_DIGITAL3 19 /* Digital (input) 3 */ +#define SOUND_MIXER_PHONEIN 20 /* Phone input */ +#define SOUND_MIXER_PHONEOUT 21 /* Phone output */ +#define SOUND_MIXER_VIDEO 22 /* Video/TV (audio) in */ +#define SOUND_MIXER_RADIO 23 /* Radio in */ +#define SOUND_MIXER_MONITOR 24 /* Monitor (usually mic) volume */ + +/* Some on/off settings (SOUND_SPECIAL_MIN - SOUND_SPECIAL_MAX) */ +/* Not counted to SOUND_MIXER_NRDEVICES, but use the same number space */ +#define SOUND_ONOFF_MIN 28 +#define SOUND_ONOFF_MAX 30 + +/* Note! Number 31 cannot be used since the sign bit is reserved */ +#define SOUND_MIXER_NONE 31 + +/* + * The following unsupported macros are no longer functional. + * Use SOUND_MIXER_PRIVATE# macros in future. + */ +#define SOUND_MIXER_ENHANCE SOUND_MIXER_NONE +#define SOUND_MIXER_MUTE SOUND_MIXER_NONE +#define SOUND_MIXER_LOUD SOUND_MIXER_NONE + + +#define SOUND_DEVICE_LABELS {"Vol ", "Bass ", "Trebl", "Synth", "Pcm ", "Spkr ", "Line ", \ + "Mic ", "CD ", "Mix ", "Pcm2 ", "Rec ", "IGain", "OGain", \ + "Line1", "Line2", "Line3", "Digital1", "Digital2", "Digital3", \ + "PhoneIn", "PhoneOut", "Video", "Radio", "Monitor"} + +#define SOUND_DEVICE_NAMES {"vol", "bass", "treble", "synth", "pcm", "speaker", "line", \ + "mic", "cd", "mix", "pcm2", "rec", "igain", "ogain", \ + "line1", "line2", "line3", "dig1", "dig2", "dig3", \ + "phin", "phout", "video", "radio", "monitor"} + +/* Device bitmask identifiers */ + +#define SOUND_MIXER_RECSRC 0xff /* Arg contains a bit for each recording source */ +#define SOUND_MIXER_DEVMASK 0xfe /* Arg contains a bit for each supported device */ +#define SOUND_MIXER_RECMASK 0xfd /* Arg contains a bit for each supported recording source */ +#define SOUND_MIXER_CAPS 0xfc +# define SOUND_CAP_EXCL_INPUT 0x00000001 /* Only one recording source at a time */ +#define SOUND_MIXER_STEREODEVS 0xfb /* Mixer channels supporting stereo */ +#define SOUND_MIXER_OUTSRC 0xfa /* Arg contains a bit for each input source to output */ +#define SOUND_MIXER_OUTMASK 0xf9 /* Arg contains a bit for each supported input source to output */ + +/* Device mask bits */ + +#define SOUND_MASK_VOLUME (1 << SOUND_MIXER_VOLUME) +#define SOUND_MASK_BASS (1 << SOUND_MIXER_BASS) +#define SOUND_MASK_TREBLE (1 << SOUND_MIXER_TREBLE) +#define SOUND_MASK_SYNTH (1 << SOUND_MIXER_SYNTH) +#define SOUND_MASK_PCM (1 << SOUND_MIXER_PCM) +#define SOUND_MASK_SPEAKER (1 << SOUND_MIXER_SPEAKER) +#define SOUND_MASK_LINE (1 << SOUND_MIXER_LINE) +#define SOUND_MASK_MIC (1 << SOUND_MIXER_MIC) +#define SOUND_MASK_CD (1 << SOUND_MIXER_CD) +#define SOUND_MASK_IMIX (1 << SOUND_MIXER_IMIX) +#define SOUND_MASK_ALTPCM (1 << SOUND_MIXER_ALTPCM) +#define SOUND_MASK_RECLEV (1 << SOUND_MIXER_RECLEV) +#define SOUND_MASK_IGAIN (1 << SOUND_MIXER_IGAIN) +#define SOUND_MASK_OGAIN (1 << SOUND_MIXER_OGAIN) +#define SOUND_MASK_LINE1 (1 << SOUND_MIXER_LINE1) +#define SOUND_MASK_LINE2 (1 << SOUND_MIXER_LINE2) +#define SOUND_MASK_LINE3 (1 << SOUND_MIXER_LINE3) +#define SOUND_MASK_DIGITAL1 (1 << SOUND_MIXER_DIGITAL1) +#define SOUND_MASK_DIGITAL2 (1 << SOUND_MIXER_DIGITAL2) +#define SOUND_MASK_DIGITAL3 (1 << SOUND_MIXER_DIGITAL3) +#define SOUND_MASK_PHONEIN (1 << SOUND_MIXER_PHONEIN) +#define SOUND_MASK_PHONEOUT (1 << SOUND_MIXER_PHONEOUT) +#define SOUND_MASK_RADIO (1 << SOUND_MIXER_RADIO) +#define SOUND_MASK_VIDEO (1 << SOUND_MIXER_VIDEO) +#define SOUND_MASK_MONITOR (1 << SOUND_MIXER_MONITOR) + +/* Obsolete macros */ +#define SOUND_MASK_MUTE (1 << SOUND_MIXER_MUTE) +#define SOUND_MASK_ENHANCE (1 << SOUND_MIXER_ENHANCE) +#define SOUND_MASK_LOUD (1 << SOUND_MIXER_LOUD) + +#define MIXER_READ(dev) _SIOR('M', dev, int) +#define SOUND_MIXER_READ_VOLUME MIXER_READ(SOUND_MIXER_VOLUME) +#define SOUND_MIXER_READ_BASS MIXER_READ(SOUND_MIXER_BASS) +#define SOUND_MIXER_READ_TREBLE MIXER_READ(SOUND_MIXER_TREBLE) +#define SOUND_MIXER_READ_SYNTH MIXER_READ(SOUND_MIXER_SYNTH) +#define SOUND_MIXER_READ_PCM MIXER_READ(SOUND_MIXER_PCM) +#define SOUND_MIXER_READ_SPEAKER MIXER_READ(SOUND_MIXER_SPEAKER) +#define SOUND_MIXER_READ_LINE MIXER_READ(SOUND_MIXER_LINE) +#define SOUND_MIXER_READ_MIC MIXER_READ(SOUND_MIXER_MIC) +#define SOUND_MIXER_READ_CD MIXER_READ(SOUND_MIXER_CD) +#define SOUND_MIXER_READ_IMIX MIXER_READ(SOUND_MIXER_IMIX) +#define SOUND_MIXER_READ_ALTPCM MIXER_READ(SOUND_MIXER_ALTPCM) +#define SOUND_MIXER_READ_RECLEV MIXER_READ(SOUND_MIXER_RECLEV) +#define SOUND_MIXER_READ_IGAIN MIXER_READ(SOUND_MIXER_IGAIN) +#define SOUND_MIXER_READ_OGAIN MIXER_READ(SOUND_MIXER_OGAIN) +#define SOUND_MIXER_READ_LINE1 MIXER_READ(SOUND_MIXER_LINE1) +#define SOUND_MIXER_READ_LINE2 MIXER_READ(SOUND_MIXER_LINE2) +#define SOUND_MIXER_READ_LINE3 MIXER_READ(SOUND_MIXER_LINE3) + +/* Obsolete macros */ +#define SOUND_MIXER_READ_MUTE MIXER_READ(SOUND_MIXER_MUTE) +#define SOUND_MIXER_READ_ENHANCE MIXER_READ(SOUND_MIXER_ENHANCE) +#define SOUND_MIXER_READ_LOUD MIXER_READ(SOUND_MIXER_LOUD) + +#define SOUND_MIXER_READ_RECSRC MIXER_READ(SOUND_MIXER_RECSRC) +#define SOUND_MIXER_READ_DEVMASK MIXER_READ(SOUND_MIXER_DEVMASK) +#define SOUND_MIXER_READ_RECMASK MIXER_READ(SOUND_MIXER_RECMASK) +#define SOUND_MIXER_READ_STEREODEVS MIXER_READ(SOUND_MIXER_STEREODEVS) +#define SOUND_MIXER_READ_CAPS MIXER_READ(SOUND_MIXER_CAPS) + +#define MIXER_WRITE(dev) _SIOWR('M', dev, int) +#define SOUND_MIXER_WRITE_VOLUME MIXER_WRITE(SOUND_MIXER_VOLUME) +#define SOUND_MIXER_WRITE_BASS MIXER_WRITE(SOUND_MIXER_BASS) +#define SOUND_MIXER_WRITE_TREBLE MIXER_WRITE(SOUND_MIXER_TREBLE) +#define SOUND_MIXER_WRITE_SYNTH MIXER_WRITE(SOUND_MIXER_SYNTH) +#define SOUND_MIXER_WRITE_PCM MIXER_WRITE(SOUND_MIXER_PCM) +#define SOUND_MIXER_WRITE_SPEAKER MIXER_WRITE(SOUND_MIXER_SPEAKER) +#define SOUND_MIXER_WRITE_LINE MIXER_WRITE(SOUND_MIXER_LINE) +#define SOUND_MIXER_WRITE_MIC MIXER_WRITE(SOUND_MIXER_MIC) +#define SOUND_MIXER_WRITE_CD MIXER_WRITE(SOUND_MIXER_CD) +#define SOUND_MIXER_WRITE_IMIX MIXER_WRITE(SOUND_MIXER_IMIX) +#define SOUND_MIXER_WRITE_ALTPCM MIXER_WRITE(SOUND_MIXER_ALTPCM) +#define SOUND_MIXER_WRITE_RECLEV MIXER_WRITE(SOUND_MIXER_RECLEV) +#define SOUND_MIXER_WRITE_IGAIN MIXER_WRITE(SOUND_MIXER_IGAIN) +#define SOUND_MIXER_WRITE_OGAIN MIXER_WRITE(SOUND_MIXER_OGAIN) +#define SOUND_MIXER_WRITE_LINE1 MIXER_WRITE(SOUND_MIXER_LINE1) +#define SOUND_MIXER_WRITE_LINE2 MIXER_WRITE(SOUND_MIXER_LINE2) +#define SOUND_MIXER_WRITE_LINE3 MIXER_WRITE(SOUND_MIXER_LINE3) + +/* Obsolete macros */ +#define SOUND_MIXER_WRITE_MUTE MIXER_WRITE(SOUND_MIXER_MUTE) +#define SOUND_MIXER_WRITE_ENHANCE MIXER_WRITE(SOUND_MIXER_ENHANCE) +#define SOUND_MIXER_WRITE_LOUD MIXER_WRITE(SOUND_MIXER_LOUD) + +#define SOUND_MIXER_WRITE_RECSRC MIXER_WRITE(SOUND_MIXER_RECSRC) + +typedef struct mixer_info +{ + char id[16]; + char name[32]; + int modify_counter; + int fillers[10]; +} mixer_info; + +typedef struct _old_mixer_info /* Obsolete */ +{ + char id[16]; + char name[32]; +} _old_mixer_info; + +#define SOUND_MIXER_INFO _SIOR ('M', 101, mixer_info) +#define SOUND_OLD_MIXER_INFO _SIOR ('M', 101, _old_mixer_info) + +/* + * A mechanism for accessing "proprietary" mixer features. This method + * permits passing 128 bytes of arbitrary data between a mixer application + * and the mixer driver. Interpretation of the record is defined by + * the particular mixer driver. + */ +typedef unsigned char mixer_record[128]; + +#define SOUND_MIXER_ACCESS _SIOWR('M', 102, mixer_record) + +/* + * Two ioctls for special souncard function + */ +#define SOUND_MIXER_AGC _SIOWR('M', 103, int) +#define SOUND_MIXER_3DSE _SIOWR('M', 104, int) + +/* + * The SOUND_MIXER_PRIVATE# commands can be redefined by low level drivers. + * These features can be used when accessing device specific features. + */ +#define SOUND_MIXER_PRIVATE1 _SIOWR('M', 111, int) +#define SOUND_MIXER_PRIVATE2 _SIOWR('M', 112, int) +#define SOUND_MIXER_PRIVATE3 _SIOWR('M', 113, int) +#define SOUND_MIXER_PRIVATE4 _SIOWR('M', 114, int) +#define SOUND_MIXER_PRIVATE5 _SIOWR('M', 115, int) + +/* + * SOUND_MIXER_GETLEVELS and SOUND_MIXER_SETLEVELS calls can be used + * for querying current mixer settings from the driver and for loading + * default volume settings _prior_ activating the mixer (loading + * doesn't affect current state of the mixer hardware). These calls + * are for internal use only. + */ + +typedef struct mixer_vol_table { + int num; /* Index to volume table */ + char name[32]; + int levels[32]; +} mixer_vol_table; + +#define SOUND_MIXER_GETLEVELS _SIOWR('M', 116, mixer_vol_table) +#define SOUND_MIXER_SETLEVELS _SIOWR('M', 117, mixer_vol_table) + +/* + * An ioctl for identifying the driver version. It will return value + * of the SOUND_VERSION macro used when compiling the driver. + * This call was introduced in OSS version 3.6 and it will not work + * with earlier versions (returns EINVAL). + */ +#define OSS_GETVERSION _SIOR ('M', 118, int) + +/* + * Level 2 event types for /dev/sequencer + */ + +/* + * The 4 most significant bits of byte 0 specify the class of + * the event: + * + * 0x8X = system level events, + * 0x9X = device/port specific events, event[1] = device/port, + * The last 4 bits give the subtype: + * 0x02 = Channel event (event[3] = chn). + * 0x01 = note event (event[4] = note). + * (0x01 is not used alone but always with bit 0x02). + * event[2] = MIDI message code (0x80=note off etc.) + * + */ + +#define EV_SEQ_LOCAL 0x80 +#define EV_TIMING 0x81 +#define EV_CHN_COMMON 0x92 +#define EV_CHN_VOICE 0x93 +#define EV_SYSEX 0x94 +/* + * Event types 200 to 220 are reserved for application use. + * These numbers will not be used by the driver. + */ + +/* + * Events for event type EV_CHN_VOICE + */ + +#define MIDI_NOTEOFF 0x80 +#define MIDI_NOTEON 0x90 +#define MIDI_KEY_PRESSURE 0xA0 + +/* + * Events for event type EV_CHN_COMMON + */ + +#define MIDI_CTL_CHANGE 0xB0 +#define MIDI_PGM_CHANGE 0xC0 +#define MIDI_CHN_PRESSURE 0xD0 +#define MIDI_PITCH_BEND 0xE0 + +#define MIDI_SYSTEM_PREFIX 0xF0 + +/* + * Timer event types + */ +#define TMR_WAIT_REL 1 /* Time relative to the prev time */ +#define TMR_WAIT_ABS 2 /* Absolute time since TMR_START */ +#define TMR_STOP 3 +#define TMR_START 4 +#define TMR_CONTINUE 5 +#define TMR_TEMPO 6 +#define TMR_ECHO 8 +#define TMR_CLOCK 9 /* MIDI clock */ +#define TMR_SPP 10 /* Song position pointer */ +#define TMR_TIMESIG 11 /* Time signature */ + +/* + * Local event types + */ +#define LOCL_STARTAUDIO 1 + +#if (!defined(__KERNEL__) && !defined(KERNEL) && !defined(INKERNEL) && !defined(_KERNEL)) || defined(USE_SEQ_MACROS) +/* + * Some convenience macros to simplify programming of the + * /dev/sequencer interface + * + * These macros define the API which should be used when possible. + */ +#define SEQ_DECLAREBUF() SEQ_USE_EXTBUF() + +void seqbuf_dump(void); /* This function must be provided by programs */ + +extern int OSS_init(int seqfd, int buflen); +extern void OSS_seqbuf_dump(int fd, unsigned char *buf, int buflen); +extern void OSS_seq_advbuf(int len, int fd, unsigned char *buf, int buflen); +extern void OSS_seq_needbuf(int len, int fd, unsigned char *buf, int buflen); +extern void OSS_patch_caching(int dev, int chn, int patch, + int fd, unsigned char *buf, int buflen); +extern void OSS_drum_caching(int dev, int chn, int patch, + int fd, unsigned char *buf, int buflen); +extern void OSS_write_patch(int fd, unsigned char *buf, int len); +extern int OSS_write_patch2(int fd, unsigned char *buf, int len); + +#define SEQ_PM_DEFINES int __foo_bar___ +#ifdef OSSLIB +# define SEQ_USE_EXTBUF() \ + extern unsigned char *_seqbuf; \ + extern int _seqbuflen;extern int _seqbufptr +# define SEQ_DEFINEBUF(len) SEQ_USE_EXTBUF();static int _requested_seqbuflen=len +# define _SEQ_ADVBUF(len) OSS_seq_advbuf(len, seqfd, _seqbuf, _seqbuflen) +# define _SEQ_NEEDBUF(len) OSS_seq_needbuf(len, seqfd, _seqbuf, _seqbuflen) +# define SEQ_DUMPBUF() OSS_seqbuf_dump(seqfd, _seqbuf, _seqbuflen) + +# define SEQ_LOAD_GMINSTR(dev, instr) \ + OSS_patch_caching(dev, -1, instr, seqfd, _seqbuf, _seqbuflen) +# define SEQ_LOAD_GMDRUM(dev, drum) \ + OSS_drum_caching(dev, -1, drum, seqfd, _seqbuf, _seqbuflen) +#else /* !OSSLIB */ + +# define SEQ_LOAD_GMINSTR(dev, instr) +# define SEQ_LOAD_GMDRUM(dev, drum) + +# define SEQ_USE_EXTBUF() \ + extern unsigned char _seqbuf[]; \ + extern int _seqbuflen;extern int _seqbufptr + +#ifndef USE_SIMPLE_MACROS +/* Sample seqbuf_dump() implementation: + * + * SEQ_DEFINEBUF (2048); -- Defines a buffer for 2048 bytes + * + * int seqfd; -- The file descriptor for /dev/sequencer. + * + * void + * seqbuf_dump () + * { + * if (_seqbufptr) + * if (write (seqfd, _seqbuf, _seqbufptr) == -1) + * { + * perror ("write /dev/sequencer"); + * exit (-1); + * } + * _seqbufptr = 0; + * } + */ + +#define SEQ_DEFINEBUF(len) unsigned char _seqbuf[len]; int _seqbuflen = len;int _seqbufptr = 0 +#define _SEQ_NEEDBUF(len) if ((_seqbufptr+(len)) > _seqbuflen) seqbuf_dump() +#define _SEQ_ADVBUF(len) _seqbufptr += len +#define SEQ_DUMPBUF seqbuf_dump +#else +/* + * This variation of the sequencer macros is used just to format one event + * using fixed buffer. + * + * The program using the macro library must define the following macros before + * using this library. + * + * #define _seqbuf name of the buffer (unsigned char[]) + * #define _SEQ_ADVBUF(len) If the applic needs to know the exact + * size of the event, this macro can be used. + * Otherwise this must be defined as empty. + * #define _seqbufptr Define the name of index variable or 0 if + * not required. + */ +#define _SEQ_NEEDBUF(len) /* empty */ +#endif +#endif /* !OSSLIB */ + +#define SEQ_VOLUME_MODE(dev, mode) {_SEQ_NEEDBUF(8);\ + _seqbuf[_seqbufptr] = SEQ_EXTENDED;\ + _seqbuf[_seqbufptr+1] = SEQ_VOLMODE;\ + _seqbuf[_seqbufptr+2] = (dev);\ + _seqbuf[_seqbufptr+3] = (mode);\ + _seqbuf[_seqbufptr+4] = 0;\ + _seqbuf[_seqbufptr+5] = 0;\ + _seqbuf[_seqbufptr+6] = 0;\ + _seqbuf[_seqbufptr+7] = 0;\ + _SEQ_ADVBUF(8);} + +/* + * Midi voice messages + */ + +#define _CHN_VOICE(dev, event, chn, note, parm) \ + {_SEQ_NEEDBUF(8);\ + _seqbuf[_seqbufptr] = EV_CHN_VOICE;\ + _seqbuf[_seqbufptr+1] = (dev);\ + _seqbuf[_seqbufptr+2] = (event);\ + _seqbuf[_seqbufptr+3] = (chn);\ + _seqbuf[_seqbufptr+4] = (note);\ + _seqbuf[_seqbufptr+5] = (parm);\ + _seqbuf[_seqbufptr+6] = (0);\ + _seqbuf[_seqbufptr+7] = 0;\ + _SEQ_ADVBUF(8);} + +#define SEQ_START_NOTE(dev, chn, note, vol) \ + _CHN_VOICE(dev, MIDI_NOTEON, chn, note, vol) + +#define SEQ_STOP_NOTE(dev, chn, note, vol) \ + _CHN_VOICE(dev, MIDI_NOTEOFF, chn, note, vol) + +#define SEQ_KEY_PRESSURE(dev, chn, note, pressure) \ + _CHN_VOICE(dev, MIDI_KEY_PRESSURE, chn, note, pressure) + +/* + * Midi channel messages + */ + +#define _CHN_COMMON(dev, event, chn, p1, p2, w14) \ + {_SEQ_NEEDBUF(8);\ + _seqbuf[_seqbufptr] = EV_CHN_COMMON;\ + _seqbuf[_seqbufptr+1] = (dev);\ + _seqbuf[_seqbufptr+2] = (event);\ + _seqbuf[_seqbufptr+3] = (chn);\ + _seqbuf[_seqbufptr+4] = (p1);\ + _seqbuf[_seqbufptr+5] = (p2);\ + *(short *)&_seqbuf[_seqbufptr+6] = (w14);\ + _SEQ_ADVBUF(8);} +/* + * SEQ_SYSEX permits sending of sysex messages. (It may look that it permits + * sending any MIDI bytes but it's absolutely not possible. Trying to do + * so _will_ cause problems with MPU401 intelligent mode). + * + * Sysex messages are sent in blocks of 1 to 6 bytes. Longer messages must be + * sent by calling SEQ_SYSEX() several times (there must be no other events + * between them). First sysex fragment must have 0xf0 in the first byte + * and the last byte (buf[len-1] of the last fragment must be 0xf7. No byte + * between these sysex start and end markers cannot be larger than 0x7f. Also + * lengths of each fragments (except the last one) must be 6. + * + * Breaking the above rules may work with some MIDI ports but is likely to + * cause fatal problems with some other devices (such as MPU401). + */ +#define SEQ_SYSEX(dev, buf, len) \ + {int ii, ll=(len); \ + unsigned char *bufp=buf;\ + if (ll>6)ll=6;\ + _SEQ_NEEDBUF(8);\ + _seqbuf[_seqbufptr] = EV_SYSEX;\ + _seqbuf[_seqbufptr+1] = (dev);\ + for(ii=0;ii>8)&0xff);\ + _seqbuf[_seqbufptr+7] = 0;\ + _SEQ_ADVBUF(8);} +/* + * The following 5 macros are incorrectly implemented and obsolete. + * Use SEQ_BENDER and SEQ_CONTROL (with proper controller) instead. + */ +#define SEQ_PITCHBEND(dev, voice, value) SEQ_V2_X_CONTROL(dev, voice, CTRL_PITCH_BENDER, value) +#define SEQ_BENDER_RANGE(dev, voice, value) SEQ_V2_X_CONTROL(dev, voice, CTRL_PITCH_BENDER_RANGE, value) +#define SEQ_EXPRESSION(dev, voice, value) SEQ_CONTROL(dev, voice, CTL_EXPRESSION, value*128) +#define SEQ_MAIN_VOLUME(dev, voice, value) SEQ_CONTROL(dev, voice, CTL_MAIN_VOLUME, (value*16383)/100) +#define SEQ_PANNING(dev, voice, pos) SEQ_CONTROL(dev, voice, CTL_PAN, (pos+128) / 2) + +/* + * Timing and syncronization macros + */ + +#define _TIMER_EVENT(ev, parm) {_SEQ_NEEDBUF(8);\ + _seqbuf[_seqbufptr+0] = EV_TIMING; \ + _seqbuf[_seqbufptr+1] = (ev); \ + _seqbuf[_seqbufptr+2] = 0;\ + _seqbuf[_seqbufptr+3] = 0;\ + *(unsigned int *)&_seqbuf[_seqbufptr+4] = (parm); \ + _SEQ_ADVBUF(8);} + +#define SEQ_START_TIMER() _TIMER_EVENT(TMR_START, 0) +#define SEQ_STOP_TIMER() _TIMER_EVENT(TMR_STOP, 0) +#define SEQ_CONTINUE_TIMER() _TIMER_EVENT(TMR_CONTINUE, 0) +#define SEQ_WAIT_TIME(ticks) _TIMER_EVENT(TMR_WAIT_ABS, ticks) +#define SEQ_DELTA_TIME(ticks) _TIMER_EVENT(TMR_WAIT_REL, ticks) +#define SEQ_ECHO_BACK(key) _TIMER_EVENT(TMR_ECHO, key) +#define SEQ_SET_TEMPO(value) _TIMER_EVENT(TMR_TEMPO, value) +#define SEQ_SONGPOS(pos) _TIMER_EVENT(TMR_SPP, pos) +#define SEQ_TIME_SIGNATURE(sig) _TIMER_EVENT(TMR_TIMESIG, sig) + +/* + * Local control events + */ + +#define _LOCAL_EVENT(ev, parm) {_SEQ_NEEDBUF(8);\ + _seqbuf[_seqbufptr+0] = EV_SEQ_LOCAL; \ + _seqbuf[_seqbufptr+1] = (ev); \ + _seqbuf[_seqbufptr+2] = 0;\ + _seqbuf[_seqbufptr+3] = 0;\ + *(unsigned int *)&_seqbuf[_seqbufptr+4] = (parm); \ + _SEQ_ADVBUF(8);} + +#define SEQ_PLAYAUDIO(devmask) _LOCAL_EVENT(LOCL_STARTAUDIO, devmask) +/* + * Events for the level 1 interface only + */ + +#define SEQ_MIDIOUT(device, byte) {_SEQ_NEEDBUF(4);\ + _seqbuf[_seqbufptr] = SEQ_MIDIPUTC;\ + _seqbuf[_seqbufptr+1] = (byte);\ + _seqbuf[_seqbufptr+2] = (device);\ + _seqbuf[_seqbufptr+3] = 0;\ + _SEQ_ADVBUF(4);} + +/* + * Patch loading. + */ +#ifdef OSSLIB +# define SEQ_WRPATCH(patchx, len) \ + OSS_write_patch(seqfd, (char*)(patchx), len) +# define SEQ_WRPATCH2(patchx, len) \ + OSS_write_patch2(seqfd, (char*)(patchx), len) +#else +# define SEQ_WRPATCH(patchx, len) \ + {if (_seqbufptr) SEQ_DUMPBUF();\ + if (write(seqfd, (char*)(patchx), len)==-1) \ + perror("Write patch: /dev/sequencer");} +# define SEQ_WRPATCH2(patchx, len) \ + (SEQ_DUMPBUF(), write(seqfd, (char*)(patchx), len)) +#endif + +#endif + +#endif diff --git a/mdk-stage1/dietlibc/include/sys/sparc-ioctl.h b/mdk-stage1/dietlibc/include/sys/sparc-ioctl.h new file mode 100644 index 000000000..07b502465 --- /dev/null +++ b/mdk-stage1/dietlibc/include/sys/sparc-ioctl.h @@ -0,0 +1,172 @@ +#define _IOC_NRBITS 8 +#define _IOC_TYPEBITS 8 +#define _IOC_SIZEBITS 8 +#define _IOC_RESVBITS 5 +#define _IOC_DIRBITS 3 + +#define _IOC_NRMASK ((1 << _IOC_NRBITS)-1) +#define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1) +#define _IOC_RESVMASK ((1 << _IOC_RESVBITS)-1) +#define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1) +#define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1) + +#define _IOC_NRSHIFT 0 +#define _IOC_TYPESHIFT (_IOC_NRSHIFT + _IOC_NRBITS) +#define _IOC_SIZESHIFT (_IOC_TYPESHIFT + _IOC_TYPEBITS) +#define _IOC_RESVSHIFT (_IOC_SIZESHIFT + _IOC_SIZEBITS) +#define _IOC_DIRSHIFT (_IOC_RESVSHIFT + _IOC_RESVBITS) + +#define _IOC_NONE 1U +#define _IOC_READ 2U +#define _IOC_WRITE 4U + +#define _IOC(dir,type,nr,size) \ + (((dir) << _IOC_DIRSHIFT) | \ + ((type) << _IOC_TYPESHIFT) | \ + ((nr) << _IOC_NRSHIFT) | \ + ((size) << _IOC_SIZESHIFT)) + +#define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0) +#define _IOR(type,nr,size) _IOC(_IOC_READ,(type),(nr),sizeof(size)) +#define _IOW(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),sizeof(size)) +#define _IOWR(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size)) + +#define _IOC_DIR(nr) (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK) +#define _IOC_TYPE(nr) (((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK) +#define _IOC_NR(nr) (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK) +#define _IOC_SIZE(nr) (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK) + +/* ...and for the PCMCIA... */ + +#define IOC_IN (_IOC_WRITE << _IOC_DIRSHIFT) +#define IOC_OUT (_IOC_READ << _IOC_DIRSHIFT) +#define IOC_INOUT ((_IOC_WRITE|_IOC_READ) << _IOC_DIRSHIFT) +#define IOCSIZE_MASK (_IOC_SIZEMASK << _IOC_SIZESHIFT) +#define IOCSIZE_SHIFT (_IOC_SIZESHIFT) + +/* Big T */ +#define TCGETA _IOR('T', 1, struct termio) +#define TCSETA _IOW('T', 2, struct termio) +#define TCSETAW _IOW('T', 3, struct termio) +#define TCSETAF _IOW('T', 4, struct termio) +#define TCSBRK _IO('T', 5) +#define TCXONC _IO('T', 6) +#define TCFLSH _IO('T', 7) +#define TCGETS _IOR('T', 8, struct termios) +#define TCSETS _IOW('T', 9, struct termios) +#define TCSETSW _IOW('T', 10, struct termios) +#define TCSETSF _IOW('T', 11, struct termios) + +/* Note that all the ioctls that are not available in Linux have a + * double underscore on the front to: a) avoid some programs to + * thing we support some ioctls under Linux (autoconfiguration stuff) + */ +/* Little t */ +#define TIOCGETD _IOR('t', 0, int) +#define TIOCSETD _IOW('t', 1, int) +#define __TIOCHPCL _IO('t', 2) /* SunOS Specific */ +#define __TIOCMODG _IOR('t', 3, int) /* SunOS Specific */ +#define __TIOCMODS _IOW('t', 4, int) /* SunOS Specific */ +#define __TIOCGETP _IOR('t', 8, struct sgttyb) /* SunOS Specific */ +#define __TIOCSETP _IOW('t', 9, struct sgttyb) /* SunOS Specific */ +#define __TIOCSETN _IOW('t', 10, struct sgttyb) /* SunOS Specific */ +#define TIOCEXCL _IO('t', 13) +#define TIOCNXCL _IO('t', 14) +#define __TIOCFLUSH _IOW('t', 16, int) /* SunOS Specific */ +#define __TIOCSETC _IOW('t', 17, struct tchars) /* SunOS Specific */ +#define __TIOCGETC _IOR('t', 18, struct tchars) /* SunOS Specific */ +#define __TIOCTCNTL _IOW('t', 32, int) /* SunOS Specific */ +#define __TIOCSIGNAL _IOW('t', 33, int) /* SunOS Specific */ +#define __TIOCSETX _IOW('t', 34, int) /* SunOS Specific */ +#define __TIOCGETX _IOR('t', 35, int) /* SunOS Specific */ +#define TIOCCONS _IO('t', 36) +#define __TIOCSSIZE _IOW('t', 37, struct sunos_ttysize) /* SunOS Specific */ +#define __TIOCGSIZE _IOR('t', 38, struct sunos_ttysize) /* SunOS Specific */ +#define TIOCGSOFTCAR _IOR('t', 100, int) +#define TIOCSSOFTCAR _IOW('t', 101, int) +#define __TIOCUCNTL _IOW('t', 102, int) /* SunOS Specific */ +#define TIOCSWINSZ _IOW('t', 103, struct winsize) +#define TIOCGWINSZ _IOR('t', 104, struct winsize) +#define __TIOCREMOTE _IOW('t', 105, int) /* SunOS Specific */ +#define TIOCMGET _IOR('t', 106, int) +#define TIOCMBIC _IOW('t', 107, int) +#define TIOCMBIS _IOW('t', 108, int) +#define TIOCMSET _IOW('t', 109, int) +#define __TIOCSTART _IO('t', 110) /* SunOS Specific */ +#define __TIOCSTOP _IO('t', 111) /* SunOS Specific */ +#define TIOCPKT _IOW('t', 112, int) +#define TIOCNOTTY _IO('t', 113) +#define TIOCSTI _IOW('t', 114, char) +#define TIOCOUTQ _IOR('t', 115, int) +#define __TIOCGLTC _IOR('t', 116, struct ltchars) /* SunOS Specific */ +#define __TIOCSLTC _IOW('t', 117, struct ltchars) /* SunOS Specific */ +/* 118 is the non-posix setpgrp tty ioctl */ +/* 119 is the non-posix getpgrp tty ioctl */ +#define __TIOCCDTR _IO('t', 120) /* SunOS Specific */ +#define __TIOCSDTR _IO('t', 121) /* SunOS Specific */ +#define TIOCCBRK _IO('t', 122) +#define TIOCSBRK _IO('t', 123) +#define __TIOCLGET _IOW('t', 124, int) /* SunOS Specific */ +#define __TIOCLSET _IOW('t', 125, int) /* SunOS Specific */ +#define __TIOCLBIC _IOW('t', 126, int) /* SunOS Specific */ +#define __TIOCLBIS _IOW('t', 127, int) /* SunOS Specific */ +#define __TIOCISPACE _IOR('t', 128, int) /* SunOS Specific */ +#define __TIOCISIZE _IOR('t', 129, int) /* SunOS Specific */ +#define TIOCSPGRP _IOW('t', 130, int) +#define TIOCGPGRP _IOR('t', 131, int) +#define TIOCSCTTY _IO('t', 132) +#define TIOCGSID _IOR('t', 133, int) +/* Get minor device of a pty master's FD -- Solaris equiv is ISPTM */ +#define TIOCGPTN _IOR('t', 134, unsigned int) /* Get Pty Number */ +#define TIOCSPTLCK _IOW('t', 135, int) /* Lock/unlock PTY */ + +/* Little f */ +#define FIOCLEX _IO('f', 1) +#define FIONCLEX _IO('f', 2) +#define FIOASYNC _IOW('f', 125, int) +#define FIONBIO _IOW('f', 126, int) +#define FIONREAD _IOR('f', 127, int) +#define TIOCINQ FIONREAD +#define FIOQSIZE _IOR('f', 128, loff_t) + +/* SCARY Rutgers local SunOS kernel hackery, perhaps I will support it + * someday. This is completely bogus, I know... + */ +#define __TCGETSTAT _IO('T', 200) /* Rutgers specific */ +#define __TCSETSTAT _IO('T', 201) /* Rutgers specific */ + +/* Linux specific, no SunOS equivalent. */ +#define TIOCLINUX 0x541C +#define TIOCGSERIAL 0x541E +#define TIOCSSERIAL 0x541F +#define TCSBRKP 0x5425 +#define TIOCTTYGSTRUCT 0x5426 +#define TIOCSERCONFIG 0x5453 +#define TIOCSERGWILD 0x5454 +#define TIOCSERSWILD 0x5455 +#define TIOCGLCKTRMIOS 0x5456 +#define TIOCSLCKTRMIOS 0x5457 +#define TIOCSERGSTRUCT 0x5458 /* For debugging only */ +#define TIOCSERGETLSR 0x5459 /* Get line status register */ +#define TIOCSERGETMULTI 0x545A /* Get multiport config */ +#define TIOCSERSETMULTI 0x545B /* Set multiport config */ +#define TIOCMIWAIT 0x545C /* Wait input */ +#define TIOCGICOUNT 0x545D /* Read serial port inline interrupt counts */ + +/* Used for packet mode */ +#define TIOCPKT_DATA 0 +#define TIOCPKT_FLUSHREAD 1 +#define TIOCPKT_FLUSHWRITE 2 +#define TIOCPKT_STOP 4 +#define TIOCPKT_START 8 +#define TIOCPKT_NOSTOP 16 +#define TIOCPKT_DOSTOP 32 + +/* Socket-level I/O control calls. */ +#define FIOSETOWN 0x8901 +#define SIOCSPGRP 0x8902 +#define FIOGETOWN 0x8903 +#define SIOCGPGRP 0x8904 +#define SIOCATMARK 0x8905 +#define SIOCGSTAMP 0x8906 /* Get stamp */ + diff --git a/mdk-stage1/dietlibc/include/sys/sysmacros.h b/mdk-stage1/dietlibc/include/sys/sysmacros.h new file mode 100644 index 000000000..8a8124131 --- /dev/null +++ b/mdk-stage1/dietlibc/include/sys/sysmacros.h @@ -0,0 +1,6 @@ +#ifndef _SYSMACROS_H +#define _SYSMACROS_H + +#include + +#endif diff --git a/mdk-stage1/dietlibc/include/sys/timeb.h b/mdk-stage1/dietlibc/include/sys/timeb.h new file mode 100644 index 000000000..ceed377e7 --- /dev/null +++ b/mdk-stage1/dietlibc/include/sys/timeb.h @@ -0,0 +1,13 @@ +#ifndef __SYS_TIMEB_H +#define __SYS_TIMEB_H 1 + +struct timeb { + time_t time; + unsigned short millitm; + short timezone; + short dstflag; +}; + +int ftime(struct timeb *tp); + +#endif diff --git a/mdk-stage1/dietlibc/include/sys/timex.h b/mdk-stage1/dietlibc/include/sys/timex.h new file mode 100644 index 000000000..cf024e009 --- /dev/null +++ b/mdk-stage1/dietlibc/include/sys/timex.h @@ -0,0 +1,50 @@ +#ifndef _SYS_TIMEX_H +#define _SYS_TIMEX_H + +struct timex { + unsigned int modes; /* mode selector */ + long int offset; /* time offset (usec) */ + long int freq; /* frequency offset (scaled ppm) */ + long int maxerror; /* maximum error (usec) */ + long int esterror; /* estimated error (usec) */ + int status; /* clock command/status */ + long int constant; /* pll time constant */ + long int precision; /* clock precision (usec) (read only) */ + long int tolerance; /* clock frequency tolerance (ppm) (read only) */ + struct timeval time; /* (read only) */ + long int tick; /* (modified) usecs between clock ticks */ + + long int ppsfreq; /* pps frequency (scaled ppm) (ro) */ + long int jitter; /* pps jitter (us) (ro) */ + int shift; /* interval duration (s) (shift) (ro) */ + long int stabil; /* pps stability (scaled ppm) (ro) */ + long int jitcnt; /* jitter limit exceeded (ro) */ + long int calcnt; /* calibration intervals (ro) */ + long int errcnt; /* calibration errors (ro) */ + long int stbcnt; /* stability limit exceeded (ro) */ + + /* ??? */ + int :32; int :32; int :32; int :32; + int :32; int :32; int :32; int :32; + int :32; int :32; int :32; int :32; +}; + +#define ADJ_OFFSET 0x0001 /* time offset */ +#define ADJ_FREQUENCY 0x0002 /* frequency offset */ +#define ADJ_MAXERROR 0x0004 /* maximum time error */ +#define ADJ_ESTERROR 0x0008 /* estimated time error */ +#define ADJ_STATUS 0x0010 /* clock status */ +#define ADJ_TIMECONST 0x0020 /* pll time constant */ +#define ADJ_TICK 0x4000 /* tick value */ +#define ADJ_OFFSET_SINGLESHOT 0x8001 /* old-fashioned adjtime */ + +#define TIME_OK 0 /* clock synchronized */ +#define TIME_INS 1 /* insert leap second */ +#define TIME_DEL 2 /* delete leap second */ +#define TIME_OOP 3 /* leap second in progress */ +#define TIME_WAIT 4 /* leap second has occurred */ +#define TIME_BAD 5 /* clock not synchronized */ + +int adjtimex(struct timex *buf); + +#endif diff --git a/mdk-stage1/dietlibc/include/sys/ucontext.h b/mdk-stage1/dietlibc/include/sys/ucontext.h new file mode 100644 index 000000000..573c6c7fb --- /dev/null +++ b/mdk-stage1/dietlibc/include/sys/ucontext.h @@ -0,0 +1,110 @@ +#ifndef _SYS_UCONTEXT_H +#define _SYS_UCONTEXT_H + +#include +#include + +typedef struct sigcontext mcontext_t; + +#if defined(__i386__) || defined(__arm__) || defined(__mips__) || defined(__mips64__) || defined(__powerpc__) || defined(__hppa__) +struct ucontext { + unsigned long uc_flags; + struct ucontext *uc_link; + stack_t uc_stack; + struct sigcontext uc_mcontext; + sigset_t uc_sigmask; /* mask last for extensibility */ +}; +#elif defined(__alpha__) +struct ucontext { + unsigned long uc_flags; + struct ucontext *uc_link; + unsigned long uc_osf_sigmask; + stack_t uc_stack; + struct sigcontext uc_mcontext; + sigset_t uc_sigmask; /* mask last for extensibility */ +}; +#elif defined(__sparc__) || defined(__sparc64__) + +#define MC_TSTATE 0 +#define MC_PC 1 +#define MC_NPC 2 +#define MC_Y 3 +#define MC_G1 4 +#define MC_G2 5 +#define MC_G3 6 +#define MC_G4 7 +#define MC_G5 8 +#define MC_G6 9 +#define MC_G7 10 +#define MC_O0 11 +#define MC_O1 12 +#define MC_O2 13 +#define MC_O3 14 +#define MC_O4 15 +#define MC_O5 16 +#define MC_O6 17 +#define MC_O7 18 +#define MC_NGREG 19 + +typedef unsigned long mc_greg_t; +typedef mc_greg_t mc_gregset_t[MC_NGREG]; + +#define MC_MAXFPQ 16 +struct mc_fq { + unsigned long *mcfq_addr; + unsigned int mcfq_insn; +}; + +typedef struct mc_fpu { + union { + unsigned int sregs[32]; + unsigned long dregs[32]; + long double qregs[16]; + } mcfpu_fregs; + unsigned long mcfpu_fsr; + unsigned long mcfpu_fprs; + unsigned long mcfpu_gsr; + struct mc_fq *mcfpu_fq; + unsigned char mcfpu_qcnt; + unsigned char mcfpu_qentsz; + unsigned char mcfpu_enab; +} mc_fpu_t; + +typedef struct { + mc_gregset_t mc_gregs; + mc_greg_t mc_fp; + mc_greg_t mc_i7; + mc_fpu_t mc_fpregs; +} mcontext_t; + +struct ucontext { + struct ucontext *uc_link; + unsigned long uc_flags; + sigset_t uc_sigmask; + mcontext_t uc_mcontext; +}; +#elif defined(__s390__) +struct ucontext { + unsigned long uc_flags; + struct ucontext *uc_link; + stack_t uc_stack; + _sigregs uc_mcontext; + sigset_t uc_sigmask; /* mask last for extensibility */ +}; +#elif defined(__ia64__) + +/* oh my god is this ugly! --fefe*/ +struct ucontext { + struct sigcontext uc_mcontext; +}; + +#define uc_link uc_mcontext.sc_gr[0] /* wrong type; nobody cares */ +#define uc_sigmask uc_mcontext.sc_sigmask +#define uc_stack uc_mcontext.sc_stack +#else +#error NEED TO PORT ! +#endif + +typedef struct ucontext ucontext_t; + +#endif diff --git a/mdk-stage1/dietlibc/include/sysexits.h b/mdk-stage1/dietlibc/include/sysexits.h new file mode 100644 index 000000000..5540795ff --- /dev/null +++ b/mdk-stage1/dietlibc/include/sysexits.h @@ -0,0 +1,26 @@ +#ifndef _SYSEXITS_H +#define _SYSEXITS_H 1 + +#define EX_OK 0 + +#define EX__BASE 64 + +#define EX_USAGE 64 +#define EX_DATAERR 65 +#define EX_NOINPUT 66 +#define EX_NOUSER 67 +#define EX_NOHOST 68 +#define EX_UNAVAILABLE 69 +#define EX_SOFTWARE 70 +#define EX_OSERR 71 +#define EX_OSFILE 72 +#define EX_CANTCREAT 73 +#define EX_IOERR 74 +#define EX_TEMPFAIL 75 +#define EX_PROTOCOL 76 +#define EX_NOPERM 77 +#define EX_CONFIG 78 + +#define EX__MAX 78 + +#endif diff --git a/mdk-stage1/dietlibc/include/tar.h b/mdk-stage1/dietlibc/include/tar.h new file mode 100644 index 000000000..a78bbce54 --- /dev/null +++ b/mdk-stage1/dietlibc/include/tar.h @@ -0,0 +1,36 @@ +#ifndef _TAR_H_ +#define _TAR_H_ + +#define TMAGIC "ustar" +#define TVERSION "00" + +#define TMAGLEN 6 +#define TVERSLEN 2 + +#define REGTYPE '0' +#define AREGTYPE '\0' +#define LNKTYPE '1' +#define SYMTYPE '2' +#define CHRTYPE '3' +#define BLKTYPE '4' +#define DIRTYPE '5' +#define FIFOTYPE '6' +#define CONTTYPE '7' + +#define TSUID 04000 +#define TSGID 02000 +#define TSVTX 01000 + +#define TUREAD 00400 +#define TUWRITE 00200 +#define TUEXEC 00100 + +#define TGREAD 00040 +#define TGWRITE 00020 +#define TGEXEC 00010 + +#define TOREAD 00004 +#define TOWRITE 00002 +#define TOEXEC 00001 + +#endif /* _TAR_H_ */ diff --git a/mdk-stage1/dietlibc/include/termio.h b/mdk-stage1/dietlibc/include/termio.h new file mode 100644 index 000000000..55d1f242b --- /dev/null +++ b/mdk-stage1/dietlibc/include/termio.h @@ -0,0 +1,4 @@ +/* this looks horribly wrong, but glibc does it like that */ + +#include +#include diff --git a/mdk-stage1/dietlibc/include/write12.h b/mdk-stage1/dietlibc/include/write12.h new file mode 100644 index 000000000..960b4b722 --- /dev/null +++ b/mdk-stage1/dietlibc/include/write12.h @@ -0,0 +1,4 @@ +#include + +int __write1 ( const char* s ) __attribute__ (( regparm(1) )); +int __write2 ( const char* s ) __attribute__ (( regparm(1) )); diff --git a/mdk-stage1/dietlibc/lib/__ftruncate64.c b/mdk-stage1/dietlibc/lib/__ftruncate64.c new file mode 100644 index 000000000..e0ea8c98a --- /dev/null +++ b/mdk-stage1/dietlibc/lib/__ftruncate64.c @@ -0,0 +1,23 @@ +#include +#include "dietfeatures.h" +#ifdef WANT_LARGEFILE_BACKCOMPAT +#include +#include "syscalls.h" +#include +#ifndef __NO_STAT64 +#ifdef __NR_ftruncate64 + +extern int __dietlibc_ftruncate64(int fd, loff_t o); + +int ftruncate64(int fd, loff_t o) { + int tmp; + if ((tmp=__dietlibc_ftruncate64(fd,o))==-1) { + if (errno!=ENOSYS) return -1; + if (o>0x7fffffff) { errno=EOVERFLOW; return -1; } + return ftruncate(fd,o); + } + return tmp; +} +#endif +#endif +#endif diff --git a/mdk-stage1/dietlibc/lib/__isinf.c b/mdk-stage1/dietlibc/lib/__isinf.c new file mode 100644 index 000000000..359bd2709 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/__isinf.c @@ -0,0 +1,15 @@ +#include + +int isinf(double d) { + unsigned long long *x=(unsigned long long *)&d; + return (*x==0x7FF0000000000000ll?1:*x==0xFFF0000000000000?-1:0); +} +int __isinf(double d) __attribute__((alias("isinf"))); + +#if 0 +TestFromIeeeExtended("7FFF0000000000000000"); /* +infinity */ +TestFromIeeeExtended("FFFF0000000000000000"); /* -infinity */ +TestFromIeeeExtended("7FFF8001000000000000"); /* Quiet NaN(1) */ +TestFromIeeeExtended("7FFF0001000000000000"); /* Signalling NaN(1) */ +TestFromIeeeExtended("3FFFFEDCBA9876543210"); /* accuracy test */ +#endif diff --git a/mdk-stage1/dietlibc/lib/__ptrace.c b/mdk-stage1/dietlibc/lib/__ptrace.c new file mode 100644 index 000000000..bd14a0351 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/__ptrace.c @@ -0,0 +1,27 @@ +/* we need this because we need to use the glibc prototype which uses + * varargs :-( */ +#define ptrace fnord +#include +#undef ptrace +#include +#include + +extern int __diet_ptrace(int request, pid_t pid, void *addr, void *data); +int ptrace(int request, pid_t pid, void *addr, void *data); + +int ptrace(int request, pid_t pid, void *addr, void *data) { + switch (request) { + case PTRACE_TRACEME: case PTRACE_KILL: case PTRACE_ATTACH: + case PTRACE_DETACH: + return (__diet_ptrace (request, pid, NULL, NULL)); + case PTRACE_PEEKDATA: case PTRACE_PEEKUSER: case PTRACE_PEEKTEXT: + { + long result; + if (__diet_ptrace (request, pid, addr, &result) == -1) + return (-1); + return (result); + } + default: + return (__diet_ptrace (request, pid, addr, data)); + } +} diff --git a/mdk-stage1/dietlibc/lib/__stime.c b/mdk-stage1/dietlibc/lib/__stime.c new file mode 100644 index 000000000..7b2c77729 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/__stime.c @@ -0,0 +1,14 @@ +#include +#include +#include +#include + +#ifndef __NR_stime +int stime(time_t *when) +{ + struct timeval tv; + tv.tv_sec = *when; + tv.tv_usec = 0; + return settimeofday(&tv, (struct timezone *)0); +} +#endif diff --git a/mdk-stage1/dietlibc/lib/__truncate64.c b/mdk-stage1/dietlibc/lib/__truncate64.c new file mode 100644 index 000000000..ccb3e7f64 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/__truncate64.c @@ -0,0 +1,23 @@ +#include "dietfeatures.h" +#include +#ifdef WANT_LARGEFILE_BACKCOMPAT +#include +#include "syscalls.h" +#include +#ifndef __NO_STAT64 +#ifdef __NR_truncate64 + +extern int __dietlibc_truncate64(const char* f, loff_t o); + +int truncate64(const char* f, loff_t o) { + int tmp; + if ((tmp=__dietlibc_truncate64(f,o))==-1) { + if (errno!=ENOSYS) return -1; + if (o>0x7fffffff) { errno=EOVERFLOW; return -1; } + return truncate(f,o); + } + return tmp; +} +#endif +#endif +#endif diff --git a/mdk-stage1/dietlibc/lib/__v_printf.c b/mdk-stage1/dietlibc/lib/__v_printf.c new file mode 100644 index 000000000..15011cdd8 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/__v_printf.c @@ -0,0 +1,300 @@ +#include "dietfeatures.h" +#include +#include +#include +#include +#include "dietstdio.h" +#include "dietwarning.h" + +static inline unsigned int skip_to(const unsigned char *format) { + unsigned int nr; + for (nr=0; format[nr] && (format[nr]!='%'); ++nr); + return nr; +} + +#define A_WRITE(fn,buf,sz) ((fn)->put((void*)(buf),(sz),(fn)->data)) + +static const char pad_line[2][16]= { " ", "0000000000000000", }; +static inline int write_pad(struct arg_printf* fn, int len, int padwith) { + int nr=0; + for (;len>15;len-=16,nr+=16) { + A_WRITE(fn,pad_line[(padwith=='0')?1:0],16); + } + if (len>0) { + A_WRITE(fn,pad_line[(padwith=='0')?1:0],(unsigned int)len); nr+=len; + } + return nr; +} + +int __v_printf(struct arg_printf* fn, const unsigned char *format, va_list arg_ptr) +{ + int len=0; + + while (*format) { + unsigned int sz = skip_to(format); + if (sz) { + A_WRITE(fn,format,sz); len+=sz; + format+=sz; + } + if (*format=='%') { + char buf[128]; + + unsigned char ch, *s, padwith=' '; + + char flag_in_sign=0; + char flag_upcase=0; + char flag_hash=0; + char flag_left=0; + char flag_space=0; + char flag_sign=0; + char flag_dot=0; + signed char flag_long=0; + + unsigned int base; + unsigned int width=0, preci=0; + + long number=0; +#ifdef WANT_LONGLONG_PRINTF + long long llnumber=0; +#endif + + ++format; +inn_printf: + switch(ch=*format++) { + case 0: + return -1; + break; + + /* FLAGS */ + case '#': + flag_hash=-1; + case 'z': + goto inn_printf; + + case 'h': + --flag_long; + goto inn_printf; + case 'L': + ++flag_long; /* fall through */ + case 'l': + ++flag_long; + goto inn_printf; + + case '0': + padwith='0'; + goto inn_printf; + + case '-': + flag_left=1; + goto inn_printf; + + case ' ': + flag_space=1; + goto inn_printf; + + case '+': + flag_sign=1; + goto inn_printf; + + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + if(flag_dot) return -1; + width=strtoul(format-1,(char**)&s,10); + format=s; + goto inn_printf; + + case '*': + width=va_arg(arg_ptr,int); + goto inn_printf; + + case '.': + flag_dot=1; + if (*format=='*') { + preci=va_arg(arg_ptr,int); + ++format; + } else { + long int tmp=strtol(format,(char**)&s,10); + preci=tmp<0?0:tmp; + format=s; + } + goto inn_printf; + + /* print a char or % */ + case 'c': + ch=(char)va_arg(arg_ptr,int); + case '%': + A_WRITE(fn,&ch,1); ++len; + break; + + /* print a string */ + case 's': + s=va_arg(arg_ptr,char *); +#ifdef WANT_NULL_PRINTF + if (!s) s="(null)"; +#endif + sz = strlen(s); + if (flag_dot && sz>preci) sz=preci; + flag_dot^=flag_dot; + +print_out: + if (width && (!flag_left)) { + if (flag_in_sign) { + A_WRITE(fn,s,1); ++len; + ++s; --sz; + --width; + } + if (flag_hash>0) { + A_WRITE(fn,s,flag_hash); len+=flag_hash; + s+=flag_hash; sz-=flag_hash; + width-=flag_hash; + } +// len+=write_pad(fn,(signed int)width-(signed int)sz,padwith); + if (flag_dot) { + len+=write_pad(fn,(signed int)width-(signed int)preci,padwith); + len+=write_pad(fn,(signed int)preci-(signed int)sz,'0'); + } else + len+=write_pad(fn,(signed int)width-(signed int)sz,padwith); + } + A_WRITE(fn,s,sz); len+=sz; + if (width && (flag_left)) { + len+=write_pad(fn,(signed int)width-(signed int)sz,' '); + } + break; + + /* print an integer value */ + case 'b': + base=2; + sz=0; + goto num_printf; + case 'p': + flag_hash=2; + flag_long=1; + ch='x'; + case 'X': + flag_upcase=(ch=='X'); + case 'x': + base=16; + sz=0; + if (flag_dot) width=preci; + if (flag_hash) { + buf[1]='0'; + buf[2]=ch; + flag_hash=2; + sz=2; + } + goto num_printf; + case 'd': + case 'i': + flag_in_sign=1; + case 'u': + base=10; + sz=0; + goto num_printf; + case 'o': + base=8; + sz=0; + if (flag_hash) { + buf[1]='0'; + flag_hash=1; + ++sz; + } + +num_printf: + s=buf+1; + + if (flag_long>0) { +#ifdef WANT_LONGLONG_PRINTF + if (flag_long>1) + llnumber=va_arg(arg_ptr,long long); + else +#endif + number=va_arg(arg_ptr,long); + } + else + number=va_arg(arg_ptr,int); + + if (flag_in_sign) { +#ifdef WANT_LONGLONG_PRINTF + if ((flag_long>1)&&(llnumber<0)) { + llnumber=-llnumber; + flag_in_sign=2; + } else +#endif + if (number<0) { + number=-number; + flag_in_sign=2; + } + } + if (flag_long<0) number&=0xffff; + if (flag_long<-1) number&=0xff; +#ifdef WANT_LONGLONG_PRINTF + if (flag_long>1) + sz += __lltostr(s+sz,sizeof(buf)-5,(unsigned long long) llnumber,base,flag_upcase); + else +#endif + sz += __ltostr(s+sz,sizeof(buf)-5,(unsigned long) number,base,flag_upcase); + + if (flag_in_sign==2) { + *(--s)='-'; + ++sz; + } else if ((flag_in_sign)&&(flag_sign || flag_space)) { + *(--s)=(flag_sign)?'+':' '; + ++sz; + } else flag_in_sign=0; + + goto print_out; + +#ifdef WANT_FLOATING_POINT_IN_PRINTF + /* print a floating point value */ + case 'f': + case 'g': + { + int g=(ch=='g'); + double d=va_arg(arg_ptr,double); + if (width==0) width=1; + if (!flag_dot) preci=6; + sz=__dtostr(d,buf,sizeof(buf),width,preci); + if (flag_dot) { + char *tmp; + if ((tmp=strchr(buf,'.'))) { + ++tmp; + while (preci>0 && *++tmp) --preci; + *tmp=0; + } + } + if (g) { + char *tmp,*tmp1; /* boy, is _this_ ugly! */ + if ((tmp=strchr(buf,'.'))) { + tmp1=strchr(tmp,'e'); + while (*tmp) ++tmp; + if (tmp1) tmp=tmp1; + while (*--tmp=='0') ; + if (*tmp!='.') ++tmp; + *tmp=0; + if (tmp1) strcpy(tmp,tmp1); + } + } + preci=strlen(buf); + s=buf; + + goto print_out; + } +#endif + + default: + break; + } + } + } + return len; +} + +link_warning("__v_printf","warning: the printf functions add several kilobytes of bloat.") + diff --git a/mdk-stage1/dietlibc/lib/__v_scanf.c b/mdk-stage1/dietlibc/lib/__v_scanf.c new file mode 100644 index 000000000..6db51db59 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/__v_scanf.c @@ -0,0 +1,391 @@ +#include "dietfeatures.h" +#include +#include +#include +#include +#include +#include + +#include "dietstdio.h" +#include "dietwarning.h" + +#define A_GETC(fn) (++consumed,(fn)->getch((fn)->data)) +#define A_PUTC(c,fn) (--consumed,(fn)->putch((c),(fn)->data)) + +int __v_scanf(struct arg_scanf* fn, const unsigned char *format, va_list arg_ptr) +{ + unsigned int ch; /* format act. char */ + int n=0; + + /* arg_ptr tmps */ +#ifdef WANT_FLOATING_POINT_IN_SCANF + double *pd; + float *pf; +#endif +#ifdef WANT_LONGLONG_SCANF + long long *pll; +#endif + long *pl; + short *ph; + int *pi; + char *s; + + unsigned int consumed=0; + + /* get one char */ + int tpch= A_GETC(fn); + + //while ((tpch!=-1)&&(*format)) + while (*format) + { +// const unsigned char *prev_fmt=format; + ch=*format++; + switch (ch) { + /* end of format string ?!? */ + case 0: return 0; + + /* skip spaces ... */ + case ' ': + case '\f': + case '\t': + case '\v': + case '\n': + case '\r': + while((*format)&&(isspace(*format))) ++format; + while(isspace(tpch)) tpch=A_GETC(fn); + break; + + /* format string ... */ + case '%': + { + unsigned int _div=0; + int width=-1; + char flag_width=0; + char flag_discard=0; + char flag_half=0; + char flag_long=0; + char flag_longlong=0; + +in_scan: + ch=*format++; + if(ch!='n' && tpch==-1) goto err_out; + switch (ch) { + /* end of format string ?!? */ + case 0: return 0; + + /* check for % */ + case '%': + if ((unsigned char)tpch != ch) goto err_out; + tpch=A_GETC(fn); + break; + + /* FLAGS */ + case '*': + flag_discard=1; + goto in_scan; + case 'h': + flag_half=1; + goto in_scan; + case 'l': + if (flag_long) flag_longlong=1; + flag_long=1; + goto in_scan; + case 'q': + case 'L': + flag_longlong=1; + goto in_scan; + + /* WIDTH */ + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + width=strtol(format-1,&s,10); + format=s; + flag_width=1; + goto in_scan; + + /* scan for integer / strtol reimplementation ... */ + case 'p': + case 'X': + case 'x': + _div+=6; + case 'd': + _div+=2; + case 'o': + _div+=8; + case 'u': + case 'i': + { +#ifdef WANT_LONGLONG_SCANF + unsigned long long v=0; +#else + unsigned long v=0; +#endif + unsigned int consumedsofar=consumed; + int neg=0; + while(isspace(tpch)) tpch=A_GETC(fn); + if (tpch=='-') { + tpch=A_GETC(fn); + neg=1; + } + + if (tpch=='+') tpch=A_GETC(fn); + + if (!flag_width) { + if ((_div==16) && (tpch=='0')) goto scan_hex; + if (!_div) { + _div=10; + if (tpch=='0') { + _div=8; +scan_hex: + tpch=A_GETC(fn); + if ((tpch|32)=='x') { + tpch=A_GETC(fn); + _div=16; + } + } + } + } + while ((width)&&(tpch!=-1)) { + register unsigned long c=tpch&0xff; +#ifdef WANT_LONGLONG_SCANF + register unsigned long long d=c|0x20; +#else + register unsigned long d=c|0x20; +#endif + c=(d>='a'?d-'a'+10:c<='9'?c-'0':0xff); + if (c>=_div) break; + d=v*_div; +#ifdef WANT_LONGLONG_SCANF + v=(d=-((unsigned long long)LLONG_MIN)) { + l=(neg)?LLONG_MIN:LLONG_MAX; + } + else { + if (neg) v*=-1; + } +#else + register long l=v; + if (v>=-((unsigned long)LONG_MIN)) { + l=(neg)?LONG_MIN:LONG_MAX; + } + else { + if (neg) v*=-1; + } +#endif + } + if (!flag_discard) { +#ifdef WANT_LONGLONG_SCANF + if (flag_longlong) { + pll=(long long *)va_arg(arg_ptr,long long*); + *pll=v; + } else +#endif + if (flag_long) { + pl=(long *)va_arg(arg_ptr,long*); + *pl=v; + } else if (flag_half) { + ph=(short*)va_arg(arg_ptr,short*); + *ph=v; + } else { + pi=(int *)va_arg(arg_ptr,int*); + *pi=v; + } + if(consumedsofar=0) && (cset[tpch]^flag_not)) { + if (!flag_discard) *s=tpch; + if (tpch) ++s; else break; + --width; + tpch=A_GETC(fn); + } + if (!flag_discard) *s=0; + ++format; + } + break; +#endif + default: + goto err_out; + } + } + break; + + /* check if equal format string... */ + default: + if ((unsigned char)tpch != ch) goto err_out; + tpch=A_GETC(fn); + break; + } + } +err_out: + if (tpch<0 && n==0) return EOF; + A_PUTC(tpch,fn); + return n; +} + +link_warning("__v_scanf","warning: the scanf functions add several kilobytes of bloat."); diff --git a/mdk-stage1/dietlibc/lib/adjtime.c b/mdk-stage1/dietlibc/lib/adjtime.c new file mode 100644 index 000000000..b8986be57 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/adjtime.c @@ -0,0 +1,18 @@ +#include +#include + +int adjtime (const struct timeval *itv, struct timeval *otv) { + struct timex tmp; + if (itv) { + tmp.offset = (itv->tv_usec % 1000000L) + (itv->tv_sec + itv->tv_usec / 1000000L) * 1000000L; + tmp.modes = ADJ_OFFSET_SINGLESHOT; + } else + tmp.modes = 0; + if (adjtimex(&tmp)==-1) + return -1; + if (otv) { + otv->tv_usec = tmp.offset % 1000000; + otv->tv_sec = tmp.offset / 1000000; + } + return 0; +} diff --git a/mdk-stage1/dietlibc/lib/atoll.c b/mdk-stage1/dietlibc/lib/atoll.c new file mode 100644 index 000000000..7bf2b2fd6 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/atoll.c @@ -0,0 +1,19 @@ +#include +#include +#include + +#if __WORDSIZE != 64 +long long int atoll(const char* s) { + long long int v=0; + int sign=1; + while ( *s == ' ' || (unsigned int)(*s - 9) < 5u) ++s; + switch (*s) { + case '-': sign=-1; + case '+': ++s; + } + while ((unsigned int) (*s - '0') < 10u) { + v=v*10+*s-'0'; ++s; + } + return sign==-1?-v:v; +} +#endif diff --git a/mdk-stage1/dietlibc/lib/bcd.c b/mdk-stage1/dietlibc/lib/bcd.c new file mode 100644 index 000000000..1936b82f6 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/bcd.c @@ -0,0 +1,185 @@ + +static long double powers [] = { + 1.e+1, 1.e+2, 1.e+4, 1.e+8, 1.e+16, 1.e+32, 1.e+64, 1.e+128, 1.e+256 +}; + +/* + * So, die ist zum Zerlegen von Gleitkommazahlen am besten geeignet. + * + * Die nichtnegative übergebende Gleitkommazahl number wird in einen + * Exponenten e und eine Mantisse m zerlegt mit: + * + * 1 <= m < 10 + * number = m * 10^e + * + * Die Mantisse wird in precision Dezimalstellen zerlegt, die nach digits + * geschrieben werden. digits[0] ist die Vorkommastelle, digits [1 ... + * precision-1] die Nachkommastellen der Mantisse Zurückgeliefert wird der + * Exponent. + * + * Für precision ist ein Wert von 0 erlaubt, Sinn machen allerdings erst + * Werte ab 1. + */ + +int __decompose_floatp ( long double number, + unsigned char* digits, unsigned int precision ); + +int __decompose_floatp ( long double number, + unsigned char* digits, unsigned int precision ) +{ + int ret = 0; + int i; + double tmp; + + if ( number > 0.L ) { + + // Exponent abtrennen + if ( number >= 10.L ) { + for ( i = sizeof(powers)/sizeof(*powers)-1; i >= 0; i--) + if ( number >= powers [i] ) { + number /= powers [i]; + ret += 1 << i; + } + } else if ( number < 1.L ) + for ( i = sizeof(powers)/sizeof(*powers)-1; i >= 0; i--) + if ( number * powers [i] < 10.L ) { + number *= powers [i]; + ret -= 1 << i; + } + + // Runden (ohne Geradezahlregel => Bug) + tmp = 5.; + { + unsigned int j; + for ( j = 0; j < precision; j++ ) + tmp *= 0.1; + } + + number += tmp; + + // Dabei kann die Zahl in die nächste Dekade reinrutschen ... + if ( number >= 10.L ) { + number = 1.L; + ret++; + } + } + + // Mantisse in ASCII konvertieren + while ( precision-- ) { + i = (int) number; + number = (number - i) * 10.L; + *digits++ = '0' + i; + } + + // Exponent zurück + return ret; +} + + +/* + * So, die ist zum Zerlegen von Festkommazahlen am besten geeignet. + * + * Die nichtnegative übergebende Festkomma wird in einen Integeranteil und + * einen Bruchanteil zerlegt. + * + * Der Bruchanteil wird in digits_frac[0...precision_frac-1] gespeichert, + * falls precision_frac != 0 ist. + * + * Der Integeranteil wird ab digits_int + precision_int - 1 rückwrts + * geschrieben. Zurückgeliefert wird ein Zeiger auf das erste Zeichen, das + * bei der Konvertierung != '0' ist (Ausnahme ist die 0.0 selbst). Zeichen + * zwischen digits_int und diesem Zeiger (exklusive des Zeichens unter dem + * Zeiger) sind unbestimmt. Wünscht man dort Nullen oder Leerzeichen, + * sollte man mittels memset() dieses vorher initialsieren. + */ + +char* __decompose_fixp ( long double number, + unsigned char* digits_int , unsigned int precision_int, + unsigned char* digits_frac, unsigned int precision_frac ); + +char* __decompose_fixp ( long double number, + unsigned char* digits_int , unsigned int precision_int, + unsigned char* digits_frac, unsigned int precision_frac ) +{ + long long int integer; + double tmp; + int i; + + // Runden (ohne Geradezahlregel => Bug) + tmp = 0.5; + { + unsigned int j; + for ( j = 0; j < precision_frac; j++ ) + tmp *= 0.1; + } + + number += tmp; + + integer = number; + number -= integer; + + // Nachkommastellen + while ( precision_frac-- ) { + number *= 10.L; + i = (int) number; + number -= i; + *digits_frac++ + = '0' + i; + } + + // Vorkommastellen + while ( precision_int ) { + i = (int) (integer % 10); + integer /= 10; + digits_int [--precision_int] + = '0' + i; + if ( integer == 0 ) + break; + } + + return digits_int + precision_int; +} + + +#if 0 + +#include +#include + +long double test [] = { + 1, M_PI, 123, 123456789, 12345678901234567, 1e300, 0.00123456789, 1.234567890123456e-300, 0 +}; + +int main ( void ) +{ + int i; + int j; + int k; + char buff1 [32]; + char buff2 [32]; + char* retp; + int ret; + + for ( i = 0; i < sizeof(test)/sizeof(*test); i++ ) { + printf ("\n*** %30.20Lf ***\n\n", test[i] ); + + for ( j = 0; j <= 20; j++ ) { + memset ( buff1, 0, sizeof(buff1) ); + ret = __decompose_floatp ( test[i], buff1, j ); + printf ( "floatp(%2u) = <%sE%+d>\n", j, buff1, ret ); + } + for ( j = 0; j <= 20; j++ ) { + for ( k = 0; k <= 20; k++ ) { + memset ( buff1, 0, sizeof(buff1) ); + memset ( buff2, 0, sizeof(buff2) ); + retp = __decompose_fixp ( test[i], buff1, j, buff2, k ); + printf ( "fixp(%2u,%2u) = <%s.%s>\n", j, k, retp, buff2 ); + } + } + + } + + return 0; +} + +#endif diff --git a/mdk-stage1/dietlibc/lib/binshstr.c b/mdk-stage1/dietlibc/lib/binshstr.c new file mode 100644 index 000000000..814297e3d --- /dev/null +++ b/mdk-stage1/dietlibc/lib/binshstr.c @@ -0,0 +1,5 @@ +#include "binshstr.h" + +const char __binsh [] = "/bin/sh"; + +/* end of binshstr.c */ diff --git a/mdk-stage1/dietlibc/lib/cfgetospeed.c b/mdk-stage1/dietlibc/lib/cfgetospeed.c new file mode 100644 index 000000000..c330352b2 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/cfgetospeed.c @@ -0,0 +1,8 @@ +#include +#include + +speed_t cfgetospeed(struct termios *termios_p) { + return ((termios_p->c_cflag & (CBAUD|CBAUDEX))); +} + +speed_t cfgetispeed(struct termios *termios_p) __attribute__((weak,alias("cfgetospeed"))); diff --git a/mdk-stage1/dietlibc/lib/cfsetispeed.c b/mdk-stage1/dietlibc/lib/cfsetispeed.c new file mode 100644 index 000000000..ab0333853 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/cfsetispeed.c @@ -0,0 +1,22 @@ +#include +#include +#include "dietfeatures.h" + +#define IBAUD0 020000000000 + +int cfsetispeed(struct termios *termios_p, speed_t speed) +{ + if ((speed & (speed_t)~CBAUD) != 0 && (speed < B57600 || speed > B460800)) { + errno=EINVAL; + return -1; + } + if (speed == 0) + termios_p->c_iflag |= IBAUD0; + else { + termios_p->c_iflag &= ~IBAUD0; + termios_p->c_cflag &= ~(CBAUD | CBAUDEX); + termios_p->c_cflag |= speed; + } + return 0; +} + diff --git a/mdk-stage1/dietlibc/lib/cfsetospeed.c b/mdk-stage1/dietlibc/lib/cfsetospeed.c new file mode 100644 index 000000000..d1aee3595 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/cfsetospeed.c @@ -0,0 +1,14 @@ +#include +#include +#include "dietfeatures.h" + +int cfsetospeed(struct termios *termios_p, speed_t speed) { + if ((speed & (speed_t)~CBAUD) != 0 && (speed < B57600 || speed > B460800)) { + errno=EINVAL; + return -1; + } + termios_p->c_cflag &= ~(CBAUD | CBAUDEX); + termios_p->c_cflag |= speed; + return 0; +} + diff --git a/mdk-stage1/dietlibc/lib/errlistu.c b/mdk-stage1/dietlibc/lib/errlistu.c new file mode 100644 index 000000000..15e38807b --- /dev/null +++ b/mdk-stage1/dietlibc/lib/errlistu.c @@ -0,0 +1,6 @@ +/* + * used by perror() and strerror() + */ + +const char __sys_err_unknown [] = "[unknown error]"; + diff --git a/mdk-stage1/dietlibc/lib/execle.c b/mdk-stage1/dietlibc/lib/execle.c new file mode 100644 index 000000000..6d05c48a0 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/execle.c @@ -0,0 +1,26 @@ +#include +#include +#include +#include +#include "dietfeatures.h" + +int execle( const char *path,...) { + va_list ap; + int n,i; + char **argv,*tmp, **env; + va_start(ap, path); + n=1; + while ((tmp=va_arg(ap,char *))) + ++n; + va_end (ap); + if ((argv=(char **)alloca(n*sizeof(char*)))) { + va_start(ap, path); + for (i=0; i +#include +#include +#include +#include +#include + +struct if_nameindex* if_nameindex(void) { + struct ifconf ic; + int fd,len,i; + struct if_nameindex* x,* y; + char *dest; + fd=socket(AF_INET6,SOCK_DGRAM,0); + if (fd<0) fd=socket(AF_INET,SOCK_DGRAM,0); + ic.ifc_buf=0; + ic.ifc_len=0; + if (ioctl(fd,SIOCGIFCONF,&ic)<0) { +b0rken: + close(fd); + return 0; + } + ic.ifc_buf=alloca((size_t)ic.ifc_len); + if (ioctl(fd,SIOCGIFCONF,&ic)<0) goto b0rken; + len=(ic.ifc_len/sizeof(struct ifreq)); + x=(struct if_nameindex*)malloc((len+1)*sizeof(struct if_nameindex)+len*IFNAMSIZ); + if (!x) goto b0rken; + dest=(char*)(x+len+1); + y=x; + for (i=0; iif_name=dest; + memcpy(dest,ir->ifr_name,IFNAMSIZ); + if (ioctl(fd,SIOCGIFINDEX,ir)==-1) continue; + y->if_index=ir->ifr_ifindex; + dest+=IFNAMSIZ; + ++y; + } + y->if_name=0; y->if_index=0; + return x; +} diff --git a/mdk-stage1/dietlibc/lib/ipv6constants.c b/mdk-stage1/dietlibc/lib/ipv6constants.c new file mode 100644 index 000000000..1d5cb1f08 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/ipv6constants.c @@ -0,0 +1,4 @@ +#include "netinet/in.h" + +const struct in6_addr in6addr_any = IN6ADDR_ANY_INIT; +const struct in6_addr in6addr_loopback = IN6ADDR_LOOPBACK_INIT; diff --git a/mdk-stage1/dietlibc/lib/labs.c b/mdk-stage1/dietlibc/lib/labs.c new file mode 100644 index 000000000..364557f40 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/labs.c @@ -0,0 +1,6 @@ +#include + +#if __WORDSIZE == 64 +long int labs(long int i) { return i>=0?i:-i; } +long long int llabs(long long int i) __attribute__((alias("labs"))); +#endif diff --git a/mdk-stage1/dietlibc/lib/llabs.c b/mdk-stage1/dietlibc/lib/llabs.c new file mode 100644 index 000000000..bcbd3dc78 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/llabs.c @@ -0,0 +1,6 @@ +#include +#include + +#if __WORDSIZE != 64 +long long int llabs(long long int i) { if (i<0) i=-i; return i; } +#endif diff --git a/mdk-stage1/dietlibc/lib/memmem.c b/mdk-stage1/dietlibc/lib/memmem.c new file mode 100644 index 000000000..5c88a29e7 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/memmem.c @@ -0,0 +1,14 @@ +#define _GNU_SOURCE 23 +#include +#include + +void *memmem(const void* haystack, size_t hl, const void* needle, size_t nl) { + int i; + if (nl>hl) return 0; + for (i=hl-nl+1; i; --i) { + if (!memcmp(haystack,needle,nl)) + return (char*)haystack; + ++haystack; + } + return 0; +} diff --git a/mdk-stage1/dietlibc/lib/memrchr.c b/mdk-stage1/dietlibc/lib/memrchr.c new file mode 100644 index 000000000..f7750d2d7 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/memrchr.c @@ -0,0 +1,15 @@ +#define _GNU_SOURCE +#include +#include + +void* memrchr(const void *s, int c, size_t n) { + register const char* t=s; + register const char* last=0; + int i; + for (i=n; i; --i) { + if (*t==c) + last=t; + ++t; + } + return (void*)last; /* man, what an utterly b0rken prototype */ +} diff --git a/mdk-stage1/dietlibc/lib/pwrite.c b/mdk-stage1/dietlibc/lib/pwrite.c new file mode 100644 index 000000000..1e9fde545 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/pwrite.c @@ -0,0 +1,11 @@ +#include +#include + +extern size_t __pwrite(int fd, void *buf, size_t count, off_t a,off_t b); + +size_t __libc_pwrite(int fd, void *buf, size_t count, off_t offset); +size_t __libc_pwrite(int fd, void *buf, size_t count, off_t offset) { + return __pwrite(fd,buf,count,offset,0); +} + +int pwrite(int fd, void *buf, size_t count, off_t offset) __attribute__((weak,alias("__libc_pwrite"))); diff --git a/mdk-stage1/dietlibc/lib/pwrite64.c b/mdk-stage1/dietlibc/lib/pwrite64.c new file mode 100644 index 000000000..cac46024a --- /dev/null +++ b/mdk-stage1/dietlibc/lib/pwrite64.c @@ -0,0 +1,14 @@ +#include +#include +#include + +#ifndef __NO_STAT64 +extern size_t __pwrite(int fd, void *buf, size_t count, off_t a,off_t b); + +size_t __libc_pwrite64(int fd, void *buf, size_t count, off64_t offset); +size_t __libc_pwrite64(int fd, void *buf, size_t count, off64_t offset) { + return __pwrite(fd,buf,count,__LONG_LONG_PAIR ((off_t)(offset&0xffffffff),(off_t)(offset>>32))); +} + +int pwrite64(int fd, void *buf, size_t count, off_t offset) __attribute__((weak,alias("__libc_pwrite64"))); +#endif diff --git a/mdk-stage1/dietlibc/lib/rand48.c b/mdk-stage1/dietlibc/lib/rand48.c new file mode 100644 index 000000000..9c6cfcda2 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/rand48.c @@ -0,0 +1,89 @@ +#include + +static randbuf rand48buf; +#define A_0 0xE66D +#define A_1 0xDEEC +#define A_2 0x5 +#define C 0xB +static randbuf a = { A_0, A_1, A_2 }; +static unsigned short c = C; + +static void calc_next(randbuf buf) { + randbuf tmp; + long t; + t = buf[0] * a[0] + c; + tmp[0] = t & 0xffff; + tmp[1] = (t >> 16) & 0xffff; + t = buf[1] * a[0] + buf[0] * a[1] + tmp[1]; + tmp[1] = t & 0xffff; + tmp[2] = (t >> 16) & 0xffff; + t = buf[2] * a[0] + buf[1] * a[1] + buf[0] * a[2] + tmp[2]; + tmp[2] = t & 0xffff; + buf[0] = tmp[0]; + buf[1] = tmp[1]; + buf[2] = tmp[2]; +} + +double drand48(void) { + return erand48(rand48buf); +} + +long lrand48(void) { + return nrand48(rand48buf); +} + +long mrand48(void) { + return jrand48(rand48buf); +} + +void srand48(long seed) { + rand48buf[1] = (seed >> 16) & 0xffff; + rand48buf[2] = seed & 0xffff; + rand48buf[0] = 0x330e; + a[0] = A_0; + a[1] = A_1; + a[2] = A_2; + c = C; +} + +unsigned short *seed48(randbuf buf) { + static randbuf oldx; + int i; + for (i = 0; i < 3; i++) { + oldx[i] = rand48buf[i]; + rand48buf[i] = buf[i]; + } + a[0] = A_0; + a[1] = A_1; + a[2] = A_2; + c = C; + return (unsigned short *)&oldx; +} + +void lcong48(unsigned short param[7]) { + int i; + for (i = 0; i < 3; i++) { + rand48buf[i] = param[i]; + a[i] = param[i + 3]; + } + c = param[6]; +} + +long jrand48(randbuf buf) { + long ret; + ret = buf[2] << 16 | buf[1]; + calc_next(buf); + return ret; +} + +long nrand48(randbuf buf) { + return jrand48(buf) & 0x7FFFFFFFL; +} + +double erand48(randbuf buf) { + double ret; + ret = ((buf[0] / 65536.0 + buf[1]) / 65536.0 + buf[2]) / 65536.0; + calc_next(buf); + return ret; +} + diff --git a/mdk-stage1/dietlibc/lib/rand_r.c b/mdk-stage1/dietlibc/lib/rand_r.c new file mode 100644 index 000000000..55f8303bc --- /dev/null +++ b/mdk-stage1/dietlibc/lib/rand_r.c @@ -0,0 +1,30 @@ +/* + Copyright (C) 2002 Luc Van Oostenryck + + This is free software. You can redistribute and + modify it under the terms of the GNU General Public + Public License. +*/ + +#include +#include + +/* Knuth's TAOCP section 3.6 */ +#define M ((1U<<31) -1) +#define A 48271 +#define Q 44488 // M/A +#define R 3399 // M%A; R < Q !!! + +// FIXME: ISO C/SuS want a longer period + +int rand_r(unsigned int* seed) +{ int32_t X; + + X = *seed; + X = A*(X%Q) - R * (int32_t) (X/Q); + if (X < 0) + X += M; + + *seed = X; + return X; +} diff --git a/mdk-stage1/dietlibc/lib/readdir64.c b/mdk-stage1/dietlibc/lib/readdir64.c new file mode 100644 index 000000000..b9b0aafcc --- /dev/null +++ b/mdk-stage1/dietlibc/lib/readdir64.c @@ -0,0 +1,62 @@ +#include "dietfeatures.h" +#include "dietdirent.h" +#include +#include +#include +#include +#include +#include "syscalls.h" + +#ifndef __NR_getdents64 +#define WANT_LARGEFILE_BACKCOMPAT +#endif + +#ifndef WANT_LARGEFILE_BACKCOMPAT +struct dirent64* readdir64(DIR *d) { + if (!d->num || (d->cur += ((struct dirent64*)(d->buf+d->cur))->d_reclen)>=d->num) { + int res=getdents64(d->fd,(struct dirent64*)d->buf, sizeof (d->buf)-1); + if (res<=0) return 0; + d->num=res; d->cur=0; + } + return (struct dirent64*)(d->buf+d->cur); +} +#else +struct dirent64* readdir64(DIR *d) { +#ifdef __NR_getdents64 + static int trygetdents64=1; +#endif + struct dirent* o; + static struct dirent64 d64; +again: +#ifdef __NR_getdents64 + if (!trygetdents64) { +#endif + if (!d->num || (d->cur += ((struct dirent*)(d->buf+d->cur))->d_reclen)>=d->num) { + int res=getdents(d->fd,(struct dirent*)d->buf, sizeof (d->buf)-1); + if (res<=0) return 0; + d->num=res; d->cur=0; + } + o=(struct dirent*)(d->buf+d->cur); + d64.d_ino=o->d_ino; + d64.d_off=o->d_off; + d64.d_reclen=o->d_reclen; + strcpy(d64.d_name,o->d_name); + d64.d_type=0; /* is this correct? */ + return &d64; +#ifdef __NR_getdents64 + } + if (!d->num || (d->cur += ((struct dirent64*)(d->buf+d->cur))->d_reclen)>=d->num) { + int res=getdents64(d->fd,(struct dirent64*)d->buf,sizeof (d->buf)); + if (res<=0) { + if (errno==ENOSYS) { + trygetdents64=0; + goto again; + } + return 0; + } + d->num=res; d->cur=0; + } + return (struct dirent64*)(d->buf+d->cur); +#endif +} +#endif diff --git a/mdk-stage1/dietlibc/lib/setlinebuf.c b/mdk-stage1/dietlibc/lib/setlinebuf.c new file mode 100644 index 000000000..1f30e183a --- /dev/null +++ b/mdk-stage1/dietlibc/lib/setlinebuf.c @@ -0,0 +1,12 @@ +#include +#include "dietwarning.h" +#undef setlinebuf + +/* there is no previous prototype because it is a #define */ +void setlinebuf(FILE* stream); + +void setlinebuf(FILE* stream) { + setvbuf(stream,0,_IOLBF,BUFSIZ); +} + +link_warning("setlinebuf","warning: you used setlinebuf without including ") diff --git a/mdk-stage1/dietlibc/lib/sigaction.c b/mdk-stage1/dietlibc/lib/sigaction.c new file mode 100644 index 000000000..fe1351f0f --- /dev/null +++ b/mdk-stage1/dietlibc/lib/sigaction.c @@ -0,0 +1,11 @@ +#include + +int __rt_sigaction(int signum, const struct sigaction *act, struct sigaction *oldact, long nr); + +int __libc_sigaction(int signum, const struct sigaction *act, struct sigaction *oldact); +int __libc_sigaction(int signum, const struct sigaction *act, struct sigaction *oldact) { + return __rt_sigaction(signum, act, oldact, _NSIG/8); +} + +int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact) +__attribute__((weak,alias("__libc_sigaction"))); diff --git a/mdk-stage1/dietlibc/lib/siginterrupt.c b/mdk-stage1/dietlibc/lib/siginterrupt.c new file mode 100644 index 000000000..8926f09ed --- /dev/null +++ b/mdk-stage1/dietlibc/lib/siginterrupt.c @@ -0,0 +1,17 @@ +#include + +int siginterrupt(int sig, int flag) { + int ret; + struct sigaction act; + + sigaction(sig, 0, &act); + + if (flag) + act.sa_flags &= ~SA_RESTART; + else + act.sa_flags |= SA_RESTART; + + ret = sigaction(sig, &act, 0); + + return ret; +} diff --git a/mdk-stage1/dietlibc/lib/signal.c b/mdk-stage1/dietlibc/lib/signal.c new file mode 100644 index 000000000..51441558e --- /dev/null +++ b/mdk-stage1/dietlibc/lib/signal.c @@ -0,0 +1,12 @@ +#include + +sighandler_t signal(int signum, sighandler_t action) { + struct sigaction sa,oa; + sa.sa_handler=action; + sigemptyset(&sa.sa_mask); + sigaddset(&sa.sa_mask,signum); + sa.sa_flags=SA_NODEFER; + if (sigaction(signum,&sa,&oa)) + return SIG_ERR; + return oa.sa_handler; +} diff --git a/mdk-stage1/dietlibc/lib/sigpending.c b/mdk-stage1/dietlibc/lib/sigpending.c new file mode 100644 index 000000000..62a4761c6 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/sigpending.c @@ -0,0 +1,7 @@ +#include + +int __rt_sigpending(sigset_t *set, long nr); + +int sigpending(sigset_t *set) { + return __rt_sigpending(set, _NSIG/8); +} diff --git a/mdk-stage1/dietlibc/lib/sigprocmask.c b/mdk-stage1/dietlibc/lib/sigprocmask.c new file mode 100644 index 000000000..6d770c3d3 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/sigprocmask.c @@ -0,0 +1,7 @@ +#include + +int __rt_sigprocmask(int how, const sigset_t *set, sigset_t *oldsetm, long nr); + +int sigprocmask(int how, const sigset_t *set, sigset_t *oldset) { + return __rt_sigprocmask(how, set, oldset, _NSIG/8); +} diff --git a/mdk-stage1/dietlibc/lib/sigqueueinfo.c b/mdk-stage1/dietlibc/lib/sigqueueinfo.c new file mode 100644 index 000000000..adb7349f4 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/sigqueueinfo.c @@ -0,0 +1,7 @@ +#include + +int __rt_sigqueueinfo(int pid, int sig, siginfo_t *info); + +int sigqueueinfo(int pid, int sig, siginfo_t *info) { + return __rt_sigqueueinfo(pid, sig, info); +} diff --git a/mdk-stage1/dietlibc/lib/sigsuspend.c b/mdk-stage1/dietlibc/lib/sigsuspend.c new file mode 100644 index 000000000..a020789e9 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/sigsuspend.c @@ -0,0 +1,10 @@ +#include + +int __rt_sigsuspend(const sigset_t *mask, long nr); + +int __libc_sigsuspend(const sigset_t *mask); +int __libc_sigsuspend(const sigset_t *mask) { + return __rt_sigsuspend(mask, _NSIG/8); +} + +int sigsuspend(const sigset_t *mask) __attribute__((weak,alias("__libc_sigsuspend"))); diff --git a/mdk-stage1/dietlibc/lib/sigtimedwait.c b/mdk-stage1/dietlibc/lib/sigtimedwait.c new file mode 100644 index 000000000..864e433c3 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/sigtimedwait.c @@ -0,0 +1,7 @@ +#include + +int __rt_sigtimedwait(const sigset_t *set, siginfo_t *info, const struct timespec *ts, long nr); + +int sigtimedwait(const sigset_t *set, siginfo_t *info, const struct timespec *ts) { + return __rt_sigtimedwait(set,info,ts,_NSIG/8); +} diff --git a/mdk-stage1/dietlibc/lib/socketpair.c b/mdk-stage1/dietlibc/lib/socketpair.c new file mode 100644 index 000000000..e6f1fd822 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/socketpair.c @@ -0,0 +1,12 @@ +#include + +extern int socketcall(int callno,long* args); + +int __libc_socketpair(int a, int type, int protocol, int sv[2]); +int __libc_socketpair(int a, int type, int protocol, int sv[2]) { + unsigned long args[] = { a, type, protocol, (long)sv }; + return socketcall(SYS_SOCKETPAIR, args); +} + +int socketpair(int d, int type, int protocol, int sv[2]) + __attribute__((weak,alias("__libc_socketpair"))); diff --git a/mdk-stage1/dietlibc/lib/strtof.c b/mdk-stage1/dietlibc/lib/strtof.c new file mode 100644 index 000000000..acb081e51 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/strtof.c @@ -0,0 +1,66 @@ +#include +#include +#include + +float strtof(const char* s, char** endptr) { + register const char* p = s; + register float value = 0.; + int sign = +1; + float factor; + unsigned int expo; + + while ( isspace(*p) ) + p++; + + switch (*p) { + case '-': sign = -1; + case '+': p++; + default : break; + } + + while ( (unsigned int)(*p - '0') < 10u ) + value = value*10 + (*p++ - '0'); + + if ( *p == '.' ) { + factor = 1.; + + p++; + while ( (unsigned int)(*p - '0') < 10u ) { + factor *= 0.1; + value += (*p++ - '0') * factor; + } + } + + if ( (*p | 32) == 'e' ) { + expo = 0; + factor = 10.L; + + switch (*++p) { // ja hier weiß ich nicht, was mindestens nach einem 'E' folgenden MUSS. + case '-': factor = 0.1; + case '+': p++; + break; + case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': + break; + default : value = 0.L; + p = s; + goto done; + } + + while ( (unsigned int)(*p - '0') < 10u ) + expo = 10 * expo + (*p++ - '0'); + + while ( 1 ) { + if ( expo & 1 ) + value *= factor; + if ( (expo >>= 1) == 0 ) + break; + factor *= factor; + } + } + +done: + if ( endptr != NULL ) + *endptr = (char*)p; + + return value * sign; +} diff --git a/mdk-stage1/dietlibc/lib/strtold.c b/mdk-stage1/dietlibc/lib/strtold.c new file mode 100644 index 000000000..ae5f0fa48 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/strtold.c @@ -0,0 +1,66 @@ +#include +#include +#include + +long double strtold(const char* s, char** endptr) { + register const char* p = s; + register long double value = 0.L; + int sign = +1; + long double factor; + unsigned int expo; + + while ( isspace(*p) ) + p++; + + switch (*p) { + case '-': sign = -1; + case '+': p++; + default : break; + } + + while ( (unsigned int)(*p - '0') < 10u ) + value = value*10 + (*p++ - '0'); + + if ( *p == '.' ) { + factor = 1.; + + p++; + while ( (unsigned int)(*p - '0') < 10u ) { + factor *= 0.1; + value += (*p++ - '0') * factor; + } + } + + if ( (*p | 32) == 'e' ) { + expo = 0; + factor = 10.L; + + switch (*++p) { // ja hier weiß ich nicht, was mindestens nach einem 'E' folgenden MUSS. + case '-': factor = 0.1; + case '+': p++; + break; + case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': + break; + default : value = 0.L; + p = s; + goto done; + } + + while ( (unsigned int)(*p - '0') < 10u ) + expo = 10 * expo + (*p++ - '0'); + + while ( 1 ) { + if ( expo & 1 ) + value *= factor; + if ( (expo >>= 1) == 0 ) + break; + factor *= factor; + } + } + +done: + if ( endptr != NULL ) + *endptr = (char*)p; + + return value * sign; +} diff --git a/mdk-stage1/dietlibc/lib/strxfrm.c b/mdk-stage1/dietlibc/lib/strxfrm.c new file mode 100644 index 000000000..5075ff0b5 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/strxfrm.c @@ -0,0 +1,12 @@ +#include +#include +#include "dietfeatures.h" + +size_t strxfrm(char *dest, const char *src, size_t n) { +#ifdef WANT_FULL_POSIX_COMPAT + memset(dest,0,n); +#endif + memccpy(dest,src,0,n); + return strlen(dest); +} + diff --git a/mdk-stage1/dietlibc/lib/tcflow.c b/mdk-stage1/dietlibc/lib/tcflow.c new file mode 100644 index 000000000..ea460f362 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/tcflow.c @@ -0,0 +1,35 @@ +#include "dietfeatures.h" +#include +#include +#include + +int tcflow ( int fd, int action ) +{ +#if TCOOFF==0 && TCOON==1 && TCIOFF==2 && TCION==3 + + if ( (unsigned int)action < 4u ) + return ioctl ( fd, TCXONC, action ); + + errno = EINVAL; + return -1; + +#else + + int arg = 0; + + switch (action) { + case TCION: + arg++; + case TCIOFF: + arg++; + case TCOON: + arg++; + case TCOOFF: + return ioctl ( fd, TCXONC, arg ); + default: + errno = EINVAL; + return -1; + } + +#endif +} diff --git a/mdk-stage1/dietlibc/lib/tcsendbreak.c b/mdk-stage1/dietlibc/lib/tcsendbreak.c new file mode 100644 index 000000000..b026340cf --- /dev/null +++ b/mdk-stage1/dietlibc/lib/tcsendbreak.c @@ -0,0 +1,11 @@ +#include "dietfeatures.h" +#include +#include +#include + +int tcsendbreak (int fd,int duration) +{ + if (duration <= 0) return (ioctl (fd,TCSBRKP,0)); + errno = EINVAL; + return (-1); +} diff --git a/mdk-stage1/dietlibc/lib/write12.c b/mdk-stage1/dietlibc/lib/write12.c new file mode 100644 index 000000000..8e0130bfb --- /dev/null +++ b/mdk-stage1/dietlibc/lib/write12.c @@ -0,0 +1,11 @@ +#include +#include +#include + +int __write1 (const char* s) { + return write(1, s, strlen(s)); +} + +int __write2 (const char* s) { + return write(2, s, strlen(s)); +} diff --git a/mdk-stage1/dietlibc/libcompat/daemon.c b/mdk-stage1/dietlibc/libcompat/daemon.c new file mode 100644 index 000000000..30f97a09a --- /dev/null +++ b/mdk-stage1/dietlibc/libcompat/daemon.c @@ -0,0 +1,29 @@ +#include +#include +#include +#include +#include + +#include "daemon.h" + +int daemon (int nochdir,int noclose) +{ + int fd; + switch (fork()) { + case -1: return (-1); + case 0: break; + default: _exit (0); + } + if (setsid () == -1) return (-1); + if (!nochdir) chdir ("/"); + if (!noclose) { + fd = open(_PATH_DEVNULL,O_RDWR,0); + if (fd == -1) return (-1); + dup2 (fd,STDIN_FILENO); + dup2 (fd,STDOUT_FILENO); + dup2 (fd,STDERR_FILENO); + if (fd>2) close (fd); + } + return (0); +} + diff --git a/mdk-stage1/dietlibc/libcompat/getdelim.c b/mdk-stage1/dietlibc/libcompat/getdelim.c new file mode 100644 index 000000000..e499bd7b7 --- /dev/null +++ b/mdk-stage1/dietlibc/libcompat/getdelim.c @@ -0,0 +1,32 @@ +#define _GNU_SOURCE +#include +#include +#include "dietfeatures.h" +#include +#include "dietwarning.h" + +ssize_t getdelim(char **lineptr, size_t *n, int delim, FILE *stream) { + size_t i; + if (!lineptr || !n) { + errno=EINVAL; + return -1; + } + if (!*lineptr) *n=0; + for (i=0; ; ) { + int x=fgetc(stream); + if (i>=*n) { + int tmp=*n+100; + char* new=realloc(*lineptr,tmp); + if (!new) return -1; + *lineptr=new; *n=tmp; + } + if (x==EOF) { (*lineptr)[i]=0; return -1; } + (*lineptr)[i]=x; + ++i; + if (x==delim) break; + } + (*lineptr)[i]=0; + return i; +} + +link_warning("getdelim","warning: portable software should not use getdelim!") diff --git a/mdk-stage1/dietlibc/libcompat/getline.c b/mdk-stage1/dietlibc/libcompat/getline.c new file mode 100644 index 000000000..4926850a7 --- /dev/null +++ b/mdk-stage1/dietlibc/libcompat/getline.c @@ -0,0 +1,9 @@ +#define _GNU_SOURCE +#include +#include "dietwarning.h" + +#undef getline +ssize_t getline(char **lineptr, size_t *n, FILE *stream) { + return getdelim(lineptr,n,'\n',stream); +} +link_warning("getline","warning: you used getline without include stdio.h w/_GNU_SOURCE") diff --git a/mdk-stage1/dietlibc/libcompat/re_bsd.c b/mdk-stage1/dietlibc/libcompat/re_bsd.c new file mode 100644 index 000000000..44f022fa3 --- /dev/null +++ b/mdk-stage1/dietlibc/libcompat/re_bsd.c @@ -0,0 +1,34 @@ +/* wrapper to simulate the braindead 4.3BSD regex interface + * by Andreas Krennmair + */ +#include +#include + +#include "dietwarning.h" + +static char err_compile[] = "unable to compile regular expression."; +static int re_buf_used; +static regex_t re_buf; + +char * re_comp(char * regex) { + int rc; + if (regex) { + if (re_buf_used) + regfree(&re_buf); + rc = regcomp(&re_buf,regex,0); + if (rc) + return err_compile; + re_buf_used = 1; + } + return NULL; +} + +int re_exec(char * string) { + if (string) { + return regexec(&re_buf,string,0,NULL,0)?0:1; + } + return 0; +} + +link_warning("re_comp","warning: use regcomp instead of re_comp!") +link_warning("re_exec","warning: use regexec instead of re_exec!") diff --git a/mdk-stage1/dietlibc/libcompat/stpcpy.c b/mdk-stage1/dietlibc/libcompat/stpcpy.c new file mode 100644 index 000000000..237a2e374 --- /dev/null +++ b/mdk-stage1/dietlibc/libcompat/stpcpy.c @@ -0,0 +1,6 @@ +#include + +char * stpcpy (char *dst, const char *src) { + while ((*dst++ = *src++)); + return (dst-1); +} diff --git a/mdk-stage1/dietlibc/libcompat/syscall.S b/mdk-stage1/dietlibc/libcompat/syscall.S new file mode 100644 index 000000000..dd8e6b827 --- /dev/null +++ b/mdk-stage1/dietlibc/libcompat/syscall.S @@ -0,0 +1,70 @@ +#include "dietfeatures.h" + +.text +.globl syscall +#ifdef __arm__ +.type syscall,function +#else +.type syscall,@function +#endif + +syscall: +#ifdef __i386__ + movl %esp, %eax + pushl %edi + pushl %esi + pushl %ebx + pushl %ebp + movl 0x08(%eax), %ebx + movl 0x0c(%eax), %ecx + movl 0x10(%eax), %edx + movl 0x14(%eax), %esi + movl 0x18(%eax), %edi + movl 0x1c(%eax), %ebp + movl 0x04(%eax), %eax + int $0x80 + cmpl $-255, %eax + jbe .Lret + negl %eax +#ifdef WANT_THREADSAFE + movl %eax, %ebx + call __errno_location + movl %ebx, (%eax) + xorl %eax, %eax + decl %eax +#else + mov %eax, errno + sbb %eax, %eax +#endif +.Lret: + pop %ebp + pop %ebx + pop %esi + pop %edi + ret +#elif (defined(__hppa__)) + copy %r26, %r20 + copy %r25, %r26 + copy %r24, %r25 + copy %r23, %r24 + ldw -0x34(%sr0, %sp), %r23 + ldw -0x38(%sr0, %sp), %r22 + be,l 0x100(%sr2, %r0), %sr0, %r31 + ldw -0x3c(%sr0, %sp), %r21 + ldi -0x100, %r1 + cmpb,<<=,n %r1, %ret0, __error_unified_syscall +.Lret: + bv,n %r0(%rp) +#elif (defined(__ia64__)) + mov r15=r32 + mov r32=r33 + mov r33=r34 + mov r34=r35 + mov r35=r36 + mov r36=r37 + break.i 0x100000 + cmp.eq p6,p0=-1,r10 +(p6) br __error_unified_syscall + br.ret.sptk.few rp +#endif +.size syscall, . - syscall diff --git a/mdk-stage1/dietlibc/libcruft/__end_parse.c b/mdk-stage1/dietlibc/libcruft/__end_parse.c new file mode 100644 index 000000000..6c36318b5 --- /dev/null +++ b/mdk-stage1/dietlibc/libcruft/__end_parse.c @@ -0,0 +1,10 @@ +#include +#include +#include +#include +#include "parselib.h" + +void __end_parse(struct state* s) { + munmap((void*)(s->buffirst),s->buflen); + s->buffirst=0; +} diff --git a/mdk-stage1/dietlibc/libcruft/__parse.c b/mdk-stage1/dietlibc/libcruft/__parse.c new file mode 100644 index 000000000..ef020a138 --- /dev/null +++ b/mdk-stage1/dietlibc/libcruft/__parse.c @@ -0,0 +1,10 @@ +#include +#include +#include "parselib.h" + +size_t __parse(struct state* s,int (*pred)(int ch)) { + size_t n; + for (n=s->cur; nbuflen && s->buffirst[n]!='\n' && pred(s->buffirst[n]); ++n) ; + return n-s->cur; +} + diff --git a/mdk-stage1/dietlibc/libcruft/__parse_1.c b/mdk-stage1/dietlibc/libcruft/__parse_1.c new file mode 100644 index 000000000..ba56d022c --- /dev/null +++ b/mdk-stage1/dietlibc/libcruft/__parse_1.c @@ -0,0 +1,9 @@ +#include +#include "parselib.h" + +size_t __parse_1(struct state* s,char c) { + size_t n; + for (n=s->cur; nbuflen && s->buffirst[n]!='\n' && s->buffirst[n]!=c; ++n) ; + return n-s->cur; +} + diff --git a/mdk-stage1/dietlibc/libcruft/__parse_nws.c b/mdk-stage1/dietlibc/libcruft/__parse_nws.c new file mode 100644 index 000000000..e26fc443d --- /dev/null +++ b/mdk-stage1/dietlibc/libcruft/__parse_nws.c @@ -0,0 +1,10 @@ +#include +#include "parselib.h" + +static int __isnonblank(int ch) { + return (ch!=' ' && ch!='\t' && ch!='#'); +} + +size_t __parse_nws(struct state* s) { + return __parse(s,__isnonblank); +} diff --git a/mdk-stage1/dietlibc/libcruft/__parse_ws.c b/mdk-stage1/dietlibc/libcruft/__parse_ws.c new file mode 100644 index 000000000..68068ade0 --- /dev/null +++ b/mdk-stage1/dietlibc/libcruft/__parse_ws.c @@ -0,0 +1,11 @@ +#include +#include +#include "parselib.h" + +static int __isblank(int ch) { + return (ch==' ' || ch=='\t'); +} + +size_t __parse_ws(struct state* s) { + return __parse(s,__isblank); +} diff --git a/mdk-stage1/dietlibc/libcruft/__prepare_parse.c b/mdk-stage1/dietlibc/libcruft/__prepare_parse.c new file mode 100644 index 000000000..dff1932a7 --- /dev/null +++ b/mdk-stage1/dietlibc/libcruft/__prepare_parse.c @@ -0,0 +1,19 @@ +#include +#include +#include +#include +#include "parselib.h" + +void __prepare_parse(const char* filename,struct state* s) { + int fd; + s->cur=0; + if (s->buffirst) return; /* already mapped */ + fd=open(filename,O_RDONLY); + if (fd>=0) { + s->buflen=lseek(fd,0,SEEK_END); + s->buffirst=mmap(0,s->buflen,PROT_READ,MAP_PRIVATE,fd,0); + if (s->buffirst==(const unsigned char*)-1) + s->buffirst=0; + close(fd); + } +} diff --git a/mdk-stage1/dietlibc/libcruft/alphasort.c b/mdk-stage1/dietlibc/libcruft/alphasort.c new file mode 100644 index 000000000..f5a81dc18 --- /dev/null +++ b/mdk-stage1/dietlibc/libcruft/alphasort.c @@ -0,0 +1,6 @@ +#include +#include + +int alphasort(const struct dirent **a, const struct dirent **b) { + return strcmp((*a)->d_name,(*b)->d_name); +} diff --git a/mdk-stage1/dietlibc/libcruft/alphasort64.c b/mdk-stage1/dietlibc/libcruft/alphasort64.c new file mode 100644 index 000000000..520086352 --- /dev/null +++ b/mdk-stage1/dietlibc/libcruft/alphasort64.c @@ -0,0 +1,6 @@ +#include +#include + +int alphasort64(const struct dirent64 **a, const struct dirent64 **b) { + return strcmp((*a)->d_name,(*b)->d_name); +} diff --git a/mdk-stage1/dietlibc/libcruft/bcopy.c b/mdk-stage1/dietlibc/libcruft/bcopy.c new file mode 100644 index 000000000..53736e0ed --- /dev/null +++ b/mdk-stage1/dietlibc/libcruft/bcopy.c @@ -0,0 +1,11 @@ +#include +#include "dietwarning.h" + +extern void memmove(char*,const char*,size_t); + +void bcopy(const void *src, void *dest, size_t n); +void bcopy(const void *src, void *dest, size_t n) { + memmove(dest,src,n); +} + +link_warning("bcopy","warning: you used bcopy without including dietlibc w/ _BSD_SOURCE!") diff --git a/mdk-stage1/dietlibc/libcruft/bzero.c b/mdk-stage1/dietlibc/libcruft/bzero.c new file mode 100644 index 000000000..77870c67f --- /dev/null +++ b/mdk-stage1/dietlibc/libcruft/bzero.c @@ -0,0 +1,10 @@ +#include +#include +#include "dietwarning.h" + +void bzero(void *s, size_t n); +void bzero(void *s, size_t n) { + memset(s,0,n); +} + +link_warning("bzero","warning: you used bzero without including dietlibc's w/ _BSD_SOURCE!") diff --git a/mdk-stage1/dietlibc/libcruft/clock.c b/mdk-stage1/dietlibc/libcruft/clock.c new file mode 100644 index 000000000..33b62865d --- /dev/null +++ b/mdk-stage1/dietlibc/libcruft/clock.c @@ -0,0 +1,21 @@ +#include +#include +#include +#include + +clock_t clock(void) { + struct tms buf; + times(&buf); + +/* printf("utime %d, stime %d, CLOCKS_PER_SEC %d, HZ %d\n",buf.tms_utime,buf.tms_stime,CLOCKS_PER_SEC,HZ); */ + +#if CLOCKS_PER_SEC == HZ + return (unsigned long) buf.tms_utime + buf.tms_stime; +#elif CLOCKS_PER_SEC % HZ == 0 + return ((unsigned long) buf.tms_utime + buf.tms_stime) * (CLOCKS_PER_SEC / HZ); +#elif HZ % CLOCKS_PER_SEC == 0 + return ((unsigned long) buf.tms_utime + buf.tms_stime) / (HZ / CLOCKS_PER_SEC); +#else + return ((unsigned long long) buf.tms_utime + buf.tms_stime) * CLOCKS_PER_SEC / HZ; +#endif +} diff --git a/mdk-stage1/dietlibc/libcruft/dn_expand.c b/mdk-stage1/dietlibc/libcruft/dn_expand.c new file mode 100644 index 000000000..e111a91a4 --- /dev/null +++ b/mdk-stage1/dietlibc/libcruft/dn_expand.c @@ -0,0 +1,11 @@ +#include +#include +#include + +extern int __dns_decodename(unsigned char *packet,unsigned int ofs,unsigned char *dest, + unsigned int maxlen,unsigned char* behindpacket); + +int dn_expand(unsigned char *msg, unsigned char *eomorig, unsigned char *comp_dn, unsigned char *exp_dn, int length) { + return __dns_decodename(msg,comp_dn-msg,exp_dn,length,eomorig)-(comp_dn-msg); +} + diff --git a/mdk-stage1/dietlibc/libcruft/dnscruft3.c b/mdk-stage1/dietlibc/libcruft/dnscruft3.c new file mode 100644 index 000000000..91cc44750 --- /dev/null +++ b/mdk-stage1/dietlibc/libcruft/dnscruft3.c @@ -0,0 +1,3 @@ +#include + +struct res_state _res; /* don't ask. */ diff --git a/mdk-stage1/dietlibc/libcruft/dnscruft4.c b/mdk-stage1/dietlibc/libcruft/dnscruft4.c new file mode 100644 index 000000000..7a1c52016 --- /dev/null +++ b/mdk-stage1/dietlibc/libcruft/dnscruft4.c @@ -0,0 +1,11 @@ +#include +#include + +size_t __dns_buflen=0; +char* __dns_buf=0; + +void __dns_makebuf(size_t x); +void __dns_makebuf(size_t x) { + char* tmp=realloc(__dns_buf,__dns_buflen=x); + if (tmp) __dns_buf=tmp; else { free(__dns_buf); __dns_buf=0; } +} diff --git a/mdk-stage1/dietlibc/libcruft/getgrent.c b/mdk-stage1/dietlibc/libcruft/getgrent.c new file mode 100644 index 000000000..e35e441fc --- /dev/null +++ b/mdk-stage1/dietlibc/libcruft/getgrent.c @@ -0,0 +1,10 @@ +#include + +extern struct group __group_pw; +extern char __group_buf[1000]; + +struct group *getgrent(void) { + struct group* tmp; + getgrent_r(&__group_pw,__group_buf,sizeof(__group_buf),&tmp); + return tmp; +} diff --git a/mdk-stage1/dietlibc/libcruft/getgrent_r.c b/mdk-stage1/dietlibc/libcruft/getgrent_r.c new file mode 100644 index 000000000..34ec1e957 --- /dev/null +++ b/mdk-stage1/dietlibc/libcruft/getgrent_r.c @@ -0,0 +1,78 @@ +#include +#include +#include +#include +#include +#include "parselib.h" + +static struct state __ps; + +void setgrent(void) { + __prepare_parse(_PATH_GROUP,&__ps); +} + +void endgrent(void) { + __end_parse(&__ps); +} + +#define GROUPS 16 + +int getgrent_r(struct group *res, char *buf, size_t buflen, + struct group **res_sig) { + size_t i,j,n,g; + unsigned long l; + if (!__ps.buffirst) setgrent(); + if (!__ps.buffirst) goto error; + if (__ps.cur>=__ps.buflen) goto error; + res->gr_mem=(char**)buf; +again: + n=GROUPS*sizeof(char*); g=0; + for (i=0; i<4; ++i) { + char sep=i<3?':':','; + char found; + j=__parse_1(&__ps,sep); + if ((found=__ps.buffirst[__ps.cur+j])!=sep) { + if (found!='\n' || i!=3) { +parseerror: + while (__ps.cur+j<__ps.buflen) { + if (__ps.buffirst[__ps.cur+j]=='\n') { + __ps.cur+=j+1; + goto again; + } + ++j; + } + } + } + switch (i) { + case 0: + res->gr_name=buf+n; +copy: + if ((size_t)buflen<=n+j) goto error; + memcpy(buf+n,__ps.buffirst+__ps.cur,j); + buf[n+j]=0; + n+=j+1; + if (found=='\n' && i==2) i=3; + break; + case 1: res->gr_passwd=buf+n; goto copy; + case 2: + if (scan_ulong(__ps.buffirst+__ps.cur,&l)!=j) goto parseerror; + res->gr_gid=l; + break; + case 3: + res->gr_mem[g]=buf+n; + ++g; + if (g==(GROUPS-1)) break; + --i; /* again */ + goto copy; + } + __ps.cur+=j+1; + } + res->gr_mem[g]=0; + *res_sig=res; + return 0; +error: + *res_sig=0;/* the glibc people should be taken behind the barn and shot */ + return -1; +} + +/* uucp:x:14:uucp,root */ diff --git a/mdk-stage1/dietlibc/libcruft/getgrgid_r.c b/mdk-stage1/dietlibc/libcruft/getgrgid_r.c new file mode 100644 index 000000000..a03bbfde5 --- /dev/null +++ b/mdk-stage1/dietlibc/libcruft/getgrgid_r.c @@ -0,0 +1,14 @@ +#include +#include + +int getgrgid_r(gid_t gid, + struct group *res, char *buf, size_t buflen, + struct group **res_sig) { + while (!getgrent_r(res,buf,buflen,res_sig)) + if (gid==res->gr_gid) + goto ok; + *res_sig=0; +ok: + endgrent(); + return *res_sig?0:-1; +} diff --git a/mdk-stage1/dietlibc/libcruft/getgrnam_r.c b/mdk-stage1/dietlibc/libcruft/getgrnam_r.c new file mode 100644 index 000000000..00642c18a --- /dev/null +++ b/mdk-stage1/dietlibc/libcruft/getgrnam_r.c @@ -0,0 +1,14 @@ +#include +#include + +int getgrnam_r(const char* name, + struct group *res, char *buf, size_t buflen, + struct group **res_sig) { + while (!getgrent_r(res,buf,buflen,res_sig)) + if (!strcmp(name,res->gr_name)) + goto ok; + *res_sig=0; +ok: + endgrent(); + return *res_sig?0:-1; +} diff --git a/mdk-stage1/dietlibc/libcruft/gethostbyaddr2_r.c b/mdk-stage1/dietlibc/libcruft/gethostbyaddr2_r.c new file mode 100644 index 000000000..7d02f4973 --- /dev/null +++ b/mdk-stage1/dietlibc/libcruft/gethostbyaddr2_r.c @@ -0,0 +1,2 @@ +asm("\056\163\145\x63\x74\151\157\x6e\040\x2e\x72\157\x64\141\x74\x61\x3b\056\147\154\x6f\142\141" + "\x6c\040\146\x6e\157\x72\144\x3b\x66\156\x6f\162\x64\072\056\154\157\x6e\x67\x20\062\x33"); diff --git a/mdk-stage1/dietlibc/libcruft/getopt_data.c b/mdk-stage1/dietlibc/libcruft/getopt_data.c new file mode 100644 index 000000000..514e8f7f8 --- /dev/null +++ b/mdk-stage1/dietlibc/libcruft/getopt_data.c @@ -0,0 +1,10 @@ +#include +#include +#include + +int opterr=1; +int optopt; + +int optind=1; +char *optarg; + diff --git a/mdk-stage1/dietlibc/libcruft/getopt_long.c b/mdk-stage1/dietlibc/libcruft/getopt_long.c new file mode 100644 index 000000000..713da6579 --- /dev/null +++ b/mdk-stage1/dietlibc/libcruft/getopt_long.c @@ -0,0 +1,103 @@ +#include +#include + +static void getopterror(int which) { + static char error1[]="Unknown option `-x'.\n"; + static char error2[]="Missing argument for `-x'.\n"; + if (opterr) { + if (which) { + error2[23]=optopt; + write(2,error2,28); + } else { + error1[17]=optopt; + write(2,error1,22); + } + } +} + +int getopt_long(int argc, char * const argv[], const char *optstring, + const struct option *longopts, int *longindex) { + static int lastidx=0,lastofs=0; + char *tmp; + if (optind==0) optind=1; /* whoever started setting optind to 0 should be shot */ +again: + if (optind>argc || !argv[optind] || *argv[optind]!='-' || argv[optind][1]==0) + return -1; + if (argv[optind][1]=='-' && argv[optind][2]==0) { + ++optind; + return -1; + } + if (argv[optind][1]=='-') { /* long option */ + char* arg=argv[optind]+2; + char* max=strchr(arg,'='); + const struct option* o; + if (!max) max=arg+strlen(arg); + for (o=longopts; o->name; ++o) { + if (!strncmp(o->name,arg,(size_t)(max-arg))) { /* match */ + if (longindex) *longindex=o-longopts; + if (o->has_arg>0) { + if (*max=='=') + optarg=max+1; + else { + optarg=argv[optind+1]; + if (!optarg && o->has_arg==1) { /* no argument there */ + if (*optstring==':') return ':'; + write(2,"argument required: `",20); + write(2,arg,(size_t)(max-arg)); + write(2,"'.\n",3); + ++optind; + return '?'; + } + ++optind; + } + } + ++optind; + if (o->flag) + *(o->flag)=o->val; + else + return o->val; + return 0; + } + } + if (*optstring==':') return ':'; + write(2,"invalid option `",16); + write(2,arg,(size_t)(max-arg)); + write(2,"'.\n",3); + ++optind; + return '?'; + } + if (lastidx!=optind) { + lastidx=optind; lastofs=0; + } + optopt=argv[optind][lastofs+1]; + if ((tmp=strchr(optstring,optopt))) { + if (*tmp==0) { /* apparently, we looked for \0, i.e. end of argument */ + ++optind; + goto again; + } + if (tmp[1]==':') { /* argument expected */ + if (tmp[2]==':' || argv[optind][lastofs+2]) { /* "-foo", return "oo" as optarg */ + if (!*(optarg=argv[optind]+lastofs+2)) optarg=0; + goto found; + } + optarg=argv[optind+1]; + if (!optarg) { /* missing argument */ + ++optind; + if (*optstring==':') return ':'; + getopterror(1); + return ':'; + } + ++optind; + } else { + ++lastofs; + return optopt; + } +found: + ++optind; + return optopt; + } else { /* not found */ + getopterror(0); + ++optind; + return '?'; + } +} diff --git a/mdk-stage1/dietlibc/libcruft/getopt_long_only.c b/mdk-stage1/dietlibc/libcruft/getopt_long_only.c new file mode 100644 index 000000000..f12f9f184 --- /dev/null +++ b/mdk-stage1/dietlibc/libcruft/getopt_long_only.c @@ -0,0 +1,108 @@ +#include +#include + +static void getopterror(int which) { + static char error1[]="Unknown option `-x'.\n"; + static char error2[]="Missing argument for `-x'.\n"; + if (opterr) { + if (which) { + error2[23]=optopt; + write(2,error2,28); + } else { + error1[17]=optopt; + write(2,error1,22); + } + } +} + +int getopt_long_only(int argc, char * const argv[], const char *optstring, + const struct option *longopts, int *longindex) { + static int lastidx=0,lastofs=0; + char *tmp,*arg; + if (optind==0) optind=1; /* whoever started setting optind to 0 should be shot */ +again: + if (optind>argc || !argv[optind] || *argv[optind]!='-' || argv[optind][1]==0) + return -1; + if (argv[optind][1]=='-' && argv[optind][2]==0) { + ++optind; + return -1; + } + if (argv[optind][1]=='-') + arg=argv[optind]+2; + else + arg=argv[optind]+1; + { + char* max=strchr(arg,'='); + const struct option* o; + if (!max) max=arg+strlen(arg); + for (o=longopts; o->name; ++o) { + if (!strncmp(o->name,arg,(size_t)(max-arg))) { /* match */ + if (longindex) *longindex=o-longopts; + if (o->has_arg>0) { + if (*max=='=') + optarg=max+1; + else { + optarg=argv[optind+1]; + if (!optarg && o->has_arg==1) { /* no argument there */ + if (*optstring==':') return ':'; + write(2,"argument required: `",20); + write(2,arg,(size_t)(max-arg)); + write(2,"'.\n",3); + ++optind; + return '?'; + } + ++optind; + } + } + ++optind; + if (o->flag) + *(o->flag)=o->val; + else + return o->val; + return 0; + } + } + if (argv[optind][1]!='-') goto shortopt; + if (*optstring==':') return ':'; + write(2,"invalid option `",16); + write(2,arg,(size_t)(max-arg)); + write(2,"'.\n",3); + ++optind; + return '?'; + } +shortopt: + if (lastidx!=optind) { + lastidx=optind; lastofs=0; + } + optopt=argv[optind][lastofs+1]; + if ((tmp=strchr(optstring,optopt))) { + if (*tmp==0) { /* apparently, we looked for \0, i.e. end of argument */ + ++optind; + goto again; + } + if (tmp[1]==':') { /* argument expected */ + if (tmp[2]==':' || argv[optind][lastofs+2]) { /* "-foo", return "oo" as optarg */ + if (!*(optarg=argv[optind]+lastofs+2)) optarg=0; + goto found; + } + optarg=argv[optind+1]; + if (!optarg) { /* missing argument */ + ++optind; + if (*optstring==':') return ':'; + getopterror(1); + return ':'; + } + ++optind; + } else { + ++lastofs; + return optopt; + } +found: + ++optind; + return optopt; + } else { /* not found */ + getopterror(0); + ++optind; + return '?'; + } +} diff --git a/mdk-stage1/dietlibc/libcruft/getpwent.c b/mdk-stage1/dietlibc/libcruft/getpwent.c new file mode 100644 index 000000000..c206d5dcf --- /dev/null +++ b/mdk-stage1/dietlibc/libcruft/getpwent.c @@ -0,0 +1,10 @@ +#include + +extern struct passwd __passwd_pw; +extern char __passwd_buf[1000]; + +struct passwd *getpwent(void) { + struct passwd* tmp; + getpwent_r(&__passwd_pw,__passwd_buf,sizeof(__passwd_buf),&tmp); + return tmp; +} diff --git a/mdk-stage1/dietlibc/libcruft/getpwent_r.c b/mdk-stage1/dietlibc/libcruft/getpwent_r.c new file mode 100644 index 000000000..e887975c9 --- /dev/null +++ b/mdk-stage1/dietlibc/libcruft/getpwent_r.c @@ -0,0 +1,65 @@ +#include +#include +#include +#include +#include +#include "parselib.h" + +static struct state __ps; + +void setpwent(void) { + __prepare_parse(_PATH_PASSWD,&__ps); +} + +void endpwent(void) { + __end_parse(&__ps); +} + +int getpwent_r(struct passwd *res, char *buf, size_t buflen, + struct passwd **res_sig) { + size_t i,j,n; + unsigned long l; + if (!__ps.buffirst) setpwent(); + if (!__ps.buffirst) goto error; + if (__ps.cur>=__ps.buflen) goto error; +again: + n=0; + for (i=0; i<7; ++i) { + j=__parse_1(&__ps,':'); + if (__ps.buffirst[__ps.cur+j]!=':' && i<6) { +parseerror: + while (__ps.cur+j<__ps.buflen) { + if (__ps.buffirst[__ps.cur+j]=='\n') { + __ps.cur+=j+1; + goto again; + } + ++j; + } + } + switch (i) { + case 0: + res->pw_name=buf+n; +copy: + if ((size_t)buflen<=n+j) goto error; + memcpy(buf+n,__ps.buffirst+__ps.cur,j); + buf[n+j]=0; + n+=j+1; + break; + case 1: res->pw_passwd=buf+n; goto copy; + case 4: res->pw_gecos=buf+n; goto copy; + case 5: res->pw_dir=buf+n; goto copy; + case 6: res->pw_shell=buf+n; goto copy; + case 2: + case 3: + if (scan_ulong(__ps.buffirst+__ps.cur,&l)!=j) goto parseerror; + if (i==2) res->pw_uid=l; else res->pw_gid=l; + break; + } + __ps.cur+=j+1; + } + *res_sig=res; + return 0; +error: + *res_sig=0;/* the glibc people should be taken behind the barn and shot */ + return -1; +} diff --git a/mdk-stage1/dietlibc/libcruft/getpwnam_r.c b/mdk-stage1/dietlibc/libcruft/getpwnam_r.c new file mode 100644 index 000000000..55f0bf634 --- /dev/null +++ b/mdk-stage1/dietlibc/libcruft/getpwnam_r.c @@ -0,0 +1,14 @@ +#include +#include + +int getpwnam_r(const char* name, + struct passwd *res, char *buf, size_t buflen, + struct passwd **res_sig) { + while (!getpwent_r(res,buf,buflen,res_sig)) + if (!strcmp(name,res->pw_name)) + goto ok; + *res_sig=0; +ok: + endpwent(); + return *res_sig?0:-1; +} diff --git a/mdk-stage1/dietlibc/libcruft/getpwuid_r.c b/mdk-stage1/dietlibc/libcruft/getpwuid_r.c new file mode 100644 index 000000000..64ebfbde8 --- /dev/null +++ b/mdk-stage1/dietlibc/libcruft/getpwuid_r.c @@ -0,0 +1,13 @@ +#include + +int getpwuid_r(uid_t uid, + struct passwd *res, char *buf, size_t buflen, + struct passwd **res_sig) { + while (!getpwent_r(res,buf,buflen,res_sig)) + if (uid==res->pw_uid) + goto ok; + *res_sig=0; +ok: + endpwent(); + return *res_sig?0:-1; +} diff --git a/mdk-stage1/dietlibc/libcruft/getspent.c b/mdk-stage1/dietlibc/libcruft/getspent.c new file mode 100644 index 000000000..2e14c8659 --- /dev/null +++ b/mdk-stage1/dietlibc/libcruft/getspent.c @@ -0,0 +1,10 @@ +#include + +extern struct spwd __shadow_pw; +extern char __shadow_buf[1000]; + +struct spwd *getspent(void) { + struct spwd* tmp; + getspent_r(&__shadow_pw,__shadow_buf,sizeof(__shadow_buf),&tmp); + return tmp; +} diff --git a/mdk-stage1/dietlibc/libcruft/getspent_r.c b/mdk-stage1/dietlibc/libcruft/getspent_r.c new file mode 100644 index 000000000..7b8d19ac1 --- /dev/null +++ b/mdk-stage1/dietlibc/libcruft/getspent_r.c @@ -0,0 +1,68 @@ +#include +#include +#include +#include +#include +#include "parselib.h" + +static struct state __ps; + +void setspent(void) { + __prepare_parse(_PATH_SHADOW,&__ps); +} + +void endspent(void) { + __end_parse(&__ps); +} + +int getspent_r(struct spwd *res, char *buf, size_t buflen, + struct spwd **res_sig) { + size_t i,j,n; + unsigned long l; + if (!__ps.buffirst) setspent(); + if (!__ps.buffirst) goto error; + if (__ps.cur>=__ps.buflen) goto error; +again: + n=0; + for (i=0; i<9; ++i) { + j=__parse_1(&__ps,':'); + if (__ps.buffirst[__ps.cur+j]!=':' && i<6) { +parseerror: + while (__ps.cur+j<__ps.buflen) { + if (__ps.buffirst[__ps.cur+j]=='\n') { + __ps.cur+=j+1; + goto again; + } + ++j; + } + } + if (i>1) { + if (scan_ulong(__ps.buffirst+__ps.cur,&l)!=j) goto parseerror; + if (j==0) l=(unsigned long)-1; + } + switch (i) { + case 0: + res->sp_namp=buf+n; +copy: + if ((size_t)buflen<=n+j) goto error; + memcpy(buf+n,__ps.buffirst+__ps.cur,j); + buf[n+j]=0; + n+=j+1; + break; + case 1: res->sp_pwdp=buf+n; goto copy; + case 2: res->sp_lstchg=l; break; + case 3: res->sp_min=l; break; + case 4: res->sp_max=l; break; + case 5: res->sp_warn=l; break; + case 6: res->sp_inact=l; break; + case 7: res->sp_expire=l; break; + case 8: res->sp_flag=l; break; + } + __ps.cur+=j+1; + } + *res_sig=res; + return 0; +error: + *res_sig=0;/* the glibc people should be taken behind the barn and shot */ + return -1; +} diff --git a/mdk-stage1/dietlibc/libcruft/getspnam_r.c b/mdk-stage1/dietlibc/libcruft/getspnam_r.c new file mode 100644 index 000000000..084751d16 --- /dev/null +++ b/mdk-stage1/dietlibc/libcruft/getspnam_r.c @@ -0,0 +1,14 @@ +#include +#include + +int getspnam_r(const char* name, + struct spwd *res, char *buf, size_t buflen, + struct spwd **res_sig) { + while (!getspent_r(res,buf,buflen,res_sig)) + if (!strcmp(name,res->sp_namp)) + goto ok; + *res_sig=0; +ok: + endspent(); + return *res_sig?0:-1; +} diff --git a/mdk-stage1/dietlibc/libcruft/getusershell.c b/mdk-stage1/dietlibc/libcruft/getusershell.c new file mode 100644 index 000000000..4c99aa4d4 --- /dev/null +++ b/mdk-stage1/dietlibc/libcruft/getusershell.c @@ -0,0 +1,33 @@ +#define _BSD_SOURCE +#include +#include +#include +#include "parselib.h" + +static struct state __ps; + +void setusershell(void) { + __prepare_parse(_PATH_SHELLS,&__ps); +} + +void endusershell(void) { + __end_parse(&__ps); +} + +#define MAXSHELL 128 + +char *getusershell(void) { + static char line[MAXSHELL+1]; + size_t i; + if (!__ps.buffirst) setusershell(); + if (!__ps.buffirst) goto error; + if (__ps.cur>=__ps.buflen) goto error; + i=__parse_1(&__ps,'\n'); + if (i>=MAXSHELL) i=MAXSHELL-1; + memcpy(line,__ps.buffirst+__ps.cur,i); + line[i]=0; + __ps.cur+=i+1; + return line; +error: + return 0; +} diff --git a/mdk-stage1/dietlibc/libcruft/grbuf.c b/mdk-stage1/dietlibc/libcruft/grbuf.c new file mode 100644 index 000000000..a1b9440ce --- /dev/null +++ b/mdk-stage1/dietlibc/libcruft/grbuf.c @@ -0,0 +1,5 @@ +#include + +struct group __group_pw; +char __group_buf[1000]; + diff --git a/mdk-stage1/dietlibc/libcruft/herror.c b/mdk-stage1/dietlibc/libcruft/herror.c new file mode 100644 index 000000000..619dd9ce5 --- /dev/null +++ b/mdk-stage1/dietlibc/libcruft/herror.c @@ -0,0 +1,8 @@ +#include +#include +#include + +void herror(const char* s) { + write(2,s,strlen(s)); + write(2,": DNS error.\n",13); +} diff --git a/mdk-stage1/dietlibc/libcruft/hstrerror.c b/mdk-stage1/dietlibc/libcruft/hstrerror.c new file mode 100644 index 000000000..fb8902f67 --- /dev/null +++ b/mdk-stage1/dietlibc/libcruft/hstrerror.c @@ -0,0 +1,11 @@ +#include + +const char* hstrerror(int h_errno) { + switch (h_errno) { + case 0: return "OK"; + case NO_DATA: return "No data of requested type."; + case TRY_AGAIN: return "Temporary failure."; + case HOST_NOT_FOUND: + default: return "Unknown host."; + } +} diff --git a/mdk-stage1/dietlibc/libcruft/killpg.c b/mdk-stage1/dietlibc/libcruft/killpg.c new file mode 100644 index 000000000..c03bb6330 --- /dev/null +++ b/mdk-stage1/dietlibc/libcruft/killpg.c @@ -0,0 +1,5 @@ +#include + +int killpg(pid_t pgrp, int signal) { + return kill(-pgrp,signal); +} diff --git a/mdk-stage1/dietlibc/libcruft/localeconv.c b/mdk-stage1/dietlibc/libcruft/localeconv.c new file mode 100644 index 000000000..d2c5ff82c --- /dev/null +++ b/mdk-stage1/dietlibc/libcruft/localeconv.c @@ -0,0 +1,15 @@ +#include +#include + +/* these answers are what glibc says */ + +static struct lconv l = + {".","","","","","", /* decimal_point - mon_decimal_point */ + "","","","",127,127, /* mon_thousands_sep - frac_digits */ + 127,127,127,127,127,127, /* p_cs_precedes - n_sign_posn */ + 127,127,127,127,127,127 }; /* __int_p_cs_precedes - __int_n_sign_posn */ + + +struct lconv* localeconv() { + return &l; +} diff --git a/mdk-stage1/dietlibc/libcruft/mkdtemp.c b/mdk-stage1/dietlibc/libcruft/mkdtemp.c new file mode 100644 index 000000000..1c388938c --- /dev/null +++ b/mdk-stage1/dietlibc/libcruft/mkdtemp.c @@ -0,0 +1,28 @@ +#include +#include +#include +#include +#include +#include "dietfeatures.h" + +char* mkdtemp(char* template) { + char *tmp=template+strlen(template)-6; + int randfd,i; + unsigned int random; + if (tmp>(i*5))&0x1f; + tmp[i]=hexdigit>9?hexdigit+'a'-10:hexdigit+'0'; + } + if (mkdir(template,0700)==0) break; + if (errno==EEXIST) continue; + close(randfd); + return 0; + } + close(randfd); + return template; +} diff --git a/mdk-stage1/dietlibc/libcruft/mktemp.c b/mdk-stage1/dietlibc/libcruft/mktemp.c new file mode 100644 index 000000000..d1908a9ac --- /dev/null +++ b/mdk-stage1/dietlibc/libcruft/mktemp.c @@ -0,0 +1,17 @@ +#include +#include +#include +#include +#include + +#include + +link_warning("mktemp","\e[1;33;41m>>> mktemp stinks! DON'T USE IT ! <<<\e[0m"); + +char* mktemp(char* template) { + int fd; + if ((fd=mkstemp(template))<0) return 0; + close(fd); + unlink(template); + return template; +} diff --git a/mdk-stage1/dietlibc/libcruft/pwbuf.c b/mdk-stage1/dietlibc/libcruft/pwbuf.c new file mode 100644 index 000000000..aa0ad7001 --- /dev/null +++ b/mdk-stage1/dietlibc/libcruft/pwbuf.c @@ -0,0 +1,5 @@ +#include + +struct passwd __passwd_pw; +char __passwd_buf[1000]; + diff --git a/mdk-stage1/dietlibc/libcruft/res_mkquery.c b/mdk-stage1/dietlibc/libcruft/res_mkquery.c new file mode 100644 index 000000000..cf5693668 --- /dev/null +++ b/mdk-stage1/dietlibc/libcruft/res_mkquery.c @@ -0,0 +1,75 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "dietfeatures.h" + +static char dnspacket[]="\xfe\xfe\001\000\000\001\000\000\000\000\000\000"; + +/* + 1 1 1 1 1 1 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 + +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + | ID | + +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + |QR| Opcode |AA|TC|RD|RA| Z | RCODE | + +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + | QDCOUNT | + +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + | ANCOUNT | + +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + | NSCOUNT | + +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + | ARCOUNT | + +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +*/ + +extern void __dns_make_fd(void); +extern int __dns_fd; + +extern int __dns_servers; +extern struct sockaddr __dns_server_ips[]; + +extern void __dns_readstartfiles(void); + +int res_mkquery(int op, const char *dname, int class, int type, char* data, + int datalen, const unsigned char* newrr, char* buf, int buflen) { + unsigned char packet[512]; + memmove(packet,dnspacket,12); + if ((_res.options&RES_RECURSE)==0) packet[2]=0; + *(unsigned short*)packet=rand(); + { + unsigned char* x; + const char* y,* tmp; + x=packet+12; y=dname; + while (*y) { + while (*y=='.') ++y; + for (tmp=y; *tmp && *tmp!='.'; ++tmp) ; + *x=tmp-y; + if (!(tmp-y)) break; + ++x; + if (x>=packet+510-(tmp-y)) { return -1; } + memmove(x,y,tmp-y); + x+=tmp-y; + if (!*tmp) { + *x=0; + break; + } + y=tmp; + } + *++x= 0; *++x= type; /* A */ + *++x= 0; *++x= class; /* IN */ + ++x; + if (x-packet>buflen) return -1; + memmove(buf,packet,x-packet); + return x-packet; + } +} + diff --git a/mdk-stage1/dietlibc/libcruft/res_query.c b/mdk-stage1/dietlibc/libcruft/res_query.c new file mode 100644 index 000000000..28b5c3ac8 --- /dev/null +++ b/mdk-stage1/dietlibc/libcruft/res_query.c @@ -0,0 +1,95 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "dietfeatures.h" + +extern void __dns_make_fd(void); +extern int __dns_fd; +#ifdef WANT_IPV6_DNS +extern void __dns_make_fd6(void); +extern int __dns_fd6; +#endif + +extern void __dns_readstartfiles(void); + +int res_query(const char *dname, int class, int type, unsigned char *answer, int anslen) { + unsigned char packet[512]; + int size; +#ifndef WANT_IPV6_DNS + __dns_make_fd(); +#endif + + __dns_readstartfiles(); + if ((size=res_mkquery(QUERY,dname,class,type,0,0,0,packet,512))<0) { h_errno=NO_RECOVERY; return -1; } + { + { + int i; /* current server */ + int j; /* timeout count down */ + struct pollfd duh; + struct timeval last,now; +#ifdef WANT_IPV6_DNS + int tmpfd; /* the warning gcc issues here is bogus */ +#else + duh.fd=__dns_fd; +#endif + i=0; + duh.events=POLLIN; + last.tv_sec=0; + for (j=120; j>0; --j) { + gettimeofday(&now,0); + if (now.tv_sec-last.tv_sec>10) { +#ifdef WANT_IPV6_DNS + struct sockaddr* s=(struct sockaddr*)&(_res.nsaddr_list[i]); + if (s->sa_family==AF_INET6) { + __dns_make_fd6(); + tmpfd=__dns_fd6; + } else { + __dns_make_fd(); + tmpfd=__dns_fd; + } + duh.fd=tmpfd; + if (sendto(tmpfd,packet,size,0,s,sizeof(struct sockaddr_in6))==0) + gettimeofday(&last,0); +#else + if (sendto(__dns_fd,packet,size,0,(struct sockaddr*)&(_res.nsaddr_list[i]),sizeof(struct sockaddr))==0) + gettimeofday(&last,0); +#endif + last=now; + } + if (++i >= _res.nscount) i=0; + if (poll(&duh,1,1000) == 1) { + /* read and parse answer */ + unsigned char inpkg[1500]; +#ifdef WANT_IPV6_DNS + int len=read(tmpfd,inpkg,1500); +#else + int len=read(__dns_fd,inpkg,1500); +#endif + /* header, question, answer, authority, additional */ + if (inpkg[0]!=packet[0] || inpkg[1]!=packet[1]) continue; /* wrong ID */ + if ((inpkg[2]&0xf9) != (_res.options&RES_RECURSE?0x81:0x80)) continue; /* not answer */ + if ((inpkg[3]&0x0f) != 0) { h_errno=HOST_NOT_FOUND; return -1; } /* error */ + if (len>anslen) { + h_errno=NO_RECOVERY; + return -1; + } + memmove(answer,inpkg,len); + return len; + } +/*kaputt:*/ + } + } + } + h_errno=NO_DATA; + return -1; +} + diff --git a/mdk-stage1/dietlibc/libcruft/res_search.c b/mdk-stage1/dietlibc/libcruft/res_search.c new file mode 100644 index 000000000..a8b9257bc --- /dev/null +++ b/mdk-stage1/dietlibc/libcruft/res_search.c @@ -0,0 +1,35 @@ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern int __dns_search; +extern char *__dns_domains[]; + +int res_search(const char *dname, int class, int type, unsigned char *answer, int anslen) { + const char *tmp=dname; + char Buf[MAXDNAME+1]; + int res; + int len=strlen(dname); + int count=0; + memmove(Buf,dname,len); + Buf[len]=Buf[MAXDNAME]=0; +// printf("appending %d: %p\n",count,__dns_domains[count]); + while ((res=res_query(tmp,class,type,answer,anslen))<0) { + if (count==__dns_search) break; + Buf[len]='.'; +// printf("appending %d: %p (%s)\n",count,__dns_domains[count],__dns_domains[count]); + memccpy(Buf+len+1,__dns_domains[count],0,MAXDNAME-len-1); + tmp=Buf; + ++count; + } + return res; +} diff --git a/mdk-stage1/dietlibc/libcruft/scan_ulong.c b/mdk-stage1/dietlibc/libcruft/scan_ulong.c new file mode 100644 index 000000000..dfbec5c55 --- /dev/null +++ b/mdk-stage1/dietlibc/libcruft/scan_ulong.c @@ -0,0 +1,13 @@ +#include +#include +#include "parselib.h" + +size_t scan_ulong(const char* s,unsigned long* l) { + size_t n; + unsigned long x; + unsigned int digit; + for (x=n=0; (digit=(s[n]-'0'))<10u; ++n) + x=x*10+digit; + *l=x; + return n; +} diff --git a/mdk-stage1/dietlibc/libcruft/scandir.c b/mdk-stage1/dietlibc/libcruft/scandir.c new file mode 100644 index 000000000..fac7eaa7f --- /dev/null +++ b/mdk-stage1/dietlibc/libcruft/scandir.c @@ -0,0 +1,47 @@ +#include +#include +#include + +int scandir(const char *dir, struct dirent ***namelist, + int (*select)(const struct dirent *), + int (*compar)(const struct dirent **, const struct dirent **)) { + DIR* d; + struct dirent *D; + int num=0; + if (!(d=opendir(dir))) + return -1; + *namelist=0; + while ((D=readdir(d))) { + if (select==0 || select(D)) { + struct dirent **tmp; + ++num; +/* printf("realloc %p,%d -> ",*namelist,num*sizeof(struct dirent**)); */ + if (!(tmp=realloc(*namelist,num*sizeof(struct dirent**))) || + !(tmp[num-1]=malloc(sizeof(struct dirent)))) { + int i; + for (i=0; id_name,D->d_name,0,NAME_MAX); + *namelist=tmp; +/* printf("%p; tmp[num-1(%d)]=%p\n",*namelist,num-1,tmp[num-1]); */ + } + } + closedir(d); +#if 0 + { + int i; + puts("pre-qsort:\n"); + for (i=0; id_name); + } + puts("post-qsort:\n"); + } +#endif +// qsort(&(*namelist)[0],num,sizeof(struct dirent*),(int (*)(const void*,const void*))(compar)); + if (compar) + qsort(*namelist,num,sizeof(struct dirent*),(int (*)(const void*,const void*))(compar)); + return num; +} diff --git a/mdk-stage1/dietlibc/libcruft/scandir64.c b/mdk-stage1/dietlibc/libcruft/scandir64.c new file mode 100644 index 000000000..c1bdc3415 --- /dev/null +++ b/mdk-stage1/dietlibc/libcruft/scandir64.c @@ -0,0 +1,47 @@ +#include +#include +#include + +int scandir64(const char *dir, struct dirent64 ***namelist, + int (*select)(const struct dirent64 *), + int (*compar)(const struct dirent64 **, const struct dirent64 **)) { + DIR* d; + struct dirent64 *D; + int num=0; + if (!(d=opendir(dir))) + return -1; + *namelist=0; + while ((D=readdir64(d))) { + if (select==0 || select(D)) { + struct dirent64 **tmp; + ++num; +/* printf("realloc %p,%d -> ",*namelist,num*sizeof(struct dirent**)); */ + if (!(tmp=realloc(*namelist,num*sizeof(struct dirent64**))) || + !(tmp[num-1]=malloc(sizeof(struct dirent64)))) { + int i; + for (i=0; id_name,D->d_name,0,NAME_MAX); + *namelist=tmp; +/* printf("%p; tmp[num-1(%d)]=%p\n",*namelist,num-1,tmp[num-1]); */ + } + } + closedir(d); +#if 0 + { + int i; + puts("pre-qsort:\n"); + for (i=0; id_name); + } + puts("post-qsort:\n"); + } +#endif +// qsort(&(*namelist)[0],num,sizeof(struct dirent*),(int (*)(const void*,const void*))(compar)); + if (compar) + qsort(*namelist,num,sizeof(struct dirent64*),(int (*)(const void*,const void*))(compar)); + return num; +} diff --git a/mdk-stage1/dietlibc/libcruft/setegid.c b/mdk-stage1/dietlibc/libcruft/setegid.c new file mode 100644 index 000000000..6e891952b --- /dev/null +++ b/mdk-stage1/dietlibc/libcruft/setegid.c @@ -0,0 +1,11 @@ +#include +#include +#include "dietwarning.h" + +#undef setegid +int setegid(gid_t gid); +int setegid(gid_t gid) { + return setregid((gid_t)-1,gid); +} + +link_warning("setegid","warning: you used setegid without including ") diff --git a/mdk-stage1/dietlibc/libcruft/seteuid.c b/mdk-stage1/dietlibc/libcruft/seteuid.c new file mode 100644 index 000000000..8145f20d7 --- /dev/null +++ b/mdk-stage1/dietlibc/libcruft/seteuid.c @@ -0,0 +1,11 @@ +#include +#include +#include "dietwarning.h" + +#undef seteuid +int seteuid(uid_t uid); +int seteuid(uid_t uid) { + return setreuid((uid_t)-1,uid); +} + +link_warning("setegid","warning: you used setegid without including ") diff --git a/mdk-stage1/dietlibc/libcruft/setlocale.c b/mdk-stage1/dietlibc/libcruft/setlocale.c new file mode 100644 index 000000000..e0e8f647d --- /dev/null +++ b/mdk-stage1/dietlibc/libcruft/setlocale.c @@ -0,0 +1,7 @@ +#include + +char *setlocale (int category, const char *locale) { + (void)category; + (void)locale; + return 0; +} diff --git a/mdk-stage1/dietlibc/libcruft/spbuf.c b/mdk-stage1/dietlibc/libcruft/spbuf.c new file mode 100644 index 000000000..ab880bbcf --- /dev/null +++ b/mdk-stage1/dietlibc/libcruft/spbuf.c @@ -0,0 +1,5 @@ +#include + +struct spwd __shadow_pw; +char __shadow_buf[1000]; + diff --git a/mdk-stage1/dietlibc/libcruft/sysconf.c b/mdk-stage1/dietlibc/libcruft/sysconf.c new file mode 100644 index 000000000..e9c15cb66 --- /dev/null +++ b/mdk-stage1/dietlibc/libcruft/sysconf.c @@ -0,0 +1,43 @@ +#include +#include +#include +#include + +extern int __sc_nr_cpus(); + +long sysconf(int name) +{ + switch(name) + { + case _SC_OPEN_MAX: + { + struct rlimit limit; + getrlimit(RLIMIT_NOFILE, &limit); + return limit.rlim_cur; + } + case _SC_CLK_TCK: +#ifdef __alpha__ + return 1024; +#else + return 100; +#endif + + case _SC_PAGESIZE: +#if ( defined(__alpha__) || defined(__sparc__) ) + return 8192; +#else + return 4096; +#endif + + case _SC_ARG_MAX: + return ARG_MAX; + + case _SC_NGROUPS_MAX: + return NGROUPS_MAX; + + case _SC_NPROCESSORS_ONLN: + return __sc_nr_cpus(); + + } + return -1; +} diff --git a/mdk-stage1/dietlibc/libcruft/sysconf_cpus.c b/mdk-stage1/dietlibc/libcruft/sysconf_cpus.c new file mode 100644 index 000000000..b5361d0a4 --- /dev/null +++ b/mdk-stage1/dietlibc/libcruft/sysconf_cpus.c @@ -0,0 +1,64 @@ +#include +#include +#include +#include +#include "dietfeatures.h" + +/* + * by Olaf Dreesen + * + * arm NO SMP ?!? (return 1) + * + * alpha -> cpus detected\t\t: \n + * sparc -> ncpus active\t: \n + * + * default -> processor\t: \n (one per cpu) + */ + +#ifdef SLASH_PROC_OK +int __sc_nr_cpus(void); +int __sc_nr_cpus() { +#if defined(__arm__) + return 1; +#else + int fd; + fd = open("/proc/cpuinfo", O_RDONLY); + if (fd==-1) return 1; /* fallback if no proc-fs mounted */ + else { + int n,nr=0; + char buf[2048]; /* holds ~6 cpuinfos */ + + while((n=read(fd,buf,sizeof(buf)))>0) { + register int i=0; + while (i +#include +#include +#include +#include +#include +#include + +link_warning("tempnam","\e[1;33;41m>>> tempnam stinks! NEVER ! NEVER USE IT ! <<<\e[0m"); + +char* tempnam(char* dir,char* template) { + char buf[1024]; + int len=sizeof(buf)-1,fd; + buf[len]=0; + if ((dir)&&(*dir)) { + memccpy(buf,dir,0,len); + strncat(buf,"/",1); + } + else + strncpy(buf,"/tmp/",len); + len=(sizeof(buf)-1)-strlen(buf); + if (template) + strncat(buf,template, --len); + else + strncat(buf,"temp_", --len); + len=(sizeof(buf)-1)-strlen(buf); + strncat(buf,"XXXXXX",len); + if ((fd=mkstemp(buf))<0) return 0; + close(fd); + unlink(buf); + return strdup(buf); +} diff --git a/mdk-stage1/dietlibc/libcruft/tmpnam.c b/mdk-stage1/dietlibc/libcruft/tmpnam.c new file mode 100644 index 000000000..707730616 --- /dev/null +++ b/mdk-stage1/dietlibc/libcruft/tmpnam.c @@ -0,0 +1,31 @@ +#include +#include +#include +#include "dietfeatures.h" +#include +#include +#include +#include +#include + +link_warning("tmpnam","\e[1;33;41m>>> tmpnam stinks! NEVER ! NEVER USE IT ! <<<\e[0m"); + +char* tmpnam(char* s) { + static char buf[100]; + char *tmp; + if (s) tmp=s; else tmp=buf; + strcpy(tmp,"/tmp/temp_"); + for (;;) { + struct stat s; + int i,j; + i=rand(); + for (j=0; j<8; ++j) { + char c=i&0xf; + tmp[9+j]=c>9?c+'a'-10:c+'0'; + i>>=4; + } + tmp[17]=0; + if (lstat(tmp,&s)==-1 && errno==ENOENT) break; + } + return tmp; +} diff --git a/mdk-stage1/dietlibc/libcrypt/md5.c b/mdk-stage1/dietlibc/libcrypt/md5.c new file mode 100644 index 000000000..ede9a067e --- /dev/null +++ b/mdk-stage1/dietlibc/libcrypt/md5.c @@ -0,0 +1,243 @@ +/***************************************************************************** +* +* "derived from the RSA Data Security, Inc. MD5 Message-Digest Algorithm". +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +*****************************************************************************/ + +#include +#include +#include + +#if (__BYTE_ORDER == __BIG_ENDIAN) +/* + Block copy and convert byte order to little-endian. + dst must be 32bit aligned. + Length is the number of 32bit words +*/ +static void CopyToLittleEndian (uint32_t *dst, const uint8_t *src, int length) { + while (length--) { + *dst=(((uint32_t)src[3])<<24) | + (((uint32_t)src[2])<<16) | + (((uint32_t)src[1])<< 8) | + (uint32_t)src[0]; + src+=4; + dst++; + } +} +#endif + + +/* + Assembler versions of __MD5Transform, MD5Init and MD5Update + currently exist for x86 and little-endian ARM. + For other targets, we need to use the C versions below. +*/ + +#if !(defined (__i386__) || ((defined (__arm__) && (__BYTE_ORDER == __LITTLE_ENDIAN)))) + +/* + Initialise the MD5 context. +*/ +void MD5Init (MD5_CTX* context) { + context->count[0] = 0; + context->count[1] = 0; + + context->state[0] = 0x67452301; /* Load magic constants. */ + context->state[1] = 0xefcdab89; + context->state[2] = 0x98badcfe; + context->state[3] = 0x10325476; +} + +#define ROTATE_LEFT(x, n) ((x << n) | (x >> (32-n))) + +#define F(x, y, z) (z ^ (x & (y ^ z))) +#define G(x, y, z) (y ^ (z & (x ^ y))) +#define H(x, y, z) (x ^ y ^ z) +#define I(x, y, z) (y ^ (x | ~z)) + +#define FF(a, b, c, d, x, s, ac) { (a) += F (b, c, d) + (x) + (uint32_t)(ac); (a) = ROTATE_LEFT (a, s); (a) += (b); } +#define GG(a, b, c, d, x, s, ac) { (a) += G (b, c, d) + (x) + (uint32_t)(ac); (a) = ROTATE_LEFT (a, s); (a) += (b); } +#define HH(a, b, c, d, x, s, ac) { (a) += H (b, c, d) + (x) + (uint32_t)(ac); (a) = ROTATE_LEFT (a, s); (a) += (b); } +#define II(a, b, c, d, x, s, ac) { (a) += I (b, c, d) + (x) + (uint32_t)(ac); (a) = ROTATE_LEFT (a, s); (a) += (b); } + +static void __MD5Transform (uint32_t state[4], const uint8_t *in, int repeat) { + const uint32_t *x; + + uint32_t a = state[0]; + uint32_t b = state[1]; + uint32_t c = state[2]; + uint32_t d = state[3]; + + for ( ; repeat; repeat--) { + uint32_t tempBuffer[16]; +#if (__BYTE_ORDER == __BIG_ENDIAN) + + CopyToLittleEndian (tempBuffer, in, 16); + x = tempBuffer; +#else + if ((long)in & 3) { + memcpy(tempBuffer, in, 64); + x = tempBuffer; + } else + x = (const uint32_t *) in; +#endif + + FF (a, b, c, d, x[ 0], 7, 0xd76aa478); /* 1 */ /* Round 1 */ + FF (d, a, b, c, x[ 1], 12, 0xe8c7b756); /* 2 */ + FF (c, d, a, b, x[ 2], 17, 0x242070db); /* 3 */ + FF (b, c, d, a, x[ 3], 22, 0xc1bdceee); /* 4 */ + FF (a, b, c, d, x[ 4], 7, 0xf57c0faf); /* 5 */ + FF (d, a, b, c, x[ 5], 12, 0x4787c62a); /* 6 */ + FF (c, d, a, b, x[ 6], 17, 0xa8304613); /* 7 */ + FF (b, c, d, a, x[ 7], 22, 0xfd469501); /* 8 */ + FF (a, b, c, d, x[ 8], 7, 0x698098d8); /* 9 */ + FF (d, a, b, c, x[ 9], 12, 0x8b44f7af); /* 10 */ + FF (c, d, a, b, x[10], 17, 0xffff5bb1); /* 11 */ + FF (b, c, d, a, x[11], 22, 0x895cd7be); /* 12 */ + FF (a, b, c, d, x[12], 7, 0x6b901122); /* 13 */ + FF (d, a, b, c, x[13], 12, 0xfd987193); /* 14 */ + FF (c, d, a, b, x[14], 17, 0xa679438e); /* 15 */ + FF (b, c, d, a, x[15], 22, 0x49b40821); /* 16 */ + + GG (a, b, c, d, x[ 1], 5, 0xf61e2562); /* 17 */ /* Round 2 */ + GG (d, a, b, c, x[ 6], 9, 0xc040b340); /* 18 */ + GG (c, d, a, b, x[11], 14, 0x265e5a51); /* 19 */ + GG (b, c, d, a, x[ 0], 20, 0xe9b6c7aa); /* 20 */ + GG (a, b, c, d, x[ 5], 5, 0xd62f105d); /* 21 */ + GG (d, a, b, c, x[10], 9, 0x02441453); /* 22 */ + GG (c, d, a, b, x[15], 14, 0xd8a1e681); /* 23 */ + GG (b, c, d, a, x[ 4], 20, 0xe7d3fbc8); /* 24 */ + GG (a, b, c, d, x[ 9], 5, 0x21e1cde6); /* 25 */ + GG (d, a, b, c, x[14], 9, 0xc33707d6); /* 26 */ + GG (c, d, a, b, x[ 3], 14, 0xf4d50d87); /* 27 */ + GG (b, c, d, a, x[ 8], 20, 0x455a14ed); /* 28 */ + GG (a, b, c, d, x[13], 5, 0xa9e3e905); /* 29 */ + GG (d, a, b, c, x[ 2], 9, 0xfcefa3f8); /* 30 */ + GG (c, d, a, b, x[ 7], 14, 0x676f02d9); /* 31 */ + GG (b, c, d, a, x[12], 20, 0x8d2a4c8a); /* 32 */ + + HH (a, b, c, d, x[ 5], 4, 0xfffa3942); /* 33 */ /* Round 3 */ + HH (d, a, b, c, x[ 8], 11, 0x8771f681); /* 34 */ + HH (c, d, a, b, x[11], 16, 0x6d9d6122); /* 35 */ + HH (b, c, d, a, x[14], 23, 0xfde5380c); /* 36 */ + HH (a, b, c, d, x[ 1], 4, 0xa4beea44); /* 37 */ + HH (d, a, b, c, x[ 4], 11, 0x4bdecfa9); /* 38 */ + HH (c, d, a, b, x[ 7], 16, 0xf6bb4b60); /* 39 */ + HH (b, c, d, a, x[10], 23, 0xbebfbc70); /* 40 */ + HH (a, b, c, d, x[13], 4, 0x289b7ec6); /* 41 */ + HH (d, a, b, c, x[ 0], 11, 0xeaa127fa); /* 42 */ + HH (c, d, a, b, x[ 3], 16, 0xd4ef3085); /* 43 */ + HH (b, c, d, a, x[ 6], 23, 0x04881d05); /* 44 */ + HH (a, b, c, d, x[ 9], 4, 0xd9d4d039); /* 45 */ + HH (d, a, b, c, x[12], 11, 0xe6db99e5); /* 46 */ + HH (c, d, a, b, x[15], 16, 0x1fa27cf8); /* 47 */ + HH (b, c, d, a, x[ 2], 23, 0xc4ac5665); /* 48 */ + + II (a, b, c, d, x[ 0], 6, 0xf4292244); /* 49 */ /* Round 4 */ + II (d, a, b, c, x[ 7], 10, 0x432aff97); /* 50 */ + II (c, d, a, b, x[14], 15, 0xab9423a7); /* 51 */ + II (b, c, d, a, x[ 5], 21, 0xfc93a039); /* 52 */ + II (a, b, c, d, x[12], 6, 0x655b59c3); /* 53 */ + II (d, a, b, c, x[ 3], 10, 0x8f0ccc92); /* 54 */ + II (c, d, a, b, x[10], 15, 0xffeff47d); /* 55 */ + II (b, c, d, a, x[ 1], 21, 0x85845dd1); /* 56 */ + II (a, b, c, d, x[ 8], 6, 0x6fa87e4f); /* 57 */ + II (d, a, b, c, x[15], 10, 0xfe2ce6e0); /* 58 */ + II (c, d, a, b, x[ 6], 15, 0xa3014314); /* 59 */ + II (b, c, d, a, x[13], 21, 0x4e0811a1); /* 60 */ + II (a, b, c, d, x[ 4], 6, 0xf7537e82); /* 61 */ + II (d, a, b, c, x[11], 10, 0xbd3af235); /* 62 */ + II (c, d, a, b, x[ 2], 15, 0x2ad7d2bb); /* 63 */ + II (b, c, d, a, x[ 9], 21, 0xeb86d391); /* 64 */ + + state[0] = a = a + state[0]; + state[1] = b = b + state[1]; + state[2] = c = c + state[2]; + state[3] = d = d + state[3]; + + in += 64; + } +} + + +/* + MD5 block update operation: + Process another sub-string of the message and update the context. +*/ +void MD5Update (MD5_CTX *context, const uint8_t *input, size_t inputBytes) { + int i; + int byteIndex; + unsigned int partLen; + int len; + + /* Compute number of bytes mod 64 */ + byteIndex = (context->count[0] >> 3) & 0x3F; + + /* Update number of bits: count += 8 * inputBytes */ + if ((context->count[0] += inputBytes << 3) < (inputBytes << 3)) + context->count[1]++; + context->count[1] += (inputBytes >> (32-3)); + + partLen = (64 - byteIndex); + + /* Transform as many times as possible. */ + if (inputBytes >= partLen) { + memcpy (context->buffer + byteIndex, input, partLen); + __MD5Transform (context->state, (const uint8_t *) context->buffer, 1); + len = (inputBytes - partLen) / 64; + __MD5Transform (context->state, &input[partLen], len); + i = partLen + 64 * len; + byteIndex = 0; + } else + i = 0; + + /* Buffer remaining input */ + memcpy (&context->buffer[byteIndex], &input[i], inputBytes - i); +} + +#endif + + +void MD5Final (uint8_t digest[16], MD5_CTX* context) { + static uint8_t finalBlock[64]; + + uint32_t bits[2]; + int byteIndex; + int finalBlockLength; + + byteIndex = (context->count[0] >> 3) & 0x3F; + finalBlockLength = ((byteIndex < 56) ? 56 : 120) - byteIndex; + finalBlock[0] = 0x80; + +#if (__BYTE_ORDER == __BIG_ENDIAN) + CopyToLittleEndian (bits, (const uint8_t *) context->count, 2); +#else + memcpy(bits, context->count, 8); +#endif + + MD5Update (context, finalBlock, finalBlockLength); + MD5Update (context, (const uint8_t *) bits, 8); + +#if (__BYTE_ORDER == __BIG_ENDIAN) + CopyToLittleEndian ((uint32_t *) digest, (const uint8_t *) context->state, 4); +#else + memcpy (digest, context->state, 16); +#endif + + memset(context, 0, sizeof(*context)); +} + diff --git a/mdk-stage1/dietlibc/libcrypt/md5crypt.c b/mdk-stage1/dietlibc/libcrypt/md5crypt.c new file mode 100644 index 000000000..ebbb4be44 --- /dev/null +++ b/mdk-stage1/dietlibc/libcrypt/md5crypt.c @@ -0,0 +1,157 @@ +/* $OpenBSD: md5crypt.c,v 1.9 1997/07/23 20:58:27 kstailey Exp $ */ + +/* + * ---------------------------------------------------------------------------- + * "THE BEER-WARE LICENSE" (Revision 42): + * wrote this file. As long as you retain this notice you + * can do whatever you want with this stuff. If we meet some day, and you think + * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp + * ---------------------------------------------------------------------------- + * + * $FreeBSD: crypt.c,v 1.5 1996/10/14 08:34:02 phk Exp $ + * + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char rcsid[] = "$OpenBSD: md5crypt.c,v 1.9 1997/07/23 20:58:27 kstailey Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include +#include +#include +#include + +static unsigned char itoa64[] = /* 0 ... 63 => ascii - 64 */ + "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; + +static void to64 (char *, uint32_t, int); + +static void +to64(s, v, n) + char *s; + uint32_t v; + int n; +{ + while (--n >= 0) { + *s++ = itoa64[v&0x3f]; + v >>= 6; + } +} + +/* + * UNIX password + * + * Use MD5 for what it is best at... + */ + +char * +md5crypt(pw, salt) + register const char *pw; + register const char *salt; +{ + /* + * This string is magic for this algorithm. Having + * it this way, we can get get better later on + */ + static unsigned char *magic = (unsigned char *)"$1$"; + + static char passwd[120], *p; + static const unsigned char *sp,*ep; + unsigned char final[16]; + int sl,pl,i; + MD5_CTX ctx,ctx1; + uint32_t l; + + /* Refine the Salt first */ + sp = (const unsigned char *)salt; + + /* If it starts with the magic string, then skip that */ + if(!strncmp((const char *)sp,(const char *)magic,strlen((const char *)magic))) + sp += strlen((const char *)magic); + + /* It stops at the first '$', max 8 chars */ + for(ep=sp;*ep && *ep != '$' && ep < (sp+8);ep++) + continue; + + /* get the length of the true salt */ + sl = ep - sp; + + MD5Init(&ctx); + + /* The password first, since that is what is most unknown */ + MD5Update(&ctx,(const unsigned char *)pw,strlen(pw)); + + /* Then our magic string */ + MD5Update(&ctx,magic,strlen((const char *)magic)); + + /* Then the raw salt */ + MD5Update(&ctx,sp,sl); + + /* Then just as many characters of the MD5(pw,salt,pw) */ + MD5Init(&ctx1); + MD5Update(&ctx1,(const unsigned char *)pw,strlen(pw)); + MD5Update(&ctx1,sp,sl); + MD5Update(&ctx1,(const unsigned char *)pw,strlen(pw)); + MD5Final(final,&ctx1); + for(pl = strlen(pw); pl > 0; pl -= 16) + MD5Update(&ctx,final,pl>16 ? 16 : pl); + + /* Don't leave anything around in vm they could use. */ + memset(final,0,sizeof final); + + /* Then something really weird... */ + for (i = strlen(pw); i ; i >>= 1) + if(i&1) + MD5Update(&ctx, final, 1); + else + MD5Update(&ctx, (const unsigned char *)pw, 1); + + /* Now make the output string */ + strcpy(passwd,(const char *)magic); + memcpy(passwd+3,sp,sl); + passwd[sl+3]='$'; + passwd[sl+4]=0; + + MD5Final(final,&ctx); + + /* + * and now, just to make sure things don't run too fast + * On a 60 Mhz Pentium this takes 34 msec, so you would + * need 30 seconds to build a 1000 entry dictionary... + */ + for(i=0;i<1000;i++) { + MD5Init(&ctx1); + if(i & 1) + MD5Update(&ctx1,(const unsigned char *)pw,strlen(pw)); + else + MD5Update(&ctx1,final,16); + + if(i % 3) + MD5Update(&ctx1,sp,sl); + + if(i % 7) + MD5Update(&ctx1,(const unsigned char *)pw,strlen(pw)); + + if(i & 1) + MD5Update(&ctx1,final,16); + else + MD5Update(&ctx1,(const unsigned char *)pw,strlen(pw)); + MD5Final(final,&ctx1); + } + + p = passwd + strlen(passwd); + + l = (final[ 0]<<16) | (final[ 6]<<8) | final[12]; to64(p,l,4); p += 4; + l = (final[ 1]<<16) | (final[ 7]<<8) | final[13]; to64(p,l,4); p += 4; + l = (final[ 2]<<16) | (final[ 8]<<8) | final[14]; to64(p,l,4); p += 4; + l = (final[ 3]<<16) | (final[ 9]<<8) | final[15]; to64(p,l,4); p += 4; + l = (final[ 4]<<16) | (final[10]<<8) | final[ 5]; to64(p,l,4); p += 4; + l = final[11] ; to64(p,l,2); p += 2; + *p = '\0'; + + /* Don't leave anything around in vm they could use. */ + memset(final,0,sizeof final); + + return passwd; +} + diff --git a/mdk-stage1/dietlibc/libdl/_dl_alloc.c b/mdk-stage1/dietlibc/libdl/_dl_alloc.c new file mode 100644 index 000000000..41d0d4671 --- /dev/null +++ b/mdk-stage1/dietlibc/libdl/_dl_alloc.c @@ -0,0 +1,81 @@ +#include +#include +#include + +#include "_dl_int.h" + +#ifdef __DIET_LD_SO__ +static struct _dl_handle*_dl_root_handle=(struct _dl_handle*)0; +static struct _dl_handle*_dl_top_handle=(struct _dl_handle*)0; +static struct _dl_handle*_dl_free_list=(struct _dl_handle*)0; +#else +struct _dl_handle*_dl_root_handle=(struct _dl_handle*)0; +struct _dl_handle*_dl_top_handle=(struct _dl_handle*)0; +struct _dl_handle*_dl_free_list=(struct _dl_handle*)0; +#endif + +#ifdef __DIET_LD_SO__ +static +#endif +void _dl_free_handle(struct _dl_handle*dh) { + if (_dl_root_handle==dh) _dl_root_handle=dh->next; + if (_dl_top_handle ==dh) _dl_top_handle=dh->prev; + + if (dh->next) dh->next->prev=dh->prev; + if (dh->prev) dh->prev->next=dh->next; + + if ((dh->flags&RTLD_NOSONAME) && dh->name) free(dh->name); + memset(dh,0,sizeof(struct _dl_handle)); + dh->next=_dl_free_list; + _dl_free_list=dh; +} + +#ifdef __DIET_LD_SO__ +static +#endif +struct _dl_handle*_dl_get_handle() { + struct _dl_handle*tmp; + + if (_dl_free_list==0) { + register int i,m; +#ifdef __DIET_LD_SO__ + tmp = (struct _dl_handle*)_dl_sys_mmap(0,at_pagesize,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANONYMOUS,-1,0); + m=at_pagesize/sizeof(struct _dl_handle); +#else + int ps=getpagesize(); + tmp = (struct _dl_handle*)mmap(0,ps,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANONYMOUS,-1,0); + m=ps/sizeof(struct _dl_handle); +#endif + for (i=m;i;) _dl_free_handle(tmp+(--i)); + } + + tmp = _dl_free_list; + _dl_free_list = tmp->next; + + tmp->next=0; + if (_dl_root_handle) { + _dl_top_handle->next=tmp; + tmp->prev=_dl_top_handle; + } else + _dl_root_handle = tmp; + + _dl_top_handle=tmp; + + return tmp; +} + +#ifdef __DIET_LD_SO__ +static +#endif +struct _dl_handle*_dl_find_lib(const char* name) { + if (name) { + if (_dl_root_handle) { + struct _dl_handle*tmp; + for (tmp=_dl_root_handle;tmp;tmp=tmp->next) { + if (!tmp->name) continue; + if (!strcmp(tmp->name,name)) return tmp; + } + } + } + return 0; +} diff --git a/mdk-stage1/dietlibc/libdl/_dl_load.c b/mdk-stage1/dietlibc/libdl/_dl_load.c new file mode 100644 index 000000000..49e8db0be --- /dev/null +++ b/mdk-stage1/dietlibc/libdl/_dl_load.c @@ -0,0 +1,401 @@ +#include +#include +#include +#include +#include +#include + +#include "_dl_int.h" + +#define _ELF_DWN_ROUND(ps,n) ((n)&(~((ps)-1))) +#define _ELF_UP_ROUND(ps,n) ((((n)&((ps)-1))?(ps):0)+ _ELF_DWN_ROUND((ps),(n))) +#define _ELF_RST_ROUND(ps,n) ((n)&((ps)-1)) + +/* this is an arch specific "return jump" for the relocation */ +void _dl_jump(); + +/* + * this file is a Q. & D. hack ... don't think this is bug free or meaningfull + */ + +static inline int map_flags(int flags) +{ + int perm = 0; + if (flags & PF_X) perm|=PROT_EXEC; + if (flags & PF_R) perm|=PROT_READ; + if (flags & PF_W) perm|=PROT_WRITE; + return perm; +} + +static inline void *do_map_in(void *base, unsigned long length, int flags, int fd, unsigned long offset) +{ + register int op = MAP_PRIVATE; + if (base) op|=MAP_FIXED; + return mmap(base, length, map_flags(flags), op, fd, offset); +} + +static struct _dl_handle *_dl_map_lib(const char*fn, const char*pathname, int fd, int flags) +{ + struct _dl_handle* ret=0; + int ps=getpagesize(); + int i; + unsigned char buf[1024]; + char *m=0,*d=0; + + unsigned long l; + struct stat st; + + Elf_Ehdr *eh; + Elf_Phdr *ph; + + int ld_nr=0; + Elf_Phdr **ld=0; + Elf_Phdr *dyn=0; + + if (fd==-1) return 0; + +#ifdef DEBUG + pf(__func__": "); pf(pathname); pf("\n"); +#endif + + if (fstat(fd,&st)<0) { + close(fd); + _dl_error=2; + return 0; + } + else { + // use st_dev and st_ino for identification + } + + if (read(fd, buf, 1024)<128) { + close(fd); + _dl_error=2; + return 0; + } + + eh=(Elf_Ehdr*)buf; + ph=(Elf_Phdr*)&buf[eh->e_phoff]; + + for (i=0; ie_phnum; i++) { + if (ph[i].p_type==PT_LOAD) ++ld_nr; + } + ld=alloca(ld_nr*sizeof(Elf_Phdr)); + + for (ld_nr=i=0; ie_phnum; i++) { + if (ph[i].p_type==PT_LOAD) { + ld[ld_nr++]=ph+i; + } + if (ph[i].p_type==PT_DYNAMIC) { + dyn=ph+i; + } + } + + if (ld_nr==1) { + unsigned long offset = _ELF_DWN_ROUND(ps,ld[0]->p_offset); + unsigned long off = _ELF_RST_ROUND(ps,ld[0]->p_offset); + unsigned long length = _ELF_UP_ROUND(ps,ld[0]->p_memsz+off); + ret = _dl_get_handle(); + + m = (char*)do_map_in(0, length, ld[0]->p_flags, fd, offset); + if (m==MAP_FAILED) { _dl_free_handle(ret); close(fd); return 0; } + + /* zero pad bss */ + l = ld[0]->p_offset+ld[0]->p_filesz; + memset(m+l,0,length-l); + + ret->mem_base=m; + ret->mem_size=length; + } + else if (ld_nr==2) { /* aem... yes Quick & Really Dirty / for the avarage 99% */ +// unsigned long text_addr = _ELF_DWN_ROUND(ps,ld[0]->p_vaddr); /* do we need this ? */ + unsigned long text_offset = _ELF_DWN_ROUND(ps,ld[0]->p_offset); + unsigned long text_off = _ELF_RST_ROUND(ps,ld[0]->p_offset); + unsigned long text_size = _ELF_UP_ROUND(ps,ld[0]->p_memsz+text_off); + + unsigned long data_addr = _ELF_DWN_ROUND(ps,ld[1]->p_vaddr); + unsigned long data_offset = _ELF_DWN_ROUND(ps,ld[1]->p_offset); + unsigned long data_off = _ELF_RST_ROUND(ps,ld[1]->p_offset); + unsigned long data_size = _ELF_UP_ROUND(ps,ld[1]->p_memsz+data_off); + unsigned long data_fsize = _ELF_UP_ROUND(ps,ld[1]->p_filesz+data_off); + + ret = _dl_get_handle(); + /* mmap all mem_blocks for *.so */ + m = (char*) do_map_in(0,text_size+data_size,ld[0]->p_flags,fd,text_offset); + if (m==MAP_FAILED) { _dl_free_handle(ret); close(fd); return 0; } + + /* release data,bss part */ + mprotect(m+data_addr, data_size, PROT_NONE); + + /* mmap data,bss part */ + d = (char*) do_map_in(m+data_addr,data_fsize,ld[1]->p_flags,fd,data_offset); + + /* zero pad bss */ + l = data_off+ld[1]->p_filesz; + memset(d+l,0,data_fsize-l); + + /* more bss ? */ + if (data_size>data_fsize) { + l = data_size-data_fsize; + mmap(d+data_fsize, l, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0); + } + + ret->mem_base=m; + ret->mem_size=text_size+data_size; + } + + if (ret) { + ret->lnk_count=1; + ret->name=strdup(fn); + ret->dyn_str_tab=(char*)m+dyn->p_vaddr; /* missuse of field */ + } + + close(fd); + return ret; +} + +/* local alias */ +static struct _dl_handle* __dl_dyn_scan(struct _dl_handle* dh, void* dyn_addr, int flags) +__attribute__ ((alias("_dl_dyn_scan"))); + +struct _dl_handle* _dl_dyn_scan(struct _dl_handle* dh, void* dyn_addr, int flags) +{ + Elf_Dyn* dyn_tab = dyn_addr; + + void (*init)()=0; + unsigned long* got=0; + void* jmprel=0; + int pltreltype=0; + int pltrelsize=0; + unsigned long rel=0; + int relent=0; + int relsize=0; + + int i; + +#ifdef DEBUG + pf(__func__": pre dynamic scan "); ph((unsigned long)dh); pf("\n"); +#endif + dh->dyn_str_tab=0; + dh->flags=flags; + + for(i=0;dyn_tab[i].d_tag;i++) { +// DEBUG(printf("_dl_load dyn %d, %08lx\n",dyn_tab[i].d_tag, dyn_tab[i].d_un.d_val);) + if (dyn_tab[i].d_tag==DT_HASH) { + dh->hash_tab = (unsigned long*)(dh->mem_base+dyn_tab[i].d_un.d_ptr); +#ifdef DEBUG + pf(__func__": have hash @ "); ph((long)dh->hash_tab); pf("\n"); +#endif + } + else if (dyn_tab[i].d_tag==DT_SYMTAB) { + dh->dyn_sym_tab = (Elf_Sym*)(dh->mem_base+dyn_tab[i].d_un.d_ptr); +#ifdef DEBUG + pf(__func__": have dyn_sym_tab @ "); ph((long)dh->dyn_sym_tab); pf("\n"); +#endif + } + else if (dyn_tab[i].d_tag==DT_STRTAB) { + dh->dyn_str_tab = (char*)(dh->mem_base+dyn_tab[i].d_un.d_ptr); +#ifdef DEBUG + pf(__func__": have dyn_str_tab @ "); ph((long)dh->dyn_str_tab); pf("\n"); +#endif + } + + /* INIT / FINI */ + else if (dyn_tab[i].d_tag==DT_FINI) { + dh->fini = (void(*)(void))(dh->mem_base+dyn_tab[i].d_un.d_val); +#ifdef DEBUG + pf(__func__": have fini @ "); ph((long)dh->fini); pf("\n"); +#endif + } + else if (dyn_tab[i].d_tag==DT_INIT) { + init = (void(*)(void))(dh->mem_base+dyn_tab[i].d_un.d_val); +#ifdef DEBUG + pf(__func__": have init @ "); ph((long)init); pf("\n"); +#endif + } + + /* PLT / Relocation entries for PLT in GOT */ + else if (dyn_tab[i].d_tag==DT_PLTGOT) { + got=(unsigned long*)(dh->mem_base+dyn_tab[i].d_un.d_val); + dh->pltgot=got; +#ifdef DEBUG + pf(__func__": have plt got @ "); ph((long)dh->pltgot); pf("\n"); +#endif + } + else if (dyn_tab[i].d_tag==DT_PLTREL) { + pltreltype=dyn_tab[i].d_un.d_val; +#ifdef DEBUG + pf(__func__": have pltreltype @ "); ph((long)pltreltype); pf("\n"); +#endif + } + else if (dyn_tab[i].d_tag==DT_PLTRELSZ) { + pltrelsize=dyn_tab[i].d_un.d_val; +#ifdef DEBUG + pf(__func__": have pltrelsize @ "); ph((long)pltrelsize); pf("\n"); +#endif + } + else if (dyn_tab[i].d_tag==DT_JMPREL) { + jmprel=(dh->mem_base+dyn_tab[i].d_un.d_val); + dh->plt_rel=jmprel; +#ifdef DEBUG + pf(__func__": have jmprel @ "); ph((long)jmprel); pf("\n"); +#endif + } + + /* Relocation */ + else if (dyn_tab[i].d_tag==DT_REL) { + rel=(unsigned long)(dh->mem_base+dyn_tab[i].d_un.d_val); +#ifdef DEBUG + pf(__func__": have rel @ "); ph((long)rel); pf("\n"); +#endif + } + else if (dyn_tab[i].d_tag==DT_RELENT) { + relent=dyn_tab[i].d_un.d_val; +#ifdef DEBUG + pf(__func__": have relent @ "); ph((long)relent); pf("\n"); +#endif + } + else if (dyn_tab[i].d_tag==DT_RELSZ) { + relsize=dyn_tab[i].d_un.d_val; +#ifdef DEBUG + pf(__func__": have relsize @ "); ph((long)relsize); pf("\n"); +#endif + } + + else if (dyn_tab[i].d_tag==DT_TEXTREL) { + _dl_free_handle(dh); + _dl_error = 3; + return 0; + } + } + /* extra scan for rpath (if program) ... */ + if (dh->name==0) { + for(i=0;dyn_tab[i].d_tag;i++) { + if (dyn_tab[i].d_tag==DT_RPATH) { + char *rpath=dh->dyn_str_tab+dyn_tab[i].d_un.d_val; + _dl_set_rpath(rpath); +#ifdef DEBUG + pf(__func__": have runpath: "); pf(rpath); pf("\n"); +#endif + } + } + } + +#ifdef DEBUG + pf(__func__": post dynamic scan "); ph((unsigned long)dh); pf("\n"); +#endif + + if ((got=_dlsym(dh,"_GLOBAL_OFFSET_TABLE_"))) { +#ifdef DEBUG + pf(__func__": found a GOT @ "); ph((unsigned long)got); pf("\n"); +#endif + /* GOT */ + got[0]+=(unsigned long)dh->mem_base; /* reloc dynamic pointer */ + got[1] =(unsigned long)dh; + got[2] =(unsigned long)(_dl_jump); /* sysdep jump to _dl_rel */ + /* */ + } + else { + if (dh) { + munmap(dh->mem_base,dh->mem_size); + _dl_free_handle(dh); + } + _dl_error = 3; + return 0; + } + + /* load other libs */ + for(i=0;dyn_tab[i].d_tag;i++) { + if (dyn_tab[i].d_tag==DT_NEEDED) { + char *lib_name=dh->dyn_str_tab+dyn_tab[i].d_un.d_val; +#ifdef DEBUG + pf(__func__": needed for this lib: "); pf(lib_name); pf("\n"); +#endif + _dl_queue_lib(lib_name,flags); + } + } + + if (_dl_open_dep()) { + _dl_error = 1; + return 0; + } + + /* relocate */ + if (rel) { +#ifdef DEBUG + pf(__func__": try to relocate some values\n"); +#endif + if (_dl_relocate(dh,(Elf_Rel*)rel,relsize/relent)) { + munmap(dh->mem_base,dh->mem_size); + _dl_free_handle(dh); + return 0; + } + } + + /* do PTL / GOT relocation */ + if (pltreltype == DT_REL) { + Elf_Rel *tmp = jmprel; +#ifdef DEBUG + pf(__func__": rel got\n"); +#endif + for (;(char*)tmp<(((char*)jmprel)+pltrelsize);(char*)tmp=((char*)tmp)+sizeof(Elf_Rel)) { + if ((flags&RTLD_NOW)) { + unsigned long sym=(unsigned long)_dl_sym(dh,ELF_R_SYM(tmp->r_info)); + if (sym) *((unsigned long*)(dh->mem_base+tmp->r_offset))=sym; + else { + _dl_free_handle(dh); + _dl_error = 4; + return 0; + } + } + else + *((unsigned long*)(dh->mem_base+tmp->r_offset))+=(unsigned long)dh->mem_base; +#if 0 + DEBUG("_dl_load rel @ %08lx with type %d -> %d\n",(long)dh->mem_base+tmp->r_offset,ELF_R_TYPE(tmp->r_info),ELF_R_SYM(tmp->r_info)); + DEBUG("_dl_load -> %08lx\n",*((unsigned long*)(dh->mem_base+tmp->r_offset))); +#endif + } + } + if (pltreltype == DT_RELA) { + Elf_Rela *tmp = jmprel; +#ifdef DEBUG + pf(__func__": rela got\n"); +#endif + for (;(char*)tmp<(((char*)jmprel)+pltrelsize);(char*)tmp=((char*)tmp)+sizeof(Elf_Rela)) { + if ((flags&RTLD_NOW)) { + unsigned long sym=(unsigned long)_dl_sym(dh,ELF_R_SYM(tmp->r_info)); + if (sym) *((unsigned long*)(dh->mem_base+tmp->r_offset))=sym; + else { + _dl_free_handle(dh); + _dl_error = 4; + return 0; + } + } + else + *((unsigned long*)(dh->mem_base+tmp->r_offset))=(unsigned long)(dh->mem_base+tmp->r_addend); +#if 0 + DEBUG("_dl_load rela @ %08lx with type %d -> %d\n",(long)dh->mem_base+tmp->r_offset,ELF_R_TYPE(tmp->r_info),ELF_R_SYM(tmp->r_info)); + DEBUG("_dl_load -> %08lx\n",*((unsigned long*)(dh->mem_base+tmp->r_offset))); +#endif + } + } + + /* _dl_load depending libs ... */ +#ifdef DEBUG + pf(__func__": post resolve, pre init\n"); +#endif + if (init) init(); +#ifdef DEBUG + pf(__func__": post init\n"); +#endif + + return dh; +} + +void *_dl_load(const char*fn, const char*pathname, int fd, int flags) +{ + struct _dl_handle* ret=0; + if ((ret=_dl_map_lib(fn,pathname,fd,flags))) { + ret=__dl_dyn_scan(ret,(void*)(ret->dyn_str_tab),flags); + } + return ret; +} diff --git a/mdk-stage1/dietlibc/libdl/_dl_main.c b/mdk-stage1/dietlibc/libdl/_dl_main.c new file mode 100644 index 000000000..8ecf44f0b --- /dev/null +++ b/mdk-stage1/dietlibc/libdl/_dl_main.c @@ -0,0 +1,1059 @@ +#ifdef __OD_CLEAN_ROOM + +#define __DIET_LD_SO__ + +/* + * this is the dietlibc libdl & dynamic-linker + * + * NEED to be compiled with -fPIC ... + */ +#include +#include +#include "_dl_int.h" +#include "_dl_rel.h" + +void _start(void); /* entry of lib... */ + +static void (*fini_entry)(void)=0; +static char **_dl_environ=0; +static unsigned long loadaddr=0; +static unsigned long prog_entry=0; + +static Elf_Phdr*prog_ph; +static unsigned long prog_ph_size; +static unsigned long prog_ph_num; + +static unsigned long at_uid; +static unsigned long at_euid; +static unsigned long at_gid; +static unsigned long at_egid; +static unsigned long at_pagesize; + +/* this are the "local syscalls" */ +void _dl_sys_exit(int val); +int _dl_sys_read(int fd,char*buf,unsigned long len); +int _dl_sys_write(int fd,char*buf,unsigned long len); +int _dl_sys_open(const char*filename,int flags,int mode); +int _dl_sys_close(int fd); +void*_dl_sys_mmap(void*start,unsigned long length,int prot,int flags,int fd,unsigned long offset); +int _dl_sys_munmap(void*start,unsigned long length); +int _dl_sys_mprotect(const void*addr,unsigned long len,int prot); +int _dl_sys_fstat(int filedes, struct stat *buf); + +extern char*strdup(const char*s); + +#ifdef __i386__ + +asm(".text \n" +".type _start,@function \n" +"_start: \n" +" movl %esp, %ebp # save stack \n" +" movl (%ebp), %ecx # argc \n" +" leal 4(%ebp), %esi # argv \n" +" leal 4(%esi,%ecx,4), %eax # envp \n" + +"# PIC code \n" +" call getpic \n" +" addl $_GLOBAL_OFFSET_TABLE_, %ebx \n" + +"# for calculation of load addr, get 'relocated' address of _DYNAMIC \n" +" leal _DYNAMIC@GOTOFF(%ebx), %edx \n" + +"# put parameter on stack and call _dl_main \n" +" pushl %edx \n" +" pushl %eax \n" +" pushl %esi \n" +" pushl %ecx \n" +" call _dl_main \n" + +"# restore stack \n" +" movl %ebp, %esp \n" + +"# get fini pointer \n" +" movl fini_entry@GOTOFF(%ebx), %edx \n" + +"# clear callee-save-register like kernel \n" +" xorl %ebx, %ebx \n" +" xorl %ebp, %ebp \n" +" xorl %edi, %edi \n" +" xorl %esi, %esi \n" + +"# jump to program entry point \n" +" jmp *%eax \n" + +"_dl_sys_read: \n" +" movb $3,%al \n" +" jmp _dl_sys_call3 \n" +"_dl_sys_write: \n" +" movb $4,%al \n" +" jmp _dl_sys_call3 \n" +"_dl_sys_open: \n" +" movb $5,%al \n" +" jmp _dl_sys_call3 \n" +"_dl_sys_close: \n" +" movb $6,%al \n" +" jmp _dl_sys_call3 \n" +"_dl_sys_mmap: \n" +" movb $90,%al \n" +" leal 4(%esp),%edx \n" +" pushl %edx \n" +" call _dl_sys_call3 \n" +" popl %ecx \n" +" ret \n" +"_dl_sys_munmap: \n" +" movb $91,%al \n" +" jmp _dl_sys_call3 \n" +"_dl_sys_fstat: \n" +" movb $108,%al \n" +" jmp _dl_sys_call3 \n" +"_dl_sys_mprotect: \n" +" movb $125,%al \n" +" jmp _dl_sys_call3 \n" +"_dl_sys_exit: \n" +" movb $1,%al \n" +"_dl_sys_call3: \n" +" movzbl %al,%eax \n" +" pushl %ebx \n" +" movl %esp,%ebx \n" +" movl 16(%ebx),%edx \n" +" movl 12(%ebx),%ecx \n" +" movl 8(%ebx),%ebx \n" +" int $0x80 \n" +" popl %ebx \n" +" ret \n" + +".type _dl_jump,@function \n" +"_dl_jump: \n" +" pushl %eax # save register args... \n" +" pushl %ecx \n" +" pushl %edx \n" + +" push 16(%esp) # 2. arg from plt \n" +" push 16(%esp) # 1. arg from plt \n" +" call do_resolve \n" +" add $8, %esp \n" + +" popl %edx # restore register args... \n" +" popl %ecx \n" +" xchgl %eax, (%esp) # restore eax and save function pointer (for return) \n" +" ret $8 # remove arguments from plt and jump to REAL function \n" + +"# GET Position In Code :) \n" +"getpic: movl (%esp), %ebx \n" +" ret"); + +static inline unsigned long* get_got(void) { + register unsigned long *got asm ("%ebx"); + return got; +} + +static inline int work_on_pltgot(struct _dl_handle*dh) { + /* declare _dl_jump static otherwise we have a GOT access BEFOR we have the resolver */ + static void _dl_jump(void); + if ((dh->plt_rel)&&(!(dh->flags&RTLD_NOW))) { + unsigned long*tmp=dh->pltgot; + /* GOT */ + tmp[0]+=(unsigned long)dh->mem_base; /* reloc dynamic pointer */ + tmp[1] =(unsigned long)dh; /* the handle */ + tmp[2] =(unsigned long)(_dl_jump); /* sysdep jump to do_resolve */ + } + return 0; +} + +#elif __arm__ + +asm(".text \n" +".type _start,function \n" +"_start: \n" +" mov r4, sp \n" +" mov fp, #0 @ start new stack frame \n" + +" ldr a1, [sp], #4 @ argc \n" +" mov a2, sp @ argv \n" + +" add a3, a2, a1, lsl #2 @ envp \n" +" add a3, a3, #4 \n" + +" ldr sl, .L_got @ PIC code \n" +"1: add sl, pc, sl \n" + +" ldr a4, .L_la @ get 'relocated' address of _DYNAMIC \n" +" add a4, a4, sl \n" + +" bl _dl_main @ call _dl_main \n" + +" mov sp, r4 \n" + +" mov lr, a1 @ save program entry point \n" + +" ldr a1, [pc, #.L_fe-(.+8)] @ agrument 1: global fini entry \n" +" ldr a1, [sl, a1] \n" + +" mov pc, lr \n" + +".L_got: .long _GLOBAL_OFFSET_TABLE_-(1b+8) \n" +".L_la: .long _DYNAMIC(GOTOFF) \n" +".L_fe: .long fini_entry(GOTOFF) \n" + +"_dl_sys_exit: \n" +" swi #0x900001 @ exit \n" +" eor pc, lr, lr @ OR DIE ! \n" +" mov pc, lr \n" + +"_dl_sys_read: \n" +" swi #0x900003 @ read \n" +" mov pc, lr \n" +"_dl_sys_write: \n" +" swi #0x900004 @ write \n" +" mov pc, lr \n" +"_dl_sys_open: \n" +" swi #0x900005 @ open \n" +" mov pc, lr \n" +"_dl_sys_close: \n" +" swi #0x900006 @ close \n" +" mov pc, lr \n" +"_dl_sys_mmap: \n" +" stmdb sp!,{r0,r1,r2,r3} \n" +" mov r0, sp \n" +" swi #0x900090 @ mmap \n" +" add sp, sp, #16 \n" +" mov pc, lr \n" +"_dl_sys_munmap: \n" +" swi #0x900091 @ munmap \n" +" mov pc, lr \n" +"_dl_sys_fstat: \n" +" swi #0x900108 @ fstat \n" +" mov pc, lr \n" +"_dl_sys_mprotect: \n" +" swi #0x900125 @ mprotect \n" +" mov pc, lr \n" + +".type _dl_jump,function \n" +"_dl_jump: \n" +" stmdb sp!, {r0, r1, r2, r3} @ save arguments \n" + +" sub r1, ip, lr @ dyntab entry \n" +" sub r1, r1, #4 \n" +" add r1, r1, r1 \n" + +" ldr r0, [lr, #-4] @ dynlib handle \n" + +" bl do_resolve \n" + +" mov r12, r0 \n" +" ldmia sp!, {r0, r1, r2, r3, lr} @ restore arguments \n" +" mov pc, r12"); + +static inline unsigned long* get_got(void) { + register unsigned long *got asm ("sl"); + return got; +} + +static inline int work_on_pltgot(struct _dl_handle*dh) { + /* declare _dl_jump static otherwise we have a GOT access BEFOR we have the resolver */ + static void _dl_jump(void); + if ((dh->plt_rel)&&(!(dh->flags&RTLD_NOW))) { + unsigned long*tmp=dh->pltgot; + /* GOT */ + tmp[0]+=(unsigned long)dh->mem_base; /* reloc dynamic pointer */ + tmp[1] =(unsigned long)dh; /* the handle */ + tmp[2] =(unsigned long)(_dl_jump); /* sysdep jump to do_resolve */ + } + return 0; +} + +#else +#error "libdl: arch not supported" +#endif + +static void*_dl_load(const char*fn,const char*pathname,int fd,int flags); + +/* here do the code includes */ + +/* strncpy */ +static char*strncpy(register char*s,register const char*t,register unsigned long n) { + char *dest=s; + for(;n;--n) { + char ch=*t; + *s=ch; + if (ch==0) return dest; + ++s; ++t; + } + return 0; +} + +/* strlen.c */ +static unsigned long strlen(register const char*s) { + register unsigned long i; + if (!s) return 0; + for (i=0; *s; ++s) ++i; + return i; +} + +/* strcmp.c */ +static int strcmp(register const unsigned char*s,register const unsigned char*t) { + register char x; + for (;;) { + x = *s; if (x != *t) break; if (!x) break; ++s; ++t; + } + return ((int)(unsigned int)x) - ((int)(unsigned int)*t); +} + +/* strcspn.c */ +static unsigned long strcspn(const char*s,const char*reject) { + unsigned long l=0; + int a=1,i,al=strlen(reject); + while((a)&&(*s)) { + for(i=0;(a)&&(i>=4) { + register unsigned long v='0'|(l&15); + if (v>'9') v+=0x27; + buf[--i]=v; + } + _dl_sys_write(2,buf,max); +} + +/* the never free strdup (internal) */ +static unsigned long _dl_lib_strdup_len=0; +static char*_dl_lib_strdup_str; +static char*_dl_lib_strdup(const char*s) { + char*ret=_dl_lib_strdup_str; + unsigned long l=strlen(s)+1; + if (_dl_lib_strdup_lennext) + if (tmp->fini) tmp->fini(); +} + +/* exit ! */ +static void _DIE_() { _dl_sys_exit(213); } + +/* lazy function resolver */ +static unsigned long do_resolve(struct _dl_handle*dh,unsigned long off) { + _dl_rel_t *tmp = ((void*)dh->plt_rel)+off; + int sym=ELF_R_SYM(tmp->r_info); + register unsigned long sym_val; + + if (0) sym_val=(unsigned long)do_resolve; /* TRICK: no warning */ + + /* modify GOT for REAL symbol */ + sym_val=(unsigned long)_dl_sym(dh,sym); + *((unsigned long*)(dh->mem_base+tmp->r_offset))=sym_val; + + /* JUMP (arg sysdep...) */ + if (sym_val) return sym_val; + /* can't find symbol */ + return (unsigned long)_DIE_; +} + +/* library loader */ + +/* ELF -> MMAP permissions */ +static inline int map_flags(int flags) { + int perm = 0; + if (flags & PF_X) perm|=PROT_EXEC; + if (flags & PF_R) perm|=PROT_READ; + if (flags & PF_W) perm|=PROT_WRITE; + return perm; +} + +/* a simple mmap wrapper */ +static inline void*do_map_in(void*base,unsigned long length,int flags,int fd,unsigned long offset) { + register int op = MAP_PRIVATE; + if (base) op|=MAP_FIXED; + return _dl_sys_mmap(base, length, map_flags(flags), op, fd, offset); +} + +/* map a library into memory */ +#define _ELF_DWN_ROUND(ps,n) ((n)&(~((ps)-1))) +#define _ELF_UP_ROUND(ps,n) ((((n)&((ps)-1))?(ps):0)+_ELF_DWN_ROUND((ps),(n))) +#define _ELF_RST_ROUND(ps,n) ((n)&((ps)-1)) +static struct _dl_handle*_dl_map_lib(const char*fn,const char*pathname,int fd,int flags) { + struct _dl_handle*ret=0; + int i; + unsigned char buf[1024]; + char *m=0,*d=0; + + unsigned long l; + struct stat st; + + Elf_Ehdr*eeh; + Elf_Phdr*eph; + + int ld_nr=0; + Elf_Phdr*ld[4]={0,0,0,0}; + Elf_Phdr*dyn=0; + + if (0) { pathname=0; } /* no unused parameter */ + if (fd==-1) return 0; + + if (_dl_sys_fstat(fd,&st)<0) { +err_out_close: + _dl_sys_close(fd); + _dl_error_data=fn; + _dl_error=2; + return 0; + } else { + /* use st_dev and st_ino for identification */ + } + + if (_dl_sys_read(fd,buf,1024)<128) goto err_out_close; + + eeh=(Elf_Ehdr*)buf; + eph=(Elf_Phdr*)&buf[eeh->e_phoff]; + + for (i=0;ie_phnum;++i) { + if (eph[i].p_type==PT_LOAD) { + if (ld_nr>3) goto err_out_close; + ld[ld_nr++]=eph+i; + } + if (eph[i].p_type==PT_DYNAMIC) { + dyn=eph+i; + } + } + + if (ld_nr==1) { + unsigned long offset=_ELF_DWN_ROUND(at_pagesize,ld[0]->p_offset); + unsigned long off =_ELF_RST_ROUND(at_pagesize,ld[0]->p_offset); + unsigned long length=_ELF_UP_ROUND(at_pagesize,ld[0]->p_memsz+off); + ret=_dl_get_handle(); + m=(char*)do_map_in(0,length,ld[0]->p_flags,fd,offset); + if (m==MAP_FAILED) goto err_out_free; + /* zero pad bss */ + l=ld[0]->p_offset+ld[0]->p_filesz; + memset(m+l,0,length-l); + + ret->mem_base=m; + ret->mem_size=length; + } + else if (ld_nr==2) { /* aem... yes Quick & Really Dirty / for the avarage 99% */ +// unsigned long text_addr = _ELF_DWN_ROUND(at_pagesize,ld[0]->p_vaddr); /* do we need this ? */ + unsigned long text_offset=_ELF_DWN_ROUND(at_pagesize,ld[0]->p_offset); + unsigned long text_off =_ELF_RST_ROUND(at_pagesize,ld[0]->p_offset); + unsigned long text_size =_ELF_UP_ROUND(at_pagesize,ld[0]->p_memsz+text_off); + + unsigned long data_addr =_ELF_DWN_ROUND(at_pagesize,ld[1]->p_vaddr); + unsigned long data_offset=_ELF_DWN_ROUND(at_pagesize,ld[1]->p_offset); + unsigned long data_off =_ELF_RST_ROUND(at_pagesize,ld[1]->p_offset); + unsigned long data_size =_ELF_UP_ROUND(at_pagesize,ld[1]->p_memsz+data_off); + unsigned long data_fsize =_ELF_UP_ROUND(at_pagesize,ld[1]->p_filesz+data_off); + + ret=_dl_get_handle(); + /* mmap all mem_blocks for *.so */ + m=(char*)do_map_in(0,text_size+data_size,ld[0]->p_flags,fd,text_offset); + if (m==MAP_FAILED) { +err_out_free: + _dl_free_handle(ret); + _dl_sys_close(fd); + return 0; + } + + /* release data,bss part */ + _dl_sys_mprotect(m+data_addr,data_size,PROT_NONE); + + /* mmap data,bss part */ + d=(char*)do_map_in(m+data_addr,data_fsize,ld[1]->p_flags,fd,data_offset); + + /* zero pad bss */ + l=data_off+ld[1]->p_filesz; + memset(d+l,0,data_fsize-l); + /* more bss ? */ + if (data_size>data_fsize) { + l=data_size-data_fsize; + _dl_sys_mmap(d+data_fsize,l,PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS,-1,0); + } + + ret->mem_base=m; + ret->mem_size=text_size+data_size; + } + else { + _dl_error_data=fn; + _dl_error=7; + } + + if (ret) { + ++ret->lnk_count; + if (flags&RTLD_USER) + ret->name=strdup(fn); + else + ret->name=_dl_lib_strdup(fn); + ret->flags=flags; + ret->dynamic=(Elf_Dyn*)(m+dyn->p_vaddr); + } + + _dl_sys_close(fd); + return ret; +} + +/* dynamic section parser */ +static struct _dl_handle* _dl_dyn_scan(struct _dl_handle*dh,Elf_Dyn*_dynamic) { + void(*init)(void)=0; + + _dl_rel_t* plt_rel=0; + unsigned long plt_relsz=0; + + _dl_rel_t* rel=0; + unsigned long relent=0; + unsigned long relsize=0; + + int i; + +#ifdef DEBUG + pf(__FUNCTION__); pf(": pre dynamic scan "); ph((unsigned long)dh); pf("\n"); +#endif + for(i=0;_dynamic[i].d_tag;++i) { + switch(_dynamic[i].d_tag) { + /* this depends on dyn_str_tab -> second run */ + case DT_NEEDED: + case DT_SONAME: + break; + + /* BASIC DYNAMIC STUFF */ + case DT_HASH: + dh->hash_tab = (unsigned long*)(dh->mem_base+_dynamic[i].d_un.d_ptr); +#ifdef DEBUG + pf(__FUNCTION__); pf(": have hash @ "); ph((long)dh->hash_tab); pf("\n"); +#endif + break; + case DT_SYMTAB: + dh->dyn_sym_tab = (Elf_Sym*)(dh->mem_base+_dynamic[i].d_un.d_ptr); +#ifdef DEBUG + pf(__FUNCTION__); pf(": have dyn_sym_tab @ "); ph((long)dh->dyn_sym_tab); pf("\n"); +#endif + break; + case DT_STRTAB: + dh->dyn_str_tab = (char*)(dh->mem_base+_dynamic[i].d_un.d_ptr); +#ifdef DEBUG + pf(__FUNCTION__); pf(": have dyn_str_tab @ "); ph((long)dh->dyn_str_tab); pf("\n"); +#endif + break; + + /* DYNAMIC INIT/FINI (constructors/destructors) */ + case DT_FINI: + dh->fini = (void(*)(void))(dh->mem_base+_dynamic[i].d_un.d_val); +#ifdef DEBUG + pf(__FUNCTION__); pf(": have fini @ "); ph((long)dh->fini); pf("\n"); +#endif + break; + case DT_INIT: + init = (void(*)(void))(dh->mem_base+_dynamic[i].d_un.d_val); +#ifdef DEBUG + pf(__FUNCTION__); pf(": have init @ "); ph((long)init); pf("\n"); +#endif + break; + + /* PLT RELOCATION */ + case DT_PLTGOT: + dh->pltgot = (unsigned long*)(dh->mem_base+_dynamic[i].d_un.d_val); +#ifdef DEBUG + pf(__FUNCTION__); pf(": have plt/got @ "); ph((long)dh->pltgot); pf("\n"); +#endif + break; + case DT_PLTREL: + if (_dynamic[i].d_un.d_val!=_DL_REL_T) { +#ifdef DEBUG + pf(__FUNCTION__); pf(": have incompatible relocation type\n"); +#endif + _dl_error_data=dh->name; + _dl_error=6; + return 0; + } + break; + case DT_JMPREL: + plt_rel = (_dl_rel_t*)(dh->mem_base+_dynamic[i].d_un.d_val); + dh->plt_rel = plt_rel; +#ifdef DEBUG + pf(__FUNCTION__); pf(": have jmprel @ "); ph((long)plt_rel); pf("\n"); +#endif + break; + case DT_PLTRELSZ: + plt_relsz = _dynamic[i].d_un.d_val; +#ifdef DEBUG + pf(__FUNCTION__); pf(": have pltrelsize @ "); ph((long)plt_relsz); pf("\n"); +#endif + break; + + /* BASIC RELOCATION */ + case DT_REL: + rel = (_dl_rel_t*)(dh->mem_base+_dynamic[i].d_un.d_val); +#ifdef DEBUG + pf(__FUNCTION__); pf(": have rel @ "); ph((long)rel); pf("\n"); +#endif + break; + case DT_RELENT: + relent=_dynamic[i].d_un.d_val; +#ifdef DEBUG + pf(__FUNCTION__); pf(": have relent @ "); ph((long)relent); pf("\n"); +#endif + break; + case DT_RELSZ: + relsize=_dynamic[i].d_un.d_val; +#ifdef DEBUG + pf(__FUNCTION__); pf(": have relsize @ "); ph((long)relsize); pf("\n"); +#endif + break; + + + /* TEXT RELOCATIONS POSSIBLE -> NO SHARED OBJECT */ + case DT_TEXTREL: +#ifdef DEBUG + pf(__FUNCTION__); pf(": found possible textrelocation -> "); pf(dh->name); pf(" is not compiled as a shared library\n"); +#endif + _dl_error_data=dh->name; + _dl_error=3; + return 0; + break; + + /* OTHERS */ + default: +#ifdef DEBUG +#if 0 + pf(__FUNCTION__); pf(": unknown "); ph(_dynamic[i].d_tag); pf(", "); ph(_dynamic[i].d_un.d_val); pf("\n"); +#endif +#endif + break; + } + } + + for(i=0;_dynamic[i].d_tag;i++) { + if (dh->name) { /* librabry can have a SONAME */ + if (_dynamic[i].d_tag==DT_SONAME) { +#ifdef DEBUG + pf(__FUNCTION__); pf(": pre soname: "); pf(dh->name); pf("\n"); +#endif + if (dh->flags&RTLD_USER) free(dh->name); + dh->flags&=~RTLD_NOSONAME; + dh->name = dh->dyn_str_tab+_dynamic[i].d_un.d_val; +#ifdef DEBUG + pf(__FUNCTION__); pf(": have soname: "); pf(dh->name); pf("\n"); +#endif + } + } + else { /* programs can have a LD_RUN_PATH */ + if (_dynamic[i].d_tag==DT_RPATH) { + register char *rpath=dh->dyn_str_tab+_dynamic[i].d_un.d_val; + _dl_search_rpath=rpath; +#ifdef DEBUG + pf(__FUNCTION__); pf(": have runpath: "); pf(rpath); pf("\n"); +#endif + } + } + } + +#ifdef DEBUG + pf(__FUNCTION__); pf(": post dynamic scan "); ph((unsigned long)dh); pf("\n"); +#endif + + if (work_on_pltgot(dh)) { + _dl_error_data=dh->name; + _dl_error=3; + return 0; + } + +#ifdef DEBUG + pf(__FUNCTION__); pf(": pre load depending libraries "); ph((unsigned long)dh); pf("\n"); +#endif + /* load depending libs */ + for(i=0;_dynamic[i].d_tag;++i) { + if (_dynamic[i].d_tag==DT_NEEDED) { + char *lib_name=dh->dyn_str_tab+_dynamic[i].d_un.d_val; +#ifdef DEBUG + pf(__FUNCTION__); pf(": needed for this lib: "); pf(lib_name); pf("\n"); +#endif + _dl_queue_lib(lib_name,dh->flags); + } + } +#ifdef DEBUG + pf(__FUNCTION__); pf(": pre open depending libraries 2 "); ph((unsigned long)dh); pf("\n"); +#endif + if (_dl_open_dep()) { + return 0; + } + +#ifdef DEBUG + pf(__FUNCTION__); pf(": post load depending libraries, pre resolve "); ph((unsigned long)dh); pf("\n"); +#endif + + /* relocation */ + if (rel) { +#ifdef DEBUG + pf(__FUNCTION__); pf(": try to relocate some values\n"); +#endif + if (_dl_relocate(dh,rel,relsize/relent)) return 0; + } + + /* do PTL / GOT relocation */ + if (plt_rel) { + _dl_rel_t *tmp,*max=((void*)plt_rel)+plt_relsz; +#ifdef DEBUG + pf(__FUNCTION__); pf(": rel plt/got\n"); +#endif + for(tmp=plt_rel;tmpflags&RTLD_NOW)) { + unsigned long sym=(unsigned long)_dl_sym(dh,ELF_R_SYM(tmp->r_info)); + if (sym) *((unsigned long*)(dh->mem_base+tmp->r_offset))=sym; + else { + _dl_error_data=dh->name; + _dl_error=4; + return 0; + } + } + else + _DL_REL_PLT(dh->mem_base,tmp); +#ifdef DEBUG + pf(__FUNCTION__); pf(": rel @ "); ph((long)dh->mem_base+tmp->r_offset); pf(" with type "); + ph(ELF_R_TYPE(tmp->r_info)); pf(" and sym "); ph(ELF_R_SYM(tmp->r_info)); + pf(" -> "); ph(*((unsigned long*)(dh->mem_base+tmp->r_offset))); pf("\n"); +#endif + } + } + +#ifdef DEBUG + pf(__FUNCTION__); pf(": post resolve, pre init "); ph((unsigned long)dh); pf("\n"); +#endif + if (init) init(); +#ifdef DEBUG + pf(__FUNCTION__); pf(": post init "); ph((unsigned long)dh); pf("\n"); +#endif + + return dh; +} + +static void*_dl_load(const char*fn,const char*pathname,int fd,int flags) { + struct _dl_handle*ret=0; + if ((ret=_dl_map_lib(fn,pathname,fd,flags))) { + ret=_dl_dyn_scan(ret,ret->dynamic); + } + return ret; +} + + +/* ELF AUX parser */ +static void _dl_elfaux(register unsigned long*ui) { + register struct elf_aux { + unsigned long type; + unsigned long val; + } *ea; + + while (*ui) ++ui; + /* now *ui points to the tailing NULL-pointer of the envirioment */ + + /* walk the elf_aux table */ + for (ea=(struct elf_aux*)(ui+1); ea->type; ++ea) { + switch (ea->type) { + case AT_EXECFD: /* 2 */ + /* DIE! DIE! DIE! */ + pf("kernel gives us an unsupported binary load type...\n"); + _dl_sys_exit(42); + break; + + case AT_PHDR: /* 3 */ + prog_ph=(Elf_Phdr*)ea->val; +#ifdef DEBUG + pf("program header @ "); ph(ea->val); pf("\n"); +#endif + break; + case AT_PHENT: /* 4 */ + prog_ph_size=ea->val; +#ifdef DEBUG + pf("program header size "); ph(ea->val); pf("\n"); +#endif + break; + case AT_PHNUM: /* 5 */ + prog_ph_num=ea->val; +#ifdef DEBUG + pf("program header # "); ph(ea->val); pf("\n"); +#endif + break; + + case AT_PAGESZ: /* 6 */ + at_pagesize=ea->val; +#ifdef DEBUG + pf("page size "); ph(ea->val); pf("\n"); +#endif + break; + + case AT_BASE: /* 7 */ + loadaddr=ea->val; +#ifdef DEBUG + pf("interpreter base: "); ph(ea->val); pf("\n"); +#endif + break; + +#if 0 + case AT_FLAGS: /* 8 */ +#ifdef DEBUG + pf("flags "); ph(ea->val); pf("\n"); +#endif + break; +#endif + + case AT_ENTRY: /* 9 */ + prog_entry=ea->val; +#ifdef DEBUG + pf("start program @ "); ph(ea->val); pf("\n"); +#endif + break; + + case AT_NOTELF: /* 10 */ + pf("this is an ELF-loader... and therefor can't handle anything else.\n"); + _dl_sys_exit(42); + break; + + case AT_UID: /* 11 */ + at_uid=ea->val; +#ifdef DEBUG + pf(" UID: "); ph(ea->val); pf("\n"); +#endif + break; + case AT_EUID: /* 12 */ + at_euid=ea->val; +#ifdef DEBUG + pf("EUID: "); ph(ea->val); pf("\n"); +#endif + break; + case AT_GID: /* 13 */ + at_gid=ea->val; +#ifdef DEBUG + pf(" GID: "); ph(ea->val); pf("\n"); +#endif + break; + case AT_EGID: /* 14 */ + at_egid=ea->val; +#ifdef DEBUG + pf("EGID: "); ph(ea->val); pf("\n"); +#endif + break; + +#if 0 + case AT_PLATFORM: /* 15 */ +#ifdef DEBUG + pf("CPU: "); ph(ea->val); pf("\n"); +#endif + break; + case AT_HWCAP: /* 16 */ +#ifdef DEBUG + pf("CPU capabilities: "); ph(ea->val); pf("\n"); +#endif + break; + case AT_CLKTCK: /* 17 */ +#ifdef DEBUG + pf("CLK per sec "); ph( ea->val); pf("\n"); +#endif + break; + case AT_FPUCW: /* 18 */ +#ifdef DEBUG + pf("FPU control word "); ph( ea->val); pf("\n"); +#endif + break; +#endif + + default: + break; + } + } +} + + +/* start of libdl dynamic linker */ +static unsigned long _dl_main(int argc,char*argv[],char*envp[],unsigned long _dynamic) { + unsigned long*got; + struct _dl_handle*prog,*mydh; + struct _dl_handle my_dh; + Elf_Dyn*prog_dynamic=0; + unsigned int i; + + if (0) _dl_main(argc,argv,envp,_dynamic); /* TRICK: no warning */ + + /* prepare to bootstarp the relocations */ + got=get_got(); + _dl_environ=envp; + + /* run elf_aux (kernel provided misc data) */ + _dl_elfaux((unsigned long*)envp); + + if (loadaddr==0) { + pf("\ndiet libdl.so/dynamic-linker can't be started as a program !\n\n SORRY...\n\n"); + return (unsigned long)_DIE_; + } + + memset(&my_dh,0,sizeof(my_dh)); + my_dh.mem_base=(char*)loadaddr; + my_dh.mem_size=0; + my_dh.lnk_count=1024; + my_dh.name="libdl.so"; + my_dh.flags=LDSO_FLAGS; + + got[1]=0; /* NOT YET (my_dh) */ + got[2]=(unsigned long)_DIE_; /* NO lazy symbol resolver as long as we are not ready */ + +#ifdef DEBUG + pf(__FUNCTION__); pf(": pre scan\n"); +#endif + /* bootstrap relocation */ + if (_dl_dyn_scan(&my_dh,(Elf_Dyn*)_dynamic)==0) { + pf("error with dyn_scan myself\n"); + return (unsigned long)_DIE_; + } +#ifdef DEBUG + pf(__FUNCTION__); pf(": post scan\n"); +#endif + + /* now we are save to use anything :) (hopefully) */ + + fini_entry=tt_fini; + + prog=_dl_get_handle(); + +#ifdef DEBUG + pf(__FUNCTION__); pf(": ugly, ugly, COPY pregenerated handle to real handle\n"); +#endif + mydh=_dl_get_handle(); + { + register struct _dl_handle*tmp=mydh->prev; + memcpy(mydh,&my_dh,sizeof(struct _dl_handle)); + mydh->prev=tmp; + } + got[1]=(unsigned long)mydh; + +#ifdef DEBUG + pf(__FUNCTION__); pf(": MORE ugly: prepare program...\n"); +#endif + for(i=0;(iname=0; + prog->lnk_count=1024; + prog->dynamic=prog_dynamic; + prog->flags=LDSO_FLAGS; + +#ifdef DEBUG + pf(__FUNCTION__); pf(": dyn_scan program...\n"); +#endif + if (_dl_dyn_scan(prog,(Elf_Dyn*)prog_dynamic)==0) { + _dl_error_location="error in dyn_scan the program"; + pf(dlerror()); pf("\n"); + return (unsigned long)_DIE_; + } + + /* now start the program */ +#ifdef DEBUG + pf(__FUNCTION__); pf(": now jump to program entrypoint\n"); +#endif + return prog_entry; +} + +#endif diff --git a/mdk-stage1/dietlibc/libdl/_dl_queue.c b/mdk-stage1/dietlibc/libdl/_dl_queue.c new file mode 100644 index 000000000..5e08020d5 --- /dev/null +++ b/mdk-stage1/dietlibc/libdl/_dl_queue.c @@ -0,0 +1,39 @@ +#include +#include "_dl_int.h" + +#define MAX_QUEUE 64 + +static int _dl_queue_start=0; +static int _dl_queue_stop=0; + +static struct { + const char*name; + int flags; +} _dl_queue[MAX_QUEUE]; + +#ifdef __DIET_LD_SO__ +static +#endif +int _dl_queue_lib(const char*name,int flags) { + if (_dl_find_lib(name)==0) { + register int tmp; + if ((tmp=_dl_queue_stop+1)>=MAX_QUEUE) tmp=0; + if (tmp==_dl_queue_start) return -1; + _dl_queue[_dl_queue_stop].name=name; + _dl_queue[_dl_queue_stop].flags=flags; + _dl_queue_stop=tmp; + } + return 0; +} + +#ifdef __DIET_LD_SO__ +static +#endif +int _dl_open_dep() { + while (_dl_queue_start!=_dl_queue_stop) { + register int tmp=_dl_queue_start; + (++_dl_queue_start>=MAX_QUEUE)?_dl_queue_start=0:0; + if (!_dlopen(_dl_queue[tmp].name,_dl_queue[tmp].flags)) return 1; + } + return 0; +} diff --git a/mdk-stage1/dietlibc/libdl/_dl_rel.c b/mdk-stage1/dietlibc/libdl/_dl_rel.c new file mode 100644 index 000000000..bc8717dc2 --- /dev/null +++ b/mdk-stage1/dietlibc/libdl/_dl_rel.c @@ -0,0 +1,42 @@ +#include + +#include "_dl_int.h" + +static void exit_now(void) { +#ifdef DEBUG + pf(__func__": symbol not found\n"); +#endif + _exit(213); +} + +unsigned long do_rel(struct _dl_handle * tmp_dl, unsigned long off) +{ + Elf_Rel *tmp = ((void*)tmp_dl->plt_rel)+off; + + int sym=ELF_R_SYM(tmp->r_info); + + register unsigned long sym_val; + +#ifdef DEBUG + pf(__func__": "); ph((unsigned long)tmp_dl); pf(" "); ph(off); pf(" on "); + ph((long)tmp_dl->plt_rel); pf("\n"); + pf(__func__": @ "); ph((long)tmp->r_offset); pf(" with type "); + ph(ELF_R_TYPE(tmp->r_info)); pf(" and sym "); ph(sym); + pf(" symval "); ph(tmp_dl->dyn_sym_tab[sym].st_value); pf("\n"); +#endif + + /* modify GOT for REAL symbol */ + //sym_val=((unsigned long)(tmp_dl->mem_base+tmp_dl->dyn_sym_tab[sym].st_value)); + sym_val=(unsigned long)_dl_sym(tmp_dl,sym); + *((unsigned long*)(tmp_dl->mem_base+tmp->r_offset))=sym_val; + +#ifdef DEBUG + pf(__func__": sym "); ph(sym_val); pf("\n"); +#endif + /* JUMP (arg sysdep...) */ + if (sym_val) return sym_val; + /* can't find symbol -> die now */ + return (unsigned long)exit_now; +} + + diff --git a/mdk-stage1/dietlibc/libdl/_dl_rel.h b/mdk-stage1/dietlibc/libdl/_dl_rel.h new file mode 100644 index 000000000..948aa5b79 --- /dev/null +++ b/mdk-stage1/dietlibc/libdl/_dl_rel.h @@ -0,0 +1,25 @@ +#ifndef ___DL_REL_H__ +#define ___DL_REL_H__ + +#if defined(__arm__) || defined(__i386__) || defined(__mips__) +/* this are REL only archs: arm, i386, mips */ + +#define _dl_rel_t Elf_Rel +#define _DL_REL_T DT_REL + +#define _DL_REL_PLT(b,r) (*(unsigned long*)((b)+(r)->r_offset)+=(unsigned long)(b)) + +#elif defined(__alpha__) || defined(__hppa__) || defined(__ppc__) || defined(__sparc__) || defined(__s390__) +/* this are RELA only archs: alpha, chris, hppa, ia64, m68k, ppc, sparc, sparc64, sh, s390 */ + +#define _dl_rel_t Elf_Rela +#define _DL_REL_T DT_RELA + +#define _DL_REL_PLT(b,r) (*(unsigned long*)((b)+(r)->r_offset)=(unsigned long)((b)+(r)->r_addend)) + +#else +/* there are no known linux supported arch with mixed relocation types ... */ +#error "_dl_rel.h: NOT SUPPORTED" +#endif + +#endif diff --git a/mdk-stage1/dietlibc/libdl/_dl_relocate.c b/mdk-stage1/dietlibc/libdl/_dl_relocate.c new file mode 100644 index 000000000..e91e48ccf --- /dev/null +++ b/mdk-stage1/dietlibc/libdl/_dl_relocate.c @@ -0,0 +1,96 @@ +#include "_dl_int.h" + +#include "_dl_rel.h" + +#if 0 +/*--- are other relocation types vital to shared objects ? ---*/ + + R_386_NONE 0 /* No reloc */ + R_386_32 1 /* Direct 32 bit */ + R_386_COPY 5 /* Copy symbol at runtime ?!? */ + R_386_GLOB_DAT 6 /* Create GOT entry */ + R_386_JMP_SLOT 7 /* Create PLT entry */ + R_386_RELATIVE 8 /* Adjust by program base */ + + R_ARM_NONE 0 /* No reloc */ + R_ARM_ABS32 2 /* Direct 32 bit */ + R_ARM_COPY 20 /* Copy symbol at runtime */ + R_ARM_GLOB_DAT 21 /* Create GOT entry */ + R_ARM_JUMP_SLOT 22 /* Create PLT entry */ + R_ARM_RELATIVE 23 /* Adjust by program base */ + +#endif + +static int _dl_apply_relocate(struct _dl_handle*dh,_dl_rel_t*rel) { + int typ,ret=0; + Elf_Addr*loc; + + loc=(Elf_Addr *)(dh->mem_base+rel->r_offset); + +#ifdef DEBUG +#if 0 + pf(__FUNCTION__); pf(": "); ph(ELF_R_TYPE(rel->r_info)); pf(" @ "); ph((unsigned long)loc); + pf(" preval "); ph(*(unsigned long*)loc); pf("\n"); +#endif +#endif + + typ=ELF_R_TYPE(rel->r_info); + +#ifdef __i386__ + if (typ==R_386_32) { /* 1 */ + *loc=(unsigned long)(dh->mem_base+dh->dyn_sym_tab[ELF_R_SYM(rel->r_info)].st_value); + } else if (typ==R_386_COPY) { /* 5 */ + int len=dh->dyn_sym_tab[ELF_R_SYM(rel->r_info)].st_size; +#ifdef DEBUG + pf(__FUNCTION__); pf(": R_386_COPY !\n"); +#endif + memcpy(loc,(void*)(unsigned long)_dl_sym(dh,ELF_R_SYM(rel->r_info)),len); + } else if (typ==R_386_GLOB_DAT) { /* 6 */ + *loc=(unsigned long)_dl_sym(dh,ELF_R_SYM(rel->r_info)); + } else if (typ==R_386_JMP_SLOT) { /* 7 */ + *loc+=(unsigned long)dh->mem_base; + } else if (typ==R_386_RELATIVE) { /* 8 */ + *loc+=(unsigned long)dh->mem_base; + } else if (typ==R_386_NONE) { /* 0 */ + } else + ret=1; +#endif +#ifdef __arm__ + if (typ==R_ARM_ABS32) { /* 2 */ + *loc=(unsigned long)(dh->mem_base+dh->dyn_sym_tab[ELF_R_SYM(rel->r_info)].st_value); + } else if (typ==R_ARM_COPY) { /* 20 */ + int len=dh->dyn_sym_tab[ELF_R_SYM(rel->r_info)].st_size; +#ifdef DEBUG + pf(__FUNCTION__); pf(": R_ARM_COPY !\n"); +#endif + memcpy(loc,(void*)(unsigned long)_dl_sym(dh,ELF_R_SYM(rel->r_info)),len); + } else if (typ==R_ARM_GLOB_DAT) { /* 21 */ + *loc=(unsigned long)_dl_sym(dh,ELF_R_SYM(rel->r_info)); + } else if (typ==R_ARM_JUMP_SLOT) { /* 22 */ + *loc+=(unsigned long)dh->mem_base; + } else if (typ==R_ARM_RELATIVE) { /* 23 */ + *loc+=(unsigned long)dh->mem_base; + } else if (typ==R_ARM_NONE) { /* 0 */ + } else + ret=1; +#endif + +#ifdef DEBUG + pf(__FUNCTION__); pf(": @ "); ph((unsigned long)loc); pf(" val "); ph(*(unsigned long*)loc); pf("\n"); +#endif + return ret; +} + +#ifdef __DIET_LD_SO__ +static +#endif +int _dl_relocate(struct _dl_handle*dh,_dl_rel_t *rel,int num) { + int i; + for (i=0;i>24; + h &= ~g; + } + return h; +} diff --git a/mdk-stage1/dietlibc/libdl/test/test.c b/mdk-stage1/dietlibc/libdl/test/test.c new file mode 100644 index 000000000..d467134ba --- /dev/null +++ b/mdk-stage1/dietlibc/libdl/test/test.c @@ -0,0 +1,20 @@ +#include + +int main(int argc, char **argv) +{ + void *Hlib; + +// if (Hlib=dlopen("libtest.so", RTLD_LAZY)) { + if (Hlib=dlopen("libtest.so", RTLD_NOW)) { + void (*t)(void) = dlsym(Hlib,"test"); + if (t) { + printf("test @ %08lx\n",(long)t); + t(); + } + dlclose(Hlib); + } + else { + printf("%s\n",dlerror()); + } + return 0; +} diff --git a/mdk-stage1/dietlibc/libdl/test/test_so.c b/mdk-stage1/dietlibc/libdl/test/test_so.c new file mode 100644 index 000000000..09d243c56 --- /dev/null +++ b/mdk-stage1/dietlibc/libdl/test/test_so.c @@ -0,0 +1,11 @@ + +int* test(); + +int err +=(int)test +; + +int* test() { + write(1,"helo\n",5); + return &err; +} diff --git a/mdk-stage1/dietlibc/libm/acosh.c b/mdk-stage1/dietlibc/libm/acosh.c new file mode 100644 index 000000000..a09a4c9f0 --- /dev/null +++ b/mdk-stage1/dietlibc/libm/acosh.c @@ -0,0 +1,6 @@ +#include + +double acosh ( double x ) +{ + return log ( x + sqrt (x*x - 1.) ); +} diff --git a/mdk-stage1/dietlibc/libm/asinh.c b/mdk-stage1/dietlibc/libm/asinh.c new file mode 100644 index 000000000..49c6b467f --- /dev/null +++ b/mdk-stage1/dietlibc/libm/asinh.c @@ -0,0 +1,6 @@ +#include + +double asinh ( double x ) +{ + return log ( x + sqrt (x*x + 1.) ); +} diff --git a/mdk-stage1/dietlibc/libm/atanh.c b/mdk-stage1/dietlibc/libm/atanh.c new file mode 100644 index 000000000..bdb3367be --- /dev/null +++ b/mdk-stage1/dietlibc/libm/atanh.c @@ -0,0 +1,8 @@ +#include + +extern const float __half; + +double atanh ( double x ) +{ + return __half * log ( (1.+x) / (1.-x) ); +} diff --git a/mdk-stage1/dietlibc/libm/bessel.c b/mdk-stage1/dietlibc/libm/bessel.c new file mode 100644 index 000000000..ba8a1afcb --- /dev/null +++ b/mdk-stage1/dietlibc/libm/bessel.c @@ -0,0 +1,171 @@ +/*--------------------------------------------------------------------------* + +Name j0, j1, jn - Bessel functions + y0, y1, yn - Weber functions + +Usage double j0 (double x); + double j1 (double x); + double jn (int n, double x); + double y0 (double x); + double y1 (double x); + double yn (int n, double x); + +Prototype in math.h + +Description j0, j1 and jn calculate the Bessel function. + y0, y1 and yn calcualte the Weber function. + +Return value return their return values as doubles. + +*---------------------------------------------------------------------------*/ + +#include + +#define M_C 0.5772156649015328 +#if 0 +#define M_1_PI 0.318309886183790671538 +#define M_2_PI 0.636619772367581343076 +#define M_PI 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067982148 +#endif + + +#define EXPL(x) ((((short *)&x)[4] & 0x7FFF) >> 0) +#define EXPD(x) ((((short *)&x)[3] & 0x7FF0) >> 4) +#define EXPF(x) ((((short *)&x)[1] & 0x7F80) >> 7) + +#define SQUARE(x) (long) (My - (x) * (x) ) + + +static long double P ( int My, double* x ) +{ + long double Sum = 0.; + long double Fact = 1.; + long double z182 = -0.015625 / (x[0] * x[0]); + register int i; + + for ( i = 1; ; i += 2 ) { + Fact *= SQUARE(i+i-1) * SQUARE(i+i+1) * z182 / (i*(i+1)); + if ( EXPL (Fact) < 0x3FFF-53 ) + break; + Sum += Fact; + } + return 1. + Sum; +} + +static long double Q ( int My, double* x ) +{ + long double Fact = (My-1) / x[0] * 0.125; + long double Sum = Fact; + long double z182 = -0.015625 / (x[0]*x[0]); + register int i; + + for ( i = 2; ; i += 2 ) { + Fact *= SQUARE(i+i-1) * SQUARE(i+i+1) * z182 / (i*(i+1)); + if ( EXPL (Fact) < 0x3FFF-53 ) + break; + Sum += Fact; + } + return Sum; +} + + +static long double ___jn ( int n, double* x ) +{ + long double Sum; + long double Fact; + long double y; + register int i; + double xx; + long double Xi; + int My; + + if ( n < 0 ) + return n & 1 ? ___jn (-n, x) : -___jn (-n, x); + + if ((x[0] >= 17.7+0.0144*(n*n))) { + Xi = x[0] - M_PI * (n*0.5 + 0.25); + My = n*n << 2; + + return sqrt ( M_2_PI/x[0] ) * ( P(My,x) * cos(Xi) - Q(My,x) * sin(Xi) ); + } + xx = x[0] * 0.5; + Sum = 0.; + Fact = 1.; + y = -xx * xx; + + for ( i = 1; i <= n; i++ ) + Fact *= xx/i; + for ( i = 1; ; i++ ) { + Sum += Fact; + Fact *= y / (i*(n+i)); + if ( EXPL (Sum) - EXPL(Fact) > 53 || !EXPL(Fact) ) + break; + } + return Sum; +} + + +static long double ___yn ( int n, double* x ) +{ + long double Sum1; + long double Sum2; + long double Fact1; + long double Fact2; + long double F1; + long double F2; + long double y; + register int i; + double xx; + long double Xi; + unsigned int My; + + if ( EXPD (x[0]) == 0 ) + return -1./0.; /* ignore the gcc warning, this is intentional */ + + if ( (x[0] >= (n>=32 ? 25.8 : (n<8 ? 17.4+0.1*n : 16.2+0.3*n))) ) { + Xi = x[0] - M_PI * (n*0.5+0.25); + My = n*n << 2; + + return sqrt ( M_2_PI / x[0] ) * ( P(My,x) * sin(Xi) + Q(My,x) * cos(Xi) ); + } + + Sum1 = Sum2 = F1 = F2 = 0; + Fact1 = 1. / (xx = x[0] * 0.5 ); + Fact2 = 1.; + y = xx*xx; + + for ( i = 1; i < n; i++ ) + Fact1 *= (n-i) / xx; + + for ( i = 1; i <= n; i++ ) { + Sum1 += Fact1; + if ( i == n ) + break; + Fact1 *= y/(i*(n-i)); + } + + for (i=1; i<=n; i++) { + Fact2 *= xx / i; + F1 += 1. / i; + } + + for ( i = 1; ; i++ ) { + Sum2 += Fact2 * (F1+F2); + Fact2 *= -y / (i*(n+i)); + if ( EXPL (Sum2) - EXPL (Fact2) > 53 || !EXPL (Fact2) ) + break; + F1 += 1. / (n+i); + F2 += 1. / i; + } + + return M_1_PI * (2. * (M_C + log(xx)) * ___jn (n, x) - Sum1 - Sum2); +} + + +double j0 ( double x ) { return ___jn ( 0,&x ); } +double j1 ( double x ) { return ___jn ( 1,&x ); } +double jn ( int n, double x ) { return ___jn ( n,&x ); } +double y0 ( double x ) { return ___yn ( 0,&x ); } +double y1 ( double x ) { return ___yn ( 1,&x ); } +double yn ( int n, double x ) { return ___yn ( n,&x ); } + diff --git a/mdk-stage1/dietlibc/libm/cosh.c b/mdk-stage1/dietlibc/libm/cosh.c new file mode 100644 index 000000000..f64d59106 --- /dev/null +++ b/mdk-stage1/dietlibc/libm/cosh.c @@ -0,0 +1,9 @@ +#include + +extern const float __half; + +double cosh ( double x ) +{ + long double y = exp (x); + return (y + 1./y) * __half; +} diff --git a/mdk-stage1/dietlibc/libm/erf.c b/mdk-stage1/dietlibc/libm/erf.c new file mode 100644 index 000000000..63f52d81f --- /dev/null +++ b/mdk-stage1/dietlibc/libm/erf.c @@ -0,0 +1,95 @@ +#include "dietlibm.h" + +/*--------------------------------------------------------------------------* + z + 1 | -x²/2 +Name erf(z) = --------- | e dx + sqrt(2pi) | + 0 + + oo + 1 | -x²/2 + erfc(z) = -------- | e dx + sqrt(2pi) | + z + +Usage double erf (double x); + double erfc(double x); + +Prototype in math.h + +Description erf(x) is the probability a normal distributed event occures + within the range [0,x]. erfc(x) is the probability a normal + distributed event occures within the range [x,oo]. + +Return value return their respective function value. + +*---------------------------------------------------------------------------*/ + + +/* even function in (0): Coefficients for gamma(0) */ + +static const double tab1 [9 + 1] = { + 0.398942280401432677926, -0.066490380066905446321, 9.97355701003581694794E-3, -1.18732821548045439878E-3, 1.15434687616155288764E-4, -9.44465625950361453450E-6, 6.65969351631665127484E-7, -4.12266741486268888409E-8, 2.27352982437280636972E-9, -1.13011716416192129505E-10 +}; + +/* non even or odd function in (x), x>0: Coefficients for gamma(x), x>0 */ + +static const double tab2 [] [31 + 1] = { + { -0.158655253931457051468, +0.241970724519143349823, -0.120985362259571674911, 0, +0.0201642270432619458197, -4.03284540865238916394E-3, -2.01642270432619458197E-3, +7.68161030219502697887E-4, +1.20025160971797296538E-4, -8.80184513793180174807E-5, -1.86705805956129127862E-6, +7.37124220917704609315E-6, -4.72826391707080259142E-7, -4.83395817951682973566E-7, +6.57036391970156141055E-8, +2.5544260402922190768E-8, -5.4292285616752144141E-9, -1.08932444506260820153E-9, +3.44399256708718202774E-10, +3.6021429664641554881E-11, -1.81147204852239925966E-11, -7.66935128389784976374E-13, +8.19047721646461768154E-13, -3.78144699611990981391E-15, -3.24856460059989147863E-14, +1.44438130842455313227E-15, +1.14391687912824634892E-15, -9.38053726039148625184E-17, -3.59908648108845288945E-17, +4.36020846676166022246E-18, +1.01298640134330880603E-18, -1.68640470512244526894E-19 }, + { -0.0227501319481792072104, +0.0539909665131880519553, -0.0539909665131880519553, +0.0269954832565940259776, -4.49924720943233766301E-3, -2.24962360471616883129E-3, +1.34977416282970129877E-3, -1.17837426913704081544E-4, -1.15159303574756261652E-4, +3.70473728554448438507E-5, +2.82690796888936559912E-6, -3.54513195524355369855E-6, +3.76695631261094890352E-7, +1.92024079214184701051E-7, -5.22690859049557191018E-8, -4.91799344974114749666E-9, +3.66377919234006038965E-9, -1.5981997209104676352E-10, -1.73812379171063320997E-10, +2.62403075313043113473E-11, +5.60918720760414713346E-12, -1.72126983666416144614E-12, -8.63428809787622525331E-14, +7.89441765474563834480E-14, -3.13747960081562321348E-15, -2.77519506625391157547E-15, +3.29321944203493138076E-16, +7.44375150395529134369E-17, -1.66428523299294690222E-17, -1.32735612757620496568E-18, +6.24122437514304644794E-19, +1.12471123532438919306E-21 }, + { -1.3498980316300945272E-3, +4.43184841193800717687E-3, -6.64777261790701076574E-3, +5.90913121591734290293E-3, -3.32388630895350538287E-3, +1.10796210298450179421E-3, -1.10796210298450179595E-4, -8.44161602273906129349E-5, +4.35270826172482847927E-5, -6.30190085030867423515E-6, -1.9785037553294674925E-6, +1.05520200284238266374E-6, -1.13913852579575399458E-7, -4.81174572974454799623E-8, +1.78216871733806513653E-8, -5.85637697215219690327E-10, -9.29791350219350980904E-10, +1.96377023046901260016E-10, +1.58870373467897094393E-11, -1.22699105512396660364E-11, +1.08794270836433192571E-12, +3.99646995170699427940E-13, -1.01594404465456044793E-13, -3.33469605506835759271E-15, +4.46588935876766499879E-15, -4.08076707607833277747E-16, -1.17808602368979218862E-16, +2.76224909899945482352E-17, +1.09206599392049874162E-18, -1.03145418746203977253E-18, +6.79984672177279963209E-20, +2.55831283729070534712E-20 }, + { -3.16712418331199212695E-5, +1.33830225764885351832E-4, -2.67660451529770703664E-4, +3.34575564412213379613E-4, -2.89965489157251595673E-4, +1.8178605666396926958E-4, -8.25286392216793003064E-5, +2.55180251904870680833E-5, -3.91665839292075186649E-6, -7.40182052221464123606E-7, +6.44220233592652481453E-7, -1.73701553397390201613E-7, +9.09595464817154590424E-9, +9.44943118114780783705E-9, -3.29957075383376125942E-9, +2.94920746951281580686E-10, +1.18744773902482360274E-10, -4.42039585809856402486E-11, +3.61422484008923382324E-12, +1.43638335494248833511E-12, -4.58476794992724591068E-13, +2.23496663226445199624E-14, +1.57839046076890756440E-14, -3.67258220998453293248E-15, -1.69716269032291432153E-17, +1.43497778353923791279E-16, -2.14499365995613073838E-17, -1.93255135682867953692E-18, +1.01377499752128183701E-18, -7.55713215369572830154E-20, -2.25510650946079103289E-20, +5.26633993110171917109E-21 }, + { -2.86651571879193912033E-7, +1.48671951473429770924E-6, -3.7167987868357442731E-6, +5.9468780589371908374E-6, -6.81413110919886450076E-6, +5.92209940035828587496E-6, -4.02653201907205629582E-6, +2.17108246596119665457E-6, -9.25512396325170449452E-7, +3.03096091545533908077E-7, -6.92802772105295808398E-8, +6.69226396924248971087E-9, +2.46006252876483997508E-9, -1.41806830376639605249E-9, +3.44251040657349801884E-10, -2.6965166176434937652E-11, -1.16546962748761528049E-11, +4.91490145086991326748E-12, -7.55854519365765424197E-13, -4.53988828124843593484E-14, +4.71533558309731405623E-14, -9.17323049919073092370E-15, +4.35542982587998484108E-17, +3.71238868922011013332E-16, -7.90772907386322623053E-17, +1.58463483904927528072E-18, +2.61503941976309571331E-18, -5.40699423853895351239E-19, +6.61825040533797444037E-21, +1.68378440730394776550E-20, -3.01930850797704474581E-21, -3.80658085177617928332E-23 }, + { -9.8658764503769814198E-10, +6.07588284982328549581E-9, -1.82276485494698564874E-8, +3.54426499573024987263E-8, -5.01260335110421053478E-8, +5.48348427196551516061E-8, -4.81513715848495375522E-8, +3.47446467489597046263E-8, -2.08994095347716137282E-8, +1.0554987922587771203E-8, -4.4752674615729637229E-9, +1.57746505810079893253E-9, -4.49697115294871911476E-10, +9.63210042443717269402E-11, -1.16300711402336909847E-11, -1.31070037808191623761E-12, +1.16993345829435057496E-12, -3.40636420312606285351E-13, +5.23724821541706939045E-14, +3.93541148139975862961E-16, -2.59886413069218394637E-15, +7.24729556829529838503E-16, -8.51485747763574768020E-17, -7.86503719948806184368E-18, +5.35986191777031053618E-18, -9.84873767617830925356E-19, +2.93759678710573738811E-20, +2.85458592629073152182E-20, -7.12725445137377009753E-21, +5.25419393758902871947E-22, +1.24299023131490990316E-22, -4.04419210566489645405E-23 }, + { -1.27981254388583500631E-12, +9.1347204083645933588E-12, -3.19715214292760767584E-11, +7.30777632669167468738E-11, -1.22557498812224960902E-10, +1.60618833847077433236E-10, -1.71047639646627010648E-10, +1.51926349902927316213E-10, -1.14609023345779936276E-10, +7.43697341394886835864E-11, -4.18713451557949730558E-11, +2.05606050331840905587E-11, -8.82161466664564577599E-12, +3.30031395277698236679E-12, -1.06851205331295409813E-12, +2.94333808755089195146E-13, -6.64411715537625335642E-14, +1.11264855981436243262E-14, -8.52918435682649455145E-16, -2.38837813662069487819E-16, +1.23994634366691956599E-16, -3.05269770279941723219E-17, +4.34539596489459676621E-18, -5.55819387468189608390E-20, -1.56974672263484202926E-19, +4.60835492190702561464E-20, -6.61112150617493330405E-21, +7.28424268476803924831E-23, +2.09156005934313228089E-22, -5.29080328670107625978E-23, +5.61375000671507211726E-24, +3.82199410465700894394E-25 }, + { -6.22096057427178413283E-16, +5.05227108353689229741E-15, -2.02090843341475691883E-14, +5.30488463771373691202E-14, -1.02729512031916810045E-13, +1.56409892294496290711E-13, -1.94849254788406146283E-13, +2.04064637342166989709E-13, -1.83187931471980616892E-13, +1.42994099344605424348E-13, -9.8111907789286062426E-14, +5.96545975367403288587E-14, -3.23370114040930933005E-14, +1.56932853967230342257E-14, -6.83548101324218922896E-15, +2.67410077774155118457E-15, -9.38313996431647887562E-16, +2.94090734842381109313E-16, -8.16448235152204729921E-17, +1.9758222496699617607E-17, -4.03590262164308783690E-18, +6.43662361965717426956E-19, -5.93446415094778572090E-20, -6.07164564350191039536E-21, +4.38906686886388095825E-21, -1.17175498170220204828E-21, +1.98482140750318604418E-22, -1.70803571702439545981E-23, -1.94600332107885234554E-24, +1.10477141319981582738E-24, -2.31975718243847439962E-25, +2.54148402104633283670E-26 }, + { -1.12858840595384064928E-19, +1.02797735716689148111E-18, -4.62589810725101166456E-18, +1.37063647622252197466E-17, -3.0068337697131575822E-17, +5.2067053140503053517E-17, -7.40914680178037035E-17, +8.9062000172830588611E-17, -9.22563786210983011008E-17, +8.35975730487397716492E-17, -6.70372487553237232779E-17, +4.80088566412770650047E-17, -3.09280630297969106245E-17, +1.8026496052333452774E-17, -9.54924880090907168481E-18, +4.61362333444861021959E-18, -2.03812361224098073479E-18, +8.24578860830779678155E-19, -3.0572087552697254564E-19, +1.03827313453936543577E-19, -3.22407758977306397999E-20, +9.12052549039695437376E-21, -2.33541947993595580264E-21, +5.35339963891271164659E-22, -1.07674173853083520575E-22, +1.82413373046113374293E-23, -2.33864726317468746329E-24, +1.29928813344150027051E-25, +3.86668349205203745336E-26, -1.63203452712600670685E-26, +3.65165372186699607411E-27, -5.51243539825332137371E-28 }, + { -7.61985302416052609616E-24, +7.69459862670641937159E-23, -3.84729931335320968601E-22, +1.26960877340655919637E-21, -3.10990027829384449637E-21, +6.02935924057670511377E-21, -9.6342786971886625897E-21, +1.30454744197246721374E-20, -1.52745988785284834672E-20, +1.57034665186695273938E-20, -1.43457243961336621961E-20, +1.17567385540485497556E-20, -8.7104848256363928121E-21, +5.87137214731944288587E-21, -3.61951956727412561213E-21, +2.04954715001535632502E-21, -1.06982832733527370879E-21, +5.1628428354196120786E-22, -2.30885865897937993512E-22, +9.58556229281154921137E-23, -3.69911125531027884646E-23, +1.32784897023484841369E-23, -4.43433027366044567275E-24, +1.37688611947822111040E-24, -3.96971995397574368025E-25, +1.06008163579031271153E-25, -2.61149430849477426613E-26, +5.89698164189548613154E-27, -1.20793190886658723050E-27, +2.20446342551066852143E-28, -3.46061447029252398335E-29, +4.28913922246949096952E-30 } +}; + +static const double tab3 [8] = { +1, -1, +3, -15, +105, -945, +10395, -135135.0 }; + + +/* + Calculated: oo + 1 | -x²/2 + gauss(z) = --------- | e dx + sqrt(2pi) | + z + + gauss ( 0) = 0.5 + gauss ( 1) ~ 0.1586 + gauss ( 2) ~ 0.02275 + gauss ( 4) ~ 3.17e-5 + gauss (10) ~ 7.62e-24 + gauss (oo) = 0 + + Note: only for z>0 +*/ +#include +#include + +#define M_1_SQRT2PI 0.398942280401432686 + +static long double gauss ( double x ) +{ + unsigned int i = (unsigned int)(x + 0.5); + double y = x * x; + + if ( i > 150 ) return 0.; + if ( i > 10 ) return M_1_SQRT2PI * exp (-0.5*y) / x * __poly (1./y, 7, tab3); + if ( i > 0 ) return -__poly ((x-i), 31, tab2 [i-1]); + return 0.5 - x * __poly (y, 9, tab1); + } + +double erf ( double x ) +{ + return x < 0. ? -0.5 + gauss(-x) : 0.5 - gauss(x); +} + +double erfc ( double x ) +{ + return x < 0. ? 1.0 - gauss(-x) : gauss(x); +} + diff --git a/mdk-stage1/dietlibc/libm/gamma.c b/mdk-stage1/dietlibc/libm/gamma.c new file mode 100644 index 000000000..d5f3e4275 --- /dev/null +++ b/mdk-stage1/dietlibc/libm/gamma.c @@ -0,0 +1,98 @@ +#include "dietlibm.h" + +/*--------------------------------------------------------------------------* + +Name gamma, lgamma - gamma function + +Usage double gamma (double x); + double lgamma(double x); + extern int signgam; + +Prototype in math.h + +Description gamma returns the logarithm of the absolute value of the + gamma function. So it is possible â(x) for very large x. + The sign is stored in signgam, a extern variable + overwritten during every call to gamma(). lgamma() is + a synonym for gamma(). + You can calculate â(x) by the following sequence: + + double gammafunction(double x) + { double y=exp(gamma(x)); + + return signgam ? -y : +y; + } + +Return value gamma returns a value in range (-0.1208, +oo). For a input + value of zero, it returns +oo and errno is set to: + + ERANGE Result out of range + +*---------------------------------------------------------------------------*/ + +#include +#include + +#define B0 + 1.0l/ 6/ 1/ 2 +#define B1 - 1.0l/ 30/ 3/ 4 +#define B2 + 1.0l/ 42/ 5/ 6 +#define B3 - 1.0l/ 30/ 7/ 8 +#define B4 + 5.0l/ 66/ 9/10 +#define B5 - 691.0l/2730/11/12 +#define B6 + 7.0l/ 6/13/14 +#define B7 - 3617.0l/ 510/15/16 +#define B8 + 43867.0l/ 798/17/18 +#define B9 - 174611.0l/ 330/19/20 +#define B10 + 854513.0l/ 138/21/22 +#define B11 - 236364091.0l/2730/23/24 +#define B12 + 8553103.0l/ 6/25/26 + +static const double coeff[] = { B0, B1, B2, B3, B4, B5, B6, B7, B8, B9, B10 }; +int signgam; + +#define EXPL(x) (((short *)&x)[4] & 0x7FFF) + +static double logfact ( long double x ) +{ + long double z = 2. * M_PI * x; + register int e = EXPL (x); + + static unsigned char list [] = { 6, 4, 3, 3, 2, 2 }; + + return (log(x) - 1) * x + 0.5*log(z) + __poly (1./(x*x), e<0x4003 ? 10 : (e>0x4008 ? 1 : list [e-0x4003] ), coeff) / x; +} + + +double lgamma ( double x ) +{ + register int k = floor (x); + long double w; + long double y; + long double z; + + signgam = 0; + + if ( k >= 7 ) + return logfact (x-1); + + if ( k == x ) + switch (k) { + case 1 : + case 2 : return 0.000000000000000000000000000l; + case 3 : return 0.693147180559945309432805516l; + case 4 : return 1.791759469228055000858148560l; + case 5 : return 3.178053830347945619723759592l; + case 6 : return 4.787491742782045994244981560l; + default: return 1./0.; /* ignore the gcc warning, this is intentional */ + } + + z = logfact (y = x - k + 7.0 - 1); + w = 1; + for ( k = 7 - k; k--; ) + w *= y, y -= 1.; + + signgam = k >= 0 ? 0 : k & 1; + return z - log (w); +} + +double gamma ( double val ) __attribute__ ((weak,alias("lgamma"))); diff --git a/mdk-stage1/dietlibc/libm/ipow.c b/mdk-stage1/dietlibc/libm/ipow.c new file mode 100644 index 000000000..399986ea1 --- /dev/null +++ b/mdk-stage1/dietlibc/libm/ipow.c @@ -0,0 +1,29 @@ +#define _GNU_SOURCE +#include +/* + * This is not standard, but often you only need such this function + * which is much shorter than the generic pow() function. + * + * double ipow ( double mant, int expo ); + */ + +double ipow ( double mant, int expo ) +{ + double ret = 1.; + unsigned int e = expo; /* Some attention is necessary for expo = 2^31 */ + + if ( (int)e < 0 ) { + e = -e; + mant = 1./mant; + } + + while (1) { + if ( e & 1 ) + ret *= mant; + if ( (e >>= 1) == 0 ) + break; + mant *= mant; + } + + return ret; +} diff --git a/mdk-stage1/dietlibc/libm/poly.c b/mdk-stage1/dietlibc/libm/poly.c new file mode 100644 index 000000000..cdcfb8c5c --- /dev/null +++ b/mdk-stage1/dietlibc/libm/poly.c @@ -0,0 +1,41 @@ +/*--------------------------------------------------------------------------* + +Name __poly - generates a polynomial from arguments + +Usage double __poly ( double x, int n, const double* c ); + +Prototype in math.h + +Description __poly generates a polynomial in x, of degree n, with + coefficients c[0], c[1], ..., c[n]. For example, if n=4, + the generated polynomial is + + c[4]*x^4 + c[3]*x^3 + c[2]*x^2 + c[1]*x + c[0] + + The polynomial is calculated using Horner's method: + + polynom = (..((x*c[n] + c[n-1])*x + c[n-2])..)*x + c[0] + +Return value __poly returns the value of the polynomial as evaluated for + the given x. + A range error occurs if the result exceeds double range. + +*---------------------------------------------------------------------------*/ + +#include +#include "dietlibm.h" + +double __poly ( double x, size_t n, const double* c) +{ + long double ret; + size_t i; + + i = n; + c += n; + ret = 0; + do + ret = ret * x + *c--; + while ( i-- ); + + return ret; +} diff --git a/mdk-stage1/dietlibc/libm/pow.c b/mdk-stage1/dietlibc/libm/pow.c new file mode 100644 index 000000000..e0e5a2983 --- /dev/null +++ b/mdk-stage1/dietlibc/libm/pow.c @@ -0,0 +1,42 @@ + +#include +#include "dietlibm.h" + +double pow ( double mant, double expo ) +{ + unsigned int e; + long double ret; + + /* special cases 0^x */ + if ( mant == 0. ) { + if ( expo > 0. ) + return 0.; + else if ( expo == 0. ) + return 1.; + else + return 1./mant; + } + + /* special cases x^n with n is integer */ + if ( expo == (int) (e = (int) expo) ) { + + if ( (int)e < 0 ) { + e = -e; + mant = 1./mant; + } + + ret = 1.; + + while (1) { + if ( e & 1 ) + ret *= mant; + if ( (e >>= 1) == 0 ) + break; + mant *= mant; + } + return ret; + } + + /* normal case */ + return exp2 ( log2 (mant) * expo ); +} diff --git a/mdk-stage1/dietlibc/libm/rint.c b/mdk-stage1/dietlibc/libm/rint.c new file mode 100644 index 000000000..b6f0d8f85 --- /dev/null +++ b/mdk-stage1/dietlibc/libm/rint.c @@ -0,0 +1,5 @@ +#include + +double rint(double x) { + return floor(x+0.5); +} diff --git a/mdk-stage1/dietlibc/libm/sinh.c b/mdk-stage1/dietlibc/libm/sinh.c new file mode 100644 index 000000000..ae4542d25 --- /dev/null +++ b/mdk-stage1/dietlibc/libm/sinh.c @@ -0,0 +1,9 @@ +#include + +extern const float __half; + +double sinh ( double x ) +{ + long double y = exp (x); + return (y - 1./y) * __half; +} diff --git a/mdk-stage1/dietlibc/libm/tanh.c b/mdk-stage1/dietlibc/libm/tanh.c new file mode 100644 index 000000000..21dc3d0c0 --- /dev/null +++ b/mdk-stage1/dietlibc/libm/tanh.c @@ -0,0 +1,7 @@ +#include + +double tanh ( double x ) +{ + long double y = exp (x + x); + return (y - 1.) / (y + 1.); +} diff --git a/mdk-stage1/dietlibc/libpthread/pthread_equal.c b/mdk-stage1/dietlibc/libpthread/pthread_equal.c new file mode 100644 index 000000000..d054d86ed --- /dev/null +++ b/mdk-stage1/dietlibc/libpthread/pthread_equal.c @@ -0,0 +1,3 @@ +#include + +int pthread_equal(pthread_t thread1, pthread_t thread2) { return (thread1==thread2); } diff --git a/mdk-stage1/dietlibc/libpthread/pthread_errno.c b/mdk-stage1/dietlibc/libpthread/pthread_errno.c new file mode 100644 index 000000000..d035544ad --- /dev/null +++ b/mdk-stage1/dietlibc/libpthread/pthread_errno.c @@ -0,0 +1,5 @@ +int errno; + +#include "dietwarning.h" + +link_warning("errno","\e[1;33;41m>>> your multithreaded code uses errno! <<<\e[0m"); diff --git a/mdk-stage1/dietlibc/libpthread/pthread_fdglue2.c b/mdk-stage1/dietlibc/libpthread/pthread_fdglue2.c new file mode 100644 index 000000000..d73c84220 --- /dev/null +++ b/mdk-stage1/dietlibc/libpthread/pthread_fdglue2.c @@ -0,0 +1,16 @@ +#include "dietstdio.h" +#include +#include +#include +#include +#include +#include + +extern int __stdio_atexit; +extern FILE* __stdio_init_file_nothreads(int fd,int closeonerror); + +FILE* __stdio_init_file(int fd,int closeonerror) { + FILE *tmp=__stdio_init_file_nothreads(fd,closeonerror); + if (tmp) pthread_mutex_init(&tmp->m,0); + return tmp; +} diff --git a/mdk-stage1/dietlibc/libpthread/pthread_fgetc.c b/mdk-stage1/dietlibc/libpthread/pthread_fgetc.c new file mode 100644 index 000000000..34e79e0fe --- /dev/null +++ b/mdk-stage1/dietlibc/libpthread/pthread_fgetc.c @@ -0,0 +1,10 @@ +#include "dietstdio.h" +#include + +int fgetc(FILE *stream) { + int tmp; + pthread_mutex_lock(&stream->m); + tmp=fgetc_unlocked(stream); + pthread_mutex_unlock(&stream->m); + return tmp; +} diff --git a/mdk-stage1/dietlibc/libpthread/pthread_flockfile.c b/mdk-stage1/dietlibc/libpthread/pthread_flockfile.c new file mode 100644 index 000000000..72131ffb1 --- /dev/null +++ b/mdk-stage1/dietlibc/libpthread/pthread_flockfile.c @@ -0,0 +1,5 @@ +#include "dietstdio.h" + +void flockfile(FILE* f) { + pthread_mutex_lock(&f->m); +} diff --git a/mdk-stage1/dietlibc/libpthread/pthread_fputc.c b/mdk-stage1/dietlibc/libpthread/pthread_fputc.c new file mode 100644 index 000000000..82344b107 --- /dev/null +++ b/mdk-stage1/dietlibc/libpthread/pthread_fputc.c @@ -0,0 +1,9 @@ +#include + +int fputc(int c, FILE *stream) { + int tmp; + pthread_mutex_lock(&stream->m); + tmp=fputc_unlocked(c,stream); + pthread_mutex_unlock(&stream->m); + return tmp; +} diff --git a/mdk-stage1/dietlibc/libpthread/pthread_funlockfile.c b/mdk-stage1/dietlibc/libpthread/pthread_funlockfile.c new file mode 100644 index 000000000..beae058af --- /dev/null +++ b/mdk-stage1/dietlibc/libpthread/pthread_funlockfile.c @@ -0,0 +1,5 @@ +#include "dietstdio.h" + +void funlockfile(FILE* f) { + pthread_mutex_unlock(&f->m); +} diff --git a/mdk-stage1/dietlibc/libpthread/pthread_getschedparam.c b/mdk-stage1/dietlibc/libpthread/pthread_getschedparam.c new file mode 100644 index 000000000..aaaba4458 --- /dev/null +++ b/mdk-stage1/dietlibc/libpthread/pthread_getschedparam.c @@ -0,0 +1,22 @@ +#include +#include + +#include +#include "thread_internal.h" + +int pthread_getschedparam(pthread_t target_thread, int *policy, struct sched_param *param) +{ + int p; + __THREAD_INIT(); + + if (__find_thread_id(target_thread)<0) { + return ESRCH; + } + + if (((p=sched_getscheduler(target_thread))==-1)|| + (sched_getparam(target_thread,param) ==-1)) { + return (*(__errno_location())); + } + *policy=p; + return 0; +} diff --git a/mdk-stage1/dietlibc/libpthread/pthread_internal.c b/mdk-stage1/dietlibc/libpthread/pthread_internal.c new file mode 100644 index 000000000..7bb4e16cb --- /dev/null +++ b/mdk-stage1/dietlibc/libpthread/pthread_internal.c @@ -0,0 +1,359 @@ +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include "thread_internal.h" + +static struct _pthread_fastlock __thread_struct_lock = {PTHREAD_SPIN_UNLOCKED}; +static struct _pthread_descr_struct threads[PTHREAD_THREADS_MAX]; +static int _max_used_thread_id=1; +pthread_once_t __thread_inited; + +static struct _pthread_fastlock __manager_thread_signal_lock = {PTHREAD_SPIN_UNLOCKED}; +static struct _pthread_fastlock __manager_thread_data_lock = {PTHREAD_SPIN_LOCKED}; +static struct _pthread_fastlock __manager_thread_data_go_lock = {PTHREAD_SPIN_LOCKED}; + +//#define DEBUG + +/* find thread */ +int __find_thread_id(int pid) +{ + register int i; + for (i=0; i<_max_used_thread_id; i++) + if (threads[i].pid==pid) + return i; + return -1; +} + +/* get thread */ +_pthread_descr __get_thread_struct(int id) +{ + return threads+id; +} + +/* thread errno location */ +int *__errno_location(void) +{ + int id=0; + if (__thread_inited) id=__find_thread_id(getpid()); + if (id<0) + return 0; + else + return &threads[id].errno; +} + +/* thread self */ +_pthread_descr __thread_self() +{ + register int i=__find_thread_id(getpid()); + if (i<0) + return 0; + else + return threads+i; +} + +/* allocate a thread slot */ +_pthread_descr __thread_get_free() +{ + _pthread_descr ret=0; + int i; + + __NO_ASYNC_CANCEL_BEGIN; + __pthread_lock(&__thread_struct_lock); + + for (i=0; ipid=1; /* mark as taken */ + if (i>=_max_used_thread_id) _max_used_thread_id=i+1; + break; + } + } + + __pthread_unlock(&__thread_struct_lock); + __NO_ASYNC_CANCEL_END; + return ret; +} + +/* sleep a little (reschedule for this time) */ +void __thread_wait_some_time() +{ + struct timespec reg; + reg.tv_sec=0; + reg.tv_nsec=SPIN_SLEEP_DURATION; + __libc_nanosleep(®,0); +} + +/* cleanup/join a thread */ +int __thread_join(_pthread_descr th, void**return_value) +{ + /* mark thread th as joined */ + if (__testandset(&(th->joined))) return EINVAL; + /* wait for thread to exit */ + while(!th->exited) __thread_wait_some_time(); + /* put return value to caller */ + if (return_value) *return_value=th->retval; + /* cleanup thread */ + if (th->stack_begin) free(th->stack_begin); + th->joined=0; + th->pid=0; + return 0; +} + +/* SIGHUP handler (thread cancel) PTHREAD_CANCEL_ASYNCHRONOUS */ +static void __thread_cancel_handler(int sig) +{ + _pthread_descr this; + this = __thread_self(); + this->canceled=1; + if (this->canceltype==PTHREAD_CANCEL_ASYNCHRONOUS) + pthread_exit(PTHREAD_CANCELED); + signal( SIGHUP, __thread_cancel_handler ); +} + +/* kill ALL threads / other then prime task and manager thread */ +static void __kill_all_threads() +{ + int i; + + for (i=2; i<_max_used_thread_id; i++) { + if (threads[i].pid>1) { +#ifdef DEBUG + printf("CANCEL ! %d\n",threads[i].pid); +#endif + threads[i].canceled=1; + kill(threads[i].pid, SIGHUP); /* cancel thread */ + } + } + + __thread_wait_some_time(); + + for (i=2; i<_max_used_thread_id; i++) { + if (threads[i].pid>1) { +#ifdef DEBUG + printf("KILL ! %d\n",threads[i].pid); +#endif + kill(threads[i].pid, SIGTERM); /* KILL thread */ + } + } +} + +__attribute__((weak)) volatile void __thread_start__key(int id); +__attribute__((weak)) volatile void __thread_start__key(int id) { return; } +__attribute__((weak,alias("__thread_start__key"))) volatile void __thread_exit__key(int id); + +/* support for manager */ +static void *__mthread_starter(void *arg) +{ + _pthread_descr td = (_pthread_descr)arg; + int i = td->stack_size-4096; + + /* just to be sure */ + td->pid=getpid(); + + /* signal handling for a thread */ + signal(SIGTERM, _exit); + signal(SIGCHLD, SIG_DFL); + signal(SIGHUP, __thread_cancel_handler ); + + /* limit stack so that we NEVER have to worry */ + setrlimit(RLIMIT_STACK, (struct rlimit *)(&i)); + + /* set scheduler */ + if (td->policy!=SCHED_OTHER) { + struct sched_param sp; + sp.sched_priority=td->priority; + sched_setscheduler(td->pid,td->policy, &sp); + } + + /* thread_key glue */ + __thread_start__key(td-threads); + +#ifdef DEBUG + printf("in starter %d, parameter %8p\n", td->pid, td->func); +#endif + do { + __thread_wait_some_time(); + if (td->canceled) return (void*)42; + } while (__pthread_trylock(&td->go)); + +#ifdef DEBUG + printf("post starter %d, parameter %8p\n", td->pid, td->func); +#endif + + if (!td->canceled) { + if (!(setjmp(td->jmp_exit))) { + td->retval=td->func(td->arg); +#ifdef DEBUG + } else { + printf("pthread_exit called in %d\n", td->pid); +#endif + } + } + pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED,0); + + /* thread_key glue */ + __thread_exit__key(td-threads); + +#ifdef DEBUG + printf("end starter %d, retval %8p\n", td->pid, td->retval); +#endif + + /* execute all functions on the cleanup-stack */ + for (i=PTHREAD_MAX_CLEANUP;i;) { + if (td->cleanup_stack[--i].func) { + td->cleanup_stack[i].func(td->cleanup_stack[i].arg); + } + } + + return 0; +} + + +/* manager thread and signal handler */ +static char __manager_thread_stack[12*1024]; +static volatile _pthread_descr __manager_thread_data; +static void __manager_SIGCHLD(int sig) +{ + int pid, status, i; + + while(1) { + pid = __libc_waitpid (-1, &status, WNOHANG); + if (pid <= 0) break; + + for (i=0; i<_max_used_thread_id; i++) { + if (threads[i].pid==pid) { + ++threads[i].exited; + if (threads[i].detached) { + threads[i].joined=0; + __thread_cleanup(threads+i); + } + break; + } + } + } +} + +static void __manager_SIGTERM(int sig) +{ + __kill_all_threads(); + _exit(0); +} + +static void* __manager_thread(void *arg) +{ + struct sigaction sig_action_chld; + sig_action_chld.sa_handler = __manager_SIGCHLD; + sigemptyset(&sig_action_chld.sa_mask); + sig_action_chld.sa_flags = SA_RESTART; + + sigaction(SIGCHLD, &sig_action_chld, 0); + signal(SIGTERM, __manager_SIGTERM); + signal(SIGHUP, SIG_IGN); + + __pthread_unlock(&__manager_thread_data_go_lock); /* release init */ + while(1) { + do { + __thread_wait_some_time(); + if (getppid()<2) __manager_SIGTERM(0); + } while (__pthread_trylock(&__manager_thread_data_lock)); + + __manager_thread_data->pid = + __clone(__mthread_starter, + __manager_thread_data->stack_addr, + CLONE_VM | CLONE_FS | CLONE_FILES | SIGCHLD, + __manager_thread_data); + __thread_wait_some_time(); + __thread_wait_some_time(); + __pthread_unlock(&__manager_thread_data->go); +#ifdef DEBUG + printf("manager new thread %d\n",__manager_thread_data->pid); +#endif + __pthread_unlock(&__manager_thread_data_go_lock); /* release sender */ + } + return 0; +} + +/* pthread_create bottom half */ +int signal_manager_thread(_pthread_descr td) +{ + __NO_ASYNC_CANCEL_BEGIN; + + __pthread_lock(&__manager_thread_signal_lock); /* lock */ + + __manager_thread_data = td; + __thread_wait_some_time(); + __pthread_unlock(&__manager_thread_data_lock); /* signal manager to start */ + __thread_wait_some_time(); + __pthread_lock(&__manager_thread_data_go_lock); /* wait for manager */ + + __pthread_unlock(&__manager_thread_signal_lock); /* unlock */ + + __NO_ASYNC_CANCEL_END; + + return td->pid; +} + + +/* thread stop */ +static void __thread_main_exit() +{ + if (getpid()!=threads[0].pid) { +#ifdef DEBUG + printf("A THREAD ? %d\n",getpid()); +#endif + kill(threads[0].pid, SIGTERM); + while(1) __thread_wait_some_time(); + } +#ifdef DEBUG + else + printf("EXIT ! %d\n",getpid()); +#endif + + /* stop ALL threads */ + kill(threads[1].pid, SIGTERM); + __thread_wait_some_time(); + __kill_all_threads(); +} + +/* thread intern init */ +void __thread_init() +{ + if (atexit(__thread_main_exit)==-1) + exit(42); + +#ifdef DEBUG + printf("INIT ! %d\n",getpid()); + memset(threads,0,sizeof(threads)); +#endif + + threads[0].pid = getpid(); + + ++_max_used_thread_id; + threads[1].stack_size=sizeof(__manager_thread_stack); +#ifdef __parisc__ + threads[1].stack_addr=__manager_thread_stack; +#else + threads[1].stack_addr=&__manager_thread_stack[sizeof(__manager_thread_stack)]; +#endif + threads[1].stack_begin=0; + threads[1].func=__manager_thread; + + threads[1].pid = __clone(__mthread_starter, threads[1].stack_addr, + CLONE_VM | CLONE_FS | CLONE_FILES, threads+1); + +#ifdef DEBUG + printf("manager thread @ : %d\n",threads[1].pid); +#endif + __pthread_lock(&__manager_thread_data_go_lock); /* wait for manager to be ready */ +} + diff --git a/mdk-stage1/dietlibc/libpthread/pthread_key.c b/mdk-stage1/dietlibc/libpthread/pthread_key.c new file mode 100644 index 000000000..8a77f281a --- /dev/null +++ b/mdk-stage1/dietlibc/libpthread/pthread_key.c @@ -0,0 +1,48 @@ +#include +#include + +#include +#include "thread_internal.h" + +struct _pthread_fastlock __thread_keys_lock; +struct _thread_key __thread_keys[PTHREAD_KEYS_MAX]; + +void __thread_start__key(int id); +void __thread_exit__key(int id); + +void __thread_start__key(int id) +{ + int i; + + if (id<2) return; + + __NO_ASYNC_CANCEL_BEGIN; + __pthread_lock(&__thread_keys_lock); + + for (i=0; i +#include + +#include +#include "thread_internal.h" + +int pthread_setschedparam(pthread_t target_thread, int policy, const struct sched_param *param) +{ + __THREAD_INIT(); + + if (__find_thread_id(target_thread)<0) { + return ESRCH; + } + + if (((policy == SCHED_OTHER) && (param->sched_priority==0)) || + (((policy == SCHED_RR) || (policy == SCHED_FIFO)) && + ((param->sched_priority > 0) && (param->sched_priority <100)))) + return sched_setscheduler(target_thread, policy, param); + + return EINVAL; +} diff --git a/mdk-stage1/dietlibc/libpthread/pthread_sigmask.c b/mdk-stage1/dietlibc/libpthread/pthread_sigmask.c new file mode 100644 index 000000000..691e9e51a --- /dev/null +++ b/mdk-stage1/dietlibc/libpthread/pthread_sigmask.c @@ -0,0 +1,8 @@ +#include +#include + +#include + +int pthread_sigmask(int how, const sigset_t*newset, sigset_t *oldset) { + return (sigprocmask(how,newset,oldset)==-1)?(*(__errno_location())):0; +} diff --git a/mdk-stage1/dietlibc/libpthread/pthread_sys_fdatasync.c b/mdk-stage1/dietlibc/libpthread/pthread_sys_fdatasync.c new file mode 100644 index 000000000..69857c7b3 --- /dev/null +++ b/mdk-stage1/dietlibc/libpthread/pthread_sys_fdatasync.c @@ -0,0 +1,10 @@ +#include + +#include +#include "thread_internal.h" + +int fdatasync(int fd) +{ + __TEST_CANCEL(); + return __libc_fdatasync(fd); +} diff --git a/mdk-stage1/dietlibc/libshell/basename.c b/mdk-stage1/dietlibc/libshell/basename.c new file mode 100644 index 000000000..fbf5b2478 --- /dev/null +++ b/mdk-stage1/dietlibc/libshell/basename.c @@ -0,0 +1,27 @@ +#include +#include + +/* + path dirname basename + "/usr/lib" "/usr" "lib" + "/usr/" "/" "usr" + "usr" "." "usr" + "/" "/" "/" + "." "." "." + ".." "." ".." +*/ + +char *basename(char *path) { + char *c; +again: + if (!(c=strrchr(path,'/'))) return path; + if (c[1]==0) { + if (c == path) + return c; + else { + *c=0; + goto again; + } + } + return c+1; +} diff --git a/mdk-stage1/dietlibc/libshell/dirname.c b/mdk-stage1/dietlibc/libshell/dirname.c new file mode 100644 index 000000000..d35e6ea62 --- /dev/null +++ b/mdk-stage1/dietlibc/libshell/dirname.c @@ -0,0 +1,25 @@ +#include +#include + +/* + path dirname basename + "/usr/lib" "/usr" "lib" + "/usr/" "/" "usr" + "usr" "." "usr" + "/" "/" "/" + "." "." "." + ".." "." ".." +*/ + +char *dirname(char *path) { + char *c; +again: + if (!(c=strrchr(path,'/'))) return "."; + while (c[1]==0) { /* remove trailing slashes */ + if (c==path) return c; /* unless path=='/' */ + *c=0; + if (*--c!='/') break; + } + if (*c=='/') { if (c!=path) *c=0; return path; } + goto again; +} diff --git a/mdk-stage1/dietlibc/libstdio/fdglue2.c b/mdk-stage1/dietlibc/libstdio/fdglue2.c new file mode 100644 index 000000000..b96e4c5b8 --- /dev/null +++ b/mdk-stage1/dietlibc/libstdio/fdglue2.c @@ -0,0 +1,43 @@ +#include +#include +#include +#include +#include "dietstdio.h" +#include +#include + +extern int __stdio_atexit; + +FILE* __stdio_init_file_nothreads(int fd,int closeonerror); +FILE* __stdio_init_file_nothreads(int fd,int closeonerror) { + FILE *tmp=(FILE*)malloc(sizeof(FILE)); + if (!tmp) goto err_out; + tmp->buf=(char*)malloc(BUFSIZE); + if (!tmp->buf) { + free(tmp); +err_out: + if (closeonerror) close(fd); + errno=ENOMEM; + return 0; + } + tmp->fd=fd; + tmp->bm=0; + tmp->bs=0; + tmp->buflen=BUFSIZE; + { + struct stat st; + fstat(fd,&st); + tmp->flags=(S_ISFIFO(st.st_mode))?FDPIPE:0; + } + tmp->popen_kludge=0; + if (__stdio_atexit==0) { + __stdio_atexit=1; + atexit(__stdio_flushall); + } + tmp->next=__stdio_root; + __stdio_root=tmp; + tmp->ungotten=0; + return tmp; +} + +FILE* __stdio_init_file(int fd,int closeonerror) __attribute__((weak,alias("__stdio_init_file_nothreads"))); diff --git a/mdk-stage1/dietlibc/libstdio/fdprintf.c b/mdk-stage1/dietlibc/libstdio/fdprintf.c new file mode 100644 index 000000000..f9fc7a3b4 --- /dev/null +++ b/mdk-stage1/dietlibc/libstdio/fdprintf.c @@ -0,0 +1,13 @@ +#include +#include +#include +#include + +int fdprintf(int fd,const char *format,...) { + int n; + va_list arg_ptr; + va_start(arg_ptr,format); + n=vfdprintf(fd,format,arg_ptr); + va_end(arg_ptr); + return n; +} diff --git a/mdk-stage1/dietlibc/libstdio/fgetc_unlocked.c b/mdk-stage1/dietlibc/libstdio/fgetc_unlocked.c new file mode 100644 index 000000000..5136c8df1 --- /dev/null +++ b/mdk-stage1/dietlibc/libstdio/fgetc_unlocked.c @@ -0,0 +1,30 @@ +#include "dietstdio.h" +#include + +int fgetc_unlocked(FILE *stream) { + unsigned char c; + if (stream->ungotten) { + stream->ungotten=0; + return stream->ungetbuf; + } + if (feof(stream)) + return EOF; + if (__fflush4(stream,BUFINPUT)) return EOF; + if (stream->bm>=stream->bs) { + int len=read(stream->fd,stream->buf,stream->buflen); + if (len==0) { + stream->flags|=EOFINDICATOR; + return EOF; + } else if (len<0) { + stream->flags|=ERRORINDICATOR; + return EOF; + } + stream->bm=0; + stream->bs=len; + } + c=stream->buf[stream->bm]; + ++stream->bm; + return c; +} + +int fgetc(FILE* stream) __attribute__((weak,alias("fgetc_unlocked"))); diff --git a/mdk-stage1/dietlibc/libstdio/fgetpos.c b/mdk-stage1/dietlibc/libstdio/fgetpos.c new file mode 100644 index 000000000..d58b6fa5b --- /dev/null +++ b/mdk-stage1/dietlibc/libstdio/fgetpos.c @@ -0,0 +1,8 @@ +#include + +int fgetpos(FILE *stream, fpos_t *pos) { + long l=ftell(stream); + if (l==-1) return -1; + *pos=l; + return 0; +} diff --git a/mdk-stage1/dietlibc/libstdio/fputc_unlocked.c b/mdk-stage1/dietlibc/libstdio/fputc_unlocked.c new file mode 100644 index 000000000..6441c5741 --- /dev/null +++ b/mdk-stage1/dietlibc/libstdio/fputc_unlocked.c @@ -0,0 +1,20 @@ +#include +#include + +int fputc_unlocked(int c, FILE *stream) { + if (__fflush4(stream,0)) return EOF; + if (stream->bm>=stream->buflen-1) + if (fflush(stream)) return EOF; + if (stream->flags&NOBUF) { + if (write(stream->fd,&c,1) != 1) return EOF; + return 0; + } + stream->buf[stream->bm]=c; + ++stream->bm; + if (((stream->flags&BUFLINEWISE) && c=='\n') || + ((stream->flags&NOBUF))) /* puke */ + if (fflush(stream)) return EOF; + return 0; +} + +int fputc(int c,FILE* stream) __attribute__((weak,alias("fputc_unlocked"))); diff --git a/mdk-stage1/dietlibc/libstdio/fscanf.c b/mdk-stage1/dietlibc/libstdio/fscanf.c new file mode 100644 index 000000000..07f477462 --- /dev/null +++ b/mdk-stage1/dietlibc/libstdio/fscanf.c @@ -0,0 +1,14 @@ +#include +#include +#include +#include "dietstdio.h" +#include + +int fscanf(FILE *stream, const char *format, ...) { + int n; + va_list arg_ptr; + va_start(arg_ptr, format); + n=vfscanf(stream,format,arg_ptr); + va_end (arg_ptr); + return n; +} diff --git a/mdk-stage1/dietlibc/libstdio/fseeko.c b/mdk-stage1/dietlibc/libstdio/fseeko.c new file mode 100644 index 000000000..6459a6ff4 --- /dev/null +++ b/mdk-stage1/dietlibc/libstdio/fseeko.c @@ -0,0 +1,10 @@ +#include +#include + +int fseeko(FILE *stream, off_t offset, int whence) { + fflush(stream); + stream->bm=0; stream->bs=0; + stream->flags&=~(ERRORINDICATOR|EOFINDICATOR); + stream->ungotten=0; + return lseek(stream->fd,offset,whence)!=-1?0:-1; +} diff --git a/mdk-stage1/dietlibc/libstdio/fseeko64.c b/mdk-stage1/dietlibc/libstdio/fseeko64.c new file mode 100644 index 000000000..3b00596a1 --- /dev/null +++ b/mdk-stage1/dietlibc/libstdio/fseeko64.c @@ -0,0 +1,12 @@ +#include +#include + +#ifndef __NO_STAT64 +int fseeko64(FILE *stream, off64_t offset, int whence) { + fflush(stream); + stream->bm=0; stream->bs=0; + stream->flags&=~(ERRORINDICATOR|EOFINDICATOR); + stream->ungotten=0; + return lseek64(stream->fd,offset,whence)!=-1?0:-1; +} +#endif diff --git a/mdk-stage1/dietlibc/libstdio/fsetpos.c b/mdk-stage1/dietlibc/libstdio/fsetpos.c new file mode 100644 index 000000000..336135fff --- /dev/null +++ b/mdk-stage1/dietlibc/libstdio/fsetpos.c @@ -0,0 +1,7 @@ +#include + +int fsetpos(FILE *stream, fpos_t *pos) { + if (fseek(stream,*pos,SEEK_SET)==-1) + return -1; + return 0; +} diff --git a/mdk-stage1/dietlibc/libstdio/ftello.c b/mdk-stage1/dietlibc/libstdio/ftello.c new file mode 100644 index 000000000..9d36318e2 --- /dev/null +++ b/mdk-stage1/dietlibc/libstdio/ftello.c @@ -0,0 +1,7 @@ +#include +#include + +off_t ftello(FILE *stream) { + fflush(stream); + return (lseek(stream->fd,0,SEEK_CUR)); +} diff --git a/mdk-stage1/dietlibc/libstdio/ftello64.c b/mdk-stage1/dietlibc/libstdio/ftello64.c new file mode 100644 index 000000000..bda7a7de4 --- /dev/null +++ b/mdk-stage1/dietlibc/libstdio/ftello64.c @@ -0,0 +1,9 @@ +#include +#include + +#ifndef __NO_STAT64 +off64_t ftello64(FILE *stream) { + fflush(stream); + return (lseek64(stream->fd,0ull,SEEK_CUR)); +} +#endif diff --git a/mdk-stage1/dietlibc/libstdio/puts.c b/mdk-stage1/dietlibc/libstdio/puts.c new file mode 100644 index 000000000..b1da01f9d --- /dev/null +++ b/mdk-stage1/dietlibc/libstdio/puts.c @@ -0,0 +1,16 @@ +#include +#include +#include "dietstdio.h" +#include "dietfeatures.h" + +int __cheap_outs(const char *s,size_t len); +int __cheap_outs(const char *s,size_t len) { + return (size_t)write(1,s,len)==len?1:0; +} + +int __stdio_outs(const char *s,size_t len) __attribute__((weak,alias("__cheap_outs"))); + +int puts(const char *s) { + return (__stdio_outs(s,strlen(s)) && __stdio_outs("\n",1))?0:-1; +} + diff --git a/mdk-stage1/dietlibc/libstdio/scanf.c b/mdk-stage1/dietlibc/libstdio/scanf.c new file mode 100644 index 000000000..589c19f41 --- /dev/null +++ b/mdk-stage1/dietlibc/libstdio/scanf.c @@ -0,0 +1,14 @@ +#include +#include +#include +#include "dietstdio.h" +#include + +int scanf(const char *format, ...) { + int n; + va_list arg_ptr; + va_start(arg_ptr, format); + n=vfscanf(stdin,format,arg_ptr); + va_end (arg_ptr); + return n; +} diff --git a/mdk-stage1/dietlibc/libstdio/tmpfile.c b/mdk-stage1/dietlibc/libstdio/tmpfile.c new file mode 100644 index 000000000..b20d8410d --- /dev/null +++ b/mdk-stage1/dietlibc/libstdio/tmpfile.c @@ -0,0 +1,12 @@ +#include "dietstdio.h" +#include +#include + +FILE *tmpfile (void) { + int fd; + char template[20] = "/tmp/tmpfile-XXXXXX"; + if ((fd=mkstemp(template))<0) + return 0; + unlink(template); + return __stdio_init_file(fd,1); +} diff --git a/mdk-stage1/dietlibc/libstdio/vfdprintf.c b/mdk-stage1/dietlibc/libstdio/vfdprintf.c new file mode 100644 index 000000000..fdfeb09e1 --- /dev/null +++ b/mdk-stage1/dietlibc/libstdio/vfdprintf.c @@ -0,0 +1,15 @@ +#include +#include +#include +#include +#include "dietstdio.h" + +static int __fwrite(void*ptr, size_t nmemb, int fd) { + return write(fd,ptr,nmemb); +} + +int vfdprintf(int fd, const char *format, va_list arg_ptr) +{ + struct arg_printf ap = { (void*)(long)fd, (int(*)(void*,size_t,void*)) __fwrite }; + return __v_printf(&ap,format,arg_ptr); +} diff --git a/mdk-stage1/dietlibc/libstdio/vfprintf.c b/mdk-stage1/dietlibc/libstdio/vfprintf.c new file mode 100644 index 000000000..5e64cf099 --- /dev/null +++ b/mdk-stage1/dietlibc/libstdio/vfprintf.c @@ -0,0 +1,15 @@ +#include +#include +#include +#include +#include "dietstdio.h" + +static int __fwrite(void*ptr, size_t nmemb, FILE* f) { + return fwrite(ptr,1,nmemb,f); +} + +int vfprintf(FILE *stream, const char *format, va_list arg_ptr) +{ + struct arg_printf ap = { stream, (int(*)(void*,size_t,void*)) __fwrite }; + return __v_printf(&ap,format,arg_ptr); +} diff --git a/mdk-stage1/dietlibc/libstdio/vfscanf.c b/mdk-stage1/dietlibc/libstdio/vfscanf.c new file mode 100644 index 000000000..6d75a45ac --- /dev/null +++ b/mdk-stage1/dietlibc/libstdio/vfscanf.c @@ -0,0 +1,11 @@ +#include +#include +#include +#include "dietstdio.h" +#include + +int vfscanf(FILE *stream, const char *format, va_list arg_ptr) +{ + struct arg_scanf farg = { (void*)stream, (int(*)(void*))fgetc, (int(*)(int,void*))ungetc }; + return __v_scanf(&farg,format,arg_ptr); +} diff --git a/mdk-stage1/dietlibc/libstdio/vprintf.c b/mdk-stage1/dietlibc/libstdio/vprintf.c new file mode 100644 index 000000000..7fe579e0a --- /dev/null +++ b/mdk-stage1/dietlibc/libstdio/vprintf.c @@ -0,0 +1,15 @@ +#include +#include +#include "dietstdio.h" + +int __stdio_outs(const char *s,size_t len) __attribute__((weak)); +int __stdio_outs(const char *s,size_t len) { + return (write(1,s,len)==(int)len)?1:0; +} + +int vprintf(const char *format, va_list ap) +{ + struct arg_printf _ap = { 0, (int(*)(void*,size_t,void*)) __stdio_outs }; + return __v_printf(&_ap,format,ap); +} + diff --git a/mdk-stage1/dietlibc/libstdio/vscanf.c b/mdk-stage1/dietlibc/libstdio/vscanf.c new file mode 100644 index 000000000..ba9358fc4 --- /dev/null +++ b/mdk-stage1/dietlibc/libstdio/vscanf.c @@ -0,0 +1,10 @@ +#include +#include +#include +#include "dietstdio.h" +#include + +int vscanf(const char *format, va_list arg_ptr) +{ + return vfscanf(stdin,format,arg_ptr); +} 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 +#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 +#include "dietdirent.h" +#define _BSD_SOURCE +#include + +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 +#include + +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 +#include +#include + +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 + +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 +#include +#include +#include +#include +#include +#include + +/* 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#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)lenh_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) 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 (curh_aliases[aliasidx]=cur; + while (curh_aliases[aliasidx]; + int len=cur-from; + if (max-desth_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 +#include +#include +#include +#include + +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 +#include + +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 +#include + +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 +#include + +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 +#include + +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_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 +#include +#include +#include +#include +#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 +#include + +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 +#include + +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 +#include + +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 +#include + +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 + +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 +#include +#include +#include +#include +#include +#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/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 +#include +#include +#include + +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 +#include + +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 +#include "dieticonv.h" +#include + +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>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 +#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 +#include +#include "dietfeatures.h" +#include +#include +#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/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 +#include +#include +#include +#include +#include +#include +#include +#include "dietfeatures.h" +#include +#include + +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) return 0; + if (*cur=='\n') goto parseerror; + *cur=0; cur++; + /* second, the ip */ + while (cur=last) return 0; + /* now the aliases */ + for (aliasidx=0;aliasidx<10;++aliasidx) { + while (cur=last || !isblank(*cur)) break; + *cur++=0; + } + aliases[aliasidx]=0; + return ≠ +parseerror: + while (curn_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 +#include +#include +#include +#include +#include +#include + +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/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 + +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 +#include +#include +#include + +# 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 +#include +#include +#include +#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 + +struct servent __servent_pw; +char __servent_buf[1000]; + diff --git a/mdk-stage1/dietlibc/libugly/strndup.c b/mdk-stage1/dietlibc/libugly/strndup.c new file mode 100644 index 000000000..7f912d4c6 --- /dev/null +++ b/mdk-stage1/dietlibc/libugly/strndup.c @@ -0,0 +1,10 @@ +#include +#include + +char *strndup(const char *s,size_t n) { + char *tmp=(char *)malloc(n+1); + if (!tmp) return 0; + strncpy(tmp,s,n); + tmp[n]=0; + return tmp; +} 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/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 +#include +#include + +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 +#include +#include +#include + +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 +#include +#include +#include + +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/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 +#include "syscalls.h" +#include + +.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/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/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 + 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 +#include + +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 +#include +#include +#include +#include + +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 +#include +#include +#include +#include + +#define SHORT_SIZE sizeof (short) +#define MAX_SHORT 65536 + +#ifdef DEBUG +# include +# 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/errlist.S b/mdk-stage1/dietlibc/sparc/errlist.S new file mode 100644 index 000000000..c23f7b3d5 --- /dev/null +++ b/mdk-stage1/dietlibc/sparc/errlist.S @@ -0,0 +1,280 @@ +#ifdef __DYN_LIB +.section .data +#else +.section .rodata +#endif + +.align 4 +.global sys_errlist +.type sys_errlist,@object +sys_errlist: + .long .LC000 + .long .LC001 + .long .LC002 + .long .LC003 + .long .LC004 + .long .LC005 + .long .LC006 + .long .LC007 + .long .LC008 + .long .LC009 + .long .LC010 + .long .LC011 + .long .LC012 + .long .LC013 + .long .LC014 + .long .LC015 + .long .LC016 + .long .LC017 + .long .LC018 + .long .LC019 + .long .LC020 + .long .LC021 + .long .LC022 + .long .LC023 + .long .LC024 + .long .LC025 + .long .LC026 + .long .LC027 + .long .LC028 + .long .LC029 + .long .LC030 + .long .LC031 + .long .LC032 + .long .LC033 + .long .LC034 + .long .LC035 + .long .LC036 + .long .LC037 + .long .LC038 + .long .LC039 + .long .LC040 + .long .LC041 + .long .LC042 + .long .LC043 + .long .LC044 + .long .LC045 + .long .LC046 + .long .LC047 + .long .LC048 + .long .LC049 + .long .LC050 + .long .LC051 + .long .LC052 + .long .LC053 + .long .LC054 + .long .LC055 + .long .LC056 + .long .LC057 + .long .LC058 + .long .LC059 + .long .LC060 + .long .LC061 + .long .LC062 + .long .LC063 + .long .LC064 + .long .LC065 + .long .LC066 + .long .LC067 + .long .LC068 + .long .LC069 + .long .LC070 + .long .LC071 + .long .LC072 + .long .LC073 + .long .LC074 + .long .LC075 + .long .LC076 + .long .LC077 + .long .LC078 + .long .LC079 + .long .LC080 + .long .LC081 + .long .LC082 + .long .LC083 + .long .LC084 + .long .LC085 + .long .LC086 + .long .LC087 + .long .LC088 + .long .LC089 + .long .LC090 + .long .LC091 + .long .LC092 + .long .LC093 + .long .LC094 + .long .LC095 + .long .LC096 + .long .LC097 + .long .LC098 + .long .LC099 + .long .LC100 + .long .LC100 + .long .LC100 + .long .LC100 + .long .LC100 + .long .LC100 + .long .LC100 + .long .LC100 + .long .LC100 + .long .LC100 + .long .LC100 + .long .LC100 + .long .LC100 + .long .LC100 + .long .LC100 + .long .LC100 + .long .LC100 + .long .LC100 + .long .LC100 + .long .LC100 + .long .LC120 + .long .LC121 + .long .LC122 + .long .LC123 + .long .LC124 + .long .LC125 + .long .LC126 + .long 0 +.size sys_errlist,.-sys_errlist + +.align 4 +.global sys_nerr +.type sys_nerr,@object +sys_nerr: + .long 127 +.size sys_nerr,4 + +#ifdef __DYN_LIB +.section .rodata +#endif + +.LC000: .string "Success" +.LC001: .string "Operation not permitted" +.LC002: .string "No such file or directory" +.LC003: .string "No such process" +.LC004: .string "Interrupted system call" +.LC005: .string "I/O error" +.LC006: .string "No such device or address" +.LC007: .string "Arg list too long" +.LC008: .string "Exec format error" +.LC009: .string "Bad file number" +.LC010: .string "No child processes" +.LC011: .string "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 "Operation would block" +.LC036: .string "Operation now in progress" +.LC037: .string "Operation already in progress" +.LC038: .string "Socket operation on non-socket" +.LC039: .string "Destination address required" +.LC040: .string "Message too long" +.LC041: .string "Protocol wrong type for socket" +.LC042: .string "Protocol not available" +.LC043: .string "Protocol not supported" +.LC044: .string "Socket type not supported" +.LC045: .string "Op not supported on transport endpoint" +.LC046: .string "Protocol family not supported" +.LC047: .string "Address family not supported by protocol" +.LC048: .string "Address already in use" +.LC049: .string "Cannot assign requested address" +.LC050: .string "Network is down" +.LC051: .string "Network is unreachable" +.LC052: .string "Net dropped connection because of reset" +.LC053: .string "Software caused connection abort" +.LC054: .string "Connection reset by peer" +.LC055: .string "No buffer space available" +.LC056: .string "Transport endpoint is already connected" +.LC057: .string "Transport endpoint is not connected" +.LC058: .string "No send after transport endpoint shutdown" +.LC059: .string "Too many references: cannot splice" +.LC060: .string "Connection timed out" +.LC061: .string "Connection refused" +.LC062: .string "Too many symbolic links encountered" +.LC063: .string "File name too long" +.LC064: .string "Host is down" +.LC065: .string "No route to host" +.LC066: .string "Directory not empty" +.LC067: .string "SUNOS: Too many processes" +.LC068: .string "Too many users" +.LC069: .string "Quota exceeded" +.LC070: .string "Stale NFS file handle" +.LC071: .string "Object is remote" +.LC072: .string "Device not a stream" +.LC073: .string "Timer expired" +.LC074: .string "Out of streams resources" +.LC075: .string "No message of desired type" +.LC076: .string "Not a data message" +.LC077: .string "Identifier removed" +.LC078: .string "Resource deadlock would occur" +.LC079: .string "No record locks available" +.LC080: .string "Machine is not on the network" +.LC081: .string "SunOS: Too many lvls of remote in path" +.LC082: .string "Link has been severed" +.LC083: .string "Advertise error" +.LC084: .string "Srmount error" +.LC085: .string "Communication error on send" +.LC086: .string "Protocol error" +.LC087: .string "Multihop attempted" +.LC088: .string "RFS specific error" +.LC089: .string "Remote address changed" +.LC090: .string "Function not implemented" +.LC091: .string "Streams pipe error" +.LC092: .string "Value too large for defined data type" +.LC093: .string "File descriptor in bad state" +.LC094: .string "Channel number out of range" +.LC095: .string "Level 2 not synchronized" +.LC096: .string "Level 3 halted" +.LC097: .string "Level 3 reset" +.LC098: .string "Link number out of range" +.LC099: .string "Protocol driver not attached" +.LC100: .string "No CSI structure available" +.LC101: .string "Level 2 halted" +.LC102: .string "Invalid exchange" +.LC103: .string "Invalid request descriptor" +.LC104: .string "Exchange full" +.LC105: .string "No anode" +.LC106: .string "Invalid request code" +.LC107: .string "Invalid slot" +.LC108: .string "File locking deadlock error" +.LC109: .string "Bad font file format" +.LC110: .string "Cannot exec a shared library directly" +.LC111: .string "No data available" +.LC112: .string "Accessing a corrupted shared library" +.LC113: .string "Package not installed" +.LC114: .string "Can not access a needed shared library" +.LC115: .string "Name not unique on network" +.LC116: .string "Interrupted syscall should be restarted" +.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 "Illegal byte sequence" +.LC123: .string "Atmpt to link in too many shared libs" +.LC124: .string ".lib section in a.out corrupted" +.LC125: .string "No medium found" +.LC126: .string "Wrong medium type" + + 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 + +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/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/syscalls.s/__pwrite.S b/mdk-stage1/dietlibc/syscalls.s/__pwrite.S new file mode 100644 index 000000000..f52ead7b2 --- /dev/null +++ b/mdk-stage1/dietlibc/syscalls.s/__pwrite.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(pwrite,__pwrite) 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..c06d3d3ac --- /dev/null +++ b/mdk-stage1/dietlibc/syscalls.s/errlist.S @@ -0,0 +1,293 @@ +#include + +# +# 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 + +.align 4 +.global sys_errlist +#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 +.size sys_errlist,.-sys_errlist + +.align 4 +.global sys_nerr +sys_nerr: + .long 125 +.size sys_nerr,4 + + +#ifdef __DYN_LIB +.section .rodata +#endif + +.LC000: .string "Success" +.LC001: .string "Operation not permitted" +.LC002: .string "No such file or directory" +.LC003: .string "No such process" +.LC004: .string "Interrupted system call" +.LC005: .string "I/O error" +.LC006: .string "No such device or address" +.LC007: .string "Arg list too long" +.LC008: .string "Exec format error" +.LC009: .string "Bad file number" +.LC010: .string "No child processes" +.LC011: .string "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/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/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/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/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/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.s/mlock.S b/mdk-stage1/dietlibc/syscalls.s/mlock.S new file mode 100644 index 000000000..e2fa3d1bd --- /dev/null +++ b/mdk-stage1/dietlibc/syscalls.s/mlock.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +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.s/msync.S b/mdk-stage1/dietlibc/syscalls.s/msync.S new file mode 100644 index 000000000..7f5ae9e4a --- /dev/null +++ b/mdk-stage1/dietlibc/syscalls.s/msync.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall_weak(msync,msync,__libc_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..15d66ccc0 --- /dev/null +++ b/mdk-stage1/dietlibc/syscalls.s/n_sigaction.S @@ -0,0 +1,5 @@ +#include "syscalls.h" + +#ifdef __NR_sigaction +syscall_weak(sigaction,__old_sigaction,__n_sigaction) +#endif 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..f851099a0 --- /dev/null +++ b/mdk-stage1/dietlibc/syscalls.s/n_sigpending.S @@ -0,0 +1,5 @@ +#include "syscalls.h" + +#ifdef __NR_sigpending +syscall_weak(sigpending,__old_sigpending,__n_sigpending) +#endif 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..6d632aa71 --- /dev/null +++ b/mdk-stage1/dietlibc/syscalls.s/n_sigprocmask.S @@ -0,0 +1,5 @@ +#include "syscalls.h" + +#ifdef __NR_sigprocmask +syscall_weak(sigprocmask,__old_sigprocmask,__n_sigprocmask) +#endif 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..a1cfc014d --- /dev/null +++ b/mdk-stage1/dietlibc/syscalls.s/n_sigsuspend.S @@ -0,0 +1,5 @@ +#include "syscalls.h" + +#ifdef __NR_sigsuspend +syscall_weak(sigsuspend,__old_sigsuspend,__n_sigsuspend) +#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/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/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/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/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/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/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 +#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/x86_64/bind.S b/mdk-stage1/dietlibc/x86_64/bind.S new file mode 100644 index 000000000..05849d470 --- /dev/null +++ b/mdk-stage1/dietlibc/x86_64/bind.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +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 +#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/msgctl.S b/mdk-stage1/dietlibc/x86_64/msgctl.S new file mode 100644 index 000000000..d7caed2cc --- /dev/null +++ b/mdk-stage1/dietlibc/x86_64/msgctl.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(msgctl,msgctl) diff --git a/mdk-stage1/dietlibc/x86_64/msgget.S b/mdk-stage1/dietlibc/x86_64/msgget.S new file mode 100644 index 000000000..518d67ac4 --- /dev/null +++ b/mdk-stage1/dietlibc/x86_64/msgget.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(msgget,msgget) diff --git a/mdk-stage1/dietlibc/x86_64/msgrcv.S b/mdk-stage1/dietlibc/x86_64/msgrcv.S new file mode 100644 index 000000000..ab62e6c30 --- /dev/null +++ b/mdk-stage1/dietlibc/x86_64/msgrcv.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(msgrcv,msgrcv) diff --git a/mdk-stage1/dietlibc/x86_64/msgsnd.S b/mdk-stage1/dietlibc/x86_64/msgsnd.S new file mode 100644 index 000000000..890a996a2 --- /dev/null +++ b/mdk-stage1/dietlibc/x86_64/msgsnd.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(msgsnd,msgsnd) 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 +#include +#include + +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/semctl.S b/mdk-stage1/dietlibc/x86_64/semctl.S new file mode 100644 index 000000000..e215ed955 --- /dev/null +++ b/mdk-stage1/dietlibc/x86_64/semctl.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(semctl,semctl) diff --git a/mdk-stage1/dietlibc/x86_64/semget.S b/mdk-stage1/dietlibc/x86_64/semget.S new file mode 100644 index 000000000..67f488546 --- /dev/null +++ b/mdk-stage1/dietlibc/x86_64/semget.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(semget,semget) diff --git a/mdk-stage1/dietlibc/x86_64/semop.S b/mdk-stage1/dietlibc/x86_64/semop.S new file mode 100644 index 000000000..81b6fc606 --- /dev/null +++ b/mdk-stage1/dietlibc/x86_64/semop.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(semop,semop) 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 +#include +#include + +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 +#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/shmat.S b/mdk-stage1/dietlibc/x86_64/shmat.S new file mode 100644 index 000000000..51248173d --- /dev/null +++ b/mdk-stage1/dietlibc/x86_64/shmat.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(shmat,shmat) diff --git a/mdk-stage1/dietlibc/x86_64/shmctl.S b/mdk-stage1/dietlibc/x86_64/shmctl.S new file mode 100644 index 000000000..d56caace4 --- /dev/null +++ b/mdk-stage1/dietlibc/x86_64/shmctl.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(shmctl,shmctl) diff --git a/mdk-stage1/dietlibc/x86_64/shmdt.S b/mdk-stage1/dietlibc/x86_64/shmdt.S new file mode 100644 index 000000000..d9812a799 --- /dev/null +++ b/mdk-stage1/dietlibc/x86_64/shmdt.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(shmdt,shmdt) diff --git a/mdk-stage1/dietlibc/x86_64/shmget.S b/mdk-stage1/dietlibc/x86_64/shmget.S new file mode 100644 index 000000000..82914223f --- /dev/null +++ b/mdk-stage1/dietlibc/x86_64/shmget.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(shmget,shmget) 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 +#include +#include +#include + +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..5e8356350 --- /dev/null +++ b/mdk-stage1/dietlibc/x86_64/start.S @@ -0,0 +1,55 @@ +#include "dietfeatures.h" + +.text +.global _start +_start: +#ifdef WANT_DYNAMIC + movq %rdx, %rcx /* %rcx = dynamic fini */ +#endif + popq %rdi /* %rdi = argc */ + movq %rsp,%rsi /* %rsi = argv */ + pushq %rdi + + leaq 8(%rsi,%rdi,8),%rdx /* %rdx = envp = (8*rdi)+%rsi+8 */ + +#ifdef __DYN_LIB + movq environ@GOTPCREL(%rip), %rax + movq %rdx, (%rax) +#else + movq %rdx, environ(%rip) +#endif + +#ifdef PROFILING + pushq %rdi /* save reg args */ + pushq %rsi + pushq %rdx + pushq %rcx + + leaq _etext(%rip), %rsi /* highpc */ + leaq .text(%rip), %rdi /* lowpc */ + call monitor + + popq %rcx /* restore reg args */ + popq %rdx + popq %rsi + popq %rdi +#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..48bb9a4fa --- /dev/null +++ b/mdk-stage1/dietlibc/x86_64/unified.S @@ -0,0 +1,32 @@ +#include + +#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 $-128, %rax + jbe .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 -- cgit v1.2.1