summaryrefslogtreecommitdiffstats
path: root/libc
diff options
context:
space:
mode:
Diffstat (limited to 'libc')
-rw-r--r--libc/stdio/Makefile4
-rw-r--r--libc/stdio/_fopen.c4
-rw-r--r--libc/stdio/_stdio.c12
-rw-r--r--libc/stdio/_stdio.h2
-rw-r--r--libc/stdio/scanf.c6
-rw-r--r--libc/stdio/vdprintf.c2
-rw-r--r--libc/stdio/vsnprintf.c6
-rw-r--r--libc/stdio/vswprintf.c2
-rw-r--r--libc/sysdeps/linux/common/bits/errno.h4
-rw-r--r--libc/sysdeps/linux/common/bits/uClibc_stdio.h8
10 files changed, 28 insertions, 22 deletions
diff --git a/libc/stdio/Makefile b/libc/stdio/Makefile
index e17d9faa5..684380ef0 100644
--- a/libc/stdio/Makefile
+++ b/libc/stdio/Makefile
@@ -121,6 +121,10 @@ ifeq ($(strip $(UCLIBC_HAS_LFS)),y)
OBJS += $(CLOBJS)
endif
+ifeq ($(UCLIBC_HAS_STDIO_FUTEXES),y)
+CFLAGS += -D__USE_STDIO_FUTEXES__
+endif
+
OBJ_LIST=../obj.stdio
all: $(OBJ_LIST)
diff --git a/libc/stdio/_fopen.c b/libc/stdio/_fopen.c
index b1722fef2..bba8cfdfd 100644
--- a/libc/stdio/_fopen.c
+++ b/libc/stdio/_fopen.c
@@ -98,7 +98,7 @@ FILE *_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 __UCLIBC_HAS_FUTEXES__
+#ifdef __USE_STDIO_FUTEXES__
_IO_lock_init (stream->_lock);
#else
__stdio_init_mutex(&stream->__lock);
@@ -194,7 +194,7 @@ FILE *_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 __UCLIBC_HAS_FUTEXES__
+#ifdef __USE_STDIO_FUTEXES__
/* _IO_lock_init (stream->_lock); */
#else
/* __stdio_init_mutex(&stream->__lock); */
diff --git a/libc/stdio/_stdio.c b/libc/stdio/_stdio.c
index 671f1e14c..b21beb728 100644
--- a/libc/stdio/_stdio.c
+++ b/libc/stdio/_stdio.c
@@ -73,7 +73,7 @@
#endif
#ifdef __UCLIBC_HAS_THREADS__
-#ifdef __UCLIBC_HAS_FUTEXES__
+#ifdef __USE_STDIO_FUTEXES__
#define __STDIO_FILE_INIT_THREADSAFE \
2, _LIBC_LOCK_RECURSIVE_INITIALIZER,
#else
@@ -156,8 +156,8 @@ FILE *__stdout = _stdio_streams + 1; /* For putchar() macro. */
FILE *_stdio_openlist = _stdio_streams;
# ifdef __UCLIBC_HAS_THREADS__
-# ifdef __UCLIBC_HAS_FUTEXES__
-# include <bits/stdio-lock.h>
+# ifdef __USE_STDIO_FUTEXES__
+# include <bits/stdio-lock.h>
_IO_lock_t _stdio_openlist_lock = _IO_lock_initializer;
# else
pthread_mutex_t _stdio_openlist_lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
@@ -172,7 +172,7 @@ int _stdio_openlist_delflag = 0;
/* 2 if threading not initialized and 0 otherwise; */
int _stdio_user_locking = 2;
-#ifndef __UCLIBC_HAS_FUTEXES__
+#ifndef __USE_STDIO_FUTEXES__
void __stdio_init_mutex(pthread_mutex_t *m)
{
static const pthread_mutex_t __stdio_mutex_initializer
@@ -196,7 +196,7 @@ void _stdio_term(void)
* locked, then I suppose there is a chance that a pointer in the
* chain might be corrupt due to a partial store.
*/
-#ifdef __UCLIBC_HAS_FUTEXES__
+#ifdef __USE_STDIO_FUTEXES__
_IO_lock_init (_stdio_openlist_lock);
#else
__stdio_init_mutex(&_stdio_openlist_lock);
@@ -221,7 +221,7 @@ void _stdio_term(void)
}
ptr->__user_locking = 1; /* Set locking mode to "by caller". */
-#ifdef __UCLIBC_HAS_FUTEXES__
+#ifdef __USE_STDIO_FUTEXES__
_IO_lock_init (ptr->_lock);
#else
__stdio_init_mutex(&ptr->__lock); /* Shouldn't be necessary, but... */
diff --git a/libc/stdio/_stdio.h b/libc/stdio/_stdio.h
index 2b956daa3..c167b177e 100644
--- a/libc/stdio/_stdio.h
+++ b/libc/stdio/_stdio.h
@@ -25,7 +25,7 @@
#ifdef __UCLIBC_HAS_THREADS__
#include <pthread.h>
-#ifdef __UCLIBC_HAS_FUTEXES__
+#ifdef __USE_STDIO_FUTEXES___
#define __STDIO_THREADLOCK_OPENLIST \
_IO_lock_lock(_stdio_openlist_lock)
diff --git a/libc/stdio/scanf.c b/libc/stdio/scanf.c
index 13254a50b..feaec3b44 100644
--- a/libc/stdio/scanf.c
+++ b/libc/stdio/scanf.c
@@ -235,7 +235,7 @@ int vsscanf(__const char *sp, __const char *fmt, va_list ap)
#ifdef __UCLIBC_HAS_THREADS__
f.__user_locking = 1; /* Set user locking. */
-#ifdef __UCLIBC_HAS_FUTEXES__
+#ifdef __USE_STDIO_FUTEXES__
_IO_lock_init (f._lock);
#else
__stdio_init_mutex(&f.__lock);
@@ -286,7 +286,7 @@ int vsscanf(__const char *sp, __const char *fmt, va_list ap)
#ifdef __UCLIBC_HAS_THREADS__
f.f.__user_locking = 1; /* Set user locking. */
-#ifdef __UCLIBC_HAS_FUTEXES__
+#ifdef __USE_STDIO_FUTEXES__
_IO_lock_init (f.f._lock);
#else
__stdio_init_mutex(&f.f.__lock);
@@ -421,7 +421,7 @@ int vswscanf(const wchar_t * __restrict str, const wchar_t * __restrict format,
#ifdef __UCLIBC_HAS_THREADS__
f.__user_locking = 1; /* Set user locking. */
-#ifdef __UCLIBC_HAS_FUTEXES__
+#ifdef __USE_STDIO_FUTEXES__
_IO_lock_init (f._lock);
#else
__stdio_init_mutex(&f.__lock);
diff --git a/libc/stdio/vdprintf.c b/libc/stdio/vdprintf.c
index 6449d37ca..6d8c91e90 100644
--- a/libc/stdio/vdprintf.c
+++ b/libc/stdio/vdprintf.c
@@ -43,7 +43,7 @@ int vdprintf(int filedes, const char * __restrict format, va_list arg)
#ifdef __UCLIBC_HAS_THREADS__
f.__user_locking = 1; /* Set user locking. */
-#ifdef __UCLIBC_HAS_FUTEXES__
+#ifdef __USE_STDIO_FUTEXES__
_IO_lock_init (f._lock);
#else
__stdio_init_mutex(&f.__lock);
diff --git a/libc/stdio/vsnprintf.c b/libc/stdio/vsnprintf.c
index 2f4f8e0a4..b8bdbaaa1 100644
--- a/libc/stdio/vsnprintf.c
+++ b/libc/stdio/vsnprintf.c
@@ -41,7 +41,7 @@ int vsnprintf(char *__restrict buf, size_t size,
#ifdef __UCLIBC_HAS_THREADS__
f.__user_locking = 1; /* Set user locking. */
-#ifdef __UCLIBC_HAS_FUTEXES__
+#ifdef __USE_STDIO_FUTEXES__
_IO_lock_init (f._lock);
#else
__stdio_init_mutex(&f.__lock);
@@ -113,7 +113,7 @@ int vsnprintf(char *__restrict buf, size_t size,
#ifdef __UCLIBC_HAS_THREADS__
f.f.__user_locking = 1; /* Set user locking. */
-#ifdef __UCLIBC_HAS_FUTEXES__
+#ifdef __USE_STDIO_FUTEXES__
_IO_lock_init (f.f._lock);
#else
__stdio_init_mutex(&f.f.__lock);
@@ -201,7 +201,7 @@ int vsnprintf(char *__restrict buf, size_t size,
#ifdef __UCLIBC_HAS_THREADS__
f.__user_locking = 1; /* Set user locking. */
-#ifdef __UCLIBC_HAS_FUTEXES__
+#ifdef __USE_STDIO_FUTEXES__
_IO_lock_init (f._lock);
#else
__stdio_init_mutex(&f.__lock);
diff --git a/libc/stdio/vswprintf.c b/libc/stdio/vswprintf.c
index ea99836e2..aab847dfd 100644
--- a/libc/stdio/vswprintf.c
+++ b/libc/stdio/vswprintf.c
@@ -38,7 +38,7 @@ int vswprintf(wchar_t *__restrict buf, size_t size,
#ifdef __UCLIBC_HAS_THREADS__
f.__user_locking = 1; /* Set user locking. */
-#ifdef __UCLIBC_HAS_FUTEXES__
+#ifdef __USE_STDIO_FUTEXES__
_IO_lock_init (f._lock);
#else
__stdio_init_mutex(&f.__lock);
diff --git a/libc/sysdeps/linux/common/bits/errno.h b/libc/sysdeps/linux/common/bits/errno.h
index cb9c2ee43..bf73a8fe1 100644
--- a/libc/sysdeps/linux/common/bits/errno.h
+++ b/libc/sysdeps/linux/common/bits/errno.h
@@ -39,7 +39,9 @@ extern int *__errno_location (void) __THROW __attribute__ ((__const__));
# if defined _LIBC
/* We wouldn't need a special macro anymore but it is history. */
-# define __set_errno(val) ((errno) = (val))
+# ifndef __set_errno
+# define __set_errno(val) ((errno) = (val))
+# endif
# endif /* _LIBC */
# if defined __UCLIBC_HAS_THREADS__
diff --git a/libc/sysdeps/linux/common/bits/uClibc_stdio.h b/libc/sysdeps/linux/common/bits/uClibc_stdio.h
index e378489a4..18ec2beca 100644
--- a/libc/sysdeps/linux/common/bits/uClibc_stdio.h
+++ b/libc/sysdeps/linux/common/bits/uClibc_stdio.h
@@ -119,7 +119,7 @@
#ifdef __UCLIBC_HAS_THREADS__
/* Need this for pthread_mutex_t. */
#include <bits/pthreadtypes.h>
-#if defined __UCLIBC_HAS_FUTEXES__ && defined _LIBC
+#ifdef __USE_STDIO_FUTEXES__
#include <bits/stdio-lock.h>
#endif
@@ -137,7 +137,7 @@
#define __STDIO_AUTO_THREADLOCK_VAR int __infunc_user_locking
-#if defined __UCLIBC_HAS_FUTEXES__ && defined _LIBC
+#ifdef __USE_STDIO_FUTEXES__
#define __STDIO_SET_USER_LOCKING(__stream) ((__stream)->__user_locking = 1)
@@ -313,7 +313,7 @@ struct __STDIO_FILE_STRUCT {
#endif
#ifdef __UCLIBC_HAS_THREADS__
int __user_locking;
-#if defined __UCLIBC_HAS_FUTEXES__ && defined _LIBC
+#ifdef __USE_STDIO_FUTEXES__
_IO_lock_t _lock;
#else
pthread_mutex_t __lock;
@@ -392,7 +392,7 @@ extern void _stdio_term(void);
extern struct __STDIO_FILE_STRUCT *_stdio_openlist;
#ifdef __UCLIBC_HAS_THREADS__
-#if defined __UCLIBC_HAS_FUTEXES__ && defined _LIBC
+#ifdef __USE_STDIO_FUTEXES__
extern _IO_lock_t _stdio_openlist_lock;
#else
extern pthread_mutex_t _stdio_openlist_lock;