From 73028bc3322c9ec88e046c57e7b297fdd1c02b1a Mon Sep 17 00:00:00 2001 From: "greg@kroah.com" Date: Thu, 20 May 2004 23:14:08 -0700 Subject: [PATCH] [PATCH] Update to version 117 of klibc (from version 108) --- klibc/MCONFIG | 11 ++- klibc/MRULES | 4 + klibc/klibc/Makefile | 5 +- klibc/klibc/README | 4 +- klibc/klibc/SYSCALLS | 3 +- klibc/klibc/__static_init.c | 2 - klibc/klibc/arch/i386/MCONFIG | 9 +- klibc/klibc/arch/i386/crt0.S | 1 - klibc/klibc/arch/parisc/Makefile.inc | 5 ++ klibc/klibc/arch/parisc/crt0.S | 34 +++++++ .../arch/parisc/include/klibc/archsignal.h | 13 ++- klibc/klibc/arch/parisc/setjmp.S | 88 +++++++++++++++++++ klibc/klibc/getpgrp.c | 9 ++ klibc/klibc/getpt.c | 17 ++++ klibc/klibc/include/klibc/compiler.h | 4 + klibc/klibc/include/stdlib.h | 6 +- klibc/klibc/include/sys/sysinfo.h | 12 +++ klibc/klibc/include/sys/un.h | 8 +- klibc/klibc/include/unistd.h | 5 +- klibc/klibc/open.c | 17 ++++ klibc/klibc/pty.c | 2 +- klibc/version | 2 +- 22 files changed, 233 insertions(+), 28 deletions(-) create mode 100644 klibc/klibc/arch/parisc/crt0.S create mode 100644 klibc/klibc/arch/parisc/setjmp.S create mode 100644 klibc/klibc/getpgrp.c create mode 100644 klibc/klibc/getpt.c create mode 100644 klibc/klibc/include/sys/sysinfo.h create mode 100644 klibc/klibc/open.c diff --git a/klibc/MCONFIG b/klibc/MCONFIG index de8b332d98..ec8b65c0e4 100644 --- a/klibc/MCONFIG +++ b/klibc/MCONFIG @@ -25,9 +25,14 @@ HOST_CFLAGS = -g -O HOST_LDFLAGS = HOST_LIBS = -CRT0 = $(KLIBSRC)/crt0.o -KLIBC = $(KLIBSRC)/libc.a -LIBGCC = $(shell $(CC) --print-libgcc) +# Static library paths +CRT0 = $(KLIBSRC)/crt0.o +KLIBC = $(KLIBSRC)/libc.a +LIBGCC = $(shell $(CC) --print-libgcc) + +# Shared library paths +CRTSHARED = $(KLIBSRC)/interp.o +LIBSHARED = $(KLIBSRC)/libc.so # # This indicates the location of the final version of the shared library. diff --git a/klibc/MRULES b/klibc/MRULES index 8a8831c348..41fdd07af8 100644 --- a/klibc/MRULES +++ b/klibc/MRULES @@ -5,6 +5,10 @@ .SUFFIXES: .c .o .a .so .lo .i .S .s .ls .ss .lss +% : %.c # Cancel default rule + +% : %.S + .c.o: $(CC) $(CFLAGS) -c -o $@ $< diff --git a/klibc/klibc/Makefile b/klibc/klibc/Makefile index 0d5b197f0d..7ed03a8e87 100644 --- a/klibc/klibc/Makefile +++ b/klibc/klibc/Makefile @@ -17,7 +17,8 @@ LIBOBJS = vsnprintf.o snprintf.o vsprintf.o sprintf.o \ strtoimax.o strtoumax.o \ globals.o exitc.o atexit.o onexit.o \ execl.o execle.o execv.o execvpe.o execvp.o execlp.o execlpe.o \ - fork.o wait.o wait3.o waitpid.o system.o setpgrp.o \ + fork.o wait.o wait3.o waitpid.o system.o setpgrp.o getpgrp.o \ + open.o \ printf.o vprintf.o fprintf.o vfprintf.o perror.o \ fopen.o fread.o fread2.o fgetc.o fgets.o \ fwrite.o fwrite2.o fputc.o fputs.o puts.o \ @@ -35,7 +36,7 @@ LIBOBJS = vsnprintf.o snprintf.o vsprintf.o sprintf.o \ seteuid.o setegid.o setresuid.o setresgid.o \ getenv.o setenv.o putenv.o __put_env.o unsetenv.o \ getopt.o readdir.o \ - syslog.o closelog.o pty.o isatty.o reboot.o \ + syslog.o closelog.o pty.o getpt.o isatty.o reboot.o \ time.o utime.o fdatasync.o llseek.o select.o nice.o getpriority.o \ qsort.o lrand48.o srand48.o seed48.o \ inet/inet_ntoa.o inet/inet_aton.o inet/inet_addr.o \ diff --git a/klibc/klibc/README b/klibc/klibc/README index 4495908a22..d69fa8de41 100644 --- a/klibc/klibc/README +++ b/klibc/klibc/README @@ -36,9 +36,9 @@ b) If you're cross-compiling, change ARCH in the main MCONFIG file to Known to work: alpha arm ia64 i386 ppc s390 s390x sparc sparc64 x86_64* - Works static, not shared: mips* arm-thumb sh* + Works static, not shared: mips* arm-thumb sh* parisc Might work: ppc64 - Need porting work: cris m68k mips64 parisc + Need porting work: cris m68k mips64 v850 x86_64: requires a kernel header patch (to be created) mips, sh: linker problem; might work with fixed linker diff --git a/klibc/klibc/SYSCALLS b/klibc/klibc/SYSCALLS index 00883cc098..82081201b4 100644 --- a/klibc/klibc/SYSCALLS +++ b/klibc/klibc/SYSCALLS @@ -19,7 +19,6 @@ int setpgid(pid_t, pid_t) pid_t getpgid(pid_t) pid_t getppid() pid_t getxpid@dual1::getppid() - pid_t getpgrp() pid_t setsid() pid_t getsid(pid_t) pid_t wait4(pid_t, int *, int, struct rusage *) @@ -92,7 +91,6 @@ int lchown(const char *, uid_t, gid_t) # ssize_t read(int, void *, size_t) ssize_t write(int, const void *, size_t) -int open(const char *, int, mode_t) int close(int) off_t lseek(int, off_t, int) int dup(int) @@ -145,6 +143,7 @@ long delete_module(const char *, unsigned int) int query_module(const char *, int, void *, size_t, size_t) int reboot::__reboot(int, int, int, void *) int syslog::klogctl(int, char *, int) +int sysinfo(struct sysinfo *) # # Low-level I/O (generally architecture-specific) diff --git a/klibc/klibc/__static_init.c b/klibc/klibc/__static_init.c index dcb8d01856..5a90b5cd88 100644 --- a/klibc/klibc/__static_init.c +++ b/klibc/klibc/__static_init.c @@ -36,5 +36,3 @@ __noreturn __libc_init(uintptr_t *elfdata, void (*onexit)(void)) environ = envp; exit(main(argc, argv, envp)); } - - diff --git a/klibc/klibc/arch/i386/MCONFIG b/klibc/klibc/arch/i386/MCONFIG index 367ee89773..516b1b6738 100644 --- a/klibc/klibc/arch/i386/MCONFIG +++ b/klibc/klibc/arch/i386/MCONFIG @@ -7,17 +7,16 @@ # accordingly. # -# Comment this out to compile with register parameter passing -# This doesn't work right now because gcc 3.2 (at least) calls -# libgcc with the default calling convention instead of forcing -# them to be cdecl -# REGPARM = -mregparm=3 -DREGPARM +# Enable this to compile with register parameters; only safe for +# gcc > 3 +REGPARM_OPT := -mregparm=3 -DREGPARM gcc_major := $(shell $(CC) -v 2>&1 | awk '/gcc version/{print int($$3)}') OPTFLAGS = $(REGPARM) -march=i386 -Os ifeq ($(gcc_major),3) +REGPARM := $(REGPARM_OPT) OPTFLAGS += -falign-functions=0 -falign-jumps=0 -falign-loops=0 else OPTFLAGS += -malign-functions=0 -malign-jumps=0 -malign-loops=0 diff --git a/klibc/klibc/arch/i386/crt0.S b/klibc/klibc/arch/i386/crt0.S index 1c82eda513..0f3a7db35e 100644 --- a/klibc/klibc/arch/i386/crt0.S +++ b/klibc/klibc/arch/i386/crt0.S @@ -26,7 +26,6 @@ _start: #endif call __libc_init # If __libc_init returns, problem... - ud2 hlt .size _start, .-_start diff --git a/klibc/klibc/arch/parisc/Makefile.inc b/klibc/klibc/arch/parisc/Makefile.inc index f7a983da7f..abe9155bf4 100644 --- a/klibc/klibc/arch/parisc/Makefile.inc +++ b/klibc/klibc/arch/parisc/Makefile.inc @@ -7,4 +7,9 @@ # accordingly. # +ARCHOBJS = \ + arch/$(ARCH)/setjmp.o + +ARCHOOBJS = $(patsubst %o,%.lo,%(ARCHOBJS)) + archclean: diff --git a/klibc/klibc/arch/parisc/crt0.S b/klibc/klibc/arch/parisc/crt0.S new file mode 100644 index 0000000000..fb0bd373ee --- /dev/null +++ b/klibc/klibc/arch/parisc/crt0.S @@ -0,0 +1,34 @@ + .align 4 + + .import $global$, data + .import __libc_init, code + + .global _start + .export _start, ENTRY + .type _start,@function + + .proc + .callinfo + +_start: +/* extend the stack by 64-bytes */ + ldo 64(%sp), %sp + +/* %r25 = argc + * %r24 = argv + * envp = argv + (argc + 1) + * elfdata = (argv - 4) + */ + ldo -4(%r24), %r26 + +/* load global data */ + ldil L%$global$, %dp + ldo R%$global$(%dp), %dp + +/* branch to __libc_init */ + bl __libc_init,%r2 + nop +/* break miserably if we ever return */ + iitlbp %r0,(%r0) /* illegal instruction */ + nop + .procend diff --git a/klibc/klibc/arch/parisc/include/klibc/archsignal.h b/klibc/klibc/arch/parisc/include/klibc/archsignal.h index 511d774b2d..3190e8528e 100644 --- a/klibc/klibc/arch/parisc/include/klibc/archsignal.h +++ b/klibc/klibc/arch/parisc/include/klibc/archsignal.h @@ -8,6 +8,17 @@ #ifndef _KLIBC_ARCHSIGNAL_H #define _KLIBC_ARCHSIGNAL_H -/* No special stuff for this architecture */ +#define _NSIG 64 +#define _NSIG_SZ (_NSIG / LONG_BIT) + +typedef struct { + unsigned long sig[_NSIG_SZ]; +} sigset_t; + +struct sigaction { + __sighandler_t sa_handler; + unsigned long sa_flags; + sigset_t sa_mask; +}; #endif diff --git a/klibc/klibc/arch/parisc/setjmp.S b/klibc/klibc/arch/parisc/setjmp.S new file mode 100644 index 0000000000..51b2b1a58b --- /dev/null +++ b/klibc/klibc/arch/parisc/setjmp.S @@ -0,0 +1,88 @@ +/* + * parisc specific setjmp/longjmp routines + * + */ + + .text + .align 4 + .global setjmp + .export setjmp, code + .proc + .callinfo +setjmp: + stw %r3,0(%r26) + stw %r4,8(%r26) + stw %r5,12(%r26) + stw %r6,16(%r26) + stw %r7,20(%r26) + stw %r8,24(%r26) + stw %r9,28(%r26) + stw %r10,32(%r26) + stw %r11,36(%r26) + stw %r12,40(%r26) + stw %r13,44(%r26) + stw %r14,48(%r26) + stw %r15,52(%r26) + stw %r16,56(%r26) + stw %r17,60(%r26) + stw %r18,64(%r26) + stw %r19,68(%r26) + stw %dp,72(%r26) + stw %r30,76(%r26) + stw %rp,80(%r26) + ldo 88(%r26),%r19 + fstd,ma %fr12,8(%r19) + fstd,ma %fr13,8(%r19) + fstd,ma %fr14,8(%r19) + fstd,ma %fr15,8(%r19) + fstd,ma %fr16,8(%r19) + fstd,ma %fr17,8(%r19) + fstd,ma %fr18,8(%r19) + fstd,ma %fr19,8(%r19) + fstd,ma %fr20,8(%r19) + fstd %fr21,0(%r19) + bv %r0(%rp) + copy %r0,%r28 + .procend + + .text + .align 4 + .global longjmp + .export longjmp, code + .proc + .callinfo +longjmp: + ldw 0(%r26),%r3 + ldw 8(%r26),%r4 + ldw 12(%r26),%r5 + ldw 16(%r26),%r6 + ldw 20(%r26),%r7 + ldw 24(%r26),%r8 + ldw 28(%r26),%r9 + ldw 32(%r26),%r10 + ldw 36(%r26),%r11 + ldw 40(%r26),%r12 + ldw 44(%r26),%r13 + ldw 48(%r26),%r14 + ldw 52(%r26),%r15 + ldw 56(%r26),%r16 + ldw 60(%r26),%r17 + ldw 64(%r26),%r18 + ldw 68(%r26),%r19 + ldw 72(%r26),%r27 + ldw 76(%r26),%r30 + ldw 80(%r26),%rp + ldo 88(%r26),%r20 + fldd,ma 8(%r20),%fr12 + fldd,ma 8(%r20),%fr13 + fldd,ma 8(%r20),%fr14 + fldd,ma 8(%r20),%fr15 + fldd,ma 8(%r20),%fr16 + fldd,ma 8(%r20),%fr17 + fldd,ma 8(%r20),%fr18 + fldd,ma 8(%r20),%fr19 + fldd,ma 8(%r20),%fr20 + fldd 0(%r20),%fr21 + bv %r0(%rp) + copy %r25,%r28 + .procend diff --git a/klibc/klibc/getpgrp.c b/klibc/klibc/getpgrp.c new file mode 100644 index 0000000000..c92369807b --- /dev/null +++ b/klibc/klibc/getpgrp.c @@ -0,0 +1,9 @@ +/* + * getpgrp.c + */ + +#include + +pid_t getpgrp(void) { + return getpgid(0); +} diff --git a/klibc/klibc/getpt.c b/klibc/klibc/getpt.c new file mode 100644 index 0000000000..a05903062c --- /dev/null +++ b/klibc/klibc/getpt.c @@ -0,0 +1,17 @@ +/* + * getpt.c + * + * GNU extension to the standard Unix98 pty suite + */ + +#include +#include +#include +#include +#include +#include + +int getpt(void) +{ + return open("/dev/ptmx", O_RDWR|O_NOCTTY); +} diff --git a/klibc/klibc/include/klibc/compiler.h b/klibc/klibc/include/klibc/compiler.h index 49872b89d4..6c01474cc1 100644 --- a/klibc/klibc/include/klibc/compiler.h +++ b/klibc/klibc/include/klibc/compiler.h @@ -8,12 +8,16 @@ #define _KLIBC_COMPILER_H /* Specific calling conventions */ +/* __cdecl is used when we want varadic and non-varadic functions to have + the same binary calling convention. */ #ifdef __i386__ # ifdef __GNUC__ # define __cdecl __attribute__((cdecl,regparm(0))) # else /* Most other C compilers have __cdecl as a keyword */ # endif +#else +# define __cdecl /* Meaningless on non-i386 */ #endif /* How to declare a function that *must* be inlined */ diff --git a/klibc/klibc/include/stdlib.h b/klibc/klibc/include/stdlib.h index 38dd1624a5..af97eea636 100644 --- a/klibc/klibc/include/stdlib.h +++ b/klibc/klibc/include/stdlib.h @@ -83,12 +83,14 @@ static __inline__ void srandom(unsigned int __s) /* Basic PTY functions. These only work if devpts is mounted! */ +__extern int unlockpt(int); +__extern char *ptsname(int); +__extern int getpt(void); + static __inline__ int grantpt(int __fd) { (void)__fd; return 0; /* devpts does this all for us! */ } -__extern int unlockpt(int); -__extern char *ptsname(int); #endif /* _STDLIB_H */ diff --git a/klibc/klibc/include/sys/sysinfo.h b/klibc/klibc/include/sys/sysinfo.h new file mode 100644 index 0000000000..4051c6897a --- /dev/null +++ b/klibc/klibc/include/sys/sysinfo.h @@ -0,0 +1,12 @@ +/* + * sys/sysinfo.h + */ + +#ifndef _SYS_SYSINFO_H +#define _SYS_SYSINFO_H + +#include + +extern int sysinfo (struct sysinfo *info); + +#endif /* _SYS_SYSINFO_H */ diff --git a/klibc/klibc/include/sys/un.h b/klibc/klibc/include/sys/un.h index 85822ba6a4..df42d719f7 100644 --- a/klibc/klibc/include/sys/un.h +++ b/klibc/klibc/include/sys/un.h @@ -1,10 +1,10 @@ /* - * sys/un.h + * */ -#ifndef _UN_H -#define _UN_H +#ifndef _SYS_UN_H +#define _SYS_UN_H #include -#endif /* _UN_H */ +#endif /* _SYS_UN_H */ diff --git a/klibc/klibc/include/unistd.h b/klibc/klibc/include/unistd.h index f1cde2376e..13ff03b012 100644 --- a/klibc/klibc/include/unistd.h +++ b/klibc/klibc/include/unistd.h @@ -17,6 +17,7 @@ __extern __noreturn _exit(int); __extern pid_t fork(void); __extern pid_t vfork(void); __extern pid_t getpid(void); +__extern pid_t getpgid(pid_t); __extern int setpgid(pid_t, pid_t); __extern pid_t getppid(void); __extern pid_t getpgrp(void); @@ -76,8 +77,8 @@ __extern int sync(void); __extern ssize_t read(int, void *, size_t); __extern ssize_t write(int, const void *, size_t); -#ifndef __IN_SYS_COMMON -__extern int open(const char *, int, ...); +#ifndef __IN_OPEN_C +__extern __cdecl int open(const char *, int, ...); #endif __extern int close(int); __extern off_t lseek(int, off_t, int); diff --git a/klibc/klibc/open.c b/klibc/klibc/open.c new file mode 100644 index 0000000000..0d7db10c4a --- /dev/null +++ b/klibc/klibc/open.c @@ -0,0 +1,17 @@ +/* + * open.c + * + * The open syscall is weird, because it's defined as a varadic + * function, but implementing it as such generally sucks for + * performance. Thus we generate it as a 3-argument function, + * but with explicit __cdecl assuming the __cdecl convention is + * independent of being varadic. + */ + +#define __IN_OPEN_C +#include +#include +#include +#include + +__cdecl _syscall3(int,open,const char *,file,int,flags,mode_t,mode) diff --git a/klibc/klibc/pty.c b/klibc/klibc/pty.c index 5907ca2ff5..2fe01ab204 100644 --- a/klibc/klibc/pty.c +++ b/klibc/klibc/pty.c @@ -1,7 +1,7 @@ /* * pty.c * - * Basic Unix98 PTY functionality; assumes devpts + * Basic Unix98 PTY functionality; assumes devpts mounted on /dev/pts */ #include diff --git a/klibc/version b/klibc/version index 4b0a18ac52..31ba1bdaa5 100644 --- a/klibc/version +++ b/klibc/version @@ -1 +1 @@ -0.108 +0.117