From 273636ca8b745ec62d432a4cbf30269f52aedaf4 Mon Sep 17 00:00:00 2001 From: "greg@kroah.com" Date: Wed, 28 Jan 2004 18:35:47 -0800 Subject: [PATCH] [PATCH] update to klibc version 0.101, fixing the stdin bug. --- klibc/klibc/Makefile | 12 ++++----- klibc/klibc/arch/ppc/include/klibc/archsys.h | 24 +++++++++++------- klibc/klibc/getpagesize.c | 26 ++++++++++++++++++++ klibc/klibc/include/stdio.h | 14 +++++------ klibc/klibc/include/unistd.h | 2 ++ klibc/klibc/mmap.c | 2 +- klibc/klibc/syscommon.h | 2 +- klibc/version | 2 +- 8 files changed, 58 insertions(+), 26 deletions(-) create mode 100644 klibc/klibc/getpagesize.c diff --git a/klibc/klibc/Makefile b/klibc/klibc/Makefile index 5fc481aa..def20152 100644 --- a/klibc/klibc/Makefile +++ b/klibc/klibc/Makefile @@ -24,7 +24,7 @@ LIBOBJS = vsnprintf.o snprintf.o vsprintf.o sprintf.o \ sleep.o usleep.o raise.o abort.o assert.o alarm.o pause.o \ __signal.o signal.o bsd_signal.o siglist.o siglongjmp.o \ sigaction.o sigpending.o sigprocmask.o sigsuspend.o \ - brk.o sbrk.o malloc.o realloc.o calloc.o mmap.o \ + brk.o sbrk.o malloc.o realloc.o calloc.o mmap.o getpagesize.o \ memcpy.o memcmp.o memset.o memccpy.o memmem.o memswap.o \ memmove.o \ strcasecmp.o strncasecmp.o strndup.o strerror.o \ @@ -118,12 +118,12 @@ socketcalls.dir: SOCKETCALLS socketcalls.pl socketcommon.h touch $@ %/static.obj: %.dir - $(MAKE) objects-$(basename $(notdir $@)) DIR=$* + $(MAKE) objects-$(basename $(notdir $@)) DIR=$*/ -STATIC = $(addsuffix .o,$(basename $(wildcard $(DIR)/*.[cS]))) +STATIC = $(addsuffix .o,$(basename $(wildcard $(DIR)*.[cS]))) objects-static: $(STATIC) - touch $(DIR)/static.obj + touch $(DIR)static.obj clean: archclean find . -type f -a \( -name \*.[isoa] -o -name \*.l[iso] \) -print0 | xargs -0rt rm -f @@ -140,6 +140,6 @@ spotless: clean bitsize: @echo $(BITSIZE) -ifneq ($(wildcard $(DIR)/.*.d),) -include $(wildcard $(DIR)/.*.d) +ifneq ($(wildcard $(DIR).*.d),) +include $(wildcard $(DIR).*.d) endif diff --git a/klibc/klibc/arch/ppc/include/klibc/archsys.h b/klibc/klibc/arch/ppc/include/klibc/archsys.h index 33a5ff32..17a28859 100644 --- a/klibc/klibc/arch/ppc/include/klibc/archsys.h +++ b/klibc/klibc/arch/ppc/include/klibc/archsys.h @@ -36,18 +36,24 @@ type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5,type6 arg6) \ __asm__ __volatile__ \ ("sc \n\t" \ "mfcr %1 " \ - : "=&r" (__sc_3), "=&r" (__sc_0) \ - : "0" (__sc_3), "1" (__sc_0), \ - "r" (__sc_4), \ - "r" (__sc_5), \ - "r" (__sc_6), \ - "r" (__sc_7), \ - "r" (__sc_8) \ - : __syscall_clobbers); \ + : "+r" (__sc_3), \ + "+r" (__sc_0), \ + "+r" (__sc_4), \ + "+r" (__sc_5), \ + "+r" (__sc_6), \ + "+r" (__sc_7), \ + "+r" (__sc_8) \ + : : "cr0", "ctr", "memory", \ + "r9", "r10", "r11", "r12"); \ __sc_ret = __sc_3; \ __sc_err = __sc_0; \ } \ - __syscall_return (type); \ + if (__sc_err & 0x10000000) \ + { \ + errno = (int)__sc_ret; \ + __sc_ret = -1; \ + } \ + return (type)__sc_ret; \ } #endif /* _syscall6() missing */ diff --git a/klibc/klibc/getpagesize.c b/klibc/klibc/getpagesize.c new file mode 100644 index 00000000..2d975b15 --- /dev/null +++ b/klibc/klibc/getpagesize.c @@ -0,0 +1,26 @@ +/* + * getpagesize.c + */ + +#include +#include + +/* Presumably there is a better way to do this... */ +#ifdef __ia64__ +# define __NR_getpagesize 1171 +#endif + +#ifdef __NR_getpagesize + +_syscall0(int,getpagesize); + +#else + +int getpagesize(void) +{ + return PAGE_SIZE; +} + +#endif + + diff --git a/klibc/klibc/include/stdio.h b/klibc/klibc/include/stdio.h index 31a1fe40..fba1e307 100644 --- a/klibc/klibc/include/stdio.h +++ b/klibc/klibc/include/stdio.h @@ -15,10 +15,6 @@ struct _IO_file; typedef struct _IO_file FILE; -#define stdin ((FILE *)0) -#define stdout ((FILE *)1) -#define stderr ((FILE *)2) - #ifndef EOF # define EOF (-1) #endif @@ -44,10 +40,12 @@ static __inline__ int fileno(FILE *__f) return (int)(size_t)__f - 1; } -static __inline__ FILE * __create_file(int __fd) -{ - return (FILE *)(size_t)(__fd + 1); -} +/* This is a macro so it can be used as initializer */ +#define __create_file(__fd) ((FILE *)(size_t)((__fd) + 1)) + +#define stdin __create_file(0) +#define stdout __create_file(1) +#define stderr __create_file(2) __extern FILE *fopen(const char *, const char *); diff --git a/klibc/klibc/include/unistd.h b/klibc/klibc/include/unistd.h index ad129138..3d5c6881 100644 --- a/klibc/klibc/include/unistd.h +++ b/klibc/klibc/include/unistd.h @@ -105,6 +105,8 @@ __extern int optind, opterr, optopt; __extern int isatty(int); +__extern int getpagesize(void); + /* Standard file descriptor numbers. */ #define STDIN_FILENO 0 #define STDOUT_FILENO 1 diff --git a/klibc/klibc/mmap.c b/klibc/klibc/mmap.c index aedf4dce..89cf3a6a 100644 --- a/klibc/klibc/mmap.c +++ b/klibc/klibc/mmap.c @@ -19,7 +19,7 @@ * Prefer mmap2() over mmap(), except on the architectures listed */ -#if defined(__NR_mmap2) && !defined(__sparc__) && !defined(__ia64__) && !defined(__powerpc64__) +#if defined(__NR_mmap2) && !defined(__sparc__) && !defined(__ia64__) && !defined(__powerpc__) && !defined(__powerpc64__) /* This architecture uses mmap2() */ diff --git a/klibc/klibc/syscommon.h b/klibc/klibc/syscommon.h index 30939207..42902527 100644 --- a/klibc/klibc/syscommon.h +++ b/klibc/klibc/syscommon.h @@ -28,5 +28,5 @@ #include #ifdef __i386__ -#include +# include #endif diff --git a/klibc/version b/klibc/version index 0f6db3dd..2f3d7fa9 100644 --- a/klibc/version +++ b/klibc/version @@ -1 +1 @@ -0.98 +0.101 -- 2.39.5