chiark / gitweb /
[PATCH] update klibc to version 0.181
authorgreg@kroah.com <greg@kroah.com>
Wed, 6 Oct 2004 01:32:12 +0000 (18:32 -0700)
committerGreg KH <gregkh@suse.de>
Wed, 27 Apr 2005 04:37:01 +0000 (21:37 -0700)
288 files changed:
klibc/MCONFIG
klibc/Makefile
klibc/README
klibc/klibc.spec [new file with mode: 0644]
klibc/klibc.spec.in
klibc/klibc/MCONFIG
klibc/klibc/Makefile
klibc/klibc/README
klibc/klibc/SOCKETCALLS [deleted file]
klibc/klibc/SOCKETCALLS.def [new file with mode: 0644]
klibc/klibc/SYSCALLS [deleted file]
klibc/klibc/SYSCALLS.def [new file with mode: 0644]
klibc/klibc/__shared_init.c
klibc/klibc/__static_init.c
klibc/klibc/alarm.c
klibc/klibc/arch/alpha/Makefile.inc
klibc/klibc/arch/alpha/crt0.S
klibc/klibc/arch/alpha/include/klibc/archsetjmp.h [deleted file]
klibc/klibc/arch/alpha/include/klibc/archsignal.h [deleted file]
klibc/klibc/arch/alpha/include/klibc/archsys.h [deleted file]
klibc/klibc/arch/alpha/include/machine/asm.h [deleted file]
klibc/klibc/arch/alpha/setjmp.S
klibc/klibc/arch/alpha/syscall.S [new file with mode: 0644]
klibc/klibc/arch/alpha/sysdual.S [new file with mode: 0644]
klibc/klibc/arch/alpha/sysstub.ph [new file with mode: 0644]
klibc/klibc/arch/arm/Makefile.inc
klibc/klibc/arch/arm/crt0.S
klibc/klibc/arch/arm/include/klibc/archsetjmp.h [deleted file]
klibc/klibc/arch/arm/include/klibc/archsignal.h [deleted file]
klibc/klibc/arch/arm/include/klibc/archsys.h [deleted file]
klibc/klibc/arch/arm/setjmp-arm.S
klibc/klibc/arch/arm/syscall.S [new file with mode: 0644]
klibc/klibc/arch/arm/sysstub.ph [new file with mode: 0644]
klibc/klibc/arch/cris/MCONFIG
klibc/klibc/arch/cris/Makefile.inc
klibc/klibc/arch/cris/__negdi2.S [new file with mode: 0644]
klibc/klibc/arch/cris/crt0.S [new file with mode: 0644]
klibc/klibc/arch/cris/divide.c [new file with mode: 0644]
klibc/klibc/arch/cris/include/klibc/archsignal.h [deleted file]
klibc/klibc/arch/cris/include/klibc/archsys.h [deleted file]
klibc/klibc/arch/cris/setjmp.S [new file with mode: 0644]
klibc/klibc/arch/cris/syscall.S [new file with mode: 0644]
klibc/klibc/arch/cris/sysstub.ph [new file with mode: 0644]
klibc/klibc/arch/i386/MCONFIG
klibc/klibc/arch/i386/Makefile.inc
klibc/klibc/arch/i386/include/klibc/archsetjmp.h [deleted file]
klibc/klibc/arch/i386/include/klibc/archsignal.h [deleted file]
klibc/klibc/arch/i386/include/klibc/archsys.h [deleted file]
klibc/klibc/arch/i386/include/klibc/diverr.h [deleted file]
klibc/klibc/arch/i386/include/sys/io.h [deleted file]
klibc/klibc/arch/i386/include/sys/vm86.h [deleted file]
klibc/klibc/arch/i386/open.S [new file with mode: 0644]
klibc/klibc/arch/i386/socketcall.S
klibc/klibc/arch/i386/syscall.S [new file with mode: 0644]
klibc/klibc/arch/i386/sysstub.ph [new file with mode: 0644]
klibc/klibc/arch/ia64/Makefile.inc
klibc/klibc/arch/ia64/include/klibc/archsetjmp.h [deleted file]
klibc/klibc/arch/ia64/include/klibc/archsignal.h [deleted file]
klibc/klibc/arch/ia64/include/klibc/archsys.h [deleted file]
klibc/klibc/arch/ia64/pipe.c
klibc/klibc/arch/ia64/syscall.S [new file with mode: 0644]
klibc/klibc/arch/ia64/sysstub.ph [new file with mode: 0644]
klibc/klibc/arch/ia64/vfork.S
klibc/klibc/arch/m68k/include/klibc/archsignal.h [deleted file]
klibc/klibc/arch/m68k/include/klibc/archsys.h [deleted file]
klibc/klibc/arch/mips/MCONFIG
klibc/klibc/arch/mips/Makefile.inc
klibc/klibc/arch/mips/include/klibc/archsetjmp.h [deleted file]
klibc/klibc/arch/mips/include/klibc/archsignal.h [deleted file]
klibc/klibc/arch/mips/include/klibc/archsys.h [deleted file]
klibc/klibc/arch/mips/include/machine/asm.h [deleted file]
klibc/klibc/arch/mips/include/sgidefs.h [deleted file]
klibc/klibc/arch/mips/klibc.ld [new file with mode: 0644]
klibc/klibc/arch/mips/syscall.S [new file with mode: 0644]
klibc/klibc/arch/mips/sysstub.ph [new file with mode: 0644]
klibc/klibc/arch/mips/vfork.S
klibc/klibc/arch/mips64/include/klibc/archsignal.h [deleted file]
klibc/klibc/arch/mips64/include/klibc/archsys.h [deleted file]
klibc/klibc/arch/parisc/Makefile.inc
klibc/klibc/arch/parisc/include/klibc/archsignal.h [deleted file]
klibc/klibc/arch/parisc/include/klibc/archsys.h [deleted file]
klibc/klibc/arch/parisc/syscall.c [new file with mode: 0644]
klibc/klibc/arch/parisc/sysstub.ph [new file with mode: 0644]
klibc/klibc/arch/ppc/MCONFIG
klibc/klibc/arch/ppc/Makefile.inc
klibc/klibc/arch/ppc/include/klibc/archsetjmp.h [deleted file]
klibc/klibc/arch/ppc/include/klibc/archsignal.h [deleted file]
klibc/klibc/arch/ppc/include/klibc/archsys.h [deleted file]
klibc/klibc/arch/ppc/syscall.S [new file with mode: 0644]
klibc/klibc/arch/ppc/sysstub.ph [new file with mode: 0644]
klibc/klibc/arch/ppc64/MCONFIG
klibc/klibc/arch/ppc64/Makefile.inc
klibc/klibc/arch/ppc64/include/klibc/archsetjmp.h [deleted file]
klibc/klibc/arch/ppc64/include/klibc/archsignal.h [deleted file]
klibc/klibc/arch/ppc64/include/klibc/archsys.h [deleted file]
klibc/klibc/arch/ppc64/setjmp.S
klibc/klibc/arch/ppc64/syscall.c [new file with mode: 0644]
klibc/klibc/arch/ppc64/sysstub.ph [new file with mode: 0644]
klibc/klibc/arch/s390/Makefile.inc
klibc/klibc/arch/s390/include/klibc/archsetjmp.h [deleted file]
klibc/klibc/arch/s390/include/klibc/archsignal.h [deleted file]
klibc/klibc/arch/s390/include/klibc/archsys.h [deleted file]
klibc/klibc/arch/s390/mmap.c [new file with mode: 0644]
klibc/klibc/arch/s390/syscall.c [new file with mode: 0644]
klibc/klibc/arch/s390/sysstub.ph [new file with mode: 0644]
klibc/klibc/arch/s390x/Makefile.inc
klibc/klibc/arch/s390x/include/klibc/archsetjmp.h [deleted file]
klibc/klibc/arch/s390x/include/klibc/archsignal.h [deleted file]
klibc/klibc/arch/s390x/include/klibc/archsys.h [deleted file]
klibc/klibc/arch/s390x/mmap.c [new file with mode: 0644]
klibc/klibc/arch/s390x/syscall.c [new file with mode: 0644]
klibc/klibc/arch/s390x/sysstub.ph [new file with mode: 0644]
klibc/klibc/arch/sh/Makefile.inc
klibc/klibc/arch/sh/crt0.S
klibc/klibc/arch/sh/include/klibc/archsetjmp.h [deleted file]
klibc/klibc/arch/sh/include/klibc/archsignal.h [deleted file]
klibc/klibc/arch/sh/include/klibc/archsys.h [deleted file]
klibc/klibc/arch/sh/syscall.S [new file with mode: 0644]
klibc/klibc/arch/sh/sysstub.ph [new file with mode: 0644]
klibc/klibc/arch/sparc/Makefile.inc
klibc/klibc/arch/sparc/include/klibc/archsetjmp.h [deleted file]
klibc/klibc/arch/sparc/include/klibc/archsignal.h [deleted file]
klibc/klibc/arch/sparc/include/klibc/archsys.h [deleted file]
klibc/klibc/arch/sparc/include/machine/asm.h [deleted file]
klibc/klibc/arch/sparc/include/machine/frame.h [deleted file]
klibc/klibc/arch/sparc/include/machine/trap.h [deleted file]
klibc/klibc/arch/sparc/syscall.S [new file with mode: 0644]
klibc/klibc/arch/sparc/sysfork.S [new file with mode: 0644]
klibc/klibc/arch/sparc/sysstub.ph [new file with mode: 0644]
klibc/klibc/arch/sparc64/Makefile.inc
klibc/klibc/arch/sparc64/include/klibc/archsetjmp.h [deleted file]
klibc/klibc/arch/sparc64/include/klibc/archsignal.h [deleted file]
klibc/klibc/arch/sparc64/include/klibc/archsys.h [deleted file]
klibc/klibc/arch/sparc64/syscall.S [new file with mode: 0644]
klibc/klibc/arch/sparc64/sysfork.S [new file with mode: 0644]
klibc/klibc/arch/sparc64/sysstub.ph [new file with mode: 0644]
klibc/klibc/arch/x86_64/MCONFIG
klibc/klibc/arch/x86_64/Makefile.inc
klibc/klibc/arch/x86_64/include/klibc/archsetjmp.h [deleted file]
klibc/klibc/arch/x86_64/include/klibc/archsignal.h [deleted file]
klibc/klibc/arch/x86_64/include/klibc/archsys.h [deleted file]
klibc/klibc/arch/x86_64/include/sys/io.h [deleted file]
klibc/klibc/arch/x86_64/syscall.S [new file with mode: 0644]
klibc/klibc/arch/x86_64/sysstub.ph [new file with mode: 0644]
klibc/klibc/asprintf.c [new file with mode: 0644]
klibc/klibc/ctypes.c
klibc/klibc/daemon.c [new file with mode: 0644]
klibc/klibc/fdatasync.c [deleted file]
klibc/klibc/fork.c
klibc/klibc/fstatfs.c [new file with mode: 0644]
klibc/klibc/getcwd.c
klibc/klibc/getpagesize.c [deleted file]
klibc/klibc/getpriority.c
klibc/klibc/include/alloca.h [deleted file]
klibc/klibc/include/arpa/inet.h [deleted file]
klibc/klibc/include/assert.h [deleted file]
klibc/klibc/include/bits32/bitsize/limits.h [deleted file]
klibc/klibc/include/bits32/bitsize/stddef.h [deleted file]
klibc/klibc/include/bits32/bitsize/stdint.h [deleted file]
klibc/klibc/include/bits32/bitsize/stdintconst.h [deleted file]
klibc/klibc/include/bits32/bitsize/stdintlimits.h [deleted file]
klibc/klibc/include/bits64/bitsize/limits.h [deleted file]
klibc/klibc/include/bits64/bitsize/stddef.h [deleted file]
klibc/klibc/include/bits64/bitsize/stdint.h [deleted file]
klibc/klibc/include/bits64/bitsize/stdintconst.h [deleted file]
klibc/klibc/include/bits64/bitsize/stdintlimits.h [deleted file]
klibc/klibc/include/ctype.h [deleted file]
klibc/klibc/include/dirent.h [deleted file]
klibc/klibc/include/elf.h [deleted file]
klibc/klibc/include/endian.h [deleted file]
klibc/klibc/include/errno.h [deleted file]
klibc/klibc/include/fcntl.h [deleted file]
klibc/klibc/include/grp.h [deleted file]
klibc/klibc/include/inttypes.h [deleted file]
klibc/klibc/include/klibc/compiler.h [deleted file]
klibc/klibc/include/klibc/diverr.h [deleted file]
klibc/klibc/include/klibc/extern.h [deleted file]
klibc/klibc/include/limits.h [deleted file]
klibc/klibc/include/net/if.h [deleted file]
klibc/klibc/include/net/if_arp.h [deleted file]
klibc/klibc/include/net/if_ether.h [deleted file]
klibc/klibc/include/net/if_packet.h [deleted file]
klibc/klibc/include/netinet/in.h [deleted file]
klibc/klibc/include/netinet/in6.h [deleted file]
klibc/klibc/include/netinet/ip.h [deleted file]
klibc/klibc/include/netinet/tcp.h [deleted file]
klibc/klibc/include/netinet/udp.h [deleted file]
klibc/klibc/include/poll.h [deleted file]
klibc/klibc/include/sched.h [deleted file]
klibc/klibc/include/setjmp.h [deleted file]
klibc/klibc/include/signal.h [deleted file]
klibc/klibc/include/stdarg.h [deleted file]
klibc/klibc/include/stddef.h [deleted file]
klibc/klibc/include/stdint.h [deleted file]
klibc/klibc/include/stdio.h [deleted file]
klibc/klibc/include/stdlib.h [deleted file]
klibc/klibc/include/string.h [deleted file]
klibc/klibc/include/sys/dirent.h [deleted file]
klibc/klibc/include/sys/elf32.h [deleted file]
klibc/klibc/include/sys/elf64.h [deleted file]
klibc/klibc/include/sys/elfcommon.h [deleted file]
klibc/klibc/include/sys/fsuid.h [deleted file]
klibc/klibc/include/sys/ioctl.h [deleted file]
klibc/klibc/include/sys/klog.h [deleted file]
klibc/klibc/include/sys/mman.h [deleted file]
klibc/klibc/include/sys/mount.h [deleted file]
klibc/klibc/include/sys/param.h [deleted file]
klibc/klibc/include/sys/reboot.h [deleted file]
klibc/klibc/include/sys/resource.h [deleted file]
klibc/klibc/include/sys/select.h [deleted file]
klibc/klibc/include/sys/socket.h [deleted file]
klibc/klibc/include/sys/socketcalls.h [deleted file]
klibc/klibc/include/sys/stat.h [deleted file]
klibc/klibc/include/sys/syscall.h [deleted file]
klibc/klibc/include/sys/sysinfo.h [deleted file]
klibc/klibc/include/sys/sysmacros.h [deleted file]
klibc/klibc/include/sys/time.h [deleted file]
klibc/klibc/include/sys/types.h [deleted file]
klibc/klibc/include/sys/uio.h [deleted file]
klibc/klibc/include/sys/un.h [deleted file]
klibc/klibc/include/sys/utime.h [deleted file]
klibc/klibc/include/sys/utsname.h [deleted file]
klibc/klibc/include/sys/vfs.h [deleted file]
klibc/klibc/include/sys/wait.h [deleted file]
klibc/klibc/include/syslog.h [deleted file]
klibc/klibc/include/termios.h [deleted file]
klibc/klibc/include/time.h [deleted file]
klibc/klibc/include/unistd.h [deleted file]
klibc/klibc/include/utime.h [deleted file]
klibc/klibc/inet/bindresvport.c
klibc/klibc/interp.S
klibc/klibc/jrand48.c [new file with mode: 0644]
klibc/klibc/libc_init.c [new file with mode: 0644]
klibc/klibc/llseek.c
klibc/klibc/lrand48.c
klibc/klibc/makeerrlist.pl
klibc/klibc/malloc.c
klibc/klibc/malloc.h
klibc/klibc/mmap.c
klibc/klibc/mrand48.c [new file with mode: 0644]
klibc/klibc/nice.c
klibc/klibc/nrand48.c [new file with mode: 0644]
klibc/klibc/open.c
klibc/klibc/pause.c
klibc/klibc/perror.c
klibc/klibc/putchar.c [new file with mode: 0644]
klibc/klibc/qsort.c
klibc/klibc/readdir.c
klibc/klibc/sbrk.c
klibc/klibc/seed48.c
klibc/klibc/select.c [deleted file]
klibc/klibc/setresgid.c [deleted file]
klibc/klibc/setresuid.c [deleted file]
klibc/klibc/sha1hash.c
klibc/klibc/sigaction.c
klibc/klibc/sigpending.c
klibc/klibc/sigprocmask.c
klibc/klibc/sigsuspend.c
klibc/klibc/socketcalls.pl
klibc/klibc/socketcommon.h
klibc/klibc/srand48.c
klibc/klibc/statfs.c [new file with mode: 0644]
klibc/klibc/strerror.c
klibc/klibc/strlcat.c [new file with mode: 0644]
klibc/klibc/strlcpy.c [new file with mode: 0644]
klibc/klibc/strncat.c
klibc/klibc/strncpy.c
klibc/klibc/strnlen.c [new file with mode: 0644]
klibc/klibc/strtotimespec.c [new file with mode: 0644]
klibc/klibc/strtotimeval.c [new file with mode: 0644]
klibc/klibc/strtotimex.c [new file with mode: 0644]
klibc/klibc/syscalls.pl
klibc/klibc/syslog.c
klibc/klibc/tests/fcntl.c [new file with mode: 0644]
klibc/klibc/tests/getpagesize.c [new file with mode: 0644]
klibc/klibc/tests/malloctest2.c [new file with mode: 0644]
klibc/klibc/tests/microhello.c
klibc/klibc/tests/minips.c [deleted file]
klibc/klibc/tests/mmaptest.c [new file with mode: 0644]
klibc/klibc/tests/opentest.c [new file with mode: 0644]
klibc/klibc/tests/stat.c [new file with mode: 0644]
klibc/klibc/tests/statfs.c [new file with mode: 0644]
klibc/klibc/tests/strtoimax.c [new file with mode: 0644]
klibc/klibc/tests/strtotime.c [new file with mode: 0644]
klibc/klibc/time.c
klibc/klibc/utime.c
klibc/klibc/vasprintf.c [new file with mode: 0644]
klibc/version

index ec8b65c..d2aa236 100644 (file)
@@ -3,22 +3,29 @@
 # Makefile configuration, without explicit rules
 #
 
+# Eventually support separate compilation, but we don't have it yet...
+OBJROOT = $(SRCROOT)
+
 ARCH    = $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/)
 CROSS   = 
 CC     = $(CROSS)gcc
 LD      = $(CROSS)ld
 KLIBSRC = $(SRCROOT)/klibc
-REQFLAGS = $(ARCHREQFLAGS) -nostdinc -iwithprefix include -I$(KLIBSRC) \
-         -I$(KLIBSRC)/arch/$(ARCH)/include \
-         -I$(KLIBSRC)/include/bits$(BITSIZE) \
-         -D__KLIBC__ -DBITSIZE=$(BITSIZE) -I$(KLIBSRC)/include \
-         -I$(KERNEL_DIR)/include
+KLIBOBJ = $(OBJROOT)/klibc
+REQFLAGS = $(ARCHREQFLAGS) -nostdinc -iwithprefix include \
+         -D__KLIBC__ -DBITSIZE=$(BITSIZE) \
+         -I$(SRCROOT)/include/arch/$(ARCH) \
+         -I$(SRCROOT)/include/bits$(BITSIZE) \
+         -I$(SRCROOT)/include \
+         -I$(SRCROOT)/linux/include -I$(SRCROOT)/linux/include2
 LDFLAGS =
 AR      = $(CROSS)ar
 RANLIB  = $(CROSS)ranlib
 NM     = $(CROSS)nm
 PERL    = perl
 STRIP   = $(CROSS)strip --strip-all -R .comment -R .note
+OBJCOPY = $(CROSS)objcopy
 
 HOST_CC      = gcc
 HOST_CFLAGS  = -g -O
@@ -26,13 +33,13 @@ HOST_LDFLAGS =
 HOST_LIBS    =
 
 # Static library paths
-CRT0      = $(KLIBSRC)/crt0.o
-KLIBC     = $(KLIBSRC)/libc.a
+CRT0      = $(KLIBOBJ)/crt0.o
+KLIBC     = $(KLIBOBJ)/libc.a
 LIBGCC    = $(shell $(CC) --print-libgcc)
 
 # Shared library paths
-CRTSHARED = $(KLIBSRC)/interp.o
-LIBSHARED = $(KLIBSRC)/libc.so
+CRTSHARED = $(KLIBOBJ)/interp.o
+LIBSHARED = $(KLIBOBJ)/libc.so
 
 #
 # This indicates the location of the final version of the shared library.
@@ -41,7 +48,15 @@ LIBSHARED = $(KLIBSRC)/libc.so
 #
 SHLIBDIR = /lib
 
+# Enable this to make perror/strerror return real error messages
+# This makes klibc.so and any static binary which uses these functions
+# about 4K bigger.
+ERRLIST = 1
+
 #
 # Include arch-specific rule fragments
 #
 include $(KLIBSRC)/arch/$(ARCH)/MCONFIG
+
+# How to tell the linker main() is the entrypoint
+EMAIN ?= -e main
index ef5fbab..8823a33 100644 (file)
@@ -10,7 +10,7 @@ klibc.spec: klibc.spec.in version
 
 .PHONY: rpm
 rpm: klibc.spec
-       +$(rpmbuild) -bb klibc.spec
+       +$(rpmbuild) -bb klibc.spec --target=$(ARCH)
 
 %:
        @set -e; for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
index 4381364..eb72e1c 100644 (file)
@@ -1,4 +1,5 @@
-Please see klibc/README for build instructions.
+Please see klibc/README for build instructions and for the status of
+various platforms.
 
 
 
