svn commit: branches/uClibc_0_9_28: libc/stdio libc/sysdeps/linux/common/bit etc...
andersen at uclibc.org
andersen at uclibc.org
Wed Feb 21 23:28:41 UTC 2007
Author: andersen
Date: 2007-02-21 15:28:41 -0800 (Wed, 21 Feb 2007)
New Revision: 17947
Log:
backport some cleanup fixes from trunk
Modified:
branches/uClibc_0_9_28/libc/stdio/fcloseall.c
branches/uClibc_0_9_28/libc/stdio/fflush.c
branches/uClibc_0_9_28/libc/sysdeps/linux/common/bits/uClibc_mutex.h
branches/uClibc_0_9_28/libc/sysdeps/linux/common/bits/uClibc_pthread.h
branches/uClibc_0_9_28/libc/sysdeps/linux/common/bits/uClibc_stdio.h
branches/uClibc_0_9_28/libpthread/linuxthreads/sysdeps/pthread/pthread.h
Changeset:
Modified: branches/uClibc_0_9_28/libc/stdio/fcloseall.c
===================================================================
--- branches/uClibc_0_9_28/libc/stdio/fcloseall.c 2007-02-21 23:27:48 UTC (rev 17946)
+++ branches/uClibc_0_9_28/libc/stdio/fcloseall.c 2007-02-21 23:28:41 UTC (rev 17947)
@@ -5,6 +5,9 @@
* Dedicated to Toni. See uClibc/DEDICATION.mjn3 for details.
*/
+#include <features.h>
+
+#ifdef __USE_GNU
#include "_stdio.h"
/* NOTE: GLIBC difference!!! -- fcloseall
@@ -21,28 +24,33 @@
int retval = 0;
FILE *f;
-#warning remove dead code
-/* __STDIO_THREADLOCK_OPENLIST; */
-/* while (_stdio_openlist) { */
-/* if (fclose(_stdio_openlist)) { */
-/* retval = EOF; */
-/* } */
-/* } */
-/* __STDIO_THREADUNLOCK_OPENLIST; */
-
__STDIO_OPENLIST_INC_USE;
-#warning should probably have a get_head() operation
+#ifdef __UCLIBC_MJN3_ONLY__
+#warning REMINDER: should probably have a get_head() operation
+#endif
__STDIO_THREADLOCK_OPENLIST_ADD;
f = _stdio_openlist;
__STDIO_THREADUNLOCK_OPENLIST_ADD;
while (f) {
-#warning should probably have a get_next() operation
+#ifdef __UCLIBC_MJN3_ONLY__
+#warning REMINDER: should probably have a get_next() operation
+#endif
FILE *n = f->__nextopen;
- if (fclose(f)) {
- retval = EOF;
+ __STDIO_AUTO_THREADLOCK_VAR;
+
+ __STDIO_AUTO_THREADLOCK(f);
+ /* Only call fclose on the stream if it is not already closed. */
+ if ((f->__modeflags & (__FLAG_READONLY|__FLAG_WRITEONLY))
+ != (__FLAG_READONLY|__FLAG_WRITEONLY)
+ ) {
+ if (fclose(f)) {
+ retval = EOF;
+ }
}
+ __STDIO_AUTO_THREADUNLOCK(f);
+
f = n;
}
@@ -58,3 +66,4 @@
#endif
}
+#endif
Modified: branches/uClibc_0_9_28/libc/stdio/fflush.c
===================================================================
--- branches/uClibc_0_9_28/libc/stdio/fflush.c 2007-02-21 23:27:48 UTC (rev 17946)
+++ branches/uClibc_0_9_28/libc/stdio/fflush.c 2007-02-21 23:28:41 UTC (rev 17947)
@@ -20,16 +20,17 @@
weak_alias(__fflush_unlocked,fflush);
#endif
+
/* Even if the stream is set to user-locking, we still need to lock
* when all (lbf) writing streams are flushed. */
-#define __MY_STDIO_THREADLOCK(__stream) \
- __UCLIBC_MUTEX_CONDITIONAL_LOCK((__stream)->__lock, \
- (_stdio_user_locking != 2))
+#define __MY_STDIO_THREADLOCK(__stream) \
+ __UCLIBC_MUTEX_CONDITIONAL_LOCK((__stream)->__lock, \
+ (_stdio_user_locking != 2))
-#define __MY_STDIO_THREADUNLOCK(__stream) \
- __UCLIBC_MUTEX_CONDITIONAL_UNLOCK((__stream)->__lock, \
- (_stdio_user_locking != 2))
+#define __MY_STDIO_THREADUNLOCK(__stream) \
+ __UCLIBC_MUTEX_CONDITIONAL_UNLOCK((__stream)->__lock, \
+ (_stdio_user_locking != 2))
#if defined(__UCLIBC_HAS_THREADS__) && defined(__STDIO_BUFFERS)
void _stdio_openlist_dec_use(void)
@@ -40,14 +41,19 @@
FILE *n;
FILE *stream;
+#ifdef __UCLIBC_MJN3_ONLY__
+#warning REMINDER: As an optimization, we could unlock after we move past the head.
+#endif
+ /* Grab the openlist add lock since we might change the head of the list. */
__STDIO_THREADLOCK_OPENLIST_ADD;
for (stream = _stdio_openlist; stream; stream = n) {
-#warning walk the list and clear out all fclosed()d files
n = stream->__nextopen;
-#warning fix for nonatomic
- if ((stream->__modeflags & (__FLAG_READONLY|__FLAG_WRITEONLY))
+#ifdef __UCLIBC_MJN3_ONLY__
+#warning REMINDER: fix for nonatomic
+#endif
+ if ((stream->__modeflags & (__FLAG_READONLY|__FLAG_WRITEONLY|__FLAG_FAILED_FREOPEN))
== (__FLAG_READONLY|__FLAG_WRITEONLY)
- ) { /* The file was closed so remove from the list. */
+ ) { /* The file was closed and should be removed from the list. */
if (!p) {
_stdio_openlist = n;
} else {
@@ -58,7 +64,8 @@
p = stream;
}
}
- __STDIO_THREADUNLOCK_OPENLIST_DEL;
+ __STDIO_THREADUNLOCK_OPENLIST_ADD;
+ _stdio_openlist_del_count = 0; /* Should be clean now. */
}
--_stdio_openlist_use_count;
__STDIO_THREADUNLOCK_OPENLIST_DEL;
Modified: branches/uClibc_0_9_28/libc/sysdeps/linux/common/bits/uClibc_mutex.h
===================================================================
--- branches/uClibc_0_9_28/libc/sysdeps/linux/common/bits/uClibc_mutex.h 2007-02-21 23:27:48 UTC (rev 17946)
+++ branches/uClibc_0_9_28/libc/sysdeps/linux/common/bits/uClibc_mutex.h 2007-02-21 23:28:41 UTC (rev 17947)
@@ -12,11 +12,16 @@
#ifdef __UCLIBC_HAS_THREADS__
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+
#include <pthread.h>
+#include <bits/uClibc_pthread.h>
-#define __UCLIBC_MUTEX_TYPE pthread_mutex_t
+#define __UCLIBC_MUTEX_TYPE pthread_mutex_t
-#define __UCLIBC_MUTEX(M) pthread_mutex_t M
+#define __UCLIBC_MUTEX(M) pthread_mutex_t M
#define __UCLIBC_MUTEX_INIT(M,I) pthread_mutex_t M = I
#define __UCLIBC_MUTEX_STATIC(M,I) static pthread_mutex_t M = I
#define __UCLIBC_MUTEX_EXTERN(M) extern pthread_mutex_t M
@@ -31,42 +36,42 @@
__pthread_mutex_trylock(&(M))
#define __UCLIBC_MUTEX_CONDITIONAL_LOCK(M,C) \
- do { \
- struct _pthread_cleanup_buffer __infunc_pthread_cleanup_buffer; \
- if (C) { \
- _pthread_cleanup_push_defer(&__infunc_pthread_cleanup_buffer, \
- __pthread_mutex_unlock, \
- &(M)); \
- __pthread_mutex_lock(&(M)); \
- } \
+ do { \
+ struct _pthread_cleanup_buffer __infunc_pthread_cleanup_buffer; \
+ if (C) { \
+ _pthread_cleanup_push_defer(&__infunc_pthread_cleanup_buffer, \
+ (void (*) (void *))__pthread_mutex_unlock, \
+ &(M)); \
+ __pthread_mutex_lock(&(M)); \
+ } \
((void)0)
#define __UCLIBC_MUTEX_CONDITIONAL_UNLOCK(M,C) \
- if (C) { \
- _pthread_cleanup_pop_restore(&__infunc_pthread_cleanup_buffer,1);\
- } \
+ if (C) { \
+ _pthread_cleanup_pop_restore(&__infunc_pthread_cleanup_buffer,1); \
+ } \
} while (0)
#define __UCLIBC_MUTEX_AUTO_LOCK_VAR(A) int A
-#define __UCLIBC_MUTEX_AUTO_LOCK(M,A,V) \
+#define __UCLIBC_MUTEX_AUTO_LOCK(M,A,V) \
__UCLIBC_MUTEX_CONDITIONAL_LOCK(M,((A=(V)) == 0))
-#define __UCLIBC_MUTEX_AUTO_UNLOCK(M,A) \
+#define __UCLIBC_MUTEX_AUTO_UNLOCK(M,A) \
__UCLIBC_MUTEX_CONDITIONAL_UNLOCK(M,(A == 0))
-#define __UCLIBC_MUTEX_LOCK(M) \
+#define __UCLIBC_MUTEX_LOCK(M) \
__UCLIBC_MUTEX_CONDITIONAL_LOCK(M, 1)
-#define __UCLIBC_MUTEX_UNLOCK(M) \
+#define __UCLIBC_MUTEX_UNLOCK(M) \
__UCLIBC_MUTEX_CONDITIONAL_UNLOCK(M, 1)
#else
-#define __UCLIBC_MUTEX(M) void *__UCLIBC_MUTEX_DUMMY_ ## M
-#define __UCLIBC_MUTEX_INIT(M,I) extern void *__UCLIBC_MUTEX_DUMMY_ ## M
-#define __UCLIBC_MUTEX_STATIC(M,I) extern void *__UCLIBC_MUTEX_DUMMY_ ## M
-#define __UCLIBC_MUTEX_EXTERN(M) extern void *__UCLIBC_MUTEX_DUMMY_ ## M
+#define __UCLIBC_MUTEX(M) void *__UCLIBC_MUTEX_DUMMY_ ## M
+#define __UCLIBC_MUTEX_INIT(M,I) extern void *__UCLIBC_MUTEX_DUMMY_ ## M
+#define __UCLIBC_MUTEX_STATIC(M,I) extern void *__UCLIBC_MUTEX_DUMMY_ ## M
+#define __UCLIBC_MUTEX_EXTERN(M) extern void *__UCLIBC_MUTEX_DUMMY_ ## M
#define __UCLIBC_MUTEX_LOCK_CANCEL_UNSAFE(M) ((void)0)
#define __UCLIBC_MUTEX_UNLOCK_CANCEL_UNSAFE(M) ((void)0)
@@ -75,12 +80,12 @@
#define __UCLIBC_MUTEX_CONDITIONAL_LOCK(M,C) ((void)0)
#define __UCLIBC_MUTEX_CONDITIONAL_UNLOCK(M,C) ((void)0)
-#define __UCLIBC_MUTEX_AUTO_LOCK_VAR(A) ((void)0)
-#define __UCLIBC_MUTEX_AUTO_LOCK(M,A,V) ((void)0)
-#define __UCLIBC_MUTEX_AUTO_UNLOCK(M,A) ((void)0)
+#define __UCLIBC_MUTEX_AUTO_LOCK_VAR(A) ((void)0)
+#define __UCLIBC_MUTEX_AUTO_LOCK(M,A,V) ((void)0)
+#define __UCLIBC_MUTEX_AUTO_UNLOCK(M,A) ((void)0)
-#define __UCLIBC_MUTEX_LOCK(M) ((void)0)
-#define __UCLIBC_MUTEX_UNLOCK(M) ((void)0)
+#define __UCLIBC_MUTEX_LOCK(M) ((void)0)
+#define __UCLIBC_MUTEX_UNLOCK(M) ((void)0)
#endif
Modified: branches/uClibc_0_9_28/libc/sysdeps/linux/common/bits/uClibc_pthread.h
===================================================================
--- branches/uClibc_0_9_28/libc/sysdeps/linux/common/bits/uClibc_pthread.h 2007-02-21 23:27:48 UTC (rev 17946)
+++ branches/uClibc_0_9_28/libc/sysdeps/linux/common/bits/uClibc_pthread.h 2007-02-21 23:28:41 UTC (rev 17947)
@@ -1,21 +1,22 @@
/* Copyright (C) 2003 Manuel Novoa III
*
* This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
+ * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
+ * version 2.1 of the License, or (at your option) any later version.
*
- * This library is distributed in the hope that it will be useful,
+ * 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
- * Library General Public License for more details.
+ * Lesser General Public License for more details.
*
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the Free
- * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * 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.
*/
-/* Supply prototypes for the (weak) thread functions used by the
+/* Supply prototypes for the internal thread functions used by the
* uClibc library code.
*/
@@ -23,17 +24,27 @@
#define _UCLIBC_PTHREAD_H
#ifndef _PTHREAD_H
-#error Always include <pthread.h> rather than <bits/uClibc_pthread.h>
+# 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) __THROW;
+#if defined _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);
-extern int __pthread_mutex_trylock (pthread_mutex_t *__mutex) __THROW;
+struct _pthread_cleanup_buffer;
+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
-extern int __pthread_mutex_lock (pthread_mutex_t *__mutex) __THROW;
-
-extern int __pthread_mutex_unlock (pthread_mutex_t *__mutex) __THROW;
-
#endif
Modified: branches/uClibc_0_9_28/libc/sysdeps/linux/common/bits/uClibc_stdio.h
===================================================================
--- branches/uClibc_0_9_28/libc/sysdeps/linux/common/bits/uClibc_stdio.h 2007-02-21 23:27:48 UTC (rev 17946)
+++ branches/uClibc_0_9_28/libc/sysdeps/linux/common/bits/uClibc_stdio.h 2007-02-21 23:28:41 UTC (rev 17947)
@@ -130,29 +130,29 @@
* This way, we avoid calling the weak lock/unlock functions.
*/
-#define __STDIO_AUTO_THREADLOCK_VAR \
+#define __STDIO_AUTO_THREADLOCK_VAR \
__UCLIBC_MUTEX_AUTO_LOCK_VAR(__infunc_user_locking)
-#define __STDIO_AUTO_THREADLOCK(__stream) \
+#define __STDIO_AUTO_THREADLOCK(__stream) \
__UCLIBC_MUTEX_AUTO_LOCK((__stream)->__lock, __infunc_user_locking, \
- (__stream)->__user_locking)
+ (__stream)->__user_locking)
-#define __STDIO_AUTO_THREADUNLOCK(__stream) \
+#define __STDIO_AUTO_THREADUNLOCK(__stream) \
__UCLIBC_MUTEX_AUTO_UNLOCK((__stream)->__lock, __infunc_user_locking)
-#define __STDIO_ALWAYS_THREADLOCK(__stream) \
+#define __STDIO_ALWAYS_THREADLOCK(__stream) \
__UCLIBC_MUTEX_LOCK((__stream)->__lock)
-#define __STDIO_ALWAYS_THREADUNLOCK(__stream) \
+#define __STDIO_ALWAYS_THREADUNLOCK(__stream) \
__UCLIBC_MUTEX_UNLOCK((__stream)->__lock)
-#define __STDIO_ALWAYS_THREADLOCK_CANCEL_UNSAFE(__stream) \
+#define __STDIO_ALWAYS_THREADLOCK_CANCEL_UNSAFE(__stream) \
__UCLIBC_MUTEX_LOCK_CANCEL_UNSAFE((__stream)->__lock)
-#define __STDIO_ALWAYS_THREADTRYLOCK_CANCEL_UNSAFE(__stream) \
+#define __STDIO_ALWAYS_THREADTRYLOCK_CANCEL_UNSAFE(__stream) \
__UCLIBC_MUTEX_TRYLOCK_CANCEL_UNSAFE((__stream)->__lock)
-#define __STDIO_ALWAYS_THREADUNLOCK_CANCEL_UNSAFE(__stream) \
+#define __STDIO_ALWAYS_THREADUNLOCK_CANCEL_UNSAFE(__stream) \
__UCLIBC_MUTEX_UNLOCK_CANCEL_UNSAFE((__stream)->__lock)
#ifdef __UCLIBC_HAS_THREADS__
@@ -191,7 +191,7 @@
/**********************************************************************/
#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
@@ -201,7 +201,7 @@
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.
@@ -304,24 +304,25 @@
#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_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_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
@@ -365,17 +366,17 @@
#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
@@ -383,17 +384,18 @@
extern int __fgetc_unlocked(FILE *__stream);
extern int __fputc_unlocked(int __c, FILE *__stream);
-/* First define the default definitions. They overriden below as necessary. */
+/* First define the default definitions.
+ They are overridden 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))
@@ -402,9 +404,9 @@
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
@@ -419,10 +421,10 @@
# 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
@@ -430,23 +432,23 @@
# 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
@@ -461,16 +463,16 @@
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))
@@ -480,10 +482,10 @@
/* 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
@@ -491,11 +493,11 @@
# 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)); \
}) )
@@ -505,9 +507,9 @@
# 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
Modified: branches/uClibc_0_9_28/libpthread/linuxthreads/sysdeps/pthread/pthread.h
===================================================================
--- branches/uClibc_0_9_28/libpthread/linuxthreads/sysdeps/pthread/pthread.h 2007-02-21 23:27:48 UTC (rev 17946)
+++ branches/uClibc_0_9_28/libpthread/linuxthreads/sysdeps/pthread/pthread.h 2007-02-21 23:28:41 UTC (rev 17947)
@@ -644,7 +644,8 @@
/* Install a cleanup handler as pthread_cleanup_push does, but also
saves the current cancellation type and set it to deferred cancellation. */
-#ifdef __USE_GNU
+/* #ifdef __USE_GNU */
+#if defined(__USE_GNU) || defined(_LIBC)
# define pthread_cleanup_push_defer_np(routine,arg) \
{ struct _pthread_cleanup_buffer _buffer; \
_pthread_cleanup_push_defer (&_buffer, (routine), (arg));
More information about the uClibc-cvs
mailing list