diff options
author | H. Peter Anvin <hpa@zytor.com> | 2002-08-12 05:50:49 +0000 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2002-08-12 05:50:49 +0000 |
commit | 6f034c4e310e89791dd65cd0ea1f997019f4e7e0 (patch) | |
tree | 4021ea70ec6dba378c44477eb75d42a867f8dd52 | |
parent | 2435704db44896a8b4c8f8fec419e43b334f01f5 (diff) | |
download | klibc-6f034c4e310e89791dd65cd0ea1f997019f4e7e0.tar.gz |
S390(x) additions; use _newselect() if available rather than select()klibc-0.22
-rw-r--r-- | SYSCALLS | 1 | ||||
-rw-r--r-- | arch/s390/crt0.S | 46 | ||||
-rw-r--r-- | arch/s390x/crt0.S | 36 | ||||
-rw-r--r-- | include/bits32/bitsize/stddef.h | 5 | ||||
-rw-r--r-- | include/sys/syscall.h | 28 | ||||
-rw-r--r-- | klibc/Makefile | 2 | ||||
-rw-r--r-- | klibc/SYSCALLS | 1 | ||||
-rw-r--r-- | klibc/arch/s390/crt0.S | 46 | ||||
-rw-r--r-- | klibc/arch/s390x/crt0.S | 36 | ||||
-rw-r--r-- | klibc/include/bits32/bitsize/stddef.h | 5 | ||||
-rw-r--r-- | klibc/include/sys/syscall.h | 28 | ||||
-rw-r--r-- | klibc/select.c | 9 | ||||
-rw-r--r-- | select.c | 9 |
13 files changed, 229 insertions, 23 deletions
diff --git a/SYSCALLS b/SYSCALLS index 255a5de572c25..48e2811c90109 100644 --- a/SYSCALLS +++ b/SYSCALLS @@ -98,7 +98,6 @@ int dup2(int, int) 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 0000000000000..569ab9102fd00 --- /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 0000000000000..fefc4bbdacc92 --- /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 36d267c396cc9..bf6e695ed3bdb 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 5930859b78589..329389ee952e6 100644 --- a/include/sys/syscall.h +++ b/include/sys/syscall.h @@ -195,10 +195,14 @@ type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5,type6 arg6) \ 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 @@ type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ : "i" (__NR_##name), \ "d" (__argp) \ : _svc_clobber); \ - __syscall_return(type, __res) \ + __syscall_return(type, __res); \ } #endif /* _syscall6() missing */ @@ -224,10 +228,14 @@ type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ 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 @@ type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ : "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 3ec4ad25f167f..f4ebe3fa860e1 100644 --- a/klibc/Makefile +++ b/klibc/Makefile @@ -34,7 +34,7 @@ LIBOBJS = vsnprintf.o snprintf.o vsprintf.o sprintf.o \ 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 255a5de572c25..48e2811c90109 100644 --- a/klibc/SYSCALLS +++ b/klibc/SYSCALLS @@ -98,7 +98,6 @@ int dup2(int, int) 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 0000000000000..569ab9102fd00 --- /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 0000000000000..fefc4bbdacc92 --- /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 36d267c396cc9..bf6e695ed3bdb 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 5930859b78589..329389ee952e6 100644 --- a/klibc/include/sys/syscall.h +++ b/klibc/include/sys/syscall.h @@ -195,10 +195,14 @@ type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5,type6 arg6) \ 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 @@ type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ : "i" (__NR_##name), \ "d" (__argp) \ : _svc_clobber); \ - __syscall_return(type, __res) \ + __syscall_return(type, __res); \ } #endif /* _syscall6() missing */ @@ -224,10 +228,14 @@ type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ 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 @@ type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ : "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 0000000000000..2404bb1e64568 --- /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 0000000000000..2404bb1e64568 --- /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); |