diff --git a/klibc/klibc.spec b/klibc/klibc.spec
new file mode 100644 (file)
index 0000000..6166a35
--- /dev/null
@@ -0,0 +1,157 @@
+Summary: A minimal libc subset for use with initramfs.
+Name: klibc
+Version: 0.181
+Release: 1
+License: BSD/GPL
+Group: Development/Libraries
+URL: http://www.zytor.com/mailman/listinfo/klibc
+Source: http://www.kernel.org/pub/linux/libs/klibc-%{version}.tar.gz
+BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
+BuildRequires: kernel-source >= 2.6.0
+Packager: H. Peter Anvin <hpa@zytor.com>
+Prefix: /usr
+Vendor: Starving Linux Artists
+
+%description
+%{name} is intended to be a minimalistic libc subset for use with
+initramfs.  It is deliberately written for small size, minimal
+entanglement, and portability, not speed.  It is definitely a work in
+progress, and a lot of things are still missing.
+
+%package kernheaders
+Summary: Kernel headers used during the build of klibc.
+Group: Development/Libraries
+
+%description kernheaders
+This package contains the set of kernel headers that were required to
+build %{name} and the utilities that ship with it.  This may or may
+not be a complete enough set to build other programs that link against
+%{name}.  If in doubt, use real kernel headers instead.
+
+%package utils
+Summary: Small statically-linked utilities built with klibc.
+Group: Utilities/System
+
+%description utils
+
+This package contains a collection of programs that are statically
+linked against klibc.  These duplicate some of the functionality of a
+regular Linux toolset, but are typically much smaller than their
+full-function counterparts.  They are intended for inclusion in
+initramfs images and embedded systems.
+
+%prep
+%setup -q
+cp -as /usr/src/linux-`rpm -q kernel-source | tail -1 | cut -d- -f3-` ./linux
+make -C linux defconfig ARCH=%{_target_cpu}
+make -C linux prepare ARCH=%{_target_cpu}
+# Deal with braindamage in RedHat's kernel-source RPM
+rm -f linux/include/linux/config.h
+cat <<EOF > linux/include/linux/config.h
+#ifndef _LINUX_CONFIG_H
+#define _LINUX_CONFIG_H
+
+#include <linux/autoconf.h>
+
+#endif
+EOF
+mkdir -p %{buildroot}
+
+%build
+make ARCH=%{_target_cpu}
+
+%install
+rm -rf %{buildroot}
+
+dest=%{buildroot}/%{prefix}
+lib=$dest/%{_lib}/klibc
+inc=$dest/include/klibc
+exe=$dest/libexec/klibc
+doc=$dest/share/doc/%{name}-%{version}
+udoc=$dest/share/doc/%{name}-utils-%{version}
+
+# First, the library.
+
+install -dD -m 755 $lib $inc/kernel $exe $doc $udoc
+install -m 755 klibc/klibc.so $lib
+install -m 644 klibc/libc.a $lib
+install -m 644 klibc/crt0.o $lib
+install -m 644 klibc/libc.so.hash $lib
+ln $lib/klibc.so $lib/libc.so
+ln $lib/klibc.so $lib/klibc-$(cat $lib/libc.so.hash).so
+
+# Next, the generated binaries.
+# These are currently static binaries, should we go for shared?
+
+install -m 755 ash/sh $exe
+install -m 755 gzip/gzip $exe
+ln $exe/gzip $exe/gunzip
+ln $exe/gzip $exe/zcat
+install -m 755 ipconfig/ipconfig $exe
+install -m 755 kinit/kinit $exe
+install -m 755 nfsmount/nfsmount $exe
+install -m 755 utils/static/* $exe
+
+# The docs.
+
+install -m 444 README $doc
+install -m 444 klibc/README $doc/README.klibc
+install -m 444 klibc/arch/README $doc/README.klibc.arch
+
+install -m 444 gzip/COPYING $udoc/COPYING.gzip
+install -m 444 gzip/README $udoc/README.gzip
+install -m 444 ipconfig/README $udoc/README.ipconfig
+install -m 444 kinit/README $udoc/README.kinit
+
+# Finally, the include files.
+
+bitsize=$(make --no-print-directory -C klibc bitsize ARCH=%{_target_cpu})
+cp --parents $(find klibc/include \( -name CVS -o -name SCCS \) -prune \
+    -o -name '*.h' -print) $inc
+mv $inc/klibc $inc/klibc.$$
+mv $inc/klibc.$$/include/* $inc
+mv $inc/bits$bitsize/bitsize $inc
+rm -rf $inc/klibc.$$ $inc/bits[0-9]*
+pushd klibc/arch/%{_arch}/include
+cp --parents -f $(find . \( -name CVS -o -name SCCS \) -prune \
+    -o -name '*.h' -print) $inc
+popd
+
+# Yeugh.  Find the transitive closure over all kernel headers included
+# by klibc, and copy them into place.
+
+find . -name '.*.d' | xargs -r sed -e 's,[ \t][ \t]*,\n,g' | sed -n -e 's,^\.\./linux/include/,,p' | sort | uniq | (cd linux/include && xargs -ri cp --parents '{}' $inc/kernel)
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%files
+%defattr(-,root,root,-)
+%docdir %{prefix}/share/doc/%{name}-%{version}
+%{prefix}/%{_lib}/klibc
+%dir %{prefix}/include/klibc
+%{prefix}/include/klibc/*.h
+%{prefix}/include/klibc/arpa
+%{prefix}/include/klibc/bitsize
+%{prefix}/include/klibc/klibc
+%{prefix}/include/klibc/net
+%{prefix}/include/klibc/netinet
+%{prefix}/include/klibc/sys
+%{prefix}/share/doc/%{name}-%{version}
+
+%files kernheaders
+%defattr(-,root,root,-)
+%{prefix}/include/klibc/kernel
+
+%files utils
+%defattr(-,root,root,-)
+%{prefix}/libexec/klibc
+%docdir %{prefix}/share/doc/%{name}-utils-%{version}
+%{prefix}/share/doc/%{name}-utils-%{version}
+
+%changelog
+* Tue Jul 6 2004 H. Peter Anvin <hpa@zytor.com>
+- Update to use kernel-source RPM for the kernel symlink.
+
+* Sat Nov 29 2003 Bryan O'Sullivan <bos@serpentine.com> - 
+- Initial build.
index f8bccc3..8f5b261 100644 (file)
@@ -1,16 +1,14 @@
-%define _rpmdir rpms
-%define _builddir .
-
 Summary: A minimal libc subset for use with initramfs.
 Name: klibc
-Version: 0.89
+Version: @@VERSION@@
 Release: 1
 License: BSD/GPL
 Group: Development/Libraries
-URL: http://www.zytor.com/klibc
-Source: /dev/null
+URL: http://www.zytor.com/mailman/listinfo/klibc
+Source: http://www.kernel.org/pub/linux/libs/klibc-%{version}.tar.gz
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
-Packager: Bryan O'Sullivan <bos@serpentine.com>
+BuildRequires: kernel-source >= 2.6.0
+Packager: H. Peter Anvin <hpa@zytor.com>
 Prefix: /usr
 Vendor: Starving Linux Artists
 
@@ -43,18 +41,24 @@ full-function counterparts.  They are intended for inclusion in
 initramfs images and embedded systems.
 
 %prep
-if [ ! -L linux ]; then
-    echo "*** You must have a symlink named linux to build klibc" 1>&2
-    exit 1
-fi
-if [ ! -f linux/include/asm/page.h ]; then
-    echo "*** You need to 'make prepare' in the linux tree before building klibc" 1>&2
-    exit 1
-fi
-mkdir -p %{buildroot} %{_rpmdir}
+%setup -q
+cp -as /usr/src/linux-`rpm -q kernel-source | tail -1 | cut -d- -f3-` ./linux
+make -C linux defconfig ARCH=%{_target_cpu}
+make -C linux prepare ARCH=%{_target_cpu}
+# Deal with braindamage in RedHat's kernel-source RPM
+rm -f linux/include/linux/config.h
+cat <<EOF > linux/include/linux/config.h
+#ifndef _LINUX_CONFIG_H
+#define _LINUX_CONFIG_H
+
+#include <linux/autoconf.h>
+
+#endif
+EOF
+mkdir -p %{buildroot}
 
 %build
-make
+make ARCH=%{_target_cpu}
 
 %install
 rm -rf %{buildroot}
@@ -77,6 +81,7 @@ ln $lib/klibc.so $lib/libc.so
 ln $lib/klibc.so $lib/klibc-$(cat $lib/libc.so.hash).so
 
 # Next, the generated binaries.
+# These are currently static binaries, should we go for shared?
 
 install -m 755 ash/sh $exe
 install -m 755 gzip/gzip $exe
@@ -85,9 +90,7 @@ ln $exe/gzip $exe/zcat
 install -m 755 ipconfig/ipconfig $exe
 install -m 755 kinit/kinit $exe
 install -m 755 nfsmount/nfsmount $exe
-for i in chroot dd fstype mkdir mkfifo mount umount; do
-    install -m 755 utils/$i $exe
-done
+install -m 755 utils/static/* $exe
 
 # The docs.
 
@@ -102,7 +105,7 @@ install -m 444 kinit/README $udoc/README.kinit
 
 # Finally, the include files.
 
-bitsize=$(make --no-print-directory -C klibc bitsize)
+bitsize=$(make --no-print-directory -C klibc bitsize ARCH=%{_target_cpu})
 cp --parents $(find klibc/include \( -name CVS -o -name SCCS \) -prune \
     -o -name '*.h' -print) $inc
 mv $inc/klibc $inc/klibc.$$
@@ -147,5 +150,8 @@ rm -rf $RPM_BUILD_ROOT
 %{prefix}/share/doc/%{name}-utils-%{version}
 
 %changelog
+* Tue Jul 6 2004 H. Peter Anvin <hpa@zytor.com>
+- Update to use kernel-source RPM for the kernel symlink.
+
 * Sat Nov 29 2003 Bryan O'Sullivan <bos@serpentine.com> - 
 - Initial build.
index 253a946..5b6eecd 100644 (file)
@@ -8,6 +8,11 @@ include ../MCONFIG
 include ../MRULES
 
 WARNFLAGS = -W -Wall -Wpointer-arith -Wwrite-strings -Wstrict-prototypes -Winline
+
+ifeq ($(ERRLIST),1)
+REQFLAGS += -DWITH_ERRLIST
+endif
+
 CFLAGS  = -Wp,-MD,$(dir $*).$(notdir $*).d $(OPTFLAGS) $(REQFLAGS) $(WARNFLAGS)
 
 SOFLAGS = -fPIC
index 7ed03a8..d7e75f1 100644 (file)
@@ -10,6 +10,7 @@ include MCONFIG
 TESTS   = $(patsubst %.c,%,$(wildcard tests/*.c)) \
          $(patsubst %.c,%.shared,$(wildcard tests/*.c))
 LIBOBJS = vsnprintf.o snprintf.o vsprintf.o sprintf.o \
+         asprintf.o vasprintf.o \
          vsscanf.o sscanf.o ctypes.o \
          strntoumax.o strntoimax.o \
          atoi.o atol.o atoll.o \
@@ -18,41 +19,51 @@ LIBOBJS = vsnprintf.o snprintf.o vsprintf.o sprintf.o \
          globals.o exitc.o atexit.o onexit.o \
          execl.o execle.o execv.o execvpe.o execvp.o execlp.o execlpe.o \
          fork.o wait.o wait3.o waitpid.o system.o setpgrp.o getpgrp.o \
-         open.o \
+         daemon.o \
          printf.o vprintf.o fprintf.o vfprintf.o perror.o \
-         fopen.o fread.o fread2.o fgetc.o fgets.o \
-         fwrite.o fwrite2.o fputc.o fputs.o puts.o \
-         sleep.o usleep.o raise.o abort.o assert.o alarm.o pause.o \
+         statfs.o fstatfs.o umount.o \
+         open.o fopen.o fread.o fread2.o fgetc.o fgets.o \
+         fwrite.o fwrite2.o fputc.o fputs.o puts.o putchar.o \
+         sleep.o usleep.o strtotimespec.o strtotimeval.o \
+         raise.o abort.o assert.o alarm.o pause.o \
          __signal.o sysv_signal.o bsd_signal.o siglist.o siglongjmp.o \
          sigaction.o sigpending.o sigprocmask.o sigsuspend.o \
-         brk.o sbrk.o malloc.o realloc.o calloc.o mmap.o getpagesize.o \
+         brk.o sbrk.o malloc.o realloc.o calloc.o mmap.o \
          memcpy.o memcmp.o memset.o memccpy.o memmem.o memswap.o \
-         memmove.o \
+         memmove.o memchr.o \
          strcasecmp.o strncasecmp.o strndup.o strerror.o \
-         strcat.o strchr.o strcmp.o strcpy.o strdup.o strlen.o \
-         strncat.o strstr.o strncmp.o strncpy.o strrchr.o strspn.o \
+         strcat.o strchr.o strcmp.o strcpy.o strdup.o strlen.o strnlen.o \
+         strncat.o strlcpy.o strlcat.o \
+         strstr.o strncmp.o strncpy.o strrchr.o strspn.o \
          strsep.o strtok.o \
          gethostname.o getdomainname.o getcwd.o \
-         seteuid.o setegid.o setresuid.o setresgid.o \
+         seteuid.o setegid.o \
          getenv.o setenv.o putenv.o __put_env.o unsetenv.o \
          getopt.o readdir.o \
          syslog.o closelog.o pty.o getpt.o isatty.o reboot.o \
-         time.o utime.o fdatasync.o llseek.o select.o nice.o getpriority.o \
-         qsort.o lrand48.o srand48.o seed48.o \
+         time.o utime.o llseek.o nice.o getpriority.o \
+         qsort.o \
+         lrand48.o jrand48.o mrand48.o nrand48.o srand48.o seed48.o \
          inet/inet_ntoa.o inet/inet_aton.o inet/inet_addr.o \
          inet/inet_ntop.o inet/inet_pton.o inet/bindresvport.o \
          send.o recv.o
+ifeq ($(ERRLIST),1)
+LIBOBJS += errlist.o
+endif
+
 SOLIB   = libc.so
 SOHASH  = klibc.so
 
 CRT0    = crt0.o
 LIB     = libc.a
 
-#all: tests $(CRT0) $(LIB) $(SOLIB) klibc.so
-all:  $(CRT0) $(LIB) $(SOLIB) klibc.so
+INTERP_O = interp.o
+
+all: tests $(CRT0) $(LIB) $(SOLIB) klibc.so
 
 # Add any architecture-specific rules
 include arch/$(ARCH)/Makefile.inc
+EMAIN ?= -e main
 
 tests: $(TESTS)
 
@@ -71,19 +82,20 @@ tests/% : tests/%.o $(LIB) $(CRT0)
        $(STRIP) $@.stripped
 
 tests/%.shared : tests/%.o interp.o $(SOLIB)
-       $(LD) $(LDFLAGS) -o $@ -e main interp.o tests/$*.o -R $(SOLIB) $(LIBGCC)
+       $(LD) $(LDFLAGS) -o $@ $(EMAIN) interp.o tests/$*.o -R $(SOLIB) $(LIBGCC)
        cp $@ $@.stripped
        $(STRIP) $@.stripped
 
 $(LIB): __static_init.o $(LIBOBJS) $(ARCHOBJS) syscalls/static.obj socketcalls/static.obj
        rm -f $(LIB)
-       $(AR) cq $(LIB) __static_init.o $(LIBOBJS) $(ARCHOBJS) syscalls/*.o socketcalls/*.o
+       $(AR) cq $(LIB) __static_init.o $(LIBOBJS) $(ARCHOBJS) \
+               $(wildcard syscalls/*.o) $(wildcard socketcalls/*.o)
        $(RANLIB) $(LIB)
 
 $(SOLIB): $(CRT0) __shared_init.o $(LIBOBJS) $(ARCHOBJS) syscalls/static.obj socketcalls/static.obj
        $(LD) $(LDFLAGS) $(SHAREDFLAGS) -o $@ \
                $(CRT0) __shared_init.o $(LIBOBJS) $(ARCHOBJS) \
-               syscalls/*.o socketcalls/*.o \
+               $(wildcard syscalls/*.o) $(wildcard socketcalls/*.o) \
                $(LIBGCC)
 
 sha1hash: sha1hash.c
@@ -99,7 +111,7 @@ $(SOHASH): $(SOLIB) $(SOLIB).hash
        rm -f klibc-??????????????????????.so
        ln -f $@ klibc-`cat $(SOLIB).hash`.so
 
-interp.o: interp.S $(SOLIB).hash
+$(INTERP_O): interp.S $(SOLIB).hash
        $(CC) $(CFLAGS) -D__ASSEMBLY__ -DLIBDIR=\"$(SHLIBDIR)\" \
                -DSOHASH=\"`cat $(SOLIB).hash`\" \
                -c -o $@ $<
@@ -107,16 +119,29 @@ interp.o: interp.S $(SOLIB).hash
 crt0.o: arch/$(ARCH)/crt0.o
        cp arch/$(ARCH)/crt0.o .
 
-syscalls.dir: SYSCALLS syscalls.pl syscommon.h
+errlist.c:
+       $(PERL) makeerrlist.pl -errlist > $@ || rm -f $@
+
+# We pass -ansi to keep cpp from define e.g. "i386" as well as "__i386__"
+SYSCALLS.i: SYSCALLS.def
+       $(CC) $(CFLAGS) -D__ASSEMBLY__ -ansi -x assembler-with-cpp -E -o $@ $<
+
+syscalls.nrs: ../include/sys/syscall.h ../include/arch/$(ARCH)/klibc/archsys.h ../linux/include/asm/unistd.h
+       $(CC) $(CFLAGS) -Wp,-dM -x c -E -o $@ ../include/sys/syscall.h
+
+syscalls.dir: SYSCALLS.i syscalls.pl arch/$(ARCH)/sysstub.ph syscommon.h syscalls.nrs
        rm -rf syscalls
        mkdir syscalls
-       $(PERL) syscalls.pl $(ARCH) SYSCALLS
+       $(PERL) syscalls.pl SYSCALLS.i $(ARCH) $(BITSIZE) syscalls.nrs ../include/klibc/havesyscall.h
        touch $@
 
-socketcalls.dir: SOCKETCALLS socketcalls.pl socketcommon.h
+../include/klibc/havesyscall.h: syscalls.dir
+       : Generated by side effect
+
+socketcalls.dir: SOCKETCALLS.def socketcalls.pl socketcommon.h
        rm -rf socketcalls
        mkdir socketcalls
-       $(PERL) socketcalls.pl $(ARCH) SOCKETCALLS
+       $(PERL) socketcalls.pl SOCKETCALLS.def $(ARCH)
        touch $@
 
 %/static.obj: %.dir
@@ -133,9 +158,10 @@ clean: archclean
        rm -f $(TESTS) tests/*.stripped
        rm -rf syscalls syscalls.dir
        rm -rf socketcalls socketcalls.dir
-       rm -f sha1hash
+       rm -f sha1hash errlist.c
 
 spotless: clean
+       rm -f ../include/klibc/havesyscall.h syscalls.nrs
        find . \( -name \*~ -o -name '.*.d' \) -not -type d -print0 | \
                xargs -0rt rm -f
 
index d69fa8d..edc8524 100644 (file)
@@ -1,6 +1,6 @@
 This is klibc, what is intended to be a minimalistic libc subset for
 use with initramfs.  It is deliberately written for small size,
-minimal entaglement and portability, not speed.  It is definitely a
+minimal entaglement, and portability, not speed.  It is definitely a
 work in progress, and a lot of things are still missing.
 
 
@@ -34,20 +34,38 @@ b) If you're cross-compiling, change ARCH in the main MCONFIG file to
 
    The following is the last known status of various architectures:
 
-   Known to work:             alpha arm ia64 i386 ppc s390 s390x sparc
-                              sparc64 x86_64*
-   Works static, not shared:   mips* arm-thumb sh* parisc
-   Might work:                ppc64
-   Need porting work:         cris m68k mips64 v850
-
-   x86_64:   requires a kernel header patch (to be created)
-   mips, sh: linker problem; might work with fixed linker
-
-   Shared library support requires binutils 2.13.90.0.4 or later on
-   many architectures.
-
-   Note that even the "known to work" ones likely have bugs.  Please
-   report them if you run into them.
+   alpha:       Working static, shared untested
+   arm-thumb:   Untested
+   arm26:       Not yet ported
+   arm:                 Working
+   cris:        Untested
+   h8300:       Not yet ported
+   i386:        Working
+   ia64:        Working
+   m68k:        Not yet ported
+   mips64:      Not yet ported
+   mips:        Working
+   parisc:      Untested
+   ppc64:       Working
+   ppc:                 Working
+   s390:        Working static, shared untested
+   s390x:       Working
+   sh:          Untested
+   sparc64:     sigaction() fails in ash for unknown reason
+   sparc:       Working
+   v850:        Not yet ported
+   x86-64:      Working
+   
+   Shared library support requires recent binutils on many
+   architectures.
+
+   "Need sysstub.ph" means the architectural changes first implemented
+   in klibc-0.117 has not yet been implemented; klibc-0.116 did,
+   however, work.  "Not yet ported" means no porting work has been
+   done on this architecture.
+
+   Note that even the "working" ones likely have bugs.  Please report
+   them if you run into them.
 
 c) Type "make" and pray...
 
diff --git a/klibc/klibc/SOCKETCALLS b/klibc/klibc/SOCKETCALLS
deleted file mode 100644 (file)
index 1ab4e36..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-# -*- fundamental -*-
-#
-# These are calls that are invoked via the socketcall mechanism
-#
-int socket(int, int, int)
-int bind(int, struct sockaddr *, int)
-int connect(int, struct sockaddr *, socklen_t)
-int listen(int, int)
-int accept(int, struct sockaddr *, socklen_t *)
-int getsockname(int, struct sockaddr *, socklen_t *)
-int getpeername(int, struct sockaddr *, socklen_t *)
-int socketpair(int, int, int, int *)
-# int send(int, const void *, size_t, unsigned int)
-int sendto(int, const void *, size_t, int, const struct sockaddr *, socklen_t)
-# int recv(int, void *, size_t, unsigned int)
-int recvfrom(int, void *, size_t, unsigned int, struct sockaddr *, socklen_t *)
-int shutdown(int, int)
-int setsockopt(int, int, int, const void *, socklen_t)
-int getsockopt(int, int, int, void *, socklen_t *)
-int sendmsg(int, const struct msghdr *, unsigned int)
-int recvmsg(int, struct msghdr *, unsigned int)
diff --git a/klibc/klibc/SOCKETCALLS.def b/klibc/klibc/SOCKETCALLS.def
new file mode 100644 (file)
index 0000000..e70b3fc
--- /dev/null
@@ -0,0 +1,21 @@
+; -*- fundamental -*-
+;
+; These are calls that are invoked via the socketcall mechanism
+; Note that on most architectures this is simply #included into
+; SYSCALLS.def.
+;
+<?> int socket(int, int, int)
+<?> int bind(int, struct sockaddr *, int)
+<?> int connect(int, struct sockaddr *, socklen_t)
+<?> int listen(int, int)
+<?> int accept(int, struct sockaddr *, socklen_t *)
+<?> int getsockname(int, struct sockaddr *, socklen_t *)
+<?> int getpeername(int, struct sockaddr *, socklen_t *)
+<?> int socketpair(int, int, int, int *)
+<?> int sendto(int, const void *, size_t, int, const struct sockaddr *, socklen_t)
+<?> int recvfrom(int, void *, size_t, unsigned int, struct sockaddr *, socklen_t *)
+<?> int shutdown(int, int)
+<?> int setsockopt(int, int, int, const void *, socklen_t)
+<?> int getsockopt(int, int, int, void *, socklen_t *)
+<?> int sendmsg(int, const struct msghdr *, unsigned int)
+<?> int recvmsg(int, struct msghdr *, unsigned int)
diff --git a/klibc/klibc/SYSCALLS b/klibc/klibc/SYSCALLS
deleted file mode 100644 (file)
index 8208120..0000000
+++ /dev/null
@@ -1,153 +0,0 @@
-# -*- fundamental -*-
-#
-# This is a list of system calls we invoke "directly".  These
-# are generated into syscall stubs in their own C files, so the
-# linker can do its job properly.
-#
-# The full description of a line is:
-# [<[!]arch,...>] type sysname[@systype][::funcname](args)
-#
-
-#
-# Process-related syscalls
-#
-<!mips,mips64,sparc,ia64> pid_t vfork()
-<sparc> pid_t vfork@forkish()
-<!alpha> pid_t getpid()
-<alpha> pid_t getxpid@dual0::getpid()
-int setpgid(pid_t, pid_t)
-pid_t getpgid(pid_t)
-<!alpha> pid_t getppid()
-<alpha> pid_t getxpid@dual1::getppid()
-pid_t setsid()
-pid_t getsid(pid_t)
-pid_t wait4(pid_t, int *, int, struct rusage *)
-int execve(const char *, char * const *, char * const *)
-int setpriority(int, int, int)
-int sched_setscheduler(pid_t, int, const struct sched_param *)
-int sched_yield()
-
-#
-# User and group IDs
-#
-int setuid(uid_t)
-int setgid(gid_t)
-<!alpha> uid_t getuid()
-<alpha> uid_t getxuid@dual0::getuid()
-<!alpha> gid_t getgid()
-<alpha> gid_t getxgid@dual0::getgid()
-<!alpha> uid_t geteuid()
-<alpha> uid_t getxuid@dual1::geteuid()
-<!alpha> gid_t getegid()
-<alpha> uid_t getxgid@dual1::getegid()
-int getgroups(int, gid_t *)
-int setgroups(size_t, const gid_t *)
-int setreuid(uid_t, uid_t)
-int setregid(gid_t, gid_t)
-int setfsuid(uid_t)
-int setfsgid(gid_t)
-
-#
-# Filesystem-related system calls
-#
-int mount(const char *, const char *, const char *, unsigned long, const void *)
-<!alpha,ia64> int umount2(const char *, int)
-<alpha,ia64> int umount::umount2(const char *, int)
-<!m68k> int pivot_root(const char *, const char *)
-int sync()
-int statfs(const char *, struct statfs *)
-int fstatfs(int, struct statfs *)
-int swapon(const char *, int)
-int swapoff(const char *)
-
-#
-# Inode-related system calls
-#
-int access(const char *, int)
-int link(const char *, const char *)
-int unlink(const char *)
-int chdir(const char *)
-int rename(const char *, const char *)
-int mknod(const char *, mode_t, dev_t)
-int chmod(const char *, mode_t)
-int fchmod(int, mode_t)
-int mkdir(const char *, mode_t)
-int rmdir(const char *)
-<!alpha,ia64,mips,mips64> int pipe(int *)
-mode_t umask(mode_t)
-int chroot(const char *)
-int symlink(const char *, const char *)
-int readlink(const char *, char *, size_t)
-int stat(const char *, struct stat *)
-int lstat(const char *, struct stat *)
-int fstat(int, struct stat *)
-int getdents(unsigned int, struct dirent *, unsigned int)
-int chown(const char *, uid_t, gid_t)
-int fchown(int, uid_t, gid_t)
-int lchown(const char *, uid_t, gid_t)
-
-#
-# I/O operations
-#
-ssize_t read(int, void *, size_t)
-ssize_t write(int, const void *, size_t)
-int close(int)
-off_t lseek(int, off_t, int)
-int dup(int)
-int dup2(int, int)
-int fcntl(int, int, long)
-int ioctl(int, int, void *)
-int flock(int, int)
-int poll(struct pollfd *, nfds_t, long)
-int fsync(int)
-int readv(int, const struct iovec *, int)
-int writev(int, const struct iovec *, int)
-int ftruncate(int, off_t)
-
-#
-# Signal operations
-#
-int kill(pid_t, int)
-int rt_sigaction(int, const struct sigaction *, struct sigaction *, size_t)
-int rt_sigsuspend(const sigset_t *, size_t)
-int rt_sigpending(sigset_t *, size_t)
-int rt_sigprocmask(int, const sigset_t *, sigset_t *, size_t)
-int getitimer(int, struct itimerval *)
-int setitimer(int, const struct itimerval *, struct itimerval *)
-
-#
-# Time-related system calls
-#
-clock_t times(struct tms *)
-int gettimeofday(struct timeval *, struct timezone *)
-int settimeofday(const struct timeval *, const struct timezone *)
-int nanosleep(const struct timespec *, struct timespec *)
-
-#
-# Memory
-#
-void * brk::__brk(void *)
-int munmap(void *, size_t)
-void * mremap(void *, size_t, size_t, unsigned long)
-int msync(const void *, size_t, int)
-int mprotect(const void *, size_t, int)
-
-#
-# System stuff
-#
-int uname(struct utsname *)
-int setdomainname(const char *, size_t)
-int sethostname(const char *, size_t)
-long init_module(void *, unsigned long, const char *)
-long delete_module(const char *, unsigned int)
-<!ia64> int query_module(const char *, int, void *, size_t, size_t)
-int reboot::__reboot(int, int, int, void *)
-int syslog::klogctl(int, char *, int)
-int sysinfo(struct sysinfo *)
-
-#
-# Low-level I/O (generally architecture-specific)
-#
-<i386,x86_64> int iopl(int)
-<i386,x86_64> int ioperm(unsigned long, unsigned long, int)
-<i386> int vm86(struct vm86_struct *)
diff --git a/klibc/klibc/SYSCALLS.def b/klibc/klibc/SYSCALLS.def
new file mode 100644 (file)
index 0000000..dbd7dc8
--- /dev/null
@@ -0,0 +1,207 @@
+; -*- fundamental -*-
+;
+; This is a list of system calls we invoke "directly".  These
+; are generated into syscall stubs in their own files, so the
+; linker can do its job properly.
+;
+; The full description of a line is:
+; [<[?][!]arch,...>] type [sysname,...][@systype][::funcname](args)
+;
+; ? means only instantiate this system call if present in asm/unistd.h
+;
+
+#include <asm/unistd.h>
+
+;
+; Process-related syscalls
+;
+<?!ia64> pid_t clone::__clone(unsigned long, void *)
+<?ia64> pid_t clone::__clone2(unsigned long, void *, void *)
+<?!sparc> pid_t fork()
+<sparc> pid_t fork@forkish()
+<!mips,mips64,sparc,ia64> pid_t vfork()
+<sparc> pid_t vfork@forkish()
+<!alpha> pid_t getpid()
+<alpha> pid_t getxpid@dual0::getpid()
+int setpgid(pid_t, pid_t)
+pid_t getpgid(pid_t)
+<!alpha> pid_t getppid()
+<alpha> pid_t getxpid@dual1::getppid()
+pid_t setsid()
+pid_t getsid(pid_t)
+pid_t wait4(pid_t, int *, int, struct rusage *)
+int execve(const char *, char * const *, char * const *)
+<?> int nice(int)
+<alpha,ia64> int getpriority(int, int)
+<!alpha,ia64> int getpriority::__getpriority(int, int)
+int setpriority(int, int, int)
+int sched_setscheduler(pid_t, int, const struct sched_param *)
+int sched_yield()
+
+;
+; User and group IDs
+;
+int setuid32,setuid::setuid(uid_t)
+int setgid32,setgid::setgid(gid_t)
+<!alpha> uid_t getuid32,getuid::getuid()
+<alpha>  uid_t getxuid@dual0::getuid()
+<!alpha> gid_t getgid32,getgid::getgid()
+<alpha> gid_t getxgid@dual0::getgid()
+<!alpha> uid_t geteuid32,geteuid::geteuid()
+<alpha> uid_t getxuid@dual1::geteuid()
+<!alpha> gid_t getegid32,getegid::getegid()
+<alpha> gid_t getxgid@dual1::getegid()
+int getgroups32,getgroups::getgroups(int, gid_t *)
+int setgroups32,setgroups::setgroups(size_t, const gid_t *)
+int setreuid32,setreuid::setreuid(uid_t, uid_t)
+int setregid32,setregid::setregid(gid_t, gid_t)
+int setfsuid32,setfsuid::setfsuid(uid_t)
+int setfsgid32,setfsgid::setfsgid(gid_t)
+int setresuid32,setresuid::setresuid(int, uid_t, uid, uid_t)
+
+;
+; Filesystem-related system calls
+;
+int mount(const char *, const char *, const char *, unsigned long, const void *)
+<!alpha,ia64> int umount2(const char *, int)
+<alpha,ia64> int umount::umount2(const char *, int)
+<!m68k> int pivot_root(const char *, const char *)
+int sync()
+#ifdef __NR_statfs64
+int statfs64::__statfs64(const char *, size_t, struct statfs *)
+#else
+int statfs(const char *, struct statfs *)
+#endif
+#ifdef __NR_fstatfs64
+int fstatfs64::__fstatfs64(int, size_t, struct statfs *)
+#else
+int fstatfs(int, struct statfs *)
+#endif
+int swapon(const char *, int)
+int swapoff(const char *)
+
+;
+; Inode-related system calls
+;
+int access(const char *, int)
+int link(const char *, const char *)
+int unlink(const char *)
+int chdir(const char *)
+int fchdir(int)
+int rename(const char *, const char *)
+int mknod(const char *, mode_t, dev_t)
+int chmod(const char *, mode_t)
+int fchmod(int, mode_t)
+int mkdir(const char *, mode_t)
+int rmdir(const char *)
+<!alpha,ia64,mips,mips64> int pipe(int *)
+mode_t umask(mode_t)
+int chroot(const char *)
+int symlink(const char *, const char *)
+int readlink(const char *, char *, size_t)
+int stat64,stat::stat(const char *, struct stat *)
+int lstat64,lstat::lstat(const char *, struct stat *)
+int fstat64,fstat::fstat(int, struct stat *)
+int getdents64,getdents::getdents(unsigned int, struct dirent *, unsigned int)
+int chown32,chown::chown(const char *, uid_t, gid_t)
+int fchown32,fchown::fchown(int, uid_t, gid_t)
+int lchown32,lchown::lchown(const char *, uid_t, gid_t)
+int getcwd::__getcwd(char *, size_t)
+<?> int utime(const char *, const struct utimbuf *)
+<?> int utimes(const char *, const struct timeval *)
+
+;
+; I/O operations
+;
+<!i386,64> int open::__open(const char *, int, mode_t)
+<64> int open(const char *, int, mode_t)
+ssize_t read(int, void *, size_t)
+ssize_t write(int, const void *, size_t)
+int close(int)
+<64> off_t lseek(int, off_t, int)
+<32> int _llseek::__llseek(int, unsigned long, unsigned long, off_t *, int)
+int dup(int)
+int dup2(int, int)
+<i386> int fcntl64@varadic::fcntl(int, int, unsigned long)
+<!i386> int fcntl64,fcntl::fcntl(int, int, unsigned long)
+int ioctl(int, int, void *)
+int flock(int, int)
+int _newselect,select::select(int, fd_set *, fd_set *, fd_set *, struct timeval *)
+int poll(struct pollfd *, nfds_t, long)
+int fsync(int)
+int fdatasync,fsync::fdatasync(int)
+int readv(int, const struct iovec *, int)
+int writev(int, const struct iovec *, int)
+int ftruncate64,ftruncate::ftruncate(int, off_t)
+ssize_t pread64,pread::pread(int, void *, size_t, off_t)
+ssize_t pwrite64,pwrite::pwrite(int, void *, size_t, off_t)
+
+;
+; Signal operations
+;
+int kill(pid_t, int)
+<?> int sigaction(int, const struct sigaction *, struct sigaction *)
+int rt_sigaction(int, const struct sigaction *, struct sigaction *, size_t)
+<?> int sigsuspend(const sigset_t *)
+int rt_sigsuspend(const sigset_t *, size_t)
+<?> int sigpending(sigset_t)
+int rt_sigpending(sigset_t *, size_t)
+<?> int sigprocmask(int, const sigset_t *, sigset_t *)
+int rt_sigprocmask(int, const sigset_t *, sigset_t *, size_t)
+<?> unsigned int alarm(unsigned int)
+int getitimer(int, struct itimerval *)
+int setitimer(int, const struct itimerval *, struct itimerval *)
+
+;
+; Time-related system calls
+;
+<?> time_t time(time_t *)
+clock_t times(struct tms *)
+int gettimeofday(struct timeval *, struct timezone *)
+int settimeofday(const struct timeval *, const struct timezone *)
+int nanosleep(const struct timespec *, struct timespec *)
+<?> int pause()
+
+;
+; Memory
+;
+void * brk::__brk(void *)
+int munmap(void *, size_t)
+void * mremap(void *, size_t, size_t, unsigned long)
+int msync(const void *, size_t, int)
+int mprotect(const void *, size_t, int)
+#if (BITSIZE == 32 && defined(__NR_mmap2)) || (BITSIZE == 64 && !defined(__NR_mmap))
+<!s390> void * mmap2::__mmap2(void *, size_t, int, int, int, long)
+#else
+<!s390x> void * mmap(void *, size_t, int, int, int, long)
+#endif
+int mlockall(int)
+int munlockall()
+int mlock(const void *, size_t)
+int munlock(const void *, size_t)
+
+;
+; System stuff
+;
+int uname(struct utsname *)
+int setdomainname(const char *, size_t)
+int sethostname(const char *, size_t)
+long init_module(void *, unsigned long, const char *)
+long delete_module(const char *, unsigned int)
+int reboot::__reboot(int, int, int, void *)
+int syslog::klogctl(int, char *, int)
+int sysinfo(struct sysinfo *)
+
+;
+; Low-level I/O (generally architecture-specific)
+;
+<i386,x86_64> int iopl(int)
+<i386,x86_64> int ioperm(unsigned long, unsigned long, int)
+<i386> int vm86(struct vm86_struct *)
+
+;
+; Most architectures have the socket interfaces using regular
+; system calls.
+;
+<?!i386> long socketcall::__socketcall(int, const unsigned long *)
+#include "SOCKETCALLS.def"
index 63e3f46..592a3db 100644 (file)
@@ -1,56 +1,2 @@
-/*
- * __shared_init.c
- *
- * This function takes the raw data block set up by the ELF loader
- * in the kernel and parses it.  It is invoked by crt0.S which makes
- * any necessary adjustments and passes calls this function using
- * the standard C calling convention.
- *
- * The arguments are:
- *  uintptr_t *elfdata  -- The ELF loader data block; usually from the stack.
- *                          Basically a pointer to argc.
- *  void (*onexit)(void) -- Function to install into onexit
- */
-
-#include <stddef.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <klibc/compiler.h>
-#include <elf.h>
-
-char **environ;
-
-__noreturn __libc_init(uintptr_t *elfdata, void (*onexit)(void))
-{
-  int argc;
-  char **argv, **envp, **envend;
-  struct auxentry {
-    uintptr_t type;
-    uintptr_t v;
-  } *auxentry;
-  typedef int (*main_t)(int, char **, char **);
-  main_t main_ptr = NULL;
-
-  (void)onexit;                        /* For now, we ignore this... */
-
-  argc = (int)*elfdata++;
-  argv = (char **)elfdata;
-  envp = argv+(argc+1);
-
-  /* The auxillary entry vector is after all the environment vars */
-  for ( envend = envp ; *envend ; envend++ );
-  auxentry = (struct auxentry *)(envend+1);
-
-  while ( auxentry->type ) {
-    if ( auxentry->type == AT_ENTRY ) {
-      main_ptr = (main_t)(auxentry->v);
-      break;
-    }
-    auxentry++;
-  }
-
-  environ = envp;
-  exit(main_ptr(argc, argv, envp));
-}
-
-  
+#define SHARED 1
+#include "libc_init.c"
index 5a90b5c..0b59eed 100644 (file)
@@ -1,38 +1,2 @@
-/*
- * __static_init.c
- *
- * This function takes the raw data block set up by the ELF loader
- * in the kernel and parses it.  It is invoked by crt0.S which makes
- * any necessary adjustments and passes calls this function using
- * the standard C calling convention.
- *
- * The arguments are:
- *  uintptr_t *elfdata  -- The ELF loader data block; usually from the stack.
- *                          Basically a pointer to argc.
- *  void (*onexit)(void) -- Function to install into onexit
- */
-
-#include <stddef.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <klibc/compiler.h>
-#include <elf.h>
-
-char **environ;
-
-extern int main(int, char **, char **);
-
-__noreturn __libc_init(uintptr_t *elfdata, void (*onexit)(void))
-{
-  int argc;
-  char **argv, **envp;
-
-  (void)onexit;                        /* For now, we ignore this... */
-
-  argc = (int)*elfdata++;
-  argv = (char **)elfdata;
-  envp = argv+(argc+1);
-
-  environ = envp;
-  exit(main(argc, argv, envp));
-}
+#define SHARED 0
+#include "libc_init.c"
index ca7bb37..40c0969 100644 (file)
@@ -5,11 +5,7 @@
 #include <sys/time.h>
 #include <sys/syscall.h>
 
