[klibc] [patch] klibc: merge s390 and s390x

Heiko Carstens heiko.carstens at de.ibm.com
Thu May 11 00:35:30 PDT 2006


Merge s390 and s390x into s390. Compiled and tested on s390/s390x and i386.
Also cross compilation for s390/s390x tested. This patch shouldn't break the
build of any architecture.

Signed-off-by: Heiko Carstens <heiko.carstens at de.ibm.com>
---

 Makefile                                  |    1 
 scripts/Kbuild.install                    |    4 +-
 scripts/Kbuild.klibc                      |    6 ++--
 usr/include/arch/s390/klibc/archsetjmp.h  |   12 ++++++++
 usr/include/arch/s390/klibc/archstat.h    |   23 ++++++++++++++++
 usr/include/arch/s390/klibc/archsys.h     |    2 -
 usr/include/arch/s390x/klibc/archconfig.h |   14 ----------
 usr/include/arch/s390x/klibc/archsetjmp.h |   15 ----------
 usr/include/arch/s390x/klibc/archsignal.h |   14 ----------
 usr/include/arch/s390x/klibc/archstat.h   |   26 -------------------
 usr/include/arch/s390x/klibc/archsys.h    |   41 ------------------------------
 usr/klibc/Kbuild                          |    6 ++--
 usr/klibc/arch/s390/MCONFIG               |    7 ++++-
 usr/klibc/arch/s390/Makefile.inc          |   17 ++++++++++--
 usr/klibc/arch/s390/crt0.S                |   10 +++++++
 usr/klibc/arch/s390/mmap.c                |   36 ++++++++++++++++++++++++++
 usr/klibc/arch/s390/setjmp.S              |   34 ++++++++++++++++++++++++
 usr/klibc/arch/s390/sysstub.ph            |   11 +++++++-
 usr/klibc/arch/s390x/MCONFIG              |   13 ---------
 usr/klibc/arch/s390x/Makefile.inc         |   18 -------------
 usr/klibc/arch/s390x/crt0.S               |   21 ---------------
 usr/klibc/arch/s390x/mmap.c               |   41 ------------------------------
 usr/klibc/arch/s390x/setjmp.S             |   36 --------------------------
 usr/klibc/arch/s390x/syscall.c            |   16 -----------
 usr/klibc/arch/s390x/sysstub.ph           |   28 --------------------
 usr/klibc/syscalls/Kbuild                 |    4 +-
 26 files changed, 157 insertions(+), 299 deletions(-)

diff -purN a/Makefile b/Makefile
--- a/Makefile	2006-05-11 08:09:08.000000000 +0200
+++ b/Makefile	2006-05-11 08:10:07.000000000 +0200
@@ -26,6 +26,7 @@ NOSTDINC_FLAGS := -nostdlib -nostdinc -i
 
 ARCH	          := $(shell uname -m | sed -e s/i.86/i386/ -e s/parisc64/parisc/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/)
 export KLIBCARCH  ?= $(ARCH)
+export KLIBCARCHDIR := $(shell echo $(KLIBCARCH) | sed -e s/s390x/s390/)
 
 export HOSTCC     := gcc
 export HOSTCFLAGS := -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
diff -purN a/scripts/Kbuild.install b/scripts/Kbuild.install
--- a/scripts/Kbuild.install	2006-05-11 08:09:08.000000000 +0200
+++ b/scripts/Kbuild.install	2006-05-11 08:10:07.000000000 +0200
@@ -95,7 +95,7 @@ header:
 	$(Q)mkdir -p $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)include
 	$(Q)mkdir -p $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)lib
 	$(Q)mkdir -p $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)bin
