[klibc] [patch] klibc: merge s390/s390x 3rd try

Heiko Carstens heiko.carstens at de.ibm.com
Fri May 26 04:30:00 PDT 2006


From: Heiko Carstens <heiko.carstens at de.ibm.com>

Merge s390 and s390x into s390. Patch is against current linux-2.6-klibc
tree and seems to work.
Adding the following line to the standalone klibc main Makefile will make
this work for the standalone version too:

export KLIBCARCHDIR := $(shell echo $(KLIBCARCH) | sed -e s/s390x/s390/)

Or, if wanted, I will send a patch for the standalone klibc as well.

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

 Makefile                                  |    3 +-
 arch/s390/Makefile                        |    4 ++
 scripts/Kbuild.klibc                      |    9 +++---
 usr/include/arch/s390/klibc/archsetjmp.h  |   11 ++++++++
 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               |   12 ++++++++
 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               |   38 ---------------------------
 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, 166 insertions(+), 296 deletions(-)

diff -purN a/Makefile b/Makefile
--- a/Makefile	2006-05-26 12:07:05.000000000 +0200
+++ b/Makefile	2006-05-26 12:13:39.000000000 +0200
@@ -180,6 +180,7 @@ UTS_MACHINE	:= $(ARCH)
 
 # Architecture used to compile user-space code
 KLIBCARCH	?= $(ARCH)
+KLIBCARCHDIR	?= $(KLIBCARCH)
 
 # klibc definitions
 export KLIBCINC := usr/include
@@ -326,7 +327,7 @@ export VERSION PATCHLEVEL SUBLEVEL KERNE
 export KLIBCARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD
 export CC CPP AR RANLIB NM STRIP OBJCOPY OBJDUMP MAKE AWK GENKSYMS
 export PERL UTS_MACHINE HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK
-export CHECKFLAGS
+export CHECKFLAGS KLIBCARCHDIR
 
 export CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS
 export CFLAGS CFLAGS_KERNEL CFLAGS_MODULE 
diff -purN a/arch/s390/Makefile b/arch/s390/Makefile
--- a/arch/s390/Makefile	2006-05-26 12:07:06.000000000 +0200
+++ b/arch/s390/Makefile	2006-05-26 12:03:06.000000000 +0200
@@ -20,6 +20,7 @@ AFLAGS		+= -m31
 UTS_MACHINE	:= s390
 STACK_SIZE	:= 8192
 CHECKFLAGS	+= -D__s390__
+KLIBCARCH	:= s390
 else
 LDFLAGS		:= -m elf64_s390
 MODFLAGS	+= -fpic -D__PIC__
@@ -28,8 +29,11 @@ AFLAGS		+= -m64
 UTS_MACHINE	:= s390x
 STACK_SIZE	:= 16384
 CHECKFLAGS	+= -D__s390__ -D__s390x__
+KLIBCARCH	:= s390x
 endif
 
+KLIBCARCHDIR	:= s390
+
 cflags-$(CONFIG_MARCH_G5)   += $(call cc-option,-march=g5)
 cflags-$(CONFIG_MARCH_Z900) += $(call cc-option,-march=z900)
 cflags-$(CONFIG_MARCH_Z990) += $(call cc-option,-march=z990)
diff -purN a/scripts/Kbuild.klibc b/scripts/Kbuild.klibc
--- a/scripts/Kbuild.klibc	2006-05-26 12:07:19.000000000 +0200
+++ b/scripts/Kbuild.klibc	2006-05-26 12:03:06.000000000 +0200
@@ -55,9 +55,10 @@ KLIBCWARNFLAGS    := -W -Wall -Wno-sign-
 KLIBCSHAREDFLAGS  :=
 KLIBCBITSIZE      :=
 KLIBCLDFLAGS      :=
+KLIBCCFLAGS       :=
 
 # Arch specific definitions for klibc
-include $(KLIBCSRC)/arch/$(KLIBCARCH)/MCONFIG
+include $(KLIBCSRC)/arch/$(KLIBCARCHDIR)/MCONFIG
 
 # include/asm-* architecture
 KLIBCASMARCH	  ?= $(KLIBCARCH)
@@ -77,7 +78,7 @@ KLIBCOBJCOPY	 := $(OBJCOPY)
 KLIBCOBJDUMP	 := $(OBJDUMP)
 
 # klibc include paths
-KLIBCCPPFLAGS    := -I$(KLIBCINC)/arch/$(KLIBCARCH)	\
+KLIBCCPPFLAGS    := -I$(KLIBCINC)/arch/$(KLIBCARCHDIR)	\
                     -I$(KLIBCINC)/bits$(KLIBCBITSIZE)	\
 		    -I$(KLIBCOBJ)/../include		\
                     -I$(KLIBCINC)