-#ifdef __NR_alarm
-
-_syscall1(unsigned int,alarm,unsigned int,seconds);
-
-#else
+#ifndef __NR_alarm
 
 /* Emulate alarm() via setitimer() */
 
index 2a1100f..62fce9d 100644 (file)
@@ -11,7 +11,7 @@
 DIVCFLAGS = $(REQFLAGS) \
        -O3 -fomit-frame-pointer -fcall-saved-1 -fcall-saved-2 \
        -fcall-saved-3 -fcall-saved-4 -fcall-saved-5 -fcall-saved-6 \
-       -fcall-saved-7 -fcall-saved-8 -fcall-saved-15 -fcall-saved-16 \
+       -fcall-saved-7 -fcall-saved-8 -ffixed-15 -fcall-saved-16 \
        -fcall-saved-17 -fcall-saved-18 -fcall-saved-19 -fcall-saved-20 \
        -fcall-saved-21 -fcall-saved-22 -ffixed-23 -fcall-saved-24 \
        -ffixed-25 -ffixed-27
@@ -26,7 +26,9 @@ ARCHOBJS = \
        arch/$(ARCH)/__divl.o \
        arch/$(ARCH)/__reml.o \
        arch/$(ARCH)/pipe.o \
-       arch/$(ARCH)/setjmp.o
+       arch/$(ARCH)/setjmp.o \
+       arch/$(ARCH)/syscall.o \
+       arch/$(ARCH)/sysdual.o
 
 ARCHSOOBJS = $(patsubst %.o,%.lo,$(ARCHOBJS))
 
index 6c29581..904b539 100644 (file)
@@ -3,10 +3,10 @@
 #
 
        .text
-       .type   __start,@function
-       .ent    __start, 0
-       .globl  __start
-__start:
+       .type   _start,@function
+       .ent    _start, 0
+       .globl  _start
+_start:
        .frame  $30, 0, $26, 0
        mov     $31, $15
        br      $29, 1f
@@ -18,4 +18,5 @@ __start:
        
        jsr     $26, __libc_init
        
-       .size __start,.-__start
+       .size   _start,.-_start
+       .end    _start
diff --git a/klibc/klibc/arch/alpha/include/klibc/archsetjmp.h b/klibc/klibc/arch/alpha/include/klibc/archsetjmp.h
deleted file mode 100644 (file)
index 9dc570a..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * arch/alpha/include/klibc/archsetjmp.h
- */
-
-#ifndef _KLIBC_ARCHSETJMP_H
-#define _KLIBC_ARCHSETJMP_H
-
-struct __jmp_buf {
-  unsigned long __s0;
-  unsigned long __s1;
-  unsigned long __s2;
-  unsigned long __s3;
-  unsigned long __s4;
-  unsigned long __s5;
-  unsigned long __fp;
-  unsigned long __ra;
-  unsigned long __gp;
-  unsigned long __sp;
-  
-  unsigned long __f2;
-  unsigned long __f3;
-  unsigned long __f4;
-  unsigned long __f5;
-  unsigned long __f6;
-  unsigned long __f7;
-  unsigned long __f8;
-  unsigned long __f9;
-};
-
-/* Must be an array so it will decay to a pointer when a function is called */
-typedef struct __jmp_buf jmp_buf[1];
-
-#endif /* _KLIBC_ARCHSETJMP_H */
diff --git a/klibc/klibc/arch/alpha/include/klibc/archsignal.h b/klibc/klibc/arch/alpha/include/klibc/archsignal.h
deleted file mode 100644 (file)
index b870a05..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * arch/alpha/include/klibc/archsignal.h
- *
- * Architecture-specific signal definitions
- *
- */
-
-#ifndef _KLIBC_ARCHSIGNAL_H
-#define _KLIBC_ARCHSIGNAL_H
-
-/* No special stuff for this architecture */
-
-#endif
diff --git a/klibc/klibc/arch/alpha/include/klibc/archsys.h b/klibc/klibc/arch/alpha/include/klibc/archsys.h
deleted file mode 100644 (file)
index 16ed658..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * arch/alpha/include/klibc/archsys.h
- *
- * Architecture-specific syscall definitions
- */
-
-#ifndef _KLIBC_ARCHSYS_H
-#define _KLIBC_ARCHSYS_H
-
-/* Alpha has some bizarre Tru64-derived system calls which return two
-   different values in $0 and $20(!), respectively.  The standard
-   macros can't deal with these; even the ones that give the right
-   return value have the wrong clobbers. */
-
-#define _syscall0_dual0(type, name)                                     \
-type name(void)                                                         \
-{                                                                       \
-        long _sc_ret, _sc_err;                                          \
-        {                                                               \
-                register long _sc_0 __asm__("$0");                      \
-                register long _sc_19 __asm__("$19");                    \
-                register long _sc_20 __asm__("$20");                    \
-                                                                        \
-                _sc_0 = __NR_##name;                                    \
-                __asm__("callsys"                                       \
-                        : "=r"(_sc_0), "=r"(_sc_19), "=r" (_sc_20)      \
-                        : "0"(_sc_0)                                    \
-                        : _syscall_clobbers);                           \
-                _sc_ret = _sc_0, _sc_err = _sc_19; (void)(_sc_20);      \
-        }                                                               \
-        _syscall_return(type);                                          \
-}
-
-#define _syscall0_dual1(type, name)                                     \
-type name(void)                                                         \
-{                                                                       \
-        long _sc_ret, _sc_err;                                          \
-        {                                                               \
-                register long _sc_0 __asm__("$0");                      \
-                register long _sc_19 __asm__("$19");                    \
-                register long _sc_20 __asm__("$20");                    \
-                                                                        \
-                _sc_0 = __NR_##name;                                    \
-                __asm__("callsys"                                       \
-                        : "=r"(_sc_0), "=r"(_sc_19), "=r" (_sc_20)      \
-                        : "0"(_sc_0)                                    \
-                        : _syscall_clobbers);                           \
-                _sc_ret = _sc_20, _sc_err = _sc_19; (void)(_sc_0);      \
-        }                                                               \
-        _syscall_return(type);                                          \
-}
-
-#endif /* _KLIBC_ARCHSYS_H */
diff --git a/klibc/klibc/arch/alpha/include/machine/asm.h b/klibc/klibc/arch/alpha/include/machine/asm.h
deleted file mode 100644 (file)
index e22db90..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * machine/asm.h
- */
-
-#ifndef _MACHINE_ASM_H
-#define _MACHINE_ASM_H
-
-/* Standard aliases for Alpha register names */
-
-#define v0     $0
-#define t0     $1
-#define t1     $2
-#define t2     $3
-#define t3     $4
-#define t4     $5
-#define t5     $6
-#define t6     $7
-#define t7     $8
-#define s0     $9
-#define s1     $10
-#define s2     $11
-#define s3     $12
-#define s4     $13
-#define s5     $14
-#define fp     $15
-#define a0     $16
-#define a1     $17
-#define a2     $18
-#define a3     $19
-#define a4     $20
-#define a5     $21
-#define t8     $22
-#define t9     $23
-#define t10    $24
-#define t11    $25
-#define ra     $26
-#define t12    $27             /* t12 and pv are both used for $27 */
-#define pv     $27             /* t12 and pv are both used for $27 */
-#define at     $28
-#define gp     $29
-#define sp     $30
-#define zero   $31
-
-#endif /* _MACHINE_ASM_H */
index e1ad642..5d915f2 100644 (file)
@@ -31,14 +31,14 @@ setjmp:
        stq     ra,  56(a0)
        stq     gp,  64(a0)
        stq     sp,  72(a0)
-       stt     f2,  80(a0)
-       stt     f3,  88(a0)
-       stt     f4,  96(a0)
-       stt     f5, 104(a0)
-       stt     f6, 112(a0)
-       stt     f7, 120(a0)
-       stt     f8, 128(a0)
-       stt     f9, 136(a0)
+       stt     $f2,  80(a0)
+       stt     $f3,  88(a0)
+       stt     $f4,  96(a0)
+       stt     $f5, 104(a0)
+       stt     $f6, 112(a0)
+       stt     $f7, 120(a0)
+       stt     $f8, 128(a0)
+       stt     $f9, 136(a0)
        ret     zero,(ra),1
 
        .size setjmp,.-setjmp
@@ -59,14 +59,14 @@ longjmp:
        ldq     ra,  56(a0)
        ldq     gp,  64(a0)
        ldq     sp,  72(a0)
-       ldt     f2,  80(a0)
-       ldt     f3,  88(a0)
-       ldt     f4,  96(a0)
-       ldt     f5, 104(a0)
-       ldt     f6, 112(a0)
-       ldt     f7, 120(a0)
-       ldt     f8, 128(a0)
-       ldt     f9, 136(a0)
+       ldt     $f2,  80(a0)
+       ldt     $f3,  88(a0)
+       ldt     $f4,  96(a0)
+       ldt     $f5, 104(a0)
+       ldt     $f6, 112(a0)
+       ldt     $f7, 120(a0)
+       ldt     $f8, 128(a0)
+       ldt     $f9, 136(a0)
        /* We're bound to get a mispredict here, but at least give us
           a chance to get the return stack back in sync... */
        ret     zero,(ra),1
diff --git a/klibc/klibc/arch/alpha/syscall.S b/klibc/klibc/arch/alpha/syscall.S
new file mode 100644 (file)
index 0000000..0c87414
--- /dev/null
@@ -0,0 +1,26 @@
+#
+# arch/alpha/syscall.S
+#
+
+#include <machine/asm.h>
+       
+       .text
+       .align  3
+       .type   __syscall_common,@function
+       .ent    __syscall_common, 0
+       .globl  __syscall_common
+__syscall_common:
+       .frame  sp,0,ra,0
+       callsys
+       beq     a3, 1f
+       br      pv, 2f                  # pv <- pc  
+2:
+       ldgp    gp, 0(pv)
+       lda     a1, errno
+       lda     v0, -1(zero)
+       stl     a3, 0(a1)
+1:
+       ret     zero,(ra),1
+
+       .size   __syscall_common,.-__syscall_common
+       .end    __syscall_common
diff --git a/klibc/klibc/arch/alpha/sysdual.S b/klibc/klibc/arch/alpha/sysdual.S
new file mode 100644 (file)
index 0000000..c00db88
--- /dev/null
@@ -0,0 +1,33 @@
+#
+# arch/alpha/sysdual.S
+#
+
+#
+# Some system calls have an alternate return value in r20 (a4).
+# This system call stub is for system calls where that is
+# the "real" return value.
+#
+
+#include <machine/asm.h>
+       
+       .text
+       .align  3
+       .type   __syscall_dual1,@function
+       .ent    __syscall_dual1, 0
+       .globl  __syscall_dual1
+__syscall_dual1:
+       .frame  sp,0,ra,0
+       callsys
+       mov     v0, a4
+       beq     a3, 1f
+       br      pv, 2f                  # pv <- pc  
+2:
+       ldgp    gp, 0(pv)
+       lda     a1, errno
+       lda     v0, -1(zero)
+       stl     a3, 0(a1)
+1:
+       ret     zero,(ra),1
+
+       .size   __syscall_dual1,.-__syscall_dual1
+       .end    __syscall_dual1
diff --git a/klibc/klibc/arch/alpha/sysstub.ph b/klibc/klibc/arch/alpha/sysstub.ph
new file mode 100644 (file)
index 0000000..a24b6c0
--- /dev/null
@@ -0,0 +1,37 @@
+# -*- perl -*-
+#
+# arch/alpha/sysstub.ph
+#
+# Script to generate system call stubs
+#
+
+# On Alpha, most system calls follow the standard convention, with the
+# system call number in r0 (v0), return an error value in r19 (a3) as
+# well as the return value in r0 (v0).
+#
+# A few system calls are dual-return with the second return value in
+# r20 (a4).
+
+sub make_sysstub($$$$@) {
+    my($fname, $type, $sname, $stype, @args) = @_;
+
+    $stype = $stype || 'common';
+    $stype = 'common' if ( $stype eq 'dual0' );
+
+    open(OUT, '>', "syscalls/${fname}.S");
+    print OUT "#include <asm/unistd.h>\n";
+    print OUT "#include <machine/asm.h>\n";
+    print OUT "\n";
+    print OUT "\t.text\n";
+    print OUT "\t.type ${fname},\@function\n";
+    print OUT "\t.ent\t${fname}, 0\n"; # What is this?
+    print OUT "\t.globl ${fname}\n";
+    print OUT "${fname}:\n";
+    print OUT "\tlda\tv0, __NR_${sname}(zero)\n";
+    print OUT "\tbr __syscall_${stype}\n";
+    print OUT "\t.size\t${fname},.-${fname}\n";
+    print OUT "\t.end\t${fname}\n";
+    close(OUT);
+}
+
+1;
index 3ec8c05..0603d85 100644 (file)
@@ -17,7 +17,8 @@ ARCHOBJS = \
        libgcc/__moddi3.o \
        libgcc/__udivdi3.o \
        libgcc/__umoddi3.o \
-       libgcc/__udivmoddi4.o
+       libgcc/__udivmoddi4.o \
+       arch/arm/syscall.o
 
 ifeq ($(THUMB),y)
 ARCHOBJS += arch/arm/setjmp-thumb.o
@@ -26,6 +27,17 @@ else
 ARCHOBJS += arch/arm/setjmp-arm.o
 endif
 