-	$(Q)set -e ; for d in linux scsi asm-$(KLIBCARCH) asm-generic $(ASMKLIBCARCH); do \
+	$(Q)set -e ; for d in linux scsi asm-$(KLIBCARCHDIR) asm-generic $(ASMKLIBCARCH); do \
 	  mkdir -p $(INSTALLROOT)$(INSTALLDIR)/$(KLIBCCROSS)include/$$d ; \
 	  for r in $(KLIBCKERNELSRC)/include $(KLIBCKERNELOBJ)/include \
 	           $(KLIBCKERNELOBJ)/include2 ; do \
@@ -104,7 +104,7 @@ header:
 	          $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)include/$$d/. ; \
 	  done ; \
 	done
-	$(Q)cd $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)include && ln -sf asm-$(KLIBCARCH) asm
+	$(Q)cd $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)include && ln -sf asm-$(KLIBCARCHDIR) asm
 	$(Q)cp -rf usr/include/. $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)include/.
 	$(Q)$(install-data) $(srctree)/klcc/klcc.1 $(INSTALLROOT)$(mandir)/man1/$(KCROSS)klcc.1
 	$(Q)$(install-bin) $(objtree)/klcc/$(KCROSS)klcc $(INSTALLROOT)$(bindir)
diff -purN a/scripts/Kbuild.klibc b/scripts/Kbuild.klibc
--- a/scripts/Kbuild.klibc	2006-05-11 08:09:08.000000000 +0200
+++ b/scripts/Kbuild.klibc	2006-05-11 08:10:07.000000000 +0200
@@ -57,7 +57,7 @@ KLIBCBITSIZE      :=
 KLIBCLDFLAGS      :=
 
 # Arch specific definitions for klibc
-include $(KLIBCSRC)/arch/$(KLIBCARCH)/MCONFIG
+include $(KLIBCSRC)/arch/$(KLIBCARCHDIR)/MCONFIG
 
 # klibc version
 KLIBCMAJOR        := $(shell cut -d. -f1 $(srctree)/usr/klibc/version)
@@ -74,7 +74,7 @@ KLIBCOBJCOPY	 := $(OBJCOPY)
 KLIBCOBJDUMP	 := $(OBJDUMP)
 
 # klibc include paths
-KLIBCCPPFLAGS    := -I$(KLIBCINC)/arch/$(KLIBCARCH)         \
+KLIBCCPPFLAGS    := -I$(KLIBCINC)/arch/$(KLIBCARCHDIR)         \
                     -I$(KLIBCINC)/bits$(KLIBCBITSIZE)  \
                     -I$(KLIBCINC)
 # kernel include paths