@@ -92,14 +93,14 @@ KLIBCDEFS        := -D__KLIBC__=$(KLIBCM
 		    -D__KLIBC_MINOR__=$(KLIBCMINOR)    \
 		    -D_BITSIZE=$(KLIBCBITSIZE)
 KLIBCCPPFLAGS    += $(KLIBCDEFS)
-KLIBCCFLAGS      := $(KLIBCCPPFLAGS) $(KLIBCREQFLAGS) $(KLIBCARCHREQFLAGS)  \
+KLIBCCFLAGS      += $(KLIBCCPPFLAGS) $(KLIBCREQFLAGS) $(KLIBCARCHREQFLAGS)  \
                     $(KLIBCOPTFLAGS) $(KLIBCWARNFLAGS)
 KLIBCAFLAGS      := -D__ASSEMBLY__ $(KLIBCCFLAGS)
 KLIBCSTRIPFLAGS  := --strip-all -R .comment -R .note
 
 KLIBCLIBGCC_DEF  := $(shell $(KLIBCCC) $(KLIBCCFLAGS) --print-libgcc)
 KLIBCLIBGCC	 ?= $(KLIBCLIBGCC_DEF)
-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-26 12:07:20.000000000 +0200
+++ b/usr/include/arch/s390/klibc/archsetjmp.h	2006-05-26 12:03:06.000000000 +0200
@@ -5,11 +5,22 @@
 #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   */
 };
 
+#else /* __s390x__ */
+
+struct __jmp_buf {
+	uint64_t __gregs[10]; /* general registers r6-r15 */
+	uint64_t __fpregs[4]; /* fp registers f1, f3, f5, f7 */
+};
+
+#endif /* __s390x__ */
+
 typedef struct __jmp_buf jmp_buf[1];
 
 #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-26 12:07:20.000000000 +0200
+++ b/usr/include/arch/s390/klibc/archstat.h	2006-05-26 12:03:06.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-26 12:07:20.000000000 +0200
+++ b/usr/include/arch/s390/klibc/archsys.h	2006-05-26 12:03:06.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-26 12:07:20.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-26 12:07:20.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-26 12:07:20.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-26 12:07:20.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-26 12:07:20.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-26 12:07:20.000000000 +0200
+++ b/usr/klibc/Kbuild	2006-05-26 12:03:06.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-26 12:07:20.000000000 +0200
+++ b/usr/klibc/arch/s390/MCONFIG	2006-05-26 12:13:21.000000000 +0200
@@ -8,6 +8,16 @@
 #
 
 KLIBCOPTFLAGS = -Os
-KLIBCBITSIZE  = 32
 
+ifneq ("$(KLIBCARCH)", "s390x")
+	KLIBCBITSIZE	= 32
+	KLIBCCFLAGS	+= -m31
+	KLIBCLDFLAGS	+= -m elf_s390
+else
+	KLIBCBITSIZE	= 64
+	KLIBCCFLAGS	+= -m64
+	KLIBCLDFLAGS	+= -m elf64_s390
+endif
+
+KLIBCASMARCH		= s390
 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-26 12:07:20.000000000 +0200
+++ b/usr/klibc/arch/s390/Makefile.inc	2006-05-26 12:13:10.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-26 12:07:20.000000000 +0200
+++ b/usr/klibc/arch/s390/crt0.S	2006-05-26 12:03:06.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-26 12:07:20.000000000 +0200
+++ b/usr/klibc/arch/s390/mmap.c	2006-05-26 12:03:06.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)
 {
 	struct mmap_arg_struct args = {
@@ -36,3 +38,37 @@ void *__mmap2(void *addr, size_t len, in
 	}
 	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-26 12:07:20.000000000 +0200
+++ b/usr/klibc/arch/s390/setjmp.S	2006-05-26 12:03:06.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-26 12:07:20.000000000 +0200
+++ b/usr/klibc/arch/s390/sysstub.ph	2006-05-26 12:03:06.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-26 12:07:20.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-26 12:07:20.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-26 12:07:20.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-26 12:07:20.000000000 +0200
+++ b/usr/klibc/arch/s390x/mmap.c	1970-01-01 01:00:00.000000000 +0100
@@ -1,38 +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-26 12:07:20.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-26 12:07:20.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-26 12:07:20.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-26 12:07:20.000000000 +0200
+++ b/usr/klibc/syscalls/Kbuild	2006-05-26 12:03:06.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