diff options
Diffstat (limited to 'libc')
-rw-r--r-- | libc/Makefile.in | 4 | ||||
-rw-r--r-- | libc/misc/Makefile.in | 1 | ||||
-rw-r--r-- | libc/misc/internals/Makefile.in | 14 | ||||
-rw-r--r-- | libc/misc/pthread/Makefile.in | 3 | ||||
-rw-r--r-- | libc/pwd_grp/Makefile.in | 2 | ||||
-rw-r--r-- | libc/pwd_grp/pwd_grp.c | 2 | ||||
-rw-r--r-- | libc/pwd_grp/pwd_grp_internal.c | 2 | ||||
-rw-r--r-- | libc/stdlib/Makefile.in | 5 | ||||
-rw-r--r-- | libc/stdlib/malloc-standard/Makefile.in | 5 | ||||
-rw-r--r-- | libc/string/generic/memmove.c | 8 | ||||
-rw-r--r-- | libc/string/mips/memcpy.S | 119 | ||||
-rw-r--r-- | libc/string/mips/memset.S | 71 | ||||
-rw-r--r-- | libc/string/strdup.c | 10 | ||||
-rw-r--r-- | libc/sysdeps/linux/common/bits/uClibc_errno.h | 8 | ||||
-rw-r--r-- | libc/sysdeps/linux/common/bits/uClibc_pthread.h | 25 | ||||
-rw-r--r-- | libc/sysdeps/linux/common/bits/uClibc_stdio.h | 118 | ||||
-rw-r--r-- | libc/unistd/sysconf.c | 49 |
17 files changed, 317 insertions, 129 deletions
diff --git a/libc/Makefile.in b/libc/Makefile.in index 450ad5ec2..f3cd20922 100644 --- a/libc/Makefile.in +++ b/libc/Makefile.in @@ -50,6 +50,7 @@ libc-multi-y = $(filter-out $(libc-nomulti-y:.o=.c),$(all_sources)) endif lib-a-y += $(top_builddir)lib/libc.a +lib-gdb-y += $(top_builddir)lib/libc.gdb lib-so-y += $(libc) objclean-y += libc_clean @@ -89,5 +90,8 @@ $(top_builddir)lib/libc.a: $(libc-a-y) | $(crt-y) $(do_strip) $(do_ar) +$(top_builddir)lib/libc.gdb: $(top_builddir)lib/libc.a $(LINK_FLAT_CRTS) + $(call link-flat.so,$(@:.gdb=),$(SHARED_FLAT_ID)) + libc_clean: $(RM) $(libc_OUT)/*.{o,os,oS,a} diff --git a/libc/misc/Makefile.in b/libc/misc/Makefile.in index 542859576..104db366e 100644 --- a/libc/misc/Makefile.in +++ b/libc/misc/Makefile.in @@ -20,7 +20,6 @@ include $(top_srcdir)libc/misc/gnu/Makefile.in include $(top_srcdir)libc/misc/internals/Makefile.in include $(top_srcdir)libc/misc/locale/Makefile.in include $(top_srcdir)libc/misc/mntent/Makefile.in -include $(top_srcdir)libc/misc/pthread/Makefile.in include $(top_srcdir)libc/misc/regex/Makefile.in include $(top_srcdir)libc/misc/search/Makefile.in include $(top_srcdir)libc/misc/statfs/Makefile.in diff --git a/libc/misc/internals/Makefile.in b/libc/misc/internals/Makefile.in index 8237c2f6c..4d57cf4e3 100644 --- a/libc/misc/internals/Makefile.in +++ b/libc/misc/internals/Makefile.in @@ -7,7 +7,7 @@ CFLAGS-__uClibc_main.c := $(SSP_DISABLE_FLAGS) -CSRC := tempname.c __errno_location.c __h_errno_location.c +CSRC := tempname.c errno.c __errno_location.c __h_errno_location.c MISC_INTERNALS_DIR := $(top_srcdir)libc/misc/internals MISC_INTERNALS_OUT := $(top_builddir)libc/misc/internals @@ -16,14 +16,14 @@ MISC_INTERNALS_SRC := $(patsubst %.c,$(MISC_INTERNALS_DIR)/%.c,$(CSRC)) MISC_INTERNALS_OBJ := $(patsubst %.c,$(MISC_INTERNALS_OUT)/%.o,$(CSRC)) libc-y += $(MISC_INTERNALS_OBJ) -libc-shared-y += $(MISC_INTERNALS_OUT)/__uClibc_main.oS \ - $(MISC_INTERNALS_OUT)/errno.oS -libc-static-y += $(MISC_INTERNALS_OUT)/__uClibc_main.o \ - $(MISC_INTERNALS_OUT)/errno.o -libc-nomulti-y += $(MISC_INTERNALS_OUT)/__uClibc_main.o \ - $(MISC_INTERNALS_OUT)/errno.o +libc-shared-y += $(MISC_INTERNALS_OUT)/__uClibc_main.oS +libc-static-y += $(MISC_INTERNALS_OUT)/__uClibc_main.o libc-so-y += $(MISC_INTERNALS_OUT)/__uClibc_main.oS \ $(MISC_INTERNALS_OUT)/errno.oS $(MISC_INTERNALS_OBJ:.o=.oS) +libc-static-$(UCLIBC_FORMAT_SHARED_FLAT) += \ + $(MISC_INTERNALS_OUT)/shared_flat_initfini.o \ + $(MISC_INTERNALS_OUT)/shared_flat_add_library.o +libc-nomulti-y += $(MISC_INTERNALS_OUT)/__uClibc_main.o objclean-y += misc_internals_objclean diff --git a/libc/misc/pthread/Makefile.in b/libc/misc/pthread/Makefile.in index fc138c91a..0d7a9e49d 100644 --- a/libc/misc/pthread/Makefile.in +++ b/libc/misc/pthread/Makefile.in @@ -8,7 +8,8 @@ MISC_PTHREAD_DIR := $(top_srcdir)libc/misc/pthread MISC_PTHREAD_OUT := $(top_builddir)libc/misc/pthread -libc-static-$(UCLIBC_HAS_THREADS) += $(MISC_PTHREAD_OUT)/weaks.o +libc-$(UCLIBC_HAS_THREADS) += $(MISC_PTHREAD_OUT)/unlock.o +libc-$(UCLIBC_HAS_THREADS) += $(MISC_PTHREAD_OUT)/weaks.o objclean-y += misc_pthread_objclean diff --git a/libc/pwd_grp/Makefile.in b/libc/pwd_grp/Makefile.in index 47699e0fa..28d7ea075 100644 --- a/libc/pwd_grp/Makefile.in +++ b/libc/pwd_grp/Makefile.in @@ -11,7 +11,7 @@ PWDGRP_OUT := $(top_builddir)libc/pwd_grp CSRC := $(notdir $(wildcard $(PWDGRP_DIR)/*.c)) CSRC := $(filter-out pwd_grp.c pwd_grp_internal.c,$(CSRC)) -ifneq ($(HAS_SHADOW),y) +ifneq ($(UCLIBC_HAS_SHADOW),y) SHADOW_CSRC := \ fgetspent_r.c fgetspent.c getspent_r.c getspent.c \ getspnam_r.c getspnam.c lckpwdf.c putspent.c \ diff --git a/libc/pwd_grp/pwd_grp.c b/libc/pwd_grp/pwd_grp.c index 961899af9..2a9d4519a 100644 --- a/libc/pwd_grp/pwd_grp.c +++ b/libc/pwd_grp/pwd_grp.c @@ -31,7 +31,7 @@ #include <pwd.h> #include <grp.h> #include <paths.h> -#ifdef __HAS_SHADOW__ +#ifdef __UCLIBC_HAS_SHADOW__ #include <shadow.h> #endif #ifdef __UCLIBC_HAS_THREADS__ diff --git a/libc/pwd_grp/pwd_grp_internal.c b/libc/pwd_grp/pwd_grp_internal.c index cb0ae76cf..c89747890 100644 --- a/libc/pwd_grp/pwd_grp_internal.c +++ b/libc/pwd_grp/pwd_grp_internal.c @@ -31,7 +31,7 @@ #include <pwd.h> #include <grp.h> #include <paths.h> -#ifdef __HAS_SHADOW__ +#ifdef __UCLIBC_HAS_SHADOW__ #include <shadow.h> #endif #ifdef __UCLIBC_HAS_THREADS__ diff --git a/libc/stdlib/Makefile.in b/libc/stdlib/Makefile.in index e6948849b..f08e24795 100644 --- a/libc/stdlib/Makefile.in +++ b/libc/stdlib/Makefile.in @@ -12,7 +12,7 @@ include $(top_srcdir)libc/stdlib/malloc-standard/Makefile.in CSRC := \ abort.c getenv.c mkdtemp.c mktemp.c realpath.c mkstemp.c \ rand.c random.c random_r.c setenv.c system.c div.c ldiv.c lldiv.c \ - getpt.c ptsname.c grantpt.c unlockpt.c gcvt.c drand48-iter.c jrand48.c \ + getpt.c ptsname.c grantpt.c unlockpt.c drand48-iter.c jrand48.c \ jrand48_r.c lrand48.c lrand48_r.c mrand48.c mrand48_r.c nrand48.c \ nrand48_r.c rand_r.c srand48.c srand48_r.c seed48.c seed48_r.c \ valloc.c posix_memalign.c a64l.c l64a.c @@ -24,6 +24,9 @@ CSRC += mkstemp64.c endif ifeq ($(UCLIBC_HAS_FLOATS),y) CSRC += drand48.c drand48_r.c erand48.c erand48_r.c +ifeq ($(UCLIBC_SUSV3_LEGACY),y) +CSRC += gcvt.c +endif endif # multi source stdlib.c diff --git a/libc/stdlib/malloc-standard/Makefile.in b/libc/stdlib/malloc-standard/Makefile.in index 12445bbf1..e3ae73715 100644 --- a/libc/stdlib/malloc-standard/Makefile.in +++ b/libc/stdlib/malloc-standard/Makefile.in @@ -5,11 +5,6 @@ # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. # -# Turn on malloc debugging if requested -ifeq ($(UCLIBC_MALLOC_DEBUGGING),y) -CFLAGS += -D__MALLOC_DEBUGGING -endif - # calloc.c can be found at uClibc/libc/stdlib/calloc.c # valloc.c can be found at uClibc/libc/stdlib/valloc.c CSRC := malloc.c calloc.c realloc.c free.c memalign.c mallopt.c mallinfo.c diff --git a/libc/string/generic/memmove.c b/libc/string/generic/memmove.c index 0e51ea771..68caacd78 100644 --- a/libc/string/generic/memmove.c +++ b/libc/string/generic/memmove.c @@ -29,8 +29,7 @@ libc_hidden_proto(memcpy) static void _wordcopy_bwd_aligned (long int dstp, long int srcp, size_t len) { - op_t a0 = 0; - op_t a1 = 0; + op_t a0, a1; switch (len % 8) { @@ -134,10 +133,7 @@ static void _wordcopy_bwd_aligned (long int dstp, long int srcp, size_t len) static void _wordcopy_bwd_dest_aligned (long int dstp, long int srcp, size_t len) { - op_t a0 = 0; - op_t a1 = 0; - op_t a2 = 0; - op_t a3 = 0; + op_t a0, a1, a2, a3; int sh_1, sh_2; /* Calculate how to shift a word read at the memory operation diff --git a/libc/string/mips/memcpy.S b/libc/string/mips/memcpy.S index 155bc1128..9b05ee6da 100644 --- a/libc/string/mips/memcpy.S +++ b/libc/string/mips/memcpy.S @@ -22,11 +22,124 @@ #include <endian.h> #include "sysdep.h" +/* void *memcpy(void *s1, const void *s2, size_t n); */ + #ifdef __mips64 -#error mips32 code being compiled for mips64! + +#include <sys/asm.h> + +#if __BYTE_ORDER == __BIG_ENDIAN +# define LDHI ldl /* high part is left in big-endian */ +# define SDHI sdl /* high part is left in big-endian */ +# define LDLO ldr /* low part is right in big-endian */ +# define SDLO sdr /* low part is right in big-endian */ +#else +# define LDHI ldr /* high part is right in little-endian */ +# define SDHI sdr /* high part is right in little-endian */ +# define LDLO ldl /* low part is left in little-endian */ +# define SDLO sdl /* low part is left in little-endian */ #endif -/* void *memcpy(void *s1, const void *s2, size_t n); */ +ENTRY (memcpy) + .set noreorder + + slti t0, a2, 16 # Less than 16? + bne t0, zero, L(last16) + move v0, a0 # Setup exit value before too late + + xor t0, a1, a0 # Find a0/a1 displacement + andi t0, 0x7 + bne t0, zero, L(shift) # Go handle the unaligned case + PTR_SUBU t1, zero, a1 + andi t1, 0x7 # a0/a1 are aligned, but are we + beq t1, zero, L(chk8w) # starting in the middle of a word? + PTR_SUBU a2, t1 + LDHI t0, 0(a1) # Yes we are... take care of that + PTR_ADDU a1, t1 + SDHI t0, 0(a0) + PTR_ADDU a0, t1 + +L(chk8w): + andi t0, a2, 0x3f # 64 or more bytes left? + beq t0, a2, L(chk1w) + PTR_SUBU a3, a2, t0 # Yes + PTR_ADDU a3, a1 # a3 = end address of loop + move a2, t0 # a2 = what will be left after loop +L(lop8w): + ld t0, 0(a1) # Loop taking 8 words at a time + ld t1, 8(a1) + ld t2, 16(a1) + ld t3, 24(a1) + ld ta0, 32(a1) + ld ta1, 40(a1) + ld ta2, 48(a1) + ld ta3, 56(a1) + PTR_ADDIU a0, 64 + PTR_ADDIU a1, 64 + sd t0, -64(a0) + sd t1, -56(a0) + sd t2, -48(a0) + sd t3, -40(a0) + sd ta0, -32(a0) + sd ta1, -24(a0) + sd ta2, -16(a0) + bne a1, a3, L(lop8w) + sd ta3, -8(a0) + +L(chk1w): + andi t0, a2, 0x7 # 8 or more bytes left? + beq t0, a2, L(last16) + PTR_SUBU a3, a2, t0 # Yes, handle them one dword at a time + PTR_ADDU a3, a1 # a3 again end address + move a2, t0 +L(lop1w): + ld t0, 0(a1) + PTR_ADDIU a0, 8 + PTR_ADDIU a1, 8 + bne a1, a3, L(lop1w) + sd t0, -8(a0) + +L(last16): + blez a2, L(lst16e) # Handle last 16 bytes, one at a time + PTR_ADDU a3, a2, a1 +L(lst16l): + lb t0, 0(a1) + PTR_ADDIU a0, 1 + PTR_ADDIU a1, 1 + bne a1, a3, L(lst16l) + sb t0, -1(a0) +L(lst16e): + jr ra # Bye, bye + nop + +L(shift): + PTR_SUBU a3, zero, a0 # Src and Dest unaligned + andi a3, 0x7 # (unoptimized case...) + beq a3, zero, L(shft1) + PTR_SUBU a2, a3 # a2 = bytes left + LDHI t0, 0(a1) # Take care of first odd part + LDLO t0, 7(a1) + PTR_ADDU a1, a3 + SDHI t0, 0(a0) + PTR_ADDU a0, a3 +L(shft1): + andi t0, a2, 0x7 + PTR_SUBU a3, a2, t0 + PTR_ADDU a3, a1 +L(shfth): + LDHI t1, 0(a1) # Limp through, dword by dword + LDLO t1, 7(a1) + PTR_ADDIU a0, 8 + PTR_ADDIU a1, 8 + bne a1, a3, L(shfth) + sd t1, -8(a0) + b L(last16) # Handle anything which may be left + move a2, t0 + + .set reorder +END (memcpy) + +#else /* !__mips64 */ #if __BYTE_ORDER == __BIG_ENDIAN # define LWHI lwl /* high part is left in big-endian */ @@ -139,4 +252,6 @@ L(shfth): .set reorder END (memcpy) +#endif /* !__mips64 */ + libc_hidden_def(memcpy) diff --git a/libc/string/mips/memset.S b/libc/string/mips/memset.S index 9169ad58a..ff0554ff9 100644 --- a/libc/string/mips/memset.S +++ b/libc/string/mips/memset.S @@ -22,11 +22,76 @@ #include <endian.h> #include "sysdep.h" +/* void *memset(void *s, int c, size_t n). */ + #ifdef __mips64 -#error mips32 code being compiled for mips64! + +#include <sys/asm.h> + +#if __BYTE_ORDER == __BIG_ENDIAN +# define SDHI sdl /* high part is left in big-endian */ +#else +# define SDHI sdr /* high part is right in little-endian */ #endif -/* void *memset(void *s, int c, size_t n). */ +ENTRY (memset) + .set noreorder + + slti ta1, a2, 16 # Less than 16? + bne ta1, zero, L(last16) + move v0, a0 # Setup exit value before too late + + beq a1, zero, L(ueven) # If zero pattern, no need to extend + andi a1, 0xff # Avoid problems with bogus arguments + dsll ta0, a1, 8 + or a1, ta0 + dsll ta0, a1, 16 + or a1, ta0 # a1 is now pattern in full word + dsll ta0, a1, 32 + or a1, ta0 # a1 is now pattern in double word + +L(ueven): + PTR_SUBU ta0, zero, a0 # Unaligned address? + andi ta0, 0x7 + beq ta0, zero, L(chkw) + PTR_SUBU a2, ta0 + SDHI a1, 0(a0) # Yes, handle first unaligned part + PTR_ADDU a0, ta0 # Now both a0 and a2 are updated + +L(chkw): + andi ta0, a2, 0xf # Enough left for one loop iteration? + beq ta0, a2, L(chkl) + PTR_SUBU a3, a2, ta0 + PTR_ADDU a3, a0 # a3 is last loop address +1 + move a2, ta0 # a2 is now # of bytes left after loop +L(loopw): + PTR_ADDIU a0, 16 # Handle 2 dwords pr. iteration + sd a1, -16(a0) + bne a0, a3, L(loopw) + sd a1, -8(a0) + +L(chkl): + andi ta0, a2, 0x8 # Check if there is at least a double + beq ta0, zero, L(last16) # word remaining after the loop + PTR_SUBU a2, ta0 + sd a1, 0(a0) # Yes... + PTR_ADDIU a0, 8 + +L(last16): + blez a2, L(exit) # Handle last 16 bytes (if cnt>0) + PTR_ADDU a3, a2, a0 # a3 is last address +1 +L(lst16l): + PTR_ADDIU a0, 1 + bne a0, a3, L(lst16l) + sb a1, -1(a0) +L(exit): + j ra # Bye, bye + nop + + .set reorder +END (memset) + +#else /* !__mips64 */ #if __BYTE_ORDER == __BIG_ENDIAN # define SWHI swl /* high part is left in big-endian */ @@ -89,4 +154,6 @@ L(exit): .set reorder END (memset) +#endif /* !__mips64 */ + libc_hidden_def(memset) diff --git a/libc/string/strdup.c b/libc/string/strdup.c index dff5af60a..d15345d0d 100644 --- a/libc/string/strdup.c +++ b/libc/string/strdup.c @@ -10,25 +10,23 @@ #ifdef WANT_WIDE libc_hidden_proto(wcslen) -libc_hidden_proto(wcscpy) # define Wstrdup wcsdup # define Wstrlen wcslen -# define Wstrcpy wcscpy #else libc_hidden_proto(strdup) libc_hidden_proto(strlen) -libc_hidden_proto(strcpy) # define Wstrdup strdup # define Wstrlen strlen -# define Wstrcpy strcpy #endif +libc_hidden_proto(memcpy) Wchar *Wstrdup(register const Wchar *s1) { register Wchar *s; + register size_t l = (Wstrlen(s1) + 1) * sizeof(Wchar); - if ((s = malloc((Wstrlen(s1) + 1) * sizeof(Wchar))) != NULL) { - Wstrcpy(s, s1); + if ((s = malloc(l)) != NULL) { + memcpy(s, s1, l); } return s; diff --git a/libc/sysdeps/linux/common/bits/uClibc_errno.h b/libc/sysdeps/linux/common/bits/uClibc_errno.h index 9da9f8155..4cb2a8caa 100644 --- a/libc/sysdeps/linux/common/bits/uClibc_errno.h +++ b/libc/sysdeps/linux/common/bits/uClibc_errno.h @@ -31,10 +31,12 @@ extern int *__errno_location (void) __THROW __attribute__ ((__const__)) attribute_hidden # endif ; -#include <tls.h> -#if USE___THREAD +# if defined __UCLIBC_HAS_THREADS__ +# include <tls.h> +# if USE___THREAD libc_hidden_proto(__errno_location) -#endif +# endif +# endif /* We now need a declaration of the `errno' variable. */ # ifndef __UCLIBC_HAS_THREADS__ diff --git a/libc/sysdeps/linux/common/bits/uClibc_pthread.h b/libc/sysdeps/linux/common/bits/uClibc_pthread.h index a3be2ca35..1d6209f5e 100644 --- a/libc/sysdeps/linux/common/bits/uClibc_pthread.h +++ b/libc/sysdeps/linux/common/bits/uClibc_pthread.h @@ -27,11 +27,24 @@ # error "Always include <pthread.h> rather than <bits/uClibc_pthread.h>" #endif -extern int __pthread_mutex_init (pthread_mutex_t *__restrict __mutex, - __const pthread_mutexattr_t *__restrict - __mutex_attr) attribute_hidden; -extern int __pthread_mutex_trylock (pthread_mutex_t *__mutex) attribute_hidden; -extern int __pthread_mutex_lock (pthread_mutex_t *__mutex) attribute_hidden; -extern int __pthread_mutex_unlock (pthread_mutex_t *__mutex) attribute_hidden; +#if defined _LIBC && (defined IS_IN_libc || defined NOT_IN_libc) +/* Threading functions internal to uClibc. Make these thread functions + * weak so that we can elide them from single-threaded processes. */ +extern int weak_function __pthread_mutex_init (pthread_mutex_t *__mutex, + __const pthread_mutexattr_t *__mutex_attr); +extern int weak_function __pthread_mutex_destroy (pthread_mutex_t *__mutex); +extern int weak_function __pthread_mutex_lock (pthread_mutex_t *__mutex); +extern int weak_function __pthread_mutex_unlock (pthread_mutex_t *__mutex); +extern void __uclibc_mutex_unlock (void *) attribute_hidden; +extern int weak_function __pthread_mutex_trylock (pthread_mutex_t *__mutex); +# ifndef __UCLIBC_HAS_THREADS_NATIVE__ +extern void weak_function _pthread_cleanup_push_defer ( + struct _pthread_cleanup_buffer *__buffer, + void (*__routine) (void *), void *__arg); +extern void weak_function _pthread_cleanup_pop_restore ( + struct _pthread_cleanup_buffer *__buffer, + int __execute); +# endif +#endif #endif diff --git a/libc/sysdeps/linux/common/bits/uClibc_stdio.h b/libc/sysdeps/linux/common/bits/uClibc_stdio.h index d73da9de7..a75f971eb 100644 --- a/libc/sysdeps/linux/common/bits/uClibc_stdio.h +++ b/libc/sysdeps/linux/common/bits/uClibc_stdio.h @@ -1,21 +1,8 @@ /* Copyright (C) 2002-2004 Manuel Novoa III <mjn3@codepoet.org> * - * Dedicated to Toni. See uClibc/DEDICATION.mjn3 for details. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * The GNU C Library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * GNU Library General Public License (LGPL) version 2 or later. * - * You should have received a copy of the GNU Lesser General Public - * License along with the GNU C Library; if not, write to the Free - * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - * 02111-1307 USA. + * Dedicated to Toni. See uClibc/DEDICATION.mjn3 for details. */ #ifndef _STDIO_H @@ -242,7 +229,7 @@ typedef struct { /**********************************************************************/ #ifdef __UCLIBC_HAS_LFS__ -typedef __off64_t __offmax_t; /* TODO -- rename this? */ +typedef __off64_t __offmax_t; /* TODO -- rename this? */ #else typedef __off_t __offmax_t; /* TODO -- rename this? */ #endif @@ -252,7 +239,7 @@ typedef __off_t __offmax_t; /* TODO -- rename this? */ typedef __ssize_t __io_read_fn(void *__cookie, char *__buf, size_t __bufsize); typedef __ssize_t __io_write_fn(void *__cookie, - __const char *__buf, size_t __bufsize); + __const char *__buf, size_t __bufsize); /* NOTE: GLIBC difference!!! -- fopencookie seek function * For glibc, the type of pos is always (__off64_t *) but in our case * it is type (__off_t *) when the lib is built without large file support. @@ -359,24 +346,25 @@ struct __STDIO_FILE_STRUCT { #define __MASK_READING 0x0003U /* (0x0001 | 0x0002) */ #define __FLAG_READING 0x0001U -#define __FLAG_UNGOT 0x0002U -#define __FLAG_EOF 0x0004U +#define __FLAG_UNGOT 0x0002U +#define __FLAG_EOF 0x0004U #define __FLAG_ERROR 0x0008U -#define __FLAG_WRITEONLY 0x0010U -#define __FLAG_READONLY 0x0020U /* (__FLAG_WRITEONLY << 1) */ +#define __FLAG_WRITEONLY 0x0010U +#define __FLAG_READONLY 0x0020U /* (__FLAG_WRITEONLY << 1) */ #define __FLAG_WRITING 0x0040U -#define __FLAG_NARROW 0x0080U - -#define __FLAG_FBF 0x0000U /* must be 0 */ -#define __FLAG_LBF 0x0100U -#define __FLAG_NBF 0x0200U /* (__FLAG_LBF << 1) */ -#define __MASK_BUFMODE 0x0300U /* (__FLAG_LBF|__FLAG_NBF) */ -#define __FLAG_APPEND 0x0400U /* fixed! == O_APPEND for linux */ -#define __FLAG_WIDE 0x0800U -/* available slot 0x1000U */ +#define __FLAG_NARROW 0x0080U + +#define __FLAG_FBF 0x0000U /* must be 0 */ +#define __FLAG_LBF 0x0100U +#define __FLAG_NBF 0x0200U /* (__FLAG_LBF << 1) */ +#define __MASK_BUFMODE 0x0300U /* (__FLAG_LBF|__FLAG_NBF) */ +#define __FLAG_APPEND 0x0400U /* fixed! == O_APPEND for linux */ +#define __FLAG_WIDE 0x0800U +/* available slot 0x1000U */ #define __FLAG_FREEFILE 0x2000U #define __FLAG_FREEBUF 0x4000U -#define __FLAG_LARGEFILE 0x8000U /* fixed! == 0_LARGEFILE for linux */ +#define __FLAG_LARGEFILE 0x8000U /* fixed! == 0_LARGEFILE for linux */ +#define __FLAG_FAILED_FREOPEN __FLAG_LARGEFILE /* Note: In no-buffer mode, it would be possible to pack the necessary * flags into one byte. Since we wouldn't be buffering and there would @@ -422,17 +410,17 @@ extern void __stdio_init_mutex(pthread_mutex_t *m) attribute_hidden; #endif /**********************************************************************/ -#define __CLEARERR_UNLOCKED(__stream) \ +#define __CLEARERR_UNLOCKED(__stream) \ ((void)((__stream)->__modeflags &= ~(__FLAG_EOF|__FLAG_ERROR))) #define __FEOF_UNLOCKED(__stream) ((__stream)->__modeflags & __FLAG_EOF) #define __FERROR_UNLOCKED(__stream) ((__stream)->__modeflags & __FLAG_ERROR) #ifdef __UCLIBC_HAS_THREADS__ -# define __CLEARERR(__stream) (clearerr)(__stream) +# define __CLEARERR(__stream) (clearerr)(__stream) # define __FERROR(__stream) (ferror)(__stream) # define __FEOF(__stream) (feof)(__stream) #else -# define __CLEARERR(__stream) __CLEARERR_UNLOCKED(__stream) +# define __CLEARERR(__stream) __CLEARERR_UNLOCKED(__stream) # define __FERROR(__stream) __FERROR_UNLOCKED(__stream) # define __FEOF(__stream) __FEOF_UNLOCKED(__stream) #endif @@ -440,17 +428,17 @@ extern void __stdio_init_mutex(pthread_mutex_t *m) attribute_hidden; extern int __fgetc_unlocked(FILE *__stream); extern int __fputc_unlocked(int __c, FILE *__stream); -/* First define the default definitions. They will be overwritten below as necessary. */ +/* First define the default definitions. They overriden below as necessary. */ #define __FGETC_UNLOCKED(__stream) (__fgetc_unlocked)((__stream)) -#define __FGETC(__stream) (fgetc)((__stream)) -#define __GETC_UNLOCKED_MACRO(__stream) (__fgetc_unlocked)((__stream)) +#define __FGETC(__stream) (fgetc)((__stream)) +#define __GETC_UNLOCKED_MACRO(__stream) (__fgetc_unlocked)((__stream)) #define __GETC_UNLOCKED(__stream) (__fgetc_unlocked)((__stream)) -#define __GETC(__stream) (fgetc)((__stream)) +#define __GETC(__stream) (fgetc)((__stream)) -#define __FPUTC_UNLOCKED(__c, __stream) (__fputc_unlocked)((__c),(__stream)) +#define __FPUTC_UNLOCKED(__c, __stream) (__fputc_unlocked)((__c),(__stream)) #define __FPUTC(__c, __stream) (fputc)((__c),(__stream)) -#define __PUTC_UNLOCKED_MACRO(__c, __stream) (__fputc_unlocked)((__c),(__stream)) -#define __PUTC_UNLOCKED(__c, __stream) (__fputc_unlocked)((__c),(__stream)) +#define __PUTC_UNLOCKED_MACRO(__c, __stream) (__fputc_unlocked)((__c),(__stream)) +#define __PUTC_UNLOCKED(__c, __stream) (__fputc_unlocked)((__c),(__stream)) #define __PUTC(__c, __stream) (fputc)((__c),(__stream)) @@ -459,9 +447,9 @@ extern int __fputc_unlocked(int __c, FILE *__stream); extern FILE *__stdin; /* For getchar() macro. */ # undef __GETC_UNLOCKED_MACRO -# define __GETC_UNLOCKED_MACRO(__stream) \ +# define __GETC_UNLOCKED_MACRO(__stream) \ ( ((__stream)->__bufpos < (__stream)->__bufgetc_u) \ - ? (*(__stream)->__bufpos++) \ + ? (*(__stream)->__bufpos++) \ : __fgetc_unlocked(__stream) ) # if 0 @@ -476,10 +464,10 @@ extern FILE *__stdin; /* For getchar() macro. */ # else /* Using gcc extension for safety and additional inlining. */ # undef __FGETC_UNLOCKED -# define __FGETC_UNLOCKED(__stream) \ +# define __FGETC_UNLOCKED(__stream) \ (__extension__ ({ \ - FILE *__S = (__stream); \ - __GETC_UNLOCKED_MACRO(__S); \ + FILE *__S = (__stream); \ + __GETC_UNLOCKED_MACRO(__S); \ }) ) # undef __GETC_UNLOCKED @@ -487,23 +475,23 @@ extern FILE *__stdin; /* For getchar() macro. */ # ifdef __UCLIBC_HAS_THREADS__ # undef __FGETC -# define __FGETC(__stream) \ +# define __FGETC(__stream) \ (__extension__ ({ \ - FILE *__S = (__stream); \ - ((__S->__user_locking ) \ - ? __GETC_UNLOCKED_MACRO(__S) \ + FILE *__S = (__stream); \ + ((__S->__user_locking ) \ + ? __GETC_UNLOCKED_MACRO(__S) \ : (fgetc)(__S)); \ }) ) # undef __GETC -# define __GETC(__stream) __FGETC((__stream)) +# define __GETC(__stream) __FGETC((__stream)) -# else +# else # undef __FGETC # define __FGETC(__stream) __FGETC_UNLOCKED((__stream)) # undef __GETC -# define __GETC(__stream) __FGETC_UNLOCKED((__stream)) +# define __GETC(__stream) __FGETC_UNLOCKED((__stream)) # endif # endif @@ -518,16 +506,16 @@ extern FILE *__stdin; /* For getchar() macro. */ extern FILE *__stdout; /* For putchar() macro. */ # undef __PUTC_UNLOCKED_MACRO -# define __PUTC_UNLOCKED_MACRO(__c, __stream) \ +# define __PUTC_UNLOCKED_MACRO(__c, __stream) \ ( ((__stream)->__bufpos < (__stream)->__bufputc_u) \ - ? (*(__stream)->__bufpos++) = (__c) \ + ? (*(__stream)->__bufpos++) = (__c) \ : __fputc_unlocked((__c),(__stream)) ) # if 0 /* Classic macro approach. putc{_unlocked} can have side effects.*/ # undef __PUTC_UNLOCKED -# define __PUTC_UNLOCKED(__c, __stream) \ - __PUTC_UNLOCKED_MACRO((__c), (__stream)) +# define __PUTC_UNLOCKED(__c, __stream) \ + __PUTC_UNLOCKED_MACRO((__c), (__stream)) # ifndef __UCLIBC_HAS_THREADS__ # undef __PUTC # define __PUTC(__c, __stream) __PUTC_UNLOCKED_MACRO((__c), (__stream)) @@ -537,10 +525,10 @@ extern FILE *__stdout; /* For putchar() macro. */ /* Using gcc extension for safety and additional inlining. */ # undef __FPUTC_UNLOCKED -# define __FPUTC_UNLOCKED(__c, __stream) \ - (__extension__ ({ \ +# define __FPUTC_UNLOCKED(__c, __stream) \ + (__extension__ ({ \ FILE *__S = (__stream); \ - __PUTC_UNLOCKED_MACRO((__c),__S); \ + __PUTC_UNLOCKED_MACRO((__c),__S); \ }) ) # undef __PUTC_UNLOCKED @@ -548,11 +536,11 @@ extern FILE *__stdout; /* For putchar() macro. */ # ifdef __UCLIBC_HAS_THREADS__ # undef __FPUTC -# define __FPUTC(__c, __stream) \ - (__extension__ ({ \ +# define __FPUTC(__c, __stream) \ + (__extension__ ({ \ FILE *__S = (__stream); \ ((__S->__user_locking) \ - ? __PUTC_UNLOCKED_MACRO((__c),__S) \ + ? __PUTC_UNLOCKED_MACRO((__c),__S) \ : (fputc)((__c),__S)); \ }) ) @@ -562,9 +550,9 @@ extern FILE *__stdout; /* For putchar() macro. */ # else # undef __FPUTC -# define __FPUTC(__c, __stream) __FPUTC_UNLOCKED((__c),(__stream)) +# define __FPUTC(__c, __stream) __FPUTC_UNLOCKED((__c),(__stream)) # undef __PUTC -# define __PUTC(__c, __stream) __FPUTC_UNLOCKED((__c),(__stream)) +# define __PUTC(__c, __stream) __FPUTC_UNLOCKED((__c),(__stream)) # endif # endif diff --git a/libc/unistd/sysconf.c b/libc/unistd/sysconf.c index 430759889..c02a25440 100644 --- a/libc/unistd/sysconf.c +++ b/libc/unistd/sysconf.c @@ -1,4 +1,3 @@ -/* vi: set sw=4 ts=4: */ /* Copyright (C) 1991, 93, 95, 96, 97, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -85,26 +84,6 @@ long int sysconf(int name) __set_errno(EINVAL); return -1; -#ifdef __UCLIBC_HAS_THREADS_NATIVE__ -# ifdef __NR_clock_getres - case _SC_MONOTONIC_CLOCK: - /* Check using the clock_getres system call. */ - { - struct timespec ts; - INTERNAL_SYSCALL_DECL (err); - int r; - r = INTERNAL_SYSCALL (clock_getres, err, 2, CLOCK_MONOTONIC, &ts); - return INTERNAL_SYSCALL_ERROR_P (r, err) ? -1 : _POSIX_VERSION; - } -# endif - case _SC_THREAD_CPUTIME: -# ifdef _POSIX_THREAD_CPUTIME > 0 - return _POSIX_THREAD_CPUTIME; -# else - return -1; -# endif -#endif - case _SC_ARG_MAX: #ifdef ARG_MAX return ARG_MAX; @@ -907,6 +886,34 @@ long int sysconf(int name) #else RETURN_NEG_1; #endif + +#ifdef __NR_clock_getres + case _SC_MONOTONIC_CLOCK: + /* Check using the clock_getres system call. */ +# ifdef __UCLIBC_HAS_THREADS_NATIVE__ + { + struct timespec ts; + INTERNAL_SYSCALL_DECL (err); + int r; + r = INTERNAL_SYSCALL (clock_getres, err, 2, CLOCK_MONOTONIC, &ts); + return INTERNAL_SYSCALL_ERROR_P (r, err) ? -1 : _POSIX_VERSION; + } +# else + if (clock_getres(CLOCK_MONOTONIC, NULL) >= 0) + return _POSIX_VERSION; + + RETURN_NEG_1; +# endif +#endif + +#ifdef __UCLIBC_HAS_THREADS_NATIVE__ + case _SC_THREAD_CPUTIME: +# ifdef _POSIX_THREAD_CPUTIME > 0 + return _POSIX_THREAD_CPUTIME; +# else + RETURN_NEG_1; +# endif +#endif } } libc_hidden_def(sysconf) |