diff options
author | Gwenolé Beauchesne <gbeauchesne@mandriva.org> | 2002-10-09 13:22:51 +0000 |
---|---|---|
committer | Gwenolé Beauchesne <gbeauchesne@mandriva.org> | 2002-10-09 13:22:51 +0000 |
commit | 67b2399796a1fd5e2b7301a7a2c844ed76cb7252 (patch) | |
tree | 380081afcf3b4b3f6139d351bb57a243b7e6ea8b /mdk-stage1/minilibc.c | |
parent | 96c3c3669c218e7693c79b0112140d431c3e74de (diff) | |
download | drakx-67b2399796a1fd5e2b7301a7a2c844ed76cb7252.tar drakx-67b2399796a1fd5e2b7301a7a2c844ed76cb7252.tar.gz drakx-67b2399796a1fd5e2b7301a7a2c844ed76cb7252.tar.bz2 drakx-67b2399796a1fd5e2b7301a7a2c844ed76cb7252.tar.xz drakx-67b2399796a1fd5e2b7301a7a2c844ed76cb7252.zip |
Add support for x86-64 to minilibc. But we don't really use it yet, as glibc
requirements for stage1 undoubtedly make images already bigger. So let have
glibc init there too. ;-)
Diffstat (limited to 'mdk-stage1/minilibc.c')
-rw-r--r-- | mdk-stage1/minilibc.c | 89 |
1 files changed, 85 insertions, 4 deletions
diff --git a/mdk-stage1/minilibc.c b/mdk-stage1/minilibc.c index 73d7deae5..0a9bc9156 100644 --- a/mdk-stage1/minilibc.c +++ b/mdk-stage1/minilibc.c @@ -60,34 +60,115 @@ void _fini (int __status __attribute__ ((unused))) { } -inline int socket(int a, int b, int c) +#ifdef __x86_64__ + +#define _NSIG 64 +#define _NSIG_BPW 64 +#define _NSIG_WORDS (_NSIG / _NSIG_BPW) + +typedef struct { + unsigned long sig[_NSIG_WORDS]; +} libc_sigset_t; + +struct sigaction { + union { + __sighandler_t _sa_handler; + void (*_sa_sigaction)(int, void*, void*); + } _u; + unsigned long sa_flags; + void (*sa_restorer)(void); + libc_sigset_t sa_mask; +}; + +#define sa_handler _u._sa_handler +#define sa_sigaction _u._sa_sigaction + +static inline int sigemptyset(libc_sigset_t *set) { + set->sig[0]=0; + if (_NSIG_WORDS>1) set->sig[1]=0; + if (_NSIG_WORDS>2) { + set->sig[2]=0; + set->sig[3]=0; + } + return 0; +} + +#define __sigmask(sig) ( ((unsigned long)1) << (((sig)-1) % (8*sizeof(unsigned long))) ) +#define __sigword(sig) ( ((sig)-1) / (8*sizeof(unsigned long)) ) + +#define EINVAL 22 + +int sigaddset(libc_sigset_t *set, int signo) { + if ((signo<1)||(signo>SIGRTMAX)) { + errno = EINVAL; + return -1; + } else { + unsigned long __mask = __sigmask (signo); + unsigned long __word = __sigword (signo); + set->sig[__word]|=__mask; + return 0; + } +} + +#define __NR___rt_sigaction __NR_rt_sigaction +static inline _syscall3(int,__rt_sigaction,int,signum,const void *,act,void *,oldact) + +int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact) { + return __rt_sigaction(signum, act, oldact); +} + +__sighandler_t signal(int signum, __sighandler_t action) { + struct sigaction sa,oa; + sa.sa_handler=action; + sigemptyset(&sa.sa_mask); + sigaddset(&sa.sa_mask,signum); + sa.sa_flags=SA_RESTART; + if (sigaction(signum,&sa,&oa)) + return SIG_ERR; + return oa.sa_handler; +} + +#endif + +#ifdef __NR_socketcall + +int socket(int a, int b, int c) { unsigned long args[] = { a, b, c }; return socketcall(SYS_SOCKET, args); } -inline int bind(int a, void * b, int c) +int bind(int a, void * b, int c) { unsigned long args[] = { a, (long) b, c }; return socketcall(SYS_BIND, args); } -inline int listen(int a, int b) +int listen(int a, int b) { unsigned long args[] = { a, b, 0 }; return socketcall(SYS_LISTEN, args); } -inline int accept(int a, void * addr, void * addr2) +int accept(int a, void * addr, void * addr2) { unsigned long args[] = { a, (long) addr, (long) addr2 }; return socketcall(SYS_ACCEPT, args); } +#else + +_syscall3(int,socket,int,domain,int,type,int,protocol) +_syscall3(int,bind,int,sockfd,void *,my_addr,int,addrlen) +_syscall2(int,listen,int,s,int,backlog) +_syscall3(int,accept,int,s,void *,addr,void *,addrlen) + +#endif + void sleep(int secs) { |