split internal lock API out of libc.h, creating lock.h
authorRich Felker <dalias@aerifal.cx>
Wed, 12 Sep 2018 14:19:54 +0000 (10:19 -0400)
committerRich Felker <dalias@aerifal.cx>
Wed, 12 Sep 2018 22:40:35 +0000 (18:40 -0400)
this further reduces the number of source files which need to include
libc.h and thereby be potentially exposed to libc global state and
internals.

this will also facilitate further improvements like adding an inline
fast-path, if we want to do so later.

25 files changed:
src/dirent/readdir_r.c
src/dirent/rewinddir.c
src/dirent/seekdir.c
src/exit/abort.c
src/exit/at_quick_exit.c
src/exit/atexit.c
src/internal/libc.h
src/internal/lock.h [new file with mode: 0644]
src/locale/dcngettext.c
src/locale/locale_map.c
src/locale/setlocale.c
src/malloc/lite_malloc.c
src/misc/syslog.c
src/prng/random.c
src/signal/sigaction.c
src/stdio/ofl.c
src/thread/pthread_atfork.c
src/thread/pthread_create.c
src/thread/pthread_getschedparam.c
src/thread/pthread_kill.c
src/thread/pthread_setschedparam.c
src/thread/pthread_setschedprio.c
src/thread/sem_open.c
src/thread/synccall.c
src/time/__tz.c

index 6293a5146196420a9959275946168a1f2e42573e..e2a818f36a0c66b398e8b0fc1622859605e1c434 100644 (file)
@@ -2,7 +2,7 @@
 #include <errno.h>
 #include <string.h>
 #include "__dirent.h"
