about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2012-11-08 17:04:20 -0500
committerRich Felker <dalias@aerifal.cx>2012-11-08 17:04:20 -0500
commitefd4d87aa472523b07889af69874259db43b3c3c (patch)
tree40138f27a9f1f0bc462084aec8a9e24e3be42c56
parent835f9f950e2f6059532bd9ab9857a856ed21a4fd (diff)
downloadmusl-efd4d87aa472523b07889af69874259db43b3c3c.tar.gz
musl-efd4d87aa472523b07889af69874259db43b3c3c.tar.xz
musl-efd4d87aa472523b07889af69874259db43b3c3c.zip
clean up sloppy nested inclusion from pthread_impl.h
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).
-rw-r--r--src/aio/aio_readwrite.c3
-rw-r--r--src/aio/lio_listio.c3
-rw-r--r--src/env/__init_tls.c2
-rw-r--r--src/internal/pthread_impl.h8
-rw-r--r--src/process/fork.c1
-rw-r--r--src/signal/sigaction.c1
-rw-r--r--src/stdio/ftrylockfile.c1
-rw-r--r--src/stdio/popen.c3
-rw-r--r--src/thread/__wake.c1
-rw-r--r--src/thread/pthread_attr_init.c3
-rw-r--r--src/thread/pthread_barrierattr_init.c2
-rw-r--r--src/thread/pthread_cond_init.c2
-rw-r--r--src/thread/pthread_condattr_init.c2
-rw-r--r--src/thread/pthread_create.c1
-rw-r--r--src/thread/pthread_join.c1
-rw-r--r--src/thread/pthread_mutex_init.c2
-rw-r--r--src/thread/pthread_mutexattr_init.c2
-rw-r--r--src/thread/pthread_rwlock_init.c2
-rw-r--r--src/thread/pthread_rwlockattr_init.c2
-rw-r--r--src/thread/synccall.c1
-rw-r--r--src/time/timer_create.c1
21 files changed, 28 insertions, 16 deletions
diff --git a/src/aio/aio_readwrite.c b/src/aio/aio_readwrite.c
index 584ccb3d..e4c95aa2 100644
--- a/src/aio/aio_readwrite.c
+++ b/src/aio/aio_readwrite.c
@@ -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)
diff --git a/src/aio/lio_listio.c b/src/aio/lio_listio.c
index 30f7cc05..53f9f502 100644
--- a/src/aio/lio_listio.c
+++ b/src/aio/lio_listio.c
@@ -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 {
diff --git a/src/env/__init_tls.c b/src/env/__init_tls.c
index c71f49c1..3a1b1f56 100644
--- a/src/env/__init_tls.c
+++ b/src/env/__init_tls.c
@@ -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"
diff --git a/src/internal/pthread_impl.h b/src/internal/pthread_impl.h
index 0f10cc48..9424a5b7 100644
--- a/src/internal/pthread_impl.h
+++ b/src/internal/pthread_impl.h
@@ -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"
diff --git a/src/process/fork.c b/src/process/fork.c
index a8bdbe0b..fb8a430a 100644
--- a/src/process/fork.c
+++ b/src/process/fork.c
@@ -1,4 +1,5 @@
 #include <unistd.h>
+#include <string.h>
 #include "syscall.h"
 #include "libc.h"
 #include "pthread_impl.h"
diff --git a/src/signal/sigaction.c b/src/signal/sigaction.c
index d9535032..7a72a44b 100644
--- a/src/signal/sigaction.c
+++ b/src/signal/sigaction.c
@@ -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"
diff --git a/src/stdio/ftrylockfile.c b/src/stdio/ftrylockfile.c
index 725c4c3e..eef4e250 100644
--- a/src/stdio/ftrylockfile.c
+++ b/src/stdio/ftrylockfile.c
@@ -1,5 +1,6 @@
 #include "stdio_impl.h"
 #include "pthread_impl.h"
+#include <limits.h>
 
 int ftrylockfile(FILE *f)
 {
diff --git a/src/stdio/popen.c b/src/stdio/popen.c
index ca3cdf9d..ed20f5a1 100644
--- a/src/stdio/popen.c
+++ b/src/stdio/popen.c
@@ -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"
diff --git a/src/thread/__wake.c b/src/thread/__wake.c
index 8fd0599c..d8bf70f7 100644
--- a/src/thread/__wake.c
+++ b/src/thread/__wake.c
@@ -1,4 +1,5 @@
 #include "pthread_impl.h"
+#include <limits.h>
 
 void __wake(volatile int *addr, int cnt, int priv)
 {
diff --git a/src/thread/pthread_attr_init.c b/src/thread/pthread_attr_init.c
index d91bf157..66934889 100644
--- a/src/thread/pthread_attr_init.c
+++ b/src/thread/pthread_attr_init.c
@@ -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;
 }
diff --git a/src/thread/pthread_barrierattr_init.c b/src/thread/pthread_barrierattr_init.c
index f2698272..fa742bb7 100644
--- a/src/thread/pthread_barrierattr_init.c
+++ b/src/thread/pthread_barrierattr_init.c
@@ -2,6 +2,6 @@
 
 int pthread_barrierattr_init(pthread_barrierattr_t *a)
 {
-	memset(a, 0, sizeof *a);
+	*a = (pthread_barrierattr_t){0};
 	return 0;
 }
diff --git a/src/thread/pthread_cond_init.c b/src/thread/pthread_cond_init.c
index 2eac30f1..71489bca 100644
--- a/src/thread/pthread_cond_init.c
+++ b/src/thread/pthread_cond_init.c
@@ -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;
diff --git a/src/thread/pthread_condattr_init.c b/src/thread/pthread_condattr_init.c
index 6d09ac1e..a41741b4 100644
--- a/src/thread/pthread_condattr_init.c
+++ b/src/thread/pthread_condattr_init.c
@@ -2,6 +2,6 @@
 
 int pthread_condattr_init(pthread_condattr_t *a)
 {
-	memset(a, 0, sizeof *a);
+	*a = (pthread_condattr_t){0};
 	return 0;
 }
diff --git a/src/thread/pthread_create.c b/src/thread/pthread_create.c
index e67616e7..a7aadb51 100644
--- a/src/thread/pthread_create.c
+++ b/src/thread/pthread_create.c
@@ -1,5 +1,6 @@
 #include "pthread_impl.h"
 #include "stdio_impl.h"
+#include <sys/mman.h>
 
 static void dummy_0()
 {
diff --git a/src/thread/pthread_join.c b/src/thread/pthread_join.c
index 86191f25..719c91ca 100644
--- a/src/thread/pthread_join.c
+++ b/src/thread/pthread_join.c
@@ -1,4 +1,5 @@
 #include "pthread_impl.h"
+#include <sys/mman.h>
 
 static void dummy(void *p)
 {
diff --git a/src/thread/pthread_mutex_init.c b/src/thread/pthread_mutex_init.c
index fb689271..a7ba39ba 100644
--- a/src/thread/pthread_mutex_init.c
+++ b/src/thread/pthread_mutex_init.c
@@ -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;
 }
diff --git a/src/thread/pthread_mutexattr_init.c b/src/thread/pthread_mutexattr_init.c
index ea631069..0b72c1ba 100644
--- a/src/thread/pthread_mutexattr_init.c
+++ b/src/thread/pthread_mutexattr_init.c
@@ -2,6 +2,6 @@
 
 int pthread_mutexattr_init(pthread_mutexattr_t *a)
 {
-	memset(a, 0, sizeof *a);
+	*a = (pthread_mutexattr_t){0};
 	return 0;
 }
diff --git a/src/thread/pthread_rwlock_init.c b/src/thread/pthread_rwlock_init.c
index 29003bc6..82df52e2 100644
--- a/src/thread/pthread_rwlock_init.c
+++ b/src/thread/pthread_rwlock_init.c
@@ -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;
diff --git a/src/thread/pthread_rwlockattr_init.c b/src/thread/pthread_rwlockattr_init.c
index e0893d67..e7420694 100644
--- a/src/thread/pthread_rwlockattr_init.c
+++ b/src/thread/pthread_rwlockattr_init.c
@@ -2,6 +2,6 @@
 
 int pthread_rwlockattr_init(pthread_rwlockattr_t *a)
 {
-	memset(a, 0, sizeof *a);
+	*a = (pthread_rwlockattr_t){0};
 	return 0;
 }
diff --git a/src/thread/synccall.c b/src/thread/synccall.c
index 2b7eac25..dc59863f 100644
--- a/src/thread/synccall.c
+++ b/src/thread/synccall.c
@@ -1,5 +1,6 @@
 #include "pthread_impl.h"
 #include <semaphore.h>
+#include <string.h>
 
 static struct chain {
 	struct chain *next;
diff --git a/src/time/timer_create.c b/src/time/timer_create.c
index 560f1a84..60a18c71 100644
--- a/src/time/timer_create.c
+++ b/src/time/timer_create.c
@@ -1,4 +1,5 @@
 #include <time.h>
+#include <setjmp.h>
 #include "pthread_impl.h"
 
 struct ksigevent {