clean up sloppy nested inclusion from pthread_impl.h
authorRich Felker <dalias@aerifal.cx>
Thu, 8 Nov 2012 22:04:20 +0000 (17:04 -0500)
committerRich Felker <dalias@aerifal.cx>
Thu, 8 Nov 2012 22:04:20 +0000 (17:04 -0500)
this mirrors the stdio_impl.h cleanup. one header which is not
strictly needed, errno.h, is left in pthread_impl.h, because since
pthread functions return their error codes rather than using errno,
nearly every single pthread function needs the errno constants.

in a few places, rather than bringing in string.h to use memset, the
memset was replaced by direct assignment. this seems to generate much
better code anyway, and makes many functions which were previously
non-leaf functions into leaf functions (possibly eliminating a great
deal of bloat on some platforms where non-leaf functions require ugly
prologue and/or epilogue).

21 files changed:
src/aio/aio_readwrite.c
src/aio/lio_listio.c
src/env/__init_tls.c
src/internal/pthread_impl.h
src/process/fork.c
src/signal/sigaction.c
src/stdio/ftrylockfile.c
src/stdio/popen.c
src/thread/__wake.c
src/thread/pthread_attr_init.c
src/thread/pthread_barrierattr_init.c
src/thread/pthread_cond_init.c
src/thread/pthread_condattr_init.c
src/thread/pthread_create.c
src/thread/pthread_join.c
src/thread/pthread_mutex_init.c
src/thread/pthread_mutexattr_init.c
src/thread/pthread_rwlock_init.c
src/thread/pthread_rwlockattr_init.c
src/thread/synccall.c
src/time/timer_create.c

index 584ccb3d73f083aa428a8e0122dc99c5773db6c6..e4c95aa2382405eadabdc61582d40bfbb6dd9eb8 100644 (file)
@@ -1,5 +1,8 @@
 #include <aio.h>
 #include <fcntl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <limits.h>
 #include "pthread_impl.h"
 
 static void dummy(void)
index 30f7cc05c28f4002e6ab1e94a94dfb662c390070..53f9f502ab4e994da2fa61c3c8a1a46045fe9d05 100644 (file)
@@ -1,5 +1,8 @@
 #include <aio.h>
 #include <errno.h>