@@ -93,7 +93,7 @@ KLIBCAFLAGS      := -D__ASSEMBLY__ $(KLI
 KLIBCSTRIPFLAGS  := --strip-all -R .comment -R .note
 
 KLIBCLIBGCC      := $(shell $(KLIBCCC) $(KLIBCCFLAGS) --print-libgcc)
-KLIBCCRT0        := $(KLIBCOBJ)/arch/$(KLIBCARCH)/crt0.o
+KLIBCCRT0        := $(KLIBCOBJ)/arch/$(KLIBCARCHDIR)/crt0.o
 KLIBCLIBC        := $(KLIBCOBJ)/libc.a
 KLIBCCRTSHARED   := $(KLIBCOBJ)/interp.o
 KLIBCLIBCSHARED  := $(KLIBCOBJ)/libc.so
diff -purN a/usr/include/arch/s390/klibc/archsetjmp.h b/usr/include/arch/s390/klibc/archsetjmp.h
--- a/usr/include/arch/s390/klibc/archsetjmp.h	2006-05-11 08:09:08.000000000 +0200
+++ b/usr/include/arch/s390/klibc/archsetjmp.h	2006-05-11 08:10:07.000000000 +0200
@@ -5,6 +5,8 @@
 #ifndef _KLIBC_ARCHSETJMP_H
 #define _KLIBC_ARCHSETJMP_H
 
+#ifndef __s390x__
+
 struct __jmp_buf {
   uint32_t __gregs[10]; /* general registers r6-r15 */
   uint64_t __fpregs[2]; /* fp registers f4 and f6   */
@@ -12,4 +14,14 @@ struct __jmp_buf {
 
 typedef struct __jmp_buf jmp_buf[1];
 
+#else /* __s390x__ */
+
+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 /* __s390x__ */
 #endif /* _SETJMP_H */
diff -purN a/usr/include/arch/s390/klibc/archstat.h b/usr/include/arch/s390/klibc/archstat.h
--- a/usr/include/arch/s390/klibc/archstat.h	2006-05-11 08:09:08.000000000 +0200
+++ b/usr/include/arch/s390/klibc/archstat.h	2006-05-11 08:10:07.000000000 +0200
@@ -5,6 +5,8 @@
 
 #define _STATBUF_ST_NSEC
 
+#ifndef __s390x__
+
 /* This matches struct stat64 in glibc2.1, hence the absolutely
  * insane amounts of padding around dev_t's.
  */
@@ -30,4 +32,25 @@ struct stat {
         unsigned long long	st_ino;
 };
 
+#else /* __s390x__ */
+
+struct stat {
+	__stdev64	(st_dev);
+	unsigned long	st_ino;
+	unsigned long	st_nlink;
+	unsigned int	st_mode;
+	unsigned int	st_uid;
+	unsigned int	st_gid;
+	unsigned int	__pad1;
+	__stdev64	(st_rdev);
+	unsigned long	st_size;
+	struct timespec	st_atim;
+	struct timespec	st_mtim;
+	struct timespec	st_ctim;
+	unsigned long	st_blksize;
+	long		st_blocks;
+	unsigned long	__unused[3];
+};
+
+#endif /* __s390x__ */
 #endif
diff -purN a/usr/include/arch/s390/klibc/archsys.h b/usr/include/arch/s390/klibc/archsys.h
--- a/usr/include/arch/s390/klibc/archsys.h	2006-05-11 08:09:08.000000000 +0200
+++ b/usr/include/arch/s390/klibc/archsys.h	2006-05-11 08:10:07.000000000 +0200
@@ -28,7 +28,7 @@ type name(type1 arg1, type2 arg2, type3 
 	long __res;					     \
 	__asm__ __volatile__ (               	             \
                 "    svc %b1\n"                              \
-                "    lr  %0,2"                               \
+                "    la  %0,2"                               \
                 : "=d" (__res)                               \
                 : "i" (__NR_##name),                         \
                   "d" (__argp)				     \
diff -purN a/usr/include/arch/s390x/klibc/archconfig.h b/usr/include/arch/s390x/klibc/archconfig.h
--- a/usr/include/arch/s390x/klibc/archconfig.h	2006-05-11 08:09:08.000000000 +0200
+++ b/usr/include/arch/s390x/klibc/archconfig.h	1970-01-01 01:00:00.000000000 +0100
@@ -1,14 +0,0 @@
-/*
- * include/arch/s390x/klibc/archconfig.h
- *
- * See include/klibc/sysconfig.h for the options that can be set in
- * this file.
- *
- */
-
-#ifndef _KLIBC_ARCHCONFIG_H
-#define _KLIBC_ARCHCONFIG_H
-
-/* All defaults */
-
-#endif /* _KLIBC_ARCHCONFIG_H */
diff -purN a/usr/include/arch/s390x/klibc/archsetjmp.h b/usr/include/arch/s390x/klibc/archsetjmp.h
--- a/usr/include/arch/s390x/klibc/archsetjmp.h	2006-05-11 08:09:08.000000000 +0200
+++ b/usr/include/arch/s390x/klibc/archsetjmp.h	1970-01-01 01:00:00.000000000 +0100
@@ -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 -purN a/usr/include/arch/s390x/klibc/archsignal.h b/usr/include/arch/s390x/klibc/archsignal.h
--- a/usr/include/arch/s390x/klibc/archsignal.h	2006-05-11 08:09:08.000000000 +0200
+++ b/usr/include/arch/s390x/klibc/archsignal.h	1970-01-01 01:00:00.000000000 +0100
@@ -1,14 +0,0 @@
-/*
- * arch/s390x/include/klibc/archsignal.h
- *
- * Architecture-specific signal definitions
- *
- */
-
-#ifndef _KLIBC_ARCHSIGNAL_H
-#define _KLIBC_ARCHSIGNAL_H
-
-#include <asm/signal.h>
-/* No special stuff for this architecture */
-
-#endif
diff -purN a/usr/include/arch/s390x/klibc/archstat.h b/usr/include/arch/s390x/klibc/archstat.h
--- a/usr/include/arch/s390x/klibc/archstat.h	2006-05-11 08:09:08.000000000 +0200
+++ b/usr/include/arch/s390x/klibc/archstat.h	1970-01-01 01:00:00.000000000 +0100
@@ -1,26 +0,0 @@
-#ifndef _KLIBC_ARCHSTAT_H
-#define _KLIBC_ARCHSTAT_H
-
-#include <klibc/stathelp.h>
-
-#define _STATBUF_ST_NSEC
-
-struct stat {
-	__stdev64	(st_dev);
-        unsigned long	st_ino;
-        unsigned long	st_nlink;
-        unsigned int	st_mode;
-        unsigned int	st_uid;
-        unsigned int	st_gid;
-        unsigned int	__pad1;
-        __stdev64	(st_rdev);
-        unsigned long	st_size;
-	struct timespec	st_atim;
-	struct timespec	st_mtim;
-	struct timespec	st_ctim;
-        unsigned long	st_blksize;
-        long		st_blocks;
-        unsigned long	__unused[3];
-};
-
-#endif
diff -purN a/usr/include/arch/s390x/klibc/archsys.h b/usr/include/arch/s390x/klibc/archsys.h
--- a/usr/include/arch/s390x/klibc/archsys.h	2006-05-11 08:09:08.000000000 +0200
+++ b/usr/include/arch/s390x/klibc/archsys.h	1970-01-01 01:00:00.000000000 +0100
@@ -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 -purN a/usr/klibc/Kbuild b/usr/klibc/Kbuild
--- a/usr/klibc/Kbuild	2006-05-11 08:09:08.000000000 +0200
+++ b/usr/klibc/Kbuild	2006-05-11 08:10:07.000000000 +0200
@@ -68,14 +68,14 @@ KLIBCCFLAGS += -DDYNAMIC_CRC_TABLE
 
 #####
 # Add any architecture-specific rules
-include $(obj)/arch/$(KLIBCARCH)/Makefile.inc
+include $(obj)/arch/$(KLIBCARCHDIR)/Makefile.inc
 
 #####
 # Shared definitions
 LIB      := libc.a
 SOLIB    := libc.so
 SOHASH   := klibc.so
-CRT0     := arch/$(KLIBCARCH)/crt0.o
+CRT0     := arch/$(KLIBCARCHDIR)/crt0.o
 INTERP_O := interp.o
 
 always   := $(CRT0) $(LIB) $(SOLIB) $(SOHASH) $(INTERP_O)
@@ -87,7 +87,7 @@ INTERP_O := $(call objectify,$(INTERP_O)
 
 SOLIBHASH = $(shell cat $(SOLIB).hash)
 
-targets  += arch/$(KLIBCARCH)/crt0.o
+targets  += arch/$(KLIBCARCHDIR)/crt0.o
 targets  += $(libc-y) $(KLIBCARCHOBJS)
 
 # Generate syscall stubs
diff -purN a/usr/klibc/arch/s390/MCONFIG b/usr/klibc/arch/s390/MCONFIG
--- a/usr/klibc/arch/s390/MCONFIG	2006-05-11 08:09:08.000000000 +0200
+++ b/usr/klibc/arch/s390/MCONFIG	2006-05-11 08:10:07.000000000 +0200
@@ -8,6 +8,11 @@
 #
 
 KLIBCOPTFLAGS = -Os
-KLIBCBITSIZE  = 32
+
+ifneq ("$(KLIBCARCH)", "s390x")
+	KLIBCBITSIZE  = 32
+else
+	KLIBCBITSIZE  = 64
+endif
 
 KLIBCSHAREDFLAGS	= -Ttext 0x40000200
diff -purN a/usr/klibc/arch/s390/Makefile.inc b/usr/klibc/arch/s390/Makefile.inc
--- a/usr/klibc/arch/s390/Makefile.inc	2006-05-11 08:09:08.000000000 +0200
+++ b/usr/klibc/arch/s390/Makefile.inc	2006-05-11 08:10:07.000000000 +0200
@@ -7,16 +7,27 @@
 # accordingly.
 #
 
+ifneq ("$(KLIBCARCH)", "s390x")
+
 KLIBCARCHOBJS = \
-	arch/$(KLIBCARCH)/setjmp.o \
-	arch/$(KLIBCARCH)/mmap.o \
-	arch/$(KLIBCARCH)/syscall.o \
+	arch/$(KLIBCARCHDIR)/setjmp.o \
+	arch/$(KLIBCARCHDIR)/mmap.o \
+	arch/$(KLIBCARCHDIR)/syscall.o \
 	libgcc/__divdi3.o \
 	libgcc/__moddi3.o \
 	libgcc/__udivdi3.o \
 	libgcc/__umoddi3.o \
 	libgcc/__udivmoddi4.o
 
+else
+
+KLIBCARCHOBJS = \
+	arch/$(KLIBCARCHDIR)/setjmp.o \
+	arch/$(KLIBCARCHDIR)/mmap.o \
+	arch/$(KLIBCARCHDIR)/syscall.o
+
+endif
+
 KLIBCARCHSOOBJS = $(patsubst %.o,%.lo,$(KLIBCARCHOBJS))
 
 
diff -purN a/usr/klibc/arch/s390/crt0.S b/usr/klibc/arch/s390/crt0.S
--- a/usr/klibc/arch/s390/crt0.S	2006-05-11 08:09:08.000000000 +0200
+++ b/usr/klibc/arch/s390/crt0.S	2006-05-11 08:10:07.000000000 +0200
@@ -11,6 +11,9 @@
 	.align 4
 	.type _start, at function
 	.globl _start
+
+#ifndef __s390x__
+
 _start:
 	lr	%r2,%r15
 	lhi	%r3,0
@@ -21,5 +24,12 @@ _start:
 	br	%r1
 .L1:
 	.long	__libc_init
+#else
 
+_start:
+	lgr	%r2,%r15
+	lghi	%r3,0
+	aghi	%r15,-160
+	jg	__libc_init
+#endif
 	.size _start,.-_start
diff -purN a/usr/klibc/arch/s390/mmap.c b/usr/klibc/arch/s390/mmap.c
--- a/usr/klibc/arch/s390/mmap.c	2006-05-11 08:09:08.000000000 +0200
+++ b/usr/klibc/arch/s390/mmap.c	2006-05-11 08:10:07.000000000 +0200
@@ -10,6 +10,8 @@ struct mmap_arg_struct {
 	unsigned long offset;
 };
 
+#ifndef __s390x__
+
 void * __mmap2(void * addr, size_t len, int prot, int flags,
 						 int fd, long offset)
 {
@@ -39,3 +41,37 @@ void * __mmap2(void * addr, size_t len, 
 	}
 	return (void *)__res;
 }
+
+#else /* __s390x__ */
+
+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;
+}
+
+#endif /* __s390x__ */
diff -purN a/usr/klibc/arch/s390/setjmp.S b/usr/klibc/arch/s390/setjmp.S
--- a/usr/klibc/arch/s390/setjmp.S	2006-05-11 08:09:08.000000000 +0200
+++ b/usr/klibc/arch/s390/setjmp.S	2006-05-11 08:10:07.000000000 +0200
@@ -8,6 +8,9 @@
 	.align 4
 	.globl setjmp
 	.type setjmp, @function
+
+#ifndef __s390x__
+
 setjmp:
 	stm	%r6,%r15,0(%r2)		# save all general registers
 	std	%f4,40(%r2)		# save fp registers f4 and f6
@@ -30,3 +33,34 @@ longjmp:
 	br	%r14			# return to restored address
 
 	.size longjmp,.-longjmp
+
+#else
+
+setjmp:
+	stmg	%r6,%r15,0(%r2)		# save all general registers
+	std	%f1,80(%r2)		# save fp registers f4 and f6
+	std	%f3,88(%r2)
+	std	%f5,96(%r2)
+	std	%f7,104(%r2)
+	lghi	%r2,0			# return 0
+	br	%r14
+
+	.size setjmp,.-setjmp
+
+	.text
+	.align 4
+	.globl longjmp
+	.type longjmp, @function
+longjmp:
+	lgr	%r1,%r2			# jmp_buf
+	lgr	%r2,%r3			# return value
+	ld	%f7,104(%r1)		# restore all saved registers
+	ld	%f5,96(%r1)
+	ld	%f3,88(%r1)
+	ld	%f1,80(%r1)
+	lmg	%r6,%r15,0(%r1)
+	br	%r14			# return to restored address
+
+	.size longjmp,.-longjmp
+
+#endif
diff -purN a/usr/klibc/arch/s390/sysstub.ph b/usr/klibc/arch/s390/sysstub.ph
--- a/usr/klibc/arch/s390/sysstub.ph	2006-05-11 08:09:08.000000000 +0200
+++ b/usr/klibc/arch/s390/sysstub.ph	2006-05-11 08:10:07.000000000 +0200
@@ -17,13 +17,22 @@ sub make_sysstub($$$$$@) {
     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 "\tla %r1,__NR_${sname}\n";
     print OUT "\tsvc 0\n";
     print OUT ".endif\n";
+
+    print OUT "#ifndef __s390x__\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 "#else\n";
+
+    print OUT "\tbrasl %r3,__syscall_common\n";
+
+    print OUT "#endif\n";
     print OUT "\t.size ${fname},.-${fname}\n";
     close(OUT);
 }
diff -purN a/usr/klibc/arch/s390x/MCONFIG b/usr/klibc/arch/s390x/MCONFIG
--- a/usr/klibc/arch/s390x/MCONFIG	2006-05-11 08:09:08.000000000 +0200
+++ b/usr/klibc/arch/s390x/MCONFIG	1970-01-01 01:00:00.000000000 +0100
@@ -1,13 +0,0 @@
-# -*- makefile -*-
-#
-# arch/s390x/MCONFIG
-#
-# Special rules for this architecture.  Note that this is actually
-# included from the main Makefile, and that pathnames should be
-# accordingly.
-#
-
-KLIBCOPTFLAGS = -Os
-KLIBCBITSIZE  = 64
-
-KLIBCSHAREDFLAGS	= -Ttext 0x40000200
diff -purN a/usr/klibc/arch/s390x/Makefile.inc b/usr/klibc/arch/s390x/Makefile.inc
--- a/usr/klibc/arch/s390x/Makefile.inc	2006-05-11 08:09:08.000000000 +0200
+++ b/usr/klibc/arch/s390x/Makefile.inc	1970-01-01 01:00:00.000000000 +0100
@@ -1,18 +0,0 @@
-# -*- makefile -*-
-#
-# arch/s390x/Makefile.inc
-#
-# Special rules for this architecture.  Note that this is actually
-# included from the main Makefile, and that pathnames should be
-# accordingly.
-#
-
-KLIBCARCHOBJS = \
-	arch/$(KLIBCARCH)/setjmp.o \
-	arch/$(KLIBCARCH)/mmap.o \
-	arch/$(KLIBCARCH)/syscall.o
-
-KLIBCARCHSOOBJS = $(patsubst %.o,%.lo,$(KLIBCARCHOBJS))
-
-
-archclean:
diff -purN a/usr/klibc/arch/s390x/crt0.S b/usr/klibc/arch/s390x/crt0.S
--- a/usr/klibc/arch/s390x/crt0.S	2006-05-11 08:09:08.000000000 +0200
+++ b/usr/klibc/arch/s390x/crt0.S	1970-01-01 01:00:00.000000000 +0100
@@ -1,21 +0,0 @@
-#
-# arch/s390/crt0.S
-#
-# Does arch-specific initialization and invokes __libc_init
-# with the appropriate arguments.
-#
-# See __static_init.c or __shared_init.c for the expected
-# arguments.
-#
-
-	.text
-	.align 4
-	.type _start, at function
-	.globl _start
-_start:
-	lgr	%r2,%r15
-	lghi	%r3,0
-	aghi	%r15,-160
-	jg	__libc_init
-
-	.size _start,.-_start
diff -purN a/usr/klibc/arch/s390x/mmap.c b/usr/klibc/arch/s390x/mmap.c
--- a/usr/klibc/arch/s390x/mmap.c	2006-05-11 08:09:08.000000000 +0200
+++ b/usr/klibc/arch/s390x/mmap.c	1970-01-01 01:00:00.000000000 +0100
@@ -1,41 +0,0 @@
-#include <sys/types.h>
-#include <linux/unistd.h>
-
-struct mmap_arg_struct {
-	unsigned long addr;
-	unsigned long len;
-	unsigned long prot;
-	unsigned long flags;
-	unsigned long fd;
-	unsigned long offset;
-};
-
-void * mmap(void * addr, size_t len, int prot, int flags,
-						 int fd, off_t offset)
-{
-	struct mmap_arg_struct args = {
-		(unsigned long) addr,
-		(unsigned long) len,
-		(unsigned long) prot,
-		(unsigned long) flags,
-		(unsigned long) fd,
-		(unsigned long) offset,
-	};
-
-	register struct mmap_arg_struct *__arg1 asm("2") = &args;
-	register long __svcres asm("2");
-	unsigned long __res;
-
-	__asm__ __volatile__ (
-		"    svc %b1\n"
-		: "=d" (__svcres)
-		: "i" (__NR_mmap),
-		  "0" (__arg1)
-		: "1", "cc", "memory");
-	__res = __svcres;
-	if (__res >= (unsigned long)-125) {
-		errno = -__res;
-		__res = -1;
-	}
-	return (void *)__res;
-}
diff -purN a/usr/klibc/arch/s390x/setjmp.S b/usr/klibc/arch/s390x/setjmp.S
--- a/usr/klibc/arch/s390x/setjmp.S	2006-05-11 08:09:08.000000000 +0200
+++ b/usr/klibc/arch/s390x/setjmp.S	1970-01-01 01:00:00.000000000 +0100
@@ -1,36 +0,0 @@
-#
-# arch/s390x/setjmp.S
-#
-# setjmp/longjmp for the s390x architecture
-#
-
-	.text
-	.align 4
-	.globl setjmp
-	.type setjmp, @function
-setjmp:
-	stmg	%r6,%r15,0(%r2)		# save all general registers
-	std	%f1,80(%r2)		# save fp registers f4 and f6
-	std	%f3,88(%r2)
-	std	%f5,96(%r2)
-	std	%f7,104(%r2)
-	lghi	%r2,0			# return 0
-	br	%r14
-
-	.size setjmp,.-setjmp
-
-	.text
-	.align 4
-	.globl longjmp
-	.type longjmp, @function
-longjmp:
-	lgr	%r1,%r2			# jmp_buf
-	lgr	%r2,%r3			# return value
-	ld	%f7,104(%r1)		# restore all saved registers
-	ld	%f5,96(%r1)
-	ld	%f3,88(%r1)
-	ld	%f1,80(%r1)
-	lmg	%r6,%r15,0(%r1)
-	br	%r14			# return to restored address
-
-	.size longjmp,.-longjmp
diff -purN a/usr/klibc/arch/s390x/syscall.c b/usr/klibc/arch/s390x/syscall.c
--- a/usr/klibc/arch/s390x/syscall.c	2006-05-11 08:09:08.000000000 +0200
+++ b/usr/klibc/arch/s390x/syscall.c	1970-01-01 01:00:00.000000000 +0100
@@ -1,16 +0,0 @@
-/*
- * arch/s390x/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>
-
-unsigned long __syscall_common(unsigned long err)
-{
-	if (err < -4095UL)
-		return err;
-	errno = -err;
-	return -1;
-}
diff -purN a/usr/klibc/arch/s390x/sysstub.ph b/usr/klibc/arch/s390x/sysstub.ph
--- a/usr/klibc/arch/s390x/sysstub.ph	2006-05-11 08:09:08.000000000 +0200
+++ b/usr/klibc/arch/s390x/sysstub.ph	1970-01-01 01:00:00.000000000 +0100
@@ -1,28 +0,0 @@
-# -*- perl -*-
-#
-# arch/s390x/sysstub.ph
-#
-# Script to generate system call stubs
-#
-
-sub make_sysstub($$$$$@) {
-    my($outputdir, $fname, $type, $sname, $stype, @args) = @_;
-
-    open(OUT, '>', "${outputdir}/${fname}.S");
-    print OUT "#include <asm/unistd.h>\n";
-    print OUT "\n";
-    print OUT "\t.type ${fname},\@function\n";
-    print OUT "\t.globl ${fname}\n";
-    print OUT "${fname}:\n";
-    print OUT ".if __NR_${sname} < 256\n";
-    print OUT "\tsvc __NR_${sname}\n";
-    print OUT ".else\n";
-    print OUT "\tlghi %r1,__NR_${sname}\n";
-    print OUT "\tsvc 0\n";
-    print OUT ".endif\n";
-    print OUT "\tbrasl %r3,__syscall_common\n";
-    print OUT "\t.size ${fname},.-${fname}\n";
-    close(OUT);
-}
-
-1;
diff -purN a/usr/klibc/syscalls/Kbuild b/usr/klibc/syscalls/Kbuild
--- a/usr/klibc/syscalls/Kbuild	2006-05-11 08:09:08.000000000 +0200
+++ b/usr/klibc/syscalls/Kbuild	2006-05-11 08:10:07.000000000 +0200
@@ -53,14 +53,14 @@ $(obj)/syscalls.nrs: $(KLIBCINC)/sys/sys
 quiet_cmd_syscalls = GEN     $@
       cmd_syscalls = mkdir -p $(KLIBCINC)/klibc/;                           \
                      $(PERL) $(KLIBCSRC)/syscalls.pl $(obj)/SYSCALLS.i      \
-                             $(KLIBCSRC)/arch/$(KLIBCARCH)/sysstub.ph            \
+                             $(KLIBCSRC)/arch/$(KLIBCARCHDIR)/sysstub.ph            \
                              $(KLIBCARCH) $(KLIBCBITSIZE) $(obj)/syscalls.nrs    \
                              $(obj)                                         \
                              $(KLIBCINC)/klibc/havesyscall.h > $@           \
                              || rm -f $@
 
 $(obj)/syscalls.mk: $(KLIBCSRC)/syscalls.pl $(obj)/SYSCALLS.i \
-                    $(KLIBCSRC)/arch/$(KLIBCARCH)/sysstub.ph       \
+                    $(KLIBCSRC)/arch/$(KLIBCARCHDIR)/sysstub.ph       \
                     $(call objectify, $(syscall-objs:.o=.S))  \
                     $(KLIBCSRC)/syscommon.h $(obj)/syscalls.nrs
 	$(call cmd,syscalls)



More information about the klibc mailing list