S390(x) additions; use _newselect() if available rather than select()

diff --git a/SYSCALLS b/SYSCALLS
index 255a5de..48e2811 100644
--- a/SYSCALLS
+++ b/SYSCALLS
@@ -98,7 +98,6 @@
 int fcntl(int, int, long)
 int ioctl(int, int, void *)
 int flock(int, int)
-int select(int, fd_set *, fd_set *, fd_set *, struct timeval *)
 int poll(struct pollfd *, nfds_t, long)
 int fsync(int)
 int readv(int, const struct iovec *, int)
diff --git a/arch/s390/crt0.S b/arch/s390/crt0.S
new file mode 100644
index 0000000..569ab91
--- /dev/null
+++ b/arch/s390/crt0.S
@@ -0,0 +1,46 @@
+#
+# arch/s390/crt0.S
+#
+# void _start(void)
+# {
+#    /* Divine up argc, argv, and envp */
+#    environ = envp;
+#    exit(main(argc, argv, envp));
+# } 
+#
+
+	.text
+	.align 4
+	.type _start,@function
+	.globl _start
+_start:
+				# save argc 
+	l	%r2,0(%r15)
+				# save argv
+	la	%r3,4(%r15)
+				# compute envp
+	lr	%r4,%r2
+	sll	%r4,2
+	la	%r4,4(%r4,%r3)
+
+				# literal pool
+	bras	%r13,.LTN0_0
+.LT0_0:
+	.long	environ
+	.long	main
+	.long	exit	
+.LTN0_0:
+				# create stack frame
+	ahi	%r15,-96
+
+				# save global environ
+	l	%r1,0(%r13)
+	st	%r4,0(%r1)
+				# call main
+	l	%r1,4(%r13)
+	basr	%r14,%r1
+				# call exit
+	l	%r1,8(%r13)
+	basr	%r14,%r1
+
+	.size _start,.-_start
diff --git a/arch/s390x/crt0.S b/arch/s390x/crt0.S
new file mode 100644
index 0000000..fefc4bb
--- /dev/null
+++ b/arch/s390x/crt0.S
@@ -0,0 +1,36 @@
+#
+# arch/s390x/crt0.S
+#
+# void _start(void)
+# {
+#    /* Divine up argc, argv, and envp */
+#    environ = envp;
+#    exit(main(argc, argv, envp));
+# } 
+#
+
+	.text
+	.align 8
+	.type _start,@function
+	.globl _start
+_start:
+				# save argc
+	lg	%r2,0(%r15)
+				# save argv
+	la	%r3,8(%r15)
+				# compute envp
+	sllg	%r4,%r2,3
+	la	%r4,8(%r4,%r3)
+
+				# create stack frame
+	aghi	%r15,-160
+
+				# save global environ
+	larl	%r1,environ
+	stg	%r4,0(%r1)
+				# call main
+	brasl	%r14,main
+				# call exit
+	brasl	%r14,exit
+
+	.size _start,.-_start
diff --git a/include/bits32/bitsize/stddef.h b/include/bits32/bitsize/stddef.h
index 36d267c..bf6e695 100644
--- a/include/bits32/bitsize/stddef.h
+++ b/include/bits32/bitsize/stddef.h
@@ -6,7 +6,12 @@
 #define _BITSIZE_STDDEF_H
 
 #define _SIZE_T
+#if (defined(__s390__) || defined(__hppa__) || defined(__cris__))
+typedef unsigned long size_t;
+#else
 typedef unsigned int size_t;
+#endif
+
 #define _PTRDIFF_T
 typedef signed int   ptrdiff_t;
 
