diff options
author | H. Peter Anvin <hpa@zytor.com> | 2002-08-19 03:24:47 +0000 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2002-08-19 03:24:47 +0000 |
commit | 4590fea82c3bba1d3ebd6dd35d86a68436beba9e (patch) | |
tree | 0df32ca68583a6343b9d3a5c7fcca6fc9a8034b1 | |
parent | a661dd750337971c837cdadb45ac8e92b82bf43a (diff) | |
download | klibc-4590fea82c3bba1d3ebd6dd35d86a68436beba9e.tar.gz |
Lots of fixes from rmk. x86-64 fixes from Mats Petersson.klibc-0.55
-rw-r--r-- | ash/Makefile | 9 | ||||
-rw-r--r-- | include/netinet/in.h | 4 | ||||
-rw-r--r-- | include/setjmp.h | 2 | ||||
-rw-r--r-- | include/signal.h | 3 | ||||
-rw-r--r-- | include/stdio.h | 2 | ||||
-rw-r--r-- | include/sys/mount.h | 2 | ||||
-rw-r--r-- | klibc/MCONFIG | 2 | ||||
-rw-r--r-- | klibc/Makefile | 4 | ||||
-rw-r--r-- | klibc/SYSCALLS | 1 | ||||
-rw-r--r-- | klibc/arch/x86_64/MCONFIG | 14 | ||||
-rw-r--r-- | klibc/arch/x86_64/exits.S | 2 | ||||
-rw-r--r-- | klibc/include/netinet/in.h | 4 | ||||
-rw-r--r-- | klibc/include/setjmp.h | 2 | ||||
-rw-r--r-- | klibc/include/signal.h | 3 | ||||
-rw-r--r-- | klibc/include/stdio.h | 2 | ||||
-rw-r--r-- | klibc/include/sys/mount.h | 2 | ||||
-rw-r--r-- | klibc/inet/inet_ntoa.c | 9 | ||||
-rw-r--r-- | klibc/inet/inet_ntop.c | 9 | ||||
-rw-r--r-- | klibc/memcpy.c | 2 | ||||
-rw-r--r-- | klibc/memset.c | 6 | ||||
-rw-r--r-- | klibc/siglist.c | 3 | ||||
-rw-r--r-- | klibc/signal.c | 12 | ||||
-rw-r--r-- | klibc/syscalls.pl | 8 |
23 files changed, 87 insertions, 20 deletions
diff --git a/ash/Makefile b/ash/Makefile index ca38182d49596..39e03c9304474 100644 --- a/ash/Makefile +++ b/ash/Makefile @@ -15,9 +15,10 @@ OBJS = $(OBJ1) $(OBJ2) KLIBSRC = ../klibc include ../MCONFIG -CFLAGS = $(OPTFLAGS) $(REQFLAGS) -DSHELL -LIBS = $(KLIBC) $(LIBGCC) -STRIP = $(CROSS)strip -R .comment -R .note +MAKEDEPS = -Wp,-MD,.$(subst /,-,$*).d +CFLAGS = $(MAKEDEPS) $(OPTFLAGS) $(REQFLAGS) -DSHELL +LIBS = $(KLIBC) $(LIBGCC) +STRIP = $(CROSS)strip -R .comment -R .note HOST_CFLAGS = -g -I. -DSHELL @@ -70,3 +71,5 @@ mknodes: mknodes.c clean: rm -f core $(CLEANFILES) $(PROG) $(OBJS) +spotless: clean + find . -name \*~ -not -type d -print0 | xargs -0rt rm -f diff --git a/include/netinet/in.h b/include/netinet/in.h index d2c2320f0ab9c..e4c2f880fe792 100644 --- a/include/netinet/in.h +++ b/include/netinet/in.h @@ -5,6 +5,10 @@ #ifndef _NETINET_IN_H #define _NETINET_IN_H +/* added this include by Mats Petersson */ +#include <linux/socket.h> + + #include <stdint.h> #include <endian.h> /* Must be included *before* <linux/in.h> */ #include <linux/in.h> diff --git a/include/setjmp.h b/include/setjmp.h index 866d3a1581f6b..b504eb6d08c5c 100644 --- a/include/setjmp.h +++ b/include/setjmp.h @@ -34,7 +34,7 @@ typedef struct __sigjmp_buf sigjmp_buf[1]; #define sigsetjmp(__env, __save) \ ({ \ struct __sigjmp_buf *__e = (__env); \ - sigprocmask(0, NULL, __e->__sigs); \ + sigprocmask(0, NULL, &__e->__sigs); \ setjmp(__e->__jmpbuf); \ }) diff --git a/include/signal.h b/include/signal.h index d417e40c16f0c..c571a0447b71a 100644 --- a/include/signal.h +++ b/include/signal.h @@ -24,6 +24,7 @@ __extern const char * const sys_siglist[]; +#if !defined(__x86_64__) /* This assumes sigset_t is either an unsigned long or an array of such, and that _NSIG_BPW in the kernel is always LONG_BIT */ @@ -55,6 +56,8 @@ static __inline__ int sigismember(sigset_t *set, int signum) return (int)((lset[signum/LONG_BIT] >> (signum%LONG_BIT)) & 1); } +#endif + __extern __sighandler_t signal(int, __sighandler_t); __extern int sigaction(int, const struct sigaction *, struct sigaction *); __extern int sigprocmask(int, const sigset_t *, sigset_t *); diff --git a/include/stdio.h b/include/stdio.h index 466b95c0192a7..7bcf32ea3807f 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -97,4 +97,6 @@ __extern int vsscanf(const char *, const char *, va_list); __extern void perror(const char *); +__extern int rename(const char *, const char *); + #endif /* _STDIO_H */ diff --git a/include/sys/mount.h b/include/sys/mount.h index 453724812325a..313c90ec0ec48 100644 --- a/include/sys/mount.h +++ b/include/sys/mount.h @@ -17,9 +17,11 @@ #define MS_SYNCHRONOUS 16 /* Writes are synced at once */ #define MS_REMOUNT 32 /* Alter flags of a mounted FS */ #define MS_MANDLOCK 64 /* Allow mandatory locks on an FS */ +#define MS_DIRSYNC 128 /* Directory modifications are synchronous */ #define MS_NOATIME 1024 /* Do not update access times. */ #define MS_NODIRATIME 2048 /* Do not update directory access times */ #define MS_BIND 4096 +#define MS_MOVE 8192 #define MS_REC 16384 #define MS_VERBOSE 32768 #define MS_NOUSER (1<<31) diff --git a/klibc/MCONFIG b/klibc/MCONFIG index 71dfc8d64e836..b5bdd189c1298 100644 --- a/klibc/MCONFIG +++ b/klibc/MCONFIG @@ -8,7 +8,7 @@ KLIBSRC = . include ../MCONFIG WARNFLAGS = -W -Wall -Wpointer-arith -Wwrite-strings -Wstrict-prototypes -Winline -CFLAGS = $(OPTFLAGS) $(REQFLAGS) $(WARNFLAGS) +CFLAGS = -Wp,-MD,$(dir $*).$(notdir $*).d $(OPTFLAGS) $(REQFLAGS) $(WARNFLAGS) SOFLAGS = -fPIC SOOBJS = $(patsubst %.o,%.lo,$(LIBOBJS)) diff --git a/klibc/Makefile b/klibc/Makefile index b03532d5f7a4d..bf49345c10176 100644 --- a/klibc/Makefile +++ b/klibc/Makefile @@ -98,3 +98,7 @@ clean: archclean spotless: clean find . -name \*~ -not -type d -print0 | xargs -0rt rm -f + +ifneq ($(wildcard $(DIR)/.*.d),) +include $(wildcard $(DIR)/.*.d) +endif diff --git a/klibc/SYSCALLS b/klibc/SYSCALLS index 75b848a0f7b01..5316e6b87859f 100644 --- a/klibc/SYSCALLS +++ b/klibc/SYSCALLS @@ -70,6 +70,7 @@ int access(const char *, int) int link(const char *, const char *) int unlink(const char *) int chdir(const char *) +int rename(const char *, const char *) int mknod(const char *, mode_t, dev_t) int chmod(const char *, mode_t) <!alpha> int utime(const char *, struct utimbuf *) diff --git a/klibc/arch/x86_64/MCONFIG b/klibc/arch/x86_64/MCONFIG new file mode 100644 index 0000000000000..422ae4543db73 --- /dev/null +++ b/klibc/arch/x86_64/MCONFIG @@ -0,0 +1,14 @@ +# -*- makefile -*- +# +# arch/x86-64/MCONFIG +# +# Special rules for this architecture. Note that this is actually +# included from the main Makefile, and that pathnames should be +# accordingly. +# +# Blatantly copied and modified from i386 version by Mats Petersson, AMD. +# + +OPTFLAGS = -Os -fomit-frame-pointer \ + -falign-functions=0 -falign-jumps=0 -falign-loops=0 +BITSIZE = 64 diff --git a/klibc/arch/x86_64/exits.S b/klibc/arch/x86_64/exits.S index 2d49d75c285e1..618f4fb585cb3 100644 --- a/klibc/arch/x86_64/exits.S +++ b/klibc/arch/x86_64/exits.S @@ -28,7 +28,7 @@ exit: .globl _exit .type _exit,@function _exit: - movl $__NR_exit,%rax + movl $__NR_exit,%eax /* The argument is already in %rdi */ syscall .size _exit,.-exit diff --git a/klibc/include/netinet/in.h b/klibc/include/netinet/in.h index d2c2320f0ab9c..e4c2f880fe792 100644 --- a/klibc/include/netinet/in.h +++ b/klibc/include/netinet/in.h @@ -5,6 +5,10 @@ #ifndef _NETINET_IN_H #define _NETINET_IN_H +/* added this include by Mats Petersson */ +#include <linux/socket.h> + + #include <stdint.h> #include <endian.h> /* Must be included *before* <linux/in.h> */ #include <linux/in.h> diff --git a/klibc/include/setjmp.h b/klibc/include/setjmp.h index 866d3a1581f6b..b504eb6d08c5c 100644 --- a/klibc/include/setjmp.h +++ b/klibc/include/setjmp.h @@ -34,7 +34,7 @@ typedef struct __sigjmp_buf sigjmp_buf[1]; #define sigsetjmp(__env, __save) \ ({ \ struct __sigjmp_buf *__e = (__env); \ - sigprocmask(0, NULL, __e->__sigs); \ + sigprocmask(0, NULL, &__e->__sigs); \ setjmp(__e->__jmpbuf); \ }) diff --git a/klibc/include/signal.h b/klibc/include/signal.h index d417e40c16f0c..c571a0447b71a 100644 --- a/klibc/include/signal.h +++ b/klibc/include/signal.h @@ -24,6 +24,7 @@ __extern const char * const sys_siglist[]; +#if !defined(__x86_64__) /* This assumes sigset_t is either an unsigned long or an array of such, and that _NSIG_BPW in the kernel is always LONG_BIT */ @@ -55,6 +56,8 @@ static __inline__ int sigismember(sigset_t *set, int signum) return (int)((lset[signum/LONG_BIT] >> (signum%LONG_BIT)) & 1); } +#endif + __extern __sighandler_t signal(int, __sighandler_t); __extern int sigaction(int, const struct sigaction *, struct sigaction *); __extern int sigprocmask(int, const sigset_t *, sigset_t *); diff --git a/klibc/include/stdio.h b/klibc/include/stdio.h index 466b95c0192a7..7bcf32ea3807f 100644 --- a/klibc/include/stdio.h +++ b/klibc/include/stdio.h @@ -97,4 +97,6 @@ __extern int vsscanf(const char *, const char *, va_list); __extern void perror(const char *); +__extern int rename(const char *, const char *); + #endif /* _STDIO_H */ diff --git a/klibc/include/sys/mount.h b/klibc/include/sys/mount.h index 453724812325a..313c90ec0ec48 100644 --- a/klibc/include/sys/mount.h +++ b/klibc/include/sys/mount.h @@ -17,9 +17,11 @@ #define MS_SYNCHRONOUS 16 /* Writes are synced at once */ #define MS_REMOUNT 32 /* Alter flags of a mounted FS */ #define MS_MANDLOCK 64 /* Allow mandatory locks on an FS */ +#define MS_DIRSYNC 128 /* Directory modifications are synchronous */ #define MS_NOATIME 1024 /* Do not update access times. */ #define MS_NODIRATIME 2048 /* Do not update directory access times */ #define MS_BIND 4096 +#define MS_MOVE 8192 #define MS_REC 16384 #define MS_VERBOSE 32768 #define MS_NOUSER (1<<31) diff --git a/klibc/inet/inet_ntoa.c b/klibc/inet/inet_ntoa.c index e761f7bda4a4f..5340aa622a850 100644 --- a/klibc/inet/inet_ntoa.c +++ b/klibc/inet/inet_ntoa.c @@ -8,9 +8,12 @@ char *inet_ntoa(struct in_addr addr) { static char name[16]; - uint32_t v = addr.s_addr; + union { + uint8_t b[4]; + uint32_t l; + } a; + a.l = addr.s_addr; - sprintf(name, "%u.%u.%u.%u", - (v >> 24), (v >> 16) & 0xff, (v >> 8) & 0xff, v & 0xff); + sprintf(name, "%u.%u.%u.%u", a.b[0], a.b[1], a.b[2], a.b[3]); return name; } diff --git a/klibc/inet/inet_ntop.c b/klibc/inet/inet_ntop.c index 1309feb26bf2f..377bab7bf2ef4 100644 --- a/klibc/inet/inet_ntop.c +++ b/klibc/inet/inet_ntop.c @@ -15,10 +15,13 @@ const char *inet_ntop(int af, const void *cp, char *buf, size_t len) switch ( af ) { case AF_INET: { - uint32_t v = ((const struct in_addr *)cp)->s_addr; + union { + uint8_t b[4]; + uint32_t l; + } a; + a.l = ((const struct in_addr *)cp)->s_addr; - xlen = snprintf(buf, len, "%u.%u.%u.%u", - (v >> 24), (v >> 16) & 0xff, (v >> 8) & 0xff, v & 0xff); + xlen = snprintf(buf, len, "%u.%u.%u.%u", a.b[0], a.b[1], a.b[2], a.b[3]); } break; diff --git a/klibc/memcpy.c b/klibc/memcpy.c index 0faab06907d76..9f11cdd9ebb9c 100644 --- a/klibc/memcpy.c +++ b/klibc/memcpy.c @@ -14,7 +14,7 @@ void *memcpy(void *dst, const void *src, size_t n) : "+c" (n), "+S" (p), "+D" (q) :: "edx"); #elif defined(__x86_64__) asm volatile("cld ; movq %0,%%rdx ; shrq $3,%0 ; rep ; movsq ; " - "movq %%rdx,%0 ; andl $7,%0 ; rep ; movsb" + "movl %%edx,%0 ; andl $7,%0 ; rep ; movsb" : "+c" (n), "+S" (p), "+D" (q) :: "rdx"); #else while ( n-- ) { diff --git a/klibc/memset.c b/klibc/memset.c index 07fbcd8d1e7b1..dcf307a1faf9c 100644 --- a/klibc/memset.c +++ b/klibc/memset.c @@ -15,10 +15,10 @@ void *memset(void *dst, int c, size_t n) : "a" ((unsigned char)c * 0x01010101U) : "edx"); #elif defined(__x86_64__) - asm volatile("cld ; movl %0,%%rdx ; shrq $3,%0 ; rep ; stosq ; " - "movl %%rdx,%0 ; andl $7,%0 ; rep ; stosb" + asm volatile("cld ; movl %0,%%edx ; shrq $3,%0 ; rep ; stosq ; " + "movl %%edx,%0 ; andl $7,%0 ; rep ; stosb" : "+c" (n), "+D" (q) - : "a" ((unsigned char)c * 0x01010101U) + : "a" ((unsigned char)c * 0x0101010101010101U) : "rdx"); #else while ( n-- ) { diff --git a/klibc/siglist.c b/klibc/siglist.c index 8e224c15f762e..dce7355079413 100644 --- a/klibc/siglist.c +++ b/klibc/siglist.c @@ -76,9 +76,6 @@ const char * const sys_siglist[NSIG] = { #ifdef SIGSTOP [SIGSTOP] = "Stopped (signal)", #endif -#ifdef SIGSWI - [SIGSWI] = "Software interrupt", -#endif #ifdef SIGSYS [SIGSYS] = "Bad system call", #endif diff --git a/klibc/signal.c b/klibc/signal.c index 9dd5abd409049..939011eaf4668 100644 --- a/klibc/signal.c +++ b/klibc/signal.c @@ -4,6 +4,18 @@ #include <signal.h> +#if __x86_64__ +/* Quick hack: Add sigaction to this file. Not a good solution, it should + be in signal.h. +*/ +struct sigaction { + __sighandler_t sa_handler; + unsigned long sa_flags; + void (*sa_restorer)(void); + sigset_t sa_mask; /* mask last for extensibility */ +}; +#endif + __sighandler_t signal(int signum, __sighandler_t handler) { struct sigaction sa; diff --git a/klibc/syscalls.pl b/klibc/syscalls.pl index 1b9ca13b7a59b..fdb8c786e5f43 100644 --- a/klibc/syscalls.pl +++ b/klibc/syscalls.pl @@ -46,6 +46,13 @@ while ( defined($line = <STDIN>) ) { open(OUT, "> syscalls/${fname}.c") or die "$0: Cannot open syscalls/${fname}.c\n"; + + if ( $fname eq "rt_sigaction") { + print OUT "#ifdef __x86_64__\n\n"; + print OUT "struct sigaction;\n\n"; + print OUT "#endif\n\n" + } + print OUT "#include \"syscommon.h\"\n\n"; if ( $fname ne $sname ) { @@ -54,6 +61,7 @@ while ( defined($line = <STDIN>) ) { } print OUT "_syscall", scalar(@args), $stype, "(", $type, ',', $fname; + $i = 0; foreach $arg ( @args ) { print OUT ",", $arg, ",a",$i++; |