diff options
Diffstat (limited to 'libc')
| -rw-r--r-- | libc/stdio/Makefile.in | 3 | ||||
| -rw-r--r-- | libc/stdio/_fopen.c | 16 | ||||
| -rw-r--r-- | libc/stdio/_scanf.c | 5 | ||||
| -rw-r--r-- | libc/stdio/_stdio.c | 11 | ||||
| -rw-r--r-- | libc/stdio/_stdio.h | 21 | ||||
| -rw-r--r-- | libc/stdio/tmpfile.c | 10 |
6 files changed, 36 insertions, 30 deletions
diff --git a/libc/stdio/Makefile.in b/libc/stdio/Makefile.in index 5d4d74ed2..5b8e86652 100644 --- a/libc/stdio/Makefile.in +++ b/libc/stdio/Makefile.in @@ -1,6 +1,5 @@ # Makefile for uClibc # -# Copyright (C) 2000 by Lineo, inc. # Copyright (C) 2004 Manuel Novoa III <mjn3@uclibc.org> # Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org> # @@ -93,6 +92,8 @@ STDIO_SRC := $(patsubst %.c,$(STDIO_DIR)/%.c,$(CSRC)) STDIO_OBJ := $(patsubst %.c,$(STDIO_OUT)/%.o,$(CSRC)) libc-y += $(STDIO_OBJ) +libc-a-y += $(STDIO_OBJ) +libc-so-y += $(STDIO_OBJ:.o=.os) ifneq ($(USE_OLD_VFPRINTF),y) libc-nomulti-y += $(patsubst %.c,$(STDIO_OUT)/%.o,$(VF_CSRC)) diff --git a/libc/stdio/_fopen.c b/libc/stdio/_fopen.c index 4ca028275..58066ea3f 100644 --- a/libc/stdio/_fopen.c +++ b/libc/stdio/_fopen.c @@ -11,10 +11,6 @@ libc_hidden_proto(isatty) libc_hidden_proto(open) libc_hidden_proto(fcntl) -#ifdef __UCLIBC_HAS_THREADS__ -libc_hidden_proto(_stdio_user_locking) -#endif - /* * Cases: * fopen64 : filename != NULL, stream == NULL, filedes == -2 @@ -80,13 +76,13 @@ FILE attribute_hidden *_stdio_fopen(intptr_t fname_or_mode, while (*++mode) { # ifdef __UCLIBC_HAS_FOPEN_EXCLUSIVE_MODE__ - if (*mode == 'x') { /* Open exclusive (a glibc extension). */ + if (*mode == 'x') { /* Open exclusive (a glibc extension). */ open_mode |= O_EXCL; continue; } # endif # ifdef __UCLIBC_HAS_FOPEN_LARGEFILE_MODE__ - if (*mode == 'F') { /* Open as large file (uClibc extension). */ + if (*mode == 'F') { /* Open as large file (uClibc extension). */ open_mode |= O_LARGEFILE; continue; } @@ -106,8 +102,12 @@ FILE attribute_hidden *_stdio_fopen(intptr_t fname_or_mode, #ifdef __UCLIBC_HAS_THREADS__ /* We only initialize the mutex in the non-freopen case. */ /* stream->__user_locking = _stdio_user_locking; */ +#ifdef __USE_STDIO_FUTEXES__ + _IO_lock_init (stream->_lock); +#else __stdio_init_mutex(&stream->__lock); #endif +#endif } #ifdef __UCLIBC_MJN3_ONLY__ @@ -198,8 +198,12 @@ FILE attribute_hidden *_stdio_fopen(intptr_t fname_or_mode, #ifdef __UCLIBC_HAS_THREADS__ /* Even in the freopen case, we reset the user locking flag. */ stream->__user_locking = _stdio_user_locking; +#ifdef __USE_STDIO_FUTEXES__ + /* _IO_lock_init (stream->_lock); */ +#else /* __stdio_init_mutex(&stream->__lock); */ #endif +#endif #ifdef __STDIO_HAS_OPENLIST __STDIO_THREADLOCK_OPENLIST; diff --git a/libc/stdio/_scanf.c b/libc/stdio/_scanf.c index 49ee7e0e2..2957d6748 100644 --- a/libc/stdio/_scanf.c +++ b/libc/stdio/_scanf.c @@ -100,10 +100,7 @@ libc_hidden_proto(fgetwc_unlocked) #endif #ifdef __UCLIBC_HAS_XLOCALE__ libc_hidden_proto(__ctype_b_loc) -#else -#ifdef __UCLIBC_HAS_LOCALE__ -libc_hidden_proto(__global_locale) -#endif +#elif __UCLIBC_HAS_CTYPE_TABLES__ libc_hidden_proto(__ctype_b) #endif diff --git a/libc/stdio/_stdio.c b/libc/stdio/_stdio.c index a967bd0de..4975ef02e 100644 --- a/libc/stdio/_stdio.c +++ b/libc/stdio/_stdio.c @@ -130,19 +130,12 @@ static FILE _stdio_streams[] = { 0 ) }; -/* psm: moved to _stdio.h: libc_hidden_proto(stdin/stdout) */ FILE *stdin = _stdio_streams; -libc_hidden_data_def(stdin) FILE *stdout = _stdio_streams + 1; -libc_hidden_data_def(stdout) -libc_hidden_proto(stderr) FILE *stderr = _stdio_streams + 2; -libc_hidden_data_def(stderr) #ifdef __STDIO_GETC_MACRO -libc_hidden_proto(__stdin) FILE *__stdin = _stdio_streams; /* For getchar() macro. */ -libc_hidden_data_def(__stdin) #endif #ifdef __STDIO_PUTC_MACRO FILE *__stdout = _stdio_streams + 1; /* For putchar() macro. */ @@ -164,7 +157,6 @@ FILE *__stdout = _stdio_streams + 1; /* For putchar() macro. */ */ FILE *_stdio_openlist = _stdio_streams; -libc_hidden_data_def(_stdio_openlist) # ifdef __UCLIBC_HAS_THREADS__ # ifdef __USE_STDIO_FUTEXES__ @@ -173,7 +165,6 @@ _IO_lock_t _stdio_openlist_lock = _IO_lock_initializer; # else pthread_mutex_t _stdio_openlist_lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; # endif -libc_hidden_data_def(_stdio_openlist_lock) int _stdio_openlist_delflag = 0; # endif @@ -182,9 +173,7 @@ int _stdio_openlist_delflag = 0; #ifdef __UCLIBC_HAS_THREADS__ /* 2 if threading not initialized and 0 otherwise; */ -libc_hidden_proto(_stdio_user_locking) int _stdio_user_locking = 2; -libc_hidden_data_def(_stdio_user_locking) #ifndef __USE_STDIO_FUTEXES__ void attribute_hidden __stdio_init_mutex(pthread_mutex_t *m) diff --git a/libc/stdio/_stdio.h b/libc/stdio/_stdio.h index 83d43352b..d4456b4a7 100644 --- a/libc/stdio/_stdio.h +++ b/libc/stdio/_stdio.h @@ -20,15 +20,19 @@ #include <wchar.h> #endif -libc_hidden_proto(stdin) -libc_hidden_proto(stdout) - -libc_hidden_proto(_stdio_openlist) - #ifdef __UCLIBC_HAS_THREADS__ #include <pthread.h> -libc_hidden_proto(_stdio_openlist_lock) +#ifdef __USE_STDIO_FUTEXES___ +#define __STDIO_THREADLOCK_OPENLIST \ + _IO_lock_lock(_stdio_openlist_lock) + +#define __STDIO_THREADUNLOCK_OPENLIST \ + _IO_lock_unlock(_stdio_openlist_lock) + +#define __STDIO_THREADTRYLOCK_OPENLIST \ + _IO_lock_trylock(_stdio_openlist_lock) +#else #define __STDIO_THREADLOCK_OPENLIST \ __pthread_mutex_lock(&_stdio_openlist_lock) @@ -37,6 +41,7 @@ libc_hidden_proto(_stdio_openlist_lock) #define __STDIO_THREADTRYLOCK_OPENLIST \ __pthread_mutex_trylock(&_stdio_openlist_lock) +#endif #else @@ -86,10 +91,10 @@ extern int __stdio_seek(FILE *stream, register __offmax_t *pos, int whence) attr (read((STREAMPTR)->__filedes,(BUF),(SIZE))) #define __WRITE(STREAMPTR,BUF,SIZE) \ (write((STREAMPTR)->__filedes,(BUF),(SIZE))) -#define __SEEK(STREAMPTR,PPOS,WHENCE) \ - (__stdio_seek((STREAMPTR),(PPOS),(WHENCE))) #define __CLOSE(STREAMPTR) \ (close((STREAMPTR)->__filedes)) +#define __SEEK(STREAMPTR,PPOS,WHENCE) \ + (__stdio_seek((STREAMPTR),(PPOS),(WHENCE))) #endif /* __UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__ */ diff --git a/libc/stdio/tmpfile.c b/libc/stdio/tmpfile.c index f83944539..f268d58cc 100644 --- a/libc/stdio/tmpfile.c +++ b/libc/stdio/tmpfile.c @@ -20,10 +20,16 @@ #include <stdio.h> #include <unistd.h> #include "../misc/internals/tempname.h" +#ifdef __UCLIBC_HAS_THREADS_NATIVE__ +#include <errno.h> +#include <not-cancel.h> +#endif libc_hidden_proto(fdopen) libc_hidden_proto(remove) +#ifndef __UCLIBC_HAS_THREADS_NATIVE__ libc_hidden_proto(close) +#endif /* This returns a new stream opened on a temporary file (generated by tmpnam). The file is opened with mode "w+b" (binary read/write). @@ -46,7 +52,11 @@ FILE * tmpfile (void) (void) remove (buf); if ((f = fdopen (fd, "w+b")) == NULL) +#ifdef __UCLIBC_HAS_THREADS_NATIVE__ + close_not_cancel (fd); +#else close (fd); +#endif return f; } |