-#include "libc.h"
+#include "lock.h"
 
 int readdir_r(DIR *restrict dir, struct dirent *restrict buf, struct dirent **restrict result)
 {
index f2053008b36c2d8e0b35dd60676cbb0b455a813f..7ddda437213d182bd90b3aa119ca4a43720d6cfc 100644 (file)
@@ -1,7 +1,7 @@
 #include <dirent.h>
 #include <unistd.h>
 #include "__dirent.h"
-#include "libc.h"
+#include "lock.h"
 
 void rewinddir(DIR *dir)
 {
index 5be47d4a15564178eb84e73a0d9a9569fd8b30b3..bf6cc6ec40453ed5a7bf4cffbfb5ef573e1ddc6e 100644 (file)
@@ -1,7 +1,7 @@
 #include <dirent.h>
 #include <unistd.h>
 #include "__dirent.h"
-#include "libc.h"
+#include "lock.h"
 
 void seekdir(DIR *dir, long off)
 {
index 7c323d2670a7d43a3c43686712e87c081b77720c..e1980f10a5b6488a8a82a98a6a987e6db7997e3b 100644 (file)
@@ -3,7 +3,7 @@
 #include "syscall.h"
 #include "pthread_impl.h"
 #include "atomic.h"
-#include "libc.h"
+#include "lock.h"
 #include "ksigaction.h"
 
 hidden volatile int __abort_lock[1];
index 4079b242cf7dc40b550208f28b7a52d2390dd99f..d3ce6522df7dd810ee1014ae84a9ceaa08e66927 100644 (file)
@@ -1,5 +1,6 @@
 #include <stdlib.h>
 #include "libc.h"
+#include "lock.h"
 
 #define COUNT 32
 
index cd3b0a648399f57f820abde2fecfdfece7a020e4..160d277aeb76a3837f856052ec9b93653eabdb2b 100644 (file)
@@ -1,6 +1,7 @@
 #include <stdlib.h>
 #include <stdint.h>
 #include "libc.h"
+#include "lock.h"
 
 /* Ensure that at least 32 atexit handlers can be registered without malloc */
 #define COUNT 32
index 0a279184bb05cff52572af218a6ffe0f0de99e10..10bd66bdf686a2ea517b265c61ff49de36839d78 100644 (file)
@@ -51,12 +51,6 @@ extern char *__progname, *__progname_full;
 
 extern hidden const char __libc_version[];
 
-/* Designed to avoid any overhead in non-threaded processes */
-hidden void __lock(volatile int *);
-hidden void __unlock(volatile int *);
-#define LOCK(x) __lock(x)
-#define UNLOCK(x) __unlock(x)
-
 hidden void __synccall(void (*)(void *), void *);
 hidden int __setxid(int, int, int, int);
 
diff --git a/src/internal/lock.h b/src/internal/lock.h
new file mode 100644 (file)
index 0000000..c77db6f
--- /dev/null
@@ -0,0 +1,9 @@
+#ifndef LOCK_H
+#define LOCK_H
+
+hidden void __lock(volatile int *);
+hidden void __unlock(volatile int *);
+#define LOCK(x) __lock(x)
+#define UNLOCK(x) __unlock(x)
+
+#endif
index eefa31a818a8a9eb37da06d40fe985b1b1bdb1cd..7fbe7196c1732246ace3db69cae6f40bf6d56ef5 100644 (file)
@@ -9,6 +9,7 @@
 #include "locale_impl.h"
 #include "atomic.h"
 #include "pleval.h"
+#include "lock.h"
 
 struct binding {
        struct binding *next;
index e7b518a1a0c8394e66e30330af360f3752b0034f..2321bac0ea97c7ef695282429cba544d07194fcb 100644 (file)
@@ -3,7 +3,7 @@
 #include <sys/mman.h>
 #include "locale_impl.h"
 #include "libc.h"
-#include "atomic.h"
+#include "lock.h"
 
 const char *__lctrans_impl(const char *msg, const struct __locale_map *lm)
 {
index 60e3353c9a7ac962cf5c94fa9fcb2d59251829eb..11d823ce93997284450ae768d8c06139b574b159 100644 (file)
@@ -3,7 +3,7 @@
 #include <string.h>
 #include "locale_impl.h"
 #include "libc.h"
-#include "atomic.h"
+#include "lock.h"
 
 static char buf[LC_ALL*(LOCALE_NAME_MAX+1)];
 
index 49157d36515720ccacbb28dc9037de0c50e05fed..050d84f648bcc690f97d704ce7232089b9a256f0 100644 (file)
@@ -2,7 +2,7 @@
 #include <stdint.h>
 #include <limits.h>
 #include <errno.h>
-#include "libc.h"
+#include "lock.h"
 #include "malloc_impl.h"
 
 #define ALIGN 16
index 410709d7eca47a27d79ba4006f9f726d7e696d50..13d4b0a6d7bc34f737eb9bb36d09bf0881f6b557 100644 (file)
@@ -9,7 +9,7 @@
 #include <pthread.h>
 #include <errno.h>
 #include <fcntl.h>
-#include "libc.h"
+#include "lock.h"
 
 static volatile int lock[1];
 static char log_ident[32];
index 13a5e6df5f650d12802c589f0e5f49122a870625..633a17f6902fcf9e287c0ecbc921304513bf23a9 100644 (file)
@@ -1,6 +1,6 @@
 #include <stdlib.h>
 #include <stdint.h>
-#include "libc.h"
+#include "lock.h"
 
 /*
 this code uses the same lagged fibonacci generator as the
index 2adedaa4711cfcc69fb1b4980022b8121bf87c53..af47195e001376c2e5e870f410b71ae5f230bb25 100644 (file)
@@ -4,6 +4,7 @@
 #include "syscall.h"
 #include "pthread_impl.h"
 #include "libc.h"
+#include "lock.h"
 #include "ksigaction.h"
 
 volatile int dummy_lock[1] = { 0 };
index 0e3602aa58e4dc2639d2075266b9da89a75751c1..f2d3215a9e7d7eec8f32351991f3ec8b4d270fc9 100644 (file)
@@ -1,5 +1,5 @@
 #include "stdio_impl.h"
-#include "libc.h"
+#include "lock.h"
 
 static FILE *ofl_head;
 static volatile int ofl_lock[1];
index c6f77b3f4fe73c626f9a1ee3ae5b2daa0175a424..764974016576d6fe816f89da88220e78b86f46af 100644 (file)
@@ -1,5 +1,6 @@
 #include <pthread.h>
 #include "libc.h"
+#include "lock.h"
 
 static struct atfork_funcs {
        void (*prepare)(void);
index 23dfe0ad5ecc185e88b8daf7bb782257cb16c5e7..3293dcd543e58b740a6b5390622203c8adf62422 100644 (file)
@@ -2,6 +2,7 @@
 #include "pthread_impl.h"
 #include "stdio_impl.h"
 #include "libc.h"
+#include "lock.h"
 #include <sys/mman.h>
 #include <string.h>
 #include <stddef.h>
index 05be42427c4503b5b6d7f1ab7a339a0d186aa641..1cba073d0c7d549023e2b5cc7faeb1ec8faa401e 100644 (file)
@@ -1,4 +1,5 @@
 #include "pthread_impl.h"
+#include "lock.h"
 
 int pthread_getschedparam(pthread_t t, int *restrict policy, struct sched_param *restrict param)
 {
index 6d70e626daf40bdf8e60240fc1fbb1b561d377dd..3d9395cb7e0a0b5797c962e4af2d22d95de93718 100644 (file)
@@ -1,4 +1,5 @@
 #include "pthread_impl.h"
+#include "lock.h"
 
 int pthread_kill(pthread_t t, int sig)
 {
index ab45f2ff8ba2e290241db7d0924e1e839bce8301..038d13d8acfb4cbd01aa573cd05c791fe2ef0b95 100644 (file)
@@ -1,4 +1,5 @@
 #include "pthread_impl.h"
+#include "lock.h"
 
 int pthread_setschedparam(pthread_t t, int policy, const struct sched_param *param)
 {
index c353f6b53942dc9d21066aba5948d83bb3d89b58..5bf4a0197e3abb9faac8b250733669126c814eab 100644 (file)
@@ -1,4 +1,5 @@
 #include "pthread_impl.h"
+#include "lock.h"
 
 int pthread_setschedprio(pthread_t t, int prio)
 {
index 1bd8020a7b7a544b15a9ad9bd99aae920cee57f9..de8555c5a6869ceda20c956cc6c8d1ea8470a138 100644 (file)
@@ -11,7 +11,7 @@
 #include <sys/stat.h>
 #include <stdlib.h>
 #include <pthread.h>
-#include "libc.h"
+#include "lock.h"
 
 static struct {
        ino_t ino;
index ba2f258e8161962a63a4f53a82ff3be04b0669e7..cc66bd2491089afb2b2dc3eb5ff50b8b7f89d3e8 100644 (file)
@@ -7,6 +7,7 @@
 #include "futex.h"
 #include "atomic.h"
 #include "../dirent/__dirent.h"
+#include "lock.h"
 
 static struct chain {
        struct chain *next;
index 6f5257fe36b7ae5652a0e148d955a2e2bc1fb3b4..51e665141b53209ae645be010cc636b5a69aeaa1 100644 (file)
@@ -5,6 +5,7 @@
 #include <string.h>
 #include <sys/mman.h>
 #include "libc.h"
+#include "lock.h"
 
 long  __timezone = 0;
 int   __daylight = 0;