summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGwenolé Beauchesne <gbeauchesne@mandriva.org>2002-10-09 13:22:51 +0000
committerGwenolé Beauchesne <gbeauchesne@mandriva.org>2002-10-09 13:22:51 +0000
commit67b2399796a1fd5e2b7301a7a2c844ed76cb7252 (patch)
tree380081afcf3b4b3f6139d351bb57a243b7e6ea8b
parent96c3c3669c218e7693c79b0112140d431c3e74de (diff)
downloaddrakx-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. ;-)
-rw-r--r--mdk-stage1/minilibc.c89
-rw-r--r--mdk-stage1/minilibc.h24
2 files changed, 104 insertions, 9 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)
{
diff --git a/mdk-stage1/minilibc.h b/mdk-stage1/minilibc.h
index e0775e3a0..cbcb21f44 100644
--- a/mdk-stage1/minilibc.h
+++ b/mdk-stage1/minilibc.h
@@ -58,6 +58,9 @@ extern int errno;
#include <asm/fcntl.h>
#include <asm/signal.h>
+#ifndef __NR__newselect
+#define __NR__newselect __NR_select
+#endif
#ifndef MINILIBC_INTERNAL
static inline _syscall5(int,mount,const char *,spec,const char *,dir,const char *,type,unsigned long,rwflag,const void *,data);
@@ -76,8 +79,17 @@ static inline _syscall2(int,chmod,const char * ,path,mode_t,mode)
static inline _syscall2(int,sethostname,const char *,name,int,len)
static inline _syscall2(int,setdomainname,const char *,name,int,len)
static inline _syscall2(int,setpgid,int,name,int,len)
+#ifdef __x86_64__
+extern __sighandler_t signal(int signum, __sighandler_t handler);
+#else
static inline _syscall2(int,signal,int,num,void *,len)
+#endif
+#ifdef __NR_umount
static inline _syscall1(int,umount,const char *,dir)
+#else
+static inline _syscall2(int,umount2,const char *,dir,int,flags)
+static inline int umount(const char * dir) { return umount2(dir, 0); }
+#endif
static inline _syscall1(int,unlink,const char *,fn)
static inline _syscall1(int,close,int,fd)
static inline _syscall1(int,swapoff,const char *,fn)
@@ -112,19 +124,21 @@ static inline _syscall3(int,syslog,int, type, char *, buf, int, len);
#else
static inline _syscall5(int,_newselect,int,n,fd_set *,rd,fd_set *,wr,fd_set *,ex,struct timeval *,timeval);
static inline _syscall3(int,write,int,fd,const char *,buf,unsigned long,count)
+#ifdef __NR_socketcall
static inline _syscall2(int,socketcall,int,code,unsigned long *, args)
+#endif
#define __NR__do_exit __NR_exit
-extern inline _syscall1(int,_do_exit,int,exitcode)
+static inline _syscall1(int,_do_exit,int,exitcode)
#endif
#define select _newselect
extern int errno;
-inline int socket(int a, int b, int c);
-inline int bind(int a, void * b, int c);
-inline int listen(int a, int b);
-inline int accept(int a, void * addr, void * addr2);
+int socket(int a, int b, int c);
+int bind(int a, void * b, int c);
+int listen(int a, int b);
+int accept(int a, void * addr, void * addr2);
void sleep(int secs);