aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSzabolcs Nagy <nsz@port70.net>2013-12-12 05:09:18 +0000
committerSzabolcs Nagy <nsz@port70.net>2013-12-12 05:09:18 +0000
commit571744447c23f91feb6439948f3a619aca850dfb (patch)
tree996c6f90721d69494683ae213ec22784d02a899a /src
parentac45692a53a1b8d2ede329d91652d43c1fb5dc8d (diff)
downloadmusl-571744447c23f91feb6439948f3a619aca850dfb.zip
musl-571744447c23f91feb6439948f3a619aca850dfb.tar.gz
musl-571744447c23f91feb6439948f3a619aca850dfb.tar.bz2
include cleanups: remove unused headers and add feature test macros
Diffstat (limited to 'src')
-rw-r--r--src/ctype/__ctype_b_loc.c1
-rw-r--r--src/ctype/__ctype_get_mb_cur_max.c2
-rw-r--r--src/ctype/__ctype_tolower_loc.c3
-rw-r--r--src/ctype/__ctype_toupper_loc.c3
-rw-r--r--src/dirent/fdopendir.c2
-rw-r--r--src/dirent/opendir.c4
-rw-r--r--src/dirent/readdir.c6
-rw-r--r--src/dirent/readdir_r.c1
-rw-r--r--src/dirent/scandir.c4
-rw-r--r--src/env/__init_security.c1
-rw-r--r--src/env/__stack_chk_fail.c3
-rw-r--r--src/env/clearenv.c1
-rw-r--r--src/env/putenv.c2
-rw-r--r--src/env/unsetenv.c1
-rw-r--r--src/exit/atexit.c2
-rw-r--r--src/exit/exit.c3
-rw-r--r--src/fcntl/fcntl.c1
-rw-r--r--src/fcntl/open.c1
-rw-r--r--src/fcntl/openat.c1
-rw-r--r--src/internal/syscall_ret.c1
-rw-r--r--src/ldso/dlinfo.c1
-rw-r--r--src/legacy/euidaccess.c1
-rw-r--r--src/legacy/futimes.c2
-rw-r--r--src/legacy/getdtablesize.c2
-rw-r--r--src/legacy/getpagesize.c1
-rw-r--r--src/legacy/getpass.c2
-rw-r--r--src/legacy/getusershell.c3
-rw-r--r--src/legacy/lutimes.c1
-rw-r--r--src/linux/chroot.c1
-rw-r--r--src/linux/clock_adjtime.c2
-rw-r--r--src/linux/klogctl.c1
-rw-r--r--src/linux/personality.c1
-rw-r--r--src/linux/prlimit.c3
-rw-r--r--src/linux/sendfile.c2
-rw-r--r--src/linux/setfsgid.c2
-rw-r--r--src/linux/setfsuid.c2
-rw-r--r--src/linux/setgroups.c1
-rw-r--r--src/linux/sethostname.c1
-rw-r--r--src/linux/setns.c1
-rw-r--r--src/linux/stime.c1
-rw-r--r--src/linux/sysinfo.c3
-rw-r--r--src/linux/wait4.c1
-rw-r--r--src/locale/intl.c1
-rw-r--r--src/locale/localeconv.c2
-rw-r--r--src/locale/strcasecmp_l.c1
-rw-r--r--src/malloc/calloc.c1
-rw-r--r--src/misc/get_current_dir_name.c1
-rw-r--r--src/misc/getgrouplist.c1
-rw-r--r--src/misc/getrusage.c1
-rw-r--r--src/misc/initgroups.c6
-rw-r--r--src/misc/nftw.c2
-rw-r--r--src/misc/syslog.c1
-rw-r--r--src/misc/uname.c1
-rw-r--r--src/mman/msync.c1
-rw-r--r--src/mman/munmap.c1
-rw-r--r--src/multibyte/internal.c2
-rw-r--r--src/multibyte/internal.h1
-rw-r--r--src/multibyte/mblen.c5
-rw-r--r--src/multibyte/mbrlen.c5
-rw-r--r--src/multibyte/mbrtowc.c3
-rw-r--r--src/multibyte/mbsinit.c5
-rw-r--r--src/multibyte/mbsnrtowcs.c6
-rw-r--r--src/multibyte/mbsrtowcs.c4
-rw-r--r--src/multibyte/mbtowc.c5
-rw-r--r--src/multibyte/wcrtomb.c4
-rw-r--r--src/multibyte/wcsnrtombs.c5
-rw-r--r--src/multibyte/wcsrtombs.c5
-rw-r--r--src/multibyte/wctomb.c4
-rw-r--r--src/network/__ipparse.c1
-rw-r--r--src/network/gethostbyaddr.c2
-rw-r--r--src/network/gethostbyname2.c2
-rw-r--r--src/network/gethostbyname2_r.c2
-rw-r--r--src/network/getifaddrs.c1
-rw-r--r--src/network/getnameinfo.c1
-rw-r--r--src/network/if_nameindex.c2
-rw-r--r--src/network/inet_ntop.c2
-rw-r--r--src/network/proto.c1
-rw-r--r--src/network/recv.c2
-rw-r--r--src/network/res_query.c1
-rw-r--r--src/network/send.c2
-rw-r--r--src/network/serv.c2
-rw-r--r--src/passwd/fgetgrent.c1
-rw-r--r--src/passwd/fgetpwent.c1
-rw-r--r--src/passwd/putgrent.c1
-rw-r--r--src/passwd/putpwent.c1
-rw-r--r--src/prng/__rand48_step.c1
-rw-r--r--src/process/fexecve.c1
-rw-r--r--src/process/system.c2
-rw-r--r--src/process/vfork.c1
-rw-r--r--src/regex/glob.c2
-rw-r--r--src/regex/regcomp.c1
-rw-r--r--src/signal/raise.c1
-rw-r--r--src/signal/sigaction.c1
-rw-r--r--src/signal/sigfillset.c1
-rw-r--r--src/signal/sighold.c2
-rw-r--r--src/signal/sigignore.c2
-rw-r--r--src/signal/siginterrupt.c2
-rw-r--r--src/signal/sigismember.c1
-rw-r--r--src/signal/siglongjmp.c1
-rw-r--r--src/signal/signal.c1
-rw-r--r--src/signal/sigpause.c1
-rw-r--r--src/signal/sigqueue.c1
-rw-r--r--src/signal/sigrelse.c2
-rw-r--r--src/signal/sigset.c2
-rw-r--r--src/signal/sigsetjmp.c1
-rw-r--r--src/stat/fchmodat.c1
-rw-r--r--src/stat/futimesat.c1
-rw-r--r--src/stat/lchmod.c1
-rw-r--r--src/stdio/fgetln.c1
-rw-r--r--src/stdio/fwide.c1
-rw-r--r--src/stdio/swprintf.c1
-rw-r--r--src/stdio/swscanf.c1
-rw-r--r--src/stdio/vfscanf.c5
-rw-r--r--src/stdio/vfwscanf.c3
-rw-r--r--src/stdlib/ecvt.c1
-rw-r--r--src/stdlib/gcvt.c1
-rw-r--r--src/stdlib/wcstod.c1
-rw-r--r--src/string/bcmp.c1
-rw-r--r--src/string/bcopy.c1
-rw-r--r--src/string/bzero.c1
-rw-r--r--src/string/index.c1
-rw-r--r--src/string/memccpy.c1
-rw-r--r--src/string/memchr.c1
-rw-r--r--src/string/memmem.c1
-rw-r--r--src/string/mempcpy.c1
-rw-r--r--src/string/rindex.c1
-rw-r--r--src/string/stpcpy.c1
-rw-r--r--src/string/stpncpy.c1
-rw-r--r--src/string/strchrnul.c1
-rw-r--r--src/string/strlcpy.c2
-rw-r--r--src/string/strlen.c1
-rw-r--r--src/string/strstr.c1
-rw-r--r--src/string/strverscmp.c1
-rw-r--r--src/string/wcsstr.c3
-rw-r--r--src/string/wmemchr.c1
-rw-r--r--src/string/wmemcmp.c1
-rw-r--r--src/string/wmemcpy.c1
-rw-r--r--src/string/wmemmove.c1
-rw-r--r--src/string/wmemset.c1
-rw-r--r--src/temp/__randname.c1
-rw-r--r--src/temp/mkdtemp.c5
-rw-r--r--src/temp/mktemp.c4
-rw-r--r--src/termios/tcgetattr.c1
-rw-r--r--src/termios/tcsetattr.c1
-rw-r--r--src/thread/pthread_attr_init.c1
-rw-r--r--src/thread/pthread_sigmask.c1
-rw-r--r--src/thread/synccall.c1
-rw-r--r--src/time/mktime.c2
-rw-r--r--src/time/nanosleep.c1
-rw-r--r--src/time/strptime.c1
-rw-r--r--src/time/time.c1
-rw-r--r--src/time/wcsftime.c1
-rw-r--r--src/unistd/ctermid.c2
-rw-r--r--src/unistd/gethostname.c1
-rw-r--r--src/unistd/getlogin_r.c1
-rw-r--r--src/unistd/ttyname_r.c2
-rw-r--r--src/unistd/usleep.c1
157 files changed, 68 insertions, 207 deletions
diff --git a/src/ctype/__ctype_b_loc.c b/src/ctype/__ctype_b_loc.c
index 6e93dc0..f43795e 100644
--- a/src/ctype/__ctype_b_loc.c
+++ b/src/ctype/__ctype_b_loc.c
@@ -1,4 +1,3 @@
-#include <ctype.h>
#include <endian.h>
#if __BYTE_ORDER == __BIG_ENDIAN
diff --git a/src/ctype/__ctype_get_mb_cur_max.c b/src/ctype/__ctype_get_mb_cur_max.c
index 42e4ee7..d235f4d 100644
--- a/src/ctype/__ctype_get_mb_cur_max.c
+++ b/src/ctype/__ctype_get_mb_cur_max.c
@@ -1,4 +1,4 @@
-#include <stdlib.h>
+#include <stddef.h>
size_t __ctype_get_mb_cur_max()
{
diff --git a/src/ctype/__ctype_tolower_loc.c b/src/ctype/__ctype_tolower_loc.c
index 62ce69a..efb9910 100644
--- a/src/ctype/__ctype_tolower_loc.c
+++ b/src/ctype/__ctype_tolower_loc.c
@@ -1,5 +1,4 @@
-#include <ctype.h>
-#include <inttypes.h>
+#include <stdint.h>
static const int32_t table[] = {
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
diff --git a/src/ctype/__ctype_toupper_loc.c b/src/ctype/__ctype_toupper_loc.c
index 1556164..ffaef0e 100644
--- a/src/ctype/__ctype_toupper_loc.c
+++ b/src/ctype/__ctype_toupper_loc.c
@@ -1,5 +1,4 @@
-#include <ctype.h>
-#include <inttypes.h>
+#include <stdint.h>
static const int32_t table[] = {
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
diff --git a/src/dirent/fdopendir.c b/src/dirent/fdopendir.c
index c684a86..c377271 100644
--- a/src/dirent/fdopendir.c
+++ b/src/dirent/fdopendir.c
@@ -3,8 +3,6 @@
#include <sys/stat.h>
#include <errno.h>
#include <stdlib.h>
-#include <unistd.h>
-#include <limits.h>
#include "__dirent.h"
DIR *fdopendir(int fd)
diff --git a/src/dirent/opendir.c b/src/dirent/opendir.c
index d33d892..5cb84e3 100644
--- a/src/dirent/opendir.c
+++ b/src/dirent/opendir.c
@@ -1,11 +1,7 @@
#define _GNU_SOURCE
#include <dirent.h>
#include <fcntl.h>
-#include <sys/stat.h>
-#include <errno.h>
#include <stdlib.h>
-#include <unistd.h>
-#include <limits.h>
#include "__dirent.h"
#include "syscall.h"
diff --git a/src/dirent/readdir.c b/src/dirent/readdir.c
index 2d27d29..98ec029 100644
--- a/src/dirent/readdir.c
+++ b/src/dirent/readdir.c
@@ -1,11 +1,5 @@
#include <dirent.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <limits.h>
#include "__dirent.h"
-#include "syscall.h"
#include "libc.h"
int __getdents(int, struct dirent *, size_t);
diff --git a/src/dirent/readdir_r.c b/src/dirent/readdir_r.c
index 639d49a..daa6c6e 100644
--- a/src/dirent/readdir_r.c
+++ b/src/dirent/readdir_r.c
@@ -1,6 +1,5 @@
#include <dirent.h>
#include <errno.h>
-#include <stdlib.h>
#include <string.h>
#include "__dirent.h"
#include "libc.h"
diff --git a/src/dirent/scandir.c b/src/dirent/scandir.c
index a85cfac..3af2b50 100644
--- a/src/dirent/scandir.c
+++ b/src/dirent/scandir.c
@@ -1,10 +1,10 @@
#include <dirent.h>
#include <string.h>
#include <stdlib.h>
-#include <inttypes.h>
+#include <stdint.h>
#include <errno.h>
#include <stddef.h>
-#include <libc.h>
+#include "libc.h"
int scandir(const char *path, struct dirent ***res,
int (*sel)(const struct dirent *),
diff --git a/src/env/__init_security.c b/src/env/__init_security.c
index 91b9b10..6204c5e 100644
--- a/src/env/__init_security.c
+++ b/src/env/__init_security.c
@@ -1,4 +1,3 @@
-#include <stddef.h>
#include <elf.h>
#include <poll.h>
#include <fcntl.h>
diff --git a/src/env/__stack_chk_fail.c b/src/env/__stack_chk_fail.c
index 031a1ed..daa1b07 100644
--- a/src/env/__stack_chk_fail.c
+++ b/src/env/__stack_chk_fail.c
@@ -1,6 +1,5 @@
#include <string.h>
-#include <inttypes.h>
-#include <elf.h>
+#include <stdint.h>
#include "pthread_impl.h"
#include "atomic.h"
diff --git a/src/env/clearenv.c b/src/env/clearenv.c
index a2475ce..62d5095 100644
--- a/src/env/clearenv.c
+++ b/src/env/clearenv.c
@@ -1,3 +1,4 @@
+#define _GNU_SOURCE
#include <stdlib.h>
extern char **__environ;
diff --git a/src/env/putenv.c b/src/env/putenv.c
index d141db1..4042869 100644
--- a/src/env/putenv.c
+++ b/src/env/putenv.c
@@ -1,7 +1,5 @@
#include <stdlib.h>
#include <string.h>
-#include <errno.h>
-#include <stdio.h>
extern char **__environ;
char **__env_map;
diff --git a/src/env/unsetenv.c b/src/env/unsetenv.c
index 7493d97..3569335 100644
--- a/src/env/unsetenv.c
+++ b/src/env/unsetenv.c
@@ -1,4 +1,3 @@
-#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
diff --git a/src/exit/atexit.c b/src/exit/atexit.c
index c31f3dc..89ff4ff 100644
--- a/src/exit/atexit.c
+++ b/src/exit/atexit.c
@@ -1,7 +1,5 @@
-#include <stddef.h>
#include <stdlib.h>
#include <stdint.h>
-#include <limits.h>
#include "libc.h"
/* Ensure that at least 32 atexit handlers can be registered without malloc */
diff --git a/src/exit/exit.c b/src/exit/exit.c
index f259c98..353f50b 100644
--- a/src/exit/exit.c
+++ b/src/exit/exit.c
@@ -1,6 +1,5 @@
#include <stdlib.h>
-#include <unistd.h>
-#include <stdio.h>
+#include <stdint.h>
#include "libc.h"
#include "atomic.h"
#include "syscall.h"
diff --git a/src/fcntl/fcntl.c b/src/fcntl/fcntl.c
index 390ef75..4c34ba0 100644
--- a/src/fcntl/fcntl.c
+++ b/src/fcntl/fcntl.c
@@ -1,6 +1,5 @@
#define _GNU_SOURCE
#include <fcntl.h>
-#include <unistd.h>
#include <stdarg.h>
#include <errno.h>
#include "syscall.h"
diff --git a/src/fcntl/open.c b/src/fcntl/open.c
index 31d6744..be44208 100644
--- a/src/fcntl/open.c
+++ b/src/fcntl/open.c
@@ -1,5 +1,4 @@
#include <fcntl.h>
-#include <unistd.h>
#include <stdarg.h>
#include "syscall.h"
#include "libc.h"
diff --git a/src/fcntl/openat.c b/src/fcntl/openat.c
index bdecb8c..634c4bf 100644
--- a/src/fcntl/openat.c
+++ b/src/fcntl/openat.c
@@ -1,5 +1,4 @@
#include <fcntl.h>
-#include <unistd.h>
#include <stdarg.h>
#include "syscall.h"
#include "libc.h"
diff --git a/src/internal/syscall_ret.c b/src/internal/syscall_ret.c
index e4a1bdb..d99f4a5 100644
--- a/src/internal/syscall_ret.c
+++ b/src/internal/syscall_ret.c
@@ -1,5 +1,4 @@
#include <errno.h>
-#include <unistd.h>
long __syscall_ret(unsigned long r)
{
diff --git a/src/ldso/dlinfo.c b/src/ldso/dlinfo.c
index 4748eaf..63d276d 100644
--- a/src/ldso/dlinfo.c
+++ b/src/ldso/dlinfo.c
@@ -1,3 +1,4 @@
+#define _GNU_SOURCE
#include <dlfcn.h>
int __dlinfo(void *, int, void *);
diff --git a/src/legacy/euidaccess.c b/src/legacy/euidaccess.c
index 47b464d..7307251 100644
--- a/src/legacy/euidaccess.c
+++ b/src/legacy/euidaccess.c
@@ -1,3 +1,4 @@
+#define _GNU_SOURCE
#include <unistd.h>
#include <fcntl.h>
#include "libc.h"
diff --git a/src/legacy/futimes.c b/src/legacy/futimes.c
index f8fd1cd..d81d83a 100644
--- a/src/legacy/futimes.c
+++ b/src/legacy/futimes.c
@@ -1,6 +1,6 @@
+#define _GNU_SOURCE
#include <sys/stat.h>
#include <sys/time.h>
-#include <fcntl.h>
int futimes(int fd, const struct timeval tv[2])
{
diff --git a/src/legacy/getdtablesize.c b/src/legacy/getdtablesize.c
index 623a6af..682da6d 100644
--- a/src/legacy/getdtablesize.c
+++ b/src/legacy/getdtablesize.c
@@ -1,3 +1,5 @@
+#define _GNU_SOURCE
+#include <unistd.h>
#include <limits.h>
#include <sys/resource.h>
diff --git a/src/legacy/getpagesize.c b/src/legacy/getpagesize.c
index a47995c..0fc29ff 100644
--- a/src/legacy/getpagesize.c
+++ b/src/legacy/getpagesize.c
@@ -1,3 +1,4 @@
+#define _GNU_SOURCE
#include <unistd.h>
#include "libc.h"
diff --git a/src/legacy/getpass.c b/src/legacy/getpass.c
index d439a2a..3565d95 100644
--- a/src/legacy/getpass.c
+++ b/src/legacy/getpass.c
@@ -1,5 +1,5 @@
+#define _GNU_SOURCE
#include <stdio.h>
-#include <string.h>
#include <termios.h>
#include <unistd.h>
#include <fcntl.h>
diff --git a/src/legacy/getusershell.c b/src/legacy/getusershell.c
index f31f404..5fecdec 100644
--- a/src/legacy/getusershell.c
+++ b/src/legacy/getusershell.c
@@ -1,7 +1,6 @@
#define _GNU_SOURCE
#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
+#include <unistd.h>
static const char defshells[] = "/bin/sh\n/bin/csh\n";
diff --git a/src/legacy/lutimes.c b/src/legacy/lutimes.c
index 13dfe4e..2e5502d 100644
--- a/src/legacy/lutimes.c
+++ b/src/legacy/lutimes.c
@@ -1,3 +1,4 @@
+#define _GNU_SOURCE
#include <sys/stat.h>
#include <sys/time.h>
#include <fcntl.h>
diff --git a/src/linux/chroot.c b/src/linux/chroot.c
index 82b4fe7..0e69f14 100644
--- a/src/linux/chroot.c
+++ b/src/linux/chroot.c
@@ -1,3 +1,4 @@
+#define _GNU_SOURCE
#include <unistd.h>
#include "syscall.h"
diff --git a/src/linux/clock_adjtime.c b/src/linux/clock_adjtime.c
index 1fc9bef..056ad6d 100644
--- a/src/linux/clock_adjtime.c
+++ b/src/linux/clock_adjtime.c
@@ -1,5 +1,3 @@
-#define _GNU_SOURCE
-#include <time.h>
#include <sys/timex.h>
#include "syscall.h"
diff --git a/src/linux/klogctl.c b/src/linux/klogctl.c
index 209ae74..8102ee6 100644
--- a/src/linux/klogctl.c
+++ b/src/linux/klogctl.c
@@ -1,3 +1,4 @@
+#include <sys/klog.h>
#include "syscall.h"
int klogctl (int type, char *buf, int len)
diff --git a/src/linux/personality.c b/src/linux/personality.c
index 06851f5..e00cf79 100644
--- a/src/linux/personality.c
+++ b/src/linux/personality.c
@@ -1,3 +1,4 @@
+#include <sys/personality.h>
#include "syscall.h"
#ifdef SYS_personality
int personality(unsigned long persona)
diff --git a/src/linux/prlimit.c b/src/linux/prlimit.c
index 1215248..d1639cc 100644
--- a/src/linux/prlimit.c
+++ b/src/linux/prlimit.c
@@ -1,4 +1,4 @@
-#include <unistd.h>
+#define _GNU_SOURCE
#include <sys/resource.h>
#include "syscall.h"
#include "libc.h"
@@ -8,4 +8,5 @@ int prlimit(pid_t pid, int resource, const struct rlimit *new_limit, struct rlim
return syscall(SYS_prlimit64, pid, resource, new_limit, old_limit);
}
+#undef prlimit64
LFS64(prlimit);
diff --git a/src/linux/sendfile.c b/src/linux/sendfile.c
index 818b19d..d63f419 100644
--- a/src/linux/sendfile.c
+++ b/src/linux/sendfile.c
@@ -1,4 +1,4 @@
-#include <unistd.h>
+#include <sys/sendfile.h>
#include "syscall.h"
#include "libc.h"
diff --git a/src/linux/setfsgid.c b/src/linux/setfsgid.c
index a7ed9e9..ad80422 100644
--- a/src/linux/setfsgid.c
+++ b/src/linux/setfsgid.c
@@ -1,4 +1,4 @@
-#include <unistd.h>
+#include <sys/fsuid.h>
#include "syscall.h"
#include "libc.h"
diff --git a/src/linux/setfsuid.c b/src/linux/setfsuid.c
index 1509e0a..8635873 100644
--- a/src/linux/setfsuid.c
+++ b/src/linux/setfsuid.c
@@ -1,4 +1,4 @@
-#include <unistd.h>
+#include <sys/fsuid.h>
#include "syscall.h"
#include "libc.h"
diff --git a/src/linux/setgroups.c b/src/linux/setgroups.c
index 9758940..1248fdb 100644
--- a/src/linux/setgroups.c
+++ b/src/linux/setgroups.c
@@ -1,3 +1,4 @@
+#define _GNU_SOURCE
#include <unistd.h>
#include "syscall.h"
diff --git a/src/linux/sethostname.c b/src/linux/sethostname.c
index 79a8707..9313b32 100644
--- a/src/linux/sethostname.c
+++ b/src/linux/sethostname.c
@@ -1,3 +1,4 @@
+#define _GNU_SOURCE
#include <unistd.h>
#include "syscall.h"
diff --git a/src/linux/setns.c b/src/linux/setns.c
index 7029b74..0afec81 100644
--- a/src/linux/setns.c
+++ b/src/linux/setns.c
@@ -1,7 +1,6 @@
#define _GNU_SOURCE
#include <sched.h>
#include "syscall.h"
-#include "libc.h"
int setns(int fd, int nstype)
{
diff --git a/src/linux/stime.c b/src/linux/stime.c
index 6a7e9e8..29a1ec6 100644
--- a/src/linux/stime.c
+++ b/src/linux/stime.c
@@ -1,4 +1,5 @@
#define _GNU_SOURCE
+#include <time.h>
#include <sys/time.h>
int stime(time_t *t)
diff --git a/src/linux/sysinfo.c b/src/linux/sysinfo.c
index 2dbd0ad..7e64f33 100644
--- a/src/linux/sysinfo.c
+++ b/src/linux/sysinfo.c
@@ -1,7 +1,6 @@
+#include <sys/sysinfo.h>
#include "syscall.h"
-struct sysinfo;
-
int sysinfo(struct sysinfo *info)
{
return syscall(SYS_sysinfo, info);
diff --git a/src/linux/wait4.c b/src/linux/wait4.c
index b3ae75e..97f12cc 100644
--- a/src/linux/wait4.c
+++ b/src/linux/wait4.c
@@ -1,7 +1,6 @@
#define _GNU_SOURCE
#include <sys/wait.h>
#include <sys/resource.h>
-#include <string.h>
#include "syscall.h"
pid_t wait4(pid_t pid, int *status, int options, struct rusage *usage)
diff --git a/src/locale/intl.c b/src/locale/intl.c
index 964f7da..ad04052 100644
--- a/src/locale/intl.c
+++ b/src/locale/intl.c
@@ -1,3 +1,4 @@
+#include <libintl.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
diff --git a/src/locale/localeconv.c b/src/locale/localeconv.c
index 494cbcc..cbc75d7 100644
--- a/src/locale/localeconv.c
+++ b/src/locale/localeconv.c
@@ -1,6 +1,4 @@
#include <locale.h>
-#include <string.h>
-#include <stdlib.h>
static const struct lconv posix_lconv = {
.decimal_point = ".",
diff --git a/src/locale/strcasecmp_l.c b/src/locale/strcasecmp_l.c
index eea2f80..ca80543 100644
--- a/src/locale/strcasecmp_l.c
+++ b/src/locale/strcasecmp_l.c
@@ -1,5 +1,4 @@
#include <strings.h>
-#include <ctype.h>
int strcasecmp_l(const char *l, const char *r, locale_t loc)
{
diff --git a/src/malloc/calloc.c b/src/malloc/calloc.c
index 9d57456..c3dfb47 100644
--- a/src/malloc/calloc.c
+++ b/src/malloc/calloc.c
@@ -1,6 +1,5 @@
#include <stdlib.h>
#include <errno.h>
-#include <string.h>
void *calloc(size_t m, size_t n)
{
diff --git a/src/misc/get_current_dir_name.c b/src/misc/get_current_dir_name.c
index e0f463b..8576df2 100644
--- a/src/misc/get_current_dir_name.c
+++ b/src/misc/get_current_dir_name.c
@@ -1,3 +1,4 @@
+#define _GNU_SOURCE
#include <stdlib.h>
#include <string.h>
#include <limits.h>
diff --git a/src/misc/getgrouplist.c b/src/misc/getgrouplist.c
index 63557af..c9a8f09 100644
--- a/src/misc/getgrouplist.c
+++ b/src/misc/getgrouplist.c
@@ -1,3 +1,4 @@
+#define _GNU_SOURCE
#include <grp.h>
#include <string.h>
#include <limits.h>
diff --git a/src/misc/getrusage.c b/src/misc/getrusage.c
index a5cbd75..0aaf0ac 100644
--- a/src/misc/getrusage.c
+++ b/src/misc/getrusage.c
@@ -1,5 +1,4 @@
#include <sys/resource.h>
-#include <string.h>
#include "syscall.h"
int getrusage(int who, struct rusage *ru)
diff --git a/src/misc/initgroups.c b/src/misc/initgroups.c
index 545d185..922a958 100644
--- a/src/misc/initgroups.c
+++ b/src/misc/initgroups.c
@@ -1,11 +1,7 @@
-#include <sys/types.h>
-#include <unistd.h>
+#define _GNU_SOURCE
#include <grp.h>
#include <limits.h>
-int getgrouplist(const char *, gid_t, gid_t *, int *);
-int setgroups(size_t, const gid_t *);
-
int initgroups(const char *user, gid_t gid)
{
gid_t groups[NGROUPS_MAX];
diff --git a/src/misc/nftw.c b/src/misc/nftw.c
index 63d6aff..b2e84bc 100644
--- a/src/misc/nftw.c
+++ b/src/misc/nftw.c
@@ -2,8 +2,6 @@
#include <dirent.h>
#include <sys/stat.h>
#include <errno.h>
-#include <stdlib.h>
-#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <limits.h>
diff --git a/src/misc/syslog.c b/src/misc/syslog.c
index ba9cc62..1cd61ce 100644
--- a/src/misc/syslog.c
+++ b/src/misc/syslog.c
@@ -1,7 +1,6 @@
#include <stdarg.h>
#include <sys/socket.h>
#include <stdio.h>
-#include <fcntl.h>
#include <unistd.h>
#include <syslog.h>
#include <time.h>
diff --git a/src/misc/uname.c b/src/misc/uname.c
index 46db90d..55ea342 100644
--- a/src/misc/uname.c
+++ b/src/misc/uname.c
@@ -1,5 +1,4 @@
#include <sys/utsname.h>
-#include <string.h>
#include "syscall.h"
int uname(struct utsname *uts)
diff --git a/src/mman/msync.c b/src/mman/msync.c
index eaf35d3..bb20475 100644
--- a/src/mman/msync.c
+++ b/src/mman/msync.c
@@ -1,4 +1,3 @@
-#include <unistd.h>
#include <sys/mman.h>
#include "syscall.h"
diff --git a/src/mman/munmap.c b/src/mman/munmap.c
index 91aefd4..8488d75 100644
--- a/src/mman/munmap.c
+++ b/src/mman/munmap.c
@@ -1,4 +1,3 @@
-#include <unistd.h>
#include <sys/mman.h>
#include "syscall.h"
#include "libc.h"
diff --git a/src/multibyte/internal.c b/src/multibyte/internal.c
index ab22806..1813b26 100644
--- a/src/multibyte/internal.c
+++ b/src/multibyte/internal.c
@@ -4,8 +4,6 @@
* unnecessary.
*/
-#include <inttypes.h>
-
#include "internal.h"
#define C(x) ( x<2 ? -1 : ( R(0x80,0xc0) | x ) )
diff --git a/src/multibyte/internal.h b/src/multibyte/internal.h
index 25ba240..82f5a07 100644
--- a/src/multibyte/internal.h
+++ b/src/multibyte/internal.h
@@ -6,6 +6,7 @@
#define bittab __fsmu8
+#include <stdint.h>
#include "libc.h"
extern const uint32_t bittab[] ATTR_LIBC_VISIBILITY;
diff --git a/src/multibyte/mblen.c b/src/multibyte/mblen.c
index 26d3564..96b47b1 100644
--- a/src/multibyte/mblen.c
+++ b/src/multibyte/mblen.c
@@ -5,11 +5,6 @@
*/
#include <stdlib.h>
-#include <inttypes.h>
-#include <wchar.h>
-#include <errno.h>
-
-#include "internal.h"
int mblen(const char *s, size_t n)
{
diff --git a/src/multibyte/mbrlen.c b/src/multibyte/mbrlen.c
index c9714ef..3a5a743 100644
--- a/src/multibyte/mbrlen.c
+++ b/src/multibyte/mbrlen.c
@@ -4,12 +4,7 @@
* unnecessary.
*/
-#include <stdlib.h>
-#include <inttypes.h>
#include <wchar.h>
-#include <errno.h>
-
-#include "internal.h"
size_t mbrlen(const char *restrict s, size_t n, mbstate_t *restrict st)
{
diff --git a/src/multibyte/mbrtowc.c b/src/multibyte/mbrtowc.c
index db80366..35e834e 100644
--- a/src/multibyte/mbrtowc.c
+++ b/src/multibyte/mbrtowc.c
@@ -4,11 +4,8 @@
* unnecessary.
*/
-#include <stdlib.h>
-#include <inttypes.h>
#include <wchar.h>
#include <errno.h>
-
#include "internal.h"
size_t mbrtowc(wchar_t *restrict wc, const char *restrict src, size_t n, mbstate_t *restrict st)
diff --git a/src/multibyte/mbsinit.c b/src/multibyte/mbsinit.c
index c0e7e49..e001d84 100644
--- a/src/multibyte/mbsinit.c
+++ b/src/multibyte/mbsinit.c
@@ -4,12 +4,7 @@
* unnecessary.
*/
-#include <stdlib.h>
-#include <inttypes.h>
#include <wchar.h>
-#include <errno.h>
-
-#include "internal.h"
int mbsinit(const mbstate_t *st)
{
diff --git a/src/multibyte/mbsnrtowcs.c b/src/multibyte/mbsnrtowcs.c
index 33457f9..68b9960 100644
--- a/src/multibyte/mbsnrtowcs.c
+++ b/src/multibyte/mbsnrtowcs.c
@@ -4,13 +4,7 @@
* unnecessary.
*/
-#include <stdlib.h>
-#include <inttypes.h>
#include <wchar.h>
-#include <errno.h>
-#include <stdio.h>
-
-#include "internal.h"
size_t mbsnrtowcs(wchar_t *restrict wcs, const char **restrict src, size_t n, size_t wn, mbstate_t *restrict st)
{
diff --git a/src/multibyte/mbsrtowcs.c b/src/multibyte/mbsrtowcs.c
index 066cce6..3c1343a 100644
--- a/src/multibyte/mbsrtowcs.c
+++ b/src/multibyte/mbsrtowcs.c
@@ -4,11 +4,9 @@
* unnecessary.
*/
-#include <stdlib.h>
-#include <inttypes.h>
+#include <stdint.h>
#include <wchar.h>
#include <errno.h>
-
#include "internal.h"
size_t mbsrtowcs(wchar_t *restrict ws, const char **restrict src, size_t wn, mbstate_t *restrict st)
diff --git a/src/multibyte/mbtowc.c b/src/multibyte/mbtowc.c
index ec9e54a..6710637 100644
--- a/src/multibyte/mbtowc.c
+++ b/src/multibyte/mbtowc.c
@@ -4,13 +4,10 @@
* unnecessary.
*/
-#include <stdlib.h>
-#include <inttypes.h>
#include <wchar.h>
#include <errno.h>
-
#include "internal.h"
-#include <stdio.h>
+
int mbtowc(wchar_t *restrict wc, const char *restrict src, size_t n)
{
unsigned c;
diff --git a/src/multibyte/wcrtomb.c b/src/multibyte/wcrtomb.c
index 250649f..59f733d 100644
--- a/src/multibyte/wcrtomb.c
+++ b/src/multibyte/wcrtomb.c
@@ -4,13 +4,9 @@
* unnecessary.
*/
-#include <stdlib.h>
-#include <inttypes.h>
#include <wchar.h>
#include <errno.h>
-#include "internal.h"
-
size_t wcrtomb(char *restrict s, wchar_t wc, mbstate_t *restrict st)
{
if (!s) return 1;
diff --git a/src/multibyte/wcsnrtombs.c b/src/multibyte/wcsnrtombs.c
index a2e308b..7eb05d4 100644
--- a/src/multibyte/wcsnrtombs.c
+++ b/src/multibyte/wcsnrtombs.c
@@ -4,12 +4,7 @@
* unnecessary.
*/
-#include <stdlib.h>
-#include <inttypes.h>
#include <wchar.h>
-#include <errno.h>
-
-#include "internal.h"
size_t wcsnrtombs(char *restrict dst, const wchar_t **restrict wcs, size_t wn, size_t n, mbstate_t *restrict st)
{
diff --git a/src/multibyte/wcsrtombs.c b/src/multibyte/wcsrtombs.c
index d48a65e..5cf8f3e 100644
--- a/src/multibyte/wcsrtombs.c
+++ b/src/multibyte/wcsrtombs.c
@@ -4,12 +4,7 @@
* unnecessary.
*/
-#include <stdlib.h>
-#include <inttypes.h>
#include <wchar.h>
-#include <errno.h>
-
-#include "internal.h"
size_t wcsrtombs(char *restrict s, const wchar_t **restrict ws, size_t n, mbstate_t *restrict st)
{
diff --git a/src/multibyte/wctomb.c b/src/multibyte/wctomb.c
index 6910ef3..de7ed84 100644
--- a/src/multibyte/wctomb.c
+++ b/src/multibyte/wctomb.c
@@ -5,11 +5,7 @@
*/
#include <stdlib.h>
-#include <inttypes.h>
#include <wchar.h>
-#include <errno.h>
-
-#include "internal.h"
int wctomb(char *s, wchar_t wc)
{
diff --git a/src/network/__ipparse.c b/src/network/__ipparse.c
index 2480265..79f3b8c 100644
--- a/src/network/__ipparse.c
+++ b/src/network/__ipparse.c
@@ -1,4 +1,3 @@
-#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <sys/socket.h>
diff --git a/src/network/gethostbyaddr.c b/src/network/gethostbyaddr.c
index c9b6388..598e224 100644
--- a/src/network/gethostbyaddr.c
+++ b/src/network/gethostbyaddr.c
@@ -1,8 +1,6 @@
#define _GNU_SOURCE
#include <netdb.h>
-#include <string.h>
-#include <netinet/in.h>
#include <errno.h>
#include <stdlib.h>
diff --git a/src/network/gethostbyname2.c b/src/network/gethostbyname2.c
index c9f90da..dc9d662 100644
--- a/src/network/gethostbyname2.c
+++ b/src/network/gethostbyname2.c
@@ -2,8 +2,6 @@
#include <sys/socket.h>
#include <netdb.h>
-#include <string.h>
-#include <netinet/in.h>
#include <errno.h>
#include <stdlib.h>
diff --git a/src/network/gethostbyname2_r.c b/src/network/gethostbyname2_r.c
index 0dc6dc0..27eb080 100644
--- a/src/network/gethostbyname2_r.c
+++ b/src/network/gethostbyname2_r.c
@@ -5,7 +5,7 @@
#include <string.h>
#include <netinet/in.h>
#include <errno.h>
-#include <inttypes.h>
+#include <stdint.h>
int gethostbyname2_r(const char *name, int af,
struct hostent *h, char *buf, size_t buflen,
diff --git a/src/network/getifaddrs.c b/src/network/getifaddrs.c
index fc49929..5a94cc7 100644
--- a/src/network/getifaddrs.c
+++ b/src/network/getifaddrs.c
@@ -11,6 +11,7 @@
#include <arpa/inet.h> /* inet_pton */
#include <unistd.h>
#include <sys/ioctl.h>
+#include <sys/socket.h>
typedef union {
struct sockaddr_in6 v6;
diff --git a/src/network/getnameinfo.c b/src/network/getnameinfo.c
index 3d115c7..33f89a3 100644
--- a/src/network/getnameinfo.c
+++ b/src/network/getnameinfo.c
@@ -1,6 +1,5 @@
#include <netdb.h>
#include <limits.h>
-#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <sys/socket.h>
diff --git a/src/network/if_nameindex.c b/src/network/if_nameindex.c
index ad0a766..53b80b2 100644
--- a/src/network/if_nameindex.c
+++ b/src/network/if_nameindex.c
@@ -6,8 +6,6 @@
#include <errno.h>
#include "syscall.h"
-#include <stdio.h>
-
static void *do_nameindex(int s, size_t n)
{
size_t i, len, k;
diff --git a/src/network/inet_ntop.c b/src/network/inet_ntop.c
index ca33343..14f9f4c 100644
--- a/src/network/inet_ntop.c
+++ b/src/network/inet_ntop.c
@@ -1,7 +1,5 @@
#include <sys/socket.h>
-#include <netinet/in.h>
#include <arpa/inet.h>
-#include <netdb.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
diff --git a/src/network/proto.c b/src/network/proto.c
index 8c25c53..031003a 100644
--- a/src/network/proto.c
+++ b/src/network/proto.c
@@ -1,5 +1,4 @@
#include <netdb.h>
-#include <stdio.h>
#include <string.h>
/* do we really need all these?? */
diff --git a/src/network/recv.c b/src/network/recv.c
index d04a54a..5970048 100644
--- a/src/network/recv.c
+++ b/src/network/recv.c
@@ -1,6 +1,4 @@
#include <sys/socket.h>
-#include "syscall.h"
-#include "libc.h"
ssize_t recv(int fd, void *buf, size_t len, int flags)
{
diff --git a/src/network/res_query.c b/src/network/res_query.c
index c3ad109..3847da3 100644
--- a/src/network/res_query.c
+++ b/src/network/res_query.c
@@ -1,4 +1,5 @@
#define _GNU_SOURCE
+#include <resolv.h>
#include <netdb.h>
#include "__dns.h"
#include "libc.h"
diff --git a/src/network/send.c b/src/network/send.c
index b6ec310..9f10497 100644
--- a/src/network/send.c
+++ b/src/network/send.c
@@ -1,6 +1,4 @@
#include <sys/socket.h>
-#include "syscall.h"
-#include "libc.h"
ssize_t send(int fd, const void *buf, size_t len, int flags)
{
diff --git a/src/network/serv.c b/src/network/serv.c
index 5ade6ad..41424e8 100644
--- a/src/network/serv.c
+++ b/src/network/serv.c
@@ -1,6 +1,4 @@
#include <netdb.h>
-#include <stdio.h>
-#include <string.h>
void endservent(void)
{
diff --git a/src/passwd/fgetgrent.c b/src/passwd/fgetgrent.c
index 2f18d92..d8d1c77 100644
--- a/src/passwd/fgetgrent.c
+++ b/src/passwd/fgetgrent.c
@@ -1,3 +1,4 @@
+#define _GNU_SOURCE
#include "pwf.h"
struct group *fgetgrent(FILE *f)
diff --git a/src/passwd/fgetpwent.c b/src/passwd/fgetpwent.c
index e95fdb2..eb47b2a 100644
--- a/src/passwd/fgetpwent.c
+++ b/src/passwd/fgetpwent.c
@@ -1,3 +1,4 @@
+#define _GNU_SOURCE
#include "pwf.h"
struct passwd *fgetpwent(FILE *f)
diff --git a/src/passwd/putgrent.c b/src/passwd/putgrent.c
index 6f26c05..a0b320f 100644
--- a/src/passwd/putgrent.c
+++ b/src/passwd/putgrent.c
@@ -1,3 +1,4 @@
+#define _GNU_SOURCE
#include <grp.h>
#include <stdio.h>
diff --git a/src/passwd/putpwent.c b/src/passwd/putpwent.c
index 80fbf38..3a02e57 100644
--- a/src/passwd/putpwent.c
+++ b/src/passwd/putpwent.c
@@ -1,3 +1,4 @@
+#define _GNU_SOURCE
#include <pwd.h>
#include <stdio.h>
diff --git a/src/prng/__rand48_step.c b/src/prng/__rand48_step.c
index 105f810..ccaffc3 100644
--- a/src/prng/__rand48_step.c
+++ b/src/prng/__rand48_step.c
@@ -1,4 +1,3 @@
-#include <stdlib.h>
#include <stdint.h>
uint64_t __rand48_step(unsigned short *xi, unsigned short *lc)
diff --git a/src/process/fexecve.c b/src/process/fexecve.c
index 8ab02a7..6507b42 100644
--- a/src/process/fexecve.c
+++ b/src/process/fexecve.c
@@ -1,5 +1,4 @@
#include <unistd.h>
-#include <stdio.h>
#include <errno.h>
void __procfdname(char *, unsigned);
diff --git a/src/process/system.c b/src/process/system.c
index f5b7b49..8cbdda0 100644
--- a/src/process/system.c
+++ b/src/process/system.c
@@ -1,5 +1,5 @@
#include <unistd.h>
-#include <fcntl.h>
+#include <stdlib.h>
#include <signal.h>
#include <sys/wait.h>
#include <spawn.h>
diff --git a/src/process/vfork.c b/src/process/vfork.c
index 16d07ea..fc4adb4 100644
--- a/src/process/vfork.c
+++ b/src/process/vfork.c
@@ -1,3 +1,4 @@
+#define _GNU_SOURCE
#include <unistd.h>
#include "syscall.h"
#include "libc.h"
diff --git a/src/regex/glob.c b/src/regex/glob.c
index 6c07e6b..6affee0 100644
--- a/src/regex/glob.c
+++ b/src/regex/glob.c
@@ -7,8 +7,6 @@
#include <stdlib.h>
#include <errno.h>
#include <stddef.h>
-#include <unistd.h>
-#include <stdio.h>
#include "libc.h"
struct match
diff --git a/src/regex/regcomp.c b/src/regex/regcomp.c
index 1633754..d907627 100644
--- a/src/regex/regcomp.c
+++ b/src/regex/regcomp.c
@@ -30,7 +30,6 @@
*/
#include <string.h>
-#include <errno.h>
#include <stdlib.h>
#include <regex.h>
#include <limits.h>
diff --git a/src/signal/raise.c b/src/signal/raise.c
index 6fa43be..35063c5 100644
--- a/src/signal/raise.c
+++ b/src/signal/raise.c
@@ -1,5 +1,4 @@
#include <signal.h>
-#include <errno.h>
#include <stdint.h>
#include "syscall.h"
#include "pthread_impl.h"
diff --git a/src/signal/sigaction.c b/src/signal/sigaction.c
index 5499bd1..f7ff4a6 100644
--- a/src/signal/sigaction.c
+++ b/src/signal/sigaction.c
@@ -1,4 +1,3 @@
-#include <stdlib.h>
#include <signal.h>
#include <errno.h>
#include <string.h>
diff --git a/src/signal/sigfillset.c b/src/signal/sigfillset.c
index 4d0a807..16e7b4f 100644
--- a/src/signal/sigfillset.c
+++ b/src/signal/sigfillset.c
@@ -1,5 +1,4 @@
#include <signal.h>
-#include <string.h>
#include <limits.h>
int sigfillset(sigset_t *set)
diff --git a/src/signal/sighold.c b/src/signal/sighold.c
index 5b0f6b1..992812f 100644
--- a/src/signal/sighold.c
+++ b/src/signal/sighold.c
@@ -1,5 +1,5 @@
#include <signal.h>
-#include <stdlib.h>
+#include <stddef.h>
int sighold(int sig)
{
diff --git a/src/signal/sigignore.c b/src/signal/sigignore.c
index 98dff61..78bd747 100644
--- a/src/signal/sigignore.c
+++ b/src/signal/sigignore.c
@@ -1,5 +1,5 @@
#include <signal.h>
-#include <stdlib.h>
+#include <stddef.h>
int sigignore(int sig)
{
diff --git a/src/signal/siginterrupt.c b/src/signal/siginterrupt.c
index 60b3405..94f92be 100644
--- a/src/signal/siginterrupt.c
+++ b/src/signal/siginterrupt.c
@@ -1,4 +1,4 @@
-#include <stdlib.h>
+#include <stddef.h>
#include <signal.h>
int siginterrupt(int sig, int flag)
diff --git a/src/signal/sigismember.c b/src/signal/sigismember.c
index dd1a8db..ab87d62 100644
--- a/src/signal/sigismember.c
+++ b/src/signal/sigismember.c
@@ -1,5 +1,4 @@
#include <signal.h>
-#include <errno.h>
int sigismember(const sigset_t *set, int sig)
{
diff --git a/src/signal/siglongjmp.c b/src/signal/siglongjmp.c
index 2974ff7..b644ceb 100644
--- a/src/signal/siglongjmp.c
+++ b/src/signal/siglongjmp.c
@@ -1,6 +1,5 @@
#include <setjmp.h>
#include <signal.h>
-#include <stdlib.h>
#include "syscall.h"
#include "pthread_impl.h"
diff --git a/src/signal/signal.c b/src/signal/signal.c
index 9d2f23a..c0f063e 100644
--- a/src/signal/signal.c
+++ b/src/signal/signal.c
@@ -1,5 +1,4 @@
#include <signal.h>
-#include <stddef.h>
#include "syscall.h"
#include "libc.h"
diff --git a/src/signal/sigpause.c b/src/signal/sigpause.c
index 6c0f05d..363d2fe 100644
--- a/src/signal/sigpause.c
+++ b/src/signal/sigpause.c
@@ -1,5 +1,4 @@
#include <signal.h>
-#include <stdlib.h>
int sigpause(int sig)
{
diff --git a/src/signal/sigqueue.c b/src/signal/sigqueue.c
index eb4d184..b75f0c5 100644
--- a/src/signal/sigqueue.c
+++ b/src/signal/sigqueue.c
@@ -1,7 +1,6 @@
#include <signal.h>
#include <string.h>
#include <unistd.h>
-#include <stdint.h>
#include "syscall.h"
#include "pthread_impl.h"
diff --git a/src/signal/sigrelse.c b/src/signal/sigrelse.c
index b0b3024..31c1a03 100644
--- a/src/signal/sigrelse.c
+++ b/src/signal/sigrelse.c
@@ -1,5 +1,5 @@
#include <signal.h>
-#include <stdlib.h>
+#include <stddef.h>
int sigrelse(int sig)
{
diff --git a/src/signal/sigset.c b/src/signal/sigset.c
index 1b6b38f..cbe4628 100644
--- a/src/signal/sigset.c
+++ b/src/signal/sigset.c
@@ -1,5 +1,5 @@
#include <signal.h>
-#include <stdlib.h>
+#include <stddef.h>
void (*sigset(int sig, void (*handler)(int)))(int)
{
diff --git a/src/signal/sigsetjmp.c b/src/signal/sigsetjmp.c
index 6a5f6f1..cb2257f 100644
--- a/src/signal/sigsetjmp.c
+++ b/src/signal/sigsetjmp.c
@@ -1,6 +1,5 @@
#include <setjmp.h>
#include <signal.h>
-#include <stdlib.h>
/* !!! This function will not work unless the compiler performs
* tail call optimization. Machine-specific asm versions should
diff --git a/src/stat/fchmodat.c b/src/stat/fchmodat.c
index aeb50bc..12e7ff0 100644
--- a/src/stat/fchmodat.c
+++ b/src/stat/fchmodat.c
@@ -1,7 +1,6 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
-#include <stdio.h>
#include "syscall.h"
void __procfdname(char *, unsigned);
diff --git a/src/stat/futimesat.c b/src/stat/futimesat.c
index 0cc1854..dbefc84 100644
--- a/src/stat/futimesat.c
+++ b/src/stat/futimesat.c
@@ -1,3 +1,4 @@
+#define _GNU_SOURCE
#include <sys/time.h>
#include "syscall.h"
diff --git a/src/stat/lchmod.c b/src/stat/lchmod.c
index c35f586..f324ba7 100644
--- a/src/stat/lchmod.c
+++ b/src/stat/lchmod.c
@@ -1,3 +1,4 @@
+#define _GNU_SOURCE
#include <sys/stat.h>
#include <fcntl.h>
diff --git a/src/stdio/fgetln.c b/src/stdio/fgetln.c
index a2e4bd3..afe12b5 100644
--- a/src/stdio/fgetln.c
+++ b/src/stdio/fgetln.c
@@ -1,3 +1,4 @@
+#define _GNU_SOURCE
#include "stdio_impl.h"
#include <string.h>
diff --git a/src/stdio/fwide.c b/src/stdio/fwide.c
index 4848068..fdf8e4b 100644
--- a/src/stdio/fwide.c
+++ b/src/stdio/fwide.c
@@ -1,3 +1,4 @@
+#include <wchar.h>
#include "stdio_impl.h"
#define SH (8*sizeof(int)-1)
diff --git a/src/stdio/swprintf.c b/src/stdio/swprintf.c
index cbf83d2..f75eb11 100644
--- a/src/stdio/swprintf.c
+++ b/src/stdio/swprintf.c
@@ -1,4 +1,3 @@
-#include <stdio.h>
#include <stdarg.h>
#include <wchar.h>
diff --git a/src/stdio/swscanf.c b/src/stdio/swscanf.c
index c798609..d893fba 100644
--- a/src/stdio/swscanf.c
+++ b/src/stdio/swscanf.c
@@ -1,4 +1,3 @@
-#include <stdio.h>
#include <stdarg.h>
#include <wchar.h>
#include "libc.h"
diff --git a/src/stdio/vfscanf.c b/src/stdio/vfscanf.c
index c0e607f..0091a8d 100644
--- a/src/stdio/vfscanf.c
+++ b/src/stdio/vfscanf.c
@@ -5,10 +5,7 @@
#include <wctype.h>
#include <limits.h>
#include <string.h>
-#include <errno.h>
-#include <math.h>
-#include <float.h>
-#include <inttypes.h>
+#include <stdint.h>
#include "stdio_impl.h"
#include "shgetc.h"
diff --git a/src/stdio/vfwscanf.c b/src/stdio/vfwscanf.c
index 75f04d7..f8f4b70 100644
--- a/src/stdio/vfwscanf.c
+++ b/src/stdio/vfwscanf.c
@@ -6,9 +6,6 @@
#include <wctype.h>
#include <limits.h>
#include <string.h>
-#include <errno.h>
-#include <math.h>
-#include <float.h>
#include "stdio_impl.h"
#include "shgetc.h"
diff --git a/src/stdlib/ecvt.c b/src/stdlib/ecvt.c
index 79c3de6..797b664 100644
--- a/src/stdlib/ecvt.c
+++ b/src/stdlib/ecvt.c
@@ -1,3 +1,4 @@
+#define _GNU_SOURCE
#include <stdlib.h>
#include <stdio.h>
diff --git a/src/stdlib/gcvt.c b/src/stdlib/gcvt.c
index 6c075e2..f29bc30 100644
--- a/src/stdlib/gcvt.c
+++ b/src/stdlib/gcvt.c
@@ -1,3 +1,4 @@
+#define _GNU_SOURCE
#include <stdlib.h>
#include <stdio.h>
diff --git a/src/stdlib/wcstod.c b/src/stdlib/wcstod.c
index 83f308d..26fe9af 100644
--- a/src/stdlib/wcstod.c
+++ b/src/stdlib/wcstod.c
@@ -1,6 +1,7 @@
#include "shgetc.h"
#include "floatscan.h"
#include "stdio_impl.h"
+#include <wchar.h>
#include <wctype.h>
/* This read function heavily cheats. It knows:
diff --git a/src/string/bcmp.c b/src/string/bcmp.c
index 5d6a388..87c6007 100644
--- a/src/string/bcmp.c
+++ b/src/string/bcmp.c
@@ -1,3 +1,4 @@
+#define _BSD_SOURCE
#include <string.h>
#include <strings.h>
diff --git a/src/string/bcopy.c b/src/string/bcopy.c
index e76272f..a07129f 100644
--- a/src/string/bcopy.c
+++ b/src/string/bcopy.c
@@ -1,3 +1,4 @@
+#define _BSD_SOURCE
#include <string.h>
#include <strings.h>
diff --git a/src/string/bzero.c b/src/string/bzero.c
index 0f98b4a..ba536b0 100644
--- a/src/string/bzero.c
+++ b/src/string/bzero.c
@@ -1,3 +1,4 @@
+#define _BSD_SOURCE
#include <string.h>
#include <strings.h>
diff --git a/src/string/index.c b/src/string/index.c
index dd61125..252948f 100644
--- a/src/string/index.c
+++ b/src/string/index.c
@@ -1,3 +1,4 @@
+#define _BSD_SOURCE
#include <string.h>
#include <strings.h>
diff --git a/src/string/memccpy.c b/src/string/memccpy.c
index b85009c..7c233d5 100644
--- a/src/string/memccpy.c
+++ b/src/string/memccpy.c
@@ -1,5 +1,4 @@
#include <string.h>
-#include <stdlib.h>
#include <stdint.h>
#include <limits.h>
diff --git a/src/string/memchr.c b/src/string/memchr.c
index a0472f7..4daff7b 100644
--- a/src/string/memchr.c
+++ b/src/string/memchr.c
@@ -1,5 +1,4 @@
#include <string.h>
-#include <stdlib.h>
#include <stdint.h>
#include <limits.h>
diff --git a/src/string/memmem.c b/src/string/memmem.c
index 861fef2..5211d75 100644
--- a/src/string/memmem.c
+++ b/src/string/memmem.c
@@ -1,6 +1,5 @@
#define _GNU_SOURCE
#include <string.h>
-#include <stdlib.h>
#include <stdint.h>
static char *twobyte_memmem(const unsigned char *h, size_t k, const unsigned char *n)
diff --git a/src/string/mempcpy.c b/src/string/mempcpy.c
index c23ca69..a297985 100644
--- a/src/string/mempcpy.c
+++ b/src/string/mempcpy.c
@@ -1,3 +1,4 @@
+#define _GNU_SOURCE
#include <string.h>
void *mempcpy(void *dest, const void *src, size_t n)
diff --git a/src/string/rindex.c b/src/string/rindex.c
index 17df2bf..693c750 100644
--- a/src/string/rindex.c
+++ b/src/string/rindex.c
@@ -1,3 +1,4 @@
+#define _BSD_SOURCE
#include <string.h>
#include <strings.h>
diff --git a/src/string/stpcpy.c b/src/string/stpcpy.c
index feb9eb8..06623c4 100644
--- a/src/string/stpcpy.c
+++ b/src/string/stpcpy.c
@@ -1,5 +1,4 @@
#include <string.h>
-#include <stdlib.h>
#include <stdint.h>
#include <limits.h>
#include "libc.h"
diff --git a/src/string/stpncpy.c b/src/string/stpncpy.c
index 0a2c2a9..1f57a4d 100644
--- a/src/string/stpncpy.c
+++ b/src/string/stpncpy.c
@@ -1,5 +1,4 @@
#include <string.h>
-#include <stdlib.h>
#include <stdint.h>
#include <limits.h>
#include "libc.h"
diff --git a/src/string/strchrnul.c b/src/string/strchrnul.c
index ceae4d4..05700ad 100644
--- a/src/string/strchrnul.c
+++ b/src/string/strchrnul.c
@@ -1,5 +1,4 @@
#include <string.h>
-#include <stdlib.h>
#include <stdint.h>
#include <limits.h>
#include "libc.h"
diff --git a/src/string/strlcpy.c b/src/string/strlcpy.c
index 4d3ff92..193d724 100644
--- a/src/string/strlcpy.c
+++ b/src/string/strlcpy.c
@@ -1,5 +1,5 @@
+#define _BSD_SOURCE
#include <string.h>
-#include <stdlib.h>
#include <stdint.h>
#include <limits.h>
#include "libc.h"
diff --git a/src/string/strlen.c b/src/string/strlen.c
index d6f8631..929ddcb 100644
--- a/src/string/strlen.c
+++ b/src/string/strlen.c
@@ -1,5 +1,4 @@
#include <string.h>
-#include <stdlib.h>
#include <stdint.h>
#include <limits.h>
diff --git a/src/string/strstr.c b/src/string/strstr.c
index 0649174..915c0a2 100644
--- a/src/string/strstr.c
+++ b/src/string/strstr.c
@@ -1,5 +1,4 @@
#include <string.h>
-#include <stdlib.h>
#include <stdint.h>
static char *twobyte_strstr(const unsigned char *h, const unsigned char *n)
diff --git a/src/string/strverscmp.c b/src/string/strverscmp.c
index 94d2e15..6f37cc6 100644
--- a/src/string/strverscmp.c
+++ b/src/string/strverscmp.c
@@ -1,7 +1,6 @@
#define _GNU_SOURCE
#include <ctype.h>
#include <string.h>
-#include <sys/types.h>
int strverscmp(const char *l, const char *r)
{
diff --git a/src/string/wcsstr.c b/src/string/wcsstr.c
index 037d096..3e28e28 100644
--- a/src/string/wcsstr.c
+++ b/src/string/wcsstr.c
@@ -1,7 +1,4 @@
#include <wchar.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdint.h>
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
diff --git a/src/string/wmemchr.c b/src/string/wmemchr.c
index 37d6962..2bc2c27 100644
--- a/src/string/wmemchr.c
+++ b/src/string/wmemchr.c
@@ -1,4 +1,3 @@
-#include <string.h>
#include <wchar.h>
wchar_t *wmemchr(const wchar_t *s, wchar_t c, size_t n)
diff --git a/src/string/wmemcmp.c b/src/string/wmemcmp.c
index 6788a38..2a19326 100644
--- a/src/string/wmemcmp.c
+++ b/src/string/wmemcmp.c
@@ -1,4 +1,3 @@
-#include <string.h>
#include <wchar.h>
int wmemcmp(const wchar_t *l, const wchar_t *r, size_t n)
diff --git a/src/string/wmemcpy.c b/src/string/wmemcpy.c
index 55a8e1d..52e6e6e 100644
--- a/src/string/wmemcpy.c
+++ b/src/string/wmemcpy.c
@@ -1,4 +1,3 @@
-#include <string.h>
#include <wchar.h>
wchar_t *wmemcpy(wchar_t *restrict d, const wchar_t *restrict s, size_t n)
diff --git a/src/string/wmemmove.c b/src/string/wmemmove.c
index cde4fee..e406f3d 100644
--- a/src/string/wmemmove.c
+++ b/src/string/wmemmove.c
@@ -1,4 +1,3 @@
-#include <string.h>
#include <wchar.h>
wchar_t *wmemmove(wchar_t *d, const wchar_t *s, size_t n)
diff --git a/src/string/wmemset.c b/src/string/wmemset.c
index 1a2a861..07a037a 100644
--- a/src/string/wmemset.c
+++ b/src/string/wmemset.c
@@ -1,4 +1,3 @@
-#include <string.h>
#include <wchar.h>
wchar_t *wmemset(wchar_t *d, wchar_t c, size_t n)
diff --git a/src/temp/__randname.c b/src/temp/__randname.c
index 38c99d3..464b83d 100644
--- a/src/temp/__randname.c
+++ b/src/temp/__randname.c
@@ -1,4 +1,3 @@
-#include <string.h>
#include <time.h>
#include <stdint.h>
diff --git a/src/temp/mkdtemp.c b/src/temp/mkdtemp.c
index 195e9cb..6c2c16e 100644
--- a/src/temp/mkdtemp.c
+++ b/src/temp/mkdtemp.c
@@ -1,12 +1,7 @@
#include <string.h>
-#include <stdio.h>
#include <stdlib.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <limits.h>
#include <errno.h>
#include <sys/stat.h>
-#include "libc.h"
char *__randname(char *);
diff --git a/src/temp/mktemp.c b/src/temp/mktemp.c
index 67130e1..4ab0df2 100644
--- a/src/temp/mktemp.c
+++ b/src/temp/mktemp.c
@@ -1,6 +1,6 @@
+#define _GNU_SOURCE
#include <string.h>
-#include <fcntl.h>
-#include <unistd.h>
+#include <stdlib.h>
#include <errno.h>
#include <sys/stat.h>
diff --git a/src/termios/tcgetattr.c b/src/termios/tcgetattr.c
index d9ce786..545a0bf 100644
--- a/src/termios/tcgetattr.c
+++ b/src/termios/tcgetattr.c
@@ -1,6 +1,5 @@
#include <termios.h>
#include <sys/ioctl.h>
-#include <string.h>
int tcgetattr(int fd, struct termios *tio)
{
diff --git a/src/termios/tcsetattr.c b/src/termios/tcsetattr.c
index e9a168f..94df18f 100644
--- a/src/termios/tcsetattr.c
+++ b/src/termios/tcsetattr.c
@@ -1,6 +1,5 @@
#include <termios.h>
#include <sys/ioctl.h>
-#include <string.h>
#include <errno.h>
int tcsetattr(int fd, int act, const struct termios *tio)
diff --git a/src/thread/pthread_attr_init.c b/src/thread/pthread_attr_init.c
index 6693488..969e0a3 100644
--- a/src/thread/pthread_attr_init.c
+++ b/src/thread/pthread_attr_init.c
@@ -1,5 +1,4 @@
#include "pthread_impl.h"
-#include <string.h>
int pthread_attr_init(pthread_attr_t *a)
{
diff --git a/src/thread/pthread_sigmask.c b/src/thread/pthread_sigmask.c
index b274bd0..88c333f 100644
--- a/src/thread/pthread_sigmask.c
+++ b/src/thread/pthread_sigmask.c
@@ -1,6 +1,5 @@
#include <signal.h>
#include <errno.h>
-#include <pthread.h>
#include "syscall.h"
int pthread_sigmask(int how, const sigset_t *restrict set, sigset_t *restrict old)
diff --git a/src/thread/synccall.c b/src/thread/synccall.c
index 4127a41..a21578d 100644
--- a/src/thread/synccall.c
+++ b/src/thread/synccall.c
@@ -1,6 +1,5 @@
#include "pthread_impl.h"
#include <semaphore.h>
-#include <string.h>
static struct chain {
struct chain *next;
diff --git a/src/time/mktime.c b/src/time/mktime.c
index ef1fb42..0ab4780 100644
--- a/src/time/mktime.c
+++ b/src/time/mktime.c
@@ -1,7 +1,5 @@
#include "time_impl.h"
#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
time_t mktime(struct tm *tm)
{
diff --git a/src/time/nanosleep.c b/src/time/nanosleep.c
index c8878b1..a2ff483 100644
--- a/src/time/nanosleep.c
+++ b/src/time/nanosleep.c
@@ -1,4 +1,3 @@
-#include <unistd.h>
#include <time.h>
#include "syscall.h"
#include "libc.h"
diff --git a/src/time/strptime.c b/src/time/strptime.c
index 0f66e6c..d1d141e 100644
--- a/src/time/strptime.c
+++ b/src/time/strptime.c
@@ -1,4 +1,3 @@
-#include <stdio.h>
#include <stdlib.h>
#include <langinfo.h>
#include <time.h>
diff --git a/src/time/time.c b/src/time/time.c
index 2275485..4b95e75 100644
--- a/src/time/time.c
+++ b/src/time/time.c
@@ -1,5 +1,4 @@
#include <time.h>
-#include <sys/time.h>
#include "syscall.h"
int __clock_gettime(clockid_t, struct timespec *);
diff --git a/src/time/wcsftime.c b/src/time/wcsftime.c
index a2804ac..8d2a2eb 100644
--- a/src/time/wcsftime.c
+++ b/src/time/wcsftime.c
@@ -1,6 +1,5 @@
#include <wchar.h>
#include <time.h>
-#include <string.h>
#include <locale.h>
#include "libc.h"
diff --git a/src/unistd/ctermid.c b/src/unistd/ctermid.c
index ffa9b75..7768405 100644
--- a/src/unistd/ctermid.c
+++ b/src/unistd/ctermid.c
@@ -1,6 +1,4 @@
#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <limits.h>
diff --git a/src/unistd/gethostname.c b/src/unistd/gethostname.c
index a406c4e..f984b7d 100644
--- a/src/unistd/gethostname.c
+++ b/src/unistd/gethostname.c
@@ -1,6 +1,5 @@
#include <unistd.h>
#include <sys/utsname.h>
-#include <string.h>
int gethostname(char *name, size_t len)
{
diff --git a/src/unistd/getlogin_r.c b/src/unistd/getlogin_r.c
index 37ce0d4..53866c6 100644
--- a/src/unistd/getlogin_r.c
+++ b/src/unistd/getlogin_r.c
@@ -1,5 +1,4 @@
#include <unistd.h>
-#include <stdlib.h>
#include <string.h>
#include <errno.h>
diff --git a/src/unistd/ttyname_r.c b/src/unistd/ttyname_r.c
index a2ce351..8bac7b2 100644
--- a/src/unistd/ttyname_r.c
+++ b/src/unistd/ttyname_r.c
@@ -1,7 +1,5 @@
#include <unistd.h>
#include <errno.h>
-#include <stdio.h>
-#include <string.h>
void __procfdname(char *, unsigned);
diff --git a/src/unistd/usleep.c b/src/unistd/usleep.c
index ce1c814..6c96652 100644
--- a/src/unistd/usleep.c
+++ b/src/unistd/usleep.c
@@ -1,3 +1,4 @@
+#define _GNU_SOURCE
#include <unistd.h>
#include <time.h>