+arch/arm/sysstubs.a: arch/arm/sysstubs.pl
+       mkdir -p arch/arm/sysstubs
+       $(PERL) $< arch/arm/sysstubs
+       $(MAKE) $(patsubst %.S,%.o,$(wildcard arch/arm/sysstubs/*.S))
+       -rm -f $@
+       $(AR) cq $@ arch/arm/sysstubs/*.o
+       $(RANLIB) $@
+
+
 ARCHSOOBJS = $(patsubst %.o,%.lo,$(ARCHOBJS))
 
 archclean:
+       -rm -rf arch/arm/sysstubs
+       -rm -f arch/arm/sysstubs.a
index 8cd3640..fc1104e 100644 (file)
@@ -3,10 +3,8 @@
 #
 # void _start(void)
 # {
-#    /* Divine up argc, argv, and envp */
-#    environ = envp;
-#    exit(main(argc, argv, envp));
-# } 
+#    __libc_init(elf_structure, atexit_ptr);
+# }
 #
 
        .text
diff --git a/klibc/klibc/arch/arm/include/klibc/archsetjmp.h b/klibc/klibc/arch/arm/include/klibc/archsetjmp.h
deleted file mode 100644 (file)
index c956b50..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-/*
- * arch/i386/include/klibc/archsetjmp.h
- */
-
-#ifndef _KLIBC_ARCHSETJMP_H
-#define _KLIBC_ARCHSETJMP_H
-
-struct __jmp_buf {
-  unsigned int regs[10];
-};
-
-typedef struct __jmp_buf jmp_buf[1];
-
-#endif /* _SETJMP_H */
diff --git a/klibc/klibc/arch/arm/include/klibc/archsignal.h b/klibc/klibc/arch/arm/include/klibc/archsignal.h
deleted file mode 100644 (file)
index 77685e6..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * arch/arm/include/klibc/archsignal.h
- *
- * Architecture-specific signal definitions
- *
- */
-
-#ifndef _KLIBC_ARCHSIGNAL_H
-#define _KLIBC_ARCHSIGNAL_H
-
-/* No special stuff for this architecture */
-
-#endif
diff --git a/klibc/klibc/arch/arm/include/klibc/archsys.h b/klibc/klibc/arch/arm/include/klibc/archsys.h
deleted file mode 100644 (file)
index 1a77e53..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-/*
- * arch/arm/include/klibc/archsys.h
- *
- * Architecture-specific syscall definitions
- */
-
-#ifndef _KLIBC_ARCHSYS_H
-#define _KLIBC_ARCHSYS_H
-
-/* No special syscall definitions for this architecture */
-
-#endif /* _KLIBC_ARCHSYS_H */
index bcb30b4..1a29ee7 100644 (file)
@@ -34,7 +34,6 @@ setjmp:
        .type longjmp, #function
 longjmp:
        ldmia   r0, {r4, r5, r6, r7, r8, r9, r10, fp, sp, lr}
-       movs    r0, r1
-       moveq   r0, #1
+       mov     r0, r1
        mov     pc, lr
        .size longjmp,.-longjmp
diff --git a/klibc/klibc/arch/arm/syscall.S b/klibc/klibc/arch/arm/syscall.S
new file mode 100644 (file)
index 0000000..0e73f68
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * arch/arm/syscall.S
+ *
+ * System call common handling
+ */
+
+       .type   __syscall_common,#function
+       .globl  __syscall_common
+#ifndef __thumb__
+       /* ARM version - this is executed after the swi */
+
+       .align  4
+__syscall_common:
+        cmn     r0, #4096
+        rsbcs  r2, r0, #0
+        ldrcs  r3, 1f
+        mvncs  r0, #0
+        strcs  r2, [r3]
+       ldmfd   sp!,{r4,r5,pc}
+       
+       .align 4        
+1:
+       .word   errno
+
+#else
+       /* Thumb version - must still load r4 and r5 and run swi */
+
+       .thumb_func
+       .align  2
+__syscall_common:
+       ldr     r4, [sp #12]
+       ldr     r5, [sp #16]
+       swi     0
+       ldr     r1, 2f
+       cmp     r0, r1
+       bcc     1f
+       ldr     r1, 3f
+       neg     r2, r0
+       mvn     r0, #0  
+       str     r2, [r1]
+1:
+       pop     {r4,r5,r7,pc}
+
+       .align  4
+2:
+       .word   #-4095
+3:
+       .word   errno
+
+#endif
diff --git a/klibc/klibc/arch/arm/sysstub.ph b/klibc/klibc/arch/arm/sysstub.ph
new file mode 100644 (file)
index 0000000..bf953cc
--- /dev/null
@@ -0,0 +1,44 @@
+# -*- perl -*-
+#
+# arch/arm/sysstub.ph
+#
+# Script to generate system call stubs
+#
+
+
+sub make_sysstub($$$$@) {
+    my($fname, $type, $sname, $stype, @args) = @_;
+
+    open(OUT, '>', "syscalls/${fname}.S");
+    print  OUT "#include <asm/unistd.h>\n";
+       
+    print  OUT "\t.text\n";
+    print  OUT "\t.type\t${fname}, #function\n";
+    print  OUT "\t.globl ${fname}\n";
+    print  OUT "\t.align\t4\n";
+
+    print  OUT "#ifndef __thumb__\n";
+
+    # ARM version first
+    print  OUT "${fname}:\n";
+    print  OUT "\tstmfd\tsp!,{r4,r5,lr}\n";
+    print  OUT "\tldr\tr4,[sp,#12]\n";
+    print  OUT "\tldr\tr5,[sp,#16]\n";
+    print  OUT "\tswi\t# __NR_${sname}\n";
+    print  OUT "\tb\t__syscall_common\n";
+
+    print  OUT "#else\n";
+
+    # Thumb version
+    print  OUT "\t.thumb_func\n";
+    print  OUT "${fname}:\n";
+    print  OUT "\tpush\t{r4,r5,r7,pc}\n";
+    print  OUT "\tmov\tr7, # __NR_${sname}\n";
+    print  OUT "\tb\t__syscall_common\n";
+    
+    print  OUT "#endif\n";
+
+    print  OUT "\t.size\t__syscall${i},.-__syscall${i}\n";
+}
+
+1;
index 27809eb..2762494 100644 (file)
@@ -9,3 +9,18 @@
 
 OPTFLAGS = -Os -fomit-frame-pointer
 BITSIZE  = 32
+
+# Extra linkflags when building the shared version of the library
+# This address needs to be reachable using normal inter-module
+# calls, and work on the memory models for this architecture
+# 224 MB - normal binaries start at 0
+# (lib?)gcc on cris seems to insist on producing .init and .fini sections
+SHAREDFLAGS     = --section-start .init=0x0e000100
+
+# The CRIS compiler needs an -iprefix to find libgcc includes when
+# nostdinc is used. It also needs -mlinux to compile linux applications.
+INCLUDE_PREFIX  = $(shell $(CC) -print-libgcc-file-name | sed -e s/libgcc.a//)
+ARCHREQFLAGS = -iprefix $(INCLUDE_PREFIX) -mlinux
+
+# Special flags needed for linking
+LDFLAGS        += -mcrislinux
index 41183fd..75fa17b 100644 (file)
@@ -7,4 +7,27 @@
 # accordingly.
 #
 
+ARCHOBJS = \
+       arch/$(ARCH)/__Umod.o \
+       arch/$(ARCH)/__Udiv.o \
+       arch/$(ARCH)/__Mod.o \
+       arch/$(ARCH)/__Div.o \
+       arch/$(ARCH)/__negdi2.o \
+       arch/$(ARCH)/setjmp.o \
+       arch/$(ARCH)/syscall.o \
+       libgcc/__divdi3.o \
+       libgcc/__moddi3.o \
+       libgcc/__udivdi3.o \
+       libgcc/__umoddi3.o \
+       libgcc/__udivmoddi4.o
+
+arch/$(ARCH)/__Umod.o: arch/$(ARCH)/divide.c
+       $(CC) $(CFLAGS) -DSIGNED=0 -DREM=1 -DBITS=32 -DNAME=__Umod -c -o $@ $<
+arch/$(ARCH)/__Udiv.o: arch/$(ARCH)/divide.c
+       $(CC) $(CFLAGS) -DSIGNED=0 -DREM=0 -DBITS=32 -DNAME=__Udiv -c -o $@ $<
+arch/$(ARCH)/__Mod.o: arch/$(ARCH)/divide.c
+       $(CC) $(CFLAGS) -DSIGNED=1 -DREM=1 -DBITS=32 -DNAME=__Mod -c -o $@ $<
+arch/$(ARCH)/__Div.o: arch/$(ARCH)/divide.c
+       $(CC) $(CFLAGS) -DSIGNED=1 -DREM=0 -DBITS=32 -DNAME=__Div -c -o $@ $<
+
 archclean:
diff --git a/klibc/klibc/arch/cris/__negdi2.S b/klibc/klibc/arch/cris/__negdi2.S
new file mode 100644 (file)
index 0000000..3cca9ed
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * arch/cris/__negdi2.c
+ */
+
+/*
+ * In 2's complement arithmetric, -x == (~x + 1), so
+ * -{h,l} = (~{h,l} + {0,1)
+ * -{h,l} = {~h,~l} + {0,1}
+ * -{h,l} = {~h + cy, ~l + 1}
+ * ... where cy = (l == 0)
+ * -{h,l} = {~h + cy, -l}
+ */
+
+       .text
+       .balign 4
+       .type   __negdi2,@function
+       .globl  __negdi2
+__negdi2:
+       neg.d   $r10,$r10
+       seq     $r12
+       not     $r11
+       ret
+         add.d $r12,$r11
+
+       .size __negdi2, .-__negdi2
diff --git a/klibc/klibc/arch/cris/crt0.S b/klibc/klibc/arch/cris/crt0.S
new file mode 100644 (file)
index 0000000..989c82b
--- /dev/null
@@ -0,0 +1,28 @@
+#
+# arch/cris/crt0.S
+#
+# Does arch-specific initialization and invokes __libc_init
+# with the appropriate arguments.
+#
+# See __static_init.c or __shared_init.c for the expected
+# arguments.
+#
+
+       .text
+       .balign 4
+       .type   _start,@function
+       .globl  _start
+_start:
+       /* Save the address of the ELF argument array */
+       move.d  $sp,$r10        /* Address of ELF arguments */
+
+       /* atexit() function (assume null) */
+       moveq   0,$r11
+       
+       /* Set up a dummy stack frame to keep gcc from getting confused */
+       push    $r11
+       push    $r11
+       jump    __libc_init
+
+       .size _start, .-_start
+
diff --git a/klibc/klibc/arch/cris/divide.c b/klibc/klibc/arch/cris/divide.c
new file mode 100644 (file)
index 0000000..29081dc
--- /dev/null
@@ -0,0 +1,92 @@
+#include <stdint.h>
+#include <signal.h>
+
+#if BITS == 64
+typedef uint64_t unum;
+typedef int64_t  snum;
+#else
+typedef uint32_t unum;
+typedef int32_t  snum;
+#endif
+
+#ifdef SIGNED
+typedef snum xnum;
+#else
+typedef unum xnum;
+#endif
+
+#ifdef __cris__
+static inline unum __attribute__((const)) dstep(unum rs, unum rd) {
+  asm("dstep %1,%0" : "+r" (rd) : "r" (rs));
+  return rd;
+}
+
+static inline unum __attribute__((const)) lz(unum rs) {
+  unum rd;
+  asm("lz %1,%0" : "=r" (rd) : "r" (rs));
+  return rd;
+}
+
+#else
+/* For testing */
+static inline unum __attribute__ ((const)) dstep(unum rs, unum rd) {
+  rd <<= 1;
+  if ( rd >= rs )
+    rd -= rs;
+
+  return rd;
+}
+
+static inline unum __attribute__((const)) lz(unum rs) {
+  unum rd = 0;
+  while ( rs >= 0x7fffffff ) {
+    rd++;
+    rs <<= 1;
+  }
+  return rd;
+}
+
+#endif
+
+xnum NAME (unum num, unum den)
+{
+  unum quot = 0, qbit = 1;
+  int minus = 0;
+  xnum v;
+  
+  if ( den == 0 ) {
+    raise(SIGFPE);
+    return 0;                  /* If signal ignored... */
+  }
+
+  if (den == 1) return (xnum)(REM ? 0 : num);
+
+#if SIGNED
+  if ( (snum)(num^den) < 0 )
+    minus = 1;
+  if ( (snum)num < 0 ) num = -num;
+  if ( (snum)den < 0 ) den = -den;
+#endif
+
+  den--;
+
+
+  /* Left-justify denominator and count shift */
+  while ( (snum)den >= 0 ) {
+    den <<= 1;
+    qbit <<= 1;
+  }
+
+  while ( qbit ) {
+    if ( den <= num ) {
+      num -= den;
+      quot += qbit;
+    }
+    den >>= 1;
+    qbit >>= 1;
+  }
+
+  v = (xnum)(REM ? num : quot);
+  if ( minus ) v = -v;
+  return v;
+}
diff --git a/klibc/klibc/arch/cris/include/klibc/archsignal.h b/klibc/klibc/arch/cris/include/klibc/archsignal.h
deleted file mode 100644 (file)
index 73b2e19..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * arch/cris/include/klibc/archsignal.h
- *
- * Architecture-specific signal definitions
- *
- */
-
-#ifndef _KLIBC_ARCHSIGNAL_H
-#define _KLIBC_ARCHSIGNAL_H
-
-/* No special stuff for this architecture */
-
-#endif
diff --git a/klibc/klibc/arch/cris/include/klibc/archsys.h b/klibc/klibc/arch/cris/include/klibc/archsys.h
deleted file mode 100644 (file)
index dfdc70a..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-/*
- * arch/cris/include/klibc/archsys.h
- *
- * Architecture-specific syscall definitions
- */
-
-#ifndef _KLIBC_ARCHSYS_H
-#define _KLIBC_ARCHSYS_H
-
-/* No special syscall definitions for this architecture */
-
-#endif /* _KLIBC_ARCHSYS_H */
diff --git a/klibc/klibc/arch/cris/setjmp.S b/klibc/klibc/arch/cris/setjmp.S
new file mode 100644 (file)
index 0000000..4316241
--- /dev/null
@@ -0,0 +1,37 @@
+#
+# arch/cris/setjmp.S
+#
+# setjmp/longjmp for the cris architecture
+#
+
+#
+# The jmp_buf is assumed to contain the following, in order:
+#      $r8..$r0        (in that order)
+#      $sp     ($r14)
+#      return address
+#
+
+       .text
+       .balign 4
+       .globl  setjmp
+       .type   setjmp, @function
+setjmp:
+       movem   $r8,[$r10+]             /* Save $r8..$r0 at $r10... */
+       move.d  $sp,[$r10+]
+       move    $srp,[$r10]
+       ret
+         moveq 0,$r10
+
+       .size setjmp,.-setjmp
+
+       .text
+       .balign 4
+       .globl  longjmp
+       .type   longjmp, @function
+longjmp:
+       movem   [$r10+],$r8             /* Load $r8..$r0 from $r10... */
+       move.d  [$r10+],$sp
+       jump    [$r10]
+       move.d $r11,$r10
+       
+       .size longjmp,.-longjmp
diff --git a/klibc/klibc/arch/cris/syscall.S b/klibc/klibc/arch/cris/syscall.S
new file mode 100644 (file)
index 0000000..d71495a
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * arch/cris/syscall.S
+ *
+ * On cris, r9 contains the syscall number (set by generated stub);
+ * r10..r13 contain arguments 0-3 per the standard calling convention,
+ * and arguments 4-5 are passed in $mof and $srp; however, we have
+ * to save $srp around the system call.
+ */
+
+       .section ".text","ax"
+       .balign 4
+       .globl  __syscall_common
+       .type   __syscall_common,@function
+__syscall_common:
+       push    $srp
+       move    [$sp+4],$mof
+       move    [$sp+8],$srp
+       break   13
+
+       cmps.w  -4096,$r10
+       blo     1f
+       neg.d   $r10,$r11
+       move.d  $r11,[errno]
+       moveq   -1,$r10
+1:
+       pop     $srp
+       ret
+       nop
+
+       .size   __syscall_common,.-__syscall_common
diff --git a/klibc/klibc/arch/cris/sysstub.ph b/klibc/klibc/arch/cris/sysstub.ph
new file mode 100644 (file)
index 0000000..6c894f6
--- /dev/null
@@ -0,0 +1,29 @@
+# -*- perl -*-
+#
+# arch/cris/sysstub.ph
+#
+# Script to generate system call stubs
+#
+
+sub make_sysstub($$$$@) {
+    my($fname, $type, $sname, $stype, @args) = @_;
+
+    open(OUT, '>', "syscalls/${fname}.S");
+    print OUT "#include <asm/unistd.h>\n";
+    print OUT "\n";
+    print OUT "\t.text\n";
+    print OUT "\t.type\t${fname},\@function\n";
+    print OUT "\t.globl\t${fname}\n";
+    print OUT "\t.balign\t4\n";
+    print OUT "${fname}:\n";
+    print OUT "#if __NR_${sname} <= 31\n";
+    print OUT "\t  moveq\t__NR_${sname}, \$r9\n";
+    print OUT "#else\n";
+    print OUT "\t  move.d\t__NR_${sname}, \$r9\n";
+    print OUT "#endif\n";
+    print OUT "\tjump\t__syscall_common\n";
+    print OUT "\t.size ${fname},.-${fname}\n";
+    close(OUT);
+}
+
+1;
index 516b1b6..2421452 100644 (file)
@@ -9,11 +9,11 @@
 
 # Enable this to compile with register parameters; only safe for
 # gcc > 3
-REGPARM_OPT := -mregparm=3 -DREGPARM
+REGPARM_OPT := -mregparm=3 -DREGPARM=3
 
-gcc_major := $(shell $(CC) -v 2>&1 | awk '/gcc version/{print int($$3)}')
+gcc_major := $(shell echo __GNUC__ | $(CC) -E -xc - | tail -n 1)
 
-OPTFLAGS = $(REGPARM) -march=i386 -Os
+OPTFLAGS = $(REGPARM) -march=i386 -Os -g
 
 ifeq ($(gcc_major),3)
 REGPARM  := $(REGPARM_OPT)
index 171248a..5c320cb 100644 (file)
@@ -11,6 +11,8 @@ ARCHOBJS = \
        arch/$(ARCH)/exits.o \
        arch/$(ARCH)/socketcall.o \
        arch/$(ARCH)/setjmp.o \
+       arch/$(ARCH)/syscall.o \
+       arch/$(ARCH)/open.o \
        arch/$(ARCH)/libgcc/__ashldi3.o \
        arch/$(ARCH)/libgcc/__ashrdi3.o \
        arch/$(ARCH)/libgcc/__lshrdi3.o \
@@ -22,6 +24,4 @@ ARCHOBJS = \
        libgcc/__umoddi3.o \
        libgcc/__udivmoddi4.o
 
-ARCHSOOBJS = $(patsubst %.o,%.lo,$(ARCHOBJS))
-
 archclean:
diff --git a/klibc/klibc/arch/i386/include/klibc/archsetjmp.h b/klibc/klibc/arch/i386/include/klibc/archsetjmp.h
deleted file mode 100644 (file)
index db04314..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * arch/i386/include/klibc/archsetjmp.h
- */
-
-#ifndef _KLIBC_ARCHSETJMP_H
-#define _KLIBC_ARCHSETJMP_H
-
-struct __jmp_buf {
-  unsigned int __ebx;
-  unsigned int __esp;
-  unsigned int __ebp;
-  unsigned int __esi;
-  unsigned int __edi;
-  unsigned int __eip;
-};
-
-typedef struct __jmp_buf jmp_buf[1];
-
-#endif /* _SETJMP_H */
diff --git a/klibc/klibc/arch/i386/include/klibc/archsignal.h b/klibc/klibc/arch/i386/include/klibc/archsignal.h
deleted file mode 100644 (file)
index b092ba6..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * arch/i386/include/klibc/archsignal.h
- *
- * Architecture-specific signal definitions
- *
- */
-
-#ifndef _KLIBC_ARCHSIGNAL_H
-#define _KLIBC_ARCHSIGNAL_H
-
-/* No special stuff for this architecture */
-
-#endif
diff --git a/klibc/klibc/arch/i386/include/klibc/archsys.h b/klibc/klibc/arch/i386/include/klibc/archsys.h
deleted file mode 100644 (file)
index e21487b..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * arch/i386/include/klibc/archsys.h
- *
- * Architecture-specific syscall definitions
- */
-
-#ifndef _KLIBC_ARCHSYS_H
-#define _KLIBC_ARCHSYS_H
-
-/*
- * If we're compiling i386 in PIC mode, we need to treat %ebx
- * specially.  Most of these are copied from the equivalent file in
- * newlib and were written by Werner Almesberger.
- */
-#if defined(__PIC__)
-
-/* _syscall0() is the same as non-PIC */
-
-#undef _syscall1
-#define _syscall1(type,name,type1,arg1) \
-type name(type1 arg1) \
-{ \
-long __res; \
-__asm__ __volatile__ ("push %%ebx; movl %2,%%ebx; int $0x80; pop %%ebx" \
-       : "=a" (__res) \
-       : "0" (__NR_##name),"r" ((long)(arg1))); \
-__syscall_return(type,__res); \
-}
-
-#undef _syscall2
-#define _syscall2(type,name,type1,arg1,type2,arg2) \
-type name(type1 arg1,type2 arg2) \
-{ \
-long __res; \
-__asm__ __volatile__ ("push %%ebx; movl %2,%%ebx; int $0x80; pop %%ebx" \
-       : "=a" (__res) \
-       : "0" (__NR_##name),"r" ((long)(arg1)),"c" ((long)(arg2))); \
-__syscall_return(type,__res); \
-}
-
-#undef _syscall3
-#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
-type name(type1 arg1,type2 arg2,type3 arg3) \
-{ \
-long __res; \
-__asm__ __volatile__ ("push %%ebx; movl %2,%%ebx; int $0x80; pop %%ebx" \
-       : "=a" (__res) \
-       : "0" (__NR_##name),"r" ((long)(arg1)),"c" ((long)(arg2)), \
-               "d" ((long)(arg3))); \
-__syscall_return(type,__res); \
-}
-
-#undef _syscall4
-#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
-type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
-{ \
-long __res; \
-__asm__ __volatile__ ("push %%ebx; movl %2,%%ebx; int $0x80; pop %%ebx" \
-       : "=a" (__res) \
-       : "0" (__NR_##name),"r" ((long)(arg1)),"c" ((long)(arg2)), \
-         "d" ((long)(arg3)),"S" ((long)(arg4))); \
-__syscall_return(type,__res); \
-}
-
-#undef _syscall5
-#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
-          type5,arg5) \
-type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
-{ \
-long __res; \
-__asm__ __volatile__ ("push %%ebx; movl %2,%%ebx; int $0x80; pop %%ebx" \
-       : "=a" (__res) \
-       : "0" (__NR_##name),"m" ((long)(arg1)),"c" ((long)(arg2)), \
-         "d" ((long)(arg3)),"S" ((long)(arg4)),"D" ((long)(arg5))); \
-__syscall_return(type,__res); \
-}
-
-#undef _syscall6
-#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
-          type5,arg5,type6,arg6) \
-type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5,type6 arg6) \
-{ \
-long __res; \
-__asm__ __volatile__ ("push %%ebx; pushl %%ebp; movl %2,%%ebx; " \
-                      "movl %%eax,%%ebp; movl %1,%%eax; int $0x80; " \
-                      "pop %%ebp ; pop %%ebx" \
-       : "=a" (__res) \
-       : "i" (__NR_##name),"m" ((long)(arg1)),"c" ((long)(arg2)), \
-         "d" ((long)(arg3)),"S" ((long)(arg4)),"D" ((long)(arg5)), \
-         "a" ((long)(arg6))); \
-__syscall_return(type,__res); \
-}
-
-#endif /* __PIC__ */
-
-#endif /* _KLIBC_ARCHSYS_H */
diff --git a/klibc/klibc/arch/i386/include/klibc/diverr.h b/klibc/klibc/arch/i386/include/klibc/diverr.h
deleted file mode 100644 (file)
index 410aba0..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * arch/i386/include/klibc/diverr.h
- */
-
-#ifndef _KLIBC_DIVERR_H
-#define _KLIBC_DIVERR_H
-
-#include <signal.h>
-
-static __inline__ void
-__divide_error(void)
-{
-  asm volatile("divl %0" :: "rm" (0) : "eax", "edx");
-}
-
-#endif /* _KLIBC_DIVERR_H */
diff --git a/klibc/klibc/arch/i386/include/sys/io.h b/klibc/klibc/arch/i386/include/sys/io.h
deleted file mode 100644 (file)
index b051464..0000000
+++ /dev/null
@@ -1,126 +0,0 @@
-#ident "$Id: io.h,v 1.2 2004/01/25 07:49:39 hpa Exp $"
-/* ----------------------------------------------------------------------- *
- *   
- *   Copyright 2004 H. Peter Anvin - All Rights Reserved
- *
- *   Permission is hereby granted, free of charge, to any person
- *   obtaining a copy of this software and associated documentation
- *   files (the "Software"), to deal in the Software without
- *   restriction, including without limitation the rights to use,
- *   copy, modify, merge, publish, distribute, sublicense, and/or
- *   sell copies of the Software, and to permit persons to whom
- *   the Software is furnished to do so, subject to the following
- *   conditions:
- *   
- *   The above copyright notice and this permission notice shall
- *   be included in all copies or substantial portions of the Software.
- *   
- *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
- *   OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- *   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
- *   HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- *   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- *   FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- *   OTHER DEALINGS IN THE SOFTWARE.
- *
- * ----------------------------------------------------------------------- */
-
-/*
- * sys/io.h for the i386 architecture
- *
- * Basic I/O macros
- */
-
-#ifndef _SYS_IO_H
-#define _SYS_IO_H 1
-
-/* I/O-related system calls */
-
-int iopl(int);
-int ioperm(unsigned long, unsigned long, int);
-
-/* Basic I/O macros */
-
-static __inline__ void
-outb(unsigned char __v, unsigned short __p)
-{
-  asm volatile("outb %0,%1" : : "a" (__v), "dN" (__p));
-}
-
-static __inline__ void
-outw(unsigned short __v, unsigned short __p)
-{
-  asm volatile("outw %0,%1" : : "a" (__v), "dN" (__p));
-}
-
-static __inline__ void
-outl(unsigned int __v, unsigned short __p)
-{
-  asm volatile("outl %0,%1" : : "a" (__v), "dN" (__p));
-}
-
-static __inline__ unsigned char
-inb(unsigned short __p)
-{
-  unsigned char __v;
-  asm volatile("inb %1,%0" : "=a" (__v) : "dN" (__p));
-  return __v;
-}
-
-static __inline__ unsigned short
-inw(unsigned short __p)
-{
-  unsigned short __v;
-  asm volatile("inw %1,%0" : "=a" (__v) : "dN" (__p));
-  return __v;
-}
-
-static __inline__ unsigned int
-inl(unsigned short __p)
-{
-  unsigned int __v;
-  asm volatile("inl %1,%0" : "=a" (__v) : "dN" (__p));
-  return __v;
-}
-
-/* String I/O macros */
-
-static __inline__ void
-outsb (unsigned short __p, const void *__d, unsigned long __n)
-{
-  asm volatile("cld; rep; outsb" : "+S" (__d), "+c" (__n) : "d" (__p));
-}
-
-static __inline__ void
-outsw (unsigned short __p, const void *__d, unsigned long __n)
-{
-  asm volatile("cld; rep; outsw" : "+S" (__d), "+c" (__n) : "d" (__p));
-}
-
-static __inline__ void
-outsl (unsigned short __p, const void *__d, unsigned long __n)
-{
-  asm volatile("cld; rep; outsl" : "+S" (__d), "+c" (__n) : "d" (__p));
-}
-
-
-static __inline__ void
-insb (unsigned short __p, void *__d, unsigned long __n)
-{
-  asm volatile("cld; rep; insb" : "+D" (__d), "+c" (__n) : "d" (__p));
-}
-
-static __inline__ void
-insw (unsigned short __p, void *__d, unsigned long __n)
-{
-  asm volatile("cld; rep; insw" : "+D" (__d), "+c" (__n) : "d" (__p));
-}
-
-static __inline__ void
-insl (unsigned short __p, void *__d, unsigned long __n)
-{
-  asm volatile("cld; rep; insl" : "+D" (__d), "+c" (__n) : "d" (__p));
-}
-
-#endif /* _SYS_IO_H */
diff --git a/klibc/klibc/arch/i386/include/sys/vm86.h b/klibc/klibc/arch/i386/include/sys/vm86.h
deleted file mode 100644 (file)
index d327239..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-#ident "$Id: vm86.h,v 1.1 2004/01/25 01:34:28 hpa Exp $"
-/* ----------------------------------------------------------------------- *
- *   
- *   Copyright 2004 H. Peter Anvin - All Rights Reserved
- *
- *   Permission is hereby granted, free of charge, to any person
- *   obtaining a copy of this software and associated documentation
- *   files (the "Software"), to deal in the Software without
- *   restriction, including without limitation the rights to use,
- *   copy, modify, merge, publish, distribute, sublicense, and/or
- *   sell copies of the Software, and to permit persons to whom
- *   the Software is furnished to do so, subject to the following
- *   conditions:
- *   
- *   The above copyright notice and this permission notice shall
- *   be included in all copies or substantial portions of the Software.
- *   
- *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
- *   OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- *   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
- *   HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- *   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- *   FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- *   OTHER DEALINGS IN THE SOFTWARE.
- *
- * ----------------------------------------------------------------------- */
-
-/*
- * sys/vm86.h for i386
- */
-
-#ifndef _SYS_VM86_H
-#define _SYS_VM86_H 1
-
-#include <asm/vm86.h>
-
-/* Actual system call */
-int vm86(struct vm86_struct *);
-
-#endif
diff --git a/klibc/klibc/arch/i386/open.S b/klibc/klibc/arch/i386/open.S
new file mode 100644 (file)
index 0000000..4f492a1
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * arch/i386/open.S
+ *
+ * Handle the open() system call - oddball due to the varadic
+ * prototype, which forces the use of the cdecl calling convention,
+ * and the need for O_LARGEFILE.
+ */
+
+#include <asm/unistd.h>
+
+/* <asm/fcntl.h>, despite the name, isn't assembly-safe */
+#define O_LARGEFILE     0100000
+       
+       .globl  open
+       .type   open,@function
+
+open:
+#ifdef REGPARM
+       movl    4(%esp),%eax
+       movl    8(%esp),%edx
+       movl    12(%esp),%ecx
+       orl     $O_LARGEFILE,%edx
+#else
+       orl     $O_LARGEFILE,8(%esp)
+#endif
+       pushl   $__NR_open
+       jmp     __syscall_common
+
+       .size   open,.-open
index 6bac1e6..b13d204 100644 (file)
        .type __socketcall_common, @function
 
 __socketcall_common:
-       pushl %ebx
-       movzbl %al,%ebx         # The socketcall number is passed in in %al
-       leal 8(%esp),%ecx       # Argument pointer
-       movl $__NR_socketcall, %eax
-       int $0x80
-       cmpl $-125,%eax         # Error return?
-       popl %ebx
-       jb 1f
-       neg %eax
-       movl %eax,errno
-       xorl %eax,%eax
-       decl %eax               # Return = -1
+       pushl   %ebx
+
+       movzbl  %al,%ebx        # The socketcall number is passed in in %al
+       leal    8(%esp),%ecx    # Argument pointer
+       movl    $__NR_socketcall,%eax
+       int     $0x80
+       
+       cmpl    $-4096,%eax     # Error return?
+       
+       popl    %ebx
+       
+       jb      1f
+       
+       negl    %eax
+       movl    %eax,errno
+       orl     $-1,%eax        # Return -1
 1:
        ret
 
diff --git a/klibc/klibc/arch/i386/syscall.S b/klibc/klibc/arch/i386/syscall.S
new file mode 100644 (file)
index 0000000..f8fa7b4
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * arch/i386/syscall.S
+ *
+ * Common tail-handling code for system calls.  Because of __syscalldecl
+ * we are using the stack even on if we are compiling with regparm.
+ *
+ * The arguments are on the stack; the system call number in %eax.
+ */
+
+#define ARG(n) (4*n+20)(%esp)
+       
+       .text
+       .align  4
+       .globl  __syscall_common
+       .type   __syscall_common,@function
+__syscall_common:
+#ifdef REGPARM
+       xchgl   %ebx,(%esp)
+#else
+       popl    %eax
+       pushl   %ebx
+#endif
+       pushl   %esi
+       pushl   %edi
+       pushl   %ebp
+
+#ifdef REGPARM
+       xchgl   %eax,%ebx
+       xchgl   %ecx,%edx
+       movl    ARG(0),%esi
+       movl    ARG(1),%edi
+       movl    ARG(2),%ebp
+#else
+       movl    ARG(0),%ebx             # Syscall arguments
+       movl    ARG(1),%ecx
+       movl    ARG(2),%edx
+       movl    ARG(3),%esi
+       movl    ARG(4),%edi
+       movl    ARG(5),%ebp
+#endif
+       int     $0x80
+
+       cmpl    $-4096,%eax
+
+       popl    %ebp
+       popl    %edi
+       popl    %esi
+       popl    %ebx
+
+       jb      1f
+
+       # Error return, must set errno
+       negl    %eax
+       movl    %eax,errno
+       orl     $-1,%eax                # Return -1
+
+1:
+       ret
+
+       .size   __syscall_common,.-__syscall_common
diff --git a/klibc/klibc/arch/i386/sysstub.ph b/klibc/klibc/arch/i386/sysstub.ph
new file mode 100644 (file)
index 0000000..eaa8180
--- /dev/null
@@ -0,0 +1,32 @@
+# -*- perl -*-
+#
+# arch/i386/sysstub.ph
+#
+# Script to generate system call stubs
+#
+
+sub make_sysstub($$$$@) {
+    my($fname, $type, $sname, $stype, @args) = @_;
+
+    open(OUT, '>', "syscalls/${fname}.S");
+    print OUT "#include <asm/unistd.h>\n";
+    print OUT "\n";
+    print OUT "\t.type ${fname},\@function\n";
+    print OUT "\t.globl ${fname}\n";
+    print OUT "${fname}:\n";
+
+    if ( $stype eq 'varadic' ) {
+       print OUT "#ifdef REGPARM\n";
+       print OUT "\tmovl  4(%esp),%eax\n";
+       print OUT "\tmovl  8(%esp),%edx\n";
+       print OUT "\tmovl 12(%esp),%ecx\n";
+       print OUT "#endif\n";
+    }
+
+    print OUT "\tpushl \$__NR_${sname}\n";
+    print OUT "\tjmp __syscall_common\n";
+    print OUT "\t.size ${fname},.-${fname}\n";
+    close(OUT);
+}
+
+1;
index 7814487..6363c1f 100644 (file)
@@ -11,6 +11,7 @@ ARCHOBJS = \
        arch/$(ARCH)/vfork.o \
        arch/$(ARCH)/setjmp.o \
        arch/$(ARCH)/pipe.o \
+       arch/$(ARCH)/syscall.o \
        libgcc/__divdi3.o \
        libgcc/__divsi3.o \
        libgcc/__udivdi3.o \
diff --git a/klibc/klibc/arch/ia64/include/klibc/archsetjmp.h b/klibc/klibc/arch/ia64/include/klibc/archsetjmp.h
deleted file mode 100644 (file)
index bd639c0..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * arch/ia64/include/klibc/archsetjmp.h
- *
- * Code borrowed from the FreeBSD kernel.
- *
- */
-
-#ifndef _KLIBC_ARCHSETJMP_H
-#define _KLIBC_ARCHSETJMP_H
-
-/* User code must not depend on the internal representation of jmp_buf. */
-#define _JBLEN 0x200
-
-/* guaranteed 128-bit alignment! */
-typedef char jmp_buf[_JBLEN] __attribute__ ((aligned (16)));
-
-#endif
diff --git a/klibc/klibc/arch/ia64/include/klibc/archsignal.h b/klibc/klibc/arch/ia64/include/klibc/archsignal.h
deleted file mode 100644 (file)
index 5b01f19..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * arch/ia64/include/klibc/archsignal.h
- * 
- * Architecture-specific signal definitions.
- *
- */
-
-#ifndef _KLIBC_ARCHSIGNAL_H
-#define _KLIBC_ARCHSIGNAL_H
-
-#define _NSIG        64
-#define _NSIG_BPW    64
-#define _NSIG_WORDS (_NSIG / _NSIG_BPW)
-
-typedef struct {
-       unsigned long sig[_NSIG_WORDS];
-} sigset_t;
-
-struct sigaction {
-        union {
-               __sighandler_t        _sa_handler;
-               void (*_sa_sigaction)(int, struct siginfo *, void *);
-        } _u;
-        sigset_t        sa_mask;
-        int             sa_flags;
-};
-
-#define sa_handler      _u._sa_handler
-#define sa_sigaction    _u._sa_sigaction
-
-#endif
diff --git a/klibc/klibc/arch/ia64/include/klibc/archsys.h b/klibc/klibc/arch/ia64/include/klibc/archsys.h
deleted file mode 100644 (file)
index fe331ac..0000000
+++ /dev/null
@@ -1,218 +0,0 @@
-/*
- * arch/ia64/include/klibc/archsys.h
- *
- * Architecture-specific syscall definitions
- */
-
-#ifndef _KLIBC_ARCHSYS_H
-#define _KLIBC_ARCHSYS_H
-
-#define __IA64_BREAK "break 0x100000;;\n\t"
-
-#define _syscall0(type,name)                                            \
-type                                                                    \
-name (void)                                                             \
-{                                                                       \
-       register long _r8 asm ("r8");                                   \
-       register long _r10 asm ("r10");                                  \
-       register long _r15 asm ("r15") = __NR_##name;                    \
-       long _retval;                                                    \
-       __asm __volatile (__IA64_BREAK                                   \
-                         : "=r" (_r8), "=r" (_r10), "=r" (_r15)         \
-                         : "2" (_r15) ASM_ARGS_0                        \
-                         : "memory" ASM_CLOBBERS_0);                    \
-       _retval = _r8;                                                   \
-       if (_r10 == -1) {                                                \
-               errno = (_retval);                                       \
-               _retval = -1;                                            \
-       }                                                                \
-       return _retval;                                                  \
-}
-
-#define _syscall1(type,name,type1,arg1)                                 \
-type                                                                    \
-name (type1 arg1)                                                       \
-{                                                                       \
-       register long _r8 asm ("r8");                                   \
-       register long _r10 asm ("r10");                                  \
-       register long _r15 asm ("r15") = __NR_##name;                    \
-       long _retval;                                                    \
-       LOAD_ARGS_1(arg1);                                               \
-       __asm __volatile (__IA64_BREAK                                   \
-                         : "=r" (_r8), "=r" (_r10), "=r" (_r15),        \
-                           ASM_OUTARGS_1                                \
-                         : "2" (_r15) ASM_ARGS_1                        \
-                         : "memory" ASM_CLOBBERS_1);                    \
-       _retval = _r8;                                                   \
-       if (_r10 == -1) {                                                \
-               errno = (_retval);                                       \
-               _retval = -1;                                            \
-       }                                                                \
-       return _retval;                                                  \
-}
-
-#define _syscall2(type,name,type1,arg1,type2,arg2)                      \
-type                                                                    \
-name (type1 arg1, type2 arg2)                                           \
-{                                                                       \
-       register long _r8 asm ("r8");                                   \
-       register long _r10 asm ("r10");                                  \
-       register long _r15 asm ("r15") = __NR_##name;                    \
-       long _retval;                                                    \
-       LOAD_ARGS_2(arg1, arg2);                                         \
-       __asm __volatile (__IA64_BREAK                                   \
-                         : "=r" (_r8), "=r" (_r10), "=r" (_r15),        \
-                           ASM_OUTARGS_2                                \
-                         : "2" (_r15) ASM_ARGS_2                        \
-                         : "memory" ASM_CLOBBERS_2);                    \
-       _retval = _r8;                                                   \
-       if (_r10 == -1) {                                                \
-               errno = (_retval);                                       \
-               _retval = -1;                                            \
-       }                                                                \
-       return _retval;                                                  \
-}
-
-#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3)           \
-type                                                                    \
-name (type1 arg1, type2 arg2, type3 arg3)                               \
-{                                                                       \
-       register long _r8 asm ("r8");                                   \
-       register long _r10 asm ("r10");                                  \
-       register long _r15 asm ("r15") = __NR_##name;                    \
-       long _retval;                                                    \
-       LOAD_ARGS_3(arg1, arg2, arg3);                                   \
-       __asm __volatile (__IA64_BREAK                                   \
-                         : "=r" (_r8), "=r" (_r10), "=r" (_r15),        \
-                           ASM_OUTARGS_3                                \
-                         : "2" (_r15) ASM_ARGS_3                        \
-                         : "memory" ASM_CLOBBERS_3);                    \
-       _retval = _r8;                                                   \
-       if (_r10 == -1) {                                                \
-               errno = (_retval);                                       \
-               _retval = -1;                                            \
-       }                                                                \
-       return _retval;                                                  \
-}
-
-#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
-type                                                                    \
-name (type1 arg1, type2 arg2, type3 arg3, type4 arg4)                   \
-{                                                                       \
-       register long _r8 asm ("r8");                                   \
-       register long _r10 asm ("r10");                                  \
-       register long _r15 asm ("r15") = __NR_##name;                    \
-       long _retval;                                                    \
-       LOAD_ARGS_4(arg1, arg2, arg3, arg4);                             \
-       __asm __volatile (__IA64_BREAK                                   \
-                         : "=r" (_r8), "=r" (_r10), "=r" (_r15),        \
-                           ASM_OUTARGS_4                                \
-                         : "2" (_r15) ASM_ARGS_4                        \
-                         : "memory" ASM_CLOBBERS_4);                    \
-       _retval = _r8;                                                   \
-       if (_r10 == -1) {                                                \
-               errno = (_retval);                                       \
-               _retval = -1;                                            \
-       }                                                                \
-       return _retval;                                                  \
-}
-
-#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \
-type                                                                    \
-name (type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5)       \
-{                                                                       \
-       register long _r8 asm ("r8");                                   \
-       register long _r10 asm ("r10");                                  \
-       register long _r15 asm ("r15") = __NR_##name;                    \
-       long _retval;                                                    \
-       LOAD_ARGS_5(arg1, arg2, arg3, arg4, arg5);                       \
-       __asm __volatile (__IA64_BREAK                                   \
-                         : "=r" (_r8), "=r" (_r10), "=r" (_r15),        \
-                           ASM_OUTARGS_5                                \
-                         : "2" (_r15) ASM_ARGS_5                        \
-                         : "memory" ASM_CLOBBERS_5);                    \
-       _retval = _r8;                                                   \
-       if (_r10 == -1) {                                                \
-               errno = (_retval);                                       \
-               _retval = -1;                                            \
-       }                                                                \
-       return _retval;                                                  \
-}
-
-#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5,type6,arg6) \
-type                                                                    \
-name (type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6)       \
-{                                                                       \
-       register long _r8 asm ("r8");                                   \
-       register long _r10 asm ("r10");                                  \
-       register long _r15 asm ("r15") = __NR_##name;                    \
-       long _retval;                                                    \
-       LOAD_ARGS_6(arg1, arg2, arg3, arg4, arg5, arg6);                 \
-       __asm __volatile (__IA64_BREAK                                   \
-                         : "=r" (_r8), "=r" (_r10), "=r" (_r15),        \
-                           ASM_OUTARGS_6                                \
-                         : "2" (_r15) ASM_ARGS_6                        \
-                         : "memory" ASM_CLOBBERS_6);                    \
-       _retval = _r8;                                                   \
-       if (_r10 == -1) {                                                \
-               errno = (_retval);                                       \
-               _retval = -1;                                            \
-       }                                                                \
-       return _retval;                                                  \
-}
-  
-
-#define LOAD_ARGS_0()   do { } while (0)
-#define LOAD_ARGS_1(out0)                              \
-  register long _out0 asm ("out0") = (long) (out0);    \
-  LOAD_ARGS_0 ()
-#define LOAD_ARGS_2(out0, out1)                                \
-  register long _out1 asm ("out1") = (long) (out1);    \
-  LOAD_ARGS_1 (out0)
-#define LOAD_ARGS_3(out0, out1, out2)                  \
-  register long _out2 asm ("out2") = (long) (out2);    \
-  LOAD_ARGS_2 (out0, out1)
-#define LOAD_ARGS_4(out0, out1, out2, out3)            \
-  register long _out3 asm ("out3") = (long) (out3);    \
-  LOAD_ARGS_3 (out0, out1, out2)
-#define LOAD_ARGS_5(out0, out1, out2, out3, out4)      \
-  register long _out4 asm ("out4") = (long) (out4);    \
-  LOAD_ARGS_4 (out0, out1, out2, out3)
-#define LOAD_ARGS_6(out0, out1, out2, out3, out4, out5)        \
-  register long _out5 asm ("out5") = (long) (out5);    \
-  LOAD_ARGS_5 (out0, out1, out2, out3, out4)
-
-#define ASM_OUTARGS_1  "=r" (_out0)
-#define ASM_OUTARGS_2  ASM_OUTARGS_1, "=r" (_out1)
-#define ASM_OUTARGS_3  ASM_OUTARGS_2, "=r" (_out2)
-#define ASM_OUTARGS_4  ASM_OUTARGS_3, "=r" (_out3)
-#define ASM_OUTARGS_5  ASM_OUTARGS_4, "=r" (_out4)
-#define ASM_OUTARGS_6  ASM_OUTARGS_5, "=r" (_out5)
-
-#define ASM_ARGS_0
-#define ASM_ARGS_1     ASM_ARGS_0, "3" (_out0)
-#define ASM_ARGS_2     ASM_ARGS_1, "4" (_out1)
-#define ASM_ARGS_3     ASM_ARGS_2, "5" (_out2)
-#define ASM_ARGS_4     ASM_ARGS_3, "6" (_out3)
-#define ASM_ARGS_5     ASM_ARGS_4, "7" (_out4)
-#define ASM_ARGS_6     ASM_ARGS_5, "8" (_out5)
-
-#define ASM_CLOBBERS_0 ASM_CLOBBERS_1, "out0"
-#define ASM_CLOBBERS_1 ASM_CLOBBERS_2, "out1"
-#define ASM_CLOBBERS_2 ASM_CLOBBERS_3, "out2"
-#define ASM_CLOBBERS_3 ASM_CLOBBERS_4, "out3"
-#define ASM_CLOBBERS_4 ASM_CLOBBERS_5, "out4"
-#define ASM_CLOBBERS_5 ASM_CLOBBERS_6, "out5"
-#define ASM_CLOBBERS_6 , "out6", "out7",                               \
-  /* Non-stacked integer registers, minus r8, r10, r15.  */            \
-  "r2", "r3", "r9", "r11", "r12", "r13", "r14", "r16", "r17", "r18",   \
-  "r19", "r20", "r21", "r22", "r23", "r24", "r25", "r26", "r27",       \
-  "r28", "r29", "r30", "r31",                                          \
-  /* Predicate registers.  */                                          \
-  "p6", "p7", "p8", "p9", "p10", "p11", "p12", "p13", "p14", "p15",    \
-  /* Non-rotating fp registers.  */                                    \
-  "f6", "f7", "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15",    \
-  /* Branch registers.  */                                             \
-  "b6", "b7"
-
-#endif /* _KLIBC_ARCHSYS_H */
index 5f5dd05..0b641e8 100644 (file)
@@ -27,7 +27,7 @@ int pipe(int *filedes)
        long _retval;
        __asm __volatile (__IA64_BREAK
                          : "=r" (_r8), "=r" (_r10), "=r" (_r15),
-                           "=r" (_out0)
+                         "=r" (_out0), "=r" (_r9)
                          : "2" (_r15), "3" (_out0)
                          : "memory" ASM_CLOBBERS);
        if (_r10 == -1) {
diff --git a/klibc/klibc/arch/ia64/syscall.S b/klibc/klibc/arch/ia64/syscall.S
new file mode 100644 (file)
index 0000000..e3f264c
--- /dev/null
@@ -0,0 +1,20 @@
+#
+# arch/ia64/syscall.S
+#
+
+#include <asm/unistd.h>
+       
+       .text
+       .align  32
+       .proc   __syscall_error
+       .globl  __syscall_error
+__syscall_error:
+       addl    r2 = @ltoffx(errno),gp
+       ;;
+       ld8.mov r3 = [r2],errno
+       ;;
+       st4     [r3] = r8
+       mov     r8 = -1
+       br.ret.sptk.many b0
+       .size   __syscall_error, .-__syscall_error
+       .endp   __syscall_error
diff --git a/klibc/klibc/arch/ia64/sysstub.ph b/klibc/klibc/arch/ia64/sysstub.ph
new file mode 100644 (file)
index 0000000..34031a2
--- /dev/null
@@ -0,0 +1,29 @@
+# -*- perl -*-
+#
+# arch/ia64/sysstub.ph
+#
+# Script to generate system call stubs
+#
+
+sub make_sysstub($$$$@) {
+    my($fname, $type, $sname, $stype, @args) = @_;
+
+    open(OUT, '>', "syscalls/${fname}.S");
+    print OUT "#include <asm/unistd.h>\n";
+    print OUT "\n";
+    print OUT "\t.text\n";
+    print OUT "\t.align 32\n";
+    print OUT "\t.proc ${fname}\n";
+    print OUT "\t.globl ${fname}\n";
+    print OUT "${fname}:\n";
+    print OUT "\tmov\tr15 = __NR_${sname}\n";
+    print OUT "\tbreak __BREAK_SYSCALL\n";
+    print OUT "\tcmp.eq p6,p0 = -1,r10\n";
+    print OUT "(p6)\tbr.few __syscall_error\n";
+    print OUT "\tbr.ret.sptk.many b0\n";
+    print OUT "\t.size\t${fname},.-${fname}\n";
+    print OUT "\t.endp\t${fname}\n";
+    close(OUT);
+}
+
+1;
index 0354fa9..efcd03f 100644 (file)
@@ -27,8 +27,8 @@ vfork:
        mov     out0=CLONE_VM|CLONE_VFORK|SIGCHLD
        mov     out1=0
        ;;
-       __IA64_BREAK      // Do the syscall
-       
+       break 0x100000      // Do the syscall
+       ;; 
        addl    r15=0,r1
        cmp.eq  p7,p6 = -1,r10
        ;;
diff --git a/klibc/klibc/arch/m68k/include/klibc/archsignal.h b/klibc/klibc/arch/m68k/include/klibc/archsignal.h
deleted file mode 100644 (file)
index 714527f..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * arch/m68k/include/klibc/archsignal.h
- *
- * Architecture-specific signal definitions
- *
- */
-
-#ifndef _KLIBC_ARCHSIGNAL_H
-#define _KLIBC_ARCHSIGNAL_H
-
-/* No special stuff for this architecture */
-
-#endif
diff --git a/klibc/klibc/arch/m68k/include/klibc/archsys.h b/klibc/klibc/arch/m68k/include/klibc/archsys.h
deleted file mode 100644 (file)
index 8f6bed8..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-/*
- * arch/m68k/include/klibc/archsys.h
- *
- * Architecture-specific syscall definitions
- */
-
-#ifndef _KLIBC_ARCHSYS_H
-#define _KLIBC_ARCHSYS_H
-
-/* No special syscall definitions for this architecture */
-
-#endif /* _KLIBC_ARCHSYS_H */
index 52b5184..a248973 100644 (file)
@@ -7,12 +7,9 @@
 # accordingly.
 #
 
-ARCHREQFLAGS = -fno-pic -mno-abicalls
+ARCHREQFLAGS = -fno-pic -mno-abicalls -G 0
 OPTFLAGS     = -Os -fomit-frame-pointer
 BITSIZE      = 32
 
 # Extra linkflags when building the shared version of the library
-# This address needs to be reachable using normal inter-module
-# calls, and work on the memory models for this architecture
-# 2 MB -- the normal starting point for text is 4 MB.
-SHAREDFLAGS    = -Ttext 0x00200200
+SHAREDFLAGS    = -T arch/$(ARCH)/klibc.ld
index 09a2d2f..e257023 100644 (file)
@@ -11,6 +11,7 @@ ARCHOBJS = \
        arch/$(ARCH)/pipe.o \
        arch/$(ARCH)/vfork.o \
        arch/$(ARCH)/setjmp.o \
+       arch/$(ARCH)/syscall.o \
        libgcc/__divdi3.o \
         libgcc/__moddi3.o \
         libgcc/__udivdi3.o \
diff --git a/klibc/klibc/arch/mips/include/klibc/archsetjmp.h b/klibc/klibc/arch/mips/include/klibc/archsetjmp.h
deleted file mode 100644 (file)
index 40e5be2..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * arch/mips/include/klibc/archsetjmp.h
- */
-
-#ifndef _KLIBC_ARCHSETJMP_H
-#define _KLIBC_ARCHSETJMP_H
-
-struct __jmp_buf {
-  unsigned long __s0;
-  unsigned long __s1;
-  unsigned long __s2;
-  unsigned long __s3;
-  unsigned long __s4;
-  unsigned long __s5;
-  unsigned long __s6;
-  unsigned long __s7;
-  unsigned long __gp;
-  unsigned long __sp;
-  unsigned long __s8;
-  unsigned long __ra;
-  unsigned long __f20;
-  unsigned long __f21;
-  unsigned long __f22;
-  unsigned long __f23;
-  unsigned long __f24;
-  unsigned long __f25;
-  unsigned long __f26;
-  unsigned long __f27;
-  unsigned long __f28;
-  unsigned long __f29;
-  unsigned long __f30;
-  unsigned long __f31;
-  unsigned long __fcr31;
-  unsigned long __unused;
-} __attribute__((aligned(8)));
-
-typedef struct __jmp_buf jmp_buf[1];
-
-#endif /* _KLIBC_ARCHSETJMP_H */
diff --git a/klibc/klibc/arch/mips/include/klibc/archsignal.h b/klibc/klibc/arch/mips/include/klibc/archsignal.h
deleted file mode 100644 (file)
index 3b72908..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * arch/mips/include/klibc/archsignal.h
- *
- * Architecture-specific signal definitions
- *
- */
-
-#ifndef _KLIBC_ARCHSIGNAL_H
-#define _KLIBC_ARCHSIGNAL_H
-
-/* No special stuff for this architecture */
-
-#endif
diff --git a/klibc/klibc/arch/mips/include/klibc/archsys.h b/klibc/klibc/arch/mips/include/klibc/archsys.h
deleted file mode 100644 (file)
index f696cdf..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-/*
- * arch/mips/include/klibc/archsys.h
- *
- * Architecture-specific syscall definitions
- */
-
-#ifndef _KLIBC_ARCHSYS_H
-#define _KLIBC_ARCHSYS_H
-
-/* No special syscall definitions for this architecture */
-
-#endif /* _KLIBC_ARCHSYS_H */
diff --git a/klibc/klibc/arch/mips/include/machine/asm.h b/klibc/klibc/arch/mips/include/machine/asm.h
deleted file mode 100644 (file)
index e5239a6..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
- * arch/mips/include/machine/asm.h
- */
-
-#ifndef _MACHINE_ASM_H
-#define _MACHINE_ASM_H
-
-#include <asm/regdef.h>
-#include <asm/asm.h>
-
-#endif /* _MACHINE_ASM_H */
diff --git a/klibc/klibc/arch/mips/include/sgidefs.h b/klibc/klibc/arch/mips/include/sgidefs.h
deleted file mode 100644 (file)
index eb103ac..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * arch/mips/include/sgidefs.h
- */
-
-/* Some ABI constants */
-
-#ifndef _SGIDEFS_H
-#define _SGIDEFS_H
-
-#define _MIPS_ISA_MIPS1 1
-#define _MIPS_ISA_MIPS2 2
-#define _MIPS_ISA_MIPS3 3
-#define _MIPS_ISA_MIPS4 4
-#define _MIPS_ISA_MIPS5 5
-
-#define _MIPS_SIM_ABI32         1
-#define _MIPS_SIM_NABI32        2
-#define _MIPS_SIM_ABI64         3
-
-#endif /* _SGIDEFS_H */
diff --git a/klibc/klibc/arch/mips/klibc.ld b/klibc/klibc/arch/mips/klibc.ld
new file mode 100644 (file)
index 0000000..d75c9de
--- /dev/null
@@ -0,0 +1,217 @@
+/* Linker script for klibc.so, needed because of the the damned
+   GNU ld script headers problem */
+
+OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips",
+             "elf32-tradlittlemips")
+OUTPUT_ARCH(mips)
+ENTRY(__start)
+SECTIONS
+{
+  /* Read-only sections, merged into text segment: */
+  /* This address needs to be reachable using normal inter-module
+      calls, and work on the memory models for this architecture */
+  /* 2 MB -- the normal starting point for text is 4 MB */
+  . = 0x00200400;
+  .interp         : { *(.interp) }
+  .reginfo        : { *(.reginfo) }
+  .dynamic        : { *(.dynamic) }
+  .hash           : { *(.hash) }
+  .dynsym         : { *(.dynsym) }
+  .dynstr         : { *(.dynstr) }
+  .gnu.version    : { *(.gnu.version) }
+  .gnu.version_d  : { *(.gnu.version_d) }
+  .gnu.version_r  : { *(.gnu.version_r) }
+  .rel.dyn        :
+    {
+      *(.rel.init)
+      *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*)
+      *(.rel.fini)
+      *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*)
+      *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*)
+      *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*)
+      *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*)
+      *(.rel.ctors)
+      *(.rel.dtors)
+      *(.rel.got)
+      *(.rel.sdata .rel.sdata.* .rel.gnu.linkonce.s.*)
+      *(.rel.sbss .rel.sbss.* .rel.gnu.linkonce.sb.*)
+      *(.rel.sdata2 .rel.sdata2.* .rel.gnu.linkonce.s2.*)
+      *(.rel.sbss2 .rel.sbss2.* .rel.gnu.linkonce.sb2.*)
+      *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*)
+    }
+  .rela.dyn       :
+    {
+      *(.rela.init)
+      *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*)
+      *(.rela.fini)
+      *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*)
+      *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*)
+      *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*)
+      *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*)
+      *(.rela.ctors)
+      *(.rela.dtors)
+      *(.rela.got)
+      *(.rela.sdata .rela.sdata.* .rela.gnu.linkonce.s.*)
+      *(.rela.sbss .rela.sbss.* .rela.gnu.linkonce.sb.*)
+      *(.rela.sdata2 .rela.sdata2.* .rela.gnu.linkonce.s2.*)
+      *(.rela.sbss2 .rela.sbss2.* .rela.gnu.linkonce.sb2.*)
+      *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*)
+    }
+  .rel.plt        : { *(.rel.plt) }
+  .rela.plt       : { *(.rela.plt) }
+  .init           :
+  {
+    KEEP (*(.init))
+  } =0
+  .plt            : { *(.plt) }
+  .text           :
+  {
+    _ftext = . ;
+    *(.text .stub .text.* .gnu.linkonce.t.*)
+    /* .gnu.warning sections are handled specially by elf32.em.  */
+    *(.gnu.warning)
+    *(.mips16.fn.*) *(.mips16.call.*)
+  } =0
+  .fini           :
+  {
+    KEEP (*(.fini))
+  } =0
+  PROVIDE (__etext = .);
+  PROVIDE (_etext = .);
+  PROVIDE (etext = .);
+  .rodata         : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
+  .rodata1        : { *(.rodata1) }
+  .sdata2         : { *(.sdata2 .sdata2.* .gnu.linkonce.s2.*) }
+  .sbss2          : { *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*) }
+  .eh_frame_hdr : { *(.eh_frame_hdr) }
+  /* Adjust the address for the data segment.  We want to adjust up to
+     the same address within the page on the next page up.  */
+  . = ALIGN(8192);
+  /* Ensure the __preinit_array_start label is properly aligned.  We
+     could instead move the label definition inside the section, but
+     the linker would then create the section even if it turns out to
+     be empty, which isn't pretty.  */
+  . = ALIGN(32 / 8);
+  PROVIDE (__preinit_array_start = .);
+  .preinit_array     : { *(.preinit_array) }
+  PROVIDE (__preinit_array_end = .);
+  PROVIDE (__init_array_start = .);
+  .init_array     : { *(.init_array) }
+  PROVIDE (__init_array_end = .);
+  PROVIDE (__fini_array_start = .);
+  .fini_array     : { *(.fini_array) }
+  PROVIDE (__fini_array_end = .);
+  .data           :
+  {
+    _fdata = . ;
+    *(.data .data.* .gnu.linkonce.d.*)
+    SORT(CONSTRUCTORS)
+  }
+  .data1          : { *(.data1) }
+  .tdata         : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
+  .tbss                  : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
+  .eh_frame       : { KEEP (*(.eh_frame)) }
+  .gcc_except_table   : { *(.gcc_except_table) }
+  .ctors          :
+  {
+    /* gcc uses crtbegin.o to find the start of
+       the constructors, so we make sure it is
+       first.  Because this is a wildcard, it
+       doesn't matter if the user does not
+       actually link against crtbegin.o; the
+       linker won't look for a file to match a
+       wildcard.  The wildcard also means that it
+       doesn't matter which directory crtbegin.o
+       is in.  */
+    KEEP (*crtbegin*.o(.ctors))
+    /* We don't want to include the .ctor section from
+       from the crtend.o file until after the sorted ctors.
+       The .ctor section from the crtend file contains the
+       end of ctors marker and it must be last */
+    KEEP (*(EXCLUDE_FILE (*crtend*.o ) .ctors))
+    KEEP (*(SORT(.ctors.*)))
+    KEEP (*(.ctors))
+  }
+  .dtors          :
+  {
+    KEEP (*crtbegin*.o(.dtors))
+    KEEP (*(EXCLUDE_FILE (*crtend*.o ) .dtors))
+    KEEP (*(SORT(.dtors.*)))
+    KEEP (*(.dtors))
+  }
+  .jcr            : { KEEP (*(.jcr)) }
+  _gp = ALIGN(16) + 0x7ff0;
+  .got            : { *(.got.plt) *(.got) }
+  /* We want the small data sections together, so single-instruction offsets
+     can access them all, and initialized data all before uninitialized, so
+     we can shorten the on-disk segment size.  */
+  .sdata          :
+  {
+    *(.sdata .sdata.* .gnu.linkonce.s.*)
+  }
+  .lit8           : { *(.lit8) }
+  .lit4           : { *(.lit4) }
+  _edata = .;
+  PROVIDE (edata = .);
+  __bss_start = .;
+  _fbss = .;
+  .sbss           :
+  {
+    PROVIDE (__sbss_start = .);
+    PROVIDE (___sbss_start = .);
+    *(.dynsbss)
+    *(.sbss .sbss.* .gnu.linkonce.sb.*)
+    *(.scommon)
+    PROVIDE (__sbss_end = .);
+    PROVIDE (___sbss_end = .);
+  }
+  .bss            :
+  {
+   *(.dynbss)
+   *(.bss .bss.* .gnu.linkonce.b.*)
+   *(COMMON)
+   /* Align here to ensure that the .bss section occupies space up to
+      _end.  Align after .bss to ensure correct alignment even if the
+      .bss section disappears because there are no input sections.  */
+   . = ALIGN(32 / 8);
+  }
+  . = ALIGN(32 / 8);
+  _end = .;
+  PROVIDE (end = .);
+  /* Stabs debugging sections.  */
+  .stab          0 : { *(.stab) }
+  .stabstr       0 : { *(.stabstr) }
+  .stab.excl     0 : { *(.stab.excl) }
+  .stab.exclstr  0 : { *(.stab.exclstr) }
+  .stab.index    0 : { *(.stab.index) }
+  .stab.indexstr 0 : { *(.stab.indexstr) }
+  .comment       0 : { *(.comment) }
+  /* DWARF debug sections.
+     Symbols in the DWARF debugging sections are relative to the beginning
+     of the section so we begin them at 0.  */
+  /* DWARF 1 */
+  .debug          0 : { *(.debug) }
+  .line           0 : { *(.line) }
+  /* GNU DWARF 1 extensions */
+  .debug_srcinfo  0 : { *(.debug_srcinfo) }
+  .debug_sfnames  0 : { *(.debug_sfnames) }
+  /* DWARF 1.1 and DWARF 2 */
+  .debug_aranges  0 : { *(.debug_aranges) }
+  .debug_pubnames 0 : { *(.debug_pubnames) }
+  /* DWARF 2 */
+  .debug_info     0 : { *(.debug_info .gnu.linkonce.wi.*) }
+  .debug_abbrev   0 : { *(.debug_abbrev) }
+  .debug_line     0 : { *(.debug_line) }
+  .debug_frame    0 : { *(.debug_frame) }
+  .debug_str      0 : { *(.debug_str) }
+  .debug_loc      0 : { *(.debug_loc) }
+  .debug_macinfo  0 : { *(.debug_macinfo) }
+  /* SGI/MIPS DWARF 2 extensions */
+  .debug_weaknames 0 : { *(.debug_weaknames) }
+  .debug_funcnames 0 : { *(.debug_funcnames) }
+  .debug_typenames 0 : { *(.debug_typenames) }
+  .debug_varnames  0 : { *(.debug_varnames) }
+  .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) }
+  .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) }
+  /DISCARD/ : { *(.note.GNU-stack) }
+}
diff --git a/klibc/klibc/arch/mips/syscall.S b/klibc/klibc/arch/mips/syscall.S
new file mode 100644 (file)
index 0000000..d5c1fe1
--- /dev/null
@@ -0,0 +1,15 @@
+#include <asm/asm.h>
+#include <asm/regdef.h>
+#include <asm/unistd.h>
+
+       .set noreorder
+       
+LEAF(__syscall_common)
+       syscall
+        beqz    a3, 1f
+       # sw is actually two instructions; the first one goes
+       # in the branch delay slot
+        sw      v0, errno
+        li      v0, -1
+1:      jr      ra
+       END(__syscall_common)
diff --git a/klibc/klibc/arch/mips/sysstub.ph b/klibc/klibc/arch/mips/sysstub.ph
new file mode 100644 (file)
index 0000000..abe599c
--- /dev/null
@@ -0,0 +1,30 @@
+# -*- perl -*-
+#
+# arch/mips/sysstub.ph
+#
+# Script to generate system call stubs
+#
+
+# On MIPS, most system calls follow the standard convention, with the
+# system call number in r0 (v0), return an error value in r19 (a3) as
+# well as the return value in r0 (v0).
+
+sub make_sysstub($$$$@) {
+    my($fname, $type, $sname, $stype, @args) = @_;
+
+    $stype = $stype || 'common';
+    open(OUT, '>', "syscalls/${fname}.S");
+    print OUT "#include <asm/asm.h>\n";
+    print OUT "#include <asm/regdef.h>\n";
+    print OUT "#include <asm/unistd.h>\n";
+    print OUT "\n";
+    print OUT "\t.set noreorder\n";
+    print OUT "\n";
+    print OUT "LEAF(${fname})\n";
+    print OUT "\tj\t__syscall_${stype}\n";
+    print OUT "\t  li\tv0, __NR_${sname}\n";
+    print OUT "\tEND(${fname})\n";
+    close(OUT);
+}
+
+1;
index aca8083..9829867 100644 (file)
@@ -6,14 +6,11 @@
 #define CLONE_VFORK    0x00004000
 #define SIGCHLD                18
 