diff --git a/include/sys/syscall.h b/include/sys/syscall.h
index 5930859..329389e 100644
--- a/include/sys/syscall.h
+++ b/include/sys/syscall.h
@@ -195,10 +195,14 @@
                   type4,arg4,type5,arg5,type6,arg6)          \
 type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4,    \
           type5 arg5, type6 arg6) {			     \
-	struct {					     \
-		type1 name1; type2 name2; type3 name3;	     \
-		type4 name4; type5 name5; type6 name6;	     \
-	} __arg = { arg1, arg2, arg3, arg4, arg5, 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__ (               	             \
@@ -208,7 +212,7 @@
                 : "i" (__NR_##name),                         \
                   "d" (__argp)				     \
 		: _svc_clobber);			     \
-	__syscall_return(type, __res)			     \
+	__syscall_return(type, __res);			     \
 }
 
 #endif /* _syscall6() missing */
@@ -224,10 +228,14 @@
                   type4,arg4,type5,arg5,type6,arg6)          \
 type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4,    \
           type5 arg5, type6 arg6) {			     \
-	struct {					     \
-		type1 name1; type2 name2; type3 name3;	     \
-		type4 name4; type5 name5; type6 name6;	     \
-	} __arg = { arg1, arg2, arg3, arg4, arg5, 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__ (               	             \
@@ -237,7 +245,7 @@
                 : "i" (__NR_##name),                         \
                   "d" (__argp)				     \
 		: _svc_clobber);			     \
-	__syscall_return(type, __res)			     \
+	__syscall_return(type, __res);			     \
 }
 
 #endif /* _syscall6() missing */
diff --git a/klibc/Makefile b/klibc/Makefile
index 3ec4ad2..f4ebe3f 100644
--- a/klibc/Makefile
+++ b/klibc/Makefile
@@ -34,7 +34,7 @@
 	  strncmp.o strncpy.o strrchr.o strspn.o strsep.o strtok.o \
 	  gethostname.o getdomainname.o getcwd.o seteuid.o setegid.o \
 	  getenv.o setenv.o unsetenv.o getopt.o readdir.o \
-	  time.o fdatasync.o llseek.o
+	  time.o fdatasync.o llseek.o select.o
 LIB     = libc.a
 
 SOFLAGS = -fPIC
diff --git a/klibc/SYSCALLS b/klibc/SYSCALLS
index 255a5de..48e2811 100644
--- a/klibc/SYSCALLS
+++ b/klibc/SYSCALLS
@@ -98,7 +98,6 @@
 int fcntl(int, int, long)
 int ioctl(int, int, void *)
 int flock(int, int)
-int select(int, fd_set *, fd_set *, fd_set *, struct timeval *)
 int poll(struct pollfd *, nfds_t, long)
 int fsync(int)
 int readv(int, const struct iovec *, int)
diff --git a/klibc/arch/s390/crt0.S b/klibc/arch/s390/crt0.S
new file mode 100644
index 0000000..569ab91
--- /dev/null
+++ b/klibc/arch/s390/crt0.S
@@ -0,0 +1,46 @@
+#
+# arch/s390/crt0.S
+#
+# void _start(void)
+# {
+#    /* Divine up argc, argv, and envp */
+#    environ = envp;
+#    exit(main(argc, argv, envp));
+# } 
+#
+
+	.text
+	.align 4
+	.type _start,@function
+	.globl _start
+_start:
+				# save argc 
+	l	%r2,0(%r15)
+				# save argv
+	la	%r3,4(%r15)
+				# compute envp
+	lr	%r4,%r2
+	sll	%r4,2
+	la	%r4,4(%r4,%r3)
+
+				# literal pool
+	bras	%r13,.LTN0_0
+.LT0_0:
+	.long	environ
+	.long	main
+	.long	exit	
+.LTN0_0:
+				# create stack frame
+	ahi	%r15,-96
+
+				# save global environ
+	l	%r1,0(%r13)
+	st	%r4,0(%r1)
+				# call main
+	l	%r1,4(%r13)
+	basr	%r14,%r1
+				# call exit
+	l	%r1,8(%r13)
+	basr	%r14,%r1
+
+	.size _start,.-_start
diff --git a/klibc/arch/s390x/crt0.S b/klibc/arch/s390x/crt0.S
new file mode 100644
index 0000000..fefc4bb
--- /dev/null
+++ b/klibc/arch/s390x/crt0.S
@@ -0,0 +1,36 @@
+#
+# arch/s390x/crt0.S
+#
+# void _start(void)
+# {
+#    /* Divine up argc, argv, and envp */
+#    environ = envp;
+#    exit(main(argc, argv, envp));
+# } 
+#
+
+	.text
+	.align 8
+	.type _start,@function
+	.globl _start
+_start:
+				# save argc
+	lg	%r2,0(%r15)
+				# save argv
+	la	%r3,8(%r15)
+				# compute envp
+	sllg	%r4,%r2,3
+	la	%r4,8(%r4,%r3)
+
+				# create stack frame
+	aghi	%r15,-160
+
+				# save global environ
+	larl	%r1,environ
+	stg	%r4,0(%r1)
+				# call main
+	brasl	%r14,main
+				# call exit
+	brasl	%r14,exit
+
+	.size _start,.-_start
diff --git a/klibc/include/bits32/bitsize/stddef.h b/klibc/include/bits32/bitsize/stddef.h
index 36d267c..bf6e695 100644
--- a/klibc/include/bits32/bitsize/stddef.h
+++ b/klibc/include/bits32/bitsize/stddef.h
@@ -6,7 +6,12 @@
 #define _BITSIZE_STDDEF_H
 
 #define _SIZE_T
+#if (defined(__s390__) || defined(__hppa__) || defined(__cris__))
+typedef unsigned long size_t;
+#else
 typedef unsigned int size_t;
+#endif
+
 #define _PTRDIFF_T
 typedef signed int   ptrdiff_t;
 
diff --git a/klibc/include/sys/syscall.h b/klibc/include/sys/syscall.h
index 5930859..329389e 100644
--- a/klibc/include/sys/syscall.h
+++ b/klibc/include/sys/syscall.h
@@ -195,10 +195,14 @@
                   type4,arg4,type5,arg5,type6,arg6)          \
 type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4,    \
           type5 arg5, type6 arg6) {			     \
-	struct {					     \
-		type1 name1; type2 name2; type3 name3;	     \
-		type4 name4; type5 name5; type6 name6;	     \
-	} __arg = { arg1, arg2, arg3, arg4, arg5, 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__ (               	             \
@@ -208,7 +212,7 @@
                 : "i" (__NR_##name),                         \
                   "d" (__argp)				     \
 		: _svc_clobber);			     \
-	__syscall_return(type, __res)			     \
+	__syscall_return(type, __res);			     \
 }
 
 #endif /* _syscall6() missing */
@@ -224,10 +228,14 @@
                   type4,arg4,type5,arg5,type6,arg6)          \
 type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4,    \
           type5 arg5, type6 arg6) {			     \
-	struct {					     \
-		type1 name1; type2 name2; type3 name3;	     \
-		type4 name4; type5 name5; type6 name6;	     \
-	} __arg = { arg1, arg2, arg3, arg4, arg5, 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__ (               	             \
@@ -237,7 +245,7 @@
                 : "i" (__NR_##name),                         \
                   "d" (__argp)				     \
 		: _svc_clobber);			     \
-	__syscall_return(type, __res)			     \
+	__syscall_return(type, __res);			     \
 }
 
 #endif /* _syscall6() missing */
diff --git a/klibc/select.c b/klibc/select.c
new file mode 100644
index 0000000..2404bb1
--- /dev/null
+++ b/klibc/select.c
@@ -0,0 +1,9 @@
+#include <unistd.h>
+#include <sys/syscall.h>
+
+#ifdef __NR__newselect
+#undef __NR_select
+#define __NR_select __NR__newselect
+#endif
+
+_syscall5(int,select,int,a0,fd_set *,a1,fd_set *,a2,fd_set *,a3,struct timeval *,a4);
diff --git a/select.c b/select.c
new file mode 100644
index 0000000..2404bb1
--- /dev/null
+++ b/select.c
@@ -0,0 +1,9 @@
+#include <unistd.h>
+#include <sys/syscall.h>
+
+#ifdef __NR__newselect
+#undef __NR_select
+#define __NR_select __NR__newselect
+#endif
+
+_syscall5(int,select,int,a0,fd_set *,a1,fd_set *,a2,fd_set *,a3,struct timeval *,a4);