+#include <limits.h>
+#include <unistd.h>
+#include <string.h>
 #include "pthread_impl.h"
 
 struct lio_state {
index c71f49c1b661aa38c65f6cb3121d41c1e2c2b8cc..3a1b1f56cb52e996226799bec0b5db8f62548fe3 100644 (file)
@@ -1,5 +1,7 @@
 #include <elf.h>
 #include <limits.h>
+#include <sys/mman.h>
+#include <string.h>
 #include "pthread_impl.h"
 #include "libc.h"
 #include "atomic.h"
index 0f10cc48b116ff026fb59bf4dfd13deb0189deb3..9424a5b7039619d2031f99e2ee815e5055dd9bf0 100644 (file)
@@ -2,17 +2,9 @@
 #define _PTHREAD_IMPL_H
 
 #include <pthread.h>
-#include <sched.h>
 #include <signal.h>
-#include <unistd.h>
-#include <sys/mman.h>
 #include <errno.h>
 #include <limits.h>
-#include <inttypes.h>
-#include <setjmp.h>
-#include <string.h>
-#include <time.h>
-#include <locale.h>
 #include "libc.h"
 #include "syscall.h"
 #include "atomic.h"
index a8bdbe0b03833cd763a0ad661de90d6d8d295dd2..fb8a430add8505e175fd643409258164d5505fa6 100644 (file)
@@ -1,4 +1,5 @@
 #include <unistd.h>
+#include <string.h>
 #include "syscall.h"
 #include "libc.h"
 #include "pthread_impl.h"
index d9535032d89d960f170e6b457b80cf86e8d5ad62..7a72a44b13fec0ca83eae4f4241258e2da8c3876 100644 (file)
@@ -1,6 +1,7 @@
 #include <stdlib.h>
 #include <signal.h>
 #include <errno.h>
+#include <string.h>
 #include "syscall.h"
 #include "pthread_impl.h"
 #include "libc.h"
index 725c4c3eacbd159dbac076a9c8e3fa4fafea22a7..eef4e2502e56af1a6ed1f8d9a08f898bab5ce856 100644 (file)
@@ -1,5 +1,6 @@
 #include "stdio_impl.h"
 #include "pthread_impl.h"
+#include <limits.h>
 
 int ftrylockfile(FILE *f)
 {
index ca3cdf9d5e1e75ec0d1a8561c22b353455677585..ed20f5a1f017c4415303940e435ce61b9caff7b1 100644 (file)
@@ -1,4 +1,7 @@
 #include <fcntl.h>
+#include <unistd.h>
+#include <errno.h>
+#include <string.h>
 #include "stdio_impl.h"
 #include "pthread_impl.h"
 #include "syscall.h"
index 8fd0599cdb0d9eb7b859e75b1919101f845fb05f..d8bf70f7b32e7c7704b3321eb1742c27d06f9152 100644 (file)
@@ -1,4 +1,5 @@
 #include "pthread_impl.h"
+#include <limits.h>
 
 void __wake(volatile int *addr, int cnt, int priv)
 {
index d91bf157408e6ead53284b25697c19f7f5a0f2f3..6693488967ff29075549b994b2e02b307b46f65c 100644 (file)
@@ -1,7 +1,8 @@
 #include "pthread_impl.h"
+#include <string.h>
 
 int pthread_attr_init(pthread_attr_t *a)
 {
-       memset(a, 0, sizeof *a);
+       *a = (pthread_attr_t){0};
        return 0;
 }
index f26982721075d9ce5a3594b129f101e009675af4..fa742bb73468a435307091347c038841422c6c7c 100644 (file)
@@ -2,6 +2,6 @@
 
 int pthread_barrierattr_init(pthread_barrierattr_t *a)
 {
-       memset(a, 0, sizeof *a);
+       *a = (pthread_barrierattr_t){0};
        return 0;
 }
index 2eac30f15e8b7903152a934a5d44533f0617b76d..71489bca2c317ed2f3055562283fe393b2e9653c 100644 (file)
@@ -2,7 +2,7 @@
 
 int pthread_cond_init(pthread_cond_t *restrict c, const pthread_condattr_t *restrict a)
 {
-       memset(c, 0, sizeof *c);
+       *c = (pthread_cond_t){0};
        if (a) {
                c->_c_clock = *a & 0x7fffffff;
                if (*a>>31) c->_c_mutex = (void *)-1;
index 6d09ac1edc63096c9dd976a7299b4ad06c45f6ff..a41741b4ec061414f3f126b1767b575e1dfb10da 100644 (file)
@@ -2,6 +2,6 @@
 
 int pthread_condattr_init(pthread_condattr_t *a)
 {
-       memset(a, 0, sizeof *a);
+       *a = (pthread_condattr_t){0};
        return 0;
 }
index e67616e7464475187a138017cc9a09d428453721..a7aadb518645bb48db767cdff32cb271e097d98d 100644 (file)
@@ -1,5 +1,6 @@
 #include "pthread_impl.h"
 #include "stdio_impl.h"
+#include <sys/mman.h>
 
 static void dummy_0()
 {
index 86191f252dda86cc398a57303a482afbcb5a7ddd..719c91ca24f7b03f729657a27208e10e3bf1c020 100644 (file)
@@ -1,4 +1,5 @@
 #include "pthread_impl.h"
+#include <sys/mman.h>
 
 static void dummy(void *p)
 {
index fb689271ce7affd0171368005ceebc03abcf6cff..a7ba39baac06821a528cbd02f1b5a57e349c57d8 100644 (file)
@@ -2,7 +2,7 @@
 
 int pthread_mutex_init(pthread_mutex_t *restrict m, const pthread_mutexattr_t *restrict a)
 {
-       memset(m, 0, sizeof *m);
+       *m = (pthread_mutex_t){0};
        if (a) m->_m_type = *a & 7;
        return 0;
 }
index ea6310699dabd7968982da62d810a41eccd16ac8..0b72c1ba5fda6d9873feedadfb20b882785fd4c9 100644 (file)
@@ -2,6 +2,6 @@
 
 int pthread_mutexattr_init(pthread_mutexattr_t *a)
 {
-       memset(a, 0, sizeof *a);
+       *a = (pthread_mutexattr_t){0};
        return 0;
 }
index 29003bc651493d551eabef97f68fbf795101debf..82df52e25b4dfe8aa06bd79dbe38cea0bc00a863 100644 (file)
@@ -2,7 +2,7 @@
 
 int pthread_rwlock_init(pthread_rwlock_t *restrict rw, const pthread_rwlockattr_t *restrict a)
 {
-       memset(rw, 0, sizeof *rw);
+       *rw = (pthread_rwlock_t){0};
        if (a) {
        }
        return 0;
index e0893d673d805f211aa51189d27bcffc636ea8b5..e742069447d6c14a0a6dbab6622689a9279294f3 100644 (file)
@@ -2,6 +2,6 @@
 
 int pthread_rwlockattr_init(pthread_rwlockattr_t *a)
 {
-       memset(a, 0, sizeof *a);
+       *a = (pthread_rwlockattr_t){0};
        return 0;
 }
index 2b7eac259ce2f3332a09cf3398014d8b99b5e426..dc59863f11c3c7ae49073a673fba9a854c668ae0 100644 (file)
@@ -1,5 +1,6 @@
 #include "pthread_impl.h"
 #include <semaphore.h>
+#include <string.h>
 
 static struct chain {
        struct chain *next;
index 560f1a8468384ff0e4f189314903bc31e4aebcd7..60a18c71989dd459399d7a64fac6d338c5c521bc 100644 (file)
@@ -1,4 +1,5 @@
 #include <time.h>
+#include <setjmp.h>
 #include "pthread_impl.h"
 
 struct ksigevent {