+       .set noreorder
+       
 LEAF(vfork)
        li      a0, CLONE_VFORK | CLONE_VM | SIGCHLD
        li      a1, 0
-       li      v0, __NR_clone
-       syscall
-       bnez    a3, 1f
-       b       2f
-1:     sw      v0, errno
-       li      v0, -1
-2:     jr      ra
+       j       __syscall_common
+         li    v0, __NR_clone
        END(vfork)
diff --git a/klibc/klibc/arch/mips64/include/klibc/archsignal.h b/klibc/klibc/arch/mips64/include/klibc/archsignal.h
deleted file mode 100644 (file)
index 56b0fd3..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * arch/mips64/include/klibc/archsignal.h
- *
- * Architecture-specific signal definitions
- *
- */
-
-#ifndef _KLIBC_ARCHSIGNAL_H
-#define _KLIBC_ARCHSIGNAL_H
-
-/* No special stuff for this architecture */
-
-#endif
diff --git a/klibc/klibc/arch/mips64/include/klibc/archsys.h b/klibc/klibc/arch/mips64/include/klibc/archsys.h
deleted file mode 100644 (file)
index 81e5106..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-/*
- * arch/mips64/include/klibc/archsys.h
- *
- * Architecture-specific syscall definitions
- */
-
-#ifndef _KLIBC_ARCHSYS_H
-#define _KLIBC_ARCHSYS_H
-
-/* No special syscall definitions for this architecture */
-
-#endif /* _KLIBC_ARCHSYS_H */
index abe9155..980a543 100644 (file)
@@ -8,8 +8,12 @@
 #
 
 ARCHOBJS = \
-       arch/$(ARCH)/setjmp.o
+       arch/$(ARCH)/setjmp.o \
+       arch/$(ARCH)/syscall.o
 
 ARCHOOBJS = $(patsubst %o,%.lo,%(ARCHOBJS))
 
 archclean:
+
+arch/$(ARCH)/syscall.o: arch/$(ARCH)/syscall.c
+       $(CC) $(CFLAGS) -ffixed-r20 -c -o $@ $<
diff --git a/klibc/klibc/arch/parisc/include/klibc/archsignal.h b/klibc/klibc/arch/parisc/include/klibc/archsignal.h
deleted file mode 100644 (file)
index 3190e85..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * arch/parisc/include/klibc/archsignal.h
- *
- * Architecture-specific signal definitions
- *
- */
-
-#ifndef _KLIBC_ARCHSIGNAL_H
-#define _KLIBC_ARCHSIGNAL_H
-
-#define _NSIG    64
-#define _NSIG_SZ (_NSIG / LONG_BIT)
-
-typedef struct {
-        unsigned long sig[_NSIG_SZ];
-} sigset_t;
-
-struct sigaction {
-        __sighandler_t sa_handler;
-        unsigned long sa_flags;
-        sigset_t sa_mask;
-};
-
-#endif
diff --git a/klibc/klibc/arch/parisc/include/klibc/archsys.h b/klibc/klibc/arch/parisc/include/klibc/archsys.h
deleted file mode 100644 (file)
index 5013ba8..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-/*
- * arch/parisc/include/klibc/archsys.h
- *
- * Architecture-specific syscall definitions
- */
-
-#ifndef _KLIBC_ARCHSYS_H
-#define _KLIBC_ARCHSYS_H
-
-/* No special syscall definitions for this architecture */
-
-#endif /* _KLIBC_ARCHSYS_H */
diff --git a/klibc/klibc/arch/parisc/syscall.c b/klibc/klibc/arch/parisc/syscall.c
new file mode 100644 (file)
index 0000000..99ef5fe
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * arch/parisc/syscall.c
+ *
+ * This function is called from a stub with %r20 already set up.
+ * Compile this function with -ffixed-r20 so that it doesn't clobber
+ * this register by mistake.
+ */
+
+#include <klibc/compiler.h>
+#include <errno.h>
+
+long __syscall_common(long a0, long a1, long a2, long a3, long a4, long a5)
+{
+  register unsigned long rv asm ("r28");
+
+  asm volatile("\tble 0x100(%%sr2, %%r0)\n"
+              : "=r" (rv)
+              : "r" (a0), "r" (a1), "r" (a2), "r" (a3), "r" (a4), "r" (a5)
+              : "%r1", "%r2", "%r29", "%r31");
+
+  if ( __unlikely(rv >= -4095UL) ) {
+    errno = -rv;
+    return -1L;
+  } else {
+    return (long)rv;
+  }
+}
+
+  
diff --git a/klibc/klibc/arch/parisc/sysstub.ph b/klibc/klibc/arch/parisc/sysstub.ph
new file mode 100644 (file)
index 0000000..eb6b5dd
--- /dev/null
@@ -0,0 +1,29 @@
+# -*- perl -*-
+#
+# arch/parisc/sysstub.ph
+#
+# Script to generate system call stubs
+#
+
+sub make_sysstub($$$$@) {
+    my($fname, $type, $sname, $stype, @args) = @_;
+
+    open(OUT, '>', "syscalls/${fname}.S");
+    print OUT "#include <asm/unistd.h>\n";
+    print OUT "\n";
+    print OUT "\t.text\n";
+    print OUT "\t.align 4\n";
+    print OUT "\t.import __syscall_common, code\n";
+    print OUT "\t.global ${fname}\n";
+    print OUT "\t.export ${fname}, code\n";
+    print OUT "\t.type   ${fname}, @function\n";
+    print OUT "\t.proc\n";
+    print OUT "\.callinfo\n";
+    print OUT "${fname}:\n";
+    print OUT "\tb\t__syscall_common\n";
+    print OUT "\t  ldo\t__NR_${sname}(%r0),%r20\n";
+    print OUT "\t.procend\n";
+    close(OUT);
+}
+
+1;
index fcb0992..ff7c44d 100644 (file)
@@ -9,3 +9,10 @@
 
 OPTFLAGS = -Os -fomit-frame-pointer
 BITSIZE  = 32
+
+# Extra linkflags when building the shared version of the library
+# This address needs to be reachable using normal inter-module
+# calls, and work on the memory models for this architecture
+# 256-16 MB - normal binaries start at 256 MB, and jumps are limited
+# to +/- 16 MB
+SHAREDFLAGS     = -Ttext 0x0f000200
index 3bd2c06..c6bb975 100644 (file)
@@ -9,6 +9,7 @@
 
 ARCHOBJS = \
        arch/$(ARCH)/setjmp.o \
+       arch/$(ARCH)/syscall.o \
        libgcc/__divdi3.o \
        libgcc/__moddi3.o \
        libgcc/__udivdi3.o \
diff --git a/klibc/klibc/arch/ppc/include/klibc/archsetjmp.h b/klibc/klibc/arch/ppc/include/klibc/archsetjmp.h
deleted file mode 100644 (file)
index 53e2fcc..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * arch/ppc/include/klibc/archsetjmp.h
- */
-
-#ifndef _KLIBC_ARCHSETJMP_H
-#define _KLIBC_ARCHSETJMP_H
-
-struct __jmp_buf {
-  unsigned long __r2;
-  unsigned long __sp;
-  unsigned long __lr;
-  unsigned long __cr;
-  unsigned long __r13;
-  unsigned long __r14;
-  unsigned long __r15;
-  unsigned long __r16;
-  unsigned long __r17;
-  unsigned long __r18;
-  unsigned long __r19;
-  unsigned long __r20;
-  unsigned long __r21;
-  unsigned long __r22;
-  unsigned long __r23;
-  unsigned long __r24;
-  unsigned long __r25;
-  unsigned long __r26;
-  unsigned long __r27;
-  unsigned long __r28;
-  unsigned long __r29;
-  unsigned long __r30;
-  unsigned long __r31;
-};
-
-typedef struct __jmp_buf jmp_buf[1];
-
-#endif /* _SETJMP_H */
diff --git a/klibc/klibc/arch/ppc/include/klibc/archsignal.h b/klibc/klibc/arch/ppc/include/klibc/archsignal.h
deleted file mode 100644 (file)
index 567a547..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * arch/ppc/include/klibc/archsignal.h
- *
- * Architecture-specific signal definitions
- *
- */
-
-#ifndef _KLIBC_ARCHSIGNAL_H
-#define _KLIBC_ARCHSIGNAL_H
-
-/* No special stuff for this architecture */
-
-#endif
diff --git a/klibc/klibc/arch/ppc/include/klibc/archsys.h b/klibc/klibc/arch/ppc/include/klibc/archsys.h
deleted file mode 100644 (file)
index 17a2885..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * arch/ppc/include/klibc/archsys.h
- *
- * Architecture-specific syscall definitions
- */
-
-#ifndef _KLIBC_ARCHSYS_H
-#define _KLIBC_ARCHSYS_H
-
-/* PowerPC seems to lack _syscall6() in its headers */
-/* This seems to work on both 32- and 64-bit ppc */
-
-#ifndef _syscall6
-
-#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
-          type5,arg5,type6,arg6) \
-type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5,type6 arg6) \
-{ \
-        unsigned long __sc_ret, __sc_err;                               \
-        {                                                               \
-                register unsigned long __sc_0 __asm__ ("r0");           \
-                register unsigned long __sc_3 __asm__ ("r3");           \
-                register unsigned long __sc_4 __asm__ ("r4");           \
-                register unsigned long __sc_5 __asm__ ("r5");           \
-                register unsigned long __sc_6 __asm__ ("r6");           \
-                register unsigned long __sc_7 __asm__ ("r7");           \
-                register unsigned long __sc_8 __asm__ ("r8");           \
-                                                                        \
-                __sc_3 = (unsigned long) (arg1);                        \
-                __sc_4 = (unsigned long) (arg2);                        \
-                __sc_5 = (unsigned long) (arg3);                        \
-                __sc_6 = (unsigned long) (arg4);                        \
-                __sc_7 = (unsigned long) (arg5);                        \
-                __sc_8 = (unsigned long) (arg6);                        \
-                __sc_0 = __NR_##name;                                   \
-                __asm__ __volatile__                                    \
-                        ("sc           \n\t"                            \
-                         "mfcr %1      "                                \
-                        : "+r"   (__sc_3),                             \
-                         "+r"   (__sc_0),                              \
-                          "+r"   (__sc_4),                              \
-                          "+r"   (__sc_5),                              \
-                          "+r"   (__sc_6),                              \
-                          "+r"   (__sc_7),                              \
-                          "+r"   (__sc_8)                               \
-                        : : "cr0", "ctr", "memory",                     \
-                            "r9", "r10", "r11", "r12");                        \
-                __sc_ret = __sc_3;                                      \
-                __sc_err = __sc_0;                                      \
-        }                                                               \
-        if (__sc_err & 0x10000000)                                      \
-        {                                                               \
-                errno = (int)__sc_ret;                                  \
-                __sc_ret = -1;                                          \
-        }                                                               \
-        return (type)__sc_ret;                                          \
-}
-
-#endif /* _syscall6() missing */
-
-#endif /* _KLIBC_ARCHSYS_H */
diff --git a/klibc/klibc/arch/ppc/syscall.S b/klibc/klibc/arch/ppc/syscall.S
new file mode 100644 (file)
index 0000000..0a7c37c
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ * arch/ppc/syscall.S
+ *
+ * Common error-handling path for system calls.
+ */
+
+       .text
+       .align  2
+       .globl  __syscall_error
+       .type   __syscall_error,@function
+__syscall_error:
+       lis     9,errno@ha
+       stw     3,errno@l(9)
+       li      3,-1
+       blr
+       .size   __syscall_error,.-__syscall_error
diff --git a/klibc/klibc/arch/ppc/sysstub.ph b/klibc/klibc/arch/ppc/sysstub.ph
new file mode 100644 (file)
index 0000000..542ab55
--- /dev/null
@@ -0,0 +1,25 @@
+# -*- perl -*-
+#
+# arch/ppc/sysstub.ph
+#
+# Script to generate system call stubs
+#
+
+sub make_sysstub($$$$@) {
+    my($fname, $type, $sname, $stype, @args) = @_;
+
+    open(OUT, '>', "syscalls/${fname}.S");
+    print OUT "#include <asm/unistd.h>\n";
+    print OUT "\n";
+    print OUT "\t.type ${fname},\@function\n";
+    print OUT "\t.globl ${fname}\n";
+    print OUT "${fname}:\n";
+    print OUT "\tli 0,__NR_${sname}\n";
+    print OUT "\tsc\n";
+    print OUT "\tbnslr\n";
+    print OUT "\tb __syscall_error\n";
+    print OUT "\t.size ${fname},.-${fname}\n";
+    close(OUT);
+}
+
+1;
index 6997693..86526f8 100644 (file)
@@ -9,3 +9,10 @@
 
 OPTFLAGS = -Os -fomit-frame-pointer
 BITSIZE  = 64
+
+# Extra linkflags when building the shared version of the library
+# This address needs to be reachable using normal inter-module
+# calls, and work on the memory models for this architecture
+# 256-16 MB - normal binaries start at 256 MB, and jumps are limited
+# to +/- 16 MB
+SHAREDFLAGS     = -Ttext 0x0f000200
index 3ab3a8c..928df1a 100644 (file)
@@ -8,8 +8,18 @@
 #
 
 ARCHOBJS = \
-       arch/$(ARCH)/setjmp.o
+       arch/$(ARCH)/setjmp.o \
+       arch/$(ARCH)/syscall.o
 
 ARCHSOOBJS = $(patsubst %.o,%.lo,$(ARCHOBJS))
 
+INTERP_O = interp1.o
+
+interp.o: interp1.o klibc.got
+       $(LD) $(LDFLAGS) -r -o $@ interp1.o klibc.got
+
+klibc.got: $(SOHASH)
+       $(OBJCOPY) -j.got $< $@
+
 archclean:
+       rm -f klibc.got
diff --git a/klibc/klibc/arch/ppc64/include/klibc/archsetjmp.h b/klibc/klibc/arch/ppc64/include/klibc/archsetjmp.h
deleted file mode 100644 (file)
index 006a2e2..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * arch/ppc64/include/klibc/archsetjmp.h
- */
-
-#ifndef _KLIBC_ARCHSETJMP_H
-#define _KLIBC_ARCHSETJMP_H
-
-struct __jmp_buf {
-  unsigned long __r2;
-  unsigned long __sp;
-  unsigned long __lr;
-  unsigned long __cr;
-  unsigned long __r13;
-  unsigned long __r14;
-  unsigned long __r15;
-  unsigned long __r16;
-  unsigned long __r17;
-  unsigned long __r18;
-  unsigned long __r19;
-  unsigned long __r20;
-  unsigned long __r21;
-  unsigned long __r22;
-  unsigned long __r23;
-  unsigned long __r24;
-  unsigned long __r25;
-  unsigned long __r26;
-  unsigned long __r27;
-  unsigned long __r28;
-  unsigned long __r29;
-  unsigned long __r30;
-  unsigned long __r31;
-};
-
-typedef struct __jmp_buf jmp_buf[1];
-
-#endif /* _SETJMP_H */
diff --git a/klibc/klibc/arch/ppc64/include/klibc/archsignal.h b/klibc/klibc/arch/ppc64/include/klibc/archsignal.h
deleted file mode 100644 (file)
index 8452f6e..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * arch/ppc64/include/klibc/archsignal.h
- *
- * Architecture-specific signal definitions
- *
- */
-
-#ifndef _KLIBC_ARCHSIGNAL_H
-#define _KLIBC_ARCHSIGNAL_H
-
-/* No special stuff for this architecture */
-
-#endif
diff --git a/klibc/klibc/arch/ppc64/include/klibc/archsys.h b/klibc/klibc/arch/ppc64/include/klibc/archsys.h
deleted file mode 100644 (file)
index 4f81fee..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * arch/ppc64/include/klibc/archsys.h
- *
- * Architecture-specific syscall definitions
- */
-
-#ifndef _KLIBC_ARCHSYS_H
-#define _KLIBC_ARCHSYS_H
-
-#ifndef _syscall6
-
-#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
-          type5,arg5,type6,arg6) \
-type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5,type6 arg6) \
-{ \
-        unsigned long __sc_ret, __sc_err;                               \
-        {                                                               \
-                register unsigned long __sc_0 __asm__ ("r0");           \
-                register unsigned long __sc_3 __asm__ ("r3");           \
-                register unsigned long __sc_4 __asm__ ("r4");           \
-                register unsigned long __sc_5 __asm__ ("r5");           \
-                register unsigned long __sc_6 __asm__ ("r6");           \
-                register unsigned long __sc_7 __asm__ ("r7");           \
-                register unsigned long __sc_8 __asm__ ("r8");           \
-                                                                        \
-                __sc_3 = (unsigned long) (arg1);                        \
-                __sc_4 = (unsigned long) (arg2);                        \
-                __sc_5 = (unsigned long) (arg3);                        \
-                __sc_6 = (unsigned long) (arg4);                        \
-                __sc_7 = (unsigned long) (arg5);                        \
-                __sc_8 = (unsigned long) (arg6);                        \
-                __sc_0 = __NR_##name;                                   \
-                __asm__ __volatile__                                    \
-                        ("sc           \n\t"                            \
-                         "mfcr %1      "                                \
-                        : "=&r" (__sc_3), "=&r" (__sc_0)                \
-                        : "0"   (__sc_3), "1"   (__sc_0),               \
-                          "r"   (__sc_4),                               \
-                          "r"   (__sc_5),                               \
-                          "r"   (__sc_6),                               \
-                          "r"   (__sc_7),                               \
-                          "r"   (__sc_8)                                \
-                        : __syscall_clobbers);                          \
-                __sc_ret = __sc_3;                                      \
-                __sc_err = __sc_0;                                      \
-        }                                                               \
-        __syscall_return (type);                                        \
-}
-
-#endif /* _syscall6() missing */
-
-#endif /* _KLIBC_ARCHSYS_H */
index 1dcc670..30db419 100644 (file)
@@ -2,7 +2,6 @@
 # arch/ppc64/setjmp.S
 #
 # Basic setjmp/longjmp implementation
-# This file was derived from the equivalent file in NetBSD
 #
 
        .text
@@ -17,13 +16,33 @@ setjmp:
        .globl  setjmp
        .globl  .setjmp
 .setjmp:
-        mflr    %r11                    /* save return address */
-        mfcr    %r12                    /* save condition register */
-        mr      %r10,%r1                /* save stack pointer */
-        mr      %r9,%r2                 /* save GPR2 (not needed) */
-        stmw    %r9,0(%r3)              /* save r9..r31 */
-        li      %r3,0                   /* indicate success */
-        blr                             /* return */
+       mflr    %r11                    /* save return address */
+       mfcr    %r12                    /* save condition register */
+       std     %r2,0(%r3)              /* save TOC pointer (not needed) */
+       stdu    %r1,8(%r3)              /* save stack pointer */
+       stdu    %r11,8(%r3)
+       stdu    %r12,8(%r3)
+       stdu    %r13,8(%r3)             /* save caller saved regs */
+       stdu    %r14,8(%r3)
+       stdu    %r15,8(%r3)
+       stdu    %r16,8(%r3)
+       stdu    %r17,8(%r3)
+       stdu    %r18,8(%r3)
+       stdu    %r19,8(%r3)
+       stdu    %r20,8(%r3)
+       stdu    %r21,8(%r3)
+       stdu    %r22,8(%r3)
+       stdu    %r23,8(%r3)
+       stdu    %r24,8(%r3)
+       stdu    %r25,8(%r3)
+       stdu    %r26,8(%r3)
+       stdu    %r27,8(%r3)
+       stdu    %r28,8(%r3)
+       stdu    %r29,8(%r3)
+       stdu    %r30,8(%r3)
+       std     %r31,8(%r3)
+       li      %r3,0                   /* indicate success */
+       blr                             /* return */
 
        .size .setjmp,.-.setjmp
        .section ".opd","aw"
@@ -35,12 +54,32 @@ longjmp:
        .globl  longjmp
        .globl  .longjmp
 .longjmp:
-        lmw     %r9,0(%r3)              /* save r9..r31 */
-        mtlr    %r11                    /* restore LR */
-        mtcr    %r12                    /* restore CR */
-        mr      %r2,%r9                 /* restore GPR2 (not needed) */
-        mr      %r1,%r10                /* restore stack */
-        mr      %r3,%r4                 /* get return value */
-        blr                             /* return */
+       ld      %r2,0(%r3)              /* restore TOC pointer (not needed) */
+       ldu     %r1,8(%r3)              /* restore stack */
+       ldu     %r11,8(%r3)
+       ldu     %r12,8(%r3)
+       ldu     %r13,8(%r3)             /* restore caller saved regs */
+       ldu     %r14,8(%r3)
+       ldu     %r15,8(%r3)
+       ldu     %r16,8(%r3)
+       ldu     %r17,8(%r3)
+       ldu     %r18,8(%r3)
+       ldu     %r19,8(%r3)
+       ldu     %r20,8(%r3)
+       ldu     %r21,8(%r3)
+       ldu     %r22,8(%r3)
+       ldu     %r23,8(%r3)
+       ldu     %r24,8(%r3)
+       ldu     %r25,8(%r3)
+       ldu     %r26,8(%r3)
+       ldu     %r27,8(%r3)
+       ldu     %r28,8(%r3)
+       ldu     %r29,8(%r3)
+       ldu     %r30,8(%r3)
+       ld      %r31,8(%r3)
+       mtlr    %r11                    /* restore LR */
+       mtcr    %r12                    /* restore CR */
+       mr      %r3,%r4                 /* get return value */
+       blr                             /* return */
 
        .size .longjmp,.-.longjmp
diff --git a/klibc/klibc/arch/ppc64/syscall.c b/klibc/klibc/arch/ppc64/syscall.c
new file mode 100644 (file)
index 0000000..a5895fe
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * arch/ppc64/syscall.c
+ *
+ * Common error-handling path for system calls.
+ * The return value from __syscall_error becomes the
+ * return value from the system call.
+ */
+#include <errno.h>
+
+long int __syscall_error(long int err)
+{
+       errno = err;
+       return -1;
+}
diff --git a/klibc/klibc/arch/ppc64/sysstub.ph b/klibc/klibc/arch/ppc64/sysstub.ph
new file mode 100644 (file)
index 0000000..1469cc6
--- /dev/null
@@ -0,0 +1,34 @@
+# -*- perl -*-
+#
+# arch/ppc64/sysstub.ph
+#
+# Script to generate system call stubs
+#
+
+sub make_sysstub($$$$@) {
+    my($fname, $type, $sname, $stype, @args) = @_;
+
+    open(OUT, '>', "syscalls/${fname}.S");
+    print OUT "#include <asm/unistd.h>\n";
+    print OUT "\n";
+    print OUT "\t.globl ${fname}\n";
+    print OUT "\t.section \".opd\",\"aw\"\n";
+    print OUT "\t.align 3\n";
+    print OUT "${fname}:\n";
+    print OUT "\t.quad .${fname},.TOC.\@tocbase,0\n";
+    print OUT "\t.size ${fname},24\n";
+    print OUT "\t.text\n";
+    print OUT "\t.type .${fname},\@function\n";
+    print OUT "\t.globl .${fname}\n";
+    print OUT ".${fname}:\n";
+    print OUT "\tli 0,__NR_${sname}\n";
+    print OUT "\tsc\n";
+    print OUT "\tmfcr 0\n";
+    print OUT "\trldicl. 9,0,36,63\n";
+    print OUT "\tbeqlr- 0\n";
+    print OUT "\tb .__syscall_error\n";
+    print OUT "\t.size .${fname},.-.${fname}\n";
+    close(OUT);
+}
+
+1;
index c50f4f2..49b64dd 100644 (file)
@@ -9,6 +9,8 @@
 
 ARCHOBJS = \
        arch/$(ARCH)/setjmp.o \
+       arch/$(ARCH)/mmap.o \
+       arch/$(ARCH)/syscall.o \
        libgcc/__divdi3.o \
        libgcc/__moddi3.o \
        libgcc/__udivdi3.o \
diff --git a/klibc/klibc/arch/s390/include/klibc/archsetjmp.h b/klibc/klibc/arch/s390/include/klibc/archsetjmp.h
deleted file mode 100644 (file)
index 11a641e..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * arch/s390/include/klibc/archsetjmp.h
- */
-
-#ifndef _KLIBC_ARCHSETJMP_H
-#define _KLIBC_ARCHSETJMP_H
-
-struct __jmp_buf {
-  uint32_t __gregs[10]; /* general registers r6-r15 */
-  uint64_t __fpregs[2]; /* fp registers f4 and f6   */
-};
-
-typedef struct __jmp_buf jmp_buf[1];
-
-#endif /* _SETJMP_H */
diff --git a/klibc/klibc/arch/s390/include/klibc/archsignal.h b/klibc/klibc/arch/s390/include/klibc/archsignal.h
deleted file mode 100644 (file)
index 1f8de28..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * arch/s390/include/klibc/archsignal.h
- *
- * Architecture-specific signal definitions
- *
- */
-
-#ifndef _KLIBC_ARCHSIGNAL_H
-#define _KLIBC_ARCHSIGNAL_H
-
-/* No special stuff for this architecture */
-
-#endif
diff --git a/klibc/klibc/arch/s390/include/klibc/archsys.h b/klibc/klibc/arch/s390/include/klibc/archsys.h
deleted file mode 100644 (file)
index 1cd0948..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * arch/s390/include/klibc/archsys.h
- *
- * Architecture-specific syscall definitions
- */
-
-#ifndef _KLIBC_ARCHSYS_H
-#define _KLIBC_ARCHSYS_H
-
-/* S/390 only has five syscall parameters, and uses a structure for
-   6-argument syscalls. */
-
-#ifndef _syscall6
-
-#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,\
-                  type4,arg4,type5,arg5,type6,arg6)          \
-type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4,    \
-          type5 arg5, type6 arg6) {                         \
-       unsigned long  __arg[6] = {                          \
-               (unsigned long) arg1,                        \
-               (unsigned long) arg2,                        \
-               (unsigned long) arg3,                        \
-               (unsigned long) arg4,                        \
-               (unsigned long) arg5,                        \
-               (unsigned long) arg6                         \
-       };                                                   \
-       register void *__argp asm("2") = &__arg;             \
-       long __res;                                          \
-       __asm__ __volatile__ (                               \
-                "    svc %b1\n"                              \
-                "    lr  %0,2"                               \
-                : "=d" (__res)                               \
-                : "i" (__NR_##name),                         \
-                  "d" (__argp)                              \
-               : _svc_clobber);                             \
-       __syscall_return(type, __res);                       \
-}
-
-#endif /* _syscall6() missing */
-
-#endif /* _KLIBC_ARCHSYS_H */
diff --git a/klibc/klibc/arch/s390/mmap.c b/klibc/klibc/arch/s390/mmap.c
new file mode 100644 (file)
index 0000000..51ff07f
--- /dev/null
@@ -0,0 +1,41 @@
+#include <sys/types.h>
+#include <linux/unistd.h>
+
+struct mmap_arg_struct {
+       unsigned long addr;
+       unsigned long len;
+       unsigned long prot;
+       unsigned long flags;
+       unsigned long fd;
+       unsigned long offset;
+};
+
+void * __mmap2(void * addr, size_t len, int prot, int flags,
+                                                int fd, long offset)
+{
+       struct mmap_arg_struct args = {
+               (unsigned long) addr,
+               (unsigned long) len,
+               (unsigned long) prot,
+               (unsigned long) flags,
+               (unsigned long) fd,
+               (unsigned long) offset,
+       };
+
+       register struct mmap_arg_struct *__arg1 asm("2") = &args;
+       register long __svcres asm("2");
+       unsigned long __res;
+
+       __asm__ __volatile__ (
+               "    svc %b1\n"
+               : "=d" (__svcres)
+               : "i" (__NR_mmap2),
+                 "0" (__arg1)
+               : "1", "cc", "memory");
+       __res = __svcres;
+       if (__res >= (unsigned long)-125) {
+               errno = -__res;
+               __res = -1;
+       }
+       return (void *)__res;
+}
diff --git a/klibc/klibc/arch/s390/syscall.c b/klibc/klibc/arch/s390/syscall.c
new file mode 100644 (file)
index 0000000..c0f17c4
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ * arch/s390/syscall.c
+ *
+ * Common error-handling path for system calls.
+ * The return value from __syscall_common becomes the
+ * return value from the system call.
+ */
+#include <errno.h>
+
+long int __syscall_common(long int err)
+{
+       if ((unsigned long)(err) < (unsigned long)(-125))
+               return err;
+       errno = err;
+       return -1;
+}
diff --git a/klibc/klibc/arch/s390/sysstub.ph b/klibc/klibc/arch/s390/sysstub.ph
new file mode 100644 (file)
index 0000000..3838a1f
--- /dev/null
@@ -0,0 +1,31 @@
+# -*- perl -*-
+#
+# arch/s390/sysstub.ph
+#
+# Script to generate system call stubs
+#
+
+sub make_sysstub($$$$@) {
+    my($fname, $type, $sname, $stype, @args) = @_;
+
+    open(OUT, '>', "syscalls/${fname}.S");
+    print OUT "#include <asm/unistd.h>\n";
+    print OUT "\n";
+    print OUT "\t.type ${fname},\@function\n";
+    print OUT "\t.globl ${fname}\n";
+    print OUT "${fname}:\n";
+    print OUT ".if __NR_${sname} < 256\n";
+    print OUT "\tsvc __NR_${sname}\n";
+    print OUT ".else\n";
+    print OUT "\tlhi %r1,__NR_${sname}\n";
+    print OUT "\tsvc 0\n";
+    print OUT ".endif\n";
+    print OUT "\tbras %r3,1f\n";
+    print OUT "\t.long __syscall_common\n";
+    print OUT "1:\tl %r3,0(%r3)\n";
+    print OUT "\tbr %r3\n";
+    print OUT "\t.size ${fname},.-${fname}\n";
+    close(OUT);
+}
+
+1;
index eff8f95..9d614e0 100644 (file)
@@ -8,7 +8,9 @@
 #
 
 ARCHOBJS = \
-       arch/$(ARCH)/setjmp.o
+       arch/$(ARCH)/setjmp.o \
+       arch/$(ARCH)/mmap.o \
+       arch/$(ARCH)/syscall.o
 
 ARCHSOOBJS = $(patsubst %.o,%.lo,$(ARCHOBJS))
 
diff --git a/klibc/klibc/arch/s390x/include/klibc/archsetjmp.h b/klibc/klibc/arch/s390x/include/klibc/archsetjmp.h
deleted file mode 100644 (file)
index dd3ed0d..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * arch/s390x/include/klibc/archsetjmp.h
- */
-
-#ifndef _KLIBC_ARCHSETJMP_H
-#define _KLIBC_ARCHSETJMP_H
-
-struct __jmp_buf {
-  uint64_t __gregs[10]; /* general registers r6-r15 */
-  uint64_t __fpregs[4]; /* fp registers f1, f3, f5, f7 */
-};
-
-typedef struct __jmp_buf jmp_buf[1];
-
-#endif /* _SETJMP_H */
diff --git a/klibc/klibc/arch/s390x/include/klibc/archsignal.h b/klibc/klibc/arch/s390x/include/klibc/archsignal.h
deleted file mode 100644 (file)
index 08c9a00..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * arch/s390x/include/klibc/archsignal.h
- *
- * Architecture-specific signal definitions
- *
- */
-
-#ifndef _KLIBC_ARCHSIGNAL_H
-#define _KLIBC_ARCHSIGNAL_H
-
-/* No special stuff for this architecture */
-
-#endif
diff --git a/klibc/klibc/arch/s390x/include/klibc/archsys.h b/klibc/klibc/arch/s390x/include/klibc/archsys.h
deleted file mode 100644 (file)
index 15f7113..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * arch/s390x/include/klibc/archsys.h
- *
- * Architecture-specific syscall definitions
- */
-
-#ifndef _KLIBC_ARCHSYS_H
-#define _KLIBC_ARCHSYS_H
-
-/* S/390X only has five syscall parameters, and uses a structure for
-   6-argument syscalls. */
-
-#ifndef _syscall6
-
-#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,\
-                  type4,arg4,type5,arg5,type6,arg6)          \
-type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4,    \
-          type5 arg5, type6 arg6) {                         \
-       unsigned long  __arg[6] = {                          \
-               (unsigned long) arg1,                        \
-               (unsigned long) arg2,                        \
-               (unsigned long) arg3,                        \
-               (unsigned long) arg4,                        \
-               (unsigned long) arg5,                        \
-               (unsigned long) arg6                         \
-       };                                                   \
-       register void *__argp asm("2") = &__arg;             \
-       long __res;                                          \
-       __asm__ __volatile__ (                               \
-                "    svc %b1\n"                              \
-                "    lgr  %0,2"                              \
-                : "=d" (__res)                               \
-                : "i" (__NR_##name),                         \
-                  "d" (__argp)                              \
-               : _svc_clobber);                             \
-       __syscall_return(type, __res);                       \
-}
-
-#endif /* _syscall6() missing */
-
-#endif /* _KLIBC_ARCHSYS_H */
diff --git a/klibc/klibc/arch/s390x/mmap.c b/klibc/klibc/arch/s390x/mmap.c
new file mode 100644 (file)
index 0000000..158f093
--- /dev/null
@@ -0,0 +1,41 @@
+#include <sys/types.h>
+#include <linux/unistd.h>
+
+struct mmap_arg_struct {
+       unsigned long addr;
+       unsigned long len;
+       unsigned long prot;
+       unsigned long flags;
+       unsigned long fd;
+       unsigned long offset;
+};
+
+void * mmap(void * addr, size_t len, int prot, int flags,
+                                                int fd, off_t offset)
+{
+       struct mmap_arg_struct args = {
+               (unsigned long) addr,
+               (unsigned long) len,
+               (unsigned long) prot,
+               (unsigned long) flags,
+               (unsigned long) fd,
+               (unsigned long) offset,
+       };
+
+       register struct mmap_arg_struct *__arg1 asm("2") = &args;
+       register long __svcres asm("2");
+       unsigned long __res;
+
+       __asm__ __volatile__ (
+               "    svc %b1\n"
+               : "=d" (__svcres)
+               : "i" (__NR_mmap),
+                 "0" (__arg1)
+               : "1", "cc", "memory");
+       __res = __svcres;
+       if (__res >= (unsigned long)-125) {
+               errno = -__res;
+               __res = -1;
+       }
+       return (void *)__res;
+}
diff --git a/klibc/klibc/arch/s390x/syscall.c b/klibc/klibc/arch/s390x/syscall.c
new file mode 100644 (file)
index 0000000..c0f17c4
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ * arch/s390/syscall.c
+ *
+ * Common error-handling path for system calls.
+ * The return value from __syscall_common becomes the
+ * return value from the system call.
+ */
+#include <errno.h>
+
+long int __syscall_common(long int err)
+{
+       if ((unsigned long)(err) < (unsigned long)(-125))
+               return err;
+       errno = err;
+       return -1;
+}
diff --git a/klibc/klibc/arch/s390x/sysstub.ph b/klibc/klibc/arch/s390x/sysstub.ph
new file mode 100644 (file)
index 0000000..10a47f7
--- /dev/null
@@ -0,0 +1,28 @@
+# -*- perl -*-
+#
+# arch/s390x/sysstub.ph
+#
+# Script to generate system call stubs
+#
+
+sub make_sysstub($$$$@) {
+    my($fname, $type, $sname, $stype, @args) = @_;
+
+    open(OUT, '>', "syscalls/${fname}.S");
+    print OUT "#include <asm/unistd.h>\n";
+    print OUT "\n";
+    print OUT "\t.type ${fname},\@function\n";
+    print OUT "\t.globl ${fname}\n";
+    print OUT "${fname}:\n";
+    print OUT ".if __NR_${sname} < 256\n";
+    print OUT "\tsvc __NR_${sname}\n";
+    print OUT ".else\n";
+    print OUT "\tlghi %r1,__NR_${sname}\n";
+    print OUT "\tsvc 0\n";
+    print OUT ".endif\n";
+    print OUT "\tbrasl %r3,__syscall_common\n";
+    print OUT "\t.size ${fname},.-${fname}\n";
+    close(OUT);
+}
+
+1;
index 16d7ea1..ccabfa4 100644 (file)
@@ -7,7 +7,8 @@
 # accordingly.
 #
 
-ARCHOBJS = arch/sh/setjmp.o
+ARCHOBJS = arch/sh/setjmp.o \
+          arch/sh/syscall.o
 
 ARCHSOOBJS = $(patsubst %.o,%.lo,$(ARCHOBJS))
 
index c9938a5..21a3765 100644 (file)
@@ -1,12 +1,11 @@
 #
 # arch/sh/crt0.S
 #
-# void _start(void)
-# {
-#    /* Divine up argc, argv, and envp */
-#    environ = envp;
-#    exit(main(argc, argv, envp));
-# } 
+# Does arch-specific initialization and invokes __libc_init
+# with the appropriate arguments.
+#
+# See __static_init.c or __shared_init.c for the expected
+# arguments.
 #
 
        .text
diff --git a/klibc/klibc/arch/sh/include/klibc/archsetjmp.h b/klibc/klibc/arch/sh/include/klibc/archsetjmp.h
deleted file mode 100644 (file)
index 28dd932..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * arch/sh/include/klibc/archsetjmp.h
- */
-
-#ifndef _KLIBC_ARCHSETJMP_H
-#define _KLIBC_ARCHSETJMP_H
-
-struct __jmp_buf {
-  unsigned long r8;
-  unsigned long r9;
-  unsigned long r10;
-  unsigned long r11;
-  unsigned long r12;
-  unsigned long r13;
-  unsigned long r14;
-  unsigned long r15;
-  unsigned long pr;
-};
-
-typedef struct __jmp_buf jmp_buf[1];
-
-#endif /* _KLIBC_ARCHSETJMP_H */
diff --git a/klibc/klibc/arch/sh/include/klibc/archsignal.h b/klibc/klibc/arch/sh/include/klibc/archsignal.h
deleted file mode 100644 (file)
index 6c4e597..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * arch/sh/include/klibc/archsignal.h
- *
- * Architecture-specific signal definitions
- *
- */
-
-#ifndef _KLIBC_ARCHSIGNAL_H
-#define _KLIBC_ARCHSIGNAL_H
-
-/* No special stuff for this architecture */
-
-#endif
diff --git a/klibc/klibc/arch/sh/include/klibc/archsys.h b/klibc/klibc/arch/sh/include/klibc/archsys.h
deleted file mode 100644 (file)
index 5f8050a..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-/*
- * arch/sh/include/klibc/archsys.h
- *
- * Architecture-specific syscall definitions
- */
-
-#ifndef _KLIBC_ARCHSYS_H
-#define _KLIBC_ARCHSYS_H
-
-/* No special syscall definitions for this architecture */
-
-#endif /* _KLIBC_ARCHSYS_H */
diff --git a/klibc/klibc/arch/sh/syscall.S b/klibc/klibc/arch/sh/syscall.S
new file mode 100644 (file)
index 0000000..41a0486
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * arch/sh/syscall.S
+ *
+ * On sh, r3 contains the syscall number (set by generated stub);
+ * r4..r7 contain arguments 0-3 per the standard calling convention,
+ * and arguments 4-5 are passed in r0 and r1.
+ *
+ * The return value is in r3 rather than standard r0.
+ */
+
+       .section ".text.syscall","ax"
+       .align  2
+       .globl  ___syscall_common
+       .type   ___syscall_common,@function
+___syscall_common:
+       mov.l   @(sp),r0
+       mov.l   @(4,sp),r1
+       trapa   #0x15
+       mov.l   1f,r0
+       cmp/hs  r0,r3
+       bt/s    3f
+         neg   r3,r4
+       mov.l   2f,r5
+       mov.l   r4,@r5
+       rts
+         mov   #-1,r0
+3:
+       rts
+         mov   r3,r0
+
+       .align 2
+1:     .long   -4096           /* Errno limit */
+2:     .long   errno
+
+       .size   ___syscall_common,.-___syscall_common
diff --git a/klibc/klibc/arch/sh/sysstub.ph b/klibc/klibc/arch/sh/sysstub.ph
new file mode 100644 (file)
index 0000000..add5d35
--- /dev/null
@@ -0,0 +1,34 @@
+# -*- perl -*-
+#
+# arch/sh/sysstub.ph
+#
+# Script to generate system call stubs
+#
+
+sub make_sysstub($$$$@) {
+    my($fname, $type, $sname, $stype, @args) = @_;
+
+    open(OUT, '>', "syscalls/${fname}.S");
+    print OUT "#include <asm/unistd.h>\n";
+    print OUT "\n";
+    print OUT "\t.section\t\".text.syscall\",\"ax\"\n";
+    print OUT "\t.type\t${fname},\#function\n";
+    print OUT "\t.globl\t${fname}\n";
+    print OUT "\t.align\t2\n";
+    print OUT "${fname}:\n";
+    print OUT "\tbra\t__syscall_common\n";
+    print OUT "#if __NR_${sname} >= 128\n";
+    print OUT "\t  mov.l\t1f, r3\n";
+    print OUT "#else\n";
+    print OUT "\t  mov\t# __NR_${sname}, r3\n";
+    print OUT "#endif\n";
+    print OUT "\t.size ${fname},.-${fname}\n";
+    print OUT "\n";
+    print OUT "#if __NR_${sname} >= 128\n";
+    print OUT "\t.align\t2\n";
+    print OUT "1:\t.long\t__NR_${sname}\n";
+    print OUT "#endif\n";
+    close(OUT);
+}
+
+1;
index 0186810..6ea6611 100644 (file)
@@ -14,7 +14,9 @@ ARCHOBJS = \
        arch/$(ARCH)/urem.o \
        arch/$(ARCH)/smul.o \
        arch/$(ARCH)/umul.o \
-       arch/$(ARCH)/setjmp.o
+       arch/$(ARCH)/setjmp.o \
+       arch/$(ARCH)/syscall.o \
+       arch/$(ARCH)/sysfork.o
 
 arch/$(ARCH)/sdiv.S: arch/$(ARCH)/divrem.m4
        @echo 'building $@ from $^'
diff --git a/klibc/klibc/arch/sparc/include/klibc/archsetjmp.h b/klibc/klibc/arch/sparc/include/klibc/archsetjmp.h
deleted file mode 100644 (file)
index 92c1c74..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * arch/sparc/include/klibc/archsetjmp.h
- */
-
-#ifndef _KLIBC_ARCHSETJMP_H
-#define _KLIBC_ARCHSETJMP_H
-
-struct __jmp_buf {
-  unsigned long __sp;
-  unsigned long __fp;
-  unsigned long __pc;
-};
-
-typedef struct __jmp_buf jmp_buf[1];
-
-#endif /* _SETJMP_H */
diff --git a/klibc/klibc/arch/sparc/include/klibc/archsignal.h b/klibc/klibc/arch/sparc/include/klibc/archsignal.h
deleted file mode 100644 (file)
index 6af3709..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * arch/sparc/include/klibc/archsignal.h
- *
- * Architecture-specific signal definitions
- *
- */
-
-#ifndef _KLIBC_ARCHSIGNAL_H
-#define _KLIBC_ARCHSIGNAL_H
-
-/* No special stuff for this architecture */
-
-#endif
diff --git a/klibc/klibc/arch/sparc/include/klibc/archsys.h b/klibc/klibc/arch/sparc/include/klibc/archsys.h
deleted file mode 100644 (file)
index fe6e68d..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * arch/sparc/include/klibc/archsys.h
- *
- * Architecture-specific syscall definitions
- */
-
-#ifndef _KLIBC_ARCHSYS_H
-#define _KLIBC_ARCHSYS_H
-
-/* fork and vfork return the "other process" pid in %o0 and an
-   "is child" flag in %o1... */
-
-#define _syscall0_forkish(type,name) \
-type name(void) \
-{ \
-register long __g1 __asm__ ("g1") = __NR_##name; \
-register unsigned long __o0 __asm__ ("o0"); \
-register unsigned long __o1 __asm__ ("o1"); \
-__asm__ __volatile__ ("t 0x10\n\t" \
-                     "bcc 1f\n\t" \
-                     "mov %%o0, %0\n\t" \
-                     "sub %%g0, %%o0, %0\n\t" \
-                     "1:\n\t" \
-                     : "=r" (__o0), "=r" (__o1)\
-                     : "r" (__g1) \
-                     : "cc"); \
-if ((unsigned long)__o0 < (unsigned long)-255) \
-    return (type)(__o0 & (__o1-1)); \
-errno = (int)-__o0; \
-return -1; \
-}
-
-/* SPARC seems to lack _syscall6() in its headers */
-
-#ifndef _syscall6
-
-#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
-  type5,arg5,type6,arg6) \
-type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5,type6 arg6) \
-{ \
-long __res; \
-register long __g1 __asm__ ("g1") = __NR_##name; \
-register long __o0 __asm__ ("o0") = (long)(arg1); \
-register long __o1 __asm__ ("o1") = (long)(arg2); \
-register long __o2 __asm__ ("o2") = (long)(arg3); \
-register long __o3 __asm__ ("o3") = (long)(arg4); \
-register long __o4 __asm__ ("o4") = (long)(arg5); \
-register long __o5 __asm__ ("o5") = (long)(arg6); \
-__asm__ __volatile__ ("t 0x10\n\t" \
-      "bcc 1f\n\t" \
-      "mov %%o0, %0\n\t" \
-      "sub %%g0, %%o0, %0\n\t" \
-      "1:\n\t" \
-      : "=r" (__res), "=&r" (__o0) \
-      : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__o3), "r" (__o4), "r" (__o5), "r" (__g1) \
-      : "cc"); \
-if (__res < -255 || __res>=0) \
-return (type) __res; \
-errno = -__res; \
-return (type)-1; \
-}
-
-#endif /* _syscall6 missing */
-
-#endif /* _KLIBC_ARCHSYS_H */
diff --git a/klibc/klibc/arch/sparc/include/machine/asm.h b/klibc/klibc/arch/sparc/include/machine/asm.h
deleted file mode 100644 (file)
index b622bd8..0000000
+++ /dev/null
@@ -1,192 +0,0 @@
-/*     $NetBSD: asm.h,v 1.14 2002/07/20 08:37:30 mrg Exp $ */
-
-/*
- * Copyright (c) 1994 Allen Briggs
- * All rights reserved.
- *
- * Gleaned from locore.s and sun3 asm.h which had the following copyrights:
- * locore.s:
- * Copyright (c) 1988 University of Utah.
- * Copyright (c) 1982, 1990 The Regents of the University of California.
- * sun3/include/asm.h:
- * Copyright (c) 1993 Adam Glass
- * Copyright (c) 1990 The Regents of the University of California.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef _ASM_H_
-#define _ASM_H_
-
-/* Pull in CCFSZ, CC64FSZ, and BIAS from frame.h */
-#ifndef _LOCORE
-#define _LOCORE
-#endif
-#include <machine/frame.h>
-
-#ifdef __ELF__
-#define        _C_LABEL(name)          name
-#else
-#ifdef __STDC__
-#define _C_LABEL(name)         _ ## name
-#else
-#define _C_LABEL(name)         _/**/name
-#endif
-#endif
-#define        _ASM_LABEL(name)        name
-
-#ifdef PIC
-/*
- * PIC_PROLOGUE() is akin to the compiler generated function prologue for
- * PIC code. It leaves the address of the Global Offset Table in DEST,
- * clobbering register TMP in the process.
- *
- * We can use two code sequences.  We can read the %pc or use the call
- * instruction that saves the pc in %o7.  Call requires the branch unit and
- * IEU1, and clobbers %o7 which needs to be restored.  This instruction
- * sequence takes about 4 cycles due to instruction interdependence.  Reading
- * the pc takes 4 cycles to dispatch and is always dispatched alone.  That
- * sequence takes 7 cycles.
- */
-#ifdef __arch64__
-#define PIC_PROLOGUE(dest,tmp) \
-       mov %o7, tmp; \
-       sethi %hi(_GLOBAL_OFFSET_TABLE_-4),dest; \
-       call 0f; \
-        or dest,%lo(_GLOBAL_OFFSET_TABLE_+4),dest; \
-0: \
-       add dest,%o7,dest; \
-       mov tmp, %o7
-#else
-#define PIC_PROLOGUE(dest,tmp) \
-       mov %o7,tmp; 3: call 4f; nop; 4: \
-       sethi %hi(_C_LABEL(_GLOBAL_OFFSET_TABLE_)-(3b-.)),dest; \
-       or dest,%lo(_C_LABEL(_GLOBAL_OFFSET_TABLE_)-(3b-.)),dest; \
-       add dest,%o7,dest; mov tmp,%o7
-#endif
-
-/*
- * PICCY_SET() does the equivalent of a `set var, %dest' instruction in
- * a PIC-like way, but without involving the Global Offset Table. This
- * only works for VARs defined in the same file *and* in the text segment.
- */
-#ifdef __arch64__
-#define PICCY_SET(var,dest,tmp) \
-       3: rd %pc, tmp; add tmp,(var-3b),dest
-#else
-#define PICCY_SET(var,dest,tmp) \
-       mov %o7,tmp; 3: call 4f; nop; 4: \
-       add %o7,(var-3b),dest; mov tmp,%o7
-#endif
-#else
-#define PIC_PROLOGUE(dest,tmp)
-#define PICCY_OFFSET(var,dest,tmp)
-#endif
-
-#define FTYPE(x)               .type x,@function
-#define OTYPE(x)               .type x,@object
-
-#define        _ENTRY(name) \
-       .align 4; .globl name; .proc 1; FTYPE(name); name:
-
-#ifdef GPROF
-/* see _MCOUNT_ENTRY in profile.h */
-#ifdef __ELF__
-#ifdef __arch64__
-#define _PROF_PROLOGUE \
-       .data; .align 8; 1: .uaword 0; .uaword 0; \
-       .text; save %sp,-CC64FSZ,%sp; sethi %hi(1b),%o0; call _mcount; \
-       or %o0,%lo(1b),%o0; restore
-#else
-#define _PROF_PROLOGUE \
-       .data; .align 4; 1: .long 0; \
-       .text; save %sp,-96,%sp; sethi %hi(1b),%o0; call _mcount; \
-       or %o0,%lo(1b),%o0; restore
-#endif
-#else
-#ifdef __arch64__
-#define _PROF_PROLOGUE \
-       .data; .align 8; 1: .uaword 0; .uaword 0; \
-       .text; save %sp,-CC64FSZ,%sp; sethi %hi(1b),%o0; call mcount; \
-       or %o0,%lo(1b),%o0; restore
-#else
-#define        _PROF_PROLOGUE \
-       .data; .align 4; 1: .long 0; \
-       .text; save %sp,-96,%sp; sethi %hi(1b),%o0; call mcount; \
-       or %o0,%lo(1b),%o0; restore
-#endif
-#endif
-#else
-#define _PROF_PROLOGUE
-#endif
-
-#define ENTRY(name)            _ENTRY(_C_LABEL(name)); _PROF_PROLOGUE
-#define ENTRY_NOPROFILE(name)  _ENTRY(_C_LABEL(name))
-#define        ASENTRY(name)           _ENTRY(_ASM_LABEL(name)); _PROF_PROLOGUE
-#define        FUNC(name)              ASENTRY(name)
-#define RODATA(name)           .align 4; .text; .globl _C_LABEL(name); \
-                               OTYPE(_C_LABEL(name)); _C_LABEL(name):
-
-
-#define ASMSTR                 .asciz
-
-#define RCSID(name)            .asciz name
-
-#ifdef __ELF__
-#define        WEAK_ALIAS(alias,sym)                                           \
-       .weak alias;                                                    \
-       alias = sym
-#endif
-
-/*
- * WARN_REFERENCES: create a warning if the specified symbol is referenced.
- */
-#ifdef __ELF__
-#ifdef __STDC__
-#define        WARN_REFERENCES(_sym,_msg)                              \
-       .section .gnu.warning. ## _sym ; .ascii _msg ; .text
-#else
-#define        WARN_REFERENCES(_sym,_msg)                              \
-       .section .gnu.warning./**/_sym ; .ascii _msg ; .text
-#endif /* __STDC__ */
-#else
-#ifdef __STDC__
-#define        __STRING(x)                     #x
-#define        WARN_REFERENCES(sym,msg)                                        \
-       .stabs msg ## ,30,0,0,0 ;                                       \
-       .stabs __STRING(_ ## sym) ## ,1,0,0,0
-#else
-#define        __STRING(x)                     "x"
-#define        WARN_REFERENCES(sym,msg)                                        \
-       .stabs msg,30,0,0,0 ;                                           \
-       .stabs __STRING(_/**/sym),1,0,0,0
-#endif /* __STDC__ */
-#endif /* __ELF__ */
-
-#endif /* _ASM_H_ */
diff --git a/klibc/klibc/arch/sparc/include/machine/frame.h b/klibc/klibc/arch/sparc/include/machine/frame.h
deleted file mode 100644 (file)
index b09175c..0000000
+++ /dev/null
@@ -1,138 +0,0 @@
-/*     $NetBSD: frame.h,v 1.4 2001/12/04 00:05:05 darrenr Exp $ */
-
-/*
- * Copyright (c) 1992, 1993
- *     The Regents of the University of California.  All rights reserved.
- *
- * This software was developed by the Computer Systems Engineering group
- * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
- * contributed to Berkeley.
- *
- * All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Lawrence Berkeley Laboratory.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *     @(#)frame.h     8.1 (Berkeley) 6/11/93
- */
-
-#if defined(_KERNEL_OPT)
-#include "opt_sparc_arch.h"
-#endif
-
-/*
- * Sparc stack frame format.
- *
- * Note that the contents of each stack frame may be held only in
- * machine register windows.  In order to get an accurate picture
- * of the frame, you must first force the kernel to write any such
- * windows to the stack.
- */
-#ifndef _LOCORE
-#ifndef SUN4U
-struct frame {
-       int32_t fr_local[8];    /* space to save locals (%l0..%l7) */
-       int32_t fr_arg[6];      /* space to save arguments (%i0..%i5) */
-       struct  frame *fr_fp;   /* space to save frame pointer (%i6) */
-       int32_t fr_pc;          /* space to save return pc (%i7) */
-       /*
-        * SunOS reserves another 8 words here; this is pointless
-        * but we do it for compatibility.
-        */
-       int32_t fr_xxx;         /* `structure return pointer' (unused) */
-       int32_t fr_argd[6];     /* `arg dump area' (lunacy) */
-       int32_t fr_argx[1];     /* arg extension (args 7..n; variable size) */
-};
-#else
-struct frame32 {
-       int32_t fr_local[8];    /* space to save locals (%l0..%l7) */
-       int32_t fr_arg[6];      /* space to save arguments (%i0..%i5) */
-       u_int32_t       fr_fp;  /* space to save frame pointer (%i6) */
-       u_int32_t       fr_pc;  /* space to save return pc (%i7) */
-       /*
-        * SunOS reserves another 8 words here; this is pointless
-        * but we do it for compatibility.
-        */
-       int32_t fr_xxx;         /* `structure return pointer' (unused) */
-       int32_t fr_argd[6];     /* `arg dump area' (lunacy) */
-       int32_t fr_argx[1];     /* arg extension (args 7..n; variable size) */
-};
-#endif
-#endif
-
-/*
- * CCFSZ (C Compiler Frame SiZe) is the size of a stack frame required if
- * a function is to call C code.  It should be just 64, but Sun defined
- * their frame with space to hold arguments 0 through 5 (plus some junk),
- * and varargs routines (such as kprintf) demand this, and gcc uses this
- * area at times anyway.
- */
-#define CCFSZ          96
-
-/*
- * Sparc v9 stack frame format.
- *
- * Note that the contents of each stack frame may be held only in
- * machine register windows.  In order to get an accurate picture
- * of the frame, you must first force the kernel to write any such
- * windows to the stack.
- *
- * V9 frames have an odd bias, so you can tall a v9 frame from
- * a v8 frame by testing the stack pointer's lsb.
- */
-#if !defined(_LOCORE) && !defined(_LIBC)
-struct frame64 {
-       int64_t fr_local[8];    /* space to save locals (%l0..%l7) */
-       int64_t fr_arg[6];      /* space to save arguments (%i0..%i5) */
-       u_int64_t       fr_fp;          /* space to save frame pointer (%i6) */
-       u_int64_t       fr_pc;          /* space to save return pc (%i7) */
-       /*
-        * SVR4 reserves a bunch of extra stuff.
-        */
-       int64_t fr_argd[6];     /* `register save area' (lunacy) */
-       int64_t fr_argx[0];     /* arg extension (args 7..n; variable size) */
-};
-
-#define v9next_frame(f)                ((struct frame64*)(f->fr_fp+BIAS))
-#endif
-
-/*
- * CC64FSZ (C Compiler 64-bit Frame SiZe) is the size of a stack frame used
- * by the compiler in 64-bit mode.  It is (16)*8; space for 8 ins, 8 outs.
- */
-#define CC64FSZ                176
-
-/*
- * v9 stacks all have a bias of 2047 added to the %sp and %fp, so you can easily
- * detect it by testing the register for an odd value.  Why 2K-1 I don't know.
- */
-#define BIAS   (2048-1)
-
diff --git a/klibc/klibc/arch/sparc/include/machine/trap.h b/klibc/klibc/arch/sparc/include/machine/trap.h
deleted file mode 100644 (file)
index 42c3ef6..0000000
+++ /dev/null
@@ -1,141 +0,0 @@
-/*     $NetBSD: trap.h,v 1.11 1999/01/20 00:15:08 pk Exp $ */
-
-/*
- * Copyright (c) 1992, 1993
- *     The Regents of the University of California.  All rights reserved.
- *
- * This software was developed by the Computer Systems Engineering group
- * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
- * contributed to Berkeley.
- *
- * All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Lawrence Berkeley Laboratory.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *     @(#)trap.h      8.1 (Berkeley) 6/11/93
- */
-/*
- * Sun4m support by Aaron Brown, Harvard University.
- * Changes Copyright (c) 1995 The President and Fellows of Harvard College.
- * All rights reserved.
- */
-
-#ifndef        _MACHINE_TRAP_H
-#define        _MACHINE_TRAP_H
-
-/*     trap            vec       (pri) description     */
-#define        T_RESET         0x00    /* (1) not actually vectored; jumps to 0 */
-#define        T_TEXTFAULT     0x01    /* (2) address fault during instr fetch */
-#define        T_ILLINST       0x02    /* (3) illegal instruction */
-#define        T_PRIVINST      0x03    /* (4) privileged instruction */
-#define        T_FPDISABLED    0x04    /* (5) fp instr while fp disabled */
-#define        T_WINOF         0x05    /* (6) register window overflow */
-#define        T_WINUF         0x06    /* (7) register window underflow */
-#define        T_ALIGN         0x07    /* (8) address not properly aligned */
-#define        T_FPE           0x08    /* (9) floating point exception */
-#define        T_DATAFAULT     0x09    /* (10) address fault during data fetch */
-#define        T_TAGOF         0x0a    /* (11) tag overflow */
-/*                     0x0b       unused */
-/*                     0x0c       unused */
-/*                     0x0d       unused */
-/*                     0x0e       unused */
-/*                     0x0f       unused */
-/*                     0x10       unused */
-#define        T_L1INT         0x11    /* (27) level 1 interrupt */
-#define        T_L2INT         0x12    /* (26) level 2 interrupt */
-#define        T_L3INT         0x13    /* (25) level 3 interrupt */
-#define        T_L4INT         0x14    /* (24) level 4 interrupt */
-#define        T_L5INT         0x15    /* (23) level 5 interrupt */
-#define        T_L6INT         0x16    /* (22) level 6 interrupt */
-#define        T_L7INT         0x17    /* (21) level 7 interrupt */
-#define        T_L8INT         0x18    /* (20) level 8 interrupt */
-#define        T_L9INT         0x19    /* (19) level 9 interrupt */
-#define        T_L10INT        0x1a    /* (18) level 10 interrupt */
-#define        T_L11INT        0x1b    /* (17) level 11 interrupt */
-#define        T_L12INT        0x1c    /* (16) level 12 interrupt */
-#define        T_L13INT        0x1d    /* (15) level 13 interrupt */
-#define        T_L14INT        0x1e    /* (14) level 14 interrupt */
-#define        T_L15INT        0x1f    /* (13) level 15 interrupt */
-/*                     0x20       unused */
-/*     through         0x23       unused */
-#define        T_CPDISABLED    0x24    /* (5) coprocessor instr while disabled */
-#define        T_UNIMPLFLUSH   0x25    /* Unimplemented FLUSH */
-/*     through         0x27       unused */
-#define        T_CPEXCEPTION   0x28    /* (9) coprocessor exception */
-/*                     0x29       unused */
-#define T_IDIV0                0x2a    /* divide by zero (from hw [su]div instr) */
-#define T_STOREBUFFAULT        0x2b    /* SuperSPARC: Store buffer copy-back fault */
-/*                     0x2c       unused */
-/*     through         0x7f       unused */
-
-/* beginning of `user' vectors (from trap instructions) - all priority 12 */
-#define        T_SUN_SYSCALL   0x80    /* system call */
-#define        T_BREAKPOINT    0x81    /* breakpoint `instruction' */
-#define        T_DIV0          0x82    /* division routine was handed 0 */
-#define        T_FLUSHWIN      0x83    /* flush windows */
-#define        T_CLEANWIN      0x84    /* provide clean windows */
-#define        T_RANGECHECK    0x85    /* ? */
-#define        T_FIXALIGN      0x86    /* fix up unaligned accesses */
-#define        T_INTOF         0x87    /* integer overflow ? */
-#define        T_SVR4_SYSCALL  0x88    /* SVR4 system call */
-#define        T_BSD_SYSCALL   0x89    /* BSD system call */
-#define        T_KGDB_EXEC     0x8a    /* for kernel gdb */
-
-/* 0x8b..0xff are currently unallocated, except the following */
-#define T_SVR4_GETCC           0xa0
-#define T_SVR4_SETCC           0xa1
-#define T_SVR4_GETPSR          0xa2
-#define T_SVR4_SETPSR          0xa3
-#define T_SVR4_GETHRTIME       0xa4
-#define T_SVR4_GETHRVTIME      0xa5
-#define T_SVR4_GETHRESTIME     0xa7
-
-
-#ifdef _KERNEL                 /* pseudo traps for locore.s */
-#define        T_RWRET         -1      /* need first user window for trap return */
-#define        T_AST           -2      /* no-op, just needed reschedule or profile */
-#endif
-
-/* flags to system call (flags in %g1 along with syscall number) */
-#define        SYSCALL_G2RFLAG 0x400   /* on success, return to %g2 rather than npc */
-#define        SYSCALL_G7RFLAG 0x800   /* use %g7 as above (deprecated) */
-
-/*
- * `software trap' macros to keep people happy (sparc v8 manual says not
- * to set the upper bits).
- */
-#define        ST_BREAKPOINT   (T_BREAKPOINT & 0x7f)
-#define        ST_DIV0         (T_DIV0 & 0x7f)
-#define        ST_FLUSHWIN     (T_FLUSHWIN & 0x7f)
-#define        ST_SYSCALL      (T_SUN_SYSCALL & 0x7f)
-
-#endif /* _MACHINE_TRAP_H_ */
diff --git a/klibc/klibc/arch/sparc/syscall.S b/klibc/klibc/arch/sparc/syscall.S
new file mode 100644 (file)
index 0000000..c0273f7
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * arch/sparc/syscall.S
+ *
+ * Common system-call stub; %g1 already set to syscall number
+ */
+
+       .globl  __syscall_common
+       .type   __syscall_common,#function
+               .align  4
+__syscall_common:
+       t       0x10
+       bcc     1f
+         sethi %hi(errno), %g4
+       or      %g4, %lo(errno), %g4
+       st      %o0,[%g4]
+       mov     -1, %o0
+1:
+               retl
+         nop
diff --git a/klibc/klibc/arch/sparc/sysfork.S b/klibc/klibc/arch/sparc/sysfork.S
new file mode 100644 (file)
index 0000000..a66c76e
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * arch/sparc/sysfork.S
+ *
+ * The fork and vfork system calls are special on sparc[64]:
+ * they return the "other process" pid in %o0 and the
+ * "is child" flag in %o1
+ *
+ * Common system-call stub; %g1 already set to syscall number
+ */
+
+       .globl  __syscall_forkish
+       .type   __syscall_forkish,#function
+               .align  4
+__syscall_forkish:
+       t       0x10
+       sub     %o1, 1, %o1
+       bcc,a   1f
+         and   %o0, %o1, %o0
+       sethi   %hi(errno), %g4
+       or      %g4, %lo(errno), %g4
+       st      %o0,[%g4]
+       mov     -1, %o0
+1:
+               retl
+         nop
diff --git a/klibc/klibc/arch/sparc/sysstub.ph b/klibc/klibc/arch/sparc/sysstub.ph
new file mode 100644 (file)
index 0000000..baad9e3
--- /dev/null
@@ -0,0 +1,25 @@
+# -*- perl -*-
+#
+# arch/sparc32/sysstub.ph
+#
+# Script to generate system call stubs
+#
+
+sub make_sysstub($$$$@) {
+    my($fname, $type, $sname, $stype, @args) = @_;
+
+    $stype = $stype || 'common';
+
+    open(OUT, '>', "syscalls/${fname}.S");
+    print OUT "#include <asm/unistd.h>\n";
+    print OUT "\n";
+    print OUT "\t.type ${fname},\@function\n";
+    print OUT "\t.globl ${fname}\n";
+    print OUT "${fname}:\n";
+    print OUT "\tb __syscall_${stype}\n";
+    print OUT "\t  mov\t__NR_${sname}, %g1\n";
+    print OUT "\t.size ${fname},.-${fname}\n";
+    close(OUT);
+}
+
+1;
index d59f987..06b7953 100644 (file)
@@ -8,6 +8,8 @@
 #
 
 ARCHOBJS = \
-       arch/$(ARCH)/setjmp.o
+       arch/$(ARCH)/setjmp.o \
+       arch/$(ARCH)/syscall.o \
+       arch/$(ARCH)/sysfork.o
 
 archclean:
diff --git a/klibc/klibc/arch/sparc64/include/klibc/archsetjmp.h b/klibc/klibc/arch/sparc64/include/klibc/archsetjmp.h
deleted file mode 100644 (file)
index 022a31e..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * arch/sparc64/include/klibc/archsetjmp.h
- */
-
-#ifndef _KLIBC_ARCHSETJMP_H
-#define _KLIBC_ARCHSETJMP_H
-
-struct __jmp_buf {
-  unsigned long __sp;
-  unsigned long __fp;
-  unsigned long __pc;
-};
-
-typedef struct __jmp_buf jmp_buf[1];
-
-#endif /* _SETJMP_H */
diff --git a/klibc/klibc/arch/sparc64/include/klibc/archsignal.h b/klibc/klibc/arch/sparc64/include/klibc/archsignal.h
deleted file mode 100644 (file)
index f81bd66..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * arch/sparc64/include/klibc/archsignal.h
- *
- * Architecture-specific signal definitions
- *
- */
-
-#ifndef _KLIBC_ARCHSIGNAL_H
-#define _KLIBC_ARCHSIGNAL_H
-
-/* No special stuff for this architecture */
-
-#endif
diff --git a/klibc/klibc/arch/sparc64/include/klibc/archsys.h b/klibc/klibc/arch/sparc64/include/klibc/archsys.h
deleted file mode 100644 (file)
index 651e4f7..0000000
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * arch/sparc64/include/klibc/archsys.h
- *
- * Architecture-specific syscall definitions
- */
-
-#ifndef _KLIBC_ARCHSYS_H
-#define _KLIBC_ARCHSYS_H
-
-/* The Linux 2.5.31 SPARC64 syscall macros are just plain broken */
-
-#undef _syscall0
-#undef _syscall1
-#undef _syscall2
-#undef _syscall3
-#undef _syscall4
-#undef _syscall5
-#undef _syscall6
-
-#define _syscall0(type,name) \
-type name (void) \
-{ \
-  register unsigned long __g1 __asm__ ("g1") = __NR_##name; \
-  register unsigned long __ret __asm__("o0"); \
-  __asm__ __volatile__ ("t 0x6d\n\t" \
-      "bcs,a %%xcc, 1f\n\t" \
-      " st %0,%1\n\t" \
-      "1:" \
-      "movcs %%xcc,-1,%0\n" \
-      : "=&r" (__ret), "+m" (errno) \
-      : "r" (__g1) \
-      : "cc"); \
-  return (type) __ret; \
-}
-
-#define _syscall1(type,name,type1,arg1) \
-type name (type1 arg1) \
-{ \
-  register unsigned long __g1 __asm__ ("g1") = __NR_##name; \
-  register unsigned long __ret __asm__("o0"); \
-  type1 __o0 = (arg1); \
-  __asm__ __volatile__ ("t 0x6d\n\t" \
-      "bcs,a %%xcc, 1f\n\t" \
-      " st %0,%1\n\t" \
-      "1:" \
-      "movcs %%xcc,-1,%0\n" \
-      : "=&r" (__ret), "+m" (errno) \
-      : "0" (__o0), "r" (__g1) \
-      : "cc"); \
-  return (type) __ret; \
-}
-
-#define _syscall2(type,name,type1,arg1,type2,arg2) \
-type name (type1 arg1,type2 arg2) \
-{ \
-  register unsigned long __g1 __asm__ ("g1") = __NR_##name; \
-  register unsigned long __ret __asm__("o0"); \
-  type1 __o0 = (arg1); \
-  register type2 __o1 __asm__ ("o1") = (arg2); \
-  __asm__ __volatile__ ("t 0x6d\n\t" \
-      "bcs,a %%xcc, 1f\n\t" \
-      " st %0,%1\n\t" \
-      "1:" \
-      "movcs %%xcc,-1,%0\n" \
-      : "=&r" (__ret), "+m" (errno) \
-      : "0" (__o0), "r" (__o1), "r" (__g1) \
-      : "cc"); \
-  return (type) __ret; \
-}
-
-#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
-type name (type1 arg1,type2 arg2,type3 arg3) \
-{ \
-  register unsigned long __g1 __asm__ ("g1") = __NR_##name; \
-  register unsigned long __ret __asm__("o0"); \
-  type1 __o0 = (arg1); \
-  register type2 __o1 __asm__ ("o1") = (arg2); \
-  register type3 __o2 __asm__ ("o2") = (arg3); \
-  __asm__ __volatile__ ("t 0x6d\n\t" \
-      "bcs,a %%xcc, 1f\n\t" \
-      " st %0,%1\n\t" \
-      "1:" \
-      "movcs %%xcc,-1,%0\n" \
-      : "=&r" (__ret), "+m" (errno) \
-      : "0" (__o0), "r" (__o1), "r" (__o2), "r" (__g1) \
-      : "cc"); \
-  return (type) __ret; \
-}
-
-#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
-type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4) \
-{ \
-  register unsigned long __g1 __asm__ ("g1") = __NR_##name; \
-  register unsigned long __ret __asm__("o0"); \
-  type1 __o0 = (arg1); \
-  register type2 __o1 __asm__ ("o1") = (arg2); \
-  register type3 __o2 __asm__ ("o2") = (arg3); \
-  register type4 __o3 __asm__ ("o3") = (arg4); \
-  __asm__ __volatile__ ("t 0x6d\n\t" \
-      "bcs,a %%xcc, 1f\n\t" \
-      " st %0,%1\n\t" \
-      "1:" \
-      "movcs %%xcc,-1,%0\n" \
-      : "=&r" (__ret), "+m" (errno) \
-      : "0" (__o0), "r" (__o1), "r" (__o2), "r" (__o3), "r" (__g1) \
-      : "cc"); \
-  return (type) __ret; \
-}
-
-#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,\
-  type5,arg5) \
-type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
-{ \
-  register unsigned long __g1 __asm__ ("g1") = __NR_##name; \
-  register unsigned long __ret __asm__("o0"); \
-  type1 __o0 = (arg1); \
-  register type2 __o1 __asm__ ("o1") = (arg2); \
-  register type3 __o2 __asm__ ("o2") = (arg3); \
-  register type4 __o3 __asm__ ("o3") = (arg4); \
-  register type5 __o4 __asm__ ("o4") = (arg5); \
-  __asm__ __volatile__ ("t 0x6d\n\t" \
-      "bcs,a %%xcc, 1f\n\t" \
-      " st %0,%1\n\t" \
-      "1:" \
-      "movcs %%xcc,-1,%0\n" \
-      : "=&r" (__ret), "+m" (errno) \
-      : "0" (__o0), "r" (__o1), "r" (__o2), "r" (__o3), "r" (__o4), \
-        "r" (__g1) \
-      : "cc"); \
-  return (type) __ret; \
-}
-
-#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
-  type5,arg5,type6,arg6) \
-type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5,type6 arg6) \
-{ \
-  register unsigned long __g1 __asm__ ("g1") = __NR_##name; \
-  register unsigned long __ret __asm__("o0"); \
-  type1 __o0 = (arg1); \
-  register type2 __o1 __asm__ ("o1") = (arg2); \
-  register type3 __o2 __asm__ ("o2") = (arg3); \
-  register type4 __o3 __asm__ ("o3") = (arg4); \
-  register type5 __o4 __asm__ ("o4") = (arg5); \
-  register type6 __o5 __asm__ ("o5") = (arg6); \
-  __asm__ __volatile__ ("t 0x6d\n\t" \
-      "bcs,a %%xcc, 1f\n\t" \
-      " st %0,%1\n\t" \
-      "1:" \
-      "movcs %%xcc,-1,%0\n" \
-      : "=&r" (__ret), "+m" (errno) \
-      : "0" (__o0), "r" (__o1), "r" (__o2), "r" (__o3), "r" (__o4), \
-        "r" (__o5), "r" (__g1) \
-      : "cc"); \
-  return (type) __ret; \
-}
-
-#endif /* _KLIBC_ARCHSYS_H */
diff --git a/klibc/klibc/arch/sparc64/syscall.S b/klibc/klibc/arch/sparc64/syscall.S
new file mode 100644 (file)
index 0000000..7ab9d95
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * arch/sparc64/syscall.S
+ *
+ * Common system-call stub; %g1 already set to syscall number
+ */
+
+       .globl  __syscall_common
+       .type   __syscall_common,#function
+               .align  4
+__syscall_common:
+       t       0x6d
+       bcc     %xcc, 1f
+         sethi %hi(errno), %g4
+       or      %g4, %lo(errno), %g4
+       st      %o0,[%g4]
+1:
+               retl
+         movcs %xcc, -1, %o0
diff --git a/klibc/klibc/arch/sparc64/sysfork.S b/klibc/klibc/arch/sparc64/sysfork.S
new file mode 100644 (file)
index 0000000..739c35e
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * arch/sparc64/sysfork.S
+ *
+ * The fork and vfork system calls are special on sparc[64]:
+ * they return the "other process" pid in %o0 and the
+ * "is child" flag in %o1
+ *
+ * Common system-call stub; %g1 already set to syscall number
+ *
+ * IS THIS CORRECT FOR SPARC64?
+ */
+
+       .globl  __syscall_forkish
+       .type   __syscall_forkish,#function
+               .align  4
+__syscall_forkish:
+       t       0x6d
+       sub     %o1, 1, %o1
+       bcc,a   %xcc, 1f
+         and   %o0, %o1, %o0
+       sethi   %hi(errno), %g4
+       or      %g4, %lo(errno), %g4
+       st      %o0,[%g4]
+1:
+               retl
+         movcs %xcc, -1, %o0
diff --git a/klibc/klibc/arch/sparc64/sysstub.ph b/klibc/klibc/arch/sparc64/sysstub.ph
new file mode 100644 (file)
index 0000000..2ef2c6b
--- /dev/null
@@ -0,0 +1,25 @@
+# -*- perl -*-
+#
+# arch/sparc64/sysstub.ph
+#
+# Script to generate system call stubs
+#
+
+sub make_sysstub($$$$@) {
+    my($fname, $type, $sname, $stype, @args) = @_;
+
+    $stype = $stype || 'common';
+
+    open(OUT, '>', "syscalls/${fname}.S");
+    print OUT "#include <asm/unistd.h>\n";
+    print OUT "\n";
+    print OUT "\t.type ${fname},\@function\n";
+    print OUT "\t.globl ${fname}\n";
+    print OUT "${fname}:\n";
+    print OUT "\tb __syscall_${stype}\n";
+    print OUT "\t  mov\t__NR_${sname}, %g1\n";
+    print OUT "\t.size ${fname},.-${fname}\n";
+    close(OUT);
+}
+
+1;
index ecb14cc..f3c8741 100644 (file)
@@ -9,8 +9,14 @@
 # Blatantly copied and modified from i386 version by Mats Petersson, AMD.
 #
 
+#
+# NOTE: -fno-asynchronous-unwind-tables produce significantly smaller
+# binaries (20% smaller), but makes the code completely useless for
+# debugging using gdb.
+#
 ARCHREQFLAGS = -m64
-OPTFLAGS     = -Os -fomit-frame-pointer -falign-functions=0 -falign-jumps=0 -falign-loops=0
+OPTFLAGS     = -Os -fno-asynchronous-unwind-tables -fomit-frame-pointer \
+               -falign-functions=0 -falign-jumps=0 -falign-loops=0
 BITSIZE      = 64
 LDFLAGS      = -m elf_x86_64
 
index c84443f..d6cc120 100644 (file)
@@ -9,7 +9,8 @@
 
 ARCHOBJS = \
        arch/$(ARCH)/exits.o \
-       arch/$(ARCH)/setjmp.o
+       arch/$(ARCH)/setjmp.o \
+       arch/$(ARCH)/syscall.o
 
 ARCHSOOBJS = $(patsubst %.o,%.lo,$(ARCHOBJS))
 
diff --git a/klibc/klibc/arch/x86_64/include/klibc/archsetjmp.h b/klibc/klibc/arch/x86_64/include/klibc/archsetjmp.h
deleted file mode 100644 (file)
index 90d0a0d..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * arch/x86_64/include/klibc/archsetjmp.h
- */
-
-#ifndef _KLIBC_ARCHSETJMP_H
-#define _KLIBC_ARCHSETJMP_H
-
-struct __jmp_buf {
-  unsigned long __rbx;
-  unsigned long __rsp;
-  unsigned long __rbp;
-  unsigned long __r12;
-  unsigned long __r13;
-  unsigned long __r14;
-  unsigned long __r15;
-  unsigned long __rip;
-};
-
-typedef struct __jmp_buf jmp_buf[1];
-
-#endif /* _SETJMP_H */
diff --git a/klibc/klibc/arch/x86_64/include/klibc/archsignal.h b/klibc/klibc/arch/x86_64/include/klibc/archsignal.h
deleted file mode 100644 (file)
index 74e82e1..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * arch/x86_64/include/klibc/archsignal.h
- *
- * Architecture-specific signal definitions
- *
- */
-
-#ifndef _KLIBC_ARCHSIGNAL_H
-#define _KLIBC_ARCHSIGNAL_H
-
-/* No special stuff for this architecture */
-
-#endif
diff --git a/klibc/klibc/arch/x86_64/include/klibc/archsys.h b/klibc/klibc/arch/x86_64/include/klibc/archsys.h
deleted file mode 100644 (file)
index 2ec72cd..0000000
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * arch/x86_64/include/klibc/archsys.h
- *
- * Architecture-specific syscall definitions
- */
-
-#ifndef _KLIBC_ARCHSYS_H
-#define _KLIBC_ARCHSYS_H
-
-/* The x86-64 syscall headers are needlessly inefficient */
-
-#undef _syscall0
-#undef _syscall1
-#undef _syscall2
-#undef _syscall3
-#undef _syscall4
-#undef _syscall5
-#undef _syscall6
-
-#define _syscall0(type,name) \
-type name (void) \
-{ \
-long __res; \
-__asm__ volatile (__syscall \
-        : "=a" (__res) \
-        : "0" (__NR_##name) \
-        : __syscall_clobber); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall1(type,name,type1,arg1) \
-type name (type1 arg1) \
-{ \
-long __res; \
-__asm__ volatile (__syscall \
-        : "=a" (__res) \
-        : "0" (__NR_##name),"D" (arg1) \
-        : __syscall_clobber); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall2(type,name,type1,arg1,type2,arg2) \
-type name (type1 arg1,type2 arg2) \
-{ \
-long __res; \
-__asm__ volatile (__syscall \
-        : "=a" (__res) \
-        : "0" (__NR_##name),"D" (arg1),"S" (arg2) \
-        : __syscall_clobber); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
-type name (type1 arg1,type2 arg2,type3 arg3) \
-{ \
-long __res; \
-__asm__ volatile (__syscall \
-        : "=a" (__res) \
-        : "0" (__NR_##name),"D" (arg1),"S" (arg2), \
-          "d" (arg3) \
-        : __syscall_clobber); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
-type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4) \
-{ \
-long __res; \
-register type4 __r10 asm("%r10") = arg4; \
-__asm__ volatile (__syscall \
-        : "=a" (__res) \
-        : "0" (__NR_##name),"D" (arg1),"S" (arg2), \
-          "d" (arg3),"r" (__r10) \
-        : __syscall_clobber); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
-          type5,arg5) \
-type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
-{ \
-long __res; \
-register type4 __r10 asm("%r10") = arg4; \
-register type5 __r8  asm("%r8")  = arg5; \
-__asm__ volatile (__syscall \
-        : "=a" (__res) \
-        : "0" (__NR_##name),"D" (arg1),"S" (arg2), \
-          "d" (arg3),"r" (__r10),"r" (__r8) \
-        : __syscall_clobber); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
-          type5,arg5,type6,arg6) \
-type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5,type6 arg6) \
-{ \
-long __res; \
-register type4 __r10 asm("%r10") = arg4; \
-register type5 __r8  asm("%r8")  = arg5; \
-register type6 __r9  asm("%r9")  = arg6; \
-__asm__ volatile (__syscall \
-        : "=a" (__res) \
-        : "0" (__NR_##name),"D" (arg1),"S" (arg2), \
-          "d" (arg3),"r" (__r10),"r" (__r8), "r" (__r9) \
-        : __syscall_clobber); \
-__syscall_return(type,__res); \
-}
-
-#endif /* _KLIBC_ARCHSYS_H */
diff --git a/klibc/klibc/arch/x86_64/include/sys/io.h b/klibc/klibc/arch/x86_64/include/sys/io.h
deleted file mode 100644 (file)
index 4a0ae44..0000000
+++ /dev/null
@@ -1,126 +0,0 @@
-#ident "$Id: io.h,v 1.1 2004/01/25 01:34:29 hpa Exp $"
-/* ----------------------------------------------------------------------- *
- *   
- *   Copyright 2004 H. Peter Anvin - All Rights Reserved
- *
- *   Permission is hereby granted, free of charge, to any person
- *   obtaining a copy of this software and associated documentation
- *   files (the "Software"), to deal in the Software without
- *   restriction, including without limitation the rights to use,
- *   copy, modify, merge, publish, distribute, sublicense, and/or
- *   sell copies of the Software, and to permit persons to whom
- *   the Software is furnished to do so, subject to the following
- *   conditions:
- *   
- *   The above copyright notice and this permission notice shall
- *   be included in all copies or substantial portions of the Software.
- *   
- *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
- *   OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- *   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
- *   HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- *   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- *   FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- *   OTHER DEALINGS IN THE SOFTWARE.
- *
- * ----------------------------------------------------------------------- */
-
-/*
- * sys/io.h for the i386 architecture
- *
- * Basic I/O macros
- */
-
-#ifndef _SYS_IO_H
-#define _SYS_IO_H 1
-
-/* I/O-related system calls */
-
-int iopl(int);
-int ioperm(unsigned long, unsigned long, int);
-
-/* Basic I/O macros */
-
-static __inline__ void
-outb(unsigned char __v, unsigned short __p)
-{
-  asm volatile("outb %0,%1" : : "a" (__v), "dN" (__p));
-}
-
-static __inline__ void
-outw(unsigned short __v, unsigned short __p)
-{
-  asm volatile("outw %0,%1" : : "a" (__v), "dN" (__p));
-}
-
-static __inline__ void
-outl(unsigned int __v, unsigned short __p)
-{
-  asm volatile("outl %0,%1" : : "a" (__v), "dN" (__p));
-}
-
-static __inline__ unsigned char
-inb(unsigned short __p)
-{
-  unsigned char __v;
-  asm volatile("inb %1,%0" : "=a" (__v) : "dN" (__p));
-  return v;
-}
-
-static __inline__ unsigned short
-inw(unsigned short __p)
-{
-  unsigned short __v;
-  asm volatile("inw %1,%0" : "=a" (__v) : "dN" (__p));
-  return v;
-}
-
-static __inline__ unsigned int
-inl(unsigned short __p)
-{
-  unsigned int __v;
-  asm volatile("inl %1,%0" : "=a" (__v) : "dN" (__p));
-  return v;
-}
-
-/* String I/O macros */
-
-static __inline__ void
-outsb (unsigned short __p, const void *__d, unsigned long __n)
-{
-  asm volatile("cld; rep; outsb" : "+S" (__d), "+c" (__n) : "d" (__p));
-}
-
-static __inline__ void
-outsw (unsigned short __p, const void *__d, unsigned long __n)
-{
-  asm volatile("cld; rep; outsw" : "+S" (__d), "+c" (__n) : "d" (__p));
-}
-
-static __inline__ void
-outsl (unsigned short __p, const void *__d, unsigned long __n)
-{
-  asm volatile("cld; rep; outsl" : "+S" (__d), "+c" (__n) : "d" (__p));
-}
-
-
-static __inline__ void
-insb (unsigned short __p, void *__d, unsigned long __n)
-{
-  asm volatile("cld; rep; insb" : "+D" (__d), "+c" (__n) : "d" (__p));
-}
-
-static __inline__ void
-insw (unsigned short __p, void *__d, unsigned long __n)
-{
-  asm volatile("cld; rep; insw" : "+D" (__d), "+c" (__n) : "d" (__p));
-}
-
-static __inline__ void
-insl (unsigned short __p, void *__d, unsigned long __n)
-{
-  asm volatile("cld; rep; insl" : "+D" (__d), "+c" (__n) : "d" (__p));
-}
-
-#endif /* _SYS_IO_H */
diff --git a/klibc/klibc/arch/x86_64/syscall.S b/klibc/klibc/arch/x86_64/syscall.S
new file mode 100644 (file)
index 0000000..f2c74ae
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * arch/x86-64/syscall.S
+ *
+ * Common tail-handling code for system calls.
+ *
+ * The arguments are in the standard argument registers; the system
+ * call number in %eax.
+ */
+       .text
+       .align  4
+       .globl  __syscall_common
+       .type   __syscall_common,@function
+__syscall_common:
+       movq    %rcx,%r10               # The kernel uses %r10 istf %rcx
+       syscall
+
+       cmpq    $-4095,%rax
+       jb      1f
+
+       # Error return, must set errno
+       negl    %eax
+       movl    %eax,errno(%rip)        # errno is type int, so 32 bits
+       orq     $-1,%rax                # orq $-1 smaller than movq $-1
+
+1:
+       ret
+
+       .size   __syscall_common,.-__syscall_common
diff --git a/klibc/klibc/arch/x86_64/sysstub.ph b/klibc/klibc/arch/x86_64/sysstub.ph
new file mode 100644 (file)
index 0000000..07af122
--- /dev/null
@@ -0,0 +1,23 @@
+# -*- perl -*-
+#
+# arch/x86_64/sysstub.ph
+#
+# Script to generate system call stubs
+#
+
+sub make_sysstub($$$$@) {
+    my($fname, $type, $sname, $stype, @args) = @_;
+
+    open(OUT, '>', "syscalls/${fname}.S");
+    print OUT "#include <asm/unistd.h>\n";
+    print OUT "\n";
+    print OUT "\t.type ${fname},\@function\n";
+    print OUT "\t.globl ${fname}\n";
+    print OUT "${fname}:\n";
+    print OUT "\tmovl \$__NR_${sname},%eax\n"; # Zero-extends to 64 bits
+    print OUT "\tjmp __syscall_common\n";
+    print OUT "\t.size ${fname},.-${fname}\n";
+    close(OUT);
+}
+
+1;
diff --git a/klibc/klibc/asprintf.c b/klibc/klibc/asprintf.c
new file mode 100644 (file)
index 0000000..457d34b
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * asprintf.c
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+
+int asprintf(char **bufp, const char *format, ...)
+{
+  va_list ap, ap1;
+  int rv;
+  int bytes;
+  char *p;
+
+  va_start(ap, format);
+  va_copy(ap1, ap);
+
+  bytes = vsnprintf(NULL, 0, format, ap1);
+  va_end(ap1);
+
+  *bufp = p = malloc(bytes+1);
+  if ( !p )
+    return -1;
+  
+  rv = vsnprintf(p, bytes, format, ap);
+  va_end(ap);
+
+  return rv;
+}
index c7adc98..acfa05a 100644 (file)
 const unsigned char __ctypes[257] = {
   0,                           /* EOF */
 
-  0,                           /* control character */
-  0,                           /* control character */
-  0,                           /* control character */
-  0,                           /* control character */
-  0,                           /* control character */
-  0,                           /* control character */
-  0,                           /* control character */
-  0,                           /* control character */
-  __ctype_space,               /* BS */
-  __ctype_space,               /* TAB */
-  __ctype_space,               /* LF */
-  __ctype_space,               /* VT */
-  __ctype_space,               /* FF */
-  __ctype_space,               /* CR */
-  0,                           /* control character */
+  __ctype_cntrl,               /* control character */
+  __ctype_cntrl,               /* control character */
+  __ctype_cntrl,               /* control character */
+  __ctype_cntrl,               /* control character */
+  __ctype_cntrl,               /* control character */
+  __ctype_cntrl,               /* control character */
+  __ctype_cntrl,               /* control character */
+  __ctype_cntrl,               /* control character */
+  __ctype_cntrl|__ctype_space, /* BS */
+  __ctype_cntrl|__ctype_space, /* TAB */
+  __ctype_cntrl|__ctype_space, /* LF */
+  __ctype_cntrl|__ctype_space, /* VT */
+  __ctype_cntrl|__ctype_space, /* FF */
+  __ctype_cntrl|__ctype_space, /* CR */
+  __ctype_cntrl,               /* control character */
 
-  0,                           /* control character */
-  0,                           /* control character */
-  0,                           /* control character */
-  0,                           /* control character */
-  0,                           /* control character */
-  0,                           /* control character */
-  0,                           /* control character */
-  0,                           /* control character */
-  0,                           /* control character */
-  0,                           /* control character */
-  0,                           /* control character */
-  0,                           /* control character */
-  0,                           /* control character */
-  0,                           /* control character */
-  0,                           /* control character */
-  0,                           /* control character */
-  0,                           /* control character */
+  __ctype_cntrl,               /* control character */
+  __ctype_cntrl,               /* control character */
+  __ctype_cntrl,               /* control character */
+  __ctype_cntrl,               /* control character */
+  __ctype_cntrl,               /* control character */
+  __ctype_cntrl,               /* control character */
+  __ctype_cntrl,               /* control character */
+  __ctype_cntrl,               /* control character */
+  __ctype_cntrl,               /* control character */
+  __ctype_cntrl,               /* control character */
+  __ctype_cntrl,               /* control character */
+  __ctype_cntrl,               /* control character */
+  __ctype_cntrl,               /* control character */
+  __ctype_cntrl,               /* control character */
+  __ctype_cntrl,               /* control character */
+  __ctype_cntrl,               /* control character */
+  __ctype_cntrl,               /* control character */
   
-  __ctype_space|__ctype_print, /* space */
+  __ctype_print|__ctype_space, /* space */
   __ctype_print|__ctype_punct, /* punctuation */
   __ctype_print|__ctype_punct, /* punctuation */
   __ctype_print|__ctype_punct, /* punctuation */
@@ -61,16 +61,16 @@ const unsigned char __ctypes[257] = {
   __ctype_print|__ctype_punct, /* punctuation */
   __ctype_print|__ctype_punct, /* punctuation */
 
-  __ctype_digit|__ctype_xdigit|__ctype_print, /* digit */
-  __ctype_digit|__ctype_xdigit|__ctype_print, /* digit */
-  __ctype_digit|__ctype_xdigit|__ctype_print, /* digit */
-  __ctype_digit|__ctype_xdigit|__ctype_print, /* digit */
-  __ctype_digit|__ctype_xdigit|__ctype_print, /* digit */
-  __ctype_digit|__ctype_xdigit|__ctype_print, /* digit */
-  __ctype_digit|__ctype_xdigit|__ctype_print, /* digit */
-  __ctype_digit|__ctype_xdigit|__ctype_print, /* digit */
-  __ctype_digit|__ctype_xdigit|__ctype_print, /* digit */
-  __ctype_digit|__ctype_xdigit|__ctype_print, /* digit */
+  __ctype_print|__ctype_digit|__ctype_xdigit, /* digit */
+  __ctype_print|__ctype_digit|__ctype_xdigit, /* digit */
+  __ctype_print|__ctype_digit|__ctype_xdigit, /* digit */
+  __ctype_print|__ctype_digit|__ctype_xdigit, /* digit */
+  __ctype_print|__ctype_digit|__ctype_xdigit, /* digit */
+  __ctype_print|__ctype_digit|__ctype_xdigit, /* digit */
+  __ctype_print|__ctype_digit|__ctype_xdigit, /* digit */
+  __ctype_print|__ctype_digit|__ctype_xdigit, /* digit */
+  __ctype_print|__ctype_digit|__ctype_xdigit, /* digit */
+  __ctype_print|__ctype_digit|__ctype_xdigit, /* digit */
   __ctype_print|__ctype_punct, /* punctuation */
   __ctype_print|__ctype_punct, /* punctuation */
   __ctype_print|__ctype_punct, /* punctuation */
@@ -79,33 +79,33 @@ const unsigned char __ctypes[257] = {
   __ctype_print|__ctype_punct, /* punctuation */
 
   __ctype_print|__ctype_punct, /* punctuation */
-  __ctype_upper|__ctype_print|__ctype_xdigit, /* A-F */
-  __ctype_upper|__ctype_print|__ctype_xdigit, /* A-F */
-  __ctype_upper|__ctype_print|__ctype_xdigit, /* A-F */
-  __ctype_upper|__ctype_print|__ctype_xdigit, /* A-F */
-  __ctype_upper|__ctype_print|__ctype_xdigit, /* A-F */
-  __ctype_upper|__ctype_print|__ctype_xdigit, /* A-F */
-  __ctype_upper|__ctype_print, /* G-Z */
-  __ctype_upper|__ctype_print, /* G-Z */
-  __ctype_upper|__ctype_print, /* G-Z */
-  __ctype_upper|__ctype_print, /* G-Z */
-  __ctype_upper|__ctype_print, /* G-Z */
-  __ctype_upper|__ctype_print, /* G-Z */
-  __ctype_upper|__ctype_print, /* G-Z */
-  __ctype_upper|__ctype_print, /* G-Z */
-  __ctype_upper|__ctype_print, /* G-Z */
+  __ctype_print|__ctype_upper|__ctype_xdigit, /* A-F */
+  __ctype_print|__ctype_upper|__ctype_xdigit, /* A-F */
+  __ctype_print|__ctype_upper|__ctype_xdigit, /* A-F */
+  __ctype_print|__ctype_upper|__ctype_xdigit, /* A-F */
+  __ctype_print|__ctype_upper|__ctype_xdigit, /* A-F */
+  __ctype_print|__ctype_upper|__ctype_xdigit, /* A-F */
+  __ctype_print|__ctype_upper, /* G-Z */
+  __ctype_print|__ctype_upper, /* G-Z */
+  __ctype_print|__ctype_upper, /* G-Z */
+  __ctype_print|__ctype_upper, /* G-Z */
+  __ctype_print|__ctype_upper, /* G-Z */
+  __ctype_print|__ctype_upper, /* G-Z */
+  __ctype_print|__ctype_upper, /* G-Z */
+  __ctype_print|__ctype_upper, /* G-Z */
+  __ctype_print|__ctype_upper, /* G-Z */
 
-  __ctype_upper|__ctype_print, /* G-Z */
-  __ctype_upper|__ctype_print, /* G-Z */
-  __ctype_upper|__ctype_print, /* G-Z */
-  __ctype_upper|__ctype_print, /* G-Z */
-  __ctype_upper|__ctype_print, /* G-Z */
-  __ctype_upper|__ctype_print, /* G-Z */
-  __ctype_upper|__ctype_print, /* G-Z */
-  __ctype_upper|__ctype_print, /* G-Z */
-  __ctype_upper|__ctype_print, /* G-Z */
-  __ctype_upper|__ctype_print, /* G-Z */
-  __ctype_upper|__ctype_print, /* G-Z */
+  __ctype_print|__ctype_upper, /* G-Z */
+  __ctype_print|__ctype_upper, /* G-Z */
+  __ctype_print|__ctype_upper, /* G-Z */
+  __ctype_print|__ctype_upper, /* G-Z */
+  __ctype_print|__ctype_upper, /* G-Z */
+  __ctype_print|__ctype_upper, /* G-Z */
+  __ctype_print|__ctype_upper, /* G-Z */
+  __ctype_print|__ctype_upper, /* G-Z */
+  __ctype_print|__ctype_upper, /* G-Z */
+  __ctype_print|__ctype_upper, /* G-Z */
+  __ctype_print|__ctype_upper, /* G-Z */
   __ctype_print|__ctype_punct, /* punctuation */
   __ctype_print|__ctype_punct, /* punctuation */
   __ctype_print|__ctype_punct, /* punctuation */
@@ -113,74 +113,74 @@ const unsigned char __ctypes[257] = {
   __ctype_print|__ctype_punct, /* punctuation */
 
   __ctype_print|__ctype_punct, /* punctuation */
-  __ctype_lower|__ctype_print|__ctype_xdigit, /* a-f */
-  __ctype_lower|__ctype_print|__ctype_xdigit, /* a-f */
-  __ctype_lower|__ctype_print|__ctype_xdigit, /* a-f */
-  __ctype_lower|__ctype_print|__ctype_xdigit, /* a-f */
-  __ctype_lower|__ctype_print|__ctype_xdigit, /* a-f */
-  __ctype_lower|__ctype_print|__ctype_xdigit, /* a-f */
-  __ctype_lower|__ctype_print, /* g-z */
-  __ctype_lower|__ctype_print, /* g-z */
-  __ctype_lower|__ctype_print, /* g-z */
-  __ctype_lower|__ctype_print, /* g-z */
-  __ctype_lower|__ctype_print, /* g-z */
-  __ctype_lower|__ctype_print, /* g-z */
-  __ctype_lower|__ctype_print, /* g-z */
-  __ctype_lower|__ctype_print, /* g-z */
-  __ctype_lower|__ctype_print, /* g-z */
+  __ctype_print|__ctype_lower|__ctype_xdigit, /* a-f */
+  __ctype_print|__ctype_lower|__ctype_xdigit, /* a-f */
+  __ctype_print|__ctype_lower|__ctype_xdigit, /* a-f */
+  __ctype_print|__ctype_lower|__ctype_xdigit, /* a-f */
+  __ctype_print|__ctype_lower|__ctype_xdigit, /* a-f */
+  __ctype_print|__ctype_lower|__ctype_xdigit, /* a-f */
+  __ctype_print|__ctype_lower, /* g-z */
+  __ctype_print|__ctype_lower, /* g-z */
+  __ctype_print|__ctype_lower, /* g-z */
+  __ctype_print|__ctype_lower, /* g-z */
+  __ctype_print|__ctype_lower, /* g-z */
+  __ctype_print|__ctype_lower, /* g-z */
+  __ctype_print|__ctype_lower, /* g-z */
+  __ctype_print|__ctype_lower, /* g-z */
+  __ctype_print|__ctype_lower, /* g-z */
 
-  __ctype_lower|__ctype_print, /* g-z */
-  __ctype_lower|__ctype_print, /* g-z */
-  __ctype_lower|__ctype_print, /* g-z */
-  __ctype_lower|__ctype_print, /* g-z */
-  __ctype_lower|__ctype_print, /* g-z */
-  __ctype_lower|__ctype_print, /* g-z */
-  __ctype_lower|__ctype_print, /* g-z */
-  __ctype_lower|__ctype_print, /* g-z */
-  __ctype_lower|__ctype_print, /* g-z */
-  __ctype_lower|__ctype_print, /* g-z */
-  __ctype_lower|__ctype_print, /* g-z */
+  __ctype_print|__ctype_lower, /* g-z */
+  __ctype_print|__ctype_lower, /* g-z */
+  __ctype_print|__ctype_lower, /* g-z */
+  __ctype_print|__ctype_lower, /* g-z */
+  __ctype_print|__ctype_lower, /* g-z */
+  __ctype_print|__ctype_lower, /* g-z */
+  __ctype_print|__ctype_lower, /* g-z */
+  __ctype_print|__ctype_lower, /* g-z */
+  __ctype_print|__ctype_lower, /* g-z */
+  __ctype_print|__ctype_lower, /* g-z */
+  __ctype_print|__ctype_lower, /* g-z */
   __ctype_print|__ctype_punct, /* punctuation */
   __ctype_print|__ctype_punct, /* punctuation */
   __ctype_print|__ctype_punct, /* punctuation */
   __ctype_print|__ctype_punct, /* punctuation */
-  0,                           /* control character */
+  __ctype_cntrl,                               /* control character */
 
-  0,                           /* control character */
-  0,                           /* control character */
-  0,                           /* control character */
-  0,                           /* control character */
-  0,                           /* control character */
-  0,                           /* control character */
-  0,                           /* control character */
-  0,                           /* control character */
-  0,                           /* control character */
-  0,                           /* control character */
-  0,                           /* control character */
-  0,                           /* control character */
-  0,                           /* control character */
-  0,                           /* control character */
-  0,                           /* control character */
-  0,                           /* control character */
+  __ctype_cntrl,                               /* control character */
+  __ctype_cntrl,                               /* control character */
+  __ctype_cntrl,                               /* control character */
+  __ctype_cntrl,                               /* control character */
+  __ctype_cntrl,                               /* control character */
+  __ctype_cntrl,                               /* control character */
+  __ctype_cntrl,                               /* control character */
+  __ctype_cntrl,                               /* control character */
+  __ctype_cntrl,                               /* control character */
+  __ctype_cntrl,                               /* control character */
+  __ctype_cntrl,                               /* control character */
+  __ctype_cntrl,                               /* control character */
+  __ctype_cntrl,                               /* control character */
+  __ctype_cntrl,                               /* control character */
+  __ctype_cntrl,                               /* control character */
+  __ctype_cntrl,                               /* control character */
 
-  0,                           /* control character */
-  0,                           /* control character */
-  0,                           /* control character */
-  0,                           /* control character */
-  0,                           /* control character */
-  0,                           /* control character */
-  0,                           /* control character */
-  0,                           /* control character */
-  0,                           /* control character */
-  0,                           /* control character */
-  0,                           /* control character */
-  0,                           /* control character */
-  0,                           /* control character */
-  0,                           /* control character */
-  0,                           /* control character */
-  0,                           /* control character */
+  __ctype_cntrl,                               /* control character */
+  __ctype_cntrl,                               /* control character */
+  __ctype_cntrl,                               /* control character */
+  __ctype_cntrl,                               /* control character */
+  __ctype_cntrl,                               /* control character */
+  __ctype_cntrl,                               /* control character */
+  __ctype_cntrl,                               /* control character */
+  __ctype_cntrl,                               /* control character */
+  __ctype_cntrl,                               /* control character */
+  __ctype_cntrl,                               /* control character */
+  __ctype_cntrl,                               /* control character */
+  __ctype_cntrl,                               /* control character */
+  __ctype_cntrl,                               /* control character */
+  __ctype_cntrl,                               /* control character */
+  __ctype_cntrl,                               /* control character */
+  __ctype_cntrl,                               /* control character */
 
-  __ctype_space|__ctype_print, /* NBSP */
+  __ctype_print|__ctype_space, /* NBSP */
   __ctype_print|__ctype_punct, /* punctuation */
   __ctype_print|__ctype_punct, /* punctuation */
   __ctype_print|__ctype_punct, /* punctuation */
@@ -214,71 +214,71 @@ const unsigned char __ctypes[257] = {
   __ctype_print|__ctype_punct, /* punctuation */
   __ctype_print|__ctype_punct, /* punctuation */
 
-  __ctype_upper|__ctype_print, /* upper accented */
-  __ctype_upper|__ctype_print, /* upper accented */
-  __ctype_upper|__ctype_print, /* upper accented */
-  __ctype_upper|__ctype_print, /* upper accented */
-  __ctype_upper|__ctype_print, /* upper accented */
-  __ctype_upper|__ctype_print, /* upper accented */
-  __ctype_upper|__ctype_print, /* upper accented */
-  __ctype_upper|__ctype_print, /* upper accented */
-  __ctype_upper|__ctype_print, /* upper accented */
-  __ctype_